1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-19 13:42:17 +03:00

Fixed psql double quoting of SQL ids

Fixed libpq printing functions
This commit is contained in:
Peter Eisentraut
2000-02-07 23:10:11 +00:00
parent 4842ef8624
commit 9ceb5d8a7b
29 changed files with 1047 additions and 770 deletions

View File

@@ -10,7 +10,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.36 2000/01/26 05:58:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.37 2000/02/07 23:10:08 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -474,6 +474,10 @@ int
fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
const char *password, char *PQerrormsg)
{
#if !defined(KRB4) && !defined(KRB5)
(void)hostname; /*not used*/
#endif
switch (areq)
{
case AUTH_REQ_OK:

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.117 2000/02/05 12:33:22 ishii Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.118 2000/02/07 23:10:09 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2291,7 +2291,7 @@ conninfo_free()
}
/* =========== accessor functions for PGconn ========= */
const char *
char *
PQdb(const PGconn *conn)
{
if (!conn)
@@ -2299,7 +2299,7 @@ PQdb(const PGconn *conn)
return conn->dbName;
}
const char *
char *
PQuser(const PGconn *conn)
{
if (!conn)
@@ -2307,7 +2307,7 @@ PQuser(const PGconn *conn)
return conn->pguser;
}
const char *
char *
PQpass(const PGconn *conn)
{
if (!conn)
@@ -2315,7 +2315,7 @@ PQpass(const PGconn *conn)
return conn->pgpass;
}
const char *
char *
PQhost(const PGconn *conn)
{
if (!conn)
@@ -2323,7 +2323,7 @@ PQhost(const PGconn *conn)
return conn->pghost;
}
const char *
char *
PQport(const PGconn *conn)
{
if (!conn)
@@ -2331,7 +2331,7 @@ PQport(const PGconn *conn)
return conn->pgport;
}
const char *
char *
PQtty(const PGconn *conn)
{
if (!conn)
@@ -2339,7 +2339,7 @@ PQtty(const PGconn *conn)
return conn->pgtty;
}
const char *
char *
PQoptions(const PGconn *conn)
{
if (!conn)
@@ -2355,7 +2355,7 @@ PQstatus(const PGconn *conn)
return conn->status;
}
const char *
char *
PQerrorMessage(const PGconn *conn)
{
static char noConn[] = "PQerrorMessage: conn pointer is NULL\n";
@@ -2478,6 +2478,7 @@ PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
static void
defaultNoticeProcessor(void *arg, const char *message)
{
(void)arg; /*not used*/
/* Note: we expect the supplied string to end with a newline already. */
fprintf(stderr, "%s", message);
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.89 2000/01/26 05:58:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.90 2000/02/07 23:10:10 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,7 +27,7 @@
#endif
/* keep this in same order as ExecStatusType in libpq-fe.h */
const char *const pgresStatus[] = {
char * const pgresStatus[] = {
"PGRES_EMPTY_QUERY",
"PGRES_COMMAND_OK",
"PGRES_TUPLES_OK",
@@ -1760,15 +1760,15 @@ PQresultStatus(const PGresult *res)
return res->resultStatus;
}
const char *
char *
PQresStatus(ExecStatusType status)
{
if ((int)status < 0 || (size_t)status >= sizeof pgresStatus / sizeof pgresStatus[0])
if (status < 0 || status >= sizeof pgresStatus / sizeof pgresStatus[0])
return "Invalid ExecStatusType code";
return pgresStatus[status];
}
const char *
char *
PQresultErrorMessage(const PGresult *res)
{
if (!res || !res->errMsg)
@@ -1862,7 +1862,7 @@ check_tuple_field_number(const char *routineName, const PGresult *res,
/*
returns NULL if the field_num is invalid
*/
const char *
char *
PQfname(const PGresult *res, int field_num)
{
if (!check_field_number("PQfname", res, field_num))
@@ -1947,8 +1947,8 @@ PQfmod(const PGresult *res, int field_num)
return 0;
}
const char *
PQcmdStatus(const PGresult *res)
char *
PQcmdStatus(PGresult *res)
{
if (!res)
return NULL;
@@ -1960,7 +1960,7 @@ PQcmdStatus(const PGresult *res)
if the last command was an INSERT, return the oid string
if not, return ""
*/
const char *
char *
PQoidStatus(const PGresult *res)
{
/*
@@ -2011,8 +2011,8 @@ PQoidValue(const PGresult *res)
if the last command was an INSERT/UPDATE/DELETE, return number
of inserted/affected tuples, if not, return ""
*/
const char *
PQcmdTuples(const PGresult *res)
char *
PQcmdTuples(PGresult *res)
{
char noticeBuf[128];
@@ -2023,7 +2023,7 @@ PQcmdTuples(const PGresult *res)
strncmp(res->cmdStatus, "DELETE", 6) == 0 ||
strncmp(res->cmdStatus, "UPDATE", 6) == 0)
{
const char *p = res->cmdStatus + 6;
char *p = res->cmdStatus + 6;
if (*p == 0)
{
@@ -2067,7 +2067,7 @@ PQcmdTuples(const PGresult *res)
if res is not binary, a null-terminated ASCII string is returned.
*/
const char *
char *
PQgetvalue(const PGresult *res, int tup_num, int field_num)
{
if (!check_tuple_field_number("PQgetvalue", res, tup_num, field_num))

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.27 2000/01/26 05:58:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.28 2000/02/07 23:10:11 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -168,7 +168,7 @@ lo_read(PGconn *conn, int fd, char *buf, size_t len)
*
*/
int
lo_write(PGconn *conn, int fd, const char *buf, size_t len)
lo_write(PGconn *conn, int fd, char *buf, size_t len)
{
PQArgBlock argv[2];
PGresult *res;

View File

@@ -25,7 +25,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.38 2000/01/29 16:58:51 petere Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.39 2000/02/07 23:10:11 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -782,6 +782,8 @@ PQenv2encoding(void)
int
PQmblen(const unsigned char *s, int encoding)
{
(void)s;
(void)encoding;
return 1;
}
int

View File

@@ -10,7 +10,7 @@
* didn't really belong there.
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.34 2000/02/05 12:33:22 ishii Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.35 2000/02/07 23:10:11 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -59,7 +59,7 @@ static char *do_header(FILE *fout, const PQprintOpt *po, const int nFields,
static void output_row(FILE *fout, const PQprintOpt *po, const int nFields, char **fields,
unsigned char *fieldNotNum, int *fieldMax, char *border,
const int row_index);
static void fill(int length, int max, char filler, FILE *fp);
/*
* PQprint()
@@ -440,7 +440,6 @@ do_header(FILE *fout, const PQprintOpt *po, const int nFields, int *fieldMax,
fputs("<tr>", fout);
else
{
int j; /* for loop index */
int tot = 0;
int n = 0;
char *p = NULL;
@@ -557,7 +556,6 @@ output_row(FILE *fout, const PQprintOpt *po, const int nFields, char **fields,
#if 0
/*
* really old printing routines
*/
@@ -728,4 +726,17 @@ PQprintTuples(const PGresult *res,
}
}
}
#endif
/* simply send out max-length number of filler characters to fp */
static void
fill(int length, int max, char filler, FILE *fp)
{
int count;
count = max - length;
while (count-- >= 0)
putc(filler, fp);
}

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-fe.h,v 1.59 2000/02/05 12:33:22 ishii Exp $
* $Id: libpq-fe.h,v 1.60 2000/02/07 23:10:11 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -74,11 +74,6 @@ extern "C"
PGRES_FATAL_ERROR
} ExecStatusType;
/* String descriptions of the ExecStatusTypes.
* NB: direct use of this array is now deprecated; call PQresStatus() instead.
*/
extern const char *const pgresStatus[];
/* PGconn encapsulates a connection to the backend.
* The contents of this struct are not supposed to be known to applications.
*/
@@ -115,16 +110,17 @@ extern "C"
typedef void (*PQnoticeProcessor) (void *arg, const char *message);
/* Print options for PQprint() */
typedef char pqbool;
typedef struct _PQprintOpt
{
int header; /* print output field headings and row
pqbool header; /* print output field headings and row
* count */
int align; /* fill align the fields */
int standard; /* old brain dead format */
int html3; /* output html tables */
int expanded; /* expand tables */
int pager; /* use pager for output if needed */
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> */
@@ -207,15 +203,15 @@ extern "C"
extern int PQrequestCancel(PGconn *conn);
/* Accessor functions for PGconn objects */
extern const char *PQdb(const PGconn *conn);
extern const char *PQuser(const PGconn *conn);
extern const char *PQpass(const PGconn *conn);
extern const char *PQhost(const PGconn *conn);
extern const char *PQport(const PGconn *conn);
extern const char *PQtty(const PGconn *conn);
extern const char *PQoptions(const PGconn *conn);
extern char *PQdb(const PGconn *conn);
extern char *PQuser(const PGconn *conn);
extern char *PQpass(const PGconn *conn);
extern char *PQhost(const PGconn *conn);
extern char *PQport(const PGconn *conn);
extern char *PQtty(const PGconn *conn);
extern char *PQoptions(const PGconn *conn);
extern ConnStatusType PQstatus(const PGconn *conn);
extern const char *PQerrorMessage(const PGconn *conn);
extern char *PQerrorMessage(const PGconn *conn);
extern int PQsocket(const PGconn *conn);
extern int PQbackendPID(const PGconn *conn);
extern int PQclientEncoding(const PGconn *conn);
@@ -279,21 +275,21 @@ extern "C"
/* Accessor functions for PGresult objects */
extern ExecStatusType PQresultStatus(const PGresult *res);
extern const char *PQresStatus(ExecStatusType status);
extern const char *PQresultErrorMessage(const PGresult *res);
extern char *PQresStatus(ExecStatusType status);
extern char *PQresultErrorMessage(const PGresult *res);
extern int PQntuples(const PGresult *res);
extern int PQnfields(const PGresult *res);
extern int PQbinaryTuples(const PGresult *res);
extern const char *PQfname(const PGresult *res, int field_num);
extern char *PQfname(const PGresult *res, int field_num);
extern int PQfnumber(const PGresult *res, const char *field_name);
extern Oid PQftype(const PGresult *res, int field_num);
extern int PQfsize(const PGresult *res, int field_num);
extern int PQfmod(const PGresult *res, int field_num);
extern const char *PQcmdStatus(const PGresult *res);
extern const char *PQoidStatus(const PGresult *res); /* old and ugly */
extern char *PQcmdStatus(PGresult *res);
extern char *PQoidStatus(const PGresult *res); /* old and ugly */
extern Oid PQoidValue(const PGresult *res); /* new and improved */
extern const char *PQcmdTuples(const PGresult *res);
extern const char *PQgetvalue(const PGresult *res, int tup_num, int field_num);
extern char *PQcmdTuples(PGresult *res);
extern char *PQgetvalue(const PGresult *res, int tup_num, int field_num);
extern int PQgetlength(const PGresult *res, int tup_num, int field_num);
extern int PQgetisnull(const PGresult *res, int tup_num, int field_num);
@@ -313,7 +309,6 @@ extern "C"
const PGresult *res,
const PQprintOpt *ps); /* option structure */
#if 0
/*
* really old printing routines
*/
@@ -330,7 +325,7 @@ extern "C"
int terseOutput, /* delimiter bars */
int width); /* width of column, if
* 0, use variable width */
#endif
/* === in fe-lobj.c === */
@@ -338,7 +333,7 @@ extern "C"
extern int lo_open(PGconn *conn, Oid lobjId, int mode);
extern int lo_close(PGconn *conn, int fd);
extern int lo_read(PGconn *conn, int fd, char *buf, size_t len);
extern int lo_write(PGconn *conn, int fd, const char *buf, size_t len);
extern int lo_write(PGconn *conn, int fd, char *buf, size_t len);
extern int lo_lseek(PGconn *conn, int fd, int offset, int whence);
extern Oid lo_creat(PGconn *conn, int mode);
extern int lo_tell(PGconn *conn, int fd);

View File

@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-int.h,v 1.18 2000/01/26 05:58:46 momjian Exp $
* $Id: libpq-int.h,v 1.19 2000/02/07 23:10:11 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -244,6 +244,11 @@ struct pg_conn
int client_encoding; /* encoding id */
};
/* String descriptions of the ExecStatusTypes.
* direct use of this array is deprecated; call PQresStatus() instead.
*/
extern char *const pgresStatus[];
/* ----------------
* Internal functions of libpq
* Functions declared here need to be visible across files of libpq,

View File

@@ -17,7 +17,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.4 2000/01/26 05:58:46 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.5 2000/02/07 23:10:11 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -124,9 +124,9 @@ resetPQExpBuffer(PQExpBuffer str)
* Returns 1 if OK, 0 if failed to enlarge buffer.
*/
int
enlargePQExpBuffer(PQExpBuffer str, int needed)
enlargePQExpBuffer(PQExpBuffer str, size_t needed)
{
int newlen;
size_t newlen;
char *newdata;
needed += str->len + 1; /* total space required now */
@@ -164,8 +164,8 @@ void
printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
{
va_list args;
int avail,
nprinted;
size_t avail;
int nprinted;
resetPQExpBuffer(str);
@@ -214,8 +214,8 @@ void
appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
{
va_list args;
int avail,
nprinted;
size_t avail;
int nprinted;
for (;;)
{
@@ -286,7 +286,7 @@ appendPQExpBufferChar(PQExpBuffer str, char ch)
* if necessary.
*/
void
appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, int datalen)
appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, size_t datalen)
{
/* Make more room if needed */
if (! enlargePQExpBuffer(str, datalen))

View File

@@ -18,7 +18,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pqexpbuffer.h,v 1.3 2000/01/26 05:58:46 momjian Exp $
* $Id: pqexpbuffer.h,v 1.4 2000/02/07 23:10:11 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -40,8 +40,8 @@
typedef struct PQExpBufferData
{
char *data;
int len;
int maxlen;
size_t len;
size_t maxlen;
} PQExpBufferData;
typedef PQExpBufferData *PQExpBuffer;
@@ -113,7 +113,7 @@ extern void resetPQExpBuffer(PQExpBuffer str);
*
* Returns 1 if OK, 0 if failed to enlarge buffer.
*/
extern int enlargePQExpBuffer(PQExpBuffer str, int needed);
extern int enlargePQExpBuffer(PQExpBuffer str, size_t needed);
/*------------------------
* printfPQExpBuffer
@@ -153,6 +153,6 @@ extern void appendPQExpBufferChar(PQExpBuffer str, char ch);
* if necessary.
*/
extern void appendBinaryPQExpBuffer(PQExpBuffer str,
const char *data, int datalen);
const char *data, size_t datalen);
#endif /* PQEXPBUFFER_H */

View File

@@ -11,9 +11,11 @@
* Some compat functions
*/
#define open(a,b,c) _open(a,b,c)
#define close(a) _close(a)
#define read(a,b,c) _read(a,b,c)
#define write(a,b,c) _write(a,b,c)
#define popen(a,b) _popen(a,b)
#define pclose(a) _pclose(a)
/*
* crypt not available (yet)