error messages in extended statistics - Mailing list pgsql-hackers

From Alvaro Herrera
Subject error messages in extended statistics
Date
Msg-id 20190503154404.GA7478@alvherre.pgsql
Whole thread Raw
Responses Re: error messages in extended statistics  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hello

Error reporting in extended statistics is inconsistent -- many messages
that are ereport() in mvdistinct.c are elog() in the other modules.  I
think what happened is that I changed them from elog to ereport when
committing mvdistinct, but Tomas and Simon didn't follow suit when
committing the other two modules.  As a result, some messages that
should be essentially duplicates only show up once, because the elog()
ones are not marked translatable.

I think this should be cleaned up, while at the same time not giving too
much hassle for translators; for example, this message

dependencies.c:     elog(ERROR, "invalid MVDependencies size %zd (expected at least %zd)",

should not only be turned into an ereport(), but also the MVDependencies
part turned into a %s.  (Alternatively, we could decide I was wrong and
turn them all back into elogs, but I obviously vote against that.)

$ git grep 'elog\|errmsg' src/backend/statistics

dependencies.c:         elog(ERROR, "cache lookup failed for ordering operator for type %u",
dependencies.c:     elog(ERROR, "invalid MVDependencies size %zd (expected at least %zd)",
dependencies.c:     elog(ERROR, "invalid dependency magic %d (expected %d)",
dependencies.c:     elog(ERROR, "invalid dependency type %d (expected %d)",
dependencies.c:              errmsg("invalid zero-length item array in MVDependencies")));
dependencies.c:     elog(ERROR, "invalid dependencies size %zd (expected at least %zd)",
dependencies.c:     elog(ERROR, "cache lookup failed for statistics object %u", mvoid);
dependencies.c:     elog(ERROR,
dependencies.c:          errmsg("cannot accept a value of type %s", "pg_dependencies")));
dependencies.c:          errmsg("cannot accept a value of type %s", "pg_dependencies")));
extended_stats.c:                        errmsg("statistics object \"%s.%s\" could not be computed for relation
\"%s.%s\"",
extended_stats.c:           elog(ERROR, "unexpected statistics type requested: %d", type);
extended_stats.c:           elog(ERROR, "stxkind is not a 1-D char array");
extended_stats.c:       elog(ERROR, "cache lookup failed for statistics object %u", statOid);
mcv.c:          elog(ERROR, "cache lookup failed for ordering operator for type %u",
mcv.c:      elog(ERROR, "cache lookup failed for statistics object %u", mvoid);
mcv.c:      elog(ERROR,
mcv.c:      elog(ERROR, "invalid MCV size %zd (expected at least %zu)",
mcv.c:      elog(ERROR, "invalid MCV magic %u (expected %u)",
mcv.c:      elog(ERROR, "invalid MCV type %u (expected %u)",
mcv.c:      elog(ERROR, "invalid zero-length dimension array in MCVList");
mcv.c:      elog(ERROR, "invalid length (%d) dimension array in MCVList",
mcv.c:      elog(ERROR, "invalid zero-length item array in MCVList");
mcv.c:      elog(ERROR, "invalid length (%u) item array in MCVList",
mcv.c:      elog(ERROR, "invalid MCV size %zd (expected %zu)",
mcv.c:      elog(ERROR, "invalid MCV size %zd (expected %zu)",
mcv.c:                   errmsg("function returning record called in context "
mcv.c:           errmsg("cannot accept a value of type %s", "pg_mcv_list")));
mcv.c:           errmsg("cannot accept a value of type %s", "pg_mcv_list")));
mcv.c:          elog(ERROR, "unknown clause type: %d", clause->type);
mvdistinct.c:       elog(ERROR, "cache lookup failed for statistics object %u", mvoid);
mvdistinct.c:       elog(ERROR,
mvdistinct.c:       elog(ERROR, "invalid MVNDistinct size %zd (expected at least %zd)",
mvdistinct.c:                errmsg("invalid ndistinct magic %08x (expected %08x)",
mvdistinct.c:                errmsg("invalid ndistinct type %d (expected %d)",
mvdistinct.c:                errmsg("invalid zero-length item array in MVNDistinct")));
mvdistinct.c:                errmsg("invalid MVNDistinct size %zd (expected at least %zd)",
mvdistinct.c:            errmsg("cannot accept a value of type %s", "pg_ndistinct")));
mvdistinct.c:            errmsg("cannot accept a value of type %s", "pg_ndistinct")));
mvdistinct.c:           elog(ERROR, "cache lookup failed for ordering operator for type %u",

-- 
Álvaro Herrera                         Developer, https://www.PostgreSQL.org/



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Heap lock levels for REINDEX INDEX CONCURRENTLY not quite right?
Next
From: Tom Lane
Date:
Subject: Re: error messages in extended statistics