|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.32 1998/02/04 21:32:08 momjian Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.33 1998/02/05 03:47:08 momjian Exp $ |
12 | 12 | *
|
13 | 13 | * NOTES
|
14 | 14 | * The old interface functions have been converted to macros
|
@@ -400,7 +400,7 @@ nocachegetattr(HeapTuple tup,
|
400 | 400 | bool*isnull)
|
401 | 401 | {
|
402 | 402 | char*tp;/* ptr to att in tuple */
|
403 |
| -bits8*bp=NULL;/* ptr to att in tuple */ |
| 403 | +bits8*bp=tup->t_bits;/* ptr to att in tuple */ |
404 | 404 | intslow;/* do we have to walk nulls? */
|
405 | 405 | AttributeTupleForm*att=tupleDesc->attrs;
|
406 | 406 |
|
@@ -452,7 +452,6 @@ nocachegetattr(HeapTuple tup,
|
452 | 452 | * there's a null somewhere in the tuple
|
453 | 453 | */
|
454 | 454 |
|
455 |
| -bp=tup->t_bits; |
456 | 455 | tp= (char*)tup+tup->t_hoff;
|
457 | 456 | slow=0;
|
458 | 457 | attnum--;
|
@@ -526,7 +525,11 @@ nocachegetattr(HeapTuple tup,
|
526 | 525 | {
|
527 | 526 | registerintj=0;
|
528 | 527 |
|
529 |
| -for (j=0;j<attnum&& !slow;j++) |
| 528 | +/* |
| 529 | + *In for(), we make this <= and not < because we want to |
| 530 | + *test if we can go past it in initializing offsets. |
| 531 | + */ |
| 532 | +for (j=0;j <=attnum&& !slow;j++) |
530 | 533 | if (att[j]->attlen<1&& !VARLENA_FIXED_SIZE(att[j]))
|
531 | 534 | slow=1;
|
532 | 535 | }
|
@@ -556,7 +559,13 @@ nocachegetattr(HeapTuple tup,
|
556 | 559 | else
|
557 | 560 | off=att[j-1]->attcacheoff+att[j-1]->atttypmod;
|
558 | 561 |
|
559 |
| -for (;j<attnum+1;j++) |
| 562 | +for (;j <=attnum|| |
| 563 | +/* Can we compute more? We will probably need them */ |
| 564 | +(j<tup->t_natts&& |
| 565 | +att[j]->attcacheoff==-1&& |
| 566 | + (HeapTupleNoNulls(tup)|| !att_isnull(j,bp))&& |
| 567 | + (HeapTupleAllFixed(tup)|| |
| 568 | +att[j]->attlen>0||VARLENA_FIXED_SIZE(att[j])));j++) |
560 | 569 | {
|
561 | 570 | /*
|
562 | 571 | * Fix me when going to a machine with more than a four-byte
|
@@ -589,13 +598,25 @@ nocachegetattr(HeapTuple tup,
|
589 | 598 |
|
590 | 599 | att[j]->attcacheoff=off;
|
591 | 600 |
|
592 |
| -/* The only varlena/-1 length value to get here is this */ |
593 |
| -if (!VARLENA_FIXED_SIZE(att[j])) |
594 |
| -off+=att[j]->attlen; |
595 |
| -else |
| 601 | +switch (att[j]->attlen) |
596 | 602 | {
|
597 |
| -Assert(att[j]->atttypmod==VARSIZE(tp+off)); |
598 |
| -off+=att[j]->atttypmod; |
| 603 | +casesizeof(char): |
| 604 | +off++; |
| 605 | +break; |
| 606 | +casesizeof(short): |
| 607 | +off+=sizeof(short); |
| 608 | +break; |
| 609 | +casesizeof(int32): |
| 610 | +off+=sizeof(int32); |
| 611 | +break; |
| 612 | +case-1: |
| 613 | +Assert(!VARLENA_FIXED_SIZE(att[j])|| |
| 614 | +att[j]->atttypmod==VARSIZE(tp+off)); |
| 615 | +off+=VARSIZE(tp+off); |
| 616 | +break; |
| 617 | +default: |
| 618 | +off+=att[j]->attlen; |
| 619 | +break; |
599 | 620 | }
|
600 | 621 | }
|
601 | 622 |
|
|