1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Restructure the pg_upgrade code to use several global structures rather

than packing everything into 'ctx' and passing that to every function.
This commit is contained in:
Bruce Momjian
2010-10-19 21:38:16 +00:00
parent 6e74a91b2b
commit e13f7e9a71
17 changed files with 972 additions and 972 deletions

View File

@ -15,9 +15,9 @@
#ifdef PAGE_CONVERSION
static const char *getPageVersion(migratorContext *ctx,
static const char *getPageVersion(
uint16 *version, const char *pathName);
static pageCnvCtx *loadConverterPlugin(migratorContext *ctx,
static pageCnvCtx *loadConverterPlugin(
uint16 newPageVersion, uint16 oldPageVersion);
@ -37,7 +37,7 @@ static pageCnvCtx *loadConverterPlugin(migratorContext *ctx,
* string.
*/
const char *
setupPageConverter(migratorContext *ctx, pageCnvCtx **result)
setupPageConverter(pageCnvCtx **result)
{
uint16 oldPageVersion;
uint16 newPageVersion;
@ -46,15 +46,15 @@ setupPageConverter(migratorContext *ctx, pageCnvCtx **result)
char dstName[MAXPGPATH];
char srcName[MAXPGPATH];
snprintf(dstName, sizeof(dstName), "%s/global/%u", ctx->new.pgdata,
ctx->new.pg_database_oid);
snprintf(srcName, sizeof(srcName), "%s/global/%u", ctx->old.pgdata,
ctx->old.pg_database_oid);
snprintf(dstName, sizeof(dstName), "%s/global/%u", new_cluster.pgdata,
new_cluster.pg_database_oid);
snprintf(srcName, sizeof(srcName), "%s/global/%u", old_cluster.pgdata,
old_cluster.pg_database_oid);
if ((msg = getPageVersion(ctx, &oldPageVersion, srcName)) != NULL)
if ((msg = getPageVersion(&oldPageVersion, srcName)) != NULL)
return msg;
if ((msg = getPageVersion(ctx, &newPageVersion, dstName)) != NULL)
if ((msg = getPageVersion(&newPageVersion, dstName)) != NULL)
return msg;
/*
@ -73,7 +73,7 @@ setupPageConverter(migratorContext *ctx, pageCnvCtx **result)
* layout.
*/
if ((converter = loadConverterPlugin(ctx, newPageVersion, oldPageVersion)) == NULL)
if ((converter = loadConverterPlugin(newPageVersion, oldPageVersion)) == NULL)
return "can't find plugin to convert from old page layout to new page layout";
else
{
@ -93,7 +93,7 @@ setupPageConverter(migratorContext *ctx, pageCnvCtx **result)
* of a null-terminated string).
*/
static const char *
getPageVersion(migratorContext *ctx, uint16 *version, const char *pathName)
getPageVersion(uint16 *version, const char *pathName)
{
int relfd;
PageHeaderData page;
@ -128,7 +128,7 @@ getPageVersion(migratorContext *ctx, uint16 *version, const char *pathName)
* is not found, this function returns NULL.
*/
static pageCnvCtx *
loadConverterPlugin(migratorContext *ctx, uint16 newPageVersion, uint16 oldPageVersion)
loadConverterPlugin(uint16 newPageVersion, uint16 oldPageVersion)
{
char pluginName[MAXPGPATH];
void *plugin;
@ -151,7 +151,7 @@ loadConverterPlugin(migratorContext *ctx, uint16 newPageVersion, uint16 oldPageV
return NULL;
else
{
pageCnvCtx *result = (pageCnvCtx *) pg_malloc(ctx, sizeof(*result));
pageCnvCtx *result = (pageCnvCtx *) pg_malloc(sizeof(*result));
result->old.PageVersion = oldPageVersion;
result->new.PageVersion = newPageVersion;