The attached, applied patch removes toast relid from the relation array
as it is no longer needed. Also other remaming was done.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
commit 0a5f11993195d74f23b63cc5c2d7024c6d27d7e2
Author: Bruce Momjian <bruce@momjian.us>
Date: Mon Jan 10 11:45:22 2011 -0500
A toast relid field are no longer needed in pg_upgrade's rel arrays, so
remove them. Also other renaming.
diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c
index 74449df..fc82be4 100644
*** /tmp/6A0Xec_check.c Mon Jan 10 11:47:29 2011
--- /tmp/ahdAoa_check.c Mon Jan 10 11:47:29 2011
*************** check_new_db_is_empty(void)
*** 362,368 ****
}
}
! dbarr_free(&new_cluster.dbarr);
if (found)
pg_log(PG_FATAL, "New cluster is not empty; exiting\n");
--- 362,368 ----
}
}
! free_db_and_rel_infos(&new_cluster.dbarr);
if (found)
pg_log(PG_FATAL, "New cluster is not empty; exiting\n");
diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c
index c805a04..c041231 100644
*** /tmp/E8qJIb_info.c Mon Jan 10 11:47:29 2011
--- /tmp/yt5zIb_info.c Mon Jan 10 11:47:29 2011
***************
*** 12,26 ****
#include "access/transam.h"
- static void get_db_infos(ClusterInfo *cluster);
- static void print_db_arr(ClusterInfo *cluster);
- static void print_rel_arr(RelInfoArr *arr);
- static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
- static void free_rel_arr(RelInfoArr *rel_arr);
static void create_rel_filename_map(const char *old_data, const char *new_data,
const DbInfo *old_db, const DbInfo *new_db,
const RelInfo *old_rel, const RelInfo *new_rel,
FileNameMap *map);
/*
--- 12,26 ----
#include "access/transam.h"
static void create_rel_filename_map(const char *old_data, const char *new_data,
const DbInfo *old_db, const DbInfo *new_db,
const RelInfo *old_rel, const RelInfo *new_rel,
FileNameMap *map);
+ static void get_db_infos(ClusterInfo *cluster);
+ static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
+ static void free_rel_infos(RelInfoArr *rel_arr);
+ static void print_db_infos(DbInfoArr *dbinfo);
+ static void print_rel_infos(RelInfoArr *arr);
/*
*************** create_rel_filename_map(const char *old_
*** 111,125 ****
void
! print_maps(FileNameMap *maps, int n, const char *dbName)
{
if (log_opts.debug)
{
int mapnum;
! pg_log(PG_DEBUG, "mappings for db %s:\n", dbName);
! for (mapnum = 0; mapnum < n; mapnum++)
pg_log(PG_DEBUG, "%s.%s: %u to %u\n",
maps[mapnum].nspname, maps[mapnum].relname,
maps[mapnum].old_relfilenode,
--- 111,125 ----
void
! print_maps(FileNameMap *maps, int n_maps, const char *db_name)
{
if (log_opts.debug)
{
int mapnum;
! pg_log(PG_DEBUG, "mappings for db %s:\n", db_name);
! for (mapnum = 0; mapnum < n_maps; mapnum++)
pg_log(PG_DEBUG, "%s.%s: %u to %u\n",
maps[mapnum].nspname, maps[mapnum].relname,
maps[mapnum].old_relfilenode,
*************** print_maps(FileNameMap *maps, int n, con
*** 131,136 ****
--- 131,160 ----
/*
+ * get_db_and_rel_infos()
+ *
+ * higher level routine to generate dbinfos for the database running
+ * on the given "port". Assumes that server is already running.
+ */
+ void
+ get_db_and_rel_infos(ClusterInfo *cluster)
+ {
+ int dbnum;
+
+ get_db_infos(cluster);
+
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ get_rel_infos(cluster, &cluster->dbarr.dbs[dbnum]);
+
+ if (log_opts.debug)
+ {
+ pg_log(PG_DEBUG, "%s databases\n", CLUSTER_NAME(cluster));
+ print_db_infos(&cluster->dbarr);
+ }
+ }
+
+
+ /*
* get_db_infos()
*
* Scans pg_database system catalog and populates all user
*************** get_db_infos(ClusterInfo *cluster)
*** 144,152 ****
int ntups;
int tupnum;
DbInfo *dbinfos;
! int i_datname;
! int i_oid;
! int i_spclocation;
res = executeQueryOrDie(conn,
"SELECT d.oid, d.datname, t.spclocation "
--- 168,174 ----
int ntups;
int tupnum;
DbInfo *dbinfos;
! int i_datname, i_oid, i_spclocation;
res = executeQueryOrDie(conn,
"SELECT d.oid, d.datname, t.spclocation "
*************** get_db_infos(ClusterInfo *cluster)
*** 183,209 ****
/*
- * get_db_and_rel_infos()
- *
- * higher level routine to generate dbinfos for the database running
- * on the given "port". Assumes that server is already running.
- */
- void
- get_db_and_rel_infos(ClusterInfo *cluster)
- {
- int dbnum;
-
- get_db_infos(cluster);
-
- for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
- get_rel_infos(cluster, &cluster->dbarr.dbs[dbnum]);
-
- if (log_opts.debug)
- print_db_arr(cluster);
- }
-
-
- /*
* get_rel_infos()
*
* gets the relinfos for all the user tables of the database refered
--- 205,210 ----
*************** get_rel_infos(ClusterInfo *cluster, DbIn
*** 224,250 ****
int num_rels = 0;
char *nspname = NULL;
char *relname = NULL;
! int i_spclocation = -1;
! int i_nspname = -1;
! int i_relname = -1;
! int i_oid = -1;
! int i_relfilenode = -1;
! int i_reltoastrelid = -1;
char query[QUERY_ALLOC];
/*
* pg_largeobject contains user data that does not appear in pg_dumpall
* --schema-only output, so we have to copy that system table heap and
! * index. Ideally we could just get the relfilenode from template1 but
! * pg_largeobject_loid_pn_index's relfilenode can change if the table was
! * reindexed so we get the relfilenode for each database and upgrade it as
! * a normal user table.
! * Order by tablespace so we can cache the directory contents efficiently.
*/
snprintf(query, sizeof(query),
! "SELECT DISTINCT c.oid, n.nspname, c.relname, "
! " c.relfilenode, c.reltoastrelid, t.spclocation "
"FROM pg_catalog.pg_class c JOIN "
" pg_catalog.pg_namespace n "
" ON c.relnamespace = n.oid "
--- 225,244 ----
int num_rels = 0;
char *nspname = NULL;
char *relname = NULL;
! int i_spclocation, i_nspname, i_relname, i_oid, i_relfilenode;
char query[QUERY_ALLOC];
/*
* pg_largeobject contains user data that does not appear in pg_dumpall
* --schema-only output, so we have to copy that system table heap and
! * index. We could grab the pg_largeobject oids from template1, but
! * it is easy to treat it as a normal table.
! * Order by oid so we can join old/new structures efficiently.
*/
snprintf(query, sizeof(query),
! "SELECT c.oid, n.nspname, c.relname, "
! " c.relfilenode, t.spclocation "
"FROM pg_catalog.pg_class c JOIN "
" pg_catalog.pg_namespace n "
" ON c.relnamespace = n.oid "
*************** get_rel_infos(ClusterInfo *cluster, DbIn
*** 256,265 ****
" n.nspname = 'pg_catalog' "
" AND relname IN "
" ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) "
! " AND relkind IN ('r','t', 'i'%s)"
! "GROUP BY c.oid, n.nspname, c.relname, c.relfilenode,"
! " c.reltoastrelid, t.spclocation, "
! " n.nspname "
/* we preserve pg_class.oid so we sort by it to match old/new */
"ORDER BY 1;",
FirstNormalObjectId,
--- 250,256 ----
" n.nspname = 'pg_catalog' "
" AND relname IN "
" ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) "
! " AND relkind IN ('r','t', 'i'%s) "
/* we preserve pg_class.oid so we sort by it to match old/new */
"ORDER BY 1;",
FirstNormalObjectId,
*************** get_rel_infos(ClusterInfo *cluster, DbIn
*** 280,286 ****
i_nspname = PQfnumber(res, "nspname");
i_relname = PQfnumber(res, "relname");
i_relfilenode = PQfnumber(res, "relfilenode");
- i_reltoastrelid = PQfnumber(res, "reltoastrelid");
i_spclocation = PQfnumber(res, "spclocation");
for (relnum = 0; relnum < ntups; relnum++)
--- 271,276 ----
*************** get_rel_infos(ClusterInfo *cluster, DbIn
*** 297,303 ****
strlcpy(curr->relname, relname, sizeof(curr->relname));
curr->relfilenode = atooid(PQgetvalue(res, relnum, i_relfilenode));
- curr->toastrelid = atooid(PQgetvalue(res, relnum, i_reltoastrelid));
tblspace = PQgetvalue(res, relnum, i_spclocation);
/* if no table tablespace, use the database tablespace */
--- 287,292 ----
*************** get_rel_infos(ClusterInfo *cluster, DbIn
*** 314,356 ****
}
- static void
- free_rel_arr(RelInfoArr *rel_arr)
- {
- pg_free(rel_arr->rels);
- rel_arr->nrels = 0;
- }
-
-
void
! dbarr_free(DbInfoArr *db_arr)
{
int dbnum;
for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
! free_rel_arr(&db_arr->dbs[dbnum].rel_arr);
db_arr->ndbs = 0;
}
static void
! print_db_arr(ClusterInfo *cluster)
{
! int dbnum;
- pg_log(PG_DEBUG, "%s databases\n", CLUSTER_NAME(cluster));
! for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
{
! pg_log(PG_DEBUG, "Database: %s\n", cluster->dbarr.dbs[dbnum].db_name);
! print_rel_arr(&cluster->dbarr.dbs[dbnum].rel_arr);
pg_log(PG_DEBUG, "\n\n");
}
}
static void
! print_rel_arr(RelInfoArr *arr)
{
int relnum;
--- 303,344 ----
}
void
! free_db_and_rel_infos(DbInfoArr *db_arr)
{
int dbnum;
for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
! free_rel_infos(&db_arr->dbs[dbnum].rel_arr);
! pg_free(db_arr->dbs);
db_arr->ndbs = 0;
}
static void
! free_rel_infos(RelInfoArr *rel_arr)
{
! pg_free(rel_arr->rels);
! rel_arr->nrels = 0;
! }
! static void
! print_db_infos(DbInfoArr *db_arr)
! {
! int dbnum;
!
! for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
{
! pg_log(PG_DEBUG, "Database: %s\n", db_arr->dbs[dbnum].db_name);
! print_rel_infos(&db_arr->dbs[dbnum].rel_arr);
pg_log(PG_DEBUG, "\n\n");
}
}
static void
! print_rel_infos(RelInfoArr *arr)
{
int relnum;
diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c
index 485412d..294f58b 100644
*** /tmp/cqNMUd_pg_upgrade.c Mon Jan 10 11:47:29 2011
--- /tmp/kQeJWd_pg_upgrade.c Mon Jan 10 11:47:29 2011
*************** create_new_objects(void)
*** 281,287 ****
check_ok();
/* regenerate now that we have objects in the databases */
! dbarr_free(&new_cluster.dbarr);
get_db_and_rel_infos(&new_cluster);
uninstall_support_functions_from_new_cluster();
--- 281,287 ----
check_ok();
/* regenerate now that we have objects in the databases */
! free_db_and_rel_infos(&new_cluster.dbarr);
get_db_and_rel_infos(&new_cluster);
uninstall_support_functions_from_new_cluster();
*************** cleanup(void)
*** 428,435 ****
pg_free(os_info.tablespaces[tblnum]);
pg_free(os_info.tablespaces);
! dbarr_free(&old_cluster.dbarr);
! dbarr_free(&new_cluster.dbarr);
pg_free(log_opts.filename);
pg_free(os_info.user);
pg_free(old_cluster.controldata.lc_collate);
--- 428,435 ----
pg_free(os_info.tablespaces[tblnum]);
pg_free(os_info.tablespaces);
! free_db_and_rel_infos(&old_cluster.dbarr);
! free_db_and_rel_infos(&new_cluster.dbarr);
pg_free(log_opts.filename);
pg_free(os_info.user);
pg_free(old_cluster.controldata.lc_collate);
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
index 18cbc19..4461952 100644
*** /tmp/g0Iv5c_pg_upgrade.h Mon Jan 10 11:47:29 2011
--- /tmp/eZYfXc_pg_upgrade.h Mon Jan 10 11:47:29 2011
*************** typedef struct
*** 69,75 ****
char relname[NAMEDATALEN]; /* relation name */
Oid reloid; /* relation oid */
Oid relfilenode; /* relation relfile node */
- Oid toastrelid; /* oid of the toast relation */
char tablespace[MAXPGPATH]; /* relations tablespace path */
} RelInfo;
--- 69,74 ----
*************** FileNameMap *gen_db_file_maps(DbInfo *ol
*** 331,339 ****
DbInfo *new_db, int *nmaps, const char *old_pgdata,
const char *new_pgdata);
void get_db_and_rel_infos(ClusterInfo *cluster);
! void dbarr_free(DbInfoArr *db_arr);
! void print_maps(FileNameMap *maps, int n,
! const char *dbName);
/* option.c */
--- 330,338 ----
DbInfo *new_db, int *nmaps, const char *old_pgdata,
const char *new_pgdata);
void get_db_and_rel_infos(ClusterInfo *cluster);
! void free_db_and_rel_infos(DbInfoArr *db_arr);
! void print_maps(FileNameMap *maps, int n,
! const char *db_name);
/* option.c */