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

Commitd5ce481

Browse files
committed
add windows support
1 parentca99703 commitd5ce481

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

‎src/bin/pg_dump/pg_backup.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ typedef struct RelFileMap
306306
Oidreltoastrelid;
307307
}RelFileMap;
308308

309+
#ifndefWIN32
310+
#definepg_link_filelink
311+
#else
312+
#definepg_link_filewin32_pghardlink
313+
#endif
314+
309315
externRelFileMap*fillRelFileMap(Archive*fout,int*nrels,int*ntoastrels,
310316
constchar*dbname,constchar*tblname);
311317
externRelFileMap*fillRelFileMapSeq(Archive*fout,int*nrels,

‎src/bin/pg_dump/pg_backup_db.c

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,6 @@ fillRelFileMapSeq(Archive *fout, int *nrels,
933933
inti_tablespace;
934934
inti_data_directory;
935935
inti_tablespace_location;
936-
inti_relpersistence;
937936
constchar*data_directory;
938937
Oiddboid;
939938
inti;
@@ -991,7 +990,6 @@ fillRelFileMapSeq(Archive *fout, int *nrels,
991990
i_relname=PQfnumber(res,"relname");
992991
i_tablespace=PQfnumber(res,"reltablespace");
993992
i_tablespace_location=PQfnumber(res,"pg_tablespace_location");
994-
i_relpersistence=PQfnumber(res,"relpersistence");
995993
map=pg_malloc(sizeof(RelFileMap)*ntups);
996994

997995
for (i=0;i<ntups;i++)
@@ -1003,10 +1001,6 @@ fillRelFileMapSeq(Archive *fout, int *nrels,
10031001
cur->relfilenode=atooid(PQgetvalue(res,i,i_relfilenode));
10041002
cur->relname=strdup(PQgetvalue(res,i,i_relname));
10051003

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-
10101004
if (atoi(PQgetvalue(res,i,i_tablespace))==0)
10111005
{
10121006
cur->datadir=strdup(data_directory);
@@ -1128,6 +1122,7 @@ fillRelFileMapToast(Archive *fout, RelFileMap *map,
11281122
staticint
11291123
copy_file(constchar*srcfile,constchar*dstfile,boolcreate_file)
11301124
{
1125+
#ifndefWIN32
11311126
#defineCOPY_BUF_SIZE (50 * BLCKSZ)
11321127

11331128
intsrc_fd;
@@ -1204,7 +1199,40 @@ copy_file(const char *srcfile, const char *dstfile, bool create_file)
12041199
errno=save_errno;
12051200

12061201
returnret;
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+
#ifdefWIN32
1219+
/* implementation of pg_link_file() on Windows */
1220+
staticint
1221+
win32_pghardlink(constchar*src,constchar*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+
return0;
12071234
}
1235+
#endif
12081236

12091237
/*
12101238
* Transfer relation fork, specified by type_suffix, to transfer subdir.
@@ -1306,12 +1334,11 @@ transfer_relfile(RelFileMap *map, const char *type_suffix,
13061334
}
13071335
else
13081336
{
1309-
if (link(db_file,transfer_file)!=0)
1337+
if (pg_link_file(db_file,transfer_file)!=0)
13101338
{
13111339
exit_horribly(NULL,"cannot dump file (link mode) %s to %s : %s \n",
13121340
db_file,transfer_file,strerror(errno));
13131341
}
1314-
13151342
}
13161343
}
13171344
else
@@ -1354,7 +1381,6 @@ transferCheckControlData(Archive *fout, const char *transfer_dir, bool isRestore
13541381
PQExpBufferq=createPQExpBuffer();
13551382
PGresult*res;
13561383
constchar*serverInfo;
1357-
size_tserverInfoLen=0;
13581384

13591385
appendPQExpBuffer(q,"SELECT pg_control_init();");
13601386
res=ExecuteSqlQueryForSingleRow(fout,q->data);

‎src/bin/pg_dump/pg_dump.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18092,7 +18092,6 @@ dumpStatistic(Archive* fout, DumpOptions* dopt, TableInfo *tbinfo)
1809218092
intnfields;
1809318093
intfield;
1809418094
inti_starelid;
18095-
inti_staattnum;
1809618095

1809718096
/* Make sure we are in proper schema */
1809818097
selectSourceSchema(fout, "pg_catalog");
@@ -18148,7 +18147,6 @@ dumpStatistic(Archive* fout, DumpOptions* dopt, TableInfo *tbinfo)
1814818147
nfields = PQnfields(res);
1814918148

1815018149
i_starelid = PQfnumber(res, "starelid");
18151-
i_staattnum = PQfnumber(res, "staattnum");
1815218150

1815318151
for (tuple = 0; tuple < PQntuples(res); tuple++)
1815418152
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp