# 2.11BSD#431 - /usr/ingres/source/dbu/print.c

##### Functions

    print             X

       1: # include   "../ingres.h"
       2: # include   "../access.h"
       3: # include   "../aux.h"
       4: # include   "../lock.h"
       5:
       6:
       7:
       8:
       9: /*
      10: **  PRINT RELATION
      11: **
      12: **	Parmv[0] through Parmv [parmc -1] contain names
      13: **	of relations to be printed on the standard output.
      14: **	Note that this calls printatt, so all the output formatting
      15: **	features associated with printatt are available here.
      16: **
      17: **	Parmv[parmc] is -1 for a "normal" print, -2 for headers on
      18: **	every page, and -3 for all headers and footers suppressed.
      19: **	err_array is set to 0 for a good relation, 1 for no
      20: **	relation by that name, and -1 for a view.
      21: **
      22: **	Uses trace flag 8
      23: **
      24: **	Returns:
      25: **		0 if no errors else the last error number
      26: **
      27: **	Diagnostics:
      28: **		5001 -- non-existant relation
      29: **		5002 -- tried to print a view
      30: **		5003 -- protection violation
      31: **
      32: **	History:
      33: **		12/18/78 (rse) -- added protection check, modified the way
      34: **				err_array was handled.
      35: **		9/12/78 -- (marc) err_array[] added, and openr()
      36: **			   call split in two to allow error messages
      37: **			   when trying to print views. error #s
      38: **			   5002 & 3 added.
      39: **		9/25/78 -- (marc) openr's merged after openr of view error
      40: */
      41:
      42: print(parmc, parmv)
      43: int parmc;
      44: char    **parmv;
      45: {
      46:     struct descriptor       d;
      47:     extern struct descriptor    Attdes;
      48:     struct attribute        att, katt;
      49:     char                tuple[MAXTUP];
      50:     struct tup_id           tid, limtid;
      51:     struct tup_id           stid;
      52:     register int            i;
      53:     register int            ern;
      54:     register char           *name;
      55:     extern struct out_arg       Out_arg;
      56:     int             mode;
      57:     int             lineno;
      58:     int             pc;
      59:     int             err_array[MAXPARMS];
      60:
      61: #	ifdef xZTR1
      62:     if (tTf(8, -1) || tTf(0, 8))
      63:         printf("entering print\n");
      64: #	endif
      65:     mode = (int) parmv[parmc] + 2;
      66:     opencatalog("attribute", 0);
      67:
      68:     for (pc = 0; pc < parmc; pc++)
      69:     {
      70:         name = parmv[pc];
      71:
      72:         ern = openr(&d, 0, name);
      73:         if (ern == AMOPNVIEW_ERR)
      74:         {
      75:             err_array[pc] = 5002;
      76:             continue;
      77:         }
      78:         if (ern > 0)
      79:         {
      80:             err_array[pc] = 5001;
      81:             continue;
      82:         }
      83:         if (ern < 0)
      84:             syserr("printr:openr target %s, %d",
      85:             name, ern);
      86:         if ((d.relstat & S_PROTALL) && (d.relstat & S_PROTRET) &&
      87:             !bequal(Usercode, d.relowner, 2))
      88:         {
      89:             err_array[pc] = 5003;
      90:             continue;
      91:         }
      92:
      93:
      94:         /* a printable relation */
      95:         err_array[pc] = 0;
      96: #		ifdef xZTR2
      97:         if (tTf(8, 1))
      98:             printdesc(&d);
      99: #		endif
     100:         lineno = Out_arg.linesperpage - 6;
     101:         if (mode >= 0)
     102:         {
     103:             if (mode == 0)
     104:                 putchar('\014');    /* form feed */
     105:             printf("\n%s relation\n", name);
     106:             lineno -= 2;
     107:         }
     108:
     109:         find(&d, NOKEY, &tid, &limtid);
     110:
     111:         if (Lockrel)
     112:             setrll(A_SLP, d.reltid, M_SHARE);   /* set shared lock on relation*/
     113:         for (;;)
     114:         {
     115:             if (mode >= 0)
     116:             {
     117:                 beginhdr();
     118:                 seq_init(&Attdes, &d);
     119:                 for (i = 1; seq_attributes(&Attdes, &d, &att); i++)
     120:                 {
     121:                     printhdr(d.relfrmt[i], d.relfrml[i], att.attname);
     122:                 }
     123:                 printeol();
     124:                 printeh();
     125:                 lineno -= 3;
     126:             }
     127:
     128: #			ifdef xZTM
     129:             if(tTf(76, 1))
     130:                 timtrace(29, 0);
     131: #			endif
     132:             while ((ern = get(&d, &tid, &limtid, tuple, TRUE)) == 0)
     133:             {
     134:                 printup(&d, tuple);
     135:                 if (mode == 0 && --lineno <= 0)
     136:                 {
     137:                     printf("\n\n\n\n\n\n");
     138:                     lineno = Out_arg.linesperpage - 6;
     139:                     break;
     140:                 }
     141:             }
     142: #			ifdef xZTM
     143:             if(tTf(76, 1))
     144:                 timtrace(30, 0);
     145: #			endif
     146:             if (ern > 0)
     147:                 break;
     148:
     149:             if (ern < 0)
     150:                 syserr("print: get %d", ern);
     151:         }
     152:
     153:         if (mode >= 0)
     154:             printeh();
     155:         if (Lockrel)
     156:             unlrl(d.reltid);    /* release relation lock */
     157:
     158:         closer(&d);
     159:     }
     160:     /* check for any error messages that should be printed */
     161:     ern = 0;
     162:     for (pc = 0; pc < parmc; pc++)
     163:     {
     164:         if (i = err_array[pc])
     165:         {
     166:             ern = error(i, parmv[pc], 0);
     167:         }
     168:     }
     169:     return (ern);
     170: }

#### Defined functions

print defined in line 42; used 5 times

- in /usr/ingres/source/dbu/overlaya.c line 4, 13
- in /usr/ingres/source/dbu/overlayg.c line 4, 19
- in /usr/ingres/source/support/printr.c line 222

Last modified: 1995-02-12 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 699 |