Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf5a465f

Browse files
committed
Promote assertion about !ReindexIsProcessingIndex to runtime error.
When this assertion was installed (in commitd2f60a3), I thoughtit was only for catching server logic errors that caused accesses tocatalogs that were undergoing index rebuilds. However, it will alsofire in case of a user-defined index expression that attempts toaccess its own table. We occasionally see reports of people tryingto do that, and typically getting unintelligible low-level errorsas a result. We can provide a more on-point message by making thisa regular runtime check.While at it, adjust the similar error check insystable_beginscan_ordered to use the same message text. That oneis (probably) not reachable without a coding bug, but we might aswell use a translatable message if we have one.Per bug #18363 from Alexander Lakhin. Back-patch to all supportedbranches.Discussion:https://postgr.es/m/18363-e3598a5a572d0699@postgresql.org
1 parent57b28c0 commitf5a465f

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

‎src/backend/access/index/genam.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,10 @@ systable_beginscan_ordered(Relation heapRelation,
653653

654654
/* REINDEX can probably be a hard error here ... */
655655
if (ReindexIsProcessingIndex(RelationGetRelid(indexRelation)))
656-
elog(ERROR,"cannot do ordered scan on index \"%s\", because it is being reindexed",
657-
RelationGetRelationName(indexRelation));
656+
ereport(ERROR,
657+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
658+
errmsg("cannot access index \"%s\" while it is being reindexed",
659+
RelationGetRelationName(indexRelation))));
658660
/* ... but we only throw a warning about violating IgnoreSystemIndexes */
659661
if (IgnoreSystemIndexes)
660662
elog(WARNING,"using index \"%s\" despite IgnoreSystemIndexes",

‎src/backend/access/index/indexam.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,23 @@
7070
* Note: the ReindexIsProcessingIndex() check in RELATION_CHECKS is there
7171
* to check that we don't try to scan or do retail insertions into an index
7272
* that is currently being rebuilt or pending rebuild. This helps to catch
73-
* things that don't work when reindexing system catalogs. The assertion
73+
* things that don't work when reindexing system catalogs, as well as prevent
74+
* user errors like index expressions that access their own tables. The check
7475
* doesn't prevent the actual rebuild because we don't use RELATION_CHECKS
7576
* when calling the index AM's ambuild routine, and there is no reason for
7677
* ambuild to call its subsidiary routines through this file.
7778
* ----------------------------------------------------------------
7879
*/
7980
#defineRELATION_CHECKS \
80-
( \
81-
AssertMacro(RelationIsValid(indexRelation)), \
82-
AssertMacro(PointerIsValid(indexRelation->rd_indam)), \
83-
AssertMacro(!ReindexIsProcessingIndex(RelationGetRelid(indexRelation))) \
84-
)
81+
do { \
82+
Assert(RelationIsValid(indexRelation)); \
83+
Assert(PointerIsValid(indexRelation->rd_indam)); \
84+
if (unlikely(ReindexIsProcessingIndex(RelationGetRelid(indexRelation)))) \
85+
ereport(ERROR, \
86+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), \
87+
errmsg("cannot access index \"%s\" while it is being reindexed", \
88+
RelationGetRelationName(indexRelation)))); \
89+
} while(0)
8590

8691
#defineSCAN_CHECKS \
8792
( \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp