1996-10-11 11:47:14 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* util.c
|
2000-07-08 05:04:41 +02:00
|
|
|
* general routines for backend libpq modules
|
1996-10-11 11:47:14 +02:00
|
|
|
*
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-10-11 11:47:14 +02:00
|
|
|
*
|
2000-07-08 05:04:41 +02:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/util.c,v 1.16 2000/07/08 03:04:41 tgl Exp $
|
1996-10-11 11:47:14 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* UTILITY ROUTINES
|
|
|
|
* pqdebug - send a string to the debugging output port
|
|
|
|
* PQtrace - turn on pqdebug() tracing
|
|
|
|
* PQuntrace - turn off pqdebug() tracing
|
1996-10-11 11:47:14 +02:00
|
|
|
*/
|
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "postgres.h"
|
2000-07-08 05:04:41 +02:00
|
|
|
|
1999-07-16 05:14:30 +02:00
|
|
|
#include "libpq/libpq.h"
|
1996-10-11 11:47:14 +02:00
|
|
|
|
|
|
|
|
1999-10-23 05:13:33 +02:00
|
|
|
/* ----------------
|
|
|
|
* global variables for backend libpq
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
char PQerrormsg[PQERRORMSG_LENGTH];
|
|
|
|
|
2000-07-08 05:04:41 +02:00
|
|
|
/*
|
|
|
|
* These are not really global --- they are referred to nowhere else.
|
|
|
|
* We declare them as global symbols to make them easier to set in a debugger.
|
|
|
|
*/
|
|
|
|
|
1999-10-23 05:13:33 +02:00
|
|
|
int PQtracep = 0; /* 1 to print out debugging messages */
|
|
|
|
|
2000-07-08 05:04:41 +02:00
|
|
|
FILE *debug_port = (FILE *) NULL;
|
1996-10-11 11:47:14 +02:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* PQ utility routines
|
1996-10-11 11:47:14 +02:00
|
|
|
* ----------------------------------------------------------------
|
|
|
|
*/
|
1999-10-23 05:13:33 +02:00
|
|
|
|
1996-10-11 11:47:14 +02:00
|
|
|
void
|
2000-07-08 05:04:41 +02:00
|
|
|
pqdebug(char *fmt, char *msg)
|
1996-10-11 11:47:14 +02:00
|
|
|
{
|
2000-07-08 05:04:41 +02:00
|
|
|
if (!fmt)
|
1997-09-07 07:04:48 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (PQtracep)
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
2000-07-08 05:04:41 +02:00
|
|
|
* if nothing else was suggested default to stderr
|
1997-09-07 07:04:48 +02:00
|
|
|
*/
|
|
|
|
if (!debug_port)
|
2000-07-08 05:04:41 +02:00
|
|
|
debug_port = stderr;
|
|
|
|
fprintf(debug_port, fmt, msg);
|
1997-09-07 07:04:48 +02:00
|
|
|
fprintf(debug_port, "\n");
|
|
|
|
}
|
1996-10-11 11:47:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* PQtrace() / PQuntrace()
|
1996-10-11 11:47:14 +02:00
|
|
|
* --------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
PQtrace()
|
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
PQtracep = 1;
|
1996-10-11 11:47:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PQuntrace()
|
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
PQtracep = 0;
|
1996-10-11 11:47:14 +02:00
|
|
|
}
|