Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0f582ce

Browse files
committed
char() cleanup and more cacheoff improvements.
1 parent48ad446 commit0f582ce

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

‎src/backend/access/common/heaptuple.c‎

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* 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 $
1212
*
1313
* NOTES
1414
* The old interface functions have been converted to macros
@@ -400,7 +400,7 @@ nocachegetattr(HeapTuple tup,
400400
bool*isnull)
401401
{
402402
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 */
404404
intslow;/* do we have to walk nulls? */
405405
AttributeTupleForm*att=tupleDesc->attrs;
406406

@@ -452,7 +452,6 @@ nocachegetattr(HeapTuple tup,
452452
* there's a null somewhere in the tuple
453453
*/
454454

455-
bp=tup->t_bits;
456455
tp= (char*)tup+tup->t_hoff;
457456
slow=0;
458457
attnum--;
@@ -526,7 +525,11 @@ nocachegetattr(HeapTuple tup,
526525
{
527526
registerintj=0;
528527

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++)
530533
if (att[j]->attlen<1&& !VARLENA_FIXED_SIZE(att[j]))
531534
slow=1;
532535
}
@@ -556,7 +559,13 @@ nocachegetattr(HeapTuple tup,
556559
else
557560
off=att[j-1]->attcacheoff+att[j-1]->atttypmod;
558561

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++)
560569
{
561570
/*
562571
* Fix me when going to a machine with more than a four-byte
@@ -589,13 +598,25 @@ nocachegetattr(HeapTuple tup,
589598

590599
att[j]->attcacheoff=off;
591600

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)
596602
{
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;
599620
}
600621
}
601622

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp