Re: Fix log_line_prefix to display the transaction id (%x) for statements not in a transaction block

From: Quan Zongliang <quanzongliang(at)yeah(dot)net>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix log_line_prefix to display the transaction id (%x) for statements not in a transaction block
Date: 2024-02-02 00:47:36
Message-ID: 7201b127-fffb-4142-9e90-fd91dee02731@yeah.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


A little tweak to the code.
GetTopTransactionIdIfAny() != InvalidTransactionId
changed to
TransactionIdIsValid(GetTopTransactionIdIfAny()

On 2024/1/12 08:51, jian he wrote:
> Hi
...
> with patch:
> src3=# explain(analyze, costs off) select 1 from pg_sleep(10);
> 2024-01-12 08:43:14.750 CST [5739] jian(at)src3/psql XID:0 LOG:
> duration: 10010.167 ms plan:
> Query Text: explain(analyze, costs off) select 1 from pg_sleep(10);
> Function Scan on pg_sleep (cost=0.00..0.01 rows=1 width=4)
> (actual time=10010.155..10010.159 rows=1 loops=1)
> 2024-01-12 08:43:14.750 CST [5739] jian(at)src3/psql XID:0 LOG:
> statement: explain(analyze, costs off) select 1 from pg_sleep(10);
> QUERY PLAN
> -----------------------------------------------------------------------------
> Function Scan on pg_sleep (actual time=10010.155..10010.159 rows=1 loops=1)
> Planning Time: 0.115 ms
> Execution Time: 10010.227 ms
> (3 rows)
This problem does exist in a statement that takes a long time to run.
XID is applied only for the first change tuple. If the user want to see
it in a single statement log, they have to wait until the statement has
finished executing. And we don't know how long it will take until the
statement ends. It is not appropriate to output the log twice because of
xid. Besides, without parsing log_line_prefix we don't know if the user
wants to see xid.

Attachment Content-Type Size
postgres-v2.patch text/plain 1.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2024-02-02 00:50:25 Re: set_cheapest without checking pathlist
Previous Message Sutou Kouhei 2024-02-02 00:40:56 Re: Make COPY format extendable: Extract COPY TO format implementations