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

Commitd38e7c9

Browse files
committed
Fix segfault on DELETE .. USING with joins of partitioned tables
1 parent713c5f9 commitd38e7c9

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

‎expected/pathman_upd_del.out‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ SET enable_seqscan = OFF;
1313
/* Temporary table for JOINs */
1414
CREATE TABLE test.tmp (id INTEGER NOT NULL, value INTEGER NOT NULL);
1515
INSERT INTO test.tmp VALUES (1, 1), (2, 2);
16+
CREATE TABLE test.tmp2 (id INTEGER NOT NULL, value INTEGER NOT NULL);
17+
SELECT pathman.create_range_partitions('test.tmp2', 'id', 1, 1, 10);
18+
create_range_partitions
19+
-------------------------
20+
10
21+
(1 row)
22+
1623
/* Partition table by RANGE */
1724
CREATE TABLE test.range_rel (
1825
idSERIAL PRIMARY KEY,
@@ -258,7 +265,10 @@ WITH q AS (DELETE FROM test.tmp t
258265
RETURNING *)
259266
DELETE FROM test.tmp USING q;
260267
ROLLBACK;
268+
/* Test special rule for CTE; DELETE + USING with partitioned table */
269+
DELETE FROM test.range_rel r USING test.tmp2 t WHERE t.id = r.id;
270+
ERROR: pg_pathman doesn't support DELETE queries with joining of partitioned tables
261271
DROP SCHEMA test CASCADE;
262-
NOTICE: drop cascades to15 other objects
272+
NOTICE: drop cascades to27 other objects
263273
DROP EXTENSION pg_pathman CASCADE;
264274
DROP SCHEMA pathman CASCADE;

‎sql/pathman_upd_del.sql‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ SET enable_seqscan = OFF;
2121
CREATETABLEtest.tmp (idINTEGERNOT NULL, valueINTEGERNOT NULL);
2222
INSERT INTOtest.tmpVALUES (1,1), (2,2);
2323

24+
CREATETABLEtest.tmp2 (idINTEGERNOT NULL, valueINTEGERNOT NULL);
25+
SELECTpathman.create_range_partitions('test.tmp2','id',1,1,10);
26+
2427

2528
/* Partition table by RANGE*/
2629
CREATETABLEtest.range_rel (
@@ -164,7 +167,8 @@ WITH q AS (DELETE FROM test.tmp t
164167
DELETEFROMtest.tmp USING q;
165168
ROLLBACK;
166169

167-
170+
/* Test special rule for CTE; DELETE + USING with partitioned table*/
171+
DELETEFROMtest.range_rel r USINGtest.tmp2 tWHEREt.id=r.id;
168172

169173
DROPSCHEMA test CASCADE;
170174
DROP EXTENSION pg_pathman CASCADE;

‎src/hooks.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,23 @@ pathman_join_pathlist_hook(PlannerInfo *root,
9999
if (innerrel->reloptkind!=RELOPT_BASEREL)
100100
return;
101101

102+
/* check if query DELETE FROM .. USING .. */
103+
if (root->parse->commandType==CMD_DELETE&&jointype==JOIN_INNER)
104+
{
105+
intx=-1;
106+
intcount=0;
107+
108+
while ((x=bms_next_member(joinrel->relids,x)) >=0)
109+
if (get_pathman_relation_info(root->simple_rte_array[x]->relid))
110+
count+=1;
111+
112+
if (count>1)
113+
ereport(ERROR,
114+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
115+
errmsg("pg_pathman doesn't support DELETE queries with "\
116+
"joining of partitioned tables")));
117+
}
118+
102119
/* We shouldn't process tables with active children */
103120
if (inner_rte->inh)
104121
return;

‎src/pg_pathman.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,6 +1916,9 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti,
19161916
childRTE=root->simple_rte_array[childRTindex];
19171917
childrel=root->simple_rel_array[childRTindex];
19181918

1919+
if (!childrel)
1920+
elog(ERROR,"could not make access paths to a relation");
1921+
19191922
#ifPG_VERSION_NUM >=90600
19201923
/*
19211924
* If parallelism is allowable for this query in general and for parent

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp