MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / pass1ExpandView

Function pass1ExpandView

src/dsql/StmtNodes.cpp:10775–10820  ·  view source on GitHub ↗

Process a view update performed by a trigger.

Source from the content-addressed store, hash-verified

10773
10774// Process a view update performed by a trigger.
10775static 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.

Callers 3

pass1EraseMethod · 0.85
pass1ModifyMethod · 0.85
pass1StoreMethod · 0.85

Calls 9

SET_TDBBFunction · 0.85
CMP_formatFunction · 0.85
PAR_gen_fieldFunction · 0.85
PAR_make_listFunction · 0.85
AssignmentNodeClass · 0.70
beginMethod · 0.45
endMethod · 0.45
getDefaultPoolMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected