Skip to content

Commit 68bac64

Browse files
committed
resolve conflicts caused by a merge of 'fix_domain_part'
2 parents 34c4dc3 + 336e88d commit 68bac64

File tree

8 files changed

+164
-81
lines changed

8 files changed

+164
-81
lines changed

hash.sql

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ RETURNS INTEGER AS
2020
$$
2121
DECLARE
2222
v_child_relname TEXT;
23-
v_type TEXT;
2423
v_plain_schema TEXT;
2524
v_plain_relname TEXT;
26-
v_hashfunc TEXT;
25+
v_atttype REGTYPE;
26+
v_hashfunc REGPROC;
2727

2828
BEGIN
2929
IF partition_data = true THEN
@@ -38,13 +38,13 @@ BEGIN
3838
attribute := lower(attribute);
3939
PERFORM @extschema@.common_relation_checks(parent_relid, attribute);
4040

41-
v_type := @extschema@.get_attribute_type_name(parent_relid, attribute);
41+
/* Fetch atttype and its hash function */
42+
v_atttype := @extschema@.get_attribute_type(parent_relid, attribute);
43+
v_hashfunc := @extschema@.get_type_hash_func(v_atttype);
4244

4345
SELECT * INTO v_plain_schema, v_plain_relname
4446
FROM @extschema@.get_plain_schema_and_relname(parent_relid);
4547

46-
v_hashfunc := @extschema@.get_type_hash_func(v_type::regtype)::regproc;
47-
4848
/* Insert new entry to pathman config */
4949
INSERT INTO @extschema@.pathman_config (partrel, attname, parttype)
5050
VALUES (parent_relid, attribute, 1);
@@ -65,7 +65,7 @@ BEGIN
6565
v_child_relname,
6666
@extschema@.build_check_constraint_name(v_child_relname::REGCLASS,
6767
attribute),
68-
v_hashfunc,
68+
v_hashfunc::TEXT,
6969
attribute,
7070
partitions_count,
7171
partnum);
@@ -137,7 +137,7 @@ DECLARE
137137
child_relname_format TEXT;
138138
funcname TEXT;
139139
triggername TEXT;
140-
atttype TEXT;
140+
atttype REGTYPE;
141141
hashfunc TEXT;
142142
partitions_count INTEGER;
143143

@@ -180,13 +180,12 @@ BEGIN
180180
quote_ident(plain_relname || '_%s');
181181

182182
/* Fetch base hash function for atttype */
183-
atttype := @extschema@.get_attribute_type_name(parent_relid, attr);
184-
hashfunc := @extschema@.get_type_hash_func(atttype::regtype)::regproc;
183+
atttype := @extschema@.get_attribute_type(parent_relid, attr);
185184

186185
/* Format function definition and execute it */
187-
func := format(func, funcname, attr, partitions_count, att_val_fmt,
188-
old_fields, att_fmt, new_fields, child_relname_format, hashfunc);
189-
EXECUTE func;
186+
EXECUTE format(func, funcname, attr, partitions_count, att_val_fmt,
187+
old_fields, att_fmt, new_fields, child_relname_format,
188+
@extschema@.get_type_hash_func(atttype)::TEXT);
190189

191190
/* Create trigger on every partition */
192191
FOR num IN 0..partitions_count-1
@@ -205,7 +204,7 @@ $$ LANGUAGE plpgsql;
205204
* Returns hash function OID for specified type
206205
*/
207206
CREATE OR REPLACE FUNCTION @extschema@.get_type_hash_func(REGTYPE)
208-
RETURNS OID AS 'pg_pathman', 'get_type_hash_func'
207+
RETURNS REGPROC AS 'pg_pathman', 'get_type_hash_func'
209208
LANGUAGE C STRICT;
210209

