summaryrefslogtreecommitdiff
path: root/src/backend/access/index/genam.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2024-02-25 16:15:07 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2024-02-25 16:15:07 -0500
commit940489b46769eb2d2997227053ab6ca76a2ac857 (patch)
treee70b070da17105a445ab2dda4a5344b4d1f1b09a /src/backend/access/index/genam.c
parentc3fdf13a53cee3488c07f2c8fe796c21949bc66b (diff)
Promote assertion about !ReindexIsProcessingIndex to runtime error.
When this assertion was installed (in commit d2f60a3ab), I thought it was only for catching server logic errors that caused accesses to catalogs that were undergoing index rebuilds. However, it will also fire in case of a user-defined index expression that attempts to access its own table. We occasionally see reports of people trying to do that, and typically getting unintelligible low-level errors as a result. We can provide a more on-point message by making this a regular runtime check. While at it, adjust the similar error check in systable_beginscan_ordered to use the same message text. That one is (probably) not reachable without a coding bug, but we might as well use a translatable message if we have one. Per bug #18363 from Alexander Lakhin. Back-patch to all supported branches. Discussion: https://postgr.es/m/18363-e3598a5a572d0699@postgresql.org
Diffstat (limited to 'src/backend/access/index/genam.c')
-rw-r--r--src/backend/access/index/genam.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c
index 98af5347b9f..95120c5b283 100644
--- a/src/backend/access/index/genam.c
+++ b/src/backend/access/index/genam.c
@@ -652,8 +652,10 @@ systable_beginscan_ordered(Relation heapRelation,
/* REINDEX can probably be a hard error here ... */
if (ReindexIsProcessingIndex(RelationGetRelid(indexRelation)))
- elog(ERROR, "cannot do ordered scan on index \"%s\", because it is being reindexed",
- RelationGetRelationName(indexRelation));
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot access index \"%s\" while it is being reindexed",
+ RelationGetRelationName(indexRelation))));
/* ... but we only throw a warning about violating IgnoreSystemIndexes */
if (IgnoreSystemIndexes)
elog(WARNING, "using index \"%s\" despite IgnoreSystemIndexes",