aboutsummaryrefslogtreecommitdiff
path: root/src/backend/libpq/util.c
blob: 4ddf17d59bb246cfc587655b8d3312ba9af137d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*-------------------------------------------------------------------------
 *
 * util.c
 *	  general routines for backend libpq modules
 *
 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 *	$Header: /cvsroot/pgsql/src/backend/libpq/Attic/util.c,v 1.18 2001/10/25 05:49:30 momjian Exp $
 *
 *-------------------------------------------------------------------------
 */
/*
 *	 UTILITY ROUTINES
 *		pqdebug			- send a string to the debugging output port
 *		PQtrace			- turn on pqdebug() tracing
 *		PQuntrace		- turn off pqdebug() tracing
 */

#include "postgres.h"

#include "libpq/libpq.h"


/* ----------------
 *		global variables for backend libpq
 * ----------------
 */
char		PQerrormsg[PQERRORMSG_LENGTH];

/*
 * 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.
 */

int			PQtracep = 0;		/* 1 to print out debugging messages */

FILE	   *debug_port = (FILE *) NULL;

/* ----------------------------------------------------------------
 *						PQ utility routines
 * ----------------------------------------------------------------
 */

void
pqdebug(char *fmt, char *msg)
{
	if (!fmt)
		return;

	if (PQtracep)
	{
		/*
		 * if nothing else was suggested default to stderr
		 */
		if (!debug_port)
			debug_port = stderr;
		fprintf(debug_port, fmt, msg);
		fprintf(debug_port, "\n");
	}
}

/* --------------------------------
 *		PQtrace() / PQuntrace()
 * --------------------------------
 */
void
PQtrace()
{
	PQtracep = 1;
}

void
PQuntrace()
{
	PQtracep = 0;
}