MCPcopy Create free account
hub / github.com/apache/cloudberry / pg_pwritev

Function pg_pwritev

src/port/pwritev.c:28–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26#include "port/pg_iovec.h"
27
28ssize_t
29pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
30{
31#ifdef HAVE_WRITEV
32 if (iovcnt == 1)
33 return pg_pwrite(fd, iov[0].iov_base, iov[0].iov_len, offset);
34 if (lseek(fd, offset, SEEK_SET) < 0)
35 return -1;
36 return writev(fd, iov, iovcnt);
37#else
38 ssize_t sum = 0;
39 ssize_t part;
40
41 for (int i = 0; i < iovcnt; ++i)
42 {
43 part = pg_pwrite(fd, iov[i].iov_base, iov[i].iov_len, offset);
44 if (part < 0)
45 {
46 if (i == 0)
47 return -1;
48 else
49 return sum;
50 }
51 sum += part;
52 offset += part;
53 if (part < iov[i].iov_len)
54 return sum;
55 }
56 return sum;
57#endif
58}

Callers 1

pg_pwritev_with_retryFunction · 0.85

Calls 1

pg_pwriteFunction · 0.85

Tested by

no test coverage detected