Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1ec8525

Browse files
committed
Merge branch 'rel_future_beta' into rel_future_update_node
2 parents 1adc516 + 9d9a855 commit 1ec8525

File tree

9 files changed

+415
-119
lines changed

9 files changed

+415
-119
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ OBJS = src/init.o src/relation_info.o src/utils.o src/partition_filter.o \
1010
src/compat/pg_compat.o src/compat/relation_tags.o src/compat/rowmarks_fix.o \
1111
src/partition_router.o $(WIN32RES)
1212

13+
ifdef USE_PGXS
1314
override PG_CPPFLAGS += -I$(CURDIR)/src/include
15+
else
16+
override PG_CPPFLAGS += -I$(top_srcdir)/$(subdir)/src/include
17+
endif
1418

1519
EXTENSION = pg_pathman
1620

expected/pathman_upd_del.out

Lines changed: 150 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ CREATE EXTENSION pg_pathman SCHEMA pathman;
1010
CREATE SCHEMA test;
1111
SET enable_indexscan = ON;
1212
SET enable_seqscan = OFF;
13-
/* Temporary table for JOINs */
13+
/* Temporary tables 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
id SERIAL PRIMARY KEY,
@@ -28,6 +35,7 @@ SELECT pathman.create_range_partitions('test.range_rel', 'dt',
2835
12
2936
(1 row)
3037

38+
VACUUM ANALYZE;
3139
/*
3240
* Test UPDATE and DELETE
3341
*/
@@ -104,16 +112,15 @@ ROLLBACK;
104112
EXPLAIN (COSTS OFF)
105113
UPDATE test.range_rel r SET value = t.value
106114
FROM test.tmp t WHERE r.dt = '2010-01-01' AND r.id = t.id;
107-
QUERY PLAN
108-
--------------------------------------------------------------------------------------------
115+
QUERY PLAN
116+
--------------------------------------------------------------------------------------
109117
Update on range_rel_1 r
110-
-> Hash Join
111-
Hash Cond: (t.id = r.id)
118+
-> Nested Loop
119+
Join Filter: (r.id = t.id)
120+
-> Index Scan using range_rel_1_pkey on range_rel_1 r
121+
Filter: (dt = 'Fri Jan 01 00:00:00 2010'::timestamp without time zone)
112122
-> Seq Scan on tmp t
113-
-> Hash
114-
-> Index Scan using range_rel_1_pkey on range_rel_1 r
115-
Filter: (dt = 'Fri Jan 01 00:00:00 2010'::timestamp without time zone)
116-
(7 rows)
123+
(6 rows)
117124

118125
BEGIN;
119126
UPDATE test.range_rel r SET value = t.value
@@ -123,17 +130,16 @@ ROLLBACK;
123130
EXPLAIN (COSTS OFF)
124131
UPDATE test.tmp t SET value = r.value
125132
FROM test.range_rel r WHERE r.dt = '2010-01-01' AND r.id = t.id;
126-
QUERY PLAN
127-
--------------------------------------------------------------------------------------------------
133+
QUERY PLAN
134+
--------------------------------------------------------------------------------------------
128135
Update on tmp t
129-
-> Hash Join
130-
Hash Cond: (t.id = r.id)
136+
-> Nested Loop
131137
-> Seq Scan on tmp t
132-
-> Hash
133-
-> Append
134-
-> Index Scan using range_rel_1_pkey on range_rel_1 r
135-
Filter: (dt = 'Fri Jan 01 00:00:00 2010'::timestamp without time zone)
136-
(8 rows)
138+
-> Append
139+
-> Index Scan using range_rel_1_pkey on range_rel_1 r
140+
Index Cond: (id = t.id)
141+
Filter: (dt = 'Fri Jan 01 00:00:00 2010'::timestamp without time zone)
142+
(7 rows)
137143

138144
BEGIN;
139145
UPDATE test.tmp t SET value = r.value
@@ -143,16 +149,15 @@ ROLLBACK;
143149
EXPLAIN (COSTS OFF)
144150
DELETE FROM test.range_rel r USING test.tmp t
145151
WHERE r.dt = '2010-01-02' AND r.id = t.id;
146-
QUERY PLAN
147-
--------------------------------------------------------------------------------------------
152+
QUERY PLAN
153+
--------------------------------------------------------------------------------------
148154
Delete on range_rel_1 r
149-
-> Hash Join
150-
Hash Cond: (t.id = r.id)
155+
-> Nested Loop
156+
Join Filter: (r.id = t.id)
157+
-> Index Scan using range_rel_1_pkey on range_rel_1 r
158+
Filter: (dt = 'Sat Jan 02 00:00:00 2010'::timestamp without time zone)
151159
-> Seq Scan on tmp t
152-
-> Hash
153-
-> Index Scan using range_rel_1_pkey on range_rel_1 r
154-
Filter: (dt = 'Sat Jan 02 00:00:00 2010'::timestamp without time zone)
155-
(7 rows)
160+
(6 rows)
156161

157162
BEGIN;
158163
DELETE FROM test.range_rel r USING test.tmp t
@@ -162,22 +167,118 @@ ROLLBACK;
162167
EXPLAIN (COSTS OFF)
163168
DELETE FROM test.tmp t USING test.range_rel r
164169
WHERE r.dt = '2010-01-02' AND r.id = t.id;
165-
QUERY PLAN
166-
--------------------------------------------------------------------------------------------------
170+
QUERY PLAN
171+
--------------------------------------------------------------------------------------------
167172
Delete on tmp t
168-
-> Hash Join
169-
Hash Cond: (t.id = r.id)
173+
-> Nested Loop
170174
-> Seq Scan on tmp t
171-
-> Hash
172-
-> Append
173-
-> Index Scan using range_rel_1_pkey on range_rel_1 r
174-
Filter: (dt = 'Sat Jan 02 00:00:00 2010'::timestamp without time zone)
175-
(8 rows)
175+
-> Append
176+
-> Index Scan using range_rel_1_pkey on range_rel_1 r
177+
Index Cond: (id = t.id)
178+
Filter: (dt = 'Sat Jan 02 00:00:00 2010'::timestamp without time zone)
179+
(7 rows)
176180

177181
BEGIN;
178182
DELETE FROM test.tmp t USING test.range_rel r
179183
WHERE r.dt = '2010-01-02' AND r.id = t.id;
180184
ROLLBACK;
185+
/* DELETE + USING, two partitioned tables */
186+
EXPLAIN (COSTS OFF)
187+
DELETE FROM test.range_rel r USING test.tmp2 t
188+
WHERE t.id = r.id;
189+
ERROR: DELETE and UPDATE queries with a join of partitioned tables are not supported
190+
BEGIN;
191+
DELETE FROM test.range_rel r USING test.tmp2 t
192+
WHERE t.id = r.id;
193+
ERROR: DELETE and UPDATE queries with a join of partitioned tables are not supported
194+
ROLLBACK;
195+
/* DELETE + USING, partitioned table + two partitioned tables in subselect */
196+
EXPLAIN (COSTS OFF)
197+
DELETE FROM test.range_rel r
198+
USING (SELECT *
199+
FROM test.tmp2 a1
200+
JOIN test.tmp2 a2
201+
USING(id)) t
202+
WHERE t.id = r.id;
203+
ERROR: DELETE and UPDATE queries with a join of partitioned tables are not supported
204+
BEGIN;
205+
DELETE FROM test.range_rel r
206+
USING (SELECT *
207+
FROM test.tmp2 a1
208+
JOIN test.tmp2 a2
209+
USING(id)) t
210+
WHERE t.id = r.id;
211+
ERROR: DELETE and UPDATE queries with a join of partitioned tables are not supported
212+
ROLLBACK;
213+
/* DELETE + USING, single table + two partitioned tables in subselect */
214+
EXPLAIN (COSTS OFF)
215+
DELETE FROM test.tmp r
216+
USING (SELECT *
217+
FROM test.tmp2 a1
218+
JOIN test.tmp2 a2
219+
USING(id)) t
220+
WHERE t.id = r.id;
221+
QUERY PLAN
222+
------------------------------------------------------
223+
Delete on tmp r
224+
-> Nested Loop
225+
Join Filter: (a1.id = a2.id)
226+
-> Append
227+
-> Seq Scan on tmp2_1 a2
228+
-> Seq Scan on tmp2_2 a2_1
229+
-> Seq Scan on tmp2_3 a2_2
230+
-> Seq Scan on tmp2_4 a2_3
231+
-> Seq Scan on tmp2_5 a2_4
232+
-> Seq Scan on tmp2_6 a2_5
233+
-> Seq Scan on tmp2_7 a2_6
234+
-> Seq Scan on tmp2_8 a2_7
235+
-> Seq Scan on tmp2_9 a2_8
236+
-> Seq Scan on tmp2_10 a2_9
237+
-> Materialize
238+
-> Nested Loop
239+
-> Seq Scan on tmp r
240+
-> Custom Scan (RuntimeAppend)
241+
Prune by: (r.id = a1.id)
242+
-> Seq Scan on tmp2_1 a1
243+
Filter: (r.id = id)
244+
-> Seq Scan on tmp2_2 a1
245+
Filter: (r.id = id)
246+
-> Seq Scan on tmp2_3 a1
247+
Filter: (r.id = id)
248+
-> Seq Scan on tmp2_4 a1
249+
Filter: (r.id = id)
250+
-> Seq Scan on tmp2_5 a1
251+
Filter: (r.id = id)
252+
-> Seq Scan on tmp2_6 a1
253+
Filter: (r.id = id)
254+
-> Seq Scan on tmp2_7 a1
255+
Filter: (r.id = id)
256+
-> Seq Scan on tmp2_8 a1
257+
Filter: (r.id = id)
258+
-> Seq Scan on tmp2_9 a1
259+
Filter: (r.id = id)
260+
-> Seq Scan on tmp2_10 a1
261+
Filter: (r.id = id)
262+
(39 rows)
263+
264+
BEGIN;
265+
DELETE FROM test.tmp r
266+
USING (SELECT *
267+
FROM test.tmp2 a1
268+
JOIN test.tmp2 a2
269+
USING(id)) t
270+
WHERE t.id = r.id;
271+
ROLLBACK;
272+
/* UPDATE + FROM, two partitioned tables */
273+
EXPLAIN (COSTS OFF)
274+
UPDATE test.range_rel r SET value = 1 FROM test.tmp2 t
275+
WHERE t.id = r.id;
276+
ERROR: DELETE and UPDATE queries with a join of partitioned tables are not supported
277+
BEGIN;
278+
UPDATE test.range_rel r SET value = 1 FROM test.tmp2 t
279+
WHERE t.id = r.id;
280+
ERROR: DELETE and UPDATE queries with a join of partitioned tables are not supported
281+
ROLLBACK;
181282
/* Test special rule for CTE; SELECT (PostgreSQL 9.5) */
182283
EXPLAIN (COSTS OFF)
183284
WITH q AS (SELECT * FROM test.range_rel r
@@ -191,10 +292,9 @@ DELETE FROM test.tmp USING q;
191292
-> Seq Scan on range_rel_1 r
192293
Filter: (dt = 'Sat Jan 02 00:00:00 2010'::timestamp without time zone)
193294
-> Nested Loop
295+
-> Seq Scan on tmp
194296
-> CTE Scan on q
195-
-> Materialize
196-
-> Seq Scan on tmp
197-
(9 rows)
297+
(8 rows)
198298

199299
BEGIN;
200300
WITH q AS (SELECT * FROM test.range_rel r
@@ -215,10 +315,9 @@ DELETE FROM test.tmp USING q;
215315
-> Seq Scan on range_rel_1 r
216316
Filter: (dt = 'Sat Jan 02 00:00:00 2010'::timestamp without time zone)
217317
-> Nested Loop
318+
-> Seq Scan on tmp
218319
-> CTE Scan on q
219-
-> Materialize
220-
-> Seq Scan on tmp
221-
(9 rows)
320+
(8 rows)
222321

223322
BEGIN;
224323
WITH q AS (DELETE FROM test.range_rel r
@@ -233,23 +332,21 @@ WITH q AS (DELETE FROM test.tmp t
233332
WHERE r.dt = '2010-01-02' AND r.id = t.id
234333
RETURNING *)
235334
DELETE FROM test.tmp USING q;
236-
QUERY PLAN
237-
----------------------------------------------------------------------------------------------------------
335+
QUERY PLAN
336+
----------------------------------------------------------------------------------------------------
238337
Delete on tmp
239338
CTE q
240339
-> Delete on tmp t
241-
-> Hash Join
242-
Hash Cond: (t.id = r.id)
340+
-> Nested Loop
243341
-> Seq Scan on tmp t
244-
-> Hash
245-
-> Append
246-
-> Index Scan using range_rel_1_pkey on range_rel_1 r
247-
Filter: (dt = 'Sat Jan 02 00:00:00 2010'::timestamp without time zone)
342+
-> Append
343+
-> Index Scan using range_rel_1_pkey on range_rel_1 r
344+
Index Cond: (id = t.id)
345+
Filter: (dt = 'Sat Jan 02 00:00:00 2010'::timestamp without time zone)
248346
-> Nested Loop
347+
-> Seq Scan on tmp
249348
-> CTE Scan on q
250-
-> Materialize
251-
-> Seq Scan on tmp
252-
(14 rows)
349+
(12 rows)
253350

254351
BEGIN;
255352
WITH q AS (DELETE FROM test.tmp t
@@ -259,6 +356,6 @@ WITH q AS (DELETE FROM test.tmp t
259356
DELETE FROM test.tmp USING q;
260357
ROLLBACK;
261358
DROP SCHEMA test CASCADE;
262-
NOTICE: drop cascades to 15 other objects
359+
NOTICE: drop cascades to 27 other objects
263360
DROP EXTENSION pg_pathman CASCADE;
264361
DROP SCHEMA pathman CASCADE;

0 commit comments

Comments
 (0)