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

Commit0a5f119

Browse files
committed
A toast relid field are no longer needed in pg_upgrade's rel arrays, so
remove them. Also other renaming.
1 parent0eb59c4 commit0a5f119

File tree

4 files changed

+63
-76
lines changed

4 files changed

+63
-76
lines changed

‎contrib/pg_upgrade/check.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ check_new_db_is_empty(void)
362362
}
363363
}
364364

365-
dbarr_free(&new_cluster.dbarr);
365+
free_db_and_rel_infos(&new_cluster.dbarr);
366366

367367
if (found)
368368
pg_log(PG_FATAL,"New cluster is not empty; exiting\n");

‎contrib/pg_upgrade/info.c

Lines changed: 56 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
#include"access/transam.h"
1313

1414

15-
staticvoidget_db_infos(ClusterInfo*cluster);
16-
staticvoidprint_db_arr(ClusterInfo*cluster);
17-
staticvoidprint_rel_arr(RelInfoArr*arr);
18-
staticvoidget_rel_infos(ClusterInfo*cluster,DbInfo*dbinfo);
19-
staticvoidfree_rel_arr(RelInfoArr*rel_arr);
2015
staticvoidcreate_rel_filename_map(constchar*old_data,constchar*new_data,
2116
constDbInfo*old_db,constDbInfo*new_db,
2217
constRelInfo*old_rel,constRelInfo*new_rel,
2318
FileNameMap*map);
19+
staticvoidget_db_infos(ClusterInfo*cluster);
20+
staticvoidget_rel_infos(ClusterInfo*cluster,DbInfo*dbinfo);
21+
staticvoidfree_rel_infos(RelInfoArr*rel_arr);
22+
staticvoidprint_db_infos(DbInfoArr*dbinfo);
23+
staticvoidprint_rel_infos(RelInfoArr*arr);
2424

2525

2626
/*
@@ -111,15 +111,15 @@ create_rel_filename_map(const char *old_data, const char *new_data,
111111

112112

113113
void
114-
print_maps(FileNameMap*maps,intn,constchar*dbName)
114+
print_maps(FileNameMap*maps,intn_maps,constchar*db_name)
115115
{
116116
if (log_opts.debug)
117117
{
118118
intmapnum;
119119

120-
pg_log(PG_DEBUG,"mappings for db %s:\n",dbName);
120+
pg_log(PG_DEBUG,"mappings for db %s:\n",db_name);
121121

122-
for (mapnum=0;mapnum<n;mapnum++)
122+
for (mapnum=0;mapnum<n_maps;mapnum++)
123123
pg_log(PG_DEBUG,"%s.%s: %u to %u\n",
124124
maps[mapnum].nspname,maps[mapnum].relname,
125125
maps[mapnum].old_relfilenode,
@@ -130,6 +130,30 @@ print_maps(FileNameMap *maps, int n, const char *dbName)
130130
}
131131

132132

133+
/*
134+
* get_db_and_rel_infos()
135+
*
136+
* higher level routine to generate dbinfos for the database running
137+
* on the given "port". Assumes that server is already running.
138+
*/
139+
void
140+
get_db_and_rel_infos(ClusterInfo*cluster)
141+
{
142+
intdbnum;
143+
144+
get_db_infos(cluster);
145+
146+
for (dbnum=0;dbnum<cluster->dbarr.ndbs;dbnum++)
147+
get_rel_infos(cluster,&cluster->dbarr.dbs[dbnum]);
148+
149+
if (log_opts.debug)
150+
{
151+
pg_log(PG_DEBUG,"%s databases\n",CLUSTER_NAME(cluster));
152+
print_db_infos(&cluster->dbarr);
153+
}
154+
}
155+
156+
133157
/*
134158
* get_db_infos()
135159
*
@@ -144,9 +168,7 @@ get_db_infos(ClusterInfo *cluster)
144168
intntups;
145169
inttupnum;
146170
DbInfo*dbinfos;
147-
inti_datname;
148-
inti_oid;
149-
inti_spclocation;
171+
inti_datname,i_oid,i_spclocation;
150172

151173
res=executeQueryOrDie(conn,
152174
"SELECT d.oid, d.datname, t.spclocation "
@@ -182,27 +204,6 @@ get_db_infos(ClusterInfo *cluster)
182204
}
183205

184206

185-
/*
186-
* get_db_and_rel_infos()
187-
*
188-
* higher level routine to generate dbinfos for the database running
189-
* on the given "port". Assumes that server is already running.
190-
*/
191-
void
192-
get_db_and_rel_infos(ClusterInfo*cluster)
193-
{
194-
intdbnum;
195-
196-
get_db_infos(cluster);
197-
198-
for (dbnum=0;dbnum<cluster->dbarr.ndbs;dbnum++)
199-
get_rel_infos(cluster,&cluster->dbarr.dbs[dbnum]);
200-
201-
if (log_opts.debug)
202-
print_db_arr(cluster);
203-
}
204-
205-
206207
/*
207208
* get_rel_infos()
208209
*
@@ -224,27 +225,20 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
224225
intnum_rels=0;
225226
char*nspname=NULL;
226227
char*relname=NULL;
227-
inti_spclocation=-1;
228-
inti_nspname=-1;
229-
inti_relname=-1;
230-
inti_oid=-1;
231-
inti_relfilenode=-1;
232-
inti_reltoastrelid=-1;
228+
inti_spclocation,i_nspname,i_relname,i_oid,i_relfilenode;
233229
charquery[QUERY_ALLOC];
234230

235231
/*
236232
* pg_largeobject contains user data that does not appear in pg_dumpall
237233
* --schema-only output, so we have to copy that system table heap and
238-
* index. Ideally we could just get the relfilenode from template1 but
239-
* pg_largeobject_loid_pn_index's relfilenode can change if the table was
240-
* reindexed so we get the relfilenode for each database and upgrade it as
241-
* a normal user table.
242-
* Order by tablespace so we can cache the directory contents efficiently.
234+
* index. We could grab the pg_largeobject oids from template1, but
235+
* it is easy to treat it as a normal table.
236+
* Order by oid so we can join old/new structures efficiently.
243237
*/
244238

