diff options
| author | Bruce Momjian <bruce@momjian.us> | 1999-11-11 00:10:14 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 1999-11-11 00:10:14 +0000 |
| commit | 2a24ec6f167a21ef074609e165d77f1f7c715259 (patch) | |
| tree | 579eb1fde3baf6cf0edd60d62e3c5bf7a60698cf /src/bin/psql/describe.c | |
| parent | c6c60302ba45ac89440ec7e2a4e1c5de3a1a61c2 (diff) | |
| download | postgresql-2a24ec6f167a21ef074609e165d77f1f7c715259.tar.gz | |
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
Diffstat (limited to 'src/bin/psql/describe.c')
| -rw-r--r-- | src/bin/psql/describe.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 58534e2575..5e40779cd1 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -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); |
