pgsql: Handle heap rewrites even better in logical decoding

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Handle heap rewrites even better in logical decoding
Date: 2018-03-21 13:19:23
Message-ID: E1eydeF-0006Lw-JT@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Handle heap rewrites even better in logical decoding

Logical decoding should not publish anything about tables created as
part of a heap rewrite during DDL. Those tables don't exist externally,
so consumers of logical decoding cannot do anything sensible with that
information. In ab28feae2bd3d4629bd73ae3548e671c57d785f0, we worked
around this for built-in logical replication, but that was hack.

This is a more proper fix: We mark such transient heaps using the new
field pg_class.relwrite, linking to the original relation OID. By
default, we ignore them in logical decoding before they get to the
output plugin. Optionally, a plugin can register their interest in
getting such changes, if they handle DDL specially, in which case the
new field will help them get information about the actual table.

Reviewed-by: Craig Ringer <craig(at)2ndquadrant(dot)com>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/325f2ec5557fd1c9156c910102522e04cb42d99c

Modified Files
--------------
.../test_decoding/expected/concurrent_ddl_dml.out | 82 ++++++++--------------
contrib/test_decoding/expected/ddl.out | 20 +++---
.../test_decoding/specs/concurrent_ddl_dml.spec | 2 +-
contrib/test_decoding/sql/ddl.sql | 5 +-
contrib/test_decoding/test_decoding.c | 14 ++++
doc/src/sgml/catalogs.sgml | 12 ++++
doc/src/sgml/logicaldecoding.sgml | 5 ++
src/backend/bootstrap/bootparse.y | 1 +
src/backend/catalog/heap.c | 4 ++
src/backend/catalog/toasting.c | 1 +
src/backend/commands/cluster.c | 1 +
src/backend/commands/tablecmds.c | 1 +
src/backend/replication/logical/logical.c | 4 ++
src/backend/replication/logical/reorderbuffer.c | 7 ++
src/backend/replication/pgoutput/pgoutput.c | 26 -------
src/include/catalog/catversion.h | 2 +-
src/include/catalog/heap.h | 1 +
src/include/catalog/pg_class.h | 22 +++---
src/include/replication/output_plugin.h | 1 +
src/include/replication/reorderbuffer.h | 5 ++
20 files changed, 113 insertions(+), 103 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tatsuo Ishii 2018-03-21 14:21:56 pgsql: Fix typo.
Previous Message Teodor Sigaev 2018-03-21 11:58:03 pgsql: Add strict_word_similarity to pg_trgm module