Ignore not-yet-defined Portals in pg_cursors view.
[pgsql.git] / src / port / win32fdatasync.c
blob1cf9c15955153f1dbef2228616b6e7d9c9e1c4d3
1 /*-------------------------------------------------------------------------
3 * win32fdatasync.c
4 * Win32 fdatasync() replacement
7 * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
9 * src/port/win32fdatasync.c
11 *-------------------------------------------------------------------------
14 #ifdef FRONTEND
15 #include "postgres_fe.h"
16 #else
17 #include "postgres.h"
18 #endif
20 #include "port/win32ntdll.h"
22 int
23 fdatasync(int fd)
25 IO_STATUS_BLOCK iosb;
26 NTSTATUS status;
27 HANDLE handle;
29 handle = (HANDLE) _get_osfhandle(fd);
30 if (handle == INVALID_HANDLE_VALUE)
32 errno = EBADF;
33 return -1;
36 if (initialize_ntdll() < 0)
37 return -1;
39 memset(&iosb, 0, sizeof(iosb));
40 status = pg_NtFlushBuffersFileEx(handle,
41 FLUSH_FLAGS_FILE_DATA_SYNC_ONLY,
42 NULL,
44 &iosb);
46 if (NT_SUCCESS(status))
47 return 0;
49 _dosmaperr(pg_RtlNtStatusToDosError(status));
50 return -1;