8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 22:43:03 +01:00

Unify DSQL/JRD sub-nodes.

This commit is contained in:
asfernandes 2012-05-03 16:43:29 +00:00
parent ec6c21f244
commit 07747144f7
30 changed files with 1453 additions and 1589 deletions

View File

@ -53,12 +53,11 @@ AggNode::AggNode(MemoryPool& pool, const AggInfo& aAggInfo, bool aDistinct, bool
aggInfo(aAggInfo),
distinct(aDistinct),
dialect1(aDialect1),
dsqlArg(aArg),
arg(NULL),
arg(aArg),
asb(NULL),
indexed(false)
{
addChildNode(dsqlArg, arg);
addChildNode(arg, arg);
}
AggNode* AggNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
@ -453,7 +452,7 @@ DmlNode* AvgAggNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* c
void AvgAggNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc)
{
MAKE_desc(dsqlScratch, desc, dsqlArg);
MAKE_desc(dsqlScratch, desc, arg);
desc->setNullable(true);
if (desc->isNull())
@ -638,10 +637,10 @@ dsc* AvgAggNode::aggExecute(thread_db* tdbb, jrd_req* request) const
return &impureTemp->vlu_desc;
}
AggNode* AvgAggNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) const
AggNode* AvgAggNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/
{
return FB_NEW(getPool()) AvgAggNode(getPool(), distinct, dialect1,
doDsqlPass(dsqlScratch, dsqlArg));
doDsqlPass(dsqlScratch, arg));
}
@ -653,10 +652,9 @@ static AggNode::Register<ListAggNode> listAggInfo("LIST", blr_agg_list, blr_agg_
ListAggNode::ListAggNode(MemoryPool& pool, bool aDistinct, ValueExprNode* aArg,
ValueExprNode* aDelimiter)
: AggNode(pool, listAggInfo, aDistinct, false, aArg),
dsqlDelimiter(aDelimiter),
delimiter(NULL)
delimiter(aDelimiter)
{
addChildNode(dsqlDelimiter, delimiter);
addChildNode(delimiter, delimiter);
}
DmlNode* ListAggNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp)
@ -670,7 +668,7 @@ DmlNode* ListAggNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch*
void ListAggNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc)
{
MAKE_desc(dsqlScratch, desc, dsqlArg);
MAKE_desc(dsqlScratch, desc, arg);
desc->makeBlob(desc->getBlobSubType(), desc->getTextType());
desc->setNullable(true);
}
@ -678,8 +676,8 @@ void ListAggNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc)
bool ListAggNode::setParameterType(DsqlCompilerScratch* dsqlScratch,
const dsc* desc, bool forceVarChar)
{
return PASS1_set_parameter_type(dsqlScratch, dsqlArg, desc, forceVarChar) |
PASS1_set_parameter_type(dsqlScratch, dsqlDelimiter, desc, forceVarChar);
return PASS1_set_parameter_type(dsqlScratch, arg, desc, forceVarChar) |
PASS1_set_parameter_type(dsqlScratch, delimiter, desc, forceVarChar);
}
void ListAggNode::getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc)
@ -766,10 +764,10 @@ dsc* ListAggNode::aggExecute(thread_db* tdbb, jrd_req* request) const
return &impure->vlu_desc;
}
AggNode* ListAggNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) const
AggNode* ListAggNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/
{
return FB_NEW(getPool()) ListAggNode(getPool(), distinct,
doDsqlPass(dsqlScratch, dsqlArg), doDsqlPass(dsqlScratch, dsqlDelimiter));
doDsqlPass(dsqlScratch, arg), doDsqlPass(dsqlScratch, delimiter));
}
@ -807,7 +805,7 @@ void CountAggNode::make(DsqlCompilerScratch* /*dsqlScratch*/, dsc* desc)
void CountAggNode::genBlr(DsqlCompilerScratch* dsqlScratch)
{
if (dsqlArg)
if (arg)
AggNode::genBlr(dsqlScratch);
else
dsqlScratch->appendUChar(blr_agg_count);
@ -858,10 +856,10 @@ dsc* CountAggNode::aggExecute(thread_db* /*tdbb*/, jrd_req* request) const
return &impure->vlu_desc;
}
AggNode* CountAggNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) const
AggNode* CountAggNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/
{
return FB_NEW(getPool()) CountAggNode(getPool(), distinct, dialect1,
doDsqlPass(dsqlScratch, dsqlArg));
doDsqlPass(dsqlScratch, arg));
}
@ -888,7 +886,7 @@ DmlNode* SumAggNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* c
void SumAggNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc)
{
MAKE_desc(dsqlScratch, desc, dsqlArg);
MAKE_desc(dsqlScratch, desc, arg);
desc->setNullable(true);
if (desc->isNull())
@ -1111,10 +1109,10 @@ dsc* SumAggNode::aggExecute(thread_db* /*tdbb*/, jrd_req* request) const
return &impure->vlu_desc;
}
AggNode* SumAggNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) const
AggNode* SumAggNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/
{
return FB_NEW(getPool()) SumAggNode(getPool(), distinct, dialect1,
doDsqlPass(dsqlScratch, dsqlArg));
doDsqlPass(dsqlScratch, arg));
}
@ -1140,7 +1138,7 @@ DmlNode* MaxMinAggNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch
void MaxMinAggNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc)
{
MAKE_desc(dsqlScratch, desc, dsqlArg);
MAKE_desc(dsqlScratch, desc, arg);
desc->setNullable(true);
}
@ -1193,9 +1191,9 @@ dsc* MaxMinAggNode::aggExecute(thread_db* /*tdbb*/, jrd_req* request) const
return &impure->vlu_desc;
}
AggNode* MaxMinAggNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) const
AggNode* MaxMinAggNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/
{
return FB_NEW(getPool()) MaxMinAggNode(getPool(), type, doDsqlPass(dsqlScratch, dsqlArg));
return FB_NEW(getPool()) MaxMinAggNode(getPool(), type, doDsqlPass(dsqlScratch, arg));
}

View File

@ -47,7 +47,7 @@ public:
virtual dsc* aggExecute(thread_db* tdbb, jrd_req* request) const;
protected:
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) const;
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/;
private:
USHORT tempImpure;
@ -80,10 +80,9 @@ public:
virtual dsc* aggExecute(thread_db* tdbb, jrd_req* request) const;
protected:
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) const;
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/;
private:
ValueExprNode* dsqlDelimiter;
NestConst<ValueExprNode> delimiter;
};
@ -104,7 +103,7 @@ public:
virtual dsc* aggExecute(thread_db* tdbb, jrd_req* request) const;
protected:
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) const;
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/;
};
class SumAggNode : public AggNode
@ -123,7 +122,7 @@ public:
virtual dsc* aggExecute(thread_db* tdbb, jrd_req* request) const;
protected:
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) const;
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/;
};
class MaxMinAggNode : public AggNode
@ -148,7 +147,7 @@ public:
virtual dsc* aggExecute(thread_db* tdbb, jrd_req* request) const;
protected:
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) const;
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/;
public:
const MaxMinType type;

View File

@ -137,13 +137,11 @@ BinaryBoolNode::BinaryBoolNode(MemoryPool& pool, UCHAR aBlrOp, BoolExprNode* aAr
BoolExprNode* aArg2)
: TypedNode<BoolExprNode, ExprNode::TYPE_BINARY_BOOL>(pool),
blrOp(aBlrOp),
dsqlArg1(aArg1),
dsqlArg2(aArg2),
arg1(NULL),
arg2(NULL)
arg1(aArg1),
arg2(aArg2)
{
addChildNode(dsqlArg1, arg1);
addChildNode(dsqlArg2, arg2);
addChildNode(arg1, arg1);
addChildNode(arg2, arg2);
}
DmlNode* BinaryBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp)
@ -163,14 +161,14 @@ void BinaryBoolNode::print(string& text) const
BoolExprNode* BinaryBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
{
return FB_NEW(getPool()) BinaryBoolNode(getPool(), blrOp,
doDsqlPass(dsqlScratch, dsqlArg1), doDsqlPass(dsqlScratch, dsqlArg2));
doDsqlPass(dsqlScratch, arg1), doDsqlPass(dsqlScratch, arg2));
}
void BinaryBoolNode::genBlr(DsqlCompilerScratch* dsqlScratch)
{
dsqlScratch->appendUChar(blrOp);
GEN_expr(dsqlScratch, dsqlArg1);
GEN_expr(dsqlScratch, dsqlArg2);
GEN_expr(dsqlScratch, arg1);
GEN_expr(dsqlScratch, arg2);
}
bool BinaryBoolNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
@ -340,21 +338,19 @@ static RegisterBoolNode<ComparativeBoolNode> regComparativeBoolNodeMatching(blr_
static RegisterBoolNode<ComparativeBoolNode> regComparativeBoolNodeMatching2(blr_matching2); // sleuth
ComparativeBoolNode::ComparativeBoolNode(MemoryPool& pool, UCHAR aBlrOp,
ValueExprNode* aArg1, ExprNode* aArg2, ValueExprNode* aArg3)
ValueExprNode* aArg1, ValueExprNode* aArg2, ValueExprNode* aArg3)
: TypedNode<BoolExprNode, ExprNode::TYPE_COMPARATIVE_BOOL>(pool),
blrOp(aBlrOp),
dsqlArg1(aArg1),
dsqlArg2(aArg2),
dsqlArg3(aArg3),
dsqlFlag(DFLAG_NONE),
dsqlWasValue(false),
arg1(NULL),
arg2(NULL),
arg3(NULL)
arg1(aArg1),
arg2(aArg2),
arg3(aArg3),
dsqlSpecialArg(NULL)
{
addChildNode(dsqlArg1, arg1);
addChildNode(dsqlArg2, arg2);
addChildNode(dsqlArg3, arg3);
addChildNode(arg1, arg1);
addChildNode(arg2, arg2);
addChildNode(arg3, arg3);
}
DmlNode* ComparativeBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp)
@ -388,14 +384,14 @@ void ComparativeBoolNode::print(string& text) const
BoolExprNode* ComparativeBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
{
ValueExprNode* procArg1 = dsqlArg1;
ExprNode* procArg2 = dsqlArg2;
ValueExprNode* procArg3 = dsqlArg3;
NestConst<ValueExprNode> procArg1 = arg1;
NestConst<ValueExprNode> procArg2 = arg2;
NestConst<ValueExprNode> procArg3 = arg3;
FieldNode* fieldNode1;
// Make INSERTING/UPDATING/DELETING in booleans to read the trigger action.
if (dsqlWasValue && (fieldNode1 = ExprNode::as<FieldNode>(procArg1)))
if (dsqlWasValue && (fieldNode1 = procArg1->as<FieldNode>()))
{
static const char* const NAMES[] = {
"INSERTING",
@ -414,53 +410,56 @@ BoolExprNode* ComparativeBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
}
}
ValueListNode* listNode = procArg2->as<ValueListNode>();
if (listNode)
if (dsqlSpecialArg)
{
int listItemCount = 0;
BoolExprNode* resultNode = NULL;
ValueExprNode** ptr = listNode->dsqlArgs.begin();
for (const ValueExprNode* const* const end = listNode->dsqlArgs.end();
ptr != end;
++listItemCount, ++ptr)
ValueListNode* listNode = dsqlSpecialArg->as<ValueListNode>();
if (listNode)
{
if (listItemCount >= MAX_MEMBER_LIST)
int listItemCount = 0;
BoolExprNode* resultNode = NULL;
NestConst<ValueExprNode>* ptr = listNode->items.begin();
for (const NestConst<ValueExprNode>* const end = listNode->items.end();
ptr != end;
++listItemCount, ++ptr)
{
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) <<
Arg::Gds(isc_imp_exc) <<
Arg::Gds(isc_dsql_too_many_values) << Arg::Num(MAX_MEMBER_LIST));
if (listItemCount >= MAX_MEMBER_LIST)
{
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) <<
Arg::Gds(isc_imp_exc) <<
Arg::Gds(isc_dsql_too_many_values) << Arg::Num(MAX_MEMBER_LIST));
}
ComparativeBoolNode* temp = FB_NEW(getPool()) ComparativeBoolNode(getPool(),
blrOp, procArg1, *ptr);
resultNode = PASS1_compose(resultNode, temp, blr_or);
}
ComparativeBoolNode* temp = FB_NEW(getPool()) ComparativeBoolNode(getPool(),
blrOp, procArg1, *ptr);
resultNode = PASS1_compose(resultNode, temp, blr_or);
return resultNode->dsqlPass(dsqlScratch);
}
return resultNode->dsqlPass(dsqlScratch);
SelectExprNode* selNode = dsqlSpecialArg->as<SelectExprNode>();
if (selNode)
{
fb_assert(!(selNode->dsqlFlags & RecordSourceNode::DFLAG_SINGLETON));
UCHAR newBlrOp = blr_any;
if (dsqlFlag == DFLAG_ANSI_ANY)
newBlrOp = blr_ansi_any;
else if (dsqlFlag == DFLAG_ANSI_ALL)
newBlrOp = blr_ansi_all;
return createRseNode(dsqlScratch, newBlrOp);
}
fb_assert(false);
}
SelectExprNode* selNode = procArg2->as<SelectExprNode>();
if (selNode)
{
fb_assert(!(selNode->dsqlFlags & RecordSourceNode::DFLAG_SINGLETON));
UCHAR newBlrOp = blr_any;
if (dsqlFlag == DFLAG_ANSI_ANY)
newBlrOp = blr_ansi_any;
else if (dsqlFlag == DFLAG_ANSI_ALL)
newBlrOp = blr_ansi_all;
return createRseNode(dsqlScratch, newBlrOp);
}
fb_assert(procArg2->kind == KIND_VALUE);
ValueExprNode* valueNode = static_cast<ValueExprNode*>(procArg2);
valueNode = doDsqlPass(dsqlScratch, valueNode);
procArg2 = doDsqlPass(dsqlScratch, procArg2);
ComparativeBoolNode* node = FB_NEW(getPool()) ComparativeBoolNode(getPool(), blrOp,
doDsqlPass(dsqlScratch, procArg1),
valueNode,
procArg2,
doDsqlPass(dsqlScratch, procArg3));
switch (blrOp)
@ -475,24 +474,24 @@ BoolExprNode* ComparativeBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
case blr_between:
{
// Try to force arg1 to be same type as arg2 eg: ? = FIELD case
PASS1_set_parameter_type(dsqlScratch, node->dsqlArg1, valueNode, false);
PASS1_set_parameter_type(dsqlScratch, node->arg1, procArg2, false);
// Try to force arg2 to be same type as arg1 eg: FIELD = ? case
// Try even when the above call succeeded, because "arg2" may
// have arg-expressions that should be resolved.
PASS1_set_parameter_type(dsqlScratch, valueNode, node->dsqlArg1, false);
PASS1_set_parameter_type(dsqlScratch, procArg2, node->arg1, false);
// X BETWEEN Y AND ? case
if (!PASS1_set_parameter_type(dsqlScratch, node->dsqlArg3, node->dsqlArg1, false))
if (!PASS1_set_parameter_type(dsqlScratch, node->arg3, node->arg1, false))
{
// ? BETWEEN Y AND ? case
PASS1_set_parameter_type(dsqlScratch, node->dsqlArg3, valueNode, false);
PASS1_set_parameter_type(dsqlScratch, node->arg3, procArg2, false);
}
dsc desc1, desc2;
MAKE_desc(dsqlScratch, &desc1, node->dsqlArg1);
MAKE_desc(dsqlScratch, &desc2, valueNode);
MAKE_desc(dsqlScratch, &desc1, node->arg1);
MAKE_desc(dsqlScratch, &desc2, procArg2);
if ((desc1.dsc_dtype == dtype_boolean || desc2.dsc_dtype == dtype_boolean) &&
!(desc1.isNull() || desc2.isNull()) && desc1.dsc_dtype != desc2.dsc_dtype)
@ -509,15 +508,15 @@ BoolExprNode* ComparativeBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
case blr_similar:
case blr_starting:
// Try to force arg1 to be same type as arg2 eg: ? LIKE FIELD case
PASS1_set_parameter_type(dsqlScratch, node->dsqlArg1, valueNode, true);
PASS1_set_parameter_type(dsqlScratch, node->arg1, procArg2, true);
// Try to force arg2 same type as arg 1 eg: FIELD LIKE ? case
// Try even when the above call succeeded, because "arg2" may
// have arg-expressions that should be resolved.
PASS1_set_parameter_type(dsqlScratch, valueNode, node->dsqlArg1, true);
PASS1_set_parameter_type(dsqlScratch, procArg2, node->arg1, true);
// X LIKE Y ESCAPE ? case
PASS1_set_parameter_type(dsqlScratch, node->dsqlArg3, valueNode, true);
PASS1_set_parameter_type(dsqlScratch, node->arg3, procArg2, true);
}
return node;
@ -525,16 +524,16 @@ BoolExprNode* ComparativeBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
void ComparativeBoolNode::genBlr(DsqlCompilerScratch* dsqlScratch)
{
dsqlScratch->appendUChar(blrOp == blr_like && dsqlArg3 ? blr_ansi_like : blrOp);
dsqlScratch->appendUChar(blrOp == blr_like && arg3 ? blr_ansi_like : blrOp);
GEN_expr(dsqlScratch, dsqlArg1);
GEN_expr(dsqlScratch, dsqlArg2);
GEN_expr(dsqlScratch, arg1);
GEN_expr(dsqlScratch, arg2);
if (blrOp == blr_similar)
dsqlScratch->appendUChar(dsqlArg3 ? 1 : 0);
dsqlScratch->appendUChar(arg3 ? 1 : 0);
if (dsqlArg3)
GEN_expr(dsqlScratch, dsqlArg3);
if (arg3)
GEN_expr(dsqlScratch, arg3);
}
bool ComparativeBoolNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
@ -1310,11 +1309,11 @@ BoolExprNode* ComparativeBoolNode::createRseNode(DsqlCompilerScratch* dsqlScratc
SelectExprNode* dt = FB_NEW(getPool()) SelectExprNode(getPool());
// Ignore validation for column names that must exist for "user" derived tables.
dt->dsqlFlags = RecordSourceNode::DFLAG_DT_IGNORE_COLUMN_CHECK | RecordSourceNode::DFLAG_DERIVED;
dt->querySpec = static_cast<RecordSourceNode*>(dsqlArg2);
dt->querySpec = static_cast<RecordSourceNode*>(dsqlSpecialArg.getObject());
RseNode* querySpec = FB_NEW(getPool()) RseNode(getPool());
querySpec->dsqlFrom = FB_NEW(getPool()) RecSourceListNode(getPool(), 1);
querySpec->dsqlFrom->dsqlArgs[0] = dt;
querySpec->dsqlFrom->items[0] = dt;
SelectExprNode* select_expr = FB_NEW(getPool()) SelectExprNode(getPool());
select_expr->querySpec = querySpec;
@ -1328,7 +1327,7 @@ BoolExprNode* ComparativeBoolNode::createRseNode(DsqlCompilerScratch* dsqlScratc
// Create a conjunct to be injected.
rse->dsqlWhere = FB_NEW(getPool()) ComparativeBoolNode(getPool(), blrOp,
doDsqlPass(dsqlScratch, dsqlArg1, false), rse->dsqlSelectList->dsqlArgs[0]);
doDsqlPass(dsqlScratch, arg1, false), rse->dsqlSelectList->items[0]);
// Create output node.
RseBoolNode* rseBoolNode = FB_NEW(getPool()) RseBoolNode(getPool(), rseBlrOp, rse);
@ -1349,11 +1348,10 @@ static RegisterBoolNode<MissingBoolNode> regMissingBoolNode(blr_missing);
MissingBoolNode::MissingBoolNode(MemoryPool& pool, ValueExprNode* aArg, bool aDsqlUnknown)
: TypedNode<BoolExprNode, ExprNode::TYPE_MISSING_BOOL>(pool),
dsqlArg(aArg),
dsqlUnknown(aDsqlUnknown),
arg(NULL)
arg(aArg)
{
addChildNode(dsqlArg, arg);
addChildNode(arg, arg);
}
DmlNode* MissingBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR /*blrOp*/)
@ -1372,12 +1370,12 @@ void MissingBoolNode::print(string& text) const
BoolExprNode* MissingBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
{
MissingBoolNode* node = FB_NEW(getPool()) MissingBoolNode(getPool(),
doDsqlPass(dsqlScratch, dsqlArg));
doDsqlPass(dsqlScratch, arg));
PASS1_set_parameter_type(dsqlScratch, node->dsqlArg, (dsc*) NULL, false);
PASS1_set_parameter_type(dsqlScratch, node->arg, (dsc*) NULL, false);
dsc desc;
MAKE_desc(dsqlScratch, &desc, node->dsqlArg);
MAKE_desc(dsqlScratch, &desc, node->arg);
if (dsqlUnknown && desc.dsc_dtype != dtype_boolean && !desc.isNull())
{
@ -1391,7 +1389,7 @@ BoolExprNode* MissingBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
void MissingBoolNode::genBlr(DsqlCompilerScratch* dsqlScratch)
{
dsqlScratch->appendUChar(blr_missing);
GEN_expr(dsqlScratch, dsqlArg);
GEN_expr(dsqlScratch, arg);
}
BoolExprNode* MissingBoolNode::copy(thread_db* tdbb, NodeCopier& copier) const
@ -1441,10 +1439,9 @@ static RegisterBoolNode<NotBoolNode> regNotBoolNode(blr_not);
NotBoolNode::NotBoolNode(MemoryPool& pool, BoolExprNode* aArg)
: TypedNode<BoolExprNode, ExprNode::TYPE_NOT_BOOL>(pool),
dsqlArg(aArg),
arg(NULL)
arg(aArg)
{
addChildNode(dsqlArg, arg);
addChildNode(arg, arg);
}
DmlNode* NotBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR /*blrOp*/)
@ -1468,7 +1465,7 @@ BoolExprNode* NotBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
void NotBoolNode::genBlr(DsqlCompilerScratch* dsqlScratch)
{
dsqlScratch->appendUChar(blr_not);
GEN_expr(dsqlScratch, dsqlArg);
GEN_expr(dsqlScratch, arg);
}
BoolExprNode* NotBoolNode::copy(thread_db* tdbb, NodeCopier& copier) const
@ -1508,7 +1505,7 @@ bool NotBoolNode::execute(thread_db* tdbb, jrd_req* request) const
// Get rid of redundant nested NOT predicates.
BoolExprNode* NotBoolNode::process(DsqlCompilerScratch* dsqlScratch, bool invert)
{
NotBoolNode* notArg = ExprNode::as<NotBoolNode>(dsqlArg);
NotBoolNode* notArg = arg->as<NotBoolNode>();
if (notArg)
{
@ -1517,14 +1514,14 @@ BoolExprNode* NotBoolNode::process(DsqlCompilerScratch* dsqlScratch, bool invert
}
if (!invert)
return dsqlArg->dsqlPass(dsqlScratch);
return arg->dsqlPass(dsqlScratch);
ComparativeBoolNode* cmpArg = ExprNode::as<ComparativeBoolNode>(dsqlArg);
BinaryBoolNode* binArg = ExprNode::as<BinaryBoolNode>(dsqlArg);
ComparativeBoolNode* cmpArg = arg->as<ComparativeBoolNode>();
BinaryBoolNode* binArg = arg->as<BinaryBoolNode>();
// Do not handle special case: <value> NOT IN <list>
if (cmpArg && !cmpArg->dsqlArg2->is<ValueListNode>())
if (cmpArg && (!cmpArg->dsqlSpecialArg || !cmpArg->dsqlSpecialArg->is<ValueListNode>()))
{
// Invert the given boolean.
switch (cmpArg->blrOp)
@ -1564,8 +1561,9 @@ BoolExprNode* NotBoolNode::process(DsqlCompilerScratch* dsqlScratch, bool invert
}
ComparativeBoolNode* node = FB_NEW(getPool()) ComparativeBoolNode(
getPool(), newBlrOp, cmpArg->dsqlArg1, cmpArg->dsqlArg2);
getPool(), newBlrOp, cmpArg->arg1, cmpArg->arg2);
node->dsqlWasValue = cmpArg->dsqlWasValue;
node->dsqlSpecialArg = cmpArg->dsqlSpecialArg;
if (cmpArg->dsqlFlag == ComparativeBoolNode::DFLAG_ANSI_ANY)
node->dsqlFlag = ComparativeBoolNode::DFLAG_ANSI_ALL;
@ -1578,10 +1576,10 @@ BoolExprNode* NotBoolNode::process(DsqlCompilerScratch* dsqlScratch, bool invert
case blr_between:
{
ComparativeBoolNode* cmpNode1 = FB_NEW(getPool()) ComparativeBoolNode(getPool(),
blr_lss, cmpArg->dsqlArg1, cmpArg->dsqlArg2);
blr_lss, cmpArg->arg1, cmpArg->arg2);
ComparativeBoolNode* cmpNode2 = FB_NEW(getPool()) ComparativeBoolNode(getPool(),
blr_gtr, cmpArg->dsqlArg1, cmpArg->dsqlArg3);
blr_gtr, cmpArg->arg1, cmpArg->arg3);
BinaryBoolNode* node = FB_NEW(getPool()) BinaryBoolNode(getPool(), blr_or,
cmpNode1, cmpNode2);
@ -1599,8 +1597,8 @@ BoolExprNode* NotBoolNode::process(DsqlCompilerScratch* dsqlScratch, bool invert
{
UCHAR newBlrOp = binArg->blrOp == blr_and ? blr_or : blr_and;
NotBoolNode* notNode1 = FB_NEW(getPool()) NotBoolNode(getPool(), binArg->dsqlArg1);
NotBoolNode* notNode2 = FB_NEW(getPool()) NotBoolNode(getPool(), binArg->dsqlArg2);
NotBoolNode* notNode1 = FB_NEW(getPool()) NotBoolNode(getPool(), binArg->arg1);
NotBoolNode* notNode2 = FB_NEW(getPool()) NotBoolNode(getPool(), binArg->arg2);
BinaryBoolNode* node = FB_NEW(getPool()) BinaryBoolNode(getPool(), newBlrOp,
notNode1, notNode2);
@ -1613,7 +1611,7 @@ BoolExprNode* NotBoolNode::process(DsqlCompilerScratch* dsqlScratch, bool invert
// No inversion is possible, so just recreate the input node
// and return immediately to avoid infinite recursion later.
return FB_NEW(getPool()) NotBoolNode(getPool(), doDsqlPass(dsqlScratch, dsqlArg));
return FB_NEW(getPool()) NotBoolNode(getPool(), doDsqlPass(dsqlScratch, arg));
}

View File

@ -54,8 +54,6 @@ private:
public:
UCHAR blrOp;
BoolExprNode* dsqlArg1;
BoolExprNode* dsqlArg2;
NestConst<BoolExprNode> arg1;
NestConst<BoolExprNode> arg2;
};
@ -72,7 +70,7 @@ public:
};
ComparativeBoolNode(MemoryPool& pool, UCHAR aBlrOp, ValueExprNode* aArg1 = NULL,
ExprNode* aArg2 = NULL, ValueExprNode* aArg3 = NULL);
ValueExprNode* aArg2 = NULL, ValueExprNode* aArg3 = NULL);
static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
@ -104,15 +102,12 @@ private:
public:
UCHAR blrOp;
ValueExprNode* dsqlArg1;
ExprNode* dsqlArg2;
ValueExprNode* dsqlArg3;
DsqlFlag dsqlFlag;
bool dsqlWasValue;
NestConst<ValueExprNode> arg1;
NestConst<ValueExprNode> arg2;
NestConst<ValueExprNode> arg3;
NestConst<ExprNode> dsqlSpecialArg; // list or select expression
};
@ -138,7 +133,6 @@ public:
virtual bool execute(thread_db* tdbb, jrd_req* request) const;
public:
ValueExprNode* dsqlArg;
bool dsqlUnknown;
NestConst<ValueExprNode> arg;
};
@ -168,7 +162,6 @@ private:
BoolExprNode* process(DsqlCompilerScratch* dsqlScratch, bool invert);
public:
BoolExprNode* dsqlArg;
NestConst<BoolExprNode> arg;
};
@ -208,7 +201,7 @@ private:
public:
UCHAR blrOp;
RecordSourceNode* dsqlRse;
NestConst<RecordSourceNode> dsqlRse;
NestConst<RseNode> rse;
NestConst<RecordSource> rsb;
};

