|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * 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 $ |
12 | 12 | *
|
13 | 13 | *
|
14 | 14 | * INTERFACE ROUTINES
|
|
42 | 42 |
|
43 | 43 | #undef TOAST_DEBUG
|
44 | 44 |
|
| 45 | +/* Size of an EXTERNAL datum that contains a standard TOAST pointer */ |
| 46 | +#define TOAST_POINTER_SIZE (VARHDRSZ_EXTERNAL + sizeof(struct varatt_external)) |
| 47 | + |
45 | 48 | /*
|
46 | 49 | * Testing whether an externally-stored value is compressed now requires
|
47 | 50 | * 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,
|
597 | 600 | toast_values, toast_isnull) > maxDataLen)
|
598 | 601 | {
|
599 | 602 | int biggest_attno = -1;
|
600 |
| - int32 biggest_size = MAXALIGN(sizeof(varattrib_pointer)); |
| 603 | + int32 biggest_size = MAXALIGN(TOAST_POINTER_SIZE); |
601 | 604 | Datum old_value;
|
602 | 605 | Datum new_value;
|
603 | 606 |
|
@@ -660,7 +663,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
|
660 | 663 | rel->rd_rel->reltoastrelid != InvalidOid)
|
661 | 664 | {
|
662 | 665 | int biggest_attno = -1;
|
663 |
| - int32 biggest_size = MAXALIGN(sizeof(varattrib_pointer)); |
| 666 | + int32 biggest_size = MAXALIGN(TOAST_POINTER_SIZE); |
664 | 667 | Datum old_value;
|
665 | 668 |
|
666 | 669 | /*------
|
@@ -710,7 +713,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
|
710 | 713 | toast_values, toast_isnull) > maxDataLen)
|
711 | 714 | {
|
712 | 715 | int biggest_attno = -1;
|
713 |
| - int32 biggest_size = MAXALIGN(sizeof(varattrib_pointer)); |
| 716 | + int32 biggest_size = MAXALIGN(TOAST_POINTER_SIZE); |
714 | 717 | Datum old_value;
|
715 | 718 | Datum new_value;
|
716 | 719 |
|
@@ -772,7 +775,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
|
772 | 775 | rel->rd_rel->reltoastrelid != InvalidOid)
|
773 | 776 | {
|
774 | 777 | int biggest_attno = -1;
|
775 |
| - int32 biggest_size = MAXALIGN(sizeof(varattrib_pointer)); |
| 778 | + int32 biggest_size = MAXALIGN(TOAST_POINTER_SIZE); |
776 | 779 | Datum old_value;
|
777 | 780 |
|
778 | 781 | /*--------
|
@@ -1085,7 +1088,7 @@ toast_save_datum(Relation rel, Datum value,
|
1085 | 1088 | Datum t_values[3];
|
1086 | 1089 | bool t_isnull[3];
|
1087 | 1090 | CommandId mycid = GetCurrentCommandId();
|
1088 |
| - varattrib_pointer *result; |
| 1091 | + struct varlena *result; |
1089 | 1092 | struct varatt_external toast_pointer;
|
1090 | 1093 | struct
|
1091 | 1094 | {
|
@@ -1206,8 +1209,8 @@ toast_save_datum(Relation rel, Datum value,
|
1206 | 1209 | /*
|
1207 | 1210 | * Create the TOAST pointer value that we'll return
|
1208 | 1211 | */
|
1209 |
| - result = (varattrib_pointer *) palloc(sizeof(varattrib_pointer)); |
1210 |
| - SET_VARSIZE_EXTERNAL(result, sizeof(varattrib_pointer)); |
| 1212 | + result = (struct varlena *) palloc(TOAST_POINTER_SIZE); |
| 1213 | + SET_VARSIZE_EXTERNAL(result, TOAST_POINTER_SIZE); |
1211 | 1214 | memcpy(VARDATA_EXTERNAL(result), &toast_pointer, sizeof(toast_pointer));
|
1212 | 1215 |
|
1213 | 1216 | return PointerGetDatum(result);
|
|
0 commit comments