pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Logical Replication - Type messages?
2+ messages / 2 participants
[nested] [flat]

Commits from this thread:
  2021-11-10 886801df4a f4ab856e5d fcfb40dcc1 78f058411b 74da4c71d6 c3b33698cf  Doc: improve protocol spec for logical replication Type messages.
* Logical Replication - Type messages?
@ 2021-11-08 19:16 Stefen Hillman <stefen.hillman@fivetran.com>
  2021-11-10 16:48 ` Re: Logical Replication - Type messages? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Stefen Hillman @ 2021-11-08 19:16 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hello psql-general,


I have an application which processes logical replication output from a
PostgreSQL server. We create publications and read data from a replication
slot with the pgoutput plugin.

Postgres has various message formats for logical replication, as defined
here:
https://www.postgresql.org/docs/10/protocol-logicalrep-message-formats.html

Currently, I process Relation messages to get most of the information I
need to work with Inserts, Updates, and Deletes. However, for type
information I'm currently using a SQL query to get the column type
information. I wanted to use the Type messages, but I never see them. I see
Begin, Commit, etc. but never Type.

   - When are the Type messages generated and sent by the server?
   - Is there a way to cause them to be generated?
   - Are these type id > type mappings set in stone, or does PostgreSQL
   allow for a server to have custom types (I notice that namespace is one of
   the properties sent with the types)?

Any help is greatly appreciated - thank you!


Best regards,


Stefen Hillman

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Logical Replication - Type messages?
  2021-11-08 19:16 Logical Replication - Type messages? Stefen Hillman <stefen.hillman@fivetran.com>
@ 2021-11-10 16:48 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2021-11-10 16:48 UTC (permalink / raw)
  To: Stefen Hillman <stefen.hillman@fivetran.com>; +Cc: pgsql-general@lists.postgresql.org

Stefen Hillman <stefen.hillman@fivetran.com> writes:
> Currently, I process Relation messages to get most of the information I
> need to work with Inserts, Updates, and Deletes. However, for type
> information I'm currently using a SQL query to get the column type
> information. I wanted to use the Type messages, but I never see them. I see
> Begin, Commit, etc. but never Type.

>    - When are the Type messages generated and sent by the server?
>    - Is there a way to cause them to be generated?

Hmm.  AFAICS the Type messages are completely undocumented in
protocol.sgml, which is an oversight.  Looking at the code, they
do exist, but they are sent only when a Relation message refers
to a non-built-in type.  There's a presumption that built-in
types have stable OIDs that will be the same at publisher and
subscriber, so the replication traffic needn't tell the subscriber
what those OIDs mean.  Non-built-in types don't have stable OIDs,
so we want to tell the subscriber what those OIDs mean.

(Actually, it looks like the cutoff is FirstGenbkiObjectId, which
means that the Type message is only suppressed for hand-assigned
type OIDs, an even stricter rule than "built in".  So for testing
purposes you could try something like an array type; replicating
a table with an array column should give rise to Type messages.)

>    - Are these type id > type mappings set in stone, or does PostgreSQL
>    allow for a server to have custom types (I notice that namespace is one of
>    the properties sent with the types)?

Some would say that custom types are THE defining feature of
Postgres, compared to other SQL implementations.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2021-11-10 16:48 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-11-08 19:16 Logical Replication - Type messages? Stefen Hillman <stefen.hillman@fivetran.com>
2021-11-10 16:48 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox