diff options
| author | Robert Haas | 2013-11-08 17:30:43 +0000 |
|---|---|---|
| committer | Robert Haas | 2013-11-08 17:30:43 +0000 |
| commit | 07cacba983ef79be4a84fcd0e0ca3b5fcb85dd65 (patch) | |
| tree | 7fa0f7c8d7b765b3e901512faef90759904d047c /src/include | |
| parent | b97ee66cc1f9319f7b457e7d8a78aab711da2dda (diff) | |
Add the notion of REPLICA IDENTITY for a table.
Pending patches for logical replication will use this to determine
which columns of a tuple ought to be considered as its candidate key.
Andres Freund, with minor, mostly cosmetic adjustments by me
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/catalog/catversion.h | 2 | ||||
| -rw-r--r-- | src/include/catalog/pg_class.h | 32 | ||||
| -rw-r--r-- | src/include/catalog/pg_index.h | 16 | ||||
| -rw-r--r-- | src/include/nodes/nodes.h | 1 | ||||
| -rw-r--r-- | src/include/nodes/parsenodes.h | 8 | ||||
| -rw-r--r-- | src/include/utils/rel.h | 7 |
6 files changed, 49 insertions, 17 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 4aa0edf399..4108f6c16c 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 201310271 +#define CATALOG_VERSION_NO 201311081 #endif diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h index 49c4f6f136..a1fee11fe6 100644 --- a/src/include/catalog/pg_class.h +++ b/src/include/catalog/pg_class.h @@ -66,6 +66,7 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO bool relhastriggers; /* has (or has had) any TRIGGERs */ bool relhassubclass; /* has (or has had) derived classes */ bool relispopulated; /* matview currently holds query results */ + char relreplident; /* see REPLICA_IDENTITY_xxx constants */ TransactionId relfrozenxid; /* all Xids < this are frozen in this rel */ TransactionId relminmxid; /* all multixacts in this rel are >= this. * this is really a MultiXactId */ @@ -93,7 +94,7 @@ typedef FormData_pg_class *Form_pg_class; * ---------------- */ -#define Natts_pg_class 28 +#define Natts_pg_class 29 #define Anum_pg_class_relname 1 #define Anum_pg_class_relnamespace 2 #define Anum_pg_class_reltype 3 @@ -118,10 +119,11 @@ typedef FormData_pg_class *Form_pg_class; #define Anum_pg_class_relhastriggers 22 #define Anum_pg_class_relhassubclass 23 #define Anum_pg_class_relispopulated 24 -#define Anum_pg_class_relfrozenxid 25 -#define Anum_pg_class_relminmxid 26 -#define Anum_pg_class_relacl 27 -#define Anum_pg_class_reloptions 28 +#define Anum_pg_class_relreplident 25 +#define Anum_pg_class_relfrozenxid 26 +#define Anum_pg_class_relminmxid 27 +#define Anum_pg_class_relacl 28 +#define Anum_pg_class_reloptions 29 /* ---------------- * initial contents of pg_class @@ -136,13 +138,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 t 3 1 _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 t n 3 1 _null_ _null_ )); DESCR(""); -DATA(insert OID = 1249 ( pg_attribute PGNSP 75 0 PGUID 0 0 0 0 0 0 0 f f p r 21 0 f f f f f t 3 1 _null_ _null_ )); +DATA(insert OID = 1249 ( pg_attribute PGNSP 75 0 PGUID 0 0 0 0 0 0 0 f f p r 21 0 f f f f f t n 3 1 _null_ _null_ )); DESCR(""); -DATA(insert OID = 1255 ( pg_proc PGNSP 81 0 PGUID 0 0 0 0 0 0 0 f f p r 27 0 t f f f f t 3 1 _null_ _null_ )); +DATA(insert OID = 1255 ( pg_proc PGNSP 81 0 PGUID 0 0 0 0 0 0 0 f f p r 27 0 t f f f f t n 3 1 _null_ _null_ )); DESCR(""); -DATA(insert OID = 1259 ( pg_class PGNSP 83 0 PGUID 0 0 0 0 0 0 0 f f p r 28 0 t f f f f t 3 1 _null_ _null_ )); +DATA(insert OID = 1259 ( pg_class PGNSP 83 0 PGUID 0 0 0 0 0 0 0 f f p r 29 0 t f f f f t n 3 1 _null_ _null_ )); DESCR(""); @@ -159,4 +161,16 @@ DESCR(""); #define RELPERSISTENCE_UNLOGGED 'u' /* unlogged permanent table */ #define RELPERSISTENCE_TEMP 't' /* temporary table */ +/* default selection for replica identity (primary key or nothing) */ +#define REPLICA_IDENTITY_DEFAULT 'd' +/* no replica identity is logged for this relation */ +#define REPLICA_IDENTITY_NOTHING 'n' +/* all columns are loged as replica identity */ +#define REPLICA_IDENTITY_FULL 'f' +/* + * an explicitly chosen candidate key's columns are used as identity; + * will still be set if the index has been dropped, in that case it + * has the same meaning as 'd' + */ +#define REPLICA_IDENTITY_INDEX 'i' #endif /* PG_CLASS_H */ diff --git a/src/include/catalog/pg_index.h b/src/include/catalog/pg_index.h index 8d1d415939..b31d9d7643 100644 --- a/src/include/catalog/pg_index.h +++ b/src/include/catalog/pg_index.h @@ -42,6 +42,7 @@ CATALOG(pg_index,2610) BKI_WITHOUT_OIDS BKI_SCHEMA_MACRO bool indcheckxmin; /* must we wait for xmin to be old? */ bool indisready; /* is this index ready for inserts? */ bool indislive; /* is this index alive at all? */ + bool indisreplident; /* is this index the identity for replication? */ /* variable-length fields start here, but we allow direct access to indkey */ int2vector indkey; /* column numbers of indexed cols, or 0 */ @@ -69,7 +70,7 @@ typedef FormData_pg_index *Form_pg_index; * compiler constants for pg_index * ---------------- */ -#define Natts_pg_index 18 +#define Natts_pg_index 19 #define Anum_pg_index_indexrelid 1 #define Anum_pg_index_indrelid 2 #define Anum_pg_index_indnatts 3 @@ -82,12 +83,13 @@ typedef FormData_pg_index *Form_pg_index; #define Anum_pg_index_indcheckxmin 10 #define Anum_pg_index_indisready 11 #define Anum_pg_index_indislive 12 -#define Anum_pg_index_indkey 13 -#define Anum_pg_index_indcollation 14 -#define Anum_pg_index_indclass 15 -#define Anum_pg_index_indoption 16 -#define Anum_pg_index_indexprs 17 -#define Anum_pg_index_indpred 18 +#define Anum_pg_index_indisreplident 13 +#define Anum_pg_index_indkey 14 +#define Anum_pg_index_indcollation 15 +#define Anum_pg_index_indclass 16 +#define Anum_pg_index_indoption 17 +#define Anum_pg_index_indexprs 18 +#define Anum_pg_index_indpred 19 /* * Index AMs that support ordered scans must support these two indoption diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index 78368c63c1..fc6b1d7dbd 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -362,6 +362,7 @@ typedef enum NodeTag T_CreateEventTrigStmt, T_AlterEventTrigStmt, T_RefreshMatViewStmt, + T_ReplicaIdentityStmt, /* * TAGS FOR PARSE TREE NODES (parsenodes.h) diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index e5235cbf40..952fbb30dd 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -1284,9 +1284,17 @@ typedef enum AlterTableType AT_DropInherit, /* NO INHERIT parent */ AT_AddOf, /* OF <type_name> */ AT_DropOf, /* NOT OF */ + AT_ReplicaIdentity, /* REPLICA IDENTITY */ AT_GenericOptions /* OPTIONS (...) */ } AlterTableType; +typedef struct ReplicaIdentityStmt +{ + NodeTag type; + char identity_type; + char *name; +} ReplicaIdentityStmt; + typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */ { NodeTag type; diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 589c9a81b6..21d5871454 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -111,6 +111,13 @@ typedef struct RelationData TriggerDesc *trigdesc; /* Trigger info, or NULL if rel has none */ /* + * The index chosen as the relation's replication identity or + * InvalidOid. Only set correctly if RelationGetIndexList has been + * called/rd_indexvalid > 0. + */ + Oid rd_replidindex; + + /* * rd_options is set whenever rd_rel is loaded into the relcache entry. * Note that you can NOT look into rd_rel for this data. NULL means "use * defaults". |
