@@ -936,11 +936,18 @@ SELECT pathman.merge_range_partitions('test.num_range_rel_1', 'test.num_range_re
936936
937937(1 row)
938938
939+ /* Table in next explain should have number from this query */
940+ SELECT currval('test.num_range_rel_seq');
941+ currval
942+ ---------
943+ 6
944+ (1 row)
945+
939946EXPLAIN (COSTS OFF) SELECT * FROM test.num_range_rel WHERE id BETWEEN 100 AND 700;
940947 QUERY PLAN
941948----------------------------------------------------------------
942949 Append
943- -> Index Scan usingnum_range_rel_1_pkey onnum_range_rel_1
950+ -> Index Scan usingnum_range_rel_6_pkey onnum_range_rel_6
944951 Index Cond: ((id >= 100) AND (id <= 700))
945952(3 rows)
946953
@@ -954,33 +961,33 @@ SELECT pathman.merge_range_partitions('test.range_rel_1', 'test.range_rel_' || c
954961SELECT pathman.append_range_partition('test.num_range_rel');
955962 append_range_partition
956963------------------------
957- test.num_range_rel_6
964+ test.num_range_rel_7
958965(1 row)
959966
960967EXPLAIN (COSTS OFF) SELECT * FROM test.num_range_rel WHERE id >= 4000;
961968 QUERY PLAN
962969-----------------------------------
963970 Append
964- -> Seq Scan onnum_range_rel_6
971+ -> Seq Scan onnum_range_rel_7
965972(2 rows)
966973
967974SELECT pathman.prepend_range_partition('test.num_range_rel');
968975 prepend_range_partition
969976-------------------------
970- test.num_range_rel_7
977+ test.num_range_rel_8
971978(1 row)
972979
973980EXPLAIN (COSTS OFF) SELECT * FROM test.num_range_rel WHERE id < 0;
974981 QUERY PLAN
975982-----------------------------------
976983 Append
977- -> Seq Scan onnum_range_rel_7
984+ -> Seq Scan onnum_range_rel_8
978985(2 rows)
979986
980- SELECT pathman.drop_range_partition('test.num_range_rel_7 ');
987+ SELECT pathman.drop_range_partition('test.num_range_rel_8 ');
981988 drop_range_partition
982989----------------------
983- test.num_range_rel_7
990+ test.num_range_rel_8
984991(1 row)
985992
986993SELECT pathman.drop_range_partition_expand_next('test.num_range_rel_4');
@@ -992,13 +999,13 @@ SELECT pathman.drop_range_partition_expand_next('test.num_range_rel_4');
992999SELECT * FROM pathman.pathman_partition_list WHERE parent = 'test.num_range_rel'::regclass;
9931000 parent | partition | parttype | expr | range_min | range_max
9941001--------------------+----------------------+----------+------+-----------+-----------
995- test.num_range_rel | test.num_range_rel_1 | 2 | id | 0 | 1000
1002+ test.num_range_rel | test.num_range_rel_6 | 2 | id | 0 | 1000
9961003 test.num_range_rel | test.num_range_rel_2 | 2 | id | 1000 | 2000
9971004 test.num_range_rel | test.num_range_rel_3 | 2 | id | 2000 | 3000
998- test.num_range_rel | test.num_range_rel_6 | 2 | id | 3000 | 5000
1005+ test.num_range_rel | test.num_range_rel_7 | 2 | id | 3000 | 5000
9991006(4 rows)
10001007
1001- SELECT pathman.drop_range_partition_expand_next('test.num_range_rel_6 ');
1008+ SELECT pathman.drop_range_partition_expand_next('test.num_range_rel_7 ');
10021009 drop_range_partition_expand_next
10031010----------------------------------
10041011
@@ -1007,44 +1014,44 @@ SELECT pathman.drop_range_partition_expand_next('test.num_range_rel_6');
10071014SELECT * FROM pathman.pathman_partition_list WHERE parent = 'test.num_range_rel'::regclass;
10081015 parent | partition | parttype | expr | range_min | range_max
10091016--------------------+----------------------+----------+------+-----------+-----------
1010- test.num_range_rel | test.num_range_rel_1 | 2 | id | 0 | 1000
1017+ test.num_range_rel | test.num_range_rel_6 | 2 | id | 0 | 1000
10111018 test.num_range_rel | test.num_range_rel_2 | 2 | id | 1000 | 2000
10121019 test.num_range_rel | test.num_range_rel_3 | 2 | id | 2000 | 3000
10131020(3 rows)
10141021
10151022SELECT pathman.append_range_partition('test.range_rel');
10161023 append_range_partition
10171024------------------------
1018- test.range_rel_6
1025+ test.range_rel_7
10191026(1 row)
10201027
10211028SELECT pathman.prepend_range_partition('test.range_rel');
10221029 prepend_range_partition
10231030-------------------------
1024- test.range_rel_7
1031+ test.range_rel_8
10251032(1 row)
10261033
10271034EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt BETWEEN '2014-12-15' AND '2015-01-15';
10281035 QUERY PLAN
10291036-------------------------------------------------------------------------------------
10301037 Append
1031- -> Index Scan usingrange_rel_7_dt_idx onrange_rel_7
1038+ -> Index Scan usingrange_rel_8_dt_idx onrange_rel_8
10321039 Index Cond: (dt >= 'Mon Dec 15 00:00:00 2014'::timestamp without time zone)
1033- -> Index Scan usingrange_rel_1_dt_idx onrange_rel_1
1040+ -> Index Scan usingrange_rel_6_dt_idx onrange_rel_6
10341041 Index Cond: (dt <= 'Thu Jan 15 00:00:00 2015'::timestamp without time zone)
10351042(5 rows)
10361043
1037- SELECT pathman.drop_range_partition('test.range_rel_7 ');
1044+ SELECT pathman.drop_range_partition('test.range_rel_8 ');
10381045 drop_range_partition
10391046----------------------
1040- test.range_rel_7
1047+ test.range_rel_8
10411048(1 row)
10421049
10431050EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt BETWEEN '2014-12-15' AND '2015-01-15';
10441051 QUERY PLAN
10451052-------------------------------------------------------------------------------------
10461053 Append
1047- -> Index Scan usingrange_rel_1_dt_idx onrange_rel_1
1054+ -> Index Scan usingrange_rel_6_dt_idx onrange_rel_6
10481055 Index Cond: (dt <= 'Thu Jan 15 00:00:00 2015'::timestamp without time zone)
10491056(3 rows)
10501057
@@ -1053,16 +1060,16 @@ ERROR: specified range [12-01-2014, 01-02-2015) overlaps with existing partitio
10531060SELECT pathman.add_range_partition('test.range_rel', '2014-12-01'::DATE, '2015-01-01'::DATE);
10541061 add_range_partition
10551062---------------------
1056- test.range_rel_8
1063+ test.range_rel_9
10571064(1 row)
10581065
10591066EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt BETWEEN '2014-12-15' AND '2015-01-15';
10601067 QUERY PLAN
10611068-------------------------------------------------------------------------------------
10621069 Append
1063- -> Index Scan usingrange_rel_8_dt_idx onrange_rel_8
1070+ -> Index Scan usingrange_rel_9_dt_idx onrange_rel_9
10641071 Index Cond: (dt >= 'Mon Dec 15 00:00:00 2014'::timestamp without time zone)
1065- -> Index Scan usingrange_rel_1_dt_idx onrange_rel_1
1072+ -> Index Scan usingrange_rel_6_dt_idx onrange_rel_6
10661073 Index Cond: (dt <= 'Thu Jan 15 00:00:00 2015'::timestamp without time zone)
10671074(5 rows)
10681075
@@ -1081,8 +1088,8 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt BETWEEN '2014-11-15' A
10811088 Append
10821089 -> Index Scan using range_rel_archive_dt_idx on range_rel_archive
10831090 Index Cond: (dt >= 'Sat Nov 15 00:00:00 2014'::timestamp without time zone)
1084- -> Seq Scan onrange_rel_8
1085- -> Index Scan usingrange_rel_1_dt_idx onrange_rel_1
1091+ -> Seq Scan onrange_rel_9
1092+ -> Index Scan usingrange_rel_6_dt_idx onrange_rel_6
10861093 Index Cond: (dt <= 'Thu Jan 15 00:00:00 2015'::timestamp without time zone)
10871094(6 rows)
10881095
@@ -1097,8 +1104,8 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt BETWEEN '2014-11-15' A
10971104 QUERY PLAN
10981105-------------------------------------------------------------------------------------
10991106 Append
1100- -> Seq Scan onrange_rel_8
1101- -> Index Scan usingrange_rel_1_dt_idx onrange_rel_1
1107+ -> Seq Scan onrange_rel_9
1108+ -> Index Scan usingrange_rel_6_dt_idx onrange_rel_6
11021109 Index Cond: (dt <= 'Thu Jan 15 00:00:00 2015'::timestamp without time zone)
11031110(4 rows)
11041111
@@ -1143,12 +1150,12 @@ SELECT * FROM pathman.pathman_partition_list WHERE parent = 'test.range_rel'::RE
11431150 parent | partition | parttype | expr | range_min | range_max
11441151----------------+-------------------------------+----------+------+--------------------------+--------------------------
11451152 test.range_rel | test.range_rel_minus_infinity | 2 | dt | | Mon Dec 01 00:00:00 2014
1146- test.range_rel | test.range_rel_8 | 2 | dt | Mon Dec 01 00:00:00 2014 | Thu Jan 01 00:00:00 2015
1147- test.range_rel | test.range_rel_1 | 2 | dt | Thu Jan 01 00:00:00 2015 | Sun Feb 01 00:00:00 2015
1153+ test.range_rel | test.range_rel_9 | 2 | dt | Mon Dec 01 00:00:00 2014 | Thu Jan 01 00:00:00 2015
1154+ test.range_rel | test.range_rel_6 | 2 | dt | Thu Jan 01 00:00:00 2015 | Sun Feb 01 00:00:00 2015
11481155 test.range_rel | test.range_rel_2 | 2 | dt | Sun Feb 01 00:00:00 2015 | Sun Mar 01 00:00:00 2015
11491156 test.range_rel | test.range_rel_3 | 2 | dt | Sun Mar 01 00:00:00 2015 | Wed Apr 01 00:00:00 2015
11501157 test.range_rel | test.range_rel_4 | 2 | dt | Wed Apr 01 00:00:00 2015 | Fri May 01 00:00:00 2015
1151- test.range_rel | test.range_rel_6 | 2 | dt | Fri May 01 00:00:00 2015 | Mon Jun 01 00:00:00 2015
1158+ test.range_rel | test.range_rel_7 | 2 | dt | Fri May 01 00:00:00 2015 | Mon Jun 01 00:00:00 2015
11521159 test.range_rel | test.range_rel_plus_infinity | 2 | dt | Mon Jun 01 00:00:00 2015 |
11531160(8 rows)
11541161
@@ -1159,14 +1166,14 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt < '2015-01-01';
11591166--------------------------------------------
11601167 Append
11611168 -> Seq Scan on range_rel_minus_infinity
1162- -> Seq Scan onrange_rel_8
1169+ -> Seq Scan onrange_rel_9
11631170(3 rows)
11641171
11651172EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt >= '2015-05-01';
11661173 QUERY PLAN
11671174-------------------------------------------
11681175 Append
1169- -> Seq Scan onrange_rel_6
1176+ -> Seq Scan onrange_rel_7
11701177 -> Seq Scan on range_rel_plus_infinity
11711178(3 rows)
11721179
@@ -1328,9 +1335,9 @@ SELECT COUNT(*) FROM ONLY test.hash_rel;
13281335
13291336DROP TABLE test.hash_rel CASCADE;
13301337SELECT pathman.drop_partitions('test.num_range_rel');
1331- NOTICE: 999 rows copied from test.num_range_rel_1
13321338NOTICE: 1000 rows copied from test.num_range_rel_2
13331339NOTICE: 1000 rows copied from test.num_range_rel_3
1340+ NOTICE: 999 rows copied from test.num_range_rel_6
13341341 drop_partitions
13351342-----------------
13361343 3
@@ -1547,7 +1554,7 @@ SELECT pathman.merge_range_partitions('test."RangeRel_1"', 'test."RangeRel_' ||
15471554
15481555(1 row)
15491556
1550- SELECT pathman.split_range_partition('test."RangeRel_1 "', '2015-01-01'::DATE);
1557+ SELECT pathman.split_range_partition('test."RangeRel_6 "', '2015-01-01'::DATE);
15511558 split_range_partition
15521559-------------------------
15531560 {12-31-2014,01-02-2015}
@@ -1617,7 +1624,7 @@ SELECT merge_range_partitions('test.range_rel_1', 'test.range_rel_2');
16171624
16181625(1 row)
16191626
1620- SELECT split_range_partition('test.range_rel_1 ', '2010-02-15'::date);
1627+ SELECT split_range_partition('test.range_rel_13 ', '2010-02-15'::date);
16211628 split_range_partition
16221629-------------------------
16231630 {01-01-2010,03-01-2010}
@@ -1626,22 +1633,22 @@ SELECT split_range_partition('test.range_rel_1', '2010-02-15'::date);
16261633SELECT append_range_partition('test.range_rel');
16271634 append_range_partition
16281635------------------------
1629- test.range_rel_14
1636+ test.range_rel_15
16301637(1 row)
16311638
16321639SELECT prepend_range_partition('test.range_rel');
16331640 prepend_range_partition
16341641-------------------------
1635- test.range_rel_15
1642+ test.range_rel_16
16361643(1 row)
16371644
16381645EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt < '2010-03-01';
16391646 QUERY PLAN
16401647--------------------------------
16411648 Append
1642- -> Seq Scan on range_rel_15
1643- -> Seq Scan on range_rel_1
1649+ -> Seq Scan on range_rel_16
16441650 -> Seq Scan on range_rel_13
1651+ -> Seq Scan on range_rel_14
16451652(4 rows)
16461653
16471654EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt > '2010-12-15';
@@ -1650,7 +1657,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt > '2010-12-15';
16501657 Append
16511658 -> Seq Scan on range_rel_12
16521659 Filter: (dt > 'Wed Dec 15 00:00:00 2010'::timestamp without time zone)
1653- -> Seq Scan onrange_rel_14
1660+ -> Seq Scan onrange_rel_15
16541661(4 rows)
16551662
16561663/* Temporary table for JOINs */
@@ -1689,32 +1696,31 @@ SELECT * FROM test.range_rel WHERE dt = '2010-06-15';
16891696EXPLAIN (COSTS OFF) UPDATE test.range_rel r SET value = t.value FROM test.tmp t WHERE r.dt = '2010-01-01' AND r.id = t.id;
16901697 QUERY PLAN
16911698--------------------------------------------------------------------------------------------
1692- Update onrange_rel_1 r
1699+ Update onrange_rel_13 r
16931700 -> Hash Join
16941701 Hash Cond: (t.id = r.id)
16951702 -> Seq Scan on tmp t
16961703 -> Hash
1697- -> Index Scan usingrange_rel_1_pkey onrange_rel_1 r
1704+ -> Index Scan usingrange_rel_13_pkey onrange_rel_13 r
16981705 Filter: (dt = 'Fri Jan 01 00:00:00 2010'::timestamp without time zone)
16991706(7 rows)
17001707
17011708UPDATE test.range_rel r SET value = t.value FROM test.tmp t WHERE r.dt = '2010-01-01' AND r.id = t.id;
17021709EXPLAIN (COSTS OFF) DELETE FROM test.range_rel r USING test.tmp t WHERE r.dt = '2010-01-02' AND r.id = t.id;
17031710 QUERY PLAN
17041711--------------------------------------------------------------------------------------------
1705- Delete onrange_rel_1 r
1712+ Delete onrange_rel_13 r
17061713 -> Hash Join
17071714 Hash Cond: (t.id = r.id)
17081715 -> Seq Scan on tmp t
17091716 -> Hash
1710- -> Index Scan usingrange_rel_1_pkey onrange_rel_1 r
1717+ -> Index Scan usingrange_rel_13_pkey onrange_rel_13 r
17111718 Filter: (dt = 'Sat Jan 02 00:00:00 2010'::timestamp without time zone)
17121719(7 rows)
17131720
17141721DELETE FROM test.range_rel r USING test.tmp t WHERE r.dt = '2010-01-02' AND r.id = t.id;
17151722/* Create range partitions from whole range */
17161723SELECT drop_partitions('test.range_rel');
1717- NOTICE: 44 rows copied from test.range_rel_1
17181724NOTICE: 31 rows copied from test.range_rel_3
17191725NOTICE: 30 rows copied from test.range_rel_4
17201726NOTICE: 31 rows copied from test.range_rel_5
@@ -1725,9 +1731,10 @@ NOTICE: 30 rows copied from test.range_rel_9
17251731NOTICE: 31 rows copied from test.range_rel_10
17261732NOTICE: 30 rows copied from test.range_rel_11
17271733NOTICE: 31 rows copied from test.range_rel_12
1728- NOTICE:14 rows copied from test.range_rel_13
1729- NOTICE:0 rows copied from test.range_rel_14
1734+ NOTICE:44 rows copied from test.range_rel_13
1735+ NOTICE:14 rows copied from test.range_rel_14
17301736NOTICE: 0 rows copied from test.range_rel_15
1737+ NOTICE: 0 rows copied from test.range_rel_16
17311738 drop_partitions
17321739-----------------
17331740 14