Sun, 08 May 2022 10:46:56 +0200
add support for O_TRUNC in pg_vfs_open
src/server/plugins/postgresql/vfs.c | file | annotate | diff | comparison | revisions |
--- a/src/server/plugins/postgresql/vfs.c Sun May 08 10:41:27 2022 +0200 +++ b/src/server/plugins/postgresql/vfs.c Sun May 08 10:46:56 2022 +0200 @@ -584,6 +584,21 @@ lo_mode = INV_WRITE; } fd = lo_open(pg->connection, oid, lo_mode); + int err = 0; + if(fd < 0) { + err = 1; + } else if((oflags & O_TRUNC) == O_TRUNC) { + if(lo_truncate(pg->connection, fd, 0)) { + lo_close(pg->connection, fd); + err = 1; + } + } + + if(err) { + pool_free(ctx->pool, file); + pool_free(ctx->pool, pgfile); + return NULL; + } } pgfile->iscollection = iscollection;