Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite38b1eb

Browse files
committed
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
1 parent8902f79 commite38b1eb

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

‎src/backend/access/heap/tuptoaster.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,11 +1365,13 @@ toast_save_datum(Relation rel, Datum value,
13651365
CommandIdmycid=GetCurrentCommandId(true);
13661366
structvarlena*result;
13671367
structvaratt_externaltoast_pointer;
1368-
struct
1368+
union
13691369
{
13701370
structvarlenahdr;
1371-
chardata[TOAST_MAX_CHUNK_SIZE];/* make struct big enough */
1372-
int32align_it;/* ensure struct is aligned well enough */
1371+
/* this is to make the union big enough for a chunk: */
1372+
chardata[TOAST_MAX_CHUNK_SIZE+VARHDRSZ];
1373+
/* ensure union is aligned well enough: */
1374+
int32align_it;
13731375
}chunk_data;
13741376
int32chunk_size;
13751377
int32chunk_seq=0;

‎src/backend/storage/large_object/inv_api.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,11 +562,13 @@ inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes)
562562
boolneednextpage;
563563
bytea*datafield;
564564
boolpfreeit;
565-
struct
565+
union
566566
{
567567
byteahdr;
568-
chardata[LOBLKSIZE];/* make struct big enough */
569-
int32align_it;/* ensure struct is aligned well enough */
568+
/* this is to make the union big enough for a LO data chunk: */
569+
chardata[LOBLKSIZE+VARHDRSZ];
570+
/* ensure union is aligned well enough: */
571+
int32align_it;
570572
}workbuf;
571573
char*workb=VARDATA(&workbuf.hdr);
572574
HeapTuplenewtup;
@@ -748,11 +750,13 @@ inv_truncate(LargeObjectDesc *obj_desc, int64 len)
748750
SysScanDescsd;
749751
HeapTupleoldtuple;
750752
Form_pg_largeobjectolddata;
751-
struct
753+
union
752754
{
753755
byteahdr;
754-
chardata[LOBLKSIZE];/* make struct big enough */
755-
int32align_it;/* ensure struct is aligned well enough */
756+
/* this is to make the union big enough for a LO data chunk: */
757+
chardata[LOBLKSIZE+VARHDRSZ];
758+
/* ensure union is aligned well enough: */
759+
int32align_it;
756760
}workbuf;
757761
char*workb=VARDATA(&workbuf.hdr);
758762
HeapTuplenewtup;

‎src/include/c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ typedef struct
391391
structvarlena
392392
{
393393
charvl_len_[4];/* Do not touch this field directly! */
394-
charvl_dat[1];
394+
charvl_dat[FLEXIBLE_ARRAY_MEMBER];/* Data content is here */
395395
};
396396

397397
#defineVARHDRSZ((int32) sizeof(int32))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp