Process a source for a store statement. This can get a little tricky if the relation is a view.
| 7889 | |
| 7890 | // Process a source for a store statement. This can get a little tricky if the relation is a view. |
| 7891 | bool 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 |
nothing calls this directly
no test coverage detected