Adjust a few pg_upgrade functions to return void.
Adjust pg_upgrade page conversion functions (which are not used) to return void so transfer_all_new_dbs can return void.
This commit is contained in:
parent
84f6fb81b8
commit
bcbe99244f
|
@ -17,7 +17,7 @@
|
||||||
#ifdef PAGE_CONVERSION
|
#ifdef PAGE_CONVERSION
|
||||||
|
|
||||||
|
|
||||||
static const char *getPageVersion(
|
static void getPageVersion(
|
||||||
uint16 *version, const char *pathName);
|
uint16 *version, const char *pathName);
|
||||||
static pageCnvCtx *loadConverterPlugin(
|
static pageCnvCtx *loadConverterPlugin(
|
||||||
uint16 newPageVersion, uint16 oldPageVersion);
|
uint16 newPageVersion, uint16 oldPageVersion);
|
||||||
|
@ -33,13 +33,9 @@ static pageCnvCtx *loadConverterPlugin(
|
||||||
* to the new format. If the versions are identical, this function just
|
* to the new format. If the versions are identical, this function just
|
||||||
* returns a NULL pageCnvCtx pointer to indicate that page-by-page conversion
|
* returns a NULL pageCnvCtx pointer to indicate that page-by-page conversion
|
||||||
* is not required.
|
* is not required.
|
||||||
*
|
|
||||||
* If successful this function sets *result and returns NULL. If an error
|
|
||||||
* occurs, this function returns an error message in the form of an null-terminated
|
|
||||||
* string.
|
|
||||||
*/
|
*/
|
||||||
const char *
|
pageCnvCtx *
|
||||||
setupPageConverter(pageCnvCtx **result)
|
setupPageConverter(void)
|
||||||
{
|
{
|
||||||
uint16 oldPageVersion;
|
uint16 oldPageVersion;
|
||||||
uint16 newPageVersion;
|
uint16 newPageVersion;
|
||||||
|
@ -53,35 +49,28 @@ setupPageConverter(pageCnvCtx **result)
|
||||||
snprintf(srcName, sizeof(srcName), "%s/global/%u", old_cluster.pgdata,
|
snprintf(srcName, sizeof(srcName), "%s/global/%u", old_cluster.pgdata,
|
||||||
old_cluster.pg_database_oid);
|
old_cluster.pg_database_oid);
|
||||||
|
|
||||||
if ((msg = getPageVersion(&oldPageVersion, srcName)) != NULL)
|
getPageVersion(&oldPageVersion, srcName);
|
||||||
return msg;
|
getPageVersion(&newPageVersion, dstName);
|
||||||
|
|
||||||
if ((msg = getPageVersion(&newPageVersion, dstName)) != NULL)
|
|
||||||
return msg;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the old cluster and new cluster use the same page layouts, then we
|
* If the old cluster and new cluster use the same page layouts, then we
|
||||||
* don't need a page converter.
|
* don't need a page converter.
|
||||||
*/
|
*/
|
||||||
if (newPageVersion == oldPageVersion)
|
if (newPageVersion != oldPageVersion)
|
||||||
{
|
{
|
||||||
*result = NULL;
|
/*
|
||||||
return NULL;
|
* The clusters use differing page layouts, see if we can find a plugin
|
||||||
|
* that knows how to convert from the old page layout to the new page
|
||||||
|
* layout.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ((converter = loadConverterPlugin(newPageVersion, oldPageVersion)) == NULL)
|
||||||
|
pg_log(PG_FATAL, "could not find plugin to convert from old page layout to new page layout\n");
|
||||||
|
|
||||||
|
return converter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* The clusters use differing page layouts, see if we can find a plugin
|
|
||||||
* that knows how to convert from the old page layout to the new page
|
|
||||||
* layout.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ((converter = loadConverterPlugin(newPageVersion, oldPageVersion)) == NULL)
|
|
||||||
return "could not find plugin to convert from old page layout to new page layout";
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
*result = converter;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +83,7 @@ setupPageConverter(pageCnvCtx **result)
|
||||||
* if an error occurs, this function returns an error message (in the form
|
* if an error occurs, this function returns an error message (in the form
|
||||||
* of a null-terminated string).
|
* of a null-terminated string).
|
||||||
*/
|
*/
|
||||||
static const char *
|
static void
|
||||||
getPageVersion(uint16 *version, const char *pathName)
|
getPageVersion(uint16 *version, const char *pathName)
|
||||||
{
|
{
|
||||||
int relfd;
|
int relfd;
|
||||||
|
@ -102,19 +91,16 @@ getPageVersion(uint16 *version, const char *pathName)
|
||||||
ssize_t bytesRead;
|
ssize_t bytesRead;
|
||||||
|
|
||||||
if ((relfd = open(pathName, O_RDONLY, 0)) < 0)
|
if ((relfd = open(pathName, O_RDONLY, 0)) < 0)
|
||||||
return "could not open relation";
|
pg_log(PG_FATAL, "could not open relation %s\n", pathName);
|
||||||
|
|
||||||
if ((bytesRead = read(relfd, &page, sizeof(page))) != sizeof(page))
|
if ((bytesRead = read(relfd, &page, sizeof(page))) != sizeof(page))
|
||||||
{
|
pg_log(PG_FATAL, "could not read page header of %s\n", pathName);
|
||||||
close(relfd);
|
|
||||||
return "could not read page header";
|
|
||||||
}
|
|
||||||
|
|
||||||
*version = PageGetPageLayoutVersion(&page);
|
*version = PageGetPageLayoutVersion(&page);
|
||||||
|
|
||||||
close(relfd);
|
close(relfd);
|
||||||
|
|
||||||
return NULL;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -359,7 +359,7 @@ typedef struct
|
||||||
pluginShutdown shutdown; /* Pointer to plugin's shutdown function */
|
pluginShutdown shutdown; /* Pointer to plugin's shutdown function */
|
||||||
} pageCnvCtx;
|
} pageCnvCtx;
|
||||||
|
|
||||||
const char *setupPageConverter(pageCnvCtx **result);
|
const pageCnvCtx *setupPageConverter(void);
|
||||||
#else
|
#else
|
||||||
/* dummy */
|
/* dummy */
|
||||||
typedef void *pageCnvCtx;
|
typedef void *pageCnvCtx;
|
||||||
|
@ -398,7 +398,7 @@ void get_sock_dir(ClusterInfo *cluster, bool live_check);
|
||||||
/* relfilenode.c */
|
/* relfilenode.c */
|
||||||
|
|
||||||
void get_pg_database_relfilenode(ClusterInfo *cluster);
|
void get_pg_database_relfilenode(ClusterInfo *cluster);
|
||||||
const char *transfer_all_new_dbs(DbInfoArr *olddb_arr,
|
void transfer_all_new_dbs(DbInfoArr *olddb_arr,
|
||||||
DbInfoArr *newdb_arr, char *old_pgdata, char *new_pgdata);
|
DbInfoArr *newdb_arr, char *old_pgdata, char *new_pgdata);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,12 @@ static void transfer_relfile(pageCnvCtx *pageConverter, FileNameMap *map,
|
||||||
* Responsible for upgrading all database. invokes routines to generate mappings and then
|
* Responsible for upgrading all database. invokes routines to generate mappings and then
|
||||||
* physically link the databases.
|
* physically link the databases.
|
||||||
*/
|
*/
|
||||||
const char *
|
void
|
||||||
transfer_all_new_dbs(DbInfoArr *old_db_arr,
|
transfer_all_new_dbs(DbInfoArr *old_db_arr,
|
||||||
DbInfoArr *new_db_arr, char *old_pgdata, char *new_pgdata)
|
DbInfoArr *new_db_arr, char *old_pgdata, char *new_pgdata)
|
||||||
{
|
{
|
||||||
int old_dbnum,
|
int old_dbnum,
|
||||||
new_dbnum;
|
new_dbnum;
|
||||||
const char *msg = NULL;
|
|
||||||
|
|
||||||
pg_log(PG_REPORT, "%s user relation files\n",
|
pg_log(PG_REPORT, "%s user relation files\n",
|
||||||
user_opts.transfer_mode == TRANSFER_MODE_LINK ? "Linking" : "Copying");
|
user_opts.transfer_mode == TRANSFER_MODE_LINK ? "Linking" : "Copying");
|
||||||
|
@ -74,7 +73,7 @@ transfer_all_new_dbs(DbInfoArr *old_db_arr,
|
||||||
print_maps(mappings, n_maps, new_db->db_name);
|
print_maps(mappings, n_maps, new_db->db_name);
|
||||||
|
|
||||||
#ifdef PAGE_CONVERSION
|
#ifdef PAGE_CONVERSION
|
||||||
msg = setupPageConverter(&pageConverter);
|
pageConverter = setupPageConverter();
|
||||||
#endif
|
#endif
|
||||||
transfer_single_new_db(pageConverter, mappings, n_maps);
|
transfer_single_new_db(pageConverter, mappings, n_maps);
|
||||||
|
|
||||||
|
@ -85,7 +84,7 @@ transfer_all_new_dbs(DbInfoArr *old_db_arr,
|
||||||
end_progress_output();
|
end_progress_output();
|
||||||
check_ok();
|
check_ok();
|
||||||
|
|
||||||
return msg;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue