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 }
0 commit comments