]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix missing initialization in pg_restore_extended_stats()
authorMichael Paquier <michael@paquier.xyz>
Mon, 26 Jan 2026 07:13:41 +0000 (16:13 +0900)
committerMichael Paquier <michael@paquier.xyz>
Mon, 26 Jan 2026 07:13:41 +0000 (16:13 +0900)
The tuple data upserted into pg_statistic_ext_data was missing an
initialization for the nulls flag of stxoid and stxdinherit.  This would
cause an incorrect handling of the stats data restored.

This issue has been spotted by CatalogTupleCheckConstraints(),
translating to a NOT NULL constraint inconsistency, while playing more
with the follow-up portions of the patch set.

Oversight in 0e80f3f88dea (mea culpa).  Surprisingly, the buildfarm did
not complain yet.

Discussion: https://postgr.es/m/CADkLM=c7DY3Jv6ef0n_MGUJ1FyTMUoT697LbkST05nraVGNHYg@mail.gmail.com

src/backend/statistics/extended_stats_funcs.c

index 269fdabdfc0ea029ee98102ccd7828836ad44609..48fa2efee76fc9e0b468df42e7f23b7ac6491562 100644 (file)
@@ -243,7 +243,7 @@ extended_statistics_update(FunctionCallInfo fcinfo)
        Form_pg_statistic_ext stxform;
 
        Datum           values[Natts_pg_statistic_ext_data] = {0};
-       bool            nulls[Natts_pg_statistic_ext_data];
+       bool            nulls[Natts_pg_statistic_ext_data] = {0};
        bool            replaces[Natts_pg_statistic_ext_data] = {0};
        bool            success = true;
        int                     numexprs = 0;
@@ -361,7 +361,9 @@ extended_statistics_update(FunctionCallInfo fcinfo)
 
        /* Primary Key: cannot be NULL or replaced. */
        values[Anum_pg_statistic_ext_data_stxoid - 1] = ObjectIdGetDatum(stxform->oid);
+       nulls[Anum_pg_statistic_ext_data_stxoid - 1] = false;
        values[Anum_pg_statistic_ext_data_stxdinherit - 1] = BoolGetDatum(inherited);
+       nulls[Anum_pg_statistic_ext_data_stxdinherit - 1] = false;
 
        /* All unspecified parameters will be left unmodified */
        nulls[Anum_pg_statistic_ext_data_stxdndistinct - 1] = true;