Skip to content

Commit 4563cc3

Browse files
committed
Merge branch 'master' into rel_future_beta
2 parents 6c45e16 + 0c4108e commit 4563cc3

15 files changed

+602
-161
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ OBJS = src/init.o src/relation_info.o src/utils.o src/partition_filter.o \
77
src/pl_funcs.o src/pl_range_funcs.o src/pl_hash_funcs.o src/pathman_workers.o \
88
src/hooks.o src/nodes_common.o src/xact_handling.o src/utility_stmt_hooking.o \
99
src/planner_tree_modification.o src/debug_print.o src/partition_creation.o \
10-
src/compat/pg_compat.o src/compat/relation_tags.o src/compat/expand_rte_hook.o \
11-
src/compat/rowmarks_fix.o $(WIN32RES)
10+
src/compat/pg_compat.o src/compat/relation_tags.o src/compat/rowmarks_fix.o \
11+
$(WIN32RES)
1212

1313
override PG_CPPFLAGS += -I$(CURDIR)/src/include
1414

expected/pathman_basic.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ PL/pgSQL function pathman.prepare_for_partitioning(regclass,text,boolean) line 9
1818
SQL statement "SELECT pathman.prepare_for_partitioning(parent_relid,
1919
expression,
2020
partition_data)"
21-
PL/pgSQL function pathman.create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 4 at PERFORM
21+
PL/pgSQL function pathman.create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 3 at PERFORM
2222
\set VERBOSITY terse
2323
ALTER TABLE test.hash_rel ALTER COLUMN value SET NOT NULL;
2424
SELECT pathman.create_hash_partitions('test.hash_rel', 'value', 3, partition_data:=false);

expected/pathman_expressions.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERF
234234
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
235235
expression,
236236
partition_data)"
237-
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 4 at PERFORM
237+
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 3 at PERFORM
238238
/* Try using system attributes */
239239
SELECT create_hash_partitions('test_exprs.hash_rel', 'xmin', 4);
240240
ERROR: failed to analyze partitioning expression "xmin"
@@ -244,7 +244,7 @@ PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERF
244244
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
245245
expression,
246246
partition_data)"
247-
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 4 at PERFORM
247+
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 3 at PERFORM
248248
/* Try using subqueries */
249249
SELECT create_hash_partitions('test_exprs.hash_rel',
250250
'value, (select oid from pg_class limit 1)',
@@ -256,7 +256,7 @@ PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERF
256256
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
257257
expression,
258258
partition_data)"
259-
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 4 at PERFORM
259+
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 3 at PERFORM
260260
/* Try using mutable expression */
261261
SELECT create_hash_partitions('test_exprs.hash_rel', 'random()', 4);
262262
ERROR: failed to analyze partitioning expression "random()"
@@ -266,7 +266,7 @@ PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERF
266266
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
267267
expression,
268268
partition_data)"
269-
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 4 at PERFORM
269+
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 3 at PERFORM
270270
/* Try using broken parentheses */
271271
SELECT create_hash_partitions('test_exprs.hash_rel', 'value * value2))', 4);
272272
ERROR: failed to parse partitioning expression "value * value2))"
@@ -276,7 +276,7 @@ CONTEXT: PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line
276276
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
277277
expression,
278278
partition_data)"
279-
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 4 at PERFORM
279+
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 3 at PERFORM
280280
/* Try using missing columns */
281281
SELECT create_hash_partitions('test_exprs.hash_rel', 'value * value3', 4);
282282
ERROR: failed to analyze partitioning expression "value * value3"
@@ -287,7 +287,7 @@ CONTEXT: PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line
287287
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
288288
expression,
289289
partition_data)"
290-
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 4 at PERFORM
290+
PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 3 at PERFORM
291291
/* Check that 'pathman_hooks_enabled' is true (1 partition in plan) */
292292
EXPLAIN (COSTS OFF) INSERT INTO test_exprs.canary_copy
293293
SELECT * FROM test_exprs.canary WHERE val = 1;

expected/pathman_rowmarks.out

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* -------------------------------------------
3+
* NOTE: This test behaves differenly on 9.5
4+
* -------------------------------------------
5+
*/
16
CREATE EXTENSION pg_pathman;
27
CREATE SCHEMA rowmarks;
38
CREATE TABLE rowmarks.first(id int NOT NULL);
@@ -168,6 +173,156 @@ FOR SHARE;
168173
6
169174
(1 row)
170175

176+
/* Check updates (plan) */
177+
SET enable_hashjoin = f; /* Hash Semi Join on 10 vs Hash Join on 9.6 */
178+
SET enable_mergejoin = f; /* Merge Semi Join on 10 vs Merge Join on 9.6 */
179+
EXPLAIN (COSTS OFF)
180+
UPDATE rowmarks.second SET id = 2
181+
WHERE rowmarks.second.id IN (SELECT id FROM rowmarks.first WHERE id = 1);
182+
QUERY PLAN
183+
---------------------------------------------
184+
Update on second
185+
-> Nested Loop Semi Join
186+
-> Seq Scan on second
187+
Filter: (id = 1)
188+
-> Materialize
189+
-> Append
190+
-> Seq Scan on first_0
191+
Filter: (id = 1)
192+
(8 rows)
193+
194+
EXPLAIN (COSTS OFF)
195+
UPDATE rowmarks.second SET id = 2
196+
WHERE rowmarks.second.id IN (SELECT id FROM rowmarks.first WHERE id < 1);
197+
QUERY PLAN
198+
-----------------------------------------------
199+
Update on second
200+
-> Nested Loop
201+
Join Filter: (second.id = first_0.id)
202+
-> HashAggregate
203+
Group Key: first_0.id
204+
-> Append
205+
-> Seq Scan on first_0
206+
Filter: (id < 1)
207+
-> Seq Scan on first_1
208+
Filter: (id < 1)
209+
-> Seq Scan on first_2
210+
Filter: (id < 1)
211+
-> Seq Scan on first_3
212+
Filter: (id < 1)
213+
-> Seq Scan on first_4
214+
Filter: (id < 1)
215+
-> Materialize
216+
-> Seq Scan on second
217+
(18 rows)
218+
219+
EXPLAIN (COSTS OFF)
220+
UPDATE rowmarks.second SET id = 2
221+
WHERE rowmarks.second.id IN (SELECT id FROM rowmarks.first WHERE id = 1 OR id = 2);
222+
QUERY PLAN
223+
-----------------------------------------------
224+
Update on second
225+
-> Nested Loop Semi Join
226+
Join Filter: (second.id = first_0.id)
227+
-> Seq Scan on second
228+
-> Materialize
229+
-> Append
230+
-> Seq Scan on first_0
231+
Filter: (id = 1)
232+
-> Seq Scan on first_1
233+
Filter: (id = 2)
234+
(10 rows)
235+
236+
EXPLAIN (COSTS OFF)
237+
UPDATE rowmarks.second SET id = 2
238+
WHERE rowmarks.second.id IN (SELECT id FROM rowmarks.first WHERE id = 1)
239+
RETURNING *, tableoid::regclass;
240+
QUERY PLAN
241+
---------------------------------------------
242+
Update on second
243+
-> Nested Loop Semi Join
244+
-> Seq Scan on second
245+
Filter: (id = 1)
246+
-> Materialize
247+
-> Append
248+
-> Seq Scan on first_0
249+
Filter: (id = 1)
250+
(8 rows)
251+
252+
SET enable_hashjoin = t;
253+
SET enable_mergejoin = t;
254+
/* Check updates (execution) */
255+
UPDATE rowmarks.second SET id = 1
256+
WHERE rowmarks.second.id IN (SELECT id FROM rowmarks.first WHERE id = 1 OR id = 2)
257+
RETURNING *, tableoid::regclass;
258+
id | tableoid
259+
----+-----------------
260+
1 | rowmarks.second
261+
1 | rowmarks.second
262+
(2 rows)
263+
264+
/* Check deletes (plan) */
265+
SET enable_hashjoin = f; /* Hash Semi Join on 10 vs Hash Join on 9.6 */
266+
SET enable_mergejoin = f; /* Merge Semi Join on 10 vs Merge Join on 9.6 */
267+
EXPLAIN (COSTS OFF)
268+
DELETE FROM rowmarks.second
269+
WHERE rowmarks.second.id IN (SELECT id FROM rowmarks.first WHERE id = 1);
270+
QUERY PLAN
271+
---------------------------------------------
272+
Delete on second
273+
-> Nested Loop Semi Join
274+
-> Seq Scan on second
275+
Filter: (id = 1)
276+
-> Materialize
277+
-> Append
278+
-> Seq Scan on first_0
279+
Filter: (id = 1)
280+
(8 rows)
281+
282+
EXPLAIN (COSTS OFF)
283+
DELETE FROM rowmarks.second
284+
WHERE rowmarks.second.id IN (SELECT id FROM rowmarks.first WHERE id < 1);
285+
QUERY PLAN
286+
-----------------------------------------------
287+
Delete on second
288+
-> Nested Loop
289+
Join Filter: (second.id = first_0.id)
290+
-> HashAggregate
291+
Group Key: first_0.id
292+
-> Append
293+
-> Seq Scan on first_0
294+
Filter: (id < 1)
295+
-> Seq Scan on first_1
296+
Filter: (id < 1)
297+
-> Seq Scan on first_2
298+
Filter: (id < 1)
299+
-> Seq Scan on first_3
300+
Filter: (id < 1)
301+
-> Seq Scan on first_4
302+
Filter: (id < 1)
303+
-> Materialize
304+
-> Seq Scan on second
305+
(18 rows)
306+
307+
EXPLAIN (COSTS OFF)
308+
DELETE FROM rowmarks.second
309+
WHERE rowmarks.second.id IN (SELECT id FROM rowmarks.first WHERE id = 1 OR id = 2);
310+
QUERY PLAN
311+
-----------------------------------------------
312+
Delete on second
313+
-> Nested Loop Semi Join
314+
Join Filter: (second.id = first_0.id)
315+
-> Seq Scan on second
316+
-> Materialize
317+
-> Append
318+
-> Seq Scan on first_0
319+
Filter: (id = 1)
320+
-> Seq Scan on first_1
321+
Filter: (id = 2)
322+
(10 rows)
323+
324+
SET enable_hashjoin = t;
325+
SET enable_mergejoin = t;
171326
DROP SCHEMA rowmarks CASCADE;
172327
NOTICE: drop cascades to 7 other objects
173328
DETAIL: drop cascades to table rowmarks.first

0 commit comments

Comments
 (0)