Index: genfile.c =================================================================== RCS file: /projects/pgadmin-tools/support/genfile.c,v retrieving revision 1.3 retrieving revision 1.4 diff -Lsupport/genfile.c -Lsupport/genfile.c -u -w -r1.3 -r1.4 --- support/genfile.c +++ support/genfile.c @@ -24,6 +24,21 @@ #include "catalog/pg_type.h" #include "funcapi.h" + +#ifdef WIN32 + +#ifdef rename +#undef rename +#endif +#define rename _rename + +#ifdef unlink +#undef unlink +#endif +#define unlink _unlink + +#endif + extern DLLIMPORT char *DataDir; extern DLLIMPORT char *Log_directory; extern DLLIMPORT char *Log_filename_prefix; @@ -261,7 +276,7 @@ { count = fwrite(VARDATA(data), 1, VARSIZE(data) - VARHDRSZ, f); - if (count != VARSIZE(data)) + if (count != VARSIZE(data) - VARHDRSZ) ereport(ERROR, (errcode_for_file_access(), errmsg("error writing file %s: %m", filename))); @@ -279,6 +294,9 @@ requireSuperuser(); + if (PG_ARGISNULL(0) || PG_ARGISNULL(1)) + PG_RETURN_NULL(); + fn1=absClusterPath(PG_GETARG_TEXT_P(0), false); fn2=absClusterPath(PG_GETARG_TEXT_P(1), false); if (PG_ARGISNULL(2)) @@ -342,8 +360,11 @@ } } } - if (rename(fn1, fn2) != 0) + else if (rename(fn1, fn2) != 0) { + ereport(WARNING, + (errcode_for_file_access(), + errmsg("renaming %s to %s %m", fn1, fn2))); ereport(ERROR, (errcode_for_file_access(), errmsg("could not rename %s to %s: %m", fn1, fn2)));