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

Commit76b12e0

Browse files
committed
Revert removal of trigger flag from plperl function hash key.
As noted by Jan Urbanski, this flag is in fact needed to ensure that thefunction's input/result conversion functions are set up as expected.Add a regression test to discourage anyone from making same mistakein future.
1 parent186cbbd commit76b12e0

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

‎src/pl/plperl/expected/plperl_trigger.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,9 @@ SELECT * FROM trigger_test;
266266
4 | immortal
267267
(1 row)
268268

269+
CREATE FUNCTION direct_trigger() RETURNS trigger AS $$
270+
return;
271+
$$ LANGUAGE plperl;
272+
SELECT direct_trigger();
273+
ERROR: trigger functions can only be called as triggers
274+
CONTEXT: compilation of PL/Perl function "direct_trigger"

‎src/pl/plperl/plperl.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ typedef struct plperl_proc_desc
113113

114114
/**********************************************************************
115115
* For speedy lookup, we maintain a hash table mapping from
116-
* function OID + user OID to plperl_proc_desc pointers.
116+
* function OID +trigger flag +user OID to plperl_proc_desc pointers.
117117
* The reason the plperl_proc_desc struct isn't directly part of the hash
118118
* entry is to simplify recovery from errors during compile_plperl_function.
119119
*
@@ -127,6 +127,11 @@ typedef struct plperl_proc_desc
127127
typedefstructplperl_proc_key
128128
{
129129
Oidproc_id;/* Function OID */
130+
/*
131+
* is_trigger is really a bool, but declare as Oid to ensure this struct
132+
* contains no padding
133+
*/
134+
Oidis_trigger;/* is it a trigger function? */
130135
Oiduser_id;/* User calling the function, or 0 */
131136
}plperl_proc_key;
132137

@@ -1955,6 +1960,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
19551960

19561961
/* Try to find function in plperl_proc_hash */
19571962
proc_key.proc_id=fn_oid;
1963+
proc_key.is_trigger=is_trigger;
19581964
proc_key.user_id=GetUserId();
19591965

19601966
proc_ptr=hash_search(plperl_proc_hash,&proc_key,

‎src/pl/plperl/sql/plperl_trigger.sql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,10 @@ FOR EACH ROW EXECUTE PROCEDURE immortal('immortal');
128128

129129
DELETEFROM trigger_test;
130130

131-
132131
SELECT*FROM trigger_test;
132+
133+
CREATEFUNCTIONdirect_trigger() RETURNS triggerAS $$
134+
return;
135+
$$ LANGUAGE plperl;
136+
137+
SELECT direct_trigger();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp