Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite38be2b

Browse files
committed
Fix migration script
1 parent574f52d commite38be2b

File tree

2 files changed

+61
-6
lines changed

2 files changed

+61
-6
lines changed

‎pg_pathman--1.3--1.4.sql

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* ------------------------------------------------------------------------
99
*/
1010

11-
DROPFUNCTION @extschema@.validate_interval_value(REGCLASS,TEXT,INTEGER,TEXT);
11+
DROPFUNCTION @extschema@.validate_interval_value(REGCLASS,TEXT,INTEGER,TEXT) CASCADE;
1212
CREATEOR REPLACE FUNCTION @extschema@.validate_interval_value(
1313
atttypeOID,
1414
parttypeINTEGER,
@@ -18,12 +18,11 @@ LANGUAGE C;
1818

1919
DROPFUNCTION @extschema@.is_attribute_nullable(REGCLASS,TEXT);
2020

21-
ALTERTABLE @extschema@.pathman_config ADD COLUMN expression_pTEXTNOT NULL;
22-
ALTERTABLE @extschema@.pathman_config ADD COLUMN atttypeOIDNOT NULL;
21+
ALTERTABLE @extschema@.pathman_config ADD COLUMN expression_pTEXTDEFAULT'--not set--';
22+
ALTERTABLE @extschema@.pathman_config ADD COLUMN atttypeOIDDEFAULT1;
2323
ALTERTABLE @extschema@.pathman_config ADD COLUMN upd_expr BOOL DEFAULT FALSE;
2424

2525
/* update constraint*/
26-
ALTERTABLE @extschema@.pathman_config DROPCONSTRAINT pathman_config_check;
2726
ALTERTABLE @extschema@.pathman_config
2827
ADDCONSTRAINT pathman_config_interval_checkCHECK (@extschema@.validate_interval_value(atttype,
2928
parttype,
@@ -32,6 +31,7 @@ ALTER TABLE @extschema@.pathman_config
3231
/* mark 'expression_p' and 'atttype' to update on next start*/
3332
UPDATE @extschema@.pathman_configSET upd_expr= TRUE;
3433

34+
DROPFUNCTION @extschema@.common_relation_checks(REGCLASS,TEXT);
3535
CREATEOR REPLACE FUNCTION @extschema@.common_relation_checks(
3636
relationREGCLASS,
3737
expressionTEXT)
@@ -95,6 +95,9 @@ CREATE OR REPLACE FUNCTION @extschema@.add_to_pathman_config(
9595
RETURNSBOOLEANAS'pg_pathman','add_to_pathman_config'
9696
LANGUAGE C;
9797

98+
DROPFUNCTION @extschema@.create_hash_partitions(REGCLASS,TEXT, INT4,BOOLEAN,
99+
TEXT[],TEXT[]);
100+
98101
CREATEOR REPLACE FUNCTION @extschema@.create_hash_partitions(
99102
parent_relidREGCLASS,
100103
expressionTEXT,
@@ -146,6 +149,7 @@ SET client_min_messages = WARNING;
146149

147150
DROPFUNCTION @extschema@.build_hash_condition(REGTYPE,TEXT, INT4, INT4);
148151

152+
DROPFUNCTION @extschema@.check_boundaries(REGCLASS,TEXT, ANYELEMENT, ANYELEMENT);
149153
CREATEOR REPLACE FUNCTION @extschema@.check_boundaries(
150154
parent_relidREGCLASS,
151155
expressionTEXT,
@@ -183,6 +187,7 @@ END
183187
$$ LANGUAGE plpgsql;
184188

185189

190+
DROPFUNCTION @extschema@.prepare_for_partitioning(REGCLASS,TEXT,BOOLEAN);
186191
CREATEOR REPLACE FUNCTION @extschema@.prepare_for_partitioning(
187192
parent_relidREGCLASS,
188193
expressionTEXT,
@@ -208,6 +213,9 @@ $$ LANGUAGE plpgsql;
208213
/*
209214
* Creates RANGE partitions for specified relation based on datetime attribute
210215
*/
216+
DROPFUNCTION @extschema@.create_range_partitions(REGCLASS,TEXT, ANYELEMENT,
217+
INTERVAL,INTEGER,BOOLEAN);
218+
211219
CREATEOR REPLACE FUNCTION @extschema@.create_range_partitions(
212220
parent_relidREGCLASS,
213221
expressionTEXT,
@@ -311,6 +319,9 @@ $$ LANGUAGE plpgsql;
311319
/*
312320
* Creates RANGE partitions for specified relation based on numerical expression
313321
*/
322+
DROPFUNCTION @extschema@.create_range_partitions(REGCLASS,TEXT, ANYELEMENT,
323+
ANYELEMENT,INTEGER,BOOLEAN);
324+
314325
CREATEOR REPLACE FUNCTION @extschema@.create_range_partitions(
315326
parent_relidREGCLASS,
316327
expressionTEXT,
@@ -410,6 +421,9 @@ $$ LANGUAGE plpgsql;
410421
/*
411422
* Creates RANGE partitions for specified relation based on bounds array
412423
*/
424+
DROPFUNCTION @extschema@.create_range_partitions(REGCLASS,TEXT, ANYARRAY,
425+
TEXT[],TEXT[],BOOLEAN);
426+
413427
CREATEOR REPLACE FUNCTION @extschema@.create_range_partitions(
414428
parent_relidREGCLASS,
415429
expressionTEXT,
@@ -471,6 +485,9 @@ LANGUAGE plpgsql;
471485
/*
472486
* Creates RANGE partitions for specified range
473487
*/
488+
DROPFUNCTION @extschema@.create_partitions_from_range(REGCLASS,TEXT, ANYELEMENT,
489+
ANYELEMENT, ANYELEMENT,BOOLEAN);
490+
474491
CREATEOR REPLACE FUNCTION @extschema@.create_partitions_from_range(
475492
parent_relidREGCLASS,
476493
expressionTEXT,
@@ -531,6 +548,9 @@ $$ LANGUAGE plpgsql;
531548
/*
532549
* Creates RANGE partitions for specified range based on datetime expression
533550
*/
551+
DROPFUNCTION @extschema@.create_partitions_from_range(REGCLASS,TEXT,
552+
ANYELEMENT, ANYELEMENT, INTERVAL,BOOLEAN);
553+
534554
CREATEOR REPLACE FUNCTION @extschema@.create_partitions_from_range(
535555
parent_relidREGCLASS,
536556
expressionTEXT,
@@ -592,6 +612,9 @@ BEGIN
592612
END
593613
$$ LANGUAGE plpgsql;
594614

615+
DROPFUNCTION @extschema@.build_range_condition(REGCLASS,TEXT,
616+
ANYELEMENT, ANYELEMENT);
617+
595618
CREATEOR REPLACE FUNCTION @extschema@.build_range_condition(
596619
partition_relidREGCLASS,
597620
expressionTEXT,

‎src/init.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,16 @@ read_pathman_config(void)
733733
HeapScanDescscan;
734734
Snapshotsnapshot;
735735
HeapTuplehtup;
736+
Oid*relids=NULL;
737+
Sizerelids_index=0,
738+
relids_count=100,
739+
j;
740+
741+
/*
742+
* Initialize relids array, we keep here relations that require
743+
* update their expression.
744+
*/
745+
relids= (Oid*)palloc(sizeof(Oid)*relids_count);
736746

737747
/* Open PATHMAN_CONFIG with latest snapshot available */
738748
rel=heap_open(get_pathman_config_relid(false),AccessShareLock);
@@ -752,7 +762,8 @@ read_pathman_config(void)
752762
while((htup=heap_getnext(scan,ForwardScanDirection))!=NULL)
753763
{
754764
Datumvalues[Natts_pathman_config];
755-
boolisnull[Natts_pathman_config];
765+
boolupd_expr,
766+
isnull[Natts_pathman_config];
756767
Oidrelid;/* partitioned table */
757768

758769
/* Extract Datums from tuple 'htup' */
@@ -763,6 +774,20 @@ read_pathman_config(void)
763774
Assert(!isnull[Anum_pathman_config_parttype-1]);
764775
Assert(!isnull[Anum_pathman_config_expression-1]);
765776
Assert(!isnull[Anum_pathman_config_expression_p-1]);
777+
Assert(!isnull[Anum_pathman_config_upd_expression-1]);
778+
779+
upd_expr=DatumGetBool(values[Anum_pathman_config_upd_expression-1]);
780+
if (upd_expr)
781+
{
782+
if (relids_index >=relids_count)
783+
{
784+
relids_count+=100;
785+
relids= (Oid*)repalloc(relids,sizeof(Oid)*relids_count);
786+
}
787+
788+
relids[relids_index]=relid;
789+
relids_index+=1;
790+
}
766791

767792
/* Extract values from Datums */
768793
relid=DatumGetObjectId(values[Anum_pathman_config_partrel-1]);
@@ -778,7 +803,8 @@ read_pathman_config(void)
778803
}
779804

780805
/* get_pathman_relation_info() will refresh this entry */
781-
refresh_pathman_relation_info(relid,
806+
if (!upd_expr)
807+
refresh_pathman_relation_info(relid,
782808
values,
783809
true);/* allow lazy prel loading */
784810
}
@@ -787,6 +813,12 @@ read_pathman_config(void)
787813
heap_endscan(scan);
788814
UnregisterSnapshot(snapshot);
789815
heap_close(rel,AccessShareLock);
816+
817+
/* Update expressions */
818+
for (j=0;j<relids_index;j++)
819+
get_pathman_relation_info(relids[j]);
820+
821+
pfree(relids);
790822
}
791823

792824

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp