Skip to content

Commit 0cc29da

Browse files
author
Commitfest Bot
committed
[CF 5638] Minor rework of ALTER TABLE SET RelOptions code
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5638 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/1913854.tdWV9SEqCh@thinkpad-pgpro Author(s): Nikolay Shaplov
2 parents c872516 + 67dd741 commit 0cc29da

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/backend/commands/tablecmds.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15919,7 +15919,6 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
1591915919
HeapTuple tuple;
1592015920
HeapTuple newtuple;
1592115921
Datum datum;
15922-
bool isnull;
1592315922
Datum newOptions;
1592415923
Datum repl_val[Natts_pg_class];
1592515924
bool repl_null[Natts_pg_class];
@@ -15944,25 +15943,25 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
1594415943
* there were none before.
1594515944
*/
1594615945
datum = (Datum) 0;
15947-
isnull = true;
1594815946
}
1594915947
else
1595015948
{
15949+
bool isnull;
1595115950
/* Get the old reloptions */
1595215951
datum = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_reloptions,
1595315952
&isnull);
15953+
if (isnull)
15954+
datum = (Datum) 0;
1595415955
}
1595515956

1595615957
/* Generate new proposed reloptions (text array) */
15957-
newOptions = transformRelOptions(isnull ? (Datum) 0 : datum,
15958-
defList, NULL, validnsps, false,
15958+
newOptions = transformRelOptions(datum, defList, NULL, validnsps, false,
1595915959
operation == AT_ResetRelOptions);
1596015960

1596115961
/* Validate */
1596215962
switch (rel->rd_rel->relkind)
1596315963
{
1596415964
case RELKIND_RELATION:
15965-
case RELKIND_TOASTVALUE:
1596615965
case RELKIND_MATVIEW:
1596715966
(void) heap_reloptions(rel->rd_rel->relkind, newOptions, true);
1596815967
break;
@@ -15976,6 +15975,12 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
1597615975
case RELKIND_PARTITIONED_INDEX:
1597715976
(void) index_reloptions(rel->rd_indam->amoptions, newOptions, true);
1597815977
break;
15978+
case RELKIND_TOASTVALUE:
15979+
/* Should never get here */
15980+
/* TOAST options are never altered directly */
15981+
Assert(0);
15982+
/* FALLTHRU */
15983+
/* If we get here in prod. error is the best option */
1597915984
default:
1598015985
ereport(ERROR,
1598115986
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -16065,18 +16070,19 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
1606516070
* pretend there were none before.
1606616071
*/
1606716072
datum = (Datum) 0;
16068-
isnull = true;
1606916073
}
1607016074
else
1607116075
{
16076+
bool isnull;
1607216077
/* Get the old reloptions */
1607316078
datum = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_reloptions,
1607416079
&isnull);
16080+
if (isnull)
16081+
datum = (Datum) 0;
1607516082
}
1607616083

16077-
newOptions = transformRelOptions(isnull ? (Datum) 0 : datum,
16078-
defList, "toast", validnsps, false,
16079-
operation == AT_ResetRelOptions);
16084+
newOptions = transformRelOptions(datum, defList, "toast", validnsps,
16085+
false, operation == AT_ResetRelOptions);
1608016086

1608116087
(void) heap_reloptions(RELKIND_TOASTVALUE, newOptions, true);
1608216088

0 commit comments

Comments
 (0)