diff --git a/src/dsql/AggNodes.cpp b/src/dsql/AggNodes.cpp index 11181b6a07..8fbeb70f81 100644 --- a/src/dsql/AggNodes.cpp +++ b/src/dsql/AggNodes.cpp @@ -114,10 +114,17 @@ AggNode* AggNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return dsqlCopy(dsqlScratch); } -void AggNode::print(string& text) const +string AggNode::internalPrint(NodePrinter& printer) const { - text = string("AggNode (") + aggInfo.name + ")"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, distinct); + NODE_PRINT(printer, dialect1); + NODE_PRINT(printer, arg); + NODE_PRINT(printer, asb); + NODE_PRINT(printer, indexed); + + return aggInfo.name; } bool AggNode::dsqlAggregateFinder(AggregateFinder& visitor) @@ -615,6 +622,15 @@ void AvgAggNode::aggPostRse(thread_db* tdbb, CompilerScratch* csb) tempImpure = CMP_impure(csb, sizeof(impure_value_ex)); } +string AvgAggNode::internalPrint(NodePrinter& printer) const +{ + AggNode::internalPrint(printer); + + NODE_PRINT(printer, tempImpure); + + return "AvgAggNode"; +} + void AvgAggNode::aggInit(thread_db* tdbb, jrd_req* request) const { AggNode::aggInit(tdbb, request); @@ -732,6 +748,15 @@ ValueExprNode* ListAggNode::copy(thread_db* tdbb, NodeCopier& copier) const return node; } +string ListAggNode::internalPrint(NodePrinter& printer) const +{ + AggNode::internalPrint(printer); + + NODE_PRINT(printer, delimiter); + + return "ListAggNode"; +} + void ListAggNode::aggInit(thread_db* tdbb, jrd_req* request) const { AggNode::aggInit(tdbb, request); @@ -864,6 +889,12 @@ ValueExprNode* CountAggNode::copy(thread_db* tdbb, NodeCopier& copier) const return node; } +string CountAggNode::internalPrint(NodePrinter& printer) const +{ + AggNode::internalPrint(printer); + return "CountAggNode"; +} + void CountAggNode::aggInit(thread_db* tdbb, jrd_req* request) const { AggNode::aggInit(tdbb, request); @@ -1086,6 +1117,12 @@ ValueExprNode* SumAggNode::copy(thread_db* tdbb, NodeCopier& copier) const return node; } +string SumAggNode::internalPrint(NodePrinter& printer) const +{ + AggNode::internalPrint(printer); + return "SumAggNode"; +} + void SumAggNode::aggInit(thread_db* tdbb, jrd_req* request) const { AggNode::aggInit(tdbb, request); @@ -1170,6 +1207,15 @@ ValueExprNode* MaxMinAggNode::copy(thread_db* tdbb, NodeCopier& copier) const return node; } +string MaxMinAggNode::internalPrint(NodePrinter& printer) const +{ + AggNode::internalPrint(printer); + + NODE_PRINT(printer, type); + + return "MaxMinAggNode"; +} + void MaxMinAggNode::aggInit(thread_db* tdbb, jrd_req* request) const { AggNode::aggInit(tdbb, request); @@ -1265,6 +1311,16 @@ ValueExprNode* StdDevAggNode::copy(thread_db* tdbb, NodeCopier& copier) const return node; } +string StdDevAggNode::internalPrint(NodePrinter& printer) const +{ + AggNode::internalPrint(printer); + + NODE_PRINT(printer, type); + NODE_PRINT(printer, impure2Offset); + + return "StdDevAggNode"; +} + void StdDevAggNode::aggInit(thread_db* tdbb, jrd_req* request) const { AggNode::aggInit(tdbb, request); @@ -1389,6 +1445,16 @@ ValueExprNode* CorrAggNode::copy(thread_db* tdbb, NodeCopier& copier) const return node; } +string CorrAggNode::internalPrint(NodePrinter& printer) const +{ + AggNode::internalPrint(printer); + + NODE_PRINT(printer, type); + NODE_PRINT(printer, arg2); + + return "CorrAggNode"; +} + void CorrAggNode::aggInit(thread_db* tdbb, jrd_req* request) const { AggNode::aggInit(tdbb, request); @@ -1561,6 +1627,16 @@ ValueExprNode* RegrAggNode::copy(thread_db* tdbb, NodeCopier& copier) const return node; } +string RegrAggNode::internalPrint(NodePrinter& printer) const +{ + AggNode::internalPrint(printer); + + NODE_PRINT(printer, type); + NODE_PRINT(printer, arg2); + + return "RegrAggNode"; +} + void RegrAggNode::aggInit(thread_db* tdbb, jrd_req* request) const { AggNode::aggInit(tdbb, request); @@ -1725,6 +1801,15 @@ ValueExprNode* RegrCountAggNode::copy(thread_db* tdbb, NodeCopier& copier) const return node; } +string RegrCountAggNode::internalPrint(NodePrinter& printer) const +{ + AggNode::internalPrint(printer); + + NODE_PRINT(printer, arg2); + + return "RegrCountAggNode"; +} + void RegrCountAggNode::aggInit(thread_db* tdbb, jrd_req* request) const { AggNode::aggInit(tdbb, request); diff --git a/src/dsql/AggNodes.h b/src/dsql/AggNodes.h index b7d06b61e0..0b18dc66dd 100644 --- a/src/dsql/AggNodes.h +++ b/src/dsql/AggNodes.h @@ -25,6 +25,7 @@ #include "../jrd/blr.h" #include "../dsql/Nodes.h" +#include "../dsql/NodePrinter.h" namespace Jrd { @@ -36,6 +37,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -61,6 +63,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, const dsc* desc, bool forceVarChar); @@ -93,6 +96,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); @@ -113,6 +117,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -138,6 +143,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -175,6 +181,7 @@ public: virtual void aggPostRse(thread_db* tdbb, CompilerScratch* csb); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -215,6 +222,7 @@ public: virtual void aggPostRse(thread_db* tdbb, CompilerScratch* csb); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -262,6 +270,7 @@ public: virtual void aggPostRse(thread_db* tdbb, CompilerScratch* csb); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -290,6 +299,7 @@ public: virtual void parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigned count); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; diff --git a/src/dsql/BoolNodes.cpp b/src/dsql/BoolNodes.cpp index 6bf4537dd9..1be9394833 100644 --- a/src/dsql/BoolNodes.cpp +++ b/src/dsql/BoolNodes.cpp @@ -153,10 +153,15 @@ DmlNode* BinaryBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratc return node; } -void BinaryBoolNode::print(string& text) const +string BinaryBoolNode::internalPrint(NodePrinter& printer) const { - text.printf("BinaryBoolNode (%d)", blrOp); - BoolExprNode::print(text); + BoolExprNode::internalPrint(printer); + + NODE_PRINT(printer, blrOp); + NODE_PRINT(printer, arg1); + NODE_PRINT(printer, arg2); + + return "BinaryBoolNode"; } BoolExprNode* BinaryBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -376,10 +381,18 @@ DmlNode* ComparativeBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerS return node; } -void ComparativeBoolNode::print(string& text) const +string ComparativeBoolNode::internalPrint(NodePrinter& printer) const { - text.printf("ComparativeBoolNode (%d)", blrOp); - BoolExprNode::print(text); + BoolExprNode::internalPrint(printer); + + NODE_PRINT(printer, blrOp); + NODE_PRINT(printer, dsqlFlag); + NODE_PRINT(printer, arg1); + NODE_PRINT(printer, arg2); + NODE_PRINT(printer, arg3); + NODE_PRINT(printer, dsqlSpecialArg); + + return "ComparativeBoolNode"; } BoolExprNode* ComparativeBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -1348,10 +1361,14 @@ DmlNode* MissingBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScrat return node; } -void MissingBoolNode::print(string& text) const +string MissingBoolNode::internalPrint(NodePrinter& printer) const { - text = "MissingBoolNode"; - BoolExprNode::print(text); + BoolExprNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlUnknown); + NODE_PRINT(printer, arg); + + return "MissingBoolNode"; } BoolExprNode* MissingBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -1438,10 +1455,13 @@ DmlNode* NotBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* return node; } -void NotBoolNode::print(string& text) const +string NotBoolNode::internalPrint(NodePrinter& printer) const { - text = "NotBoolNode"; - BoolExprNode::print(text); + BoolExprNode::internalPrint(printer); + + NODE_PRINT(printer, arg); + + return "NotBoolNode"; } BoolExprNode* NotBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -1635,10 +1655,17 @@ DmlNode* RseBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* return node; } -void RseBoolNode::print(string& text) const +string RseBoolNode::internalPrint(NodePrinter& printer) const { - text.printf("RseBoolNode (%d)", blrOp); - BoolExprNode::print(text); + BoolExprNode::internalPrint(printer); + + NODE_PRINT(printer, blrOp); + NODE_PRINT(printer, ownSavepoint); + NODE_PRINT(printer, dsqlRse); + NODE_PRINT(printer, rse); + NODE_PRINT(printer, rsb); + + return "RseBoolNode"; } BoolExprNode* RseBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) diff --git a/src/dsql/BoolNodes.h b/src/dsql/BoolNodes.h index 5b21d862ad..2fb5f69d69 100644 --- a/src/dsql/BoolNodes.h +++ b/src/dsql/BoolNodes.h @@ -39,7 +39,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual BoolExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -74,7 +74,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual BoolExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -117,7 +117,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual BoolExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -144,7 +144,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual BoolExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -172,7 +172,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual BoolExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); diff --git a/src/dsql/DdlNodes.epp b/src/dsql/DdlNodes.epp index 0c807405d7..63521ba21c 100644 --- a/src/dsql/DdlNodes.epp +++ b/src/dsql/DdlNodes.epp @@ -1051,24 +1051,29 @@ ParameterClause::ParameterClause(MemoryPool& pool, dsql_fld* field, const MetaNa type->collate = aCollate; } -void ParameterClause::print(string& text) const +string ParameterClause::internalPrint(NodePrinter& printer) const { - string s; - type->print(s); - text.printf("name: '%s' %s", name.c_str(), s.c_str()); + NODE_PRINT(printer, name); + NODE_PRINT(printer, type); + NODE_PRINT(printer, defaultClause); + NODE_PRINT(printer, parameterExpr); + NODE_PRINT(printer, udfMechanism); + + return "ParameterClause"; } //---------------------- -void AlterCharSetNode::print(string& text) const +string AlterCharSetNode::internalPrint(NodePrinter& printer) const { - text.printf( - "AlterCharSetNode\n" - " charSet: %s\n" - " defaultCollation: %s\n", - charSet.c_str(), defaultCollation.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, charSet); + NODE_PRINT(printer, defaultCollation); + + return "AlterCharSetNode"; } bool AlterCharSetNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -1135,14 +1140,17 @@ void AlterCharSetNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch //---------------------- -void CommentOnNode::print(string& text) const +string CommentOnNode::internalPrint(NodePrinter& printer) const { - text.printf( - "CommentOnNode\n" - " objType: %s\n" - " objName: %s\n" - " text: %s\n", - objType, objName.toString().c_str(), this->text.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, objType); + NODE_PRINT(printer, objName); + NODE_PRINT(printer, subName); + NODE_PRINT(printer, text); + NODE_PRINT(printer, str); + + return "CommentOnNode"; } bool CommentOnNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -1470,31 +1478,28 @@ void CommentOnNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, //---------------------- -void CreateAlterFunctionNode::print(string& text) const +string CreateAlterFunctionNode::internalPrint(NodePrinter& printer) const { - text.printf( - "CreateAlterFunctionNode\n" - " name: '%s' create: %d alter: %d\n", - name.c_str(), create, alter); + DdlNode::internalPrint(printer); - if (external) - { - string s; - s.printf(" external -> name: '%s' engine: '%s'\n", - external->name.c_str(), external->engine.c_str()); - text += s; - } + NODE_PRINT(printer, name); + NODE_PRINT(printer, create); + NODE_PRINT(printer, alter); + NODE_PRINT(printer, external); + NODE_PRINT(printer, deterministic); + NODE_PRINT(printer, parameters); + NODE_PRINT(printer, returnType); + NODE_PRINT(printer, localDeclList); + NODE_PRINT(printer, source); + NODE_PRINT(printer, body); + NODE_PRINT(printer, compiled); + NODE_PRINT(printer, invalid); + NODE_PRINT(printer, package); + NODE_PRINT(printer, packageOwner); + NODE_PRINT(printer, privateScope); + NODE_PRINT(printer, udfReturnPos); - text += " Parameters:\n"; - - for (FB_SIZE_T i = 0; i < parameters.getCount(); ++i) - { - const ParameterClause* parameter = parameters[i]; - - string s; - parameter->print(s); - text += " " + s + "\n"; - } + return "CreateAlterFunctionNode"; } DdlNode* CreateAlterFunctionNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -2197,14 +2202,14 @@ void CreateAlterFunctionNode::collectParamComments(thread_db* tdbb, jrd_tra* tra //---------------------- -void AlterExternalFunctionNode::print(string& text) const +string AlterExternalFunctionNode::internalPrint(NodePrinter& printer) const { - text.printf( - "AlterExternalFunctionNode\n" - " name: '%s'\n" - " entrypoint: '%s'\n" - " module: '%s'\n", - name.c_str(), clauses.name.c_str(), clauses.udfModule.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, clauses); + + return "AlterExternalFunctionNode"; } bool AlterExternalFunctionNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -2318,12 +2323,15 @@ void DropFunctionNode::dropArguments(thread_db* tdbb, jrd_tra* transaction, END_FOR } -void DropFunctionNode::print(string& text) const +string DropFunctionNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropFunctionNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, silent); + NODE_PRINT(printer, package); + + return "DropFunctionNode"; } DdlNode* DropFunctionNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -2415,42 +2423,26 @@ void DropFunctionNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch //---------------------- -void CreateAlterProcedureNode::print(string& text) const +string CreateAlterProcedureNode::internalPrint(NodePrinter& printer) const { - text.printf( - "CreateAlterProcedureNode\n" - " name: '%s' create: %d alter: %d\n", - name.c_str(), create, alter); + DdlNode::internalPrint(printer); - if (external) - { - string s; - s.printf(" external -> name: '%s' engine: '%s'\n", - external->name.c_str(), external->engine.c_str()); - text += s; - } + NODE_PRINT(printer, name); + NODE_PRINT(printer, create); + NODE_PRINT(printer, alter); + NODE_PRINT(printer, external); + NODE_PRINT(printer, parameters); + NODE_PRINT(printer, returns); + NODE_PRINT(printer, source); + NODE_PRINT(printer, localDeclList); + NODE_PRINT(printer, body); + NODE_PRINT(printer, compiled); + NODE_PRINT(printer, invalid); + NODE_PRINT(printer, package); + NODE_PRINT(printer, packageOwner); + NODE_PRINT(printer, privateScope); - text += " Parameters:\n"; - - for (FB_SIZE_T i = 0; i < parameters.getCount(); ++i) - { - const ParameterClause* parameter = parameters[i]; - - string s; - parameter->print(s); - text += " " + s + "\n"; - } - - text += " Returns:\n"; - - for (FB_SIZE_T i = 0; i < returns.getCount(); ++i) - { - const ParameterClause* parameter = returns[i]; - - string s; - parameter->print(s); - text += " " + s + "\n"; - } + return "CreateAlterProcedureNode"; } DdlNode* CreateAlterProcedureNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -3091,12 +3083,15 @@ void DropProcedureNode::dropParameters(thread_db* tdbb, jrd_tra* transaction, END_FOR } -void DropProcedureNode::print(string& text) const +string DropProcedureNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropProcedureNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, silent); + NODE_PRINT(printer, package); + + return "DropProcedureNode"; } DdlNode* DropProcedureNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -3332,22 +3327,18 @@ bool TriggerDefinition::modify(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch //---------------------- -void CreateAlterTriggerNode::print(string& text) const +string CreateAlterTriggerNode::internalPrint(NodePrinter& printer) const { - text.printf( - "CreateAlterTriggerNode\n" - " name: '%s' create: %d alter: %d relationName: '%s'\n" - " type: %d, %d active: %d, %d position: %d, %d\n", - name.c_str(), create, alter, relationName.c_str(), type.specified, type.value, - active.specified, active.value, position.specified, position.value); + DdlNode::internalPrint(printer); - if (external) - { - string s; - s.printf(" external -> name: '%s' engine: '%s'\n", - external->name.c_str(), external->engine.c_str()); - text += s; - } + NODE_PRINT(printer, create); + NODE_PRINT(printer, alter); + NODE_PRINT(printer, localDeclList); + NODE_PRINT(printer, body); + NODE_PRINT(printer, compiled); + NODE_PRINT(printer, invalid); + + return "CreateAlterTriggerNode"; } DdlNode* CreateAlterTriggerNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -3548,12 +3539,14 @@ void CreateAlterTriggerNode::compile(thread_db* /*tdbb*/, DsqlCompilerScratch* d //---------------------- -void DropTriggerNode::print(string& text) const +string DropTriggerNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropTriggerNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, silent); + + return "DropTriggerNode"; } DdlNode* DropTriggerNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -3684,18 +3677,21 @@ void DropTriggerNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, //---------------------- -void CreateCollationNode::print(string& text) const +string CreateCollationNode::internalPrint(NodePrinter& printer) const { - text.printf( - "CreateCollationNode\n" - " name: '%s'\n" - " forCharSet: '%s'\n" - " fromName: '%s'\n" - " fromExternal: '%s'\n" - " attributesOn: %x\n" - " attributesOff: %x\n", - name.c_str(), forCharSet.c_str(), fromName.c_str(), fromExternal.c_str(), - attributesOn, attributesOff); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, forCharSet); + NODE_PRINT(printer, fromName); + NODE_PRINT(printer, fromExternal); + NODE_PRINT(printer, specificAttributes); + NODE_PRINT(printer, attributesOn); + NODE_PRINT(printer, attributesOff); + NODE_PRINT(printer, forCharSetId); + NODE_PRINT(printer, fromCollationId); + + return "CreateCollationNode"; } bool CreateCollationNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -3908,12 +3904,13 @@ DdlNode* CreateCollationNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) //---------------------- -void DropCollationNode::print(string& text) const +string DropCollationNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropCollationNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + + return "DropCollationNode"; } bool DropCollationNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -4061,14 +4058,15 @@ void DropCollationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc //---------------------- -void CreateDomainNode::print(string& text) const +string CreateDomainNode::internalPrint(NodePrinter& printer) const { - string nameTypeStr; - nameType->print(nameTypeStr); + DdlNode::internalPrint(printer); - text = - "CreateDomainNode\n" - " " + nameTypeStr + "\n"; + NODE_PRINT(printer, nameType); + NODE_PRINT(printer, notNull); + NODE_PRINT(printer, check); + + return "CreateDomainNode"; } bool CreateDomainNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -4615,11 +4613,20 @@ void AlterDomainNode::modifyLocalFieldIndex(thread_db* tdbb, jrd_tra* transactio END_FOR } -void AlterDomainNode::print(string& text) const +string AlterDomainNode::internalPrint(NodePrinter& printer) const { - text.printf( - "AlterDomainNode\n" - " %s\n", name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, dropConstraint); + NODE_PRINT(printer, dropDefault); + NODE_PRINT(printer, setConstraint); + NODE_PRINT(printer, setDefault); + NODE_PRINT(printer, renameTo); + NODE_PRINT(printer, type); + NODE_PRINT(printer, notNullFlag); + + return "AlterDomainNode"; } bool AlterDomainNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -4960,12 +4967,13 @@ bool DropDomainNode::deleteDimensionRecords(thread_db* tdbb, jrd_tra* transactio return found; } -void DropDomainNode::print(string& text) const +string DropDomainNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropDomainNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + + return "DropDomainNode"; } bool DropDomainNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -5085,13 +5093,16 @@ void DropDomainNode::check(thread_db* tdbb, jrd_tra* transaction) //---------------------- -void CreateAlterExceptionNode::print(string& text) const +string CreateAlterExceptionNode::internalPrint(NodePrinter& printer) const { - text.printf( - "CreateAlterExceptionNode\n" - " name: '%s' create: %d alter: %d\n" - " message: '%s'\n", - name.c_str(), create, alter, message.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, message); + NODE_PRINT(printer, create); + NODE_PRINT(printer, alter); + + return "CreateAlterExceptionNode"; } bool CreateAlterExceptionNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -5221,12 +5232,14 @@ bool CreateAlterExceptionNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch //---------------------- -void DropExceptionNode::print(string& text) const +string DropExceptionNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropExceptionNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, silent); + + return "DropExceptionNode"; } bool DropExceptionNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -5285,12 +5298,19 @@ void DropExceptionNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc //---------------------- -void CreateAlterSequenceNode::print(string& text) const +string CreateAlterSequenceNode::internalPrint(NodePrinter& printer) const { - text.printf( - "CreateAlterSequenceNode\n" - " name: %s\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, create); + NODE_PRINT(printer, alter); + NODE_PRINT(printer, legacy); + NODE_PRINT(printer, restartSpecified); + NODE_PRINT(printer, name); + NODE_PRINT(printer, value); + NODE_PRINT(printer, step); + + return "CreateAlterSequenceNode"; } bool CreateAlterSequenceNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -5541,12 +5561,14 @@ SSHORT CreateAlterSequenceNode::store(thread_db* tdbb, jrd_tra* transaction, con //---------------------- -void DropSequenceNode::print(string& text) const +string DropSequenceNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropSequenceNode\n" - " name: %s\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, silent); + + return "DropSequenceNode"; } bool DropSequenceNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -6983,12 +7005,14 @@ void RelationNode::stuffTriggerFiringCondition(const Constraint& constraint, Blr //---------------------- -void CreateRelationNode::print(string& text) const +string CreateRelationNode::internalPrint(NodePrinter& printer) const { - text.printf( - "CreateRelationNode\n" - " name: '%s'\n", - name.c_str()); + RelationNode::internalPrint(printer); + + NODE_PRINT(printer, externalFile); + NODE_PRINT(printer, relationType); + + return "CreateRelationNode"; } bool CreateRelationNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -7113,12 +7137,10 @@ const ObjectsArray* CreateRelationNode::findPkColumns() //---------------------- -void AlterRelationNode::print(string& text) const +string AlterRelationNode::internalPrint(NodePrinter& printer) const { - text.printf( - "AlterRelationNode\n" - " name: '%s'\n", - name.c_str()); + RelationNode::internalPrint(printer); + return "AlterRelationNode"; } bool AlterRelationNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -7815,12 +7837,15 @@ void DropRelationNode::deleteGlobalField(thread_db* tdbb, jrd_tra* transaction, END_FOR } -void DropRelationNode::print(string& text) const +string DropRelationNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropRelationNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, view); + NODE_PRINT(printer, silent); + + return "DropRelationNode"; } bool DropRelationNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -8054,12 +8079,18 @@ void DropRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch //---------------------- -void CreateAlterViewNode::print(string& text) const +string CreateAlterViewNode::internalPrint(NodePrinter& printer) const { - text.printf( - "CreateAlterViewNode\n" - " name: '%s'\n", - name.c_str()); + RelationNode::internalPrint(printer); + + NODE_PRINT(printer, create); + NODE_PRINT(printer, alter); + NODE_PRINT(printer, viewFields); + NODE_PRINT(printer, selectExpr); + NODE_PRINT(printer, source); + NODE_PRINT(printer, withCheckOption); + + return "CreateAlterViewNode"; } DdlNode* CreateAlterViewNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -9193,12 +9224,18 @@ void CreateIndexNode::store(thread_db* tdbb, jrd_tra* transaction, MetaName& nam } -void CreateIndexNode::print(string& text) const +string CreateIndexNode::internalPrint(NodePrinter& printer) const { - text.printf( - "CreateIndexNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, unique); + NODE_PRINT(printer, descending); + NODE_PRINT(printer, relation); + NODE_PRINT(printer, columns); + NODE_PRINT(printer, computed); + + return "CreateIndexNode"; } bool CreateIndexNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -9260,13 +9297,14 @@ void CreateIndexNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, //---------------------- -void AlterIndexNode::print(string& text) const +string AlterIndexNode::internalPrint(NodePrinter& printer) const { - text.printf( - "AlterIndexNode\n" - " name: '%s'\n" - " active: '%d'\n", - name.c_str(), active); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, active); + + return "AlterIndexNode"; } bool AlterIndexNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -9318,12 +9356,13 @@ void AlterIndexNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, //---------------------- -void SetStatisticsNode::print(string& text) const +string SetStatisticsNode::internalPrint(NodePrinter& printer) const { - text.printf( - "SetStatisticsNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + + return "SetStatisticsNode"; } bool SetStatisticsNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -9394,12 +9433,13 @@ bool DropIndexNode::deleteSegmentRecords(thread_db* tdbb, jrd_tra* transaction, return found; } -void DropIndexNode::print(string& text) const +string DropIndexNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropIndexNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + + return "DropIndexNode"; } bool DropIndexNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -9455,12 +9495,17 @@ void DropIndexNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, j //---------------------- -void CreateFilterNode::print(string& text) const +string CreateFilterNode::internalPrint(NodePrinter& printer) const { - text.printf( - "CreateFilterNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, inputFilter); + NODE_PRINT(printer, outputFilter); + NODE_PRINT(printer, entryPoint); + NODE_PRINT(printer, moduleName); + + return "CreateFilterNode"; } bool CreateFilterNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -9529,12 +9574,13 @@ void CreateFilterNode::execute(thread_db* tdbb, DsqlCompilerScratch* /*dsqlScrat //---------------------- -void DropFilterNode::print(string& text) const +string DropFilterNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropFilterNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + + return "DropFilterNode"; } bool DropFilterNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -9573,12 +9619,17 @@ void DropFilterNode::execute(thread_db* tdbb, DsqlCompilerScratch* /*dsqlScratch //---------------------- -void CreateShadowNode::print(string& text) const +string CreateShadowNode::internalPrint(NodePrinter& printer) const { - text.printf( - "CreateShadowNode\n" - " number: '%d'\n", - number); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, number); + NODE_PRINT(printer, manual); + NODE_PRINT(printer, conditional); + NODE_PRINT(printer, firstLength); + NODE_PRINT(printer, files); + + return "CreateShadowNode"; } bool CreateShadowNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -9641,12 +9692,13 @@ void CreateShadowNode::execute(thread_db* tdbb, DsqlCompilerScratch* /*dsqlScrat //---------------------- -void DropShadowNode::print(string& text) const +string DropShadowNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropShadowNode\n" - " number: '%d'\n", - number); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, number); + + return "DropShadowNode"; } bool DropShadowNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -9679,12 +9731,13 @@ void DropShadowNode::execute(thread_db* tdbb, DsqlCompilerScratch* /*dsqlScratch //---------------------- -void CreateRoleNode::print(string& text) const +string CreateRoleNode::internalPrint(NodePrinter& printer) const { - text.printf( - "CreateRoleNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + + return "CreateRoleNode"; } bool CreateRoleNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -9788,25 +9841,22 @@ bool CreateRoleNode::isItUserName(thread_db* tdbb, jrd_tra* transaction) //---------------------- -void MappingNode::print(string& text) const +string MappingNode::internalPrint(NodePrinter& printer) const { - const char* null = ""; + DdlNode::internalPrint(printer); - text.printf( - "MappingNode\n" - " op: '%s'\n" - " global: '%d'\n" - " mode: '%c'\n" - " plugin: '%s'\n" - " db: '%s'\n" - " fromType: '%s'\n" - " from: '%s'\n" - " role: '%d'\n" - " to: '%s'\n", - op, global, mode, - plugin ? plugin->c_str() : null, db ? db->c_str() : null, - fromType ? fromType->c_str() : null, from ? from->getString().c_str() : null, - role, to ? to->c_str() : null); + NODE_PRINT(printer, name); + NODE_PRINT(printer, plugin); + NODE_PRINT(printer, db); + NODE_PRINT(printer, fromType); + NODE_PRINT(printer, from); + NODE_PRINT(printer, to); + NODE_PRINT(printer, op); + NODE_PRINT(printer, mode); + NODE_PRINT(printer, global); + NODE_PRINT(printer, role); + + return "MappingNode"; } void MappingNode::validateAdmin() @@ -10182,12 +10232,13 @@ void MappingNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd //---------------------- -void DropRoleNode::print(string& text) const +string DropRoleNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropRoleNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + + return "DropRoleNode"; } bool DropRoleNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -10275,12 +10326,23 @@ Firebird::MetaName UserNode::upper(const Firebird::MetaName& str) //---------------------- -void CreateAlterUserNode::print(string& text) const +string CreateAlterUserNode::internalPrint(NodePrinter& printer) const { - text.printf( - "CreateAlterUserNode\n" - " name: '%s'\n", - name.c_str()); + UserNode::internalPrint(printer); + + //// FIXME-PRINT: NODE_PRINT(printer, properties); + NODE_PRINT(printer, name); + NODE_PRINT(printer, password); + NODE_PRINT(printer, firstName); + NODE_PRINT(printer, middleName); + NODE_PRINT(printer, lastName); + NODE_PRINT(printer, plugin); + NODE_PRINT(printer, comment); + NODE_PRINT(printer, adminRole); + NODE_PRINT(printer, active); + NODE_PRINT(printer, mode); + + return "CreateAlterUserNode"; } @@ -10422,12 +10484,14 @@ void CreateAlterUserNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra //---------------------- -void DropUserNode::print(string& text) const +string DropUserNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropUserNode\n" - " name: '%s'\n", - name.c_str()); + UserNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, plugin); + + return "DropUserNode"; } bool DropUserNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -10470,12 +10534,20 @@ void DropUserNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jr //---------------------- -void GrantRevokeNode::print(string& text) const +string GrantRevokeNode::internalPrint(NodePrinter& printer) const { - text.printf( - "GrantRevokeNode\n" - " isGrant: '%d'\n", - isGrant); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, isGrant); + NODE_PRINT(printer, privileges); + NODE_PRINT(printer, roles); + NODE_PRINT(printer, object); + NODE_PRINT(printer, users); + NODE_PRINT(printer, grantAdminOption); + NODE_PRINT(printer, grantor); + NODE_PRINT(printer, isDdl); + + return "GrantRevokeNode"; } bool GrantRevokeNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -11310,10 +11382,21 @@ void GrantRevokeNode::setFieldClassName(thread_db* tdbb, jrd_tra* transaction, //---------------------- -void AlterDatabaseNode::print(string& text) const +string AlterDatabaseNode::internalPrint(NodePrinter& printer) const { - text.printf( - "AlterDatabaseNode\n"); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, create); + NODE_PRINT(printer, createLength); + NODE_PRINT(printer, linger); + NODE_PRINT(printer, clauses); + NODE_PRINT(printer, differenceFile); + NODE_PRINT(printer, setDefaultCharSet); + NODE_PRINT(printer, setDefaultCollation); + NODE_PRINT(printer, files); + NODE_PRINT(printer, cryptPlugin); + + return "AlterDatabaseNode"; } bool AlterDatabaseNode::checkPermission(thread_db* tdbb, jrd_tra* transaction) diff --git a/src/dsql/DdlNodes.h b/src/dsql/DdlNodes.h index c8224019ed..18f8daf23d 100644 --- a/src/dsql/DdlNodes.h +++ b/src/dsql/DdlNodes.h @@ -30,6 +30,7 @@ #include "../dsql/BlrDebugWriter.h" #include "../dsql/Nodes.h" #include "../dsql/ExprNodes.h" +#include "../dsql/NodePrinter.h" #include "../common/classes/array.h" #include "../common/classes/ByteChunk.h" #include "../common/classes/Nullable.h" @@ -43,33 +44,55 @@ class RelationSourceNode; class ValueListNode; class SecDbContext; -struct BoolSourceClause +class BoolSourceClause : public Printable { +public: explicit BoolSourceClause(MemoryPool& p) : value(NULL), source(p) { } +public: + virtual Firebird::string internalPrint(NodePrinter& printer) const + { + NODE_PRINT(printer, value); + NODE_PRINT(printer, source); + + return "BoolSourceClause"; + } + +public: NestConst value; Firebird::string source; }; -struct ValueSourceClause +class ValueSourceClause : public Printable { +public: explicit ValueSourceClause(MemoryPool& p) : value(NULL), source(p) { } +public: + virtual Firebird::string internalPrint(NodePrinter& printer) const + { + NODE_PRINT(printer, value); + NODE_PRINT(printer, source); + + return "ValueSourceClause"; + } + +public: NestConst value; Firebird::string source; }; -class DbFileClause +class DbFileClause : public Printable { public: DbFileClause(MemoryPool& p, const DbFileClause& o) @@ -86,6 +109,16 @@ public: { } +public: + virtual Firebird::string internalPrint(NodePrinter& printer) const + { + NODE_PRINT(printer, name); + NODE_PRINT(printer, start); + NODE_PRINT(printer, length); + + return "DbFileClause"; + } + public: Firebird::string name; // File name SLONG start; // Starting page @@ -93,7 +126,7 @@ public: }; -class ExternalClause +class ExternalClause : public Printable { public: ExternalClause(MemoryPool& p, const ExternalClause& o) @@ -110,6 +143,16 @@ public: { } +public: + virtual Firebird::string internalPrint(NodePrinter& printer) const + { + NODE_PRINT(printer, name); + NODE_PRINT(printer, engine); + NODE_PRINT(printer, udfModule); + + return "Node"; + } + public: Firebird::string name; Firebird::MetaName engine; @@ -117,14 +160,14 @@ public: }; -class ParameterClause +class ParameterClause : public Printable { public: ParameterClause(MemoryPool& pool, dsql_fld* field, const Firebird::MetaName& aCollate, ValueSourceClause* aDefaultClause = NULL, ValueExprNode* aParameterExpr = NULL); public: - void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; public: Firebird::MetaName name; @@ -160,9 +203,14 @@ public: } public: - virtual void print(Firebird::string& text) const + virtual Firebird::string internalPrint(NodePrinter& printer) const { - text.printf("RecreateNode\n"); + Node::internalPrint(printer); + + NODE_PRINT(printer, createNode); + NODE_PRINT(printer, dropNode); + + return "RecreateNode"; } virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction) @@ -212,7 +260,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -244,7 +292,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -292,7 +340,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -353,7 +401,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -385,7 +433,7 @@ public: const Firebird::MetaName& functionName, const Firebird::MetaName& packageName); public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -430,7 +478,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -488,7 +536,7 @@ public: const Firebird::MetaName& procedureName, const Firebird::MetaName& packageName); public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -573,7 +621,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -647,7 +695,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -687,7 +735,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -747,7 +795,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -774,7 +822,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -813,7 +861,7 @@ public: const Firebird::MetaName& relationName, const Firebird::MetaName& fieldName, const Firebird::MetaName& newFieldName); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -851,7 +899,7 @@ public: const Firebird::MetaName& name); public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -883,7 +931,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -920,7 +968,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -972,7 +1020,7 @@ public: fb_sysflag sysFlag, SINT64 value, SLONG step); public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1015,7 +1063,7 @@ public: const Firebird::MetaName& name); public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1324,6 +1372,17 @@ public: const Firebird::MetaName& relationName, const Firebird::MetaName& fieldName); protected: + virtual Firebird::string internalPrint(NodePrinter& printer) const + { + DdlNode::internalPrint(printer); + + //// FIXME-PRINT: NODE_PRINT(printer, dsqlNode); + NODE_PRINT(printer, name); + //// FIXME-PRINT: NODE_PRINT(printer, clauses); + + return "RelationNode"; + } + void defineField(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction, AddColumnClause* clause, SSHORT position, const Firebird::ObjectsArray* pkcols); @@ -1369,7 +1428,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1397,7 +1456,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1428,7 +1487,7 @@ public: const Firebird::MetaName& globalName); public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1465,7 +1524,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1548,7 +1607,7 @@ public: const Definition& definition, Firebird::MetaName* referredIndexName = NULL); public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1579,7 +1638,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1605,7 +1664,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1634,7 +1693,7 @@ public: const Firebird::MetaName& name); public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1652,8 +1711,9 @@ public: class CreateFilterNode : public DdlNode { public: - struct NameNumber + class NameNumber : public Printable { + public: NameNumber(MemoryPool& p, const Firebird::MetaName& aName) : name(p, aName), number(0) @@ -1666,6 +1726,16 @@ public: { } + public: + virtual Firebird::string internalPrint(NodePrinter& printer) const + { + NODE_PRINT(printer, name); + NODE_PRINT(printer, number); + + return "NameNumber"; + } + + public: Firebird::MetaName name; SSHORT number; }; @@ -1682,7 +1752,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1711,7 +1781,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1739,7 +1809,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1768,7 +1838,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1793,7 +1863,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1834,7 +1904,7 @@ public: void validateAdmin(); public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1874,7 +1944,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1920,7 +1990,7 @@ public: { } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -1983,7 +2053,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -2020,7 +2090,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -2133,7 +2203,7 @@ public: return this; } - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); diff --git a/src/dsql/ExprNodes.cpp b/src/dsql/ExprNodes.cpp index 73450872c7..f81b65935e 100644 --- a/src/dsql/ExprNodes.cpp +++ b/src/dsql/ExprNodes.cpp @@ -114,10 +114,42 @@ void NodeRef::pass2(thread_db* tdbb, CompilerScratch* csb) //-------------------- -void ExprNode::print(string& /*text*/) const +void Printable::print(NodePrinter& printer) const { + NodePrinter subPrinter(printer.getIndent() + 1); + Firebird::string tag(internalPrint(subPrinter)); + printer.begin(tag); + printer.append(subPrinter); + printer.end(); } + +//-------------------- + + +string Node::internalPrint(NodePrinter& printer) const +{ + NODE_PRINT(printer, line); + NODE_PRINT(printer, column); + + return "Node"; +} + + +//-------------------- + + +string ExprNode::internalPrint(NodePrinter& printer) const +{ + Node::internalPrint(printer); + + NODE_PRINT(printer, nodFlags); + NODE_PRINT(printer, impureOffset); + + return "ExprNode"; +} + + bool ExprNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const { if (other->type != type) @@ -208,6 +240,40 @@ ExprNode* ExprNode::pass2(thread_db* tdbb, CompilerScratch* csb) //-------------------- +string ValueExprNode::internalPrint(NodePrinter& printer) const +{ + ExprNode::internalPrint(printer); + + NODE_PRINT(printer, nodScale); + NODE_PRINT(printer, nodDesc); + + return "ValueNode"; +} + + +//-------------------- + + +Firebird::string ValueListNode::internalPrint(NodePrinter& printer) const +{ + NODE_PRINT(printer, items); + return "ValueListNode"; +} + + +//-------------------- + + +Firebird::string RecSourceListNode::internalPrint(NodePrinter& printer) const +{ + NODE_PRINT(printer, items); + return "RecSourceListNode"; +} + + +//-------------------- + + static RegisterNode regArithmeticNodeAdd(blr_add); static RegisterNode regArithmeticNodeSubtract(blr_subtract); static RegisterNode regArithmeticNodeMultiply(blr_multiply); @@ -260,10 +326,17 @@ DmlNode* ArithmeticNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratc return node; } -void ArithmeticNode::print(string& text) const +string ArithmeticNode::internalPrint(NodePrinter& printer) const { - text.printf("ArithmeticNode %s (%d)", label.c_str(), (dialect1 ? 1 : 3)); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, blrOp); + NODE_PRINT(printer, dialect1); + NODE_PRINT(printer, label); + NODE_PRINT(printer, arg1); + NODE_PRINT(printer, arg2); + + return "ArithmeticNode"; } void ArithmeticNode::setParameterName(dsql_par* parameter) const @@ -2330,10 +2403,13 @@ ArrayNode::ArrayNode(MemoryPool& pool, FieldNode* aField) { } -void ArrayNode::print(string& text) const +string ArrayNode::internalPrint(NodePrinter& printer) const { - text = "ArrayNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, field); + + return "ArrayNode"; } ValueExprNode* ArrayNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -2367,10 +2443,13 @@ DmlNode* BoolAsValueNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScrat return node; } -void BoolAsValueNode::print(string& text) const +string BoolAsValueNode::internalPrint(NodePrinter& printer) const { - text = "BoolAsValueNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, boolean); + + return "BoolAsValueNode"; } ValueExprNode* BoolAsValueNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -2473,10 +2552,17 @@ DmlNode* CastNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb return node; } -void CastNode::print(string& text) const +string CastNode::internalPrint(NodePrinter& printer) const { - text.printf("CastNode"); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlAlias); + NODE_PRINT(printer, dsqlField); + NODE_PRINT(printer, castDesc); + NODE_PRINT(printer, source); + NODE_PRINT(printer, itemInfo); + + return "CastNode"; } ValueExprNode* CastNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -2753,10 +2839,13 @@ DmlNode* CoalesceNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* return node; } -void CoalesceNode::print(string& text) const +string CoalesceNode::internalPrint(NodePrinter& printer) const { - text = "CoalesceNode\n"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, args); + + return "CoalesceNode"; } ValueExprNode* CoalesceNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -2867,10 +2956,14 @@ CollateNode::CollateNode(MemoryPool& pool, ValueExprNode* aArg, const Firebird:: addDsqlChildNode(arg); } -void CollateNode::print(string& text) const +string CollateNode::internalPrint(NodePrinter& printer) const { - text = "CollateNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, arg); + NODE_PRINT(printer, collation); + + return "CollateNode"; } // Turn a collate clause into a cast clause. @@ -2960,10 +3053,14 @@ DmlNode* ConcatenateNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScrat return node; } -void ConcatenateNode::print(string& text) const +string ConcatenateNode::internalPrint(NodePrinter& printer) const { - text = "ConcatenateNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, arg1); + NODE_PRINT(printer, arg2); + + return "ConcatenateNode"; } void ConcatenateNode::setParameterName(dsql_par* parameter) const @@ -3218,10 +3315,11 @@ DmlNode* CurrentDateNode::parse(thread_db* /*tdbb*/, MemoryPool& pool, CompilerS return FB_NEW(pool) CurrentDateNode(pool); } -void CurrentDateNode::print(string& text) const +string CurrentDateNode::internalPrint(NodePrinter& printer) const { - text.printf("CurrentDateNode"); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + return "CurrentDateNode"; } void CurrentDateNode::setParameterName(dsql_par* parameter) const @@ -3311,10 +3409,13 @@ DmlNode* CurrentTimeNode::parse(thread_db* /*tdbb*/, MemoryPool& pool, CompilerS return FB_NEW(pool) CurrentTimeNode(pool, precision); } -void CurrentTimeNode::print(string& text) const +string CurrentTimeNode::internalPrint(NodePrinter& printer) const { - text.printf("CurrentTimeNode (%d)", precision); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, precision); + + return "CurrentTimeNode"; } void CurrentTimeNode::setParameterName(dsql_par* parameter) const @@ -3421,10 +3522,13 @@ DmlNode* CurrentTimeStampNode::parse(thread_db* /*tdbb*/, MemoryPool& pool, Comp return FB_NEW(pool) CurrentTimeStampNode(pool, precision); } -void CurrentTimeStampNode::print(string& text) const +string CurrentTimeStampNode::internalPrint(NodePrinter& printer) const { - text.printf("CurrentTimeStampNode (%d)", precision); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, precision); + + return "CurrentTimeStampNode"; } void CurrentTimeStampNode::setParameterName(dsql_par* parameter) const @@ -3518,10 +3622,11 @@ DmlNode* CurrentRoleNode::parse(thread_db* /*tdbb*/, MemoryPool& pool, CompilerS return FB_NEW(pool) CurrentRoleNode(pool); } -void CurrentRoleNode::print(string& text) const +string CurrentRoleNode::internalPrint(NodePrinter& printer) const { - text = "CurrentRoleNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + return "CurrentRoleNode"; } void CurrentRoleNode::setParameterName(dsql_par* parameter) const @@ -3613,10 +3718,11 @@ DmlNode* CurrentUserNode::parse(thread_db* /*tdbb*/, MemoryPool& pool, CompilerS return FB_NEW(pool) CurrentUserNode(pool); } -void CurrentUserNode::print(string& text) const +string CurrentUserNode::internalPrint(NodePrinter& printer) const { - text = "CurrentUserNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + return "CurrentUserNode"; } void CurrentUserNode::setParameterName(dsql_par* parameter) const @@ -3710,10 +3816,16 @@ DmlNode* DecodeNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* c return node; } -void DecodeNode::print(string& text) const +string DecodeNode::internalPrint(NodePrinter& printer) const { - text = "DecodeNode\n"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, label); + NODE_PRINT(printer, test); + NODE_PRINT(printer, conditions); + NODE_PRINT(printer, values); + + return "DecodeNode"; } ValueExprNode* DecodeNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -4079,10 +4191,13 @@ dsc* DerivedExprNode::execute(thread_db* tdbb, jrd_req* request) const //-------------------- -void DomainValidationNode::print(Firebird::string& text) const +string DomainValidationNode::internalPrint(NodePrinter& printer) const { - text.printf("DomainValidationNode"); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, domDesc); + + return "DomainValidationNode"; } ValueExprNode* DomainValidationNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -4169,10 +4284,14 @@ DmlNode* ExtractNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* return node; } -void ExtractNode::print(string& text) const +string ExtractNode::internalPrint(NodePrinter& printer) const { - text.printf("ExtractNode (%d)", blrSubOp); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, blrSubOp); + NODE_PRINT(printer, arg); + + return "ExtractNode"; } ValueExprNode* ExtractNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -4693,10 +4812,23 @@ DmlNode* FieldNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* cs return PAR_gen_field(tdbb, stream, id, byId); } -void FieldNode::print(string& text) const +string FieldNode::internalPrint(NodePrinter& printer) const { - text = "FieldNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlQualifier); + NODE_PRINT(printer, dsqlName); + NODE_PRINT(printer, dsqlContext); + NODE_PRINT(printer, dsqlField); + NODE_PRINT(printer, dsqlIndices); + NODE_PRINT(printer, fieldStream); + NODE_PRINT(printer, format); + NODE_PRINT(printer, fieldId); + NODE_PRINT(printer, byId); + NODE_PRINT(printer, dsqlCursorField); + NODE_PRINT(printer, cursorNumber); + + return "FieldNode"; } ValueExprNode* FieldNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -5676,10 +5808,19 @@ DmlNode* GenIdNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* cs return node; } -void GenIdNode::print(string& text) const +string GenIdNode::internalPrint(NodePrinter& printer) const { - text.printf("GenIdNode %s (%d)", generator.name.c_str(), (dialect1 ? 1 : 3)); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, dialect1); + NODE_PRINT(printer, generator); + NODE_PRINT(printer, arg); + NODE_PRINT(printer, step); + NODE_PRINT(printer, sysGen); + NODE_PRINT(printer, implicit); + NODE_PRINT(printer, identity); + + return "GenIdNode"; } ValueExprNode* GenIdNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -5884,10 +6025,13 @@ DmlNode* InternalInfoNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScra return node; } -void InternalInfoNode::print(string& text) const +string InternalInfoNode::internalPrint(NodePrinter& printer) const { - text = "InternalInfoNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, arg); + + return "InternalInfoNode"; } void InternalInfoNode::setParameterName(dsql_par* parameter) const @@ -6263,10 +6407,14 @@ void LiteralNode::genConstant(DsqlCompilerScratch* dsqlScratch, const dsc* desc, } } -void LiteralNode::print(string& text) const +string LiteralNode::internalPrint(NodePrinter& printer) const { - text.printf("LiteralNode"); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlStr); + NODE_PRINT(printer, litDesc); + + return "LiteralNode"; } // Turn an international string reference into internal subtype ID. @@ -6456,10 +6604,15 @@ dsc* LiteralNode::execute(thread_db* /*tdbb*/, jrd_req* /*request*/) const //-------------------- -void DsqlAliasNode::print(string& text) const +string DsqlAliasNode::internalPrint(NodePrinter& printer) const { - text.printf("DsqlAliasNode"); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, value); + NODE_PRINT(printer, implicitJoin); + + return "DsqlAliasNode"; } ValueExprNode* DsqlAliasNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -6497,10 +6650,14 @@ DsqlMapNode::DsqlMapNode(MemoryPool& pool, dsql_ctx* aContext, dsql_map* aMap) { } -void DsqlMapNode::print(string& text) const +string DsqlMapNode::internalPrint(NodePrinter& printer) const { - text.printf("DsqlMapNode"); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, context); + NODE_PRINT(printer, map); + + return "DsqlMapNode"; } ValueExprNode* DsqlMapNode::dsqlPass(DsqlCompilerScratch* /*dsqlScratch*/) @@ -6671,10 +6828,16 @@ DerivedFieldNode::DerivedFieldNode(MemoryPool& pool, const MetaName& aName, USHO addDsqlChildNode(value); } -void DerivedFieldNode::print(string& text) const +string DerivedFieldNode::internalPrint(NodePrinter& printer) const { - text.printf("DerivedFieldNode"); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, scope); + NODE_PRINT(printer, value); + NODE_PRINT(printer, context); + + return "DerivedFieldNode"; } ValueExprNode* DerivedFieldNode::dsqlPass(DsqlCompilerScratch* /*dsqlScratch*/) @@ -6880,10 +7043,13 @@ DmlNode* NegateNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* c return node; } -void NegateNode::print(string& text) const +string NegateNode::internalPrint(NodePrinter& printer) const { - text = "NegateNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, arg); + + return "NegateNode"; } void NegateNode::setParameterName(dsql_par* parameter) const @@ -7072,10 +7238,11 @@ DmlNode* NullNode::parse(thread_db* /*tdbb*/, MemoryPool& pool, CompilerScratch* return FB_NEW(pool) NullNode(pool); } -void NullNode::print(string& text) const +string NullNode::internalPrint(NodePrinter& printer) const { - text.printf("NullNode"); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + return "NullNode"; } void NullNode::setParameterName(dsql_par* parameter) const @@ -7147,10 +7314,15 @@ OrderNode::OrderNode(MemoryPool& pool, ValueExprNode* aValue) addDsqlChildNode(value); } -void OrderNode::print(string& text) const +string OrderNode::internalPrint(NodePrinter& printer) const { - text = "OrderNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, value); + NODE_PRINT(printer, descending); + NODE_PRINT(printer, nullsPlacement); + + return "OrderNode"; } OrderNode* OrderNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -7187,10 +7359,15 @@ OverNode::OverNode(MemoryPool& pool, AggNode* aAggExpr, ValueListNode* aPartitio addDsqlChildNode(order); } -void OverNode::print(string& text) const +string OverNode::internalPrint(NodePrinter& printer) const { - text = "OverNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, aggExpr); + NODE_PRINT(printer, partition); + NODE_PRINT(printer, order); + + return "OverNode"; } bool OverNode::dsqlAggregateFinder(AggregateFinder& visitor) @@ -7450,10 +7627,19 @@ DmlNode* ParameterNode::parse(thread_db* /*tdbb*/, MemoryPool& pool, CompilerScr return node; } -void ParameterNode::print(string& text) const +string ParameterNode::internalPrint(NodePrinter& printer) const { - text = "ParameterNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlParameterIndex); + NODE_PRINT(printer, dsqlParameter); + NODE_PRINT(printer, message); + NODE_PRINT(printer, argNumber); + NODE_PRINT(printer, argFlag); + NODE_PRINT(printer, argIndicator); + NODE_PRINT(printer, argInfo); + + return "ParameterNode"; } ValueExprNode* ParameterNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -7752,13 +7938,17 @@ DmlNode* RecordKeyNode::parse(thread_db* /*tdbb*/, MemoryPool& pool, CompilerScr return node; } -void RecordKeyNode::print(string& text) const +string RecordKeyNode::internalPrint(NodePrinter& printer) const { - text.printf("RecordKeyNode (%s)", - (blrOp == blr_dbkey ? "dbkey" : - blrOp == blr_record_version2 ? "record_version2" : "record_version")); + ValueExprNode::internalPrint(printer); - ExprNode::print(text); + NODE_PRINT(printer, blrOp); + NODE_PRINT(printer, dsqlQualifier); + NODE_PRINT(printer, dsqlRelation); + NODE_PRINT(printer, recStream); + NODE_PRINT(printer, aggregate); + + return "RecordKeyNode"; } // Resolve a dbkey to an available context. @@ -8464,10 +8654,14 @@ DmlNode* StrCaseNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* return node; } -void StrCaseNode::print(string& text) const +string StrCaseNode::internalPrint(NodePrinter& printer) const { - text.printf("StrCaseNode (%s)", (blrOp == blr_lowcase ? "lower" : "upper")); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, blrOp); + NODE_PRINT(printer, arg); + + return "StrCaseNode"; } ValueExprNode* StrCaseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -8657,10 +8851,14 @@ DmlNode* StrLenNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* c return node; } -void StrLenNode::print(string& text) const +string StrLenNode::internalPrint(NodePrinter& printer) const { - text.printf("StrLenNode (%d)", blrSubOp); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, blrSubOp); + NODE_PRINT(printer, arg); + + return "StrLenNode"; } ValueExprNode* StrLenNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -8919,10 +9117,19 @@ DmlNode* SubQueryNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* return node; } -void SubQueryNode::print(string& text) const +string SubQueryNode::internalPrint(NodePrinter& printer) const { - text = "SubQueryNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, blrOp); + NODE_PRINT(printer, ownSavepoint); + NODE_PRINT(printer, dsqlRse); + NODE_PRINT(printer, rse); + NODE_PRINT(printer, value1); + NODE_PRINT(printer, value2); + NODE_PRINT(printer, rsb); + + return "SubQueryNode"; } ValueExprNode* SubQueryNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -9372,10 +9579,15 @@ DmlNode* SubstringNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch return node; } -void SubstringNode::print(string& text) const +string SubstringNode::internalPrint(NodePrinter& printer) const { - text = "SubstringNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, expr); + NODE_PRINT(printer, start); + NODE_PRINT(printer, length); + + return "SubstringNode"; } ValueExprNode* SubstringNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -9711,10 +9923,15 @@ DmlNode* SubstringSimilarNode::parse(thread_db* tdbb, MemoryPool& pool, Compiler return node; } -void SubstringSimilarNode::print(string& text) const +string SubstringSimilarNode::internalPrint(NodePrinter& printer) const { - text = "SubstringSimilarNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, expr); + NODE_PRINT(printer, pattern); + NODE_PRINT(printer, escape); + + return "SubstringSimilarNode"; } void SubstringSimilarNode::setParameterName(dsql_par* parameter) const @@ -9953,10 +10170,15 @@ DmlNode* SysFuncCallNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScrat return node; } -void SysFuncCallNode::print(string& text) const +string SysFuncCallNode::internalPrint(NodePrinter& printer) const { - text = "SysFuncCallNode\n\tname: " + string(name.c_str()); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, dsqlSpecialSyntax); + NODE_PRINT(printer, args); + + return "SysFuncCallNode"; } void SysFuncCallNode::setParameterName(dsql_par* parameter) const @@ -10141,10 +10363,15 @@ DmlNode* TrimNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb return node; } -void TrimNode::print(string& text) const +string TrimNode::internalPrint(NodePrinter& printer) const { - text = "TrimNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, where); + NODE_PRINT(printer, value); + NODE_PRINT(printer, trimChars); + + return "TrimNode"; } ValueExprNode* TrimNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -10545,10 +10772,14 @@ DmlNode* UdfCallNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* return node; } -void UdfCallNode::print(string& text) const +string UdfCallNode::internalPrint(NodePrinter& printer) const { - text = "UdfCallNode\n\tname: " + name.toString(); - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, args); + + return "UdfCallNode"; } void UdfCallNode::setParameterName(dsql_par* parameter) const @@ -11074,10 +11305,15 @@ DmlNode* ValueIfNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* return node; } -void ValueIfNode::print(string& text) const +string ValueIfNode::internalPrint(NodePrinter& printer) const { - text = "ValueIfNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, condition); + NODE_PRINT(printer, trueValue); + NODE_PRINT(printer, falseValue); + + return "ValueIfNode"; } ValueExprNode* ValueIfNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -11192,10 +11428,17 @@ DmlNode* VariableNode::parse(thread_db* /*tdbb*/, MemoryPool& pool, CompilerScra return node; } -void VariableNode::print(string& text) const +string VariableNode::internalPrint(NodePrinter& printer) const { - text = "VariableNode"; - ExprNode::print(text); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlName); + NODE_PRINT(printer, dsqlVar); + NODE_PRINT(printer, varId); + NODE_PRINT(printer, varDecl); + NODE_PRINT(printer, varInfo); + + return "VariableNode"; } ValueExprNode* VariableNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -11332,6 +11575,31 @@ dsc* VariableNode::execute(thread_db* tdbb, jrd_req* request) const //-------------------- +Firebird::string RowsClause::internalPrint(NodePrinter& printer) const +{ + NODE_PRINT(printer, length); + NODE_PRINT(printer, skip); + + return "RowsClause"; +} + + +//-------------------- + + +Firebird::string GeneratorItem::internalPrint(NodePrinter& printer) const +{ + NODE_PRINT(printer, id); + NODE_PRINT(printer, name); + NODE_PRINT(printer, secName); + + return "GeneratorItem"; +} + + +//-------------------- + + // Firebird provides transparent conversion from string to date in // contexts where it makes sense. This macro checks a descriptor to // see if it is something that *could* represent a date value diff --git a/src/dsql/ExprNodes.h b/src/dsql/ExprNodes.h index fe7712fe3d..c1fca2e6d2 100644 --- a/src/dsql/ExprNodes.h +++ b/src/dsql/ExprNodes.h @@ -25,13 +25,14 @@ #include "../jrd/blr.h" #include "../dsql/Nodes.h" +#include "../dsql/NodePrinter.h" #include "../dsql/pass1_proto.h" class SysFunction; namespace Jrd { -struct ItemInfo; +class ItemInfo; class DeclareVariableNode; class RecordSource; class RelationSourceNode; @@ -46,7 +47,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -95,7 +96,7 @@ class ArrayNode : public TypedNode public: ArrayNode(MemoryPool& pool, FieldNode* aField); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); // This class is used only in the parser. It turns in a FieldNode in dsqlPass. @@ -144,7 +145,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* /*parameter*/) const @@ -171,7 +172,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -208,7 +209,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -231,7 +232,7 @@ class CollateNode : public TypedNode public: CollateNode(MemoryPool& pool, ValueExprNode* aArg, const Firebird::MetaName& aCollation); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); static ValueExprNode* pass1Collate(DsqlCompilerScratch* dsqlScratch, ValueExprNode* input, @@ -287,7 +288,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -316,7 +317,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void setParameterName(dsql_par* parameter) const; virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); @@ -339,7 +340,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -366,7 +367,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -392,7 +393,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -415,7 +416,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -448,7 +449,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -484,9 +485,15 @@ public: // This is a non-DSQL node. - virtual void print(Firebird::string& /*text*/) const + virtual Firebird::string internalPrint(NodePrinter& printer) const { - fb_assert(false); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, arg); + NODE_PRINT(printer, internalStreamList); + NODE_PRINT(printer, cursorNumber); + + return "DerivedExprNode"; } virtual void setParameterName(dsql_par* /*parameter*/) const @@ -534,7 +541,7 @@ public: domDesc.clear(); } - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* /*parameter*/) const @@ -561,7 +568,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -590,7 +597,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); ValueExprNode* internalDsqlPass(DsqlCompilerScratch* dsqlScratch, RecordSourceNode** list); @@ -665,7 +672,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -709,7 +716,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -733,7 +740,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); static void genConstant(DsqlCompilerScratch* dsqlScratch, const dsc* desc, bool negateValue); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -772,7 +779,7 @@ public: addDsqlChildNode(value); } - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; @@ -808,7 +815,7 @@ class DsqlMapNode : public TypedNode public: DsqlMapNode(MemoryPool& pool, dsql_ctx* aContext, dsql_map* aMap); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool dsqlAggregateFinder(AggregateFinder& visitor); @@ -852,7 +859,7 @@ public: DerivedFieldNode(MemoryPool& pool, const Firebird::MetaName& aName, USHORT aScope, ValueExprNode* aValue); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool dsqlAggregateFinder(AggregateFinder& visitor); @@ -898,7 +905,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -926,7 +933,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void setParameterName(dsql_par* parameter) const; virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); @@ -950,7 +957,7 @@ public: OrderNode(MemoryPool& pool, ValueExprNode* aValue); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual OrderNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool dsqlMatch(const ExprNode* other, bool ignoreMapCast) const; @@ -1001,7 +1008,7 @@ public: explicit OverNode(MemoryPool& pool, AggNode* aAggExpr = NULL, ValueListNode* aPartition = NULL, ValueListNode* aOrder = NULL); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool dsqlAggregateFinder(AggregateFinder& visitor); @@ -1037,7 +1044,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* /*parameter*/) const @@ -1073,7 +1080,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool dsqlAggregate2Finder(Aggregate2Finder& visitor); @@ -1152,9 +1159,14 @@ public: // This is a non-DSQL node. - virtual void print(Firebird::string& /*text*/) const + virtual Firebird::string internalPrint(NodePrinter& printer) const { - fb_assert(false); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, field); + NODE_PRINT(printer, subscripts); + + return "ScalarNode"; } virtual void setParameterName(dsql_par* /*parameter*/) const @@ -1199,9 +1211,14 @@ public: // This is a non-DSQL node. - virtual void print(Firebird::string& /*text*/) const + virtual Firebird::string internalPrint(NodePrinter& printer) const { - fb_assert(false); + ValueExprNode::internalPrint(printer); + + NODE_PRINT(printer, stmt); + NODE_PRINT(printer, expr); + + return "StmtExprNode"; } virtual void setParameterName(dsql_par* /*parameter*/) const @@ -1238,7 +1255,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -1266,7 +1283,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -1296,7 +1313,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -1352,7 +1369,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -1383,7 +1400,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -1412,7 +1429,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -1441,7 +1458,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -1471,7 +1488,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -1503,7 +1520,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual bool setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -1535,7 +1552,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void setParameterName(dsql_par* parameter) const; virtual void genBlr(DsqlCompilerScratch* dsqlScratch); diff --git a/src/dsql/NodePrinter.h b/src/dsql/NodePrinter.h new file mode 100644 index 0000000000..d9bb942fa5 --- /dev/null +++ b/src/dsql/NodePrinter.h @@ -0,0 +1,331 @@ +/* + * The contents of this file are subject to the Initial + * Developer's Public License Version 1.0 (the "License"); + * you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. + * + * Software distributed under the License is distributed AS IS, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. + * See the License for the specific language governing rights + * and limitations under the License. + * + * The Original Code was created by Adriano dos Santos Fernandes + * for the Firebird Open Source RDBMS project. + * + * Copyright (c) 2015 Adriano dos Santos Fernandes + * and all contributors signed below. + * + * All Rights Reserved. + * Contributor(s): ______________________________________. + */ + +#ifndef DSQL_NODE_PRINTER_H +#define DSQL_NODE_PRINTER_H + +#include "../dsql/Nodes.h" + +#define NODE_PRINT(var, property) var.print(STRINGIZE(property), property) + +namespace Jrd { + + +class NodePrinter +{ +public: + NodePrinter(unsigned aIndent = 0) + : indent(aIndent) + { + } + +public: + void begin(const Firebird::string& s) + { + printIndent(); + text += "<"; + text += s; + text += ">\n"; + + ++indent; + stack.push(s); + } + + void end() + { + Firebird::string s = stack.pop(); + + --indent; + + printIndent(); + text += "\n"; + } + + void print(const Firebird::string& s, const Firebird::MetaName& value) + { + printIndent(); + + text += "<"; + text += s; + text += ">"; + text += value.c_str(); + text += "\n"; + } + + void print(const Firebird::string& s, const Firebird::QualifiedName& value) + { + printIndent(); + + text += "<"; + text += s; + text += ">"; + text += value.toString(); + text += "\n"; + } + + void print(const Firebird::string&, const IntlString&) + { + //// FIXME-PRINT: + } + + void print(const Firebird::string& s, const Firebird::string& value) + { + printIndent(); + + text += "<"; + text += s; + text += ">"; + text += value; + text += "\n"; + } + + void print(const Firebird::string& s, bool value) + { + printIndent(); + + text += "<"; + text += s; + text += ">"; + text += value ? "true" : "false"; + text += "\n"; + } + + void print(const Firebird::string& s, SINT64 value) + { + printIndent(); + + Firebird::string temp; + temp.printf("<%s>%"QUADFORMAT"d\n", s.c_str(), value, s.c_str()); + text += temp; + } + + void print(const Firebird::string& s, int value) + { + print(s, (SINT64) value); + } + + void print(const Firebird::string& s, unsigned value) + { + print(s, (SINT64) value); + } + + void print(const Firebird::string& s, USHORT value) + { + print(s, (SINT64) value); + } + + void print(const Firebird::string& s, SSHORT value) + { + print(s, (SINT64) value); + } + + void print(const Firebird::string&, const Firebird::UCharBuffer&) + { + //// FIXME-PRINT: + } + + void print(const Firebird::string&, const dsql_ctx&) + { + //// FIXME-PRINT: + } + + void print(const Firebird::string&, const dsql_var&) + { + //// FIXME-PRINT: + } + + void print(const Firebird::string&, const dsql_fld&) + { + //// FIXME-PRINT: + } + + void print(const Firebird::string&, const dsql_map&) + { + //// FIXME-PRINT: + } + + void print(const Firebird::string&, const dsql_par&) + { + //// FIXME-PRINT: + } + + void print(const Firebird::string&, const ImplicitJoin&) + { + //// FIXME-PRINT: + } + + void print(const Firebird::string&, const dsc&) + { + //// FIXME-PRINT: + } + + void print(const Firebird::string&, const Format&) + { + //// FIXME-PRINT: + } + + void print(const Firebird::string&, const GeneratorItem&) + { + //// FIXME-PRINT: + } + + void print(const Firebird::string&, const RecordSource& recordSource) + { + //// FIXME-PRINT: + } + + void print(const Firebird::string&, const Cursor&) + { + //// FIXME-PRINT: + } + + template + void print(const Firebird::string& s, const Firebird::Array& array) + { + begin(s); + + for (const T* i = array.begin(); i != array.end(); ++i) + { + Firebird::string s2; + s2.printf("%d", i - array.begin()); + print(s2, *i); + } + + end(); + } + + template + void print(const Firebird::string& s, const Firebird::ObjectsArray& array) + { + begin(s); + + unsigned n = 0; + + for (typename Firebird::ObjectsArray::const_iterator i = array.begin(); + i != array.end(); + ++i, ++n) + { + Firebird::string s2; + s2.printf("%d", n); + print(s2, *i); + } + + end(); + } + + template + void print(const Firebird::string& s, const T* array) + { + if (array) + print(s, *array); + } + + template + void print(const Firebird::string& s, const BaseNullable& nullable) + { + if (nullable.specified) + print(s, nullable.value); + } + + template + void print(const Firebird::string&, const Firebird::Pair&) + { + //// FIXME-PRINT: + } + + template + void print(const Firebird::string& s, const NestConst& ptr) + { + print(s, ptr.getObject()); + } + + void print(const Firebird::string& s, const Printable* printable) + { + printIndent(); + text += "<"; + text += s; + + if (!printable) + { + text += " />\n"; + return; + } + + text += ">\n"; + + ++indent; + printable->print(*this); + --indent; + + printIndent(); + text += "\n"; + } + + void print(const Firebird::string& s, const Printable& printable) + { + print(s, &printable); + } + + void append(const NodePrinter& subPrinter) + { + text += subPrinter.text; + } + + unsigned getIndent() const + { + return indent; + } + + const Firebird::string& getText() const + { + return text; + } + +private: + void printIndent() + { + for (unsigned i = 0; i < indent; ++i) + text += "\t"; + } + +private: + unsigned indent; + Firebird::ObjectsArray stack; + Firebird::string text; +}; + + +} // namespace Jrd + +#endif // DSQL_NODE_PRINTER_H diff --git a/src/dsql/Nodes.h b/src/dsql/Nodes.h index 112893cdd2..6685b9410f 100644 --- a/src/dsql/Nodes.h +++ b/src/dsql/Nodes.h @@ -34,6 +34,8 @@ namespace Jrd { class AggregateSort; class CompilerScratch; class Cursor; +class Node; +class NodePrinter; class ExprNode; class OptimizerBlk; class OptimizerRetrieval; @@ -68,6 +70,20 @@ typedef Firebird::SortedArray SortedStreamList; typedef Firebird::Array > NestValueArray; +class Printable +{ +public: + virtual ~Printable() + { + } + +public: + void print(NodePrinter& printer) const; + + virtual Firebird::string internalPrint(NodePrinter& printer) const = 0; +}; + + template class RegisterNode { @@ -89,7 +105,7 @@ public: }; -class Node : public Firebird::PermanentStorage +class Node : public Firebird::PermanentStorage, public Printable { public: explicit Node(MemoryPool& pool) @@ -139,7 +155,7 @@ public: doDsqlPass(dsqlScratch, target, node); } - virtual void print(Firebird::string& text) const = 0; + virtual Firebird::string internalPrint(NodePrinter& printer) const = 0; virtual Node* dsqlPass(DsqlCompilerScratch* /*dsqlScratch*/) { @@ -506,6 +522,8 @@ public: *node = (*node)->pass2(tdbb, csb); } + virtual Firebird::string internalPrint(NodePrinter& printer) const = 0; + virtual bool dsqlAggregateFinder(AggregateFinder& visitor) { bool ret = false; @@ -619,7 +637,6 @@ public: return streams.exist(stream); } - virtual void print(Firebird::string& text) const; virtual bool dsqlMatch(const ExprNode* other, bool ignoreMapCast) const; virtual ExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -759,6 +776,9 @@ public: nodDesc.clear(); } +public: + virtual Firebird::string internalPrint(NodePrinter& printer) const = 0; + virtual ValueExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) { ExprNode::dsqlPass(dsqlScratch); @@ -901,7 +921,7 @@ public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const = 0; virtual bool dsqlAggregateFinder(AggregateFinder& visitor); virtual bool dsqlAggregate2Finder(Aggregate2Finder& visitor); @@ -1030,6 +1050,8 @@ public: stream = value; } + virtual Firebird::string internalPrint(NodePrinter& printer) const = 0; + virtual RecordSourceNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) { ExprNode::dsqlPass(dsqlScratch); @@ -1104,11 +1126,6 @@ public: { } - virtual void print(Firebird::string& /*text*/) const - { - fb_assert(false); - } - virtual void genBlr(DsqlCompilerScratch* /*dsqlScratch*/) { fb_assert(false); @@ -1160,6 +1177,8 @@ public: resetChildNodes(); } + virtual Firebird::string internalPrint(NodePrinter& printer) const; + virtual ValueListNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) { ValueListNode* node = FB_NEW(getPool()) ValueListNode(getPool(), items.getCount()); @@ -1231,6 +1250,8 @@ public: return this; } + virtual Firebird::string internalPrint(NodePrinter& printer) const; + virtual RecSourceListNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual RecSourceListNode* dsqlFieldRemapper(FieldRemapper& visitor) @@ -1491,7 +1512,7 @@ public: static StmtNode* make(MemoryPool& pool, DsqlCompilerScratch* dsqlScratch, StmtNode* node); public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void genBlr(DsqlCompilerScratch* dsqlScratch); private: @@ -1507,7 +1528,7 @@ struct ScaledNumber }; -class RowsClause : public Firebird::PermanentStorage +class RowsClause : public Firebird::PermanentStorage, public Printable { public: explicit RowsClause(MemoryPool& pool) @@ -1517,13 +1538,16 @@ public: { } +public: + virtual Firebird::string internalPrint(NodePrinter& printer) const; + public: NestConst length; NestConst skip; }; -class GeneratorItem +class GeneratorItem : public Printable { public: GeneratorItem(Firebird::MemoryPool& pool, const Firebird::MetaName& name) @@ -1538,6 +1562,10 @@ public: return *this; } +public: + virtual Firebird::string internalPrint(NodePrinter& printer) const; + +public: SLONG id; Firebird::MetaName name; Firebird::MetaName secName; diff --git a/src/dsql/PackageNodes.epp b/src/dsql/PackageNodes.epp index dbd6623ed1..1b555202a3 100644 --- a/src/dsql/PackageNodes.epp +++ b/src/dsql/PackageNodes.epp @@ -361,36 +361,19 @@ namespace //---------------------- -void CreateAlterPackageNode::print(string& text) const +string CreateAlterPackageNode::internalPrint(NodePrinter& printer) const { - fb_assert(items); + DdlNode::internalPrint(printer); - text.printf( - "CreateAlterPackageNode\n" - " name: '%s' create: %d alter: %d\n" - " Items:\n" - "--------\n", - name.c_str(), create, alter); + NODE_PRINT(printer, name); + NODE_PRINT(printer, create); + NODE_PRINT(printer, alter); + NODE_PRINT(printer, source); + //// FIXME-PRINT: NODE_PRINT(printer, items); + NODE_PRINT(printer, functionNames); + NODE_PRINT(printer, procedureNames); - for (unsigned i = 0; i < items->getCount(); ++i) - { - string item; - - switch ((*items)[i].type) - { - case Item::FUNCTION: - (*items)[i].function->print(item); - break; - - case Item::PROCEDURE: - (*items)[i].procedure->print(item); - break; - } - - text += item; - } - - text += "--------\n"; + return "CreateAlterPackageNode"; } @@ -629,12 +612,14 @@ bool CreateAlterPackageNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch* //---------------------- -void DropPackageNode::print(string& text) const +string DropPackageNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropPackageNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, silent); + + return "DropPackageNode"; } @@ -728,62 +713,16 @@ void DropPackageNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, //---------------------- -void CreatePackageBodyNode::print(string& text) const +string CreatePackageBodyNode::internalPrint(NodePrinter& printer) const { - fb_assert(items); + DdlNode::internalPrint(printer); - text.printf( - "CreatePackageBodyNode\n" - " name: '%s'\n" - " declaredItems:\n" - "--------\n", - name.c_str()); + NODE_PRINT(printer, name); + NODE_PRINT(printer, source); + //// FIXME-PRINT: NODE_PRINT(printer, declaredItems); + //// FIXME-PRINT: NODE_PRINT(printer, items); - if (declaredItems) - { - for (unsigned i = 0; i < declaredItems->getCount(); ++i) - { - string item; - - switch ((*declaredItems)[i].type) - { - case CreateAlterPackageNode::Item::FUNCTION: - (*declaredItems)[i].function->print(item); - break; - - case CreateAlterPackageNode::Item::PROCEDURE: - (*declaredItems)[i].procedure->print(item); - break; - } - - text += item; - } - } - - text += - "--------\n" - " items:\n" - "--------\n"; - - for (unsigned i = 0; i < items->getCount(); ++i) - { - string item; - - switch ((*items)[i].type) - { - case CreateAlterPackageNode::Item::FUNCTION: - (*items)[i].function->print(item); - break; - - case CreateAlterPackageNode::Item::PROCEDURE: - (*items)[i].procedure->print(item); - break; - } - - text += item; - } - - text += "--------\n"; + return "CreatePackageBodyNode"; } @@ -1092,12 +1031,14 @@ void CreatePackageBodyNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlSc //---------------------- -void DropPackageBodyNode::print(string& text) const +string DropPackageBodyNode::internalPrint(NodePrinter& printer) const { - text.printf( - "DropPackageBodyNode\n" - " name: '%s'\n", - name.c_str()); + DdlNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, silent); + + return "DropPackageBodyNode"; } diff --git a/src/dsql/PackageNodes.h b/src/dsql/PackageNodes.h index 59a013aede..4920fa6ec7 100644 --- a/src/dsql/PackageNodes.h +++ b/src/dsql/PackageNodes.h @@ -83,7 +83,7 @@ public: public: virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -126,7 +126,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -161,7 +161,7 @@ public: public: virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); @@ -193,7 +193,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool checkPermission(thread_db* tdbb, jrd_tra* transaction); virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction); diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index fc7e7a64dd..47a27fe10d 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -240,12 +240,13 @@ StmtNode* SavepointEncloseNode::make(MemoryPool& pool, DsqlCompilerScratch* dsql return node; } -void SavepointEncloseNode::print(string& text) const +string SavepointEncloseNode::internalPrint(NodePrinter& printer) const { - text = "SavepointEncloseNode\n"; - string s; - stmt->print(s); - text += s; + DsqlOnlyStmtNode::internalPrint(printer); + + NODE_PRINT(printer, stmt); + + return "SavepointEncloseNode"; } void SavepointEncloseNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -329,9 +330,16 @@ AssignmentNode* AssignmentNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return node; } -void AssignmentNode::print(string& text) const +string AssignmentNode::internalPrint(NodePrinter& printer) const { - text = "AssignmentNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, asgnFrom); + NODE_PRINT(printer, asgnTo); + NODE_PRINT(printer, missing); + NODE_PRINT(printer, missing2); + + return "AssignmentNode"; } void AssignmentNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -458,10 +466,14 @@ StmtNode* BlockNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return node; } -void BlockNode::print(string& text) const +string BlockNode::internalPrint(NodePrinter& printer) const { - text = "BlockNode"; - // print handlers, too? + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, action); + NODE_PRINT(printer, handlers); + + return "BlockNode"; } void BlockNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -769,9 +781,14 @@ CompoundStmtNode* CompoundStmtNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return node; } -void CompoundStmtNode::print(string& text) const +string CompoundStmtNode::internalPrint(NodePrinter& printer) const { - text = "CompoundStmtNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, statements); + NODE_PRINT(printer, onlyAssignments); + + return "CompoundStmtNode"; } void CompoundStmtNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -904,9 +921,15 @@ ContinueLeaveNode* ContinueLeaveNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return this; } -void ContinueLeaveNode::print(string& text) const +string ContinueLeaveNode::internalPrint(NodePrinter& printer) const { - text = "ContinueLeaveNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, blrOp); + NODE_PRINT(printer, labelNumber); + NODE_PRINT(printer, dsqlLabelName); + + return "ContinueLeaveNode"; } void ContinueLeaveNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -1002,9 +1025,19 @@ CursorStmtNode* CursorStmtNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return this; } -void CursorStmtNode::print(string& text) const +string CursorStmtNode::internalPrint(NodePrinter& printer) const { - text = "CursorStmtNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlName); + NODE_PRINT(printer, dsqlIntoStmt); + NODE_PRINT(printer, cursorOp); + NODE_PRINT(printer, cursorNumber); + NODE_PRINT(printer, scrollOp); + NODE_PRINT(printer, scrollExpr); + NODE_PRINT(printer, intoStmt); + + return "CursorStmtNode"; } void CursorStmtNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -1211,9 +1244,20 @@ DeclareCursorNode* DeclareCursorNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return this; } -void DeclareCursorNode::print(string& text) const +string DeclareCursorNode::internalPrint(NodePrinter& printer) const { - text = "DeclareCursorNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlCursorType); + NODE_PRINT(printer, dsqlScroll); + NODE_PRINT(printer, dsqlName); + NODE_PRINT(printer, dsqlSelect); + NODE_PRINT(printer, rse); + NODE_PRINT(printer, refs); + NODE_PRINT(printer, cursorNumber); + NODE_PRINT(printer, cursor); + + return "DeclareCursorNode"; } void DeclareCursorNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -1422,9 +1466,15 @@ void DeclareSubFuncNode::parseParameters(thread_db* tdbb, MemoryPool& pool, Comp } } -void DeclareSubFuncNode::print(string& text) const +string DeclareSubFuncNode::internalPrint(NodePrinter& printer) const { - text = "DeclareSubFuncNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, dsqlDeterministic); + NODE_PRINT(printer, dsqlBlock); + + return "DeclareSubFuncNode"; } DeclareSubFuncNode* DeclareSubFuncNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -1699,9 +1749,14 @@ void DeclareSubProcNode::parseParameters(thread_db* tdbb, MemoryPool& pool, Comp } } -void DeclareSubProcNode::print(string& text) const +string DeclareSubProcNode::internalPrint(NodePrinter& printer) const { - text = "DeclareSubProcNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, name); + NODE_PRINT(printer, dsqlBlock); + + return "DeclareSubProcNode"; } DeclareSubProcNode* DeclareSubProcNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -1876,9 +1931,15 @@ DeclareVariableNode* DeclareVariableNode::dsqlPass(DsqlCompilerScratch* /*dsqlSc return this; } -void DeclareVariableNode::print(string& text) const +string DeclareVariableNode::internalPrint(NodePrinter& printer) const { - text = "DeclareVariableNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlDef); + NODE_PRINT(printer, varId); + NODE_PRINT(printer, varDesc); + + return "DeclareVariableNode"; } void DeclareVariableNode::genBlr(DsqlCompilerScratch* /*dsqlScratch*/) @@ -2028,9 +2089,24 @@ StmtNode* EraseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return SavepointEncloseNode::make(getPool(), dsqlScratch, ret); } -void EraseNode::print(string& text) const +string EraseNode::internalPrint(NodePrinter& printer) const { - text = "EraseNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlRelation); + NODE_PRINT(printer, dsqlBoolean); + NODE_PRINT(printer, dsqlPlan); + NODE_PRINT(printer, dsqlOrder); + NODE_PRINT(printer, dsqlRows); + NODE_PRINT(printer, dsqlCursorName); + NODE_PRINT(printer, dsqlReturning); + NODE_PRINT(printer, dsqlRse); + NODE_PRINT(printer, dsqlContext); + NODE_PRINT(printer, statement); + NODE_PRINT(printer, subStatement); + NODE_PRINT(printer, stream); + + return "EraseNode"; } void EraseNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -2422,9 +2498,14 @@ ErrorHandlerNode* ErrorHandlerNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return node; } -void ErrorHandlerNode::print(string& text) const +string ErrorHandlerNode::internalPrint(NodePrinter& printer) const { - text = "ErrorHandlerNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, action); + NODE_PRINT(printer, conditions); + + return "ErrorHandlerNode"; } void ErrorHandlerNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -2686,9 +2767,19 @@ ValueListNode* ExecProcedureNode::explodeOutputs(DsqlCompilerScratch* dsqlScratc return output; } -void ExecProcedureNode::print(string& text) const +string ExecProcedureNode::internalPrint(NodePrinter& printer) const { - text = "ExecProcedureNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlName); + NODE_PRINT(printer, inputSources); + NODE_PRINT(printer, inputTargets); + NODE_PRINT(printer, inputMessage); + NODE_PRINT(printer, outputSources); + NODE_PRINT(printer, outputTargets); + NODE_PRINT(printer, outputMessage); + + return "ExecProcedureNode"; } void ExecProcedureNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -3121,9 +3212,25 @@ StmtNode* ExecStatementNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return SavepointEncloseNode::make(getPool(), dsqlScratch, node); } -void ExecStatementNode::print(string& text) const +string ExecStatementNode::internalPrint(NodePrinter& printer) const { - text = "ExecStatementNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlLabelName); + NODE_PRINT(printer, dsqlLabelNumber); + NODE_PRINT(printer, sql); + NODE_PRINT(printer, dataSource); + NODE_PRINT(printer, userName); + NODE_PRINT(printer, password); + NODE_PRINT(printer, role); + NODE_PRINT(printer, innerStmt); + NODE_PRINT(printer, inputs); + NODE_PRINT(printer, outputs); + NODE_PRINT(printer, useCallerPrivs); + NODE_PRINT(printer, traScope); + NODE_PRINT(printer, inputNames); + + return "ExecStatementNode"; } void ExecStatementNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -3418,9 +3525,15 @@ IfNode* IfNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return node; } -void IfNode::print(string& text) const +string IfNode::internalPrint(NodePrinter& printer) const { - text = "IfNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, condition); + NODE_PRINT(printer, trueAction); + NODE_PRINT(printer, falseAction); + + return "IfNode"; } void IfNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -3506,9 +3619,14 @@ InAutonomousTransactionNode* InAutonomousTransactionNode::dsqlPass(DsqlCompilerS return node; } -void InAutonomousTransactionNode::print(string& text) const +string InAutonomousTransactionNode::internalPrint(NodePrinter& printer) const { - text = "InAutonomousTransactionNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, action); + NODE_PRINT(printer, impureOffset); + + return "InAutonomousTransactionNode"; } void InAutonomousTransactionNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -3706,9 +3824,15 @@ InitVariableNode* InitVariableNode::dsqlPass(DsqlCompilerScratch* /*dsqlScratch* return this; } -void InitVariableNode::print(string& text) const +string InitVariableNode::internalPrint(NodePrinter& printer) const { - text = "InitVariableNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, varId); + NODE_PRINT(printer, varDecl); + NODE_PRINT(printer, varInfo); + + return "InitVariableNode"; } void InitVariableNode::genBlr(DsqlCompilerScratch* /*dsqlScratch*/) @@ -3864,27 +3988,16 @@ ExecBlockNode* ExecBlockNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return node; } -void ExecBlockNode::print(string& text) const +string ExecBlockNode::internalPrint(NodePrinter& printer) const { - text = "ExecBlockNode\n"; + StmtNode::internalPrint(printer); - text += " Returns:\n"; + NODE_PRINT(printer, parameters); + NODE_PRINT(printer, returns); + NODE_PRINT(printer, localDeclList); + NODE_PRINT(printer, body); - for (FB_SIZE_T i = 0; i < returns.getCount(); ++i) - { - const ParameterClause* parameter = returns[i]; - - string s; - parameter->print(s); - text += " " + s + "\n"; - } - - if (localDeclList) - { - string s; - localDeclList->print(s); - text += s + "\n"; - } + return "ExecBlockNode"; } void ExecBlockNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -4128,9 +4241,15 @@ StmtNode* ExceptionNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return SavepointEncloseNode::make(getPool(), dsqlScratch, node); } -void ExceptionNode::print(string& text) const +string ExceptionNode::internalPrint(NodePrinter& printer) const { - text.printf("ExceptionNode: Name: %s", (exception ? exception->name.c_str() : "")); + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, messageExpr); + NODE_PRINT(printer, parameters); + NODE_PRINT(printer, exception); + + return "ExceptionNode"; } void ExceptionNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -4353,9 +4472,10 @@ void ExceptionNode::setError(thread_db* tdbb) const //-------------------- -void ExitNode::print(string& text) const +string ExitNode::internalPrint(NodePrinter& printer) const { - text = "ExitNode"; + StmtNode::internalPrint(printer); + return "ExitNode"; } void ExitNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -4453,9 +4573,23 @@ ForNode* ForNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return node; } -void ForNode::print(string& text) const +string ForNode::internalPrint(NodePrinter& printer) const { - text = "ForNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlSelect); + NODE_PRINT(printer, dsqlInto); + NODE_PRINT(printer, dsqlCursor); + NODE_PRINT(printer, dsqlLabelName); + NODE_PRINT(printer, dsqlLabelNumber); + NODE_PRINT(printer, dsqlForceSingular); + NODE_PRINT(printer, stall); + NODE_PRINT(printer, rse); + NODE_PRINT(printer, statement); + NODE_PRINT(printer, cursor); + NODE_PRINT(printer, parBlrBeginCnt); + + return "ForNode"; } void ForNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -4628,9 +4762,13 @@ HandlerNode* HandlerNode::dsqlPass(DsqlCompilerScratch* /*dsqlScratch*/) return this; } -void HandlerNode::print(string& text) const +string HandlerNode::internalPrint(NodePrinter& printer) const { - text = "HandlerNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, statement); + + return "HandlerNode"; } void HandlerNode::genBlr(DsqlCompilerScratch* /*dsqlScratch*/) @@ -4686,9 +4824,14 @@ LabelNode* LabelNode::dsqlPass(DsqlCompilerScratch* /*dsqlScratch*/) return this; } -void LabelNode::print(string& text) const +string LabelNode::internalPrint(NodePrinter& printer) const { - text = "LabelNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, statement); + NODE_PRINT(printer, labelNumber); + + return "LabelNode"; } void LabelNode::genBlr(DsqlCompilerScratch* /*dsqlScratch*/) @@ -4734,9 +4877,13 @@ const StmtNode* LabelNode::execute(thread_db* /*tdbb*/, jrd_req* request, ExeSta //-------------------- -void LineColumnNode::print(string& text) const +string LineColumnNode::internalPrint(NodePrinter& printer) const { - text.printf("LineColumnNode: line %d, col %d", line, column); + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, statement); + + return "LineColumnNode"; } LineColumnNode* LineColumnNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -4781,9 +4928,16 @@ LoopNode* LoopNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return node; } -void LoopNode::print(string& text) const +string LoopNode::internalPrint(NodePrinter& printer) const { - text = "LoopNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlLabelName); + NODE_PRINT(printer, dsqlLabelNumber); + NODE_PRINT(printer, dsqlExpr); + NODE_PRINT(printer, statement); + + return "LoopNode"; } void LoopNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -4858,9 +5012,13 @@ StmtNode* MergeNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) } public: - virtual void print(string& text) const + virtual string internalPrint(NodePrinter& printer) const { - text = "MergeSendNode"; + DsqlOnlyStmtNode::internalPrint(printer); + + NODE_PRINT(printer, stmt); + + return "MergeSendNode"; } // Do not make dsqlPass to process 'stmt'. It's already processed. @@ -5262,9 +5420,18 @@ StmtNode* MergeNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return SavepointEncloseNode::make(getPool(), dsqlScratch, sendNode); } -void MergeNode::print(string& text) const +string MergeNode::internalPrint(NodePrinter& printer) const { - text = "MergeNode"; + DsqlOnlyStmtNode::internalPrint(printer); + + NODE_PRINT(printer, relation); + NODE_PRINT(printer, usingClause); + NODE_PRINT(printer, condition); + //// FIXME-PRINT: NODE_PRINT(printer, whenMatched); + //// FIXME-PRINT: NODE_PRINT(printer, whenNotMatched); + NODE_PRINT(printer, returning); + + return "MergeNode"; } void MergeNode::genBlr(DsqlCompilerScratch* /*dsqlScratch*/) @@ -5356,9 +5523,15 @@ MessageNode* MessageNode::dsqlPass(DsqlCompilerScratch* /*dsqlScratch*/) return this; } -void MessageNode::print(string& text) const +string MessageNode::internalPrint(NodePrinter& printer) const { - text = "MessageNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, messageNumber); + NODE_PRINT(printer, format); + NODE_PRINT(printer, impureFlags); + + return "MessageNode"; } void MessageNode::genBlr(DsqlCompilerScratch* /*dsqlScratch*/) @@ -5631,9 +5804,29 @@ StmtNode* ModifyNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return SavepointEncloseNode::make(getPool(), dsqlScratch, internalDsqlPass(dsqlScratch, false)); } -void ModifyNode::print(string& text) const +string ModifyNode::internalPrint(NodePrinter& printer) const { - text = "ModifyNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlRelation); + NODE_PRINT(printer, dsqlBoolean); + NODE_PRINT(printer, dsqlPlan); + NODE_PRINT(printer, dsqlOrder); + NODE_PRINT(printer, dsqlRows); + NODE_PRINT(printer, dsqlCursorName); + NODE_PRINT(printer, dsqlReturning); + NODE_PRINT(printer, dsqlRseFlags); + NODE_PRINT(printer, dsqlRse); + NODE_PRINT(printer, dsqlContext); + NODE_PRINT(printer, statement); + NODE_PRINT(printer, statement2); + NODE_PRINT(printer, subMod); + //// FIXME-PRINT: NODE_PRINT(printer, validations); + NODE_PRINT(printer, mapView); + NODE_PRINT(printer, orgStream); + NODE_PRINT(printer, newStream); + + return "ModifyNode"; } void ModifyNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -6081,9 +6274,14 @@ PostEventNode* PostEventNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return node; } -void PostEventNode::print(string& text) const +string PostEventNode::internalPrint(NodePrinter& printer) const { - text = "PostEventNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, event); + NODE_PRINT(printer, argument); + + return "PostEventNode"; } void PostEventNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -6160,9 +6358,14 @@ ReceiveNode* ReceiveNode::dsqlPass(DsqlCompilerScratch* /*dsqlScratch*/) return this; } -void ReceiveNode::print(string& text) const +string ReceiveNode::internalPrint(NodePrinter& printer) const { - text = "ReceiveNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, statement); + NODE_PRINT(printer, message); + + return "ReceiveNode"; } void ReceiveNode::genBlr(DsqlCompilerScratch* /*dsqlScratch*/) @@ -6400,9 +6603,21 @@ StmtNode* StoreNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return SavepointEncloseNode::make(getPool(), dsqlScratch, internalDsqlPass(dsqlScratch, false)); } -void StoreNode::print(string& text) const +string StoreNode::internalPrint(NodePrinter& printer) const { - text = "StoreNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlRelation); + NODE_PRINT(printer, dsqlFields); + NODE_PRINT(printer, dsqlValues); + NODE_PRINT(printer, dsqlReturning); + NODE_PRINT(printer, dsqlRse); + NODE_PRINT(printer, statement); + NODE_PRINT(printer, statement2); + //// FIXME-PRINT: NODE_PRINT(printer, validations); + NODE_PRINT(printer, relationSource); + + return "StoreNode"; } void StoreNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -6863,9 +7078,14 @@ UserSavepointNode* UserSavepointNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return this; } -void UserSavepointNode::print(string& text) const +string UserSavepointNode::internalPrint(NodePrinter& printer) const { - text = "UserSavepointNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, command); + NODE_PRINT(printer, name); + + return "UserSavepointNode"; } void UserSavepointNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -7045,9 +7265,17 @@ SelectNode* SelectNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return node; } -void SelectNode::print(string& text) const +string SelectNode::internalPrint(NodePrinter& printer) const { - text = "SelectNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlExpr); + NODE_PRINT(printer, dsqlForUpdate); + NODE_PRINT(printer, dsqlWithLock); + NODE_PRINT(printer, dsqlRse); + NODE_PRINT(printer, statements); + + return "SelectNode"; } // Generate BLR for a SELECT statement. @@ -7261,9 +7489,14 @@ DmlNode* SetGeneratorNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScra return node; } -void SetGeneratorNode::print(string& text) const +string SetGeneratorNode::internalPrint(NodePrinter& printer) const { - text = "SetGeneratorNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, generator); + NODE_PRINT(printer, value); + + return "SetGeneratorNode"; } SetGeneratorNode* SetGeneratorNode::pass1(thread_db* tdbb, CompilerScratch* csb) @@ -7320,9 +7553,10 @@ StallNode* StallNode::dsqlPass(DsqlCompilerScratch* /*dsqlScratch*/) return this; } -void StallNode::print(string& text) const +string StallNode::internalPrint(NodePrinter& printer) const { - text = "StallNode"; + StmtNode::internalPrint(printer); + return "StallNode"; } void StallNode::genBlr(DsqlCompilerScratch* /*dsqlScratch*/) @@ -7402,9 +7636,14 @@ SuspendNode* SuspendNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return this; } -void SuspendNode::print(string& text) const +string SuspendNode::internalPrint(NodePrinter& printer) const { - text = "SuspendNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, message); + NODE_PRINT(printer, statement); + + return "SuspendNode"; } void SuspendNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -7502,9 +7741,13 @@ ReturnNode* ReturnNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return node; } -void ReturnNode::print(string& text) const +string ReturnNode::internalPrint(NodePrinter& printer) const { - text = "ReturnNode"; + DsqlOnlyStmtNode::internalPrint(printer); + + NODE_PRINT(printer, value); + + return "ReturnNode"; } void ReturnNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -7538,9 +7781,13 @@ SavePointNode* SavePointNode::dsqlPass(DsqlCompilerScratch* /*dsqlScratch*/) return this; } -void SavePointNode::print(string& text) const +string SavePointNode::internalPrint(NodePrinter& printer) const { - text = "SavePointNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, blrOp); + + return "SavePointNode"; } void SavePointNode::genBlr(DsqlCompilerScratch* dsqlScratch) @@ -7937,9 +8184,17 @@ StmtNode* UpdateOrInsertNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) return SavepointEncloseNode::make(getPool(), dsqlScratch, list); } -void UpdateOrInsertNode::print(string& text) const +string UpdateOrInsertNode::internalPrint(NodePrinter& printer) const { - text = "UpdateOrInsertNode"; + DsqlOnlyStmtNode::internalPrint(printer); + + NODE_PRINT(printer, relation); + NODE_PRINT(printer, fields); + NODE_PRINT(printer, values); + NODE_PRINT(printer, matching); + NODE_PRINT(printer, returning); + + return "UpdateOrInsertNode"; } void UpdateOrInsertNode::genBlr(DsqlCompilerScratch* /*dsqlScratch*/) diff --git a/src/dsql/StmtNodes.h b/src/dsql/StmtNodes.h index 6c7482872a..d9dcf2b6af 100644 --- a/src/dsql/StmtNodes.h +++ b/src/dsql/StmtNodes.h @@ -29,6 +29,7 @@ #include "../jrd/extds/ExtDS.h" #include "../dsql/Nodes.h" #include "../dsql/DdlNodes.h" +#include "../dsql/NodePrinter.h" namespace Jrd { @@ -43,7 +44,7 @@ typedef Firebird::Pair< Firebird::NonPooled, NestConst > > ReturningClause; -class ExceptionItem : public Firebird::PermanentStorage +class ExceptionItem : public Firebird::PermanentStorage, public Printable { public: enum Type @@ -80,6 +81,18 @@ public: return *this; } +public: + virtual Firebird::string internalPrint(NodePrinter& printer) const + { + NODE_PRINT(printer, type); + NODE_PRINT(printer, code); + NODE_PRINT(printer, name); + NODE_PRINT(printer, secName); + + return "ExceptionItem"; + } + +public: Type type; SLONG code; // ASF: There are some inconsistencies in the type of 'name'. Metanames have maximum of 31 chars, @@ -117,7 +130,7 @@ public: static void validateTarget(CompilerScratch* csb, const ValueExprNode* target); static void dsqlValidateTarget(const ValueExprNode* target); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual AssignmentNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual AssignmentNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -146,7 +159,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual BlockNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -180,9 +193,14 @@ public: } public: - virtual void print(Firebird::string& text) const + virtual Firebird::string internalPrint(NodePrinter& printer) const { - text = "CommitRollbackNode"; + TransactionNode::internalPrint(printer); + + NODE_PRINT(printer, command); + NODE_PRINT(printer, retain); + + return "CommitRollbackNode"; } virtual CommitRollbackNode* dsqlPass(DsqlCompilerScratch* dsqlScratch) @@ -254,7 +272,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual CompoundStmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual CompoundStmtNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -283,7 +301,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ContinueLeaveNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -325,7 +343,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual CursorStmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual CursorStmtNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -368,7 +386,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual DeclareCursorNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual DeclareCursorNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -407,7 +425,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual DeclareSubFuncNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -454,7 +472,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual DeclareSubProcNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -495,7 +513,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual DeclareVariableNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual DeclareVariableNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -533,7 +551,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual EraseNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -573,7 +591,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ErrorHandlerNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual ErrorHandlerNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -608,7 +626,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ExecProcedureNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual ExecProcedureNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -656,7 +674,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual ExecStatementNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -700,7 +718,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual IfNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual IfNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -733,7 +751,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual InAutonomousTransactionNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual InAutonomousTransactionNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -760,7 +778,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual InitVariableNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual InitVariableNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -787,7 +805,7 @@ public: { } - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ExecBlockNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -827,7 +845,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual ExceptionNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -853,7 +871,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void genBlr(DsqlCompilerScratch* dsqlScratch); }; @@ -880,7 +898,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ForNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual StmtNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -914,7 +932,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual HandlerNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual HandlerNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -939,7 +957,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual LabelNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual LabelNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -964,7 +982,7 @@ public: } public: - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual LineColumnNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -988,7 +1006,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual LoopNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual LoopNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -1043,7 +1061,7 @@ public: { } - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -1076,7 +1094,7 @@ public: virtual USHORT setupDesc(thread_db* tdbb, CompilerScratch* csb, USHORT index, dsc* desc, ItemInfo* itemInfo); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual MessageNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual MessageNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -1119,7 +1137,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; StmtNode* internalDsqlPass(DsqlCompilerScratch* dsqlScratch, bool updateOrInsert); virtual StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -1165,7 +1183,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual PostEventNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual PostEventNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -1191,7 +1209,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ReceiveNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual ReceiveNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -1225,7 +1243,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; StmtNode* internalDsqlPass(DsqlCompilerScratch* dsqlScratch, bool updateOrInsert); virtual StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -1275,7 +1293,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual UserSavepointNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual UserSavepointNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -1304,7 +1322,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual SelectNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual SelectNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -1333,7 +1351,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; // DSQL support is implemented in CreateAlterSequenceNode. virtual void genBlr(DsqlCompilerScratch* dsqlScratch) @@ -1362,7 +1380,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual StallNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual StallNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -1384,7 +1402,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual SuspendNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual SuspendNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -1406,7 +1424,7 @@ public: { } - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual ReturnNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -1428,7 +1446,7 @@ public: public: static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp); - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual SavePointNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); @@ -1488,9 +1506,21 @@ public: } public: - virtual void print(Firebird::string& text) const + virtual Firebird::string internalPrint(NodePrinter& printer) const { - text = "SetTransactionNode"; + TransactionNode::internalPrint(printer); + + NODE_PRINT(printer, readOnly); + NODE_PRINT(printer, wait); + NODE_PRINT(printer, isoLevel); + NODE_PRINT(printer, noAutoUndo); + NODE_PRINT(printer, ignoreLimbo); + NODE_PRINT(printer, restartRequests); + NODE_PRINT(printer, lockTimeout); + //// FIXME-PRINT: NODE_PRINT(printer, reserveList); + NODE_PRINT(printer, tpb); + + return "SetTransactionNode"; } virtual SetTransactionNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); @@ -1535,9 +1565,14 @@ public: } public: - virtual void print(Firebird::string& text) const + virtual Firebird::string internalPrint(NodePrinter& printer) const { - text = "SetRoleNode"; + TransactionNode::internalPrint(printer); + + NODE_PRINT(printer, trusted); + NODE_PRINT(printer, roleName); + + return "SetRoleNode"; } virtual SetRoleNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); @@ -1562,7 +1597,7 @@ public: { } - virtual void print(Firebird::string& text) const; + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual StmtNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual void genBlr(DsqlCompilerScratch* dsqlScratch); diff --git a/src/dsql/WinNodes.cpp b/src/dsql/WinNodes.cpp index 187ebc10a8..34bad07385 100644 --- a/src/dsql/WinNodes.cpp +++ b/src/dsql/WinNodes.cpp @@ -55,6 +55,12 @@ DenseRankWinNode::DenseRankWinNode(MemoryPool& pool) jrdChildNodes.clear(); } +string DenseRankWinNode::internalPrint(NodePrinter& printer) const +{ + WinFuncNode::internalPrint(printer); + return "DenseRankWinNode"; +} + void DenseRankWinNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc) { if (dsqlScratch->clientDialect == 1) @@ -112,6 +118,15 @@ RankWinNode::RankWinNode(MemoryPool& pool) jrdChildNodes.clear(); } +string RankWinNode::internalPrint(NodePrinter& printer) const +{ + WinFuncNode::internalPrint(printer); + + NODE_PRINT(printer, tempImpure); + + return "RankWinNode"; +} + void RankWinNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc) { if (dsqlScratch->clientDialect == 1) @@ -187,6 +202,12 @@ RowNumberWinNode::RowNumberWinNode(MemoryPool& pool) jrdChildNodes.clear(); } +string RowNumberWinNode::internalPrint(NodePrinter& printer) const +{ + WinFuncNode::internalPrint(printer); + return "RowNumberWinNode"; +} + void RowNumberWinNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc) { if (dsqlScratch->clientDialect == 1) @@ -251,6 +272,12 @@ void FirstValueWinNode::parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigne arg = PAR_parse_value(tdbb, csb); } +string FirstValueWinNode::internalPrint(NodePrinter& printer) const +{ + WinFuncNode::internalPrint(printer); + return "FirstValueWinNode"; +} + void FirstValueWinNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc) { MAKE_desc(dsqlScratch, desc, arg); @@ -325,6 +352,12 @@ void LastValueWinNode::parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigned arg = PAR_parse_value(tdbb, csb); } +string LastValueWinNode::internalPrint(NodePrinter& printer) const +{ + WinFuncNode::internalPrint(printer); + return "LastValueWinNode"; +} + void LastValueWinNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc) { MAKE_desc(dsqlScratch, desc, arg); @@ -397,6 +430,16 @@ void NthValueWinNode::parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigned from = PAR_parse_value(tdbb, csb); } +string NthValueWinNode::internalPrint(NodePrinter& printer) const +{ + WinFuncNode::internalPrint(printer); + + NODE_PRINT(printer, row); + NODE_PRINT(printer, from); + + return "NthValueWinNode"; +} + void NthValueWinNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc) { MAKE_desc(dsqlScratch, desc, arg); @@ -508,6 +551,17 @@ void LagLeadWinNode::parseArgs(thread_db* tdbb, CompilerScratch* csb, unsigned / outExpr = PAR_parse_value(tdbb, csb); } +string LagLeadWinNode::internalPrint(NodePrinter& printer) const +{ + WinFuncNode::internalPrint(printer); + + NODE_PRINT(printer, direction); + NODE_PRINT(printer, rows); + NODE_PRINT(printer, outExpr); + + return "LagLeadWinNode"; +} + void LagLeadWinNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc) { MAKE_desc(dsqlScratch, desc, arg); diff --git a/src/dsql/WinNodes.h b/src/dsql/WinNodes.h index 87c25ed824..2a7100e123 100644 --- a/src/dsql/WinNodes.h +++ b/src/dsql/WinNodes.h @@ -25,6 +25,7 @@ #include "../jrd/blr.h" #include "../dsql/Nodes.h" +#include "../dsql/NodePrinter.h" namespace Jrd { @@ -35,6 +36,7 @@ class DenseRankWinNode : public WinFuncNode public: explicit DenseRankWinNode(MemoryPool& pool); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -53,6 +55,7 @@ class RankWinNode : public WinFuncNode public: explicit RankWinNode(MemoryPool& pool); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -75,6 +78,7 @@ class RowNumberWinNode : public WinFuncNode public: explicit RowNumberWinNode(MemoryPool& pool); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -100,6 +104,7 @@ class FirstValueWinNode : public WinFuncNode public: explicit FirstValueWinNode(MemoryPool& pool, ValueExprNode* aArg = NULL); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -127,6 +132,7 @@ class LastValueWinNode : public WinFuncNode public: explicit LastValueWinNode(MemoryPool& pool, ValueExprNode* aArg = NULL); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -162,6 +168,7 @@ public: explicit NthValueWinNode(MemoryPool& pool, ValueExprNode* aArg = NULL, ValueExprNode* aRow = NULL, ValueExprNode* aFrom = NULL); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -194,6 +201,7 @@ public: explicit LagLeadWinNode(MemoryPool& pool, const AggInfo& aAggInfo, int aDirection, ValueExprNode* aArg = NULL, ValueExprNode* aRows = NULL, ValueExprNode* aOutExpr = NULL); + virtual Firebird::string internalPrint(NodePrinter& printer) const = 0; virtual void make(DsqlCompilerScratch* dsqlScratch, dsc* desc); virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc); @@ -224,6 +232,12 @@ public: explicit LagWinNode(MemoryPool& pool, ValueExprNode* aArg = NULL, ValueExprNode* aRows = NULL, ValueExprNode* aOutExpr = NULL); + virtual Firebird::string internalPrint(NodePrinter& printer) const + { + LagLeadWinNode::internalPrint(printer); + return "LagWinNode"; + } + virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; protected: @@ -237,6 +251,12 @@ public: explicit LeadWinNode(MemoryPool& pool, ValueExprNode* aArg = NULL, ValueExprNode* aRows = NULL, ValueExprNode* aOutExpr = NULL); + virtual Firebird::string internalPrint(NodePrinter& printer) const + { + LagLeadWinNode::internalPrint(printer); + return "LeadWinNode"; + } + virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) const; protected: diff --git a/src/dsql/dsql.h b/src/dsql/dsql.h index 0232bb25a4..369638808f 100644 --- a/src/dsql/dsql.h +++ b/src/dsql/dsql.h @@ -229,13 +229,6 @@ public: { } -public: - virtual void print(Firebird::string& text) const - { - text.printf("typeOfTable: '%s' typeOfName: '%s' notNull: %d fieldSource: '%s'", - typeOfTable.c_str(), typeOfName.c_str(), notNull, fieldSource.c_str()); - } - public: USHORT dtype; FLD_LENGTH length; diff --git a/src/jrd/ExtEngineManager.cpp b/src/jrd/ExtEngineManager.cpp index a999a1095f..9708408a9a 100644 --- a/src/jrd/ExtEngineManager.cpp +++ b/src/jrd/ExtEngineManager.cpp @@ -152,9 +152,15 @@ namespace defaultValueNode = CMP_clone_node(tdbb, csb, parameter->prm_default_value); } - void print(string& text) const + string internalPrint(NodePrinter& printer) const { - text = "ExtInitParameterNode"; + StmtNode::internalPrint(printer); + + NODE_PRINT(printer, message); + NODE_PRINT(printer, argNumber); + NODE_PRINT(printer, defaultValueNode); + + return "ExtInitParameterNode"; } void genBlr(DsqlCompilerScratch* /*dsqlScratch*/) @@ -409,9 +415,10 @@ namespace { } - void print(string& text) const + string internalPrint(NodePrinter& printer) const { - text = "ExtTriggerNode"; + StmtNode::internalPrint(printer); + return "ExtTriggerNode"; } void genBlr(DsqlCompilerScratch* /*dsqlScratch*/) diff --git a/src/jrd/RecordSourceNodes.cpp b/src/jrd/RecordSourceNodes.cpp index 1c48f8c885..78de4b4af5 100644 --- a/src/jrd/RecordSourceNodes.cpp +++ b/src/jrd/RecordSourceNodes.cpp @@ -97,6 +97,21 @@ namespace //-------------------- +string RecordSourceNode::internalPrint(NodePrinter& printer) const +{ + ExprNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlFlags); + NODE_PRINT(printer, dsqlContext); + NODE_PRINT(printer, stream); + + return "RecordSourceNode"; +} + + +//-------------------- + + SortNode* SortNode::copy(thread_db* tdbb, NodeCopier& copier) const { SortNode* newSort = FB_NEW(*tdbb->getDefaultPool()) SortNode(*tdbb->getDefaultPool()); @@ -539,6 +554,17 @@ RelationSourceNode* RelationSourceNode::parse(thread_db* tdbb, CompilerScratch* return node; } +string RelationSourceNode::internalPrint(NodePrinter& printer) const +{ + RecordSourceNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlName); + NODE_PRINT(printer, alias); + NODE_PRINT(printer, context); + + return "RelationSourceNode"; +} + RecordSourceNode* RelationSourceNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) { return dsqlPassRelProc(dsqlScratch, this); @@ -924,6 +950,16 @@ ProcedureSourceNode* ProcedureSourceNode::parse(thread_db* tdbb, CompilerScratch return node; } +string ProcedureSourceNode::internalPrint(NodePrinter& printer) const +{ + RecordSourceNode::internalPrint(printer); + + NODE_PRINT(printer, in_msg); + NODE_PRINT(printer, context); + + return "ProcedureSourceNode"; +} + RecordSourceNode* ProcedureSourceNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) { return dsqlPassRelProc(dsqlScratch, this); @@ -1220,6 +1256,19 @@ AggregateSourceNode* AggregateSourceNode::parse(thread_db* tdbb, CompilerScratch return node; } +string AggregateSourceNode::internalPrint(NodePrinter& printer) const +{ + RecordSourceNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlGroup); + NODE_PRINT(printer, dsqlRse); + NODE_PRINT(printer, dsqlWindow); + NODE_PRINT(printer, group); + NODE_PRINT(printer, map); + + return "AggregateSourceNode"; +} + bool AggregateSourceNode::dsqlAggregateFinder(AggregateFinder& visitor) { return !visitor.ignoreSubSelects && visitor.visit(dsqlRse); @@ -1587,6 +1636,17 @@ UnionSourceNode* UnionSourceNode::parse(thread_db* tdbb, CompilerScratch* csb, c return node; } +string UnionSourceNode::internalPrint(NodePrinter& printer) const +{ + RecordSourceNode::internalPrint(printer); + + NODE_PRINT(printer, clauses); + NODE_PRINT(printer, maps); + NODE_PRINT(printer, mapStream); + + return "UnionSourceNode"; +} + void UnionSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch) { dsqlScratch->appendUChar((recursive ? blr_recurse : blr_union)); @@ -1894,6 +1954,16 @@ WindowSourceNode* WindowSourceNode::parse(thread_db* tdbb, CompilerScratch* csb) return node; } +string WindowSourceNode::internalPrint(NodePrinter& printer) const +{ + RecordSourceNode::internalPrint(printer); + + NODE_PRINT(printer, rse); + //// FIXME-PRINT: NODE_PRINT(printer, partitions); + + return "WindowSourceNode"; +} + // Parse PARTITION BY subclauses of window functions. void WindowSourceNode::parsePartitionBy(thread_db* tdbb, CompilerScratch* csb) { @@ -2120,6 +2190,36 @@ void WindowSourceNode::findDependentFromStreams(const OptimizerRetrieval* optRet //-------------------- +string RseNode::internalPrint(NodePrinter& printer) const +{ + RecordSourceNode::internalPrint(printer); + + NODE_PRINT(printer, dsqlFirst); + NODE_PRINT(printer, dsqlSkip); + NODE_PRINT(printer, dsqlDistinct); + NODE_PRINT(printer, dsqlSelectList); + NODE_PRINT(printer, dsqlFrom); + NODE_PRINT(printer, dsqlWhere); + NODE_PRINT(printer, dsqlJoinUsing); + NODE_PRINT(printer, dsqlGroup); + NODE_PRINT(printer, dsqlHaving); + NODE_PRINT(printer, dsqlOrder); + NODE_PRINT(printer, dsqlStreams); + NODE_PRINT(printer, dsqlExplicitJoin); + NODE_PRINT(printer, rse_jointype); + NODE_PRINT(printer, rse_first); + NODE_PRINT(printer, rse_skip); + NODE_PRINT(printer, rse_boolean); + NODE_PRINT(printer, rse_sorted); + NODE_PRINT(printer, rse_projection); + NODE_PRINT(printer, rse_aggregate); + NODE_PRINT(printer, rse_plan); + NODE_PRINT(printer, rse_relations); + NODE_PRINT(printer, flags); + + return "RseNode"; +} + bool RseNode::dsqlAggregateFinder(AggregateFinder& visitor) { AutoSetRestore autoValidateExpr(&visitor.currentLevel, visitor.currentLevel + 1); @@ -3070,6 +3170,20 @@ void RseNode::collectStreams(SortedStreamList& streamList) const //-------------------- +string SelectExprNode::internalPrint(NodePrinter& printer) const +{ + RecordSourceNode::internalPrint(printer); + + NODE_PRINT(printer, querySpec); + NODE_PRINT(printer, orderClause); + NODE_PRINT(printer, rowsClause); + NODE_PRINT(printer, withClause); + NODE_PRINT(printer, alias); + NODE_PRINT(printer, columns); + + return "SelectExprNode"; +} + RseNode* SelectExprNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) { fb_assert(dsqlFlags & DFLAG_DERIVED); diff --git a/src/jrd/RecordSourceNodes.h b/src/jrd/RecordSourceNodes.h index 0996f01776..47445a6b24 100644 --- a/src/jrd/RecordSourceNodes.h +++ b/src/jrd/RecordSourceNodes.h @@ -45,7 +45,7 @@ class SelectExprNode; class ValueListNode; -class SortNode : public Firebird::PermanentStorage +class SortNode : public Firebird::PermanentStorage, public Printable { public: explicit SortNode(MemoryPool& pool) @@ -57,19 +57,27 @@ public: { } +public: + virtual Firebird::string internalPrint(NodePrinter& printer) const + { + //// FIXME-PRINT: + return "SortNode"; + } + SortNode* copy(thread_db* tdbb, NodeCopier& copier) const; SortNode* pass1(thread_db* tdbb, CompilerScratch* csb); SortNode* pass2(thread_db* tdbb, CompilerScratch* csb); bool computable(CompilerScratch* csb, StreamType stream, bool allowOnlyCurrentStream); void findDependentFromStreams(const OptimizerRetrieval* optRet, SortedStreamList* streamList); +public: bool unique; // sorts using unique key - for distinct and group by NestValueArray expressions; // sort expressions Firebird::Array descending; // true = descending / false = ascending Firebird::Array nullOrder; // rse_nulls_* }; -class MapNode : public Firebird::PermanentStorage +class MapNode : public Firebird::PermanentStorage, public Printable { public: explicit MapNode(MemoryPool& pool) @@ -84,11 +92,23 @@ public: MapNode* pass2(thread_db* tdbb, CompilerScratch* csb); void aggPostRse(thread_db* tdbb, CompilerScratch* csb); +public: + virtual Firebird::string internalPrint(NodePrinter& printer) const + { + /*** FIXME-PRINT: + NODE_PRINT(printer, sourceList); + NODE_PRINT(printer, targetList); + ***/ + + return "MapNode"; + } + +public: NestValueArray sourceList; NestValueArray targetList; }; -class PlanNode : public Firebird::PermanentStorage +class PlanNode : public Firebird::PermanentStorage, public Printable { public: enum Type @@ -149,6 +169,13 @@ public: { } +public: + virtual Firebird::string internalPrint(NodePrinter& printer) const + { + //// FIXME-PRINT: + return "PlanNode"; + } + PlanNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); private: @@ -249,6 +276,7 @@ public: static RelationSourceNode* parse(thread_db* tdbb, CompilerScratch* csb, const SSHORT blrOp, bool parseContext); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual RecordSourceNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool dsqlSubSelectFinder(SubSelectFinder& /*visitor*/) @@ -329,6 +357,7 @@ public: static ProcedureSourceNode* parse(thread_db* tdbb, CompilerScratch* csb, const SSHORT blrOp); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual RecordSourceNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual bool dsqlAggregateFinder(AggregateFinder& visitor); @@ -403,6 +432,7 @@ public: static AggregateSourceNode* parse(thread_db* tdbb, CompilerScratch* csb); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool dsqlAggregateFinder(AggregateFinder& visitor); virtual bool dsqlAggregate2Finder(Aggregate2Finder& visitor); virtual bool dsqlInvalidReferenceFinder(InvalidReferenceFinder& visitor); @@ -467,6 +497,7 @@ public: static UnionSourceNode* parse(thread_db* tdbb, CompilerScratch* csb, const SSHORT blrOp); + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual void genBlr(DsqlCompilerScratch* dsqlScratch); virtual UnionSourceNode* copy(thread_db* tdbb, NodeCopier& copier) const; @@ -542,6 +573,8 @@ public: return 0; } + virtual Firebird::string internalPrint(NodePrinter& printer) const; + virtual WindowSourceNode* copy(thread_db* tdbb, NodeCopier& copier) const; virtual void ignoreDbKey(thread_db* tdbb, CompilerScratch* csb) const; virtual RecordSourceNode* pass1(thread_db* tdbb, CompilerScratch* csb); @@ -641,6 +674,7 @@ public: return obj; } + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual bool dsqlAggregateFinder(AggregateFinder& visitor); virtual bool dsqlAggregate2Finder(Aggregate2Finder& visitor); virtual bool dsqlInvalidReferenceFinder(InvalidReferenceFinder& visitor); @@ -719,6 +753,7 @@ public: { } + virtual Firebird::string internalPrint(NodePrinter& printer) const; virtual RseNode* dsqlPass(DsqlCompilerScratch* dsqlScratch); virtual RseNode* copy(thread_db* /*tdbb*/, NodeCopier& /*copier*/) const diff --git a/src/jrd/evl_proto.h b/src/jrd/evl_proto.h index d3769700d1..b930da00e2 100644 --- a/src/jrd/evl_proto.h +++ b/src/jrd/evl_proto.h @@ -31,7 +31,7 @@ namespace Jrd { class InversionNode; struct Item; - struct ItemInfo; + class ItemInfo; } dsc* EVL_assign_to(Jrd::thread_db* tdbb, const Jrd::ValueExprNode*); diff --git a/src/jrd/exe.h b/src/jrd/exe.h index 2b681187b0..13240da93e 100644 --- a/src/jrd/exe.h +++ b/src/jrd/exe.h @@ -94,7 +94,7 @@ const int rse_nulls_last = 2; // Aggregate Sort Block (for DISTINCT aggregates) -class AggregateSort : protected Firebird::PermanentStorage +class AggregateSort : protected Firebird::PermanentStorage, public Printable { public: explicit AggregateSort(Firebird::MemoryPool& p) @@ -107,6 +107,13 @@ public: desc.clear(); } +public: + virtual Firebird::string internalPrint(NodePrinter& printer) const + { + return "AggregateSort"; + } + +public: dsc desc; ULONG length; bool intl; @@ -331,8 +338,9 @@ struct FieldInfo NestConst validationExpr; }; -struct ItemInfo +class ItemInfo : public Printable { +public: ItemInfo(MemoryPool& p, const ItemInfo& o) : name(p, o.name), field(p, o.field), @@ -360,11 +368,26 @@ struct ItemInfo { } +public: bool isSpecial() const { return !nullable || fullDomain; } + virtual Firebird::string internalPrint(NodePrinter& printer) const + { + /*** FIXME-PRINT: + NODE_PRINT(printer, name); + NODE_PRINT(printer, field); + NODE_PRINT(printer, nullable); + NODE_PRINT(printer, explicitCollation); + NODE_PRINT(printer, fullDomain); + ***/ + + return "ItemInfo"; + } + +public: Firebird::MetaName name; Firebird::MetaNamePair field; bool nullable; diff --git a/src/jrd/par_proto.h b/src/jrd/par_proto.h index bf903c0efb..d7b5a87c70 100644 --- a/src/jrd/par_proto.h +++ b/src/jrd/par_proto.h @@ -30,7 +30,7 @@ namespace Jrd { class jrd_req; class JrdStatement; class thread_db; - struct ItemInfo; + class ItemInfo; class BoolExprNode; class CompoundStmtNode; class DmlNode;