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

Commitfb85322

Browse files
committed
Fix migration script, return to old version, so tests can work
1 parente38be2b commitfb85322

File tree

5 files changed

+62
-54
lines changed

5 files changed

+62
-54
lines changed

‎pg_pathman--1.3--1.4.sql

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,31 @@ ALTER TABLE @extschema@.pathman_config
3131
/* mark 'expression_p' and 'atttype' to update on next start*/
3232
UPDATE @extschema@.pathman_configSET upd_expr= TRUE;
3333

34+
/* we've changed the format of constraint names, and we need rename them*/
35+
CREATEOR REPLACE FUNCTION @extschema@.update_constraints()
36+
RETURNSBOOLEANAS
37+
$$
38+
DECLARE
39+
v_rec RECORD;
40+
BEGIN
41+
FOR v_recIN (SELECT conrelid::regclassAS t, conname, regexp_replace(conname,'\d+_check','check')as new_conname
42+
FROM pg_constraint
43+
WHERE conname ~'pathman_.*_\d+_\d+_check')
44+
LOOP
45+
EXECUTE format('ALTER TABLE %s RENAME CONSTRAINT %s TO %s',
46+
v_rec.t,v_rec.conname,v_rec.new_conname);
47+
END LOOP;
48+
49+
RETURN TRUE;
50+
END
51+
$$
52+
LANGUAGE plpgsql;
53+
54+
SELECT @extschema@.update_constraints();
55+
56+
/* we don't need this function anymore*/
57+
DROPFUNCTION @extschema@.update_constraints();
58+
3459
DROPFUNCTION @extschema@.common_relation_checks(REGCLASS,TEXT);
3560
CREATEOR REPLACE FUNCTION @extschema@.common_relation_checks(
3661
relationREGCLASS,

‎pg_pathman.control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# pg_pathman extension
22
comment = 'Partitioning tool for PostgreSQL'
3-
default_version = '1.4'
3+
default_version = '1.3'
44
module_pathname = '$libdir/pg_pathman'

‎src/include/relation_info.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ PrelLastChild(const PartRelationInfo *prel)
237237
}
238238

239239

240+
PartRelationInfo*create_pathman_relation_info(Oidrelid);
240241
constPartRelationInfo*refresh_pathman_relation_info(Oidrelid,
241242
Datum*values,
242243
boolallow_incomplete);

‎src/init.c

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -733,16 +733,6 @@ 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);
746736

747737
/* Open PATHMAN_CONFIG with latest snapshot available */
748738
rel=heap_open(get_pathman_config_relid(false),AccessShareLock);
@@ -776,21 +766,9 @@ read_pathman_config(void)
776766
Assert(!isnull[Anum_pathman_config_expression_p-1]);
777767
Assert(!isnull[Anum_pathman_config_upd_expression-1]);
778768

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-
}
791-
792769
/* Extract values from Datums */
793770
relid=DatumGetObjectId(values[Anum_pathman_config_partrel-1]);
771+
upd_expr=DatumGetBool(values[Anum_pathman_config_upd_expression-1]);
794772

795773
/* Check that relation 'relid' exists */
796774
if (get_rel_type_id(relid)==InvalidOid)
@@ -802,8 +780,9 @@ read_pathman_config(void)
802780
errhint(INIT_ERROR_HINT)));
803781
}
804782

805-
/* get_pathman_relation_info() will refresh this entry */
806-
if (!upd_expr)
783+
if (upd_expr)
784+
create_pathman_relation_info(relid);
785+
else
807786
refresh_pathman_relation_info(relid,
808787
values,
809788
true);/* allow lazy prel loading */
@@ -813,12 +792,6 @@ read_pathman_config(void)
813792
heap_endscan(scan);
814793
UnregisterSnapshot(snapshot);
815794
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);
822795
}
823796

824797

‎src/relation_info.c

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -116,35 +116,18 @@ init_relation_info_static_data(void)
116116
NULL);
117117
}
118118

119-
120-
/*
121-
* refresh\invalidate\get\remove PartRelationInfo functions.
122-
*/
123-
124119
/* Create or update PartRelationInfo in local cache. Might emit ERROR. */
125-
constPartRelationInfo*
126-
refresh_pathman_relation_info(Oidrelid,
127-
Datum*values,
128-
boolallow_incomplete)
120+
PartRelationInfo*
121+
create_pathman_relation_info(Oidrelid)
129122
{
130-
constLOCKMODElockmode=AccessShareLock;
131-
constTypeCacheEntry*typcache;
132-
Oid*prel_children;
133-
uint32prel_children_count=0,
134-
i;
135-
boolfound_entry;
136123
PartRelationInfo*prel;
137-
Datumparam_values[Natts_pathman_config_params];
138-
boolparam_isnull[Natts_pathman_config_params];
139-
char*expr;
140-
HeapTupletp;
141-
MemoryContextoldcontext;
124+
boolfound_entry;
142125

143126
AssertTemporaryContext();
144-
145127
prel= (PartRelationInfo*)pathman_cache_search_relid(partitioned_rels,
146128
relid,HASH_ENTER,
147129
&found_entry);
130+
148131
elog(DEBUG2,
149132
found_entry ?
150133
"Refreshing record for relation %u in pg_pathman's cache [%u]" :
@@ -166,7 +149,33 @@ refresh_pathman_relation_info(Oid relid,
166149
}
167150

168151
/* First we assume that this entry is invalid */
169-
prel->valid= false;
152+
prel->valid= false;
153+
returnprel;
154+
}
155+
156+
/*
157+
* refresh\invalidate\get\remove PartRelationInfo functions.
158+
*/
159+
160+
constPartRelationInfo*
161+
refresh_pathman_relation_info(Oidrelid,
162+
Datum*values,
163+
boolallow_incomplete)
164+
{
165+
constLOCKMODElockmode=AccessShareLock;
166+
constTypeCacheEntry*typcache;
167+
Oid*prel_children;
168+
uint32prel_children_count=0,
169+
i;
170+
PartRelationInfo*prel;
171+
Datumparam_values[Natts_pathman_config_params];
172+
boolparam_isnull[Natts_pathman_config_params];
173+
char*expr;
174+
HeapTupletp;
175+
MemoryContextoldcontext;
176+
177+
AssertTemporaryContext();
178+
prel=create_pathman_relation_info(relid);
170179

171180
/* Try locking parent, exit fast if 'allow_incomplete' */
172181
if (allow_incomplete)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp