Skip to content

Commit 48bf023

Browse files
committed
get rid of duplicate struct defs
1 parent 5606374 commit 48bf023

File tree

3 files changed

+49
-64
lines changed

3 files changed

+49
-64
lines changed

src/backend/access/transam/twophase.c

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ int max_prepared_xacts = 0;
127127
* typedef struct GlobalTransactionData *GlobalTransaction appears in
128128
* twophase.h
129129
*/
130-
#define GIDSIZE 200
131130

132131
typedef struct GlobalTransactionData
133132
{
@@ -825,50 +824,6 @@ TwoPhaseGetDummyProc(TransactionId xid)
825824
return &ProcGlobal->allProcs[gxact->pgprocno];
826825
}
827826

828-
/************************************************************************/
829-
/* State file support */
830-
/************************************************************************/
831-
832-
#define TwoPhaseFilePath(path, xid) \
833-
snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X", xid)
834-
835-
/*
836-
* 2PC state file format:
837-
*
838-
* 1. TwoPhaseFileHeader
839-
* 2. TransactionId[] (subtransactions)
840-
* 3. RelFileNode[] (files to be deleted at commit)
841-
* 4. RelFileNode[] (files to be deleted at abort)
842-
* 5. SharedInvalidationMessage[] (inval messages to be sent at commit)
843-
* 6. TwoPhaseRecordOnDisk
844-
* 7. ...
845-
* 8. TwoPhaseRecordOnDisk (end sentinel, rmid == TWOPHASE_RM_END_ID)
846-
* 9. checksum (CRC-32C)
847-
*
848-
* Each segment except the final checksum is MAXALIGN'd.
849-
*/
850-
851-
/*
852-
* Header for a 2PC state file
853-
*/
854-
#define TWOPHASE_MAGIC 0x57F94532 /* format identifier */
855-
856-
typedef struct TwoPhaseFileHeader
857-
{
858-
uint32 magic; /* format identifier */
859-
uint32 total_len; /* actual file length */
860-
TransactionId xid; /* original transaction XID */
861-
Oid database; /* OID of database it was in */
862-
TimestampTz prepared_at; /* time of preparation */
863-
Oid owner; /* user running the transaction */
864-
int32 nsubxacts; /* number of following subxact XIDs */
865-
int32 ncommitrels; /* number of delete-on-commit rels */
866-
int32 nabortrels; /* number of delete-on-abort rels */
867-
int32 ninvalmsgs; /* number of cache invalidation messages */
868-
bool initfileinval; /* does relcache init file need invalidation? */
869-
char gid[GIDSIZE]; /* GID for transaction */
870-
} TwoPhaseFileHeader;
871-
872827
/*
873828
* Header for each record in a state file
874829
*

src/backend/replication/logical/decode.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "access/xlogreader.h"
3636
#include "access/xlogrecord.h"
3737
#include "access/twophase.h"
38-
//#include "access/twophase_rmgr.h"
3938

4039
#include "catalog/pg_control.h"
4140

@@ -54,24 +53,6 @@ typedef struct XLogRecordBuffer
5453
XLogReaderState *record;
5554
} XLogRecordBuffer;
5655

57-
58-
typedef struct TwoPhaseFileHeader
59-
{
60-
uint32 magic; /* format identifier */
61-
uint32 total_len; /* actual file length */
62-
TransactionId xid; /* original transaction XID */
63-
Oid database; /* OID of database it was in */
64-
TimestampTz prepared_at; /* time of preparation */
65-
Oid owner; /* user running the transaction */
66-
int32 nsubxacts; /* number of following subxact XIDs */
67-
int32 ncommitrels; /* number of delete-on-commit rels */
68-
int32 nabortrels; /* number of delete-on-abort rels */
69-
int32 ninvalmsgs; /* number of cache invalidation messages */
70-
bool initfileinval; /* does relcache init file need invalidation? */
71-
char gid[200]; /* GID for transaction */
72-
} TwoPhaseFileHeader;
73-
74-
7556
/* RMGR Handlers */
7657
static void DecodeXLogOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf);
7758
static void DecodeHeapOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf);

src/include/access/twophase.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,61 @@
1818
#include "datatype/timestamp.h"
1919
#include "storage/lock.h"
2020

21+
/*
22+
* Maximum size of Global Transaction ID.
23+
*/
24+
#define GIDSIZE 200
25+
2126
/*
2227
* GlobalTransactionData is defined in twophase.c; other places have no
2328
* business knowing the internal definition.
2429
*/
2530
typedef struct GlobalTransactionData *GlobalTransaction;
2631

32+
/************************************************************************/
33+
/* State file support */
34+
/************************************************************************/
35+
36+
#define TwoPhaseFilePath(path, xid) \
37+
snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X", xid)
38+
39+
/*
40+
* 2PC state file format:
41+
*
42+
* 1. TwoPhaseFileHeader
43+
* 2. TransactionId[] (subtransactions)
44+
* 3. RelFileNode[] (files to be deleted at commit)
45+
* 4. RelFileNode[] (files to be deleted at abort)
46+
* 5. SharedInvalidationMessage[] (inval messages to be sent at commit)
47+
* 6. TwoPhaseRecordOnDisk
48+
* 7. ...
49+
* 8. TwoPhaseRecordOnDisk (end sentinel, rmid == TWOPHASE_RM_END_ID)
50+
* 9. checksum (CRC-32C)
51+
*
52+
* Each segment except the final checksum is MAXALIGN'd.
53+
*/
54+
55+
/*
56+
* Header for a 2PC state file
57+
*/
58+
#define TWOPHASE_MAGIC 0x57F94532 /* format identifier */
59+
60+
typedef struct TwoPhaseFileHeader
61+
{
62+
uint32 magic; /* format identifier */
63+
uint32 total_len; /* actual file length */
64+
TransactionId xid; /* original transaction XID */
65+
Oid database; /* OID of database it was in */
66+
TimestampTz prepared_at; /* time of preparation */
67+
Oid owner; /* user running the transaction */
68+
int32 nsubxacts; /* number of following subxact XIDs */
69+
int32 ncommitrels; /* number of delete-on-commit rels */
70+
int32 nabortrels; /* number of delete-on-abort rels */
71+
int32 ninvalmsgs; /* number of cache invalidation messages */
72+
bool initfileinval; /* does relcache init file need invalidation? */
73+
char gid[GIDSIZE]; /* GID for transaction */
74+
} TwoPhaseFileHeader;
75+
2776
/* GUC variable */
2877
extern int max_prepared_xacts;
2978

0 commit comments

Comments
 (0)