Ability To Increase NAMEDATALEN
Hello, we use libpg_query via pg_query_go. We are interested in increasing the value of NAMEDATALEN from its default value of 64.
Is there a way to increase the value of NAMEDATELEN via libpg_query or pg_query_go? (As far as I can tell, you can’t override NAMEDATALEN e.g. via pg_query_go’s cgo CFLAGS without first modifying the underlying source in libpg_query, but maybe I’m missing something).
What would be the best way to go about adding support for configurable NAMEDATALEN values?
Hello, we use
libpg_queryviapg_query_go. We are interested in increasing the value of NAMEDATALEN from its default value of 64.
Can you share more about the use case where this is helpful?
Since Postgres itself has this limit, we match that in libpg_query.
Is there a way to increase the value of
NAMEDATELENvialibpg_queryorpg_query_go? (As far as I can tell, you can’t overrideNAMEDATALENe.g. via pg_query_go’s cgo CFLAGS without first modifying the underlying source inlibpg_query, but maybe I’m missing something).
Correct, today there isn't a way to do this, though it may be possible to support a define here in the future (not sure if there is a good way to have that be passed down frompg_query_go though).
Can you share more about the use case where this is helpful?
We use pg_query_go / libpg_query to parse SQL statements destined for several different database backends (e.g. postgres, and trino, and clickhouse etc.). Some of those databases support identifiers longer than ~64 characters, so we’d like to be able to increase the limit.
Since Postgres itself has this limit, we match that in libpg_query.
Agreed, I think libpg_query is doing the right thing in propagating Postgres’s default limit, and I don’t want to change the default behavior.
(not sure if there is a good way to have that be passed down from
pg_query_gothough).
My thought was to…
(1) Update the #define NAMEDATALEN in libpg_query with an #IFNDEF via a libpg_query patch/ file…e.g. to generate this final output in src/postgres/include/pg_config_manual.h:
#ifndef NAMEDATALEN
#define NAMEDATALEN 64
#endif
(2) Then, users could build pg_query_go with a modified NAMEDATALEN value using the CGO_CFLAGS env var… e.g. to increase NAMEDATALEN to 128:
CGO_CFLAGS="-DNAMEDATALEN=128" go build ...
Go merges the CGO_CFLAGS env var, with anything you might define in the source: "When building, the CGO_CFLAGS, CGO_CPPFLAGS, CGO_CXXFLAGS, CGO_FFLAGS and CGO_LDFLAGS environment variables are added to the flags derived from these directives.”