git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ee1b38f)
Don't use elog() in src/port/pwrite.c.
2021年1月13日 06:11:09 +0000 (19:11 +1300)
2021年1月13日 06:34:14 +0000 (19:34 +1300)
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


diff --git a/src/port/pwrite.c b/src/port/pwrite.c
index e029f44bc0ce030f1ca87403aa674bacfdc1b268..a98343ec05b70614befe29c952dbc1593b500d00 100644 (file)
--- a/src/port/pwrite.c
+++ b/src/port/pwrite.c
@@ -70,8 +70,8 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
return -1;
return writev(fd, iov, iovcnt);
#else
- ssize_t sum = 0;
- ssize_t part;
+ ssize_t sum = 0;
+ ssize_t part;
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)
/* Are they all done? */
if (iovcnt == 0)
{
- if (part > 0)
- elog(ERROR, "unexpectedly wrote more than requested");
+ /* We don't expect the kernel to write more than requested. */
+ Assert(part == 0);
break;
}
/*
- * Move whatever's left to the front of our mutable copy and adjust the
- * leading iovec.
+ * Move whatever's left to the front of our mutable copy and adjust
+ * the leading iovec.
*/
Assert(iovcnt > 0);
memmove(iov_copy, iov, sizeof(*iov) * iovcnt);
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /