8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -135,6 +135,7 @@ fastgetiattr(IndexTuple tup,
135
135
register char * bp = NULL ; /* ptr to att in tuple */
136
136
int slow ; /* do we have to walk nulls? */
137
137
register int data_off ; /* tuple data offset */
138
+ AttributeTupleForm * att = tupleDesc -> attrs ;
138
139
139
140
/* ----------------
140
141
* sanity checks
@@ -162,14 +163,14 @@ fastgetiattr(IndexTuple tup,
162
163
/* first attribute is always at position zero */
163
164
164
165
if (attnum == 1 ) {
165
- return (fetchatt (& (tupleDesc -> attrs [0 ]), (char * ) tup + data_off ));
166
+ return (fetchatt (& (att [0 ]), (char * ) tup + data_off ));
166
167
}
167
168
attnum -- ;
168
169
169
- if (tupleDesc -> attrs [attnum ]-> attcacheoff > 0 ) {
170
- return (fetchatt (& (tupleDesc -> attrs [attnum ]),
170
+ if (att [attnum ]-> attcacheoff > 0 ) {
171
+ return (fetchatt (& (att [attnum ]),
171
172
(char * ) tup + data_off +
172
- tupleDesc -> attrs [attnum ]-> attcacheoff ));
173
+ att [attnum ]-> attcacheoff ));
173
174
}
174
175
175
176
tp = (char * ) tup + data_off ;
@@ -226,14 +227,14 @@ fastgetiattr(IndexTuple tup,
226
227
/* now check for any non-fixed length attrs before our attribute */
227
228
228
229
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 ));
232
233
}else if (!IndexTupleAllFixed (tup )) {
233
234
register int j = 0 ;
234
235
235
236
for (j = 0 ; j < attnum && !slow ; j ++ )
236
- if (tupleDesc -> attrs [j ]-> attlen < 1 ) slow = 1 ;
237
+ if (att [j ]-> attlen < 1 ) slow = 1 ;
237
238
}
238
239
}
239
240
@@ -251,23 +252,23 @@ fastgetiattr(IndexTuple tup,
251
252
* need to set cache for some atts
252
253
*/
253
254
254
- tupleDesc -> attrs [0 ]-> attcacheoff = 0 ;
255
+ att [0 ]-> attcacheoff = 0 ;
255
256
256
- while (tupleDesc -> attrs [j ]-> attcacheoff > 0 ) j ++ ;
257
+ while (att [j ]-> attcacheoff > 0 ) j ++ ;
257
258
258
- off = tupleDesc -> attrs [j - 1 ]-> attcacheoff +
259
- tupleDesc -> attrs [j - 1 ]-> attlen ;
259
+ off = att [j - 1 ]-> attcacheoff +
260
+ att [j - 1 ]-> attlen ;
260
261
261
262
for (; j < attnum + 1 ; j ++ ) {
262
263
/*
263
264
* Fix me when going to a machine with more than a four-byte
264
265
* word!
265
266
*/
266
267
267
- switch (tupleDesc -> attrs [j ]-> attlen )
268
+ switch (att [j ]-> attlen )
268
269
{
269
270
case -1 :
270
- off = (tupleDesc -> attrs [j ]-> attalign == 'd' )?
271
+ off = (att [j ]-> attalign == 'd' )?
271
272
DOUBLEALIGN (off ):INTALIGN (off );
272
273
break ;
273
274
case sizeof (char ):
@@ -279,22 +280,22 @@ fastgetiattr(IndexTuple tup,
279
280
off = INTALIGN (off );
280
281
break ;
281
282
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' )?
284
285
DOUBLEALIGN (off ) : LONGALIGN (off );
285
286
else
286
287
elog (WARN , "fastgetiattr: attribute %d has len %d" ,
287
- j , tupleDesc -> attrs [j ]-> attlen );
288
+ j , att [j ]-> attlen );
288
289
break ;
289
290
290
291
}
291
292
292
- tupleDesc -> attrs [j ]-> attcacheoff = off ;
293
- off += tupleDesc -> attrs [j ]-> attlen ;
293
+ att [j ]-> attcacheoff = off ;
294
+ off += att [j ]-> attlen ;
294
295
}
295
296
296
- return (fetchatt ( & (tupleDesc -> attrs [attnum ]),
297
- tp + tupleDesc -> attrs [attnum ]-> attcacheoff ));
297
+ return (fetchatt ( & (att [attnum ]),
298
+ tp + att [attnum ]-> attcacheoff ));
298
299
}else {
299
300
register bool usecache = true;
300
301
register int off = 0 ;
@@ -312,16 +313,16 @@ fastgetiattr(IndexTuple tup,
312
313
}
313
314
}
314
315
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 )
318
319
usecache = false;
319
320
else
320
321
continue ;
321
322
}
322
323
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 )
325
326
{
326
327
case sizeof (char ):
327
328
off ++ ;
@@ -334,24 +335,52 @@ fastgetiattr(IndexTuple tup,
334
335
break ;
335
336
case -1 :
336
337
usecache = false;
337
- off = (tupleDesc -> attrs [i ]-> attalign == 'd' )?
338
+ off = (att [i ]-> attalign == 'd' )?
338
339
DOUBLEALIGN (off ):INTALIGN (off );
339
340
off += VARSIZE (tp + off );
340
341
break ;
341
342
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 ;
346
347
else
347
348
elog (WARN , "fastgetiattr2: attribute %d has len %d" ,
348
- i , tupleDesc -> attrs [i ]-> attlen );
349
+ i , att [i ]-> attlen );
349
350
350
351
break ;
351
352
}
352
353
}
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
+ case sizeof (char ):
365
+ break ;
366
+ case sizeof (short ):
367
+ off = SHORTALIGN (off );
368
+ break ;
369
+ case sizeof (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
+ }
353
382
354
- return (fetchatt (& tupleDesc -> attrs [attnum ], tp + off ));
383
+ return (fetchatt (& att [attnum ], tp + off ));
355
384
}
356
385
}
357
386
0 commit comments