| 2758 | // |
| 2759 | |
| 2760 | static void replace_field_names(gpre_nod* const input, |
| 2761 | const gpre_nod* const search_list, |
| 2762 | gpre_fld* const replace_with, |
| 2763 | bool null_them, |
| 2764 | gpre_ctx** contexts) |
| 2765 | { |
| 2766 | if (!input) |
| 2767 | return; |
| 2768 | |
| 2769 | if ((input->nod_type == nod_via || input->nod_type == nod_any || input->nod_type == nod_unique) && |
| 2770 | search_list == 0 && replace_with == 0 && input->nod_count == 0) |
| 2771 | { |
| 2772 | CPR_error("Invalid view WITH CHECK OPTION - no subqueries permitted"); |
| 2773 | return; |
| 2774 | } |
| 2775 | |
| 2776 | gpre_nod** ptr = input->nod_arg; |
| 2777 | for (const gpre_nod* const* const end = ptr + input->nod_count; ptr < end; ptr++) |
| 2778 | { |
| 2779 | if ((*ptr)->nod_type == nod_field) |
| 2780 | { |
| 2781 | ref* reference = (ref*) (*ptr)->nod_arg[0]; |
| 2782 | gpre_fld* rse_field = reference->ref_field; |
| 2783 | if (null_them) |
| 2784 | { |
| 2785 | if (reference->ref_context == contexts[2]) { |
| 2786 | *ptr = MSC_node(nod_null, 0); |
| 2787 | } |
| 2788 | continue; |
| 2789 | } |
| 2790 | reference->ref_context = contexts[2]; |
| 2791 | if (!search_list) |
| 2792 | continue; |
| 2793 | gpre_fld* view_field = replace_with; |
| 2794 | gpre_nod* const* ptrs = search_list->nod_arg; |
| 2795 | for (gpre_nod* const* const ends = ptrs + search_list->nod_count; |
| 2796 | ptrs < ends; |
| 2797 | ptrs++, view_field = view_field ? view_field->fld_next : NULL) |
| 2798 | { |
| 2799 | const ref* references = (ref*) (*ptrs)->nod_arg[0]; |
| 2800 | gpre_fld* select_field = references->ref_field; |
| 2801 | if (rse_field == select_field) |
| 2802 | { |
| 2803 | reference->ref_field = view_field ? view_field : select_field; |
| 2804 | reference->ref_context = contexts[1]; |
| 2805 | break; |
| 2806 | } |
| 2807 | } |
| 2808 | } |
| 2809 | else |
| 2810 | replace_field_names(*ptr, search_list, replace_with, null_them, contexts); |
| 2811 | } |
| 2812 | } |
| 2813 | |
| 2814 | |
| 2815 | //____________________________________________________________ |
no test coverage detected