Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3ca998b

Browse files
committed
Allow psql to use 7.4.X database by not referencing tablespaces.
Greg Sabino Mullan
1 parent ee85595 commit 3ca998b

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

src/bin/psql/describe.c

+13-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.103 2004/07/15 03:56:06 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.104 2004/08/20 20:18:23 momjian Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "describe.h"
@@ -112,6 +112,12 @@ describeTablespaces(const char *pattern, bool verbose)
112112
PGresult *res;
113113
printQueryOpt myopt = pset.popt;
114114

115+
if (pset.sversion < 70500) {
116+
fprintf(stderr, _("This server version (%d) does not support tablespaces.\n"),
117+
pset.sversion);
118+
return true;
119+
}
120+
115121
initPQExpBuffer(&buf);
116122

117123
printfPQExpBuffer(&buf,
@@ -706,8 +712,9 @@ describeOneTableDetails(const char *schemaname,
706712
/* Get general table info */
707713
printfPQExpBuffer(&buf,
708714
"SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, \n"
709-
"relhasoids, reltablespace \n"
715+
"relhasoids %s \n"
710716
"FROM pg_catalog.pg_class WHERE oid = '%s'",
717+
pset.sversion >= 70500 ? ", reltablespace" : "",
711718
oid);
712719
res = PSQLexec(buf.data, false);
713720
if (!res)
@@ -729,7 +736,8 @@ describeOneTableDetails(const char *schemaname,
729736
tableinfo.hasindex = strcmp(PQgetvalue(res, 0, 0), "t") == 0;
730737
tableinfo.hasrules = strcmp(PQgetvalue(res, 0, 4), "t") == 0;
731738
tableinfo.hasoids = strcmp(PQgetvalue(res, 0, 5), "t") == 0;
732-
tableinfo.tablespace = atooid(PQgetvalue(res, 0, 6));
739+
tableinfo.tablespace = (pset.sversion >= 70500) ?
740+
atooid(PQgetvalue(res, 0, 6)) : 0;
733741
PQclear(res);
734742

735743
headers[0] = _("Column");
@@ -932,8 +940,8 @@ describeOneTableDetails(const char *schemaname,
932940

933941
footers = pg_malloc_zero(4 * sizeof(*footers));
934942
footers[count_footers++] = pg_strdup(tmpbuf.data);
935-
add_tablespace_footer(tableinfo.relkind, tableinfo.tablespace,
936-
footers, &count_footers, tmpbuf);
943+
add_tablespace_footer(tableinfo.relkind, tableinfo.tablespace,
944+
footers, &count_footers, tmpbuf);
937945
footers[count_footers] = NULL;
938946

939947
}

src/bin/psql/settings.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.18 2004/05/12 13:38:45 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.19 2004/08/20 20:18:23 momjian Exp $
77
*/
88
#ifndef SETTINGS_H
99
#define SETTINGS_H
@@ -41,7 +41,7 @@ typedef struct _psqlSettings
4141
FILE *cur_cmd_source; /* describe the status of the current main
4242
* loop */
4343
bool cur_cmd_interactive;
44-
44+
int sversion; /* backend server version */
4545
const char *progname; /* in case you renamed psql */
4646
char *inputfile; /* for error reporting */
4747
unsigned lineno; /* also for error reporting */

src/bin/psql/startup.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.96 2004/08/18 02:59:11 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.97 2004/08/20 20:18:23 momjian Exp $
77
*/
88
#include "postgres_fe.h"
99

@@ -217,6 +217,9 @@ main(int argc, char *argv[])
217217

218218
SyncVariables();
219219

220+
/* Grab the backend server version */
221+
pset.sversion = PQserverVersion(pset.db);
222+
220223
if (options.action == ACT_LIST_DB)
221224
{
222225
int success = listAllDbs(false);

0 commit comments

Comments
 (0)