logical decoding output plugin

Started by Torsten Förtschover 9 years ago4 messagesgeneral
Jump to latest
#1Torsten Förtsch
tfoertsch123@gmail.com

Hi,

I am working on a logical decoding output plugin. I am only interested in
the changes in one particular table.

One way to check for the table would be to compare class_form->relname
and get_namespace_name(class_form->relnamespace). But I'd much prefer to
just compare the OID of the table.

Is there a cheap way to do something like "SELECT
'schema.table'::regclass::oid" that can be called in the startup callback?

Thanks,
Torsten

#2Andres Freund
andres@anarazel.de
In reply to: Torsten Förtsch (#1)
Re: logical decoding output plugin

Hi,

On 2016-12-10 22:34:02 +0100, Torsten F�rtsch wrote:

I am working on a logical decoding output plugin. I am only interested in
the changes in one particular table.

One way to check for the table would be to compare class_form->relname
and get_namespace_name(class_form->relnamespace). But I'd much prefer to
just compare the OID of the table.

Is there a cheap way to do something like "SELECT
'schema.table'::regclass::oid" that can be called in the startup callback?

You shouldn't do it in the startup callback (no catalog access there),
but you can do it the first time through the change callback.

For lookups the most complete lookup is to use RangeVarGetRelid() to get
the oid. There's other variants, but that's the easiest approach.

Do you have to care about the table being renamed?

Greetings,

Andres Freund

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Torsten Förtsch
tfoertsch123@gmail.com
In reply to: Andres Freund (#2)
Re: logical decoding output plugin

On Sun, Dec 11, 2016 at 12:10 AM, Andres Freund <andres@anarazel.de> wrote:

On 2016-12-10 22:34:02 +0100, Torsten Förtsch wrote:

I am working on a logical decoding output plugin. I am only interested in
the changes in one particular table.

One way to check for the table would be to compare class_form->relname
and get_namespace_name(class_form->relnamespace). But I'd much prefer to
just compare the OID of the table.

Is there a cheap way to do something like "SELECT
'schema.table'::regclass::oid" that can be called in the startup

callback?

You shouldn't do it in the startup callback (no catalog access there),
but you can do it the first time through the change callback.

For lookups the most complete lookup is to use RangeVarGetRelid() to get
the oid. There's other variants, but that's the easiest approach.

Do you have to care about the table being renamed?

Thanks, Andres. That would be nice to have but not really necessary, at
least not at the beginning. Is it possible to catch CREATE TABLE and ALTER
TABLE RENAME in 9.5?

Thanks,
Torsten

#4Michael Paquier
michael@paquier.xyz
In reply to: Torsten Förtsch (#3)
Re: logical decoding output plugin

On Sun, Dec 11, 2016 at 7:31 PM, Torsten Förtsch <tfoertsch123@gmail.com> wrote:

Is it possible to catch CREATE TABLE and ALTER TABLE RENAME in 9.5?

You are looking for pg_ddl_command via event triggers.
src/test/modules/test_ddl_deparse is one example of that in the code
tree.
--
Michael

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general