Skip to content

Commit c9e46e8

Browse files
committed
Merge branch 'rel_future_update_node' into rel_future_beta
2 parents 9e0591f + 65d2f20 commit c9e46e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3199
-1291
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ regression.out
99
*.gcda
1010
*.gcno
1111
*.gcov
12+
*.log
1213
pg_pathman--*.sql
1314
tags
1415
cscope*

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ OBJS = src/init.o src/relation_info.o src/utils.o src/partition_filter.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 \
1010
src/compat/pg_compat.o src/compat/relation_tags.o src/compat/rowmarks_fix.o \
11-
$(WIN32RES)
11+
src/partition_router.o $(WIN32RES)
1212

1313
ifdef USE_PGXS
1414
override PG_CPPFLAGS += -I$(CURDIR)/src/include
@@ -51,11 +51,13 @@ REGRESS = pathman_array_qual \
5151
pathman_rebuild_updates \
5252
pathman_rowmarks \
5353
pathman_runtime_nodes \
54-
pathman_update_trigger \
54+
pathman_subpartitions \
55+
pathman_update_node \
5556
pathman_upd_del \
5657
pathman_utility_stmt \
5758
pathman_views
5859

60+
5961
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
6062

6163
EXTRA_CLEAN = pg_pathman--$(EXTVERSION).sql ./isolation_output

expected/pathman_basic.out

+2-50
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ PL/pgSQL function pathman.prepare_for_partitioning(regclass,text,boolean) line 9
147147
SQL statement "SELECT pathman.prepare_for_partitioning(parent_relid,
148148
expression,
149149
partition_data)"
150-
PL/pgSQL function pathman.create_range_partitions(regclass,text,anyelement,interval,integer,boolean) line 12 at PERFORM
150+
PL/pgSQL function pathman.create_range_partitions(regclass,text,anyelement,interval,integer,boolean) line 13 at PERFORM
151151
\set VERBOSITY terse
152152
ALTER TABLE test.range_rel ALTER COLUMN dt SET NOT NULL;
153153
SELECT pathman.create_range_partitions('test.range_rel', 'dt', '2015-01-01'::DATE, '1 month'::INTERVAL, 2);
@@ -1087,7 +1087,6 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt BETWEEN '2014-11-15' A
10871087
(6 rows)
10881088

10891089
SELECT pathman.detach_range_partition('test.range_rel_archive');
1090-
NOTICE: trigger "range_rel_upd_trig" for relation "test.range_rel_archive" does not exist, skipping
10911090
detach_range_partition
10921091
------------------------
10931092
test.range_rel_archive
@@ -1496,55 +1495,8 @@ SELECT * FROM test."TeSt";
14961495
1 | 1
14971496
(3 rows)
14981497

