4 * Postgres-version-specific routines
6 * Copyright (c) 2010, PostgreSQL Global Development Group
7 * contrib/pg_upgrade/version.c
10 #include "pg_upgrade.h"
12 #include "access/transam.h"
16 * new_9_0_populate_pg_largeobject_metadata()
17 * new >= 9.0, old <= 8.4
18 * 9.0 has a new pg_largeobject permission table
21 new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster, bool check_mode)
26 char output_path[MAXPGPATH];
28 prep_status("Checking for large objects");
30 snprintf(output_path, sizeof(output_path), "%s/pg_largeobject.sql",
33 for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
37 DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
38 PGconn *conn = connectToServer(cluster, active_db->db_name);
40 /* find if there are any large objects */
41 res = executeQueryOrDie(conn,
43 "FROM pg_catalog.pg_largeobject ");
45 i_count = PQfnumber(res, "count");
46 if (atoi(PQgetvalue(res, 0, i_count)) != 0)
51 if (script == NULL && (script = fopen(output_path, "w")) == NULL)
52 pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path);
53 fprintf(script, "\\connect %s\n",
54 quote_identifier(active_db->db_name));
56 "SELECT pg_catalog.lo_create(t.loid)\n"
57 "FROM (SELECT DISTINCT loid FROM pg_catalog.pg_largeobject) AS t;\n");
69 report_status(PG_WARNING, "warning");
71 pg_log(PG_WARNING, "\n"
72 "| Your installation contains large objects.\n"
73 "| The new database has an additional large object\n"
74 "| permission table. After upgrading, you will be\n"
75 "| given a command to populate the pg_largeobject\n"
76 "| permission table with default permissions.\n\n");
78 pg_log(PG_WARNING, "\n"
79 "| Your installation contains large objects.\n"
80 "| The new database has an additional large object\n"
81 "| permission table so default permissions must be\n"
82 "| defined for all large objects. The file:\n"
84 "| when executed by psql by the database super-user\n"
85 "| will define the default permissions.\n\n",