pganalyze / libpg_query

C library for accessing the PostgreSQL parser outside of the server environment
BSD 3-Clause "New" or "Revised" License
1.21k stars 182 forks source link

Unpermitted node type #195

Closed emin100 closed 1 year ago

emin100 commented 1 year ago

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"}}]}}]}}}}}]}

emin100 commented 1 year ago

Rebased and checked in CreateFunctionStmt PR: https://github.com/pganalyze/libpg_query/pull/197