1996-10-11 11:47:14 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* util.c--
|
1997-09-07 07:04:48 +02:00
|
|
|
* general routines for libpq backend
|
1996-10-11 11:47:14 +02:00
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
1997-09-08 04:41:22 +02:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/util.c,v 1.5 1997/09/08 02:23:21 momjian 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
|
|
|
|
* pqdebug2 - send two strings to stdout
|
|
|
|
* PQtrace - turn on pqdebug() tracing
|
|
|
|
* PQuntrace - turn off pqdebug() tracing
|
1996-10-11 11:47:14 +02:00
|
|
|
*/
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#include <stdio.h> /* for sprintf() */
|
1996-10-11 11:47:14 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
1996-11-06 09:48:33 +01:00
|
|
|
#include <postgres.h>
|
|
|
|
#include <lib/dllist.h>
|
1997-09-07 07:04:48 +02:00
|
|
|
#include <libpq/libpq.h> /* where the declarations go */
|
1996-11-06 09:48:33 +01:00
|
|
|
#include <utils/exc.h>
|
1996-10-11 11:47:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* exceptions
|
1996-10-11 11:47:14 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
Exception MemoryError = {"Memory Allocation Error"};
|
|
|
|
Exception PortalError = {"Invalid arguments to portal functions"};
|
|
|
|
Exception PostquelError = {"Sql Error"};
|
|
|
|
Exception ProtocolError = {"Protocol Error"};
|
|
|
|
char PQerrormsg[ERROR_MSG_LENGTH];
|
1996-10-11 11:47:14 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
int PQtracep = 0; /* 1 to print out debugging messages */
|
|
|
|
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
|
|
|
* ----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
pqdebug(char *target, char *msg)
|
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
if (!target)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (PQtracep)
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if nothing else was suggested default to stdout
|
|
|
|
*/
|
|
|
|
if (!debug_port)
|
|
|
|
debug_port = stdout;
|
|
|
|
fprintf(debug_port, target, msg);
|
|
|
|
fprintf(debug_port, "\n");
|
|
|
|
}
|
1996-10-11 11:47:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pqdebug2(char *target, char *msg1, char *msg2)
|
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
if (!target)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (PQtracep)
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if nothing else was suggested default to stdout
|
|
|
|
*/
|
|
|
|
if (!debug_port)
|
|
|
|
debug_port = stdout;
|
|
|
|
fprintf(debug_port, target, msg1, msg2);
|
|
|
|
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
|
|
|
}
|