Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix deparse ALTER TABLE table_name ENABLE TRIGGER ALL syntax errors
Browse files Browse the repository at this point in the history
This change fixes syntax errors output by parsing/deparsing `ALTER TABLE
table_name ENABLE TRIGGER ALL` statements. Previously the deparsed
statement would be missing the `ALL` keyword.

Looks like the bug was a typo in the deparse logic that caused the `ALL`
keyword to be left off.

This change adds the `ALL` keyword to the output string when `ENABLE
TRIGGER ALL` is used. This change also adds coverage for other forms of
`ALTER TABLE` statments that use `ENABLE`/`DISABLE` `TRIGGER`, but
the other cases look to already be handled correctly.
CDThomas committed Nov 29, 2023

Verified

This commit was signed with the committer’s verified signature.
wasdennnoch Adrian Paschkowski
1 parent d7005f5 commit 144e2d9
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/postgres_deparse.c
Original file line number Diff line number Diff line change
@@ -6330,7 +6330,7 @@ static void deparseAlterTableCmd(StringInfo str, AlterTableCmd *alter_table_cmd,
appendStringInfoString(str, "DISABLE TRIGGER ");
break;
case AT_EnableTrigAll: /* ENABLE TRIGGER ALL */
appendStringInfoString(str, "ENABLE TRIGGER ");
appendStringInfoString(str, "ENABLE TRIGGER ALL ");
break;
case AT_DisableTrigAll: /* DISABLE TRIGGER ALL */
appendStringInfoString(str, "DISABLE TRIGGER ALL ");
6 changes: 6 additions & 0 deletions test/deparse_tests.c
Original file line number Diff line number Diff line change
@@ -400,6 +400,12 @@ const char* tests[] = {
"SELECT 1 FROM tbl LIMIT COALESCE($1, $2)",
"SELECT (false AND true) IS FALSE",
"SELECT a = (true IS FALSE)",
"ALTER TABLE a ENABLE TRIGGER b",
"ALTER TABLE a ENABLE TRIGGER ALL",
"ALTER TABLE a ENABLE TRIGGER USER",
"ALTER TABLE a DISABLE TRIGGER b",
"ALTER TABLE a DISABLE TRIGGER ALL",
"ALTER TABLE a DISABLE TRIGGER USER",
};

size_t testsLength = __LINE__ - 4;

0 comments on commit 144e2d9

Please sign in to comment.