1: # include   "../ingres.h"
   2: # include   "../aux.h"
   3: # include   "../access.h"
   4: 
   5: /*
   6: **	Get - get a single tuple
   7: **
   8: **	Get either gets the next sequencial tuple after
   9: **	"tid" or else gets the tuple specified by tid.
  10: **
  11: **	If getnxt == TRUE, then tid is incremented to the next
  12: **	tuple after tid. If there are no more, then get returns
  13: **	1. Otherwise get returns 0 and "tid" is set to the tid of
  14: **	the returned tuple.
  15: **
  16: **	Under getnxt mode, the previous page is reset before
  17: **	the next page is read. This is done to prevent the previous
  18: **	page from hanging around in the am's buffers when we "know"
  19: **	that it will not be referenced again.
  20: **
  21: **	If getnxt == FALSE then the tuple specified by tid is
  22: **	returned. If the tuple was deleted previously,
  23: **	get retuns 2 else get returns 0.
  24: **
  25: **	If getnxt is true, limtid holds the the page number
  26: **	of the first page past the end point. Limtid and the
  27: **	initial value of tid are set by calls to FIND.
  28: **
  29: **	returns:
  30: **		<0  fatal error
  31: **		0   success
  32: **		1   end of scan (getnxt=TRUE only)
  33: **		2   tuple deleted (getnxt=FALSE only)
  34: */
  35: 
  36: 
  37: get(d, tid, limtid, tuple, getnxt)
  38: struct descriptor   *d;
  39: struct tup_id       *tid, *limtid;
  40: int         getnxt;
  41: char            *tuple;
  42: {
  43:     register int        i;
  44:     register struct tup_id  *tidx;
  45:     long            pageid, lpageid;
  46: 
  47: #	ifdef xATR1
  48:     if (tTf(93, 0))
  49:     {
  50:         printf("get: %.14s,", d->relid);
  51:         dumptid(tid);
  52:         printf("get: lim");
  53:         dumptid(limtid);
  54:     }
  55: #	endif
  56:     tidx = tid;
  57:     if (get_page(d, tidx))
  58:     {
  59:         return (-1);
  60:     }
  61:     if (getnxt)
  62:     {
  63:         pluck_page(limtid, &lpageid);
  64:         do
  65:         {
  66:             while (((++(tidx->line_id)) & I1MASK) >= Acc_head->nxtlino)
  67:             {
  68:                 tidx->line_id = -1;
  69:                 pageid = Acc_head->ovflopg;
  70:                 stuff_page(tidx, &pageid);
  71:                 if (pageid == 0)
  72:                 {
  73:                     pageid = Acc_head->mainpg;
  74:                     stuff_page(tidx, &pageid);
  75:                     if (pageid == 0 || pageid == lpageid + 1)
  76:                         return (1);
  77:                 }
  78:                 if (i = resetacc(Acc_head))
  79:                     return (i);
  80:                 if (i = get_page(d, tidx))
  81:                     return (i);
  82:             }
  83:         } while (!Acc_head->linetab[-(tidx->line_id & I1MASK)]);
  84:     }
  85:     else
  86:     {
  87:         if (i = invalid(tidx))
  88:             return (i);
  89:     }
  90:     get_tuple(d, tidx, tuple);
  91: #	ifdef xATR2
  92:     if (tTf(93, 1))
  93:     {
  94:         printf("get: ");
  95:         printup(d, tuple);
  96:     }
  97: #	endif
  98:     return (0);
  99: }
Last modified: 1980-12-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2583
Valid CSS Valid XHTML 1.0 Strict