@@ -201,6 +201,87 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster)
201
201
}
202
202
203
203
204
+ /*
205
+ * old_8_3_check_ltree_usage()
206
+ * 8.3 -> 8.4
207
+ * The internal ltree structure was changed in 8.4 so upgrading is impossible.
208
+ */
209
+ void
210
+ old_8_3_check_ltree_usage (ClusterInfo * cluster )
211
+ {
212
+ int dbnum ;
213
+ FILE * script = NULL ;
214
+ bool found = false;
215
+ char output_path [MAXPGPATH ];
216
+
217
+ prep_status ("Checking for contrib/ltree" );
218
+
219
+ snprintf (output_path , sizeof (output_path ), "%s/contrib_ltree.txt" ,
220
+ os_info .cwd );
221
+
222
+ for (dbnum = 0 ; dbnum < cluster -> dbarr .ndbs ; dbnum ++ )
223
+ {
224
+ PGresult * res ;
225
+ bool db_used = false;
226
+ int ntups ;
227
+ int rowno ;
228
+ int i_nspname ,
229
+ i_proname ;
230
+ DbInfo * active_db = & cluster -> dbarr .dbs [dbnum ];
231
+ PGconn * conn = connectToServer (cluster , active_db -> db_name );
232
+
233
+ /* Find any functions coming from contrib/ltree */
234
+ res = executeQueryOrDie (conn ,
235
+ "SELECT n.nspname, p.proname "
236
+ "FROM pg_catalog.pg_proc p, "
237
+ " pg_catalog.pg_namespace n "
238
+ "WHERE p.pronamespace = n.oid AND "
239
+ " p.probin = '$libdir/ltree'" );
240
+
241
+ ntups = PQntuples (res );
242
+ i_nspname = PQfnumber (res , "nspname" );
243
+ i_proname = PQfnumber (res , "proname" );
244
+ for (rowno = 0 ; rowno < ntups ; rowno ++ )
245
+ {
246
+ found = true;
247
+ if (script == NULL && (script = fopen (output_path , "w" )) == NULL )
248
+ pg_log (PG_FATAL , "Could not open file \"%s\": %s\n" ,
249
+ output_path , getErrorText (errno ));
250
+ if (!db_used )
251
+ {
252
+ fprintf (script , "Database: %s\n" , active_db -> db_name );
253
+ db_used = true;
254
+ }
255
+ fprintf (script , " %s.%s\n" ,
256
+ PQgetvalue (res , rowno , i_nspname ),
257
+ PQgetvalue (res , rowno , i_proname ));
258
+ }
259
+
260
+ PQclear (res );
261
+
262
+ PQfinish (conn );
263
+ }
264
+
265
+ if (script )
266
+ fclose (script );
267
+
268
+ if (found )
269
+ {
270
+ pg_log (PG_REPORT , "fatal\n" );
271
+ pg_log (PG_FATAL ,
272
+ "Your installation contains the \"ltree\" data type. This data type\n"
273
+ "changed its internal storage format between your old and new clusters so this\n"
274
+ "cluster cannot currently be upgraded. You can manually upgrade databases\n"
275
+ "that use \"contrib/ltree\" facilities and remove \"contrib/ltree\" from the old\n"
276
+ "cluster and restart the upgrade. A list of the problem functions is in the\n"
277
+ "file:\n"
278
+ " %s\n\n" , output_path );
279
+ }
280
+ else
281
+ check_ok ();
282
+ }
283
+
284
+
204
285
/*
205
286
* old_8_3_rebuild_tsvector_tables()
206
287
* 8.3 -> 8.4
0 commit comments