1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 mu_retrieve: proc (dbcb_ptr, area_ptr, rti_ptr, search_spec_ptr_parm,
32 cvla_ptr_parm, tid_ptr, tuple_var_name, whole_stv_ptr,
33 simple_typed_vector_ptr_parm, id_list_ptr_parm, code);
34
35
36
37
38
39
40
41 %page;
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89 debug
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175 Note
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202 %page;
203 display_values_compared = substr (db_mu_retrieve, 1, 1);
204 display_tuple_data = substr (db_mu_retrieve, 2, 1);
205 cvla_ptr = cvla_ptr_parm;
206 id_list_ptr = id_list_ptr_parm;
207 simple_typed_vector_ptr = simple_typed_vector_ptr_parm;
208
209 rmri_ptr = rtrv_info.ri_ptr;
210 k = 0;
211 ta_ptr = rtrv_info.ta_ptr;
212 ta_nids = rtrv_info.ntids;
213
214 found = "0"b;
215 do while (^found);
216
217 call get_next_tuple (dbcb_ptr, rti_ptr,
218 search_spec_ptr_parm, simple_typed_vector_ptr, tuple_id);
219 found = "1"b;
220
221
222
223
224 i, j = 0;
225 if cvla_ptr ^= null then do;
226
227 work_area_ptr = dbcb.work_area_ptr;
228 match = "0"b;
229 do i = 1 to cvl_array.nlists while (^match);
230 cvl_ptr = cvl_array.list_ptr (i);
231 match = "1"b;
232 do j = 1 to comp_val_list.nvals while (match);
233
234 desc_ptr1 = addr (comp_val_list.val.desc1 (j));
235 desc_ptr2 = addr (comp_val_list.val.desc2 (j));
236 need_to_free_user_value = "0"b;
237 GET_COMPARISON_VALUE:
238 call get_comparison_value (
239 comp_val_list.val.exp_ptr (j),
240 null(),
241 comp_val_list.val.erslt_ptr (j),
242 comp_val_list.val.attr_ind (j),
243 desc_ptr1,
244 di_ptr,
245 icode);
246 if icode = error_table_$noalloc
247 then do;
248 call mrds_area_initialize (work_area_ptr);
249 go to GET_COMPARISON_VALUE;
250 end;
251 if comp_val_list.val.match_ptr (j) = null ()
252 then do;
253 call get_comparison_value (
254 comp_val_list.val.exp_ptr2 (j),
255 comp_val_list.val.c_ai_ptr2 (j),
256 comp_val_list.val.erslt_ptr2 (j),
257 comp_val_list.val.attr_ind2 (j),
258 desc_ptr2,
259 di_ptr2,
260 icode);
261 if icode = error_table_$noalloc then do;
262 call mrds_area_initialize (work_area_ptr);
263 go to GET_COMPARISON_VALUE;
264 end;
265 end;
266 else do;
267 di_ptr2 = comp_val_list.val.match_ptr (j);
268 end;
269
270 call mu_compare_values (di_ptr, desc_ptr1, di_ptr2, desc_ptr2,
271 comp_val_list.val.op (j), match, code);
272
273 if display_values_compared | code ^= 0 then do;
274 if display_values_compared then
275 call ioa_ ("di_ptr = ^p; di_ptr2 = ^p", di_ptr, di_ptr2);
276 if display_values_compared then
277 call ioa_ ("Compared: ");
278 else call ioa_ ("Compared the data type: ^a", mu_display_descriptor (desc_ptr1));
279 call mdb_display_data_value$ptr (di_ptr, desc_ptr1);
280 call ioa_ ("Using the comparison operator ""^a"" to:", rtrim (CVL_ops (comp_val_list.val.op (j))));
281 if ^display_values_compared then
282 call ioa_ ("The data type: ^a", mu_display_descriptor (desc_ptr2));
283 call mdb_display_data_value$ptr (di_ptr2, desc_ptr2);
284 end;
285
286 if code ^= 0
287 then call error (code);
288 if need_to_free_user_value then
289 free value_for_user;
290 end;
291 end;
292 found = match;
293 end;
294 if display_tuple_data then do;
295 call mdb_display_tuple_$data (simple_typed_vector_ptr, rmri_ptr, iox_$user_output, icode);
296 if icode ^= 0 then call error (icode);
297 if found
298 then call ioa_ ("Tuple Accepted for ""^a""", tuple_var_name);
299 else call ioa_ ("Tuple Rejected for ""^a""", tuple_var_name);
300 end; debug
301 end;
302
303 code = 0;
304
305 exit:
306 return;
307 %page;
308 get_next_tuple:
309 proc (dbcbptr, retrieve_info_ptr, search_spec_ptr,
310 simple_typed_vector_ptr, tuple_id);
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327 Note
328
329
330 Note
331
332 Note
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353 dcl dbcbptr ptr;
354 dcl retrieve_info_ptr ptr;
355 dcl search_spec_ptr ptr;
356 dcl simple_typed_vector_ptr ptr;
357 dcl tuple_id bit (36) aligned;
358 dcl continue_for_next_tuple bit (1) aligned;
359
360
361
362 dcl icode fixed bin (35);
363
364
365
366
367 continue_for_next_tuple = "1"b;
368 do while (continue_for_next_tuple);
369 continue_for_next_tuple = "0"b;
370 if dbcb.scopes_changed then do;
371 if retrieve_info_ptr -> rtrv_info.ri_ptr -> rm_rel_info.file_type ^= 3 then
372
373 if dbcb.non_shared_to_shared = "0"b then do;
374 current_scope_ptr = retrieve_info_ptr -> rtrv_info.ri_ptr -> rm_rel_info.scope_flags_ptr;
375 if (current_scope_flags.permits.read_attr |
376 current_scope_flags.permits.delete_tuple |
377 current_scope_flags.permits.modify_attr) then
378 if ^current_scope_flags.prevents.modify_attr |
379 (^current_scope_flags.prevents.append_tuple &
380 ^current_scope_flags.prevents.delete_tuple) then
381 if retrieve_info_ptr -> rtrv_info.maxtids ^=
382 mrds_data_$max_safe_tids_returned_per_call then
383
384
385 dbcb.non_shared_to_shared = "1"b;
386 end;
387 end;
388
389 if retrieve_info_ptr -> rtrv_info.ctid >=
390 retrieve_info_ptr -> rtrv_info.ntids then do;
391 if retrieve_info_ptr -> rtrv_info.first_seq_io then do;
392 retrieve_info_ptr -> rtrv_info.first_seq_io = "0"b;
393 search_spec_ptr -> relation_search_specification.head.type =
394 ABSOLUTE_RELATION_SEARCH_SPECIFICATION_TYPE;
395 end;
396 else do;
397 if retrieve_info_ptr -> rtrv_info.ntids <
398 retrieve_info_ptr -> rtrv_info.maxtids
399 then call error (mrds_error_$tuple_not_found);
400 search_spec_ptr -> relation_search_specification.head.type =
401 RELATIVE_RELATION_SEARCH_SPECIFICATION_TYPE;
402 retrieve_info_ptr -> rtrv_info.ta_ptr -> element_id_list.number_of_elements = 0;
403 end;
404 call dbcbptr -> dbcb.relmgr_entries.get_tuple_id (
405 retrieve_info_ptr -> rtrv_info.relation_cursor_ptr,
406 search_spec_ptr, dbcbptr -> dbcb.select_area_ptr,
407 retrieve_info_ptr -> rtrv_info.ta_ptr,
408 icode);
409 if icode ^= 0
410 then call error (icode);
411 retrieve_info_ptr -> rtrv_info.ctid = 0;
412 retrieve_info_ptr -> rtrv_info.ntids =
413 retrieve_info_ptr -> rtrv_info.ta_ptr -> element_id_list.number_of_elements;
414 end;
415
416
417
418
419 retrieve_info_ptr -> rtrv_info.ctid =
420 retrieve_info_ptr -> rtrv_info.ctid + 1;
421 tuple_id = retrieve_info_ptr -> rtrv_info.ta_ptr ->
422 element_id_list.id (retrieve_info_ptr -> rtrv_info.ctid);
423 if id_list_ptr -> id_list.number_of_ids > 0
424 then do;
425 call dbcbptr -> dbcb.relmgr_entries.get_tuple_by_id (
426 retrieve_info_ptr -> rtrv_info.relation_cursor_ptr,
427 tuple_id, id_list_ptr, dbcbptr -> dbcb.select_area_ptr,
428 simple_typed_vector_ptr, icode);
429 if icode = mrds_error_$inconsistent_data_length then do;
430 icode = 0;
431 continue_for_next_tuple = "1"b;
432 end;
433 else if icode ^= 0
434 then call error (icode);
435 end;
436 end;
437
438 end get_next_tuple;
439 %page;
440 get_comparison_value: proc (exp_ptr, ai_ptr, erslt_ptr, attr_index, desc_ptr, di_ptr, icode);
441
442
443
444
445
446
447 dcl exp_ptr ptr;
448 dcl ai_ptr ptr;
449 dcl erslt_ptr ptr;
450 dcl attr_index fixed bin (17);
451 dcl desc_ptr ptr;
452 dcl di_ptr ptr;
453 dcl icode fixed bin (35);
454
455 icode = 0;
456 if exp_ptr = null ()
457 then do;
458 di_ptr = whole_stv_ptr -> simple_typed_vector.dimension (attr_index).value_ptr;
459 if ai_ptr ^= null then
460 if ai_ptr -> rm_attr_info.domain_ptr -> rm_domain_info.decd_proc
461 then do;
462 t_domain_ptr = ai_ptr -> rm_attr_info.domain_ptr;
463 user_bit_length = t_domain_ptr -> rm_domain_info.user_bit_len;
464 user_val_ptr = mrds_space_allocate (work_area_ptr, (user_bit_length + 35) / 36);
465 if user_val_ptr = null () then do;
466 icode = error_table_$noalloc;
467 return;
468 end;
469 k = k + 1;
470 value_for_user = "0"b;
471
472 call mu_get_data$get_data_item (ai_ptr, work_area_ptr, di_ptr,
473 user_val_ptr, desc_ptr, icode);
474 if icode = error_table_$noalloc then
475 return;
476 di_ptr = user_val_ptr;
477 end;
478 end;
479 else do;
480 di_ptr = erslt_ptr;
481 call mrds_dsl_eval_expr (area_ptr, exp_ptr, rmri_ptr, whole_stv_ptr, icode);
482 end;
483 if icode ^= 0 then call error (icode);
484 end get_comparison_value;
485 %page;
486 %include mrds_space_allocate;
487 %page;
488 %include mrds_area_initialize;
489 %page;
490 error: proc (cd);
491
492
493
494 dcl cd fixed bin (35);
495
496 if (cd = dm_error_$no_tuple) | (cd = dm_error_$no_tuple_id)
497 then code = mrds_error_$no_tuple;
498 else code = cd;
499 go to exit;
500
501 end error;
502 %page;
503 dcl cvla_ptr_parm ptr;
504 dcl id_list_ptr_parm ptr parameter;
505 dcl simple_typed_vector_ptr_parm ptr parameter;
506 dcl search_spec_ptr_parm ptr;
507 dcl tuple_var_name char (*);
508 dcl user_bit_length fixed bin;
509 dcl value_for_user bit (user_bit_length) based (user_val_ptr);
510 dcl work_area_ptr ptr;
511
512 dcl (i, k,
513 j) fixed bin;
514
515 dcl (code,
516 icode) fixed bin (35);
517
518 dcl (area_ptr,
519 desc_ptr1,
520 desc_ptr2,
521 di_ptr,
522 di_ptr2,
523 t_domain_ptr,
524 tid_ptr,
525 user_val_ptr,
526 whole_stv_ptr) ptr;
527
528
529 dcl (display_tuple_data,
530 display_values_compared,
531 found) bit (1) unaligned;
532
533 dcl match bit (1) aligned;
534 dcl need_to_free_user_value bit (1) aligned;
535
536 dcl (addr,
537 fixed,
538 null,
539 rel,
540 rtrim,
541 substr,
542 unspec) builtin;
543
544 dcl tuple_id bit (36) aligned based (tid_ptr);
545
546 dcl CVL_ops (1:6) char (2) int static options (constant) init (
547 "=",
548 "^=",
549 "<",
550 "<=",
551 ">",
552 ">=");
553 dcl 1 current_scope_flags aligned based (current_scope_ptr) like scope_flags;
554 dcl current_scope_ptr ptr;
555 dcl dm_error_$no_tuple fixed bin (35) ext static;
556 dcl dm_error_$no_tuple_id fixed bin (35) ext static;
557 dcl mrds_data_$max_safe_tids_returned_per_call fixed bin (35) ext static;
558 dcl mrds_error_$no_tuple ext fixed bin (35);
559 dcl mrds_error_$tuple_not_found fixed bin (35) ext static;
560 dcl mrds_error_$inconsistent_data_length fixed bin (35) ext static;
561 dcl mrds_dsl_eval_expr entry (ptr, ptr, ptr, ptr, fixed bin (35));
562 dcl ioa_ entry options (variable);
563
564 dcl iox_$user_output ext ptr;
565
566 dcl sys_info$max_seg_size fixed bin (35) ext static;
567
568 dcl error_table_$noalloc fixed bin (35) ext static;
569
570 dcl mdb_display_data_value$ptr entry (ptr, ptr);
571
572 dcl mdb_display_tuple_$data entry (ptr, ptr, ptr, fixed bin (35));
573 dcl mu_compare_values entry (ptr, ptr, ptr, ptr, fixed bin, bit (1) aligned, fixed bin (35));
574 dcl mu_display_descriptor entry (ptr) returns (char (120) varying);
575 dcl mu_get_data$get_data_item entry (ptr, ptr, ptr, ptr, ptr, fixed bin (35));
576 %page;
577 %include dm_element_id_list;
578 %page;
579 %include dm_id_list;
580 %page;
581 %include dm_relation_spec;
582 %page;
583 %include dm_specification_head;
584 %page;
585 %include mdbm_scope_info;
586 %page;
587 %include mdbm_comp_val_list;
588 %page;
589 %include mdbm_rm_rel_info;
590 %page;
591 %include mdbm_rm_attr_info;
592 %page;
593 %include mdbm_rm_domain_info;
594 %page;
595 %include mdbm_rtrv_info;
596 %page;
597 %include mrds_debug_names;
598 %page;
599 %include mrds_dbcb;
600 %page;
601 %include vu_typed_vector;
602
603 end mu_retrieve;