libpg_query
libpg_query copied to clipboard
Allow alternate definitions of NAMEDATALEN identifier limit
What
This PR surrounds the definition of the NAMEDATALEN constant with an #ifndef.
Why
Increasing NAMEDATALEN allows you to, for example, avoid the truncation normally produced by the postgres parser on this 65 character identifier:
SELECT aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa12345
{
"stmts": [
{
"stmt": {
"SelectStmt": {
"limitOption": "LIMIT_OPTION_DEFAULT",
"op": "SETOP_NONE",
"targetList": [
{
"ResTarget": {
"location": 7,
"val": {
"ColumnRef": {
"fields": [
{
"String": {
- "sval": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa123"
+ "sval": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa12345"
}
}
],
"location": 7
}
}
}
}
]
}
}
}
],
"version": 150001
}
Notes
To generate this PR and validate it, I needed to run make extract_source.
To get make extract_source working, I needed these 3 pre-requisites:
- macOS.
- There is an invocation of
xcruninside ofextract_source.rb. - Non-portable (macOS specific)
sed -i ""invocations peppered throughoutMakefile(example). - I used the most recent version of macOS Sonoma.
- There is an invocation of
- ruby
3.1.2. - gem
ffi-clang 0.8.0gem install ffi-clang --version'0.8.0'- I did not see the
ffi-clangrequirement pinned or documented anywhere, but versions offfi-clangnewer than0.8.0move thevisit_childrenmethod and cause a runtime error inextract_source.rb:
extract_source.rb:260:in `analyze_file': undefined method `visit_children' for an instance of FFI::Clang::Cursor (NoMethodError)
cursor.visit_children do |cursor, parent|
^^^^^^^^^^^^^^^