211210
/*

init.sql

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,14 @@ CREATE OR REPLACE FUNCTION @extschema@.get_parent_of_partition(REGCLASS)
614614
RETURNS REGCLASS AS 'pg_pathman', 'get_parent_of_partition_pl'
615615
LANGUAGE C STRICT;
616616

617+
/*
618+
* Extract basic type of a domain.
619+
*/
620+
CREATE OR REPLACE FUNCTION @extschema@.get_base_type(REGTYPE)
621+
RETURNS REGTYPE AS 'pg_pathman', 'get_base_type_pl'
622+
LANGUAGE C STRICT;
623+
624+
617625
/*
618626
* Checks if attribute is nullable
619627
*/
@@ -633,9 +641,9 @@ LANGUAGE C STRICT;
633641
/*
634642
* Returns attribute type name for relation
635643
*/
636-
CREATE OR REPLACE FUNCTION @extschema@.get_attribute_type_name(
644+
CREATE OR REPLACE FUNCTION @extschema@.get_attribute_type(
637645
REGCLASS, TEXT)
638-
RETURNS TEXT AS 'pg_pathman', 'get_attribute_type_name'
646+
RETURNS REGTYPE AS 'pg_pathman', 'get_attribute_type_pl'
639647
LANGUAGE C STRICT;
640648

641649
/*

range.sql

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ BEGIN
138138
p_attribute,
139139
p_start_value,
140140
p_start_value + p_interval * p_count,
141-
pg_typeof(p_start_value));
141+
@extschema@.get_base_type(pg_typeof(p_start_value))::TEXT);
142142
END IF;
143143

144144
/* Create sequence for child partitions names */
@@ -153,7 +153,7 @@ BEGIN
153153
FOR i IN 1..p_count
154154
LOOP
155155
EXECUTE format('SELECT @extschema@.create_single_range_partition($1, $2, $3::%s)',
156-
pg_typeof(p_start_value))
156+
@extschema@.get_base_type(pg_typeof(p_start_value))::TEXT)
157157
USING parent_relid, p_start_value, p_start_value + p_interval;
158158

159159
p_start_value := p_start_value + p_interval;
@@ -283,7 +283,7 @@ CREATE OR REPLACE FUNCTION @extschema@.create_partitions_from_range(
283283
p_start_value ANYELEMENT,
284284
p_end_value ANYELEMENT,
285285
p_interval ANYELEMENT,
286-
partition_data BOOLEAN DEFAULT true)
286+
partition_data BOOLEAN DEFAULT true)
287287
RETURNS INTEGER AS
288288
$$
289289
DECLARE
@@ -353,7 +353,7 @@ CREATE OR REPLACE FUNCTION @extschema@.create_partitions_from_range(
353353
p_start_value ANYELEMENT,
354354
p_end_value ANYELEMENT,
355355
p_interval INTERVAL,
356-
partition_data BOOLEAN DEFAULT true)
356+
partition_data BOOLEAN DEFAULT true)
357357
RETURNS INTEGER AS
358358
$$
359359
DECLARE
@@ -389,7 +389,7 @@ BEGIN
389389
WHILE p_start_value <= p_end_value
390390
LOOP
391391
EXECUTE format('SELECT @extschema@.create_single_range_partition($1, $2, $3::%s);',
392-
pg_typeof(p_start_value))
392+
@extschema@.get_base_type(pg_typeof(p_start_value))::TEXT)
393393
USING parent_relid, p_start_value, p_start_value + p_interval;
394394

395395
p_start_value := p_start_value + p_interval;
@@ -588,7 +588,7 @@ DECLARE
588588
v_parent_relid2 REGCLASS;
589589
v_attname TEXT;
590590
v_part_type INTEGER;
591-
v_atttype TEXT;
591+
v_atttype REGTYPE;
592592

593593
BEGIN
594594
IF partition1 = partition2 THEN
@@ -623,10 +623,10 @@ BEGIN
623623
RAISE EXCEPTION 'Specified partitions aren''t RANGE partitions';
624624
END IF;
625625

626-
v_atttype := @extschema@.get_attribute_type_name(partition1, v_attname);
626+
v_atttype := @extschema@.get_attribute_type(partition1, v_attname);
627627

628628
EXECUTE format('SELECT @extschema@.merge_range_partitions_internal($1, $2, $3, NULL::%s)',
629-
v_atttype)
629+
@extschema@.get_base_type(v_atttype)::TEXT)
630630
USING v_parent_relid1, partition1, partition2;
631631

632632
/* Tell backend to reload configuration */
@@ -713,7 +713,7 @@ RETURNS TEXT AS
713713
$$
714714
DECLARE
715715
v_attname TEXT;
716-
v_atttype TEXT;
716+
v_atttype REGTYPE;
717717
v_part_name TEXT;
718718
v_interval TEXT;
719719

@@ -730,12 +730,11 @@ BEGIN
730730
RAISE EXCEPTION 'Table "%" is not partitioned', parent_relid::TEXT;
731731
END IF;
732732

733-
v_atttype := @extschema@.get_attribute_type_name(parent_relid, v_attname);
733+
v_atttype := @extschema@.get_attribute_type(parent_relid, v_attname);
734734

735735
EXECUTE
736-
format(
737-
'SELECT @extschema@.append_partition_internal($1, $2, $3, ARRAY[]::%s[], $4)',
738-
v_atttype)
736+
format('SELECT @extschema@.append_partition_internal($1, $2, $3, ARRAY[]::%s[], $4)',
737+
@extschema@.get_base_type(v_atttype)::TEXT)
739738
USING
740739
parent_relid,
741740
v_atttype,
@@ -759,7 +758,7 @@ LANGUAGE plpgsql;
759758
*/
760759
CREATE OR REPLACE FUNCTION @extschema@.append_partition_internal(
761760
parent_relid REGCLASS,
762-
p_atttype TEXT,
761+
p_atttype REGTYPE,
763762
p_interval TEXT,
764763
p_range ANYARRAY DEFAULT NULL,
765764
partition_name TEXT DEFAULT NULL)
@@ -775,17 +774,16 @@ BEGIN
775774

776775
p_range := @extschema@.get_range_by_idx(parent_relid, -1, 0);
777776

778-
IF @extschema@.is_date_type(p_atttype::regtype) THEN
777+
IF @extschema@.is_date_type(p_atttype) THEN
779778
v_part_name := @extschema@.create_single_range_partition(
780779
parent_relid,
781780
p_range[2],
782781
p_range[2] + p_interval::interval,
783782
partition_name);
784783
ELSE
785784
EXECUTE
786-
format(
787-
'SELECT @extschema@.create_single_range_partition($1, $2, $2 + $3::%s, $4)',
788-
p_atttype)
785+
format('SELECT @extschema@.create_single_range_partition($1, $2, $2 + $3::%s, $4)',
786+
@extschema@.get_base_type(p_atttype)::TEXT)
789787
USING
790788
parent_relid,
791789
p_range[2],
@@ -811,7 +809,7 @@ RETURNS TEXT AS
811809
$$
812810
DECLARE
813811
v_attname TEXT;
814-
v_atttype TEXT;
812+
v_atttype REGTYPE;
815813
v_part_name TEXT;
816814
v_interval TEXT;
817815

@@ -825,12 +823,11 @@ BEGIN
825823
RAISE EXCEPTION 'Table "%" is not partitioned', parent_relid::TEXT;
826824
END IF;
827825

828-
v_atttype := @extschema@.get_attribute_type_name(parent_relid, v_attname);
826+
v_atttype := @extschema@.get_attribute_type(parent_relid, v_attname);
829827

830828
EXECUTE
831-
format(
832-
'SELECT @extschema@.prepend_partition_internal($1, $2, $3, ARRAY[]::%s[], $4)',
833-
v_atttype)
829+
format('SELECT @extschema@.prepend_partition_internal($1, $2, $3, ARRAY[]::%s[], $4)',
830+
@extschema@.get_base_type(v_atttype)::TEXT)
834831
USING
835832
parent_relid,
836833
v_atttype,
@@ -854,7 +851,7 @@ LANGUAGE plpgsql;
854851
*/
855852
CREATE OR REPLACE FUNCTION @extschema@.prepend_partition_internal(
856853
parent_relid REGCLASS,
857-
p_atttype TEXT,
854+
p_atttype REGTYPE,
858855
p_interval TEXT,
859856
p_range ANYARRAY DEFAULT NULL,
860857
partition_name TEXT DEFAULT NULL)
@@ -870,17 +867,16 @@ BEGIN
870867

871868
p_range := @extschema@.get_range_by_idx(parent_relid, 0, 0);
872869

873-
IF @extschema@.is_date_type(p_atttype::regtype) THEN
870+
IF @extschema@.is_date_type(p_atttype) THEN
874871
v_part_name := @extschema@.create_single_range_partition(
875872
parent_relid,
876873
p_range[1] - p_interval::interval,
877874
p_range[1],
878875
partition_name);
879876
ELSE
880877
EXECUTE
881-
format(
882-
'SELECT @extschema@.create_single_range_partition($1, $2 - $3::%s, $2, $4)',
883-
p_atttype)
878+
format('SELECT @extschema@.create_single_range_partition($1, $2 - $3::%s, $2, $4)',
879+
@extschema@.get_base_type(p_atttype)::TEXT)
884880
USING
885881
parent_relid,
886882
p_range[1],

src/hooks.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,6 @@ pathman_relcache_hook(Datum arg, Oid relid)
565565
/* Both syscache and pathman's cache say it isn't a partition */
566566
case PPS_ENTRY_NOT_FOUND:
567567
{
568-
/* NOTE: Remove NOT_USED when it's time */
569568
delay_invalidation_parent_rel(partitioned_table);
570569
#ifdef NOT_USED
571570
elog(DEBUG2, "Invalidation message for relation %u [%u]",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy