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

Commitb526462

Browse files
committed
Avoid assuming that struct varattrib_pointer doesn't get padded by the
compiler --- at least on ARM, it does. I suspect that the varvarlena patchhas been creating larger-than-intended toast pointers all along on ARM,but it wasn't exposed until the latest tweak added some Asserts thatcalculated the expected size in a different way. We could probably havefixed this by adding __attribute__((packed)) as is done for ItemPointerData,but struct varattrib_pointer isn't really all that useful anyway, so itseems cleanest to just get rid of it and have only struct varattrib_1b_e.Per results from buildfarm member quagga.
1 parentb8ce3d3 commitb526462

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.76 2007/09/30 19:54:58 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.77 2007/10/01 16:25:56 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -42,6 +42,9 @@
4242

4343
#undef TOAST_DEBUG
4444

45+
/* Size of an EXTERNAL datum that contains a standard TOAST pointer */
46+
#defineTOAST_POINTER_SIZE (VARHDRSZ_EXTERNAL + sizeof(struct varatt_external))
47+
4548
/*
4649
* Testing whether an externally-stored value is compressed now requires
4750
* comparing extsize (the actual length of the external data) to rawsize
@@ -597,7 +600,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
597600
toast_values,toast_isnull)>maxDataLen)
598601
{
599602
intbiggest_attno=-1;
600-
int32biggest_size=MAXALIGN(sizeof(varattrib_pointer));
603+
int32biggest_size=MAXALIGN(TOAST_POINTER_SIZE);
601604
Datumold_value;
602605
Datumnew_value;
603606

@@ -660,7 +663,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
660663
rel->rd_rel->reltoastrelid!=InvalidOid)
661664
{
662665
intbiggest_attno=-1;
663-
int32biggest_size=MAXALIGN(sizeof(varattrib_pointer));
666+
int32biggest_size=MAXALIGN(TOAST_POINTER_SIZE);
664667
Datumold_value;
665668

666669
/*------
@@ -710,7 +713,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
710713
toast_values,toast_isnull)>maxDataLen)
711714
{
712715
intbiggest_attno=-1;
713-
int32biggest_size=MAXALIGN(sizeof(varattrib_pointer));
716+
int32biggest_size=MAXALIGN(TOAST_POINTER_SIZE);
714717
Datumold_value;
715718
Datumnew_value;
716719

@@ -772,7 +775,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
772775
rel->rd_rel->reltoastrelid!=InvalidOid)
773776
{
774777
intbiggest_attno=-1;
775-
int32biggest_size=MAXALIGN(sizeof(varattrib_pointer));
778+
int32biggest_size=MAXALIGN(TOAST_POINTER_SIZE);
776779
Datumold_value;
777780

778781
/*--------
@@ -1085,7 +1088,7 @@ toast_save_datum(Relation rel, Datum value,
10851088
Datumt_values[3];
10861089
boolt_isnull[3];
10871090
CommandIdmycid=GetCurrentCommandId();
1088-
varattrib_pointer*result;
1091+
structvarlena*result;
10891092
structvaratt_externaltoast_pointer;
10901093
struct
10911094
{
@@ -1206,8 +1209,8 @@ toast_save_datum(Relation rel, Datum value,
12061209
/*
12071210
* Create the TOAST pointer value that we'll return
12081211
*/
1209-
result= (varattrib_pointer*)palloc(sizeof(varattrib_pointer));
1210-
SET_VARSIZE_EXTERNAL(result,sizeof(varattrib_pointer));
1212+
result= (structvarlena*)palloc(TOAST_POINTER_SIZE);
1213+
SET_VARSIZE_EXTERNAL(result,TOAST_POINTER_SIZE);
12111214
memcpy(VARDATA_EXTERNAL(result),&toast_pointer,sizeof(toast_pointer));
12121215

12131216
returnPointerGetDatum(result);

‎src/include/postgres.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
1111
* Portions Copyright (c) 1995, Regents of the University of California
1212
*
13-
* $PostgreSQL: pgsql/src/include/postgres.h,v 1.84 2007/09/30 19:54:58 tgl Exp $
13+
* $PostgreSQL: pgsql/src/include/postgres.h,v 1.85 2007/10/01 16:25:56 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -110,13 +110,6 @@ typedef struct
110110
charva_data[1];/* Data (for now always a TOAST pointer) */
111111
}varattrib_1b_e;
112112

113-
typedefstruct
114-
{
115-
uint8va_header;/* Always 0x80 or 0x01 */
116-
uint8va_len_1be;/* Physical length of datum */
117-
charva_data[sizeof(structvaratt_external)];
118-
}varattrib_pointer;
119-
120113
/*
121114
* Bit layouts for varlena headers on big-endian machines:
122115
*
@@ -225,6 +218,8 @@ typedef struct
225218
#defineVARATT_CONVERTED_SHORT_SIZE(PTR) \
226219
(VARSIZE(PTR) - VARHDRSZ + VARHDRSZ_SHORT)
227220

221+
#defineVARHDRSZ_EXTERNAL2
222+
228223
#defineVARDATA_4B(PTR)(((varattrib_4b *) (PTR))->va_4byte.va_data)
229224
#defineVARDATA_4B_C(PTR)(((varattrib_4b *) (PTR))->va_compressed.va_data)
230225
#defineVARDATA_1B(PTR)(((varattrib_1b *) (PTR))->va_data)
@@ -276,9 +271,9 @@ typedef struct
276271
VARSIZE_4B(PTR)))
277272

278273
#defineVARSIZE_ANY_EXHDR(PTR) \
279-
(VARATT_IS_1B_E(PTR) ? VARSIZE_1B_E(PTR)-2 : \
280-
(VARATT_IS_1B(PTR) ? VARSIZE_1B(PTR)-1 : \
281-
VARSIZE_4B(PTR)-4))
274+
(VARATT_IS_1B_E(PTR) ? VARSIZE_1B_E(PTR)-VARHDRSZ_EXTERNAL : \
275+
(VARATT_IS_1B(PTR) ? VARSIZE_1B(PTR)-VARHDRSZ_SHORT : \
276+
VARSIZE_4B(PTR)-VARHDRSZ))
282277

283278
/* caution: this will not work on an external or compressed-in-line Datum */
284279
/* caution: this will return a possibly unaligned pointer */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp