4 * Postgres-version-specific routines
6 * Copyright (c) 2010-2014, PostgreSQL Global Development Group
7 * contrib/pg_upgrade/version.c
10 #include "postgres_fe.h"
12 #include "pg_upgrade.h"
17 * new_9_0_populate_pg_largeobject_metadata()
18 * new >= 9.0, old <= 8.4
19 * 9.0 has a new pg_largeobject permission table
22 new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster, bool check_mode)
27 char output_path[MAXPGPATH];
29 prep_status("Checking for large objects");
31 snprintf(output_path, sizeof(output_path), "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_priv(output_path, "w")) == NULL)
52 pg_fatal("could not open file \"%s\": %s\n", output_path, getErrorText(errno));
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");
70 report_status(PG_WARNING, "warning");
72 pg_log(PG_WARNING, "\n"
73 "Your installation contains large objects. The new database has an\n"
74 "additional large object permission table. After upgrading, you will be\n"
75 "given a command to populate the pg_largeobject permission table with\n"
76 "default permissions.\n\n");
78 pg_log(PG_WARNING, "\n"
79 "Your installation contains large objects. The new database has an\n"
80 "additional large object permission table, so default permissions must be\n"
81 "defined for all large objects. The file\n"
83 "when executed by psql by the database superuser will set the default\n"