diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2018-03-21 09:13:24 -0400 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2018-03-21 09:15:04 -0400 |
commit | 325f2ec5557fd1c9156c910102522e04cb42d99c (patch) | |
tree | d41044a9ebc9beec2809fe61289467b107802c25 /src/include | |
parent | be8a7a6866276b228b4ffaa3003e1dc2dd1d140a (diff) | |
download | postgresql-325f2ec5557fd1c9156c910102522e04cb42d99c.tar.gz postgresql-325f2ec5557fd1c9156c910102522e04cb42d99c.zip |
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@2ndquadrant.com>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/catalog/catversion.h | 2 | ||||
-rw-r--r-- | src/include/catalog/heap.h | 1 | ||||
-rw-r--r-- | src/include/catalog/pg_class.h | 22 | ||||
-rw-r--r-- | src/include/replication/output_plugin.h | 1 | ||||
-rw-r--r-- | src/include/replication/reorderbuffer.h | 5 |
5 files changed, 20 insertions, 11 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 96d3406abe0..3a3593be8dc 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 201803141 +#define CATALOG_VERSION_NO 201803211 #endif diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h index 9bdc63ceb5a..3308fa3dfd5 100644 --- a/src/include/catalog/heap.h +++ b/src/include/catalog/heap.h @@ -71,6 +71,7 @@ extern Oid heap_create_with_catalog(const char *relname, bool use_user_acl, bool allow_system_table_mods, bool is_internal, + Oid relrewrite, ObjectAddress *typaddress); extern void heap_create_init_fork(Relation rel); diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h index 7fc355acb89..85cdb99f1f6 100644 --- a/src/include/catalog/pg_class.h +++ b/src/include/catalog/pg_class.h @@ -70,6 +70,7 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO bool relispopulated; /* matview currently holds query results */ char relreplident; /* see REPLICA_IDENTITY_xxx constants */ bool relispartition; /* is relation a partition? */ + Oid relrewrite; /* heap for rewrite during DDL, link to original rel */ TransactionId relfrozenxid; /* all Xids < this are frozen in this rel */ TransactionId relminmxid; /* all multixacts in this rel are >= this. * this is really a MultiXactId */ @@ -98,7 +99,7 @@ typedef FormData_pg_class *Form_pg_class; * ---------------- */ -#define Natts_pg_class 32 +#define Natts_pg_class 33 #define Anum_pg_class_relname 1 #define Anum_pg_class_relnamespace 2 #define Anum_pg_class_reltype 3 @@ -126,11 +127,12 @@ typedef FormData_pg_class *Form_pg_class; #define Anum_pg_class_relispopulated 25 #define Anum_pg_class_relreplident 26 #define Anum_pg_class_relispartition 27 -#define Anum_pg_class_relfrozenxid 28 -#define Anum_pg_class_relminmxid 29 -#define Anum_pg_class_relacl 30 -#define Anum_pg_class_reloptions 31 -#define Anum_pg_class_relpartbound 32 +#define Anum_pg_class_relrewrite 28 +#define Anum_pg_class_relfrozenxid 29 +#define Anum_pg_class_relminmxid 30 +#define Anum_pg_class_relacl 31 +#define Anum_pg_class_reloptions 32 +#define Anum_pg_class_relpartbound 33 /* ---------------- * initial contents of pg_class @@ -145,13 +147,13 @@ typedef FormData_pg_class *Form_pg_class; * Note: "3" in the relfrozenxid column stands for FirstNormalTransactionId; * similarly, "1" in relminmxid stands for FirstMultiXactId */ -DATA(insert OID = 1247 ( pg_type PGNSP 71 0 PGUID 0 0 0 0 0 0 0 f f p r 30 0 t f f f f f t n f 3 1 _null_ _null_ _null_)); +DATA(insert OID = 1247 ( pg_type PGNSP 71 0 PGUID 0 0 0 0 0 0 0 f f p r 30 0 t f f f f f t n f 0 3 1 _null_ _null_ _null_)); DESCR(""); -DATA(insert OID = 1249 ( pg_attribute PGNSP 75 0 PGUID 0 0 0 0 0 0 0 f f p r 22 0 f f f f f f t n f 3 1 _null_ _null_ _null_)); +DATA(insert OID = 1249 ( pg_attribute PGNSP 75 0 PGUID 0 0 0 0 0 0 0 f f p r 22 0 f f f f f f t n f 0 3 1 _null_ _null_ _null_)); DESCR(""); -DATA(insert OID = 1255 ( pg_proc PGNSP 81 0 PGUID 0 0 0 0 0 0 0 f f p r 28 0 t f f f f f t n f 3 1 _null_ _null_ _null_)); +DATA(insert OID = 1255 ( pg_proc PGNSP 81 0 PGUID 0 0 0 0 0 0 0 f f p r 28 0 t f f f f f t n f 0 3 1 _null_ _null_ _null_)); DESCR(""); -DATA(insert OID = 1259 ( pg_class PGNSP 83 0 PGUID 0 0 0 0 0 0 0 f f p r 32 0 t f f f f f t n f 3 1 _null_ _null_ _null_)); +DATA(insert OID = 1259 ( pg_class PGNSP 83 0 PGUID 0 0 0 0 0 0 0 f f p r 33 0 t f f f f f t n f 0 3 1 _null_ _null_ _null_)); DESCR(""); diff --git a/src/include/replication/output_plugin.h b/src/include/replication/output_plugin.h index 78fd38bb169..82875d6b3d5 100644 --- a/src/include/replication/output_plugin.h +++ b/src/include/replication/output_plugin.h @@ -26,6 +26,7 @@ typedef enum OutputPluginOutputType typedef struct OutputPluginOptions { OutputPluginOutputType output_type; + bool receive_rewrites; } OutputPluginOptions; /* diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h index 0970abca52a..aa430c843c0 100644 --- a/src/include/replication/reorderbuffer.h +++ b/src/include/replication/reorderbuffer.h @@ -337,6 +337,11 @@ struct ReorderBuffer void *private_data; /* + * Saved output plugin option + */ + bool output_rewrites; + + /* * Private memory context. */ MemoryContext context; |