Skip to content

Commit 3b50503

Browse files
committed
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
1 parent e3bf3c0 commit 3b50503

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/backend/replication/logical/relation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ logicalrep_typmap_gettypname(Oid remoteid)
424424
bool found;
425425

426426
/* Internal types are mapped directly. */
427-
if (remoteid < FirstNormalObjectId)
427+
if (remoteid < FirstBootstrapObjectId)
428428
{
429429
if (!get_typisdefined(remoteid))
430430
{

src/backend/replication/pgoutput/pgoutput.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,12 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
302302
desc = RelationGetDescr(relation);
303303

304304
/*
305-
* Write out type info if needed. We do that only for user created
306-
* types.
305+
* Write out type info if needed. We do that only for user-created
306+
* types. We use FirstBootstrapObjectId as the cutoff, so that we only
307+
* consider objects with hand-assigned OIDs to be "built in", not for
308+
* instance any function or type defined in the information_schema.
309+
* This is important because only hand-assigned OIDs can be expected
310+
* to remain stable across major versions.
307311
*/
308312
for (i = 0; i < desc->natts; i++)
309313
{
@@ -312,7 +316,7 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
312316
if (att->attisdropped)
313317
continue;
314318

315-
if (att->atttypid < FirstNormalObjectId)
319+
if (att->atttypid < FirstBootstrapObjectId)
316320
continue;
317321

318322
OutputPluginPrepareWrite(ctx, false);

0 commit comments

Comments
 (0)