| 1706 | // |
| 1707 | |
| 1708 | static bool create_view(gpre_req* request, act* action) |
| 1709 | { |
| 1710 | // add relation name |
| 1711 | |
| 1712 | gpre_rel* relation = (gpre_rel*) action->act_object; |
| 1713 | put_symbol(request, isc_dyn_def_view, relation->rel_symbol); |
| 1714 | put_numeric(request, isc_dyn_rel_sql_protection, 1); |
| 1715 | |
| 1716 | // write out blr |
| 1717 | |
| 1718 | put_blr(request, isc_dyn_view_blr, (gpre_nod*) relation->rel_view_rse, CME_rse); |
| 1719 | |
| 1720 | // write out view source |
| 1721 | |
| 1722 | TEXT* view_source = (TEXT *) MSC_alloc(relation->rel_view_text->txt_length + 1); |
| 1723 | CPR_get_text(view_source, relation->rel_view_text); |
| 1724 | put_cstring(request, isc_dyn_view_source, view_source); |
| 1725 | |
| 1726 | // Write out view context info |
| 1727 | gpre_rel* sub_relation = 0; |
| 1728 | for (gpre_ctx* context = request->req_contexts; context; context = context->ctx_next) |
| 1729 | { |
| 1730 | sub_relation = context->ctx_relation; |
| 1731 | if (!sub_relation) |
| 1732 | continue; |
| 1733 | put_symbol(request, isc_dyn_view_relation, sub_relation->rel_symbol); |
| 1734 | put_numeric(request, isc_dyn_view_context, context->ctx_internal); |
| 1735 | if (context->ctx_symbol) |
| 1736 | put_symbol(request, isc_dyn_view_context_name, context->ctx_symbol); |
| 1737 | //if (context->ctx_type) |
| 1738 | // put_numeric(request, isc_dyn_view_context_type, context->ctx_type); |
| 1739 | //if (context->ctx_package) |
| 1740 | // put_symbol(request, isc_dyn_pkg_name, context->ctx_package); |
| 1741 | request->add_end(); |
| 1742 | } |
| 1743 | |
| 1744 | // add the mapping from the rse to the view fields |
| 1745 | |
| 1746 | gpre_fld* field = relation->rel_fields; |
| 1747 | gpre_nod* fields = relation->rel_view_rse->rse_fields; |
| 1748 | SSHORT position = 0; |
| 1749 | bool non_updateable = false; |
| 1750 | |
| 1751 | gpre_nod** ptr; |
| 1752 | const gpre_nod* const* end; |
| 1753 | |
| 1754 | for (ptr = fields->nod_arg, end = ptr + fields->nod_count; ptr < end; |
| 1755 | ptr++, (field = field ? field->fld_next : NULL)) |
| 1756 | { |
| 1757 | const gpre_fld* fld = NULL; |
| 1758 | const gpre_ctx* context = NULL; |
| 1759 | gpre_nod* value = *ptr; |
| 1760 | if (value->nod_type == nod_field) |
| 1761 | { |
| 1762 | const ref* reference = (ref*) value->nod_arg[0]; |
| 1763 | fld = reference->ref_field; |
| 1764 | const gpre_req* slice_req; |
| 1765 | const slc* slice; |
no test coverage detected