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

Method pass1Store

src/dsql/StmtNodes.cpp:7891–8002  ·  view source on GitHub ↗

Process a source for a store statement. This can get a little tricky if the relation is a view.

Source from the content-addressed store, hash-verified

7889
7890// Process a source for a store statement. This can get a little tricky if the relation is a view.
7891bool StoreNode::pass1Store(thread_db* tdbb, CompilerScratch* csb, StoreNode* node)
7892{
7893 // If updateable views with triggers are involved, there may be a recursive call to be ignored.
7894
7895 if (node->subStore)
7896 return false;
7897
7898 auto relSource = nodeAs<RelationSourceNode>(node->target);
7899
7900 if (!relSource) // Is this a LocalTableSourceNode?
7901 {
7902 const StreamType stream = node->target->getStream();
7903 const auto tail = &csb->csb_rpt[stream];
7904 tail->csb_flags |= csb_store;
7905
7906 // Apply validation constraints.
7907 makeValidation(tdbb, csb, stream, node->validations);
7908
7909 return false;
7910 }
7911
7912 jrd_rel* parent = NULL;
7913 jrd_rel* view = NULL;
7914 StreamType parentStream;
7915
7916 // To support nested views, loop until we hit a table or a view with user-defined triggers
7917 // (which means no update).
7918
7919 for (;;)
7920 {
7921 const StreamType stream = node->target->getStream();
7922
7923 CompilerScratch::csb_repeat* const tail = &csb->csb_rpt[stream];
7924 tail->csb_flags |= csb_store;
7925
7926 jrd_rel* const relation = tail->csb_relation;
7927 view = relation->rel_view_rse ? relation : view;
7928
7929 if (!parent)
7930 {
7931 parent = tail->csb_view;
7932 parentStream = tail->csb_view_stream;
7933 }
7934
7935 postTriggerAccess(csb, relation, ExternalAccess::exa_insert, view);
7936
7937 RefPtr<TrigVector> trigger(relation->rel_pre_store ?
7938 relation->rel_pre_store : relation->rel_post_store);
7939
7940 // Check out insert. If this is an insert thru a view, verify the view by checking for read
7941 // access on the base table. If field-level select privileges are implemented, this needs
7942 // to be enhanced.
7943
7944 SecurityClass::flags_t priv = SCL_insert;
7945
7946 if (parent)
7947 priv |= SCL_select;
7948

Callers

nothing calls this directly

Calls 10

makeValidationFunction · 0.85
postTriggerAccessFunction · 0.85
pass1UpdateFunction · 0.85
CMP_post_resourceFunction · 0.85
CMP_alloc_mapFunction · 0.85
StoreNodeClass · 0.85
pass1ExpandViewFunction · 0.85
getStreamMethod · 0.45
copyMethod · 0.45
getDefaultPoolMethod · 0.45

Tested by

no test coverage detected