Thread: Where I find examples of pqtrace ???

Where I find examples of pqtrace ???

From
"Marcelo Fabiano da Silveira"
Date:
Hi,

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.


Regards

Marcelo Silveira
OBS: text original in Portuguese, translate with google.






Re: Where I find examples of pqtrace ???

From
"Jim C. Nasby"
Date:
On Sat, May 06, 2006 at 12:08:32AM -0300, Marcelo Fabiano da Silveira wrote:
> Hi,
>
> 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.

Since no one's replied... you might have better luck on
pgsql-interfaces. Unfortunately I don't know very much about PQtrace...
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

Re: Where I find examples of pqtrace?

From
Volkan YAZICI
Date:
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.