1499-
SELECT pathman.create_update_triggers('test."TeSt"');
1500-
create_update_triggers
1501-
------------------------
1502-
1503-
(1 row)
1504-
1505-
UPDATE test."TeSt" SET a = 1;
1506-
SELECT * FROM test."TeSt";
1507-
a | b
1508-
---+---
1509-
1 | 3
1510-
1 | 2
1511-
1 | 1
1512-
(3 rows)
1513-
1514-
SELECT * FROM test."TeSt" WHERE a = 1;
1515-
a | b
1516-
---+---
1517-
1 | 3
1518-
1 | 2
1519-
1 | 1
1520-
(3 rows)
1521-
1522-
EXPLAIN (COSTS OFF) SELECT * FROM test."TeSt" WHERE a = 1;
1523-
QUERY PLAN
1524-
----------------------------
1525-
Append
1526-
-> Seq Scan on "TeSt_2"
1527-
Filter: (a = 1)
1528-
(3 rows)
1529-
1530-
SELECT pathman.drop_partitions('test."TeSt"');
1531-
NOTICE: 0 rows copied from test."TeSt_0"
1532-
NOTICE: 0 rows copied from test."TeSt_1"
1533-
NOTICE: 3 rows copied from test."TeSt_2"
1534-
drop_partitions
1535-
-----------------
1536-
3
1537-
(1 row)
1538-
1539-
SELECT * FROM test."TeSt";
1540-
a | b
1541-
---+---
1542-
1 | 3
1543-
1 | 2
1544-
1 | 1
1545-
(3 rows)
1546-
15471498
DROP TABLE test."TeSt" CASCADE;
1499+
NOTICE: drop cascades to 3 other objects
15481500
CREATE TABLE test."RangeRel" (
15491501
id SERIAL PRIMARY KEY,
15501502
dt TIMESTAMP NOT NULL,

expected/pathman_calamity.out

-84
Original file line numberDiff line numberDiff line change
@@ -398,36 +398,6 @@ SELECT build_check_constraint_name(NULL) IS NULL;
398398
t
399399
(1 row)
400400

401-
/* check function build_update_trigger_name() */
402-
SELECT build_update_trigger_name('calamity.part_test'); /* OK */
403-
build_update_trigger_name
404-
---------------------------
405-
part_test_upd_trig
406-
(1 row)
407-
408-
SELECT build_update_trigger_name(0::REGCLASS); /* not ok */
409-
ERROR: relation "0" does not exist
410-
SELECT build_update_trigger_name(NULL) IS NULL;
411-
?column?
412-
----------
413-
t
414-
(1 row)
415-
416-
/* check function build_update_trigger_func_name() */
417-
SELECT build_update_trigger_func_name('calamity.part_test'); /* OK */
418-
build_update_trigger_func_name
419-
----------------------------------
420-
calamity.part_test_upd_trig_func
421-
(1 row)
422-
423-
SELECT build_update_trigger_func_name(0::REGCLASS); /* not ok */
424-
ERROR: relation "0" does not exist
425-
SELECT build_update_trigger_func_name(NULL) IS NULL;
426-
?column?
427-
----------
428-
t
429-
(1 row)
430-
431401
/* check function build_sequence_name() */
432402
SELECT build_sequence_name('calamity.part_test'); /* OK */
433403
build_sequence_name
@@ -512,14 +482,6 @@ WARNING: table "pg_class" is not partitioned
512482

513483
(1 row)
514484

515-
SELECT has_update_trigger(NULL);
516-
has_update_trigger
517-
--------------------
518-
519-
(1 row)
520-
521-
SELECT has_update_trigger(0::REGCLASS); /* not ok */
522-
ERROR: relation "0" does not exist
523485
/* check invoke_on_partition_created_callback() */
524486
CREATE FUNCTION calamity.dummy_cb(arg jsonb) RETURNS void AS $$
525487
begin
@@ -806,52 +768,6 @@ SELECT merge_range_partitions('{calamity.merge_test_a_1,
806768
ERROR: cannot merge partitions
807769
DROP TABLE calamity.merge_test_a,calamity.merge_test_b CASCADE;
808770
NOTICE: drop cascades to 6 other objects
809-
/* check function drop_triggers() */
810-
CREATE TABLE calamity.trig_test_tbl(val INT4 NOT NULL);
811-
SELECT create_hash_partitions('calamity.trig_test_tbl', 'val', 2);
812-
create_hash_partitions
813-
------------------------
814-
2
815-
(1 row)
816-
817-
SELECT create_update_triggers('calamity.trig_test_tbl');
818-
create_update_triggers
819-
------------------------
820-
821-
(1 row)
822-
823-
SELECT count(*) FROM pg_trigger WHERE tgrelid = 'calamity.trig_test_tbl'::REGCLASS;
824-
count
825-
-------
826-
1
827-
(1 row)
828-
829-
SELECT count(*) FROM pg_trigger WHERE tgrelid = 'calamity.trig_test_tbl_1'::REGCLASS;
830-
count
831-
-------
832-
1
833-
(1 row)
834-
835-
SELECT drop_triggers('calamity.trig_test_tbl'); /* OK */
836-
drop_triggers
837-
---------------
838-
839-
(1 row)
840-
841-
SELECT count(*) FROM pg_trigger WHERE tgrelid = 'calamity.trig_test_tbl'::REGCLASS;
842-
count
843-
-------
844-
0
845-
(1 row)
846-
847-
SELECT count(*) FROM pg_trigger WHERE tgrelid = 'calamity.trig_test_tbl_1'::REGCLASS;
848-
count
849-
-------
850-
0
851-
(1 row)
852-
853-
DROP TABLE calamity.trig_test_tbl CASCADE;
854-
NOTICE: drop cascades to 2 other objects
855771
DROP SCHEMA calamity CASCADE;
856772
NOTICE: drop cascades to 15 other objects
857773
DROP EXTENSION pg_pathman;

expected/pathman_expressions.out

+2-46
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERF
371371
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
372372
expression,
373373
partition_data)"
374-
PL/pgSQL function create_range_partitions(regclass,text,anyelement,interval,integer,boolean) line 12 at PERFORM
374+
PL/pgSQL function create_range_partitions(regclass,text,anyelement,interval,integer,boolean) line 13 at PERFORM
375375
/* Try using mutable expression */
376376
SELECT create_range_partitions('test_exprs.range_rel', 'RANDOM()',
377377
'15 years'::INTERVAL, '1 year'::INTERVAL, 10);
@@ -382,7 +382,7 @@ PL/pgSQL function prepare_for_partitioning(regclass,text,boolean) line 9 at PERF
382382
SQL statement "SELECT public.prepare_for_partitioning(parent_relid,
383383
expression,
384384
partition_data)"
385-
PL/pgSQL function create_range_partitions(regclass,text,anyelement,interval,integer,boolean) line 12 at PERFORM
385+
PL/pgSQL function create_range_partitions(regclass,text,anyelement,interval,integer,boolean) line 13 at PERFORM
386386
/* Check that 'pathman_hooks_enabled' is true (1 partition in plan) */
387387
EXPLAIN (COSTS OFF) INSERT INTO test_exprs.canary_copy
388388
SELECT * FROM test_exprs.canary WHERE val = 1;
@@ -425,50 +425,6 @@ EXPLAIN (COSTS OFF) SELECT * FROM test_exprs.range_rel WHERE (AGE(dt, '2000-01-0
425425
Filter: (age(dt, 'Sat Jan 01 00:00:00 2000'::timestamp without time zone) = '@ 18 years'::interval)
426426
(3 rows)
427427

428-
SELECT create_update_triggers('test_exprs.range_rel');
429-
create_update_triggers
430-
------------------------
431-
432-
(1 row)
433-
434-
SELECT COUNT(*) FROM test_exprs.range_rel;
435-
count
436-
-------
437-
65
438-
(1 row)
439-
440-
SELECT COUNT(*) FROM test_exprs.range_rel_1;
441-
count
442-
-------
443-
12
444-
(1 row)
445-
446-
SELECT COUNT(*) FROM test_exprs.range_rel_2;
447-
count
448-
-------
449-
12
450-
(1 row)
451-
452-
UPDATE test_exprs.range_rel SET dt = '2016-12-01' WHERE dt >= '2015-10-10' AND dt <= '2017-10-10';
453-
/* counts in partitions should be changed */
454-
SELECT COUNT(*) FROM test_exprs.range_rel;
455-
count
456-
-------
457-
65
458-
(1 row)
459-
460-
SELECT COUNT(*) FROM test_exprs.range_rel_1;
461-
count
462-
-------
463-
10
464-
(1 row)
465-
466-
SELECT COUNT(*) FROM test_exprs.range_rel_2;
467-
count
468-
-------
469-
24
470-
(1 row)
471-
472428
DROP SCHEMA test_exprs CASCADE;
473429
NOTICE: drop cascades to 24 other objects
474430
DROP EXTENSION pg_pathman;

expected/pathman_inserts.out

+6-6
Original file line numberDiff line numberDiff line change
@@ -872,11 +872,11 @@ RETURNING e * 2, b, tableoid::regclass;
872872
EXPLAIN (VERBOSE, COSTS OFF)
873873
INSERT INTO test_inserts.storage (d, e) SELECT i, i
874874
FROM generate_series(1, 10) i;
875-
QUERY PLAN
876-
-------------------------------------------------------------------------------
875+
QUERY PLAN
876+
-----------------------------------------------------------------------------------
877877
Insert on test_inserts.storage
878878
-> Custom Scan (PartitionFilter)
879-
Output: NULL::integer, storage.b, NULL::integer, storage.d, storage.e
879+
Output: NULL::integer, NULL::integer, NULL::integer, storage.d, storage.e
880880
-> Function Scan on pg_catalog.generate_series i
881881
Output: NULL::integer, NULL::integer, NULL::integer, i.i, i.i
882882
Function Call: generate_series(1, 10)
@@ -889,7 +889,7 @@ FROM generate_series(1, 10) i;
889889
-----------------------------------------------------------------------------------
890890
Insert on test_inserts.storage
891891
-> Custom Scan (PartitionFilter)
892-
Output: NULL::integer, storage.b, NULL::integer, storage.d, storage.e
892+
Output: NULL::integer, storage.b, NULL::integer, NULL::text, NULL::bigint
893893
-> Function Scan on pg_catalog.generate_series i
894894
Output: NULL::integer, i.i, NULL::integer, NULL::text, NULL::bigint
895895
Function Call: generate_series(1, 10)
@@ -943,7 +943,7 @@ FROM test_inserts.storage;
943943
----------------------------------------------------------------------------------------------
944944
Insert on test_inserts.storage
945945
-> Custom Scan (PartitionFilter)
946-
Output: NULL::integer, storage.b, NULL::integer, storage.d, storage.e
946+
Output: NULL::integer, storage.b, NULL::integer, storage.d, NULL::bigint
947947
-> Result
948948
Output: NULL::integer, storage_11.b, NULL::integer, storage_11.d, NULL::bigint
949949
-> Append
@@ -984,7 +984,7 @@ FROM test_inserts.storage;
984984
--------------------------------------------------------------------------------------------
985985
Insert on test_inserts.storage
986986
-> Custom Scan (PartitionFilter)
987-
Output: NULL::integer, storage.b, NULL::integer, storage.d, storage.e
987+
Output: NULL::integer, storage.b, NULL::integer, NULL::text, NULL::bigint
988988
-> Result
989989
Output: NULL::integer, storage_11.b, NULL::integer, NULL::text, NULL::bigint
990990
-> Append

expected/pathman_inserts_1.out

+12-12
Original file line numberDiff line numberDiff line change
@@ -872,11 +872,11 @@ RETURNING e * 2, b, tableoid::regclass;
872872
EXPLAIN (VERBOSE, COSTS OFF)
873873
INSERT INTO test_inserts.storage (d, e) SELECT i, i
874874
FROM generate_series(1, 10) i;
875-
QUERY PLAN
876-
-------------------------------------------------------------------------------
875+
QUERY PLAN
876+
-----------------------------------------------------------------------------------
877877
Insert on test_inserts.storage
878878
-> Custom Scan (PartitionFilter)
879-
Output: NULL::integer, storage.b, NULL::integer, storage.d, storage.e
879+
Output: NULL::integer, NULL::integer, NULL::integer, storage.d, storage.e
880880
-> Function Scan on pg_catalog.generate_series i
881881
Output: NULL::integer, NULL::integer, NULL::integer, i, i
882882
Function Call: generate_series(1, 10)
@@ -885,11 +885,11 @@ FROM generate_series(1, 10) i;
885885
EXPLAIN (VERBOSE, COSTS OFF)
886886
INSERT INTO test_inserts.storage (b) SELECT i
887887
FROM generate_series(1, 10) i;
888-
QUERY PLAN
889-
---------------------------------------------------------------------------------
888+
QUERY PLAN
889+
-----------------------------------------------------------------------------------
890890
Insert on test_inserts.storage
891891
-> Custom Scan (PartitionFilter)
892-
Output: NULL::integer, storage.b, NULL::integer, storage.d, storage.e
892+
Output: NULL::integer, storage.b, NULL::integer, NULL::text, NULL::bigint
893893
-> Function Scan on pg_catalog.generate_series i
894894
Output: NULL::integer, i, NULL::integer, NULL::text, NULL::bigint
895895
Function Call: generate_series(1, 10)
@@ -939,11 +939,11 @@ FROM test_inserts.storage;
939939
EXPLAIN (VERBOSE, COSTS OFF)
940940
INSERT INTO test_inserts.storage (b, d) SELECT b, d
941941
FROM test_inserts.storage;
942-
QUERY PLAN
943-
-------------------------------------------------------------------------------
942+
QUERY PLAN
943+
----------------------------------------------------------------------------------
944944
Insert on test_inserts.storage
945945
-> Custom Scan (PartitionFilter)
946-
Output: NULL::integer, storage.b, NULL::integer, storage.d, storage.e
946+
Output: NULL::integer, storage.b, NULL::integer, storage.d, NULL::bigint
947947
-> Result
948948
Output: NULL::integer, b, NULL::integer, d, NULL::bigint
949949
-> Append
@@ -980,11 +980,11 @@ FROM test_inserts.storage;
980980
EXPLAIN (VERBOSE, COSTS OFF)
981981
INSERT INTO test_inserts.storage (b) SELECT b
982982
FROM test_inserts.storage;
983-
QUERY PLAN
984-
---------------------------------------------------------------------------------
983+
QUERY PLAN
984+
-----------------------------------------------------------------------------------
985985
Insert on test_inserts.storage
986986
-> Custom Scan (PartitionFilter)
987-
Output: NULL::integer, storage.b, NULL::integer, storage.d, storage.e
987+
Output: NULL::integer, storage.b, NULL::integer, NULL::text, NULL::bigint
988988
-> Result
989989
Output: NULL::integer, b, NULL::integer, NULL::text, NULL::bigint
990990
-> Append

0 commit comments

Comments
 (0)