Thread: Logical decoding output plug-in questions
I'm having a great time playing with logical decoding, and had a couple of parameter questions: * OutputPluginPrepareWrite, OutputPluginWrite -- last_write. This is false if you are planning to do another OutputPluginPrepareWrite/OutputPluginWritepair in the same invocation of the same callback function, yes? * On an UPDATE, it appears that data.tp.oldtuple is only not-NULL if a primary key field changed, and then it only includesprimary key fields (the rest being NULL). Correct? * pg_decode_startup -- is_init. What's the situation under which this is true or false? Thanks! -- -- Christophe Pettus xof@thebuild.com
On 2015-01-26 13:00:29 -0800, Christophe Pettus wrote: > * OutputPluginPrepareWrite, OutputPluginWrite -- last_write. This is false if you are planning to do another OutputPluginPrepareWrite/OutputPluginWritepair in the same invocation of the same callback function, yes? Yes. Important so the other side gets an appropriate LSN of the record you're essentially sending feedback for. That's primarily important for sync rep, but also also > * On an UPDATE, it appears that data.tp.oldtuple is only not-NULL if a > primary key field changed, and then it only includes primary key > fields (the rest being NULL). Correct? What's in the old tuple depends on the configured replica identity. > * pg_decode_startup -- is_init. What's the situation under which this is true or false? That's actually documented: The <literal>is_init</literal> parameter will be true when the replication slot is being created and false otherwise. <parameter>options</parameter> points to a struct of options that output plugins can set: Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
Thank you! On Jan 26, 2015, at 2:24 PM, Andres Freund <andres@2ndquadrant.com> wrote: > What's in the old tuple depends on the configured replica identity. My apologies, but... "configured replica identity"? > The <literal>is_init</literal> parameter will be true when the > replication slot is being created [...] Thanks! I suppose my question then is: Besides slot creation, when is pg_decode_startup called? -- -- Christophe Pettus xof@thebuild.com
On 2015-01-26 15:35:39 -0800, Christophe Pettus wrote: > On Jan 26, 2015, at 2:24 PM, Andres Freund <andres@2ndquadrant.com> wrote: > > > What's in the old tuple depends on the configured replica identity. > > My apologies, but... "configured replica identity"? Search for "postgres" and "replica identity". > > The <literal>is_init</literal> parameter will be true when the > > replication slot is being created [...] > > Thanks! I suppose my question then is: Besides slot creation, when is pg_decode_startup called? Whenever changes from a slot are starting to be consumed. I.e. when you call one of the SQL functions pg_logical_slot_*_changes or when the walsender receives a START_LOGICAL_REPLICATION. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services