pgsql-ast-parser
pgsql-ast-parser copied to clipboard
`CREATE TRIGGER` statements fail to parse
Parsing:
CREATE TRIGGER t1 BEFORE UPDATE ON foo
FOR EACH ROW
WHEN (OLD.bar = False)
EXECUTE PROCEDURE p1();
Fails with:
Error: Syntax error at line 1 col 16:
CREATE TRIGGER t1
^
Unexpected word token: "t1". I did not expect any more input. Here is the state of my parse table:
kw_view → %word ●
kw_recursive → %word ●
kw_global → %word ●
kw_local → %word ●
kw_unlogged → %word ●
kw_index → %word ●
kw_sequence → %word ●
kw_temporary → %word ●
kw_temp → %word ●
kw_function → %word ●
kw_extension → %word ●
kw_type → %word ●
kw_materialized → %word ●
kw_schema → %word ●
at Parser.feed (/src/node_modules/nearley/lib/nearley.js:343:27)
at _parse (/src/node_modules/pgsql-ast-parser/src/parser.ts:110:16)
at doParse (/src/node_modules/pgsql-ast-parser/src/parser.ts:57:27)
at Object.parse (/src/node_modules/pgsql-ast-parser/src/parser.ts:60:11)
Today we face the same problem trying to create a trigger: Parsing: create trigger t1 after insert or update on schema.table_name for each row execute function schema.db_function(); Fails with: Unexpected word token: "t1". I did not expect any more input. Here is the state of my parse table:
kw_view → %word ●
kw_recursive → %word ●
kw_global → %word ●
kw_local → %word ●
kw_unlogged → %word ●
kw_index → %word ●
kw_sequence → %word ●
kw_temporary → %word ●
kw_temp → %word ●
kw_function → %word ●
kw_extension → %word ●
kw_type → %word ●
kw_materialized → %word ●
kw_schema → %word ●
At version 11.0.0 we have already the support for drop trigger: https://github.com/oguimbal/pgsql-ast-parser/issues/105 So please make some effort to not leave this behind.