Skip to content

Commit 7b0e28d

Browse files
committed
fix build on master (pg17+)
1 parent 8e7b9c9 commit 7b0e28d

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/cursors_leaks.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ typedef struct
4848

4949
MemoryContextCallback contextCallback;
5050

51-
5251
static LocalTransactionId traces_lxid = InvalidLocalTransactionId;
5352
static HTAB *traces = NULL;
5453
static MemoryContext traces_mcxt = NULL;
@@ -60,14 +59,24 @@ static void stmt_end(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt, void **plugi
6059
static plpgsql_check_plugin2 cursors_leaks_plugin2 = { func_setup, NULL, func_end, NULL,
6160
NULL, stmt_end, NULL, NULL, NULL, NULL, NULL, NULL };
6261

62+
#if PG_VERSION_NUM >= 170000
63+
64+
#define CURRENT_LXID (MyProc->vxid.lxid)
65+
66+
#else
67+
68+
#define CURRENT_LXID (MyProc->lxid)
69+
70+
#endif
71+
6372
static FunctionTrace *
6473
get_function_trace(PLpgSQL_function *func)
6574
{
6675
bool found;
6776
FunctionTrace *ftrace;
6877
FunctionTraceKey key;
6978

70-
if (traces == NULL || traces_lxid != MyProc->lxid)
79+
if (traces == NULL || traces_lxid != CURRENT_LXID)
7180
{
7281
HASHCTL ctl;
7382

@@ -85,7 +94,7 @@ get_function_trace(PLpgSQL_function *func)
8594
&ctl,
8695
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
8796

88-
traces_lxid = MyProc->lxid;
97+
traces_lxid = CURRENT_LXID;
8998
}
9099

91100
key.fn_oid = func->fn_oid;
@@ -132,7 +141,7 @@ func_end(PLpgSQL_execstate *estate,
132141
FunctionTrace *ftrace = *plugin2_info;
133142
int i;
134143

135-
if (!ftrace || traces_lxid != MyProc->lxid)
144+
if (!ftrace || traces_lxid != CURRENT_LXID)
136145
return;
137146

138147
for (i = 0; i < ftrace->ncursors; i++)
@@ -182,7 +191,7 @@ stmt_end(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt, void **plugin2_info)
182191
if (!ftrace)
183192
return;
184193

185-
if (traces_lxid != MyProc->lxid)
194+
if (traces_lxid != CURRENT_LXID)
186195
{
187196
ftrace = get_function_trace(estate->func);
188197
*plugin2_info = ftrace;

0 commit comments

Comments
 (0)