| 3676 | // |
| 3677 | |
| 3678 | static gpre_fld* resolve(gpre_nod* node, |
| 3679 | gpre_ctx* context, gpre_ctx** found_context, act** slice_action) |
| 3680 | { |
| 3681 | gpre_fld* field; |
| 3682 | |
| 3683 | assert_IS_NOD(node); |
| 3684 | |
| 3685 | gpre_rse* rs_stream = context->ctx_stream; |
| 3686 | if (rs_stream) |
| 3687 | { |
| 3688 | for (SSHORT i = 0; i < rs_stream->rse_count; i++) |
| 3689 | { |
| 3690 | if ((field = resolve(node, rs_stream->rse_context[i], found_context, slice_action))) |
| 3691 | { |
| 3692 | return field; |
| 3693 | } |
| 3694 | } |
| 3695 | |
| 3696 | return NULL; |
| 3697 | } |
| 3698 | |
| 3699 | tok* f_token = (tok*) node->nod_arg[0]; |
| 3700 | tok* q_token = (tok*) node->nod_arg[1]; |
| 3701 | |
| 3702 | if (!(context->ctx_relation || context->ctx_procedure)) |
| 3703 | return NULL; |
| 3704 | |
| 3705 | // Handle unqualified fields first for simplicity |
| 3706 | |
| 3707 | if (!q_token) |
| 3708 | field = MET_context_field(context, f_token->tok_string); |
| 3709 | else |
| 3710 | { |
| 3711 | // Now search alternatives for the qualifier |
| 3712 | |
| 3713 | gpre_sym* symbol = HSH_lookup(q_token->tok_string); |
| 3714 | |
| 3715 | // This caused gpre to dump core if there are lower case |
| 3716 | // table aliases in a where clause used with dialect 2 or 3 |
| 3717 | |
| 3718 | //if ( (symbol == NULL) && (sw_case || gpreGlob.sw_sql_dialect == SQL_DIALECT_V5)) |
| 3719 | // symbol = HSH_lookup2 (q_token->tok_string); |
| 3720 | |
| 3721 | |
| 3722 | // So I replaced it with the following, don't know |
| 3723 | // why we don't do a HSH_lookup2 in any case, but so it may be. |
| 3724 | // FSG 16.Nov.2000 |
| 3725 | |
| 3726 | if (symbol == NULL) |
| 3727 | symbol = HSH_lookup2(q_token->tok_string); |
| 3728 | |
| 3729 | |
| 3730 | for (gpre_sym* temp_symbol = symbol; temp_symbol; temp_symbol = temp_symbol->sym_homonym) |
| 3731 | { |
| 3732 | if (temp_symbol->sym_type == SYM_context) |
| 3733 | { |
| 3734 | symbol = temp_symbol; |
| 3735 | break; |
no test coverage detected