Skip to content

Commit 183a393

Browse files
committed
support for case-sensitive table names
1 parent b94b4f2 commit 183a393

File tree

6 files changed

+602
-245
lines changed

6 files changed

+602
-245
lines changed

expected/pg_pathman.out

Lines changed: 209 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -488,17 +488,17 @@ WHERE j1.dt < '2015-03-01' AND j2.dt >= '2015-02-01' ORDER BY j2.dt;
488488
-> Index Scan using num_range_rel_4_pkey on num_range_rel_4 j3_3
489489
-> Materialize
490490
-> Merge Join
491-
Merge Cond: (j1.id = j2.id)
491+
Merge Cond: (j2.id = j1.id)
492492
-> Merge Append
493-
Sort Key: j1.id
494-
-> Index Scan using range_rel_1_pkey on range_rel_1 j1
495-
-> Index Scan using range_rel_2_pkey on range_rel_2 j1_1
493+
Sort Key: j2.id
494+
-> Index Scan using range_rel_2_pkey on range_rel_2 j2
495+
-> Index Scan using range_rel_3_pkey on range_rel_3 j2_1
496+
-> Index Scan using range_rel_4_pkey on range_rel_4 j2_2
496497
-> Materialize
497498
-> Merge Append
498-
Sort Key: j2.id
499-
-> Index Scan using range_rel_2_pkey on range_rel_2 j2
500-
-> Index Scan using range_rel_3_pkey on range_rel_3 j2_1
501-
-> Index Scan using range_rel_4_pkey on range_rel_4 j2_2
499+
Sort Key: j1.id
500+
-> Index Scan using range_rel_1_pkey on range_rel_1 j1
501+
-> Index Scan using range_rel_2_pkey on range_rel_2 j1_1
502502
(22 rows)
503503

504504
SET enable_hashjoin = ON;
@@ -508,28 +508,28 @@ SELECT * FROM test.range_rel j1
508508
JOIN test.range_rel j2 on j2.id = j1.id
509509
JOIN test.num_range_rel j3 on j3.id = j1.id
510510
WHERE j1.dt < '2015-03-01' AND j2.dt >= '2015-02-01' ORDER BY j2.dt;
511-
QUERY PLAN
512-
---------------------------------------------------------------------------------------
511+
QUERY PLAN
512+
-------------------------------------------------------------------------------------------
513513
Sort
514514
Sort Key: j2.dt
515515
-> Hash Join
516-
Hash Cond: (j1.id = j2.id)
517-
-> Hash Join
518-
Hash Cond: (j3.id = j1.id)
519-
-> Append
520-
-> Index Scan using num_range_rel_1_pkey on num_range_rel_1 j3
521-
-> Index Scan using num_range_rel_2_pkey on num_range_rel_2 j3_1
522-
-> Index Scan using num_range_rel_3_pkey on num_range_rel_3 j3_2
523-
-> Index Scan using num_range_rel_4_pkey on num_range_rel_4 j3_3
524-
-> Hash
525-
-> Append
526-
-> Index Scan using range_rel_1_pkey on range_rel_1 j1
527-
-> Index Scan using range_rel_2_pkey on range_rel_2 j1_1
516+
Hash Cond: (j3.id = j2.id)
517+
-> Append
518+
-> Index Scan using num_range_rel_1_pkey on num_range_rel_1 j3
519+
-> Index Scan using num_range_rel_2_pkey on num_range_rel_2 j3_1
520+
-> Index Scan using num_range_rel_3_pkey on num_range_rel_3 j3_2
521+
-> Index Scan using num_range_rel_4_pkey on num_range_rel_4 j3_3
528522
-> Hash
529-
-> Append
530-
-> Index Scan using range_rel_2_dt_idx on range_rel_2 j2
531-
-> Index Scan using range_rel_3_dt_idx on range_rel_3 j2_1
532-
-> Index Scan using range_rel_4_dt_idx on range_rel_4 j2_2
523+
-> Hash Join
524+
Hash Cond: (j2.id = j1.id)
525+
-> Append
526+
-> Index Scan using range_rel_2_dt_idx on range_rel_2 j2
527+
-> Index Scan using range_rel_3_dt_idx on range_rel_3 j2_1
528+
-> Index Scan using range_rel_4_dt_idx on range_rel_4 j2_2
529+
-> Hash
530+
-> Append
531+
-> Index Scan using range_rel_1_pkey on range_rel_1 j1
532+
-> Index Scan using range_rel_2_pkey on range_rel_2 j1_1
533533
(20 rows)
534534

