Skip to content

Commit 25bb11f

Browse files
committed
domain-related fixes (base type), remove functions get_min_range_value() & get_max_range_value(), overloaded function get_part_range() (written in C), fix calls of get_part_range() - pass dummy NULL cast to partitioned column's type
1 parent ad7f159 commit 25bb11f

File tree

8 files changed

+173
-186
lines changed

8 files changed

+173
-186
lines changed

expected/pg_pathman.out

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ INSERT INTO test.hash_rel VALUES (1, 1);
99
INSERT INTO test.hash_rel VALUES (2, 2);
1010
INSERT INTO test.hash_rel VALUES (3, 3);
1111
SELECT pathman.create_hash_partitions('test.hash_rel', 'value', 3);
12-
ERROR: Partitioning key 'value' must be NOT NULL
12+
ERROR: partitioning key 'value' must be NOT NULL
1313
ALTER TABLE test.hash_rel ALTER COLUMN value SET NOT NULL;
1414
SELECT pathman.create_hash_partitions('test.hash_rel', 'value', 3, partition_data:=false);
1515
create_hash_partitions
@@ -130,10 +130,10 @@ CREATE INDEX ON test.range_rel (dt);
130130
INSERT INTO test.range_rel (dt, txt)
131131
SELECT g, md5(g::TEXT) FROM generate_series('2015-01-01', '2015-04-30', '1 day'::interval) as g;
132132
SELECT pathman.create_range_partitions('test.range_rel', 'dt', '2015-01-01'::DATE, '1 month'::INTERVAL, 2);
133-
ERROR: Partitioning key 'dt' must be NOT NULL
133+
ERROR: partitioning key 'dt' must be NOT NULL
134134
ALTER TABLE test.range_rel ALTER COLUMN dt SET NOT NULL;
135135
SELECT pathman.create_range_partitions('test.range_rel', 'dt', '2015-01-01'::DATE, '1 month'::INTERVAL, 2);
136-
ERROR: Not enough partitions to fit all values of 'dt'
136+
ERROR: not enough partitions to fit all values of 'dt'
137137
SELECT pathman.create_range_partitions('test.range_rel', 'DT', '2015-01-01'::DATE, '1 month'::INTERVAL);
138138
NOTICE: sequence "range_rel_seq" does not exist, skipping
139139
create_range_partitions
@@ -1045,7 +1045,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt BETWEEN '2014-12-15' A
10451045
(3 rows)
10461046

10471047
SELECT pathman.add_range_partition('test.range_rel', '2014-12-01'::DATE, '2015-01-02'::DATE);
1048-
ERROR: Specified range overlaps with existing partitions
1048+
ERROR: specified range overlaps with existing partitions
10491049
SELECT pathman.add_range_partition('test.range_rel', '2014-12-01'::DATE, '2015-01-01'::DATE);
10501050
add_range_partition
10511051
---------------------
@@ -1064,7 +1064,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel WHERE dt BETWEEN '2014-12-15' A
10641064

10651065
CREATE TABLE test.range_rel_archive (LIKE test.range_rel INCLUDING ALL);
10661066
SELECT pathman.attach_range_partition('test.range_rel', 'test.range_rel_archive', '2014-01-01'::DATE, '2015-01-01'::DATE);
1067-
ERROR: Specified range overlaps with existing partitions
1067+
ERROR: specified range overlaps with existing partitions
10681068
SELECT pathman.attach_range_partition('test.range_rel', 'test.range_rel_archive', '2014-01-01'::DATE, '2014-12-01'::DATE);
10691069
attach_range_partition
10701070
------------------------
@@ -1103,12 +1103,12 @@ CREATE TABLE test.range_rel_test1 (
11031103
txt TEXT,
11041104
abc INTEGER);
11051105
SELECT pathman.attach_range_partition('test.range_rel', 'test.range_rel_test1', '2013-01-01'::DATE, '2014-01-01'::DATE);
1106-
ERROR: Partition must have the exact same structure as parent
1106+
ERROR: partition must have the exact same structure as parent
11071107
CREATE TABLE test.range_rel_test2 (
11081108
id SERIAL PRIMARY KEY,
11091109
dt TIMESTAMP);
11101110
SELECT pathman.attach_range_partition('test.range_rel', 'test.range_rel_test2', '2013-01-01'::DATE, '2014-01-01'::DATE);
1111-
ERROR: Partition must have the exact same structure as parent
1111+
ERROR: partition must have the exact same structure as parent
11121112
/*
11131113
* Zero partitions count and adding partitions with specified name
11141114
*/
@@ -1124,9 +1124,9 @@ NOTICE: sequence "zero_seq" does not exist, skipping
11241124
(1 row)
11251125

