|
|
FMT format; | FMT format; |
USHORT id; | USHORT id; |
| |
id = (USHORT) node->nod_arg[e_fld_id]; |
id = (USHORT)(IPTR) node->nod_arg[e_fld_id]; |
format = | format = |
CMP_format(tdbb, csb, (USHORT) node->nod_arg[e_fld_stream]); |
CMP_format(tdbb, csb, (USHORT)(IPTR) node->nod_arg[e_fld_stream]); |
if (id >= format->fmt_count) { | if (id >= format->fmt_count) { |
desc->dsc_dtype = dtype_null; | desc->dsc_dtype = dtype_null; |
desc->dsc_length = 0; | desc->dsc_length = 0; |
|
|
| |
sub = node->nod_arg[e_scl_field]; | sub = node->nod_arg[e_scl_field]; |
relation = | relation = |
csb->csb_rpt[(USHORT) sub-> |
csb->csb_rpt[(USHORT)(IPTR) sub-> |
nod_arg[e_fld_stream]].csb_relation; | nod_arg[e_fld_stream]].csb_relation; |
id = (USHORT) sub->nod_arg[e_fld_id]; |
id = (USHORT)(IPTR) sub->nod_arg[e_fld_id]; |
field = MET_get_field(relation, id); | field = MET_get_field(relation, id); |
if (!field || !(array = field->fld_array)) | if (!field || !(array = field->fld_array)) |
IBERROR(223); /* msg 223 argument of scalar operation must be an array */ | IBERROR(223); /* msg 223 argument of scalar operation must be an array */ |
|
|
return; | return; |
| |
case nod_extract: | case nod_extract: |
if ((ULONG) node->nod_arg[e_extract_part] == blr_extract_second) { |
if ((ULONG)(IPTR) node->nod_arg[e_extract_part] == blr_extract_second) { |
/* QUADDATE - SECOND returns a float, or scaled! */ | /* QUADDATE - SECOND returns a float, or scaled! */ |
desc->dsc_dtype = dtype_long; | desc->dsc_dtype = dtype_long; |
desc->dsc_length = sizeof(ULONG); | desc->dsc_length = sizeof(ULONG); |
|
|
| |
message = node->nod_arg[e_arg_message]; | message = node->nod_arg[e_arg_message]; |
format = (FMT) message->nod_arg[e_msg_format]; | format = (FMT) message->nod_arg[e_msg_format]; |
*desc = format->fmt_desc[(int) node->nod_arg[e_arg_number]]; |
*desc = format->fmt_desc[(int)(IPTR) node->nod_arg[e_arg_number]]; |
return; | return; |
} | } |
| |
|
|
!input->nod_arg[e_fld_id] && !input->nod_arg[e_fld_stream]) | !input->nod_arg[e_fld_id] && !input->nod_arg[e_fld_stream]) |
--field_id; | --field_id; |
else | else |
field_id = (USHORT) input->nod_arg[e_fld_id]; |
field_id = (USHORT)(IPTR) input->nod_arg[e_fld_id]; |
stream = (USHORT) input->nod_arg[e_fld_stream]; |
stream = (USHORT)(IPTR) input->nod_arg[e_fld_stream]; |
if (remap_fld) { | if (remap_fld) { |
JRD_REL relation; | JRD_REL relation; |
JRD_FLD field; | JRD_FLD field; |
|
|
relation = (*csb)->csb_rpt[stream].csb_relation; | relation = (*csb)->csb_rpt[stream].csb_relation; |
field = MET_get_field(relation, field_id); | field = MET_get_field(relation, field_id); |
if (field->fld_source) | if (field->fld_source) |
field_id = (USHORT) field->fld_source->nod_arg[e_fld_id]; |
field_id = (USHORT)(IPTR) field->fld_source->nod_arg[e_fld_id]; |
} | } |
if (remap) | if (remap) |
stream = remap[stream]; | stream = remap[stream]; |
|
|
node->nod_type = input->nod_type; | node->nod_type = input->nod_type; |
node->nod_count = 0; | node->nod_count = 0; |
| |
stream = (USHORT) input->nod_arg[e_rel_stream]; |
stream = (USHORT)(IPTR) input->nod_arg[e_rel_stream]; |
/** | /** |
Last entry in the remap contains the the original stream number. | Last entry in the remap contains the the original stream number. |
Get that stream number so that the flags can be copied | Get that stream number so that the flags can be copied |
|
|
node->nod_arg[e_prc_inputs] = | node->nod_arg[e_prc_inputs] = |
copy(tdbb, csb, input->nod_arg[e_prc_inputs], remap, field_id, | copy(tdbb, csb, input->nod_arg[e_prc_inputs], remap, field_id, |
node->nod_arg[e_prc_in_msg], remap_fld); | node->nod_arg[e_prc_in_msg], remap_fld); |
stream = (USHORT) input->nod_arg[e_prc_stream]; |
stream = (USHORT)(IPTR) input->nod_arg[e_prc_stream]; |
new_stream = (*csb)->csb_n_stream++; | new_stream = (*csb)->csb_n_stream++; |
node->nod_arg[e_prc_stream] = (JRD_NOD) (SLONG) new_stream; | node->nod_arg[e_prc_stream] = (JRD_NOD) (SLONG) new_stream; |
/* TMN: Here we should really have the following assert */ | /* TMN: Here we should really have the following assert */ |
|
|
element = CMP_csb_element(csb, new_stream); | element = CMP_csb_element(csb, new_stream); |
// SKIDDER: Maybe we need to check if we really found a procedure ? | // SKIDDER: Maybe we need to check if we really found a procedure ? |
element->csb_procedure = MET_lookup_procedure_id(tdbb, | element->csb_procedure = MET_lookup_procedure_id(tdbb, |
(SSHORT)node->nod_arg[e_prc_procedure],FALSE,FALSE,0); |
(SSHORT)(IPTR)node->nod_arg[e_prc_procedure],FALSE,FALSE,0); |
| |
(*csb)->csb_rpt[new_stream].csb_flags |= | (*csb)->csb_rpt[new_stream].csb_flags |= |
(*csb)->csb_rpt[stream].csb_flags & csb_no_dbkey; | (*csb)->csb_rpt[stream].csb_flags & csb_no_dbkey; |
|
|
node = PAR_make_node(tdbb, e_agg_length); | node = PAR_make_node(tdbb, e_agg_length); |
node->nod_type = input->nod_type; | node->nod_type = input->nod_type; |
node->nod_count = 0; | node->nod_count = 0; |
stream = (USHORT) input->nod_arg[e_agg_stream]; |
stream = (USHORT)(IPTR) input->nod_arg[e_agg_stream]; |
assert(stream <= MAX_STREAMS); | assert(stream <= MAX_STREAMS); |
new_stream = (*csb)->csb_n_stream++; | new_stream = (*csb)->csb_n_stream++; |
assert(new_stream <= MAX_STREAMS); | assert(new_stream <= MAX_STREAMS); |
|
|
node = PAR_make_node(tdbb, e_uni_length); | node = PAR_make_node(tdbb, e_uni_length); |
node->nod_type = input->nod_type; | node->nod_type = input->nod_type; |
node->nod_count = 2; | node->nod_count = 2; |
stream = (USHORT) input->nod_arg[e_uni_stream]; |
stream = (USHORT)(IPTR) input->nod_arg[e_uni_stream]; |
new_stream = (*csb)->csb_n_stream++; | new_stream = (*csb)->csb_n_stream++; |
node->nod_arg[e_uni_stream] = (JRD_NOD) (SLONG) new_stream; | node->nod_arg[e_uni_stream] = (JRD_NOD) (SLONG) new_stream; |
/* TMN: Here we should really have the following assert */ | /* TMN: Here we should really have the following assert */ |
|
|
csb_repeat *tail; | csb_repeat *tail; |
JRD_REL relation; | JRD_REL relation; |
| |
stream = (USHORT) node->nod_arg[e_rel_stream]; |
stream = (USHORT)(IPTR) node->nod_arg[e_rel_stream]; |
csb->csb_rpt[stream].csb_flags |= csb_no_dbkey; | csb->csb_rpt[stream].csb_flags |= csb_no_dbkey; |
tail = &csb->csb_rpt[stream]; | tail = &csb->csb_rpt[stream]; |
if ( (relation = tail->csb_relation) ) | if ( (relation = tail->csb_relation) ) |
|
|
JRD_FLD field; | JRD_FLD field; |
UCHAR *map, local_map[MAP_LENGTH]; | UCHAR *map, local_map[MAP_LENGTH]; |
| |
stream = (USHORT) node->nod_arg[e_fld_stream]; |
stream = (USHORT)(IPTR) node->nod_arg[e_fld_stream]; |
| |
/* Look at all rse's which are lower in scope than the rse which this field | /* Look at all rse's which are lower in scope than the rse which this field |
is referencing, and mark them as varying -- the rule is that if a field | is referencing, and mark them as varying -- the rule is that if a field |
|
|
if (!(relation = tail->csb_relation) || | if (!(relation = tail->csb_relation) || |
!(field = | !(field = |
MET_get_field(relation, | MET_get_field(relation, |
(USHORT) node->nod_arg[e_fld_id]))) break; |
(USHORT)(IPTR) node->nod_arg[e_fld_id]))) break; |
| |
/* if this is a modify or store, check REFERENCES access to any foreign keys. */ | /* if this is a modify or store, check REFERENCES access to any foreign keys. */ |
| |
|
|
| |
sub = node->nod_arg[e_asgn_from]; | sub = node->nod_arg[e_asgn_from]; |
if (sub->nod_type == nod_field) { | if (sub->nod_type == nod_field) { |
stream = (USHORT) sub->nod_arg[e_fld_stream]; |
stream = (USHORT)(IPTR) sub->nod_arg[e_fld_stream]; |
field = MET_get_field((*csb)->csb_rpt[stream].csb_relation, | field = MET_get_field((*csb)->csb_rpt[stream].csb_relation, |
(USHORT) sub->nod_arg[e_fld_id]); |
(USHORT)(IPTR) sub->nod_arg[e_fld_id]); |
if (field) | if (field) |
node->nod_arg[e_asgn_missing2] = field->fld_missing_value; | node->nod_arg[e_asgn_missing2] = field->fld_missing_value; |
} | } |
|
|
sub = node->nod_arg[e_asgn_to]; | sub = node->nod_arg[e_asgn_to]; |
if (sub->nod_type != nod_field) | if (sub->nod_type != nod_field) |
break; | break; |
stream = (USHORT) sub->nod_arg[e_fld_stream]; |
stream = (USHORT)(IPTR) sub->nod_arg[e_fld_stream]; |
tail = &(*csb)->csb_rpt[stream]; | tail = &(*csb)->csb_rpt[stream]; |
if (! | if (! |
(field = | (field = |
MET_get_field(tail->csb_relation, | MET_get_field(tail->csb_relation, |
(USHORT) sub->nod_arg[e_fld_id]))) break; |
(USHORT)(IPTR) sub->nod_arg[e_fld_id]))) break; |
if (field->fld_missing_value) { | if (field->fld_missing_value) { |
node->nod_arg[e_asgn_missing] = field->fld_missing_value; | node->nod_arg[e_asgn_missing] = field->fld_missing_value; |
node->nod_count = 3; | node->nod_count = 3; |
|
|
break; | break; |
| |
case nod_modify: | case nod_modify: |
stream = (USHORT) node->nod_arg[e_mod_new_stream]; |
stream = (USHORT)(IPTR) node->nod_arg[e_mod_new_stream]; |
tail = &(*csb)->csb_rpt[stream]; | tail = &(*csb)->csb_rpt[stream]; |
tail->csb_flags |= csb_modify; | tail->csb_flags |= csb_modify; |
pass1_modify(tdbb, csb, node); | pass1_modify(tdbb, csb, node); |
|
|
/* assert(node->nod_arg [e_mod_new_stream] <= MAX_USHORT); */ | /* assert(node->nod_arg [e_mod_new_stream] <= MAX_USHORT); */ |
if ( (node->nod_arg[e_mod_validate] = | if ( (node->nod_arg[e_mod_validate] = |
make_validation(tdbb, csb, | make_validation(tdbb, csb, |
(USHORT) node-> |
(USHORT)(IPTR) node-> |
nod_arg[e_mod_new_stream])) ) node->nod_count = | nod_arg[e_mod_new_stream])) ) node->nod_count = |
MAX(node->nod_count, (USHORT) e_mod_validate + 1); | MAX(node->nod_count, (USHORT) e_mod_validate + 1); |
break; | break; |
| |
case nod_erase: | case nod_erase: |
stream = (USHORT) node->nod_arg[e_erase_stream]; |
stream = (USHORT)(IPTR) node->nod_arg[e_erase_stream]; |
tail = &(*csb)->csb_rpt[stream]; | tail = &(*csb)->csb_rpt[stream]; |
tail->csb_flags |= csb_erase; | tail->csb_flags |= csb_erase; |
pass1_erase(tdbb, csb, node); | pass1_erase(tdbb, csb, node); |
|
|
| |
case nod_store: | case nod_store: |
sub = node->nod_arg[e_sto_relation]; | sub = node->nod_arg[e_sto_relation]; |
stream = (USHORT) sub->nod_arg[e_rel_stream]; |
stream = (USHORT)(IPTR) sub->nod_arg[e_rel_stream]; |
tail = &(*csb)->csb_rpt[stream]; | tail = &(*csb)->csb_rpt[stream]; |
tail->csb_flags |= csb_store; | tail->csb_flags |= csb_store; |
sub = pass1_store(tdbb, csb, node); | sub = pass1_store(tdbb, csb, node); |
if (sub) { | if (sub) { |
stream = (USHORT) sub->nod_arg[e_rel_stream]; |
stream = (USHORT)(IPTR) sub->nod_arg[e_rel_stream]; |
if ((!node->nod_arg[e_sto_sub_store]) && | if ((!node->nod_arg[e_sto_sub_store]) && |
(node->nod_arg[e_sto_validate] = | (node->nod_arg[e_sto_validate] = |
make_validation(tdbb, csb, stream))) node->nod_count = | make_validation(tdbb, csb, stream))) node->nod_count = |
|
|
| |
case nod_aggregate: | case nod_aggregate: |
assert((int)node->nod_arg[e_agg_stream] <= MAX_STREAMS); | assert((int)node->nod_arg[e_agg_stream] <= MAX_STREAMS); |
(*csb)->csb_rpt[(USHORT) node->nod_arg[e_agg_stream]].csb_flags |= |
(*csb)->csb_rpt[(USHORT)(IPTR) node->nod_arg[e_agg_stream]].csb_flags |= |
csb_no_dbkey; | csb_no_dbkey; |
ignore_dbkey(tdbb, *csb, (RSE) node->nod_arg[e_agg_rse], view); | ignore_dbkey(tdbb, *csb, (RSE) node->nod_arg[e_agg_rse], view); |
node->nod_arg[e_agg_rse] = | node->nod_arg[e_agg_rse] = |
|
|
NOD_T type; | NOD_T type; |
| |
type = node->nod_type; | type = node->nod_type; |
stream = (USHORT) node->nod_arg[0]; |
stream = (USHORT)(IPTR) node->nod_arg[0]; |
| |
if (!(*csb)->csb_rpt[stream].csb_map) | if (!(*csb)->csb_rpt[stream].csb_map) |
return node; | return node; |
|
|
break; | break; |
| |
case nod_cardinality: | case nod_cardinality: |
stream = (USHORT) node->nod_arg[e_card_stream]; |
stream = (USHORT)(IPTR) node->nod_arg[e_card_stream]; |
(*csb)->csb_rpt[stream].csb_flags |= csb_compute; | (*csb)->csb_rpt[stream].csb_flags |= csb_compute; |
break; | break; |
| |
|
|
/* To support views of views, loop until we hit a real relation */ | /* To support views of views, loop until we hit a real relation */ |
| |
for (;;) { | for (;;) { |
stream = new_stream = (USHORT) node->nod_arg[e_erase_stream]; |
stream = new_stream = (USHORT)(IPTR) node->nod_arg[e_erase_stream]; |
tail = &(*csb)->csb_rpt[stream]; | tail = &(*csb)->csb_rpt[stream]; |
tail->csb_flags |= csb_erase; | tail->csb_flags |= csb_erase; |
relation = (*csb)->csb_rpt[stream].csb_relation; | relation = (*csb)->csb_rpt[stream].csb_relation; |
|
|
| |
parent = relation; | parent = relation; |
parent_stream = stream; | parent_stream = stream; |
new_stream = (USHORT) source->nod_arg[e_rel_stream]; |
new_stream = (USHORT)(IPTR) source->nod_arg[e_rel_stream]; |
node->nod_arg[e_erase_stream] = (JRD_NOD) (SLONG) map[new_stream]; | node->nod_arg[e_erase_stream] = (JRD_NOD) (SLONG) map[new_stream]; |
} | } |
} | } |
|
|
field = MET_get_field(relation, id); | field = MET_get_field(relation, id); |
if (field->fld_source) | if (field->fld_source) |
new_id = | new_id = |
(USHORT) (JRD_NOD) (field->fld_source)->nod_arg[e_fld_id]; |
(USHORT)(IPTR) (JRD_NOD) (field->fld_source)->nod_arg[e_fld_id]; |
else | else |
new_id = id; | new_id = id; |
} | } |
|
|
/* To support views of views, loop until we hit a real relation */ | /* To support views of views, loop until we hit a real relation */ |
| |
for (;;) { | for (;;) { |
stream = (USHORT) node->nod_arg[e_mod_org_stream]; |
stream = (USHORT)(IPTR) node->nod_arg[e_mod_org_stream]; |
new_stream = (USHORT) node->nod_arg[e_mod_new_stream]; |
new_stream = (USHORT)(IPTR) node->nod_arg[e_mod_new_stream]; |
tail = &(*csb)->csb_rpt[new_stream]; | tail = &(*csb)->csb_rpt[new_stream]; |
tail->csb_flags |= csb_modify; | tail->csb_flags |= csb_modify; |
relation = (*csb)->csb_rpt[stream].csb_relation; | relation = (*csb)->csb_rpt[stream].csb_relation; |
|
|
node->nod_count = | node->nod_count = |
MAX(node->nod_count, (USHORT) e_mod_map_view + 1); | MAX(node->nod_count, (USHORT) e_mod_map_view + 1); |
map = (*csb)->csb_rpt[stream].csb_map; | map = (*csb)->csb_rpt[stream].csb_map; |
stream = (USHORT) source->nod_arg[e_rel_stream]; |
stream = (USHORT)(IPTR) source->nod_arg[e_rel_stream]; |
stream = map[stream]; | stream = map[stream]; |
view_stream = new_stream; | view_stream = new_stream; |
| |
|
|
| |
map = | map = |
alloc_map(tdbb, csb, | alloc_map(tdbb, csb, |
(SSHORT) node->nod_arg[e_mod_new_stream]); |
(SSHORT)(IPTR) node->nod_arg[e_mod_new_stream]); |
source = copy(tdbb, csb, source, map, 0, NULL, FALSE); | source = copy(tdbb, csb, source, map, 0, NULL, FALSE); |
/* TMN: Here we should really have the following assert */ | /* TMN: Here we should really have the following assert */ |
/* assert(source->nod_arg [e_rel_stream] <= MAX_UCHAR); */ | /* assert(source->nod_arg [e_rel_stream] <= MAX_UCHAR); */ |
map[new_stream] = (UCHAR) source->nod_arg[e_rel_stream]; |
map[new_stream] = (UCHAR)(IPTR) source->nod_arg[e_rel_stream]; |
view_node = copy(tdbb, csb, node, map, 0, NULL, TRUE); | view_node = copy(tdbb, csb, node, map, 0, NULL, TRUE); |
view_node->nod_arg[e_mod_org_stream] = (JRD_NOD) (SLONG) stream; | view_node->nod_arg[e_mod_org_stream] = (JRD_NOD) (SLONG) stream; |
view_node->nod_arg[e_mod_new_stream] = | view_node->nod_arg[e_mod_new_stream] = |
source->nod_arg[e_rel_stream]; | source->nod_arg[e_rel_stream]; |
view_node->nod_arg[e_mod_map_view] = NULL; | view_node->nod_arg[e_mod_map_view] = NULL; |
node->nod_arg[e_mod_sub_mod] = view_node; | node->nod_arg[e_mod_sub_mod] = view_node; |
new_stream = (USHORT) source->nod_arg[e_rel_stream]; |
new_stream = (USHORT)(IPTR) source->nod_arg[e_rel_stream]; |
view_node->nod_arg[e_mod_statement] = | view_node->nod_arg[e_mod_statement] = |
pass1_expand_view(tdbb, *csb, view_stream, new_stream, TRUE); | pass1_expand_view(tdbb, *csb, view_stream, new_stream, TRUE); |
node->nod_count = | node->nod_count = |
|
|
/* View passes muster -- do some translation. Start with source stream */ | /* View passes muster -- do some translation. Start with source stream */ |
| |
map = (*csb)->csb_rpt[stream].csb_map; | map = (*csb)->csb_rpt[stream].csb_map; |
stream = (USHORT) source->nod_arg[e_rel_stream]; |
stream = (USHORT)(IPTR) source->nod_arg[e_rel_stream]; |
node->nod_arg[e_mod_org_stream] = (JRD_NOD) (SLONG) map[stream]; | node->nod_arg[e_mod_org_stream] = (JRD_NOD) (SLONG) map[stream]; |
| |
/* Next, do update stream */ | /* Next, do update stream */ |
| |
map = | map = |
alloc_map(tdbb, csb, | alloc_map(tdbb, csb, |
(SSHORT) node->nod_arg[e_mod_new_stream]); |
(SSHORT)(IPTR) node->nod_arg[e_mod_new_stream]); |
source = copy(tdbb, csb, source, map, 0, NULL, FALSE); | source = copy(tdbb, csb, source, map, 0, NULL, FALSE); |
node->nod_arg[e_mod_new_stream] = source->nod_arg[e_rel_stream]; | node->nod_arg[e_mod_new_stream] = source->nod_arg[e_rel_stream]; |
} | } |
|
|
| |
pass1(tdbb, csb, source, parent_view, view_stream, FALSE); | pass1(tdbb, csb, source, parent_view, view_stream, FALSE); |
procedure = MET_lookup_procedure_id(tdbb, | procedure = MET_lookup_procedure_id(tdbb, |
(SSHORT)source->nod_arg[e_prc_procedure], FALSE, FALSE, 0); |
(SSHORT)(IPTR)source->nod_arg[e_prc_procedure], FALSE, FALSE, 0); |
post_procedure_access(tdbb, *csb, procedure); | post_procedure_access(tdbb, *csb, procedure); |
CMP_post_resource(&(*csb)->csb_resources, (BLK) procedure, | CMP_post_resource(&(*csb)->csb_resources, (BLK) procedure, |
Resource::rsc_procedure, procedure->prc_id); | Resource::rsc_procedure, procedure->prc_id); |
|
|
view->rel_id); | view->rel_id); |
source->nod_arg[e_rel_view] = (JRD_NOD) parent_view; | source->nod_arg[e_rel_view] = (JRD_NOD) parent_view; |
| |
stream = (USHORT) source->nod_arg[e_rel_stream]; |
stream = (USHORT)(IPTR) source->nod_arg[e_rel_stream]; |
element = CMP_csb_element(csb, stream); | element = CMP_csb_element(csb, stream); |
element->csb_view = parent_view; | element->csb_view = parent_view; |
/* TMN: Here we should really have the following assert */ | /* TMN: Here we should really have the following assert */ |
|
|
for (vcx_ptr = &parent_view->rel_view_contexts; *vcx_ptr; | for (vcx_ptr = &parent_view->rel_view_contexts; *vcx_ptr; |
vcx_ptr = &(*vcx_ptr)->vcx_next) | vcx_ptr = &(*vcx_ptr)->vcx_next) |
if ((*vcx_ptr)->vcx_context == | if ((*vcx_ptr)->vcx_context == |
(USHORT) source->nod_arg[e_rel_context]) { |
(USHORT)(IPTR) source->nod_arg[e_rel_context]) { |
element->csb_alias = (*vcx_ptr)->vcx_context_name; | element->csb_alias = (*vcx_ptr)->vcx_context_name; |
break; | break; |
} | } |
|
|
| |
for (;;) { | for (;;) { |
original = node->nod_arg[e_sto_relation]; | original = node->nod_arg[e_sto_relation]; |
stream = (USHORT) original->nod_arg[e_rel_stream]; |
stream = (USHORT)(IPTR) original->nod_arg[e_rel_stream]; |
tail = &(*csb)->csb_rpt[stream]; | tail = &(*csb)->csb_rpt[stream]; |
tail->csb_flags |= csb_store; | tail->csb_flags |= csb_store; |
relation = (*csb)->csb_rpt[stream].csb_relation; | relation = (*csb)->csb_rpt[stream].csb_relation; |
|
|
node->nod_arg[e_sto_relation] = | node->nod_arg[e_sto_relation] = |
copy(tdbb, csb, source, map, 0, NULL, FALSE); | copy(tdbb, csb, source, map, 0, NULL, FALSE); |
new_stream = | new_stream = |
(USHORT) node->nod_arg[e_sto_relation]->nod_arg[e_rel_stream]; |
(USHORT)(IPTR) node->nod_arg[e_sto_relation]->nod_arg[e_rel_stream]; |
node->nod_arg[e_sto_statement] = | node->nod_arg[e_sto_statement] = |
pass1_expand_view(tdbb, *csb, stream, new_stream, TRUE); | pass1_expand_view(tdbb, *csb, stream, new_stream, TRUE); |
node->nod_arg[e_sto_statement] = | node->nod_arg[e_sto_statement] = |
|
|
/* AB: Mark the streams involved with an UPDATE statement | /* AB: Mark the streams involved with an UPDATE statement |
active. So that the optimizer can use indices for | active. So that the optimizer can use indices for |
eventually used sub-selects. */ | eventually used sub-selects. */ |
stream = (USHORT) node->nod_arg[e_mod_org_stream]; |
stream = (USHORT)(IPTR) node->nod_arg[e_mod_org_stream]; |
csb->csb_rpt[stream].csb_flags |= csb_active; | csb->csb_rpt[stream].csb_flags |= csb_active; |
stream = (USHORT) node->nod_arg[e_mod_new_stream]; |
stream = (USHORT)(IPTR) node->nod_arg[e_mod_new_stream]; |
csb->csb_rpt[stream].csb_flags |= csb_active; | csb->csb_rpt[stream].csb_flags |= csb_active; |
} | } |
| |
|
|
| |
if (node->nod_type == nod_modify) { | if (node->nod_type == nod_modify) { |
/* AB: Remove the previous flags */ | /* AB: Remove the previous flags */ |
stream = (USHORT) node->nod_arg[e_mod_org_stream]; |
stream = (USHORT)(IPTR) node->nod_arg[e_mod_org_stream]; |
csb->csb_rpt[stream].csb_flags &= ~csb_active; | csb->csb_rpt[stream].csb_flags &= ~csb_active; |
stream = (USHORT) node->nod_arg[e_mod_new_stream]; |
stream = (USHORT)(IPTR) node->nod_arg[e_mod_new_stream]; |
csb->csb_rpt[stream].csb_flags &= ~csb_active; | csb->csb_rpt[stream].csb_flags &= ~csb_active; |
} | } |
| |
|
|
FMT format; | FMT format; |
fmt::fmt_desc_iterator desc; | fmt::fmt_desc_iterator desc; |
| |
stream = (USHORT) node->nod_arg[e_mod_org_stream]; |
stream = (USHORT)(IPTR) node->nod_arg[e_mod_org_stream]; |
csb->csb_rpt[stream].csb_flags |= csb_update; | csb->csb_rpt[stream].csb_flags |= csb_update; |
format = CMP_format(tdbb, csb, stream); | format = CMP_format(tdbb, csb, stream); |
desc = format->fmt_desc.begin(); | desc = format->fmt_desc.begin(); |
|
|
break; | break; |
| |
case nod_erase: | case nod_erase: |
stream = (USHORT) node->nod_arg[e_erase_stream]; |
stream = (USHORT)(IPTR) node->nod_arg[e_erase_stream]; |
csb->csb_rpt[stream].csb_flags |= csb_update; | csb->csb_rpt[stream].csb_flags |= csb_update; |
break; | break; |
| |
case nod_field: | case nod_field: |
stream = (USHORT) node->nod_arg[e_fld_stream]; |
stream = (USHORT)(IPTR) node->nod_arg[e_fld_stream]; |
id = (USHORT) node->nod_arg[e_fld_id]; |
id = (USHORT)(IPTR) node->nod_arg[e_fld_id]; |
SBM_set(tdbb, &csb->csb_rpt[stream].csb_fields, id); | SBM_set(tdbb, &csb->csb_rpt[stream].csb_fields, id); |
if (node->nod_flags & nod_value) { | if (node->nod_flags & nod_value) { |
csb->csb_impure += sizeof(struct vlux); | csb->csb_impure += sizeof(struct vlux); |
|
|
pass2_rse(tdbb, csb, (RSE) node->nod_arg[e_agg_rse]); | pass2_rse(tdbb, csb, (RSE) node->nod_arg[e_agg_rse]); |
pass2(tdbb, csb, node->nod_arg[e_agg_map], node); | pass2(tdbb, csb, node->nod_arg[e_agg_map], node); |
pass2(tdbb, csb, node->nod_arg[e_agg_group], node); | pass2(tdbb, csb, node->nod_arg[e_agg_group], node); |
stream = (USHORT) node->nod_arg[e_agg_stream]; |
stream = (USHORT)(IPTR) node->nod_arg[e_agg_stream]; |
assert(stream <= MAX_STREAMS); | assert(stream <= MAX_STREAMS); |
process_map(tdbb, csb, node->nod_arg[e_agg_map], | process_map(tdbb, csb, node->nod_arg[e_agg_map], |
&csb->csb_rpt[stream].csb_format); | &csb->csb_rpt[stream].csb_format); |
|
|
| |
node = *ptr; | node = *ptr; |
if (node->nod_type == nod_relation) { | if (node->nod_type == nod_relation) { |
USHORT stream = (USHORT) node->nod_arg[e_rel_stream]; |
USHORT stream = (USHORT)(IPTR) node->nod_arg[e_rel_stream]; |
csb->csb_rpt[stream].csb_flags |= csb_active; | csb->csb_rpt[stream].csb_flags |= csb_active; |
pass2(tdbb, csb, node, (JRD_NOD) rse); | pass2(tdbb, csb, node, (JRD_NOD) rse); |
} | } |
|
|
pass2_rse(tdbb, csb, (RSE) node); | pass2_rse(tdbb, csb, (RSE) node); |
} | } |
else if (node->nod_type == nod_procedure) { | else if (node->nod_type == nod_procedure) { |
USHORT stream = (USHORT) node->nod_arg[e_prc_stream]; |
USHORT stream = (USHORT)(IPTR) node->nod_arg[e_prc_stream]; |
csb->csb_rpt[stream].csb_flags |= csb_active; | csb->csb_rpt[stream].csb_flags |= csb_active; |
pass2(tdbb, csb, node, (JRD_NOD) rse); | pass2(tdbb, csb, node, (JRD_NOD) rse); |
} | } |
else if (node->nod_type == nod_aggregate) { | else if (node->nod_type == nod_aggregate) { |
USHORT stream = (USHORT) node->nod_arg[e_agg_stream]; |
USHORT stream = (USHORT)(IPTR) node->nod_arg[e_agg_stream]; |
assert(stream <= MAX_STREAMS); | assert(stream <= MAX_STREAMS); |
csb->csb_rpt[stream].csb_flags |= csb_active; | csb->csb_rpt[stream].csb_flags |= csb_active; |
pass2(tdbb, csb, node, (JRD_NOD) rse); | pass2(tdbb, csb, node, (JRD_NOD) rse); |
|
|
/* Make up a format block sufficiently large to hold instantiated record */ | /* Make up a format block sufficiently large to hold instantiated record */ |
| |
clauses = node->nod_arg[e_uni_clauses]; | clauses = node->nod_arg[e_uni_clauses]; |
id = (USHORT) node->nod_arg[e_uni_stream]; |
id = (USHORT)(IPTR) node->nod_arg[e_uni_stream]; |
format = &csb->csb_rpt[id].csb_format; | format = &csb->csb_rpt[id].csb_format; |
| |
/* Process alternating rse and map blocks */ | /* Process alternating rse and map blocks */ |
|
|
| |
for (ptr = rse->rse_relation, end = ptr + rse->rse_count; ptr < end; | for (ptr = rse->rse_relation, end = ptr + rse->rse_count; ptr < end; |
ptr++) if ((*ptr)->nod_type == nod_relation) { | ptr++) if ((*ptr)->nod_type == nod_relation) { |
stream = (USHORT) (*ptr)->nod_arg[e_rel_stream]; |
stream = (USHORT)(IPTR) (*ptr)->nod_arg[e_rel_stream]; |
if (!(csb->csb_rpt[stream].csb_plan)) | if (!(csb->csb_rpt[stream].csb_plan)) |
ERR_post(gds_no_stream_plan, gds_arg_string, | ERR_post(gds_no_stream_plan, gds_arg_string, |
csb->csb_rpt[stream].csb_relation->rel_name, 0); | csb->csb_rpt[stream].csb_relation->rel_name, 0); |
|
|
| |
/* find the tail for the relation specified in the rse */ | /* find the tail for the relation specified in the rse */ |
| |
stream = (USHORT) plan_relation_node->nod_arg[e_rel_stream]; |
stream = (USHORT)(IPTR) plan_relation_node->nod_arg[e_rel_stream]; |
tail = &csb->csb_rpt[stream]; | tail = &csb->csb_rpt[stream]; |
| |
/* if the plan references a view, find the real base relation | /* if the plan references a view, find the real base relation |
|
|
ptr < end; ptr++) { | ptr < end; ptr++) { |
node = *ptr; | node = *ptr; |
if (node->nod_type == nod_relation) { | if (node->nod_type == nod_relation) { |
USHORT stream = (USHORT) node->nod_arg[e_rel_stream]; |
USHORT stream = (USHORT)(IPTR) node->nod_arg[e_rel_stream]; |
csb->csb_rpt[stream].csb_flags &= ~csb_active; | csb->csb_rpt[stream].csb_flags &= ~csb_active; |
} | } |
else if (node->nod_type == nod_procedure) { | else if (node->nod_type == nod_procedure) { |
USHORT stream = (USHORT) node->nod_arg[e_prc_stream]; |
USHORT stream = (USHORT)(IPTR) node->nod_arg[e_prc_stream]; |
csb->csb_rpt[stream].csb_flags &= ~csb_active; | csb->csb_rpt[stream].csb_flags &= ~csb_active; |
} | } |
else if (node->nod_type == nod_aggregate) { | else if (node->nod_type == nod_aggregate) { |
USHORT stream = (USHORT) node->nod_arg[e_agg_stream]; |
USHORT stream = (USHORT)(IPTR) node->nod_arg[e_agg_stream]; |
assert(stream <= MAX_STREAMS); | assert(stream <= MAX_STREAMS); |
csb->csb_rpt[stream].csb_flags &= ~csb_active; | csb->csb_rpt[stream].csb_flags &= ~csb_active; |
} | } |
|
|
for (end = ptr + map->nod_count; ptr < end; ptr++) { | for (end = ptr + map->nod_count; ptr < end; ptr++) { |
assignment = *ptr; | assignment = *ptr; |
field = assignment->nod_arg[e_asgn_to]; | field = assignment->nod_arg[e_asgn_to]; |
id = (USHORT) field->nod_arg[e_fld_id]; |
id = (USHORT)(IPTR) field->nod_arg[e_fld_id]; |
if (id >= format->fmt_count) { | if (id >= format->fmt_count) { |
format->fmt_desc.resize(id + 1); | format->fmt_desc.resize(id + 1); |
} | } |
|
|
/* for aggregates, check current rse, if not found then check | /* for aggregates, check current rse, if not found then check |
the sub-rse */ | the sub-rse */ |
if (sub->nod_type == nod_aggregate) { | if (sub->nod_type == nod_aggregate) { |
if ((stream == (USHORT) sub->nod_arg[e_rel_stream]) || |
if ((stream == (USHORT)(IPTR) sub->nod_arg[e_rel_stream]) || |
(stream_in_rse(stream, (RSE) sub->nod_arg[e_agg_rse]))) | (stream_in_rse(stream, (RSE) sub->nod_arg[e_agg_rse]))) |
return TRUE; /* do not mark as variant */ | return TRUE; /* do not mark as variant */ |
} | } |
| |
if ((sub->nod_type == nod_relation) && | if ((sub->nod_type == nod_relation) && |
(stream == (USHORT) sub->nod_arg[e_rel_stream])) |
(stream == (USHORT)(IPTR) sub->nod_arg[e_rel_stream])) |
return TRUE; /* do not mark as variant */ | return TRUE; /* do not mark as variant */ |
} | } |
| |