mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Allow psql to use 7.4.X database by not referencing tablespaces.
Greg Sabino Mullan
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.103 2004/07/15 03:56:06 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.104 2004/08/20 20:18:23 momjian Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
#include "describe.h"
|
#include "describe.h"
|
||||||
@ -112,6 +112,12 @@ describeTablespaces(const char *pattern, bool verbose)
|
|||||||
PGresult *res;
|
PGresult *res;
|
||||||
printQueryOpt myopt = pset.popt;
|
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);
|
initPQExpBuffer(&buf);
|
||||||
|
|
||||||
printfPQExpBuffer(&buf,
|
printfPQExpBuffer(&buf,
|
||||||
@ -706,8 +712,9 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
/* Get general table info */
|
/* Get general table info */
|
||||||
printfPQExpBuffer(&buf,
|
printfPQExpBuffer(&buf,
|
||||||
"SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, \n"
|
"SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, \n"
|
||||||
"relhasoids, reltablespace \n"
|
"relhasoids %s \n"
|
||||||
"FROM pg_catalog.pg_class WHERE oid = '%s'",
|
"FROM pg_catalog.pg_class WHERE oid = '%s'",
|
||||||
|
pset.sversion >= 70500 ? ", reltablespace" : "",
|
||||||
oid);
|
oid);
|
||||||
res = PSQLexec(buf.data, false);
|
res = PSQLexec(buf.data, false);
|
||||||
if (!res)
|
if (!res)
|
||||||
@ -729,7 +736,8 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
tableinfo.hasindex = strcmp(PQgetvalue(res, 0, 0), "t") == 0;
|
tableinfo.hasindex = strcmp(PQgetvalue(res, 0, 0), "t") == 0;
|
||||||
tableinfo.hasrules = strcmp(PQgetvalue(res, 0, 4), "t") == 0;
|
tableinfo.hasrules = strcmp(PQgetvalue(res, 0, 4), "t") == 0;
|
||||||
tableinfo.hasoids = strcmp(PQgetvalue(res, 0, 5), "t") == 0;
|
tableinfo.hasoids = strcmp(PQgetvalue(res, 0, 5), "t") == 0;
|
||||||
tableinfo.tablespace = atooid(PQgetvalue(res, 0, 6));
|
tableinfo.tablespace = (pset.sversion >= 70500) ?
|
||||||
|
atooid(PQgetvalue(res, 0, 6)) : 0;
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
headers[0] = _("Column");
|
headers[0] = _("Column");
|
||||||
@ -932,8 +940,8 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
|
|
||||||
footers = pg_malloc_zero(4 * sizeof(*footers));
|
footers = pg_malloc_zero(4 * sizeof(*footers));
|
||||||
footers[count_footers++] = pg_strdup(tmpbuf.data);
|
footers[count_footers++] = pg_strdup(tmpbuf.data);
|
||||||
add_tablespace_footer(tableinfo.relkind, tableinfo.tablespace,
|
add_tablespace_footer(tableinfo.relkind, tableinfo.tablespace,
|
||||||
footers, &count_footers, tmpbuf);
|
footers, &count_footers, tmpbuf);
|
||||||
footers[count_footers] = NULL;
|
footers[count_footers] = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.18 2004/05/12 13:38:45 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.19 2004/08/20 20:18:23 momjian Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef SETTINGS_H
|
#ifndef SETTINGS_H
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
@ -41,7 +41,7 @@ typedef struct _psqlSettings
|
|||||||
FILE *cur_cmd_source; /* describe the status of the current main
|
FILE *cur_cmd_source; /* describe the status of the current main
|
||||||
* loop */
|
* loop */
|
||||||
bool cur_cmd_interactive;
|
bool cur_cmd_interactive;
|
||||||
|
int sversion; /* backend server version */
|
||||||
const char *progname; /* in case you renamed psql */
|
const char *progname; /* in case you renamed psql */
|
||||||
char *inputfile; /* for error reporting */
|
char *inputfile; /* for error reporting */
|
||||||
unsigned lineno; /* also for error reporting */
|
unsigned lineno; /* also for error reporting */
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.96 2004/08/18 02:59:11 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.97 2004/08/20 20:18:23 momjian Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
|
|
||||||
@ -217,6 +217,9 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
SyncVariables();
|
SyncVariables();
|
||||||
|
|
||||||
|
/* Grab the backend server version */
|
||||||
|
pset.sversion = PQserverVersion(pset.db);
|
||||||
|
|
||||||
if (options.action == ACT_LIST_DB)
|
if (options.action == ACT_LIST_DB)
|
||||||
{
|
{
|
||||||
int success = listAllDbs(false);
|
int success = listAllDbs(false);
|
||||||
|
Reference in New Issue
Block a user