In the spirit of TODO item
* Add use of 'const' for varibles in source tree (which is misspelled, btw.) I went through the front-end libpq code and did so. This affects in particular the various accessor functions (such as PQdb() and PQgetvalue()) as well as, by necessity, the internal helpers they use. I have been really thorough in that regard, perhaps some people will find it annoying that things like char * foo = PQgetvalue(res, 0, 0) will generate a warning. On the other hand it _should_ generate one. This is no real compatibility break, although a few clients will have to be fixed to suppress warnings. (Which again would be in the spirit of the above TODO.) In addition I replaced some int's by size_t's and removed some warnings (and generated some new ones -- grmpf!). Also I rewrote PQoidStatus (so it actually honors the const!) and supplied a new function PQoidValue that returns a proper Oid type. This is only front-end stuff, none of the communicaton stuff was touched. The psql patch also adds some new consts to honor the new libpq situation, as well as fixes a fatal condition that resulted when using the -V (--version) option and there is no database listening. So, to summarize, the psql you should definitely put in (with or without the libpq). If you think I went too far with the const-mania in libpq, let me know and I'll make adjustments. If you approve it, I will also update the docs. -Peter -- Peter Eisentraut Sernanders vaeg 10:115
This commit is contained in:
parent
c6c60302ba
commit
2a24ec6f16
@ -828,7 +828,7 @@ do_connect(const char *new_dbname, const char *new_user, PsqlSettings *pset)
|
||||
PGconn *oldconn = pset->db;
|
||||
const char *dbparam = NULL;
|
||||
const char *userparam = NULL;
|
||||
char *pwparam = NULL;
|
||||
const char *pwparam = NULL;
|
||||
char *prompted_password = NULL;
|
||||
char *prompted_user = NULL;
|
||||
bool need_pass;
|
||||
|
@ -519,8 +519,8 @@ describeTableDetails(const char *name, PsqlSettings *pset)
|
||||
printTableOpt myopt = pset->popt.topt;
|
||||
bool description = GetVariableBool(pset->vars, "description");
|
||||
int i;
|
||||
char *view_def = NULL;
|
||||
char *headers[5];
|
||||
const char *view_def = NULL;
|
||||
const char *headers[5];
|
||||
char **cells = NULL;
|
||||
char *title = NULL;
|
||||
char **footers = NULL;
|
||||
@ -587,11 +587,10 @@ describeTableDetails(const char *name, PsqlSettings *pset)
|
||||
for (i = 0; i < PQntuples(res); i++)
|
||||
{
|
||||
int4 attypmod = atoi(PQgetvalue(res, i, 3));
|
||||
char *attype = PQgetvalue(res, i, 1);
|
||||
const char *attype = PQgetvalue(res, i, 1);
|
||||
|
||||
/* Name */
|
||||
cells[i * cols + 0] = PQgetvalue(res, i, 0); /* don't free this
|
||||
* afterwards */
|
||||
cells[i * cols + 0] = (char*)PQgetvalue(res, i, 0); /* don't free this afterwards */
|
||||
|
||||
/* Type */
|
||||
cells[i * cols + 1] = xmalloc(NAMEDATALEN + 16);
|
||||
@ -609,7 +608,7 @@ describeTableDetails(const char *name, PsqlSettings *pset)
|
||||
|
||||
/* Info */
|
||||
cells[i * cols + 2] = xmalloc(128 + 128); /* I'm cutting off the
|
||||
* default string at 128 */
|
||||
* 'default' string at 128 */
|
||||
cells[i * cols + 2][0] = '\0';
|
||||
if (strcmp(PQgetvalue(res, i, 4), "t") == 0)
|
||||
strcat(cells[i * cols + 2], "not null");
|
||||
@ -633,7 +632,7 @@ describeTableDetails(const char *name, PsqlSettings *pset)
|
||||
|
||||
/* Description */
|
||||
if (description)
|
||||
cells[i * cols + 3] = PQgetvalue(res, i, 7);
|
||||
cells[i * cols + 3] = (char*)PQgetvalue(res, i, 7);
|
||||
}
|
||||
|
||||
/* Make title */
|
||||
@ -685,7 +684,7 @@ describeTableDetails(const char *name, PsqlSettings *pset)
|
||||
|
||||
|
||||
myopt.tuples_only = false;
|
||||
printTable(title, headers, cells, footers, "llll", &myopt, pset->queryFout);
|
||||
printTable(title, headers, (const char**)cells, (const char**)footers, "llll", &myopt, pset->queryFout);
|
||||
|
||||
/* clean up */
|
||||
free(title);
|
||||
|
@ -28,13 +28,14 @@
|
||||
|
||||
|
||||
static void
|
||||
print_unaligned_text(const char *title, char **headers, char **cells, char **footers,
|
||||
print_unaligned_text(const char *title, const char * const * headers,
|
||||
const char * const * cells, const char * const * footers,
|
||||
const char *opt_fieldsep, bool opt_barebones,
|
||||
FILE *fout)
|
||||
{
|
||||
unsigned int col_count = 0;
|
||||
unsigned int i;
|
||||
char **ptr;
|
||||
const char * const * ptr;
|
||||
|
||||
if (!opt_fieldsep)
|
||||
opt_fieldsep = "";
|
||||
@ -80,14 +81,15 @@ print_unaligned_text(const char *title, char **headers, char **cells, char **foo
|
||||
|
||||
|
||||
static void
|
||||
print_unaligned_vertical(const char *title, char **headers, char **cells, char **footers,
|
||||
print_unaligned_vertical(const char *title, const char * const * headers,
|
||||
const char * const * cells, const char * const * footers,
|
||||
const char *opt_fieldsep, bool opt_barebones,
|
||||
FILE *fout)
|
||||
{
|
||||
unsigned int col_count = 0;
|
||||
unsigned int i;
|
||||
unsigned int record = 1;
|
||||
char **ptr;
|
||||
const char * const * ptr;
|
||||
|
||||
if (!opt_fieldsep)
|
||||
opt_fieldsep = "";
|
||||
@ -167,8 +169,9 @@ _print_horizontal_line(const unsigned int col_count, const unsigned int *widths,
|
||||
|
||||
|
||||
static void
|
||||
print_aligned_text(const char *title, char **headers, char **cells, char **footers,
|
||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
print_aligned_text(const char *title, const char * const * headers,
|
||||
const char * const * cells, const char * const * footers,
|
||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
FILE *fout)
|
||||
{
|
||||
unsigned int col_count = 0;
|
||||
@ -176,7 +179,7 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
tmp;
|
||||
unsigned int *widths,
|
||||
total_w;
|
||||
char **ptr;
|
||||
const char * const * ptr;
|
||||
|
||||
/* count columns */
|
||||
for (ptr = headers; *ptr; ptr++)
|
||||
@ -308,13 +311,14 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
|
||||
|
||||
static void
|
||||
print_aligned_vertical(const char *title, char **headers, char **cells, char **footers,
|
||||
print_aligned_vertical(const char *title, const char * const * headers,
|
||||
const char * const * cells, const char * const * footers,
|
||||
bool opt_barebones, unsigned short int opt_border,
|
||||
FILE *fout)
|
||||
{
|
||||
unsigned int col_count = 0;
|
||||
unsigned int record = 1;
|
||||
char **ptr;
|
||||
const char * const *ptr;
|
||||
unsigned int i,
|
||||
tmp,
|
||||
hwidth = 0,
|
||||
@ -471,14 +475,15 @@ html_escaped_print(const char *in, FILE *fout)
|
||||
|
||||
|
||||
static void
|
||||
print_html_text(const char *title, char **headers, char **cells, char **footers,
|
||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
char *opt_table_attr,
|
||||
print_html_text(const char *title, const char * const * headers,
|
||||
const char * const * cells, const char * const * footers,
|
||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
const char *opt_table_attr,
|
||||
FILE *fout)
|
||||
{
|
||||
unsigned int col_count = 0;
|
||||
unsigned int i;
|
||||
char **ptr;
|
||||
const char * const *ptr;
|
||||
|
||||
fprintf(fout, "<table border=%d", opt_border);
|
||||
if (opt_table_attr)
|
||||
@ -544,15 +549,16 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
|
||||
|
||||
static void
|
||||
print_html_vertical(const char *title, char **headers, char **cells, char **footers,
|
||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
char *opt_table_attr,
|
||||
print_html_vertical(const char *title, const char * const * headers,
|
||||
const char * const * cells, const char * const * footers,
|
||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
const char *opt_table_attr,
|
||||
FILE *fout)
|
||||
{
|
||||
unsigned int col_count = 0;
|
||||
unsigned int i;
|
||||
unsigned int record = 1;
|
||||
char **ptr;
|
||||
const char * const *ptr;
|
||||
|
||||
fprintf(fout, "<table border=%d", opt_border);
|
||||
if (opt_table_attr)
|
||||
@ -652,14 +658,15 @@ latex_escaped_print(const char *in, FILE *fout)
|
||||
|
||||
|
||||
static void
|
||||
print_latex_text(const char *title, char **headers, char **cells, char **footers,
|
||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
print_latex_text(const char *title, const char * const * headers,
|
||||
const char * const * cells, const char * const * footers,
|
||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
FILE *fout)
|
||||
{
|
||||
unsigned int col_count = 0;
|
||||
unsigned int i;
|
||||
const char *cp;
|
||||
char **ptr;
|
||||
const char * const *ptr;
|
||||
|
||||
|
||||
/* print title */
|
||||
@ -747,13 +754,14 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
|
||||
|
||||
static void
|
||||
print_latex_vertical(const char *title, char **headers, char **cells, char **footers,
|
||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
print_latex_vertical(const char *title, const char * const * headers,
|
||||
const char * const * cells, const char * const * footers,
|
||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
FILE *fout)
|
||||
{
|
||||
unsigned int col_count = 0;
|
||||
unsigned int i;
|
||||
char **ptr;
|
||||
const char * const *ptr;
|
||||
unsigned int record = 1;
|
||||
|
||||
(void) opt_align; /* currently unused parameter */
|
||||
@ -833,11 +841,14 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||
|
||||
|
||||
void
|
||||
printTable(const char *title, char **headers, char **cells, char **footers,
|
||||
printTable(const char *title,
|
||||
const char * const * headers,
|
||||
const char * const * cells,
|
||||
const char * const * footers,
|
||||
const char *align,
|
||||
const printTableOpt * opt, FILE *fout)
|
||||
{
|
||||
char *default_footer[] = {NULL};
|
||||
const char *default_footer[] = {NULL};
|
||||
unsigned short int border = opt->border;
|
||||
FILE *pager = NULL,
|
||||
*output;
|
||||
@ -868,7 +879,7 @@ printTable(const char *title, char **headers, char **cells, char **footers,
|
||||
unsigned int col_count = 0,
|
||||
row_count = 0,
|
||||
lines;
|
||||
char **ptr;
|
||||
const char * const *ptr;
|
||||
int result;
|
||||
struct winsize screen_size;
|
||||
|
||||
@ -952,11 +963,11 @@ printTable(const char *title, char **headers, char **cells, char **footers,
|
||||
|
||||
|
||||
void
|
||||
printQuery(PGresult *result, const printQueryOpt * opt, FILE *fout)
|
||||
printQuery(const PGresult *result, const printQueryOpt * opt, FILE *fout)
|
||||
{
|
||||
int nfields;
|
||||
char **headers;
|
||||
char **cells;
|
||||
const char **headers;
|
||||
const char **cells;
|
||||
char **footers;
|
||||
char *align;
|
||||
int i;
|
||||
@ -1043,8 +1054,9 @@ printQuery(PGresult *result, const printQueryOpt * opt, FILE *fout)
|
||||
|
||||
/* call table printer */
|
||||
|
||||
printTable(opt->title, headers, cells, footers ? footers : opt->footers, align,
|
||||
&opt->topt, fout);
|
||||
printTable(opt->title, headers, cells,
|
||||
footers ? (const char * const *)footers : (const char * const *)(opt->footers),
|
||||
align, &opt->topt, fout);
|
||||
|
||||
free(headers);
|
||||
free(cells);
|
||||
|
@ -44,7 +44,8 @@ typedef struct _printTableOpt
|
||||
* - align is an 'l' or an 'r' for every column, if the output format needs it.
|
||||
* (You must specify this long enough. Otherwise anything could happen.)
|
||||
*/
|
||||
void printTable(const char *title, char **headers, char **cells, char **footers,
|
||||
void printTable(const char *title, const char * const * headers,
|
||||
const char * const * cells, const char * const * footers,
|
||||
const char *align,
|
||||
const printTableOpt * opt, FILE *fout);
|
||||
|
||||
@ -66,7 +67,7 @@ typedef struct _printQueryOpt
|
||||
* It calls the printTable above with all the things set straight.
|
||||
*/
|
||||
void
|
||||
printQuery(PGresult *result, const printQueryOpt * opt, FILE *fout);
|
||||
printQuery(const PGresult *result, const printQueryOpt * opt, FILE *fout);
|
||||
|
||||
|
||||
#endif /* PRINT_H */
|
||||
|
@ -37,10 +37,10 @@
|
||||
|
||||
|
||||
static void
|
||||
process_psqlrc(PsqlSettings *pset);
|
||||
process_psqlrc(PsqlSettings *pset);
|
||||
|
||||
static void
|
||||
showVersion(PsqlSettings *pset, bool verbose);
|
||||
showVersion(PsqlSettings *pset);
|
||||
|
||||
|
||||
/* Structures to pass information between the option parsing routine
|
||||
@ -68,7 +68,7 @@ struct adhoc_opts
|
||||
};
|
||||
|
||||
static void
|
||||
parse_options(int argc, char *argv[], PsqlSettings *pset, struct adhoc_opts * options);
|
||||
parse_options(int argc, char *argv[], PsqlSettings *pset, struct adhoc_opts * options);
|
||||
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ main(int argc, char **argv)
|
||||
free(username);
|
||||
free(password);
|
||||
|
||||
if (PQstatus(settings.db) == CONNECTION_BAD)
|
||||
if (PQstatus(settings.db) == CONNECTION_BAD && options.action != ACT_SHOW_VER)
|
||||
{
|
||||
fprintf(stderr, "Connection to database '%s' failed.\n%s\n", PQdb(settings.db), PQerrorMessage(settings.db));
|
||||
PQfinish(settings.db);
|
||||
@ -169,7 +169,7 @@ main(int argc, char **argv)
|
||||
|
||||
if (options.action == ACT_SHOW_VER)
|
||||
{
|
||||
showVersion(&settings, true);
|
||||
showVersion(&settings);
|
||||
PQfinish(settings.db);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
@ -177,11 +177,8 @@ main(int argc, char **argv)
|
||||
|
||||
if (!GetVariable(settings.vars, "quiet") && !settings.notty && !options.action)
|
||||
{
|
||||
puts("Welcome to psql, the PostgreSQL interactive terminal.\n");
|
||||
|
||||
//showVersion(&settings, false);
|
||||
|
||||
puts("Type: \\copyright for distribution terms\n"
|
||||
puts("Welcome to psql, the PostgreSQL interactive terminal.\n\n"
|
||||
"Type: \\copyright for distribution terms\n"
|
||||
" \\h for help with SQL commands\n"
|
||||
" \\? for help on internal slash commands\n"
|
||||
" \\g or terminate with semicolon to execute query\n"
|
||||
@ -509,28 +506,22 @@ process_psqlrc(PsqlSettings *pset)
|
||||
* or a mismatch was detected.
|
||||
*/
|
||||
static void
|
||||
showVersion(PsqlSettings *pset, bool verbose)
|
||||
showVersion(PsqlSettings *pset)
|
||||
{
|
||||
PGresult *res;
|
||||
char *versionstr = NULL;
|
||||
PGresult *res = NULL;
|
||||
const char *versionstr = NULL;
|
||||
long int release = 0,
|
||||
version = 0,
|
||||
subversion = 0;
|
||||
|
||||
/* get backend version */
|
||||
if (pset->db && PQstatus(pset->db) == CONNECTION_OK) {
|
||||
res = PSQLexec(pset, "SELECT version()");
|
||||
if (PQresultStatus(res) == PGRES_TUPLES_OK)
|
||||
versionstr = PQgetvalue(res, 0, 0);
|
||||
|
||||
if (!verbose)
|
||||
{
|
||||
if (versionstr)
|
||||
puts(versionstr);
|
||||
PQclear(res);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp(versionstr, "PostgreSQL ", 11) == 0)
|
||||
if (versionstr && strncmp(versionstr, "PostgreSQL ", 11) == 0)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
@ -539,9 +530,9 @@ showVersion(PsqlSettings *pset, bool verbose)
|
||||
subversion = strtol(tmp + 1, &tmp, 10);
|
||||
}
|
||||
|
||||
printf("Server: %s\npsql", versionstr ? versionstr : "(could not connected)");
|
||||
printf("Server: %s\npsql", versionstr ? versionstr : "(could not connect)");
|
||||
|
||||
if (strcmp(versionstr, PG_VERSION_STR) != 0)
|
||||
if (!versionstr || strcmp(versionstr, PG_VERSION_STR) != 0)
|
||||
printf(&PG_VERSION_STR[strcspn(PG_VERSION_STR, " ")]);
|
||||
printf(" (" __DATE__ " " __TIME__ ")");
|
||||
|
||||
@ -569,10 +560,11 @@ showVersion(PsqlSettings *pset, bool verbose)
|
||||
|
||||
puts("");
|
||||
|
||||
if (release < 6 || (release == 6 && version < 5))
|
||||
if (versionstr && (release < 6 || (release == 6 && version < 5)))
|
||||
puts("\nWarning: The server you are connected to is potentially too old for this client\n"
|
||||
"version. You should ideally be using clients and servers from the same\n"
|
||||
"distribution.");
|
||||
|
||||
if (res)
|
||||
PQclear(res);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.105 1999/11/05 06:43:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.106 1999/11/11 00:10:13 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -141,7 +141,7 @@ static struct EnvironmentOptions
|
||||
"PGGEQO", "geqo"
|
||||
},
|
||||
{
|
||||
NULL
|
||||
NULL, NULL
|
||||
}
|
||||
};
|
||||
|
||||
@ -1453,56 +1453,56 @@ conninfo_free()
|
||||
}
|
||||
|
||||
/* =========== accessor functions for PGconn ========= */
|
||||
char *
|
||||
PQdb(PGconn *conn)
|
||||
const char *
|
||||
PQdb(const PGconn *conn)
|
||||
{
|
||||
if (!conn)
|
||||
return (char *) NULL;
|
||||
return conn->dbName;
|
||||
}
|
||||
|
||||
char *
|
||||
PQuser(PGconn *conn)
|
||||
const char *
|
||||
PQuser(const PGconn *conn)
|
||||
{
|
||||
if (!conn)
|
||||
return (char *) NULL;
|
||||
return conn->pguser;
|
||||
}
|
||||
|
||||
char *
|
||||
PQpass(PGconn *conn)
|
||||
const char *
|
||||
PQpass(const PGconn *conn)
|
||||
{
|
||||
if (!conn)
|
||||
return (char *) NULL;
|
||||
return conn->pgpass;
|
||||
}
|
||||
|
||||
char *
|
||||
PQhost(PGconn *conn)
|
||||
const char *
|
||||
PQhost(const PGconn *conn)
|
||||
{
|
||||
if (!conn)
|
||||
return (char *) NULL;
|
||||
return conn->pghost;
|
||||
}
|
||||
|
||||
char *
|
||||
PQport(PGconn *conn)
|
||||
const char *
|
||||
PQport(const PGconn *conn)
|
||||
{
|
||||
if (!conn)
|
||||
return (char *) NULL;
|
||||
return conn->pgport;
|
||||
}
|
||||
|
||||
char *
|
||||
PQtty(PGconn *conn)
|
||||
const char *
|
||||
PQtty(const PGconn *conn)
|
||||
{
|
||||
if (!conn)
|
||||
return (char *) NULL;
|
||||
return conn->pgtty;
|
||||
}
|
||||
|
||||
char *
|
||||
PQoptions(PGconn *conn)
|
||||
const char *
|
||||
PQoptions(const PGconn *conn)
|
||||
{
|
||||
if (!conn)
|
||||
return (char *) NULL;
|
||||
@ -1510,15 +1510,15 @@ PQoptions(PGconn *conn)
|
||||
}
|
||||
|
||||
ConnStatusType
|
||||
PQstatus(PGconn *conn)
|
||||
PQstatus(const PGconn *conn)
|
||||
{
|
||||
if (!conn)
|
||||
return CONNECTION_BAD;
|
||||
return conn->status;
|
||||
}
|
||||
|
||||
char *
|
||||
PQerrorMessage(PGconn *conn)
|
||||
const char *
|
||||
PQerrorMessage(const PGconn *conn)
|
||||
{
|
||||
static char noConn[] = "PQerrorMessage: conn pointer is NULL\n";
|
||||
|
||||
@ -1528,7 +1528,7 @@ PQerrorMessage(PGconn *conn)
|
||||
}
|
||||
|
||||
int
|
||||
PQsocket(PGconn *conn)
|
||||
PQsocket(const PGconn *conn)
|
||||
{
|
||||
if (!conn)
|
||||
return -1;
|
||||
@ -1536,7 +1536,7 @@ PQsocket(PGconn *conn)
|
||||
}
|
||||
|
||||
int
|
||||
PQbackendPID(PGconn *conn)
|
||||
PQbackendPID(const PGconn *conn)
|
||||
{
|
||||
if (!conn || conn->status != CONNECTION_OK)
|
||||
return 0;
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.85 1999/08/31 01:37:36 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.86 1999/11/11 00:10:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -179,7 +179,7 @@ PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
|
||||
* be allocated on any byte boundary.
|
||||
*/
|
||||
void *
|
||||
pqResultAlloc(PGresult *res, int nBytes, int isBinary)
|
||||
pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary)
|
||||
{
|
||||
char *space;
|
||||
PGresult_data *block;
|
||||
@ -882,7 +882,7 @@ getAnotherTuple(PGconn *conn, int binary)
|
||||
char std_bitmap[64]; /* used unless it doesn't fit */
|
||||
char *bitmap = std_bitmap;
|
||||
int i;
|
||||
int nbytes; /* the number of bytes in bitmap */
|
||||
size_t nbytes; /* the number of bytes in bitmap */
|
||||
char bmap; /* One byte of the bitmap */
|
||||
int bitmap_index; /* Its index */
|
||||
int bitcnt; /* number of bits examined in current byte */
|
||||
@ -1495,7 +1495,7 @@ PQfn(PGconn *conn,
|
||||
int *result_buf,
|
||||
int *actual_result_len,
|
||||
int result_is_int,
|
||||
PQArgBlock *args,
|
||||
const PQArgBlock *args,
|
||||
int nargs)
|
||||
{
|
||||
bool needInput = false;
|
||||
@ -1674,7 +1674,7 @@ PQfn(PGconn *conn,
|
||||
/* ====== accessor funcs for PGresult ======== */
|
||||
|
||||
ExecStatusType
|
||||
PQresultStatus(PGresult *res)
|
||||
PQresultStatus(const PGresult *res)
|
||||
{
|
||||
if (!res)
|
||||
return PGRES_NONFATAL_ERROR;
|
||||
@ -1684,14 +1684,13 @@ PQresultStatus(PGresult *res)
|
||||
const char *
|
||||
PQresStatus(ExecStatusType status)
|
||||
{
|
||||
if (((int) status) < 0 ||
|
||||
((int) status) >= (sizeof(pgresStatus) / sizeof(pgresStatus[0])))
|
||||
if ((int)status < 0 || (size_t)status >= sizeof pgresStatus / sizeof pgresStatus[0])
|
||||
return "Invalid ExecStatusType code";
|
||||
return pgresStatus[status];
|
||||
}
|
||||
|
||||
const char *
|
||||
PQresultErrorMessage(PGresult *res)
|
||||
PQresultErrorMessage(const PGresult *res)
|
||||
{
|
||||
if (!res || !res->errMsg)
|
||||
return "";
|
||||
@ -1699,7 +1698,7 @@ PQresultErrorMessage(PGresult *res)
|
||||
}
|
||||
|
||||
int
|
||||
PQntuples(PGresult *res)
|
||||
PQntuples(const PGresult *res)
|
||||
{
|
||||
if (!res)
|
||||
return 0;
|
||||
@ -1707,7 +1706,7 @@ PQntuples(PGresult *res)
|
||||
}
|
||||
|
||||
int
|
||||
PQnfields(PGresult *res)
|
||||
PQnfields(const PGresult *res)
|
||||
{
|
||||
if (!res)
|
||||
return 0;
|
||||
@ -1715,7 +1714,7 @@ PQnfields(PGresult *res)
|
||||
}
|
||||
|
||||
int
|
||||
PQbinaryTuples(PGresult *res)
|
||||
PQbinaryTuples(const PGresult *res)
|
||||
{
|
||||
if (!res)
|
||||
return 0;
|
||||
@ -1728,7 +1727,7 @@ PQbinaryTuples(PGresult *res)
|
||||
*/
|
||||
|
||||
static int
|
||||
check_field_number(const char *routineName, PGresult *res, int field_num)
|
||||
check_field_number(const char *routineName, const PGresult *res, int field_num)
|
||||
{
|
||||
char noticeBuf[128];
|
||||
|
||||
@ -1749,7 +1748,7 @@ check_field_number(const char *routineName, PGresult *res, int field_num)
|
||||
}
|
||||
|
||||
static int
|
||||
check_tuple_field_number(const char *routineName, PGresult *res,
|
||||
check_tuple_field_number(const char *routineName, const PGresult *res,
|
||||
int tup_num, int field_num)
|
||||
{
|
||||
char noticeBuf[128];
|
||||
@ -1784,8 +1783,8 @@ check_tuple_field_number(const char *routineName, PGresult *res,
|
||||
/*
|
||||
returns NULL if the field_num is invalid
|
||||
*/
|
||||
char *
|
||||
PQfname(PGresult *res, int field_num)
|
||||
const char *
|
||||
PQfname(const PGresult *res, int field_num)
|
||||
{
|
||||
if (!check_field_number("PQfname", res, field_num))
|
||||
return NULL;
|
||||
@ -1799,7 +1798,7 @@ PQfname(PGresult *res, int field_num)
|
||||
returns -1 on a bad field name
|
||||
*/
|
||||
int
|
||||
PQfnumber(PGresult *res, const char *field_name)
|
||||
PQfnumber(const PGresult *res, const char *field_name)
|
||||
{
|
||||
int i;
|
||||
char *field_case;
|
||||
@ -1837,7 +1836,7 @@ PQfnumber(PGresult *res, const char *field_name)
|
||||
}
|
||||
|
||||
Oid
|
||||
PQftype(PGresult *res, int field_num)
|
||||
PQftype(const PGresult *res, int field_num)
|
||||
{
|
||||
if (!check_field_number("PQftype", res, field_num))
|
||||
return InvalidOid;
|
||||
@ -1848,7 +1847,7 @@ PQftype(PGresult *res, int field_num)
|
||||
}
|
||||
|
||||
int
|
||||
PQfsize(PGresult *res, int field_num)
|
||||
PQfsize(const PGresult *res, int field_num)
|
||||
{
|
||||
if (!check_field_number("PQfsize", res, field_num))
|
||||
return 0;
|
||||
@ -1859,7 +1858,7 @@ PQfsize(PGresult *res, int field_num)
|
||||
}
|
||||
|
||||
int
|
||||
PQfmod(PGresult *res, int field_num)
|
||||
PQfmod(const PGresult *res, int field_num)
|
||||
{
|
||||
if (!check_field_number("PQfmod", res, field_num))
|
||||
return 0;
|
||||
@ -1869,8 +1868,8 @@ PQfmod(PGresult *res, int field_num)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
PQcmdStatus(PGresult *res)
|
||||
const char *
|
||||
PQcmdStatus(const PGresult *res)
|
||||
{
|
||||
if (!res)
|
||||
return NULL;
|
||||
@ -1883,47 +1882,49 @@ PQcmdStatus(PGresult *res)
|
||||
if not, return ""
|
||||
*/
|
||||
const char *
|
||||
PQoidStatus(PGresult *res)
|
||||
PQoidStatus(const PGresult *res)
|
||||
{
|
||||
char *p,
|
||||
*e,
|
||||
*scan;
|
||||
int slen,
|
||||
olen;
|
||||
/*
|
||||
* This must be enough to hold the result. Don't laugh, this is
|
||||
* better than what this function used to do.
|
||||
*/
|
||||
static char buf[24];
|
||||
|
||||
if (!res)
|
||||
size_t len;
|
||||
|
||||
if (!res || !res->cmdStatus || strncmp(res->cmdStatus, "INSERT ", 7) != 0)
|
||||
return "";
|
||||
|
||||
if (strncmp(res->cmdStatus, "INSERT ", 7) != 0)
|
||||
return "";
|
||||
len = strspn(res->cmdStatus + 7, "0123456789");
|
||||
if (len > 23)
|
||||
len = 23;
|
||||
strncpy(buf, res->cmdStatus + 7, len);
|
||||
buf[23] = '\0';
|
||||
|
||||
/*----------
|
||||
* The cmdStatus string looks like
|
||||
* INSERT oid count\0
|
||||
* In order to be able to return an ordinary C string without
|
||||
* damaging the result for PQcmdStatus or PQcmdTuples, we copy
|
||||
* the oid part of the string to just after the null, so that
|
||||
* cmdStatus looks like
|
||||
* INSERT oid count\0oid\0
|
||||
* ^ our return value points here
|
||||
* Pretty klugy eh? This routine should've just returned an Oid value.
|
||||
*----------
|
||||
*/
|
||||
return buf;
|
||||
}
|
||||
|
||||
slen = strlen(res->cmdStatus);
|
||||
p = res->cmdStatus + 7; /* where oid is now */
|
||||
e = res->cmdStatus + slen + 1; /* where to put the oid string */
|
||||
/*
|
||||
PQoidValue -
|
||||
a perhaps preferable form of the above which just returns
|
||||
an Oid type
|
||||
*/
|
||||
Oid
|
||||
PQoidValue(const PGresult *res)
|
||||
{
|
||||
char * endptr = NULL;
|
||||
long int result;
|
||||
|
||||
for (scan = p; *scan && *scan != ' ';)
|
||||
scan++;
|
||||
olen = scan - p;
|
||||
if (slen + olen + 2 > sizeof(res->cmdStatus))
|
||||
return ""; /* something very wrong if it doesn't fit */
|
||||
if (!res || !res->cmdStatus || strncmp(res->cmdStatus, "INSERT ", 7) != 0)
|
||||
return InvalidOid;
|
||||
|
||||
strncpy(e, p, olen);
|
||||
e[olen] = '\0';
|
||||
errno = 0;
|
||||
result = strtoul(res->cmdStatus + 7, &endptr, 10);
|
||||
|
||||
return e;
|
||||
if (!endptr || (*endptr != ' ' && *endptr != '\0') || errno == ERANGE)
|
||||
return InvalidOid;
|
||||
else
|
||||
return (Oid)result;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1932,7 +1933,7 @@ PQoidStatus(PGresult *res)
|
||||
of inserted/affected tuples, if not, return ""
|
||||
*/
|
||||
const char *
|
||||
PQcmdTuples(PGresult *res)
|
||||
PQcmdTuples(const PGresult *res)
|
||||
{
|
||||
char noticeBuf[128];
|
||||
|
||||
@ -1943,7 +1944,7 @@ PQcmdTuples(PGresult *res)
|
||||
strncmp(res->cmdStatus, "DELETE", 6) == 0 ||
|
||||
strncmp(res->cmdStatus, "UPDATE", 6) == 0)
|
||||
{
|
||||
char *p = res->cmdStatus + 6;
|
||||
const char *p = res->cmdStatus + 6;
|
||||
|
||||
if (*p == 0)
|
||||
{
|
||||
@ -1987,8 +1988,8 @@ PQcmdTuples(PGresult *res)
|
||||
|
||||
if res is not binary, a null-terminated ASCII string is returned.
|
||||
*/
|
||||
char *
|
||||
PQgetvalue(PGresult *res, int tup_num, int field_num)
|
||||
const char *
|
||||
PQgetvalue(const PGresult *res, int tup_num, int field_num)
|
||||
{
|
||||
if (!check_tuple_field_number("PQgetvalue", res, tup_num, field_num))
|
||||
return NULL;
|
||||
@ -2002,7 +2003,7 @@ PQgetvalue(PGresult *res, int tup_num, int field_num)
|
||||
by PQgetvalue doesn't either.)
|
||||
*/
|
||||
int
|
||||
PQgetlength(PGresult *res, int tup_num, int field_num)
|
||||
PQgetlength(const PGresult *res, int tup_num, int field_num)
|
||||
{
|
||||
if (!check_tuple_field_number("PQgetlength", res, tup_num, field_num))
|
||||
return 0;
|
||||
@ -2016,7 +2017,7 @@ PQgetlength(PGresult *res, int tup_num, int field_num)
|
||||
returns the null status of a field value.
|
||||
*/
|
||||
int
|
||||
PQgetisnull(PGresult *res, int tup_num, int field_num)
|
||||
PQgetisnull(const PGresult *res, int tup_num, int field_num)
|
||||
{
|
||||
if (!check_tuple_field_number("PQgetisnull", res, tup_num, field_num))
|
||||
return 1; /* pretend it is null */
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.25 1999/08/31 01:37:36 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.26 1999/11/11 00:10:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -127,7 +127,7 @@ lo_close(PGconn *conn, int fd)
|
||||
*/
|
||||
|
||||
int
|
||||
lo_read(PGconn *conn, int fd, char *buf, int len)
|
||||
lo_read(PGconn *conn, int fd, char *buf, size_t len)
|
||||
{
|
||||
PQArgBlock argv[2];
|
||||
PGresult *res;
|
||||
@ -167,7 +167,7 @@ lo_read(PGconn *conn, int fd, char *buf, int len)
|
||||
*
|
||||
*/
|
||||
int
|
||||
lo_write(PGconn *conn, int fd, char *buf, int len)
|
||||
lo_write(PGconn *conn, int fd, const char *buf, size_t len)
|
||||
{
|
||||
PQArgBlock argv[2];
|
||||
PGresult *res;
|
||||
@ -378,7 +378,7 @@ lo_unlink(PGconn *conn, Oid lobjId)
|
||||
*/
|
||||
|
||||
Oid
|
||||
lo_import(PGconn *conn, char *filename)
|
||||
lo_import(PGconn *conn, const char *filename)
|
||||
{
|
||||
int fd;
|
||||
int nbytes,
|
||||
@ -451,7 +451,7 @@ lo_import(PGconn *conn, char *filename)
|
||||
* returns -1 upon failure, 1 otherwise
|
||||
*/
|
||||
int
|
||||
lo_export(PGconn *conn, Oid lobjId, char *filename)
|
||||
lo_export(PGconn *conn, Oid lobjId, const char *filename)
|
||||
{
|
||||
int fd;
|
||||
int nbytes,
|
||||
@ -522,7 +522,7 @@ lo_initialize(PGconn *conn)
|
||||
PGresult *res;
|
||||
PGlobjfuncs *lobjfuncs;
|
||||
int n;
|
||||
char *fname;
|
||||
const char *fname;
|
||||
Oid foid;
|
||||
|
||||
/* ----------------
|
||||
|
@ -24,7 +24,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.31 1999/09/27 03:13:16 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.32 1999/11/11 00:10:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -82,9 +82,9 @@ pqGetc(char *result, PGconn *conn)
|
||||
with buffering
|
||||
*/
|
||||
static int
|
||||
pqPutBytes(const char *s, int nbytes, PGconn *conn)
|
||||
pqPutBytes(const char *s, size_t nbytes, PGconn *conn)
|
||||
{
|
||||
int avail = conn->outBufSize - conn->outCount;
|
||||
size_t avail = Max(conn->outBufSize - conn->outCount, 0);
|
||||
|
||||
while (nbytes > avail)
|
||||
{
|
||||
@ -157,7 +157,7 @@ pqPuts(const char *s, PGconn *conn)
|
||||
get a string of exactly len bytes in buffer s, no null termination
|
||||
*/
|
||||
int
|
||||
pqGetnchar(char *s, int len, PGconn *conn)
|
||||
pqGetnchar(char *s, size_t len, PGconn *conn)
|
||||
{
|
||||
if (len < 0 || len > conn->inEnd - conn->inCursor)
|
||||
return EOF;
|
||||
@ -168,7 +168,7 @@ pqGetnchar(char *s, int len, PGconn *conn)
|
||||
conn->inCursor += len;
|
||||
|
||||
if (conn->Pfdebug)
|
||||
fprintf(conn->Pfdebug, "From backend (%d)> %.*s\n", len, len, s);
|
||||
fprintf(conn->Pfdebug, "From backend (%d)> %.*s\n", len, (int)len, s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -178,13 +178,13 @@ pqGetnchar(char *s, int len, PGconn *conn)
|
||||
send a string of exactly len bytes, no null termination needed
|
||||
*/
|
||||
int
|
||||
pqPutnchar(const char *s, int len, PGconn *conn)
|
||||
pqPutnchar(const char *s, size_t len, PGconn *conn)
|
||||
{
|
||||
if (pqPutBytes(s, len, conn))
|
||||
return EOF;
|
||||
|
||||
if (conn->Pfdebug)
|
||||
fprintf(conn->Pfdebug, "To backend> %.*s\n", len, s);
|
||||
fprintf(conn->Pfdebug, "To backend> %.*s\n", (int)len, s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -195,7 +195,7 @@ pqPutnchar(const char *s, int len, PGconn *conn)
|
||||
to local byte order
|
||||
*/
|
||||
int
|
||||
pqGetInt(int *result, int bytes, PGconn *conn)
|
||||
pqGetInt(int *result, size_t bytes, PGconn *conn)
|
||||
{
|
||||
uint16 tmp2;
|
||||
uint32 tmp4;
|
||||
@ -236,7 +236,7 @@ pqGetInt(int *result, int bytes, PGconn *conn)
|
||||
to network byte order.
|
||||
*/
|
||||
int
|
||||
pqPutInt(int value, int bytes, PGconn *conn)
|
||||
pqPutInt(int value, size_t bytes, PGconn *conn)
|
||||
{
|
||||
uint16 tmp2;
|
||||
uint32 tmp4;
|
||||
|
@ -9,7 +9,7 @@
|
||||
* didn't really belong there.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.27 1999/08/31 01:37:37 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.28 1999/11/11 00:10:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -50,16 +50,16 @@ static struct winsize
|
||||
#endif
|
||||
|
||||
|
||||
static void do_field(PQprintOpt *po, PGresult *res,
|
||||
static void do_field(const PQprintOpt *po, const PGresult *res,
|
||||
const int i, const int j, const int fs_len,
|
||||
char **fields,
|
||||
const int nFields, char **fieldNames,
|
||||
const int nFields, const char **fieldNames,
|
||||
unsigned char *fieldNotNum, int *fieldMax,
|
||||
const int fieldMaxLen, FILE *fout);
|
||||
static char *do_header(FILE *fout, PQprintOpt *po, const int nFields,
|
||||
int *fieldMax, char **fieldNames, unsigned char *fieldNotNum,
|
||||
const int fs_len, PGresult *res);
|
||||
static void output_row(FILE *fout, PQprintOpt *po, const int nFields, char **fields,
|
||||
static char *do_header(FILE *fout, const PQprintOpt *po, const int nFields,
|
||||
int *fieldMax, const char **fieldNames, unsigned char *fieldNotNum,
|
||||
const int fs_len, const PGresult *res);
|
||||
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);
|
||||
@ -79,8 +79,8 @@ static void fill(int length, int max, char filler, FILE *fp);
|
||||
|
||||
void
|
||||
PQprint(FILE *fout,
|
||||
PGresult *res,
|
||||
PQprintOpt *po)
|
||||
const PGresult *res,
|
||||
const PQprintOpt *po)
|
||||
{
|
||||
int nFields;
|
||||
|
||||
@ -95,7 +95,7 @@ PQprint(FILE *fout,
|
||||
unsigned char *fieldNotNum = NULL;
|
||||
char *border = NULL;
|
||||
char **fields = NULL;
|
||||
char **fieldNames;
|
||||
const char **fieldNames;
|
||||
int fieldMaxLen = 0;
|
||||
int numFieldName;
|
||||
int fs_len = strlen(po->fieldSep);
|
||||
@ -105,7 +105,7 @@ PQprint(FILE *fout,
|
||||
char *pagerenv;
|
||||
|
||||
nTups = PQntuples(res);
|
||||
if (!(fieldNames = (char **) calloc(nFields, sizeof(char *))))
|
||||
if (!(fieldNames = (const char **) calloc(nFields, sizeof(char *))))
|
||||
{
|
||||
perror("calloc");
|
||||
exit(1);
|
||||
@ -127,7 +127,7 @@ PQprint(FILE *fout,
|
||||
for (j = 0; j < nFields; j++)
|
||||
{
|
||||
int len;
|
||||
char *s = (j < numFieldName && po->fieldName[j][0]) ?
|
||||
const char *s = (j < numFieldName && po->fieldName[j][0]) ?
|
||||
po->fieldName[j] : PQfname(res, j);
|
||||
|
||||
fieldNames[j] = s;
|
||||
@ -218,7 +218,7 @@ PQprint(FILE *fout,
|
||||
|
||||
for (j = 0; j < nFields; j++)
|
||||
{
|
||||
char *s = fieldNames[j];
|
||||
const char *s = fieldNames[j];
|
||||
|
||||
fputs(s, fout);
|
||||
len += strlen(s) + fs_len;
|
||||
@ -317,12 +317,12 @@ PQprint(FILE *fout,
|
||||
*/
|
||||
|
||||
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
|
||||
PQdisplayTuples(const 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
|
||||
)
|
||||
{
|
||||
#define DEFAULT_FIELD_SEP " "
|
||||
@ -414,12 +414,12 @@ PQdisplayTuples(PGresult *res,
|
||||
*
|
||||
*/
|
||||
void
|
||||
PQprintTuples(PGresult *res,
|
||||
FILE *fout, /* output stream */
|
||||
int PrintAttNames,/* print attribute names or not */
|
||||
int TerseOutput, /* delimiter bars or not? */
|
||||
int colWidth /* width of column, if 0, use variable
|
||||
* width */
|
||||
PQprintTuples(const PGresult *res,
|
||||
FILE *fout, /* output stream */
|
||||
int PrintAttNames,/* print attribute names or not */
|
||||
int TerseOutput, /* delimiter bars or not? */
|
||||
int colWidth /* width of column, if 0, use variable
|
||||
* width */
|
||||
)
|
||||
{
|
||||
int nFields;
|
||||
@ -475,7 +475,7 @@ PQprintTuples(PGresult *res,
|
||||
{
|
||||
for (j = 0; j < nFields; j++)
|
||||
{
|
||||
char *pval = PQgetvalue(res, i, j);
|
||||
const char *pval = PQgetvalue(res, i, j);
|
||||
|
||||
fprintf(fout, formatString,
|
||||
TerseOutput ? "" : "|",
|
||||
@ -498,7 +498,7 @@ PQprintTuples(PGresult *res,
|
||||
* the backend is assumed.
|
||||
*/
|
||||
int
|
||||
PQmblen(unsigned char *s)
|
||||
PQmblen(const unsigned char *s)
|
||||
{
|
||||
char *str;
|
||||
int encoding = -1;
|
||||
@ -515,7 +515,7 @@ PQmblen(unsigned char *s)
|
||||
|
||||
/* Provide a default definition in case someone calls it anyway */
|
||||
int
|
||||
PQmblen(unsigned char *s)
|
||||
PQmblen(const unsigned char *s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@ -523,15 +523,15 @@ PQmblen(unsigned char *s)
|
||||
#endif /* MULTIBYTE */
|
||||
|
||||
static void
|
||||
do_field(PQprintOpt *po, PGresult *res,
|
||||
do_field(const PQprintOpt *po, const PGresult *res,
|
||||
const int i, const int j, const int fs_len,
|
||||
char **fields,
|
||||
const int nFields, char **fieldNames,
|
||||
const int nFields, char const **fieldNames,
|
||||
unsigned char *fieldNotNum, int *fieldMax,
|
||||
const int fieldMaxLen, FILE *fout)
|
||||
{
|
||||
|
||||
char *pval,
|
||||
const char *pval,
|
||||
*p;
|
||||
int plen;
|
||||
bool skipit;
|
||||
@ -641,9 +641,9 @@ do_field(PQprintOpt *po, PGresult *res,
|
||||
|
||||
|
||||
static char *
|
||||
do_header(FILE *fout, PQprintOpt *po, const int nFields, int *fieldMax,
|
||||
char **fieldNames, unsigned char *fieldNotNum,
|
||||
const int fs_len, PGresult *res)
|
||||
do_header(FILE *fout, const PQprintOpt *po, const int nFields, int *fieldMax,
|
||||
const char **fieldNames, unsigned char *fieldNotNum,
|
||||
const int fs_len, const PGresult *res)
|
||||
{
|
||||
|
||||
int j; /* for loop index */
|
||||
@ -697,7 +697,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);
|
||||
const char *s = PQfname(res, j);
|
||||
|
||||
if (po->html3)
|
||||
{
|
||||
@ -729,7 +729,7 @@ do_header(FILE *fout, PQprintOpt *po, const int nFields, int *fieldMax,
|
||||
|
||||
|
||||
static void
|
||||
output_row(FILE *fout, PQprintOpt *po, const int nFields, char **fields,
|
||||
output_row(FILE *fout, const PQprintOpt *po, const int nFields, char **fields,
|
||||
unsigned char *fieldNotNum, int *fieldMax, char *border,
|
||||
const int row_index)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: libpq-fe.h,v 1.51 1999/10/26 04:49:00 momjian Exp $
|
||||
* $Id: libpq-fe.h,v 1.52 1999/11/11 00:10:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -176,17 +176,17 @@ extern "C"
|
||||
extern int PQrequestCancel(PGconn *conn);
|
||||
|
||||
/* Accessor functions for PGconn objects */
|
||||
extern char *PQdb(PGconn *conn);
|
||||
extern char *PQuser(PGconn *conn);
|
||||
extern char *PQpass(PGconn *conn);
|
||||
extern char *PQhost(PGconn *conn);
|
||||
extern char *PQport(PGconn *conn);
|
||||
extern char *PQtty(PGconn *conn);
|
||||
extern char *PQoptions(PGconn *conn);
|
||||
extern ConnStatusType PQstatus(PGconn *conn);
|
||||
extern char *PQerrorMessage(PGconn *conn);
|
||||
extern int PQsocket(PGconn *conn);
|
||||
extern int PQbackendPID(PGconn *conn);
|
||||
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 ConnStatusType PQstatus(const PGconn *conn);
|
||||
extern const char *PQerrorMessage(const PGconn *conn);
|
||||
extern int PQsocket(const PGconn *conn);
|
||||
extern int PQbackendPID(const PGconn *conn);
|
||||
|
||||
/* Enable/disable tracing */
|
||||
extern void PQtrace(PGconn *conn, FILE *debug_port);
|
||||
@ -221,31 +221,32 @@ extern "C"
|
||||
* use
|
||||
*/
|
||||
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,
|
||||
const PQArgBlock *args,
|
||||
int nargs);
|
||||
|
||||
/* Accessor functions for PGresult objects */
|
||||
extern ExecStatusType PQresultStatus(PGresult *res);
|
||||
extern ExecStatusType PQresultStatus(const PGresult *res);
|
||||
extern const char *PQresStatus(ExecStatusType status);
|
||||
extern const char *PQresultErrorMessage(PGresult *res);
|
||||
extern int PQntuples(PGresult *res);
|
||||
extern int PQnfields(PGresult *res);
|
||||
extern int PQbinaryTuples(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 int PQfsize(PGresult *res, int field_num);
|
||||
extern int PQfmod(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 const 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 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 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 int PQgetlength(const PGresult *res, int tup_num, int field_num);
|
||||
extern int PQgetisnull(const PGresult *res, int tup_num, int field_num);
|
||||
|
||||
/* Delete a PGresult */
|
||||
extern void PQclear(PGresult *res);
|
||||
@ -260,47 +261,47 @@ extern "C"
|
||||
/* === in fe-print.c === */
|
||||
|
||||
extern void PQprint(FILE *fout, /* output stream */
|
||||
PGresult *res,
|
||||
PQprintOpt *ps); /* option structure */
|
||||
const PGresult *res,
|
||||
const PQprintOpt *ps); /* option structure */
|
||||
|
||||
/*
|
||||
* PQdisplayTuples() is a better version of PQprintTuples(), but both
|
||||
* are obsoleted by PQprint().
|
||||
*/
|
||||
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 PQdisplayTuples(const 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 PQprintTuples(const 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 */
|
||||
|
||||
/* Determine length of multibyte encoded char at *s */
|
||||
extern int PQmblen(unsigned char *s);
|
||||
extern int PQmblen(const unsigned char *s);
|
||||
|
||||
/* === in fe-lobj.c === */
|
||||
|
||||
/* Large-object access routines */
|
||||
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, int len);
|
||||
extern int lo_write(PGconn *conn, int fd, char *buf, int len);
|
||||
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_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);
|
||||
extern int lo_unlink(PGconn *conn, Oid lobjId);
|
||||
extern Oid lo_import(PGconn *conn, char *filename);
|
||||
extern int lo_export(PGconn *conn, Oid lobjId, char *filename);
|
||||
extern Oid lo_import(PGconn *conn, const char *filename);
|
||||
extern int lo_export(PGconn *conn, Oid lobjId, const char *filename);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
@ -11,7 +11,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: libpq-int.h,v 1.12 1999/09/27 03:13:16 momjian Exp $
|
||||
* $Id: libpq-int.h,v 1.13 1999/11/11 00:10:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -247,7 +247,7 @@ extern int pqPacketSend(PGconn *conn, const char *buf, size_t len);
|
||||
/* === in fe-exec.c === */
|
||||
|
||||
extern void pqSetResultError(PGresult *res, const char *msg);
|
||||
extern void *pqResultAlloc(PGresult *res, int nBytes, int isBinary);
|
||||
extern void *pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary);
|
||||
extern char *pqResultStrdup(PGresult *res, const char *str);
|
||||
extern void pqClearAsyncResult(PGconn *conn);
|
||||
|
||||
@ -261,10 +261,10 @@ extern void pqClearAsyncResult(PGconn *conn);
|
||||
extern int pqGetc(char *result, PGconn *conn);
|
||||
extern int pqGets(PQExpBuffer buf, PGconn *conn);
|
||||
extern int pqPuts(const char *s, PGconn *conn);
|
||||
extern int pqGetnchar(char *s, int len, PGconn *conn);
|
||||
extern int pqPutnchar(const char *s, int len, PGconn *conn);
|
||||
extern int pqGetInt(int *result, int bytes, PGconn *conn);
|
||||
extern int pqPutInt(int value, int bytes, PGconn *conn);
|
||||
extern int pqGetnchar(char *s, size_t len, PGconn *conn);
|
||||
extern int pqPutnchar(const char *s, size_t len, PGconn *conn);
|
||||
extern int pqGetInt(int *result, size_t bytes, PGconn *conn);
|
||||
extern int pqPutInt(int value, size_t bytes, PGconn *conn);
|
||||
extern int pqReadData(PGconn *conn);
|
||||
extern int pqFlush(PGconn *conn);
|
||||
extern int pqWait(int forRead, int forWrite, PGconn *conn);
|
||||
|
Loading…
x
Reference in New Issue
Block a user