88 *
99 *
1010 * 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 $
1212 *
1313 *
1414 * INTERFACE ROUTINES
@@ -383,7 +383,7 @@ toast_delete(Relation rel, HeapTuple oldtup)
383383{
384384Datum value = toast_values [i ];
385385
386- if (!toast_isnull [i ]&& VARATT_IS_EXTERNAL (value ))
386+ if (!toast_isnull [i ]&& VARATT_IS_EXTERNAL (PointerGetDatum ( value ) ))
387387toast_delete_datum (rel ,value );
388388}
389389}
@@ -615,9 +615,9 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
615615{
616616if (toast_action [i ]!= ' ' )
617617continue ;
618- if (VARATT_IS_EXTERNAL (toast_values [i ]))
618+ if (VARATT_IS_EXTERNAL (DatumGetPointer ( toast_values [i ]) ))
619619continue ;/* 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 ]) ))
621621continue ;
622622if (att [i ]-> attstorage != 'x' && att [i ]-> attstorage != 'e' )
623623continue ;
@@ -647,7 +647,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
647647pfree (DatumGetPointer (old_value ));
648648toast_values [i ]= new_value ;
649649toast_free [i ]= true;
650- toast_sizes [i ]= VARSIZE (toast_values [i ]);
650+ toast_sizes [i ]= VARSIZE (DatumGetPointer ( toast_values [i ]) );
651651need_change = true;
652652need_free = true;
653653}
@@ -707,7 +707,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
707707{
708708if (toast_action [i ]== 'p' )
709709continue ;
710- if (VARATT_IS_EXTERNAL (toast_values [i ]))
710+ if (VARATT_IS_EXTERNAL (DatumGetPointer ( toast_values [i ]) ))
711711continue ;/* can't happen, toast_action would be 'p' */
712712if (att [i ]-> attstorage != 'x' && att [i ]-> attstorage != 'e' )
713713continue ;
@@ -756,9 +756,9 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
756756{
757757if (toast_action [i ]!= ' ' )
758758continue ;
759- if (VARATT_IS_EXTERNAL (toast_values [i ]))
759+ if (VARATT_IS_EXTERNAL (DatumGetPointer ( toast_values [i ]) ))
760760continue ;/* 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 ]) ))
762762continue ;
763763if (att [i ]-> attstorage != 'm' )
764764continue ;
@@ -786,7 +786,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
786786pfree (DatumGetPointer (old_value ));
787787toast_values [i ]= new_value ;
788788toast_free [i ]= true;
789- toast_sizes [i ]= VARSIZE (toast_values [i ]);
789+ toast_sizes [i ]= VARSIZE (DatumGetPointer ( toast_values [i ]) );
790790need_change = true;
791791need_free = true;
792792}
@@ -817,7 +817,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
817817{
818818if (toast_action [i ]== 'p' )
819819continue ;
820- if (VARATT_IS_EXTERNAL (toast_values [i ]))
820+ if (VARATT_IS_EXTERNAL (DatumGetPointer ( toast_values [i ]) ))
821821continue ;/* can't happen, toast_action would be 'p' */
822822if (att [i ]-> attstorage != 'm' )
823823continue ;
@@ -1070,10 +1070,10 @@ Datum
10701070toast_compress_datum (Datum value )
10711071{
10721072struct varlena * tmp ;
1073- int32 valsize = VARSIZE_ANY_EXHDR (value );
1073+ int32 valsize = VARSIZE_ANY_EXHDR (DatumGetPointer ( value ) );
10741074
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 ) ));
10771077
10781078/*
10791079 * No point in wasting a palloc cycle if value size is out of the
@@ -1095,7 +1095,7 @@ toast_compress_datum(Datum value)
10951095 * header byte and no padding if the value is short enough. So we insist
10961096 * on a savings of more than 2 bytes to ensure we have a gain.
10971097 */
1098- if (pglz_compress (VARDATA_ANY (value ),valsize ,
1098+ if (pglz_compress (VARDATA_ANY (DatumGetPointer ( value ) ),valsize ,
10991099 (PGLZ_Header * )tmp ,PGLZ_strategy_default )&&
11001100VARSIZE (tmp )< valsize - 2 )
11011101{
@@ -1141,6 +1141,7 @@ toast_save_datum(Relation rel, Datum value,
11411141int32 chunk_seq = 0 ;
11421142char * data_p ;
11431143int32 data_todo ;
1144+ Pointer dval = DatumGetPointer (value );
11441145
11451146/*
11461147 * 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,
11591160 *
11601161 * va_extsize is the actual size of the data payload in the toast records.
11611162 */
1162- if (VARATT_IS_SHORT (value ))
1163+ if (VARATT_IS_SHORT (dval ))
11631164{
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 ;
11661167toast_pointer .va_rawsize = data_todo + VARHDRSZ ;/* as if not short */
11671168toast_pointer .va_extsize = data_todo ;
11681169}
1169- else if (VARATT_IS_COMPRESSED (value ))
1170+ else if (VARATT_IS_COMPRESSED (dval ))
11701171{
1171- data_p = VARDATA (value );
1172- data_todo = VARSIZE (value )- VARHDRSZ ;
1172+ data_p = VARDATA (dval );
1173+ data_todo = VARSIZE (dval )- VARHDRSZ ;
11731174/* 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 ;
11751176toast_pointer .va_extsize = data_todo ;
11761177/* Assert that the numbers look like it's compressed */
11771178Assert (VARATT_EXTERNAL_IS_COMPRESSED (toast_pointer ));
11781179}
11791180else
11801181{
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 );
11841185toast_pointer .va_extsize = data_todo ;
11851186}
11861187