3
3
*
4
4
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
5
5
*
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 $
7
7
*/
8
8
#include "postgres_fe.h"
9
9
#include "describe.h"
@@ -112,6 +112,12 @@ describeTablespaces(const char *pattern, bool verbose)
112
112
PGresult * res ;
113
113
printQueryOpt myopt = pset .popt ;
114
114
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
+
115
121
initPQExpBuffer (& buf );
116
122
117
123
printfPQExpBuffer (& buf ,
@@ -706,8 +712,9 @@ describeOneTableDetails(const char *schemaname,
706
712
/* Get general table info */
707
713
printfPQExpBuffer (& buf ,
708
714
"SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, \n"
709
- "relhasoids, reltablespace \n"
715
+ "relhasoids %s \n"
710
716
"FROM pg_catalog.pg_class WHERE oid = '%s'" ,
717
+ pset .sversion >= 70500 ? ", reltablespace" : "" ,
711
718
oid );
712
719
res = PSQLexec (buf .data , false);
713
720
if (!res )
@@ -729,7 +736,8 @@ describeOneTableDetails(const char *schemaname,
729
736
tableinfo .hasindex = strcmp (PQgetvalue (res , 0 , 0 ), "t" ) == 0 ;
730
737
tableinfo .hasrules = strcmp (PQgetvalue (res , 0 , 4 ), "t" ) == 0 ;
731
738
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 ;
733
741
PQclear (res );
734
742
735
743
headers [0 ] = _ ("Column" );
@@ -932,8 +940,8 @@ describeOneTableDetails(const char *schemaname,
932
940
933
941
footers = pg_malloc_zero (4 * sizeof (* footers ));
934
942
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 );
937
945
footers [count_footers ] = NULL ;
938
946
939
947
}
0 commit comments