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

Commitc0b4dad

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 parent10f3087 commitc0b4dad

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
@@ -572,8 +572,10 @@ systable_beginscan_ordered(Relation heapRelation,
572572

573573
/* REINDEX can probably be a hard error here ... */
574574
if (ReindexIsProcessingIndex(RelationGetRelid(indexRelation)))
575-
elog(ERROR,"cannot do ordered scan on index \"%s\", because it is being reindexed",
576-
RelationGetRelationName(indexRelation));
575+
ereport(ERROR,
576+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
577+
errmsg("cannot access index \"%s\" while it is being reindexed",
578+
RelationGetRelationName(indexRelation))));
577579
/* ... but we only throw a warning about violating IgnoreSystemIndexes */
578580
if (IgnoreSystemIndexes)
579581
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
@@ -64,18 +64,23 @@
6464
* Note: the ReindexIsProcessingIndex() check in RELATION_CHECKS is there
6565
* to check that we don't try to scan or do retail insertions into an index
6666
* that is currently being rebuilt or pending rebuild. This helps to catch
67-
* things that don't work when reindexing system catalogs. The assertion
67+
* things that don't work when reindexing system catalogs, as well as prevent
68+
* user errors like index expressions that access their own tables. The check
6869
* doesn't prevent the actual rebuild because we don't use RELATION_CHECKS
6970
* when calling the index AM's ambuild routine, and there is no reason for
7071
* ambuild to call its subsidiary routines through this file.
7172
* ----------------------------------------------------------------
7273
*/
7374
#defineRELATION_CHECKS \
74-
( \
75-
AssertMacro(RelationIsValid(indexRelation)), \
76-
AssertMacro(PointerIsValid(indexRelation->rd_indam)), \
77-
AssertMacro(!ReindexIsProcessingIndex(RelationGetRelid(indexRelation))) \
78-
)
75+
do { \
76+
Assert(RelationIsValid(indexRelation)); \
77+
Assert(PointerIsValid(indexRelation->rd_indam)); \
78+
if (unlikely(ReindexIsProcessingIndex(RelationGetRelid(indexRelation)))) \
79+
ereport(ERROR, \
80+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), \
81+
errmsg("cannot access index \"%s\" while it is being reindexed", \
82+
RelationGetRelationName(indexRelation)))); \
83+
} while(0)
7984

8085
#defineSCAN_CHECKS \
8186
( \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp