steps:
1.create table:
CREATE TABLE uctest(f1 int, f2 text);
2.insert data
INSERT INTO uctest VALUES (1, 'one');
INSERT INTO uctest VALUES (2, 'two');
INSERT INTO uctest VALUES (3, 'three');
3.cursor:
BEGIN;
DECLARE c1 CURSOR FOR SELECT * FROM uctest ORDER BY f1;
FETCH 2 FROM c1;
DELETE FROM uctest WHERE CURRENT OF c1;
4.executed results:
server closed
5.core log:
Core was generated by `postgres: shench postgres [local] DELETE '.
Program terminated with signal 11, Segmentation fault.
[New process 23656]
#0 0x000000000056155f in pgxc_node_send_gxid (handle=0xaebed00, gxid=1749) at pgxcnode.c:1228
1228 handle->outBuffer[handle->outEnd++] = 'g';
(gdb) bt
#0 0x000000000056155f in pgxc_node_send_gxid (handle=0xaebed00, gxid=1749) at pgxcnode.c:1228
#1 0x0000000000565b2f in pgxc_node_begin (conn_count=1, connections=0x7fffc73b0ae0, gxid=1749) at execRemote.c:1452
#2 0x0000000000567bb0 in ExecRemoteQuery (node=0xafe5790) at execRemote.c:2976
#3 0x0000000000537bda in ExecProcNode (node=0xafe5790) at execProcnode.c:465
#4 0x0000000000536962 in ExecutePlan (estate=0xafe51e0, planstate=0xafe5790, operation=CMD_DELETE, numberTuples=0,
direction=NoMovementScanDirection, dest=0xaf789b8) at execMain.c:1520
#5 0x000000000053764c in standard_ExecutorRun (queryDesc=0xafba2d0, direction=ForwardScanDirection, count=0) at execMain.c:312
#6 0x00000000005ed411 in ProcessQuery (plan=0xaf78690, sourceText=0xaf77440 "DELETE FROM uctest WHERE CURRENT OF c1;",
params=<value optimized out>, dest=0xaf789b8, completionTag=0x7fffc73b1360 "") at pquery.c:199
#7 0x00000000005ed619 in PortalRunMulti (portal=0xafe31d0, isTopLevel=1 '\001', dest=0xaf789b8, altdest=0xaf789b8,
completionTag=0x7fffc73b1360 "") at pquery.c:1287
#8 0x00000000005eddd5 in PortalRun (portal=0xafe31d0, count=9223372036854775807, isTopLevel=1 '\001', dest=0xaf789b8,
altdest=0xaf789b8, completionTag=0x7fffc73b1360 "") at pquery.c:837
#9 0x00000000005e9181 in exec_simple_query (query_string=0xaf77440 "DELETE FROM uctest WHERE CURRENT OF c1;")
at postgres.c:1053
#10 0x00000000005ea796 in PostgresMain (argc=4, argv=<value optimized out>, username=0xaeba220 "shench") at postgres.c:3766
#11 0x00000000005c07ac in ServerLoop () at postmaster.c:3607
#12 0x00000000005c29fc in PostmasterMain (argc=7, argv=0xaeb76f0) at postmaster.c:1098
#13 0x000000000056d5ce in main (argc=7, argv=<value optimized out>) at main.c:188
6.expected results:
ERROR: cursor "c1" is not a simply updatable scan of table "uctest"
The bug is from pg_regress.
Note that WHERE CURRENT OF is currently only safe for cursors declared with SELECT FOR UPDATE
We observed the crash even with FOR UPDATE. Should look into the problem.
Server crash is fixed by 55433e8be6a7b51568e4d727605b45e911c19f75
The commit only fixes server crash, WHERE CURRENT OF still does not work.
WHERE CURRENT OF is blocked for now, moving this case to 1.1 Dev Q.
Q2
Will be done as a part of WHERE CURRENT OF