1: #
   2: 
   3: /*
   4: **  RMQM -- DBU to delete protection and integrity constraints
   5: **
   6: **	Defines:
   7: **		dest_const
   8: **		dest_integ
   9: **		dest_prot
  10: **		i_cat
  11: **		dl_all
  12: **		del_int
  13: **		del_tree
  14: **		chk_const
  15: **		r_relstat
  16: **		tree_const
  17: **		tree_prot
  18: **		prot_protree
  19: **		int_inttree
  20: **
  21: **	Required By:
  22: **		DBU driver
  23: **
  24: **	Files:
  25: **		../ingres.h
  26: **		../access.h
  27: **		../aux.h
  28: **		../catalog.h
  29: **		../symbol.h
  30: **
  31: **	Compilation Flags:
  32: **		xZTR1
  33: **
  34: **	Trace Flags:
  35: **		13
  36: **
  37: **	History:
  38: **		1/10/79 -- (marc) written
  39: */
  40: 
  41: 
  42: 
  43: 
  44: 
  45: 
  46: # include   "../ingres.h"
  47: # include   "../access.h"
  48: # include   "../aux.h"
  49: # include   "../unix.h"
  50: # include   "../catalog.h"
  51: # include   "../symbol.h"
  52: 
  53: /*
  54: **  DEST_CONST -- destroy constraints
  55: **
  56: **	Parameters:
  57: **		argc -- number of parameters in argv
  58: **		argv -- argv [0] == 5 destroy permission
  59: **			         == 6 destroy integrity constraint
  60: **		        argv [1]    relation from which to destroy constrain
  61: **		        argv [2] == if (argc != 2) relation from which to delete
  62: **				     	constraints
  63: **		        argv[3] ... argv[argc - 1] == id of constraint
  64: **
  65: **	Returns:
  66: **		0
  67: **
  68: **	Side Effects:
  69: **		destroys constraints. Involves activity on catalogs 'relation',
  70: **		protect, integrities, and tree.
  71: **
  72: **	Requires:
  73: **		dest_integ()
  74: **		dest_prot()
  75: **
  76: **	Called By:
  77: **		DBU driver
  78: **
  79: **	Trace Flags:
  80: **		13, 0
  81: **
  82: **	Diagnostics:
  83: **		5202	no relation user owns by the name given
  84: **
  85: **	Syserrs:
  86: **		bad openr, bad function mode !(5 || 6)
  87: **
  88: **	History:
  89: **		1/10/79 -- (marc) written
  90: */
  91: 
  92: dest_const(argc, argv)
  93: int     argc;
  94: char        **argv;
  95: {
  96:     struct descriptor   d;
  97:     register        i;
  98:     int         mode;
  99:     extern struct admin Admin;
 100: 
 101: #	ifdef xZTR1
 102:     if (tTf(13, 0))
 103:     {
 104:         printf("dest_const\n");
 105:         prargs(argc, argv);
 106:     }
 107: #	endif
 108: 
 109:     if (!(Admin.adhdr.adflags & A_QRYMOD))
 110:         return (0);
 111:     i = openr(&d, -1, argv[1]);
 112:     if (i < 0)
 113:         syserr("dest_const: openr(%s) %d", argv[1], i);
 114: 
 115:     if (i == 1 || !bequal(Usercode, d.relowner, 2))
 116:     {
 117:         error(5202, argv[1], 0);
 118:         return (0);
 119:     }
 120:     argv[argc] = 0;
 121:     if (i = atoi(argv[0], &mode))
 122:         syserr("dest_const: bad mode string \"%s\"", argv[0]);
 123: 
 124:     if (mode == 5)
 125:         dest_prot(&d, &argv[2]);
 126:     else if (mode == 6)
 127:         dest_integ(&d, &argv[2]);
 128:     else
 129:         syserr("dest_const: bad mode %d", mode);
 130:     return (0);
 131: }
 132: 
 133: /*
 134: **  DEST_INTEG -- directs destruction of integrity constraints
 135: **
 136: **	Parameters:
 137: **		desc -- descriptor for relation
 138: **		intv -- 0 terminated list of id strings, if first element
 139: **		        is 0 means "all"
 140: **
 141: **	Returns:
 142: **		none
 143: **
 144: **	Side Effects:
 145: **		deletes integrity constraint. Activity on 'relation', integrities,
 146: **		and tree.
 147: **
 148: **	Requires:
 149: **		i_cat()
 150: **		del_all()
 151: **		del_int()
 152: **		chk_const()
 153: **		tree_const()
 154: **		int_inttree()
 155: **
 156: **	Called By:
 157: **		dest_const
 158: **
 159: **	Trace Flags:
 160: **		13, 1
 161: **
 162: **	Diagnostics:
 163: **		5203	no integrity constraint by given id
 164: **
 165: **	History:
 166: **		1/10/79 -- (marc) written
 167: */
 168: 
 169: dest_integ(desc, intv)
 170: struct descriptor   *desc;
 171: char            *intv[];
 172: {
 173:     register struct descriptor  *d;
 174:     extern struct descriptor    Intdes;
 175:     struct integrity        tuple, key;
 176:     struct tree         tkey;
 177:     register            i, j;
 178:     int             tree_const();
 179:     int             int_inttree();
 180: 
 181:     d = desc;
 182: #	ifdef xZTR1
 183:     if (tTf(13, 1))
 184:         printf("dest_integ((%s, %s)...)\n", d->relid, d->relowner);
 185: #	endif
 186: 
 187:     i_cat("integrities", &Intdes, &key, d->relid, INTRELID,
 188:     d->relowner, INTRELOWNER, mdINTEG, &tkey);
 189: 
 190:     if (intv[0] == 0)
 191:     {
 192:         /* destroy integrity 'relation' ALL */
 193:         if (!(d->relstat & S_INTEG))
 194:             return (0);
 195:         del_all(d, &Intdes, &key, &tuple, &tkey, S_INTEG,
 196:         &tree_const, &int_inttree);
 197:         return (0);
 198:     }
 199:     /* destroy integrity 'relation' int {, int} */
 200:     for (i = 0; intv[i]; i++)
 201:         del_int(&Intdes, &key, &tuple, &tkey, intv[i], INTTREE,
 202:         &tree_const, &int_inttree);
 203: 
 204:     /* rescan to output error messages */
 205:     for (j = 0; j < i; j++)
 206:         if (*intv[j])
 207:             error(5203, intv[j], 0);
 208: 
 209:     /* finally, check that there are still integrity constraints
 210: 	** on the relation, if not must reset the S_INTEG bit in the relation
 211: 	** relation tuple for that relation.
 212: 	*/
 213:     chk_const(d, &Intdes, &key, &tuple, d->relid, INTRELID, d->relowner,
 214:     INTRELOWNER, S_INTEG);
 215: }
 216: 
 217: 
 218: /*
 219: **  DEST_PROT -- directs destruction of protection constraints
 220: **
 221: **	Parameters:
 222: **		desc -- descriptor for relation
 223: **		intv -- 0 terminated list of id strings, if first element
 224: **		        is 0 means "all"
 225: **
 226: **	Returns:
 227: **		none
 228: **
 229: **	Side Effects:
 230: **		deletes protection constraint. Activity on 'relation',
 231: **		protect, and tree.
 232: **
 233: **	Requires:
 234: **		i_cat()
 235: **		del_all()
 236: **		del_int()
 237: **		chk_const()
 238: **		tree_prot()
 239: **		prot_protree()
 240: **
 241: **	Called By:
 242: **		dest_const
 243: **
 244: **	Trace Flags:
 245: **		13, 2
 246: **
 247: **	Diagnostics:
 248: **		5204	no protection constraint by given id
 249: **
 250: **	History:
 251: **		1/10/79 -- (marc) written
 252: */
 253: 
 254: 
 255: dest_prot(desc, intv)
 256: struct descriptor   *desc;
 257: char            *intv[];
 258: {
 259:     register struct descriptor  *d;
 260:     extern struct descriptor    Prodes;
 261:     struct protect          tuple, key;
 262:     struct tree         tkey;
 263:     register            i, j;
 264:     int             propermid;
 265:     int             prot_protree();
 266:     int             tree_prot();
 267: 
 268:     d = desc;
 269: #	ifdef xZTR1
 270:     if (tTf(13, 2))
 271:         printf("dest_prot((%s, %s)...)\n", d->relid, d->relowner);
 272: #	endif
 273: 
 274:     i_cat("protect", &Prodes, &key, d->relid, PRORELID, d->relowner,
 275:     PRORELOWN, mdPROT, &tkey);
 276: 
 277:     if (intv[0] == 0)
 278:     {
 279:         /* destroy permit 'relation' ALL */
 280:         if (!(d->relstat & S_PROTRET) || !(d->relstat & S_PROTALL))
 281:             r_relstat(d, S_PROTRET | S_PROTALL, 1);
 282:         if (!(d->relstat & S_PROTUPS))
 283:             return (0);
 284:         del_all(d, &Prodes, &key, &tuple, &tkey, S_PROTUPS,
 285:         &tree_prot, &prot_protree);
 286:         return (0);
 287:     }
 288:     /* destroy permit 'relation' int {, int} */
 289:     for (i = 0; intv[i]; i++)
 290:     {
 291:         if (j = atoi(intv[i], &propermid))
 292:             syserr("dest_prot: bad atoi \"%s\" %d", intv[i], j);
 293:         if (propermid == 0)
 294:         {
 295:             if (!(d->relstat & S_PROTALL))
 296:             {
 297:                 r_relstat(d, S_PROTALL, 1);
 298:                 *intv[i] = 0;
 299:             }
 300:             continue;
 301:         }
 302:         else if (propermid == 1)
 303:         {
 304:             if (!(d->relstat & S_PROTRET))
 305:             {
 306:                 r_relstat(d, S_PROTRET, 1);
 307:                 *intv[i] = 0;
 308:             }
 309:             continue;
 310:         }
 311:         del_int(&Prodes, &key, &tuple, &tkey, intv[i], PROPERMID,
 312:         &tree_prot, &prot_protree);
 313:     }
 314:     /* rescan to output error messages */
 315:     for (j = 0; j < i; j++)
 316:         if (*intv[j])
 317:             error(5204, intv[j], 0);
 318: 
 319:     /* finally, check that there are still permissions
 320: 	** on the relation, if not must reset the S_PROTUPS bit in the relation
 321: 	** relation tuple for that relation's relstat.
 322: 	*/
 323:     chk_const(d, &Prodes, &key, &tuple, d->relid, PRORELID,
 324:     d->relowner, PRORELOWN, S_PROTUPS);
 325: }
 326: 
 327: /*
 328: **  I_CAT -- prepare catalogs for deletin of constraint
 329: **
 330: **	Initializes treerelid, treeowner, and treetype fields
 331: **	of tree key. Also relation id and owner fields of
 332: **	appropriate catalog c_desc, with key 'key'.
 333: **
 334: **	Parameters:
 335: **		c_name -- name of catalog for opencatalog
 336: **		c_desc -- descriptor of catalog
 337: **		key -- key for catalog
 338: **		relid -- relation.relid for relation to be de-constrained
 339: **		id_attno -- attno of relid in constraint catalog c_desc
 340: **		relowner -- relation.relowner for rel to be de-constrained
 341: **		own_attno -- attno of owner in constrain catalog
 342: **		type -- treetype for tree tuple (depends on catalog)
 343: **		tkey -- key for tree catalog
 344: **
 345: **	Returns:
 346: **		none
 347: **
 348: **	Side Effects:
 349: **		opencatalogs the constraint catalog c_desc, and the "tree" rel
 350: **		for READ/WRITE. Sets keys.
 351: **
 352: **	Called By:
 353: **		dest_prot()
 354: **		dest_int()
 355: **
 356: **	Trace Flags:
 357: **		13, 3
 358: **
 359: **	History:
 360: **		1/10/79 -- (marc) written
 361: */
 362: 
 363: i_cat(c_name, c_desc, key, relid, id_attno, relowner, own_attno, type, tkey)
 364: char            *c_name;
 365: struct descriptor   *c_desc;
 366: char            *key;
 367: char            *relid;
 368: int         id_attno;
 369: char            *relowner;
 370: int         own_attno;
 371: int         type;
 372: struct tree     *tkey;
 373: {
 374:     extern struct descriptor    Treedes;
 375: 
 376: #	ifdef xZTR1
 377:     if (tTf(13, 3))
 378:         printf("i_cat(c_name \"%s\", relid %s id_attno %d relowner %s own_attno %d type %d)\n",
 379:         c_name, relid, id_attno, relowner, own_attno, type);
 380: #	endif
 381: 
 382:     opencatalog("tree", 2);
 383:     setkey(&Treedes, tkey, relid, TREERELID);
 384:     setkey(&Treedes, tkey, relowner, TREEOWNER);
 385:     setkey(&Treedes, tkey, &type, TREETYPE);
 386:     opencatalog(c_name, 2);
 387:     clearkeys(c_desc);
 388:     setkey(c_desc, key, relid, id_attno);
 389:     setkey(c_desc, key, relowner, own_attno);
 390: }
 391: 
 392: /*
 393: **  DEL_ALL -- delete all constraints for a given relation
 394: **
 395: **	Deletes all constraints of a given type given by a constraint
 396: **	catalog 'c_desc'. Note that Protection constraints 0 & 1, given
 397: **	by relation.relstat field are not deleted here.
 398: **
 399: **	Parameters:
 400: **		r_desc -- descriptor for relation to de-constrain (for
 401: **			r_relstat)
 402: **		c_desc -- constraint catalog descriptor
 403: **		key -- c_desc's key
 404: **		tuple -- c_desc's tuple (needed because sizeof tuple is not
 405: **			known here, so must be allocated beforehand)
 406: **		tkey -- tree key with TREERELID and TREERELOWNER setkeyed
 407: **		bit -- bits in relstat to reset after deleting all constraints
 408: **		tree_pred -- called with constraint tuple to determine
 409: **			wether a tree tuple is present or not (as can happen
 410: **			for protect catalog)
 411: **		tree_field -- should return the treeid from tuple
 412: **
 413: **	Returns:
 414: **		none
 415: **
 416: **	Side Effects:
 417: **		tree and constraint catalog activity
 418: **
 419: **	Requires:
 420: **		del_tree()
 421: **		r_relstat()
 422: **
 423: **	Called By:
 424: **		dest_????
 425: **
 426: **	Trace Flags:
 427: **		13, 4
 428: **
 429: **	Syserrs:
 430: **		bad find, get, delete, flush_rel
 431: **
 432: **	History:
 433: **		1/10/79 -- (marc) written
 434: */
 435: 
 436: del_all(r_desc, c_desc, key, tuple, tkey, bit, tree_pred, tree_field)
 437: struct descriptor   *r_desc;
 438: struct descriptor   *c_desc;
 439: char            *key;
 440: char            *tuple;
 441: struct tree     *tkey;
 442: int         bit;
 443: int         (*tree_pred)();
 444: int         (*tree_field)();
 445: {
 446:     struct tup_id       lotid, hitid;
 447:     register        i;
 448: 
 449: #	ifdef xZTR1
 450:     if (tTf(13, 4))
 451:         printf("del_all(bit=0%o)\n", bit);
 452: #	endif
 453: 
 454:     if (i = find(c_desc, EXACTKEY, &lotid, &hitid, key))
 455:         syserr("del_all: find %d", i);
 456:     while (!(i = get(c_desc, &lotid, &hitid, tuple, TRUE)))
 457:     {
 458:         if (!kcompare(c_desc, tuple, key))
 459:         {
 460:             /* for each constraint of for a relation */
 461:             if (i = delete(c_desc, &lotid))
 462:                 syserr("del_all: delete %d", i);
 463:             /* for crash recovery */
 464:             if (i = flush_rel(c_desc, FALSE))
 465:                 syserr("del_all: flush_rel %d", i);
 466:             /* if there is a tree tuple, destroy it */
 467:             if ((*tree_pred)(tuple))
 468:                 del_tree(tkey, (*tree_field)(tuple));
 469:         }
 470:     }
 471:     if (i != 1)
 472:         syserr("del_all: get %d", i);
 473:     /* turn off bit in relstat field */
 474:     r_relstat(r_desc, bit, 0);
 475: }
 476: 
 477: 
 478: /*
 479: **  DEL_INT -- delete from a constraint catalog a constraint
 480: **
 481: **	Parameters:
 482: **		c_desc -- catalog descriptor
 483: **		key -- catalog key
 484: **		tuple -- catalog tuple (needed because tuple size unknown here)
 485: **		tkey -- tree key with TREERELID and TREERELOWNER setkeyed
 486: **		constid -- integer constraint id in string form
 487: **		constattno -- attno of comstraint number in c_desc
 488: **		tree_pred -- predicate on existence of tree tuple
 489: **		tree_field -- returns treeid from constrain tuple
 490: **
 491: **	Returns:
 492: **		none
 493: **
 494: **	Side Effects:
 495: **		constraint and tree catalog activity.
 496: **		*constid set to 0 if constraint id exists.
 497: **
 498: **	Requires:
 499: **		del_tree()
 500: **
 501: **	Called By:
 502: **		dest_????
 503: **
 504: **	Trace Flags:
 505: **		13, 5
 506: **
 507: **	Syserrs:
 508: **		bad atoi (parser error), getequal, delete, flush_rel
 509: **
 510: **	History:
 511: **		1/10/79 -- (marc) written
 512: */
 513: 
 514: del_int(c_desc, key, tuple, tkey, constid, constattno, tree_pred, tree_field)
 515: struct descriptor   *c_desc;
 516: char            *key;
 517: char            *tuple;
 518: struct tree     *tkey;
 519: char            *constid;
 520: int         constattno;
 521: int         (*tree_pred)();
 522: int         (*tree_field)();
 523: {
 524:     struct tup_id       tid;
 525:     register        i;
 526:     int         constnum;
 527: 
 528: #	ifdef xZTR1
 529:     if (tTf(13, 5))
 530:         printf("del_int(constid=%s, constattno=%d)\n",
 531:         constid, constattno);
 532: #	endif
 533: 
 534:     if (i = atoi(constid, &constnum))
 535:         syserr("del_int: bad atoi \"%s\" %d", constid, i);
 536:     setkey(c_desc, key, &constnum, constattno);
 537:     if (!(i = getequal(c_desc, key, tuple, &tid)))
 538:     {
 539:         if (i = delete(c_desc, &tid))
 540:             syserr("del_int(%d) %d", constid, i);
 541:         if ((*tree_pred)(tuple))
 542:             del_tree(tkey, (*tree_field)(tuple));
 543:         *constid = '\0';
 544:         return;
 545:     }
 546:     else if (i != 1)
 547:         syserr("dest_int: getequal %d", i);
 548:     /* bad constnum */
 549: }
 550: 
 551: /*
 552: **  DEST_TREE -- destroy a tree tuple with for a given treeid
 553: **
 554: **	Deletes all tuples from tree with 'treeid' and previously set
 555: **	keys.
 556: **
 557: **	Parameters:
 558: **		key -- tre key
 559: **		treeid -- integer treeid
 560: **
 561: **	Returns:
 562: **		none
 563: **
 564: **	Side Effects:
 565: **		tree activity
 566: **
 567: **	Called By:
 568: **		del_int, del_all
 569: **
 570: **	Trace Flags:
 571: **		13, 6
 572: **
 573: **	Syserrs:
 574: **		bad find, get, delete, flush_rel, no tuple qualified.
 575: **
 576: **	History:
 577: **		1/10/79 -- (marc) written
 578: */
 579: 
 580: del_tree(key, treeid)
 581: struct tree     *key;
 582: int         treeid;
 583: {
 584:     struct tree         tuple;
 585:     struct tup_id           lotid, hitid;
 586:     register            i;
 587:     register            flag;
 588:     extern struct descriptor    Treedes;
 589: 
 590: #	ifdef xZTR1
 591:     if (tTf(13, 6))
 592:         printf("del_tree(treeid=%d)\n", treeid);
 593: #	endif
 594: 
 595:     setkey(&Treedes, key, &treeid, TREEID);
 596:     if (i = find(&Treedes, EXACTKEY, &lotid, &hitid, key))
 597:         syserr("del_tree: bad find %d treeid %d", i, treeid);
 598:     flag = 0;
 599:     while (!(i = get(&Treedes, &lotid, &hitid, &tuple, TRUE)))
 600:     {
 601:         if (!kcompare(&Treedes, &tuple, key))
 602:         {
 603:             if (i = delete(&Treedes, &lotid))
 604:                 syserr("del_tree: delete treeid %d %d", treeid, i);
 605:             if (!flag)
 606:                 flag++;
 607:         }
 608:     }
 609:     if (i != 1)
 610:         syserr("del_tree: bad get %d", i);
 611:     if (!flag)
 612:         syserr("del_tree: no tuples qualified treeid %d", treeid);
 613:     if (i = flush_rel(&Treedes, FALSE))
 614:         syserr("del_tree: flush_rel(&Treedes) %d", i);
 615: }
 616: 
 617: /*
 618: **  CHK_CONST -- check constraint catlg for tuples for a rel, and reset relatin.relstat
 619: **
 620: **	Parameters:
 621: **		r_desc -- relation desc for de-constrained relation
 622: **		c_desc -- catalog desc
 623: **		key -- catalog key (here unknown size)
 624: **		tuple -- " tuple space " " " " "
 625: **		relid -- relation name
 626: **		id_attno -- attno of relid
 627: **		relowner -- relation owner
 628: **		own_attno -- relowner attno
 629: **		bit -- bits to reset in relstat if there are no constraints left
 630: **
 631: **	Returns:
 632: **		none
 633: **
 634: **	Side Effects:
 635: **		reads catalog, maybe changes relstat field of relation relations's
 636: **		r_desc tuple
 637: **
 638: **	Requires:
 639: **		r_relstat
 640: **
 641: **	Called By:
 642: **		dest_????
 643: **
 644: **	Trace Flags:
 645: **		13, 7
 646: **
 647: **	Syserrs:
 648: **		bad getequal
 649: **
 650: **	History:
 651: **		1/10/79 -- (marc) written
 652: */
 653: 
 654: chk_const(r_desc, c_desc, key, tuple, relid, id_attno, relowner, own_attno, bit)
 655: struct descriptor   *r_desc;
 656: struct descriptor   *c_desc;
 657: char            *key;
 658: char            *tuple;
 659: char            *relid;
 660: int         id_attno;
 661: char            *relowner;
 662: int         own_attno;
 663: int         bit;
 664: {
 665:     struct tup_id       tid;
 666:     register        i;
 667: 
 668: 
 669: #	ifdef xZTR1
 670:     if (tTf(13, 7))
 671:         printf("chk_const: relid %s id_attno %d relowner %s own_attno %d bit 0%o)\n",
 672:         relid, id_attno, relowner, own_attno, bit);
 673: #	endif
 674: 
 675:     clearkeys(c_desc);
 676:     setkey(c_desc, key, relid, id_attno);
 677:     setkey(c_desc, key, relowner, own_attno);
 678:     if ((i = getequal(c_desc, key, tuple, &tid)) == 1)
 679:         r_relstat(r_desc, bit, 0);
 680:     else if (i < 0)
 681:         syserr("chk_const: getequal %d", i);
 682: }
 683: 
 684: /*
 685: **  R_RELSTAT -- set or reset bits in the relation.relstat field
 686: **
 687: **	Does the above for relation described by desc.
 688: **
 689: **	Parameters:
 690: **		desc -- relation to have relation.relstat field changed
 691: **		bit -- bits to set or reset
 692: **		action -- 0 reset, 1 set
 693: **
 694: **	Returns:
 695: **		none
 696: **
 697: **	Side Effects:
 698: **		relation is opened for READ/WRITE, relstat changed
 699: **
 700: **	Called By:
 701: **		everyone
 702: **
 703: **	Trace Flags:
 704: **		13, 8
 705: **
 706: **	Syserrs:
 707: **		bad getequal, replace, flush_rel
 708: **
 709: **	History:
 710: **		1/10/79 -- (marc) written
 711: */
 712: 
 713: 
 714: r_relstat(desc, bit, action)
 715: struct descriptor       *desc;
 716: int             bit;
 717: int             action;
 718: {
 719:     struct relation         tuple, key;
 720:     struct tup_id           tid;
 721:     register            i;
 722:     extern struct descriptor    Reldes;
 723:     register struct descriptor  *d;
 724: 
 725:     d = desc;
 726: #	ifdef xZTR1
 727:     if (tTf(13, 8))
 728:         printf("r_relstat(bit=0%o, action %d)\n",
 729:         bit, action);
 730: #	endif
 731: 
 732:     opencatalog("relation", 2);
 733:     clearkeys(&Reldes);
 734:     setkey(&Reldes, &key, d->relid, RELID);
 735:     setkey(&Reldes, &key, d->relowner, RELOWNER);
 736:     if (i = getequal(&Reldes, &key, &tuple, &tid))
 737:         syserr("r_relstat: getequal %s, %s, %d", d->relid,
 738:         d->relowner, i);
 739:     if (action)
 740:     {
 741:         if (tuple.relstat == (i = tuple.relstat | bit))
 742:             return;
 743:         tuple.relstat = i;
 744:     }
 745:     else
 746:     {
 747:         if (tuple.relstat == (i = tuple.relstat & ~bit))
 748:             return;
 749:         tuple.relstat = i;
 750:     }
 751:     if ((i = replace(&Reldes, &tid, &tuple, 0)) < 0 || i == 2)
 752:         syserr("r_relstat: replace %d", i);
 753:     if (i = flush_rel(&Reldes, FALSE))
 754:         syserr("r_relstat: flush_rel(&Reldes) %d", i);
 755: }
 756: 
 757: /*
 758: **  TREE_CONST -- True predicate
 759: **
 760: **	Called indirectly by routines wishing to know if
 761: **	a integrity constraint has an associated tree tuple.
 762: **	As this is always the case, returns TRUE always.
 763: **
 764: **	Parameters:
 765: **		i -- integrity tuple
 766: **
 767: **	Returns:
 768: **		TRUE
 769: **
 770: **	Side Effects:
 771: **		none
 772: **
 773: **	Called By:
 774: **		sent to del_int, del_all, by dest_int
 775: **
 776: **	Trace Flags:
 777: **		13, 9
 778: **
 779: **	History:
 780: **		1/11/79 -- (marc) written
 781: */
 782: 
 783: tree_const(i)
 784: struct integrity    *i;
 785: {
 786: #	ifdef xZTR1
 787:     if (tTf(13, 9))
 788:         printf("tree_const()\n");
 789: #	endif
 790: 
 791:     return (TRUE);
 792: }
 793: 
 794: /*
 795: **  TREE_PROT -- Protection tuple tree predicate
 796: **
 797: **	Called indirectly by routines wishing to know if
 798: **	a protection constraint has an associated tree tuple.
 799: **
 800: **	Parameters:
 801: **		p -- protect tuple
 802: **
 803: **	Returns:
 804: **		TRUE -- if p->protree != -1
 805: **		FLASE -- otherwise
 806: **
 807: **	Side Effects:
 808: **		none
 809: **
 810: **	Called By:
 811: **		sent to del_int, del_all, by dest_prot
 812: **
 813: **	Trace Flags:
 814: **		13, 9
 815: **
 816: **	History:
 817: **		1/11/79 -- (marc) written
 818: */
 819: 
 820: tree_prot(p)
 821: struct protect      *p;
 822: {
 823: #	ifdef xZTR1
 824:     if (tTf(13, 9))
 825:         printf("tree_prot(p->protree=%d)\n", p->protree);
 826: #	endif
 827: 
 828:     if (p->protree == -1)
 829:         return (FALSE);
 830:     else
 831:         return (TRUE);
 832: }
 833: 
 834: /*
 835: **  PROT_PROTREE -- get protree field of a protection tuple
 836: **
 837: **	Parameters:
 838: **		p -- protect tuple
 839: **
 840: **	Returns:
 841: **		p->protree
 842: **
 843: **	Side Effects:
 844: **		none
 845: **
 846: **	Called By:
 847: **		Indirectly. Passed to del_int, del_all by dest_prot
 848: **
 849: **	Trace Flags:
 850: **		13, 9
 851: **
 852: **	History:
 853: **		1/11/79 -- (marc) written
 854: */
 855: 
 856: prot_protree(p)
 857: struct protect  *p;
 858: {
 859: #	ifdef xZTR1
 860:     if (tTf(13, 9))
 861:         printf("prot_protree(protree=%d)\n", p->protree);
 862: #	endif
 863: 
 864:     return (p->protree);
 865: }
 866: 
 867: /*
 868: **  INT_INTTREE -- get inttree field of a integrity tuple
 869: **
 870: **	Parameters:
 871: **		i -- integrity tuple
 872: **
 873: **	Returns:
 874: **		i->inttree
 875: **
 876: **	Side Effects:
 877: **		none
 878: **
 879: **	Called By:
 880: **		Indirectly. Passed to del_int, del_all by dest_int
 881: **
 882: **	Trace Flags:
 883: **		13, 9
 884: **
 885: **	History:
 886: **		1/11/79 -- (marc) written
 887: */
 888: 
 889: int_inttree(i)
 890: struct integrity    *i;
 891: {
 892: #	ifdef xZTR1
 893:     if (tTf(13, 9))
 894:         printf("int_inttree(inttree=%d)\n", i->inttree);
 895: #	endif
 896: 
 897:     return (i->inttree);
 898: }

Defined functions

chk_const defined in line 654; used 2 times
del_all defined in line 436; used 2 times
del_int defined in line 514; used 2 times
del_tree defined in line 580; used 2 times
dest_integ defined in line 169; used 1 times
dest_prot defined in line 255; used 1 times
i_cat defined in line 363; used 2 times
int_inttree defined in line 889; used 3 times
prot_protree defined in line 856; used 3 times
r_relstat defined in line 714; used 5 times
tree_const defined in line 783; used 3 times
tree_prot defined in line 820; used 3 times
Last modified: 1980-12-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3709
Valid CSS Valid XHTML 1.0 Strict