Hi, On Tue, Aug 5, 2025 at 9:42 AM Peter Eisentraut <pe...@eisentraut.org> wrote: > > On 03.08.25 22:20, Tom Lane wrote: > > It looks like the majority vote is still in favor of writing out > > DatumGetPointer instead of using "_D()" functions, so let's roll > > with that approach. > > > > I looked through our two versions of the varatt.h changes and > > merged them. The attached is only cosmetically different from > > yours, I think --- mostly, I kept the comments I'd written. > > > > I've tested this atop 0001-0005 from [1], and it all seems good. > > I'd like to move along with getting these changes committed, and > > then I'll take another look at the 8-byte-datums-everywhere proposal. > > I committed this with the required prerequisite patches. That concludes > this thread, I think. I'll follow up on the remaining work in the > "Datum as struct" thread, and the work in the "8 byte Datums" thread can > also continue. >
I got the following compiler warning: % make -C src/backend/storage/large_object inv_api.c: In function ‘inv_write’: inv_api.c:565:29: warning: ‘workbuf’ may be used uninitialized [-Wmaybe-uninitialized] 565 | char *workb = VARDATA(&workbuf.hdr); | ^~~~~~~~~~~~~~~~~~~~~ In file included from ../../../../src/include/access/htup_details.h:22, from ../../../../src/include/nodes/tidbitmap.h:25, from ../../../../src/include/access/genam.h:20, from inv_api.c:36: ../../../../src/include/varatt.h:305:1: note: by argument 1 of type ‘const void *’ to ‘VARDATA’ declared here 305 | VARDATA(const void *PTR) | ^~~~~~~ inv_api.c:564:33: note: ‘workbuf’ declared here 564 | } workbuf; | ^~~~~~~ inv_api.c: In function ‘inv_truncate’: inv_api.c:756:29: warning: ‘workbuf’ may be used uninitialized [-Wmaybe-uninitialized] 756 | char *workb = VARDATA(&workbuf.hdr); | ^~~~~~~~~~~~~~~~~~~~~ ../../../../src/include/varatt.h:305:1: note: by argument 1 of type ‘const void *’ to ‘VARDATA’ declared here 305 | VARDATA(const void *PTR) | ^~~~~~~ inv_api.c:755:33: note: ‘workbuf’ declared here 755 | } workbuf; | ^~~~~~~ I've not fully investigated the root cause but commit e035863c9a0 presumably is the culprit. FYI I'm using gcc 14.2.1. The attached patch fixes the warning. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c index 68b76f2cc18..a874000c8ca 100644 --- a/src/backend/storage/large_object/inv_api.c +++ b/src/backend/storage/large_object/inv_api.c @@ -561,7 +561,7 @@ inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes) char data[LOBLKSIZE + VARHDRSZ]; /* ensure union is aligned well enough: */ int32 align_it; - } workbuf; + } workbuf = {0}; char *workb = VARDATA(&workbuf.hdr); HeapTuple newtup; Datum values[Natts_pg_largeobject]; @@ -752,7 +752,7 @@ inv_truncate(LargeObjectDesc *obj_desc, int64 len) char data[LOBLKSIZE + VARHDRSZ]; /* ensure union is aligned well enough: */ int32 align_it; - } workbuf; + } workbuf = {0}; char *workb = VARDATA(&workbuf.hdr); HeapTuple newtup; Datum values[Natts_pg_largeobject];