11261126
SELECT pathman.append_range_partition('test.zero', 'test.zero_0');
1127-
ERROR: Cannot append to empty partitions set
1127+
ERROR: cannot append to empty partitions set
11281128
SELECT pathman.prepend_range_partition('test.zero', 'test.zero_1');
1129-
ERROR: Cannot prepend to empty partitions set
1129+
ERROR: cannot prepend to empty partitions set
11301130
SELECT pathman.add_range_partition('test.zero', 50, 70, 'test.zero_50');
11311131
add_range_partition
11321132
---------------------
@@ -1689,8 +1689,8 @@ CREATE TABLE replies(id SERIAL PRIMARY KEY, message_id INTEGER REFERENCES messag
16891689
INSERT INTO messages SELECT g, md5(g::text) FROM generate_series(1, 10) as g;
16901690
INSERT INTO replies SELECT g, g, md5(g::text) FROM generate_series(1, 10) as g;
16911691
SELECT create_range_partitions('messages', 'id', 1, 100, 2);
1692-
WARNING: Foreign key 'replies_message_id_fkey' references to the relation 'messages'
1693-
ERROR: Relation "messages" is referenced from other relations
1692+
WARNING: foreign key 'replies_message_id_fkey' references relation 'messages'
1693+
ERROR: relation "messages" is referenced from other relations
16941694
ALTER TABLE replies DROP CONSTRAINT replies_message_id_fkey;
16951695
SELECT create_range_partitions('messages', 'id', 1, 100, 2);
16961696
NOTICE: sequence "messages_seq" does not exist, skipping

init.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,30 +332,30 @@ BEGIN
332332
WHERE oid = p_relation INTO rel_persistence;
333333

334334
IF rel_persistence = 't'::CHAR THEN
335-
RAISE EXCEPTION 'Temporary table "%" cannot be partitioned',
335+
RAISE EXCEPTION 'temporary table "%" cannot be partitioned',
336336
p_relation::TEXT;
337337
END IF;
338338

339339
IF EXISTS (SELECT * FROM @extschema@.pathman_config
340340
WHERE partrel = p_relation) THEN
341-
RAISE EXCEPTION 'Relation "%" has already been partitioned', p_relation;
341+
RAISE EXCEPTION 'relation "%" has already been partitioned', p_relation;
342342
END IF;
343343

344344
IF @extschema@.is_attribute_nullable(p_relation, p_attribute) THEN
345-
RAISE EXCEPTION 'Partitioning key ''%'' must be NOT NULL', p_attribute;
345+
RAISE EXCEPTION 'partitioning key ''%'' must be NOT NULL', p_attribute;
346346
END IF;
347347

348348
/* Check if there are foreign keys that reference the relation */
349349
FOR v_rec IN (SELECT *
350350
FROM pg_constraint WHERE confrelid = p_relation::regclass::oid)
351351
LOOP
352352
is_referenced := TRUE;
353-
RAISE WARNING 'Foreign key ''%'' references to the relation ''%''',
353+
RAISE WARNING 'foreign key ''%'' references relation ''%''',
354354
v_rec.conname, p_relation;
355355
END LOOP;
356356

357357
IF is_referenced THEN
358-
RAISE EXCEPTION 'Relation "%" is referenced from other relations', p_relation;
358+
RAISE EXCEPTION 'relation "%" is referenced from other relations', p_relation;
359359
END IF;
360360

361361
RETURN TRUE;
@@ -414,7 +414,7 @@ BEGIN
414414
relname = @extschema@.get_schema_qualified_name(cls);
415415

416416
IF relname IS NULL THEN
417-
RAISE EXCEPTION 'Relation %s does not exist', cls;
417+
RAISE EXCEPTION 'relation %s does not exist', cls;
418418
END IF;
419419

420420
RETURN relname;
@@ -529,7 +529,7 @@ BEGIN
529529
DELETE FROM @extschema@.pathman_config_params WHERE partrel = parent_relid;
530530

531531
IF conf_num_del = 0 THEN
532-
RAISE EXCEPTION 'Relation "%" has no partitions', parent_relid::text;
532+
RAISE EXCEPTION 'relation "%" has no partitions', parent_relid::text;
533533
END IF;
534534

535535
FOR v_rec IN (SELECT inhrelid::regclass::text AS tbl

0 commit comments

Comments
 (0)