-
Notifications
You must be signed in to change notification settings - Fork 167
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
Stack overflow when parsing specific query #9
Comments
Also, that statement should be an error since it's not valid. |
@zhm Thanks for reporting, this does indeed look like a bug - I'll investigate. |
Alright, so the issue comes down to the difference between this (old): _outCreateForeignTableStmt(StringInfo str, const CreateForeignTableStmt *node)
{
WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
_outCreateStmtInfo(str, (const CreateStmt *) node);
WRITE_STRING_FIELD(servername);
WRITE_NODE_FIELD(options);
} https://github.com/lfittl/libpg_query/blob/9.4-latest/patches/01_output_nodes_as_json.patch#L4153 and the new, auto-generated one: static void
_outCreateForeignTableStmt(StringInfo str, const CreateForeignTableStmt *node)
{
WRITE_NODE_TYPE("CreateForeignTableStmt");
WRITE_NODE_FIELD(base);
WRITE_STRING_FIELD(servername);
WRITE_NODE_PTR_FIELD(options);
} Note that
I think the issue here is that the contained I'll need to fix this in the generator script and add a test case - I'll see if I can do that tonight. |
Thanks for looking into this! |
I was able to port the CoffeeScript deparser over to the new V2 JSON. The great news is that this is the only bug I found in the conversion. Over 7000 of the statements in the test suite parse with perfect symmetry. Very nice work on the V2 output @lfittl! 👌 |
@zhm Yay, awesome work porting the deparser to the new format! The good thing is, this format is more future-proof (since it closely resembles the in-source structs that Postgres uses), so hopefully you don't have to do this again :) Fixed the stack overflow issue in 122b25f and released as tag |
In the process of attempting to port https://github.com/zhm/pg-query-parser to the newer AST, I encountered an error parsing this statement when running the postgres regression tests:
I also checked the latest ruby parser just to see if it was an issue with the node module and it also fails there.
Note that this isn't a statement I care about, it's just in the Postgres regression folder.
https://github.com/postgres/postgres/blob/master/src/test/regress/sql/foreign_data.sql#L269
The text was updated successfully, but these errors were encountered: