Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability To Increase NAMEDATALEN #258

Open
david-h-muller opened this issue Aug 26, 2024 · 2 comments
Open

Ability To Increase NAMEDATALEN #258

david-h-muller opened this issue Aug 26, 2024 · 2 comments

Comments

@david-h-muller
Copy link

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?

@lfittl
Copy link
Member

lfittl commented Aug 29, 2024

Hello, we use libpg_query via pg_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 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).

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).

@david-h-muller
Copy link
Author

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 frompg_query_go though).

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@lfittl @david-h-muller and others