8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.86 2008/04/12 23:14:21 tgl Exp $
11
+ * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.87 2008/04/17 21:37:28 alvherre Exp $
12
12
*
13
13
*
14
14
* INTERFACE ROUTINES
@@ -383,7 +383,7 @@ toast_delete(Relation rel, HeapTuple oldtup)
383
383
{
384
384
Datum value = toast_values [i ];
385
385
386
- if (!toast_isnull [i ] && VARATT_IS_EXTERNAL (value ))
386
+ if (!toast_isnull [i ] && VARATT_IS_EXTERNAL (PointerGetDatum ( value ) ))
387
387
toast_delete_datum (rel , value );
388
388
}
389
389
}
@@ -615,9 +615,9 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
615
615
{
616
616
if (toast_action [i ] != ' ' )
617
617
continue ;
618
- if (VARATT_IS_EXTERNAL (toast_values [i ]))
618
+ if (VARATT_IS_EXTERNAL (DatumGetPointer ( toast_values [i ]) ))
619
619
continue ; /* can't happen, toast_action would be 'p' */
620
- if (VARATT_IS_COMPRESSED (toast_values [i ]))
620
+ if (VARATT_IS_COMPRESSED (DatumGetPointer ( toast_values [i ]) ))
621
621
continue ;
622
622
if (att [i ]-> attstorage != 'x' && att [i ]-> attstorage != 'e' )
623
623
continue ;
@@ -647,7 +647,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
647
647
pfree (DatumGetPointer (old_value ));
648
648
toast_values [i ] = new_value ;
649
649
toast_free [i ] = true;
650
- toast_sizes [i ] = VARSIZE (toast_values [i ]);
650
+ toast_sizes [i ] = VARSIZE (DatumGetPointer ( toast_values [i ]) );
651
651
need_change = true;
652
652
need_free = true;
653
653
}
@@ -707,7 +707,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
707
707
{
708
708
if (toast_action [i ] == 'p' )
709
709
continue ;
710
- if (VARATT_IS_EXTERNAL (toast_values [i ]))
710
+ if (VARATT_IS_EXTERNAL (DatumGetPointer ( toast_values [i ]) ))
711
711
continue ; /* can't happen, toast_action would be 'p' */
712
712
if (att [i ]-> attstorage != 'x' && att [i ]-> attstorage != 'e' )
713
713
continue ;
@@ -756,9 +756,9 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
756
756
{
757
757
if (toast_action [i ] != ' ' )
758
758
continue ;
759
- if (VARATT_IS_EXTERNAL (toast_values [i ]))
759
+ if (VARATT_IS_EXTERNAL (DatumGetPointer ( toast_values [i ]) ))
760
760
continue ; /* can't happen, toast_action would be 'p' */
761
- if (VARATT_IS_COMPRESSED (toast_values [i ]))
761
+ if (VARATT_IS_COMPRESSED (DatumGetPointer ( toast_values [i ]) ))
762
762
continue ;
763
763
if (att [i ]-> attstorage != 'm' )
764
764
continue ;
@@ -786,7 +786,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
786
786
pfree (DatumGetPointer (old_value ));
787
787
toast_values [i ] = new_value ;
788
788
toast_free [i ] = true;
789
- toast_sizes [i ] = VARSIZE (toast_values [i ]);
789
+ toast_sizes [i ] = VARSIZE (DatumGetPointer ( toast_values [i ]) );
790
790
need_change = true;
791
791
need_free = true;
792
792
}
@@ -817,7 +817,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
817
817
{
818
818
if (toast_action [i ] == 'p' )
819
819
continue ;
820
- if (VARATT_IS_EXTERNAL (toast_values [i ]))
820
+ if (VARATT_IS_EXTERNAL (DatumGetPointer ( toast_values [i ]) ))
821
821
continue ; /* can't happen, toast_action would be 'p' */
822
822
if (att [i ]-> attstorage != 'm' )
823
823
continue ;
@@ -1070,10 +1070,10 @@ Datum
1070
1070
toast_compress_datum (Datum value )
1071
1071
{
1072
1072
struct varlena * tmp ;
1073
- int32 valsize = VARSIZE_ANY_EXHDR (value );
1073
+ int32 valsize = VARSIZE_ANY_EXHDR (DatumGetPointer ( value ) );
1074
1074
1075
- Assert (!VARATT_IS_EXTERNAL (value ));
1076
- Assert (!VARATT_IS_COMPRESSED (value ));
1075
+ Assert (!VARATT_IS_EXTERNAL (DatumGetPointer ( value ) ));
1076
+ Assert (!VARATT_IS_COMPRESSED (DatumGetPointer ( value ) ));
1077
1077
1078
1078
/*
1079
1079
* No point in wasting a palloc cycle if value size is out of the
@@ -1095,7 +1095,7 @@ toast_compress_datum(Datum value)
1095
1095
* header byte and no padding if the value is short enough. So we insist
1096
1096
* on a savings of more than 2 bytes to ensure we have a gain.
1097
1097
*/
1098
- if (pglz_compress (VARDATA_ANY (value ), valsize ,
1098
+ if (pglz_compress (VARDATA_ANY (DatumGetPointer ( value ) ), valsize ,
1099
1099
(PGLZ_Header * ) tmp , PGLZ_strategy_default ) &&
1100
1100
VARSIZE (tmp ) < valsize - 2 )
1101
1101
{
@@ -1141,6 +1141,7 @@ toast_save_datum(Relation rel, Datum value,
1141
1141
int32 chunk_seq = 0 ;
1142
1142
char * data_p ;
1143
1143
int32 data_todo ;
1144
+ Pointer dval = DatumGetPointer (value );
1144
1145
1145
1146
/*
1146
1147
* Open the toast relation and its index. We can use the index to check
@@ -1159,28 +1160,28 @@ toast_save_datum(Relation rel, Datum value,
1159
1160
*
1160
1161
* va_extsize is the actual size of the data payload in the toast records.
1161
1162
*/
1162
- if (VARATT_IS_SHORT (value ))
1163
+ if (VARATT_IS_SHORT (dval ))
1163
1164
{
1164
- data_p = VARDATA_SHORT (value );
1165
- data_todo = VARSIZE_SHORT (value ) - VARHDRSZ_SHORT ;
1165
+ data_p = VARDATA_SHORT (dval );
1166
+ data_todo = VARSIZE_SHORT (dval ) - VARHDRSZ_SHORT ;
1166
1167
toast_pointer .va_rawsize = data_todo + VARHDRSZ ; /* as if not short */
1167
1168
toast_pointer .va_extsize = data_todo ;
1168
1169
}
1169
- else if (VARATT_IS_COMPRESSED (value ))
1170
+ else if (VARATT_IS_COMPRESSED (dval ))
1170
1171
{
1171
- data_p = VARDATA (value );
1172
- data_todo = VARSIZE (value ) - VARHDRSZ ;
1172
+ data_p = VARDATA (dval );
1173
+ data_todo = VARSIZE (dval ) - VARHDRSZ ;
1173
1174
/* rawsize in a compressed datum is just the size of the payload */
1174
- toast_pointer .va_rawsize = VARRAWSIZE_4B_C (value ) + VARHDRSZ ;
1175
+ toast_pointer .va_rawsize = VARRAWSIZE_4B_C (dval ) + VARHDRSZ ;
1175
1176
toast_pointer .va_extsize = data_todo ;
1176
1177
/* Assert that the numbers look like it's compressed */
1177
1178
Assert (VARATT_EXTERNAL_IS_COMPRESSED (toast_pointer ));
1178
1179
}
1179
1180
else
1180
1181
{
1181
- data_p = VARDATA (value );
1182
- data_todo = VARSIZE (value ) - VARHDRSZ ;
1183
- toast_pointer .va_rawsize = VARSIZE (value );
1182
+ data_p = VARDATA (dval );
1183
+ data_todo = VARSIZE (dval ) - VARHDRSZ ;
1184
+ toast_pointer .va_rawsize = VARSIZE (dval );
1184
1185
toast_pointer .va_extsize = data_todo ;
1185
1186
}
1186
1187
0 commit comments