diff options
author | Noah Misch <noah@leadboat.com> | 2023-10-30 14:46:05 -0700 |
---|---|---|
committer | Noah Misch <noah@leadboat.com> | 2023-10-30 14:46:09 -0700 |
commit | 0a7b183fdc1bbd221acf88b03ee4b4cfd23e0abe (patch) | |
tree | 0ffb0be299d6cf07c3693d9b6021fbc78e1ee83a /contrib/pgstattuple/pgstattuple.c | |
parent | 42496cba60bc086f3fdba4b3d20426e27100fbfb (diff) |
Diagnose !indisvalid in more SQL functions.
pgstatindex failed with ERRCODE_DATA_CORRUPTED, of the "can't-happen"
class XX. The other functions succeeded on an empty index; they might
have malfunctioned if the failed index build left torn I/O or other
complex state. Report an ERROR in statistics functions pgstatindex,
pgstatginindex, pgstathashindex, and pgstattuple. Report DEBUG1 and
skip all index I/O in maintenance functions brin_desummarize_range,
brin_summarize_new_values, brin_summarize_range, and
gin_clean_pending_list. Back-patch to v11 (all supported versions).
Discussion: https://postgr.es/m/20231001195309.a3@google.com
Diffstat (limited to 'contrib/pgstattuple/pgstattuple.c')
-rw-r--r-- | contrib/pgstattuple/pgstattuple.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c index 21fdeff8afd..32ac4103ce6 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -260,6 +260,13 @@ pgstat_relation(Relation rel, FunctionCallInfo fcinfo) case RELKIND_SEQUENCE: return pgstat_heap(rel, fcinfo); case RELKIND_INDEX: + /* see pgstatindex_impl */ + if (!rel->rd_index->indisvalid) + ereport(ERROR, + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("index \"%s\" is not valid", + RelationGetRelationName(rel)))); + switch (rel->rd_rel->relam) { case BTREE_AM_OID: |