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

Additional PL/pgSQL parsing fixes #263

Open
wants to merge 7 commits into
base: 16-latest
Choose a base branch
from

Conversation

lfittl
Copy link
Member

@lfittl lfittl commented Sep 24, 2024

See individual commit messages. Some of this based on work by @MGorkov in #244 - this PR (mostly) supersedes that PR. Note there were some changes there that modified the parse structs that I didn't carry over, since they are not directly related to parsing errors.

Fixes #160, #248, #260.

… as records

This ensures the PL/pgSQL lexer detects variable references to such
variables as variables, instead of erroring out with
"[var.name] is not a known variable".

The trade-off here is that we might incorrectly detect custom data types
registered outside of pg_catalog as being records, instead of data types.
…references

This makes sure function bodies that contain ALIAS FOR statements to
rename positional references like $1 get parsed correctly, instead of
erroring out with "variable "$1" does not exist".
…param_varno

This ensures functions with statements like "RETURN NEXT;" or "RETURN;"
don't error out.
This requires the data type parsing to correctly set the collation field,
which for now we do when the type is defined as "text".

In passing we also adjust the hardcoded collection in get_collation_oid
to use DEFAULT_COLLATION_OID (100), which seems better than using -1.
@lfittl lfittl requested review from msepga and a team September 24, 2024 07:49
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

Successfully merging this pull request may close these issues.

plpgsql parsing error when defining alias for non-named parameter (e.g. _a alias for $1)
1 participant