mirror of
https://github.com/postgres/postgres.git
synced 2025-06-22 02:52:08 +03:00
Improve some error messages with invalid indexes for REINDEX CONCURRENTLY
An invalid index is skipped when doing REINDEX CONCURRENTLY at table level, with INDEX_CORRUPTED used as errcode. This is confusing, because an invalid index could exist after an interruption. The errcode is switched to OBJECT_NOT_IN_PREREQUISITE_STATE instead, as per a suggestion from Andres Freund. While on it, the error messages are reworded, and a hint is added, telling how to rebuild an invalid index in this case. This has been suggested by Noah Misch. Discussion: https://postgr.es/m/20231118230958.4fm3fhk4ypshxopa@awork3.anarazel.de
This commit is contained in:
@ -3526,10 +3526,11 @@ ReindexRelationConcurrently(const ReindexStmt *stmt, Oid relationOid, const Rein
|
||||
|
||||
if (!indexRelation->rd_index->indisvalid)
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot reindex invalid index \"%s.%s\" concurrently, skipping",
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("skipping reindex of invalid index \"%s.%s\"",
|
||||
get_namespace_name(get_rel_namespace(cellOid)),
|
||||
get_rel_name(cellOid))));
|
||||
get_rel_name(cellOid)),
|
||||
errhint("Use DROP INDEX or REINDEX INDEX.")));
|
||||
else if (indexRelation->rd_index->indisexclusion)
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
@ -3578,10 +3579,11 @@ ReindexRelationConcurrently(const ReindexStmt *stmt, Oid relationOid, const Rein
|
||||
|
||||
if (!indexRelation->rd_index->indisvalid)
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_INDEX_CORRUPTED),
|
||||
errmsg("cannot reindex invalid index \"%s.%s\" concurrently, skipping",
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("skipping reindex of invalid index \"%s.%s\"",
|
||||
get_namespace_name(get_rel_namespace(cellOid)),
|
||||
get_rel_name(cellOid))));
|
||||
get_rel_name(cellOid)),
|
||||
errhint("Use DROP INDEX or REINDEX INDEX.")));
|
||||
else
|
||||
{
|
||||
ReindexIndexInfo *idx;
|
||||
|
Reference in New Issue
Block a user