Re: Virtual tx id - Mailing list pgsql-hackers

From Zhang Mingli
Subject Re: Virtual tx id
Date
Msg-id 21e65c15-f7ad-48c0-be19-0f53c786588e@Spark
Whole thread Raw
In response to Virtual tx id  (James Sewell <james.sewell@gmail.com>)
List pgsql-hackers
HI,
On Sep 21, 2022, 11:59 +0800, James Sewell <james.sewell@gmail.com>, wrote:
Hello Hackers!

Is it possible to get the current virtual txid from C somehow?

I've looked through the code, but can't seem to find anything other than getting a NULL when there is no (real) xid assigned. Maybe I'm missing something?

Cheers,
James

Virtual xid is meaningful only inside a read-only transaction. 

It’s made up of MyProc->BackendId and MyProc->LocalTransactionId.

To catch it, you can begin a transaction, but don’t exec sqls that could change the db.

And gdb on process to see( must exec a read only sql to call StartTransaction, else MyProc->lxid is not assigned).

```
Begin;
// do nothing

```
gdb on it and see

```
p MyProc->lxid
p MyProc->backendId

```




Regards,
Zhang Mingli

pgsql-hackers by date:

Previous
From: Japin Li
Date:
Subject: Re: Virtual tx id
Next
From: Julien Rouhaud
Date:
Subject: Re: Virtual tx id