1: # include <ingres.h> 2: # include <aux.h> 3: # include <pv.h> 4: # include <sccs.h> 5: # include <symbol.h> 6: # include <func.h> 7: 8: 9: SCCSID (@(#)sysfunc.c 8.2 1/15/85) 10: 11: short tTdbu[100]; 12: extern int sysfunc(); 13: extern int null_fn(); 14: 15: int Noupdt = FALSE; 16: 17: struct fn_def SysFuncFn = 18: { 19: "SYSMOD", 20: sysfunc, 21: null_fn, 22: null_fn, 23: NULL, 24: 0, 25: tTdbu, 26: 100, 27: 'S', 28: 0 29: }; 30: 31: 32: extern int Status; 33: 34: struct modtabl 35: { 36: char *rname; 37: char **parvec; 38: int goahead; 39: int normgo; 40: int optn; 41: }; 42: 43: char *Relpar[] = 44: { 45: "relation", "hash", "name", 46: "relid", NULL 47: }; 48: 49: char *Attpar[] = 50: { 51: "attribute", "hash", "name", 52: "attrelid", "attowner", "#attid", 53: NULL 54: }; 55: 56: char *Indpar[] = 57: { 58: "indexes", "hash", "name", 59: "irelidp", "iownerp", "", 60: "minpages", "5", NULL 61: }; 62: 63: char *Trepar[] = 64: { 65: "tree", "hash", "name", 66: "treerelid", "treeowner", "treetype", 67: NULL 68: }; 69: 70: char *Propar[] = 71: { 72: "protect", "hash", "name", 73: "prorelid", "prorelown", NULL 74: }; 75: 76: char *Intpar[] = 77: { 78: "integrities", "hash", "name", 79: "intrelid", "intrelowner", NULL 80: }; 81: 82: char *Rdelpar[] = 83: { 84: "rdelim", "isam", "name", 85: "order", "group", "delim", 86: NULL 87: }; 88: 89: struct modtabl Modtabl[] = 90: { 91: "relation", &Relpar[0], FALSE, TRUE, FALSE, 92: "attribute", &Attpar[0], FALSE, TRUE, FALSE, 93: "indexes", &Indpar[0], FALSE, TRUE, FALSE, 94: "tree", &Trepar[0], FALSE, TRUE, TRUE, 95: "protect", &Propar[0], FALSE, TRUE, TRUE, 96: "integrities", &Intpar[0], FALSE, TRUE, TRUE, 97: "rdelim", &Rdelpar[0], FALSE, TRUE, TRUE, 98: 0 99: }; 100: 101: 102: /* 103: ** SYSMOD -- Modify system catalogs to a predetermined 104: ** storage structure with predetermined keys. 105: ** 106: ** Flags: 107: ** '-Rsystem relation name' will modify 108: ** only the named relations 109: ** 110: ** Trace flags: 111: ** -S99 112: ** 113: */ 114: 115: sysfunc (pc, pv) 116: int pc; 117: PARM *pv; 118: { 119: register int i; 120: register int j; 121: register char **av; 122: char *p; 123: char *argptr; 124: 125: 126: # ifdef xSTR1 127: if (tTf(99,0)) 128: { 129: printf("SYSFUNC: starting. \n"); 130: prvect(pc, pv); 131: } 132: # endif 133: 134: /* 135: ** if there are any arguments, verify that they are valid 136: ** names of relations which can be modified by this program. 137: ** if there are no arguments, assume all system relations are to be 138: ** modified. 139: */ 140: 141: if (pv[0].pv_val.pv_str != NULL) 142: if ((pv[1].pv_val.pv_str == NULL) && sequal(argptr = &pv[0].pv_val.pv_str[2], "all")) 143: for (i = 0; Modtabl[i].rname; i++) 144: Modtabl[i].goahead = TRUE; 145: else 146: for ( i = 0; i <= pc; i++) 147: { 148: av = &pv[i].pv_val.pv_str; 149: if (( p = *av) == NULL) 150: break; 151: 152: argptr = &p[2]; 153: for (j = 0; Modtabl[j].rname; j++) 154: { 155: if (sequal(argptr, Modtabl[j].rname)) 156: { 157: if (Modtabl[j].goahead) 158: { 159: printf("%s duplicate relation name\n", p); 160: return(1); 161: } 162: Modtabl[j].goahead = TRUE; 163: break; 164: } 165: } 166: if ((!Modtabl[j].rname) && !(p[1] == 'Z')) 167: { 168: printf("%s is not a system relation\n", p); 169: return(1); 170: } 171: } 172: else 173: for (i = 0; Modtabl[i].rname; i++) 174: Modtabl[i].goahead = Modtabl[i].normgo; 175: 176: for (i = 0; Modtabl[i].rname; i++) 177: { 178: if (Modtabl[i].goahead == 0 || optn_rel(&Modtabl[i])) 179: continue; 180: argptr = Modtabl[i].rname; 181: printf("modifying %s\n", argptr); 182: av = Modtabl[i].parvec; 183: j = 0; 184: initp(); 185: while (*av != NULL) 186: { 187: setp(PV_STR, *av); 188: av++; 189: } 190: 191: call( mdMODIFY, NULL); 192: } 193: printf("sysmod done\n"); 194: return(0); 195: } 196: 197: 198: optn_rel(mx) 199: struct modtabl *mx; 200: { 201: register struct modtabl *m; 202: register int ret; 203: char *temp; 204: 205: struct descriptor des; 206: 207: m = mx; 208: ret = FALSE; 209: 210: if (m->optn) 211: { 212: if (openr(&des, OR_RELTID, m->rname)) 213: { 214: ret = TRUE; 215: } 216: } 217: return (ret); 218: } 219: 220: /* rubproc() 221: { 222: printf("sysmod interrupted\n"); 223: return(1); 224: } */