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

Commit66abc26

Browse files
committed
Add a new reloption, user_catalog_table.
When this reloption is set and wal_level=logical is configured,we'll record the CIDs stamped by inserts, updates, and deletes tothe table just as we would for an actual catalog table. This willallow logical decoding to use historical MVCC snapshots to accesssuch tables just as they access ordinary catalog tables.Replication solutions built around the logical decoding machinerywill likely need to set this operation for their configurationtables; it might also be needed by extensions which perform tableaccess in their output functions.Andres Freund, reviewed by myself and others.
1 parente55704d commit66abc26

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

‎src/backend/access/common/reloptions.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ static relopt_bool boolRelOpts[] =
6161
},
6262
true
6363
},
64+
{
65+
{
66+
"user_catalog_table",
67+
"Declare a table as an additional catalog table, e.g. for the purpose of logical replication",
68+
RELOPT_KIND_HEAP
69+
},
70+
false
71+
},
6472
{
6573
{
6674
"fastupdate",
@@ -1166,6 +1174,8 @@ default_reloptions(Datum reloptions, bool validate, relopt_kind kind)
11661174
offsetof(StdRdOptions,security_barrier)},
11671175
{"check_option",RELOPT_TYPE_STRING,
11681176
offsetof(StdRdOptions,check_option_offset)},
1177+
{"user_catalog_table",RELOPT_TYPE_BOOL,
1178+
offsetof(StdRdOptions,user_catalog_table)}
11691179
};
11701180

11711181
options=parseRelOptions(reloptions,validate,kind,&numoptions);

‎src/backend/commands/tablecmds.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3532,6 +3532,12 @@ ATRewriteTables(List **wqueue, LOCKMODE lockmode)
35323532
errmsg("cannot rewrite system relation \"%s\"",
35333533
RelationGetRelationName(OldHeap))));
35343534

3535+
if (RelationIsUsedAsCatalogTable(OldHeap))
3536+
ereport(ERROR,
3537+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3538+
errmsg("cannot rewrite table \"%s\" used as a catalog table",
3539+
RelationGetRelationName(OldHeap))));
3540+
35353541
/*
35363542
* Don't allow rewrite on temp tables of other backends ... their
35373543
* local buffer manager is not going to cope.

‎src/include/utils/rel.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ typedef struct StdRdOptions
217217
AutoVacOptsautovacuum;/* autovacuum-related options */
218218
boolsecurity_barrier;/* for views */
219219
intcheck_option_offset;/* for views */
220+
booluser_catalog_table;/* use as an additional catalog relation */
220221
}StdRdOptions;
221222

222223
#defineHEAP_MIN_FILLFACTOR10
@@ -285,6 +286,15 @@ typedef struct StdRdOptions
285286
((StdRdOptions *) (relation)->rd_options)->check_option_offset,\
286287
"cascaded") == 0 : false)
287288

289+
/*
290+
* RelationIsUsedAsCatalogTable
291+
*Returns whether the relation should be treated as a catalog table
292+
* from the pov of logical decoding.
293+
*/
294+
#defineRelationIsUsedAsCatalogTable(relation)\
295+
((relation)->rd_options ?\
296+
((StdRdOptions *) (relation)->rd_options)->user_catalog_table : false)
297+
288298
/*
289299
* RelationIsValid
290300
*True iff relation descriptor is valid.
@@ -462,7 +472,7 @@ typedef struct StdRdOptions
462472
#defineRelationIsAccessibleInLogicalDecoding(relation) \
463473
(XLogLogicalInfoActive() && \
464474
RelationNeedsWAL(relation) && \
465-
IsCatalogRelation(relation))
475+
(IsCatalogRelation(relation) || RelationIsUsedAsCatalogTable(relation)))
466476

467477
/*
468478
* RelationIsLogicallyLogged
@@ -471,7 +481,9 @@ typedef struct StdRdOptions
471481
*
472482
* We don't log information for unlogged tables (since they don't WAL log
473483
* anyway) and for system tables (their content is hard to make sense of, and
474-
* it would complicate decoding slightly for little gain).
484+
* it would complicate decoding slightly for little gain). Note that we *do*
485+
* log information for user defined catalog tables since they presumably are
486+
* interesting to the user...
475487
*/
476488
#defineRelationIsLogicallyLogged(relation) \
477489
(XLogLogicalInfoActive() && \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp