Skip to content

Commit a97d132

Browse files
committed
Work around cpychecker false positive in conn_tpc_begin()
See davidmalcolm/gcc-python-plugin#109
1 parent 2b02477 commit a97d132

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

psycopg/connection_int.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,17 @@ conn_set_client_encoding(connectionObject *self, const char *pgenc)
13521352
}
13531353

13541354

1355+
/* Set the xid in the connection status.
1356+
*
1357+
* Simple function to separate the ref stealing semantic and work around
1358+
* davidmalcolm/gcc-python-plugin#109
1359+
*/
1360+
STEALS(2) IGNORE_REFCOUNT static void
1361+
conn_set_xid(connectionObject *self, xidObject *xid)
1362+
{
1363+
self->tpc_xid = xid;
1364+
}
1365+
13551366
/* conn_tpc_begin -- begin a two-phase commit.
13561367
*
13571368
* The state of a connection in the middle of a TPC is exactly the same
@@ -1383,7 +1394,7 @@ conn_tpc_begin(connectionObject *self, xidObject *xid)
13831394

13841395
/* The transaction started ok, let's store this xid. */
13851396
Py_INCREF(xid);
1386-
self->tpc_xid = xid;
1397+
conn_set_xid(self, xid);
13871398

13881399
return 0;
13891400
}

0 commit comments

Comments
 (0)