void 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 */ if (GET_MAJOR_VERSION(old_cluster.major_version) < 803) pg_log(PG_FATAL, "This utility can only upgrade from PostgreSQL version 8.3 and later.\n"); /* Only current PG version is supported as a target */ if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM)) pg_log(PG_FATAL, "This utility can only upgrade to PostgreSQL version %s.\n", PG_MAJORVERSION); /* * We can't allow downgrading because we use the target pg_dumpall, and * pg_dumpall cannot operate on new datbase versions, only older versions. */ if (old_cluster.major_version > new_cluster.major_version) pg_log(PG_FATAL, "This utility cannot be used to downgrade to older major PostgreSQL versions.\n"); }
void check_cluster_versions(void) { prep_status("Checking cluster versions"); /* 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 */ if (GET_MAJOR_VERSION(old_cluster.major_version) < 803) pg_log(PG_FATAL, "This utility can only upgrade from PostgreSQL version 8.3 and later.\n"); /* Only current PG version is supported as a target */ if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM)) pg_log(PG_FATAL, "This utility can only upgrade to PostgreSQL version %s.\n", PG_MAJORVERSION); /* * We can't allow downgrading because we use the target pg_dumpall, and * pg_dumpall cannot operate on new database versions, only older * versions. */ if (old_cluster.major_version > new_cluster.major_version) pg_log(PG_FATAL, "This utility cannot be used to downgrade to older major PostgreSQL versions.\n"); /* get old and new binary versions */ get_bin_version(&old_cluster); get_bin_version(&new_cluster); /* Ensure binaries match the designated data directories */ if (GET_MAJOR_VERSION(old_cluster.major_version) != GET_MAJOR_VERSION(old_cluster.bin_version)) pg_log(PG_FATAL, "Old cluster data and binary directories are from different major versions.\n"); if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(new_cluster.bin_version)) pg_log(PG_FATAL, "New cluster data and binary directories are from different major versions.\n"); check_ok(); }
/* * check_data_dir() * * This function validates the given cluster directory - we search for a * small set of subdirectories that we expect to find in a valid $PGDATA * directory. If any of the subdirectories are missing (or secured against * us) we display an error message and exit() * */ static void check_data_dir(ClusterInfo *cluster) { const char *pg_data = cluster->pgdata; /* 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); check_single_dir(pg_data, ""); check_single_dir(pg_data, "base"); check_single_dir(pg_data, "global"); check_single_dir(pg_data, "pg_multixact"); check_single_dir(pg_data, "pg_subtrans"); check_single_dir(pg_data, "pg_tblspc"); check_single_dir(pg_data, "pg_twophase"); /* pg_xlog has been renamed to pg_wal in post-10 cluster */ if (GET_MAJOR_VERSION(cluster->major_version) < 1000) check_single_dir(pg_data, "pg_xlog"); else check_single_dir(pg_data, "pg_wal"); }