245239
snprintf(query,sizeof(query),
246-
"SELECTDISTINCTc.oid, n.nspname, c.relname, "
247-
"c.relfilenode,c.reltoastrelid,t.spclocation "
240+
"SELECT c.oid, n.nspname, c.relname, "
241+
"c.relfilenode, t.spclocation "
248242
"FROM pg_catalog.pg_class c JOIN "
249243
"pg_catalog.pg_namespace n "
250244
"ON c.relnamespace = n.oid "
@@ -256,10 +250,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
256250
"n.nspname = 'pg_catalog' "
257251
"AND relname IN "
258252
" ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) "
259-
"AND relkind IN ('r','t', 'i'%s)"
260-
"GROUP BY c.oid, n.nspname, c.relname, c.relfilenode,"
261-
"c.reltoastrelid, t.spclocation, "
262-
"n.nspname "
253+
"AND relkind IN ('r','t', 'i'%s) "
263254
/* we preserve pg_class.oid so we sort by it to match old/new */
264255
"ORDER BY 1;",
265256
FirstNormalObjectId,
@@ -280,7 +271,6 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
280271
i_nspname=PQfnumber(res,"nspname");
281272
i_relname=PQfnumber(res,"relname");
282273
i_relfilenode=PQfnumber(res,"relfilenode");
283-
i_reltoastrelid=PQfnumber(res,"reltoastrelid");
284274
i_spclocation=PQfnumber(res,"spclocation");
285275

286276
for (relnum=0;relnum<ntups;relnum++)
@@ -297,7 +287,6 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
297287
strlcpy(curr->relname,relname,sizeof(curr->relname));
298288

299289
curr->relfilenode=atooid(PQgetvalue(res,relnum,i_relfilenode));
300-
curr->toastrelid=atooid(PQgetvalue(res,relnum,i_reltoastrelid));
301290

302291
tblspace=PQgetvalue(res,relnum,i_spclocation);
303292
/* if no table tablespace, use the database tablespace */
@@ -314,43 +303,42 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
314303
}
315304

316305

