Allow psql to work against non-tablespace servers (e.g. 7.4)

From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: Allow psql to work against non-tablespace servers (e.g. 7.4)
Date: 2004-08-12 01:22:39
Message-ID: a88a4b614b26489358503bb4a015f296@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


Index: describe.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/describe.c,v
retrieving revision 1.103
diff -c -r1.103 describe.c
*** describe.c 15 Jul 2004 03:56:06 -0000 1.103
--- describe.c 11 Aug 2004 21:15:34 -0000
***************
*** 112,117 ****
--- 112,123 ----
PGresult *res;
printQueryOpt myopt = pset.popt;

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

printfPQExpBuffer(&buf,
***************
*** 706,713 ****
/* Get general table info */
printfPQExpBuffer(&buf,
"SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, \n"
! "relhasoids, reltablespace \n"
"FROM pg_catalog.pg_class WHERE oid = `%s`",
oid);
res = PSQLexec(buf.data, false);
if (!res)
--- 712,720 ----
/* Get general table info */
printfPQExpBuffer(&buf,
"SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, \n"
! "relhasoids %s \n"
"FROM pg_catalog.pg_class WHERE oid = `%s`",
+ pset.sversion >= 70500 ? ", reltablespace" : "",
oid);
res = PSQLexec(buf.data, false);
if (!res)
***************
*** 729,735 ****
tableinfo.hasindex = strcmp(PQgetvalue(res, 0, 0), "t") == 0;
tableinfo.hasrules = strcmp(PQgetvalue(res, 0, 4), "t") == 0;
tableinfo.hasoids = strcmp(PQgetvalue(res, 0, 5), "t") == 0;
! tableinfo.tablespace = atooid(PQgetvalue(res, 0, 6));
PQclear(res);

headers[0] = _("Column");
--- 736,743 ----
tableinfo.hasindex = strcmp(PQgetvalue(res, 0, 0), "t") == 0;
tableinfo.hasrules = strcmp(PQgetvalue(res, 0, 4), "t") == 0;
tableinfo.hasoids = strcmp(PQgetvalue(res, 0, 5), "t") == 0;
! tableinfo.tablespace = (pset.sversion >= 70500) ?
! atooid(PQgetvalue(res, 0, 6)) : 0;
PQclear(res);

headers[0] = _("Column");
***************
*** 932,939 ****

footers = pg_malloc_zero(4 * sizeof(*footers));
footers[count_footers++] = pg_strdup(tmpbuf.data);
! add_tablespace_footer(tableinfo.relkind, tableinfo.tablespace,
! footers, &count_footers, tmpbuf);
footers[count_footers] = NULL;

}
--- 940,947 ----

footers = pg_malloc_zero(4 * sizeof(*footers));
footers[count_footers++] = pg_strdup(tmpbuf.data);
! add_tablespace_footer(tableinfo.relkind, tableinfo.tablespace,
! footers, &count_footers, tmpbuf);
footers[count_footers] = NULL;

}
Index: settings.h
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/settings.h,v
retrieving revision 1.18
diff -c -r1.18 settings.h
*** settings.h 12 May 2004 13:38:45 -0000 1.18
--- settings.h 11 Aug 2004 21:15:34 -0000
***************
*** 41,47 ****
FILE *cur_cmd_source; /* describe the status of the current main
* loop */
bool cur_cmd_interactive;
!
const char *progname; /* in case you renamed psql */
char *inputfile; /* for error reporting */
unsigned lineno; /* also for error reporting */
--- 41,47 ----
FILE *cur_cmd_source; /* describe the status of the current main
* loop */
bool cur_cmd_interactive;
! int sversion; /* backend server version */
const char *progname; /* in case you renamed psql */
char *inputfile; /* for error reporting */
unsigned lineno; /* also for error reporting */
Index: startup.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/startup.c,v
retrieving revision 1.95
diff -c -r1.95 startup.c
*** startup.c 3 Jun 2004 00:07:37 -0000 1.95
--- startup.c 11 Aug 2004 21:15:34 -0000
***************
*** 217,222 ****
--- 217,225 ----

SyncVariables();

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

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message efesar (the kay) 2004-08-12 01:39:45 8.0 Beta 1 // Environment Vars // .pgpass
Previous Message Philip Warner 2004-08-12 00:58:43 Re: pg_dump 'die_on_errors'