@@ -193,15 +193,21 @@ get_db_infos(ClusterInfo *cluster)
193
193
int i_datname ,
194
194
i_oid ,
195
195
i_spclocation ;
196
+ char query [QUERY_ALLOC ];
196
197
197
- res = executeQueryOrDie ( conn ,
198
- "SELECT d.oid, d.datname, t.spclocation "
199
- "FROM pg_catalog.pg_database d "
200
- " LEFT OUTER JOIN pg_catalog.pg_tablespace t "
201
- " ON d.dattablespace = t.oid "
202
- "WHERE d.datallowconn = true "
198
+ snprintf ( query , sizeof ( query ) ,
199
+ "SELECT d.oid, d.datname, %s "
200
+ "FROM pg_catalog.pg_database d "
201
+ " LEFT OUTER JOIN pg_catalog.pg_tablespace t "
202
+ " ON d.dattablespace = t.oid "
203
+ "WHERE d.datallowconn = true "
203
204
/* we don't preserve pg_database.oid so we sort by name */
204
- "ORDER BY 2" );
205
+ "ORDER BY 2" ,
206
+ /* 9.2 removed the spclocation column */
207
+ (GET_MAJOR_VERSION (old_cluster .major_version ) <= 901 ) ?
208
+ "t.spclocation" : "pg_catalog.pg_tablespace_location(t.oid) AS spclocation" );
209
+
210
+ res = executeQueryOrDie (conn , "%s" , query );
205
211
206
212
i_oid = PQfnumber (res , "oid" );
207
213
i_datname = PQfnumber (res , "datname" );
@@ -265,7 +271,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
265
271
266
272
snprintf (query , sizeof (query ),
267
273
"SELECT c.oid, n.nspname, c.relname, "
268
- " c.relfilenode, t.spclocation "
274
+ " c.relfilenode, %s "
269
275
"FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n "
270
276
" ON c.relnamespace = n.oid "
271
277
" LEFT OUTER JOIN pg_catalog.pg_tablespace t "
@@ -280,6 +286,9 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
280
286
" relname IN ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) "
281
287
/* we preserve pg_class.oid so we sort by it to match old/new */
282
288
"ORDER BY 1;" ,
289
+ /* 9.2 removed the spclocation column */
290
+ (GET_MAJOR_VERSION (old_cluster .major_version ) <= 901 ) ?
291
+ "t.spclocation" : "pg_catalog.pg_tablespace_location(t.oid) AS spclocation" ,
283
292
/* see the comment at the top of old_8_3_create_sequence_script() */
284
293
(GET_MAJOR_VERSION (old_cluster .major_version ) <= 803 ) ?
285
294
"" : ", 'S'" ,
0 commit comments