Re: Virtual tx id

From: Zhang Mingli <zmlpostgres(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, James Sewell <james(dot)sewell(at)gmail(dot)com>
Subject: Re: Virtual tx id
Date: 2022-09-21 04:19:46
Message-ID: 21e65c15-f7ad-48c0-be19-0f53c786588e@Spark
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

HI,
On Sep 21, 2022, 11:59 +0800, James Sewell <james(dot)sewell(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Julien Rouhaud 2022-09-21 04:21:10 Re: Virtual tx id
Previous Message Japin Li 2022-09-21 04:17:19 Re: Virtual tx id