View File

@ -92,7 +92,7 @@ static void checkViewDependency(thread_db* tdbb, jrd_tra* transaction,
const MetaName& relationName, const MetaName& fieldName);
static void clearPermanentField(dsql_rel* relation, bool permanent);
static void defineComputed(DsqlCompilerScratch* dsqlScratch, RelationSourceNode* relation,
dsql_fld* field, const ValueSourceClause* clause, string& source, BlrWriter::BlrData& value);
dsql_fld* field, ValueSourceClause* clause, string& source, BlrWriter::BlrData& value);
static void deleteKeyConstraint(thread_db* tdbb, jrd_tra* transaction,
const MetaName& relationName, const MetaName& constraintName, const MetaName& indexName);
static void defineFile(thread_db* tdbb, jrd_tra* transaction, SLONG shadowNumber, bool manualShadow,
@ -291,7 +291,7 @@ static void clearPermanentField(dsql_rel* relation, bool permanent)
// Define a COMPUTED BY clause, for a field or an index.
void defineComputed(DsqlCompilerScratch* dsqlScratch, RelationSourceNode* relation, dsql_fld* field,
const ValueSourceClause* clause, string& source, BlrWriter::BlrData& value)
ValueSourceClause* clause, string& source, BlrWriter::BlrData& value)
{
// Get the table node and set up correct context.
DDL_reset_context_stack(dsqlScratch);
@ -823,7 +823,7 @@ void DdlNode::storeGlobalField(thread_db* tdbb, jrd_tra* transaction, MetaName&
const string& userName = attachment->att_user->usr_user_name;
const ValueListNode* elements = field.legacyField->fld_ranges;
const USHORT dims = elements ? elements->dsqlArgs.getCount() / 2 : 0;
const USHORT dims = elements ? elements->items.getCount() / 2 : 0;
if (dims > MAX_ARRAY_DIMENSIONS)
{
@ -888,8 +888,8 @@ void DdlNode::storeGlobalField(thread_db* tdbb, jrd_tra* transaction, MetaName&
requestHandle.reset(tdbb, drq_s_fld_dym, DYN_REQUESTS);
SSHORT position = 0;
const ValueExprNode* const* ptr = elements->dsqlArgs.begin();
for (const ValueExprNode* const* const end = elements->dsqlArgs.end();
const NestConst<ValueExprNode>* ptr = elements->items.begin();
for (const NestConst<ValueExprNode>* const end = elements->items.end();
ptr != end;
++ptr, ++position)
{
@ -1735,7 +1735,7 @@ bool CreateAlterFunctionNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch*
}
void CreateAlterFunctionNode::storeArgument(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch,
jrd_tra* transaction, unsigned pos, const ParameterClause& parameter,
jrd_tra* transaction, unsigned pos, ParameterClause& parameter,
const bid* comment)
{
Attachment* const attachment = transaction->getAttachment();
@ -2596,7 +2596,7 @@ bool CreateAlterProcedureNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch
}
void CreateAlterProcedureNode::storeParameter(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch,
jrd_tra* transaction, USHORT type, unsigned pos, const ParameterClause& parameter,
jrd_tra* transaction, USHORT type, unsigned pos, ParameterClause& parameter,
const bid* comment)
{
Attachment* const attachment = transaction->getAttachment();
@ -3782,7 +3782,7 @@ void CreateDomainNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch
}
const ValueListNode* elements = nameType.legacyField->fld_ranges;
const USHORT dims = elements ? elements->dsqlArgs.getCount() / 2 : 0;
const USHORT dims = elements ? elements->items.getCount() / 2 : 0;
if (nameType.defaultClause && dims != 0)
{
@ -5391,7 +5391,7 @@ void RelationNode::deleteLocalField(thread_db* tdbb, jrd_tra* transaction,
}
void RelationNode::defineField(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch,
jrd_tra* transaction, const AddColumnClause* clause, SSHORT position,
jrd_tra* transaction, AddColumnClause* clause, SSHORT position,
const ObjectsArray<MetaName>* pkCols)
{
dsql_fld* field = clause->field;
@ -5425,7 +5425,7 @@ void RelationNode::defineField(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch
if (clause->identity)
notNullFlag = true; // identity columns are implicitly not null
for (ObjectsArray<AddConstraintClause>::const_iterator ptr = clause->constraints.begin();
for (ObjectsArray<AddConstraintClause>::iterator ptr = clause->constraints.begin();
ptr != clause->constraints.end(); ++ptr)
{
makeConstraint(tdbb, dsqlScratch, transaction, &*ptr, constraints, &notNullFlag);
@ -5559,7 +5559,7 @@ void RelationNode::defineField(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch
// Define a DEFAULT clause. Return true for DEFAULT NULL.
bool RelationNode::defineDefault(thread_db* /*tdbb*/, DsqlCompilerScratch* dsqlScratch,
dsql_fld* /*field*/, const ValueSourceClause* clause, string& source, BlrWriter::BlrData& value)
dsql_fld* /*field*/, ValueSourceClause* clause, string& source, BlrWriter::BlrData& value)
{
ValueExprNode* input = doDsqlPass(dsqlScratch, clause->value);
@ -5582,7 +5582,7 @@ bool RelationNode::defineDefault(thread_db* /*tdbb*/, DsqlCompilerScratch* dsqlS
// Make a constraint object from a legacy node.
void RelationNode::makeConstraint(thread_db* /*tdbb*/, DsqlCompilerScratch* dsqlScratch,
jrd_tra* transaction, const AddConstraintClause* clause, ObjectsArray<Constraint>& constraints,
jrd_tra* transaction, AddConstraintClause* clause, ObjectsArray<Constraint>& constraints,
bool* notNull)
{
switch (clause->constraintType)
@ -5627,7 +5627,7 @@ void RelationNode::makeConstraint(thread_db* /*tdbb*/, DsqlCompilerScratch* dsql
// primary key of the referenced table designates the referenced fields.
if (clause->refColumns.isEmpty())
{
Array<FieldNode*> refColumns;
Array<NestConst<FieldNode> > refColumns;
METD_get_primary_key(transaction, clause->refRelation, refColumns);
// If there is NEITHER an explicitly referenced field name, NOR does
@ -5645,9 +5645,9 @@ void RelationNode::makeConstraint(thread_db* /*tdbb*/, DsqlCompilerScratch* dsql
}
else
{
const FieldNode* const* ptr = refColumns.begin();
const NestConst<FieldNode>* ptr = refColumns.begin();
for (const FieldNode* const* const end = refColumns.end(); ptr != end; ++ptr)
for (const NestConst<FieldNode>* const end = refColumns.end(); ptr != end; ++ptr)
constraint.refColumns.add((*ptr)->dsqlName);
}
}
@ -5803,11 +5803,11 @@ void RelationNode::defineConstraint(thread_db* tdbb, DsqlCompilerScratch* dsqlSc
definition.refRelation = constraint.refRelation;
definition.refColumns = constraint.refColumns;
CreateIndexNode::store(tdbb, transaction, constraint.index->name, definition,
&referredIndexName);
MetaName indexName(constraint.index->name);
CreateIndexNode::store(tdbb, transaction, indexName, definition, &referredIndexName);
CRT.RDB$INDEX_NAME.NULL = FALSE;
strcpy(CRT.RDB$INDEX_NAME, constraint.index->name.c_str());
strcpy(CRT.RDB$INDEX_NAME, indexName.c_str());
checkForeignKeyTempScope(tdbb, transaction, name, referredIndexName);
@ -5977,7 +5977,7 @@ void RelationNode::defineConstraint(thread_db* tdbb, DsqlCompilerScratch* dsqlSc
// Generate triggers to implement the CHECK clause, either at the field or table level.
void RelationNode::defineCheckConstraint(DsqlCompilerScratch* dsqlScratch, Constraint& constraint,
const BoolSourceClause* clause)
BoolSourceClause* clause)
{
// Create the INSERT trigger.
defineCheckConstraintTrigger(dsqlScratch, constraint, clause, PRE_STORE_TRIGGER);
@ -5988,7 +5988,7 @@ void RelationNode::defineCheckConstraint(DsqlCompilerScratch* dsqlScratch, Const
// Define a check constraint trigger.
void RelationNode::defineCheckConstraintTrigger(DsqlCompilerScratch* dsqlScratch,
Constraint& constraint, const BoolSourceClause* clause, FB_UINT64 triggerType)
Constraint& constraint, BoolSourceClause* clause, FB_UINT64 triggerType)
{
thread_db* tdbb = JRD_get_thread_data();
MemoryPool& pool = *tdbb->getDefaultPool();
@ -5999,7 +5999,7 @@ void RelationNode::defineCheckConstraintTrigger(DsqlCompilerScratch* dsqlScratch
blrWriter.init(dsqlScratch);
// Specify that the trigger should abort if the condition is not met.
CompoundStmtNode* actionNode = FB_NEW(pool) CompoundStmtNode(pool);
NestConst<CompoundStmtNode> actionNode = FB_NEW(pool) CompoundStmtNode(pool);
ExceptionNode* exceptionNode = FB_NEW(pool) ExceptionNode(pool, CHECK_CONSTRAINT_EXCEPTION);
exceptionNode->exception->type = ExceptionItem::GDS_CODE;
@ -6106,12 +6106,12 @@ void RelationNode::defineSetDefaultTrigger(DsqlCompilerScratch* dsqlScratch,
// Search the parse tree to find the column
for (const Clause* const* ptr = clauses.begin(); ptr != clauses.end(); ++ptr)
for (NestConst<Clause>* ptr = clauses.begin(); ptr != clauses.end(); ++ptr)
{
if ((*ptr)->type != Clause::TYPE_ADD_COLUMN)
continue;
const AddColumnClause* clause = static_cast<const AddColumnClause*>(*ptr);
AddColumnClause* clause = static_cast<AddColumnClause*>(ptr->getObject());
if (*column != clause->field->fld_name)
continue;
@ -6493,19 +6493,19 @@ void CreateRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScrat
const ObjectsArray<MetaName>* pkCols = findPkColumns();
SSHORT position = 0;
for (const Clause* const* i = clauses.begin(); i != clauses.end(); ++i)
for (NestConst<Clause>* i = clauses.begin(); i != clauses.end(); ++i)
{
switch ((*i)->type)
{
case Clause::TYPE_ADD_COLUMN:
defineField(tdbb, dsqlScratch, transaction,
static_cast<const AddColumnClause*>(*i), position, pkCols);
static_cast<AddColumnClause*>(i->getObject()), position, pkCols);
++position;
break;
case Clause::TYPE_ADD_CONSTRAINT:
makeConstraint(tdbb, dsqlScratch, transaction,
static_cast<const AddConstraintClause*>(*i), constraints);
static_cast<AddConstraintClause*>(i->getObject()), constraints);
break;
default:
@ -6536,11 +6536,11 @@ void CreateRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScrat
// separate table constraint declaration.
const ObjectsArray<MetaName>* CreateRelationNode::findPkColumns()
{
for (const Clause* const* i = clauses.begin(); i != clauses.end(); ++i)
for (const NestConst<Clause>* i = clauses.begin(); i != clauses.end(); ++i)
{
if ((*i)->type == Clause::TYPE_ADD_CONSTRAINT)
{
const AddConstraintClause* clause = static_cast<const AddConstraintClause*>(*i);
const AddConstraintClause* clause = static_cast<const AddConstraintClause*>(i->getObject());
if (clause->constraintType == AddConstraintClause::CTYPE_PK)
return &clause->columns;
@ -6593,23 +6593,24 @@ void AlterRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
ObjectsArray<Constraint> constraints;
for (const Clause* const* i = clauses.begin(); i != clauses.end(); ++i)
for (NestConst<Clause>* i = clauses.begin(); i != clauses.end(); ++i)
{
switch ((*i)->type)
{
case Clause::TYPE_ADD_COLUMN:
defineField(tdbb, dsqlScratch, transaction,
static_cast<const AddColumnClause*>(*i), -1, NULL);
static_cast<AddColumnClause*>(i->getObject()), -1, NULL);
break;
case Clause::TYPE_ALTER_COL_TYPE:
modifyField(tdbb, dsqlScratch, transaction,
static_cast<const AlterColTypeClause*>(*i));
static_cast<AlterColTypeClause*>(i->getObject()));
break;
case Clause::TYPE_ALTER_COL_NAME:
{
const AlterColNameClause* clause = static_cast<const AlterColNameClause*>(*i);
const AlterColNameClause* clause =
static_cast<const AlterColNameClause*>(i->getObject());
AutoRequest request;
bool found = false;
@ -6652,7 +6653,8 @@ void AlterRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
case Clause::TYPE_ALTER_COL_NULL:
{
const AlterColNullClause* clause = static_cast<const AlterColNullClause*>(*i);
const AlterColNullClause* clause =
static_cast<const AlterColNullClause*>(i->getObject());
//// FIXME: This clause allows inconsistencies like setting a field with a
//// not null CONSTRAINT as nullable, or setting a field based on a not null
@ -6691,7 +6693,8 @@ void AlterRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
case Clause::TYPE_ALTER_COL_POS:
{
const AlterColPosClause* clause = static_cast<const AlterColPosClause*>(*i);
const AlterColPosClause* clause =
static_cast<const AlterColPosClause*>(i->getObject());
// CVC: Since now the parser accepts pos=1..N, let's subtract one here.
const SSHORT pos = clause->newPos - 1;
@ -6730,7 +6733,8 @@ void AlterRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
// Option CASCADE causes an error: unsupported DSQL construct.
// Option RESTRICT is default behaviour.
const DropColumnClause* clause = static_cast<const DropColumnClause*>(*i);
const DropColumnClause* clause =
static_cast<const DropColumnClause*>(i->getObject());
if (clause->cascade)
{
@ -6747,12 +6751,13 @@ void AlterRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
case Clause::TYPE_ADD_CONSTRAINT:
makeConstraint(tdbb, dsqlScratch, transaction,
static_cast<const AddConstraintClause*>(*i), constraints);
static_cast<AddConstraintClause*>(i->getObject()), constraints);
break;
case Clause::TYPE_DROP_CONSTRAINT:
{
const MetaName& constraintName = static_cast<const DropConstraintClause *>(*i)->name;
const MetaName& constraintName =
static_cast<const DropConstraintClause*>(i->getObject())->name;
AutoCacheRequest request(tdbb, drq_e_rel_con, DYN_REQUESTS);
bool found = false;
@ -6832,7 +6837,7 @@ void AlterRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
// Anything to Blob
// Anything to Array
void AlterRelationNode::modifyField(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch,
jrd_tra* transaction, const AlterColTypeClause* clause)
jrd_tra* transaction, AlterColTypeClause* clause)
{
Attachment* const attachment = transaction->tra_attachment;
@ -7641,13 +7646,13 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
// SELECT. Otherwise use all the fields from the rse node that was created from the select
// expression.
const ValueExprNode* const* ptr = NULL;
const ValueExprNode* const* end = NULL;
const NestConst<ValueExprNode>* ptr = NULL;
const NestConst<ValueExprNode>* end = NULL;
if (viewFields)
{
ptr = viewFields->dsqlArgs.begin();
end = viewFields->dsqlArgs.end();
ptr = viewFields->items.begin();
end = viewFields->items.end();
}
// Go through the fields list, defining or modifying the local fields;
@ -7655,47 +7660,46 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
// field for the computed value as well.
ValueListNode* items = rse->dsqlSelectList;
ValueExprNode** itemsPtr = items->dsqlArgs.begin();
NestConst<ValueExprNode>* itemsPtr = items->items.begin();
SortedArray<dsql_fld*> modifiedFields;
bool updatable = true;
SSHORT position = 0;
for (const ValueExprNode* const* const itemsEnd = items->dsqlArgs.end();
for (NestConst<ValueExprNode>* itemsEnd = items->items.end();
itemsPtr < itemsEnd; ++itemsPtr, ++position)
{
ValueExprNode* fieldNode = *itemsPtr;
// Determine the proper field name, replacing the default if necessary.
const ValueExprNode* nameNode = fieldNode;
ValueExprNode* nameNode = fieldNode;
const char* aliasName = NULL;
while (ExprNode::is<DsqlAliasNode>(nameNode) ||
ExprNode::is<DerivedFieldNode>(nameNode) ||
ExprNode::is<DsqlMapNode>(nameNode))
while (nameNode->is<DsqlAliasNode>() || nameNode->is<DerivedFieldNode>() ||
nameNode->is<DsqlMapNode>(nameNode))
{
const DsqlAliasNode* aliasNode;
const DsqlMapNode* mapNode;
const DerivedFieldNode* derivedField;
DsqlAliasNode* aliasNode;
DsqlMapNode* mapNode;
DerivedFieldNode* derivedField;
if ((aliasNode = ExprNode::as<DsqlAliasNode>(nameNode)))
if ((aliasNode = nameNode->as<DsqlAliasNode>()))
{
if (!aliasName)
aliasName = aliasNode->name.c_str();
nameNode = aliasNode->value;
}
else if ((mapNode = ExprNode::as<DsqlMapNode>(nameNode)))
else if ((mapNode = nameNode->as<DsqlMapNode>()))
nameNode = mapNode->map->map_node;
else if ((derivedField = ExprNode::as<DerivedFieldNode>(nameNode)))
else if ((derivedField = nameNode->as<DerivedFieldNode>()))
{
if (!aliasName)
aliasName = derivedField->name.c_str();
nameNode = derivedField->dsqlValue;
nameNode = derivedField->value;
}
}
const dsql_fld* nameField = NULL;
const FieldNode* fieldNameNode = ExprNode::as<FieldNode>(nameNode);
const FieldNode* fieldNameNode = nameNode->as<FieldNode>();
if (fieldNameNode)
nameField = fieldNameNode->dsqlField;
@ -7709,7 +7713,7 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
// Check if this is a field or an expression.
const DsqlAliasNode* aliasNode = ExprNode::as<DsqlAliasNode>(fieldNode);
DsqlAliasNode* aliasNode = fieldNode->as<DsqlAliasNode>();
if (aliasNode)
fieldNode = aliasNode->value;
@ -7717,7 +7721,7 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
dsql_fld* field = NULL;
const dsql_ctx* context = NULL;
fieldNameNode = ExprNode::as<FieldNode>(fieldNode);
fieldNameNode = fieldNode->as<FieldNode>();
if (fieldNameNode)
{
@ -7744,7 +7748,7 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
if (ptr)
{
if (ptr < end)
fieldStr = ExprNode::as<FieldNode>(*ptr)->dsqlName.c_str();
fieldStr = (*ptr)->as<FieldNode>()->dsqlName.c_str();
else
{
// Generate an error when going out of this loop.
@ -7972,7 +7976,7 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
RseNode* querySpec = ExprNode::as<RseNode>(querySpecNod);
fb_assert(querySpec);
if (querySpec->dsqlFrom->dsqlArgs.getCount() != 1)
if (querySpec->dsqlFrom->items.getCount() != 1)
{
// Only one table allowed for VIEW WITH CHECK OPTION
status_exception::raise(
@ -8038,7 +8042,7 @@ void CreateAlterViewNode::createCheckTriggers(thread_db* tdbb, DsqlCompilerScrat
RseNode* rse = FB_NEW(pool) RseNode(pool);
rse->dsqlWhere = baseAndNode;
rse->dsqlStreams = FB_NEW(pool) RecSourceListNode(pool, 1);
rse->dsqlStreams->dsqlArgs[0] = baseRelation;
rse->dsqlStreams->items[0] = baseRelation;
createCheckTrigger(tdbb, dsqlScratch, rse, items, actionNode, PRE_MODIFY_TRIGGER);
createCheckTrigger(tdbb, dsqlScratch, NULL, items, actionNode, PRE_STORE_TRIGGER);
@ -8052,7 +8056,7 @@ void CreateAlterViewNode::createCheckTrigger(thread_db* tdbb, DsqlCompilerScratc
AutoSetRestore<bool> autoCheckConstraintTrigger(&dsqlScratch->checkConstraintTrigger, true);
const RecordSourceNode* querySpecNod = selectExpr->querySpec;
RecordSourceNode* querySpecNod = selectExpr->querySpec;
RelationSourceNode* relationNode = dsqlNode;
// Generate the trigger blr.
@ -8107,26 +8111,26 @@ void CreateAlterViewNode::createCheckTrigger(thread_db* tdbb, DsqlCompilerScratc
// Generate the condition for firing the trigger.
const RseNode* querySpec = ExprNode::as<RseNode>(querySpecNod);
RseNode* querySpec = querySpecNod->as<RseNode>();
fb_assert(querySpec);
if (triggerType == PRE_MODIFY_TRIGGER)
{
dsqlScratch->appendUChar(blr_for);
rse->dsqlStreams->dsqlArgs[0] = doDsqlPass(dsqlScratch, rse->dsqlStreams->dsqlArgs[0]);
rse->dsqlStreams->items[0] = doDsqlPass(dsqlScratch, rse->dsqlStreams->items[0]);
rse->dsqlWhere = doDsqlPass(dsqlScratch, rse->dsqlWhere);
GEN_expr(dsqlScratch, rse);
replaceFieldNames(querySpec->dsqlWhere, items, viewFields, false, NEW_CONTEXT);
replaceFieldNames(querySpec->dsqlWhere.getObject(), items, viewFields, false, NEW_CONTEXT);
}
else if (triggerType == PRE_STORE_TRIGGER)
replaceFieldNames(querySpec->dsqlWhere, items, viewFields, true, NEW_CONTEXT);
replaceFieldNames(querySpec->dsqlWhere.getObject(), items, viewFields, true, NEW_CONTEXT);
else
fb_assert(false);
BoolExprNode* condition = querySpec->dsqlWhere;
NestConst<BoolExprNode> condition = querySpec->dsqlWhere;
dsqlScratch->appendUChar(blr_if);
GEN_expr(dsqlScratch, doDsqlPass(dsqlScratch, condition));
@ -8163,10 +8167,10 @@ void CreateAlterViewNode::defineUpdateAction(DsqlCompilerScratch* dsqlScratch,
// Check whether this is an updatable view definition.
RseNode* querySpec = ExprNode::as<RseNode>(ExprNode::as<SelectExprNode>(selectExpr)->querySpec);
RseNode* querySpec = selectExpr->querySpec->as<RseNode>();
RecSourceListNode* fromList = NULL;
if (!querySpec || !(fromList = querySpec->dsqlFrom) || fromList->dsqlArgs.getCount() != 1)
if (!querySpec || !(fromList = querySpec->dsqlFrom) || fromList->items.getCount() != 1)
{
// The caller seems throwing proper errors for all the above conditions.
// But just in case it doesn't, here we have the final attempt to prevent the bad things.
@ -8176,7 +8180,7 @@ void CreateAlterViewNode::defineUpdateAction(DsqlCompilerScratch* dsqlScratch,
// Use the relation referenced in the select statement for rse.
RelationSourceNode* relationNode = FB_NEW(pool) RelationSourceNode(pool,
ExprNode::as<ProcedureSourceNode>(fromList->dsqlArgs[0])->dsqlName.identifier);
fromList->items[0]->as<ProcedureSourceNode>()->dsqlName.identifier);
relationNode->alias = TEMP_CONTEXT;
*baseRelation = relationNode;
@ -8205,10 +8209,10 @@ void CreateAlterViewNode::defineUpdateAction(DsqlCompilerScratch* dsqlScratch,
// Generate the list of assignments to fields in the base relation.
ValueExprNode** ptr = fieldsNode->dsqlArgs.begin();
const ValueExprNode* const* const end = fieldsNode->dsqlArgs.end();
ValueExprNode** ptr2 = valuesNode->dsqlArgs.begin();
const ValueExprNode* const* const end2 = valuesNode->dsqlArgs.end();
NestConst<ValueExprNode>* ptr = fieldsNode->items.begin();
const NestConst<ValueExprNode>* const end = fieldsNode->items.end();
NestConst<ValueExprNode>* ptr2 = valuesNode->items.begin();
const NestConst<ValueExprNode>* const end2 = valuesNode->items.end();
int andArg = 0;
BinaryBoolNode* andNode = FB_NEW(pool) BinaryBoolNode(pool, blr_and);
@ -8230,7 +8234,7 @@ void CreateAlterViewNode::defineUpdateAction(DsqlCompilerScratch* dsqlScratch,
fieldNode->dsqlQualifier = TEMP_CONTEXT;
FieldNode* oldValueNode = FB_NEW(pool) FieldNode(pool);
oldValueNode->dsqlName = ExprNode::as<FieldNode>(*ptr2)->dsqlName;
oldValueNode->dsqlName = (*ptr2)->as<FieldNode>()->dsqlName;
oldValueNode->dsqlQualifier = OLD_CONTEXT;
ComparativeBoolNode* eqlNode = FB_NEW(pool) ComparativeBoolNode(pool,
@ -8245,12 +8249,12 @@ void CreateAlterViewNode::defineUpdateAction(DsqlCompilerScratch* dsqlScratch,
if (andArg == 0)
{
++andArg;
andNode->dsqlArg1 = orNode;
andNode->arg1 = orNode;
}
else if (andArg == 1)
{
++andArg;
andNode->dsqlArg2 = orNode;
andNode->arg2 = orNode;
}
else
andNode = FB_NEW(pool) BinaryBoolNode(pool, blr_and, andNode, orNode);
@ -8258,12 +8262,18 @@ void CreateAlterViewNode::defineUpdateAction(DsqlCompilerScratch* dsqlScratch,
}
if (andArg == 0)
replaceFieldNames((andNode->dsqlArg1 = querySpec->dsqlWhere), items, NULL, false, TEMP_CONTEXT);
{
replaceFieldNames((andNode->arg1 = querySpec->dsqlWhere).getObject(), items, NULL,
false, TEMP_CONTEXT);
}
else if (andArg == 1)
replaceFieldNames((andNode->dsqlArg2 = querySpec->dsqlWhere), items, NULL, false, TEMP_CONTEXT);
{
replaceFieldNames((andNode->arg2 = querySpec->dsqlWhere).getObject(), items, NULL,
false, TEMP_CONTEXT);
}
else
{
replaceFieldNames(querySpec->dsqlWhere, items, NULL, false, TEMP_CONTEXT);
replaceFieldNames(querySpec->dsqlWhere.getObject(), items, NULL, false, TEMP_CONTEXT);
andNode = FB_NEW(pool) BinaryBoolNode(pool, blr_and, andNode, querySpec->dsqlWhere);
}
@ -8310,12 +8320,12 @@ void CreateAlterViewNode::replaceFieldNames(ExprNode* input, ValueListNode* sear
{
// Found a field node, check if it needs to be replaced.
ValueExprNode** search = searchFields->dsqlArgs.begin();
const ValueExprNode* const* const end = searchFields->dsqlArgs.end();
ValueExprNode** replace = NULL;
NestConst<ValueExprNode>* search = searchFields->items.begin();
const NestConst<ValueExprNode>* const end = searchFields->items.end();
NestConst<ValueExprNode>* replace = NULL;
if (replaceFields)
replace = replaceFields->dsqlArgs.begin();
replace = replaceFields->items.begin();
bool found = false;
@ -8717,8 +8727,8 @@ void CreateIndexNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch,
if (columns)
{
const ValueExprNode* const* ptr = columns->dsqlArgs.begin();
const ValueExprNode* const* const end = columns->dsqlArgs.end();
const NestConst<ValueExprNode>* ptr = columns->items.begin();
const NestConst<ValueExprNode>* const end = columns->items.end();
for (; ptr != end; ++ptr)
{
@ -9054,7 +9064,7 @@ void CreateShadowNode::execute(thread_db* tdbb, DsqlCompilerScratch* /*dsqlScrat
SLONG start = 0;
for (DbFileClause** i = files.begin(); i != files.end(); ++i)
for (NestConst<DbFileClause>* i = files.begin(); i != files.end(); ++i)
{
bool first = i == files.begin();
DbFileClause* file = *i;
@ -9560,7 +9570,7 @@ void GrantRevokeNode::modifyPrivileges(thread_db* tdbb, jrd_tra* transaction, SS
ValueListNode* fields = i->second;
for (ValueExprNode** ptr = fields->dsqlArgs.begin(); ptr != fields->dsqlArgs.end(); ++ptr)
for (NestConst<ValueExprNode>* ptr = fields->items.begin(); ptr != fields->items.end(); ++ptr)
{
grantRevoke(tdbb, transaction, table, user, privs0,
(*ptr)->as<FieldNode>()->dsqlName, option);
@ -10192,7 +10202,7 @@ void AlterDatabaseNode::execute(thread_db* tdbb, DsqlCompilerScratch* /*dsqlScra
if (clauses & CLAUSE_DROP_DIFFERENCE)
changeBackupMode(tdbb, transaction, CLAUSE_DROP_DIFFERENCE);
for (DbFileClause** i = files.begin(); i != files.end(); ++i)
for (NestConst<DbFileClause>* i = files.begin(); i != files.end(); ++i)
{
DbFileClause* file = *i;

View File

@ -50,7 +50,7 @@ struct BoolSourceClause
{
}
BoolExprNode* value;
NestConst<BoolExprNode> value;
Firebird::string source;
};
@ -63,7 +63,7 @@ struct ValueSourceClause
{
}
ValueExprNode* value;
NestConst<ValueExprNode> value;
Firebird::string source;
};
@ -164,8 +164,8 @@ public:
public:
Firebird::MetaName name;
ValueSourceClause* defaultClause;
ValueExprNode* parameterExpr;
NestConst<ValueSourceClause> defaultClause;
NestConst<ValueExprNode> parameterExpr;
Nullable<int> udfMechanism;
};
@ -213,7 +213,7 @@ protected:
}
protected:
CreateNode* createNode;
NestConst<CreateNode> createNode;
DropNode dropNode;
};
@ -335,7 +335,7 @@ private:
bool secondPass, bool runTriggers);
void storeArgument(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
unsigned pos, const ParameterClause& parameter, const bid* comment);
unsigned pos, ParameterClause& parameter, const bid* comment);
void compile(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch);
void collectParamComments(thread_db* tdbb, jrd_tra* transaction, MetaNameBidMap& items);
@ -343,7 +343,7 @@ public:
Firebird::MetaName name;
bool create;
bool alter;
ExternalClause* external;
NestConst<ExternalClause> external;
bool deterministic;
Firebird::Array<ParameterClause> parameters;
ParameterClause returnType;
@ -464,7 +464,7 @@ private:
bool executeAlter(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
bool secondPass, bool runTriggers);
void storeParameter(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
USHORT type, unsigned pos, const ParameterClause& parameter, const bid* comment);
USHORT type, unsigned pos, ParameterClause& parameter, const bid* comment);
void compile(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch);
void collectParamComments(thread_db* tdbb, jrd_tra* transaction, MetaNameBidMap& items);
@ -472,7 +472,7 @@ public:
Firebird::MetaName name;
bool create;
bool alter;
ExternalClause* external;
NestConst<ExternalClause> external;
Firebird::Array<ParameterClause> parameters;
Firebird::Array<ParameterClause> returns;
Firebird::string source;
@ -556,7 +556,7 @@ public:
Nullable<FB_UINT64> type;
Nullable<bool> active;
Nullable<int> position;
ExternalClause* external;
NestConst<ExternalClause> external;
Firebird::string source;
Firebird::ByteChunk blrData;
Firebird::ByteChunk debugData;
@ -791,7 +791,7 @@ protected:
public:
ParameterClause nameType;
bool notNull;
BoolSourceClause* check;
NestConst<BoolSourceClause> check;
};
@ -833,8 +833,8 @@ public:
Firebird::MetaName name;
bool dropConstraint;
bool dropDefault;
BoolSourceClause* setConstraint;
ValueSourceClause* setDefault;
NestConst<BoolSourceClause> setConstraint;
NestConst<ValueSourceClause> setDefault;
Firebird::MetaName renameTo;
Firebird::AutoPtr<TypeClause> type;
Nullable<bool> notNullFlag; // true = NOT NULL / false = NULL
@ -1100,7 +1100,7 @@ public:
Constraint::Type type;
Firebird::MetaName name;
Firebird::ObjectsArray<Firebird::MetaName> columns;
IndexConstraintClause* index;
const IndexConstraintClause* index;
Firebird::MetaName refRelation;
Firebird::ObjectsArray<Firebird::MetaName> refColumns;
const char* refUpdateAction;
@ -1176,11 +1176,11 @@ public:
Firebird::MetaName name;
ConstraintType constraintType;
Firebird::ObjectsArray<Firebird::MetaName> columns;
IndexConstraintClause* index;
NestConst<IndexConstraintClause> index;
Firebird::MetaName refRelation;
Firebird::ObjectsArray<Firebird::MetaName> refColumns;
RefActionClause* refAction;
BoolSourceClause* check;
NestConst<RefActionClause> refAction;
NestConst<BoolSourceClause> check;
};
struct AddColumnClause : public Clause
@ -1198,11 +1198,11 @@ public:
}
dsql_fld* field;
ValueSourceClause* defaultValue;
NestConst<ValueSourceClause> defaultValue;
Firebird::ObjectsArray<AddConstraintClause> constraints;
Firebird::MetaName collate;
Firebird::MetaName domain;
ValueSourceClause* computed;
NestConst<ValueSourceClause> computed;
bool identity;
};
@ -1259,9 +1259,9 @@ public:
dsql_fld* field;
Firebird::MetaName domain;
ValueSourceClause* defaultValue;
NestConst<ValueSourceClause> defaultValue;
bool dropDefault;
ValueSourceClause* computed;
NestConst<ValueSourceClause> computed;
};
struct DropColumnClause : public Clause
@ -1295,19 +1295,19 @@ public:
protected:
void defineField(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
const AddColumnClause* clause, SSHORT position,
AddColumnClause* clause, SSHORT position,
const Firebird::ObjectsArray<Firebird::MetaName>* pkcols);
bool defineDefault(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, dsql_fld* field,
const ValueSourceClause* clause, Firebird::string& source, BlrWriter::BlrData& value);
ValueSourceClause* clause, Firebird::string& source, BlrWriter::BlrData& value);
void makeConstraint(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
const AddConstraintClause* clause, Firebird::ObjectsArray<Constraint>& constraints,
AddConstraintClause* clause, Firebird::ObjectsArray<Constraint>& constraints,
bool* notNull = NULL);
void defineConstraint(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
Constraint& constraint);
void defineCheckConstraint(DsqlCompilerScratch* dsqlScratch, Constraint& constraint,
const BoolSourceClause* clause);
BoolSourceClause* clause);
void defineCheckConstraintTrigger(DsqlCompilerScratch* dsqlScratch, Constraint& constraint,
const BoolSourceClause* clause, FB_UINT64 triggerType);
BoolSourceClause* clause, FB_UINT64 triggerType);
void defineSetDefaultTrigger(DsqlCompilerScratch* dsqlScratch, Constraint& constraint,
bool onUpdate);
void defineSetNullTrigger(DsqlCompilerScratch* dsqlScratch, Constraint& constraint,
@ -1321,9 +1321,9 @@ protected:
void stuffTriggerFiringCondition(const Constraint& constraint, BlrWriter& blrWriter);
public:
RelationSourceNode* dsqlNode;
NestConst<RelationSourceNode> dsqlNode;
Firebird::MetaName name;
Firebird::Array<Clause*> clauses;
Firebird::Array<NestConst<Clause> > clauses;
};
@ -1377,7 +1377,7 @@ protected:
private:
void modifyField(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
const AlterColTypeClause* clause);
AlterColTypeClause* clause);
};
@ -1458,8 +1458,8 @@ private:
public:
bool create;
bool alter;
ValueListNode* viewFields;
SelectExprNode* selectExpr;
NestConst<ValueListNode> viewFields;
NestConst<SelectExprNode> selectExpr;
Firebird::string source;
bool withCheckOption;
};
@ -1532,9 +1532,9 @@ public:
Firebird::MetaName name;
bool unique;
bool descending;
RelationSourceNode* relation;
ValueListNode* columns;
ValueSourceClause* computed;
NestConst<RelationSourceNode> relation;
NestConst<ValueListNode> columns;
NestConst<ValueSourceClause> computed;
};
@ -1660,8 +1660,8 @@ protected:
public:
Firebird::MetaName name;
NameNumber* inputFilter;
NameNumber* outputFilter;
NestConst<NameNumber> inputFilter;
NestConst<NameNumber> outputFilter;
Firebird::string entryPoint;
Firebird::string moduleName;
};
@ -1718,7 +1718,7 @@ public:
bool manual;
bool conditional;
Nullable<SLONG> firstLength;
Firebird::Array<DbFileClause*> files;
Firebird::Array<NestConst<DbFileClause> > files;
};
@ -1946,10 +1946,10 @@ public:
bool isGrant;
Firebird::Array<PrivilegeClause> privileges;
Firebird::Array<GranteeClause> roles;
GranteeClause* table;
NestConst<GranteeClause> table;
Firebird::Array<GranteeClause> users;
bool grantAdminOption;
Firebird::MetaName* grantor;
NestConst<Firebird::MetaName> grantor;
};
@ -2001,7 +2001,7 @@ public:
Firebird::PathName differenceFile;
Firebird::MetaName setDefaultCharSet;
Firebird::MetaName setDefaultCollation;
Firebird::Array<DbFileClause*> files;
Firebird::Array<NestConst<DbFileClause> > files;
};

View File

@ -315,7 +315,7 @@ void DsqlCompilerScratch::putLocalVariable(dsql_var* variable, const DeclareVari
//field->fld_dtype = dtype;
// Check for a default value, borrowed from define_domain
ValueSourceClause* node = hostParam ? hostParam->dsqlDef->defaultClause : NULL;
NestConst<ValueSourceClause> node = hostParam ? hostParam->dsqlDef->defaultClause : NULL;
if (variable->type == dsql_var::TYPE_INPUT)
{
@ -616,7 +616,7 @@ SelectExprNode* DsqlCompilerScratch::pass1RecursiveCte(SelectExprNode* input)
RecordSourceNode* rse = NULL;
if (unionQuery)
rse = unionQuery->dsqlClauses->dsqlArgs[1];
rse = unionQuery->dsqlClauses->items[1];
else
rse = qry;
@ -670,16 +670,16 @@ SelectExprNode* DsqlCompilerScratch::pass1RecursiveCte(SelectExprNode* input)
newRse->dsqlFlags |= RecordSourceNode::DFLAG_RECURSIVE;
if (unionQuery)
newQry->dsqlClauses->dsqlArgs[1] = newRse;
newQry->dsqlClauses->items[1] = newRse;
else
newQry->dsqlClauses->dsqlArgs[0] = newRse;
newQry->dsqlClauses->items[0] = newRse;
}
else
{
if (unionQuery)
newQry->dsqlClauses->dsqlArgs[1] = rse;
newQry->dsqlClauses->items[1] = rse;
else
newQry->dsqlClauses->dsqlArgs[0] = rse;
newQry->dsqlClauses->items[0] = rse;
if (!anchorRse)
{
@ -693,7 +693,7 @@ SelectExprNode* DsqlCompilerScratch::pass1RecursiveCte(SelectExprNode* input)
if (!unionQuery)
break;
qry = unionQuery->dsqlClauses->dsqlArgs[0];
qry = unionQuery->dsqlClauses->items[0];
unionQuery = qry->as<UnionSourceNode>();
if (unionQuery)
@ -703,7 +703,7 @@ SelectExprNode* DsqlCompilerScratch::pass1RecursiveCte(SelectExprNode* input)
newUnion->dsqlAll = unionQuery->dsqlAll;
newUnion->recursive = unionQuery->recursive;
newQry->dsqlClauses->dsqlArgs[0] = newUnion;
newQry->dsqlClauses->items[0] = newUnion;
newQry = newUnion;
}
}
@ -721,25 +721,25 @@ SelectExprNode* DsqlCompilerScratch::pass1RecursiveCte(SelectExprNode* input)
UnionSourceNode* qry2 = recursiveRse->as<UnionSourceNode>();
UnionSourceNode* list = NULL;
while (qry2->dsqlClauses->dsqlArgs[0] != anchorRse)
while (qry2->dsqlClauses->items[0] != anchorRse)
{
list = qry2;
qry2 = qry2->dsqlClauses->dsqlArgs[0]->as<UnionSourceNode>();
qry2 = qry2->dsqlClauses->items[0]->as<UnionSourceNode>();
}
qry2->dsqlClauses->dsqlArgs[0] = NULL;
qry2->dsqlClauses->items[0] = NULL;
if (list)
list->dsqlClauses->dsqlArgs[0] = qry2->dsqlClauses->dsqlArgs[1];
list->dsqlClauses->items[0] = qry2->dsqlClauses->items[1];
else
recursiveRse = qry2->dsqlClauses->dsqlArgs[1];
recursiveRse = qry2->dsqlClauses->items[1];
UnionSourceNode* unionNode = FB_NEW(pool) UnionSourceNode(pool);
unionNode->dsqlAll = true;
unionNode->recursive = true;
unionNode->dsqlClauses = FB_NEW(pool) RecSourceListNode(pool, 2);
unionNode->dsqlClauses->dsqlArgs[0] = anchorRse;
unionNode->dsqlClauses->dsqlArgs[1] = recursiveRse;
unionNode->dsqlClauses->items[0] = anchorRse;
unionNode->dsqlClauses->items[1] = recursiveRse;
SelectExprNode* select = FB_NEW(getPool()) SelectExprNode(getPool());
select->querySpec = unionNode;
@ -769,15 +769,15 @@ RseNode* DsqlCompilerScratch::pass1RseIsRecursive(RseNode* input)
result->rse_plan = input->rse_plan;
RecSourceListNode* srcTables = input->dsqlFrom;
RecSourceListNode* dstTables = FB_NEW(pool) RecSourceListNode(pool, srcTables->dsqlArgs.getCount());
RecSourceListNode* dstTables = FB_NEW(pool) RecSourceListNode(pool, srcTables->items.getCount());
result->dsqlFrom = dstTables;
RecordSourceNode** pDstTable = dstTables->dsqlArgs.begin();
RecordSourceNode** pSrcTable = srcTables->dsqlArgs.begin();
RecordSourceNode** end = srcTables->dsqlArgs.end();
NestConst<RecordSourceNode>* pDstTable = dstTables->items.begin();
NestConst<RecordSourceNode>* pSrcTable = srcTables->items.begin();
NestConst<RecordSourceNode>* end = srcTables->items.end();
bool found = false;
for (RecordSourceNode** prev = pDstTable; pSrcTable < end; ++pSrcTable, ++pDstTable)
for (NestConst<RecordSourceNode>* prev = pDstTable; pSrcTable < end; ++pSrcTable, ++pDstTable)
{
*prev++ = *pDstTable = *pSrcTable;
@ -791,7 +791,7 @@ RseNode* DsqlCompilerScratch::pass1RseIsRecursive(RseNode* input)
*pDstTable = dstRse;
BoolExprNode* joinBool = pass1JoinIsRecursive(*pDstTable);
BoolExprNode* joinBool = pass1JoinIsRecursive(*pDstTable->getAddress());
if (joinBool)
{
@ -820,7 +820,7 @@ RseNode* DsqlCompilerScratch::pass1RseIsRecursive(RseNode* input)
found = true;
--prev;
dstTables->dsqlArgs.pop();
dstTables->items.pop();
}
}
else if (!(*pDstTable)->is<SelectExprNode>())
@ -878,12 +878,12 @@ BoolExprNode* DsqlCompilerScratch::pass1JoinIsRecursive(RecordSourceNode*& input
bool leftRecursive = false;
BoolExprNode* leftBool = NULL;
RecordSourceNode** joinTable = &inputRse->dsqlFrom->dsqlArgs[0];
NestConst<RecordSourceNode>* joinTable = &inputRse->dsqlFrom->items[0];
RseNode* joinRse;
if ((joinRse = ExprNode::as<RseNode>(*joinTable)) && joinRse->dsqlExplicitJoin)
if ((joinRse = (*joinTable)->as<RseNode>()) && joinRse->dsqlExplicitJoin)
{
leftBool = pass1JoinIsRecursive(*joinTable);
leftBool = pass1JoinIsRecursive(*joinTable->getAddress());
leftRecursive = (leftBool != NULL);
}
else
@ -905,17 +905,17 @@ BoolExprNode* DsqlCompilerScratch::pass1JoinIsRecursive(RecordSourceNode*& input
bool rightRecursive = false;
BoolExprNode* rightBool = NULL;
joinTable = &inputRse->dsqlFrom->dsqlArgs[1];
joinTable = &inputRse->dsqlFrom->items[1];
if ((joinRse = ExprNode::as<RseNode>(*joinTable)) && joinRse->dsqlExplicitJoin)
if ((joinRse = (*joinTable)->as<RseNode>()) && joinRse->dsqlExplicitJoin)
{
rightBool = pass1JoinIsRecursive(*joinTable);
rightBool = pass1JoinIsRecursive(*joinTable->getAddress());
rightRecursive = (rightBool != NULL);
}
else
{
rightBool = inputRse->dsqlWhere;
rightRecursive = pass1RelProcIsRecursive(*joinTable);
rightRecursive = pass1RelProcIsRecursive(*joinTable->getAddress());
if (rightRecursive)
remove = true;
@ -938,7 +938,7 @@ BoolExprNode* DsqlCompilerScratch::pass1JoinIsRecursive(RecordSourceNode*& input
if (leftRecursive)
{
if (remove)
input = inputRse->dsqlFrom->dsqlArgs[1];
input = inputRse->dsqlFrom->items[1];
return leftBool;
}
@ -946,7 +946,7 @@ BoolExprNode* DsqlCompilerScratch::pass1JoinIsRecursive(RecordSourceNode*& input
if (rightRecursive)
{
if (remove)
input = inputRse->dsqlFrom->dsqlArgs[0];
input = inputRse->dsqlFrom->items[0];
return rightBool;
}

File diff suppressed because it is too large Load Diff

View File

@ -85,8 +85,6 @@ public:
UCHAR blrOp;
bool dialect1;
Firebird::string label;
ValueExprNode* dsqlArg1;
ValueExprNode* dsqlArg2;
NestConst<ValueExprNode> arg1;
NestConst<ValueExprNode> arg2;
};
@ -95,7 +93,7 @@ public:
class ArrayNode : public TypedNode<ValueExprNode, ExprNode::TYPE_ARRAY>
{
public:
ArrayNode(MemoryPool& pool, FieldNode* field);
ArrayNode(MemoryPool& pool, FieldNode* aField);
virtual void print(Firebird::string& text) const;
virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
@ -135,7 +133,7 @@ public:
}
public:
FieldNode* dsqlField;
NestConst<FieldNode> field;
};
@ -162,7 +160,6 @@ public:
virtual dsc* execute(thread_db* tdbb, jrd_req* request) const;
public:
BoolExprNode* dsqlBoolean;
NestConst<BoolExprNode> boolean;
};
@ -170,7 +167,7 @@ public:
class CastNode : public TypedNode<ValueExprNode, ExprNode::TYPE_CAST>
{
public:
explicit CastNode(MemoryPool& pool, ValueExprNode* aDsqlSource = NULL, dsql_fld* aDsqlField = NULL);
explicit CastNode(MemoryPool& pool, ValueExprNode* aSource = NULL, dsql_fld* aDsqlField = NULL);
static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
@ -192,7 +189,6 @@ public:
public:
Firebird::MetaName dsqlAlias;
ValueExprNode* dsqlSource;
dsql_fld* dsqlField;
dsc castDesc;
NestConst<ValueExprNode> source;
@ -203,12 +199,11 @@ public:
class CoalesceNode : public TypedNode<ValueExprNode, ExprNode::TYPE_COALESCE>
{
public:
explicit CoalesceNode(MemoryPool& pool, ValueListNode* aDsqlArgs = NULL)
explicit CoalesceNode(MemoryPool& pool, ValueListNode* aArgs = NULL)
: TypedNode<ValueExprNode, ExprNode::TYPE_COALESCE>(pool),
dsqlArgs(aDsqlArgs),
args(NULL)
args(aArgs)
{
addChildNode(dsqlArgs, args);
addChildNode(args, args);
}
static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
@ -227,7 +222,6 @@ public:
virtual dsc* execute(thread_db* tdbb, jrd_req* request) const;
public:
ValueListNode* dsqlArgs;
NestConst<ValueListNode> args;
};
@ -235,7 +229,7 @@ public:
class CollateNode : public TypedNode<ValueExprNode, ExprNode::TYPE_COLLATE>
{
public:
CollateNode(MemoryPool& pool, ValueExprNode* aDsqlArg, const Firebird::MetaName& aCollation);
CollateNode(MemoryPool& pool, ValueExprNode* aArg, const Firebird::MetaName& aCollation);
virtual void print(Firebird::string& text) const;
virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
@ -281,7 +275,7 @@ private:
static void assignFieldDtypeFromDsc(dsql_fld* field, const dsc* desc);
public:
ValueExprNode* dsqlArg;
NestConst<ValueExprNode> arg;
Firebird::MetaName collation;
};
@ -307,8 +301,6 @@ public:
virtual dsc* execute(thread_db* tdbb, jrd_req* request) const;
public:
ValueExprNode* dsqlArg1;
ValueExprNode* dsqlArg2;
NestConst<ValueExprNode> arg1;
NestConst<ValueExprNode> arg2;
};
@ -439,20 +431,17 @@ public:
class DecodeNode : public TypedNode<ValueExprNode, ExprNode::TYPE_DECODE>
{
public:
explicit DecodeNode(MemoryPool& pool, ValueExprNode* aDsqlTest = NULL,
ValueListNode* aDsqlConditions = NULL, ValueListNode* aDsqlValues = NULL)
explicit DecodeNode(MemoryPool& pool, ValueExprNode* aTest = NULL,
ValueListNode* aConditions = NULL, ValueListNode* aValues = NULL)
: TypedNode<ValueExprNode, ExprNode::TYPE_DECODE>(pool),
label(pool),
dsqlTest(aDsqlTest),
dsqlConditions(aDsqlConditions),
dsqlValues(aDsqlValues),
test(NULL),
conditions(NULL),
values(NULL)
test(aTest),
conditions(aConditions),
values(aValues)
{
addChildNode(dsqlTest, test);
addChildNode(dsqlConditions, conditions);
addChildNode(dsqlValues, values);
addChildNode(test, test);
addChildNode(conditions, conditions);
addChildNode(values, values);
label = "DECODE";
}
@ -474,9 +463,6 @@ public:
public:
Firebird::string label;
ValueExprNode* dsqlTest;
ValueListNode* dsqlConditions;
ValueListNode* dsqlValues;
NestConst<ValueExprNode> test;
NestConst<ValueListNode> conditions;
NestConst<ValueListNode> values;
@ -589,7 +575,6 @@ public:
public:
UCHAR blrSubOp;
ValueExprNode* dsqlArg;
NestConst<ValueExprNode> arg;
};
@ -662,7 +647,7 @@ public:
Firebird::MetaName dsqlName;
dsql_ctx* const dsqlContext;
dsql_fld* const dsqlField;
ValueListNode* dsqlIndices;
NestConst<ValueListNode> dsqlIndices;
const StreamType fieldStream;
const Format* format;
const USHORT fieldId;
@ -701,7 +686,6 @@ public:
public:
bool dialect1;
Firebird::MetaName name;
ValueExprNode* dsqlArg;
NestConst<ValueExprNode> arg;
SLONG id;
};
@ -734,7 +718,6 @@ public:
virtual dsc* execute(thread_db* tdbb, jrd_req* request) const;
public:
ValueExprNode* dsqlArg;
NestConst<ValueExprNode> arg;
};
@ -812,7 +795,7 @@ public:
public:
const Firebird::MetaName name;
ValueExprNode* value;
NestConst<ValueExprNode> value;
NestConst<ImplicitJoin> implicitJoin;
};
@ -864,7 +847,7 @@ class DerivedFieldNode : public TypedNode<ValueExprNode, ExprNode::TYPE_DERIVED_
{
public:
DerivedFieldNode(MemoryPool& pool, const Firebird::MetaName& aName, USHORT aScope,
ValueExprNode* aDsqlValue);
ValueExprNode* aValue);
virtual void print(Firebird::string& text) const;
virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
@ -900,7 +883,7 @@ public:
public:
Firebird::MetaName name;
USHORT scope;
ValueExprNode* dsqlValue;
NestConst<ValueExprNode> value;
dsql_ctx* context;
};
@ -926,7 +909,6 @@ public:
virtual dsc* execute(thread_db* tdbb, jrd_req* request) const;
public:
ValueExprNode* dsqlArg;
NestConst<ValueExprNode> arg;
};
@ -963,7 +945,7 @@ public:
NULLS_LAST
};
OrderNode(MemoryPool& pool, ValueExprNode* aDsqlValue);
OrderNode(MemoryPool& pool, ValueExprNode* aValue);
virtual void print(Firebird::string& text) const;
virtual OrderNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
@ -1002,7 +984,7 @@ public:
}
public:
ValueExprNode* dsqlValue;
NestConst<ValueExprNode> value;
bool descending;
NullsPlacement nullsPlacement;
};
@ -1034,9 +1016,9 @@ public:
virtual dsc* execute(thread_db* tdbb, jrd_req* request) const;
public:
ValueExprNode* dsqlAggExpr;
ValueListNode* dsqlPartition;
ValueListNode* dsqlOrder;
NestConst<ValueExprNode> aggExpr;
NestConst<ValueListNode> partition;
NestConst<ValueListNode> order;
};
@ -1134,7 +1116,7 @@ private:
public:
UCHAR blrOp;
Firebird::MetaName dsqlQualifier;
RecordSourceNode* dsqlRelation;
NestConst<RecordSourceNode> dsqlRelation;
StreamType recStream;
bool aggregate;
};
@ -1259,7 +1241,6 @@ public:
public:
UCHAR blrOp;
ValueExprNode* dsqlArg;
NestConst<ValueExprNode> arg;
};
@ -1288,7 +1269,6 @@ public:
public:
UCHAR blrSubOp;
ValueExprNode* dsqlArg;
NestConst<ValueExprNode> arg;
};
@ -1342,9 +1322,7 @@ public:
public:
UCHAR blrOp;
RecordSourceNode* dsqlRse;
ValueExprNode* dsqlValue1;
ValueExprNode* dsqlValue2;
NestConst<RecordSourceNode> dsqlRse;
NestConst<RseNode> rse;
NestConst<ValueExprNode> value1;
NestConst<ValueExprNode> value2;
@ -1377,9 +1355,6 @@ public:
const dsc* startDsc, const dsc* lengthDsc);
public:
ValueExprNode* dsqlExpr;
ValueExprNode* dsqlStart;
ValueExprNode* dsqlLength;
NestConst<ValueExprNode> expr;
NestConst<ValueExprNode> start;
NestConst<ValueExprNode> length;
@ -1409,9 +1384,6 @@ public:
virtual dsc* execute(thread_db* tdbb, jrd_req* request) const;
public:
ValueExprNode* dsqlExpr;
ValueExprNode* dsqlPattern;
ValueExprNode* dsqlEscape;
NestConst<ValueExprNode> expr;
NestConst<ValueExprNode> pattern;
NestConst<ValueExprNode> escape;
@ -1441,7 +1413,6 @@ public:
public:
Firebird::MetaName name;
ValueListNode* dsqlArgs;
bool dsqlSpecialSyntax;
NestConst<ValueListNode> args;
const SysFunction* function;
@ -1473,8 +1444,6 @@ public:
public:
UCHAR where;
ValueExprNode* dsqlValue;
ValueExprNode* dsqlTrimChars; // may be NULL
NestConst<ValueExprNode> value;
NestConst<ValueExprNode> trimChars; // may be NULL
};
@ -1504,7 +1473,6 @@ public:
public:
Firebird::QualifiedName name;
ValueListNode* dsqlArgs;
NestConst<ValueListNode> args;
NestConst<Function> function;
@ -1540,9 +1508,6 @@ public:
virtual dsc* execute(thread_db* tdbb, jrd_req* request) const;
public:
BoolExprNode* dsqlCondition;
ValueExprNode* dsqlTrueValue;
ValueExprNode* dsqlFalseValue;
NestConst<BoolExprNode> condition;
NestConst<ValueExprNode> trueValue;
NestConst<ValueExprNode> falseValue;

View File

@ -125,7 +125,7 @@ public:
// Compile a parsed statement into something more interesting.
template <typename T>
static T* doDsqlPass(DsqlCompilerScratch* dsqlScratch, T* node)
static T* doDsqlPass(DsqlCompilerScratch* dsqlScratch, NestConst<T>& node)
{
if (!node)
return NULL;
@ -135,7 +135,7 @@ public:
// Compile a parsed statement into something more interesting and assign it to target.
template <typename T1, typename T2>
static void doDsqlPass(DsqlCompilerScratch* dsqlScratch, T1*& target, T2* node)
static void doDsqlPass(DsqlCompilerScratch* dsqlScratch, NestConst<T1>& target, NestConst<T2>& node)
{
if (!node)
target = NULL;
@ -145,7 +145,7 @@ public:
// Changes dsqlScratch->isPsql() value, calls doDsqlPass and restore dsqlScratch->isPsql().
template <typename T>
static T* doDsqlPass(DsqlCompilerScratch* dsqlScratch, T* node, bool psql)
static T* doDsqlPass(DsqlCompilerScratch* dsqlScratch, NestConst<T>& node, bool psql)
{
PsqlChanger changer(dsqlScratch, psql);
return doDsqlPass(dsqlScratch, node);
@ -153,7 +153,7 @@ public:
// Changes dsqlScratch->isPsql() value, calls doDsqlPass and restore dsqlScratch->isPsql().
template <typename T1, typename T2>
static void doDsqlPass(DsqlCompilerScratch* dsqlScratch, T1*& target, T2* node, bool psql)
static void doDsqlPass(DsqlCompilerScratch* dsqlScratch, NestConst<T1>& target, NestConst<T2>& node, bool psql)
{
PsqlChanger changer(dsqlScratch, psql);
doDsqlPass(dsqlScratch, target, node);
@ -587,14 +587,14 @@ public:
}
template <typename T>
static void doDsqlFieldRemapper(FieldRemapper& visitor, T*& node)
static void doDsqlFieldRemapper(FieldRemapper& visitor, NestConst<T>& node)
{
if (node)
node = node->dsqlFieldRemapper(visitor);
}
template <typename T1, typename T2>
static void doDsqlFieldRemapper(FieldRemapper& visitor, T1*& target, T2* node)
static void doDsqlFieldRemapper(FieldRemapper& visitor, NestConst<T1>& target, NestConst<T2> node)
{
target = node ? node->dsqlFieldRemapper(visitor) : NULL;
}
@ -631,16 +631,16 @@ public:
protected:
template <typename T1, typename T2>
void addChildNode(T1*& dsqlNode, NestConst<T2>& jrdNode)
void addChildNode(NestConst<T1>& dsqlNode, NestConst<T2>& jrdNode)
{
addDsqlChildNode(dsqlNode);
addChildNode(jrdNode);
}
template <typename T>
void addDsqlChildNode(T*& dsqlNode)
void addDsqlChildNode(NestConst<T>& dsqlNode)
{
dsqlChildNodes.add(FB_NEW(getPool()) NodeRefImpl<T>(&dsqlNode));
dsqlChildNodes.add(FB_NEW(getPool()) NodeRefImpl<T>(dsqlNode.getAddress()));
}
template <typename T>
@ -674,7 +674,8 @@ inline const ExprNode* NodeRefImpl<T>::getExpr() const
template <typename T>
inline void NodeRefImpl<T>::remap(FieldRemapper& visitor)
{
ExprNode::doDsqlFieldRemapper(visitor, *ptr);
if (*ptr)
*ptr = (*ptr)->dsqlFieldRemapper(visitor);
}
template <typename T>
@ -909,13 +910,12 @@ public:
virtual AggNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
protected:
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) const = 0;
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/ = 0;
public:
const AggInfo& aggInfo;
bool distinct;
bool dialect1;
ValueExprNode* dsqlArg;
NestConst<ValueExprNode> arg;
const AggregateSort* asb;
bool indexed;
@ -1093,52 +1093,52 @@ class ValueListNode : public TypedNode<ListExprNode, ExprNode::TYPE_VALUE_LIST>
public:
ValueListNode(MemoryPool& pool, unsigned count)
: TypedNode<ListExprNode, ExprNode::TYPE_VALUE_LIST>(pool),
dsqlArgs(pool),
args(pool)
items(pool)
{
dsqlArgs.resize(count);
args.resize(count);
items.resize(count);
for (unsigned i = 0; i < count; ++i)
addChildNode((dsqlArgs[i] = NULL), (args[i] = NULL));
{
items[i] = NULL;
addChildNode(items[i], items[i]);
}
}
ValueListNode(MemoryPool& pool, ValueExprNode* arg1)
: TypedNode<ListExprNode, ExprNode::TYPE_VALUE_LIST>(pool),
dsqlArgs(pool),
args(pool)
items(pool)
{
dsqlArgs.resize(1);
addDsqlChildNode((dsqlArgs[0] = arg1));
items.resize(1);
addDsqlChildNode((items[0] = arg1));
}
ValueListNode* add(ValueExprNode* argn)
{
dsqlArgs.add(argn);
items.add(argn);
resetChildNodes();
return this;
}
ValueListNode* addFront(ValueExprNode* argn)
{
dsqlArgs.insert(0, argn);
items.insert(0, argn);
resetChildNodes();
return this;
}
void clear()
{
dsqlArgs.clear();
items.clear();
resetChildNodes();
}
virtual ValueListNode* dsqlPass(DsqlCompilerScratch* dsqlScratch)
{
ValueListNode* node = FB_NEW(getPool()) ValueListNode(getPool(), dsqlArgs.getCount());
ValueListNode* node = FB_NEW(getPool()) ValueListNode(getPool(), items.getCount());
ValueExprNode** dst = node->dsqlArgs.begin();
NestConst<ValueExprNode>* dst = node->items.begin();
for (ValueExprNode** src = dsqlArgs.begin(); src != dsqlArgs.end(); ++src, ++dst)
for (NestConst<ValueExprNode>* src = items.begin(); src != items.end(); ++src, ++dst)
*dst = doDsqlPass(dsqlScratch, *src);
return node;
@ -1165,11 +1165,11 @@ public:
virtual ValueListNode* copy(thread_db* tdbb, NodeCopier& copier) const
{
ValueListNode* node = FB_NEW(*tdbb->getDefaultPool()) ValueListNode(*tdbb->getDefaultPool(),
args.getCount());
items.getCount());
NestConst<ValueExprNode>* j = node->args.begin();
NestConst<ValueExprNode>* j = node->items.begin();
for (const NestConst<ValueExprNode>* i = args.begin(); i != args.end(); ++i, ++j)
for (const NestConst<ValueExprNode>* i = items.begin(); i != items.end(); ++i, ++j)
*j = copier.copy(tdbb, *i);
return node;
@ -1181,16 +1181,12 @@ private:
dsqlChildNodes.clear();
jrdChildNodes.clear();
for (size_t i = 0; i < dsqlArgs.getCount(); ++i)
addDsqlChildNode(dsqlArgs[i]);
for (size_t i = 0; i < args.getCount(); ++i)
addChildNode(args[i]);
for (size_t i = 0; i < items.getCount(); ++i)
addChildNode(items[i], items[i]);
}
public:
Firebird::Array<ValueExprNode*> dsqlArgs;
NestValueArray args;
NestValueArray items;
};
// Container for a list of record source expressions.
@ -1202,7 +1198,7 @@ public:
RecSourceListNode* add(RecordSourceNode* argn)
{
dsqlArgs.add(argn);
items.add(argn);
resetChildNodes();
return this;
}
@ -1238,12 +1234,12 @@ private:
{
dsqlChildNodes.clear();
for (size_t i = 0; i < dsqlArgs.getCount(); ++i)
addDsqlChildNode(dsqlArgs[i]);
for (size_t i = 0; i < items.getCount(); ++i)
addDsqlChildNode(items[i]);
}
public:
Firebird::Array<RecordSourceNode*> dsqlArgs;
Firebird::Array<NestConst<RecordSourceNode> > items;
};
@ -1468,7 +1464,7 @@ public:
virtual void genBlr(DsqlCompilerScratch* dsqlScratch);
private:
StmtNode* stmt;
NestConst<StmtNode> stmt;
};
@ -1483,8 +1479,8 @@ public:
}
public:
ValueExprNode* length;
ValueExprNode* skip;
NestConst<ValueExprNode> length;
NestConst<ValueExprNode> skip;
};

View File

@ -219,6 +219,12 @@ private:
clause = value;
}
template <typename T1, typename T2>
void setClause(NestConst<T1>& clause, const char* duplicateMsg, const T2& value)
{
setClause(*clause.getAddress(), duplicateMsg, value);
}
void setClause(bool& clause, const char* duplicateMsg)
{
setClause(clause, duplicateMsg, true);

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,8 @@ class PlanNode;
class RelationSourceNode;
class SelectNode;
typedef Firebird::Pair<Firebird::NonPooled<ValueListNode*, Firebird::Array<ValueExprNode*>*> > ReturningClause;
typedef Firebird::Pair<
Firebird::NonPooled<NestConst<ValueListNode>, NestConst<ValueListNode> > > ReturningClause;
class ExceptionItem : public Firebird::PermanentStorage
@ -100,8 +101,6 @@ class AssignmentNode : public TypedNode<StmtNode, StmtNode::TYPE_ASSIGNMENT>
public:
explicit AssignmentNode(MemoryPool& pool)
: TypedNode<StmtNode, StmtNode::TYPE_ASSIGNMENT>(pool),
dsqlAsgnFrom(NULL),
dsqlAsgnTo(NULL),
asgnFrom(NULL),
asgnTo(NULL),
missing(NULL),
@ -121,8 +120,6 @@ public:
virtual const StmtNode* execute(thread_db* tdbb, jrd_req* request, ExeState* exeState) const;
public:
ValueExprNode* dsqlAsgnFrom;
ValueExprNode* dsqlAsgnTo;
NestConst<ValueExprNode> asgnFrom;
NestConst<ValueExprNode> asgnTo;
NestConst<ValueExprNode> missing;
@ -307,11 +304,10 @@ class CursorStmtNode : public TypedNode<StmtNode, StmtNode::TYPE_CURSOR_STMT>
{
public:
explicit CursorStmtNode(MemoryPool& pool, UCHAR aCursorOp, const Firebird::MetaName& aDsqlName = "",
Firebird::Array<ValueExprNode*>* aDsqlIntoStmt = NULL)
ValueListNode* aDsqlIntoStmt = NULL)
: TypedNode<StmtNode, StmtNode::TYPE_CURSOR_STMT>(pool),
dsqlName(pool, aDsqlName),
dsqlIntoStmt(aDsqlIntoStmt),
dsqlScrollExpr(NULL),
cursorOp(aCursorOp),
cursorNumber(0),
scrollOp(0),
@ -332,8 +328,7 @@ public:
public:
Firebird::MetaName dsqlName;
Firebird::Array<ValueExprNode*>* dsqlIntoStmt;
ValueExprNode* dsqlScrollExpr;
ValueListNode* dsqlIntoStmt;
UCHAR cursorOp;
USHORT cursorNumber;
UCHAR scrollOp;
@ -357,7 +352,6 @@ public:
dsqlScroll(false),
dsqlName(aDsqlName),
dsqlSelect(NULL),
dsqlRse(NULL),
rse(NULL),
refs(NULL),
cursorNumber(0),
@ -379,8 +373,7 @@ public:
USHORT dsqlCursorType;
bool dsqlScroll;
Firebird::MetaName dsqlName;
SelectNode* dsqlSelect;
RseNode* dsqlRse;
NestConst<SelectNode> dsqlSelect;
NestConst<RseNode> rse;
NestConst<ValueListNode> refs;
USHORT cursorNumber;
@ -421,12 +414,12 @@ private:
Firebird::Array<NestConst<Parameter> >& paramArray, USHORT* defaultCount = NULL);
void genParameters(DsqlCompilerScratch* dsqlScratch,
const Firebird::Array<ParameterClause>& paramArray);
Firebird::Array<ParameterClause>& paramArray);
public:
Firebird::MetaName name;
bool dsqlDeterministic;
ExecBlockNode* dsqlBlock;
NestConst<ExecBlockNode> dsqlBlock;
DsqlCompilerScratch* blockScratch;
dsql_udf* dsqlFunction;
const UCHAR* blrStart;
@ -468,11 +461,11 @@ private:
Firebird::Array<NestConst<Parameter> >& paramArray, USHORT* defaultCount = NULL);
void genParameters(DsqlCompilerScratch* dsqlScratch,
const Firebird::Array<ParameterClause>& paramArray);
Firebird::Array<ParameterClause>& paramArray);
public:
Firebird::MetaName name;
ExecBlockNode* dsqlBlock;
NestConst<ExecBlockNode> dsqlBlock;
DsqlCompilerScratch* blockScratch;
dsql_prc* dsqlProcedure;
const UCHAR* blrStart;
@ -546,14 +539,14 @@ private:
const StmtNode* erase(thread_db* tdbb, jrd_req* request, WhichTrigger whichTrig) const;
public:
RelationSourceNode* dsqlRelation;
BoolExprNode* dsqlBoolean;
PlanNode* dsqlPlan;
ValueListNode* dsqlOrder;
RowsClause* dsqlRows;
NestConst<RelationSourceNode> dsqlRelation;
NestConst<BoolExprNode> dsqlBoolean;
NestConst<PlanNode> dsqlPlan;
NestConst<ValueListNode> dsqlOrder;
NestConst<RowsClause> dsqlRows;
Firebird::MetaName dsqlCursorName;
ReturningClause* dsqlReturning;
RseNode* dsqlRse;
NestConst<ReturningClause> dsqlReturning;
NestConst<RseNode> dsqlRse;
dsql_ctx* dsqlContext;
NestConst<StmtNode> statement;
NestConst<StmtNode> subStatement;
@ -592,16 +585,14 @@ class ExecProcedureNode : public TypedNode<StmtNode, StmtNode::TYPE_EXEC_PROCEDU
public:
explicit ExecProcedureNode(MemoryPool& pool,
const Firebird::QualifiedName& aDsqlName = Firebird::QualifiedName(),
ValueListNode* aDsqlInputs = NULL, Firebird::Array<ValueExprNode*>* aDsqlOutputs = NULL)
ValueListNode* aInputs = NULL, ValueListNode* aOutputs = NULL)
: TypedNode<StmtNode, StmtNode::TYPE_EXEC_PROCEDURE>(pool),
dsqlName(pool, aDsqlName),
dsqlInputs(aDsqlInputs),
dsqlOutputs(aDsqlOutputs),
dsqlProcedure(NULL),
inputSources(NULL),
inputSources(aInputs),
inputTargets(NULL),
inputMessage(NULL),
outputSources(NULL),
outputSources(aOutputs),
outputTargets(NULL),
outputMessage(NULL),
procedure(NULL)
@ -619,14 +610,11 @@ public:
virtual const StmtNode* execute(thread_db* tdbb, jrd_req* request, ExeState* exeState) const;
private:
Firebird::Array<ValueExprNode*>* explodeOutputs(DsqlCompilerScratch* dsqlScratch,
const dsql_prc* procedure);
ValueListNode* explodeOutputs(DsqlCompilerScratch* dsqlScratch, const dsql_prc* procedure);
void executeProcedure(thread_db* tdbb, jrd_req* request) const;
public:
Firebird::QualifiedName dsqlName;
ValueListNode* dsqlInputs;
Firebird::Array<ValueExprNode*>* dsqlOutputs;
dsql_prc* dsqlProcedure;
NestConst<ValueListNode> inputSources;
NestConst<ValueListNode> inputTargets;
@ -643,13 +631,6 @@ class ExecStatementNode : public TypedNode<StmtNode, StmtNode::TYPE_EXEC_STATEME
public:
explicit ExecStatementNode(MemoryPool& pool)
: TypedNode<StmtNode, StmtNode::TYPE_EXEC_STATEMENT>(pool),
dsqlSql(NULL),
dsqlDataSource(NULL),
dsqlUserName(NULL),
dsqlPassword(NULL),
dsqlRole(NULL),
dsqlInputs(NULL),
dsqlOutputs(NULL),
dsqlLabelName(NULL),
dsqlLabelNumber(0),
sql(NULL),
@ -683,13 +664,6 @@ private:
Firebird::string& str, bool useAttCS = false) const;
public:
ValueExprNode* dsqlSql;
ValueExprNode* dsqlDataSource;
ValueExprNode* dsqlUserName;
ValueExprNode* dsqlPassword;
ValueExprNode* dsqlRole;
ValueListNode* dsqlInputs;
Firebird::Array<ValueExprNode*>* dsqlOutputs;
Firebird::MetaName* dsqlLabelName;
USHORT dsqlLabelNumber;
NestConst<ValueExprNode> sql;
@ -711,7 +685,6 @@ class IfNode : public TypedNode<StmtNode, StmtNode::TYPE_IF>
public:
explicit IfNode(MemoryPool& pool)
: TypedNode<StmtNode, StmtNode::TYPE_IF>(pool),
dsqlCondition(NULL),
condition(NULL),
trueAction(NULL),
falseAction(NULL)
@ -729,7 +702,6 @@ public:
virtual const StmtNode* execute(thread_db* tdbb, jrd_req* request, ExeState* exeState) const;
public:
BoolExprNode* dsqlCondition;
NestConst<BoolExprNode> condition;
NestConst<StmtNode> trueAction;
NestConst<StmtNode> falseAction;
@ -822,12 +794,10 @@ class ExceptionNode : public TypedNode<StmtNode, StmtNode::TYPE_EXCEPTION>
{
public:
ExceptionNode(MemoryPool& pool, const Firebird::MetaName& name,
ValueExprNode* aDsqlMessageExpr = NULL, ValueListNode* aDsqlParameters = NULL)
ValueExprNode* aMessageExpr = NULL, ValueListNode* aParameters = NULL)
: TypedNode<StmtNode, StmtNode::TYPE_EXCEPTION>(pool),
dsqlMessageExpr(aDsqlMessageExpr),
dsqlParameters(aDsqlParameters),
messageExpr(NULL),
parameters(NULL)
messageExpr(aMessageExpr),
parameters(aParameters)
{
exception = FB_NEW(pool) ExceptionItem(pool);
exception->type = ExceptionItem::XCP_CODE;
@ -836,8 +806,6 @@ public:
explicit ExceptionNode(MemoryPool& pool)
: TypedNode<StmtNode, StmtNode::TYPE_EXCEPTION>(pool),
dsqlMessageExpr(NULL),
dsqlParameters(NULL),
messageExpr(NULL),
parameters(NULL),
exception(NULL)
@ -858,8 +826,6 @@ private:
void setError(thread_db* tdbb) const;
public:
ValueExprNode* dsqlMessageExpr;
ValueListNode* dsqlParameters;
NestConst<ValueExprNode> messageExpr;
NestConst<ValueListNode> parameters;
NestConst<ExceptionItem> exception;
@ -909,8 +875,8 @@ public:
virtual const StmtNode* execute(thread_db* tdbb, jrd_req* request, ExeState* exeState) const;
public:
SelectNode* dsqlSelect;
Firebird::Array<ValueExprNode*>* dsqlInto;
NestConst<SelectNode> dsqlSelect;
NestConst<ValueListNode> dsqlInto;
DeclareCursorNode* dsqlCursor;
Firebird::MetaName* dsqlLabelName;
USHORT dsqlLabelNumber;
@ -1018,7 +984,7 @@ public:
public:
Firebird::MetaName* dsqlLabelName;
USHORT dsqlLabelNumber;
BoolExprNode* dsqlExpr;
NestConst<BoolExprNode> dsqlExpr;
NestConst<StmtNode> statement;
};
@ -1034,8 +1000,8 @@ public:
{
}
CompoundStmtNode* assignments;
BoolExprNode* condition;
NestConst<CompoundStmtNode> assignments;
NestConst<BoolExprNode> condition;
};
struct NotMatched
@ -1047,19 +1013,19 @@ public:
{
}
Firebird::Array<FieldNode*> fields;
ValueListNode* values;
BoolExprNode* condition;
Firebird::Array<NestConst<FieldNode> > fields;
NestConst<ValueListNode> values;
NestConst<BoolExprNode> condition;
};
explicit MergeNode(MemoryPool& pool)
: TypedNode<DsqlOnlyStmtNode, StmtNode::TYPE_MERGE>(pool),
dsqlRelation(NULL),
dsqlUsing(NULL),
dsqlCondition(NULL),
dsqlWhenMatched(pool),
dsqlWhenNotMatched(pool),
dsqlReturning(NULL)
relation(NULL),
usingClause(NULL),
condition(NULL),
whenMatched(pool),
whenNotMatched(pool),
returning(NULL)
{
}
@ -1068,12 +1034,12 @@ public:
virtual void genBlr(DsqlCompilerScratch* dsqlScratch);
public:
RelationSourceNode* dsqlRelation;
RecordSourceNode* dsqlUsing;
BoolExprNode* dsqlCondition;
Firebird::ObjectsArray<Matched> dsqlWhenMatched;
Firebird::ObjectsArray<NotMatched> dsqlWhenNotMatched;
ReturningClause* dsqlReturning;
NestConst<RelationSourceNode> relation;
NestConst<RecordSourceNode> usingClause;
NestConst<BoolExprNode> condition;
Firebird::ObjectsArray<Matched> whenMatched;
Firebird::ObjectsArray<NotMatched> whenNotMatched;
NestConst<ReturningClause> returning;
};
@ -1147,15 +1113,15 @@ private:
const StmtNode* modify(thread_db* tdbb, jrd_req* request, WhichTrigger whichTrig) const;
public:
RecordSourceNode* dsqlRelation;
BoolExprNode* dsqlBoolean;
PlanNode* dsqlPlan;
ValueListNode* dsqlOrder;
RowsClause* dsqlRows;
NestConst<RecordSourceNode> dsqlRelation;
NestConst<BoolExprNode> dsqlBoolean;
NestConst<PlanNode> dsqlPlan;
NestConst<ValueListNode> dsqlOrder;
NestConst<RowsClause> dsqlRows;
Firebird::MetaName dsqlCursorName;
ReturningClause* dsqlReturning;
NestConst<ReturningClause> dsqlReturning;
USHORT dsqlRseFlags;
RecordSourceNode* dsqlRse;
NestConst<RecordSourceNode> dsqlRse;
dsql_ctx* dsqlContext;
NestConst<StmtNode> statement;
NestConst<StmtNode> statement2;
@ -1172,8 +1138,6 @@ class PostEventNode : public TypedNode<StmtNode, StmtNode::TYPE_POST_EVENT>
public:
explicit PostEventNode(MemoryPool& pool)
: TypedNode<StmtNode, StmtNode::TYPE_POST_EVENT>(pool),
dsqlEvent(NULL),
dsqlArgument(NULL),
event(NULL),
argument(NULL)
{
@ -1190,8 +1154,6 @@ public:
virtual const StmtNode* execute(thread_db* tdbb, jrd_req* request, ExeState* exeState) const;
public:
ValueExprNode* dsqlEvent;
ValueExprNode* dsqlArgument;
NestConst<ValueExprNode> event;
NestConst<ValueExprNode> argument;
};
@ -1258,11 +1220,11 @@ private:
const StmtNode* store(thread_db* tdbb, jrd_req* request, WhichTrigger whichTrig) const;
public:
RecordSourceNode* dsqlRelation;
Firebird::Array<FieldNode*> dsqlFields;
ValueListNode* dsqlValues;
ReturningClause* dsqlReturning;
RecordSourceNode* dsqlRse;
NestConst<RecordSourceNode> dsqlRelation;
Firebird::Array<NestConst<FieldNode> > dsqlFields;
NestConst<ValueListNode> dsqlValues;
NestConst<ReturningClause> dsqlReturning;
NestConst<RecordSourceNode> dsqlRse;
NestConst<StmtNode> statement;
NestConst<StmtNode> statement2;
NestConst<StmtNode> subStore;
@ -1331,10 +1293,10 @@ public:
virtual const StmtNode* execute(thread_db* tdbb, jrd_req* request, ExeState* exeState) const;
public:
SelectExprNode* dsqlExpr;
NestConst<SelectExprNode> dsqlExpr;
bool dsqlForUpdate;
bool dsqlWithLock;
RseNode* dsqlRse;
NestConst<RseNode> dsqlRse;
Firebird::Array<NestConst<StmtNode> > statements;
};
@ -1342,11 +1304,10 @@ public:
class SetGeneratorNode : public TypedNode<StmtNode, StmtNode::TYPE_SET_GENERATOR>
{
public:
SetGeneratorNode(MemoryPool& pool, const Firebird::MetaName& aName, ValueExprNode* aDsqlValue = NULL)
SetGeneratorNode(MemoryPool& pool, const Firebird::MetaName& aName, ValueExprNode* aValue = NULL)
: TypedNode<StmtNode, StmtNode::TYPE_SET_GENERATOR>(pool),
name(aName),
dsqlValue(aDsqlValue),
value(NULL),
value(aValue),
genId(0)
{
}
@ -1363,7 +1324,6 @@ public:
public:
Firebird::MetaName name;
ValueExprNode* dsqlValue;
NestConst<ValueExprNode> value;
USHORT genId;
};
@ -1429,7 +1389,7 @@ public:
virtual void genBlr(DsqlCompilerScratch* dsqlScratch);
public:
ValueExprNode* value;
NestConst<ValueExprNode> value;
};
@ -1536,11 +1496,11 @@ class UpdateOrInsertNode : public TypedNode<DsqlOnlyStmtNode, StmtNode::TYPE_UPD
public:
explicit UpdateOrInsertNode(MemoryPool& pool)
: TypedNode<DsqlOnlyStmtNode, StmtNode::TYPE_UPDATE_OR_INSERT>(pool),
dsqlRelation(NULL),
dsqlFields(pool),
dsqlValues(NULL),
dsqlMatching(pool),
dsqlReturning(NULL)
relation(NULL),
fields(pool),
values(NULL),
matching(pool),
returning(NULL)
{
}
@ -1549,11 +1509,11 @@ public:
virtual void genBlr(DsqlCompilerScratch* dsqlScratch);
public:
RelationSourceNode* dsqlRelation;
Firebird::Array<FieldNode*> dsqlFields;
ValueListNode* dsqlValues;
Firebird::Array<FieldNode*> dsqlMatching;
ReturningClause* dsqlReturning;
NestConst<RelationSourceNode> relation;
Firebird::Array<NestConst<FieldNode> > fields;
NestConst<ValueListNode> values;
Firebird::Array<NestConst<FieldNode> > matching;
NestConst<ReturningClause> returning;
};

View File

@ -122,7 +122,7 @@ dsc* DenseRankWinNode::aggExecute(thread_db* /*tdbb*/, jrd_req* request) const
return &impure->vlu_desc;
}
AggNode* DenseRankWinNode::dsqlCopy(DsqlCompilerScratch* /*dsqlScratch*/) const
AggNode* DenseRankWinNode::dsqlCopy(DsqlCompilerScratch* /*dsqlScratch*/) /*const*/
{
return FB_NEW(getPool()) DenseRankWinNode(getPool());
}
@ -195,7 +195,7 @@ dsc* RankWinNode::aggExecute(thread_db* tdbb, jrd_req* request) const
return &impureTemp->vlu_desc;
}
AggNode* RankWinNode::dsqlCopy(DsqlCompilerScratch* /*dsqlScratch*/) const
AggNode* RankWinNode::dsqlCopy(DsqlCompilerScratch* /*dsqlScratch*/) /*const*/
{
return FB_NEW(getPool()) RankWinNode(getPool());
}
@ -254,7 +254,7 @@ dsc* RowNumberWinNode::winPass(thread_db* /*tdbb*/, jrd_req* request, SlidingWin
return &impure->vlu_desc;
}
AggNode* RowNumberWinNode::dsqlCopy(DsqlCompilerScratch* /*dsqlScratch*/) const
AggNode* RowNumberWinNode::dsqlCopy(DsqlCompilerScratch* /*dsqlScratch*/) /*const*/
{
return FB_NEW(getPool()) RowNumberWinNode(getPool());
}
@ -277,7 +277,7 @@ void FirstValueWinNode::parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigne
void FirstValueWinNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc)
{
MAKE_desc(dsqlScratch, desc, dsqlArg);
MAKE_desc(dsqlScratch, desc, arg);
desc->setNullable(true);
}
@ -328,9 +328,9 @@ dsc* FirstValueWinNode::winPass(thread_db* tdbb, jrd_req* request, SlidingWindow
return desc;
}
AggNode* FirstValueWinNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) const
AggNode* FirstValueWinNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/
{
return FB_NEW(getPool()) FirstValueWinNode(getPool(), doDsqlPass(dsqlScratch, dsqlArg));
return FB_NEW(getPool()) FirstValueWinNode(getPool(), doDsqlPass(dsqlScratch, arg));
}
@ -351,7 +351,7 @@ void LastValueWinNode::parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigned
void LastValueWinNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc)
{
MAKE_desc(dsqlScratch, desc, dsqlArg);
MAKE_desc(dsqlScratch, desc, arg);
desc->setNullable(true);
}
@ -393,9 +393,9 @@ dsc* LastValueWinNode::winPass(thread_db* tdbb, jrd_req* request, SlidingWindow*
return desc;
}
AggNode* LastValueWinNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) const
AggNode* LastValueWinNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/
{
return FB_NEW(getPool()) LastValueWinNode(getPool(), doDsqlPass(dsqlScratch, dsqlArg));
return FB_NEW(getPool()) LastValueWinNode(getPool(), doDsqlPass(dsqlScratch, arg));
}
@ -406,9 +406,9 @@ static WinFuncNode::Register<NthValueWinNode> nthValueWinInfo("NTH_VALUE");
NthValueWinNode::NthValueWinNode(MemoryPool& pool, ValueExprNode* aArg, ValueExprNode* aRow)
: WinFuncNode(pool, nthValueWinInfo, aArg),
dsqlRow(aRow)
row(aRow)
{
addChildNode(dsqlRow, row);
addChildNode(row, row);
}
void NthValueWinNode::parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigned /*count*/)
@ -419,7 +419,7 @@ void NthValueWinNode::parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigned
void NthValueWinNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc)
{
MAKE_desc(dsqlScratch, desc, dsqlArg);
MAKE_desc(dsqlScratch, desc, arg);
desc->setNullable(true);
}
@ -484,10 +484,10 @@ dsc* NthValueWinNode::winPass(thread_db* tdbb, jrd_req* request, SlidingWindow*
return desc;
}
AggNode* NthValueWinNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) const
AggNode* NthValueWinNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/
{
return FB_NEW(getPool()) NthValueWinNode(getPool(),
doDsqlPass(dsqlScratch, dsqlArg), doDsqlPass(dsqlScratch, dsqlRow));
doDsqlPass(dsqlScratch, arg), doDsqlPass(dsqlScratch, row));
}
@ -499,15 +499,13 @@ LagLeadWinNode::LagLeadWinNode(MemoryPool& pool, const AggInfo& aAggInfo, int aD
ValueExprNode* aArg, ValueExprNode* aRows, ValueExprNode* aOutExpr)
: WinFuncNode(pool, aAggInfo, aArg),
direction(aDirection),
dsqlRows(aRows),
dsqlOutExpr(aOutExpr),
rows(NULL),
outExpr(NULL)
rows(aRows),
outExpr(aOutExpr)
{
fb_assert(direction == -1 || direction == 1);
addChildNode(dsqlRows, rows);
addChildNode(dsqlOutExpr, outExpr);
addChildNode(rows, rows);
addChildNode(outExpr, outExpr);
}
void LagLeadWinNode::parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigned /*count*/)
@ -519,7 +517,7 @@ void LagLeadWinNode::parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigned /
void LagLeadWinNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc)
{
MAKE_desc(dsqlScratch, desc, dsqlArg);
MAKE_desc(dsqlScratch, desc, arg);
desc->setNullable(true);
}
@ -592,12 +590,12 @@ ValueExprNode* LagWinNode::copy(thread_db* tdbb, NodeCopier& copier) const
return node;
}
AggNode* LagWinNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) const
AggNode* LagWinNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/
{
return FB_NEW(getPool()) LagWinNode(getPool(),
doDsqlPass(dsqlScratch, dsqlArg),
doDsqlPass(dsqlScratch, dsqlRows),
doDsqlPass(dsqlScratch, dsqlOutExpr));
doDsqlPass(dsqlScratch, arg),
doDsqlPass(dsqlScratch, rows),
doDsqlPass(dsqlScratch, outExpr));
}
@ -621,12 +619,12 @@ ValueExprNode* LeadWinNode::copy(thread_db* tdbb, NodeCopier& copier) const
return node;
}
AggNode* LeadWinNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) const
AggNode* LeadWinNode::dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/
{
return FB_NEW(getPool()) LeadWinNode(getPool(),
doDsqlPass(dsqlScratch, dsqlArg),
doDsqlPass(dsqlScratch, dsqlRows),
doDsqlPass(dsqlScratch, dsqlOutExpr));
doDsqlPass(dsqlScratch, arg),
doDsqlPass(dsqlScratch, rows),
doDsqlPass(dsqlScratch, outExpr));
}

View File

@ -44,7 +44,7 @@ public:
virtual dsc* aggExecute(thread_db* tdbb, jrd_req* request) const;
protected:
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) const;
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/;
};
// RANK function.
@ -63,7 +63,7 @@ public:
virtual dsc* aggExecute(thread_db* tdbb, jrd_req* request) const;
protected:
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) const;
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/;
private:
USHORT tempImpure;
@ -91,7 +91,7 @@ public:
virtual dsc* winPass(thread_db* tdbb, jrd_req* request, SlidingWindow* window) const;
protected:
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) const;
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/;
};
// FIRST_VALUE function.
@ -116,7 +116,7 @@ public:
virtual dsc* winPass(thread_db* tdbb, jrd_req* request, SlidingWindow* window) const;
protected:
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) const;
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/;
virtual void parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigned count);
};
@ -143,7 +143,7 @@ public:
virtual dsc* winPass(thread_db* tdbb, jrd_req* request, SlidingWindow* window) const;
protected:
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) const;
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/;
virtual void parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigned count);
};
@ -170,12 +170,11 @@ public:
virtual dsc* winPass(thread_db* tdbb, jrd_req* request, SlidingWindow* window) const;
protected:
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) const;
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/;
virtual void parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigned count);
private:
ValueExprNode* dsqlRow;
NestConst<ValueExprNode> row;
};
@ -205,8 +204,6 @@ protected:
protected:
const int direction;
ValueExprNode* dsqlRows;
ValueExprNode* dsqlOutExpr;
NestConst<ValueExprNode> rows;
NestConst<ValueExprNode> outExpr;
};
@ -221,7 +218,7 @@ public:
virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const;
protected:
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) const;
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/;
};
// LEAD function.
@ -234,7 +231,7 @@ public:
virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const;
protected:
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) const;
virtual AggNode* dsqlCopy(DsqlCompilerScratch* dsqlScratch) /*const*/;
};

View File

@ -577,7 +577,9 @@ public:
protected:
// Request should never be destroyed using delete.
// It dies together with it's pool in release_request().
~dsql_req();
~dsql_req()
{
}
// To avoid posix warning about missing public destructor declare
// MemoryPool as friend class. In fact IT releases request memory!
@ -607,7 +609,7 @@ public:
ULONG msgLength, UCHAR* msgBuffer);
private:
StmtNode* node;
NestConst<StmtNode> node;
};
class DsqlDdlRequest : public dsql_req
@ -629,7 +631,7 @@ public:
bool singleton);
private:
DdlNode* node;
NestConst<DdlNode> node;
DsqlCompilerScratch* internalScratch;
};
@ -652,7 +654,7 @@ public:
bool singleton);
private:
TransactionNode* node;
NestConst<TransactionNode> node;
};
//! Implicit (NATURAL and USING) joins
@ -674,9 +676,9 @@ struct PartitionMap
{
}
ValueListNode* partition;
ValueListNode* partitionRemapped;
ValueListNode* order;
NestConst<ValueListNode> partition;
NestConst<ValueListNode> partitionRemapped;
NestConst<ValueListNode> order;
dsql_map* map;
USHORT context;
};
@ -697,7 +699,7 @@ public:
dsql_rel* ctx_relation; // Relation for context
dsql_prc* ctx_procedure; // Procedure for context
ValueListNode* ctx_proc_inputs; // Procedure input parameters
NestConst<ValueListNode> ctx_proc_inputs; // Procedure input parameters
dsql_map* ctx_map; // Maps for aggregates and unions
RseNode* ctx_rse; // Sub-rse for aggregates
dsql_ctx* ctx_parent; // Parent context for aggregates
@ -736,7 +738,7 @@ public:
return *this;
}
bool getImplicitJoinField(const Firebird::MetaName& name, ValueExprNode*& node);
bool getImplicitJoinField(const Firebird::MetaName& name, NestConst<ValueExprNode>& node);
PartitionMap* getPartitionMap(DsqlCompilerScratch* dsqlScratch,
ValueListNode* partitionNode, ValueListNode* orderNode);
};
@ -754,10 +756,10 @@ const USHORT CTX_recursive = 0x10; // Context has secondary number (ctx_recursiv
class dsql_map : public pool_alloc<dsql_type_map>
{
public:
dsql_map* map_next; // Next map in item
ValueExprNode* map_node; // Value for map item
USHORT map_position; // Position in map
PartitionMap* map_partition; // Partition
dsql_map* map_next; // Next map in item
NestConst<ValueExprNode> map_node; // Value for map item
USHORT map_position; // Position in map
NestConst<PartitionMap> map_partition; // Partition
};
// Message block used in communicating with a running request

View File

@ -547,7 +547,7 @@ static void gen_plan(DsqlCompilerScratch* dsqlScratch, const PlanNode* planNode)
@param rse
**/
void GEN_rse(DsqlCompilerScratch* dsqlScratch, const RseNode* rse)
void GEN_rse(DsqlCompilerScratch* dsqlScratch, RseNode* rse)
{
if (rse->dsqlFlags & RecordSourceNode::DFLAG_SINGLETON)
dsqlScratch->appendUChar(blr_singular);
@ -555,16 +555,16 @@ void GEN_rse(DsqlCompilerScratch* dsqlScratch, const RseNode* rse)
if (rse->dsqlExplicitJoin)
{
dsqlScratch->appendUChar(blr_rs_stream);
fb_assert(rse->dsqlStreams->dsqlArgs.getCount() == 2);
fb_assert(rse->dsqlStreams->items.getCount() == 2);
}
else
dsqlScratch->appendUChar(blr_rse);
// Handle source streams
dsqlScratch->appendUChar(rse->dsqlStreams->dsqlArgs.getCount());
RecordSourceNode* const* ptr = rse->dsqlStreams->dsqlArgs.begin();
for (const RecordSourceNode* const* const end = rse->dsqlStreams->dsqlArgs.end(); ptr != end; ++ptr)
dsqlScratch->appendUChar(rse->dsqlStreams->items.getCount());
NestConst<RecordSourceNode>* ptr = rse->dsqlStreams->items.begin();
for (const NestConst<RecordSourceNode>* const end = rse->dsqlStreams->items.end(); ptr != end; ++ptr)
GEN_expr(dsqlScratch, *ptr);
if (rse->flags & RseNode::FLAG_WRITELOCK)
@ -600,11 +600,11 @@ void GEN_rse(DsqlCompilerScratch* dsqlScratch, const RseNode* rse)
if (rse->dsqlDistinct)
{
dsqlScratch->appendUChar(blr_project);
dsqlScratch->appendUChar(rse->dsqlDistinct->dsqlArgs.getCount());
dsqlScratch->appendUChar(rse->dsqlDistinct->items.getCount());
ValueExprNode** ptr = rse->dsqlDistinct->dsqlArgs.begin();
NestConst<ValueExprNode>* ptr = rse->dsqlDistinct->items.begin();
for (const ValueExprNode* const* const end = rse->dsqlDistinct->dsqlArgs.end(); ptr != end; ++ptr)
for (const NestConst<ValueExprNode>* const end = rse->dsqlDistinct->items.end(); ptr != end; ++ptr)
GEN_expr(dsqlScratch, *ptr);
}
@ -624,12 +624,12 @@ void GEN_rse(DsqlCompilerScratch* dsqlScratch, const RseNode* rse)
void GEN_sort(DsqlCompilerScratch* dsqlScratch, ValueListNode* list)
{
dsqlScratch->appendUChar(blr_sort);
dsqlScratch->appendUChar(list->dsqlArgs.getCount());
dsqlScratch->appendUChar(list->items.getCount());
ValueExprNode* const* ptr = list->dsqlArgs.begin();
for (const ValueExprNode* const* const end = list->dsqlArgs.end(); ptr != end; ++ptr)
NestConst<ValueExprNode>* ptr = list->items.begin();
for (const NestConst<ValueExprNode>* const end = list->items.end(); ptr != end; ++ptr)
{
const OrderNode* orderNode = (*ptr)->as<OrderNode>();
OrderNode* orderNode = (*ptr)->as<OrderNode>();
switch (orderNode->nullsPlacement)
{
@ -642,7 +642,7 @@ void GEN_sort(DsqlCompilerScratch* dsqlScratch, ValueListNode* list)
}
dsqlScratch->appendUChar((orderNode->descending ? blr_descending : blr_ascending));
GEN_expr(dsqlScratch, orderNode->dsqlValue);
GEN_expr(dsqlScratch, orderNode->value);
}
}

View File

@ -36,7 +36,7 @@ void GEN_hidden_variables(Jrd::DsqlCompilerScratch* dsqlScratch);
void GEN_parameter(Jrd::DsqlCompilerScratch*, const Jrd::dsql_par*);
void GEN_port(Jrd::DsqlCompilerScratch*, Jrd::dsql_msg*);
void GEN_request(Jrd::DsqlCompilerScratch*, Jrd::DmlNode*);
void GEN_rse(Jrd::DsqlCompilerScratch*, const Jrd::RseNode*);
void GEN_rse(Jrd::DsqlCompilerScratch*, Jrd::RseNode*);
void GEN_sort(Jrd::DsqlCompilerScratch*, Jrd::ValueListNode*);
void GEN_stuff_context(Jrd::DsqlCompilerScratch*, const Jrd::dsql_ctx*);

View File

@ -389,8 +389,8 @@ void MAKE_desc_from_field(dsc* desc, const dsql_fld* field)
void MAKE_desc_from_list(DsqlCompilerScratch* dsqlScratch, dsc* desc, ValueListNode* node,
const TEXT* expression_name)
{
ValueExprNode** p = node->dsqlArgs.begin();
ValueExprNode** end = node->dsqlArgs.end();
NestConst<ValueExprNode>* p = node->items.begin();
NestConst<ValueExprNode>* end = node->items.end();
Array<const dsc*> args;

View File

@ -1060,7 +1060,7 @@ dsql_udf* METD_get_function(jrd_tra* transaction, DsqlCompilerScratch* dsqlScrat
void METD_get_primary_key(jrd_tra* transaction, const MetaName& relationName,
Array<FieldNode*>& fields)
Array<NestConst<FieldNode> >& fields)
{
/**************************************
*

View File

@ -63,7 +63,8 @@ USHORT METD_get_domain_default(Jrd::jrd_tra*, const Firebird::MetaName&, bool*,
bool METD_get_exception(Jrd::jrd_tra*, const Jrd::dsql_str*);
Jrd::dsql_udf* METD_get_function(Jrd::jrd_tra*, Jrd::DsqlCompilerScratch*,
const Firebird::QualifiedName&);
void METD_get_primary_key(Jrd::jrd_tra*, const Firebird::MetaName&, Firebird::Array<Jrd::FieldNode*>&);
void METD_get_primary_key(Jrd::jrd_tra*, const Firebird::MetaName&,
Firebird::Array<NestConst<Jrd::FieldNode> >&);
Jrd::dsql_prc* METD_get_procedure(Jrd::jrd_tra*, Jrd::DsqlCompilerScratch*,
const Firebird::QualifiedName&);
Jrd::dsql_rel* METD_get_relation(Jrd::jrd_tra*, Jrd::DsqlCompilerScratch*, const Firebird::MetaName&);

View File

@ -620,7 +620,6 @@ inline void check_copy_incr(char*& to, const char ch, const char* const string)
Jrd::ComparativeBoolNode::DsqlFlag cmpBoolFlag;
Jrd::dsql_str* legacyStr;
Jrd::dsql_fld* legacyField;
Firebird::Array<Jrd::ValueExprNode*>* valueArray;
Jrd::ReturningClause* returningClause;
Firebird::MetaName* metaNamePtr;
Firebird::ObjectsArray<Firebird::MetaName>* metaNameArray;
@ -629,7 +628,7 @@ inline void check_copy_incr(char*& to, const char ch, const char* const string)
Jrd::IntlString* intlStringPtr;
TEXT* textPtr;
Jrd::DbFileClause* dbFileClause;
Firebird::Array<Jrd::DbFileClause*>* dbFilesClause;
Firebird::Array<NestConst<Jrd::DbFileClause> >* dbFilesClause;
Jrd::ExternalClause* externalClause;
Firebird::Array<Jrd::ParameterClause>* parametersClause;
Jrd::Node* node;
@ -651,6 +650,7 @@ inline void check_copy_incr(char*& to, const char ch, const char* const string)
Jrd::FieldNode* fieldNode;
Jrd::DecodeNode* decodeNode;
Firebird::Array<Jrd::FieldNode*>* fieldArray;
Firebird::Array<NestConst<Jrd::FieldNode> >* nestFieldArray;
Jrd::TransactionNode* traNode;
Firebird::Array<Jrd::PrivilegeClause>* privilegeArray;
Jrd::GranteeClause* granteeClause;
@ -1872,9 +1872,9 @@ column_constraint($addColumnClause)
const ValueListNode* refColumns = $3;
if (refColumns)
{
const ValueExprNode* const* ptr = refColumns->dsqlArgs.begin();
const NestConst<ValueExprNode>* ptr = refColumns->items.begin();
for (const ValueExprNode* const* const end = refColumns->dsqlArgs.end(); ptr != end; ++ptr)
for (const NestConst<ValueExprNode>* const end = refColumns->items.end(); ptr != end; ++ptr)
constraint.refColumns.add((*ptr)->as<FieldNode>()->dsqlName);
}
@ -1900,7 +1900,7 @@ column_constraint($addColumnClause)
%type table_constraint_definition(<relationNode>)
table_constraint_definition($relationNode)
: constraint_name_opt table_constraint($relationNode)
{ static_cast<RelationNode::AddConstraintClause*>($relationNode->clauses.back())->name = toName($1); }
{ static_cast<RelationNode::AddConstraintClause*>($relationNode->clauses.back().getObject())->name = toName($1); }
;
%type <legacyStr> constraint_name_opt
@ -1917,9 +1917,9 @@ table_constraint($relationNode)
constraint.constraintType = RelationNode::AddConstraintClause::CTYPE_UNIQUE;
const ValueListNode* columns = $2;
const ValueExprNode* const* ptr = columns->dsqlArgs.begin();
const NestConst<ValueExprNode>* ptr = columns->items.begin();
for (const ValueExprNode* const* const end = columns->dsqlArgs.end(); ptr != end; ++ptr)
for (const NestConst<ValueExprNode>* const end = columns->items.end(); ptr != end; ++ptr)
constraint.columns.add((*ptr)->as<FieldNode>()->dsqlName);
constraint.index = $3;
@ -1932,9 +1932,9 @@ table_constraint($relationNode)
constraint.constraintType = RelationNode::AddConstraintClause::CTYPE_PK;
const ValueListNode* columns = $3;
const ValueExprNode* const* ptr = columns->dsqlArgs.begin();
const NestConst<ValueExprNode>* ptr = columns->items.begin();
for (const ValueExprNode* const* const end = columns->dsqlArgs.end(); ptr != end; ++ptr)
for (const NestConst<ValueExprNode>* const end = columns->items.end(); ptr != end; ++ptr)
constraint.columns.add((*ptr)->as<FieldNode>()->dsqlName);
constraint.index = $4;
@ -1948,9 +1948,9 @@ table_constraint($relationNode)
constraint.constraintType = RelationNode::AddConstraintClause::CTYPE_FK;
const ValueListNode* columns = $3;
const ValueExprNode* const* ptr = columns->dsqlArgs.begin();
const NestConst<ValueExprNode>* ptr = columns->items.begin();
for (const ValueExprNode* const* const end = columns->dsqlArgs.end(); ptr != end; ++ptr)
for (const NestConst<ValueExprNode>* const end = columns->items.end(); ptr != end; ++ptr)
constraint.columns.add((*ptr)->as<FieldNode>()->dsqlName);
constraint.refRelation = toName($5);
@ -1959,9 +1959,9 @@ table_constraint($relationNode)
const ValueListNode* refColumns = $6;
if (refColumns)
{
const ValueExprNode* const* ptr = refColumns->dsqlArgs.begin();
const NestConst<ValueExprNode>* ptr = refColumns->items.begin();
for (const ValueExprNode* const* const end = refColumns->dsqlArgs.end(); ptr != end; ++ptr)
for (const NestConst<ValueExprNode>* const end = refColumns->items.end(); ptr != end; ++ptr)
constraint.refColumns.add((*ptr)->as<FieldNode>()->dsqlName);
}
@ -2583,7 +2583,7 @@ exec_into
: exec_sql INTO variable_list
{
$$ = $<execStatementNode>1;
$$->dsqlOutputs = $3;
$$->outputs = $3;
}
;
@ -2600,15 +2600,11 @@ for_exec_into
%type exec_stmt_inputs(<execStatementNode>)
exec_stmt_inputs($execStatementNode)
: value
{ $execStatementNode->dsqlSql = $1; }
{ $execStatementNode->sql = $1; }
| '(' value ')' '(' named_params_list($execStatementNode) ')'
{
$execStatementNode->dsqlSql = $2;
}
{ $execStatementNode->sql = $2; }
| '(' value ')' '(' not_named_params_list($execStatementNode) ')'
{
$execStatementNode->dsqlSql = $2;
}
{ $execStatementNode->sql = $2; }
;
%type named_params_list(<execStatementNode>)
@ -2627,10 +2623,10 @@ named_param($execStatementNode)
$execStatementNode->inputNames->add(
FB_NEW(getPool()) string(getPool(), toString((dsql_str*) $1)));
if (!$execStatementNode->dsqlInputs)
$execStatementNode->dsqlInputs = newNode<ValueListNode>($3);
if (!$execStatementNode->inputs)
$execStatementNode->inputs = newNode<ValueListNode>($3);
else
$execStatementNode->dsqlInputs->add($3);
$execStatementNode->inputs->add($3);
}
;
@ -2644,10 +2640,10 @@ not_named_params_list($execStatementNode)
not_named_param($execStatementNode)
: value
{
if (!$execStatementNode->dsqlInputs)
$execStatementNode->dsqlInputs = newNode<ValueListNode>($1);
if (!$execStatementNode->inputs)
$execStatementNode->inputs = newNode<ValueListNode>($1);
else
$execStatementNode->dsqlInputs->add($1);
$execStatementNode->inputs->add($1);
}
;
@ -2666,15 +2662,15 @@ exec_stmt_options_list($execStatementNode)
%type exec_stmt_option(<execStatementNode>)
exec_stmt_option($execStatementNode)
: ON EXTERNAL DATA SOURCE value
{ setClause($execStatementNode->dsqlDataSource, "EXTERNAL DATA SOURCE", $5); }
{ setClause($execStatementNode->dataSource, "EXTERNAL DATA SOURCE", $5); }
| ON EXTERNAL value
{ setClause($execStatementNode->dsqlDataSource, "EXTERNAL DATA SOURCE", $3); }
{ setClause($execStatementNode->dataSource, "EXTERNAL DATA SOURCE", $3); }
| AS USER value
{ setClause($execStatementNode->dsqlUserName, "USER", $3); }
{ setClause($execStatementNode->userName, "USER", $3); }
| PASSWORD value
{ setClause($execStatementNode->dsqlPassword, "PASSWORD", $2); }
{ setClause($execStatementNode->password, "PASSWORD", $2); }
| ROLE value
{ setClause($execStatementNode->dsqlRole, "ROLE", $2); }
{ setClause($execStatementNode->role, "ROLE", $2); }
| WITH AUTONOMOUS TRANSACTION
{ setClause($execStatementNode->traScope, "TRANSACTION", EDS::traAutonomous); }
| WITH COMMON TRANSACTION
@ -2692,7 +2688,7 @@ if_then_else
: IF '(' search_condition ')' THEN proc_block ELSE proc_block
{
IfNode* node = newNode<IfNode>();
node->dsqlCondition = $3;
node->condition = $3;
node->trueAction = $6;
node->falseAction = $8;
$$ = node;
@ -2700,7 +2696,7 @@ if_then_else
| IF '(' search_condition ')' THEN proc_block
{
IfNode* node = newNode<IfNode>();
node->dsqlCondition = $3;
node->condition = $3;
node->trueAction = $6;
$$ = node;
}
@ -2711,8 +2707,8 @@ post_event
: POST_EVENT value event_argument_opt
{
PostEventNode* node = newNode<PostEventNode>();
node->dsqlEvent = $2;
node->dsqlArgument = $3;
node->event = $2;
node->argument = $3;
$$ = node;
}
;
@ -2744,28 +2740,12 @@ variable
}
;
%type <valueArray> variable_list
%type <valueListNode> variable_list
variable_list
: variable
{
$$ = FB_NEW(getPool()) Array<ValueExprNode*>(getPool());
$$->add($1);
}
| column_name
{
$$ = FB_NEW(getPool()) Array<ValueExprNode*>(getPool());
$$->add($1);
}
| variable_list ',' column_name
{
$$ = $1;
$$->add($3);
}
| variable_list ',' variable
{
$$ = $1;
$$->add($3);
}
: variable { $$ = newNode<ValueListNode>($1); }
| column_name { $$ = newNode<ValueListNode>($1); }
| variable_list ',' column_name { $$ = $1->add($3); }
| variable_list ',' variable { $$ = $1->add($3); }
;
%type <stmtNode> while
@ -2922,12 +2902,12 @@ fetch_scroll($cursorStmtNode)
| KW_ABSOLUTE value
{
$cursorStmtNode->scrollOp = blr_scroll_absolute;
$cursorStmtNode->dsqlScrollExpr = $2;
$cursorStmtNode->scrollExpr = $2;
}
| KW_RELATIVE value
{
$cursorStmtNode->scrollOp = blr_scroll_relative;
$cursorStmtNode->dsqlScrollExpr = $2;
$cursorStmtNode->scrollExpr = $2;
}
;
@ -2949,7 +2929,7 @@ proc_inputs
| '(' value_list ')' { $$ = $2; }
;
%type <valueArray> proc_outputs_opt
%type <valueListNode> proc_outputs_opt
proc_outputs_opt
: /* nothing */ { $$ = NULL; }
| RETURNING_VALUES variable_list { $$ = $2; }
@ -3710,13 +3690,13 @@ array_type
: non_charset_simple_type '[' array_spec ']'
{
lex.g_field->fld_ranges = $3;
lex.g_field->fld_dimensions = lex.g_field->fld_ranges->dsqlArgs.getCount() / 2;
lex.g_field->fld_dimensions = lex.g_field->fld_ranges->items.getCount() / 2;
lex.g_field->fld_element_dtype = lex.g_field->fld_dtype;
}
| character_type '[' array_spec ']' charset_clause
{
lex.g_field->fld_ranges = $3;
lex.g_field->fld_dimensions = lex.g_field->fld_ranges->dsqlArgs.getCount() / 2;
lex.g_field->fld_dimensions = lex.g_field->fld_ranges->items.getCount() / 2;
lex.g_field->fld_element_dtype = lex.g_field->fld_dtype;
}
;
@ -3724,7 +3704,7 @@ array_type
%type <valueListNode> array_spec
array_spec
: array_range
| array_spec ',' array_range { $$ = $1->add($3->dsqlArgs[0])->add($3->dsqlArgs[1]); }
| array_spec ',' array_range { $$ = $1->add($3->items[0])->add($3->items[1]); }
;
%type <valueListNode> array_range
@ -4550,8 +4530,8 @@ query_spec
plan_clause
{
RseNode* rse = newNode<RseNode>();
rse->dsqlFirst = $2 ? $2->dsqlArgs[1] : NULL;
rse->dsqlSkip = $2 ? $2->dsqlArgs[0] : NULL;
rse->dsqlFirst = $2 ? $2->items[1] : NULL;
rse->dsqlSkip = $2 ? $2->items[0] : NULL;
rse->dsqlDistinct = $3;
rse->dsqlSelectList = $4;
rse->dsqlFrom = $5;
@ -4757,21 +4737,21 @@ table_proc
: symbol_procedure_name table_proc_inputs as_noise symbol_table_alias_name
{
ProcedureSourceNode* node = newNode<ProcedureSourceNode>(QualifiedName(toName($1)));
node->dsqlInputs = $2;
node->sourceList = $2;
node->alias = toString((dsql_str*) $4);
$$ = node;
}
| symbol_procedure_name table_proc_inputs
{
ProcedureSourceNode* node = newNode<ProcedureSourceNode>(QualifiedName(toName($1)));
node->dsqlInputs = $2;
node->sourceList = $2;
$$ = node;
}
| symbol_package_name '.' symbol_procedure_name table_proc_inputs as_noise symbol_table_alias_name
{
ProcedureSourceNode* node = newNode<ProcedureSourceNode>(
QualifiedName(toName($3), toName($1)));
node->dsqlInputs = $4;
node->sourceList = $4;
node->alias = toString((dsql_str*) $6);
$$ = node;
}
@ -4779,7 +4759,7 @@ table_proc
{
ProcedureSourceNode* node = newNode<ProcedureSourceNode>(
QualifiedName(toName($3), toName($1)));
node->dsqlInputs = $4;
node->sourceList = $4;
$$ = node;
}
;
@ -5057,14 +5037,14 @@ merge
: MERGE INTO table_name USING table_reference ON search_condition
{
MergeNode* node = $$ = newNode<MergeNode>();
node->dsqlRelation = $3;
node->dsqlUsing = $5;
node->dsqlCondition = $7;
node->relation = $3;
node->usingClause = $5;
node->condition = $7;
}
merge_when_clause($8) returning_clause
{
MergeNode* node = $$ = $8;
node->dsqlReturning = $10;
node->returning = $10;
}
;
@ -5079,14 +5059,14 @@ merge_when_clause($mergeNode)
%type merge_when_matched_clause(<mergeNode>)
merge_when_matched_clause($mergeNode)
: WHEN MATCHED
{ $<mergeMatchedClause>$ = &$mergeNode->dsqlWhenMatched.add(); }
{ $<mergeMatchedClause>$ = &$mergeNode->whenMatched.add(); }
merge_update_specification($<mergeMatchedClause>3)
;
%type merge_when_not_matched_clause(<mergeNode>)
merge_when_not_matched_clause($mergeNode)
: WHEN NOT MATCHED
{ $<mergeNotMatchedClause>$ = &$mergeNode->dsqlWhenNotMatched.add(); }
{ $<mergeNotMatchedClause>$ = &$mergeNode->whenNotMatched.add(); }
merge_insert_specification($<mergeNotMatchedClause>4)
;
@ -5199,18 +5179,18 @@ update_or_insert
: UPDATE OR INSERT INTO simple_table_name
{
UpdateOrInsertNode* node = $$ = newNode<UpdateOrInsertNode>();
node->dsqlRelation = $5;
node->relation = $5;
}
ins_column_parens_opt(&$6->dsqlFields)
VALUES '(' value_list ')' update_or_insert_matching_opt(&$6->dsqlMatching) returning_clause
ins_column_parens_opt(&$6->fields)
VALUES '(' value_list ')' update_or_insert_matching_opt(&$6->matching) returning_clause
{
UpdateOrInsertNode* node = $$ = $6;
node->dsqlValues = $10;
node->dsqlReturning = $13;
node->values = $10;
node->returning = $13;
}
;
%type update_or_insert_matching_opt(<fieldArray>)
%type update_or_insert_matching_opt(<nestFieldArray>)
update_or_insert_matching_opt($fieldArray)
: // nothing
| MATCHING ins_column_parens($fieldArray)
@ -5261,8 +5241,8 @@ assignment
: update_column_name '=' value
{
AssignmentNode* node = newNode<AssignmentNode>();
node->dsqlAsgnTo = $1;
node->dsqlAsgnFrom = $3;
node->asgnTo = $1;
node->asgnFrom = $3;
$$ = node;
}
;
@ -5272,15 +5252,15 @@ exec_function
: udf
{
AssignmentNode* node = newNode<AssignmentNode>();
node->dsqlAsgnTo = newNode<NullNode>();
node->dsqlAsgnFrom = $1;
node->asgnTo = newNode<NullNode>();
node->asgnFrom = $1;
$$ = node;
}
| non_aggregate_function
{
AssignmentNode* node = newNode<AssignmentNode>();
node->dsqlAsgnTo = newNode<NullNode>();
node->dsqlAsgnFrom = $1;
node->asgnTo = newNode<NullNode>();
node->asgnFrom = $1;
$$ = node;
}
;
@ -5306,18 +5286,18 @@ column_list
;
// begin IBO hack
%type ins_column_parens_opt(<fieldArray>)
%type ins_column_parens_opt(<nestFieldArray>)
ins_column_parens_opt($fieldArray)
: // nothing
| ins_column_parens($fieldArray)
;
%type ins_column_parens(<fieldArray>)
%type ins_column_parens(<nestFieldArray>)
ins_column_parens($fieldArray)
: '(' ins_column_list($fieldArray) ')'
;
%type ins_column_list(<fieldArray>)
%type ins_column_list(<nestFieldArray>)
ins_column_list($fieldArray)
: update_column_name { $fieldArray->add($1); }
| ins_column_list ',' update_column_name { $fieldArray->add($3); }
@ -5368,7 +5348,7 @@ search_condition
{
BoolAsValueNode* node = ExprNode::as<BoolAsValueNode>($1);
if (node)
$$ = node->dsqlBoolean;
$$ = node->boolean;
else
{
ComparativeBoolNode* cmpNode = newNode<ComparativeBoolNode>(
@ -5439,8 +5419,9 @@ comparison_operator
quantified_predicate
: common_value comparison_operator quantified_flag '(' column_select ')'
{
ComparativeBoolNode* node = newNode<ComparativeBoolNode>($2, $1, $5);
ComparativeBoolNode* node = newNode<ComparativeBoolNode>($2, $1);
node->dsqlFlag = $3;
node->dsqlSpecialArg = $5;
$$ = node;
}
;
@ -5522,14 +5503,16 @@ escape_opt
in_predicate
: common_value KW_IN in_predicate_value
{
ComparativeBoolNode* node = newNode<ComparativeBoolNode>(blr_eql, $1, $3);
ComparativeBoolNode* node = newNode<ComparativeBoolNode>(blr_eql, $1);
node->dsqlFlag = ComparativeBoolNode::DFLAG_ANSI_ANY;
node->dsqlSpecialArg = $3;
$$ = node;
}
| common_value NOT KW_IN in_predicate_value
{
ComparativeBoolNode* node = newNode<ComparativeBoolNode>(blr_eql, $1, $4);
ComparativeBoolNode* node = newNode<ComparativeBoolNode>(blr_eql, $1);
node->dsqlFlag = ComparativeBoolNode::DFLAG_ANSI_ANY;
node->dsqlSpecialArg = $4;
$$ = newNode<NotBoolNode>(node);
}
;
@ -5782,7 +5765,7 @@ array_element
: column_name '[' value_list ']'
{
ArrayNode* node = newNode<ArrayNode>(ExprNode::as<FieldNode>($1));
node->dsqlField->dsqlIndices = $3;
node->field->dsqlIndices = $3;
$$ = node;
}
;
@ -6335,13 +6318,13 @@ case_abbreviation
| DECODE '(' value ',' decode_pairs ')'
{
ValueListNode* list = $5;
ValueListNode* conditions = newNode<ValueListNode>(list->dsqlArgs.getCount() / 2);
ValueListNode* values = newNode<ValueListNode>(list->dsqlArgs.getCount() / 2);
ValueListNode* conditions = newNode<ValueListNode>(list->items.getCount() / 2);
ValueListNode* values = newNode<ValueListNode>(list->items.getCount() / 2);
for (size_t i = 0; i < list->dsqlArgs.getCount(); i += 2)
for (size_t i = 0; i < list->items.getCount(); i += 2)
{
conditions->dsqlArgs[i / 2] = list->dsqlArgs[i];
values->dsqlArgs[i / 2] = list->dsqlArgs[i + 1];
conditions->items[i / 2] = list->items[i];
values->items[i / 2] = list->items[i + 1];
}
$$ = newNode<DecodeNode>($3, conditions, values);
@ -6349,16 +6332,16 @@ case_abbreviation
| DECODE '(' value ',' decode_pairs ',' value ')'
{
ValueListNode* list = $5;
ValueListNode* conditions = newNode<ValueListNode>(list->dsqlArgs.getCount() / 2);
ValueListNode* values = newNode<ValueListNode>(list->dsqlArgs.getCount() / 2 + 1);
ValueListNode* conditions = newNode<ValueListNode>(list->items.getCount() / 2);
ValueListNode* values = newNode<ValueListNode>(list->items.getCount() / 2 + 1);
for (size_t i = 0; i < list->dsqlArgs.getCount(); i += 2)
for (size_t i = 0; i < list->items.getCount(); i += 2)
{
conditions->dsqlArgs[i / 2] = list->dsqlArgs[i];
values->dsqlArgs[i / 2] = list->dsqlArgs[i + 1];
conditions->items[i / 2] = list->items[i];
values->items[i / 2] = list->items[i + 1];
}
values->dsqlArgs[list->dsqlArgs.getCount() / 2] = $7;
values->items[list->items.getCount() / 2] = $7;
$$ = newNode<DecodeNode>($3, conditions, values);
}
@ -6374,12 +6357,12 @@ case_specification
simple_case
: CASE case_operand
{ $$ = newNode<DecodeNode>($2, newNode<ValueListNode>(0u), newNode<ValueListNode>(0u)); }
simple_when_clause($3->dsqlConditions, $3->dsqlValues) else_case_result_opt END
simple_when_clause($3->conditions, $3->values) else_case_result_opt END
{
DecodeNode* node = $$ = $3;
node->label = "CASE";
if ($5)
node->dsqlValues->add($5);
node->values->add($5);
}
;
@ -6411,12 +6394,12 @@ searched_case
ValueIfNode* last = $2;
ValueIfNode* next;
while ((next = ExprNode::as<ValueIfNode>(last->dsqlFalseValue)))
while ((next = last->falseValue->as<ValueIfNode>()))
last = next;
fb_assert(ExprNode::is<NullNode>(last->dsqlFalseValue));
fb_assert(last->falseValue->is<NullNode>());
last->dsqlFalseValue = $4;
last->falseValue = $4;
$$ = $2;
}
;
@ -6431,12 +6414,12 @@ searched_when_clause
ValueIfNode* last = $1;
ValueIfNode* next;
while ((next = ExprNode::as<ValueIfNode>(last->dsqlFalseValue)))
while ((next = last->falseValue->as<ValueIfNode>()))
last = next;
fb_assert(ExprNode::is<NullNode>(last->dsqlFalseValue));
fb_assert(last->falseValue->is<NullNode>());
last->dsqlFalseValue = cond;
last->falseValue = cond;
$$ = $1;
}
;

View File

@ -288,8 +288,8 @@ bool InvalidReferenceFinder::visit(ExprNode* node)
{
// Check if this node (with ignoring of CASTs) appears also
// in the list of group by. If yes then it's allowed
const ValueExprNode* const* ptr = list->dsqlArgs.begin();
for (const ValueExprNode* const* const end = list->dsqlArgs.end(); ptr != end; ++ptr)
const NestConst<ValueExprNode>* ptr = list->items.begin();
for (const NestConst<ValueExprNode>* const end = list->items.end(); ptr != end; ++ptr)
{
if (PASS1_node_match(node, *ptr, true))
return false;
@ -336,7 +336,7 @@ bool SubSelectFinder::visit(ExprNode* node)
@param relationNode
**/
dsql_ctx* PASS1_make_context(DsqlCompilerScratch* dsqlScratch, const RecordSourceNode* relationNode)
dsql_ctx* PASS1_make_context(DsqlCompilerScratch* dsqlScratch, RecordSourceNode* relationNode)
{
DEV_BLKCHK(dsqlScratch, dsql_type_req);
@ -349,9 +349,9 @@ dsql_ctx* PASS1_make_context(DsqlCompilerScratch* dsqlScratch, const RecordSourc
// and give an error if it is neither
MetaName relation_name;
const ProcedureSourceNode* procNode = NULL;
const RelationSourceNode* relNode = NULL;
const SelectExprNode* selNode = NULL;
ProcedureSourceNode* procNode = NULL;
RelationSourceNode* relNode = NULL;
SelectExprNode* selNode = NULL;
if ((procNode = relationNode->as<ProcedureSourceNode>()))
relation_name = procNode->dsqlName.identifier;
@ -366,7 +366,7 @@ dsql_ctx* PASS1_make_context(DsqlCompilerScratch* dsqlScratch, const RecordSourc
{
// No processing needed here for derived tables.
}
else if (procNode && (procNode->dsqlName.package.hasData() || procNode->dsqlInputs))
else if (procNode && (procNode->dsqlName.package.hasData() || procNode->sourceList))
{
if (procNode->dsqlName.package.isEmpty())
procedure = dsqlScratch->getSubProcedure(procNode->dsqlName.identifier);
@ -516,10 +516,10 @@ dsql_ctx* PASS1_make_context(DsqlCompilerScratch* dsqlScratch, const RecordSourc
{
USHORT count = 0;
if (procNode->dsqlInputs)
if (procNode->sourceList)
{
context->ctx_proc_inputs = Node::doDsqlPass(dsqlScratch, procNode->dsqlInputs, false);
count = context->ctx_proc_inputs->dsqlArgs.getCount();
context->ctx_proc_inputs = Node::doDsqlPass(dsqlScratch, procNode->sourceList, false);
count = context->ctx_proc_inputs->items.getCount();
}
if (count > procedure->prc_in_count ||
@ -533,10 +533,10 @@ dsql_ctx* PASS1_make_context(DsqlCompilerScratch* dsqlScratch, const RecordSourc
// Initialize this stack variable, and make it look like a node
dsc desc_node;
ValueListNode* inputList = context->ctx_proc_inputs;
ValueExprNode* const* input = inputList->dsqlArgs.begin();
NestConst<ValueExprNode>* input = inputList->items.begin();
for (dsql_fld* field = procedure->prc_inputs;
input != inputList->dsqlArgs.end();
input != inputList->items.end();
++input, field = field->fld_next)
{
DEV_BLKCHK(field, dsql_type_fld);
@ -801,10 +801,10 @@ bool PASS1_node_match(const ExprNode* node1, const ExprNode* node2, bool ignoreM
castNode1->castDesc.dsc_length == castNode2->castDesc.dsc_length &&
castNode1->castDesc.dsc_sub_type == castNode2->castDesc.dsc_sub_type)
{
return PASS1_node_match(castNode1->dsqlSource, castNode2->dsqlSource, ignoreMapCast);
return PASS1_node_match(castNode1->source, castNode2->source, ignoreMapCast);
}
return PASS1_node_match(castNode1->dsqlSource, node2, ignoreMapCast);
return PASS1_node_match(castNode1->source, node2, ignoreMapCast);
}
const DsqlMapNode* mapNode1 = node1->as<DsqlMapNode>();
@ -855,15 +855,14 @@ bool PASS1_node_match(const ExprNode* node1, const ExprNode* node2, bool ignoreM
return false;
}
return PASS1_node_match(derivedField1->dsqlValue, derivedField2->dsqlValue,
ignoreMapCast);
return PASS1_node_match(derivedField1->value, derivedField2->value, ignoreMapCast);
}
if (derivedField1)
return PASS1_node_match(derivedField1->dsqlValue, node2, ignoreMapCast);
return PASS1_node_match(derivedField1->value, node2, ignoreMapCast);
if (derivedField2)
return PASS1_node_match(node1, derivedField2->dsqlValue, ignoreMapCast);
return PASS1_node_match(node1, derivedField2->value, ignoreMapCast);
}
return node1->type == node2->type && node1->dsqlMatch(node2, ignoreMapCast);
@ -1001,7 +1000,7 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
// one, non-recursive member. The dummy will be replaced at the end
// of this function.
RecordSourceNode* save = unionQuery->dsqlClauses->dsqlArgs.pop();
RecordSourceNode* save = unionQuery->dsqlClauses->items.pop();
unionQuery->recursive = false;
dsql_ctx* baseUnionCtx = dsqlScratch->unionContext.hasData() ?
@ -1015,7 +1014,7 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
dsqlScratch->contextNumber = dsqlScratch->recursiveCtxId + 1;
// recursive union always has exactly 2 members
unionQuery->dsqlClauses->dsqlArgs.push(save);
unionQuery->dsqlClauses->items.push(save);
unionQuery->recursive = true;
while (dsqlScratch->unionContext.hasData() &&
@ -1046,7 +1045,7 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
{
UnionSourceNode* unionExpr = FB_NEW(pool) UnionSourceNode(pool);
unionExpr->dsqlClauses = FB_NEW(pool) RecSourceListNode(pool, 1);
unionExpr->dsqlClauses->dsqlArgs[0] = input;
unionExpr->dsqlClauses->items[0] = input;
unionExpr->dsqlAll = true;
rse = pass1_union(dsqlScratch, unionExpr, NULL, NULL, NULL, 0);
}
@ -1118,13 +1117,13 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
if (input->columns && input->columns->hasData())
{
// Do both lists have the same number of items?
if (input->columns->getCount() != rse->dsqlSelectList->dsqlArgs.getCount())
if (input->columns->getCount() != rse->dsqlSelectList->items.getCount())
{
// Column list by derived table %s [alias-name] has %s [more/fewer] columns
// than the number of items.
int errcode = isc_dsql_derived_table_less_columns;
if (input->columns->getCount() > rse->dsqlSelectList->dsqlArgs.getCount())
if (input->columns->getCount() > rse->dsqlSelectList->items.getCount())
errcode = isc_dsql_derived_table_more_columns;
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
@ -1135,7 +1134,7 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
// Generate derived fields and assign alias-name to them.
for (int count = 0; count < input->columns->getCount(); ++count)
{
ValueExprNode* select_item = rse->dsqlSelectList->dsqlArgs[count];
ValueExprNode* select_item = rse->dsqlSelectList->items[count];
MAKE_desc(dsqlScratch, &select_item->nodDesc, select_item);
// Make new derived field node.
@ -1143,17 +1142,17 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
DerivedFieldNode* derivedField = FB_NEW(pool) DerivedFieldNode(pool,
(*input->columns)[count], dsqlScratch->scopeLevel, select_item);
derivedField->nodDesc = select_item->nodDesc;
rse->dsqlSelectList->dsqlArgs[count] = derivedField;
rse->dsqlSelectList->items[count] = derivedField;
}
}
else
{
// For those select-items where no alias is specified try
// to generate one from the field_name.
for (int count = 0; count < rse->dsqlSelectList->dsqlArgs.getCount(); ++count)
for (int count = 0; count < rse->dsqlSelectList->items.getCount(); ++count)
{
ValueExprNode* select_item = pass1_make_derived_field(tdbb, dsqlScratch,
rse->dsqlSelectList->dsqlArgs[count]);
rse->dsqlSelectList->items[count]);
// Auto-create dummy column name for pass1_any()
if (ignoreColumnChecks && !ExprNode::is<DerivedFieldNode>(select_item))
@ -1172,16 +1171,16 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
select_item = derivedField;
}
rse->dsqlSelectList->dsqlArgs[count] = select_item;
rse->dsqlSelectList->items[count] = select_item;
}
}
int count;
// Check if all root select-items have a derived field else show a message.
for (count = 0; count < rse->dsqlSelectList->dsqlArgs.getCount(); ++count)
for (count = 0; count < rse->dsqlSelectList->items.getCount(); ++count)
{
ValueExprNode* select_item = rse->dsqlSelectList->dsqlArgs[count];
ValueExprNode* select_item = rse->dsqlSelectList->items[count];
DerivedFieldNode* derivedField;
if ((derivedField = ExprNode::as<DerivedFieldNode>(select_item)))
@ -1198,15 +1197,15 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
}
// Check for ambiguous column names inside this derived table.
for (count = 0; count < rse->dsqlSelectList->dsqlArgs.getCount(); ++count)
for (count = 0; count < rse->dsqlSelectList->items.getCount(); ++count)
{
const DerivedFieldNode* selectItem1 =
ExprNode::as<DerivedFieldNode>(rse->dsqlSelectList->dsqlArgs[count]);
rse->dsqlSelectList->items[count]->as<DerivedFieldNode>();
for (int count2 = (count + 1); count2 < rse->dsqlSelectList->dsqlArgs.getCount(); ++count2)
for (int count2 = (count + 1); count2 < rse->dsqlSelectList->items.getCount(); ++count2)
{
const DerivedFieldNode* selectItem2 =
ExprNode::as<DerivedFieldNode>(rse->dsqlSelectList->dsqlArgs[count2]);
rse->dsqlSelectList->items[count2]->as<DerivedFieldNode>();
if (selectItem1->name == selectItem2->name)
{
@ -1253,11 +1252,11 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
// Mark union's map context as recursive and assign secondary context number to it.
ValueListNode* items = rse->dsqlSelectList;
ValueExprNode* map_item = items->dsqlArgs[0];
ValueExprNode* map_item = items->items[0];
DerivedFieldNode* derivedField;
if ((derivedField = ExprNode::as<DerivedFieldNode>(map_item)))
map_item = derivedField->dsqlValue;
map_item = derivedField->value;
dsql_ctx* map_context = ExprNode::as<DsqlMapNode>(map_item)->context;
@ -1298,12 +1297,12 @@ static ValueListNode* pass1_expand_select_list(DsqlCompilerScratch* dsqlScratch,
if (list)
{
for (ValueExprNode** ptr = list->dsqlArgs.begin(); ptr != list->dsqlArgs.end(); ++ptr)
for (NestConst<ValueExprNode>* ptr = list->items.begin(); ptr != list->items.end(); ++ptr)
PASS1_expand_select_node(dsqlScratch, *ptr, retList, true);
}
else
{
for (RecordSourceNode** ptr = streams->dsqlArgs.begin(); ptr != streams->dsqlArgs.end(); ++ptr)
for (NestConst<RecordSourceNode>* ptr = streams->items.begin(); ptr != streams->items.end(); ++ptr)
PASS1_expand_select_node(dsqlScratch, *ptr, retList, true);
}
@ -1325,18 +1324,18 @@ void PASS1_expand_select_node(DsqlCompilerScratch* dsqlScratch, ExprNode* node,
if (sub_items) // AB: Derived table support
{
ValueExprNode** ptr = sub_items->dsqlArgs.begin();
NestConst<ValueExprNode>* ptr = sub_items->items.begin();
for (const ValueExprNode* const* const end = sub_items->dsqlArgs.end(); ptr != end; ++ptr)
for (const NestConst<ValueExprNode>* const end = sub_items->items.end(); ptr != end; ++ptr)
{
// Create a new alias else mappings would be mangled.
ValueExprNode* select_item = *ptr;
NestConst<ValueExprNode> select_item = *ptr;
// select-item should always be a derived field!
DerivedFieldNode* derivedField;
if (!(derivedField = ExprNode::as<DerivedFieldNode>(select_item)))
if (!(derivedField = select_item->as<DerivedFieldNode>()))
{
// Internal dsql error: alias type expected by PASS1_expand_select_node
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
@ -1355,8 +1354,12 @@ void PASS1_expand_select_node(DsqlCompilerScratch* dsqlScratch, ExprNode* node,
{
RecSourceListNode* streamList = rseNode->dsqlStreams;
for (RecordSourceNode** ptr = streamList->dsqlArgs.begin(); ptr != streamList->dsqlArgs.end(); ++ptr)
for (NestConst<RecordSourceNode>* ptr = streamList->items.begin();
ptr != streamList->items.end();
++ptr)
{
PASS1_expand_select_node(dsqlScratch, *ptr, list, true);
}
}
}
else if ((procNode = ExprNode::as<ProcedureSourceNode>(node)))
@ -1369,7 +1372,7 @@ void PASS1_expand_select_node(DsqlCompilerScratch* dsqlScratch, ExprNode* node,
{
DEV_BLKCHK(field, dsql_type_fld);
ValueExprNode* select_item = NULL;
NestConst<ValueExprNode> select_item = NULL;
if (!hide_using || context->getImplicitJoinField(field->fld_name, select_item))
{
if (!select_item)
@ -1389,7 +1392,7 @@ void PASS1_expand_select_node(DsqlCompilerScratch* dsqlScratch, ExprNode* node,
{
DEV_BLKCHK(field, dsql_type_fld);
ValueExprNode* select_item = NULL;
NestConst<ValueExprNode> select_item = NULL;
if (!hide_using || context->getImplicitJoinField(field->fld_name, select_item))
{
if (!select_item)
@ -1438,7 +1441,7 @@ static ValueListNode* pass1_group_by_list(DsqlCompilerScratch* dsqlScratch, Valu
DEV_BLKCHK(dsqlScratch, dsql_type_req);
if (input->dsqlArgs.getCount() > MAX_SORT_ITEMS) // sort, group and distinct have the same limit for now
if (input->items.getCount() > MAX_SORT_ITEMS) // sort, group and distinct have the same limit for now
{
// cannot group on more than 255 items
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
@ -1448,8 +1451,8 @@ static ValueListNode* pass1_group_by_list(DsqlCompilerScratch* dsqlScratch, Valu
ValueListNode* retList = FB_NEW(pool) ValueListNode(pool, 0u);
ValueExprNode** ptr = input->dsqlArgs.begin();
for (const ValueExprNode* const* const end = input->dsqlArgs.end(); ptr != end; ++ptr)
NestConst<ValueExprNode>* ptr = input->items.begin();
for (const NestConst<ValueExprNode>* const end = input->items.end(); ptr != end; ++ptr)
{
ValueExprNode* sub = (*ptr);
ValueExprNode* frnode = NULL;
@ -1474,14 +1477,14 @@ static ValueListNode* pass1_group_by_list(DsqlCompilerScratch* dsqlScratch, Valu
{
const ULONG position = literal->getSlong();
if (position < 1 || !selectList || position > (ULONG) selectList->dsqlArgs.getCount())
if (position < 1 || !selectList || position > (ULONG) selectList->items.getCount())
{
// Invalid column position used in the GROUP BY clause
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
Arg::Gds(isc_dsql_column_pos_err) << Arg::Str("GROUP BY"));
}
frnode = Node::doDsqlPass(dsqlScratch, selectList->dsqlArgs[position - 1], false);
frnode = Node::doDsqlPass(dsqlScratch, selectList->items[position - 1], false);
}
else
frnode = Node::doDsqlPass(dsqlScratch, *ptr, false);
@ -1569,8 +1572,8 @@ USHORT PASS1_label(DsqlCompilerScratch* dsqlScratch, bool breakContinue, MetaNam
// Process the limit clause (FIRST/SKIP/ROWS)
void PASS1_limit(DsqlCompilerScratch* dsqlScratch, ValueExprNode* firstNode, ValueExprNode* skipNode,
RseNode* rse)
void PASS1_limit(DsqlCompilerScratch* dsqlScratch, NestConst<ValueExprNode> firstNode,
NestConst<ValueExprNode> skipNode, RseNode* rse)
{
DEV_BLKCHK(dsqlScratch, dsql_type_req);
DEV_BLKCHK(firstNode, dsql_type_nod);
@ -1597,27 +1600,27 @@ ValueExprNode* PASS1_lookup_alias(DsqlCompilerScratch* dsqlScratch, const MetaNa
ValueListNode* selectList, bool process)
{
ValueExprNode* returnNode = NULL;
ValueExprNode** ptr = selectList->dsqlArgs.begin();
const ValueExprNode* const* const end = selectList->dsqlArgs.end();
NestConst<ValueExprNode>* ptr = selectList->items.begin();
const NestConst<ValueExprNode>* const end = selectList->items.end();
for (; ptr < end; ++ptr)
{
ValueExprNode* matchingNode = NULL;
NestConst<ValueExprNode> matchingNode = NULL;
ValueExprNode* node = *ptr;
DsqlAliasNode* aliasNode;
FieldNode* fieldNode;
DerivedFieldNode* derivedField;
if ((aliasNode = ExprNode::as<DsqlAliasNode>(node)))
if ((aliasNode = node->as<DsqlAliasNode>()))
{
if (aliasNode->name == name)
matchingNode = node;
}
else if ((fieldNode = ExprNode::as<FieldNode>(node)))
else if ((fieldNode = node->as<FieldNode>()))
{
if (fieldNode->dsqlField->fld_name == name.c_str())
matchingNode = node;
}
else if ((derivedField = ExprNode::as<DerivedFieldNode>(node)))
else if ((derivedField = node->as<DerivedFieldNode>()))
{
if (derivedField->name == name)
matchingNode = node;
@ -1634,11 +1637,11 @@ ValueExprNode* PASS1_lookup_alias(DsqlCompilerScratch* dsqlScratch, const MetaNa
TEXT buffer1[256];
buffer1[0] = 0;
if (ExprNode::is<DsqlAliasNode>(returnNode))
if (returnNode->is<DsqlAliasNode>())
strcat(buffer1, "an alias");
else if (ExprNode::is<FieldNode>(returnNode))
else if (returnNode->is<FieldNode>())
strcat(buffer1, "a field");
else if (ExprNode::is<DerivedFieldNode>(returnNode))
else if (returnNode->is<DerivedFieldNode>())
strcat(buffer1, "a derived field");
else
strcat(buffer1, "an item");
@ -1646,11 +1649,11 @@ ValueExprNode* PASS1_lookup_alias(DsqlCompilerScratch* dsqlScratch, const MetaNa
TEXT buffer2[256];
buffer2[0] = 0;
if (ExprNode::is<DsqlAliasNode>(matchingNode))
if (matchingNode->is<DsqlAliasNode>())
strcat(buffer2, "an alias");
else if (ExprNode::is<FieldNode>(matchingNode))
else if (matchingNode->is<FieldNode>())
strcat(buffer2, "a field");
else if (ExprNode::is<DerivedFieldNode>(matchingNode))
else if (matchingNode->is<DerivedFieldNode>())
strcat(buffer2, "a derived field");
else
strcat(buffer2, "an item");
@ -1704,11 +1707,11 @@ static ValueExprNode* pass1_make_derived_field(thread_db* tdbb, DsqlCompilerScra
{
// Try to generate derived field from sub-select
ValueExprNode* derived_field = pass1_make_derived_field(tdbb, dsqlScratch,
subQueryNode->dsqlValue1);
subQueryNode->value1);
if ((derivedField = ExprNode::as<DerivedFieldNode>(derived_field)))
{
derivedField->dsqlValue = select_item;
derivedField->value = select_item;
return derived_field;
}
}
@ -1720,7 +1723,7 @@ static ValueExprNode* pass1_make_derived_field(thread_db* tdbb, DsqlCompilerScra
// If we had succesfully made a derived field node change it with orginal map.
if ((derivedField = ExprNode::as<DerivedFieldNode>(derived_field)))
{
derivedField->dsqlValue = select_item;
derivedField->value = select_item;
derivedField->scope = dsqlScratch->scopeLevel;
derived_field->nodDesc = select_item->nodDesc;
return derived_field;
@ -1890,7 +1893,7 @@ static RseNode* pass1_rse_impl(DsqlCompilerScratch* dsqlScratch, RecordSourceNod
}
else if (unionNode)
{
fb_assert(unionNode->dsqlClauses->dsqlArgs.hasData());
fb_assert(unionNode->dsqlClauses->items.hasData());
return pass1_union(dsqlScratch, unionNode, order, rows, updateLock, flags);
}
@ -1913,8 +1916,8 @@ static RseNode* pass1_rse_impl(DsqlCompilerScratch* dsqlScratch, RecordSourceNod
const dsql_rel* relation;
if (updateLock &&
(streamList->dsqlArgs.getCount() != 1 ||
!(relNode = ExprNode::as<RelationSourceNode>(streamList->dsqlArgs[0])) ||
(streamList->items.getCount() != 1 ||
!(relNode = streamList->items[0]->as<RelationSourceNode>()) ||
!(relation = relNode->dsqlContext->ctx_relation) ||
(relation->rel_flags & REL_view) || (relation->rel_flags & REL_external)))
{
@ -1973,7 +1976,7 @@ static RseNode* pass1_rse_impl(DsqlCompilerScratch* dsqlScratch, RecordSourceNod
selectList = pass1_expand_select_list(dsqlScratch, selectList, rse->dsqlStreams);
if ((flags & RecordSourceNode::DFLAG_VALUE) &&
(!selectList || selectList->dsqlArgs.getCount() > 1))
(!selectList || selectList->items.getCount() > 1))
{
// More than one column (or asterisk) is specified in column_singleton
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
@ -2026,7 +2029,7 @@ static RseNode* pass1_rse_impl(DsqlCompilerScratch* dsqlScratch, RecordSourceNod
aggregate->dsqlRse = rse;
parentRse = targetRse = FB_NEW(pool) RseNode(pool);
parentRse->dsqlStreams = (streamList = FB_NEW(pool) RecSourceListNode(pool, 1));
streamList->dsqlArgs[0] = aggregate;
streamList->items[0] = aggregate;
if (rse->dsqlFirst)
{
@ -2090,7 +2093,7 @@ static RseNode* pass1_rse_impl(DsqlCompilerScratch* dsqlScratch, RecordSourceNod
--dsqlScratch->inSelectList;
// sort, group and distinct have the same limit for now
if (selectList->dsqlArgs.getCount() > MAX_SORT_ITEMS)
if (selectList->items.getCount() > MAX_SORT_ITEMS)
{
// Cannot have more than 255 items in DISTINCT list.
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
@ -2112,8 +2115,8 @@ static RseNode* pass1_rse_impl(DsqlCompilerScratch* dsqlScratch, RecordSourceNod
ValueListNode* valueList = parentRse->dsqlSelectList;
{ // scope block
ValueExprNode** ptr = valueList->dsqlArgs.begin();
for (const ValueExprNode* const* const end = valueList->dsqlArgs.end(); ptr != end; ++ptr)
NestConst<ValueExprNode>* ptr = valueList->items.begin();
for (const NestConst<ValueExprNode>* const end = valueList->items.end(); ptr != end; ++ptr)
{
if (InvalidReferenceFinder::find(parent_context, aggregate->dsqlGroup, *ptr))
{
@ -2134,8 +2137,8 @@ static RseNode* pass1_rse_impl(DsqlCompilerScratch* dsqlScratch, RecordSourceNod
// AB: Check for invalid contructions inside the ORDER BY clause
ValueListNode* valueList = targetRse->dsqlOrder;
ValueExprNode** ptr = valueList->dsqlArgs.begin();
for (const ValueExprNode* const* const end = valueList->dsqlArgs.end(); ptr != end; ++ptr)
NestConst<ValueExprNode>* ptr = valueList->items.begin();
for (const NestConst<ValueExprNode>* const end = valueList->items.end(); ptr != end; ++ptr)
{
if (InvalidReferenceFinder::find(parent_context, aggregate->dsqlGroup, *ptr))
{
@ -2203,7 +2206,7 @@ static RseNode* pass1_rse_impl(DsqlCompilerScratch* dsqlScratch, RecordSourceNod
parentRse = targetRse = FB_NEW(pool) RseNode(pool);
parentRse->dsqlStreams = streamList = FB_NEW(pool) RecSourceListNode(pool, 1);
streamList->dsqlArgs[0] = window;
streamList->items[0] = window;
if (rse->flags & RseNode::FLAG_WRITELOCK)
{
@ -2231,8 +2234,8 @@ static RseNode* pass1_rse_impl(DsqlCompilerScratch* dsqlScratch, RecordSourceNod
{
// Check for invalid contructions inside selected-items list
ValueListNode* valueList = rse->dsqlSelectList;
ValueExprNode** ptr = valueList->dsqlArgs.begin();
for (const ValueExprNode* const* const end = valueList->dsqlArgs.end(); ptr != end; ++ptr)
NestConst<ValueExprNode>* ptr = valueList->items.begin();
for (const NestConst<ValueExprNode>* const end = valueList->items.end(); ptr != end; ++ptr)
{
if (InvalidReferenceFinder::find(parent_context, aggregate->dsqlGroup, *ptr))
{
@ -2269,8 +2272,8 @@ static RseNode* pass1_rse_impl(DsqlCompilerScratch* dsqlScratch, RecordSourceNod
{
// Check for invalid contructions inside the order-by list
ValueListNode* valueList = rse->dsqlOrder;
ValueExprNode** ptr = valueList->dsqlArgs.begin();
for (const ValueExprNode* const* const end = valueList->dsqlArgs.end(); ptr != end; ++ptr)
NestConst<ValueExprNode>* ptr = valueList->items.begin();
for (const NestConst<ValueExprNode>* const end = valueList->items.end(); ptr != end; ++ptr)
{
if (InvalidReferenceFinder::find(parent_context, aggregate->dsqlGroup, *ptr))
{
@ -2321,8 +2324,8 @@ static ValueListNode* pass1_sel_list(DsqlCompilerScratch* dsqlScratch, ValueList
ValueListNode* retList = FB_NEW(pool) ValueListNode(pool, 0u);
ValueExprNode** ptr = input->dsqlArgs.begin();
for (const ValueExprNode* const* const end = input->dsqlArgs.end(); ptr != end; ++ptr)
NestConst<ValueExprNode>* ptr = input->items.begin();
for (const NestConst<ValueExprNode>* const end = input->items.end(); ptr != end; ++ptr)
retList->add(Node::doDsqlPass(dsqlScratch, *ptr, false));
return retList;
@ -2347,7 +2350,7 @@ ValueListNode* PASS1_sort(DsqlCompilerScratch* dsqlScratch, ValueListNode* input
Arg::Gds(isc_order_by_err));
}
if (input->dsqlArgs.getCount() > MAX_SORT_ITEMS)
if (input->items.getCount() > MAX_SORT_ITEMS)
{
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
Arg::Gds(isc_dsql_command_err) <<
@ -2358,13 +2361,13 @@ ValueListNode* PASS1_sort(DsqlCompilerScratch* dsqlScratch, ValueListNode* input
// Node is simply to be rebuilt -- just recurse merrily
ValueListNode* node = FB_NEW(pool) ValueListNode(pool, input->dsqlArgs.getCount());
ValueExprNode** ptr2 = node->dsqlArgs.begin();
NestConst<ValueListNode> node = FB_NEW(pool) ValueListNode(pool, input->items.getCount());
NestConst<ValueExprNode>* ptr2 = node->items.begin();
for (int sortloop = 0; sortloop < input->dsqlArgs.getCount(); ++sortloop)
for (int sortloop = 0; sortloop < input->items.getCount(); ++sortloop)
{
DEV_BLKCHK(input->dsqlArgs[sortloop], dsql_type_nod);
OrderNode* node1 = ExprNode::as<OrderNode>(input->dsqlArgs[sortloop]);
DEV_BLKCHK(input->items[sortloop], dsql_type_nod);
NestConst<OrderNode> node1 = input->items[sortloop]->as<OrderNode>();
if (!node1)
{
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
@ -2374,20 +2377,20 @@ ValueListNode* PASS1_sort(DsqlCompilerScratch* dsqlScratch, ValueListNode* input
}
// get node of value to be ordered by
ValueExprNode* orderValue = node1->dsqlValue;
NestConst<ValueExprNode> orderValue = node1->value;
const CollateNode* collateNode = ExprNode::as<CollateNode>(orderValue);
NestConst<CollateNode> collateNode = orderValue->as<CollateNode>();
if (collateNode)
{
// substitute CollateNode with its argument (real value)
orderValue = collateNode->dsqlArg;
orderValue = collateNode->arg;
}
FieldNode* field;
LiteralNode* literal;
if ((field = ExprNode::as<FieldNode>(orderValue)))
if ((field = orderValue->as<FieldNode>()))
{
ValueExprNode* aliasNode = NULL;
@ -2402,11 +2405,11 @@ ValueListNode* PASS1_sort(DsqlCompilerScratch* dsqlScratch, ValueListNode* input
orderValue = aliasNode ? aliasNode : field->internalDsqlPass(dsqlScratch, NULL);
}
else if ((literal = ExprNode::as<LiteralNode>(orderValue)) && literal->litDesc.dsc_dtype == dtype_long)
else if ((literal = orderValue->as<LiteralNode>()) && literal->litDesc.dsc_dtype == dtype_long)
{
const ULONG position = literal->getSlong();
if (position < 1 || !selectList || position > (ULONG) selectList->dsqlArgs.getCount())
if (position < 1 || !selectList || position > (ULONG) selectList->items.getCount())
{
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
// Invalid column position used in the ORDER BY clause
@ -2414,7 +2417,7 @@ ValueListNode* PASS1_sort(DsqlCompilerScratch* dsqlScratch, ValueListNode* input
}
// substitute ordinal with appropriate field
orderValue = Node::doDsqlPass(dsqlScratch, selectList->dsqlArgs[position - 1], false);
orderValue = Node::doDsqlPass(dsqlScratch, selectList->items[position - 1], false);
}
else
orderValue = Node::doDsqlPass(dsqlScratch, orderValue, false);
@ -2456,7 +2459,7 @@ static RseNode* pass1_union(DsqlCompilerScratch* dsqlScratch, UnionSourceNode* i
RseNode* unionRse = FB_NEW(pool) RseNode(pool);
unionRse->dsqlStreams = FB_NEW(pool) RecSourceListNode(pool, 1);
unionRse->dsqlStreams->dsqlArgs[0] = unionSource;
unionRse->dsqlStreams->items[0] = unionSource;
unionSource->dsqlParentRse = unionRse;
// generate a context for the union itself.
@ -2477,15 +2480,15 @@ static RseNode* pass1_union(DsqlCompilerScratch* dsqlScratch, UnionSourceNode* i
dsqlScratch->context->push(union_context);
unionSource->dsqlClauses = FB_NEW(pool) RecSourceListNode(pool,
input->dsqlClauses->dsqlArgs.getCount());
input->dsqlClauses->items.getCount());
// process all the sub-rse's.
{ // scope block
RecordSourceNode** uptr = unionSource->dsqlClauses->dsqlArgs.begin();
NestConst<RecordSourceNode>* uptr = unionSource->dsqlClauses->items.begin();
const DsqlContextStack::const_iterator base(*dsqlScratch->context);
RecordSourceNode** ptr = input->dsqlClauses->dsqlArgs.begin();
NestConst<RecordSourceNode>* ptr = input->dsqlClauses->items.begin();
for (const RecordSourceNode* const* const end = input->dsqlClauses->dsqlArgs.end();
for (const NestConst<RecordSourceNode>* const end = input->dsqlClauses->items.end();
ptr != end;
++ptr, ++uptr)
{
@ -2498,22 +2501,22 @@ static RseNode* pass1_union(DsqlCompilerScratch* dsqlScratch, UnionSourceNode* i
// Push recursive context after initial select has been processed.
// Corresponding pop occurs in pass1_derived_table
if (input->recursive && (ptr == input->dsqlClauses->dsqlArgs.begin()))
if (input->recursive && (ptr == input->dsqlClauses->items.begin()))
dsqlScratch->context->push(dsqlScratch->recursiveCtx);
}
} // end scope block
// generate the list of fields to select.
ValueListNode* items = unionSource->dsqlClauses->dsqlArgs[0]->as<RseNode>()->dsqlSelectList;
ValueListNode* items = unionSource->dsqlClauses->items[0]->as<RseNode>()->dsqlSelectList;
// loop through the list nodes, checking to be sure that they have the
// same number of items
for (int i = 1; i < unionSource->dsqlClauses->dsqlArgs.getCount(); ++i)
for (int i = 1; i < unionSource->dsqlClauses->items.getCount(); ++i)
{
const ValueListNode* nod1 = unionSource->dsqlClauses->dsqlArgs[i]->as<RseNode>()->dsqlSelectList;
const ValueListNode* nod1 = unionSource->dsqlClauses->items[i]->as<RseNode>()->dsqlSelectList;
if (items->dsqlArgs.getCount() != nod1->dsqlArgs.getCount())
if (items->items.getCount() != nod1->items.getCount())
{
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
Arg::Gds(isc_dsql_command_err) <<
@ -2536,15 +2539,15 @@ static RseNode* pass1_union(DsqlCompilerScratch* dsqlScratch, UnionSourceNode* i
// loop through the list nodes and cast whenever possible.
ValueListNode* tmp_list = FB_NEW(pool) ValueListNode(
pool, unionSource->dsqlClauses->dsqlArgs.getCount());
pool, unionSource->dsqlClauses->items.getCount());
for (int j = 0; j < items->dsqlArgs.getCount(); ++j)
for (int j = 0; j < items->items.getCount(); ++j)
{
for (int i = 0; i < unionSource->dsqlClauses->dsqlArgs.getCount(); ++i)
for (int i = 0; i < unionSource->dsqlClauses->items.getCount(); ++i)
{
ValueListNode* nod1 = unionSource->dsqlClauses->dsqlArgs[i]->as<RseNode>()->dsqlSelectList;
MAKE_desc(dsqlScratch, &nod1->dsqlArgs[j]->nodDesc, nod1->dsqlArgs[j]);
tmp_list->dsqlArgs[i] = nod1->dsqlArgs[j];
ValueListNode* nod1 = unionSource->dsqlClauses->items[i]->as<RseNode>()->dsqlSelectList;
MAKE_desc(dsqlScratch, &nod1->items[j]->nodDesc, nod1->items[j]);
tmp_list->items[i] = nod1->items[j];
// We look only at the items->nod_arg[] when creating the
// output descriptors. Make sure that the sub-rses
@ -2553,32 +2556,32 @@ static RseNode* pass1_union(DsqlCompilerScratch* dsqlScratch, UnionSourceNode* i
// -Sudesh 07/28/1999.
if (i > 0)
{
if (nod1->dsqlArgs[j]->nodDesc.dsc_flags & DSC_nullable)
items->dsqlArgs[j]->nodDesc.dsc_flags |= DSC_nullable;
if (nod1->items[j]->nodDesc.dsc_flags & DSC_nullable)
items->items[j]->nodDesc.dsc_flags |= DSC_nullable;
}
}
dsc desc;
MAKE_desc_from_list(dsqlScratch, &desc, tmp_list, "UNION");
// Only mark upper node as a NULL node when all sub-nodes are NULL
items->dsqlArgs[j]->nodDesc.dsc_flags &= ~DSC_null;
items->dsqlArgs[j]->nodDesc.dsc_flags |= (desc.dsc_flags & DSC_null);
items->items[j]->nodDesc.dsc_flags &= ~DSC_null;
items->items[j]->nodDesc.dsc_flags |= (desc.dsc_flags & DSC_null);
pass1_union_auto_cast(dsqlScratch, unionSource->dsqlClauses, desc, j);
}
items = unionSource->dsqlClauses->dsqlArgs[0]->as<RseNode>()->dsqlSelectList;
items = unionSource->dsqlClauses->items[0]->as<RseNode>()->dsqlSelectList;
// Create mappings for union.
ValueListNode* union_items = FB_NEW(pool) ValueListNode(pool, items->dsqlArgs.getCount());
ValueListNode* union_items = FB_NEW(pool) ValueListNode(pool, items->items.getCount());
{ // scope block
USHORT count = 0;
ValueExprNode** uptr = items->dsqlArgs.begin();
ValueExprNode** ptr = union_items->dsqlArgs.begin();
NestConst<ValueExprNode>* uptr = items->items.begin();
NestConst<ValueExprNode>* ptr = union_items->items.begin();
for (const ValueExprNode* const* const end = union_items->dsqlArgs.end(); ptr != end; ++ptr)
for (const NestConst<ValueExprNode>* const end = union_items->items.end(); ptr != end; ++ptr)
{
// Set up the dsql_map* between the sub-rses and the union context.
dsql_map* map = union_context->ctx_map = FB_NEW(*tdbb->getDefaultPool()) dsql_map;
@ -2597,20 +2600,20 @@ static RseNode* pass1_union(DsqlCompilerScratch* dsqlScratch, UnionSourceNode* i
// Process ORDER clause, if any.
if (orderList)
{
ValueListNode* sort = FB_NEW(pool) ValueListNode(pool, orderList->dsqlArgs.getCount());
ValueExprNode** uptr = sort->dsqlArgs.begin();
ValueExprNode** ptr = orderList->dsqlArgs.begin();
ValueListNode* sort = FB_NEW(pool) ValueListNode(pool, orderList->items.getCount());
NestConst<ValueExprNode>* uptr = sort->items.begin();
NestConst<ValueExprNode>* ptr = orderList->items.begin();
for (const ValueExprNode* const* const end = orderList->dsqlArgs.end();
for (const NestConst<ValueExprNode>* const end = orderList->items.end();
ptr != end;
++ptr, ++uptr)
{
OrderNode* order1 = (*ptr)->as<OrderNode>();
const ValueExprNode* position = order1->dsqlValue;
const ValueExprNode* position = order1->value;
const CollateNode* collateNode = position->as<CollateNode>();
if (collateNode)
position = collateNode->dsqlArg;
position = collateNode->arg;
const LiteralNode* literal = position->as<LiteralNode>();
@ -2624,7 +2627,7 @@ static RseNode* pass1_union(DsqlCompilerScratch* dsqlScratch, UnionSourceNode* i
const SLONG number = literal->getSlong();
if (number < 1 || number > union_items->dsqlArgs.getCount())
if (number < 1 || number > union_items->items.getCount())
{
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
Arg::Gds(isc_dsql_command_err) <<
@ -2633,14 +2636,14 @@ static RseNode* pass1_union(DsqlCompilerScratch* dsqlScratch, UnionSourceNode* i
}
// make a new order node pointing at the Nth item in the select list.
OrderNode* order2 = FB_NEW(pool) OrderNode(pool, union_items->dsqlArgs[number - 1]);
OrderNode* order2 = FB_NEW(pool) OrderNode(pool, union_items->items[number - 1]);
*uptr = order2;
order2->descending = order1->descending;
if (collateNode)
{
order2->dsqlValue = CollateNode::pass1Collate(
dsqlScratch, order2->dsqlValue, collateNode->collation);
order2->value = CollateNode::pass1Collate(dsqlScratch,
order2->value, collateNode->collation);
}
order2->nullsPlacement = order1->nullsPlacement;
@ -2703,8 +2706,8 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
if ((recSourceList = input->as<RecSourceListNode>()))
{
RecordSourceNode** ptr = recSourceList->dsqlArgs.begin();
for (const RecordSourceNode* const* const end = recSourceList->dsqlArgs.end(); ptr != end; ++ptr)
NestConst<RecordSourceNode>* ptr = recSourceList->items.begin();
for (const NestConst<RecordSourceNode>* const end = recSourceList->items.end(); ptr != end; ++ptr)
pass1_union_auto_cast(dsqlScratch, *ptr, desc, position);
}
else if ((rseNode = input->as<RseNode>()) && !rseNode->dsqlExplicitJoin &&
@ -2712,23 +2715,23 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
{
pass1_union_auto_cast(dsqlScratch, rseNode->dsqlStreams, desc, position);
if (rseNode->dsqlStreams->dsqlArgs.getCount() == 1 &&
(unionNode = ExprNode::as<UnionSourceNode>(rseNode->dsqlStreams->dsqlArgs[0])) &&
if (rseNode->dsqlStreams->items.getCount() == 1 &&
(unionNode = rseNode->dsqlStreams->items[0]->as<UnionSourceNode>()) &&
unionNode->dsqlParentRse == rseNode)
{
// We're now in a UNION under a UNION so don't change the existing mappings.
// Only replace the node where the map points to, because they could be changed.
ValueListNode* sub_rse_items = ExprNode::as<RseNode>(
unionNode->dsqlClauses->dsqlArgs[0])->dsqlSelectList;
dsql_map* map = ExprNode::as<DsqlMapNode>(rseNode->dsqlSelectList->dsqlArgs[position])->map;
map->map_node = sub_rse_items->dsqlArgs[position];
rseNode->dsqlSelectList->dsqlArgs[position]->nodDesc = desc;
ValueListNode* sub_rse_items =
unionNode->dsqlClauses->items[0]->as<RseNode>()->dsqlSelectList;
dsql_map* map = rseNode->dsqlSelectList->items[position]->as<DsqlMapNode>()->map;
map->map_node = sub_rse_items->items[position];
rseNode->dsqlSelectList->items[position]->nodDesc = desc;
}
else
{
ValueListNode* list = rseNode->dsqlSelectList;
if (position < 0 || position >= list->dsqlArgs.getCount())
if (position < 0 || position >= list->items.getCount())
{
// Internal dsql error: column position out of range in pass1_union_auto_cast
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
@ -2737,7 +2740,7 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
}
else
{
ValueExprNode* select_item = list->dsqlArgs[position];
ValueExprNode* select_item = list->items[position];
MAKE_desc(dsqlScratch, &select_item->nodDesc, select_item);
if (select_item->nodDesc.dsc_dtype != desc.dsc_dtype ||
@ -2754,11 +2757,11 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
// Pick a existing cast if available else make a new one.
if ((aliasNode = ExprNode::as<DsqlAliasNode>(select_item)) &&
aliasNode->value && (castNode = ExprNode::as<CastNode>(aliasNode->value)))
aliasNode->value && (castNode = aliasNode->value->as<CastNode>()))
{
}
else if ((derivedField = ExprNode::as<DerivedFieldNode>(select_item)) &&
(castNode = ExprNode::as<CastNode>(derivedField->dsqlValue)))
(castNode = derivedField->value->as<CastNode>()))
{
}
else if ((castNode = ExprNode::as<CastNode>(select_item)))
@ -2776,11 +2779,11 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
// uses the select_items from the first sub-rse to determine the
// columnname.
if ((aliasNode = ExprNode::as<DsqlAliasNode>(select_item)))
castNode->dsqlSource = aliasNode->value;
castNode->source = aliasNode->value;
else if ((derivedField = ExprNode::as<DerivedFieldNode>(select_item)))
castNode->dsqlSource = derivedField->dsqlValue;
castNode->source = derivedField->value;
else
castNode->dsqlSource = select_item;
castNode->source = select_item;
// When a cast is created we're losing our fieldname, thus
// create an alias to keep it.
@ -2840,8 +2843,8 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
}
else if ((derivedField = ExprNode::as<DerivedFieldNode>(select_item)))
{
derivedField->dsqlValue = castNode;
derivedField->dsqlValue->nodDesc = desc;
derivedField->value = castNode;
derivedField->value->nodDesc = desc;
select_item->nodDesc = desc;
}
else
@ -2852,10 +2855,10 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
{
newAliasNode->value = castNode;
newAliasNode->value->nodDesc = castNode->nodDesc;
list->dsqlArgs[position] = newAliasNode;
list->items[position] = newAliasNode;
}
else
list->dsqlArgs[position] = castNode;
list->items[position] = castNode;
}
}
}
@ -2865,8 +2868,8 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
{
recSourceList = unionNode->dsqlClauses;
for (RecordSourceNode** ptr = recSourceList->dsqlArgs.begin();
ptr != recSourceList->dsqlArgs.end();
for (NestConst<RecordSourceNode>* ptr = recSourceList->items.begin();
ptr != recSourceList->items.end();
++ptr)
{
pass1_union_auto_cast(dsqlScratch, *ptr, desc, position);
@ -2947,8 +2950,8 @@ static void remap_streams_to_parent_context(ExprNode* input, dsql_ctx* parent_co
if ((listNode = input->as<RecSourceListNode>()))
{
RecordSourceNode** ptr = listNode->dsqlArgs.begin();
for (const RecordSourceNode* const* const end = listNode->dsqlArgs.end(); ptr != end; ++ptr)
NestConst<RecordSourceNode>* ptr = listNode->items.begin();
for (const NestConst<RecordSourceNode>* const end = listNode->items.end(); ptr != end; ++ptr)
remap_streams_to_parent_context(*ptr, parent_context);
}
else if ((procNode = input->as<ProcedureSourceNode>()))
@ -2992,7 +2995,7 @@ bool PASS1_set_parameter_type(DsqlCompilerScratch* dsqlScratch, ValueExprNode* i
// Returns false for hidden fields and true for non-hidden.
// For non-hidden, change "node" if the field is part of an
// implicit join.
bool dsql_ctx::getImplicitJoinField(const MetaName& name, ValueExprNode*& node)
bool dsql_ctx::getImplicitJoinField(const MetaName& name, NestConst<ValueExprNode>& node)
{
ImplicitJoin* impJoin;
if (ctx_imp_join.get(name, impJoin))

View File

@ -45,9 +45,11 @@ Jrd::RseNode* PASS1_derived_table(Jrd::DsqlCompilerScratch*, Jrd::SelectExprNode
void PASS1_expand_select_node(Jrd::DsqlCompilerScratch*, Jrd::ExprNode*, Jrd::ValueListNode*, bool);
void PASS1_field_unknown(const TEXT*, const TEXT*, const Jrd::ExprNode*);
USHORT PASS1_label(Jrd::DsqlCompilerScratch*, bool, Firebird::MetaName*);
void PASS1_limit(Jrd::DsqlCompilerScratch*, Jrd::ValueExprNode*, Jrd::ValueExprNode*, Jrd::RseNode*);
Jrd::ValueExprNode* PASS1_lookup_alias(Jrd::DsqlCompilerScratch*, const Firebird::MetaName&, Jrd::ValueListNode*, bool);
Jrd::dsql_ctx* PASS1_make_context(Jrd::DsqlCompilerScratch* statement, const Jrd::RecordSourceNode* relationNode);
void PASS1_limit(Jrd::DsqlCompilerScratch*, NestConst<Jrd::ValueExprNode>,
NestConst<Jrd::ValueExprNode>, Jrd::RseNode*);
Jrd::ValueExprNode* PASS1_lookup_alias(Jrd::DsqlCompilerScratch*, const Firebird::MetaName&,
Jrd::ValueListNode*, bool);
Jrd::dsql_ctx* PASS1_make_context(Jrd::DsqlCompilerScratch* statement, Jrd::RecordSourceNode* relationNode);
bool PASS1_node_match(const Jrd::ExprNode*, const Jrd::ExprNode*, bool);
Jrd::DsqlMapNode* PASS1_post_map(Jrd::DsqlCompilerScratch*, Jrd::ValueExprNode*, Jrd::dsql_ctx*,
Jrd::ValueListNode*, Jrd::ValueListNode*);

View File

@ -428,29 +428,29 @@ dsql_ctx* PlanNode::dsqlPassAlias(DsqlCompilerScratch* dsqlScratch, DsqlContextS
RecSourceListNode::RecSourceListNode(MemoryPool& pool, unsigned count)
: TypedNode<ListExprNode, ExprNode::TYPE_REC_SOURCE_LIST>(pool),
dsqlArgs(pool)
items(pool)
{
dsqlArgs.resize(count);
items.resize(count);
for (unsigned i = 0; i < count; ++i)
addDsqlChildNode((dsqlArgs[i] = NULL));
addDsqlChildNode((items[i] = NULL));
}
RecSourceListNode::RecSourceListNode(MemoryPool& pool, RecordSourceNode* arg1)
: TypedNode<ListExprNode, ExprNode::TYPE_REC_SOURCE_LIST>(pool),
dsqlArgs(pool)
items(pool)
{
dsqlArgs.resize(1);
addDsqlChildNode((dsqlArgs[0] = arg1));
items.resize(1);
addDsqlChildNode((items[0] = arg1));
}
RecSourceListNode* RecSourceListNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
{
RecSourceListNode* node = FB_NEW(getPool()) RecSourceListNode(getPool(), dsqlArgs.getCount());
RecSourceListNode* node = FB_NEW(getPool()) RecSourceListNode(getPool(), items.getCount());
RecordSourceNode** dst = node->dsqlArgs.begin();
NestConst<RecordSourceNode>* dst = node->items.begin();
for (RecordSourceNode** src = dsqlArgs.begin(); src != dsqlArgs.end(); ++src, ++dst)
for (NestConst<RecordSourceNode>* src = items.begin(); src != items.end(); ++src, ++dst)
*dst = doDsqlPass(dsqlScratch, *src);
return node;
@ -1071,10 +1071,10 @@ void ProcedureSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch)
if (inputs)
{
dsqlScratch->appendUShort(inputs->dsqlArgs.getCount());
dsqlScratch->appendUShort(inputs->items.getCount());
for (ValueExprNode* const* ptr = inputs->dsqlArgs.begin();
ptr != inputs->dsqlArgs.end();
for (NestConst<ValueExprNode>* ptr = inputs->items.begin();
ptr != inputs->items.end();
++ptr)
{
GEN_expr(dsqlScratch, *ptr);
@ -1343,14 +1343,14 @@ void AggregateSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch)
if (partition)
{
dsqlScratch->appendUChar(partition->dsqlArgs.getCount()); // partition by expression count
dsqlScratch->appendUChar(partition->items.getCount()); // partition by expression count
ValueExprNode** ptr = partition->dsqlArgs.begin();
for (const ValueExprNode* const* end = partition->dsqlArgs.end(); ptr != end; ++ptr)
NestConst<ValueExprNode>* ptr = partition->items.begin();
for (const NestConst<ValueExprNode>* end = partition->items.end(); ptr != end; ++ptr)
GEN_expr(dsqlScratch, *ptr);
ptr = partitionRemapped->dsqlArgs.begin();
for (const ValueExprNode* const* end = partitionRemapped->dsqlArgs.end(); ptr != end; ++ptr)
ptr = partitionRemapped->items.begin();
for (const NestConst<ValueExprNode>* end = partitionRemapped->items.end(); ptr != end; ++ptr)
GEN_expr(dsqlScratch, *ptr);
}
else
@ -1375,10 +1375,10 @@ void AggregateSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch)
if (list)
{
dsqlScratch->appendUChar(list->dsqlArgs.getCount());
ValueExprNode** ptr = list->dsqlArgs.begin();
dsqlScratch->appendUChar(list->items.getCount());
NestConst<ValueExprNode>* ptr = list->items.begin();
for (const ValueExprNode* const* end = list->dsqlArgs.end(); ptr != end; ++ptr)
for (const NestConst<ValueExprNode>* end = list->items.end(); ptr != end; ++ptr)
(*ptr)->genBlr(dsqlScratch);
}
else
@ -1649,13 +1649,13 @@ void UnionSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch)
dsqlScratch->appendUChar((recursive ? blr_recurse : blr_union));
// Obtain the context for UNION from the first dsql_map* node.
ValueExprNode* mapItem = dsqlParentRse->dsqlSelectList->dsqlArgs[0];
ValueExprNode* mapItem = dsqlParentRse->dsqlSelectList->items[0];
// AB: First item could be a virtual field generated by derived table.
DerivedFieldNode* derivedField = mapItem->as<DerivedFieldNode>();
if (derivedField)
mapItem = derivedField->dsqlValue;
mapItem = derivedField->value;
dsql_ctx* dsqlContext = mapItem->as<DsqlMapNode>()->context;
@ -1664,10 +1664,10 @@ void UnionSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch)
dsqlContext->ctx_flags &= ~CTX_recursive;
RecSourceListNode* streams = dsqlClauses;
dsqlScratch->appendUChar(streams->dsqlArgs.getCount()); // number of substreams
dsqlScratch->appendUChar(streams->items.getCount()); // number of substreams
RecordSourceNode** ptr = streams->dsqlArgs.begin();
for (const RecordSourceNode* const* const end = streams->dsqlArgs.end(); ptr != end; ++ptr)
NestConst<RecordSourceNode>* ptr = streams->items.begin();
for (const NestConst<RecordSourceNode>* const end = streams->items.end(); ptr != end; ++ptr)
{
RseNode* sub_rse = (*ptr)->as<RseNode>();
GEN_rse(dsqlScratch, sub_rse);
@ -1675,12 +1675,12 @@ void UnionSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch)
ValueListNode* items = sub_rse->dsqlSelectList;
dsqlScratch->appendUChar(blr_map);
dsqlScratch->appendUShort(items->dsqlArgs.getCount());
dsqlScratch->appendUShort(items->items.getCount());
USHORT count = 0;
ValueExprNode** iptr = items->dsqlArgs.begin();
NestConst<ValueExprNode>* iptr = items->items.begin();
for (const ValueExprNode* const* const iend = items->dsqlArgs.end(); iptr != iend; ++iptr)
for (const NestConst<ValueExprNode>* const iend = items->items.end(); iptr != iend; ++iptr)
{
dsqlScratch->appendUShort(count);
GEN_expr(dsqlScratch, *iptr);
@ -2244,7 +2244,7 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
RecSourceListNode* fromList = dsqlFrom;
RecSourceListNode* streamList = FB_NEW(getPool()) RecSourceListNode(
getPool(), fromList->dsqlArgs.getCount());
getPool(), fromList->items.getCount());
RseNode* node = FB_NEW(getPool()) RseNode(getPool());
node->dsqlExplicitJoin = dsqlExplicitJoin;
@ -2254,28 +2254,28 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
switch (rse_jointype)
{
case blr_inner:
streamList->dsqlArgs[0] = doDsqlPass(dsqlScratch, fromList->dsqlArgs[0]);
streamList->dsqlArgs[1] = doDsqlPass(dsqlScratch, fromList->dsqlArgs[1]);
streamList->items[0] = doDsqlPass(dsqlScratch, fromList->items[0]);
streamList->items[1] = doDsqlPass(dsqlScratch, fromList->items[1]);
break;
case blr_left:
streamList->dsqlArgs[0] = doDsqlPass(dsqlScratch, fromList->dsqlArgs[0]);
streamList->items[0] = doDsqlPass(dsqlScratch, fromList->items[0]);
++dsqlScratch->inOuterJoin;
streamList->dsqlArgs[1] = doDsqlPass(dsqlScratch, fromList->dsqlArgs[1]);
streamList->items[1] = doDsqlPass(dsqlScratch, fromList->items[1]);
--dsqlScratch->inOuterJoin;
break;
case blr_right:
++dsqlScratch->inOuterJoin;
streamList->dsqlArgs[0] = doDsqlPass(dsqlScratch, fromList->dsqlArgs[0]);
streamList->items[0] = doDsqlPass(dsqlScratch, fromList->items[0]);
--dsqlScratch->inOuterJoin;
streamList->dsqlArgs[1] = doDsqlPass(dsqlScratch, fromList->dsqlArgs[1]);
streamList->items[1] = doDsqlPass(dsqlScratch, fromList->items[1]);
break;
case blr_full:
++dsqlScratch->inOuterJoin;
streamList->dsqlArgs[0] = doDsqlPass(dsqlScratch, fromList->dsqlArgs[0]);
streamList->dsqlArgs[1] = doDsqlPass(dsqlScratch, fromList->dsqlArgs[1]);
streamList->items[0] = doDsqlPass(dsqlScratch, fromList->items[0]);
streamList->items[1] = doDsqlPass(dsqlScratch, fromList->items[1]);
--dsqlScratch->inOuterJoin;
break;
@ -2284,7 +2284,7 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
break;
}
BoolExprNode* boolean = dsqlWhere;
NestConst<BoolExprNode> boolean = dsqlWhere;
ValueListNode* usingList = dsqlJoinUsing;
if (usingList)
@ -2298,21 +2298,21 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
ValueListNode leftStack(dsqlScratch->getPool(), 0u);
ValueListNode rightStack(dsqlScratch->getPool(), 0u);
if (usingList->dsqlArgs.isEmpty()) // NATURAL JOIN
if (usingList->items.isEmpty()) // NATURAL JOIN
{
StrArray leftNames(dsqlScratch->getPool());
ValueListNode* matched = FB_NEW(getPool()) ValueListNode(getPool(), 0u);
PASS1_expand_select_node(dsqlScratch, streamList->dsqlArgs[0], &leftStack, true);
PASS1_expand_select_node(dsqlScratch, streamList->dsqlArgs[1], &rightStack, true);
PASS1_expand_select_node(dsqlScratch, streamList->items[0], &leftStack, true);
PASS1_expand_select_node(dsqlScratch, streamList->items[1], &rightStack, true);
// verify columns that exist in both sides
for (int i = 0; i < 2; ++i)
{
ValueListNode& currentStack = i == 0 ? leftStack : rightStack;
for (ValueExprNode** j = currentStack.dsqlArgs.begin();
j != currentStack.dsqlArgs.end();
for (NestConst<ValueExprNode>* j = currentStack.items.begin();
j != currentStack.items.end();
++j)
{
const TEXT* name = NULL;
@ -2341,7 +2341,7 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
}
}
if (matched->dsqlArgs.isEmpty())
if (matched->items.isEmpty())
{
// There is no match. Transform to CROSS JOIN.
node->rse_jointype = blr_inner;
@ -2358,9 +2358,9 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
BoolExprNode* newBoolean = NULL;
StrArray usedColumns(dsqlScratch->getPool());
for (size_t i = 0; i < usingList->dsqlArgs.getCount(); ++i)
for (size_t i = 0; i < usingList->items.getCount(); ++i)
{
const FieldNode* field = ExprNode::as<FieldNode>(usingList->dsqlArgs[i]);
const FieldNode* field = usingList->items[i]->as<FieldNode>();
// verify if the column was already used
size_t pos;
@ -2380,8 +2380,8 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
rightStack.clear();
// get the column names from both sides
PASS1_expand_select_node(dsqlScratch, streamList->dsqlArgs[0], &leftStack, true);
PASS1_expand_select_node(dsqlScratch, streamList->dsqlArgs[1], &rightStack, true);
PASS1_expand_select_node(dsqlScratch, streamList->items[0], &leftStack, true);
PASS1_expand_select_node(dsqlScratch, streamList->items[1], &rightStack, true);
// create the boolean
@ -2401,7 +2401,7 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
if (!leftCtx->ctx_imp_join.get(field->dsqlName, impJoinLeft))
{
impJoinLeft = FB_NEW(dsqlScratch->getPool()) ImplicitJoin();
impJoinLeft->value = eqlNode->dsqlArg1;
impJoinLeft->value = eqlNode->arg1;
impJoinLeft->visibleInContext = leftCtx;
}
else
@ -2419,9 +2419,9 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
// create the COALESCE
ValueListNode* stack = FB_NEW(getPool()) ValueListNode(getPool(), 0u);
ValueExprNode* temp = impJoinLeft->value;
DsqlAliasNode* aliasNode = ExprNode::as<DsqlAliasNode>(temp);
CoalesceNode* coalesceNode;
NestConst<ValueExprNode> temp = impJoinLeft->value;
NestConst<DsqlAliasNode> aliasNode = temp->as<DsqlAliasNode>();
NestConst<CoalesceNode> coalesceNode;
if (aliasNode)
temp = aliasNode->value;
@ -2429,12 +2429,12 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
{ // scope
PsqlChanger changer(dsqlScratch, false);
if ((coalesceNode = ExprNode::as<CoalesceNode>(temp)))
if ((coalesceNode = temp->as<CoalesceNode>()))
{
ValueListNode* list = coalesceNode->dsqlArgs;
ValueListNode* list = coalesceNode->args;
for (ValueExprNode** ptr = list->dsqlArgs.begin();
ptr != list->dsqlArgs.end();
for (NestConst<ValueExprNode>* ptr = list->items.begin();
ptr != list->items.end();
++ptr)
{
stack->add(doDsqlPass(dsqlScratch, *ptr));
@ -2445,15 +2445,15 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
temp = impJoinRight->value;
if ((aliasNode = ExprNode::as<DsqlAliasNode>(temp)))
if ((aliasNode = temp->as<DsqlAliasNode>()))
temp = aliasNode->value;
if ((coalesceNode = ExprNode::as<CoalesceNode>(temp)))
if ((coalesceNode = temp->as<CoalesceNode>()))
{
ValueListNode* list = coalesceNode->dsqlArgs;
ValueListNode* list = coalesceNode->args;
for (ValueExprNode** ptr = list->dsqlArgs.begin();
ptr != list->dsqlArgs.end();
for (NestConst<ValueExprNode>* ptr = list->items.begin();
ptr != list->items.end();
++ptr)
{
stack->add(doDsqlPass(dsqlScratch, *ptr));
@ -3222,7 +3222,7 @@ static RecordSourceNode* dsqlPassRelProc(DsqlCompilerScratch* dsqlScratch, Recor
{
relName = procNode->dsqlName.identifier;
relAlias = procNode->alias;
couldBeCte = !procNode->dsqlInputs && procNode->dsqlName.package.isEmpty();
couldBeCte = !procNode->sourceList && procNode->dsqlName.package.isEmpty();
}
else if (relNode)
{

View File

@ -320,7 +320,6 @@ public:
const Firebird::QualifiedName& aDsqlName = Firebird::QualifiedName())
: TypedNode<RecordSourceNode, RecordSourceNode::TYPE_PROCEDURE>(pool),
dsqlName(pool, aDsqlName),
dsqlInputs(NULL),
alias(pool),
sourceList(NULL),
targetList(NULL),
@ -381,7 +380,6 @@ private:
public:
Firebird::QualifiedName dsqlName;
ValueListNode* dsqlInputs;
Firebird::string alias;
NestConst<ValueListNode> sourceList;
NestConst<ValueListNode> targetList;
@ -445,8 +443,8 @@ private:
StreamType shellStream);
public:
ValueListNode* dsqlGroup;
RseNode* dsqlRse;
NestConst<ValueListNode> dsqlGroup;
NestConst<RseNode> dsqlRse;
bool dsqlWindow;
NestConst<SortNode> group;
NestConst<MapNode> map;
@ -685,17 +683,17 @@ private:
static void planSet(CompilerScratch* csb, PlanNode* plan);
public:
ValueExprNode* dsqlFirst;
ValueExprNode* dsqlSkip;
ValueListNode* dsqlDistinct;
ValueListNode* dsqlSelectList;
RecSourceListNode* dsqlFrom;
BoolExprNode* dsqlWhere;
ValueListNode* dsqlJoinUsing;
ValueListNode* dsqlGroup;
BoolExprNode* dsqlHaving;
ValueListNode* dsqlOrder;
RecSourceListNode* dsqlStreams;
NestConst<ValueExprNode> dsqlFirst;
NestConst<ValueExprNode> dsqlSkip;
NestConst<ValueListNode> dsqlDistinct;
NestConst<ValueListNode> dsqlSelectList;
NestConst<RecSourceListNode> dsqlFrom;
NestConst<BoolExprNode> dsqlWhere;
NestConst<ValueListNode> dsqlJoinUsing;
NestConst<ValueListNode> dsqlGroup;
NestConst<BoolExprNode> dsqlHaving;
NestConst<ValueListNode> dsqlOrder;
NestConst<RecSourceListNode> dsqlStreams;
bool dsqlExplicitJoin;
USHORT rse_jointype; // inner, left, full
NestConst<ValueExprNode> rse_first;
@ -778,10 +776,10 @@ public:
}
public:
RecordSourceNode* querySpec;
ValueListNode* orderClause;
RowsClause* rowsClause;
WithClause* withClause;
NestConst<RecordSourceNode> querySpec;
NestConst<ValueListNode> orderClause;
NestConst<RowsClause> rowsClause;
NestConst<WithClause> withClause;
Firebird::string alias;
Firebird::ObjectsArray<Firebird::MetaName>* columns;
};

View File

@ -1218,7 +1218,7 @@ void Statement::preprocess(const string& sql, string& ret)
void Statement::setInParams(thread_db* tdbb, const string* const* names,
const ValueListNode* params)
{
const size_t count = params ? params->args.getCount() : 0;
const size_t count = params ? params->items.getCount() : 0;
m_error = (names && (m_sqlParamNames.getCount() != count || count == 0)) ||
(!names && m_sqlParamNames.getCount());
@ -1253,13 +1253,13 @@ void Statement::setInParams(thread_db* tdbb, const string* const* names,
status_exception::raise(Arg::Gds(isc_eds_input_prm_not_set) << Arg::Str(*sqlName));
}
sqlParams[sqlNum] = params->args[num];
sqlParams[sqlNum] = params->items[num];
}
doSetInParams(tdbb, sqlCount, m_sqlParamsMap.begin(), sqlParams);
}
else
doSetInParams(tdbb, count, names, (params ? params->args.begin() : NULL));
doSetInParams(tdbb, count, names, (params ? params->items.begin() : NULL));
}
void Statement::doSetInParams(thread_db* tdbb, unsigned int count, const string* const* /*names*/,
@ -1337,7 +1337,7 @@ void Statement::doSetInParams(thread_db* tdbb, unsigned int count, const string*
// m_outDescs -> ValueExprNode
void Statement::getOutParams(thread_db* tdbb, const ValueListNode* params)
{
const size_t count = params ? params->args.getCount() : 0;
const size_t count = params ? params->items.getCount() : 0;
if (count != getOutputs())
{
@ -1349,7 +1349,7 @@ void Statement::getOutParams(thread_db* tdbb, const ValueListNode* params)
if (!count)
return;
const NestConst<ValueExprNode>* jrdVar = params->args.begin();
const NestConst<ValueExprNode>* jrdVar = params->items.begin();
for (size_t i = 0; i < count; ++i, ++jrdVar)
{

View File

@ -795,7 +795,7 @@ ValueListNode* PAR_args(thread_db* tdbb, CompilerScratch* csb, UCHAR count,
MemoryPool& pool = *tdbb->getDefaultPool();
ValueListNode* node = FB_NEW(pool) ValueListNode(pool, allocCount);
NestConst<ValueExprNode>* ptr = node->args.begin();
NestConst<ValueExprNode>* ptr = node->items.begin();
if (count)
{
@ -1222,9 +1222,9 @@ void PAR_procedure_parms(thread_db* tdbb, CompilerScratch* csb, jrd_prc* procedu
ValueListNode* targetValues = *targetList = FB_NEW(pool) ValueListNode(pool, n);
NestConst<ValueExprNode>* sourcePtr =
input_flag ? sourceValues->args.begin() : targetValues->args.begin();
input_flag ? sourceValues->items.begin() : targetValues->items.begin();
NestConst<ValueExprNode>* targetPtr =
input_flag ? targetValues->args.begin() : sourceValues->args.begin();
input_flag ? targetValues->items.begin() : sourceValues->items.begin();
for (USHORT i = 0; n; count--, n--)
{

View File

@ -51,7 +51,7 @@ ProcedureScan::ProcedureScan(CompilerScratch* csb, const Firebird::string& name,
if (sourceList && targetList)
{
fb_assert(sourceList->args.getCount() == targetList->args.getCount());
fb_assert(sourceList->items.getCount() == targetList->items.getCount());
}
}
@ -80,9 +80,9 @@ void ProcedureScan::open(thread_db* tdbb) const
{
enum jrd_req::req_s saved_state = request->req_operation;
const NestConst<ValueExprNode>* const sourceEnd = m_sourceList->args.end();
const NestConst<ValueExprNode>* sourcePtr = m_sourceList->args.begin();
const NestConst<ValueExprNode>* targetPtr = m_targetList->args.begin();
const NestConst<ValueExprNode>* const sourceEnd = m_sourceList->items.end();
const NestConst<ValueExprNode>* sourcePtr = m_sourceList->items.begin();
const NestConst<ValueExprNode>* targetPtr = m_targetList->items.begin();
for (; sourcePtr != sourceEnd; ++sourcePtr, ++targetPtr)
EXE_assignment(tdbb, *sourcePtr, *targetPtr);

View File

@ -331,8 +331,8 @@ void TraceProcedureImpl::JrdParamsImpl::fillParams()
thread_db* tdbb = JRD_get_thread_data();
const NestConst<ValueExprNode>* ptr = m_params->args.begin();
const NestConst<ValueExprNode>* const end = m_params->args.end();
const NestConst<ValueExprNode>* ptr = m_params->items.begin();
const NestConst<ValueExprNode>* const end = m_params->items.end();
for (; ptr != end; ++ptr)
{