Skip to content

Commit 9b2197a

Browse files
committed
Rename 'gxid' to 'xid' in dtmd.
1 parent ab845b0 commit 9b2197a

File tree

5 files changed

+41
-41
lines changed

5 files changed

+41
-41
lines changed

contrib/pg_xtm/dtmd/include/clog.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#include <stdbool.h>
99
#include "int.h"
1010

11-
#define INVALID_GXID 0
12-
#define MIN_GXID 42
13-
#define MAX_GXID 0xdeadbeefcafebabe
11+
#define INVALID_XID 0
12+
#define MIN_XID 42
13+
#define MAX_XID 0xdeadbeefcafebabe
1414

1515
#define NEUTRAL 0
1616
#define POSITIVE 1
@@ -24,11 +24,11 @@ typedef struct clog_data_t *clog_t;
2424
clog_t clog_open(char *datadir);
2525

2626
// Get the status of the specified global commit.
27-
int clog_read(clog_t clog, xid_t gxid);
27+
int clog_read(clog_t clog, xid_t xid);
2828

2929
// Set the status of the specified global commit. Return 'true' on success,
3030
// 'false' otherwise.
31-
bool clog_write(clog_t clog, xid_t gxid, int status);
31+
bool clog_write(clog_t clog, xid_t xid, int status);
3232

3333
// Forget about the commits before the given one ('until'), and free the
3434
// occupied space if possible. Return 'true' on success, 'false' otherwise.

contrib/pg_xtm/dtmd/include/clogfile.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#define COMMITS_PER_BYTE 4
1414
#define COMMITS_PER_FILE 1024 // 0x100000000
1515
#define BYTES_PER_FILE ((COMMITS_PER_FILE) / (COMMITS_PER_BYTE))
16-
#define GXID_TO_FILEID(GXID) ((GXID) / (COMMITS_PER_FILE))
17-
#define GXID_TO_OFFSET(GXID) (((GXID) % (COMMITS_PER_FILE)) / (COMMITS_PER_BYTE))
18-
#define GXID_TO_SUBOFFSET(GXID) (((GXID) % (COMMITS_PER_FILE)) % (COMMITS_PER_BYTE))
16+
#define XID_TO_FILEID(XID) ((XID) / (COMMITS_PER_FILE))
17+
#define XID_TO_OFFSET(XID) (((XID) % (COMMITS_PER_FILE)) / (COMMITS_PER_BYTE))
18+
#define XID_TO_SUBOFFSET(XID) (((XID) % (COMMITS_PER_FILE)) % (COMMITS_PER_BYTE))
1919

2020
typedef struct clogfile_t {
2121
char *path;
@@ -36,10 +36,10 @@ bool clogfile_remove(clogfile_t *clogfile);
3636
bool clogfile_close(clogfile_t *clogfile);
3737

3838
// Get the status of the specified global commit from the clog file.
39-
int clogfile_get_status(clogfile_t *clogfile, xid_t gxid);
39+
int clogfile_get_status(clogfile_t *clogfile, xid_t xid);
4040

4141
// Set the status of the specified global commit in the clog file. Return
4242
// 'true' on success, 'false' otherwise.
43-
bool clogfile_set_status(clogfile_t *clogfile, xid_t gxid, int status);
43+
bool clogfile_set_status(clogfile_t *clogfile, xid_t xid, int status);
4444

4545
#endif

contrib/pg_xtm/dtmd/src/clog.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,42 +100,42 @@ clog_t clog_open(char *datadir) {
100100
return clog;
101101
}
102102

103-
// Find a file containing info about the given 'gxid'. Return the clogfile
103+
// Find a file containing info about the given 'xid'. Return the clogfile
104104
// pointer, or NULL if not found.
105-
static clogfile_t *clog_gxid_to_file(clog_t clog, xid_t gxid) {
105+
static clogfile_t *clog_xid_to_file(clog_t clog, xid_t xid) {
106106
clogfile_chain_t *cur;
107107
for (cur = clog->lastfile; cur; cur = cur->prev) {
108-
if (inrange(cur->file.min, gxid, cur->file.max)) {
108+
if (inrange(cur->file.min, xid, cur->file.max)) {
109109
return &cur->file;
110110
}
111111
}
112112
return NULL;
113113
}
114114

115115
// Get the status of the specified global commit.
116-
int clog_read(clog_t clog, xid_t gxid) {
117-
clogfile_t *file = clog_gxid_to_file(clog, gxid);
116+
int clog_read(clog_t clog, xid_t xid) {
117+
clogfile_t *file = clog_xid_to_file(clog, xid);
118118
if (file) {
119-
int status = clogfile_get_status(file, gxid);
119+
int status = clogfile_get_status(file, xid);
120120
return status;
121121
} else {
122122
shout(
123-
"gxid %016llx status is out of range, "
123+
"xid %016llx status is out of range, "
124124
"you might be experiencing a bug in backend\n",
125-
gxid
125+
xid
126126
);
127127
return NEUTRAL;
128128
}
129129
}
130130

131131
// Set the status of the specified global commit. Return 'true' on success,
132132
// 'false' otherwise.
133-
bool clog_write(clog_t clog, xid_t gxid, int status) {
134-
clogfile_t *file = clog_gxid_to_file(clog, gxid);
133+
bool clog_write(clog_t clog, xid_t xid, int status) {
134+
clogfile_t *file = clog_xid_to_file(clog, xid);
135135
if (!file) {
136-
shout("gxid %016llx out of range, creating the file\n", gxid);
136+
shout("xid %016llx out of range, creating the file\n", xid);
137137
clogfile_t newfile;
138-
if (!clogfile_open_by_id(&newfile, clog->datadir, GXID_TO_FILEID(gxid), true)) {
138+
if (!clogfile_open_by_id(&newfile, clog->datadir, XID_TO_FILEID(xid), true)) {
139139
shout(
140140
"failed to create new clogfile "
141141
"while saving transaction status\n"
@@ -147,12 +147,12 @@ bool clog_write(clog_t clog, xid_t gxid, int status) {
147147
lastfile->prev = clog->lastfile;
148148
clog->lastfile = lastfile;
149149
}
150-
file = clog_gxid_to_file(clog, gxid);
150+
file = clog_xid_to_file(clog, xid);
151151
if (!file) {
152152
shout("the file is absent despite out efforts\n");
153153
return false;
154154
}
155-
bool ok = clogfile_set_status(file, gxid, status);
155+
bool ok = clogfile_set_status(file, xid, status);
156156
return ok;
157157
}
158158

contrib/pg_xtm/dtmd/src/clogfile-test.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ int main() {
1515
}
1616
}
1717

18-
uint64_t gxid;
19-
for (gxid = 0; gxid < 32; gxid++) {
18+
uint64_t xid;
19+
for (xid = 0; xid < 32; xid++) {
2020
int status;
21-
if (gxid < 16) {
22-
status = clogfile_get_status(&a, gxid);
21+
if (xid < 16) {
22+
status = clogfile_get_status(&a, xid);
2323
} else {
24-
status = clogfile_get_status(&b, gxid);
24+
status = clogfile_get_status(&b, xid);
2525
}
26-
printf("before: %lu status %d\n", gxid, status);
26+
printf("before: %lu status %d\n", xid, status);
2727
}
2828

2929
if (!clogfile_set_status(&a, 0, XSTATUS_INPROGRESS)) return EXIT_FAILURE;
@@ -33,14 +33,14 @@ int main() {
3333
if (!clogfile_set_status(&b, 30, XSTATUS_COMMITTED)) return EXIT_FAILURE;
3434
if (!clogfile_set_status(&b, 31, XSTATUS_ABORTED)) return EXIT_FAILURE;
3535

36-
for (gxid = 0; gxid < 32; gxid++) {
36+
for (xid = 0; xid < 32; xid++) {
3737
int status;
38-
if (gxid < 16) {
39-
status = clogfile_get_status(&a, gxid);
38+
if (xid < 16) {
39+
status = clogfile_get_status(&a, xid);
4040
} else {
41-
status = clogfile_get_status(&b, gxid);
41+
status = clogfile_get_status(&b, xid);
4242
}
43-
printf(" after: %lu status %d\n", gxid, status);
43+
printf(" after: %lu status %d\n", xid, status);
4444
}
4545

4646
if (!clogfile_close(&a)) return EXIT_FAILURE;

contrib/pg_xtm/dtmd/src/clogfile.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,18 @@ bool clogfile_close(clogfile_t *clogfile) {
8585
}
8686

8787
// Get the status of the specified global commit from the clog file.
88-
int clogfile_get_status(clogfile_t *clogfile, xid_t gxid) {
89-
off64_t offset = GXID_TO_OFFSET(gxid);
90-
int suboffset = GXID_TO_SUBOFFSET(gxid);
88+
int clogfile_get_status(clogfile_t *clogfile, xid_t xid) {
89+
off64_t offset = XID_TO_OFFSET(xid);
90+
int suboffset = XID_TO_SUBOFFSET(xid);
9191
char *p = ((char*)clogfile->data + offset);
9292
return ((*p) >> (BITS_PER_COMMIT * suboffset)) & COMMIT_MASK; // AND-out all other status
9393
}
9494

9595
// Set the status of the specified global commit in the clog file. Return
9696
// 'true' on success, 'false' otherwise.
97-
bool clogfile_set_status(clogfile_t *clogfile, xid_t gxid, int status) {
98-
off64_t offset = GXID_TO_OFFSET(gxid);
99-
int suboffset = GXID_TO_SUBOFFSET(gxid);
97+
bool clogfile_set_status(clogfile_t *clogfile, xid_t xid, int status) {
98+
off64_t offset = XID_TO_OFFSET(xid);
99+
int suboffset = XID_TO_SUBOFFSET(xid);
100100
char *p = ((char*)clogfile->data + offset);
101101
*p &= ~(COMMIT_MASK << (BITS_PER_COMMIT * suboffset)); // AND-out the old status
102102
*p |= status << (BITS_PER_COMMIT * suboffset); // OR-in the new status

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy