1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-26 01:22:12 +03:00

Clean up representation of flags in struct ReorderBufferTXN

This simplifies addition of further flags.

Author: Nikhil Sontakke
Discussion: https://postgr.es/m/CAMGcDxeViP+R-OL7QhzUV9eKCVjURobuY1Zijik4Ay_Ddwo4Cg@mail.gmail.com
This commit is contained in:
Alvaro Herrera
2020-01-10 17:46:57 -03:00
parent 00b047fa67
commit a7b6ab5db1
2 changed files with 47 additions and 37 deletions

View File

@ -158,18 +158,38 @@ typedef struct ReorderBufferChange
dlist_node node;
} ReorderBufferChange;
/* ReorderBufferTXN txn_flags */
#define RBTXN_HAS_CATALOG_CHANGES 0x0001
#define RBTXN_IS_SUBXACT 0x0002
#define RBTXN_IS_SERIALIZED 0x0004
/* Does the transaction have catalog changes? */
#define rbtxn_has_catalog_changes(txn) \
( \
((txn)->txn_flags & RBTXN_HAS_CATALOG_CHANGES) != 0 \
)
/* Is the transaction known as a subxact? */
#define rbtxn_is_known_subxact(txn) \
( \
((txn)->txn_flags & RBTXN_IS_SUBXACT) != 0 \
)
/* Has this transaction been spilled to disk? */
#define rbtxn_is_serialized(txn) \
( \
((txn)->txn_flags & RBTXN_IS_SERIALIZED) != 0 \
)
typedef struct ReorderBufferTXN
{
/*
* The transactions transaction id, can be a toplevel or sub xid.
*/
/* See above */
bits32 txn_flags;
/* The transaction's transaction id, can be a toplevel or sub xid. */
TransactionId xid;
/* did the TX have catalog changes */
bool has_catalog_changes;
/* Do we know this is a subxact? Xid of top-level txn if so */
bool is_known_as_subxact;
/* Xid of top-level transaction, if known */
TransactionId toplevel_xid;
/*
@ -237,15 +257,6 @@ typedef struct ReorderBufferTXN
*/
uint64 nentries_mem;
/*
* Has this transaction been spilled to disk? It's not always possible to
* deduce that fact by comparing nentries with nentries_mem, because e.g.
* subtransactions of a large transaction might get serialized together
* with the parent - if they're restored to memory they'd have
* nentries_mem == nentries.
*/
bool serialized;
/*
* List of ReorderBufferChange structs, including new Snapshots and new
* CommandIds
@ -298,7 +309,6 @@ typedef struct ReorderBufferTXN
* Size of this transaction (changes currently in memory, in bytes).
*/
Size size;
} ReorderBufferTXN;
/* so we can define the callbacks used inside struct ReorderBuffer itself */