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

Commit67c9e44

Browse files
committed
Furter pg_upgrade optimizations to reduce function call argument count.
1 parent6e6bee9 commit67c9e44

File tree

5 files changed

+20
-24
lines changed

5 files changed

+20
-24
lines changed

‎contrib/pg_upgrade/check.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ void
209209
check_cluster_versions(void)
210210
{
211211
/* get old and new cluster versions */
212-
old_cluster.major_version=get_major_server_version(&old_cluster,&old_cluster.major_version_str);
213-
new_cluster.major_version=get_major_server_version(&new_cluster,&new_cluster.major_version_str);
212+
old_cluster.major_version=get_major_server_version(&old_cluster);
213+
new_cluster.major_version=get_major_server_version(&new_cluster);
214214

215215
/* We allow upgrades from/to the same major version for alpha/beta upgrades */
216216

‎contrib/pg_upgrade/info.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
staticvoidget_db_infos(ClusterInfo*cluster);
1616
staticvoiddbarr_print(ClusterInfo*cluster);
1717
staticvoidrelarr_print(RelInfoArr*arr);
18-
staticvoidget_rel_infos(ClusterInfo*cluster,constDbInfo*dbinfo,
19-
RelInfoArr*relarr);
18+
staticvoidget_rel_infos(ClusterInfo*cluster,constintdbnum);
2019
staticvoidrelarr_free(RelInfoArr*rel_arr);
2120
staticvoidmap_rel(constRelInfo*oldrel,
2221
constRelInfo*newrel,constDbInfo*old_db,
@@ -272,8 +271,7 @@ get_db_and_rel_infos(ClusterInfo *cluster)
272271
get_db_infos(cluster);
273272

274273
for (dbnum=0;dbnum<cluster->dbarr.ndbs;dbnum++)
275-
get_rel_infos(cluster,&cluster->dbarr.dbs[dbnum],
276-
&cluster->dbarr.dbs[dbnum].rel_arr);
274+
get_rel_infos(cluster,dbnum);
277275

278276
if (log_opts.debug)
279277
dbarr_print(cluster);
@@ -290,9 +288,10 @@ get_db_and_rel_infos(ClusterInfo *cluster)
290288
* FirstNormalObjectId belongs to the user
291289
*/
292290
staticvoid
293-
get_rel_infos(ClusterInfo*cluster,constDbInfo*dbinfo,RelInfoArr*relarr)
291+
get_rel_infos(ClusterInfo*cluster,constintdbnum)
294292
{
295-
PGconn*conn=connectToServer(cluster,dbinfo->db_name);
293+
PGconn*conn=connectToServer(cluster,
294+
cluster->dbarr.dbs[dbnum].db_name);
296295
PGresult*res;
297296
RelInfo*relinfos;
298297
intntups;
@@ -374,16 +373,16 @@ get_rel_infos(ClusterInfo *cluster, const DbInfo *dbinfo, RelInfoArr *relarr)
374373
tblspace=PQgetvalue(res,relnum,i_spclocation);
375374
/* if no table tablespace, use the database tablespace */
376375
if (strlen(tblspace)==0)
377-
tblspace=dbinfo->db_tblspace;
376+
tblspace=cluster->dbarr.dbs[dbnum].db_tblspace;
378377
strlcpy(curr->tablespace,tblspace,sizeof(curr->tablespace));
379378
}
380379
PQclear(res);
381380

382381
PQfinish(conn);
383382

384-
relarr->rels=relinfos;
385-
relarr->nrels=num_rels;
386-
relarr->last_relname_lookup=0;
383+
cluster->dbarr.dbs[dbnum].rel_arr.rels=relinfos;
384+
cluster->dbarr.dbs[dbnum].rel_arr.nrels=num_rels;
385+
cluster->dbarr.dbs[dbnum].rel_arr.last_relname_lookup=0;
387386
}
388387

389388

‎contrib/pg_upgrade/pg_upgrade.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,6 @@ cleanup(void)
384384
dbarr_free(&new_cluster.dbarr);
385385
pg_free(log_opts.filename);
386386
pg_free(os_info.user);
387-
pg_free(old_cluster.major_version_str);
388-
pg_free(new_cluster.major_version_str);
389387
pg_free(old_cluster.controldata.lc_collate);
390388
pg_free(new_cluster.controldata.lc_collate);
391389
pg_free(old_cluster.controldata.lc_ctype);

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ typedef struct
179179
char*bindir;/* pathname for cluster's executable directory */
180180
unsigned shortport;/* port number where postmaster is waiting */
181181
uint32major_version;/* PG_VERSION of cluster */
182-
char*major_version_str;/* string PG_VERSION of cluster */
182+
charmajor_version_str[64];/* string PG_VERSION of cluster */
183183
Oidpg_database_oid;/* OID of pg_database relation */
184184
char*libpath;/* pathname for cluster's pkglibdir */
185185
char*tablespace_suffix;/* directory specification */
@@ -357,7 +357,7 @@ PGresult *executeQueryOrDie(PGconn *conn, const char *fmt,...);
357357

358358
voidstart_postmaster(ClusterInfo*cluster,boolquiet);
359359
voidstop_postmaster(boolfast,boolquiet);
360-
uint32get_major_server_version(ClusterInfo*cluster,char**verstr);
360+
uint32get_major_server_version(ClusterInfo*cluster);
361361
voidcheck_for_libpq_envvars(void);
362362

363363

‎contrib/pg_upgrade/server.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,21 @@ get_postmaster_pid(const char *datadir)
129129
* is retrieved by reading the PG_VERSION file.
130130
*/
131131
uint32
132-
get_major_server_version(ClusterInfo*cluster,char**verstr)
132+
get_major_server_version(ClusterInfo*cluster)
133133
{
134134
constchar*datadir=cluster->pgdata;
135135
FILE*version_fd;
136-
charver_file[MAXPGPATH];
136+
charver_filename[MAXPGPATH];
137137
intinteger_version=0;
138138
intfractional_version=0;
139139

140-
*verstr=pg_malloc(64);
141-
142-
snprintf(ver_file,sizeof(ver_file),"%s/PG_VERSION",datadir);
143-
if ((version_fd=fopen(ver_file,"r"))==NULL)
140+
snprintf(ver_filename,sizeof(ver_filename),"%s/PG_VERSION",datadir);
141+
if ((version_fd=fopen(ver_filename,"r"))==NULL)
144142
return0;
145143

146-
if (fscanf(version_fd,"%63s",*verstr)==0||
147-
sscanf(*verstr,"%d.%d",&integer_version,&fractional_version)!=2)
144+
if (fscanf(version_fd,"%63s",cluster->major_version_str)==0||
145+
sscanf(cluster->major_version_str,"%d.%d",&integer_version,
146+
&fractional_version)!=2)
148147
{
149148
pg_log(PG_FATAL,"could not get version from %s\n",datadir);
150149
fclose(version_fd);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp