1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +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:
Bruce Momjian
1999-11-11 00:10:14 +00:00
parent c6c60302ba
commit 2a24ec6f16
12 changed files with 266 additions and 260 deletions

View File

@ -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;