@@ -23,17 +23,13 @@ static int win32_pghardlink(const char *src, const char *dst);
23
23
24
24
25
25
/*
26
- * copyAndUpdateFile ()
26
+ * copyFile ()
27
27
*
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.
30
29
*/
31
30
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 )
34
32
{
35
- if (pageConverter == NULL )
36
- {
37
33
#ifndef WIN32
38
34
if (copy_file (src , dst , force ) == -1 )
39
35
#else
@@ -42,70 +38,11 @@ copyAndUpdateFile(pageCnvCtx *pageConverter,
42
38
return getErrorText ();
43
39
else
44
40
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
- }
104
41
}
105
42
106
43
107
44
/*
108
- * linkAndUpdateFile ()
45
+ * linkFile ()
109
46
*
110
47
* Creates a hard link between the given relation files. We use
111
48
* this function to perform a true in-place update. If the on-disk
@@ -114,12 +51,8 @@ copyAndUpdateFile(pageCnvCtx *pageConverter,
114
51
* instead of copying the data from the old cluster to the new cluster.
115
52
*/
116
53
const char *
117
- linkAndUpdateFile (pageCnvCtx * pageConverter ,
118
- const char * src , const char * dst )
54
+ linkFile (const char * src , const char * dst )
119
55
{
120
- if (pageConverter != NULL )
121
- return "Cannot in-place update this cluster, page-by-page conversion is required" ;
122
-
123
56
if (pg_link_file (src , dst ) == -1 )
124
57
return getErrorText ();
125
58
else
0 commit comments