diff -r 03c052d9a097 -r 52831b82b3fd src/server/plugins/postgresql/vfs.c --- 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;