aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-05-13 17:23:00 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-05-13 17:23:00 -0400
commitb6abc2241ac4549623d6894d7855765df6345ad5 (patch)
tree7b1df97a3af9f55f83ceb8a91f5a7a109f2ee935
parentbf78f50bae0b3b5ffcbf3e3c5b03fd138be15f9a (diff)
downloadpostgresql-b6abc2241ac4549623d6894d7855765df6345ad5.tar.gz
postgresql-b6abc2241ac4549623d6894d7855765df6345ad5.zip
Fix logical replication's ideas about which type OIDs are built-in.
Only hand-assigned type OIDs should be presumed to match across different PG servers; those assigned during genbki.pl or during initdb are likely to change due to addition or removal of unrelated objects. This means that the cutoff should be FirstGenbkiObjectId (in HEAD) or FirstBootstrapObjectId (before that), not FirstNormalObjectId. Compare postgres_fdw's is_builtin() test. It's likely that this error has no observable consequence in a normally-functioning system, since ATM the only affected type OIDs are system catalog rowtypes and information_schema types, which would not typically be interesting for logical replication. But you could probably break it if you tried hard, so back-patch. Discussion: https://postgr.es/m/15150.1557257111@sss.pgh.pa.us
-rw-r--r--src/backend/replication/logical/relation.c2
-rw-r--r--src/backend/replication/pgoutput/pgoutput.c10
2 files changed, 8 insertions, 4 deletions
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c
index 1f20df5680e..905ca12fd80 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -425,7 +425,7 @@ logicalrep_typmap_gettypname(Oid remoteid)
bool found;
/* Internal types are mapped directly. */
- if (remoteid < FirstNormalObjectId)
+ if (remoteid < FirstBootstrapObjectId)
{
if (!get_typisdefined(remoteid))
{
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c
index 86e0951a700..dc07420fa10 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -269,8 +269,12 @@ maybe_send_schema(LogicalDecodingContext *ctx,
desc = RelationGetDescr(relation);
/*
- * Write out type info if needed. We do that only for user created
- * types.
+ * Write out type info if needed. We do that only for user-created
+ * types. We use FirstBootstrapObjectId as the cutoff, so that we only
+ * consider objects with hand-assigned OIDs to be "built in", not for
+ * instance any function or type defined in the information_schema.
+ * This is important because only hand-assigned OIDs can be expected
+ * to remain stable across major versions.
*/
for (i = 0; i < desc->natts; i++)
{
@@ -279,7 +283,7 @@ maybe_send_schema(LogicalDecodingContext *ctx,
if (att->attisdropped)
continue;
- if (att->atttypid < FirstNormalObjectId)
+ if (att->atttypid < FirstBootstrapObjectId)
continue;
OutputPluginPrepareWrite(ctx, false);