From: | "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
---|---|
To: | "Arvind Singh *EXTERN*" <arvindps(at)hotmail(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Help in Parsing PG log usings CSV format |
Date: | 2012-03-22 15:47:11 |
Message-ID: | D960CB61B694CF459DCFB4B0128514C207A2B869@exadv11.host.magwien.gv.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Arvind Singh wrote:
> Help needed in parsing PostgreSQL CSV Log
[...]
> **However the main problem that is, the Log format is not readable**
> A Sample Log data line
> > 2012-03-21 11:59:20.640
>
IST,"postgres","stock_apals",3276,"localhost:1639",4f697540.ccc,10,"idle
",2012-03-21 11:59:20
> IST,2/163,0,LOG,00000,"statement: SELECT
version()",,,,,,,,"exec_simple_query,
> .\src\backend\tcop\postgres.c:900",""
>
> As you can see the columns in the Log are comma separated , But
however individual values are not
> Quote Enclosed.
>
> For instance the 1st,4rth,6th .. columns
>
> **Is there a setting in PostgreSQL configuration to place quotes
around all columns in a Logfili
>
> I just want to update the columns so that all are within Quotes
>
> what happens wrong is when it reaches the column where sql statement
is place. it also has commas set
> for table columns. The log line is a mix bunch of quote-enclosed and
non-quote-enclosed column. is
> there is a configuration or utility to convert the non-quoted column
to quoted column
The columns that are not quoted are guaranteed not to contain a comma.
So it shouldn't be a problem to parse them.
In fact, it is quite easy. As an example, see here:
http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/pgreplay/pgreplay/parse.c?re
v=1.14&content-type=text/x-cvsweb-markup
In the function parse_csvlog_entry, after the comment
"read next line after start timestamp from log file"
you can find code that parses such a line.
The code is in C, so it should be easy to port it to C#, which
is essentially Java, which has C-like syntax.
Yours,
Laurenz Albe
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2012-03-22 15:57:38 | Re: Large PostgreSQL servers |
Previous Message | Merlin Moncure | 2012-03-22 15:29:46 | Re: Large PostgreSQL servers |