commit 67c9e4442f2521ff2ad62aa4d409269ea684ac0a Author: Bruce Momjian Date: Sat Jan 1 12:28:48 2011 -0500 Furter pg_upgrade optimizations to reduce function call argument count. diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c index 839a3c9..5708e2f 100644 *** /tmp/ky16ee_check.c Wed Jan 5 09:04:30 2011 --- /tmp/uJkDve_check.c Wed Jan 5 09:04:30 2011 *************** void *** 209,216 **** check_cluster_versions(void) { /* get old and new cluster versions */ ! old_cluster.major_version = get_major_server_version(&old_cluster, &old_cluster.major_version_str); ! new_cluster.major_version = get_major_server_version(&new_cluster, &new_cluster.major_version_str); /* We allow upgrades from/to the same major version for alpha/beta upgrades */ --- 209,216 ---- check_cluster_versions(void) { /* get old and new cluster versions */ ! old_cluster.major_version = get_major_server_version(&old_cluster); ! new_cluster.major_version = get_major_server_version(&new_cluster); /* We allow upgrades from/to the same major version for alpha/beta upgrades */ diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c index e44798a..7651096 100644 *** /tmp/Q6ensd_info.c Wed Jan 5 09:04:30 2011 --- /tmp/a3Vosb_info.c Wed Jan 5 09:04:30 2011 *************** *** 15,22 **** static void get_db_infos(ClusterInfo *cluster); static void dbarr_print(ClusterInfo *cluster); static void relarr_print(RelInfoArr *arr); ! static void get_rel_infos(ClusterInfo *cluster, const DbInfo *dbinfo, ! RelInfoArr *relarr); static void relarr_free(RelInfoArr *rel_arr); static void map_rel(const RelInfo *oldrel, const RelInfo *newrel, const DbInfo *old_db, --- 15,21 ---- static void get_db_infos(ClusterInfo *cluster); static void dbarr_print(ClusterInfo *cluster); static void relarr_print(RelInfoArr *arr); ! static void get_rel_infos(ClusterInfo *cluster, const int dbnum); static void relarr_free(RelInfoArr *rel_arr); static void map_rel(const RelInfo *oldrel, const RelInfo *newrel, const DbInfo *old_db, *************** get_db_and_rel_infos(ClusterInfo *cluste *** 272,279 **** get_db_infos(cluster); for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++) ! get_rel_infos(cluster, &cluster->dbarr.dbs[dbnum], ! &cluster->dbarr.dbs[dbnum].rel_arr); if (log_opts.debug) dbarr_print(cluster); --- 271,277 ---- get_db_infos(cluster); for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++) ! get_rel_infos(cluster, dbnum); if (log_opts.debug) dbarr_print(cluster); *************** get_db_and_rel_infos(ClusterInfo *cluste *** 290,298 **** * FirstNormalObjectId belongs to the user */ static void ! get_rel_infos(ClusterInfo *cluster, const DbInfo *dbinfo, RelInfoArr *relarr) { ! PGconn *conn = connectToServer(cluster, dbinfo->db_name); PGresult *res; RelInfo *relinfos; int ntups; --- 288,297 ---- * FirstNormalObjectId belongs to the user */ static void ! get_rel_infos(ClusterInfo *cluster, const int dbnum) { ! PGconn *conn = connectToServer(cluster, ! cluster->dbarr.dbs[dbnum].db_name); PGresult *res; RelInfo *relinfos; int ntups; *************** get_rel_infos(ClusterInfo *cluster, cons *** 374,389 **** tblspace = PQgetvalue(res, relnum, i_spclocation); /* if no table tablespace, use the database tablespace */ if (strlen(tblspace) == 0) ! tblspace = dbinfo->db_tblspace; strlcpy(curr->tablespace, tblspace, sizeof(curr->tablespace)); } PQclear(res); PQfinish(conn); ! relarr->rels = relinfos; ! relarr->nrels = num_rels; ! relarr->last_relname_lookup = 0; } --- 373,388 ---- tblspace = PQgetvalue(res, relnum, i_spclocation); /* if no table tablespace, use the database tablespace */ if (strlen(tblspace) == 0) ! tblspace = cluster->dbarr.dbs[dbnum].db_tblspace; strlcpy(curr->tablespace, tblspace, sizeof(curr->tablespace)); } PQclear(res); PQfinish(conn); ! cluster->dbarr.dbs[dbnum].rel_arr.rels = relinfos; ! cluster->dbarr.dbs[dbnum].rel_arr.nrels = num_rels; ! cluster->dbarr.dbs[dbnum].rel_arr.last_relname_lookup = 0; } diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c index d2ca08b..5b8bf72 100644 *** /tmp/Ch0sza_pg_upgrade.c Wed Jan 5 09:04:30 2011 --- /tmp/KJwJSa_pg_upgrade.c Wed Jan 5 09:04:30 2011 *************** cleanup(void) *** 384,391 **** dbarr_free(&new_cluster.dbarr); pg_free(log_opts.filename); pg_free(os_info.user); - pg_free(old_cluster.major_version_str); - pg_free(new_cluster.major_version_str); pg_free(old_cluster.controldata.lc_collate); pg_free(new_cluster.controldata.lc_collate); pg_free(old_cluster.controldata.lc_ctype); --- 384,389 ---- diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h index b6ce965..5405209 100644 *** /tmp/uDtZHc_pg_upgrade.h Wed Jan 5 09:04:30 2011 --- /tmp/mf7mXc_pg_upgrade.h Wed Jan 5 09:04:30 2011 *************** typedef struct *** 179,185 **** char *bindir; /* pathname for cluster's executable directory */ unsigned short port; /* port number where postmaster is waiting */ uint32 major_version; /* PG_VERSION of cluster */ ! char *major_version_str; /* string PG_VERSION of cluster */ Oid pg_database_oid; /* OID of pg_database relation */ char *libpath; /* pathname for cluster's pkglibdir */ char *tablespace_suffix; /* directory specification */ --- 179,185 ---- char *bindir; /* pathname for cluster's executable directory */ unsigned short port; /* port number where postmaster is waiting */ uint32 major_version; /* PG_VERSION of cluster */ ! char major_version_str[64]; /* string PG_VERSION of cluster */ Oid pg_database_oid; /* OID of pg_database relation */ char *libpath; /* pathname for cluster's pkglibdir */ char *tablespace_suffix; /* directory specification */ *************** PGresult *executeQueryOrDie(PGconn *conn *** 357,363 **** void start_postmaster(ClusterInfo *cluster, bool quiet); void stop_postmaster(bool fast, bool quiet); ! uint32 get_major_server_version(ClusterInfo *cluster, char **verstr); void check_for_libpq_envvars(void); --- 357,363 ---- void start_postmaster(ClusterInfo *cluster, bool quiet); void stop_postmaster(bool fast, bool quiet); ! uint32 get_major_server_version(ClusterInfo *cluster); void check_for_libpq_envvars(void); diff --git a/contrib/pg_upgrade/server.c b/contrib/pg_upgrade/server.c index 56dcb10..785e2ee 100644 *** /tmp/MgF32b_server.c Wed Jan 5 09:04:30 2011 --- /tmp/wuqipc_server.c Wed Jan 5 09:04:30 2011 *************** get_postmaster_pid(const char *datadir) *** 129,150 **** * is retrieved by reading the PG_VERSION file. */ uint32 ! get_major_server_version(ClusterInfo *cluster, char **verstr) { const char *datadir = cluster->pgdata; FILE *version_fd; ! char ver_file[MAXPGPATH]; int integer_version = 0; int fractional_version = 0; ! *verstr = pg_malloc(64); ! ! snprintf(ver_file, sizeof(ver_file), "%s/PG_VERSION", datadir); ! if ((version_fd = fopen(ver_file, "r")) == NULL) return 0; ! if (fscanf(version_fd, "%63s", *verstr) == 0 || ! sscanf(*verstr, "%d.%d", &integer_version, &fractional_version) != 2) { pg_log(PG_FATAL, "could not get version from %s\n", datadir); fclose(version_fd); --- 129,149 ---- * is retrieved by reading the PG_VERSION file. */ uint32 ! get_major_server_version(ClusterInfo *cluster) { const char *datadir = cluster->pgdata; FILE *version_fd; ! char ver_filename[MAXPGPATH]; int integer_version = 0; int fractional_version = 0; ! snprintf(ver_filename, sizeof(ver_filename), "%s/PG_VERSION", datadir); ! if ((version_fd = fopen(ver_filename, "r")) == NULL) return 0; ! if (fscanf(version_fd, "%63s", cluster->major_version_str) == 0 || ! sscanf(cluster->major_version_str, "%d.%d", &integer_version, ! &fractional_version) != 2) { pg_log(PG_FATAL, "could not get version from %s\n", datadir); fclose(version_fd);