Search Postgresql Archives

Re: Where I find examples of pqtrace?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux