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

Unpermitted node type #195

Closed
wants to merge 2 commits into from

Conversation

emin100
Copy link
Contributor

@emin100 emin100 commented Jun 7, 2023

SQL:
CREATE PROCEDURE insert_data(a integer, b integer)
LANGUAGE SQL
BEGIN ATOMIC
INSERT INTO tbl VALUES (a);
INSERT INTO tbl VALUES (b);
END;

ERROR for "CREATE PROCEDURE insert_data(a int, b int) LANGUAGE sql BEGIN ATOMIC INSERT INTO tbl VALUES (a); INSERT INTO tbl VALUES (b); END"
deparse: unpermitted node type in a_expr/b_expr: 231
parsetree: {"version":150001,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"insert_data"}}],"parameters":[{"FunctionParameter":{"name":"a","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":31},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"b","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":38},"mode":"FUNC_PARAM_DEFAULT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"sql"}},"defaction":"DEFELEM_UNSPEC","location":43}}],"sql_body":{"List":{"items":[{"List":{"items":[{"InsertStmt":{"relation":{"relname":"tbl","inh":true,"relpersistence":"p","location":81},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"ColumnRef":{"fields":[{"String":{"sval":"a"}}],"location":93}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}},{"InsertStmt":{"relation":{"relname":"tbl","inh":true,"relpersistence":"p","location":109},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"ColumnRef":{"fields":[{"String":{"sval":"b"}}],"location":121}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}]}}]}}}}}]}

Mehmet Emin Karakaş and others added 2 commits June 7, 2023 11:43
CREATE PROCEDURE insert_data(a integer, b integer)
LANGUAGE SQL
BEGIN ATOMIC
  INSERT INTO tbl VALUES (a);
  INSERT INTO tbl VALUES (b);
END;

ERROR for "CREATE PROCEDURE insert_data(a int, b int) LANGUAGE sql BEGIN ATOMIC INSERT INTO tbl VALUES (a); INSERT INTO tbl VALUES (b); END"
  deparse: unpermitted node type in a_expr/b_expr: 231
  parsetree: {"version":150001,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"insert_data"}}],"parameters":[{"FunctionParameter":{"name":"a","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":31},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"b","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":38},"mode":"FUNC_PARAM_DEFAULT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"sql"}},"defaction":"DEFELEM_UNSPEC","location":43}}],"sql_body":{"List":{"items":[{"List":{"items":[{"InsertStmt":{"relation":{"relname":"tbl","inh":true,"relpersistence":"p","location":81},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"ColumnRef":{"fields":[{"String":{"sval":"a"}}],"location":93}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}},{"InsertStmt":{"relation":{"relname":"tbl","inh":true,"relpersistence":"p","location":109},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"ColumnRef":{"fields":[{"String":{"sval":"b"}}],"location":121}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}]}}]}}}}}]}
Copy link
Member

@lfittl lfittl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate from my comment re: List vs CreateFunctionStmt sql_body, this will also need a rebase on 15-latest after the move of the deparser to a different file (#192).

src/pg_query_deparse.c Show resolved Hide resolved
@emin100
Copy link
Contributor Author

emin100 commented Jun 12, 2023

Rebased and checked in CreateFunctionStmt
PR: #197

@emin100 emin100 closed this Jun 12, 2023
@emin100 emin100 deleted the unpermitted_node_type branch June 12, 2023 17: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.

2 participants