1 /* BEGIN INCLUDE FILE mdbm_file_model.incl.pl1 -- jaw, 8/29/78 */
  2 
  3 
  4 /****^  HISTORY COMMENTS:
  5   1) change(79-02-01,JGray), approve(), audit(), install():
  6      modified to save space occupied by model
  7   2) change(82-05-19,Davids), approve(), audit(), install():
  8      renamed rel_info.nsec_inds to rel_info.unused_3 because it really wasn't
  9      the number of secondary indices in the relation - it was always zero.
 10   3) change(82-08-19,DWoodka), approve(), audit(), install():
 11      changed rel_info.id and attr_info.index_id to bit (36) unaligned for the
 12      DMS conversion.
 13   4) change(82-09-20,MKubicar), approve(), audit(), install():
 14      changed rel_info.id and attr_info.index_id to aligned; they are needed that
 15      way for relmgr_ calls.  Also added rel_info.primary_key_index_id, needed
 16      for relation manager changes.
 17   5) change(85-12-02,Spitzer), approve(85-12-02,MCR7311),
 18      audit(86-09-02,Blair), install(86-10-16,MR12.0-1187):
 19      used 2 reserved bits to indicate whether the copy of the <rel>.m and/or
 20      <rel> files are good (for rmdb)
 21                                                    END HISTORY COMMENTS */
 22 
 23 
 24 /* each file in the database will have a model segment with the name
 25    file_name.m (i.e. the files name plus a suffix of ".m")
 26    the file_model structure is allocated at the base of the segment for a given file.
 27    it contains an area with which all other structures in this include file are allocated.
 28    these structures contain the information about which relations, foreign keys,
 29    and attributes are members of this file. all lists are singly linked lists in
 30    definition order. pointers to these structures are obtained by using the "pointer"
 31    builtin function with arguments of the segment base pointer, and the
 32    offset (bit (18)) relative to that pointer that is actually stored in
 33    the file model itself. this is because pointer segment numbers are
 34    per process dependent. the major lists pointed to by the file_model structure
 35    are the list of relations in this file(each with a contained attribute list),
 36    and the list of foreign keys whose parent relation resides in this file
 37    (along with a participating attribute sublist, and the child relation list,
 38    if they are also in this file) */
 39 
 40 dcl 1 file_model aligned based (fm_ptr),                    /* base of segment */
 41     2 temporary bit (1) unal,                               /* on if file not part of db. */
 42     2 procedures_present bit (1) unal,                      /* on => ids procedures present */
 43     2 file_model_copy_good bit (1) unaligned,               /* on => <rel>.m file is the good copy */
 44     2 relation_copy_good bit (1) unaligned,                 /* on => <rel> file is the good copy */
 45     2 reserved bit (32) unal,                               /* reserved for future flags */
 46     2 max_tuples fixed bin (35),                            /* max no. of tuples in file */
 47     2 num_blocks fixed bin (35),                            /* number of blocks in file */
 48     2 num_buckets fixed bin (35),                           /* number of buckets in file */
 49     2 pad_1 fixed bin (35),                                 /* for future use */
 50     2 pad_2 fixed bin (35),
 51     2 ratd_len fixed bin (21),                              /* length of above */
 52     2 mratd_len fixed bin (21),                             /* length of above */
 53     2 uatd_len fixed bin (21),                              /* char. length of update attach desc. */
 54     2 latd_len fixed bin (21),                              /* char. len. of attach desc. */
 55     2 sratd_len fixed bin (21),                             /* char. length of above attach desc. */
 56     2 suatd_len fixed bin (21),                             /* char. length of attach desc. */
 57     2 file_type unal fixed bin,                             /* 1 => unblocked, 2 => blocked */
 58     2 block_size unal fixed bin,                            /* no. pages in block */
 59     2 block_factor unal fixed bin,                          /* no. tuple slots per block */
 60     2 bucket_density unal fixed bin,                        /* no. of bucket headers per block, neg. => blocks per header */
 61     2 tuple_id_len unal fixed bin,                          /* no. bits needed for local tuple id */
 62     2 num_rels unal fixed bin,                              /* number of relations in file */
 63     2 num_links unal fixed bin,                             /* number of links in file */
 64     2 num_children unal fixed bin,                          /* count of all child_link_infos in this file */
 65     2 default_rbs (3) unal fixed bin (8),                   /* file ring brackets when not MDBM-secured */
 66     2 rel_ptr unal bit (18),                                /* to first of list of rel_infos */
 67     2 link_ptr unal bit (18),                               /* to first in list of parent link_infos */
 68     2 children_ptr unal bit (18),                           /* to list of all child_link_infos in this file model */
 69     2 cno_array_ptr unal bit (18),                          /* pointer to array of data component numbers */
 70     2 fi_ptr unal bit (18),                                 /* offset to file_info in db_model */
 71     2 suatd_ptr unal bit (18),                              /* offset of scope_update attach desc. */
 72     2 sratd_ptr unal bit (18),                              /* offset of scope_retrieve attach desc. */
 73     2 latd_ptr unal bit (18),                               /* offset of load attach desc. */
 74     2 uatd_ptr unal bit (18),                               /* offset of update attach description for file */
 75     2 mratd_ptr unal bit (18),                              /* offset of moniter-retrieve attach desc. */
 76     2 ratd_ptr unal bit (18),                               /* offset of retrieve attach desc. */
 77     2 open_eu_before_path_ptr unal bit (18),                /* paths and ents of file procs. */
 78     2 open_eu_err_path_ptr unal bit (18),
 79     2 open_eu_after_path_ptr unal bit (18),
 80     2 open_er_before_path_ptr unal bit (18),
 81     2 open_er_err_path_ptr unal bit (18),
 82     2 open_er_after_path_ptr unal bit (18),
 83     2 open_neu_before_path_ptr unal bit (18),               /* paths and ents of file procs. */
 84     2 open_neu_err_path_ptr unal bit (18),
 85     2 open_neu_after_path_ptr unal bit (18),
 86     2 open_ner_before_path_ptr unal bit (18),
 87     2 open_ner_err_path_ptr unal bit (18),
 88     2 open_ner_after_path_ptr unal bit (18),
 89     2 open_pu_before_path_ptr unal bit (18),
 90     2 open_pu_err_path_ptr unal bit (18),
 91     2 open_pu_after_path_ptr unal bit (18),
 92     2 open_pr_before_path_ptr unal bit (18),
 93     2 open_pr_err_path_ptr unal bit (18),
 94     2 open_pr_after_path_ptr unal bit (18),
 95     2 open_cu_before_path_ptr unal bit (18),
 96     2 open_cu_err_path_ptr unal bit (18),
 97     2 open_cu_after_path_ptr unal bit (18),
 98     2 open_cr_before_path_ptr unal bit (18),
 99     2 open_cr_err_path_ptr unal bit (18),
