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

Commit7540eda

Browse files
committed
Someone forgot about aligning in fastgetiattr()...
1 parent9392a19 commit7540eda

File tree

1 file changed

+63
-34
lines changed

1 file changed

+63
-34
lines changed

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

Lines changed: 63 additions & 34 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/indextuple.c,v 1.13 1997/03/26 02:24:38 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.14 1997/06/12 15:41:52 vadim Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -135,6 +135,7 @@ fastgetiattr(IndexTuple tup,
135135
registerchar*bp=NULL;/* ptr to att in tuple */
136136
intslow;/* do we have to walk nulls? */
137137
registerintdata_off;/* tuple data offset */
138+
AttributeTupleForm*att=tupleDesc->attrs;
138139

139140
/* ----------------
140141
*sanity checks
@@ -162,14 +163,14 @@ fastgetiattr(IndexTuple tup,
162163
/* first attribute is always at position zero */
163164

164165
if (attnum==1) {
165-
return(fetchatt(&(tupleDesc->attrs[0]), (char*)tup+data_off));
166+
return(fetchatt(&(att[0]), (char*)tup+data_off));
166167
}
167168
attnum--;
168169

169-
if (tupleDesc->attrs[attnum]->attcacheoff>0) {
170-
return(fetchatt(&(tupleDesc->attrs[attnum]),
170+
if (att[attnum]->attcacheoff>0) {
171+
return(fetchatt(&(att[attnum]),
171172
(char*)tup+data_off+
172-
tupleDesc->attrs[attnum]->attcacheoff));
173+
att[attnum]->attcacheoff));
173174
}
174175

175176
tp= (char*)tup+data_off;
@@ -226,14 +227,14 @@ fastgetiattr(IndexTuple tup,
226227
/* now check for any non-fixed length attrs before our attribute */
227228

228229
if (!slow) {
229-
if (tupleDesc->attrs[attnum]->attcacheoff>0) {
230-
return(fetchatt(&(tupleDesc->attrs[attnum]),
231-
tp+tupleDesc->attrs[attnum]->attcacheoff));
230+
if (att[attnum]->attcacheoff>0) {
231+
return(fetchatt(&(att[attnum]),
232+
tp+att[attnum]->attcacheoff));
232233
}elseif (!IndexTupleAllFixed(tup)) {
233234
registerintj=0;
234235

235236
for (j=0;j<attnum&& !slow;j++)
236-
if (tupleDesc->attrs[j]->attlen<1)slow=1;
237+
if (att[j]->attlen<1)slow=1;
237238
}
238239
}
239240

@@ -251,23 +252,23 @@ fastgetiattr(IndexTuple tup,
251252
* need to set cache for some atts
252253
*/
253254

254-
tupleDesc->attrs[0]->attcacheoff=0;
255+
att[0]->attcacheoff=0;
255256

256-
while (tupleDesc->attrs[j]->attcacheoff>0)j++;
257+
while (att[j]->attcacheoff>0)j++;
257258

258-
off=tupleDesc->attrs[j-1]->attcacheoff+
259-
tupleDesc->attrs[j-1]->attlen;
259+
off=att[j-1]->attcacheoff+
260+
att[j-1]->attlen;
260261

261262
for (;j<attnum+1;j++) {
262263
/*
263264
* Fix me when going to a machine with more than a four-byte
264265
* word!
265266
*/
266267

267-
switch(tupleDesc->attrs[j]->attlen)
268+
switch(att[j]->attlen)
268269
{
269270
case-1:
270-
off= (tupleDesc->attrs[j]->attalign=='d')?
271+
off= (att[j]->attalign=='d')?
271272
DOUBLEALIGN(off):INTALIGN(off);
272273
break;
273274
casesizeof(char):
@@ -279,22 +280,22 @@ fastgetiattr(IndexTuple tup,
279280
off=INTALIGN(off);
280281
break;
281282
default:
282-
if (tupleDesc->attrs[j]->attlen>sizeof(int32))
283-
off= (tupleDesc->attrs[j]->attalign=='d')?
283+
if (att[j]->attlen>sizeof(int32))
284+
off= (att[j]->attalign=='d')?
284285
DOUBLEALIGN(off) :LONGALIGN(off);
285286
else
286287
elog(WARN,"fastgetiattr: attribute %d has len %d",
287-
j,tupleDesc->attrs[j]->attlen);
288+
j,att[j]->attlen);
288289
break;
289290

290291
}
291292

292-
tupleDesc->attrs[j]->attcacheoff=off;
293-
off+=tupleDesc->attrs[j]->attlen;
293+
att[j]->attcacheoff=off;
294+
off+=att[j]->attlen;
294295
}
295296

296-
return(fetchatt(&(tupleDesc->attrs[attnum]),
297-
tp+tupleDesc->attrs[attnum]->attcacheoff));
297+
return(fetchatt(&(att[attnum]),
298+
tp+att[attnum]->attcacheoff));
298299
}else {
299300
registerboolusecache= true;
300301
registerintoff=0;
@@ -312,16 +313,16 @@ fastgetiattr(IndexTuple tup,
312313
}
313314
}
314315

315-
if (usecache&&tupleDesc->attrs[i]->attcacheoff>0) {
316-
off=tupleDesc->attrs[i]->attcacheoff;
317-
if (tupleDesc->attrs[i]->attlen==-1)
316+
if (usecache&&att[i]->attcacheoff>0) {
317+
off=att[i]->attcacheoff;
318+
if (att[i]->attlen==-1)
318319
usecache= false;
319320
else
320321
continue;
321322
}
322323

323-
if (usecache)tupleDesc->attrs[i]->attcacheoff=off;
324-
switch(tupleDesc->attrs[i]->attlen)
324+
if (usecache)att[i]->attcacheoff=off;
325+
switch(att[i]->attlen)
325326
{
326327
casesizeof(char):
327328
off++;
@@ -334,24 +335,52 @@ fastgetiattr(IndexTuple tup,
334335
break;
335336
case-1:
336337
usecache= false;
337-
off= (tupleDesc->attrs[i]->attalign=='d')?
338+
off= (att[i]->attalign=='d')?
338339
DOUBLEALIGN(off):INTALIGN(off);
339340
off+=VARSIZE(tp+off);
340341
break;
341342
default:
342-
if (tupleDesc->attrs[i]->attlen>sizeof(int32))
343-
off= (tupleDesc->attrs[i]->attalign=='d') ?
344-
DOUBLEALIGN(off)+tupleDesc->attrs[i]->attlen :
345-
LONGALIGN(off)+tupleDesc->attrs[i]->attlen;
343+
if (att[i]->attlen>sizeof(int32))
344+
off= (att[i]->attalign=='d') ?
345+
DOUBLEALIGN(off)+att[i]->attlen :
346+
LONGALIGN(off)+att[i]->attlen;
346347
else
347348
elog(WARN,"fastgetiattr2: attribute %d has len %d",
348-
i,tupleDesc->attrs[i]->attlen);
349+
i,att[i]->attlen);
349350

350351
break;
351352
}
352353
}
354+
/*
355+
* I don't know why this code was missed here!
356+
* I've got it from heaptuple.c:fastgetattr().
357+
* - vadim 06/12/97
358+
*/
359+
switch (att[attnum]->attlen) {
360+
case-1:
361+
off= (att[attnum]->attalign=='d')?
362+
DOUBLEALIGN(off) :INTALIGN(off);
363+
break;
364+
casesizeof(char):
365+
break;
366+
casesizeof(short):
367+
off=SHORTALIGN(off);
368+
break;
369+
casesizeof(int32):
370+
off=INTALIGN(off);
371+
break;
372+
default:
373+
if (att[attnum]->attlen<sizeof(int32))
374+
elog(WARN,"fastgetattr3: attribute %d has len %d",
375+
attnum,att[attnum]->attlen);
376+
if (att[attnum]->attalign=='d')
377+
off=DOUBLEALIGN(off);
378+
else
379+
off=LONGALIGN(off);
380+
break;
381+
}
353382

354-
return(fetchatt(&tupleDesc->attrs[attnum],tp+off));
383+
return(fetchatt(&att[attnum],tp+off));
355384
}
356385
}
357386

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp