Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbcbe992

Browse files
committed
Adjust a few pg_upgrade functions to return void.
Adjust pg_upgrade page conversion functions (which are not used) toreturn void so transfer_all_new_dbs can return void.
1 parent84f6fb8 commitbcbe992

File tree

3 files changed

+25
-40
lines changed

3 files changed

+25
-40
lines changed

‎contrib/pg_upgrade/page.c

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifdefPAGE_CONVERSION
1818

1919

20-
staticconstchar*getPageVersion(
20+
staticvoidgetPageVersion(
2121
uint16*version,constchar*pathName);
2222
staticpageCnvCtx*loadConverterPlugin(
2323
uint16newPageVersion,uint16oldPageVersion);
@@ -33,13 +33,9 @@ static pageCnvCtx *loadConverterPlugin(
3333
*to the new format.If the versions are identical, this function just
3434
*returns a NULL pageCnvCtx pointer to indicate that page-by-page conversion
3535
*is not required.
36-
*
37-
*If successful this function sets *result and returns NULL.If an error
38-
*occurs, this function returns an error message in the form of an null-terminated
39-
*string.
4036
*/
41-
constchar*
42-
setupPageConverter(pageCnvCtx**result)
37+
pageCnvCtx*
38+
setupPageConverter(void)
4339
{
4440
uint16oldPageVersion;
4541
uint16newPageVersion;
@@ -53,35 +49,28 @@ setupPageConverter(pageCnvCtx **result)
5349
snprintf(srcName,sizeof(srcName),"%s/global/%u",old_cluster.pgdata,
5450
old_cluster.pg_database_oid);
5551

56-
if ((msg=getPageVersion(&oldPageVersion,srcName))!=NULL)
57-
returnmsg;
58-
59-
if ((msg=getPageVersion(&newPageVersion,dstName))!=NULL)
60-
returnmsg;
52+
getPageVersion(&oldPageVersion,srcName);
53+
getPageVersion(&newPageVersion,dstName);
6154

6255
/*
6356
* If the old cluster and new cluster use the same page layouts, then we
6457
* don't need a page converter.
6558
*/
66-
if (newPageVersion==oldPageVersion)
59+
if (newPageVersion!=oldPageVersion)
6760
{
68-
*result=NULL;
69-
returnNULL;
70-
}
71-
72-
/*
73-
* The clusters use differing page layouts, see if we can find a plugin
74-
* that knows how to convert from the old page layout to the new page
75-
* layout.
76-
*/
61+
/*
62+
* The clusters use differing page layouts, see if we can find a plugin
63+
* that knows how to convert from the old page layout to the new page
64+
* layout.
65+
*/
66+
67+
if ((converter=loadConverterPlugin(newPageVersion,oldPageVersion))==NULL)
68+
pg_log(PG_FATAL,"could not find plugin to convert from old page layout to new page layout\n");
7769

78-
if ((converter=loadConverterPlugin(newPageVersion,oldPageVersion))==NULL)
79-
return"could not find plugin to convert from old page layout to new page layout";
70+
returnconverter;
71+
}
8072
else
81-
{
82-
*result=converter;
8373
returnNULL;
84-
}
8574
}
8675

8776

@@ -94,27 +83,24 @@ setupPageConverter(pageCnvCtx **result)
9483
*if an error occurs, this function returns an error message (in the form
9584
*of a null-terminated string).
9685
*/
97-
staticconstchar*
86+
staticvoid
9887
getPageVersion(uint16*version,constchar*pathName)
9988
{
10089
intrelfd;
10190
PageHeaderDatapage;
10291
ssize_tbytesRead;
10392

10493
if ((relfd=open(pathName,O_RDONLY,0))<0)
105-
return"could not open relation";
94+
pg_log(PG_FATAL,"could not open relation %s\n",pathName);
10695

10796
if ((bytesRead=read(relfd,&page,sizeof(page)))!=sizeof(page))
108-
{
109-
close(relfd);
110-
return"could not read page header";
111-
}
97+
pg_log(PG_FATAL,"could not read page header of %s\n",pathName);
11298

11399
*version=PageGetPageLayoutVersion(&page);
114100

115101
close(relfd);
116102

117-
returnNULL;
103+
return;
118104
}
119105

120106

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ typedef struct
359359
pluginShutdownshutdown;/* Pointer to plugin's shutdown function */
360360
}pageCnvCtx;
361361

362-
constchar*setupPageConverter(pageCnvCtx**result);
362+
constpageCnvCtx*setupPageConverter(void);
363363
#else
364364
/* dummy */
365365
typedefvoid*pageCnvCtx;
@@ -398,7 +398,7 @@ voidget_sock_dir(ClusterInfo *cluster, bool live_check);
398398
/* relfilenode.c */
399399

400400
voidget_pg_database_relfilenode(ClusterInfo*cluster);
401-
constchar*transfer_all_new_dbs(DbInfoArr*olddb_arr,
401+
voidtransfer_all_new_dbs(DbInfoArr*olddb_arr,
402402
DbInfoArr*newdb_arr,char*old_pgdata,char*new_pgdata);
403403

404404

‎contrib/pg_upgrade/relfilenode.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ static void transfer_relfile(pageCnvCtx *pageConverter, FileNameMap *map,
2727
* Responsible for upgrading all database. invokes routines to generate mappings and then
2828
* physically link the databases.
2929
*/
30-
constchar*
30+
void
3131
transfer_all_new_dbs(DbInfoArr*old_db_arr,
3232
DbInfoArr*new_db_arr,char*old_pgdata,char*new_pgdata)
3333
{
3434
intold_dbnum,
3535
new_dbnum;
36-
constchar*msg=NULL;
3736

3837
pg_log(PG_REPORT,"%s user relation files\n",
3938
user_opts.transfer_mode==TRANSFER_MODE_LINK ?"Linking" :"Copying");
@@ -74,7 +73,7 @@ transfer_all_new_dbs(DbInfoArr *old_db_arr,
7473
print_maps(mappings,n_maps,new_db->db_name);
7574

7675
#ifdefPAGE_CONVERSION
77-
msg=setupPageConverter(&pageConverter);
76+
pageConverter=setupPageConverter();
7877
#endif
7978
transfer_single_new_db(pageConverter,mappings,n_maps);
8079

@@ -85,7 +84,7 @@ transfer_all_new_dbs(DbInfoArr *old_db_arr,
8584
end_progress_output();
8685
check_ok();
8786

88-
returnmsg;
87+
return;
8988
}
9089

9190

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp