1: # include   "../ingres.h"
   2: # include   "../catalog.h"
   3: /*
   4: **  GET_P_TID -- Get the primary tid for a relation for locking
   5: **
   6: **	Finds the correct tid for locking the relation. If the
   7: **	relation is a primary relation, then the tid of the
   8: **	relation is returned.
   9: **
  10: **	If the relation is a secondary index then the tid of the
  11: **	primary relation is returned.
  12: **
  13: **	Parameters:
  14: **		des - an open descriptor for the relation.
  15: **		tidp - a pointer to a place to store the tid.
  16: **
  17: **	Returns:
  18: **		none
  19: **
  20: **	Side Effects:
  21: **		alters the value stored in "tidp",
  22: **		may cause access to the indexes relation
  23: **
  24: **	Requires:
  25: **		opencatalog
  26: **
  27: **	Called By:
  28: **		modify
  29: **
  30: **	Syserrs:
  31: **		if the indexes relation cannot be accessed or
  32: **		is inconsistent.
  33: **
  34: **	History:
  35: **		12/28/78 (rse) - written
  36: */
  37: 
  38: 
  39: 
  40: get_p_tid(des, tidp)
  41: struct descriptor   *des;
  42: struct tup_id       *tidp;
  43: {
  44:     register struct descriptor  *d;
  45:     register struct tup_id      *tp;
  46:     register int            i;
  47:     struct index            indkey, itup;
  48:     struct descriptor       ides;
  49:     extern struct descriptor    Inddes;
  50: 
  51:     d = des;
  52:     tp = tidp;
  53:     if (d->relindxd < 0)
  54:     {
  55:         /* this is a secondary index. lock the primary rel */
  56:         opencatalog("indexes", 0);
  57:         setkey(&Inddes, &indkey, d->relowner, IOWNERP);
  58:         setkey(&Inddes, &indkey, d->relid, IRELIDI);
  59:         if (getequal(&Inddes, &indkey, &itup, tp))
  60:             syserr("No prim for %.14s", d->relid);
  61: 
  62:         if (i = openr(&ides, -1, itup.irelidp))
  63:             syserr("openr prim %d,%.14s", i, itup.irelidp);
  64: 
  65:         bmove(&ides.reltid, tp, sizeof (*tp));
  66:     }
  67:     else
  68:         bmove(&d->reltid, tp, sizeof (*tp));
  69: }

Defined functions

get_p_tid defined in line 40; used 1 times
Last modified: 1980-12-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1853
Valid CSS Valid XHTML 1.0 Strict