Re: Where I find examples of pqtrace?

Поиск
Список
Период
Сортировка
От Volkan YAZICI
Тема Re: Where I find examples of pqtrace?
Дата
Msg-id 20060518090606.GB223@alamut
обсуждение исходный текст
Ответ на Re: Where I find examples of pqtrace ???  ("Jim C. Nasby" <jnasby@pervasive.com>)
Список 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.

В списке pgsql-general по дате отправления:

Предыдущее
От: Florian Weimer
Дата:
Сообщение: Re: Announce: GPL Framework centered on Postgres
Следующее
От: Sim Zacks
Дата:
Сообщение: table variables