aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>1997-09-08 02:41:22 +0000
committerBruce Momjian <bruce@momjian.us>1997-09-08 02:41:22 +0000
commit319dbfa7364721d3343af03a7ce063c2a2c9d385 (patch)
treea2146fe02c49ce1e497b7c287dfcaa367a703ae4 /src/interfaces/libpq
parenta90f12fd9d6886da4f0734288496361a304d3882 (diff)
downloadpostgresql-319dbfa7364721d3343af03a7ce063c2a2c9d385.tar.gz
postgresql-319dbfa7364721d3343af03a7ce063c2a2c9d385.zip
Another PGINDENT run that changes variable indenting and case label indenting. Also static variable indenting.
Diffstat (limited to 'src/interfaces/libpq')
-rw-r--r--src/interfaces/libpq/fe-auth.c174
-rw-r--r--src/interfaces/libpq/fe-auth.h4
-rw-r--r--src/interfaces/libpq/fe-connect.c106
-rw-r--r--src/interfaces/libpq/fe-connect.h6
-rw-r--r--src/interfaces/libpq/fe-exec.c646
-rw-r--r--src/interfaces/libpq/fe-lobj.c98
-rw-r--r--src/interfaces/libpq/fe-misc.c50
-rw-r--r--src/interfaces/libpq/libpq-fe.h315
-rw-r--r--src/interfaces/libpq/pqsignal.c4
-rw-r--r--src/interfaces/libpq/pqsignal.h4
10 files changed, 700 insertions, 707 deletions
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index 433cc65ded7..0b4a697f859 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.9 1997/09/07 05:03:17 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.10 1997/09/08 02:40:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -49,9 +49,9 @@
struct authsvc
{
- char name[16]; /* service nickname (for command line) */
- MsgType msgtype; /* startup packet header type */
- int allowed; /* initially allowed (before command line
+ char name[16]; /* service nickname (for command line) */
+ MsgType msgtype; /* startup packet header type */
+ int allowed; /* initially allowed (before command line
* option parsing)? */
};
@@ -84,7 +84,7 @@ static struct authsvc authsvcs[] = {
{"password", STARTUP_PASSWORD_MSG, 0}
};
-static n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc);
+static n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc);
#ifdef KRB4
/*----------------------------------------------------------------
@@ -95,7 +95,7 @@ static n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc);
#include "krb.h"
/* for some reason, this is not defined in krb.h ... */
-extern char *tkt_string(void);
+extern char *tkt_string(void);
/*
* pg_krb4_init -- initialization performed before any Kerberos calls are made
@@ -107,8 +107,8 @@ extern char *tkt_string(void);
static void
pg_krb4_init()
{
- char *realm;
- static init_done = 0;
+ char *realm;
+ static init_done = 0;
if (init_done)
return;
@@ -120,7 +120,7 @@ pg_krb4_init()
*/
if (realm = getenv("PGREALM"))
{
- char tktbuf[MAXPATHLEN];
+ char tktbuf[MAXPATHLEN];
(void) sprintf(tktbuf, "%s@%s", tkt_string(), realm);
krb_set_tkt_string(tktbuf);
@@ -133,13 +133,13 @@ pg_krb4_init()
*
* We obtain this information by digging around in the ticket file.
*/
-static char *
+static char *
pg_krb4_authname(char *PQerrormsg)
{
- char instance[INST_SZ];
- char realm[REALM_SZ];
- int status;
- static char name[SNAME_SZ + 1] = "";
+ char instance[INST_SZ];
+ char realm[REALM_SZ];
+ int status;
+ static char name[SNAME_SZ + 1] = "";
if (name[0])
return (name);
@@ -178,11 +178,11 @@ pg_krb4_sendauth(const char *PQerrormsg, int sock,
struct sockaddr_in * raddr,
const char *hostname)
{
- long krbopts = 0;/* one-way authentication */
- KTEXT_ST clttkt;
- int status;
- char hostbuf[MAXHOSTNAMELEN];
- const char *realm = getenv("PGREALM"); /* NULL == current realm */
+ long krbopts = 0; /* one-way authentication */
+ KTEXT_ST clttkt;
+ int status;
+ char hostbuf[MAXHOSTNAMELEN];
+ const char *realm = getenv("PGREALM"); /* NULL == current realm */
if (!hostname || !(*hostname))
{
@@ -239,10 +239,10 @@ pg_krb4_sendauth(const char *PQerrormsg, int sock,
* krb5_an_to_ln, except that it punts if multiple components are found,
* and we can't afford to punt.
*/
-static char *
+static char *
pg_an_to_ln(const char *aname)
{
- char *p;
+ char *p;
if ((p = strchr(aname, '/')) || (p = strchr(aname, '@')))
*p = '\0';
@@ -259,13 +259,13 @@ pg_an_to_ln(const char *aname)
*
*/
static int
-krb5_ccache
+ krb5_ccache
pg_krb5_init(void)
{
krb5_error_code code;
- char *realm,
- *defname;
- char tktbuf[MAXPATHLEN];
+ char *realm,
+ *defname;
+ char tktbuf[MAXPATHLEN];
static krb5_ccache ccache = (krb5_ccache) NULL;
if (ccache)
@@ -308,10 +308,10 @@ pg_krb5_init(void)
static const char *
pg_krb5_authname(const char *PQerrormsg)
{
- krb5_ccache ccache;
- krb5_principal principal;
+ krb5_ccache ccache;
+ krb5_principal principal;
krb5_error_code code;
- static char *authname = (char *) NULL;
+ static char *authname = (char *) NULL;
if (authname)
return (authname);
@@ -360,15 +360,15 @@ pg_krb5_sendauth(const char *PQerrormsg, int sock,
struct sockaddr_in * raddr,
const char *hostname)
{
- char servbuf[MAXHOSTNAMELEN + 1 +
- sizeof(PG_KRB_SRVNAM)];
- const char *hostp;
- const char *realm;
+ char servbuf[MAXHOSTNAMELEN + 1 +
+ sizeof(PG_KRB_SRVNAM)];
+ const char *hostp;
+ const char *realm;
krb5_error_code code;
- krb5_principal client,
- server;
- krb5_ccache ccache;
- krb5_error *error = (krb5_error *) NULL;
+ krb5_principal client,
+ server;
+ krb5_ccache ccache;
+ krb5_error *error = (krb5_error *) NULL;
ccache = pg_krb5_init(); /* don't free this */
@@ -459,8 +459,8 @@ pg_krb5_sendauth(const char *PQerrormsg, int sock,
static int
pg_password_sendauth(Port * port, const char *user, const char *password)
{
- PacketBuf buf;
- char *tmp;
+ PacketBuf buf;
+ char *tmp;
buf.len = htonl(sizeof(PacketBuf));
buf.msgtype = STARTUP_PASSWORD_MSG;
@@ -484,36 +484,36 @@ fe_sendauth(MsgType msgtype, Port * port, const char *hostname,
switch (msgtype)
{
#ifdef KRB4
- case STARTUP_KRB4_MSG:
- if (pg_krb4_sendauth(PQerrormsg, port->sock, &port->laddr,
- &port->raddr,
- hostname) != STATUS_OK)
- {
- (void) sprintf(PQerrormsg,
- "fe_sendauth: krb4 authentication failed\n");
+ case STARTUP_KRB4_MSG:
+ if (pg_krb4_sendauth(PQerrormsg, port->sock, &port->laddr,
+ &port->raddr,
+ hostname) != STATUS_OK)
+ {
+ (void) sprintf(PQerrormsg,
+ "fe_sendauth: krb4 authentication failed\n");
/* fputs(PQerrormsg, stderr); */
- return (STATUS_ERROR);
- }
- break;
+ return (STATUS_ERROR);
+ }
+ break;
#endif
#ifdef KRB5
- case STARTUP_KRB5_MSG:
- if (pg_krb5_sendauth(PQerrormsg, port->sock, &port->laddr,
- &port->raddr,
- hostname) != STATUS_OK)
- {
- (void) sprintf(PQerrormsg,
- "fe_sendauth: krb5 authentication failed\n");
- return (STATUS_ERROR);
- }
- break;
+ case STARTUP_KRB5_MSG:
+ if (pg_krb5_sendauth(PQerrormsg, port->sock, &port->laddr,
+ &port->raddr,
+ hostname) != STATUS_OK)
+ {
+ (void) sprintf(PQerrormsg,
+ "fe_sendauth: krb5 authentication failed\n");
+ return (STATUS_ERROR);
+ }
+ break;
#endif
- case STARTUP_MSG:
- break;
- case STARTUP_PASSWORD_MSG:
- pg_password_sendauth(port, user, password);
- default:
- break;
+ case STARTUP_MSG:
+ break;
+ case STARTUP_PASSWORD_MSG:
+ pg_password_sendauth(port, user, password);
+ default:
+ break;
}
return (STATUS_OK);
}
@@ -525,12 +525,12 @@ fe_sendauth(MsgType msgtype, Port * port, const char *hostname,
* Set/return the authentication service currently selected for use by the
* frontend. (You can only use one in the frontend, obviously.)
*/
-static pg_authsvc = -1;
+static pg_authsvc = -1;
void
fe_setauthsvc(const char *name, char *PQerrormsg)
{
- int i;
+ int i;
for (i = 0; i < n_authsvcs; ++i)
if (!strcmp(name, authsvcs[i].name))
@@ -560,39 +560,39 @@ fe_getauthsvc(char *PQerrormsg)
* name the user has authenticated to the system
* if there is an error, return the error message in PQerrormsg
*/
-char *
+char *
fe_getauthname(char *PQerrormsg)
{
- char *name = (char *) NULL;
- char *authn = (char *) NULL;
- MsgType authsvc;
+ char *name = (char *) NULL;
+ char *authn = (char *) NULL;
+ MsgType authsvc;
authsvc = fe_getauthsvc(PQerrormsg);
switch ((int) authsvc)
{
#ifdef KRB4
- case STARTUP_KRB4_MSG:
- name = pg_krb4_authname(PQerrormsg);
- break;
+ case STARTUP_KRB4_MSG:
+ name = pg_krb4_authname(PQerrormsg);
+ break;
#endif
#ifdef KRB5
- case STARTUP_KRB5_MSG:
- name = pg_krb5_authname(PQerrormsg);
- break;
+ case STARTUP_KRB5_MSG:
+ name = pg_krb5_authname(PQerrormsg);
+ break;
#endif
- case STARTUP_MSG:
- {
- struct passwd *pw = getpwuid(geteuid());
+ case STARTUP_MSG:
+ {
+ struct passwd *pw = getpwuid(geteuid());
- if (pw)
- name = pw->pw_name;
- }
- break;
- default:
- (void) sprintf(PQerrormsg,
+ if (pw)
+ name = pw->pw_name;
+ }
+ break;
+ default:
+ (void) sprintf(PQerrormsg,
"fe_getauthname: invalid authentication system: %d\n",
- authsvc);
- break;
+ authsvc);
+ break;
}
if (name && (authn = (char *) malloc(strlen(name) + 1)))
diff --git a/src/interfaces/libpq/fe-auth.h b/src/interfaces/libpq/fe-auth.h
index 6ca83fe4e89..6bd4530a285 100644
--- a/src/interfaces/libpq/fe-auth.h
+++ b/src/interfaces/libpq/fe-auth.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: fe-auth.h,v 1.4 1997/09/07 05:03:21 momjian Exp $
+ * $Id: fe-auth.h,v 1.5 1997/09/08 02:40:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -32,7 +32,7 @@ extern int
fe_sendauth(MsgType msgtype, Port * port, const char *hostname,
const char *user, const char *password,
const char *PQerromsg);
-extern void fe_setauthsvc(const char *name, char *PQerrormsg);
+extern void fe_setauthsvc(const char *name, char *PQerrormsg);
#define PG_KRB4_VERSION "PGVER4.1" /* at most KRB_SENDAUTH_VLEN chars */
#define PG_KRB5_VERSION "PGVER5.1"
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 1b6a1c1243d..c338f49ca3e 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.39 1997/09/07 05:03:24 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.40 1997/09/08 02:40:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -41,12 +41,12 @@
/* use a local version instead of the one found in pqpacket.c */
static ConnStatusType connectDB(PGconn * conn);
-static void startup2PacketBuf(StartupInfo * s, PacketBuf * res);
-static void freePGconn(PGconn * conn);
-static void closePGconn(PGconn * conn);
-static int conninfo_parse(const char *conninfo, char *errorMessage);
-static char *conninfo_getval(char *keyword);
-static void conninfo_free(void);
+static void startup2PacketBuf(StartupInfo * s, PacketBuf * res);
+static void freePGconn(PGconn * conn);
+static void closePGconn(PGconn * conn);
+static int conninfo_parse(const char *conninfo, char *errorMessage);
+static char *conninfo_getval(char *keyword);
+static void conninfo_free(void);
#define NOTIFYLIST_INITIAL_SIZE 10
#define NOTIFYLIST_GROWBY 10
@@ -104,9 +104,9 @@ static PQconninfoOption PQconninfoOptions[] = {
struct EnvironmentOptions
{
- const char *envName,
- *pgName;
-} EnvironmentOptions[] =
+ const char *envName,
+ *pgName;
+} EnvironmentOptions[] =
{
{
@@ -136,12 +136,12 @@ struct EnvironmentOptions
* then some fields may be null'ed out instead of having valid values
* ----------------
*/
-PGconn *
+PGconn *
PQconnectdb(const char *conninfo)
{
- PGconn *conn;
+ PGconn *conn;
PQconninfoOption *option;
- char errorMessage[ERROR_MSG_LENGTH];
+ char errorMessage[ERROR_MSG_LENGTH];
/* ----------
* Allocate memory for the conn structure
@@ -240,7 +240,7 @@ PQconnectdb(const char *conninfo)
conn->status = connectDB(conn);
if (conn->status == CONNECTION_OK)
{
- PGresult *res;
+ PGresult *res;
/*
* Send a blank query to make sure everything works; in
@@ -270,7 +270,7 @@ PQconnectdb(const char *conninfo)
PQconninfoOption *
PQconndefaults(void)
{
- char errorMessage[ERROR_MSG_LENGTH];
+ char errorMessage[ERROR_MSG_LENGTH];
conninfo_parse("", errorMessage);
return PQconninfoOptions;
@@ -311,18 +311,18 @@ PQconndefaults(void)
*
* ----------------
*/
-PGconn *
+PGconn *
PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const char *pgtty, const char *dbName)
{
- PGconn *conn;
- char *tmp;
- char errorMessage[ERROR_MSG_LENGTH];
+ PGconn *conn;
+ char *tmp;
+ char errorMessage[ERROR_MSG_LENGTH];
/* An error message from some service we call. */
- bool error;
+ bool error;
/* We encountered an error that prevents successful completion */
- int i;
+ int i;
conn = (PGconn *) malloc(sizeof(PGconn));
@@ -436,7 +436,7 @@ PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const cha
/* Puts message in conn->errorMessage */
if (conn->status == CONNECTION_OK)
{
- PGresult *res;
+ PGresult *res;
/*
* Send a blank query to make sure everything works; in
@@ -462,18 +462,18 @@ PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const cha
* return CONNECTION_OK if successful, CONNECTION_BAD if not.
*
*/
-static ConnStatusType
+static ConnStatusType
connectDB(PGconn * conn)
{
struct hostent *hp;
- StartupInfo startup;
- PacketBuf pacBuf;
- int status;
- MsgType msgtype;
- int laddrlen = sizeof(struct sockaddr);
- Port *port = conn->port;
- int portno;
+ StartupInfo startup;
+ PacketBuf pacBuf;
+ int status;
+ MsgType msgtype;
+ int laddrlen = sizeof(struct sockaddr);
+ Port *port = conn->port;
+ int portno;
/*
* Initialize the startup packet.
@@ -534,7 +534,7 @@ connectDB(PGconn * conn)
}
{
struct protoent *pe;
- int on = 1;
+ int on = 1;
pe = getprotobyname("TCP");
if (pe == NULL)
@@ -609,15 +609,15 @@ connectDB(PGconn * conn)
{
struct EnvironmentOptions *eo;
- char setQuery[80]; /* mjl: size okay? XXX */
+ char setQuery[80]; /* mjl: size okay? XXX */
for (eo = EnvironmentOptions; eo->envName; eo++)
{
- const char *val;
+ const char *val;
if ((val = getenv(eo->envName)))
{
- PGresult *res;
+ PGresult *res;
sprintf(setQuery, "SET %s TO '%.60s'", eo->pgName, val);
res = PQexec(conn, setQuery);
@@ -699,7 +699,7 @@ closePGconn(PGconn * conn)
fflush(conn->Pfout);
sigaction(SIGPIPE, &oldaction, NULL);
#else
- signal(SIGPIPE, SIG_IGN);
+ signal(SIGPIPE, SIG_IGN);
fputs("X\0", conn->Pfout);
fflush(conn->Pfout);
signal(SIGPIPE, SIG_DFL);
@@ -773,8 +773,8 @@ packetSend(Port * port,
PacketLen len,
bool nonBlocking)
{
- PacketLen totalLen;
- int addrLen = sizeof(struct sockaddr_in);
+ PacketLen totalLen;
+ int addrLen = sizeof(struct sockaddr_in);
totalLen = len;
@@ -800,7 +800,7 @@ packetSend(Port * port,
static void
startup2PacketBuf(StartupInfo * s, PacketBuf * res)
{
- char *tmp;
+ char *tmp;
/* res = (PacketBuf*)malloc(sizeof(PacketBuf)); */
res->len = htonl(sizeof(PacketBuf));
@@ -827,14 +827,14 @@ startup2PacketBuf(StartupInfo * s, PacketBuf * res)
static int
conninfo_parse(const char *conninfo, char *errorMessage)
{
- char *pname;
- char *pval;
- char *buf;
- char *tmp;
- char *cp;
- char *cp2;
+ char *pname;
+ char *pval;
+ char *buf;
+ char *tmp;
+ char *cp;
+ char *cp2;
PQconninfoOption *option;
- char errortmp[ERROR_MSG_LENGTH];
+ char errortmp[ERROR_MSG_LENGTH];
conninfo_free();
@@ -1054,7 +1054,7 @@ conninfo_parse(const char *conninfo, char *errorMessage)
}
-static char *
+static char *
conninfo_getval(char *keyword)
{
PQconninfoOption *option;
@@ -1087,7 +1087,7 @@ conninfo_free()
}
/* =========== accessor functions for PGconn ========= */
-char *
+char *
PQdb(PGconn * conn)
{
if (!conn)
@@ -1098,7 +1098,7 @@ PQdb(PGconn * conn)
return conn->dbName;
}
-char *
+char *
PQuser(PGconn * conn)
{
if (!conn)
@@ -1109,7 +1109,7 @@ PQuser(PGconn * conn)
return conn->pguser;
}
-char *
+char *
PQhost(PGconn * conn)
{
if (!conn)
@@ -1121,7 +1121,7 @@ PQhost(PGconn * conn)
return conn->pghost;
}
-char *
+char *
PQoptions(PGconn * conn)
{
if (!conn)
@@ -1132,7 +1132,7 @@ PQoptions(PGconn * conn)
return conn->pgoptions;
}
-char *
+char *
PQtty(PGconn * conn)
{
if (!conn)
@@ -1143,7 +1143,7 @@ PQtty(PGconn * conn)
return conn->pgtty;
}
-char *
+char *
PQport(PGconn * conn)
{
if (!conn)
@@ -1165,7 +1165,7 @@ PQstatus(PGconn * conn)
return conn->status;
}
-char *
+char *
PQerrorMessage(PGconn * conn)
{
if (!conn)
diff --git a/src/interfaces/libpq/fe-connect.h b/src/interfaces/libpq/fe-connect.h
index 5bd38084488..bf4c5cdf35d 100644
--- a/src/interfaces/libpq/fe-connect.h
+++ b/src/interfaces/libpq/fe-connect.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: fe-connect.h,v 1.2 1997/09/07 05:03:26 momjian Exp $
+ * $Id: fe-connect.h,v 1.3 1997/09/08 02:40:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -18,12 +18,12 @@
*----------------------------------------------------------------
*/
-extern int packetSend(Port * port, PacketBuf * buf, PacketLen len, bool nonBlocking);
+extern int packetSend(Port * port, PacketBuf * buf, PacketLen len, bool nonBlocking);
#endif /* FE_CONNECT_H */
#ifndef FE_CONNECT_H
#define FE_CONNECT_H
-int packetSend(Port * port, PacketBuf * buf, PacketLen len, bool nonBlocking);
+int packetSend(Port * port, PacketBuf * buf, PacketLen len, bool nonBlocking);
#endif
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index be8913e7bf7..454555bfda3 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.36 1997/09/07 05:03:28 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.37 1997/09/08 02:40:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -30,14 +30,14 @@
#ifdef TIOCGWINSZ
-struct winsize screen_size;
+struct winsize screen_size;
#else
struct winsize
{
- int ws_row;
- int ws_col;
-} screen_size;
+ int ws_row;
+ int ws_col;
+} screen_size;
#endif
@@ -46,7 +46,7 @@ struct winsize
#define TUPARR_GROW_BY 100
/* keep this in same order as ExecStatusType in pgtclCmds.h */
-const char *pgresStatus[] = {
+const char *pgresStatus[] = {
"PGRES_EMPTY_QUERY",
"PGRES_COMMAND_OK",
"PGRES_TUPLES_OK",
@@ -57,11 +57,11 @@ const char *pgresStatus[] = {
static PGresult *makePGresult(PGconn * conn, char *pname);
-static void addTuple(PGresult * res, PGresAttValue * tup);
+static void addTuple(PGresult * res, PGresAttValue * tup);
static PGresAttValue *getTuple(PGconn * conn, PGresult * res, int binary);
static PGresult *makeEmptyPGresult(PGconn * conn, ExecStatusType status);
-static void fill(int length, int max, char filler, FILE * fp);
-static char *
+static void fill(int length, int max, char filler, FILE * fp);
+static char *
do_header(FILE * fout, PQprintOpt * po, const int nFields,
int fieldMax[], char *fieldNames[], unsigned char fieldNotNum[],
const int fs_len, PGresult * res);
@@ -74,8 +74,8 @@ do_header(FILE * fout, PQprintOpt * po, const int nFields,
void
PQclear(PGresult * res)
{
- int i,
- j;
+ int i,
+ j;
if (!res)
return;
@@ -116,7 +116,7 @@ PQclear(PGresult * res)
static PGresult *
makeEmptyPGresult(PGconn * conn, ExecStatusType status)
{
- PGresult *result;
+ PGresult *result;
result = (PGresult *) malloc(sizeof(PGresult));
@@ -142,22 +142,22 @@ makeEmptyPGresult(PGconn * conn, ExecStatusType status)
static PGresAttValue *
getTuple(PGconn * conn, PGresult * result, int binary)
{
- char bitmap[MAX_FIELDS]; /* the backend sends us a bitmap
+ char bitmap[MAX_FIELDS]; /* the backend sends us a bitmap
* of */
/* which attributes are null */
- int bitmap_index = 0;
- int i;
- int nbytes; /* the number of bytes in bitmap */
- char bmap; /* One byte of the bitmap */
- int bitcnt = 0; /* number of bits examined in current byte */
- int vlen; /* length of the current field value */
- FILE *pfin = conn->Pfin;
- FILE *pfdebug = conn->Pfdebug;
+ int bitmap_index = 0;
+ int i;
+ int nbytes; /* the number of bytes in bitmap */
+ char bmap; /* One byte of the bitmap */
+ int bitcnt = 0; /* number of bits examined in current byte */
+ int vlen; /* length of the current field value */
+ FILE *pfin = conn->Pfin;
+ FILE *pfdebug = conn->Pfdebug;
- PGresAttValue *tup;
+ PGresAttValue *tup;
- int nfields = result->numAttributes;
+ int nfields = result->numAttributes;
result->binary = binary;
@@ -264,16 +264,16 @@ addTuple(PGresult * res, PGresAttValue * tup)
static PGresult *
makePGresult(PGconn * conn, char *pname)
{
- PGresult *result;
- int id;
- int nfields;
- int i;
- int done = 0;
+ PGresult *result;
+ int id;
+ int nfields;
+ int i;
+ int done = 0;
- PGresAttValue *newTup;
+ PGresAttValue *newTup;
- FILE *pfin = conn->Pfin;
- FILE *pfdebug = conn->Pfdebug;
+ FILE *pfin = conn->Pfin;
+ FILE *pfdebug = conn->Pfdebug;
result = makeEmptyPGresult(conn, PGRES_TUPLES_OK);
@@ -299,9 +299,9 @@ makePGresult(PGconn * conn, char *pname)
/* get type info */
for (i = 0; i < nfields; i++)
{
- char typName[MAX_MESSAGE_LEN];
- int adtid;
- int adtsize;
+ char typName[MAX_MESSAGE_LEN];
+ int adtid;
+ int adtsize;
if (pqGets(typName, MAX_MESSAGE_LEN, pfin, pfdebug) ||
pqGetInt(&adtid, 4, pfin, pfdebug) ||
@@ -325,57 +325,57 @@ makePGresult(PGconn * conn, char *pname)
{
switch (id)
{
- case 'T': /* a new row group */
- sprintf(conn->errorMessage,
- "makePGresult() -- "
- "is not equipped to handle multiple row groups.\n");
- goto makePGresult_badResponse_return;
- case 'B': /* a row in binary format */
- case 'D': /* a row in ASCII format */
- newTup = getTuple(conn, result, (id == 'B'));
- if (newTup == NULL)
+ case 'T': /* a new row group */
+ sprintf(conn->errorMessage,
+ "makePGresult() -- "
+ "is not equipped to handle multiple row groups.\n");
goto makePGresult_badResponse_return;
- addTuple(result, newTup);
- break;
- case 'C': /* end of portal row stream */
- {
- char command[MAX_MESSAGE_LEN];
+ case 'B': /* a row in binary format */
+ case 'D': /* a row in ASCII format */
+ newTup = getTuple(conn, result, (id == 'B'));
+ if (newTup == NULL)
+ goto makePGresult_badResponse_return;
+ addTuple(result, newTup);
+ break;
+ case 'C': /* end of portal row stream */
+ {
+ char command[MAX_MESSAGE_LEN];
- pqGets(command, MAX_MESSAGE_LEN, pfin, pfdebug); /* read command tag */
- done = 1;
- }
- break;
- case 'E': /* errors */
- if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug) == 1)
- {
- sprintf(conn->errorMessage,
- "Error return detected from backend, "
- "but error message cannot be read");
- }
- result->resultStatus = PGRES_FATAL_ERROR;
- return result;
- break;
- case 'N': /* notices from the backend */
- if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug) == 1)
- {
- sprintf(conn->errorMessage,
- "Notice return detected from backend, "
- "but error message cannot be read");
- }
- else
- /* XXXX send Notices to stderr for now */
- fprintf(stderr, "%s\n", conn->errorMessage);
- break;
- default: /* uh-oh this should never happen but
+ pqGets(command, MAX_MESSAGE_LEN, pfin, pfdebug); /* read command tag */
+ done = 1;
+ }
+ break;
+ case 'E': /* errors */
+ if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug) == 1)
+ {
+ sprintf(conn->errorMessage,
+ "Error return detected from backend, "
+ "but error message cannot be read");
+ }
+ result->resultStatus = PGRES_FATAL_ERROR;
+ return result;
+ break;
+ case 'N': /* notices from the backend */
+ if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug) == 1)
+ {
+ sprintf(conn->errorMessage,
+ "Notice return detected from backend, "
+ "but error message cannot be read");
+ }
+ else
+ /* XXXX send Notices to stderr for now */
+ fprintf(stderr, "%s\n", conn->errorMessage);
+ break;
+ default: /* uh-oh this should never happen but
* frequently does when the backend dumps
* core */
- sprintf(conn->errorMessage,
- "FATAL: unrecognized data from the backend. "
- "It probably dumped core.\n");
- fprintf(stderr, conn->errorMessage);
- result->resultStatus = PGRES_FATAL_ERROR;
- return result;
- break;
+ sprintf(conn->errorMessage,
+ "FATAL: unrecognized data from the backend. "
+ "It probably dumped core.\n");
+ fprintf(stderr, conn->errorMessage);
+ result->resultStatus = PGRES_FATAL_ERROR;
+ return result;
+ break;
}
if (!done)
id = getc(pfin);
@@ -411,32 +411,32 @@ process_response_from_backend(FILE * pfin, FILE * pfout, FILE * pfdebug,
PGresult ** result_p, char *const reason)
{
- int id;
+ int id;
/*
* The protocol character received from the backend. The protocol
* character is the first character in the backend's response to our
* query. It defines the nature of the response.
*/
- PGnotify *newNotify;
- bool done;
+ PGnotify *newNotify;
+ bool done;
/* We're all done with the query and ready to return the result. */
- int emptiesSent;
+ int emptiesSent;
/*
* Number of empty queries we have sent in order to flush out multiple
* responses, less the number of corresponding responses we have
* received.
*/
- int errors;
+ int errors;
/*
* If an error is received, we must still drain out the empty queries
* sent. So we need another flag.
*/
- char cmdStatus[MAX_MESSAGE_LEN];
- char pname[MAX_MESSAGE_LEN]; /* portal name */
+ char cmdStatus[MAX_MESSAGE_LEN];
+ char pname[MAX_MESSAGE_LEN]; /* portal name */
/*
* loop because multiple messages, especially NOTICES, can come back
@@ -470,82 +470,95 @@ process_response_from_backend(FILE * pfin, FILE * pfout, FILE * pfdebug,
{
switch (id)
{
- case 'A':
- newNotify = (PGnotify *) malloc(sizeof(PGnotify));
- pqGetInt(&(newNotify->be_pid), 4, pfin, pfdebug);
- pqGets(newNotify->relname, NAMEDATALEN, pfin, pfdebug);
- DLAddTail(conn->notifyList, DLNewElem(newNotify));
-
- /*
- * async messages are piggy'ed back on other messages, so
- * we stay in the while loop for other messages
- */
- break;
- case 'C': /* portal query command, no rows returned */
- if (pqGets(cmdStatus, MAX_MESSAGE_LEN, pfin, pfdebug) == 1)
- {
- sprintf(reason,
- "PQexec() -- query command completed, "
- "but return message from backend cannot be read.");
- *result_p = (PGresult *) NULL;
- done = true;
- }
- else
- {
+ case 'A':
+ newNotify = (PGnotify *) malloc(sizeof(PGnotify));
+ pqGetInt(&(newNotify->be_pid), 4, pfin, pfdebug);
+ pqGets(newNotify->relname, NAMEDATALEN, pfin, pfdebug);
+ DLAddTail(conn->notifyList, DLNewElem(newNotify));
/*
- * since backend may produce more than one result for
- * some commands need to poll until clear send an
- * empty query down, and keep reading out of the pipe
- * until an 'I' is received.
+ * async messages are piggy'ed back on other messages,
+ * so we stay in the while loop for other messages
*/
- pqPuts("Q ", pfout, pfdebug); /* send an empty query */
-
- /*
- * Increment a flag and process messages in the usual
- * way because there may be async notifications
- * pending. DZ - 31-8-1996
- */
- emptiesSent++;
- }
- break;
- case 'E': /* error return */
- if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug) == 1)
- {
- (void) sprintf(reason,
- "PQexec() -- error return detected from backend, "
- "but attempt to read the error message failed.");
- }
- *result_p = (PGresult *) NULL;
- errors++;
- if (emptiesSent == 0)
- {
- done = true;
- }
- break;
- case 'I':
- { /* empty query */
- /* read and throw away the closing '\0' */
- int c;
+ break;
+ case 'C': /* portal query command, no rows returned */
+ if (pqGets(cmdStatus, MAX_MESSAGE_LEN, pfin, pfdebug) == 1)
+ {
+ sprintf(reason,
+ "PQexec() -- query command completed, "
+ "but return message from backend cannot be read.");
+ *result_p = (PGresult *) NULL;
+ done = true;
+ }
+ else
+ {
- if ((c = pqGetc(pfin, pfdebug)) != '\0')
+ /*
+ * since backend may produce more than one result
+ * for some commands need to poll until clear send
+ * an empty query down, and keep reading out of
+ * the pipe until an 'I' is received.
+ */
+ pqPuts("Q ", pfout, pfdebug); /* send an empty query */
+
+ /*
+ * Increment a flag and process messages in the
+ * usual way because there may be async
+ * notifications pending. DZ - 31-8-1996
+ */
+ emptiesSent++;
+ }
+ break;
+ case 'E': /* error return */
+ if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug) == 1)
{
- fprintf(stderr, "error!, unexpected character %c following 'I'\n", c);
+ (void) sprintf(reason,
+ "PQexec() -- error return detected from backend, "
+ "but attempt to read the error message failed.");
}
- if (emptiesSent)
+ *result_p = (PGresult *) NULL;
+ errors++;
+ if (emptiesSent == 0)
{
- if (--emptiesSent == 0)
- { /* is this the last one? */
-
- /*
- * If this is the result of a portal query
- * command set the command status and message
- * accordingly. DZ - 31-8-1996
- */
+ done = true;
+ }
+ break;
+ case 'I':
+ { /* empty query */
+ /* read and throw away the closing '\0' */
+ int c;
+
+ if ((c = pqGetc(pfin, pfdebug)) != '\0')
+ {
+ fprintf(stderr, "error!, unexpected character %c following 'I'\n", c);
+ }
+ if (emptiesSent)
+ {
+ if (--emptiesSent == 0)
+ { /* is this the last one? */
+
+ /*
+ * If this is the result of a portal query
+ * command set the command status and
+ * message accordingly. DZ - 31-8-1996
+ */
+ if (!errors)
+ {
+ *result_p = makeEmptyPGresult(conn, PGRES_COMMAND_OK);
+ strncpy((*result_p)->cmdStatus, cmdStatus, CMDSTATUS_LEN - 1);
+ }
+ else
+ {
+ *result_p = (PGresult *) NULL;
+ }
+ done = true;
+ }
+ }
+ else
+ {
if (!errors)
{
- *result_p = makeEmptyPGresult(conn, PGRES_COMMAND_OK);
- strncpy((*result_p)->cmdStatus, cmdStatus, CMDSTATUS_LEN - 1);
+ *result_p = makeEmptyPGresult(conn, PGRES_EMPTY_QUERY);
}
else
{
@@ -554,62 +567,50 @@ process_response_from_backend(FILE * pfin, FILE * pfout, FILE * pfdebug,
done = true;
}
}
- else
+ break;
+ case 'N': /* notices from the backend */
+ if (pqGets(reason, ERROR_MSG_LENGTH, pfin, pfdebug) == 1)
{
- if (!errors)
- {
- *result_p = makeEmptyPGresult(conn, PGRES_EMPTY_QUERY);
- }
- else
- {
- *result_p = (PGresult *) NULL;
- }
+ sprintf(reason,
+ "PQexec() -- Notice detected from backend, "
+ "but attempt to read the notice failed.");
+ *result_p = (PGresult *) NULL;
done = true;
}
- }
- break;
- case 'N': /* notices from the backend */
- if (pqGets(reason, ERROR_MSG_LENGTH, pfin, pfdebug) == 1)
- {
+ else
+
+ /*
+ * Should we really be doing this? These notices
+ * are not important enough for us to presume to
+ * put them on stderr. Maybe the caller should
+ * decide whether to put them on stderr or not.
+ * BJH 96.12.27
+ */
+ fprintf(stderr, "%s", reason);
+ break;
+ case 'P': /* synchronous (normal) portal */
+ pqGets(pname, MAX_MESSAGE_LEN, pfin, pfdebug); /* read in portal name */
+ break;
+ case 'T': /* actual row results: */
+ *result_p = makePGresult(conn, pname);
+ done = true;
+ break;
+ case 'D': /* copy command began successfully */
+ *result_p = makeEmptyPGresult(conn, PGRES_COPY_IN);
+ done = true;
+ break;
+ case 'B': /* copy command began successfully */
+ *result_p = makeEmptyPGresult(conn, PGRES_COPY_OUT);
+ done = true;
+ break;
+ default:
sprintf(reason,
- "PQexec() -- Notice detected from backend, "
- "but attempt to read the notice failed.");
+ "unknown protocol character '%c' read from backend. "
+ "(The protocol character is the first character the "
+ "backend sends in response to a query it receives).\n",
+ id);
*result_p = (PGresult *) NULL;
done = true;
- }
- else
-
- /*
- * Should we really be doing this? These notices are
- * not important enough for us to presume to put them
- * on stderr. Maybe the caller should decide whether
- * to put them on stderr or not. BJH 96.12.27
- */
- fprintf(stderr, "%s", reason);
- break;
- case 'P': /* synchronous (normal) portal */
- pqGets(pname, MAX_MESSAGE_LEN, pfin, pfdebug); /* read in portal name */
- break;
- case 'T': /* actual row results: */
- *result_p = makePGresult(conn, pname);
- done = true;
- break;
- case 'D': /* copy command began successfully */
- *result_p = makeEmptyPGresult(conn, PGRES_COPY_IN);
- done = true;
- break;
- case 'B': /* copy command began successfully */
- *result_p = makeEmptyPGresult(conn, PGRES_COPY_OUT);
- done = true;
- break;
- default:
- sprintf(reason,
- "unknown protocol character '%c' read from backend. "
- "(The protocol character is the first character the "
- "backend sends in response to a query it receives).\n",
- id);
- *result_p = (PGresult *) NULL;
- done = true;
} /* switch on protocol character */
} /* if character was received */
} /* while not done */
@@ -628,11 +629,11 @@ process_response_from_backend(FILE * pfin, FILE * pfout, FILE * pfdebug,
*
*/
-PGresult *
+PGresult *
PQexec(PGconn * conn, const char *query)
{
- PGresult *result;
- char buffer[MAX_MESSAGE_LEN];
+ PGresult *result;
+ char buffer[MAX_MESSAGE_LEN];
if (!conn)
return NULL;
@@ -690,10 +691,10 @@ PQexec(PGconn * conn, const char *query)
* the CALLER is responsible for FREE'ing the structure returned
*/
-PGnotify *
+PGnotify *
PQnotifies(PGconn * conn)
{
- Dlelem *e;
+ Dlelem *e;
if (!conn)
return NULL;
@@ -728,7 +729,7 @@ PQnotifies(PGconn * conn)
int
PQgetline(PGconn * conn, char *s, int maxlen)
{
- int c = '\0';
+ int c = '\0';
if (!conn)
return EOF;
@@ -784,9 +785,9 @@ PQputline(PGconn * conn, const char *s)
int
PQendcopy(PGconn * conn)
{
- FILE *pfin,
- *pfdebug;
- bool valid = true;
+ FILE *pfin,
+ *pfdebug;
+ bool valid = true;
if (!conn)
return (int) NULL;
@@ -796,7 +797,7 @@ PQendcopy(PGconn * conn)
if (pqGetc(pfin, pfdebug) == 'C')
{
- char command[MAX_MESSAGE_LEN];
+ char command[MAX_MESSAGE_LEN];
pqGets(command, MAX_MESSAGE_LEN, pfin, pfdebug); /* read command tag */
}
@@ -820,8 +821,8 @@ PQendcopy(PGconn * conn)
static void
fill(int length, int max, char filler, FILE * fp)
{
- int count;
- char filltmp[2];
+ int count;
+ char filltmp[2];
filltmp[0] = filler;
filltmp[1] = 0;
@@ -847,11 +848,11 @@ PQdisplayTuples(PGresult * res,
{
#define DEFAULT_FIELD_SEP " "
- int i,
- j;
- int nFields;
- int nTuples;
- int fLength[MAX_FIELDS];
+ int i,
+ j;
+ int nFields;
+ int nTuples;
+ int fLength[MAX_FIELDS];
if (fieldSep == NULL)
fieldSep = DEFAULT_FIELD_SEP;
@@ -941,13 +942,13 @@ PQprintTuples(PGresult * res,
* width */
)
{
- int nFields;
- int nTups;
- int i,
- j;
- char formatString[80];
+ int nFields;
+ int nTups;
+ int i,
+ j;
+ char formatString[80];
- char *tborder = NULL;
+ char *tborder = NULL;
nFields = PQnfields(res);
nTups = PQntuples(res);
@@ -964,7 +965,7 @@ PQprintTuples(PGresult * res,
if (!TerseOutput)
{
- int width;
+ int width;
width = nFields * 14;
tborder = malloc(width + 1);
@@ -996,7 +997,7 @@ PQprintTuples(PGresult * res,
{
for (j = 0; j < nFields; j++)
{
- char *pval = PQgetvalue(res, i, j);
+ char *pval = PQgetvalue(res, i, j);
fprintf(fout, formatString,
TerseOutput ? "" : "|",
@@ -1022,11 +1023,11 @@ do_field(PQprintOpt * po, PGresult * res,
)
{
- char *pval,
- *p,
- *o;
- int plen;
- bool skipit;
+ char *pval,
+ *p,
+ *o;
+ int plen;
+ bool skipit;
plen = PQgetlength(res, i, j);
pval = PQgetvalue(res, i, j);
@@ -1062,7 +1063,7 @@ do_field(PQprintOpt * po, PGresult * res,
*o = '\0';
if (!po->expanded && (po->align || po->html3))
{
- int n = strlen(buf);
+ int n = strlen(buf);
if (n > fieldMax[j])
fieldMax[j] = n;
@@ -1112,23 +1113,23 @@ do_field(PQprintOpt * po, PGresult * res,
}
-static char *
+static char *
do_header(FILE * fout, PQprintOpt * po, const int nFields, int fieldMax[],
char *fieldNames[], unsigned char fieldNotNum[],
const int fs_len, PGresult * res)
{
- int j; /* for loop index */
- char *border = NULL;
+ int j; /* for loop index */
+ char *border = NULL;
if (po->html3)
fputs("<tr>", fout);
else
{
- int j; /* for loop index */
- int tot = 0;
- int n = 0;
- char *p = NULL;
+ int j; /* for loop index */
+ int tot = 0;
+ int n = 0;
+ char *p = NULL;
for (; n < nFields; n++)
tot += fieldMax[n] + fs_len + (po->standard ? 2 : 0);
@@ -1143,19 +1144,19 @@ do_header(FILE * fout, PQprintOpt * po, const int nFields, int fieldMax[],
p = border;
if (po->standard)
{
- char *fs = po->fieldSep;
+ char *fs = po->fieldSep;
while (*fs++)
*p++ = '+';
}
for (j = 0; j < nFields; j++)
{
- int len;
+ int len;
for (len = fieldMax[j] + (po->standard ? 2 : 0); len--; *p++ = '-');
if (po->standard || (j + 1) < nFields)
{
- char *fs = po->fieldSep;
+ char *fs = po->fieldSep;
while (*fs++)
*p++ = '+';
@@ -1169,7 +1170,7 @@ do_header(FILE * fout, PQprintOpt * po, const int nFields, int fieldMax[],
fputs(po->fieldSep, fout);
for (j = 0; j < nFields; j++)
{
- char *s = PQfname(res, j);
+ char *s = PQfname(res, j);
if (po->html3)
{
@@ -1178,7 +1179,7 @@ do_header(FILE * fout, PQprintOpt * po, const int nFields, int fieldMax[],
}
else
{
- int n = strlen(s);
+ int n = strlen(s);
if (n > fieldMax[j])
fieldMax[j] = n;
@@ -1206,7 +1207,7 @@ output_row(FILE * fout, PQprintOpt * po, const int nFields, char *fields[],
const int row_index)
{
- int field_index;/* for loop index */
+ int field_index; /* for loop index */
if (po->html3)
fputs("<tr>", fout);
@@ -1214,7 +1215,7 @@ output_row(FILE * fout, PQprintOpt * po, const int nFields, char *fields[],
fputs(po->fieldSep, fout);
for (field_index = 0; field_index < nFields; field_index++)
{
- char *p = fields[row_index * nFields + field_index];
+ char *p = fields[row_index * nFields + field_index];
if (po->html3)
fprintf(fout, "<td align=%s>%s</td>",
@@ -1261,28 +1262,27 @@ PQprint(FILE * fout,
PQprintOpt * po
)
{
- int nFields;
+ int nFields;
nFields = PQnfields(res);
if (nFields > 0)
{ /* only print rows with at least 1 field. */
- int i,
- j;
- int nTups;
- int *fieldMax = NULL; /* in case we don't use
- * them */
- unsigned char *fieldNotNum = NULL;
- char *border = NULL;
- char **fields = NULL;
- char **fieldNames;
- int fieldMaxLen = 0;
- int numFieldName;
- int fs_len = strlen(po->fieldSep);
- int total_line_length = 0;
- int usePipe = 0;
- char *pagerenv;
- char buf[8192 * 2 + 1];
+ int i,
+ j;
+ int nTups;
+ int *fieldMax = NULL; /* in case we don't use them */
+ unsigned char *fieldNotNum = NULL;
+ char *border = NULL;
+ char **fields = NULL;
+ char **fieldNames;
+ int fieldMaxLen = 0;
+ int numFieldName;
+ int fs_len = strlen(po->fieldSep);
+ int total_line_length = 0;
+ int usePipe = 0;
+ char *pagerenv;
+ char buf[8192 * 2 + 1];
nTups = PQntuples(res);
if (!(fieldNames = (char **) calloc(nFields, sizeof(char *))))
@@ -1306,8 +1306,8 @@ PQprint(FILE * fout,
;
for (j = 0; j < nFields; j++)
{
- int len;
- char *s =
+ int len;
+ char *s =
(j < numFieldName && po->fieldName[j][0]) ?
po->fieldName[j] : PQfname(res, j);
@@ -1386,11 +1386,11 @@ PQprint(FILE * fout,
}
else
{
- int len = 0;
+ int len = 0;
for (j = 0; j < nFields; j++)
{
- char *s = fieldNames[j];
+ char *s = fieldNames[j];
fputs(s, fout);
len += strlen(s) + fs_len;
@@ -1501,7 +1501,7 @@ PQprint(FILE * fout,
* ----------------
*/
-PGresult *
+PGresult *
PQfn(PGconn * conn,
int fnid,
int *result_buf,
@@ -1510,11 +1510,11 @@ PQfn(PGconn * conn,
PQArgBlock * args,
int nargs)
{
- FILE *pfin,
- *pfout,
- *pfdebug;
- int id;
- int i;
+ FILE *pfin,
+ *pfout,
+ *pfdebug;
+ int id;
+ int i;
if (!conn)
return NULL;
@@ -1561,47 +1561,47 @@ PQfn(PGconn * conn,
id = pqGetc(pfin, pfdebug);
for (;;)
{
- int c;
+ int c;
switch (id)
{
- case 'G': /* function returned properly */
- pqGetInt(actual_result_len, 4, pfin, pfdebug);
- if (result_is_int)
- {
- pqGetInt(result_buf, 4, pfin, pfdebug);
- }
- else
- {
- pqGetnchar((char *) result_buf, *actual_result_len,
- pfin, pfdebug);
- }
- c = pqGetc(pfin, pfdebug); /* get the last '0' */
- return makeEmptyPGresult(conn, PGRES_COMMAND_OK);
- case 'E':
- sprintf(conn->errorMessage,
- "PQfn: returned an error");
- return makeEmptyPGresult(conn, PGRES_FATAL_ERROR);
- case 'N':
- /* print notice and go back to processing return values */
- if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug)
- == 1)
- {
+ case 'G': /* function returned properly */
+ pqGetInt(actual_result_len, 4, pfin, pfdebug);
+ if (result_is_int)
+ {
+ pqGetInt(result_buf, 4, pfin, pfdebug);
+ }
+ else
+ {
+ pqGetnchar((char *) result_buf, *actual_result_len,
+ pfin, pfdebug);
+ }
+ c = pqGetc(pfin, pfdebug); /* get the last '0' */
+ return makeEmptyPGresult(conn, PGRES_COMMAND_OK);
+ case 'E':
sprintf(conn->errorMessage,
+ "PQfn: returned an error");
+ return makeEmptyPGresult(conn, PGRES_FATAL_ERROR);
+ case 'N':
+ /* print notice and go back to processing return values */
+ if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug)
+ == 1)
+ {
+ sprintf(conn->errorMessage,
"Notice return detected from backend, but message "
- "cannot be read");
- }
- else
- fprintf(stderr, "%s\n", conn->errorMessage);
- /* keep iterating */
- break;
- case '0': /* no return value */
- return makeEmptyPGresult(conn, PGRES_COMMAND_OK);
- default:
- /* The backend violates the protocol. */
- sprintf(conn->errorMessage,
- "FATAL: PQfn: protocol error: id=%x\n", id);
- return makeEmptyPGresult(conn, PGRES_FATAL_ERROR);
+ "cannot be read");
+ }
+ else
+ fprintf(stderr, "%s\n", conn->errorMessage);
+ /* keep iterating */
+ break;
+ case '0': /* no return value */
+ return makeEmptyPGresult(conn, PGRES_COMMAND_OK);
+ default:
+ /* The backend violates the protocol. */
+ sprintf(conn->errorMessage,
+ "FATAL: PQfn: protocol error: id=%x\n", id);
+ return makeEmptyPGresult(conn, PGRES_FATAL_ERROR);
}
}
}
@@ -1645,7 +1645,7 @@ PQnfields(PGresult * res)
/*
returns NULL if the field_num is invalid
*/
-char *
+char *
PQfname(PGresult * res, int field_num)
{
if (!res)
@@ -1675,7 +1675,7 @@ PQfname(PGresult * res, int field_num)
int
PQfnumber(PGresult * res, const char *field_name)
{
- int i;
+ int i;
if (!res)
{
@@ -1743,7 +1743,7 @@ PQfsize(PGresult * res, int field_num)
return 0;
}
-char *
+char *
PQcmdStatus(PGresult * res)
{
if (!res)
@@ -1759,8 +1759,8 @@ PQcmdStatus(PGresult * res)
if the last command was an INSERT, return the oid string
if not, return ""
*/
-static char oidStatus[32] = {0};
-const char *
+static char oidStatus[32] = {0};
+const char *
PQoidStatus(PGresult * res)
{
if (!res)
@@ -1775,8 +1775,8 @@ PQoidStatus(PGresult * res)
if (strncmp(res->cmdStatus, "INSERT", 6) == 0)
{
- char *p = res->cmdStatus + 7;
- char *e;
+ char *p = res->cmdStatus + 7;
+ char *e;
for (e = p; *e != ' ' && *e;)
e++;
@@ -1790,7 +1790,7 @@ PQoidStatus(PGresult * res)
if the last command was an INSERT/UPDATE/DELETE, return number
of inserted/affected tuples, if not, return ""
*/
-const char *
+const char *
PQcmdTuples(PGresult * res)
{
if (!res)
@@ -1806,7 +1806,7 @@ PQcmdTuples(PGresult * res)
strncmp(res->cmdStatus, "DELETE", 6) == 0 ||
strncmp(res->cmdStatus, "UPDATE", 6) == 0)
{
- char *p = res->cmdStatus + 6;
+ char *p = res->cmdStatus + 6;
if (*p == 0)
{
@@ -1840,7 +1840,7 @@ PQcmdTuples(PGresult * res)
if res is not binary, a null-terminated ASCII string is returned.
*/
-char *
+char *
PQgetvalue(PGresult * res, int tup_num, int field_num)
{
if (!res)
diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c
index 1636edc7f42..6e97e6465d9 100644
--- a/src/interfaces/libpq/fe-lobj.c
+++ b/src/interfaces/libpq/fe-lobj.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.8 1997/09/07 05:03:34 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.9 1997/09/08 02:40:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -23,7 +23,7 @@
#define LO_BUFSIZE 1024
-static int lo_initialize(PGconn * conn);
+static int lo_initialize(PGconn * conn);
/*
* lo_open
@@ -35,10 +35,10 @@ static int lo_initialize(PGconn * conn);
int
lo_open(PGconn * conn, Oid lobjId, int mode)
{
- int fd;
- int result_len;
- PQArgBlock argv[2];
- PGresult *res;
+ int fd;
+ int result_len;
+ PQArgBlock argv[2];
+ PGresult *res;
argv[0].isint = 1;
argv[0].len = 4;
@@ -81,10 +81,10 @@ lo_open(PGconn * conn, Oid lobjId, int mode)
int
lo_close(PGconn * conn, int fd)
{
- PQArgBlock argv[1];
- PGresult *res;
- int retval;
- int result_len;
+ PQArgBlock argv[1];
+ PGresult *res;
+ int retval;
+ int result_len;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
{
@@ -119,9 +119,9 @@ lo_close(PGconn * conn, int fd)
int
lo_read(PGconn * conn, int fd, char *buf, int len)
{
- PQArgBlock argv[2];
- PGresult *res;
- int result_len;
+ PQArgBlock argv[2];
+ PGresult *res;
+ int result_len;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
{
@@ -158,10 +158,10 @@ lo_read(PGconn * conn, int fd, char *buf, int len)
int
lo_write(PGconn * conn, int fd, char *buf, int len)
{
- PQArgBlock argv[2];
- PGresult *res;
- int result_len;
- int retval;
+ PQArgBlock argv[2];
+ PGresult *res;
+ int result_len;
+ int retval;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
{
@@ -203,10 +203,10 @@ lo_write(PGconn * conn, int fd, char *buf, int len)
int
lo_lseek(PGconn * conn, int fd, int offset, int whence)
{
- PQArgBlock argv[3];
- PGresult *res;
- int retval;
- int result_len;
+ PQArgBlock argv[3];
+ PGresult *res;
+ int retval;
+ int result_len;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
{
@@ -251,10 +251,10 @@ lo_lseek(PGconn * conn, int fd, int offset, int whence)
Oid
lo_creat(PGconn * conn, int mode)
{
- PQArgBlock argv[1];
- PGresult *res;
- int retval;
- int result_len;
+ PQArgBlock argv[1];
+ PGresult *res;
+ int retval;
+ int result_len;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
{
@@ -288,10 +288,10 @@ lo_creat(PGconn * conn, int mode)
int
lo_tell(PGconn * conn, int fd)
{
- int retval;
- PQArgBlock argv[1];
- PGresult *res;
- int result_len;
+ int retval;
+ PQArgBlock argv[1];
+ PGresult *res;
+ int result_len;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
{
@@ -325,10 +325,10 @@ lo_tell(PGconn * conn, int fd)
int
lo_unlink(PGconn * conn, Oid lobjId)
{
- PQArgBlock argv[1];
- PGresult *res;
- int result_len;
- int retval;
+ PQArgBlock argv[1];
+ PGresult *res;
+ int result_len;
+ int retval;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
{
@@ -364,12 +364,12 @@ lo_unlink(PGconn * conn, Oid lobjId)
Oid
lo_import(PGconn * conn, char *filename)
{
- int fd;
- int nbytes,
- tmp;
- char buf[LO_BUFSIZE];
- Oid lobjOid;
- int lobj;
+ int fd;
+ int nbytes,
+ tmp;
+ char buf[LO_BUFSIZE];
+ Oid lobjOid;
+ int lobj;
/*
* open the file to be read in
@@ -429,11 +429,11 @@ lo_import(PGconn * conn, char *filename)
int
lo_export(PGconn * conn, Oid lobjId, char *filename)
{
- int fd;
- int nbytes,
- tmp;
- char buf[LO_BUFSIZE];
- int lobj;
+ int fd;
+ int nbytes,
+ tmp;
+ char buf[LO_BUFSIZE];
+ int lobj;
/*
* create an inversion "object"
@@ -490,11 +490,11 @@ lo_export(PGconn * conn, Oid lobjId, char *filename)
static int
lo_initialize(PGconn * conn)
{
- PGresult *res;
- PGlobjfuncs *lobjfuncs;
- int n;
- char *fname;
- Oid foid;
+ PGresult *res;
+ PGlobjfuncs *lobjfuncs;
+ int n;
+ char *fname;
+ Oid foid;
/* ----------------
* Allocate the structure to hold the functions OID's
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index b7e8a1b1c69..23d1e42955f 100644
--- a/src/interfaces/libpq/fe-misc.c
+++ b/src/interfaces/libpq/fe-misc.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.6 1997/09/07 05:03:35 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.7 1997/09/08 02:40:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -32,7 +32,7 @@
int
pqGetc(FILE * fin, FILE * debug)
{
- int c;
+ int c;
c = getc(fin);
@@ -70,7 +70,7 @@ pqPutnchar(const char *s, int len, FILE * f, FILE * debug)
int
pqGetnchar(char *s, int len, FILE * f, FILE * debug)
{
- int cnt;
+ int cnt;
if (f == NULL)
return 1;
@@ -92,8 +92,8 @@ pqGetnchar(char *s, int len, FILE * f, FILE * debug)
int
pqGets(char *s, int len, FILE * f, FILE * debug)
{
- int c;
- const char *str = s;
+ int c;
+ const char *str = s;
if (f == NULL)
return 1;
@@ -118,19 +118,19 @@ pqGets(char *s, int len, FILE * f, FILE * debug)
int
pqPutInt(const int integer, int bytes, FILE * f, FILE * debug)
{
- int retval = 0;
+ int retval = 0;
switch (bytes)
{
- case 2:
- retval = pqPutShort(integer, f);
- break;
- case 4:
- retval = pqPutLong(integer, f);
- break;
- default:
- fprintf(stderr, "** int size %d not supported\n", bytes);
- retval = 1;
+ case 2:
+ retval = pqPutShort(integer, f);
+ break;
+ case 4:
+ retval = pqPutLong(integer, f);
+ break;
+ default:
+ fprintf(stderr, "** int size %d not supported\n", bytes);
+ retval = 1;
}
if (debug)
@@ -148,19 +148,19 @@ pqPutInt(const int integer, int bytes, FILE * f, FILE * debug)
int
pqGetInt(int *result, int bytes, FILE * f, FILE * debug)
{
- int retval = 0;
+ int retval = 0;
switch (bytes)
{
- case 2:
- retval = pqGetShort(result, f);
- break;
- case 4:
- retval = pqGetLong(result, f);
- break;
- default:
- fprintf(stderr, "** int size %d not supported\n", bytes);
- retval = 1;
+ case 2:
+ retval = pqGetShort(result, f);
+ break;
+ case 4:
+ retval = pqGetLong(result, f);
+ break;
+ default:
+ fprintf(stderr, "** int size %d not supported\n", bytes);
+ retval = 1;
}
if (debug)
diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h
index 3013d5a2bfc..397630ad5d9 100644
--- a/src/interfaces/libpq/libpq-fe.h
+++ b/src/interfaces/libpq/libpq-fe.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq-fe.h,v 1.21 1997/09/07 05:03:36 momjian Exp $
+ * $Id: libpq-fe.h,v 1.22 1997/09/08 02:40:36 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -15,7 +15,7 @@
#define LIBPQ_FE_H
#ifdef __cplusplus
-extern "C"
+extern "C"
{
#endif
@@ -32,7 +32,7 @@ extern "C"
{
CONNECTION_OK,
CONNECTION_BAD
- } ConnStatusType;
+ } ConnStatusType;
typedef enum
{
@@ -49,7 +49,7 @@ extern "C"
PGRES_NONFATAL_ERROR,
PGRES_FATAL_ERROR
- } ExecStatusType;
+ } ExecStatusType;
/* string descriptions of the ExecStatusTypes */
extern const char *pgresStatus[];
@@ -72,21 +72,21 @@ extern "C"
*/
typedef struct
{
- int len;
- int isint;
+ int len;
+ int isint;
union
{
- int *ptr;/* can't use void (dec compiler barfs) */
- int integer;
- } u;
- } PQArgBlock;
+ int *ptr; /* can't use void (dec compiler barfs) */
+ int integer;
+ } u;
+ } PQArgBlock;
typedef struct pgresAttDesc
{
- char *name; /* type name */
- Oid adtid; /* type id */
- short adtsize;/* type size */
- } PGresAttDesc;
+ char *name; /* type name */
+ Oid adtid; /* type id */
+ short adtsize; /* type size */
+ } PGresAttDesc;
/* use char* for Attribute values,
ASCII tuples are guaranteed to be null-terminated
@@ -98,60 +98,56 @@ extern "C"
typedef struct pgresAttValue
{
- int len; /* length in bytes of the value */
- char *value; /* actual value */
- } PGresAttValue;
+ int len; /* length in bytes of the value */
+ char *value; /* actual value */
+ } PGresAttValue;
typedef struct pgNotify
{
- char relname[NAMEDATALEN]; /* name of relation
+ char relname[NAMEDATALEN]; /* name of relation
* containing data */
- int be_pid; /* process id of backend */
- } PGnotify;
+ int be_pid; /* process id of backend */
+ } PGnotify;
typedef struct pgLobjfuncs
{
- Oid fn_lo_open; /* OID of backend function lo_open */
- Oid fn_lo_close; /* OID of backend function
- * lo_close */
- Oid fn_lo_creat; /* OID of backend function
- * lo_creat */
- Oid fn_lo_unlink; /* OID of backend function
+ Oid fn_lo_open; /* OID of backend function lo_open */
+ Oid fn_lo_close;/* OID of backend function lo_close */
+ Oid fn_lo_creat;/* OID of backend function lo_creat */
+ Oid fn_lo_unlink; /* OID of backend function
* lo_unlink */
- Oid fn_lo_lseek; /* OID of backend function
- * lo_lseek */
- Oid fn_lo_tell; /* OID of backend function lo_tell */
- Oid fn_lo_read; /* OID of backend function LOread */
- Oid fn_lo_write; /* OID of backend function LOwrite */
- } PGlobjfuncs;
+ Oid fn_lo_lseek;/* OID of backend function lo_lseek */
+ Oid fn_lo_tell; /* OID of backend function lo_tell */
+ Oid fn_lo_read; /* OID of backend function LOread */
+ Oid fn_lo_write;/* OID of backend function LOwrite */
+ } PGlobjfuncs;
/* PGconn encapsulates a connection to the backend */
typedef struct pg_conn
{
- char *pghost; /* the machine on which the server is
+ char *pghost; /* the machine on which the server is
* running */
- char *pgtty; /* tty on which the backend messages is
+ char *pgtty; /* tty on which the backend messages is
* displayed */
- char *pgport; /* the communication port with the backend */
- char *pgoptions; /* options to start the backend
- * with */
- char *dbName; /* database name */
- ConnStatusType status;
- char errorMessage[ERROR_MSG_LENGTH];
+ char *pgport; /* the communication port with the backend */
+ char *pgoptions; /* options to start the backend with */
+ char *dbName; /* database name */
+ ConnStatusType status;
+ char errorMessage[ERROR_MSG_LENGTH];
/* pipes for be/fe communication */
- FILE *Pfin;
- FILE *Pfout;
- FILE *Pfdebug;
- void *port; /* really a Port* */
- int asyncNotifyWaiting;
- Dllist *notifyList;
- char *pguser; /* Postgres username of user who is
+ FILE *Pfin;
+ FILE *Pfout;
+ FILE *Pfdebug;
+ void *port; /* really a Port* */
+ int asyncNotifyWaiting;
+ Dllist *notifyList;
+ char *pguser; /* Postgres username of user who is
* connected */
- char *pgpass;
- char *pgauth;
- PGlobjfuncs *lobjfuncs; /* Backend function OID's for
- * large object access */
- } PGconn;
+ char *pgpass;
+ char *pgauth;
+ PGlobjfuncs *lobjfuncs; /* Backend function OID's for large object
+ * access */
+ } PGconn;
#define CMDSTATUS_LEN 40
@@ -159,21 +155,21 @@ extern "C"
/* unlike the old libpq, we assume that queries only return in one group */
typedef struct pg_result
{
- int ntups;
- int numAttributes;
- PGresAttDesc *attDescs;
- PGresAttValue **tuples;/* each PGresTuple is an array of
+ int ntups;
+ int numAttributes;
+ PGresAttDesc *attDescs;
+ PGresAttValue **tuples; /* each PGresTuple is an array of
* PGresAttValue's */
- int tupArrSize; /* size of tuples array allocated */
- ExecStatusType resultStatus;
- char cmdStatus[CMDSTATUS_LEN]; /* cmd status from the
- * last insert query */
- int binary; /* binary tuple values if binary == 1,
+ int tupArrSize; /* size of tuples array allocated */
+ ExecStatusType resultStatus;
+ char cmdStatus[CMDSTATUS_LEN]; /* cmd status from the
+ * last insert query */
+ int binary; /* binary tuple values if binary == 1,
* otherwise ASCII */
- PGconn *conn;
- } PGresult;
+ PGconn *conn;
+ } PGresult;
- typedef char pqbool;
+ typedef char pqbool;
/*
* We can't use the conventional "bool", because we are designed to be
@@ -183,18 +179,18 @@ extern "C"
struct _PQprintOpt
{
- pqbool header; /* print output field headings and row
+ pqbool header; /* print output field headings and row
* count */
- pqbool align; /* fill align the fields */
- pqbool standard; /* old brain dead format */
- pqbool html3; /* output html tables */
- pqbool expanded; /* expand tables */
- pqbool pager; /* use pager for output if needed */
- char *fieldSep; /* field separator */
- char *tableOpt; /* insert to HTML <table ...> */
- char *caption;/* HTML <caption> */
- char **fieldName; /* null terminated array of
- * repalcement field names */
+ pqbool align; /* fill align the fields */
+ pqbool standard; /* old brain dead format */
+ pqbool html3; /* output html tables */
+ pqbool expanded; /* expand tables */
+ pqbool pager; /* use pager for output if needed */
+ char *fieldSep; /* field separator */
+ char *tableOpt; /* insert to HTML <table ...> */
+ char *caption; /* HTML <caption> */
+ char **fieldName; /* null terminated array of repalcement
+ * field names */
};
typedef struct _PQprintOpt PQprintOpt;
@@ -205,134 +201,131 @@ extern "C"
*/
struct _PQconninfoOption
{
- char *keyword;/* The keyword of the option */
- char *environ;/* Fallback environment variable name */
- char *compiled; /* Fallback compiled in default
- * value */
- char *val; /* Options value */
- char *label; /* Label for field in connect dialog */
- char *dispchar; /* Character to display for this
- * field */
+ char *keyword; /* The keyword of the option */
+ char *environ; /* Fallback environment variable name */
+ char *compiled; /* Fallback compiled in default value */
+ char *val; /* Options value */
+ char *label; /* Label for field in connect dialog */
+ char *dispchar; /* Character to display for this field */
/* in a connect dialog. Values are: */
/* "" Display entered value as is */
/* "*" Password field - hide value */
/* "D" Debug options - don't */
/* create a field by default */
- int dispsize; /* Field size in characters for
- * dialog */
+ int dispsize; /* Field size in characters for dialog */
};
typedef struct _PQconninfoOption PQconninfoOption;
/* === in fe-connect.c === */
/* make a new client connection to the backend */
- extern PGconn *PQconnectdb(const char *conninfo);
+ extern PGconn *PQconnectdb(const char *conninfo);
extern PQconninfoOption *PQconndefaults(void);
- extern PGconn *PQsetdb(const char *pghost, const char *pgport, const char *pgoptions,
+ extern PGconn *PQsetdb(const char *pghost, const char *pgport, const char *pgoptions,
const char *pgtty, const char *dbName);
/* close the current connection and free the PGconn data structure */
- extern void PQfinish(PGconn * conn);
+ extern void PQfinish(PGconn * conn);
/*
* close the current connection and restablish a new one with the same
* parameters
*/
- extern void PQreset(PGconn * conn);
-
- extern char *PQdb(PGconn * conn);
- extern char *PQuser(PGconn * conn);
- extern char *PQhost(PGconn * conn);
- extern char *PQoptions(PGconn * conn);
- extern char *PQport(PGconn * conn);
- extern char *PQtty(PGconn * conn);
+ extern void PQreset(PGconn * conn);
+
+ extern char *PQdb(PGconn * conn);
+ extern char *PQuser(PGconn * conn);
+ extern char *PQhost(PGconn * conn);
+ extern char *PQoptions(PGconn * conn);
+ extern char *PQport(PGconn * conn);
+ extern char *PQtty(PGconn * conn);
extern ConnStatusType PQstatus(PGconn * conn);
- extern char *PQerrorMessage(PGconn * conn);
- extern void PQtrace(PGconn * conn, FILE * debug_port);
- extern void PQuntrace(PGconn * conn);
+ extern char *PQerrorMessage(PGconn * conn);
+ extern void PQtrace(PGconn * conn, FILE * debug_port);
+ extern void PQuntrace(PGconn * conn);
/* === in fe-exec.c === */
extern PGresult *PQexec(PGconn * conn, const char *query);
- extern int PQgetline(PGconn * conn, char *string, int length);
- extern int PQendcopy(PGconn * conn);
- extern void PQputline(PGconn * conn, const char *string);
+ extern int PQgetline(PGconn * conn, char *string, int length);
+ extern int PQendcopy(PGconn * conn);
+ extern void PQputline(PGconn * conn, const char *string);
extern ExecStatusType PQresultStatus(PGresult * res);
- extern int PQntuples(PGresult * res);
- extern int PQnfields(PGresult * res);
- extern char *PQfname(PGresult * res, int field_num);
- extern int PQfnumber(PGresult * res, const char *field_name);
- extern Oid PQftype(PGresult * res, int field_num);
- extern short PQfsize(PGresult * res, int field_num);
- extern char *PQcmdStatus(PGresult * res);
+ extern int PQntuples(PGresult * res);
+ extern int PQnfields(PGresult * res);
+ extern char *PQfname(PGresult * res, int field_num);
+ extern int PQfnumber(PGresult * res, const char *field_name);
+ extern Oid PQftype(PGresult * res, int field_num);
+ extern short PQfsize(PGresult * res, int field_num);
+ extern char *PQcmdStatus(PGresult * res);
extern const char *PQoidStatus(PGresult * res);
extern const char *PQcmdTuples(PGresult * res);
- extern char *PQgetvalue(PGresult * res, int tup_num, int field_num);
- extern int PQgetlength(PGresult * res, int tup_num, int field_num);
- extern int PQgetisnull(PGresult * res, int tup_num, int field_num);
- extern void PQclear(PGresult * res);
+ extern char *PQgetvalue(PGresult * res, int tup_num, int field_num);
+ extern int PQgetlength(PGresult * res, int tup_num, int field_num);
+ extern int PQgetisnull(PGresult * res, int tup_num, int field_num);
+ extern void PQclear(PGresult * res);
/* PQdisplayTuples() is a better version of PQprintTuples() */
- extern void PQdisplayTuples(PGresult * res,
- FILE * fp, /* where to send the
- * output */
- int fillAlign, /* pad the fields with
- * spaces */
- const char *fieldSep, /* field separator */
- int printHeader, /* display headers? */
- int quiet);
- extern void PQprintTuples(PGresult * res,
- FILE * fout, /* output stream */
- int printAttName, /* print attribute names
- * or not */
- int terseOutput, /* delimiter bars or
- * not? */
- int width /* width of column, if
- * 0, use variable width */
+ extern void PQdisplayTuples(PGresult * res,
+ FILE * fp, /* where to send the
+ * output */
+ int fillAlign, /* pad the fields with
+ * spaces */
+ const char *fieldSep, /* field separator */
+ int printHeader, /* display headers? */
+ int quiet);
+ extern void PQprintTuples(PGresult * res,
+ FILE * fout, /* output stream */
+ int printAttName, /* print attribute names
+ * or not */
+ int terseOutput, /* delimiter bars or
+ * not? */
+ int width /* width of column, if
+ * 0, use variable width */
);
- extern void PQprint(FILE * fout, /* output stream */
- PGresult * res,
- PQprintOpt * ps /* option structure */
+ extern void PQprint(FILE * fout, /* output stream */
+ PGresult * res,
+ PQprintOpt * ps /* option structure */
);
extern PGnotify *PQnotifies(PGconn * conn);
extern PGresult *PQfn(PGconn * conn,
- int fnid,
- int *result_buf,
- int *result_len,
- int result_is_int,
- PQArgBlock * args,
- int nargs);
+ int fnid,
+ int *result_buf,
+ int *result_len,
+ int result_is_int,
+ PQArgBlock * args,
+ int nargs);
/* === in fe-auth.c === */
- extern MsgType fe_getauthsvc(char *PQerrormsg);
- extern void fe_setauthsvc(const char *name, char *PQerrormsg);
- extern char *fe_getauthname(char *PQerrormsg);
+ extern MsgType fe_getauthsvc(char *PQerrormsg);
+ extern void fe_setauthsvc(const char *name, char *PQerrormsg);
+ extern char *fe_getauthname(char *PQerrormsg);
/* === in fe-misc.c === */
/* pqGets and pqPuts gets and sends strings to the file stream
returns 0 if successful
if debug is non-null, debugging output is sent to that stream
*/
- extern int pqGets(char *s, int maxlen, FILE * stream, FILE * debug);
- extern int pqGetnchar(char *s, int maxlen, FILE * stream, FILE * debug);
- extern int pqPutnchar(const char *s, int maxlen, FILE * stream, FILE * debug);
- extern int pqPuts(const char *s, FILE * stream, FILE * debug);
- extern int pqGetc(FILE * stream, FILE * debug);
+ extern int pqGets(char *s, int maxlen, FILE * stream, FILE * debug);
+ extern int pqGetnchar(char *s, int maxlen, FILE * stream, FILE * debug);
+ extern int pqPutnchar(const char *s, int maxlen, FILE * stream, FILE * debug);
+ extern int pqPuts(const char *s, FILE * stream, FILE * debug);
+ extern int pqGetc(FILE * stream, FILE * debug);
/* get a n-byte integer from the stream into result */
/* returns 0 if successful */
- extern int pqGetInt(int *result, int bytes, FILE * stream, FILE * debug);
+ extern int pqGetInt(int *result, int bytes, FILE * stream, FILE * debug);
/* put a n-byte integer into the stream */
/* returns 0 if successful */
- extern int pqPutInt(const int n, int bytes, FILE * stream, FILE * debug);
- extern void pqFlush(FILE * stream, FILE * debug);
+ extern int pqPutInt(const int n, int bytes, FILE * stream, FILE * debug);
+ extern void pqFlush(FILE * stream, FILE * debug);
/* === in fe-lobj.c === */
- int lo_open(PGconn * conn, Oid lobjId, int mode);
- int lo_close(PGconn * conn, int fd);
- int lo_read(PGconn * conn, int fd, char *buf, int len);
- int lo_write(PGconn * conn, int fd, char *buf, int len);
- int lo_lseek(PGconn * conn, int fd, int offset, int whence);
- Oid lo_creat(PGconn * conn, int mode);
- int lo_tell(PGconn * conn, int fd);
- int lo_unlink(PGconn * conn, Oid lobjId);
- Oid lo_import(PGconn * conn, char *filename);
- int lo_export(PGconn * conn, Oid lobjId, char *filename);
+ int lo_open(PGconn * conn, Oid lobjId, int mode);
+ int lo_close(PGconn * conn, int fd);
+ int lo_read(PGconn * conn, int fd, char *buf, int len);
+ int lo_write(PGconn * conn, int fd, char *buf, int len);
+ int lo_lseek(PGconn * conn, int fd, int offset, int whence);
+ Oid lo_creat(PGconn * conn, int mode);
+ int lo_tell(PGconn * conn, int fd);
+ int lo_unlink(PGconn * conn, Oid lobjId);
+ Oid lo_import(PGconn * conn, char *filename);
+ int lo_export(PGconn * conn, Oid lobjId, char *filename);
/* max length of message to send */
#define MAX_MESSAGE_LEN 8193
@@ -349,12 +342,12 @@ extern "C"
#define DefaultPassword ""
- typedef void *TUPLE;
+ typedef void *TUPLE;
#define palloc malloc
#define pfree free
#if defined(sunos4)
- extern char *sys_errlist[];
+ extern char *sys_errlist[];
#define strerror(A) (sys_errlist[(A)])
#endif /* sunos4 */
diff --git a/src/interfaces/libpq/pqsignal.c b/src/interfaces/libpq/pqsignal.c
index c004704ba45..3a43271be0d 100644
--- a/src/interfaces/libpq/pqsignal.c
+++ b/src/interfaces/libpq/pqsignal.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqsignal.c,v 1.4 1997/09/07 05:03:37 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqsignal.c,v 1.5 1997/09/08 02:40:37 momjian Exp $
*
* NOTES
* This shouldn't be in libpq, but the monitor and some other
@@ -29,7 +29,7 @@ pqsignal(int signo, pqsigfunc func)
return signal(signo, func);
#else
struct sigaction act,
- oact;
+ oact;
act.sa_handler = func;
sigemptyset(&act.sa_mask);
diff --git a/src/interfaces/libpq/pqsignal.h b/src/interfaces/libpq/pqsignal.h
index e2f6d7a973b..4c34a37ebef 100644
--- a/src/interfaces/libpq/pqsignal.h
+++ b/src/interfaces/libpq/pqsignal.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqsignal.h,v 1.3 1997/09/07 05:03:39 momjian Exp $
+ * $Id: pqsignal.h,v 1.4 1997/09/08 02:40:38 momjian Exp $
*
* NOTES
* This shouldn't be in libpq, but the monitor and some other
@@ -19,7 +19,7 @@
#include "c.h"
-typedef void (*pqsigfunc) (int);
+typedef void (*pqsigfunc) (int);
extern pqsigfunc pqsignal(int signo, pqsigfunc func);