Commit df10ac62 authored by Thomas Munro's avatar Thomas Munro

Don't use elog() in src/port/pwrite.c.

Nothing broke because of this oversight yet, but it would fail to link
if we tried to use pg_pwrite() in frontend code on a system that lacks
pwrite().  Use an assertion instead.  Also pgindent while here.

Discussion: https://postgr.es/m/CA%2BhUKGL57RvoQsS35TVPnQoPYqbtBixsdRhynB8NpcUKpHTTtg%40mail.gmail.com
parent ee1b38f6
...@@ -70,8 +70,8 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset) ...@@ -70,8 +70,8 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
return -1; return -1;
return writev(fd, iov, iovcnt); return writev(fd, iov, iovcnt);
#else #else
ssize_t sum = 0; ssize_t sum = 0;
ssize_t part; ssize_t part;
for (int i = 0; i < iovcnt; ++i) for (int i = 0; i < iovcnt; ++i)
{ {
...@@ -137,14 +137,14 @@ pg_pwritev_with_retry(int fd, const struct iovec *iov, int iovcnt, off_t offset) ...@@ -137,14 +137,14 @@ pg_pwritev_with_retry(int fd, const struct iovec *iov, int iovcnt, off_t offset)
/* Are they all done? */ /* Are they all done? */
if (iovcnt == 0) if (iovcnt == 0)
{ {
if (part > 0) /* We don't expect the kernel to write more than requested. */
elog(ERROR, "unexpectedly wrote more than requested"); Assert(part == 0);
break; break;
} }
/* /*
* Move whatever's left to the front of our mutable copy and adjust the * Move whatever's left to the front of our mutable copy and adjust
* leading iovec. * the leading iovec.
*/ */
Assert(iovcnt > 0); Assert(iovcnt > 0);
memmove(iov_copy, iov, sizeof(*iov) * iovcnt); memmove(iov_copy, iov, sizeof(*iov) * iovcnt);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment