@@ -933,7 +933,6 @@ fillRelFileMapSeq(Archive *fout, int *nrels,
933
933
int i_tablespace ;
934
934
int i_data_directory ;
935
935
int i_tablespace_location ;
936
- int i_relpersistence ;
937
936
const char * data_directory ;
938
937
Oid dboid ;
939
938
int i ;
@@ -991,7 +990,6 @@ fillRelFileMapSeq(Archive *fout, int *nrels,
991
990
i_relname = PQfnumber (res , "relname" );
992
991
i_tablespace = PQfnumber (res , "reltablespace" );
993
992
i_tablespace_location = PQfnumber (res , "pg_tablespace_location" );
994
- i_relpersistence = PQfnumber (res , "relpersistence" );
995
993
map = pg_malloc (sizeof (RelFileMap ) * ntups );
996
994
997
995
for (i = 0 ; i < ntups ; i ++ )
@@ -1003,10 +1001,6 @@ fillRelFileMapSeq(Archive *fout, int *nrels,
1003
1001
cur -> relfilenode = atooid (PQgetvalue (res , i , i_relfilenode ));
1004
1002
cur -> relname = strdup (PQgetvalue (res , i , i_relname ));
1005
1003
1006
- /* 'c' is for RELPERSISTENCE_CONSTANT. */
1007
- // if (*PQgetvalue(res, i, i_relpersistence) != 'c')
1008
- // exit_horribly(NULL, "Cannot transfer non-constant relation '%s' \n", cur->relname);
1009
-
1010
1004
if (atoi (PQgetvalue (res , i , i_tablespace )) == 0 )
1011
1005
{
1012
1006
cur -> datadir = strdup (data_directory );
@@ -1128,6 +1122,7 @@ fillRelFileMapToast(Archive *fout, RelFileMap *map,
1128
1122
static int
1129
1123
copy_file (const char * srcfile , const char * dstfile , bool create_file )
1130
1124
{
1125
+ #ifndef WIN32
1131
1126
#define COPY_BUF_SIZE (50 * BLCKSZ)
1132
1127
1133
1128
int src_fd ;
@@ -1204,7 +1199,40 @@ copy_file(const char *srcfile, const char *dstfile, bool create_file)
1204
1199
errno = save_errno ;
1205
1200
1206
1201
return ret ;
1202
+ #else /* WIN32 */
1203
+
1204
+ /* Last argument of Windows CopyFile func is bFailIfExists.
1205
+ * If we're asked to create_file, it should not exist. Otherwise, we
1206
+ * want to rewrite it.
1207
+ */
1208
+ if (CopyFile (src , dst , create_file ) == 0 )
1209
+ {
1210
+ _dosmaperr (GetLastError ());
1211
+ pg_fatal ("error while copying relation \"%s.%s\" (\"%s\" to \"%s\"): %s\n" ,
1212
+ schemaName , relName , src , dst , strerror (errno ));
1213
+ }
1214
+
1215
+ #endif /* WIN32 */
1216
+ }
1217
+
1218
+ #ifdef WIN32
1219
+ /* implementation of pg_link_file() on Windows */
1220
+ static int
1221
+ win32_pghardlink (const char * src , const char * dst )
1222
+ {
1223
+ /*
1224
+ * CreateHardLinkA returns zero for failure
1225
+ * http://msdn.microsoft.com/en-us/library/aa363860(VS.85).aspx
1226
+ */
1227
+ if (CreateHardLinkA (dst , src , NULL ) == 0 )
1228
+ {
1229
+ _dosmaperr (GetLastError ());
1230
+ return -1 ;
1231
+ }
1232
+ else
1233
+ return 0 ;
1207
1234
}
1235
+ #endif
1208
1236
1209
1237
/*
1210
1238
* Transfer relation fork, specified by type_suffix, to transfer subdir.
@@ -1306,12 +1334,11 @@ transfer_relfile(RelFileMap *map, const char *type_suffix,
1306
1334
}
1307
1335
else
1308
1336
{
1309
- if (link (db_file , transfer_file ) != 0 )
1337
+ if (pg_link_file (db_file , transfer_file ) != 0 )
1310
1338
{
1311
1339
exit_horribly (NULL , "cannot dump file (link mode) %s to %s : %s \n" ,
1312
1340
db_file , transfer_file , strerror (errno ));
1313
1341
}
1314
-
1315
1342
}
1316
1343
}
1317
1344
else
@@ -1354,7 +1381,6 @@ transferCheckControlData(Archive *fout, const char *transfer_dir, bool isRestore
1354
1381
PQExpBuffer q = createPQExpBuffer ();
1355
1382
PGresult * res ;
1356
1383
const char * serverInfo ;
1357
- size_t serverInfoLen = 0 ;
1358
1384
1359
1385
appendPQExpBuffer (q , "SELECT pg_control_init();" );
1360
1386
res = ExecuteSqlQueryForSingleRow (fout , q -> data );
0 commit comments