2008-05-19 15:47:48 +02:00
|
|
|
/*
|
|
|
|
* 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) 2008 Adriano dos Santos Fernandes <adrianosf@uol.com.br>
|
|
|
|
* and all contributors signed below.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DSQL_STMT_NODES_H
|
|
|
|
#define DSQL_STMT_NODES_H
|
|
|
|
|
|
|
|
#include "../jrd/common.h"
|
2009-10-24 19:45:33 +02:00
|
|
|
#include "../jrd/blr.h"
|
2008-05-19 15:47:48 +02:00
|
|
|
#include "../dsql/Nodes.h"
|
2009-11-21 21:42:27 +01:00
|
|
|
#include "../dsql/DdlNodes.h"
|
2009-10-24 19:45:33 +02:00
|
|
|
#include "../common/classes/MetaName.h"
|
2008-05-19 15:47:48 +02:00
|
|
|
|
|
|
|
namespace Jrd {
|
|
|
|
|
2010-01-05 18:32:42 +01:00
|
|
|
class PsqlException;
|
|
|
|
|
2008-05-19 15:47:48 +02:00
|
|
|
|
2009-10-24 19:45:33 +02:00
|
|
|
class IfNode : public StmtNode
|
|
|
|
{
|
|
|
|
public:
|
2009-12-20 22:01:10 +01:00
|
|
|
explicit IfNode(MemoryPool& pool, DsqlCompilerScratch* aDsqlScratch = NULL)
|
2009-10-24 19:45:33 +02:00
|
|
|
: StmtNode(pool),
|
|
|
|
dsqlCondition(NULL),
|
|
|
|
dsqlTrueAction(NULL),
|
|
|
|
dsqlFalseAction(NULL),
|
|
|
|
condition(NULL),
|
|
|
|
trueAction(NULL),
|
|
|
|
falseAction(NULL)
|
|
|
|
{
|
2009-12-20 22:01:10 +01:00
|
|
|
dsqlScratch = aDsqlScratch;
|
2009-10-24 19:45:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual IfNode* internalDsqlPass();
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
|
|
|
virtual void genBlr();
|
|
|
|
virtual IfNode* pass1(thread_db* tdbb, CompilerScratch* csb);
|
|
|
|
virtual IfNode* pass2(thread_db* tdbb, CompilerScratch* csb);
|
2009-12-23 01:57:08 +01:00
|
|
|
virtual jrd_nod* execute(thread_db* tdbb, jrd_req* request) const;
|
2009-10-24 19:45:33 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
dsql_nod* dsqlCondition;
|
|
|
|
dsql_nod* dsqlTrueAction;
|
|
|
|
dsql_nod* dsqlFalseAction;
|
|
|
|
jrd_nod* condition;
|
|
|
|
jrd_nod* trueAction;
|
|
|
|
jrd_nod* falseAction;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-05-19 15:47:48 +02:00
|
|
|
class InAutonomousTransactionNode : public StmtNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit InAutonomousTransactionNode(MemoryPool& pool)
|
|
|
|
: StmtNode(pool),
|
|
|
|
dsqlAction(NULL),
|
2009-08-05 23:36:49 +02:00
|
|
|
action(NULL),
|
2009-08-06 08:30:35 +02:00
|
|
|
savNumberOffset(0)
|
2008-05-19 15:47:48 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2009-10-24 19:45:33 +02:00
|
|
|
static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
|
2008-05-19 15:47:48 +02:00
|
|
|
|
2008-05-25 17:41:54 +02:00
|
|
|
protected:
|
2009-10-21 02:42:38 +02:00
|
|
|
virtual InAutonomousTransactionNode* internalDsqlPass();
|
2008-05-25 17:41:54 +02:00
|
|
|
|
|
|
|
public:
|
2008-05-19 15:47:48 +02:00
|
|
|
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
|
|
|
virtual void genBlr();
|
|
|
|
virtual InAutonomousTransactionNode* pass1(thread_db* tdbb, CompilerScratch* csb);
|
|
|
|
virtual InAutonomousTransactionNode* pass2(thread_db* tdbb, CompilerScratch* csb);
|
2009-12-23 01:57:08 +01:00
|
|
|
virtual jrd_nod* execute(thread_db* tdbb, jrd_req* request) const;
|
2008-05-19 15:47:48 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
dsql_nod* dsqlAction;
|
|
|
|
jrd_nod* action;
|
2009-08-06 08:30:35 +02:00
|
|
|
SLONG savNumberOffset;
|
2008-05-19 15:47:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-10-24 19:45:33 +02:00
|
|
|
class ExecBlockNode : public DsqlOnlyStmtNode, public BlockNode
|
2009-10-21 02:42:38 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit ExecBlockNode(MemoryPool& pool)
|
2009-10-24 19:45:33 +02:00
|
|
|
: DsqlOnlyStmtNode(pool),
|
2009-11-21 21:42:27 +01:00
|
|
|
returns(pool),
|
|
|
|
variables(pool),
|
|
|
|
outputVariables(pool),
|
2009-10-21 02:42:38 +02:00
|
|
|
legacyParameters(NULL),
|
|
|
|
localDeclList(NULL),
|
|
|
|
body(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ExecBlockNode* internalDsqlPass();
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
|
|
|
virtual void genBlr();
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void genReturn();
|
|
|
|
virtual dsql_nod* resolveVariable(const dsql_str* varName);
|
|
|
|
|
|
|
|
private:
|
2009-12-19 19:50:38 +01:00
|
|
|
static void revertParametersOrder(Firebird::Array<dsql_par*>& parameters);
|
2009-10-21 02:42:38 +02:00
|
|
|
|
|
|
|
public:
|
2009-11-21 21:42:27 +01:00
|
|
|
Firebird::Array<ParameterClause> returns;
|
|
|
|
Firebird::Array<dsql_nod*> variables;
|
|
|
|
Firebird::Array<dsql_nod*> outputVariables;
|
2009-10-21 02:42:38 +02:00
|
|
|
dsql_nod* legacyParameters;
|
|
|
|
dsql_nod* localDeclList;
|
|
|
|
dsql_nod* body;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-01-05 18:32:42 +01:00
|
|
|
class ExceptionNode : public StmtNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit ExceptionNode(MemoryPool& pool, const Firebird::MetaName& aName = "",
|
2010-01-07 01:16:50 +01:00
|
|
|
dsql_nod* aDsqlMessageExpr = NULL, dsql_nod* aDsqlParameters = NULL)
|
2010-01-05 18:32:42 +01:00
|
|
|
: StmtNode(pool),
|
|
|
|
name(pool, aName),
|
|
|
|
dsqlMessageExpr(aDsqlMessageExpr),
|
2010-01-07 01:16:50 +01:00
|
|
|
dsqlParameters(aDsqlParameters),
|
2010-01-05 18:32:42 +01:00
|
|
|
messageExpr(NULL),
|
2010-01-07 01:16:50 +01:00
|
|
|
parameters(NULL),
|
2010-01-05 18:32:42 +01:00
|
|
|
exception(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual StmtNode* internalDsqlPass();
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
|
|
|
virtual void genBlr();
|
|
|
|
virtual ExceptionNode* pass1(thread_db* tdbb, CompilerScratch* csb);
|
|
|
|
virtual ExceptionNode* pass2(thread_db* tdbb, CompilerScratch* csb);
|
|
|
|
virtual jrd_nod* execute(thread_db* tdbb, jrd_req* request) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void setError(thread_db* tdbb) const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
dsql_nod* dsqlMessageExpr;
|
2010-01-07 01:16:50 +01:00
|
|
|
dsql_nod* dsqlParameters;
|
2010-01-05 18:32:42 +01:00
|
|
|
jrd_nod* messageExpr;
|
2010-01-07 01:16:50 +01:00
|
|
|
jrd_nod* parameters;
|
2010-01-05 18:32:42 +01:00
|
|
|
PsqlException* exception;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-10-24 19:45:33 +02:00
|
|
|
class ExitNode : public DsqlOnlyStmtNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit ExitNode(MemoryPool& pool)
|
|
|
|
: DsqlOnlyStmtNode(pool)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
|
|
|
virtual void genBlr();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-02-22 17:00:49 +01:00
|
|
|
class ForNode : public StmtNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit ForNode(MemoryPool& pool, DsqlCompilerScratch* aDsqlScratch = NULL)
|
|
|
|
: StmtNode(pool),
|
|
|
|
dsqlSelect(NULL),
|
|
|
|
dsqlInto(NULL),
|
|
|
|
dsqlCursor(NULL),
|
|
|
|
dsqlAction(NULL),
|
|
|
|
dsqlLabel(NULL),
|
2010-06-10 04:03:03 +02:00
|
|
|
dsqlForceSingular(false),
|
2010-02-22 17:00:49 +01:00
|
|
|
stall(NULL),
|
|
|
|
rse(NULL),
|
|
|
|
statement(NULL),
|
|
|
|
cursor(NULL)
|
|
|
|
{
|
|
|
|
dsqlScratch = aDsqlScratch;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual StmtNode* internalDsqlPass();
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
|
|
|
virtual void genBlr();
|
|
|
|
virtual StmtNode* pass1(thread_db* tdbb, CompilerScratch* csb);
|
|
|
|
virtual StmtNode* pass2(thread_db* tdbb, CompilerScratch* csb);
|
|
|
|
|
|
|
|
virtual void pass2Cursor(RecordSelExpr*& rsePtr, Cursor**& cursorPtr)
|
|
|
|
{
|
|
|
|
rsePtr = (RecordSelExpr*) rse;
|
|
|
|
cursorPtr = &cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual jrd_nod* execute(thread_db* tdbb, jrd_req* request) const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
dsql_nod* dsqlSelect;
|
|
|
|
dsql_nod* dsqlInto;
|
|
|
|
dsql_nod* dsqlCursor;
|
|
|
|
dsql_nod* dsqlAction;
|
|
|
|
dsql_nod* dsqlLabel;
|
2010-06-10 04:03:03 +02:00
|
|
|
bool dsqlForceSingular;
|
2010-02-22 17:00:49 +01:00
|
|
|
jrd_nod* stall;
|
|
|
|
jrd_nod* rse;
|
|
|
|
jrd_nod* statement;
|
|
|
|
Cursor* cursor;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-10-24 19:45:33 +02:00
|
|
|
class PostEventNode : public StmtNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit PostEventNode(MemoryPool& pool)
|
|
|
|
: StmtNode(pool),
|
|
|
|
dsqlEvent(NULL),
|
|
|
|
dsqlArgument(NULL),
|
|
|
|
event(NULL),
|
|
|
|
argument(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual PostEventNode* internalDsqlPass();
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
|
|
|
virtual void genBlr();
|
|
|
|
virtual PostEventNode* pass1(thread_db* tdbb, CompilerScratch* csb);
|
|
|
|
virtual PostEventNode* pass2(thread_db* tdbb, CompilerScratch* csb);
|
2009-12-23 01:57:08 +01:00
|
|
|
virtual jrd_nod* execute(thread_db* tdbb, jrd_req* request) const;
|
2009-10-24 19:45:33 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
dsql_nod* dsqlEvent;
|
|
|
|
dsql_nod* dsqlArgument;
|
|
|
|
jrd_nod* event;
|
|
|
|
jrd_nod* argument;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SavepointNode : public StmtNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Command
|
|
|
|
{
|
2009-10-31 02:46:06 +01:00
|
|
|
CMD_NOTHING = -1,
|
2009-10-24 19:45:33 +02:00
|
|
|
CMD_SET = blr_savepoint_set,
|
|
|
|
CMD_RELEASE = blr_savepoint_release,
|
|
|
|
CMD_RELEASE_ONLY = blr_savepoint_release_single,
|
|
|
|
CMD_ROLLBACK = blr_savepoint_undo
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit SavepointNode(MemoryPool& pool)
|
|
|
|
: StmtNode(pool),
|
2009-10-30 11:43:42 +01:00
|
|
|
command(CMD_NOTHING),
|
2009-10-24 19:45:33 +02:00
|
|
|
name(pool)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual SavepointNode* internalDsqlPass();
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
|
|
|
virtual void genBlr();
|
|
|
|
virtual SavepointNode* pass1(thread_db* tdbb, CompilerScratch* csb);
|
|
|
|
virtual SavepointNode* pass2(thread_db* tdbb, CompilerScratch* csb);
|
2009-12-23 01:57:08 +01:00
|
|
|
virtual jrd_nod* execute(thread_db* tdbb, jrd_req* request) const;
|
2009-10-24 19:45:33 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
Command command;
|
|
|
|
Firebird::MetaName name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SuspendNode : public StmtNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit SuspendNode(MemoryPool& pool)
|
|
|
|
: StmtNode(pool),
|
|
|
|
blockNode(NULL),
|
|
|
|
message(NULL),
|
|
|
|
statement(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual SuspendNode* internalDsqlPass();
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
|
|
|
virtual void genBlr();
|
|
|
|
virtual SuspendNode* pass1(thread_db* tdbb, CompilerScratch* csb);
|
|
|
|
virtual SuspendNode* pass2(thread_db* tdbb, CompilerScratch* csb);
|
2009-12-23 01:57:08 +01:00
|
|
|
virtual jrd_nod* execute(thread_db* tdbb, jrd_req* request) const;
|
2009-10-24 19:45:33 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
BlockNode* blockNode;
|
|
|
|
jrd_nod* message;
|
|
|
|
jrd_nod* statement;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-12-21 18:23:07 +01:00
|
|
|
class ReturnNode : public DsqlOnlyStmtNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit ReturnNode(MemoryPool& pool, dsql_nod* val = NULL)
|
|
|
|
: DsqlOnlyStmtNode(pool), value(val)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ReturnNode* internalDsqlPass();
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
|
|
|
virtual void genBlr();
|
|
|
|
|
|
|
|
public:
|
|
|
|
BlockNode* blockNode;
|
|
|
|
dsql_nod* value;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-05-19 15:47:48 +02:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif // DSQL_STMT_NODES_H
|