Skip to content

Commit 30d4969

Browse files
committed
pathman: fixed attribute case sensitivity
1 parent 0344edd commit 30d4969

File tree

7 files changed

+12
-8
lines changed

7 files changed

+12
-8
lines changed

contrib/pg_pathman/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# contrib/pg_pathman/Makefile
22

3-
43
MODULE_big = pg_pathman
54
OBJS = init.o pg_pathman.o dsm_array.o rangeset.o pl_funcs.o worker.o $(WIN32RES)
65

@@ -37,4 +36,4 @@ isolationcheck: | submake-isolation
3736
$(pg_isolation_regress_check) \
3837
--temp-config=$(top_srcdir)/$(subdir)/conf.add \
3938
--outputdir=./isolation_output \
40-
$(ISOLATIONCHECKS)
39+
$(ISOLATIONCHECKS)

contrib/pg_pathman/expected/pg_pathman.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ INSERT INTO test.hash_rel VALUES (3, 3);
1111
SELECT pathman.create_hash_partitions('test.hash_rel', 'value', 3);
1212
ERROR: Partitioning key 'value' must be NOT NULL
1313
ALTER TABLE test.hash_rel ALTER COLUMN value SET NOT NULL;
14-
SELECT pathman.create_hash_partitions('test.hash_rel', 'value', 3);
14+
SELECT pathman.create_hash_partitions('test.hash_rel', 'Value', 3);
1515
NOTICE: function test.hash_rel_hash_insert_trigger_func() does not exist, skipping
1616
NOTICE: function test.hash_rel_hash_update_trigger_func() does not exist, skipping
1717
NOTICE: Copying data to partitions...
@@ -59,7 +59,7 @@ ERROR: Partitioning key 'dt' must be NOT NULL P0001
5959
ALTER TABLE test.range_rel ALTER COLUMN dt SET NOT NULL;
6060
SELECT pathman.create_range_partitions('test.range_rel', 'dt', '2015-01-01'::DATE, '1 month'::INTERVAL, 2);
6161
ERROR: Not enough partitions to fit all the values of 'dt' P0001
62-
SELECT pathman.create_range_partitions('test.range_rel', 'dt', '2015-01-01'::DATE, '1 month'::INTERVAL);
62+
SELECT pathman.create_range_partitions('test.range_rel', 'DT', '2015-01-01'::DATE, '1 month'::INTERVAL);
6363
NOTICE: sequence "range_rel_seq" does not exist, skipping
6464
NOTICE: Copying data to partitions...
6565
create_range_partitions

contrib/pg_pathman/hash.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ DECLARE
2121
v_type TEXT;
2222
BEGIN
2323
relation := @extschema@.validate_relname(relation);
24+
attribute := lower(attribute);
2425
PERFORM @extschema@.common_relation_checks(relation, attribute);
2526

2627
v_type := @extschema@.get_attribute_type_name(relation, attribute);

contrib/pg_pathman/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ load_relations_hashtable(bool reinitialize)
175175
char sql[] = "SELECT pg_class.relfilenode, pg_attribute.attnum, cfg.parttype, pg_attribute.atttypid "
176176
"FROM %s.pathman_config as cfg "
177177
"JOIN pg_class ON pg_class.relfilenode = cfg.relname::regclass::oid "
178-
"JOIN pg_attribute ON pg_attribute.attname = cfg.attname "
178+
"JOIN pg_attribute ON pg_attribute.attname = lower(cfg.attname) "
179179
"AND attrelid = pg_class.relfilenode";
180180
char *query;
181181

contrib/pg_pathman/range.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ DECLARE
2626
i INTEGER;
2727
BEGIN
2828
p_relation := @extschema@.validate_relname(p_relation);
29+
p_attribute := lower(p_attribute);
2930
PERFORM @extschema@.common_relation_checks(p_relation, p_attribute);
3031

3132
/* Try to determine partitions count if not set */
@@ -110,6 +111,7 @@ DECLARE
110111
i INTEGER;
111112
BEGIN
112113
p_relation := @extschema@.validate_relname(p_relation);
114+
p_attribute := lower(p_attribute);
113115
PERFORM @extschema@.common_relation_checks(p_relation, p_attribute);
114116

115117
IF p_count <= 0 THEN
@@ -195,6 +197,7 @@ DECLARE
195197
i INTEGER := 0;
196198
BEGIN
197199
p_relation := @extschema@.validate_relname(p_relation);
200+
p_attribute := lower(p_attribute);
198201
PERFORM @extschema@.common_relation_checks(p_relation, p_attribute);
199202

200203
IF p_interval <= 0 THEN
@@ -258,6 +261,7 @@ DECLARE
258261
i INTEGER := 0;
259262
BEGIN
260263
p_relation := @extschema@.validate_relname(p_relation);
264+
p_attribute := lower(p_attribute);
261265
PERFORM @extschema@.common_relation_checks(p_relation, p_attribute);
262266

263267
EXECUTE format('DROP SEQUENCE IF EXISTS %s_seq', p_relation);

contrib/pg_pathman/sql/pg_pathman.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ INSERT INTO test.hash_rel VALUES (2, 2);
1212
INSERT INTO test.hash_rel VALUES (3, 3);
1313
SELECT pathman.create_hash_partitions('test.hash_rel', 'value', 3);
1414
ALTER TABLE test.hash_rel ALTER COLUMN value SET NOT NULL;
15-
SELECT pathman.create_hash_partitions('test.hash_rel', 'value', 3);
15+
SELECT pathman.create_hash_partitions('test.hash_rel', 'Value', 3);
1616
SELECT COUNT(*) FROM test.hash_rel;
1717
SELECT COUNT(*) FROM ONLY test.hash_rel;
1818
INSERT INTO test.hash_rel VALUES (4, 4);
@@ -31,7 +31,7 @@ SELECT g, md5(g::TEXT) FROM generate_series('2015-01-01', '2015-04-30', '1 day':
3131
SELECT pathman.create_range_partitions('test.range_rel', 'dt', '2015-01-01'::DATE, '1 month'::INTERVAL, 2);
3232
ALTER TABLE test.range_rel ALTER COLUMN dt SET NOT NULL;
3333
SELECT pathman.create_range_partitions('test.range_rel', 'dt', '2015-01-01'::DATE, '1 month'::INTERVAL, 2);
34-
SELECT pathman.create_range_partitions('test.range_rel', 'dt', '2015-01-01'::DATE, '1 month'::INTERVAL);
34+
SELECT pathman.create_range_partitions('test.range_rel', 'DT', '2015-01-01'::DATE, '1 month'::INTERVAL);
3535
SELECT COUNT(*) FROM test.range_rel;
3636
SELECT COUNT(*) FROM ONLY test.range_rel;
3737

contrib/pg_pathman/worker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ bg_worker_main(Datum main_arg)
124124
if (!handle)
125125
{
126126
ereport(WARNING,
127-
(errmsg("pg_pathman worker: ivalid dsm_handle")));
127+
(errmsg("pg_pathman worker: invalid dsm_handle")));
128128
}
129129
segment = dsm_attach(handle);
130130
args = dsm_segment_address(segment);

0 commit comments

Comments
 (0)