Thu, 03 Feb 2022 18:03:27 +0100
add missing postgresql vfs io functions
src/server/plugins/postgresql/vfs.c | file | annotate | diff | comparison | revisions |
--- a/src/server/plugins/postgresql/vfs.c Thu Feb 03 17:26:08 2022 +0100 +++ b/src/server/plugins/postgresql/vfs.c Thu Feb 03 18:03:27 2022 +0100 @@ -396,26 +396,32 @@ ssize_t pg_vfs_io_write(SYS_FILE fd, const void *buf, size_t nbyte) { PgVFS *pgvfs = fd->ctx->vfs->instance; - - return 0; + PgFile *pg = fd->data; + return lo_write(pgvfs->connection, pg->fd, buf, nbyte); } ssize_t pg_vfs_io_pread(SYS_FILE fd, void *buf, size_t nbyte, off_t offset) { PgVFS *pgvfs = fd->ctx->vfs->instance; - - return 0; + PgFile *pg = fd->data; + if(lo_lseek64(pgvfs->connection, pg->fd, offset, SEEK_SET) == -1) { + return -1; + } + return lo_read(pgvfs->connection, pg->fd, buf, nbyte); } ssize_t pg_vfs_io_pwrite(SYS_FILE fd, const void *buf, size_t nbyte, off_t offset) { PgVFS *pgvfs = fd->ctx->vfs->instance; - - return 0; + PgFile *pg = fd->data; + if(lo_lseek64(pgvfs->connection, pg->fd, offset, SEEK_SET) == -1) { + return -1; + } + return lo_write(pgvfs->connection, pg->fd, buf, nbyte); } off_t pg_vfs_io_seek(SYS_FILE fd, off_t offset, int whence) { PgVFS *pgvfs = fd->ctx->vfs->instance; - - return 0; + PgFile *pg = fd->data; + return lo_lseek64(pgvfs->connection, pg->fd, offset, whence); } void pg_vfs_io_close(SYS_FILE fd) {