1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-07 11:02:12 +03:00

ATExecSetRelOptions: Reduce scope of 'isnull' variable

Author: Nikolay Shaplov <dhyan@nataraj.su>
Reviewed-by: Timur Magomedov <t.magomedov@postgrespro.ru>
Discussion: https://postgr.es/m/1913854.tdWV9SEqCh@thinkpad-pgpro
This commit is contained in:
Álvaro Herrera 2025-03-13 18:15:59 +01:00
parent da0f0582e8
commit c7fc8808a9
No known key found for this signature in database
GPG Key ID: 1C20ACB9D5C564AE

View File

@ -15919,7 +15919,6 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
HeapTuple tuple; HeapTuple tuple;
HeapTuple newtuple; HeapTuple newtuple;
Datum datum; Datum datum;
bool isnull;
Datum newOptions; Datum newOptions;
Datum repl_val[Natts_pg_class]; Datum repl_val[Natts_pg_class];
bool repl_null[Natts_pg_class]; bool repl_null[Natts_pg_class];
@ -15944,18 +15943,20 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
* there were none before. * there were none before.
*/ */
datum = (Datum) 0; datum = (Datum) 0;
isnull = true;
} }
else else
{ {
bool isnull;
/* Get the old reloptions */ /* Get the old reloptions */
datum = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_reloptions, datum = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_reloptions,
&isnull); &isnull);
if (isnull)
datum = (Datum) 0;
} }
/* Generate new proposed reloptions (text array) */ /* Generate new proposed reloptions (text array) */
newOptions = transformRelOptions(isnull ? (Datum) 0 : datum, newOptions = transformRelOptions(datum, defList, NULL, validnsps, false,
defList, NULL, validnsps, false,
operation == AT_ResetRelOptions); operation == AT_ResetRelOptions);
/* Validate */ /* Validate */
@ -16065,18 +16066,20 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
* pretend there were none before. * pretend there were none before.
*/ */
datum = (Datum) 0; datum = (Datum) 0;
isnull = true;
} }
else else
{ {
bool isnull;
/* Get the old reloptions */ /* Get the old reloptions */
datum = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_reloptions, datum = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_reloptions,
&isnull); &isnull);
if (isnull)
datum = (Datum) 0;
} }
newOptions = transformRelOptions(isnull ? (Datum) 0 : datum, newOptions = transformRelOptions(datum, defList, "toast", validnsps,
defList, "toast", validnsps, false, false, operation == AT_ResetRelOptions);
operation == AT_ResetRelOptions);
(void) heap_reloptions(RELKIND_TOASTVALUE, newOptions, true); (void) heap_reloptions(RELKIND_TOASTVALUE, newOptions, true);