From: | Piotr Gabriel Kosinski <pg(dot)kosinski(at)gmail(dot)com> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Segmentation fault during update inside ExecBRUpdateTriggers |
Date: | 2019-08-15 21:33:20 |
Message-ID: | CAFMLSdP0rd7LqC3j-H6Fh51FYSt5A10DDh-3=W4PPc4LLUQ8YQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hello,
The following code causes a segmentation fault (confirmed in versions
11.4 on Debian Buster, 11.5 on Debian Buster and Arch Linux 64-bit):
CREATE TABLE foo (id SERIAL NOT NULL PRIMARY KEY, bar INTEGER, baz
INTEGER, ud TIMESTAMPTZ, ud2 TIMESTAMPTZ);
CREATE OR REPLACE FUNCTION udu() RETURNS TRIGGER AS $$
BEGIN
NEW.ud := current_timestamp;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION ud2u() RETURNS TRIGGER AS $$
BEGIN
IF row(NEW.bar) IS DISTINCT FROM row(OLD.bar) THEN
NEW.ud2 := current_timestamp;
RETURN NEW;
ELSE
RETURN OLD;
END IF;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER udt
BEFORE UPDATE ON foo
FOR EACH ROW EXECUTE PROCEDURE udu();
CREATE TRIGGER ud2t
BEFORE UPDATE ON foo
FOR EACH ROW EXECUTE PROCEDURE ud2u();
INSERT INTO foo (bar, baz) VALUES (1, 2);
UPDATE foo SET baz = 5 WHERE id = 1;
Backtrace on Debian Buster:
#0 0x000055c9e358b0c0 in ?? ()
#1 0x000055c9e133d144 in ExecBRUpdateTriggers
(estate=estate(at)entry=0x55c9e3583190,
epqstate=epqstate(at)entry=0x55c9e35845c0,
relinfo=relinfo(at)entry=0x55c9e3583420,
tupleid=tupleid(at)entry=0x7fff0e1565da,
fdw_trigtuple=fdw_trigtuple(at)entry=0x0, slot=0x55c9e3589688) at
./build/../src/backend/commands/trigger.c:3065
#2 0x000055c9e138258e in ExecUpdate
(mtstate=mtstate(at)entry=0x55c9e3584500, tupleid=0x7fff0e1565da,
oldtuple=0x0, slot=<optimized out>, planSlot=0x55c9e3584dd0,
epqstate=epqstate(at)entry=0x55c9e35845c0,
estate=0x55c9e3583190, canSetTag=true) at
./build/../src/backend/executor/nodeModifyTable.c:974
#3 0x000055c9e1382f72 in ExecModifyTable (pstate=0x55c9e3584500) at
./build/../src/backend/executor/nodeModifyTable.c:2166
#4 0x000055c9e135df3b in ExecProcNode (node=0x55c9e3584500) at
./build/../src/include/executor/executor.h:247
#5 ExecutePlan (execute_once=<optimized out>, dest=0x55c9e357ede0,
direction=<optimized out>, numberTuples=0, sendTuples=<optimized out>,
operation=CMD_UPDATE, use_parallel_mode=<optimized out>,
planstate=0x55c9e3584500, estate=0x55c9e3583190) at
./build/../src/backend/executor/execMain.c:1723
#6 standard_ExecutorRun (queryDesc=0x55c9e35780c0,
direction=<optimized out>, count=0, execute_once=<optimized out>) at
./build/../src/backend/executor/execMain.c:364
#7 0x000055c9e14b7fc7 in ProcessQuery (plan=<optimized out>,
sourceText=0x55c9e348c180 "UPDATE foo SET baz = 5 WHERE id = 1;",
params=0x0, queryEnv=0x0, dest=0x55c9e357ede0,
completionTag=0x7fff0e156920 "") at ./build/../src/backend/tcop/pquery.c:161
#8 0x000055c9e14b820b in PortalRunMulti
(portal=portal(at)entry=0x55c9e3525c60, isTopLevel=isTopLevel(at)entry=true,
setHoldSnapshot=setHoldSnapshot(at)entry=false,
dest=dest(at)entry=0x55c9e357ede0,
altdest=altdest(at)entry=0x55c9e357ede0,
completionTag=completionTag(at)entry=0x7fff0e156920 "") at
./build/../src/backend/tcop/pquery.c:1286
#9 0x000055c9e14b8e0f in PortalRun
(portal=portal(at)entry=0x55c9e3525c60,
count=count(at)entry=9223372036854775807,
isTopLevel=isTopLevel(at)entry=true, run_once=run_once(at)entry=true,
dest=dest(at)entry=0x55c9e357ede0,
altdest=altdest(at)entry=0x55c9e357ede0, completionTag=0x7fff0e156920
"") at ./build/../src/backend/tcop/pquery.c:799
#10 0x000055c9e14b4cce in exec_simple_query
(query_string=0x55c9e348c180 "UPDATE foo SET baz = 5 WHERE id = 1;")
at ./build/../src/backend/tcop/postgres.c:1145
#11 0x000055c9e14b6527 in PostgresMain (argc=<optimized out>,
argv=argv(at)entry=0x55c9e34ec2c8, dbname=<optimized out>,
username=<optimized out>) at
./build/../src/backend/tcop/postgres.c:4182
#12 0x000055c9e14402d2 in BackendRun (port=0x55c9e34e3a80) at
./build/../src/backend/postmaster/postmaster.c:4358
#13 BackendStartup (port=0x55c9e34e3a80) at
./build/../src/backend/postmaster/postmaster.c:4030
#14 ServerLoop () at ./build/../src/backend/postmaster/postmaster.c:1707
#15 0x000055c9e1441176 in PostmasterMain (argc=5, argv=0x55c9e3486c30)
at ./build/../src/backend/postmaster/postmaster.c:1380
#16 0x000055c9e11bddc9 in main (argc=5, argv=0x55c9e3486c30) at
./build/../src/backend/main/main.c:228
Regards,
Piotr Kosinski
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2019-08-15 22:06:25 | Re: BUG #15960: ON CONFLICT Trying accessing to variables |
Previous Message | Andres Freund | 2019-08-15 19:42:13 | Re: BUG #15960: ON CONFLICT Trying accessing to variables |