@@ -82,7 +82,7 @@ text_to_bits(char *str, int len)
82
82
else
83
83
ereport (ERROR ,
84
84
(errcode (ERRCODE_DATA_CORRUPTED ),
85
- errmsg ("illegal character '%c' in t_bits string" , str [off ])));
85
+ errmsg ("illegal character '%c' in t_bits string" , str [off ])));
86
86
87
87
if (off % 8 == 7 )
88
88
bits [off / 8 ] = byte ;
@@ -192,9 +192,9 @@ heap_page_items(PG_FUNCTION_ARGS)
192
192
lp_offset == MAXALIGN (lp_offset ) &&
193
193
lp_offset + lp_len <= raw_page_size )
194
194
{
195
- HeapTupleHeader tuphdr ;
196
- bytea * tuple_data_bytea ;
197
- int tuple_data_len ;
195
+ HeapTupleHeader tuphdr ;
196
+ bytea * tuple_data_bytea ;
197
+ int tuple_data_len ;
198
198
199
199
/* Extract information from the tuple header */
200
200
@@ -214,7 +214,7 @@ heap_page_items(PG_FUNCTION_ARGS)
214
214
tuple_data_bytea = (bytea * ) palloc (tuple_data_len + VARHDRSZ );
215
215
SET_VARSIZE (tuple_data_bytea , tuple_data_len + VARHDRSZ );
216
216
memcpy (VARDATA (tuple_data_bytea ), (char * ) tuphdr + tuphdr -> t_hoff ,
217
- tuple_data_len );
217
+ tuple_data_len );
218
218
values [13 ] = PointerGetDatum (tuple_data_bytea );
219
219
220
220
/*
@@ -284,16 +284,16 @@ heap_page_items(PG_FUNCTION_ARGS)
284
284
*/
285
285
static Datum
286
286
tuple_data_split_internal (Oid relid , char * tupdata ,
287
- uint16 tupdata_len , uint16 t_infomask ,
288
- uint16 t_infomask2 , bits8 * t_bits ,
289
- bool do_detoast )
287
+ uint16 tupdata_len , uint16 t_infomask ,
288
+ uint16 t_infomask2 , bits8 * t_bits ,
289
+ bool do_detoast )
290
290
{
291
- ArrayBuildState * raw_attrs ;
292
- int nattrs ;
293
- int i ;
294
- int off = 0 ;
295
- Relation rel ;
296
- TupleDesc tupdesc ;
291
+ ArrayBuildState * raw_attrs ;
292
+ int nattrs ;
293
+ int i ;
294
+ int off = 0 ;
295
+ Relation rel ;
296
+ TupleDesc tupdesc ;
297
297
298
298
/* Get tuple descriptor from relation OID */
299
299
rel = relation_open (relid , NoLock );
@@ -310,30 +310,31 @@ tuple_data_split_internal(Oid relid, char *tupdata,
310
310
311
311
for (i = 0 ; i < nattrs ; i ++ )
312
312
{
313
- Form_pg_attribute attr ;
314
- bool is_null ;
315
- bytea * attr_data = NULL ;
313
+ Form_pg_attribute attr ;
314
+ bool is_null ;
315
+ bytea * attr_data = NULL ;
316
316
317
317
attr = tupdesc -> attrs [i ];
318
318
is_null = (t_infomask & HEAP_HASNULL ) && att_isnull (i , t_bits );
319
319
320
320
/*
321
- * Tuple header can specify less attributes than tuple descriptor
322
- * as ALTER TABLE ADD COLUMN without DEFAULT keyword does not
323
- * actually change tuples in pages, so attributes with numbers greater
324
- * than (t_infomask2 & HEAP_NATTS_MASK) should be treated as NULL.
321
+ * Tuple header can specify less attributes than tuple descriptor as
322
+ * ALTER TABLE ADD COLUMN without DEFAULT keyword does not actually
323
+ * change tuples in pages, so attributes with numbers greater than
324
+ * (t_infomask2 & HEAP_NATTS_MASK) should be treated as NULL.
325
325
*/
326
326
if (i >= (t_infomask2 & HEAP_NATTS_MASK ))
327
327
is_null = true;
328
328
329
329
if (!is_null )
330
330
{
331
- int len ;
331
+ int len ;
332
332
333
333
if (attr -> attlen == -1 )
334
334
{
335
335
off = att_align_pointer (off , tupdesc -> attrs [i ]-> attalign , -1 ,
336
336
tupdata + off );
337
+
337
338
/*
338
339
* As VARSIZE_ANY throws an exception if it can't properly
339
340
* detect the type of external storage in macros VARTAG_SIZE,
@@ -343,8 +344,8 @@ tuple_data_split_internal(Oid relid, char *tupdata,
343
344
!VARATT_IS_EXTERNAL_ONDISK (tupdata + off ) &&
344
345
!VARATT_IS_EXTERNAL_INDIRECT (tupdata + off ))
345
346
ereport (ERROR ,
346
- (errcode (ERRCODE_DATA_CORRUPTED ),
347
- errmsg ("first byte of varlena attribute is incorrect for attribute %d" , i )));
347
+ (errcode (ERRCODE_DATA_CORRUPTED ),
348
+ errmsg ("first byte of varlena attribute is incorrect for attribute %d" , i )));
348
349
349
350
len = VARSIZE_ANY (tupdata + off );
350
351
}
@@ -381,7 +382,7 @@ tuple_data_split_internal(Oid relid, char *tupdata,
381
382
if (tupdata_len != off )
382
383
ereport (ERROR ,
383
384
(errcode (ERRCODE_DATA_CORRUPTED ),
384
- errmsg ("end of tuple reached without looking at all its data" )));
385
+ errmsg ("end of tuple reached without looking at all its data" )));
385
386
386
387
return makeArrayResult (raw_attrs , CurrentMemoryContext );
387
388
}
@@ -397,14 +398,14 @@ PG_FUNCTION_INFO_V1(tuple_data_split);
397
398
Datum
398
399
tuple_data_split (PG_FUNCTION_ARGS )
399
400
{
400
- Oid relid ;
401
- bytea * raw_data ;
402
- uint16 t_infomask ;
403
- uint16 t_infomask2 ;
404
- char * t_bits_str ;
405
- bool do_detoast = false;
406
- bits8 * t_bits = NULL ;
407
- Datum res ;
401
+ Oid relid ;
402
+ bytea * raw_data ;
403
+ uint16 t_infomask ;
404
+ uint16 t_infomask2 ;
405
+ char * t_bits_str ;
406
+ bool do_detoast = false;
407
+ bits8 * t_bits = NULL ;
408
+ Datum res ;
408
409
409
410
relid = PG_GETARG_OID (0 );
410
411
raw_data = PG_ARGISNULL (1 ) ? NULL : PG_GETARG_BYTEA_P (1 );
@@ -430,8 +431,8 @@ tuple_data_split(PG_FUNCTION_ARGS)
430
431
*/
431
432
if (t_infomask & HEAP_HASNULL )
432
433
{
433
- int bits_str_len ;
434
- int bits_len ;
434
+ int bits_str_len ;
435
+ int bits_len ;
435
436
436
437
bits_len = (t_infomask2 & HEAP_NATTS_MASK ) / 8 + 1 ;
437
438
if (!t_bits_str )
0 commit comments