@@ -12,8 +12,6 @@ SELECT pathman.create_hash_partitions('test.hash_rel', 'value', 3);
12
12
ERROR: Partitioning key 'value' must be NOT NULL
13
13
ALTER TABLE test.hash_rel ALTER COLUMN value SET NOT NULL;
14
14
SELECT pathman.create_hash_partitions('test.hash_rel', 'Value', 3);
15
- NOTICE: function test.hash_rel_insert_trigger_func() does not exist, skipping
16
- NOTICE: function test.hash_rel_update_trigger_func() does not exist, skipping
17
15
NOTICE: Copying data to partitions...
18
16
create_hash_partitions
19
17
------------------------
@@ -728,12 +726,60 @@ begin
728
726
return 'ok';
729
727
end;
730
728
$$ language plpgsql;
729
+ create or replace function test.pathman_test_5() returns text as $$
730
+ declare
731
+ res record;
732
+ begin
733
+ select
734
+ from test.runtime_test_3
735
+ where id = (select * from test.vals order by val limit 1)
736
+ limit 1
737
+ into res; /* test empty tlist */
738
+
739
+
740
+ select id, generate_series(1, 2) gen, val
741
+ from test.runtime_test_3
742
+ where id = any (select * from test.vals order by val limit 5)
743
+ order by id, gen, val
744
+ offset 1 limit 1
745
+ into res; /* without IndexOnlyScan */
746
+
747
+ perform test.pathman_equal(res.id::text, '1', 'id is incorrect (t2)');
748
+ perform test.pathman_equal(res.gen::text, '2', 'gen is incorrect (t2)');
749
+ perform test.pathman_equal(res.val::text, 'k = 1', 'val is incorrect (t2)');
750
+
751
+
752
+ select id
753
+ from test.runtime_test_3
754
+ where id = any (select * from test.vals order by val limit 5)
755
+ order by id
756
+ offset 3 limit 1
757
+ into res; /* with IndexOnlyScan */
758
+
759
+ perform test.pathman_equal(res.id::text, '4', 'id is incorrect (t3)');
760
+
761
+
762
+ select v.val v1, generate_series(2, 2) gen, t.val v2
763
+ from test.runtime_test_3 t join test.vals v on id = v.val
764
+ order by v1, gen, v2
765
+ limit 1
766
+ into res;
767
+
768
+ perform test.pathman_equal(res.v1::text, '1', 'v1 is incorrect (t4)');
769
+ perform test.pathman_equal(res.gen::text, '2', 'gen is incorrect (t4)');
770
+ perform test.pathman_equal(res.v2::text, 'k = 1', 'v2 is incorrect (t4)');
771
+
772
+ return 'ok';
773
+ end;
774
+ $$ language plpgsql
775
+ set pg_pathman.enable = true
776
+ set enable_hashjoin = off
777
+ set enable_mergejoin = off;
778
+ NOTICE: RuntimeAppend, RuntimeMergeAppend and PartitionFilter nodes have been enabled
731
779
create table test.run_values as select generate_series(1, 10000) val;
732
780
create table test.runtime_test_1(id serial primary key, val real);
733
781
insert into test.runtime_test_1 select generate_series(1, 10000), random();
734
782
select pathman.create_hash_partitions('test.runtime_test_1', 'id', 6);
735
- NOTICE: function test.runtime_test_1_insert_trigger_func() does not exist, skipping
736
- NOTICE: function test.runtime_test_1_update_trigger_func() does not exist, skipping
737
783
NOTICE: Copying data to partitions...
738
784
create_hash_partitions
739
785
------------------------
@@ -745,16 +791,29 @@ create table test.runtime_test_2 (id serial, category_id int not null, name text
745
791
insert into test.runtime_test_2 (select id, (id % 6) + 1 as category_id, 'good' || id::text as name, random() as rating from generate_series(1, 100000) id);
746
792
create index on test.runtime_test_2 (category_id, rating);
747
793
select pathman.create_hash_partitions('test.runtime_test_2', 'category_id', 6);
748
- NOTICE: function test.runtime_test_2_insert_trigger_func() does not exist, skipping
749
- NOTICE: function test.runtime_test_2_update_trigger_func() does not exist, skipping
750
794
NOTICE: Copying data to partitions...
751
795
create_hash_partitions
752
796
------------------------
753
797
6
754
798
(1 row)
755
799
800
+ create table test.vals as (select generate_series(1, 10000) as val);
801
+ create table test.runtime_test_3(val text, id serial not null);
802
+ insert into test.runtime_test_3(id, val) select * from generate_series(1, 10000) k, format('k = %s', k);
803
+ select pathman.create_hash_partitions('test.runtime_test_3', 'id', 4);
804
+ NOTICE: Copying data to partitions...
805
+ create_hash_partitions
806
+ ------------------------
807
+ 4
808
+ (1 row)
809
+
810
+ create index on test.runtime_test_3 (id);
811
+ create index on test.runtime_test_3_0 (id);
756
812
analyze test.run_values;
757
813
analyze test.runtime_test_1;
814
+ analyze test.runtime_test_2;
815
+ analyze test.runtime_test_3;
816
+ analyze test.runtime_test_3_0;
758
817
set enable_mergejoin = off;
759
818
set enable_hashjoin = off;
760
819
set pg_pathman.enable_runtimeappend = on;
@@ -783,12 +842,18 @@ select test.pathman_test_4(); /* RuntimeMergeAppend (lateral) */
783
842
ok
784
843
(1 row)
785
844
845
+ select test.pathman_test_5(); /* projection tests for RuntimeXXX nodes */
846
+ pathman_test_5
847
+ ----------------
848
+ ok
849
+ (1 row)
850
+
786
851
set pg_pathman.enable_runtimeappend = off;
787
852
set pg_pathman.enable_runtimemergeappend = off;
788
853
set enable_mergejoin = on;
789
854
set enable_hashjoin = on;
790
- drop table test.run_values, test.runtime_test_1, test.runtime_test_2 cascade;
791
- NOTICE: drop cascades to12 other objects
855
+ drop table test.run_values, test.runtime_test_1, test.runtime_test_2, test.runtime_test_3, test.vals cascade;
856
+ NOTICE: drop cascades to16 other objects
792
857
/*
793
858
* Test split and merge
794
859
*/
@@ -1009,15 +1074,14 @@ SELECT * FROM test.hash_rel WHERE id = 123;
1009
1074
/*
1010
1075
* Clean up
1011
1076
*/
1012
- SELECT pathman.drop_hash_partitions('test.hash_rel');
1013
- NOTICE: drop cascades to trigger test_hash_rel_insert_trigger on table test.hash_rel
1077
+ SELECT pathman.drop_partitions('test.hash_rel');
1014
1078
NOTICE: drop cascades to 3 other objects
1015
1079
NOTICE: 2 rows copied from test.hash_rel_2
1016
1080
NOTICE: 3 rows copied from test.hash_rel_1
1017
1081
NOTICE: 2 rows copied from test.hash_rel_0
1018
- drop_hash_partitions
1019
- ----------------------
1020
- 3
1082
+ drop_partitions
1083
+ -----------------
1084
+ 3
1021
1085
(1 row)
1022
1086
1023
1087
SELECT COUNT(*) FROM ONLY test.hash_rel;
@@ -1027,20 +1091,17 @@ SELECT COUNT(*) FROM ONLY test.hash_rel;
1027
1091
(1 row)
1028
1092
1029
1093
SELECT pathman.create_hash_partitions('test.hash_rel', 'value', 3);
1030
- NOTICE: function test.hash_rel_insert_trigger_func() does not exist, skipping
1031
- NOTICE: function test.hash_rel_update_trigger_func() does not exist, skipping
1032
1094
NOTICE: Copying data to partitions...
1033
1095
create_hash_partitions
1034
1096
------------------------
1035
1097
3
1036
1098
(1 row)
1037
1099
1038
- SELECT pathman.drop_hash_partitions('test.hash_rel', TRUE);
1039
- NOTICE: drop cascades to trigger test_hash_rel_insert_trigger on table test.hash_rel
1100
+ SELECT pathman.drop_partitions('test.hash_rel', TRUE);
1040
1101
NOTICE: function test.hash_rel_update_trigger_func() does not exist, skipping
1041
- drop_hash_partitions
1042
- ----------------------
1043
- 3
1102
+ drop_partitions
1103
+ -----------------
1104
+ 3
1044
1105
(1 row)
1045
1106
1046
1107
SELECT COUNT(*) FROM ONLY test.hash_rel;
@@ -1050,15 +1111,16 @@ SELECT COUNT(*) FROM ONLY test.hash_rel;
1050
1111
(1 row)
1051
1112
1052
1113
DROP TABLE test.hash_rel CASCADE;
1053
- SELECT pathman.drop_range_partitions('test.num_range_rel');
1114
+ SELECT pathman.drop_partitions('test.num_range_rel');
1115
+ NOTICE: drop cascades to 4 other objects
1054
1116
NOTICE: 0 rows copied from test.num_range_rel_6
1055
1117
NOTICE: 2 rows copied from test.num_range_rel_4
1056
1118
NOTICE: 1000 rows copied from test.num_range_rel_3
1057
1119
NOTICE: 1000 rows copied from test.num_range_rel_2
1058
1120
NOTICE: 998 rows copied from test.num_range_rel_1
1059
- drop_range_partitions
1060
- -----------------------
1061
- 5
1121
+ drop_partitions
1122
+ -----------------
1123
+ 5
1062
1124
(1 row)
1063
1125
1064
1126
DROP TABLE test.num_range_rel CASCADE;
@@ -1172,8 +1234,6 @@ CREATE TABLE test."TeSt" (a INT NOT NULL, b INT);
1172
1234
SELECT pathman.create_hash_partitions('test.TeSt', 'a', 3);
1173
1235
ERROR: relation "test.test" does not exist at character 39
1174
1236
SELECT pathman.create_hash_partitions('test."TeSt"', 'a', 3);
1175
- NOTICE: function test.TeSt_insert_trigger_func() does not exist, skipping
1176
- NOTICE: function test.TeSt_update_trigger_func() does not exist, skipping
1177
1237
NOTICE: Copying data to partitions...
1178
1238
create_hash_partitions
1179
1239
------------------------
@@ -1222,15 +1282,14 @@ EXPLAIN (COSTS OFF) SELECT * FROM test."TeSt" WHERE a = 1;
1222
1282
Filter: (a = 1)
1223
1283
(3 rows)
1224
1284
1225
- SELECT pathman.drop_hash_partitions('test."TeSt"');
1226
- NOTICE: drop cascades to trigger test_TeSt_insert_trigger on table test."TeSt"
1285
+ SELECT pathman.drop_partitions('test."TeSt"');
1227
1286
NOTICE: drop cascades to 3 other objects
1228
1287
NOTICE: 0 rows copied from test."TeSt_2"
1229
1288
NOTICE: 3 rows copied from test."TeSt_1"
1230
1289
NOTICE: 0 rows copied from test."TeSt_0"
1231
- drop_hash_partitions
1232
- ----------------------
1233
- 3
1290
+ drop_partitions
1291
+ -----------------
1292
+ 3
1234
1293
(1 row)
1235
1294
1236
1295
SELECT * FROM test."TeSt";
@@ -1291,15 +1350,16 @@ NOTICE: Done!
1291
1350
{12-31-2014,01-02-2015}
1292
1351
(1 row)
1293
1352
1294
- SELECT pathman.drop_range_partitions('test."RangeRel"');
1353
+ SELECT pathman.drop_partitions('test."RangeRel"');
1354
+ NOTICE: function test.RangeRel_update_trigger_func() does not exist, skipping
1295
1355
NOTICE: 1 rows copied from test."RangeRel_6"
1296
1356
NOTICE: 0 rows copied from test."RangeRel_4"
1297
1357
NOTICE: 1 rows copied from test."RangeRel_3"
1298
1358
NOTICE: 1 rows copied from test."RangeRel_2"
1299
1359
NOTICE: 0 rows copied from test."RangeRel_1"
1300
- drop_range_partitions
1301
- -----------------------
1302
- 5
1360
+ drop_partitions
1361
+ -----------------
1362
+ 5
1303
1363
(1 row)
1304
1364
1305
1365
SELECT pathman.create_partitions_from_range('test."RangeRel"', 'dt', '2015-01-01'::DATE, '2015-01-05'::DATE, '1 day'::INTERVAL);
@@ -1314,7 +1374,7 @@ NOTICE: drop cascades to 5 other objects
1314
1374
SELECT * FROM pathman.pathman_config;
1315
1375
id | relname | attname | parttype | range_interval
1316
1376
----+--------------------+---------+----------+----------------
1317
- 8 | test.num_range_rel | id | 2 | 1000
1377
+ 9 | test.num_range_rel | id | 2 | 1000
1318
1378
(1 row)
1319
1379
1320
1380
CREATE TABLE test."RangeRel" (
@@ -1328,13 +1388,14 @@ NOTICE: Copying data to partitions...
1328
1388
3
1329
1389
(1 row)
1330
1390
1331
- SELECT pathman.drop_range_partitions('test."RangeRel"');
1391
+ SELECT pathman.drop_partitions('test."RangeRel"');
1392
+ NOTICE: function test.RangeRel_update_trigger_func() does not exist, skipping
1332
1393
NOTICE: 0 rows copied from test."RangeRel_3"
1333
1394
NOTICE: 0 rows copied from test."RangeRel_2"
1334
1395
NOTICE: 0 rows copied from test."RangeRel_1"
1335
- drop_range_partitions
1336
- -----------------------
1337
- 3
1396
+ drop_partitions
1397
+ -----------------
1398
+ 3
1338
1399
(1 row)
1339
1400
1340
1401
SELECT pathman.create_partitions_from_range('test."RangeRel"', 'id', 1, 300, 100);
@@ -1355,8 +1416,6 @@ CREATE TABLE hash_rel (
1355
1416
valueINTEGER NOT NULL);
1356
1417
INSERT INTO hash_rel (value) SELECT g FROM generate_series(1, 10000) as g;
1357
1418
SELECT create_hash_partitions('hash_rel', 'value', 3);
1358
- NOTICE: function public.hash_rel_insert_trigger_func() does not exist, skipping
1359
- NOTICE: function public.hash_rel_update_trigger_func() does not exist, skipping
1360
1419
NOTICE: Copying data to partitions...
1361
1420
create_hash_partitions
1362
1421
------------------------
@@ -1503,7 +1562,8 @@ EXPLAIN (COSTS OFF) DELETE FROM range_rel r USING tmp t WHERE r.dt = '2010-01-02
1503
1562
1504
1563
DELETE FROM range_rel r USING tmp t WHERE r.dt = '2010-01-02' AND r.id = t.id;
1505
1564
/* Create range partitions from whole range */
1506
- SELECT drop_range_partitions('range_rel');
1565
+ SELECT drop_partitions('range_rel');
1566
+ NOTICE: function public.range_rel_update_trigger_func() does not exist, skipping
1507
1567
NOTICE: 0 rows copied from range_rel_15
1508
1568
NOTICE: 0 rows copied from range_rel_14
1509
1569
NOTICE: 14 rows copied from range_rel_13
@@ -1518,9 +1578,9 @@ NOTICE: 31 rows copied from range_rel_5
1518
1578
NOTICE: 30 rows copied from range_rel_4
1519
1579
NOTICE: 31 rows copied from range_rel_3
1520
1580
NOTICE: 44 rows copied from range_rel_1
1521
- drop_range_partitions
1522
- -----------------------
1523
- 14
1581
+ drop_partitions
1582
+ -----------------
1583
+ 14
1524
1584
(1 row)
1525
1585
1526
1586
SELECT create_partitions_from_range('range_rel', 'id', 1, 1000, 100);
@@ -1530,10 +1590,11 @@ NOTICE: Copying data to partitions...
1530
1590
10
1531
1591
(1 row)
1532
1592
1533
- SELECT drop_range_partitions('range_rel', TRUE);
1534
- drop_range_partitions
1535
- -----------------------
1536
- 10
1593
+ SELECT drop_partitions('range_rel', TRUE);
1594
+ NOTICE: function public.range_rel_update_trigger_func() does not exist, skipping
1595
+ drop_partitions
1596
+ -----------------
1597
+ 10
1537
1598
(1 row)
1538
1599
1539
1600
SELECT create_partitions_from_range('range_rel', 'dt', '2015-01-01'::date, '2015-12-01'::date, '1 month'::interval);