Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit64d15e4

Browse files
committed
Defend against bad trigger definitions in contrib/lo's lo_manage() trigger.
This function formerly crashed if called as a statement-level trigger,or if a column-name argument wasn't given.In passing, add the trigger name to all error messages from the function.(None of them are expected cases, so this shouldn't pose any compatibilityrisk.)Marc Cousin, reviewed by Sawada Masahiko
1 parenta5036ca commit64d15e4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

‎contrib/lo/lo.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ lo_manage(PG_FUNCTION_ARGS)
4040
HeapTupletrigtuple;/* The original value of tuple*/
4141

4242
if (!CALLED_AS_TRIGGER(fcinfo))/* internal error */
43-
elog(ERROR,"not fired by trigger manager");
43+
elog(ERROR,"%s: not fired by trigger manager",
44+
trigdata->tg_trigger->tgname);
45+
46+
if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))/* internal error */
47+
elog(ERROR,"%s: must be fired for row",
48+
trigdata->tg_trigger->tgname);
4449

4550
/*
4651
* Fetch some values from trigdata
@@ -50,6 +55,10 @@ lo_manage(PG_FUNCTION_ARGS)
5055
tupdesc=trigdata->tg_relation->rd_att;
5156
args=trigdata->tg_trigger->tgargs;
5257

58+
if (args==NULL)/* internal error */
59+
elog(ERROR,"%s: no column name provided in the trigger definition",
60+
trigdata->tg_trigger->tgname);
61+
5362
/* tuple to return to Executor */
5463
if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
5564
rettuple=newtuple;
@@ -63,7 +72,8 @@ lo_manage(PG_FUNCTION_ARGS)
6372
attnum=SPI_fnumber(tupdesc,args[0]);
6473

6574
if (attnum <=0)
66-
elog(ERROR,"column \"%s\" does not exist",args[0]);
75+
elog(ERROR,"%s: column \"%s\" does not exist",
76+
trigdata->tg_trigger->tgname,args[0]);
6777

6878
/*
6979
* Handle updates

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp