HI,
On Sep 21, 2022, 11:59 +0800, James Sewell <james.sew...@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

Reply via email to