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

Method makeDefaults

src/dsql/StmtNodes.cpp:8005–8081  ·  view source on GitHub ↗

Build a default value assignments.

Source from the content-addressed store, hash-verified

8003
8004// Build a default value assignments.
8005void StoreNode::makeDefaults(thread_db* tdbb, CompilerScratch* csb)
8006{
8007 const StreamType stream = target->getStream();
8008 jrd_rel* relation = csb->csb_rpt[stream].csb_relation;
8009
8010 vec<jrd_fld*>* vector = relation->rel_fields;
8011 if (!vector)
8012 return;
8013
8014 StreamMap localMap;
8015 StreamType* map = csb->csb_rpt[stream].csb_map;
8016
8017 if (!map)
8018 {
8019 map = localMap.getBuffer(STREAM_MAP_LENGTH);
8020 fb_assert(stream <= MAX_STREAMS);
8021 map[0] = stream;
8022 map[1] = 1;
8023 map[2] = 2;
8024 }
8025
8026 StmtNodeStack stack;
8027 USHORT fieldId = 0;
8028 vec<jrd_fld*>::iterator ptr1 = vector->begin();
8029
8030 for (const vec<jrd_fld*>::const_iterator end = vector->end(); ptr1 < end; ++ptr1, ++fieldId)
8031 {
8032 ValueExprNode* value;
8033
8034 if (!*ptr1 || !((*ptr1)->fld_generator_name.hasData() || (value = (*ptr1)->fld_default_value)))
8035 continue;
8036
8037 CompoundStmtNode* compoundNode = nodeAs<CompoundStmtNode>(statement.getObject());
8038 fb_assert(compoundNode);
8039
8040 if (compoundNode)
8041 {
8042 bool inList = false;
8043
8044 for (FB_SIZE_T i = 0; i < compoundNode->statements.getCount(); ++i)
8045 {
8046 const AssignmentNode* assign = nodeAs<AssignmentNode>(
8047 compoundNode->statements[i].getObject());
8048 fb_assert(assign);
8049
8050 if (assign)
8051 {
8052 const FieldNode* fieldNode = nodeAs<FieldNode>(assign->asgnTo);
8053 fb_assert(fieldNode);
8054
8055 if (fieldNode && fieldNode->fieldStream == stream && fieldNode->fieldId == fieldId)
8056 {
8057 inList = true;
8058 break;
8059 }
8060 }
8061 }
8062

Callers

nothing calls this directly

Calls 13

PAR_gen_fieldFunction · 0.85
PAR_make_listFunction · 0.85
AssignmentNodeClass · 0.70
getStreamMethod · 0.45
getBufferMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
hasDataMethod · 0.45
getObjectMethod · 0.45
getCountMethod · 0.45
getDefaultPoolMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected