Re: Allow psql to work against non-tablespace servers (e.g. - Mailing list pgsql-patches
From | Bruce Momjian |
---|---|
Subject | Re: Allow psql to work against non-tablespace servers (e.g. |
Date | |
Msg-id | 200408172026.i7HKQ2i26322@candle.pha.pa.us Whole thread Raw |
In response to | Allow psql to work against non-tablespace servers (e.g. 7.4) ("Greg Sabino Mullane" <greg@turnstep.com>) |
Responses |
Re: Allow psql to work against non-tablespace servers (e.g.
Re: Allow psql to work against non-tablespace servers (e.g. |
List | pgsql-patches |
I don't see any other code in psql that allows it to run with older server versions so it doesn't make sense to me to fix things just for tablespaces, and doing it for everything seems like it would uglify the code too much. --------------------------------------------------------------------------- Greg Sabino Mullane wrote: > > 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); > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
pgsql-patches by date: