Skip to content

Commit 09397f0

Browse files
committed
Add missing quote_identifier calls for CREATE TRIGGER ... REFERENCING.
Mixed-case names for transition tables weren't dumped correctly. Oversight in commit 8c48375, per bug #15440 from Karl Czajkowski. In passing, I couldn't resist a bit of code beautification. Back-patch to v10 where this was introduced. Discussion: https://postgr.es/m/15440-02d1468e94d63d76@postgresql.org
1 parent 34f9944 commit 09397f0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/backend/utils/adt/ruleutils.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -952,22 +952,24 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
952952
value = fastgetattr(ht_trig, Anum_pg_trigger_tgoldtable,
953953
tgrel->rd_att, &isnull);
954954
if (!isnull)
955-
tgoldtable = NameStr(*((NameData *) DatumGetPointer(value)));
955+
tgoldtable = NameStr(*DatumGetName(value));
956956
else
957957
tgoldtable = NULL;
958958
value = fastgetattr(ht_trig, Anum_pg_trigger_tgnewtable,
959959
tgrel->rd_att, &isnull);
960960
if (!isnull)
961-
tgnewtable = NameStr(*((NameData *) DatumGetPointer(value)));
961+
tgnewtable = NameStr(*DatumGetName(value));
962962
else
963963
tgnewtable = NULL;
964964
if (tgoldtable != NULL || tgnewtable != NULL)
965965
{
966966
appendStringInfoString(&buf, "REFERENCING ");
967967
if (tgoldtable != NULL)
968-
appendStringInfo(&buf, "OLD TABLE AS %s ", tgoldtable);
968+
appendStringInfo(&buf, "OLD TABLE AS %s ",
969+
quote_identifier(tgoldtable));
969970
if (tgnewtable != NULL)
970-
appendStringInfo(&buf, "NEW TABLE AS %s ", tgnewtable);
971+
appendStringInfo(&buf, "NEW TABLE AS %s ",
972+
quote_identifier(tgnewtable));
971973
}
972974

973975
if (TRIGGER_FOR_ROW(trigrec->tgtype))

0 commit comments

Comments
 (0)