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

Question about ColumnDef.is_not_null always set to false #251

Open
lelit opened this issue Jun 15, 2024 · 1 comment
Open

Question about ColumnDef.is_not_null always set to false #251

lelit opened this issue Jun 15, 2024 · 1 comment
Labels

Comments

@lelit
Copy link
Contributor

lelit commented Jun 15, 2024

I have been asked (here) about the fact that the is_not_null flag of a ColumnDef is always false.

I tried to determine whether it was a fault of pglast, but inspecting libpg_query sources I suspect that the additional transformation steps that PG applies to the ColumnDef nodes thru transformCreateStmt() were removed with a reason and are probably not useful (or even harmful) in the context of libpg_query (and in transition of pglast).

Am I correct?

@lfittl
Copy link
Member

lfittl commented Jun 24, 2024

@lelit Thanks for forwarding the question!

I believe that is because is_not_null is set by the parse-analysis stage of Postgres (e.g. in transformColumnDefinition), which occurs after the raw parser. libpg_query only covers the raw parser, and not any later stages.

I'd recommend doing analysis on the elements that are set by the raw parser instead, they should generally cover the same information (unless the information is only available in internal Postgres catalog tables, as is the case for some type definitions for example).

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

No branches or pull requests

2 participants