diff options
| author | vvvv <[email protected]> | 2024-11-07 12:29:36 +0300 |
|---|---|---|
| committer | vvvv <[email protected]> | 2024-11-07 13:49:47 +0300 |
| commit | d4c258e9431675bab6745c8638df6e3dfd4dca6b (patch) | |
| tree | b5efcfa11351152a4c872fccaea35749141c0b11 /yql/essentials/parser/pg_wrapper/postgresql/src/port/pwritev.c | |
| parent | 13a4f274caef5cfdaf0263b24e4d6bdd5521472b (diff) | |
Moved other yql/essentials libs YQL-19206
init
commit_hash:7d4c435602078407bbf20dd3c32f9c90d2bbcbc0
Diffstat (limited to 'yql/essentials/parser/pg_wrapper/postgresql/src/port/pwritev.c')
| -rw-r--r-- | yql/essentials/parser/pg_wrapper/postgresql/src/port/pwritev.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/yql/essentials/parser/pg_wrapper/postgresql/src/port/pwritev.c b/yql/essentials/parser/pg_wrapper/postgresql/src/port/pwritev.c new file mode 100644 index 00000000000..519de450374 --- /dev/null +++ b/yql/essentials/parser/pg_wrapper/postgresql/src/port/pwritev.c @@ -0,0 +1,43 @@ +/*------------------------------------------------------------------------- + * + * pwritev.c + * Implementation of pwritev(2) for platforms that lack one. + * + * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group + * + * IDENTIFICATION + * src/port/pwritev.c + * + *------------------------------------------------------------------------- + */ + + +#include "c.h" + +#include <unistd.h> + +#include "port/pg_iovec.h" + +ssize_t +pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset) +{ + ssize_t sum = 0; + ssize_t part; + + for (int i = 0; i < iovcnt; ++i) + { + part = pg_pwrite(fd, iov[i].iov_base, iov[i].iov_len, offset); + if (part < 0) + { + if (i == 0) + return -1; + else + return sum; + } + sum += part; + offset += part; + if (part < iov[i].iov_len) + return sum; + } + return sum; +} |
