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

Commitc90578a

Browse files
committed
Make initialization of special trigger variables a little more readable.
Correct one mis-setting of freeval (which could at worst leak a few bytesuntil the trigger exits, so it's no big deal).
1 parent87a4f9b commitc90578a

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

‎src/pl/plpgsql/src/pl_exec.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* procedural language
44
*
55
* IDENTIFICATION
6-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.132 2005/02/24 01:11:40 tgl Exp $
6+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.133 2005/03/25 01:45:42 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -497,9 +497,6 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
497497
*/
498498

499499
var= (PLpgSQL_var*) (estate.datums[func->tg_op_varno]);
500-
var->isnull= false;
501-
var->freeval= false;
502-
503500
if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))
504501
var->value=DirectFunctionCall1(textin,CStringGetDatum("INSERT"));
505502
elseif (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
@@ -508,48 +505,50 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
508505
var->value=DirectFunctionCall1(textin,CStringGetDatum("DELETE"));
509506
else
510507
elog(ERROR,"unrecognized trigger action: not INSERT, DELETE, or UPDATE");
511-
512-
var= (PLpgSQL_var*) (estate.datums[func->tg_name_varno]);
513508
var->isnull= false;
514509
var->freeval= true;
510+
511+
var= (PLpgSQL_var*) (estate.datums[func->tg_name_varno]);
515512
var->value=DirectFunctionCall1(namein,
516513
CStringGetDatum(trigdata->tg_trigger->tgname));
517-
518-
var= (PLpgSQL_var*) (estate.datums[func->tg_when_varno]);
519514
var->isnull= false;
520515
var->freeval= true;
516+
517+
var= (PLpgSQL_var*) (estate.datums[func->tg_when_varno]);
521518
if (TRIGGER_FIRED_BEFORE(trigdata->tg_event))
522519
var->value=DirectFunctionCall1(textin,CStringGetDatum("BEFORE"));
523520
elseif (TRIGGER_FIRED_AFTER(trigdata->tg_event))
524521
var->value=DirectFunctionCall1(textin,CStringGetDatum("AFTER"));
525522
else
526523
elog(ERROR,"unrecognized trigger execution time: not BEFORE or AFTER");
527-
528-
var= (PLpgSQL_var*) (estate.datums[func->tg_level_varno]);
529524
var->isnull= false;
530525
var->freeval= true;
526+
527+
var= (PLpgSQL_var*) (estate.datums[func->tg_level_varno]);
531528
if (TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
532529
var->value=DirectFunctionCall1(textin,CStringGetDatum("ROW"));
533530
elseif (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
534531
var->value=DirectFunctionCall1(textin,CStringGetDatum("STATEMENT"));
535532
else
536533
elog(ERROR,"unrecognized trigger event type: not ROW or STATEMENT");
534+
var->isnull= false;
535+
var->freeval= true;
537536

538537
var= (PLpgSQL_var*) (estate.datums[func->tg_relid_varno]);
538+
var->value=ObjectIdGetDatum(trigdata->tg_relation->rd_id);
539539
var->isnull= false;
540540
var->freeval= false;
541-
var->value=ObjectIdGetDatum(trigdata->tg_relation->rd_id);
542541

543542
var= (PLpgSQL_var*) (estate.datums[func->tg_relname_varno]);
544-
var->isnull= false;
545-
var->freeval= true;
546543
var->value=DirectFunctionCall1(namein,
547544
CStringGetDatum(RelationGetRelationName(trigdata->tg_relation)));
545+
var->isnull= false;
546+
var->freeval= true;
548547

549548
var= (PLpgSQL_var*) (estate.datums[func->tg_nargs_varno]);
549+
var->value=Int16GetDatum(trigdata->tg_trigger->tgnargs);
550550
var->isnull= false;
551551
var->freeval= false;
552-
var->value=Int16GetDatum(trigdata->tg_trigger->tgnargs);
553552

554553
/*
555554
* Store the actual call argument values into the special execution
@@ -712,6 +711,9 @@ plpgsql_exec_error_callback(void *arg)
712711

713712
/* ----------
714713
* Support functions for copying local execution variables
714+
*
715+
* NB: this is not a generic copy operation because it assumes that any
716+
* pass-by-ref original values will live as long as the copy is needed.
715717
* ----------
716718
*/
717719
staticPLpgSQL_datum*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp