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

Commit2cdb2bd

Browse files
committed
Avoid segfaults on 1.5-upgraded installations before10e6c71
1 parentbf0a84c commit2cdb2bd

File tree

6 files changed

+27
-15
lines changed

6 files changed

+27
-15
lines changed

‎src/include/pathman.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
*/
4747
#definePATHMAN_CONFIG"pathman_config"
4848
#defineNatts_pathman_config4
49+
#defineNatts_pathman_config_historic5
4950
#defineAnum_pathman_config_partrel1/* partitioned relation (regclass) */
5051
#defineAnum_pathman_config_expr2/* partition expression (original) */
5152
#defineAnum_pathman_config_parttype3/* partitioning type (1|2) */

‎src/init.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ pathman_config_contains_relation(Oid relid, Datum *values, bool *isnull,
648648
Snapshotsnapshot;
649649
HeapTuplehtup;
650650
boolcontains_rel= false;
651+
TupleDesctupleDescr;
651652

652653
ScanKeyInit(&key[0],
653654
Anum_pathman_config_partrel,
@@ -656,13 +657,15 @@ pathman_config_contains_relation(Oid relid, Datum *values, bool *isnull,
656657

657658
/* Open PATHMAN_CONFIG with latest snapshot available */
658659
rel=heap_open(get_pathman_config_relid(false),AccessShareLock);
660+
tupleDescr=RelationGetDescr(rel);
659661

660662
/* Check that 'partrel' column is of regclass type */
661-
Assert(TupleDescAttr(RelationGetDescr(rel),
663+
Assert(TupleDescAttr(tupleDescr,
662664
Anum_pathman_config_partrel-1)->atttypid==REGCLASSOID);
663665

664666
/* Check that number of columns == Natts_pathman_config */
665-
Assert(RelationGetDescr(rel)->natts==Natts_pathman_config);
667+
Assert(tupleDescr->natts==Natts_pathman_config
668+
||tupleDescr->natts==Natts_pathman_config_historic);
666669

667670
snapshot=RegisterSnapshot(GetLatestSnapshot());
668671
#ifPG_VERSION_NUM >=120000
@@ -679,7 +682,7 @@ pathman_config_contains_relation(Oid relid, Datum *values, bool *isnull,
679682
if (values&&isnull)
680683
{
681684
htup=heap_copytuple(htup);
682-
heap_deform_tuple(htup,RelationGetDescr(rel),values,isnull);
685+
heap_deform_tuple(htup,tupleDescr,values,isnull);
683686

684687
/* Perform checks for non-NULL columns */
685688
Assert(!isnull[Anum_pathman_config_partrel-1]);

‎src/partition_creation.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ create_single_range_partition_internal(Oid parent_relid,
116116
init_callback_paramscallback_params;
117117
List*trigger_columns=NIL;
118118
Node*expr;
119-
Datumvalues[Natts_pathman_config];
120-
boolisnull[Natts_pathman_config];
119+
Datumvalues[Natts_pathman_config_historic];
120+
boolisnull[Natts_pathman_config_historic];
121121

122122

123123
/*
@@ -353,8 +353,8 @@ Oid
353353
create_partitions_for_value_internal(Oidrelid,Datumvalue,Oidvalue_type)
354354
{
355355
Oidpartid=InvalidOid;/* last created partition (or InvalidOid) */
356-
Datumvalues[Natts_pathman_config];
357-
boolisnull[Natts_pathman_config];
356+
Datumvalues[Natts_pathman_config_historic];
357+
boolisnull[Natts_pathman_config_historic];
358358

359359
/* Get both PartRelationInfo & PATHMAN_CONFIG contents for this relation */
360360
if (pathman_config_contains_relation(relid,values,isnull,NULL,NULL))
@@ -1914,8 +1914,8 @@ build_partitioning_expression(Oid parent_relid,
19141914
List**columns)/* ret val #2 */
19151915
{
19161916
/* Values extracted from PATHMAN_CONFIG */
1917-
Datumvalues[Natts_pathman_config];
1918-
boolisnull[Natts_pathman_config];
1917+
Datumvalues[Natts_pathman_config_historic];
1918+
boolisnull[Natts_pathman_config_historic];
19191919
char*expr_cstr;
19201920
Node*expr;
19211921

‎src/pl_funcs.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,8 @@ add_to_pathman_config(PG_FUNCTION_ARGS)
751751
uint32children_count;
752752

753753
Relationpathman_config;
754-
Datumvalues[Natts_pathman_config];
755-
boolisnull[Natts_pathman_config];
754+
Datumvalues[Natts_pathman_config_historic];
755+
boolisnull[Natts_pathman_config_historic];
756756
HeapTuplehtup;
757757

758758
Oidexpr_type;
@@ -851,6 +851,14 @@ add_to_pathman_config(PG_FUNCTION_ARGS)
851851
values[Anum_pathman_config_expr-1]=CStringGetTextDatum(expression);
852852
isnull[Anum_pathman_config_expr-1]= false;
853853

854+
/*
855+
* In case of 1.5 update before 10e6c71 there is acutlly 5 attributes in
856+
* pathman_config description (inclusing cooked expression). To avoid
857+
* potential problems we allocate 5th attribute and initialize it with null.
858+
*/
859+
values[Natts_pathman_config_historic-1]= (Datum)0;
860+
isnull[Natts_pathman_config_historic-1]= true;
861+
854862
/* Insert new row into PATHMAN_CONFIG */
855863
pathman_config=heap_open(get_pathman_config_relid(false),RowExclusiveLock);
856864

‎src/pl_range_funcs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ create_single_range_partition_pl(PG_FUNCTION_ARGS)
110110
RangeVar*partition_name_rv;
111111
char*tablespace;
112112

113-
Datumvalues[Natts_pathman_config];
114-
boolisnull[Natts_pathman_config];
113+
Datumvalues[Natts_pathman_config_historic];
114+
boolisnull[Natts_pathman_config_historic];
115115

116116

117117
/* Handle 'parent_relid' */

‎src/relation_info.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ get_pathman_relation_info(Oid relid)
350350
{
351351
PartRelationInfo*prel=NULL;
352352
ItemPointerDataiptr;
353-
Datumvalues[Natts_pathman_config];
354-
boolisnull[Natts_pathman_config];
353+
Datumvalues[Natts_pathman_config_historic];
354+
boolisnull[Natts_pathman_config_historic];
355355
boolfound;
356356

357357
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp