},
true
},
+ {
+ {
+ "user_catalog_table",
+ "Declare a table as an additional catalog table, e.g. for the purpose of logical replication",
+ RELOPT_KIND_HEAP
+ },
+ false
+ },
{
{
"fastupdate",
offsetof(StdRdOptions, security_barrier)},
{"check_option", RELOPT_TYPE_STRING,
offsetof(StdRdOptions, check_option_offset)},
+ {"user_catalog_table", RELOPT_TYPE_BOOL,
+ offsetof(StdRdOptions, user_catalog_table)}
};
options = parseRelOptions(reloptions, validate, kind, &numoptions);
errmsg("cannot rewrite system relation \"%s\"",
RelationGetRelationName(OldHeap))));
+ if (RelationIsUsedAsCatalogTable(OldHeap))
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot rewrite table \"%s\" used as a catalog table",
+ RelationGetRelationName(OldHeap))));
+
/*
* Don't allow rewrite on temp tables of other backends ... their
* local buffer manager is not going to cope.
AutoVacOpts autovacuum; /* autovacuum-related options */
bool security_barrier; /* for views */
int check_option_offset; /* for views */
+ bool user_catalog_table; /* use as an additional catalog relation */
} StdRdOptions;
#define HEAP_MIN_FILLFACTOR 10
((StdRdOptions *) (relation)->rd_options)->check_option_offset, \
"cascaded") == 0 : false)
+/*
+ * RelationIsUsedAsCatalogTable
+ * Returns whether the relation should be treated as a catalog table
+ * from the pov of logical decoding.
+ */
+#define RelationIsUsedAsCatalogTable(relation) \
+ ((relation)->rd_options ? \
+ ((StdRdOptions *) (relation)->rd_options)->user_catalog_table : false)
+
/*
* RelationIsValid
* True iff relation descriptor is valid.
#define RelationIsAccessibleInLogicalDecoding(relation) \
(XLogLogicalInfoActive() && \
RelationNeedsWAL(relation) && \
- IsCatalogRelation(relation))
+ (IsCatalogRelation(relation) || RelationIsUsedAsCatalogTable(relation)))
/*
* RelationIsLogicallyLogged
*
* We don't log information for unlogged tables (since they don't WAL log
* anyway) and for system tables (their content is hard to make sense of, and
- * it would complicate decoding slightly for little gain).
+ * it would complicate decoding slightly for little gain). Note that we *do*
+ * log information for user defined catalog tables since they presumably are
+ * interesting to the user...
*/
#define RelationIsLogicallyLogged(relation) \
(XLogLogicalInfoActive() && \