diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2014-03-07 17:02:48 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2014-03-07 17:03:26 -0500 |
commit | ea177a3ba7a7901f6467eadb0a407e03d46462fd (patch) | |
tree | eab3ef55a25f72fe0ea2941cb0c2251e45d2db78 /src/include/replication/reorderbuffer.h | |
parent | 83204e100c7855a50ccffd761bcd45474955b5fb (diff) |
Remove unportable use of anonymous unions from reorderbuffer.h.
In b89e151054a I had assumed it was ok to use anonymous unions as
struct members, but while a longstanding extension in many compilers,
it's only been standardized in C11.
To fix, remove one of the anonymous unions which tried to hide some
implementation specific enum values and give the other a name. The
latter unfortunately requires changes in output plugins, but since the
feature has only been added a few days ago...
Andres Freund
Diffstat (limited to 'src/include/replication/reorderbuffer.h')
-rw-r--r-- | src/include/replication/reorderbuffer.h | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h index 01eabfb7be7..04ff002990d 100644 --- a/src/include/replication/reorderbuffer.h +++ b/src/include/replication/reorderbuffer.h @@ -32,12 +32,22 @@ typedef struct ReorderBufferTupleBuf char data[MaxHeapTupleSize]; } ReorderBufferTupleBuf; -/* types of the change passed to a 'change' callback */ +/* + * Types of the change passed to a 'change' callback. + * + * For efficiency and simplicity reasons we want to keep Snapshots, CommandIds + * and ComboCids in the same list with the user visible INSERT/UPDATE/DELETE + * changes. Users of the decoding facilities will never see changes with + * *_INTERNAL_* actions. + */ enum ReorderBufferChangeType { REORDER_BUFFER_CHANGE_INSERT, REORDER_BUFFER_CHANGE_UPDATE, - REORDER_BUFFER_CHANGE_DELETE + REORDER_BUFFER_CHANGE_DELETE, + REORDER_BUFFER_CHANGE_INTERNAL_SNAPSHOT, + REORDER_BUFFER_CHANGE_INTERNAL_COMMAND_ID, + REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID }; /* @@ -51,13 +61,8 @@ typedef struct ReorderBufferChange { XLogRecPtr lsn; - /* type of change */ - union - { - enum ReorderBufferChangeType action; - /* do not leak internal enum values to the outside */ - int action_internal; - }; + /* The type of change. */ + enum ReorderBufferChangeType action; /* * Context data for the change, which part of the union is valid depends @@ -65,7 +70,7 @@ typedef struct ReorderBufferChange */ union { - /* old, new tuples when action == *_INSERT|UPDATE|DELETE */ + /* Old, new tuples when action == *_INSERT|UPDATE|DELETE */ struct { /* relation that has been changed */ @@ -76,13 +81,19 @@ typedef struct ReorderBufferChange ReorderBufferTupleBuf *newtuple; } tp; - /* new snapshot */ + /* New snapshot, set when action == *_INTERNAL_SNAPSHOT */ Snapshot snapshot; - /* new command id for existing snapshot in a catalog changing tx */ + /* + * New command id for existing snapshot in a catalog changing tx. Set + * when action == *_INTERNAL_COMMAND_ID. + */ CommandId command_id; - /* new cid mapping for catalog changing transaction */ + /* + * New cid mapping for catalog changing transaction, set when action + * == *_INTERNAL_TUPLECID. + */ struct { RelFileNode node; @@ -91,7 +102,7 @@ typedef struct ReorderBufferChange CommandId cmax; CommandId combocid; } tuplecid; - }; + } data; /* * While in use this is how a change is linked into a transactions, |