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

Function dsqlSetParameterName

src/dsql/StmtNodes.cpp:10576–10621  ·  view source on GitHub ↗

Setup parameter name. This function was added as a part of array data type support for InterClient. It is called when either "insert" or "update" statements are parsed. If the statements have input parameters, then the parameter is assigned the name of the field it is being inserted (or updated). The same goes to the name of a relation. The names are assigned to the parameter only if the field is

Source from the content-addressed store, hash-verified

10574// to the name of a relation.
10575// The names are assigned to the parameter only if the field is of array data type.
10576static void dsqlSetParameterName(DsqlCompilerScratch* dsqlScratch, ExprNode* exprNode, const ValueExprNode* fld_node,
10577 const dsql_rel* relation)
10578{
10579 DEV_BLKCHK(fld_node, dsql_type_nod);
10580 DEV_BLKCHK(relation, dsql_type_dsql_rel);
10581
10582 if (!exprNode)
10583 return;
10584
10585 const FieldNode* fieldNode = nodeAs<FieldNode>(fld_node);
10586 fb_assert(fieldNode); // Could it be something else ???
10587
10588 if (fieldNode->getDsqlDesc().dsc_dtype != dtype_array)
10589 return;
10590
10591 switch (exprNode->getType())
10592 {
10593 case ExprNode::TYPE_ARITHMETIC:
10594 case ExprNode::TYPE_CONCATENATE:
10595 case ExprNode::TYPE_EXTRACT:
10596 case ExprNode::TYPE_NEGATE:
10597 case ExprNode::TYPE_STR_CASE:
10598 case ExprNode::TYPE_STR_LEN:
10599 case ExprNode::TYPE_SUBSTRING:
10600 case ExprNode::TYPE_SUBSTRING_SIMILAR:
10601 case ExprNode::TYPE_TRIM:
10602 {
10603 NodeRefsHolder holder(dsqlScratch->getPool());
10604 exprNode->getChildren(holder, true);
10605
10606 for (auto ref : holder.refs)
10607 dsqlSetParameterName(dsqlScratch, *ref, fld_node, relation);
10608
10609 break;
10610 }
10611
10612 case ExprNode::TYPE_PARAMETER:
10613 {
10614 ParameterNode* paramNode = nodeAs<ParameterNode>(exprNode);
10615 dsql_par* parameter = paramNode->dsqlParameter;
10616 parameter->par_name = fieldNode->dsqlField->fld_name.c_str();
10617 parameter->par_rel_name = relation->rel_name.c_str();
10618 break;
10619 }
10620 }
10621}
10622
10623// Setup parameter parameters name.
10624static void dsqlSetParametersName(DsqlCompilerScratch* dsqlScratch, CompoundStmtNode* statements,

Callers 1

dsqlSetParametersNameFunction · 0.85

Calls 3

getTypeMethod · 0.45
getChildrenMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected