1: # include "../ingres.h"
2: # include "../aux.h"
3: # include "../unix.h"
4: # include "../access.h"
5:
6: /*
7: ** OPENCATALOG -- open system catalog
8: **
9: ** This routine opens a system catalog into a predetermined
10: ** cache. If the catalog is already open, it is not reopened.
11: **
12: ** The 'Desxx' struct defines which relations may be opened
13: ** in this manner and is defined in .../source/aux.h.
14: **
15: ** The relation should not be closed after use (except in
16: ** special cases); however, it should be noclose'd after use
17: ** if the number of tuples in the catalog may have changed.
18: **
19: ** The Desxx structure has an alias field which
20: ** is the address of the 'Admin' structure cache which holds
21: ** the relation descriptor. Thus, an openr need never actually
22: ** occur.
23: **
24: ** The actual desxx structure definition is in the file
25: **
26: ** catalog_desc.c
27: **
28: ** which defines which relations can be cached and if any
29: ** alias descriptors exist for the relations. That file
30: ** can be redefined to include various caching.
31: **
32: **
33: ** Parameters:
34: ** name -- the name of the relation to open. It must
35: ** match one of the names in the Desxx
36: ** structure.
37: ** mode -- just like 'mode' to openr. If zero, it
38: ** is opened read-only; if two, it is opened
39: ** read/write. In fact, the catalog is always
40: ** opened read/write, but the flags are set
41: ** right for concurrency to think that you are
42: ** using it as you have declared.
43: **
44: ** Returns:
45: ** none
46: **
47: ** Side Effects:
48: ** A relation is (may be) opened.
49: **
50: ** Requires:
51: ** Desxx -- a structure which defines the relations which
52: ** may be opened. A default structure is defined in
53: ** catalog_desc.c
54: **
55: ** Called By:
56: ** most dbu routines.
57: ** qrymod.
58: ** parser.
59: ** creatdb.
60: **
61: ** Trace Flags:
62: ** none
63: **
64: ** Diagnostics:
65: ** none
66: **
67: ** Syserrs:
68: ** opencatalog: (%s)
69: ** The indicated relation was not present in
70: ** the Desxx structure.
71: ** opencatalog: open(%s)
72: ** The indicated physical file could not be
73: ** opened.
74: ** opencatalog(%s): mode %d
75: ** You specified a bad mode (not 0 or 2).
76: **
77: ** History:
78: ** 12/19/78 (epa) -- added a call to 'acc_init' if the
79: ** aliased form (avoiding an openr) is used.
80: ** 12/12/78 (rse) -- structure definition moved to aux.h
81: ** 10/6/78 (rse) -- catalog_desc.c broken off, and the
82: ** whole routine was moved to the utility library.
83: ** 8/23/78 (eric) -- physical open of files dropped,
84: ** since we can reuse the file descriptors
85: ** from the Admin struct.
86: */
87:
88: int Files[MAXFILES];
89:
90: opencatalog(name, mode)
91: char *name;
92: int mode;
93: {
94: int i;
95: register struct descriptor *d;
96: register char *n;
97: register struct desxx *p;
98: extern struct desxx Desxx[];
99:
100: n = name;
101:
102: /* find out which descriptor it is */
103: for (p = Desxx; p->cach_relname; p++)
104: if (sequal(n, p->cach_relname))
105: break;
106: if (!p->cach_relname)
107: syserr("opencatalog: (%s)", n);
108:
109: d = p->cach_desc;
110:
111: /* if it's already open, just return */
112: if (d->relopn)
113: {
114: clearkeys(d);
115: }
116: else
117: {
118: /* not open, open it */
119: if (p->cach_alias)
120: {
121: acc_init();
122: bmove(p->cach_alias, d, sizeof (*d));
123: }
124: else
125: {
126: if ((i = openr(d, 2, n)) != 0)
127: syserr("opencatalog: openr(%s) %d", n, i);
128: }
129:
130: /* mark it as an open file */
131: Files[d->relfp] = 0;
132: }
133:
134: /* determine the mode to mark it as for concurrency */
135: switch (mode)
136: {
137: case 0: /* read only */
138: d->relopn = abs(d->relopn);
139: break;
140:
141: case 2: /* read-write */
142: d->relopn = -abs(d->relopn);
143: break;
144:
145: default:
146: syserr("opencatalog(%s): mode %d", n, mode);
147: }
148:
149: return;
150: }
Defined functions
opencatalog
defined in line
90; used 64 times
- in /usr/ingres/source/dbu/copy.c line
674
- in /usr/ingres/source/dbu/create.c line
253,
270
- in /usr/ingres/source/dbu/destroy.c line
54-55(2)
- in /usr/ingres/source/dbu/display.c line
106,
301
- in /usr/ingres/source/dbu/get_p_tid.c line
56
- in /usr/ingres/source/dbu/help.c line
186,
319,
336,
358
- in /usr/ingres/source/dbu/index.c line
87,
193,
200
- in /usr/ingres/source/dbu/modify.c line
308
- in /usr/ingres/source/dbu/modupdate.c line
141,
156
- in /usr/ingres/source/dbu/pr_prot.c line
138
- in /usr/ingres/source/dbu/pr_tree.c line
238
- in /usr/ingres/source/dbu/print.c line
66
- in /usr/ingres/source/dbu/readtree.c line
289
- in /usr/ingres/source/dbu/resetrel.c line
22
- in /usr/ingres/source/dbu/rmqm.c line
382-386(2),
732
- in /usr/ingres/source/dbu/save.c line
121
- in /usr/ingres/source/dbu/secupdate.c line
39
- in /usr/ingres/source/dbu/userdestroy.c line
55,
87,
116,
123,
130
- in /usr/ingres/source/decomp/call_ovqp70.c line
133
- in /usr/ingres/source/decomp/reformat.c line
494
- in /usr/ingres/source/ovqp/getqry.c line
95
- in /usr/ingres/source/ovqp/strategy.c line
89
- in /usr/ingres/source/qrymod/d_integ.c line
142,
180
- in /usr/ingres/source/qrymod/d_prot.c line
236,
266
- in /usr/ingres/source/qrymod/define.c line
215
- in /usr/ingres/source/qrymod/integrity.c line
125
- in /usr/ingres/source/qrymod/protect.c line
481
- in /usr/ingres/source/qrymod/readtree.c line
303
- in /usr/ingres/source/support/creatdb.c line
1626-1627(2)
- in /usr/ingres/source/support/purge.c line
131
- in /usr/ingres/source/support/restore.c line
327-328(2),
383,
544,
568,
612,
628,
693,
738,
782,
821,
836,
920,
934,
1007,
1021
Defined variables
Files
defined in line
88; used 6 times