mirror of
https://github.com/postgres/postgres.git
synced 2025-04-29 13:56:47 +03:00
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;
|
PGconn *oldconn = pset->db;
|
||||||
const char *dbparam = NULL;
|
const char *dbparam = NULL;
|
||||||
const char *userparam = NULL;
|
const char *userparam = NULL;
|
||||||
char *pwparam = NULL;
|
const char *pwparam = NULL;
|
||||||
char *prompted_password = NULL;
|
char *prompted_password = NULL;
|
||||||
char *prompted_user = NULL;
|
char *prompted_user = NULL;
|
||||||
bool need_pass;
|
bool need_pass;
|
||||||
|
@ -519,8 +519,8 @@ describeTableDetails(const char *name, PsqlSettings *pset)
|
|||||||
printTableOpt myopt = pset->popt.topt;
|
printTableOpt myopt = pset->popt.topt;
|
||||||
bool description = GetVariableBool(pset->vars, "description");
|
bool description = GetVariableBool(pset->vars, "description");
|
||||||
int i;
|
int i;
|
||||||
char *view_def = NULL;
|
const char *view_def = NULL;
|
||||||
char *headers[5];
|
const char *headers[5];
|
||||||
char **cells = NULL;
|
char **cells = NULL;
|
||||||
char *title = NULL;
|
char *title = NULL;
|
||||||
char **footers = NULL;
|
char **footers = NULL;
|
||||||
@ -587,11 +587,10 @@ describeTableDetails(const char *name, PsqlSettings *pset)
|
|||||||
for (i = 0; i < PQntuples(res); i++)
|
for (i = 0; i < PQntuples(res); i++)
|
||||||
{
|
{
|
||||||
int4 attypmod = atoi(PQgetvalue(res, i, 3));
|
int4 attypmod = atoi(PQgetvalue(res, i, 3));
|
||||||
char *attype = PQgetvalue(res, i, 1);
|
const char *attype = PQgetvalue(res, i, 1);
|
||||||
|
|
||||||
/* Name */
|
/* Name */
|
||||||
cells[i * cols + 0] = PQgetvalue(res, i, 0); /* don't free this
|
cells[i * cols + 0] = (char*)PQgetvalue(res, i, 0); /* don't free this afterwards */
|
||||||
* afterwards */
|
|
||||||
|
|
||||||
/* Type */
|
/* Type */
|
||||||
cells[i * cols + 1] = xmalloc(NAMEDATALEN + 16);
|
cells[i * cols + 1] = xmalloc(NAMEDATALEN + 16);
|
||||||
@ -609,7 +608,7 @@ describeTableDetails(const char *name, PsqlSettings *pset)
|
|||||||
|
|
||||||
/* Info */
|
/* Info */
|
||||||
cells[i * cols + 2] = xmalloc(128 + 128); /* I'm cutting off the
|
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';
|
cells[i * cols + 2][0] = '\0';
|
||||||
if (strcmp(PQgetvalue(res, i, 4), "t") == 0)
|
if (strcmp(PQgetvalue(res, i, 4), "t") == 0)
|
||||||
strcat(cells[i * cols + 2], "not null");
|
strcat(cells[i * cols + 2], "not null");
|
||||||
@ -633,7 +632,7 @@ describeTableDetails(const char *name, PsqlSettings *pset)
|
|||||||
|
|
||||||
/* Description */
|
/* Description */
|
||||||
if (description)
|
if (description)
|
||||||
cells[i * cols + 3] = PQgetvalue(res, i, 7);
|
cells[i * cols + 3] = (char*)PQgetvalue(res, i, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make title */
|
/* Make title */
|
||||||
@ -685,7 +684,7 @@ describeTableDetails(const char *name, PsqlSettings *pset)
|
|||||||
|
|
||||||
|
|
||||||
myopt.tuples_only = false;
|
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 */
|
/* clean up */
|
||||||
free(title);
|
free(title);
|
||||||
|
@ -28,13 +28,14 @@
|
|||||||
|
|
||||||
|
|
||||||
static void
|
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,
|
const char *opt_fieldsep, bool opt_barebones,
|
||||||
FILE *fout)
|
FILE *fout)
|
||||||
{
|
{
|
||||||
unsigned int col_count = 0;
|
unsigned int col_count = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
char **ptr;
|
const char * const * ptr;
|
||||||
|
|
||||||
if (!opt_fieldsep)
|
if (!opt_fieldsep)
|
||||||
opt_fieldsep = "";
|
opt_fieldsep = "";
|
||||||
@ -80,14 +81,15 @@ print_unaligned_text(const char *title, char **headers, char **cells, char **foo
|
|||||||
|
|
||||||
|
|
||||||
static void
|
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,
|
const char *opt_fieldsep, bool opt_barebones,
|
||||||
FILE *fout)
|
FILE *fout)
|
||||||
{
|
{
|
||||||
unsigned int col_count = 0;
|
unsigned int col_count = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int record = 1;
|
unsigned int record = 1;
|
||||||
char **ptr;
|
const char * const * ptr;
|
||||||
|
|
||||||
if (!opt_fieldsep)
|
if (!opt_fieldsep)
|
||||||
opt_fieldsep = "";
|
opt_fieldsep = "";
|
||||||
@ -167,8 +169,9 @@ _print_horizontal_line(const unsigned int col_count, const unsigned int *widths,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_aligned_text(const char *title, char **headers, char **cells, char **footers,
|
print_aligned_text(const char *title, const char * const * headers,
|
||||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
const char * const * cells, const char * const * footers,
|
||||||
|
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||||
FILE *fout)
|
FILE *fout)
|
||||||
{
|
{
|
||||||
unsigned int col_count = 0;
|
unsigned int col_count = 0;
|
||||||
@ -176,7 +179,7 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
|||||||
tmp;
|
tmp;
|
||||||
unsigned int *widths,
|
unsigned int *widths,
|
||||||
total_w;
|
total_w;
|
||||||
char **ptr;
|
const char * const * ptr;
|
||||||
|
|
||||||
/* count columns */
|
/* count columns */
|
||||||
for (ptr = headers; *ptr; ptr++)
|
for (ptr = headers; *ptr; ptr++)
|
||||||
@ -308,13 +311,14 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
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,
|
bool opt_barebones, unsigned short int opt_border,
|
||||||
FILE *fout)
|
FILE *fout)
|
||||||
{
|
{
|
||||||
unsigned int col_count = 0;
|
unsigned int col_count = 0;
|
||||||
unsigned int record = 1;
|
unsigned int record = 1;
|
||||||
char **ptr;
|
const char * const *ptr;
|
||||||
unsigned int i,
|
unsigned int i,
|
||||||
tmp,
|
tmp,
|
||||||
hwidth = 0,
|
hwidth = 0,
|
||||||
@ -471,14 +475,15 @@ html_escaped_print(const char *in, FILE *fout)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_html_text(const char *title, char **headers, char **cells, char **footers,
|
print_html_text(const char *title, const char * const * headers,
|
||||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
const char * const * cells, const char * const * footers,
|
||||||
char *opt_table_attr,
|
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||||
|
const char *opt_table_attr,
|
||||||
FILE *fout)
|
FILE *fout)
|
||||||
{
|
{
|
||||||
unsigned int col_count = 0;
|
unsigned int col_count = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
char **ptr;
|
const char * const *ptr;
|
||||||
|
|
||||||
fprintf(fout, "<table border=%d", opt_border);
|
fprintf(fout, "<table border=%d", opt_border);
|
||||||
if (opt_table_attr)
|
if (opt_table_attr)
|
||||||
@ -544,15 +549,16 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_html_vertical(const char *title, char **headers, char **cells, char **footers,
|
print_html_vertical(const char *title, const char * const * headers,
|
||||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
const char * const * cells, const char * const * footers,
|
||||||
char *opt_table_attr,
|
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||||
|
const char *opt_table_attr,
|
||||||
FILE *fout)
|
FILE *fout)
|
||||||
{
|
{
|
||||||
unsigned int col_count = 0;
|
unsigned int col_count = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int record = 1;
|
unsigned int record = 1;
|
||||||
char **ptr;
|
const char * const *ptr;
|
||||||
|
|
||||||
fprintf(fout, "<table border=%d", opt_border);
|
fprintf(fout, "<table border=%d", opt_border);
|
||||||
if (opt_table_attr)
|
if (opt_table_attr)
|
||||||
@ -652,14 +658,15 @@ latex_escaped_print(const char *in, FILE *fout)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_latex_text(const char *title, char **headers, char **cells, char **footers,
|
print_latex_text(const char *title, const char * const * headers,
|
||||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
const char * const * cells, const char * const * footers,
|
||||||
|
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||||
FILE *fout)
|
FILE *fout)
|
||||||
{
|
{
|
||||||
unsigned int col_count = 0;
|
unsigned int col_count = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
const char *cp;
|
const char *cp;
|
||||||
char **ptr;
|
const char * const *ptr;
|
||||||
|
|
||||||
|
|
||||||
/* print title */
|
/* print title */
|
||||||
@ -747,13 +754,14 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_latex_vertical(const char *title, char **headers, char **cells, char **footers,
|
print_latex_vertical(const char *title, const char * const * headers,
|
||||||
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
const char * const * cells, const char * const * footers,
|
||||||
|
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
||||||
FILE *fout)
|
FILE *fout)
|
||||||
{
|
{
|
||||||
unsigned int col_count = 0;
|
unsigned int col_count = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
char **ptr;
|
const char * const *ptr;
|
||||||
unsigned int record = 1;
|
unsigned int record = 1;
|
||||||
|
|
||||||
(void) opt_align; /* currently unused parameter */
|
(void) opt_align; /* currently unused parameter */
|
||||||
@ -833,11 +841,14 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
|
|||||||
|
|
||||||
|
|
||||||
void
|
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 char *align,
|
||||||
const printTableOpt * opt, FILE *fout)
|
const printTableOpt * opt, FILE *fout)
|
||||||
{
|
{
|
||||||
char *default_footer[] = {NULL};
|
const char *default_footer[] = {NULL};
|
||||||
unsigned short int border = opt->border;
|
unsigned short int border = opt->border;
|
||||||
FILE *pager = NULL,
|
FILE *pager = NULL,
|
||||||
*output;
|
*output;
|
||||||
@ -868,7 +879,7 @@ printTable(const char *title, char **headers, char **cells, char **footers,
|
|||||||
unsigned int col_count = 0,
|
unsigned int col_count = 0,
|
||||||
row_count = 0,
|
row_count = 0,
|
||||||
lines;
|
lines;
|
||||||
char **ptr;
|
const char * const *ptr;
|
||||||
int result;
|
int result;
|
||||||
struct winsize screen_size;
|
struct winsize screen_size;
|
||||||
|
|
||||||
@ -952,11 +963,11 @@ printTable(const char *title, char **headers, char **cells, char **footers,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
printQuery(PGresult *result, const printQueryOpt * opt, FILE *fout)
|
printQuery(const PGresult *result, const printQueryOpt * opt, FILE *fout)
|
||||||
{
|
{
|
||||||
int nfields;
|
int nfields;
|
||||||
char **headers;
|
const char **headers;
|
||||||
char **cells;
|
const char **cells;
|
||||||
char **footers;
|
char **footers;
|
||||||
char *align;
|
char *align;
|
||||||
int i;
|
int i;
|
||||||
@ -1043,8 +1054,9 @@ printQuery(PGresult *result, const printQueryOpt * opt, FILE *fout)
|
|||||||
|
|
||||||
/* call table printer */
|
/* call table printer */
|
||||||
|
|
||||||
printTable(opt->title, headers, cells, footers ? footers : opt->footers, align,
|
printTable(opt->title, headers, cells,
|
||||||
&opt->topt, fout);
|
footers ? (const char * const *)footers : (const char * const *)(opt->footers),
|
||||||
|
align, &opt->topt, fout);
|
||||||
|
|
||||||
free(headers);
|
free(headers);
|
||||||
free(cells);
|
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.
|
* - 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.)
|
* (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 char *align,
|
||||||
const printTableOpt * opt, FILE *fout);
|
const printTableOpt * opt, FILE *fout);
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ typedef struct _printQueryOpt
|
|||||||
* It calls the printTable above with all the things set straight.
|
* It calls the printTable above with all the things set straight.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
printQuery(PGresult *result, const printQueryOpt * opt, FILE *fout);
|
printQuery(const PGresult *result, const printQueryOpt * opt, FILE *fout);
|
||||||
|
|
||||||
|
|
||||||
#endif /* PRINT_H */
|
#endif /* PRINT_H */
|
||||||
|
@ -37,10 +37,10 @@
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
process_psqlrc(PsqlSettings *pset);
|
process_psqlrc(PsqlSettings *pset);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
showVersion(PsqlSettings *pset, bool verbose);
|
showVersion(PsqlSettings *pset);
|
||||||
|
|
||||||
|
|
||||||
/* Structures to pass information between the option parsing routine
|
/* Structures to pass information between the option parsing routine
|
||||||
@ -68,7 +68,7 @@ struct adhoc_opts
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void
|
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(username);
|
||||||
free(password);
|
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));
|
fprintf(stderr, "Connection to database '%s' failed.\n%s\n", PQdb(settings.db), PQerrorMessage(settings.db));
|
||||||
PQfinish(settings.db);
|
PQfinish(settings.db);
|
||||||
@ -169,7 +169,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
if (options.action == ACT_SHOW_VER)
|
if (options.action == ACT_SHOW_VER)
|
||||||
{
|
{
|
||||||
showVersion(&settings, true);
|
showVersion(&settings);
|
||||||
PQfinish(settings.db);
|
PQfinish(settings.db);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
@ -177,11 +177,8 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
if (!GetVariable(settings.vars, "quiet") && !settings.notty && !options.action)
|
if (!GetVariable(settings.vars, "quiet") && !settings.notty && !options.action)
|
||||||
{
|
{
|
||||||
puts("Welcome to psql, the PostgreSQL interactive terminal.\n");
|
puts("Welcome to psql, the PostgreSQL interactive terminal.\n\n"
|
||||||
|
"Type: \\copyright for distribution terms\n"
|
||||||
//showVersion(&settings, false);
|
|
||||||
|
|
||||||
puts("Type: \\copyright for distribution terms\n"
|
|
||||||
" \\h for help with SQL commands\n"
|
" \\h for help with SQL commands\n"
|
||||||
" \\? for help on internal slash commands\n"
|
" \\? for help on internal slash commands\n"
|
||||||
" \\g or terminate with semicolon to execute query\n"
|
" \\g or terminate with semicolon to execute query\n"
|
||||||
@ -509,28 +506,22 @@ process_psqlrc(PsqlSettings *pset)
|
|||||||
* or a mismatch was detected.
|
* or a mismatch was detected.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
showVersion(PsqlSettings *pset, bool verbose)
|
showVersion(PsqlSettings *pset)
|
||||||
{
|
{
|
||||||
PGresult *res;
|
PGresult *res = NULL;
|
||||||
char *versionstr = NULL;
|
const char *versionstr = NULL;
|
||||||
long int release = 0,
|
long int release = 0,
|
||||||
version = 0,
|
version = 0,
|
||||||
subversion = 0;
|
subversion = 0;
|
||||||
|
|
||||||
/* get backend version */
|
/* get backend version */
|
||||||
|
if (pset->db && PQstatus(pset->db) == CONNECTION_OK) {
|
||||||
res = PSQLexec(pset, "SELECT version()");
|
res = PSQLexec(pset, "SELECT version()");
|
||||||
if (PQresultStatus(res) == PGRES_TUPLES_OK)
|
if (PQresultStatus(res) == PGRES_TUPLES_OK)
|
||||||
versionstr = PQgetvalue(res, 0, 0);
|
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;
|
char *tmp;
|
||||||
|
|
||||||
@ -539,9 +530,9 @@ showVersion(PsqlSettings *pset, bool verbose)
|
|||||||
subversion = strtol(tmp + 1, &tmp, 10);
|
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(&PG_VERSION_STR[strcspn(PG_VERSION_STR, " ")]);
|
||||||
printf(" (" __DATE__ " " __TIME__ ")");
|
printf(" (" __DATE__ " " __TIME__ ")");
|
||||||
|
|
||||||
@ -569,10 +560,11 @@ showVersion(PsqlSettings *pset, bool verbose)
|
|||||||
|
|
||||||
puts("");
|
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"
|
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"
|
"version. You should ideally be using clients and servers from the same\n"
|
||||||
"distribution.");
|
"distribution.");
|
||||||
|
|
||||||
|
if (res)
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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"
|
"PGGEQO", "geqo"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
NULL
|
NULL, NULL
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1453,56 +1453,56 @@ conninfo_free()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* =========== accessor functions for PGconn ========= */
|
/* =========== accessor functions for PGconn ========= */
|
||||||
char *
|
const char *
|
||||||
PQdb(PGconn *conn)
|
PQdb(const PGconn *conn)
|
||||||
{
|
{
|
||||||
if (!conn)
|
if (!conn)
|
||||||
return (char *) NULL;
|
return (char *) NULL;
|
||||||
return conn->dbName;
|
return conn->dbName;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
PQuser(PGconn *conn)
|
PQuser(const PGconn *conn)
|
||||||
{
|
{
|
||||||
if (!conn)
|
if (!conn)
|
||||||
return (char *) NULL;
|
return (char *) NULL;
|
||||||
return conn->pguser;
|
return conn->pguser;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
PQpass(PGconn *conn)
|
PQpass(const PGconn *conn)
|
||||||
{
|
{
|
||||||
if (!conn)
|
if (!conn)
|
||||||
return (char *) NULL;
|
return (char *) NULL;
|
||||||
return conn->pgpass;
|
return conn->pgpass;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
PQhost(PGconn *conn)
|
PQhost(const PGconn *conn)
|
||||||
{
|
{
|
||||||
if (!conn)
|
if (!conn)
|
||||||
return (char *) NULL;
|
return (char *) NULL;
|
||||||
return conn->pghost;
|
return conn->pghost;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
PQport(PGconn *conn)
|
PQport(const PGconn *conn)
|
||||||
{
|
{
|
||||||
if (!conn)
|
if (!conn)
|
||||||
return (char *) NULL;
|
return (char *) NULL;
|
||||||
return conn->pgport;
|
return conn->pgport;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
PQtty(PGconn *conn)
|
PQtty(const PGconn *conn)
|
||||||
{
|
{
|
||||||
if (!conn)
|
if (!conn)
|
||||||
return (char *) NULL;
|
return (char *) NULL;
|
||||||
return conn->pgtty;
|
return conn->pgtty;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
PQoptions(PGconn *conn)
|
PQoptions(const PGconn *conn)
|
||||||
{
|
{
|
||||||
if (!conn)
|
if (!conn)
|
||||||
return (char *) NULL;
|
return (char *) NULL;
|
||||||
@ -1510,15 +1510,15 @@ PQoptions(PGconn *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConnStatusType
|
ConnStatusType
|
||||||
PQstatus(PGconn *conn)
|
PQstatus(const PGconn *conn)
|
||||||
{
|
{
|
||||||
if (!conn)
|
if (!conn)
|
||||||
return CONNECTION_BAD;
|
return CONNECTION_BAD;
|
||||||
return conn->status;
|
return conn->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
PQerrorMessage(PGconn *conn)
|
PQerrorMessage(const PGconn *conn)
|
||||||
{
|
{
|
||||||
static char noConn[] = "PQerrorMessage: conn pointer is NULL\n";
|
static char noConn[] = "PQerrorMessage: conn pointer is NULL\n";
|
||||||
|
|
||||||
@ -1528,7 +1528,7 @@ PQerrorMessage(PGconn *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PQsocket(PGconn *conn)
|
PQsocket(const PGconn *conn)
|
||||||
{
|
{
|
||||||
if (!conn)
|
if (!conn)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1536,7 +1536,7 @@ PQsocket(PGconn *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PQbackendPID(PGconn *conn)
|
PQbackendPID(const PGconn *conn)
|
||||||
{
|
{
|
||||||
if (!conn || conn->status != CONNECTION_OK)
|
if (!conn || conn->status != CONNECTION_OK)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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.
|
* be allocated on any byte boundary.
|
||||||
*/
|
*/
|
||||||
void *
|
void *
|
||||||
pqResultAlloc(PGresult *res, int nBytes, int isBinary)
|
pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary)
|
||||||
{
|
{
|
||||||
char *space;
|
char *space;
|
||||||
PGresult_data *block;
|
PGresult_data *block;
|
||||||
@ -882,7 +882,7 @@ getAnotherTuple(PGconn *conn, int binary)
|
|||||||
char std_bitmap[64]; /* used unless it doesn't fit */
|
char std_bitmap[64]; /* used unless it doesn't fit */
|
||||||
char *bitmap = std_bitmap;
|
char *bitmap = std_bitmap;
|
||||||
int i;
|
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 */
|
char bmap; /* One byte of the bitmap */
|
||||||
int bitmap_index; /* Its index */
|
int bitmap_index; /* Its index */
|
||||||
int bitcnt; /* number of bits examined in current byte */
|
int bitcnt; /* number of bits examined in current byte */
|
||||||
@ -1495,7 +1495,7 @@ PQfn(PGconn *conn,
|
|||||||
int *result_buf,
|
int *result_buf,
|
||||||
int *actual_result_len,
|
int *actual_result_len,
|
||||||
int result_is_int,
|
int result_is_int,
|
||||||
PQArgBlock *args,
|
const PQArgBlock *args,
|
||||||
int nargs)
|
int nargs)
|
||||||
{
|
{
|
||||||
bool needInput = false;
|
bool needInput = false;
|
||||||
@ -1674,7 +1674,7 @@ PQfn(PGconn *conn,
|
|||||||
/* ====== accessor funcs for PGresult ======== */
|
/* ====== accessor funcs for PGresult ======== */
|
||||||
|
|
||||||
ExecStatusType
|
ExecStatusType
|
||||||
PQresultStatus(PGresult *res)
|
PQresultStatus(const PGresult *res)
|
||||||
{
|
{
|
||||||
if (!res)
|
if (!res)
|
||||||
return PGRES_NONFATAL_ERROR;
|
return PGRES_NONFATAL_ERROR;
|
||||||
@ -1684,14 +1684,13 @@ PQresultStatus(PGresult *res)
|
|||||||
const char *
|
const char *
|
||||||
PQresStatus(ExecStatusType status)
|
PQresStatus(ExecStatusType status)
|
||||||
{
|
{
|
||||||
if (((int) status) < 0 ||
|
if ((int)status < 0 || (size_t)status >= sizeof pgresStatus / sizeof pgresStatus[0])
|
||||||
((int) status) >= (sizeof(pgresStatus) / sizeof(pgresStatus[0])))
|
|
||||||
return "Invalid ExecStatusType code";
|
return "Invalid ExecStatusType code";
|
||||||
return pgresStatus[status];
|
return pgresStatus[status];
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
PQresultErrorMessage(PGresult *res)
|
PQresultErrorMessage(const PGresult *res)
|
||||||
{
|
{
|
||||||
if (!res || !res->errMsg)
|
if (!res || !res->errMsg)
|
||||||
return "";
|
return "";
|
||||||
@ -1699,7 +1698,7 @@ PQresultErrorMessage(PGresult *res)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PQntuples(PGresult *res)
|
PQntuples(const PGresult *res)
|
||||||
{
|
{
|
||||||
if (!res)
|
if (!res)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1707,7 +1706,7 @@ PQntuples(PGresult *res)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PQnfields(PGresult *res)
|
PQnfields(const PGresult *res)
|
||||||
{
|
{
|
||||||
if (!res)
|
if (!res)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1715,7 +1714,7 @@ PQnfields(PGresult *res)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PQbinaryTuples(PGresult *res)
|
PQbinaryTuples(const PGresult *res)
|
||||||
{
|
{
|
||||||
if (!res)
|
if (!res)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1728,7 +1727,7 @@ PQbinaryTuples(PGresult *res)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
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];
|
char noticeBuf[128];
|
||||||
|
|
||||||
@ -1749,7 +1748,7 @@ check_field_number(const char *routineName, PGresult *res, int field_num)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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)
|
int tup_num, int field_num)
|
||||||
{
|
{
|
||||||
char noticeBuf[128];
|
char noticeBuf[128];
|
||||||
@ -1784,8 +1783,8 @@ check_tuple_field_number(const char *routineName, PGresult *res,
|
|||||||
/*
|
/*
|
||||||
returns NULL if the field_num is invalid
|
returns NULL if the field_num is invalid
|
||||||
*/
|
*/
|
||||||
char *
|
const char *
|
||||||
PQfname(PGresult *res, int field_num)
|
PQfname(const PGresult *res, int field_num)
|
||||||
{
|
{
|
||||||
if (!check_field_number("PQfname", res, field_num))
|
if (!check_field_number("PQfname", res, field_num))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1799,7 +1798,7 @@ PQfname(PGresult *res, int field_num)
|
|||||||
returns -1 on a bad field name
|
returns -1 on a bad field name
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
PQfnumber(PGresult *res, const char *field_name)
|
PQfnumber(const PGresult *res, const char *field_name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *field_case;
|
char *field_case;
|
||||||
@ -1837,7 +1836,7 @@ PQfnumber(PGresult *res, const char *field_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Oid
|
Oid
|
||||||
PQftype(PGresult *res, int field_num)
|
PQftype(const PGresult *res, int field_num)
|
||||||
{
|
{
|
||||||
if (!check_field_number("PQftype", res, field_num))
|
if (!check_field_number("PQftype", res, field_num))
|
||||||
return InvalidOid;
|
return InvalidOid;
|
||||||
@ -1848,7 +1847,7 @@ PQftype(PGresult *res, int field_num)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PQfsize(PGresult *res, int field_num)
|
PQfsize(const PGresult *res, int field_num)
|
||||||
{
|
{
|
||||||
if (!check_field_number("PQfsize", res, field_num))
|
if (!check_field_number("PQfsize", res, field_num))
|
||||||
return 0;
|
return 0;
|
||||||
@ -1859,7 +1858,7 @@ PQfsize(PGresult *res, int field_num)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PQfmod(PGresult *res, int field_num)
|
PQfmod(const PGresult *res, int field_num)
|
||||||
{
|
{
|
||||||
if (!check_field_number("PQfmod", res, field_num))
|
if (!check_field_number("PQfmod", res, field_num))
|
||||||
return 0;
|
return 0;
|
||||||
@ -1869,8 +1868,8 @@ PQfmod(PGresult *res, int field_num)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
PQcmdStatus(PGresult *res)
|
PQcmdStatus(const PGresult *res)
|
||||||
{
|
{
|
||||||
if (!res)
|
if (!res)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1883,47 +1882,49 @@ PQcmdStatus(PGresult *res)
|
|||||||
if not, return ""
|
if not, return ""
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
PQoidStatus(PGresult *res)
|
PQoidStatus(const PGresult *res)
|
||||||
{
|
{
|
||||||
char *p,
|
/*
|
||||||
*e,
|
* This must be enough to hold the result. Don't laugh, this is
|
||||||
*scan;
|
* better than what this function used to do.
|
||||||
int slen,
|
|
||||||
olen;
|
|
||||||
|
|
||||||
if (!res)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
if (strncmp(res->cmdStatus, "INSERT ", 7) != 0)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
/*----------
|
|
||||||
* 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.
|
|
||||||
*----------
|
|
||||||
*/
|
*/
|
||||||
|
static char buf[24];
|
||||||
|
|
||||||
slen = strlen(res->cmdStatus);
|
size_t len;
|
||||||
p = res->cmdStatus + 7; /* where oid is now */
|
|
||||||
e = res->cmdStatus + slen + 1; /* where to put the oid string */
|
|
||||||
|
|
||||||
for (scan = p; *scan && *scan != ' ';)
|
if (!res || !res->cmdStatus || strncmp(res->cmdStatus, "INSERT ", 7) != 0)
|
||||||
scan++;
|
return "";
|
||||||
olen = scan - p;
|
|
||||||
if (slen + olen + 2 > sizeof(res->cmdStatus))
|
|
||||||
return ""; /* something very wrong if it doesn't fit */
|
|
||||||
|
|
||||||
strncpy(e, p, olen);
|
len = strspn(res->cmdStatus + 7, "0123456789");
|
||||||
e[olen] = '\0';
|
if (len > 23)
|
||||||
|
len = 23;
|
||||||
|
strncpy(buf, res->cmdStatus + 7, len);
|
||||||
|
buf[23] = '\0';
|
||||||
|
|
||||||
return e;
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (!res || !res->cmdStatus || strncmp(res->cmdStatus, "INSERT ", 7) != 0)
|
||||||
|
return InvalidOid;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
result = strtoul(res->cmdStatus + 7, &endptr, 10);
|
||||||
|
|
||||||
|
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 ""
|
of inserted/affected tuples, if not, return ""
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
PQcmdTuples(PGresult *res)
|
PQcmdTuples(const PGresult *res)
|
||||||
{
|
{
|
||||||
char noticeBuf[128];
|
char noticeBuf[128];
|
||||||
|
|
||||||
@ -1943,7 +1944,7 @@ PQcmdTuples(PGresult *res)
|
|||||||
strncmp(res->cmdStatus, "DELETE", 6) == 0 ||
|
strncmp(res->cmdStatus, "DELETE", 6) == 0 ||
|
||||||
strncmp(res->cmdStatus, "UPDATE", 6) == 0)
|
strncmp(res->cmdStatus, "UPDATE", 6) == 0)
|
||||||
{
|
{
|
||||||
char *p = res->cmdStatus + 6;
|
const char *p = res->cmdStatus + 6;
|
||||||
|
|
||||||
if (*p == 0)
|
if (*p == 0)
|
||||||
{
|
{
|
||||||
@ -1987,8 +1988,8 @@ PQcmdTuples(PGresult *res)
|
|||||||
|
|
||||||
if res is not binary, a null-terminated ASCII string is returned.
|
if res is not binary, a null-terminated ASCII string is returned.
|
||||||
*/
|
*/
|
||||||
char *
|
const char *
|
||||||
PQgetvalue(PGresult *res, int tup_num, int field_num)
|
PQgetvalue(const PGresult *res, int tup_num, int field_num)
|
||||||
{
|
{
|
||||||
if (!check_tuple_field_number("PQgetvalue", res, tup_num, field_num))
|
if (!check_tuple_field_number("PQgetvalue", res, tup_num, field_num))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2002,7 +2003,7 @@ PQgetvalue(PGresult *res, int tup_num, int field_num)
|
|||||||
by PQgetvalue doesn't either.)
|
by PQgetvalue doesn't either.)
|
||||||
*/
|
*/
|
||||||
int
|
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))
|
if (!check_tuple_field_number("PQgetlength", res, tup_num, field_num))
|
||||||
return 0;
|
return 0;
|
||||||
@ -2016,7 +2017,7 @@ PQgetlength(PGresult *res, int tup_num, int field_num)
|
|||||||
returns the null status of a field value.
|
returns the null status of a field value.
|
||||||
*/
|
*/
|
||||||
int
|
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))
|
if (!check_tuple_field_number("PQgetisnull", res, tup_num, field_num))
|
||||||
return 1; /* pretend it is null */
|
return 1; /* pretend it is null */
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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
|
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];
|
PQArgBlock argv[2];
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
@ -167,7 +167,7 @@ lo_read(PGconn *conn, int fd, char *buf, int len)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
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];
|
PQArgBlock argv[2];
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
@ -378,7 +378,7 @@ lo_unlink(PGconn *conn, Oid lobjId)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Oid
|
Oid
|
||||||
lo_import(PGconn *conn, char *filename)
|
lo_import(PGconn *conn, const char *filename)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int nbytes,
|
int nbytes,
|
||||||
@ -451,7 +451,7 @@ lo_import(PGconn *conn, char *filename)
|
|||||||
* returns -1 upon failure, 1 otherwise
|
* returns -1 upon failure, 1 otherwise
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
lo_export(PGconn *conn, Oid lobjId, char *filename)
|
lo_export(PGconn *conn, Oid lobjId, const char *filename)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int nbytes,
|
int nbytes,
|
||||||
@ -522,7 +522,7 @@ lo_initialize(PGconn *conn)
|
|||||||
PGresult *res;
|
PGresult *res;
|
||||||
PGlobjfuncs *lobjfuncs;
|
PGlobjfuncs *lobjfuncs;
|
||||||
int n;
|
int n;
|
||||||
char *fname;
|
const char *fname;
|
||||||
Oid foid;
|
Oid foid;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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
|
with buffering
|
||||||
*/
|
*/
|
||||||
static int
|
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)
|
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
|
get a string of exactly len bytes in buffer s, no null termination
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
pqGetnchar(char *s, int len, PGconn *conn)
|
pqGetnchar(char *s, size_t len, PGconn *conn)
|
||||||
{
|
{
|
||||||
if (len < 0 || len > conn->inEnd - conn->inCursor)
|
if (len < 0 || len > conn->inEnd - conn->inCursor)
|
||||||
return EOF;
|
return EOF;
|
||||||
@ -168,7 +168,7 @@ pqGetnchar(char *s, int len, PGconn *conn)
|
|||||||
conn->inCursor += len;
|
conn->inCursor += len;
|
||||||
|
|
||||||
if (conn->Pfdebug)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -178,13 +178,13 @@ pqGetnchar(char *s, int len, PGconn *conn)
|
|||||||
send a string of exactly len bytes, no null termination needed
|
send a string of exactly len bytes, no null termination needed
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
pqPutnchar(const char *s, int len, PGconn *conn)
|
pqPutnchar(const char *s, size_t len, PGconn *conn)
|
||||||
{
|
{
|
||||||
if (pqPutBytes(s, len, conn))
|
if (pqPutBytes(s, len, conn))
|
||||||
return EOF;
|
return EOF;
|
||||||
|
|
||||||
if (conn->Pfdebug)
|
if (conn->Pfdebug)
|
||||||
fprintf(conn->Pfdebug, "To backend> %.*s\n", len, s);
|
fprintf(conn->Pfdebug, "To backend> %.*s\n", (int)len, s);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -195,7 +195,7 @@ pqPutnchar(const char *s, int len, PGconn *conn)
|
|||||||
to local byte order
|
to local byte order
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
pqGetInt(int *result, int bytes, PGconn *conn)
|
pqGetInt(int *result, size_t bytes, PGconn *conn)
|
||||||
{
|
{
|
||||||
uint16 tmp2;
|
uint16 tmp2;
|
||||||
uint32 tmp4;
|
uint32 tmp4;
|
||||||
@ -236,7 +236,7 @@ pqGetInt(int *result, int bytes, PGconn *conn)
|
|||||||
to network byte order.
|
to network byte order.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
pqPutInt(int value, int bytes, PGconn *conn)
|
pqPutInt(int value, size_t bytes, PGconn *conn)
|
||||||
{
|
{
|
||||||
uint16 tmp2;
|
uint16 tmp2;
|
||||||
uint32 tmp4;
|
uint32 tmp4;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* didn't really belong there.
|
* didn't really belong there.
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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
|
#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,
|
const int i, const int j, const int fs_len,
|
||||||
char **fields,
|
char **fields,
|
||||||
const int nFields, char **fieldNames,
|
const int nFields, const char **fieldNames,
|
||||||
unsigned char *fieldNotNum, int *fieldMax,
|
unsigned char *fieldNotNum, int *fieldMax,
|
||||||
const int fieldMaxLen, FILE *fout);
|
const int fieldMaxLen, FILE *fout);
|
||||||
static char *do_header(FILE *fout, PQprintOpt *po, const int nFields,
|
static char *do_header(FILE *fout, const PQprintOpt *po, const int nFields,
|
||||||
int *fieldMax, char **fieldNames, unsigned char *fieldNotNum,
|
int *fieldMax, const char **fieldNames, unsigned char *fieldNotNum,
|
||||||
const int fs_len, PGresult *res);
|
const int fs_len, const PGresult *res);
|
||||||
static void output_row(FILE *fout, PQprintOpt *po, const int nFields, char **fields,
|
static void output_row(FILE *fout, const PQprintOpt *po, const int nFields, char **fields,
|
||||||
unsigned char *fieldNotNum, int *fieldMax, char *border,
|
unsigned char *fieldNotNum, int *fieldMax, char *border,
|
||||||
const int row_index);
|
const int row_index);
|
||||||
static void fill(int length, int max, char filler, FILE *fp);
|
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
|
void
|
||||||
PQprint(FILE *fout,
|
PQprint(FILE *fout,
|
||||||
PGresult *res,
|
const PGresult *res,
|
||||||
PQprintOpt *po)
|
const PQprintOpt *po)
|
||||||
{
|
{
|
||||||
int nFields;
|
int nFields;
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ PQprint(FILE *fout,
|
|||||||
unsigned char *fieldNotNum = NULL;
|
unsigned char *fieldNotNum = NULL;
|
||||||
char *border = NULL;
|
char *border = NULL;
|
||||||
char **fields = NULL;
|
char **fields = NULL;
|
||||||
char **fieldNames;
|
const char **fieldNames;
|
||||||
int fieldMaxLen = 0;
|
int fieldMaxLen = 0;
|
||||||
int numFieldName;
|
int numFieldName;
|
||||||
int fs_len = strlen(po->fieldSep);
|
int fs_len = strlen(po->fieldSep);
|
||||||
@ -105,7 +105,7 @@ PQprint(FILE *fout,
|
|||||||
char *pagerenv;
|
char *pagerenv;
|
||||||
|
|
||||||
nTups = PQntuples(res);
|
nTups = PQntuples(res);
|
||||||
if (!(fieldNames = (char **) calloc(nFields, sizeof(char *))))
|
if (!(fieldNames = (const char **) calloc(nFields, sizeof(char *))))
|
||||||
{
|
{
|
||||||
perror("calloc");
|
perror("calloc");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -127,7 +127,7 @@ PQprint(FILE *fout,
|
|||||||
for (j = 0; j < nFields; j++)
|
for (j = 0; j < nFields; j++)
|
||||||
{
|
{
|
||||||
int len;
|
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);
|
po->fieldName[j] : PQfname(res, j);
|
||||||
|
|
||||||
fieldNames[j] = s;
|
fieldNames[j] = s;
|
||||||
@ -218,7 +218,7 @@ PQprint(FILE *fout,
|
|||||||
|
|
||||||
for (j = 0; j < nFields; j++)
|
for (j = 0; j < nFields; j++)
|
||||||
{
|
{
|
||||||
char *s = fieldNames[j];
|
const char *s = fieldNames[j];
|
||||||
|
|
||||||
fputs(s, fout);
|
fputs(s, fout);
|
||||||
len += strlen(s) + fs_len;
|
len += strlen(s) + fs_len;
|
||||||
@ -317,7 +317,7 @@ PQprint(FILE *fout,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
PQdisplayTuples(PGresult *res,
|
PQdisplayTuples(const PGresult *res,
|
||||||
FILE *fp, /* where to send the output */
|
FILE *fp, /* where to send the output */
|
||||||
int fillAlign, /* pad the fields with spaces */
|
int fillAlign, /* pad the fields with spaces */
|
||||||
const char *fieldSep, /* field separator */
|
const char *fieldSep, /* field separator */
|
||||||
@ -414,7 +414,7 @@ PQdisplayTuples(PGresult *res,
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
PQprintTuples(PGresult *res,
|
PQprintTuples(const PGresult *res,
|
||||||
FILE *fout, /* output stream */
|
FILE *fout, /* output stream */
|
||||||
int PrintAttNames,/* print attribute names or not */
|
int PrintAttNames,/* print attribute names or not */
|
||||||
int TerseOutput, /* delimiter bars or not? */
|
int TerseOutput, /* delimiter bars or not? */
|
||||||
@ -475,7 +475,7 @@ PQprintTuples(PGresult *res,
|
|||||||
{
|
{
|
||||||
for (j = 0; j < nFields; j++)
|
for (j = 0; j < nFields; j++)
|
||||||
{
|
{
|
||||||
char *pval = PQgetvalue(res, i, j);
|
const char *pval = PQgetvalue(res, i, j);
|
||||||
|
|
||||||
fprintf(fout, formatString,
|
fprintf(fout, formatString,
|
||||||
TerseOutput ? "" : "|",
|
TerseOutput ? "" : "|",
|
||||||
@ -498,7 +498,7 @@ PQprintTuples(PGresult *res,
|
|||||||
* the backend is assumed.
|
* the backend is assumed.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
PQmblen(unsigned char *s)
|
PQmblen(const unsigned char *s)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
int encoding = -1;
|
int encoding = -1;
|
||||||
@ -515,7 +515,7 @@ PQmblen(unsigned char *s)
|
|||||||
|
|
||||||
/* Provide a default definition in case someone calls it anyway */
|
/* Provide a default definition in case someone calls it anyway */
|
||||||
int
|
int
|
||||||
PQmblen(unsigned char *s)
|
PQmblen(const unsigned char *s)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -523,15 +523,15 @@ PQmblen(unsigned char *s)
|
|||||||
#endif /* MULTIBYTE */
|
#endif /* MULTIBYTE */
|
||||||
|
|
||||||
static void
|
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,
|
const int i, const int j, const int fs_len,
|
||||||
char **fields,
|
char **fields,
|
||||||
const int nFields, char **fieldNames,
|
const int nFields, char const **fieldNames,
|
||||||
unsigned char *fieldNotNum, int *fieldMax,
|
unsigned char *fieldNotNum, int *fieldMax,
|
||||||
const int fieldMaxLen, FILE *fout)
|
const int fieldMaxLen, FILE *fout)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *pval,
|
const char *pval,
|
||||||
*p;
|
*p;
|
||||||
int plen;
|
int plen;
|
||||||
bool skipit;
|
bool skipit;
|
||||||
@ -641,9 +641,9 @@ do_field(PQprintOpt *po, PGresult *res,
|
|||||||
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
do_header(FILE *fout, PQprintOpt *po, const int nFields, int *fieldMax,
|
do_header(FILE *fout, const PQprintOpt *po, const int nFields, int *fieldMax,
|
||||||
char **fieldNames, unsigned char *fieldNotNum,
|
const char **fieldNames, unsigned char *fieldNotNum,
|
||||||
const int fs_len, PGresult *res)
|
const int fs_len, const PGresult *res)
|
||||||
{
|
{
|
||||||
|
|
||||||
int j; /* for loop index */
|
int j; /* for loop index */
|
||||||
@ -697,7 +697,7 @@ do_header(FILE *fout, PQprintOpt *po, const int nFields, int *fieldMax,
|
|||||||
fputs(po->fieldSep, fout);
|
fputs(po->fieldSep, fout);
|
||||||
for (j = 0; j < nFields; j++)
|
for (j = 0; j < nFields; j++)
|
||||||
{
|
{
|
||||||
char *s = PQfname(res, j);
|
const char *s = PQfname(res, j);
|
||||||
|
|
||||||
if (po->html3)
|
if (po->html3)
|
||||||
{
|
{
|
||||||
@ -729,7 +729,7 @@ do_header(FILE *fout, PQprintOpt *po, const int nFields, int *fieldMax,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
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,
|
unsigned char *fieldNotNum, int *fieldMax, char *border,
|
||||||
const int row_index)
|
const int row_index)
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* 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);
|
extern int PQrequestCancel(PGconn *conn);
|
||||||
|
|
||||||
/* Accessor functions for PGconn objects */
|
/* Accessor functions for PGconn objects */
|
||||||
extern char *PQdb(PGconn *conn);
|
extern const char *PQdb(const PGconn *conn);
|
||||||
extern char *PQuser(PGconn *conn);
|
extern const char *PQuser(const PGconn *conn);
|
||||||
extern char *PQpass(PGconn *conn);
|
extern const char *PQpass(const PGconn *conn);
|
||||||
extern char *PQhost(PGconn *conn);
|
extern const char *PQhost(const PGconn *conn);
|
||||||
extern char *PQport(PGconn *conn);
|
extern const char *PQport(const PGconn *conn);
|
||||||
extern char *PQtty(PGconn *conn);
|
extern const char *PQtty(const PGconn *conn);
|
||||||
extern char *PQoptions(PGconn *conn);
|
extern const char *PQoptions(const PGconn *conn);
|
||||||
extern ConnStatusType PQstatus(PGconn *conn);
|
extern ConnStatusType PQstatus(const PGconn *conn);
|
||||||
extern char *PQerrorMessage(PGconn *conn);
|
extern const char *PQerrorMessage(const PGconn *conn);
|
||||||
extern int PQsocket(PGconn *conn);
|
extern int PQsocket(const PGconn *conn);
|
||||||
extern int PQbackendPID(PGconn *conn);
|
extern int PQbackendPID(const PGconn *conn);
|
||||||
|
|
||||||
/* Enable/disable tracing */
|
/* Enable/disable tracing */
|
||||||
extern void PQtrace(PGconn *conn, FILE *debug_port);
|
extern void PQtrace(PGconn *conn, FILE *debug_port);
|
||||||
@ -225,27 +225,28 @@ extern "C"
|
|||||||
int *result_buf,
|
int *result_buf,
|
||||||
int *result_len,
|
int *result_len,
|
||||||
int result_is_int,
|
int result_is_int,
|
||||||
PQArgBlock *args,
|
const PQArgBlock *args,
|
||||||
int nargs);
|
int nargs);
|
||||||
|
|
||||||
/* Accessor functions for PGresult objects */
|
/* 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 *PQresStatus(ExecStatusType status);
|
||||||
extern const char *PQresultErrorMessage(PGresult *res);
|
extern const char *PQresultErrorMessage(const PGresult *res);
|
||||||
extern int PQntuples(PGresult *res);
|
extern int PQntuples(const PGresult *res);
|
||||||
extern int PQnfields(PGresult *res);
|
extern int PQnfields(const PGresult *res);
|
||||||
extern int PQbinaryTuples(PGresult *res);
|
extern int PQbinaryTuples(const PGresult *res);
|
||||||
extern char *PQfname(PGresult *res, int field_num);
|
extern const char *PQfname(const PGresult *res, int field_num);
|
||||||
extern int PQfnumber(PGresult *res, const char *field_name);
|
extern int PQfnumber(const PGresult *res, const char *field_name);
|
||||||
extern Oid PQftype(PGresult *res, int field_num);
|
extern Oid PQftype(const PGresult *res, int field_num);
|
||||||
extern int PQfsize(PGresult *res, int field_num);
|
extern int PQfsize(const PGresult *res, int field_num);
|
||||||
extern int PQfmod(PGresult *res, int field_num);
|
extern int PQfmod(const PGresult *res, int field_num);
|
||||||
extern char *PQcmdStatus(PGresult *res);
|
extern const char *PQcmdStatus(const PGresult *res);
|
||||||
extern const char *PQoidStatus(PGresult *res);
|
extern const char *PQoidStatus(const PGresult *res); /* old and ugly */
|
||||||
extern const char *PQcmdTuples(PGresult *res);
|
extern Oid PQoidValue(const PGresult *res); /* new and improved */
|
||||||
extern char *PQgetvalue(PGresult *res, int tup_num, int field_num);
|
extern const char *PQcmdTuples(const PGresult *res);
|
||||||
extern int PQgetlength(PGresult *res, int tup_num, int field_num);
|
extern const char *PQgetvalue(const PGresult *res, int tup_num, int field_num);
|
||||||
extern int PQgetisnull(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 */
|
/* Delete a PGresult */
|
||||||
extern void PQclear(PGresult *res);
|
extern void PQclear(PGresult *res);
|
||||||
@ -260,14 +261,14 @@ extern "C"
|
|||||||
/* === in fe-print.c === */
|
/* === in fe-print.c === */
|
||||||
|
|
||||||
extern void PQprint(FILE *fout, /* output stream */
|
extern void PQprint(FILE *fout, /* output stream */
|
||||||
PGresult *res,
|
const PGresult *res,
|
||||||
PQprintOpt *ps); /* option structure */
|
const PQprintOpt *ps); /* option structure */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PQdisplayTuples() is a better version of PQprintTuples(), but both
|
* PQdisplayTuples() is a better version of PQprintTuples(), but both
|
||||||
* are obsoleted by PQprint().
|
* are obsoleted by PQprint().
|
||||||
*/
|
*/
|
||||||
extern void PQdisplayTuples(PGresult *res,
|
extern void PQdisplayTuples(const PGresult *res,
|
||||||
FILE *fp, /* where to send the
|
FILE *fp, /* where to send the
|
||||||
* output */
|
* output */
|
||||||
int fillAlign, /* pad the fields with
|
int fillAlign, /* pad the fields with
|
||||||
@ -276,7 +277,7 @@ extern "C"
|
|||||||
int printHeader, /* display headers? */
|
int printHeader, /* display headers? */
|
||||||
int quiet);
|
int quiet);
|
||||||
|
|
||||||
extern void PQprintTuples(PGresult *res,
|
extern void PQprintTuples(const PGresult *res,
|
||||||
FILE *fout, /* output stream */
|
FILE *fout, /* output stream */
|
||||||
int printAttName, /* print attribute names
|
int printAttName, /* print attribute names
|
||||||
* or not */
|
* or not */
|
||||||
@ -286,21 +287,21 @@ extern "C"
|
|||||||
* 0, use variable width */
|
* 0, use variable width */
|
||||||
|
|
||||||
/* Determine length of multibyte encoded char at *s */
|
/* 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 === */
|
/* === in fe-lobj.c === */
|
||||||
|
|
||||||
/* Large-object access routines */
|
/* Large-object access routines */
|
||||||
extern int lo_open(PGconn *conn, Oid lobjId, int mode);
|
extern int lo_open(PGconn *conn, Oid lobjId, int mode);
|
||||||
extern int lo_close(PGconn *conn, int fd);
|
extern int lo_close(PGconn *conn, int fd);
|
||||||
extern int lo_read(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, char *buf, int 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 int lo_lseek(PGconn *conn, int fd, int offset, int whence);
|
||||||
extern Oid lo_creat(PGconn *conn, int mode);
|
extern Oid lo_creat(PGconn *conn, int mode);
|
||||||
extern int lo_tell(PGconn *conn, int fd);
|
extern int lo_tell(PGconn *conn, int fd);
|
||||||
extern int lo_unlink(PGconn *conn, Oid lobjId);
|
extern int lo_unlink(PGconn *conn, Oid lobjId);
|
||||||
extern Oid lo_import(PGconn *conn, char *filename);
|
extern Oid lo_import(PGconn *conn, const char *filename);
|
||||||
extern int lo_export(PGconn *conn, Oid lobjId, char *filename);
|
extern int lo_export(PGconn *conn, Oid lobjId, const char *filename);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* 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 === */
|
/* === in fe-exec.c === */
|
||||||
|
|
||||||
extern void pqSetResultError(PGresult *res, const char *msg);
|
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 char *pqResultStrdup(PGresult *res, const char *str);
|
||||||
extern void pqClearAsyncResult(PGconn *conn);
|
extern void pqClearAsyncResult(PGconn *conn);
|
||||||
|
|
||||||
@ -261,10 +261,10 @@ extern void pqClearAsyncResult(PGconn *conn);
|
|||||||
extern int pqGetc(char *result, PGconn *conn);
|
extern int pqGetc(char *result, PGconn *conn);
|
||||||
extern int pqGets(PQExpBuffer buf, PGconn *conn);
|
extern int pqGets(PQExpBuffer buf, PGconn *conn);
|
||||||
extern int pqPuts(const char *s, PGconn *conn);
|
extern int pqPuts(const char *s, PGconn *conn);
|
||||||
extern int pqGetnchar(char *s, int len, PGconn *conn);
|
extern int pqGetnchar(char *s, size_t len, PGconn *conn);
|
||||||
extern int pqPutnchar(const char *s, int len, PGconn *conn);
|
extern int pqPutnchar(const char *s, size_t len, PGconn *conn);
|
||||||
extern int pqGetInt(int *result, int bytes, PGconn *conn);
|
extern int pqGetInt(int *result, size_t bytes, PGconn *conn);
|
||||||
extern int pqPutInt(int value, int bytes, PGconn *conn);
|
extern int pqPutInt(int value, size_t bytes, PGconn *conn);
|
||||||
extern int pqReadData(PGconn *conn);
|
extern int pqReadData(PGconn *conn);
|
||||||
extern int pqFlush(PGconn *conn);
|
extern int pqFlush(PGconn *conn);
|
||||||
extern int pqWait(int forRead, int forWrite, PGconn *conn);
|
extern int pqWait(int forRead, int forWrite, PGconn *conn);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user