100     2 open_cr_after_path_ptr unal bit (18),
101     2 close_before_path_ptr unal bit (18),
102     2 close_err_path_ptr unal bit (18),
103     2 close_after_path_ptr unal bit (18),
104     2 unused_1 unal bit (18),                               /* for future expansion */
105     2 unused_2 unal bit (18),
106     2 changer_ptr unal bit (18),                            /* pointer to changer_id, changer_time structure */
107     2 fm_area area (sys_info$max_seg_size - fixed (rel (addr (file_model.fm_area))) - 1);
108 dcl  fm_ptr ptr;
109 dcl  atd char (atd_len) based (atd_ptr);                    /* attach description for each file ready mode */
110 dcl  atd_ptr ptr;
111 dcl  atd_len fixed bin;
112 dcl 1 comp_no_array unal based (cna_ptr),                   /* ordered array of data comp. nos. */
113     2 ncomponents fixed bin,
114     2 comp_no (ncomp_init refer (comp_no_array.ncomponents)) fixed bin;
115 dcl  cna_ptr ptr;
116 dcl  ncomp_init fixed bin;
117 
118 /* a rel_info structure contains information describing a relation.
119    a relation may only occur in one file, thus there is one rel_info
120    per relation per database, each stored in the file_model area for
121    the file that contains it. the list of rel_info's in this file
122    form a singly linked list in definition order.
123    the rel_info itself points to a list of the attributes it contains,
124    and to any parent_link or child_link info's that involve it in a foreign key */
125 
126 dcl 1 rel_info aligned based (ri_ptr),
127     2 name char (32),                                       /* relation name */
128     2 id  bit (36) aligned,                                 /* relation id number */
129     2 hashed bit (1) unal,                                  /* on if hashed */
130     2 duplicates bit (1) unal,                              /* on if allow dup. hash fields */
131     2 via_link bit (1) unal,                                /* on if to be stored by parent */
132     2 system bit (1) unal,                                  /* on if dont care how stored */
133     2 indexed bit (1) unal,                                 /* on if secondary index */
134     2 mrds_update bit (1) unal,                             /* on if updateable by MRDS */
135     2 mrds_retrieve bit (1) unal,                           /* on if retrievable by MRDS */
136     2 virtual bit (1) unal,                                 /* if virtual relation, mapped on IDS records */
137     2 procedures_present bit (1) unal,                      /* on => ids type procedures present */
138     2 reserved bit (27) unal,                               /* for future flags */
139     2 num_attr unal fixed bin,                              /* number of attributes (all levels) defined */
140     2 num_links_child unal fixed bin,                       /* no. links in which child */
141     2 num_links_par unal fixed bin,                         /* no. links_in which parent */
142     2 max_attr_index_id unal fixed bin,                     /* max index id used by attr in this rel or PLI */
143     2 num_key_attrs unal fixed bin,                         /* number of attributes in primary key for this rel */
144     2 nvar_atts unal fixed bin,                             /* no. varying len. attributes */
145     2 n36_thds unal fixed bin,                              /* no. of 36-bit threads */
146     2 n27_thds unal fixed bin,                              /* no of 27-bit threads */
147     2 n18_thds unal fixed bin,                              /* no of 18-bit threads */
148     2 unused_3 unal fixed bin,                              /* element that was never used */
149     2 max_data_len fixed bin (35),                          /* max length of data portion of tuple */
150     2 avg_data_len fixed bin (35),                          /* average length of tuple data portion */
151     2 max_key_len fixed bin (35),                           /* max key length if not hashed */
152     2 var_offset fixed bin (35),                            /* position of first varying attr. */
153     2 max_tuples fixed bin (35),                            /* max no. tuples if blocked file */
154     2 fwd_thread unal bit (18),                             /* offsset to next rel. in file */
155     2 attr_ptr unal bit (18),                               /* to attr. info */
156     2 primary_key_index_id bit (36) aligned,                /* index id of the relation's primary key */
157     2 clink_ptr unal bit (18),                              /* offset to child info of link determining location */
158     2 map_ptr unal bit (18),                                /* pointer to mapping info if virtual rel. */
159     2 sec_ind_ptr unal bit (18),                            /* ptr to list of sec. ind. infos, init. not used */
160     2 locator_proc_path_ptr unal bit (18),                  /* proc to determ. location */
161     2 link_before_path_ptr unal bit (18),                   /* op. proc. paths and entries */
162     2 link_err_path_ptr unal bit (18),
163     2 link_after_path_ptr unal bit (18),
164     2 unlk_before_path_ptr unal bit (18),
165     2 unlk_err_path_ptr unal bit (18),
166     2 unlk_after_path_ptr unal bit (18),
167     2 str_before_path_ptr unal bit (18),
168     2 str_err_path_ptr unal bit (18),
169     2 str_after_path_ptr unal bit (18),
170     2 del_before_path_ptr unal bit (18),
171     2 del_err_path_ptr unal bit (18),
172     2 del_after_path_ptr unal bit (18),
173     2 mod_before_path_ptr unal bit (18),
174     2 mod_err_path_ptr unal bit (18),
175     2 mod_after_path_ptr unal bit (18),
176     2 find_before_path_ptr unal bit (18),
177     2 find_err_path_ptr unal bit (18),
178     2 find_after_path_ptr unal bit (18),
179     2 retr_before_path_ptr unal bit (18),
180     2 retr_err_path_ptr unal bit (18),
181     2 retr_after_path_ptr unal bit (18),
182     2 unused_1 unal bit (18),                               /* for future expansion */
183     2 unused_2 unal bit (18),
184     2 changer_ptr unal bit (18) ;                           /* pointer to changer_id, changer_time structure */
185 dcl  ri_ptr ptr;
186 
187 /* a attr_info structure contains information about an attribute in a given relation.
188    since attributes may appear in more than one relation, each occurence of an attribute
189    means that an attr_info for it will be put in that relations sublist of attributes.
190    the list is singly linked in definition order. the attr_info describes
191    the data it represents, and how that data is used during a database search. */
192 dcl 1 attr_info aligned based (ai_ptr),                     /* info for a single attr. in attr. list */
193     2 name char (32),                                       /* name of attribute */
194     2 key_attr bit (1) unal,                                /* on if part of primary or hash key */
195     2 index_attr bit (1) unal,                              /* on if a secondary index */
196     2 link_attr bit (1) unal,                               /* on if participates in link */
197     2 reserved bit (33) unal,
198     2 index_id bit (36) aligned,                            /* id of index if index attr. */
199     2 defn_order unal fixed bin,                            /* relative posit. in which defined */
200     2 key_order unal fixed bin,                             /* relative posit. in key */
201     2 bit_offset fixed bin (35),                            /* position in tuple */
202     2 bit_length fixed bin (35),                            /* length if fixed */
203     2 link_child_cnt fixed bin,                             /* number of uses of attr in child rel of link */
204     2 link_par_cnt fixed bin,                               /* number of uses of attr in parent rel of link */
205     2 domain_ptr unal bit (18),                             /* to domain info */
206     2 rslt_ptr unal bit (18),                               /* ptr to info for "result" clause */
207     2 fwd_thread unal bit (18),                             /* to next in list */
208     2 changer_ptr unal bit (18) ;                           /* pointer to changer_id and changer_time */
209 dcl  ai_ptr ptr;
210 
211 /* a parent_link_info structure is the carrier of foreign key definition info.
212    each time a foreign key definition indicates a relation as it's parent,
213    that relation will get a parent_link_info put in a list of associated parent_link_info's.
214    a relation can be parent and/or child in any number of foreign keys.
215    the parent_link_info structure describes the foreign key, and also points
216    to a list of the attributes that participate in this foreign key.
217    (this could be from 1 up to all attributes in the relation)
218    the attr_list structures are in a singly linked list in definition order
219    for this purpose. also pointed to is a list of child_link_info's
220    that describe the child relations in this foreign key. since foreign keys
221    may span files, not all related child_link_info's have to be in this file's
222    model area. */
223 dcl 1 parent_link_info aligned based (pli_ptr),             /* gen'l link info, appears in each area spanned by link parent */
224     2 name char (32),                                       /* name of link */
225     2 singular bit (1) unal,                                /* on if system owned link */
226     2 temp bit (1) unal,                                    /* on if temp. order */
227     2 first bit (1) unal,                                   /* insertion indicators */
228     2 last bit (1) unal,
229     2 next bit (1) unal,
230     2 prior bit (1) unal,
231     2 sort_rel_name bit (1) unal,                           /* sort -- relation name */
232     2 sort_keys bit (1) unal,                               /* sort -- defined keys */
233     2 dup_first bit (1) unal,                               /* duplicates first */
234     2 dup_last bit (1) unal,                                /* duplicates last */
235     2 indexed bit (1) unal,                                 /* locate parent via index */
236     2 hashed bit (1) unal,                                  /* locate parent via hashed primary key */
237     2 thread_36 bit (1) unal,                               /* thread size indicators */
238     2 thread_27 bit (1) unal,
239     2 thread_18 bit (1) unal,
240     2 clustered bit (1) unal,                               /* ON => cluster option specified for this link */
241     2 procedures_present bit (1) unal,                      /* on => ids type procedures present */
242     2 reserved bit (19) unal,                               /* reserved for future flags */
243     2 index_id aligned bit (8),                             /* id of index if indexed */
244     2 thread_index unal fixed bin,                          /* index to threads in parent */
245     2 nsel_attr unal fixed bin,                             /* no. attr. determ. parent */
246     2 n_children unal fixed bin,                            /* no. children in link */
247     2 child_fn char (30),                                   /* file name for first child in list */
248     2 parent_ptr unal bit (18),                             /* to parent relation info in file model */
249     2 child_ptr unal bit (18),                              /* to list of child info ptrs */
250     2 sel_attr_ptr unal bit (18),                           /* to first in list of attr. determ. parent */
251     2 fwd_thread unal bit (18),                             /* thread to next parent link info in file */
252     2 rel_fwd_thread unal bit (18),                         /* for multiple links within a relation */
253     2 sort_before_path_ptr unal bit (18),                   /* proc. paths and entries */
254     2 sort_err_path_ptr unal bit (18),
255     2 sort_after_path_ptr unal bit (18),
256     2 srch_before_path_ptr unal bit (18),
257     2 srch_err_path_ptr unal bit (18),
258     2 srch_after_path_ptr unal bit (18),
259     2 link_before_path_ptr unal bit (18),
260     2 link_err_path_ptr unal bit (18),
261     2 link_after_path_ptr unal bit (18),
262     2 unlk_before_path_ptr unal bit (18),
263     2 unlk_err_path_ptr unal bit (18),
264     2 unlk_after_path_ptr unal bit (18),
265     2 unused_1 unal bit (18),                               /* for future expansion */
266     2 unused_2 unal bit (18),
267     2 changer_ptr unal bit (18) ;                           /* pointer to changer_id, changer_time structure */
268 dcl  pli_ptr ptr;
269 
270 /* a child_link_info structure is the counter part of a parent_link_info
271    for foreign key child relations. each time a relation is defined to be
272    a child in a foreign key, it's list of child_link_infos will be added to.
273    this list is singly linked in foreign key definition order.
274    the child_link_info points to a list of participating attributes from the
275    child relation by means of a singly linked list of attr_list structures
276    in definition order. the number of attributes in the parent attr_list
277    and the child attr_list lists are the same with corresponding attr_list
278    attributes having the same domain. all child_link_infos in this file
279    are on a seperately linked list. this may not include all
280    child_link_infos for foreign keys whose parent relation resides in this file,
281    since foreign keys may span files, and the child_link_info will
282    reside in the file containing it's associated relation_info. */
283 dcl 1 child_link_info aligned based (cli_ptr),              /* in same files as children */
284     2 link_name char (32),                                  /* name of foreign key involving parent relation for this child */
285     2 mandatory bit (1) unal,                               /* on if membership mandatory */
286     2 fixed bit (1) unal,                                   /* on if membership fixed */
287     2 optional bit (1) unal,                                /* on if membership optional */
288     2 auto bit (1) unal,                                    /* on if insertion automatic */
289     2 manual bit (1) unal,                                  /* on if insertion manual */
290     2 struct_const bit (1) unal,                            /* on if membership constrained by attr. comp. */
291     2 range_sel bit (1) unal,                               /* on if range type selection */
292     2 key_dup_first bit (1) unal,                           /* sort key flags */
293     2 key_dup_last bit (1) unal,
294     2 key_null bit (1) unal,                                /* on if null allowed */
295     2 sel_system bit (1) unal,                              /* selection criteria flags */
296     2 sel_current bit (1) unal,
297     2 sel_key bit (1) unal,
298     2 sel_proc bit (1) unal,
299     2 no_null bit (1) unal,                                 /* if null key values not allowed */
300     2 reserved bit (21) unal,
301     2 thread_index unal fixed bin,                          /* index to thread in tuple */
302     2 chain_len unal fixed bin,                             /* no. "then-thru's" in selction crit. */
303     2 n_sort_keys unal fixed bin,                           /* no. attr. in sort key */
304     2 n_sel_items unal fixed bin,                           /* no. items to sel for link sel. */
305     2 n_dup_prevs unal fixed bin,                           /* no. attr. for dup prev. */
306     2 link_fwd_fn char (30),                                /* file name for next child info in link */
307     2 parent_fn char (30),                                  /* file name for parent info */
308     2 parent_ptr unal bit (18),                             /* offset to parent link info */
309     2 link_fwd_thread unal bit (18),                        /* offset for next child in link */
310     2 rel_info_ptr unal bit (18),                           /* to corresponding rel info */
311     2 dup_prev_ptr unal bit (18),                           /* list of attrs. for dup. prev. */
312     2 sel_ptr unal bit (18),                                /* list of attr. for link sel. */
313     2 rel_fwd_thread unal bit (18),                         /* for multiple links within a relation */
314     2 child_fwd_thread unal bit (18),                       /* pointer to next in list of all child_link_infos in this file */
315     2 sort_key_ptr unal bit (18),                           /* list of sort keys */
316     2 chain_ptr unal bit (18),                              /* to "then thru" list */
317     2 sel_proc_path_ptr unal bit (18),                      /* link selection proc. */
318     2 link_before_path_ptr unal bit (18),                   /* proc. paths and entries */
319     2 link_err_path_ptr unal bit (18),
320     2 link_after_path_ptr unal bit (18),
321     2 unlk_before_path_ptr unal bit (18),
322     2 unlk_err_path_ptr unal bit (18),
323     2 unlk_after_path_ptr unal bit (18),
324     2 srch_before_path_ptr unal bit (18),
325     2 srch_err_path_ptr unal bit (18),
326     2 srch_after_path_ptr unal bit (18),
327     2 unused_1 unal bit (18),                               /* for future expansion */
328     2 unused_2 unal bit (18) ;
329 dcl  cli_ptr ptr;
330 
331 /* the attr_list structure is associated with the parent_link_info
332    and child_link_info structures to represent by means of a singly linked list
333    the participating attributes from relations in a foreign key.
334    the parent_link_info has a list for the parent relation,
335    and the child_link_info has a list for the child relation.
336    the participating attributes are a subset(not necessary proper) of
337    those attributes contained in a relation definition.
338    there are equal numbers of attr_list structures in the parent and
339    child lists of the same foreign key. the corresponding attributes in these
340    lists must have the same domain. */
341 dcl 1 attr_list aligned based (al_ptr),                     /* general attr. list */
342     2 attr_fn char (30),                                    /* file name for attr. */
343     2 attr_ptr unal bit (18),                               /* to attr info block */
344     2 fwd_thread unal bit (18);                             /* to next in list */
345 dcl  al_ptr ptr;
346 dcl 1 sort_key aligned based (sk_ptr),                      /* entry in sort key list */
347     2 ascend bit (1) unal,                                  /* ascending order */
348     2 descend bit (1) unal,                                 /* descending order */
349     2 reserved bit (34) unal,
350     2 attr_ptr unal bit (18),                               /* to attr info */
351     2 fwd_thread unal bit (18);                             /* to next in list */
352 dcl  sk_ptr ptr;
353 dcl 1 dup_prev aligned based (dp_ptr),                      /* dup. prevention list entry */
354     2 attr_ptr unal bit (18),                               /* to attr info */
355     2 fwd_thread unal bit (18);                             /* to next in list */
356 dcl  dp_ptr ptr;
357 dcl 1 select_chain aligned based (sc_ptr),                  /* "then thru" list entry */
358     2 link_fn char (30),                                    /* file name for thru link */
359     2 link_ptr unal bit (18),                               /* to parent link info */
360     2 parent_attr_ptr unal bit (18),                        /* to parent ident. attr. list */
361     2 comp_proc_path_ptr unal bit (18),                     /* comparison procedure */
362     2 comp_attr_fn char (30),                               /* file name for comparison attr. */
363     2 comp_attr_ptr unal bit (18),                          /* to comparison attr list */
364     2 fwd_thread unal bit (18);                             /* to next in chain */
365 dcl  sc_ptr ptr;
366 
367 /* END INCLUDE FILE mdbm_file_model.incl.pl1 */
368 
369