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

Commit3301383

Browse files
committed
Avoid segfaults on 1.5-upgraded installations before10e6c71
1 parentafdf2f5 commit3301383

File tree

6 files changed

+25
-13
lines changed

6 files changed

+25
-13
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
@@ -620,6 +620,7 @@ pathman_config_contains_relation(Oid relid, Datum *values, bool *isnull,
620620
Snapshotsnapshot;
621621
HeapTuplehtup;
622622
boolcontains_rel= false;
623+
TupleDesctupleDescr;
623624

624625
ScanKeyInit(&key[0],
625626
Anum_pathman_config_partrel,
@@ -628,13 +629,15 @@ pathman_config_contains_relation(Oid relid, Datum *values, bool *isnull,
628629

629630
/* Open PATHMAN_CONFIG with latest snapshot available */
630631
rel=heap_open(get_pathman_config_relid(false),AccessShareLock);
632+
tupleDescr=RelationGetDescr(rel);
631633

632634
/* Check that 'partrel' column is of regclass type */
633-
Assert(TupleDescAttr(RelationGetDescr(rel),
635+
Assert(TupleDescAttr(tupleDescr,
634636
Anum_pathman_config_partrel-1)->atttypid==REGCLASSOID);
635637

636638
/* Check that number of columns == Natts_pathman_config */
637-
Assert(RelationGetDescr(rel)->natts==Natts_pathman_config);
639+
Assert(tupleDescr->natts==Natts_pathman_config
640+
||tupleDescr->natts==Natts_pathman_config_historic);
638641

639642
snapshot=RegisterSnapshot(GetLatestSnapshot());
640643
scan=heap_beginscan(rel,snapshot,1,key);
@@ -647,7 +650,7 @@ pathman_config_contains_relation(Oid relid, Datum *values, bool *isnull,
647650
if (values&&isnull)
648651
{
649652
htup=heap_copytuple(htup);
650-
heap_deform_tuple(htup,RelationGetDescr(rel),values,isnull);
653+
heap_deform_tuple(htup,tupleDescr,values,isnull);
651654

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

‎src/partition_creation.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ create_partitions_for_value_internal(Oid relid, Datum value, Oid value_type,
338338

339339
PG_TRY();
340340
{
341-
Datumvalues[Natts_pathman_config];
342-
boolisnull[Natts_pathman_config];
341+
Datumvalues[Natts_pathman_config_historic];
342+
boolisnull[Natts_pathman_config_historic];
343343

344344
/* Get both PartRelationInfo & PATHMAN_CONFIG contents for this relation */
345345
if (pathman_config_contains_relation(relid,values,isnull,NULL,NULL))
@@ -1842,8 +1842,8 @@ build_partitioning_expression(Oid parent_relid,
18421842
List**columns)/* ret val #2 */
18431843
{
18441844
/* Values extracted from PATHMAN_CONFIG */
1845-
Datumvalues[Natts_pathman_config];
1846-
boolisnull[Natts_pathman_config];
1845+
Datumvalues[Natts_pathman_config_historic];
1846+
boolisnull[Natts_pathman_config_historic];
18471847
char*expr_cstr;
18481848
Node*expr;
18491849

‎src/pl_funcs.c‎

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

702702
Relationpathman_config;
703-
Datumvalues[Natts_pathman_config];
704-
boolisnull[Natts_pathman_config];
703+
Datumvalues[Natts_pathman_config_historic];
704+
boolisnull[Natts_pathman_config_historic];
705705
HeapTuplehtup;
706706

707707
Oidexpr_type;
@@ -797,6 +797,14 @@ add_to_pathman_config(PG_FUNCTION_ARGS)
797797
values[Anum_pathman_config_expr-1]=CStringGetTextDatum(expression);
798798
isnull[Anum_pathman_config_expr-1]= false;
799799

800+
/*
801+
* In case of 1.5 update before 10e6c71 there is acutlly 5 attributes in
802+
* pathman_config description (inclusing cooked expression). To avoid
803+
* potential problems we allocate 5th attribute and initialize it with null.
804+
*/
805+
values[Natts_pathman_config_historic-1]= (Datum)0;
806+
isnull[Natts_pathman_config_historic-1]= true;
807+
800808
/* Insert new row into PATHMAN_CONFIG */
801809
pathman_config=heap_open(get_pathman_config_relid(false),RowExclusiveLock);
802810

‎src/pl_range_funcs.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ create_single_range_partition_pl(PG_FUNCTION_ARGS)
103103
RangeVar*partition_name_rv;
104104
char*tablespace;
105105

106-
Datumvalues[Natts_pathman_config];
107-
boolisnull[Natts_pathman_config];
106+
Datumvalues[Natts_pathman_config_historic];
107+
boolisnull[Natts_pathman_config_historic];
108108

109109

110110
/* Handle 'parent_relid' */

‎src/relation_info.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ get_pathman_relation_info(Oid relid)
336336
{
337337
PartRelationInfo*prel=NULL;
338338
ItemPointerDataiptr;
339-
Datumvalues[Natts_pathman_config];
340-
boolisnull[Natts_pathman_config];
339+
Datumvalues[Natts_pathman_config_historic];
340+
boolisnull[Natts_pathman_config_historic];
341341
boolfound;
342342

343343
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp