From: | Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr> |
---|---|
To: | Marcelo Fabiano da Silveira <mfsilveira(at)italnet(dot)com(dot)br> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Where I find examples of pqtrace? |
Date: | 2006-05-18 09:06:06 |
Message-ID: | 20060518090606.GB223@alamut |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sat, May 06, 2006 at 12:08:32AM -0300, Marcelo Fabiano da Silveira wrote:
> I Have some questions of use PQtrace in Windows' systens....
>
> 1- The implementation of PQtrace, is possible ONLY with non bloking
> connections ???
> 2- Please, I need same samples of implementation of PQtrace.
PQtrace(PGconn *conn, FILE *fp) enables logging of sent/received data
(appears on PGconn *conn), to the file pointed by FILE *fp. It achieves
this by making simple fprintf(fp, ...) calls using the file pointed by fp.
(I hope above explanation also answers to your 1st question.)
Here's a simple use case:
PGconn *conn = PQconnectdb("...");
FILE *fp;
fp = fopen(...);
if (!fp)
{
/*
* It's programmer's responsibility to take care of the file
* pointer. Moreover, a blocking socket (on the FILE *fp) will
* cause fprintf(fp, ...) calls to block too, which is an undesired
* behaviour for an API. So you should take the care of consistency
* of this part too.
*/
}
/*
* File is opened with success and we're sure it won't block for
* writing.
*/
PQtrace(conn, fp);
...
/*
* We won't need a connection anymore. Thus, droping connection and its
* tracing.
*/
PQuntrace(conn);
PQfinish(conn);
Regards.
From | Date | Subject | |
---|---|---|---|
Next Message | Matteo Beccati | 2006-05-18 10:34:50 | Re: Announce: GPL Framework centered on Postgres |
Previous Message | Peter Kovacs | 2006-05-18 06:52:23 | Re: Why won't it index scan? |