Process a view update performed by a trigger.
| 10773 | |
| 10774 | // Process a view update performed by a trigger. |
| 10775 | static StmtNode* pass1ExpandView(thread_db* tdbb, CompilerScratch* csb, StreamType orgStream, |
| 10776 | StreamType newStream, bool remap) |
| 10777 | { |
| 10778 | SET_TDBB(tdbb); |
| 10779 | |
| 10780 | DEV_BLKCHK(csb, type_csb); |
| 10781 | |
| 10782 | StmtNodeStack stack; |
| 10783 | jrd_rel* relation = csb->csb_rpt[orgStream].csb_relation; |
| 10784 | vec<jrd_fld*>* fields = relation->rel_fields; |
| 10785 | |
| 10786 | dsc desc; |
| 10787 | USHORT id = 0, newId = 0; |
| 10788 | vec<jrd_fld*>::iterator ptr = fields->begin(); |
| 10789 | |
| 10790 | for (const vec<jrd_fld*>::const_iterator end = fields->end(); ptr < end; ++ptr, ++id) |
| 10791 | { |
| 10792 | if (*ptr) |
| 10793 | { |
| 10794 | if (remap) |
| 10795 | { |
| 10796 | const jrd_fld* field = MET_get_field(relation, id); |
| 10797 | |
| 10798 | if (field->fld_source) |
| 10799 | newId = nodeAs<FieldNode>(field->fld_source)->fieldId; |
| 10800 | else |
| 10801 | newId = id; |
| 10802 | } |
| 10803 | else |
| 10804 | newId = id; |
| 10805 | |
| 10806 | const Format* const format = CMP_format(tdbb, csb, newStream); |
| 10807 | if (newId >= format->fmt_count || !format->fmt_desc[newId].dsc_address) |
| 10808 | continue; |
| 10809 | |
| 10810 | AssignmentNode* const assign = |
| 10811 | FB_NEW_POOL(*tdbb->getDefaultPool()) AssignmentNode(*tdbb->getDefaultPool()); |
| 10812 | assign->asgnTo = PAR_gen_field(tdbb, newStream, newId); |
| 10813 | assign->asgnFrom = PAR_gen_field(tdbb, orgStream, id); |
| 10814 | |
| 10815 | stack.push(assign); |
| 10816 | } |
| 10817 | } |
| 10818 | |
| 10819 | return PAR_make_list(tdbb, stack); |
| 10820 | } |
| 10821 | |
| 10822 | // Check out a prospective update to a relation. If it fails security check, bounce it. |
| 10823 | // If it's a view update, make sure the view is updatable, and return the view source for redirection. |
no test coverage detected