535535
/*
@@ -924,6 +924,185 @@ SELECT pathman.check_overlap('test.num_range_rel'::regclass::oid, 0, 1001);
924924
t
925925
(1 row)
926926

927+
/* CaMeL cAsE table names and attributes */
928+
CREATE TABLE test."TeSt" (a INT NOT NULL, b INT);
929+
SELECT pathman.create_hash_partitions('test.TeSt', 'a', 3);
930+
ERROR: relation "test.test" does not exist at character 39
931+
SELECT pathman.create_hash_partitions('test."TeSt"', 'a', 3);
932+
NOTICE: function test.TeSt_insert_trigger_func() does not exist, skipping
933+
NOTICE: function test.TeSt_update_trigger_func() does not exist, skipping
934+
NOTICE: Copying data to partitions...
935+
create_hash_partitions
936+
------------------------
937+
3
938+
(1 row)
939+
940+
INSERT INTO test."TeSt" VALUES (1, 1);
941+
INSERT INTO test."TeSt" VALUES (2, 2);
942+
INSERT INTO test."TeSt" VALUES (3, 3);
943+
SELECT * FROM test."TeSt";
944+
a | b
945+
---+---
946+
3 | 3
947+
1 | 1
948+
2 | 2
949+
(3 rows)
950+
951+
SELECT pathman.create_hash_update_trigger('test."TeSt"');
952+
create_hash_update_trigger
953+
----------------------------
954+
955+
(1 row)
956+
957+
UPDATE test."TeSt" SET a = 1;
958+
SELECT * FROM test."TeSt";
959+
a | b
960+
---+---
961+
1 | 3
962+
1 | 1
963+
1 | 2
964+
(3 rows)
965+
966+
SELECT * FROM test."TeSt" WHERE a = 1;
967+
a | b
968+
---+---
969+
1 | 3
970+
1 | 1
971+
1 | 2
972+
(3 rows)
973+
974+
EXPLAIN (COSTS OFF) SELECT * FROM test."TeSt" WHERE a = 1;
975+
QUERY PLAN
976+
----------------------------
977+
Append
978+
-> Seq Scan on "TeSt_1"
979+
Filter: (a = 1)
980+
(3 rows)
981+
982+
SELECT pathman.drop_hash_partitions('test."TeSt"');
983+
NOTICE: drop cascades to trigger test_TeSt_insert_trigger on table test."TeSt"
984+
NOTICE: drop cascades to 3 other objects
985+
NOTICE: 0 rows copied from test."TeSt_2"
986+
NOTICE: 3 rows copied from test."TeSt_1"
987+
NOTICE: 0 rows copied from test."TeSt_0"
988+
drop_hash_partitions
989+
----------------------
990+
3
991+
(1 row)
992+
993+
SELECT * FROM test."TeSt";
994+
a | b
995+
---+---
996+
1 | 3
997+
1 | 1
998+
1 | 2
999+
(3 rows)
1000+
1001+
CREATE TABLE test."RangeRel" (
1002+
id SERIAL PRIMARY KEY,
1003+
dt TIMESTAMP NOT NULL,
1004+
txt TEXT);
1005+
INSERT INTO test."RangeRel" (dt, txt)
1006+
SELECT g, md5(g::TEXT) FROM generate_series('2015-01-01', '2015-01-03', '1 day'::interval) as g;
1007+
SELECT pathman.create_range_partitions('test."RangeRel"', 'dt', '2015-01-01'::DATE, '1 day'::INTERVAL);
1008+
NOTICE: sequence "RangeRel_seq" does not exist, skipping
1009+
NOTICE: Copying data to partitions...
1010+
create_range_partitions
1011+
-------------------------
1012+
3
1013+
(1 row)
1014+
1015+
SELECT pathman.append_range_partition('test."RangeRel"');
1016+
NOTICE: Appending new partition...
1017+
NOTICE: Done!
1018+
append_range_partition
1019+
------------------------
1020+
test."RangeRel_4"
1021+
(1 row)
1022+
1023+
SELECT pathman.prepend_range_partition('test."RangeRel"');
1024+
NOTICE: Prepending new partition...
1025+
NOTICE: Done!
1026+
prepend_range_partition
1027+
-------------------------
1028+
test."RangeRel_5"
1029+
(1 row)
1030+
1031+
SELECT pathman.merge_range_partitions('test."RangeRel_1"', 'test."RangeRel_' || currval('test."RangeRel_seq"') || '"');
1032+
NOTICE: Altering first partition...
1033+
NOTICE: Copying data...
1034+
NOTICE: Dropping second partition...
1035+
NOTICE: Done!
1036+
merge_range_partitions
1037+
------------------------
1038+
1039+
(1 row)
1040+
1041+
SELECT pathman.split_range_partition('test."RangeRel_1"', '2015-01-01'::DATE);
1042+
NOTICE: Creating new partition...
1043+
NOTICE: Copying data to new partition...
1044+
NOTICE: Altering original partition...
1045+
NOTICE: Done!
1046+
split_range_partition
1047+
-------------------------
1048+
{12-31-2014,01-02-2015}
1049+
(1 row)
1050+
1051+
SELECT pathman.drop_range_partitions('test."RangeRel"');
1052+
NOTICE: 1 rows copied from test."RangeRel_6"
1053+
NOTICE: 0 rows copied from test."RangeRel_4"
1054+
NOTICE: 1 rows copied from test."RangeRel_3"
1055+
NOTICE: 1 rows copied from test."RangeRel_2"
1056+
NOTICE: 0 rows copied from test."RangeRel_1"
1057+
drop_range_partitions
1058+
-----------------------
1059+
5
1060+
(1 row)
1061+
1062+
SELECT pathman.create_partitions_from_range('test."RangeRel"', 'dt', '2015-01-01'::DATE, '2015-01-05'::DATE, '1 day'::INTERVAL);
1063+
NOTICE: Copying data to partitions...
1064+
create_partitions_from_range
1065+
------------------------------
1066+
5
1067+
(1 row)
1068+
1069+
DROP TABLE test."RangeRel" CASCADE;
1070+
NOTICE: drop cascades to 5 other objects
1071+
SELECT * FROM pathman.pathman_config;
1072+
id | relname | attname | parttype | range_interval
1073+
----+--------------------+---------+----------+----------------
1074+
6 | test.num_range_rel | id | 2 | 1000
1075+
(1 row)
1076+
1077+
CREATE TABLE test."RangeRel" (
1078+
id SERIAL PRIMARY KEY,
1079+
dt TIMESTAMP NOT NULL,
1080+
txt TEXT);
1081+
SELECT pathman.create_range_partitions('test."RangeRel"', 'id', 1, 100, 3);
1082+
NOTICE: Copying data to partitions...
1083+
create_range_partitions
1084+
-------------------------
1085+
3
1086+
(1 row)
1087+
1088+
SELECT pathman.drop_range_partitions('test."RangeRel"');
1089+
NOTICE: 0 rows copied from test."RangeRel_3"
1090+
NOTICE: 0 rows copied from test."RangeRel_2"
1091+
NOTICE: 0 rows copied from test."RangeRel_1"
1092+
drop_range_partitions
1093+
-----------------------
1094+
3
1095+
(1 row)
1096+
1097+
SELECT pathman.create_partitions_from_range('test."RangeRel"', 'id', 1, 300, 100);
1098+
NOTICE: Copying data to partitions...
1099+
create_partitions_from_range
1100+
------------------------------
1101+
3
1102+
(1 row)
1103+
1104+
DROP TABLE test."RangeRel" CASCADE;
1105+
NOTICE: drop cascades to 3 other objects
9271106
DROP EXTENSION pg_pathman;
9281107
/* Test that everithing works fine without schemas */
9291108
CREATE EXTENSION pg_pathman;
@@ -933,8 +1112,8 @@ CREATE TABLE hash_rel (
9331112
value INTEGER NOT NULL);
9341113
INSERT INTO hash_rel (value) SELECT g FROM generate_series(1, 10000) as g;
9351114
SELECT create_hash_partitions('hash_rel', 'value', 3);
936-
NOTICE: function hash_rel_insert_trigger_func() does not exist, skipping
937-
NOTICE: function hash_rel_update_trigger_func() does not exist, skipping
1115+
NOTICE: function public.hash_rel_insert_trigger_func() does not exist, skipping
1116+
NOTICE: function public.hash_rel_update_trigger_func() does not exist, skipping
9381117
NOTICE: Copying data to partitions...
9391118
create_hash_partitions
9401119
------------------------
@@ -1134,8 +1313,8 @@ CREATE TABLE replies(id SERIAL PRIMARY KEY, message_id INTEGER REFERENCES messag
11341313
INSERT INTO messages SELECT g, md5(g::text) FROM generate_series(1, 10) as g;
11351314
INSERT INTO replies SELECT g, g, md5(g::text) FROM generate_series(1, 10) as g;
11361315
SELECT create_range_partitions('messages', 'id', 1, 100, 2);
1137-
WARNING: Foreign key 'replies_message_id_fkey' references to the relation 'public.messages'
1138-
ERROR: Relation 'public.messages' is referenced from other relations P0001
1316+
WARNING: Foreign key 'replies_message_id_fkey' references to the relation 'messages'
1317+
ERROR: Relation 'messages' is referenced from other relations P0001
11391318
ALTER TABLE replies DROP CONSTRAINT replies_message_id_fkey;
11401319
SELECT create_range_partitions('messages', 'id', 1, 100, 2);
11411320
NOTICE: sequence "messages_seq" does not exist, skipping

0 commit comments

Comments
 (0)