mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Restore pg_pread and friends.
Commitscf112c12
anda0dc8271
were a little too hasty in getting rid of the pg_ prefixes where we use pread(), pwrite() and vectored variants. We dropped support for ancient Unixes where we needed to use lseek() to implement replacements for those, but it turns out that Windows also changes the current position even when you pass in an offset to ReadFile() and WriteFile() if the file handle is synchronous, despite its documentation saying otherwise. Switching to asynchronous file handles would fix that, but have other complications. For now let's just put back the pg_ prefix and add some comments to highlight the non-standard side-effect, which we can now describe as Windows-only. Reported-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> Discussion: https://postgr.es/m/20220923202439.GA1156054%40nathanxps13
This commit is contained in:
@ -312,10 +312,10 @@ test_sync(int writes_per_op)
|
||||
for (ops = 0; alarm_triggered == false; ops++)
|
||||
{
|
||||
for (writes = 0; writes < writes_per_op; writes++)
|
||||
if (pwrite(tmpfile,
|
||||
buf,
|
||||
XLOG_BLCKSZ,
|
||||
writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
|
||||
if (pg_pwrite(tmpfile,
|
||||
buf,
|
||||
XLOG_BLCKSZ,
|
||||
writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
|
||||
die("write failed");
|
||||
}
|
||||
STOP_TIMER;
|
||||
@ -337,10 +337,10 @@ test_sync(int writes_per_op)
|
||||
for (ops = 0; alarm_triggered == false; ops++)
|
||||
{
|
||||
for (writes = 0; writes < writes_per_op; writes++)
|
||||
if (pwrite(tmpfile,
|
||||
buf,
|
||||
XLOG_BLCKSZ,
|
||||
writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
|
||||
if (pg_pwrite(tmpfile,
|
||||
buf,
|
||||
XLOG_BLCKSZ,
|
||||
writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
|
||||
die("write failed");
|
||||
fdatasync(tmpfile);
|
||||
}
|
||||
@ -359,10 +359,10 @@ test_sync(int writes_per_op)
|
||||
for (ops = 0; alarm_triggered == false; ops++)
|
||||
{
|
||||
for (writes = 0; writes < writes_per_op; writes++)
|
||||
if (pwrite(tmpfile,
|
||||
buf,
|
||||
XLOG_BLCKSZ,
|
||||
writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
|
||||
if (pg_pwrite(tmpfile,
|
||||
buf,
|
||||
XLOG_BLCKSZ,
|
||||
writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
|
||||
die("write failed");
|
||||
if (fsync(tmpfile) != 0)
|
||||
die("fsync failed");
|
||||
@ -383,10 +383,10 @@ test_sync(int writes_per_op)
|
||||
for (ops = 0; alarm_triggered == false; ops++)
|
||||
{
|
||||
for (writes = 0; writes < writes_per_op; writes++)
|
||||
if (pwrite(tmpfile,
|
||||
buf,
|
||||
XLOG_BLCKSZ,
|
||||
writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
|
||||
if (pg_pwrite(tmpfile,
|
||||
buf,
|
||||
XLOG_BLCKSZ,
|
||||
writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
|
||||
die("write failed");
|
||||
if (pg_fsync_writethrough(tmpfile) != 0)
|
||||
die("fsync failed");
|
||||
@ -415,10 +415,10 @@ test_sync(int writes_per_op)
|
||||
for (ops = 0; alarm_triggered == false; ops++)
|
||||
{
|
||||
for (writes = 0; writes < writes_per_op; writes++)
|
||||
if (pwrite(tmpfile,
|
||||
buf,
|
||||
XLOG_BLCKSZ,
|
||||
writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
|
||||
if (pg_pwrite(tmpfile,
|
||||
buf,
|
||||
XLOG_BLCKSZ,
|
||||
writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
|
||||
|
||||
/*
|
||||
* This can generate write failures if the filesystem has
|
||||
@ -480,10 +480,10 @@ test_open_sync(const char *msg, int writes_size)
|
||||
for (ops = 0; alarm_triggered == false; ops++)
|
||||
{
|
||||
for (writes = 0; writes < 16 / writes_size; writes++)
|
||||
if (pwrite(tmpfile,
|
||||
buf,
|
||||
writes_size * 1024,
|
||||
writes * writes_size * 1024) !=
|
||||
if (pg_pwrite(tmpfile,
|
||||
buf,
|
||||
writes_size * 1024,
|
||||
writes * writes_size * 1024) !=
|
||||
writes_size * 1024)
|
||||
die("write failed");
|
||||
}
|
||||
@ -582,7 +582,7 @@ test_non_sync(void)
|
||||
START_TIMER;
|
||||
for (ops = 0; alarm_triggered == false; ops++)
|
||||
{
|
||||
if (pwrite(tmpfile, buf, XLOG_BLCKSZ, 0) != XLOG_BLCKSZ)
|
||||
if (pg_pwrite(tmpfile, buf, XLOG_BLCKSZ, 0) != XLOG_BLCKSZ)
|
||||
die("write failed");
|
||||
}
|
||||
STOP_TIMER;
|
||||
|
Reference in New Issue
Block a user