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);
+ 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 */
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 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_infos(cluster);
for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
- get_rel_infos(cluster, &cluster->dbarr.dbs[dbnum],
- &cluster->dbarr.dbs[dbnum].rel_arr);
+ get_rel_infos(cluster, dbnum);
if (log_opts.debug)
dbarr_print(cluster);
* FirstNormalObjectId belongs to the user
*/
static void
-get_rel_infos(ClusterInfo *cluster, const DbInfo *dbinfo, RelInfoArr *relarr)
+get_rel_infos(ClusterInfo *cluster, const int dbnum)
{
- PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGconn *conn = connectToServer(cluster,
+ cluster->dbarr.dbs[dbnum].db_name);
PGresult *res;
RelInfo *relinfos;
int ntups;
tblspace = PQgetvalue(res, relnum, i_spclocation);
/* if no table tablespace, use the database tablespace */
if (strlen(tblspace) == 0)
- tblspace = dbinfo->db_tblspace;
+ tblspace = cluster->dbarr.dbs[dbnum].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;
+ 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;
}
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);
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 */
+ 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 */
void start_postmaster(ClusterInfo *cluster, bool quiet);
void stop_postmaster(bool fast, bool quiet);
-uint32 get_major_server_version(ClusterInfo *cluster, char **verstr);
+uint32 get_major_server_version(ClusterInfo *cluster);
void check_for_libpq_envvars(void);
* is retrieved by reading the PG_VERSION file.
*/
uint32
-get_major_server_version(ClusterInfo *cluster, char **verstr)
+get_major_server_version(ClusterInfo *cluster)
{
const char *datadir = cluster->pgdata;
FILE *version_fd;
- char ver_file[MAXPGPATH];
+ char ver_filename[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)
+ 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", *verstr) == 0 ||
- sscanf(*verstr, "%d.%d", &integer_version, &fractional_version) != 2)
+ 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);