317-
staticvoid
318-
free_rel_arr(RelInfoArr*rel_arr)
319-
{
320-
pg_free(rel_arr->rels);
321-
rel_arr->nrels=0;
322-
}
323-
324-
325306
void
326-
dbarr_free(DbInfoArr*db_arr)
307+
free_db_and_rel_infos(DbInfoArr*db_arr)
327308
{
328309
intdbnum;
329310

330311
for (dbnum=0;dbnum<db_arr->ndbs;dbnum++)
331-
free_rel_arr(&db_arr->dbs[dbnum].rel_arr);
312+
free_rel_infos(&db_arr->dbs[dbnum].rel_arr);
313+
pg_free(db_arr->dbs);
332314
db_arr->ndbs=0;
333315
}
334316

335317

336318
staticvoid
337-
print_db_arr(ClusterInfo*cluster)
319+
free_rel_infos(RelInfoArr*rel_arr)
338320
{
339-
intdbnum;
321+
pg_free(rel_arr->rels);
322+
rel_arr->nrels=0;
323+
}
340324

341-
pg_log(PG_DEBUG,"%s databases\n",CLUSTER_NAME(cluster));
342325

343-
for (dbnum=0;dbnum<cluster->dbarr.ndbs;dbnum++)
326+
staticvoid
327+
print_db_infos(DbInfoArr*db_arr)
328+
{
329+
intdbnum;
330+
331+
for (dbnum=0;dbnum<db_arr->ndbs;dbnum++)
344332
{
345-
pg_log(PG_DEBUG,"Database: %s\n",cluster->dbarr.dbs[dbnum].db_name);
346-
print_rel_arr(&cluster->dbarr.dbs[dbnum].rel_arr);
333+
pg_log(PG_DEBUG,"Database: %s\n",db_arr->dbs[dbnum].db_name);
334+
print_rel_infos(&db_arr->dbs[dbnum].rel_arr);
347335
pg_log(PG_DEBUG,"\n\n");
348336
}
349337
}
350338

351339

352340
staticvoid
353-
print_rel_arr(RelInfoArr*arr)
341+
print_rel_infos(RelInfoArr*arr)
354342
{
355343
intrelnum;
356344

‎contrib/pg_upgrade/pg_upgrade.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ create_new_objects(void)
281281
check_ok();
282282

283283
/* regenerate now that we have objects in the databases */
284-
dbarr_free(&new_cluster.dbarr);
284+
free_db_and_rel_infos(&new_cluster.dbarr);
285285
get_db_and_rel_infos(&new_cluster);
286286

287287
uninstall_support_functions_from_new_cluster();
@@ -428,8 +428,8 @@ cleanup(void)
428428
pg_free(os_info.tablespaces[tblnum]);
429429
pg_free(os_info.tablespaces);
430430

431-
dbarr_free(&old_cluster.dbarr);
432-
dbarr_free(&new_cluster.dbarr);
431+
free_db_and_rel_infos(&old_cluster.dbarr);
432+
free_db_and_rel_infos(&new_cluster.dbarr);
433433
pg_free(log_opts.filename);
434434
pg_free(os_info.user);
435435
pg_free(old_cluster.controldata.lc_collate);

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ typedef struct
6969
charrelname[NAMEDATALEN];/* relation name */
7070
Oidreloid;/* relation oid */
7171
Oidrelfilenode;/* relation relfile node */
72-
Oidtoastrelid;/* oid of the toast relation */
7372
chartablespace[MAXPGPATH];/* relations tablespace path */
7473
}RelInfo;
7574

@@ -331,9 +330,9 @@ FileNameMap *gen_db_file_maps(DbInfo *old_db,
331330
DbInfo*new_db,int*nmaps,constchar*old_pgdata,
332331
constchar*new_pgdata);
333332
voidget_db_and_rel_infos(ClusterInfo*cluster);
334-
voiddbarr_free(DbInfoArr*db_arr);
335-
voidprint_maps(FileNameMap*maps,intn,
336-
constchar*dbName);
333+
voidfree_db_and_rel_infos(DbInfoArr*db_arr);
334+
voidprint_maps(FileNameMap*maps,intn,
335+
constchar*db_name);
337336

338337
/* option.c */
339338

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp