Commit 3b3ffc8d authored by Marc G. Fournier's avatar Marc G. Fournier

From: Magnus Hagander <mha@sollentuna.net>

Here is a first patch to cleanup the backend side of libpq.
This patch removes all external dependencies on the "Pfin" and "Pfout" that
are declared in pqcomm.h. These variables are also changed to "static" to
make sure.
Almost all the change is in the handler of the "copy" command - most other
areas of the backend already used the correct functions.
This change will make the way for cleanup of the internal stuff there - now
that all the functions accessing the file descriptors are confined to a
single directory.
parent 6d5d673c
This diff is collapsed.
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: pqcomm.c,v 1.59 1998/12/14 06:50:27 scrappy Exp $ * $Id: pqcomm.c,v 1.60 1999/01/11 03:56:06 scrappy Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
* declarations * declarations
* ---------------- * ----------------
*/ */
FILE *Pfout, static FILE *Pfout,
*Pfin, *Pfin,
*Pfdebug; /* debugging libpq */ *Pfdebug; /* debugging libpq */
...@@ -98,7 +98,7 @@ pq_init(int fd) ...@@ -98,7 +98,7 @@ pq_init(int fd)
} }
/* ------------------------- /* -------------------------
* pq_getc(File* fin) * pq_getchar()
* *
* get a character from the input file, * get a character from the input file,
* *
...@@ -107,20 +107,29 @@ pq_init(int fd) ...@@ -107,20 +107,29 @@ pq_init(int fd)
* used for debugging libpq * used for debugging libpq
*/ */
#if 0 /* not used anymore */ int
pq_getchar(void)
static int
pq_getc(FILE *fin)
{ {
int c; int c;
c = getc(fin); c = getc(Pfin);
if (Pfdebug && c != EOF) if (Pfdebug && c != EOF)
putc(c, Pfdebug); putc(c, Pfdebug);
return c; return c;
} }
#endif /*
* --------------------------------
* pq_peekchar - get 1 character from connection, but leave it in the stream
*/
int
pq_peekchar(void) {
char c = getc(Pfin);
ungetc(c,Pfin);
return c;
}
/* -------------------------------- /* --------------------------------
* pq_gettty - return the name of the tty in the given buffer * pq_gettty - return the name of the tty in the given buffer
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.36 1999/01/01 04:48:45 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.37 1999/01/11 03:56:07 scrappy Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -67,11 +67,6 @@ elog(int lev, const char *fmt,...) ...@@ -67,11 +67,6 @@ elog(int lev, const char *fmt,...)
extern int errno, extern int errno,
sys_nerr; sys_nerr;
#ifndef PG_STANDALONE
extern FILE *Pfout;
#endif
#ifdef USE_SYSLOG #ifdef USE_SYSLOG
int log_level; int log_level;
...@@ -190,7 +185,7 @@ elog(int lev, const char *fmt,...) ...@@ -190,7 +185,7 @@ elog(int lev, const char *fmt,...)
#ifndef PG_STANDALONE #ifndef PG_STANDALONE
/* Send IPC message to the front-end program */ /* Send IPC message to the front-end program */
if (Pfout != NULL && lev > DEBUG) if (IsUnderPostmaster && lev > DEBUG)
{ {
/* notices are not exactly errors, handle it differently */ /* notices are not exactly errors, handle it differently */
if (lev == NOTICE) if (lev == NOTICE)
...@@ -201,7 +196,7 @@ elog(int lev, const char *fmt,...) ...@@ -201,7 +196,7 @@ elog(int lev, const char *fmt,...)
pq_putstr(line + TIMESTAMP_SIZE); /* don't show timestamps */ pq_putstr(line + TIMESTAMP_SIZE); /* don't show timestamps */
pq_flush(); pq_flush();
} }
if (Pfout == NULL) if (!IsUnderPostmaster)
{ {
/* /*
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: libpq-be.h,v 1.12 1998/09/01 04:36:27 momjian Exp $ * $Id: libpq-be.h,v 1.13 1999/01/11 03:56:11 scrappy Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -131,8 +131,6 @@ typedef struct Port ...@@ -131,8 +131,6 @@ typedef struct Port
} Port; } Port;
extern FILE *Pfout,
*Pfin;
extern ProtocolVersion FrontendProtocol; extern ProtocolVersion FrontendProtocol;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: libpq.h,v 1.21 1998/09/01 04:36:29 momjian Exp $ * $Id: libpq.h,v 1.22 1999/01/11 03:56:11 scrappy Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -258,6 +258,8 @@ extern void pq_flush(void); ...@@ -258,6 +258,8 @@ extern void pq_flush(void);
extern int pq_getstr(char *s, int maxlen); extern int pq_getstr(char *s, int maxlen);
extern int PQgetline(char *s, int maxlen); extern int PQgetline(char *s, int maxlen);
extern int PQputline(char *s); extern int PQputline(char *s);
extern int pq_getchar(void);
extern int pq_peekchar(void);
extern int pq_getnchar(char *s, int off, int maxlen); extern int pq_getnchar(char *s, int off, int maxlen);
extern int pq_getint(int b); extern int pq_getint(int b);
extern void pq_putstr(char *s); extern void pq_putstr(char *s);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment