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

Commit7acd35b

Browse files
Justin Pryzbyololobus
Justin Pryzby
authored andcommitted
Specially handle toast relations during REINDEX.
Is this fine ? It says "cannot reindex system catalogs concurrently" (once),and hits the pg_toast tables for information_schema. Should it skip toastindexes (like it said) ? Or should it REINDEX them on the same tablespace?template1=# REINDEX DATABASE CONCURRENTLY template1 TABLESPACE pg_default;2020-03-09 15:33:51.792 CDT [6464] WARNING: cannot reindex system catalogs concurrently, skipping allWARNING: cannot reindex system catalogs concurrently, skipping all2020-03-09 15:33:51.794 CDT [6464] WARNING: skipping tablespace change of "pg_toast_12558_index"2020-03-09 15:33:51.794 CDT [6464] DETAIL: Cannot move system relation, only REINDEX CONCURRENTLY is performed.WARNING: skipping tablespace change of "pg_toast_12558_index"DETAIL: Cannot move system relation, only REINDEX CONCURRENTLY is performed.2020-03-09 15:33:51.924 CDT [6464] WARNING: skipping tablespace change of "pg_toast_12543_index"2020-03-09 15:33:51.924 CDT [6464] DETAIL: Cannot move system relation, only REINDEX CONCURRENTLY is performed.WARNING: skipping tablespace change of "pg_toast_12543_index"DETAIL: Cannot move system relation, only REINDEX CONCURRENTLY is performed.2020-03-09 15:33:51.982 CDT [6464] WARNING: skipping tablespace change of "pg_toast_12548_index"2020-03-09 15:33:51.982 CDT [6464] DETAIL: Cannot move system relation, only REINDEX CONCURRENTLY is performed.WARNING: skipping tablespace change of "pg_toast_12548_index"DETAIL: Cannot move system relation, only REINDEX CONCURRENTLY is performed.2020-03-09 15:33:52.048 CDT [6464] WARNING: skipping tablespace change of "pg_toast_12553_index"2020-03-09 15:33:52.048 CDT [6464] DETAIL: Cannot move system relation, only REINDEX CONCURRENTLY is performed.WARNING: skipping tablespace change of "pg_toast_12553_index"DETAIL: Cannot move system relation, only REINDEX CONCURRENTLY is performed.REINDEX
1 parent507a6ed commit7acd35b

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

‎src/backend/catalog/index.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3474,11 +3474,23 @@ reindex_index(Oid indexId, Oid tablespaceOid, bool skip_constraint_checks,
34743474
RelationGetRelationName(iRel));
34753475

34763476
/*
3477-
*We don't support moving system relations into different tablespaces,
3478-
*unlessallow_system_table_mods=1.
3477+
*Skip tablespace change of all indexes on TOAST tables, unless
3478+
* allow_system_table_mods=1, but error out on system catalog.
34793479
*/
3480-
if (set_tablespace&&
3481-
!allowSystemTableMods&&IsSystemRelation(iRel))
3480+
if (set_tablespace&&IsToastRelation(iRel))
3481+
{
3482+
if (!allowSystemTableMods)
3483+
{
3484+
ereport(WARNING,
3485+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3486+
errmsg("skipping tablespace change of \"%s\"",
3487+
RelationGetRelationName(iRel)),
3488+
errdetail("Cannot move system relation, only REINDEX is performed.")));
3489+
set_tablespace= false;
3490+
}
3491+
}
3492+
elseif (set_tablespace&&
3493+
IsCatalogRelationOid(indexId)&& !allowSystemTableMods)
34823494
ereport(ERROR,
34833495
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
34843496
errmsg("permission denied: \"%s\" is a system catalog",

‎src/backend/commands/indexcmds.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,14 +3061,17 @@ ReindexRelationConcurrently(Oid relationOid, Oid tablespaceOid, int options)
30613061

30623062
/*
30633063
* We don't support moving system relations into different tablespaces,
3064-
* unless allow_system_table_mods=1.
3064+
* unless allow_system_table_mods=1. Reindexing concurrently is not
3065+
* allowed for system catalog, so we only check for indexes on
3066+
* TOAST tables here.
30653067
*/
3066-
if (OidIsValid(tablespaceOid)&&
3067-
!allowSystemTableMods&&IsSystemRelation(indexRel))
3068-
ereport(ERROR,
3069-
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3070-
errmsg("permission denied: \"%s\" is a system catalog",
3071-
RelationGetRelationName(indexRel))));
3068+
if (OidIsValid(tablespaceOid)
3069+
&&IsToastRelation(indexRel)&& !allowSystemTableMods)
3070+
ereport(WARNING,
3071+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3072+
errmsg("skipping tablespace change of \"%s\"",
3073+
RelationGetRelationName(indexRel)),
3074+
errdetail("Cannot move system relation, only REINDEX CONCURRENTLY is performed.")));
30723075

30733076
/*
30743077
* We cannot support moving mapped relations into different tablespaces.
@@ -3099,7 +3102,8 @@ ReindexRelationConcurrently(Oid relationOid, Oid tablespaceOid, int options)
30993102
/* Create new index definition based on given index */
31003103
newIndexId=index_concurrently_create_copy(heapRel,
31013104
indexId,
3102-
tablespaceOid,
3105+
IsToastRelation(indexRel)&& !allowSystemTableMods ?
3106+
InvalidOid :tablespaceOid,
31033107
concurrentName);
31043108

31053109
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp