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

Quan Zongliang <quanzongliang@yeah.net>

From: Quan Zongliang <quanzongliang@yeah.net>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2023-10-08T03:50:43Z
Lists: pgsql-hackers

Attachments


Implement TODO item:

Fix log_line_prefix to display the transaction id (%x) for statements 
not in a transaction block
     Currently it displays zero.


Check that the XID has been assigned at the location where the statement 
log is now printed. If not, no statement log is output.
And then before finish_xact_command. If the statement has not been 
output to the log. Here the log can get XID.

DML that does not manipulate any data still does not get XID.

[32718][788] LOG:  statement: insert into t1 values(1,0,'');
[32718][789] LOG:  statement: delete from t1;
[32718][0] LOG:  statement: delete from t1;


--
Quan Zongliang