Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6f56b41

Browse files
committed
pg_upgrade: Remove converter plugin facility.
We've not found a use for this so far, and the current need, which is to convert the visibility map to a new format, does not suit the existing design anyway. So just rip it out. Author: Masahiko Sawada, slightly revised by me. Discussion: 20160215211313.GB31273@momjian.us
1 parent a93aec4 commit 6f56b41

File tree

7 files changed

+18
-330
lines changed

7 files changed

+18
-330
lines changed

src/bin/pg_upgrade/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ top_builddir = ../../..
88
include $(top_builddir)/src/Makefile.global
99

1010
OBJS = check.o controldata.o dump.o exec.o file.o function.o info.o \
11-
option.o page.o parallel.o pg_upgrade.o relfilenode.o server.o \
11+
option.o parallel.o pg_upgrade.o relfilenode.o server.o \
1212
tablespace.o util.o version.o $(WIN32RES)
1313

1414
override CPPFLAGS := -DDLSUFFIX=\"$(DLSUFFIX)\" -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)

src/bin/pg_upgrade/check.c

-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ check_and_dump_old_cluster(bool live_check)
8080
if (!live_check)
8181
start_postmaster(&old_cluster, true);
8282

83-
get_pg_database_relfilenode(&old_cluster);
84-
8583
/* Extract a list of databases and tables from the old cluster */
8684
get_db_and_rel_infos(&old_cluster);
8785

src/bin/pg_upgrade/file.c

+5-72
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,13 @@ static int win32_pghardlink(const char *src, const char *dst);
2323

2424

2525
/*
26-
* copyAndUpdateFile()
26+
* copyFile()
2727
*
28-
* Copies a relation file from src to dst. If pageConverter is non-NULL, this function
29-
* uses that pageConverter to do a page-by-page conversion.
28+
* Copies a relation file from src to dst.
3029
*/
3130
const char *
32-
copyAndUpdateFile(pageCnvCtx *pageConverter,
33-
const char *src, const char *dst, bool force)
31+
copyFile(const char *src, const char *dst, bool force)
3432
{
35-
if (pageConverter == NULL)
36-
{
3733
#ifndef WIN32
3834
if (copy_file(src, dst, force) == -1)
3935
#else
@@ -42,70 +38,11 @@ copyAndUpdateFile(pageCnvCtx *pageConverter,
4238
return getErrorText();
4339
else
4440
return NULL;
45-
}
46-
else
47-
{
48-
/*
49-
* We have a pageConverter object - that implies that the
50-
* PageLayoutVersion differs between the two clusters so we have to
51-
* perform a page-by-page conversion.
52-
*
53-
* If the pageConverter can convert the entire file at once, invoke
54-
* that plugin function, otherwise, read each page in the relation
55-
* file and call the convertPage plugin function.
56-
*/
57-
58-
#ifdef PAGE_CONVERSION
59-
if (pageConverter->convertFile)
60-
return pageConverter->convertFile(pageConverter->pluginData,
61-
dst, src);
62-
else
63-
#endif
64-
{
65-
int src_fd;
66-
int dstfd;
67-
char buf[BLCKSZ];
68-
ssize_t bytesRead;
69-
const char *msg = NULL;
70-
71-
if ((src_fd = open(src, O_RDONLY, 0)) < 0)
72-
return "could not open source file";
73-
74-
if ((dstfd = open(dst, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) < 0)
75-
{
76-
close(src_fd);
77-
return "could not create destination file";
78-
}
79-
80-
while ((bytesRead = read(src_fd, buf, BLCKSZ)) == BLCKSZ)
81-
{
82-
#ifdef PAGE_CONVERSION
83-
if ((msg = pageConverter->convertPage(pageConverter->pluginData, buf, buf)) != NULL)
84-
break;
85-
#endif
86-
if (write(dstfd, buf, BLCKSZ) != BLCKSZ)
87-
{
88-
msg = "could not write new page to destination";
89-
break;
90-
}
91-
}
92-
93-
close(src_fd);
94-
close(dstfd);
95-
96-
if (msg)
97-
return msg;
98-
else if (bytesRead != 0)
99-
return "found partial page in source file";
100-
else
101-
return NULL;
102-
}
103-
}
10441
}
10542

10643

10744
/*
108-
* linkAndUpdateFile()
45+
* linkFile()
10946
*
11047
* Creates a hard link between the given relation files. We use
11148
* this function to perform a true in-place update. If the on-disk
@@ -114,12 +51,8 @@ copyAndUpdateFile(pageCnvCtx *pageConverter,
11451
* instead of copying the data from the old cluster to the new cluster.
11552
*/
11653
const char *
117-
linkAndUpdateFile(pageCnvCtx *pageConverter,
118-
const char *src, const char *dst)
54+
linkFile(const char *src, const char *dst)
11955
{
120-
if (pageConverter != NULL)
121-
return "Cannot in-place update this cluster, page-by-page conversion is required";
122-
12356
if (pg_link_file(src, dst) == -1)
12457
return getErrorText();
12558
else

src/bin/pg_upgrade/page.c

-164
This file was deleted.

src/bin/pg_upgrade/pg_upgrade.c

-2
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ prepare_new_cluster(void)
260260
new_cluster.bindir, cluster_conn_opts(&new_cluster),
261261
log_opts.verbose ? "--verbose" : "");
262262
check_ok();
263-
264-
get_pg_database_relfilenode(&new_cluster);
265263
}
266264

267265

src/bin/pg_upgrade/pg_upgrade.h

+2-35
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ typedef struct
269269
uint32 major_version; /* PG_VERSION of cluster */
270270
char major_version_str[64]; /* string PG_VERSION of cluster */
271271
uint32 bin_version; /* version returned from pg_ctl */
272-
Oid pg_database_oid; /* OID of pg_database relation */
273272
const char *tablespace_suffix; /* directory specification */
274273
} ClusterInfo;
275274

@@ -364,40 +363,8 @@ bool pid_lock_file_exists(const char *datadir);
364363

365364
/* file.c */
366365

367-
#ifdef PAGE_CONVERSION
368-
typedef const char *(*pluginStartup) (uint16 migratorVersion,
369-
uint16 *pluginVersion, uint16 newPageVersion,
370-
uint16 oldPageVersion, void **pluginData);
371-
typedef const char *(*pluginConvertFile) (void *pluginData,
372-
const char *dstName, const char *srcName);
373-
typedef const char *(*pluginConvertPage) (void *pluginData,
374-
const char *dstPage, const char *srcPage);
375-
typedef const char *(*pluginShutdown) (void *pluginData);
376-
377-
typedef struct
378-
{
379-
uint16 oldPageVersion; /* Page layout version of the old cluster */
380-
uint16 newPageVersion; /* Page layout version of the new cluster */
381-
uint16 pluginVersion; /* API version of converter plugin */
382-
void *pluginData; /* Plugin data (set by plugin) */
383-
pluginStartup startup; /* Pointer to plugin's startup function */
384-
pluginConvertFile convertFile; /* Pointer to plugin's file converter
385-
* function */
386-
pluginConvertPage convertPage; /* Pointer to plugin's page converter
387-
* function */
388-
pluginShutdown shutdown; /* Pointer to plugin's shutdown function */
389-
} pageCnvCtx;
390-
391-
const pageCnvCtx *setupPageConverter(void);
392-
#else
393-
/* dummy */
394-
typedef void *pageCnvCtx;
395-
#endif
396-
397-
const char *copyAndUpdateFile(pageCnvCtx *pageConverter, const char *src,
398-
const char *dst, bool force);
399-
const char *linkAndUpdateFile(pageCnvCtx *pageConverter, const char *src,
400-
const char *dst);
366+
const char *copyFile(const char *src, const char *dst, bool force);
367+
const char *linkFile(const char *src, const char *dst);
401368

402369
void check_hard_link(void);
403370
FILE *fopen_priv(const char *path, const char *mode);

0 commit comments

Comments
 (0)