4 * Postgres-version-specific routines
6 * $PostgreSQL: pgsql/contrib/pg_upgrade/version.c,v 1.3 2010/07/03 14:23:14 momjian Exp $
9 #include "pg_upgrade.h"
11 #include "access/transam.h"
15 * new_9_0_populate_pg_largeobject_metadata()
16 * new >= 9.0, old <= 8.4
17 * 9.0 has a new pg_largeobject permission table
20 new_9_0_populate_pg_largeobject_metadata(migratorContext *ctx, bool check_mode,
23 ClusterInfo *active_cluster = (whichCluster == CLUSTER_OLD) ?
24 &ctx->old : &ctx->new;
28 char output_path[MAXPGPATH];
30 prep_status(ctx, "Checking for large objects");
32 snprintf(output_path, sizeof(output_path), "%s/pg_largeobject.sql",
35 for (dbnum = 0; dbnum < active_cluster->dbarr.ndbs; dbnum++)
39 DbInfo *active_db = &active_cluster->dbarr.dbs[dbnum];
40 PGconn *conn = connectToServer(ctx, active_db->db_name, whichCluster);
42 /* find if there are any large objects */
43 res = executeQueryOrDie(ctx, conn,
45 "FROM pg_catalog.pg_largeobject ");
47 i_count = PQfnumber(res, "count");
48 if (atoi(PQgetvalue(res, 0, i_count)) != 0)
53 if (script == NULL && (script = fopen(output_path, "w")) == NULL)
54 pg_log(ctx, PG_FATAL, "Could not create necessary file: %s\n", output_path);
55 fprintf(script, "\\connect %s\n",
56 quote_identifier(ctx, active_db->db_name));
58 "SELECT pg_catalog.lo_create(t.loid)\n"
59 "FROM (SELECT DISTINCT loid FROM pg_catalog.pg_largeobject) AS t;\n");
71 report_status(ctx, PG_WARNING, "warning");
73 pg_log(ctx, PG_WARNING, "\n"
74 "| Your installation contains large objects.\n"
75 "| The new database has an additional large object\n"
76 "| permission table. After migration, you will be\n"
77 "| given a command to populate the pg_largeobject\n"
78 "| permission table with default permissions.\n\n");
80 pg_log(ctx, PG_WARNING, "\n"
81 "| Your installation contains large objects.\n"
82 "| The new database has an additional large object\n"
83 "| permission table so default permissions must be\n"
84 "| defined for all large objects. The file:\n"
86 "| when executed by psql by the database super-user\n"
87 "| will define the default permissions.\n\n",