diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2015-02-20 16:51:53 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2015-02-20 16:51:53 -0500 |
commit | e38b1eb0986990d539e056a65c6b122b295ce932 (patch) | |
tree | 8679ce3dd542a3464588cb3647c403993ab84c02 /src/backend/storage/large_object/inv_api.c | |
parent | 8902f79264d95ed84e4c9fb4749b3956b4c74349 (diff) | |
download | postgresql-e38b1eb0986990d539e056a65c6b122b295ce932.tar.gz postgresql-e38b1eb0986990d539e056a65c6b122b295ce932.zip |
Use FLEXIBLE_ARRAY_MEMBER in struct varlena.
This forces some minor coding adjustments in tuptoaster.c and inv_api.c,
but the new coding there is cleaner anyway.
Michael Paquier
Diffstat (limited to 'src/backend/storage/large_object/inv_api.c')
-rw-r--r-- | src/backend/storage/large_object/inv_api.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c index a19c40186f5..ecd5e618f3c 100644 --- a/src/backend/storage/large_object/inv_api.c +++ b/src/backend/storage/large_object/inv_api.c @@ -562,11 +562,13 @@ inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes) bool neednextpage; bytea *datafield; bool pfreeit; - struct + union { bytea hdr; - char data[LOBLKSIZE]; /* make struct big enough */ - int32 align_it; /* ensure struct is aligned well enough */ + /* this is to make the union big enough for a LO data chunk: */ + char data[LOBLKSIZE + VARHDRSZ]; + /* ensure union is aligned well enough: */ + int32 align_it; } workbuf; char *workb = VARDATA(&workbuf.hdr); HeapTuple newtup; @@ -748,11 +750,13 @@ inv_truncate(LargeObjectDesc *obj_desc, int64 len) SysScanDesc sd; HeapTuple oldtuple; Form_pg_largeobject olddata; - struct + union { bytea hdr; - char data[LOBLKSIZE]; /* make struct big enough */ - int32 align_it; /* ensure struct is aligned well enough */ + /* this is to make the union big enough for a LO data chunk: */ + char data[LOBLKSIZE + VARHDRSZ]; + /* ensure union is aligned well enough: */ + int32 align_it; } workbuf; char *workb = VARDATA(&workbuf.hdr); HeapTuple newtup; |