COPY-able sql log outputs - Mailing list pgsql-patches

From FAST PostgreSQL
Subject COPY-able sql log outputs
Date
Msg-id 21558.10091175247187.fast.fujitsu.com.au@MHS
Whole thread Raw
Responses Re: COPY-able sql log outputs  (Peter Eisentraut <peter_e@gmx.net>)
Re: COPY-able sql log outputs  (Russell Smith <mr-russ@pws.com.au>)
List pgsql-patches
Hi,

Attached is the completed patch for the COPY-able sql log outputs. I have
modified my previous WIP patch, incorporating all the changes requested by
the community.  This patch has been tested both on windows and linux.

Reiterating what has been done.

The log is now output in COPY-able format as suggested. (Not INSERT-able as
was in the previous WIP patch.)

log_destination now accepts 'sqllog' as a valid output destination. The log
output file will be determined by pg_log and log_filename variables. The sql
log output filename will be 'log_filename'.sql. The file rotation rules apply
to the sql log file output as well.

The log output format is as follows.

timestamp, username, database_name, sessionid, host_port, process_id,
command_tag, session_start_time, transaction_id, error_severity,
sql_state_code, statement

The logs can be loaded into a table using the command

COPY sqltable FROM 'filename.sql' WITH CSV;

There are only two minor issues I can think of
1. The sql log is currently output with newline and tab characters. It loads
into the table neatly. No problems. But when read back, atleast from psql in
windows, the tabs are replaced with some special characters.

2. I think it is better to document somewhere the table structure and the
COPY statement above. But where?

[P.S. - In the wake of community's concerns regarding the legal disclaimer
getting attached to the end of mails we send to the community, we have got an
exemption from the disclaimer getting attached. As this is the first mail I
am sending after this approval, fingers crossed, it works. If for some reason
it gets attached, please ignore this mail and I will send the patch from some
other account.]

Rgds,
Arul Shaji






Attachment

pgsql-patches by date:

Previous
From: ITAGAKI Takahiro
Date:
Subject: Dead Space Map version 3 (simplified)
Next
From: "FAST PostgreSQL"
Date:
Subject: Fwd: Re: [pgsql-patches] pg_get_domaindef