summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Vondra2019-05-30 14:16:12 +0000
committerTomas Vondra2019-05-30 15:03:36 +0000
commitfe415ff10408a1487d5773b47459306476ec58f0 (patch)
tree9b4d712deb836d52e9c7f3dbd33655d835c60392
parent56b78626c7288fad498c0fae7fe4fd1f240ed13f (diff)
Make error logging in extended statistics more consistent
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/[email protected]
-rw-r--r--src/backend/statistics/dependencies.c4
-rw-r--r--src/backend/statistics/mvdistinct.c22
2 files changed, 8 insertions, 18 deletions
diff --git a/src/backend/statistics/dependencies.c b/src/backend/statistics/dependencies.c
index 591bc16e57..cd318faf3b 100644
--- a/src/backend/statistics/dependencies.c
+++ b/src/backend/statistics/dependencies.c
@@ -534,9 +534,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 = SizeOfItem(dependencies->ndeps);
diff --git a/src/backend/statistics/mvdistinct.c b/src/backend/statistics/mvdistinct.c
index b1a426265b..7432a6a396 100644
--- a/src/backend/statistics/mvdistinct.c
+++ b/src/backend/statistics/mvdistinct.c
@@ -274,27 +274,19 @@ 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 = MinSizeOfItems(ndist.nitems);
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