]> granicus.if.org Git - postgresql/commitdiff
Make error logging in extended statistics more consistent
authorTomas Vondra <tomas.vondra@postgresql.org>
Thu, 30 May 2019 14:16:12 +0000 (16:16 +0200)
committerTomas Vondra <tomas.vondra@postgresql.org>
Thu, 30 May 2019 15:06:21 +0000 (17:06 +0200)
Most errors reported in extended statistics are internal issues, and so
should use elog(). The MCV list code was already following this rule, but
the functional dependencies and ndistinct coefficients were using a mix
of elog() and ereport(). Fix this by changing most places to elog(), with
the exception of input functions.

This is a mostly cosmetic change, it makes the life a little bit easier
for translators, as elog() messages are not translated. So backpatch to
PostgreSQL 10, where extended statistics were introduced.

Author: Tomas Vondra
Backpatch-through: 10 where extended statistics were added
Discussion: https://postgr.es/m/20190503154404.GA7478@alvherre.pgsql

src/backend/statistics/dependencies.c
src/backend/statistics/mvdistinct.c

index 140783cfb3a9451e8d8578186490a6fdee4f208d..1a41d2d96974b970206f38716006163ccf0981dd 100644 (file)
@@ -529,9 +529,7 @@ statext_dependencies_deserialize(bytea *data)
                         dependencies->type, STATS_DEPS_TYPE_BASIC);
 
        if (dependencies->ndeps == 0)
-               ereport(ERROR,
-                               (errcode(ERRCODE_DATA_CORRUPTED),
-                                errmsg("invalid zero-length item array in MVDependencies")));
+               elog(ERROR, "invalid zero-length item array in MVDependencies");
 
        /* what minimum bytea size do we expect for those parameters */
        min_expected_size = SizeOfDependencies +
index 593c21983960501f8a1b93fbd97b76dd55f9a91a..f8dba74cbd3dd64a29aaef13b737d6e045a288a0 100644 (file)
@@ -257,29 +257,21 @@ statext_ndistinct_deserialize(bytea *data)
        tmp += sizeof(uint32);
 
        if (ndist.magic != STATS_NDISTINCT_MAGIC)
-               ereport(ERROR,
-                               (errcode(ERRCODE_DATA_CORRUPTED),
-                                errmsg("invalid ndistinct magic %08x (expected %08x)",
-                                               ndist.magic, STATS_NDISTINCT_MAGIC)));
+               elog(ERROR, "invalid ndistinct magic %08x (expected %08x)",
+                        ndist.magic, STATS_NDISTINCT_MAGIC);
        if (ndist.type != STATS_NDISTINCT_TYPE_BASIC)
-               ereport(ERROR,
-                               (errcode(ERRCODE_DATA_CORRUPTED),
-                                errmsg("invalid ndistinct type %d (expected %d)",
-                                               ndist.type, STATS_NDISTINCT_TYPE_BASIC)));
+               elog(ERROR, "invalid ndistinct type %d (expected %d)",
+                        ndist.type, STATS_NDISTINCT_TYPE_BASIC);
        if (ndist.nitems == 0)
-               ereport(ERROR,
-                               (errcode(ERRCODE_DATA_CORRUPTED),
-                                errmsg("invalid zero-length item array in MVNDistinct")));
+               elog(ERROR, "invalid zero-length item array in MVNDistinct");
 
        /* what minimum bytea size do we expect for those parameters */
        minimum_size = (SizeOfMVNDistinct +
                                        ndist.nitems * (SizeOfMVNDistinctItem +
                                                                        sizeof(AttrNumber) * 2));
        if (VARSIZE_ANY_EXHDR(data) < minimum_size)
-               ereport(ERROR,
-                               (errcode(ERRCODE_DATA_CORRUPTED),
-                                errmsg("invalid MVNDistinct size %zd (expected at least %zd)",
-                                               VARSIZE_ANY_EXHDR(data), minimum_size)));
+               elog(ERROR, "invalid MVNDistinct size %zd (expected at least %zd)",
+                        VARSIZE_ANY_EXHDR(data), minimum_size);
 
        /*
         * Allocate space for the ndistinct items (no space for each item's