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_DDL_NODES_H
|
|
|
|
#define DSQL_DDL_NODES_H
|
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
#include "../jrd/blr.h"
|
2010-06-26 03:52:06 +02:00
|
|
|
#include "../jrd/dyn.h"
|
|
|
|
#include "../jrd/msg_encode.h"
|
2009-12-21 18:23:07 +01:00
|
|
|
#include "../dsql/make_proto.h"
|
2010-07-26 04:37:57 +02:00
|
|
|
#include "../dsql/BlrWriter.h"
|
2008-05-19 15:47:48 +02:00
|
|
|
#include "../dsql/Nodes.h"
|
2009-10-21 02:42:38 +02:00
|
|
|
#include "../common/classes/array.h"
|
2010-07-26 04:37:57 +02:00
|
|
|
#include "../common/classes/ByteChunk.h"
|
2010-07-29 02:20:53 +02:00
|
|
|
#include "../common/classes/Nullable.h"
|
2010-08-02 17:47:36 +02:00
|
|
|
#include "../jrd/vio_proto.h"
|
2010-06-26 03:52:06 +02:00
|
|
|
#include "../dsql/errd_proto.h"
|
2008-05-19 15:47:48 +02:00
|
|
|
|
|
|
|
namespace Jrd {
|
|
|
|
|
2011-02-22 01:51:56 +01:00
|
|
|
class CompoundStmtNode;
|
2012-04-25 03:42:47 +02:00
|
|
|
class RelationSourceNode;
|
|
|
|
class ValueListNode;
|
|
|
|
|
|
|
|
|
|
|
|
struct BoolSourceClause
|
|
|
|
{
|
|
|
|
explicit BoolSourceClause(MemoryPool& p)
|
|
|
|
: value(NULL),
|
|
|
|
source(p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<BoolExprNode> value;
|
2012-04-25 03:42:47 +02:00
|
|
|
Firebird::string source;
|
|
|
|
};
|
2011-02-22 01:51:56 +01:00
|
|
|
|
2008-05-19 15:47:48 +02:00
|
|
|
|
2012-03-18 22:37:13 +01:00
|
|
|
struct ValueSourceClause
|
|
|
|
{
|
2012-04-10 03:52:05 +02:00
|
|
|
explicit ValueSourceClause(MemoryPool& p)
|
2012-03-18 22:37:13 +01:00
|
|
|
: value(NULL),
|
|
|
|
source(p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<ValueExprNode> value;
|
2012-03-18 22:37:13 +01:00
|
|
|
Firebird::string source;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-22 17:33:25 +01:00
|
|
|
class DbFileClause
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DbFileClause(MemoryPool& p, const DbFileClause& o)
|
|
|
|
: name(p, o.name),
|
|
|
|
start(o.start),
|
|
|
|
length(o.length)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit DbFileClause(MemoryPool& p, const Firebird::PathName& aName)
|
|
|
|
: name(p, aName),
|
|
|
|
start(0),
|
|
|
|
length(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::PathName name; // File name
|
|
|
|
SLONG start; // Starting page
|
|
|
|
SLONG length; // File length in pages
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-10-21 02:42:38 +02:00
|
|
|
class ExternalClause
|
|
|
|
{
|
|
|
|
public:
|
2010-07-26 04:37:57 +02:00
|
|
|
ExternalClause(MemoryPool& p, const ExternalClause& o)
|
|
|
|
: name(p, o.name),
|
2011-11-08 15:54:48 +01:00
|
|
|
engine(p, o.engine),
|
2011-11-22 17:33:25 +01:00
|
|
|
udfModule(p, o.udfModule)
|
2010-07-26 04:37:57 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit ExternalClause(MemoryPool& p)
|
|
|
|
: name(p),
|
2011-11-08 15:54:48 +01:00
|
|
|
engine(p),
|
|
|
|
udfModule(p)
|
2009-10-21 02:42:38 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::string name;
|
|
|
|
Firebird::MetaName engine;
|
2011-11-08 15:54:48 +01:00
|
|
|
Firebird::string udfModule;
|
2009-10-21 02:42:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-12-05 03:07:37 +01:00
|
|
|
class ParameterClause
|
2009-10-21 02:42:38 +02:00
|
|
|
{
|
|
|
|
public:
|
2010-10-30 20:57:53 +02:00
|
|
|
ParameterClause(MemoryPool& pool, dsql_fld* field, const Firebird::MetaName& aCollate,
|
2012-12-05 03:07:37 +01:00
|
|
|
ValueSourceClause* aDefaultClause = NULL, ValueExprNode* aParameterExpr = NULL);
|
2009-10-21 02:42:38 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
void print(Firebird::string& text) const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
2012-12-05 03:07:37 +01:00
|
|
|
NestConst<dsql_fld> type;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<ValueSourceClause> defaultClause;
|
|
|
|
NestConst<ValueExprNode> parameterExpr;
|
2011-11-08 15:54:48 +01:00
|
|
|
Nullable<int> udfMechanism;
|
2009-10-21 02:42:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-08-02 17:47:36 +02:00
|
|
|
template <typename CreateNode, typename DropNode, ISC_STATUS ERROR_CODE>
|
|
|
|
class RecreateNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
RecreateNode(MemoryPool& p, CreateNode* aCreateNode)
|
|
|
|
: DdlNode(p),
|
2010-08-02 17:47:36 +02:00
|
|
|
createNode(aCreateNode),
|
2010-08-05 02:47:06 +02:00
|
|
|
dropNode(p, createNode->name)
|
2010-08-02 17:47:36 +02:00
|
|
|
{
|
|
|
|
dropNode.silent = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const
|
2010-08-02 17:47:36 +02:00
|
|
|
{
|
|
|
|
text.printf("RecreateNode\n");
|
|
|
|
}
|
|
|
|
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction)
|
2010-08-02 17:47:36 +02:00
|
|
|
{
|
|
|
|
// run all statements under savepoint control
|
|
|
|
AutoSavePoint savePoint(tdbb, transaction);
|
|
|
|
|
2010-09-17 05:15:32 +02:00
|
|
|
dropNode.execute(tdbb, dsqlScratch, transaction);
|
|
|
|
createNode->execute(tdbb, dsqlScratch, transaction);
|
2010-08-02 17:47:36 +02:00
|
|
|
|
|
|
|
savePoint.release(); // everything is ok
|
|
|
|
}
|
|
|
|
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch)
|
2010-08-02 17:47:36 +02:00
|
|
|
{
|
2010-09-17 05:15:32 +02:00
|
|
|
createNode->dsqlPass(dsqlScratch);
|
|
|
|
dropNode.dsqlPass(dsqlScratch);
|
|
|
|
return DdlNode::dsqlPass(dsqlScratch);
|
2010-08-02 17:47:36 +02:00
|
|
|
}
|
|
|
|
|
2010-09-17 05:15:32 +02:00
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
2010-08-02 17:47:36 +02:00
|
|
|
{
|
2010-09-17 05:15:32 +02:00
|
|
|
statusVector << Firebird::Arg::Gds(ERROR_CODE) << createNode->name;
|
2010-08-02 17:47:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<CreateNode> createNode;
|
2010-08-02 17:47:36 +02:00
|
|
|
DropNode dropNode;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-05-19 15:47:48 +02:00
|
|
|
class AlterCharSetNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
AlterCharSetNode(MemoryPool& pool, const Firebird::MetaName& aCharSet,
|
|
|
|
const Firebird::MetaName& aDefaultCollation)
|
|
|
|
: DdlNode(pool),
|
2009-10-21 02:42:38 +02:00
|
|
|
charSet(pool, aCharSet),
|
|
|
|
defaultCollation(pool, aDefaultCollation)
|
2008-05-19 15:47:48 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2008-05-19 15:47:48 +02:00
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_alter_charset_failed) << charSet;
|
|
|
|
}
|
|
|
|
|
2008-05-19 15:47:48 +02:00
|
|
|
private:
|
|
|
|
Firebird::MetaName charSet;
|
|
|
|
Firebird::MetaName defaultCollation;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-10-21 02:42:38 +02:00
|
|
|
class CommentOnNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
CommentOnNode(MemoryPool& pool, int aObjType,
|
2009-10-21 02:42:38 +02:00
|
|
|
const Firebird::MetaName& aObjName, const Firebird::MetaName& aSubName,
|
2012-12-10 16:46:51 +01:00
|
|
|
const IntlString* aText)
|
2010-08-05 02:47:06 +02:00
|
|
|
: DdlNode(pool),
|
2009-10-21 02:42:38 +02:00
|
|
|
objType(aObjType),
|
|
|
|
objName(pool, aObjName),
|
|
|
|
subName(pool, aSubName),
|
2012-12-10 16:46:51 +01:00
|
|
|
text(aText)
|
2009-10-21 02:42:38 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2009-10-21 02:42:38 +02:00
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
/*** ASF: FIXME: When returning, str is destroyed but its pointer is recorded.
|
|
|
|
Firebird::string str(objName.c_str());
|
|
|
|
if (subName.hasData())
|
|
|
|
str.append(".").append(subName.c_str());
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_comment_on_failed) << str;
|
|
|
|
***/
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_comment_on_failed) << objName;
|
|
|
|
}
|
|
|
|
|
2009-10-21 02:42:38 +02:00
|
|
|
private:
|
|
|
|
int objType;
|
|
|
|
Firebird::MetaName objName;
|
|
|
|
Firebird::MetaName subName;
|
2012-12-10 16:46:51 +01:00
|
|
|
const IntlString* text;
|
2009-10-21 02:42:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-08-27 04:18:00 +02:00
|
|
|
class CreateAlterFunctionNode : public DdlNode
|
2009-10-21 02:42:38 +02:00
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
CreateAlterFunctionNode(MemoryPool& pool, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(pool),
|
2009-10-21 02:42:38 +02:00
|
|
|
name(pool, aName),
|
|
|
|
create(true),
|
|
|
|
alter(false),
|
|
|
|
external(NULL),
|
2010-11-13 16:03:44 +01:00
|
|
|
deterministic(false),
|
2009-10-21 02:42:38 +02:00
|
|
|
parameters(pool),
|
2012-12-05 03:07:37 +01:00
|
|
|
returnType(NULL),
|
2009-12-21 18:23:07 +01:00
|
|
|
localDeclList(NULL),
|
|
|
|
source(pool),
|
2009-12-21 21:55:07 +01:00
|
|
|
body(NULL),
|
2009-12-21 18:23:07 +01:00
|
|
|
compiled(false),
|
|
|
|
invalid(false),
|
2009-10-21 02:42:38 +02:00
|
|
|
package(pool),
|
2009-12-21 18:23:07 +01:00
|
|
|
packageOwner(pool),
|
2011-11-08 15:54:48 +01:00
|
|
|
privateScope(false),
|
|
|
|
udfReturnPos(0)
|
2009-10-21 02:42:38 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
|
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2009-10-21 02:42:38 +02:00
|
|
|
|
2009-12-20 22:01:10 +01:00
|
|
|
protected:
|
2010-07-26 04:37:57 +02:00
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector <<
|
|
|
|
Firebird::Arg::Gds(createAlterCode(create, alter,
|
|
|
|
isc_dsql_create_func_failed, isc_dsql_alter_func_failed,
|
|
|
|
isc_dsql_create_alter_func_failed)) <<
|
|
|
|
name;
|
|
|
|
}
|
|
|
|
|
2009-10-21 02:42:38 +02:00
|
|
|
private:
|
2012-01-19 05:54:39 +01:00
|
|
|
bool isUdf() const
|
2011-11-08 15:54:48 +01:00
|
|
|
{
|
|
|
|
return external && external->udfModule.hasData();
|
|
|
|
}
|
|
|
|
|
2010-09-17 05:15:32 +02:00
|
|
|
void executeCreate(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
bool executeAlter(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
|
|
|
|
bool secondPass, bool runTriggers);
|
2009-10-21 02:42:38 +02:00
|
|
|
|
2010-09-17 05:15:32 +02:00
|
|
|
void storeArgument(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
|
2012-12-05 03:07:37 +01:00
|
|
|
unsigned pos, ParameterClause* parameter, const bid* comment);
|
2010-09-17 05:15:32 +02:00
|
|
|
void compile(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch);
|
2011-07-14 17:27:25 +02:00
|
|
|
void collectParamComments(thread_db* tdbb, jrd_tra* transaction, MetaNameBidMap& items);
|
2009-10-21 02:42:38 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
bool create;
|
|
|
|
bool alter;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<ExternalClause> external;
|
2010-11-13 16:03:44 +01:00
|
|
|
bool deterministic;
|
2012-12-05 03:07:37 +01:00
|
|
|
Firebird::Array<NestConst<ParameterClause> > parameters;
|
|
|
|
NestConst<ParameterClause> returnType;
|
2011-02-22 01:51:56 +01:00
|
|
|
NestConst<CompoundStmtNode> localDeclList;
|
2009-12-21 21:55:07 +01:00
|
|
|
Firebird::string source;
|
2011-03-06 03:48:34 +01:00
|
|
|
NestConst<StmtNode> body;
|
2009-12-21 18:23:07 +01:00
|
|
|
bool compiled;
|
|
|
|
bool invalid;
|
2009-10-21 02:42:38 +02:00
|
|
|
Firebird::MetaName package;
|
2009-12-21 18:23:07 +01:00
|
|
|
Firebird::string packageOwner;
|
2009-10-21 02:42:38 +02:00
|
|
|
bool privateScope;
|
2011-11-08 15:54:48 +01:00
|
|
|
SLONG udfReturnPos;
|
2009-10-21 02:42:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-22 17:33:25 +01:00
|
|
|
class AlterExternalFunctionNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AlterExternalFunctionNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
|
|
|
name(p, aName),
|
|
|
|
clauses(p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-22 17:33:25 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_alter_func_failed) << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
ExternalClause clauses;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-10-21 02:42:38 +02:00
|
|
|
class DropFunctionNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
DropFunctionNode(MemoryPool& pool, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(pool),
|
2009-10-21 02:42:38 +02:00
|
|
|
name(pool, aName),
|
|
|
|
silent(false),
|
|
|
|
package(pool)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-12-21 18:23:07 +01:00
|
|
|
public:
|
|
|
|
static void dropArguments(thread_db* tdbb, jrd_tra* transaction,
|
|
|
|
const Firebird::MetaName& functionName, const Firebird::MetaName& packageName);
|
|
|
|
|
2009-10-21 02:42:38 +02:00
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
|
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2009-10-21 02:42:38 +02:00
|
|
|
|
2009-12-21 18:23:07 +01:00
|
|
|
protected:
|
2010-07-26 04:37:57 +02:00
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_drop_func_failed) << name;
|
|
|
|
}
|
|
|
|
|
2009-10-21 02:42:38 +02:00
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
bool silent;
|
|
|
|
Firebird::MetaName package;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-08-02 17:47:36 +02:00
|
|
|
typedef RecreateNode<CreateAlterFunctionNode, DropFunctionNode, isc_dsql_recreate_func_failed>
|
|
|
|
RecreateFunctionNode;
|
2009-12-21 18:23:07 +01:00
|
|
|
|
|
|
|
|
2010-08-27 04:18:00 +02:00
|
|
|
class CreateAlterProcedureNode : public DdlNode
|
2009-10-21 02:42:38 +02:00
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
CreateAlterProcedureNode(MemoryPool& pool, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(pool),
|
2009-10-21 02:42:38 +02:00
|
|
|
name(pool, aName),
|
|
|
|
create(true),
|
|
|
|
alter(false),
|
|
|
|
external(NULL),
|
|
|
|
parameters(pool),
|
|
|
|
returns(pool),
|
|
|
|
source(pool),
|
|
|
|
localDeclList(NULL),
|
|
|
|
body(NULL),
|
|
|
|
compiled(false),
|
|
|
|
invalid(false),
|
|
|
|
package(pool),
|
|
|
|
packageOwner(pool),
|
|
|
|
privateScope(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
|
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2009-10-21 02:42:38 +02:00
|
|
|
|
|
|
|
protected:
|
2010-07-26 04:37:57 +02:00
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector <<
|
|
|
|
Firebird::Arg::Gds(createAlterCode(create, alter,
|
|
|
|
isc_dsql_create_proc_failed, isc_dsql_alter_proc_failed,
|
|
|
|
isc_dsql_create_alter_proc_failed)) <<
|
|
|
|
name;
|
|
|
|
}
|
|
|
|
|
2009-10-21 02:42:38 +02:00
|
|
|
private:
|
2010-09-17 05:15:32 +02:00
|
|
|
void executeCreate(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
bool executeAlter(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
|
|
|
|
bool secondPass, bool runTriggers);
|
|
|
|
void storeParameter(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
|
2012-12-05 03:07:37 +01:00
|
|
|
USHORT parameterType, unsigned pos, ParameterClause* parameter, const bid* comment);
|
2010-09-17 05:15:32 +02:00
|
|
|
void compile(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch);
|
2010-10-29 02:28:35 +02:00
|
|
|
void collectParamComments(thread_db* tdbb, jrd_tra* transaction, MetaNameBidMap& items);
|
2010-10-29 02:23:18 +02:00
|
|
|
|
2009-10-21 02:42:38 +02:00
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
bool create;
|
|
|
|
bool alter;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<ExternalClause> external;
|
2012-12-05 03:07:37 +01:00
|
|
|
Firebird::Array<NestConst<ParameterClause> > parameters;
|
|
|
|
Firebird::Array<NestConst<ParameterClause> > returns;
|
2009-10-21 02:42:38 +02:00
|
|
|
Firebird::string source;
|
2011-02-22 01:51:56 +01:00
|
|
|
NestConst<CompoundStmtNode> localDeclList;
|
2011-03-06 03:48:34 +01:00
|
|
|
NestConst<StmtNode> body;
|
2009-10-21 02:42:38 +02:00
|
|
|
bool compiled;
|
|
|
|
bool invalid;
|
|
|
|
Firebird::MetaName package;
|
|
|
|
Firebird::string packageOwner;
|
|
|
|
bool privateScope;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DropProcedureNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
DropProcedureNode(MemoryPool& pool, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(pool),
|
2009-10-21 02:42:38 +02:00
|
|
|
name(pool, aName),
|
|
|
|
silent(false),
|
|
|
|
package(pool)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
static void dropParameters(thread_db* tdbb, jrd_tra* transaction,
|
|
|
|
const Firebird::MetaName& procedureName, const Firebird::MetaName& packageName);
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
|
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2009-10-21 02:42:38 +02:00
|
|
|
|
|
|
|
protected:
|
2010-07-26 04:37:57 +02:00
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_drop_proc_failed) << name;
|
|
|
|
}
|
|
|
|
|
2009-10-21 02:42:38 +02:00
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
bool silent;
|
|
|
|
Firebird::MetaName package;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-08-02 17:47:36 +02:00
|
|
|
typedef RecreateNode<CreateAlterProcedureNode, DropProcedureNode, isc_dsql_recreate_proc_failed>
|
|
|
|
RecreateProcedureNode;
|
2009-10-21 02:42:38 +02:00
|
|
|
|
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
class TriggerDefinition
|
|
|
|
{
|
|
|
|
public:
|
2010-08-09 13:50:12 +02:00
|
|
|
explicit TriggerDefinition(MemoryPool& p)
|
2010-07-26 04:37:57 +02:00
|
|
|
: name(p),
|
|
|
|
relationName(p),
|
|
|
|
external(NULL),
|
|
|
|
source(p),
|
|
|
|
systemFlag(fb_sysflag_user),
|
|
|
|
fkTrigger(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-09-17 05:15:32 +02:00
|
|
|
void store(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
bool modify(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2010-07-26 04:37:57 +02:00
|
|
|
|
|
|
|
protected:
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void preModify(thread_db* /*tdbb*/, DsqlCompilerScratch* /*dsqlScratch*/,
|
|
|
|
jrd_tra* /*transaction*/)
|
2010-07-26 04:37:57 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void postModify(thread_db* /*tdbb*/, DsqlCompilerScratch* /*dsqlScratch*/,
|
|
|
|
jrd_tra* /*transaction*/)
|
2010-07-26 04:37:57 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
Firebird::MetaName relationName;
|
2010-07-29 02:20:53 +02:00
|
|
|
Nullable<FB_UINT64> type;
|
|
|
|
Nullable<bool> active;
|
|
|
|
Nullable<int> position;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<ExternalClause> external;
|
2010-07-26 04:37:57 +02:00
|
|
|
Firebird::string source;
|
|
|
|
Firebird::ByteChunk blrData;
|
|
|
|
Firebird::ByteChunk debugData;
|
|
|
|
USHORT systemFlag;
|
|
|
|
bool fkTrigger;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-08-27 04:18:00 +02:00
|
|
|
class CreateAlterTriggerNode : public DdlNode, public TriggerDefinition
|
2009-10-21 02:42:38 +02:00
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
CreateAlterTriggerNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
2010-07-26 04:37:57 +02:00
|
|
|
TriggerDefinition(p),
|
2009-10-21 02:42:38 +02:00
|
|
|
create(true),
|
|
|
|
alter(false),
|
|
|
|
localDeclList(NULL),
|
|
|
|
body(NULL),
|
|
|
|
compiled(false),
|
|
|
|
invalid(false)
|
|
|
|
{
|
2010-07-26 04:37:57 +02:00
|
|
|
name = aName;
|
2009-10-21 02:42:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
|
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2009-10-21 02:42:38 +02:00
|
|
|
|
|
|
|
protected:
|
2010-07-26 04:37:57 +02:00
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector <<
|
|
|
|
Firebird::Arg::Gds(createAlterCode(create, alter,
|
|
|
|
isc_dsql_create_trigger_failed, isc_dsql_alter_trigger_failed,
|
|
|
|
isc_dsql_create_alter_trigger_failed)) <<
|
|
|
|
name;
|
|
|
|
}
|
|
|
|
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void preModify(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction)
|
2010-07-26 04:37:57 +02:00
|
|
|
{
|
|
|
|
if (alter)
|
2010-09-17 05:15:32 +02:00
|
|
|
{
|
|
|
|
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_BEFORE,
|
|
|
|
DDL_TRIGGER_ALTER_TRIGGER, name);
|
|
|
|
}
|
2010-07-26 04:37:57 +02:00
|
|
|
}
|
|
|
|
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void postModify(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction)
|
2010-07-26 04:37:57 +02:00
|
|
|
{
|
|
|
|
if (alter)
|
2010-09-17 05:15:32 +02:00
|
|
|
{
|
|
|
|
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_AFTER,
|
|
|
|
DDL_TRIGGER_ALTER_TRIGGER, name);
|
|
|
|
}
|
2010-07-26 04:37:57 +02:00
|
|
|
}
|
|
|
|
|
2009-10-21 02:42:38 +02:00
|
|
|
private:
|
2010-09-17 05:15:32 +02:00
|
|
|
void executeCreate(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
void compile(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch);
|
2009-10-21 02:42:38 +02:00
|
|
|
|
|
|
|
static inline bool hasOldContext(const unsigned value)
|
|
|
|
{
|
|
|
|
const unsigned val1 = ((value + 1) >> 1) & 3;
|
|
|
|
const unsigned val2 = ((value + 1) >> 3) & 3;
|
|
|
|
const unsigned val3 = ((value + 1) >> 5) & 3;
|
|
|
|
return (val1 && val1 != 1) || (val2 && val2 != 1) || (val3 && val3 != 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool hasNewContext(const unsigned value)
|
|
|
|
{
|
|
|
|
const unsigned val1 = ((value + 1) >> 1) & 3;
|
|
|
|
const unsigned val2 = ((value + 1) >> 3) & 3;
|
|
|
|
const unsigned val3 = ((value + 1) >> 5) & 3;
|
|
|
|
return (val1 && val1 != 3) || (val2 && val2 != 3) || (val3 && val3 != 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool create;
|
|
|
|
bool alter;
|
2011-02-22 01:51:56 +01:00
|
|
|
NestConst<CompoundStmtNode> localDeclList;
|
2011-03-06 03:48:34 +01:00
|
|
|
NestConst<StmtNode> body;
|
2009-10-21 02:42:38 +02:00
|
|
|
bool compiled;
|
|
|
|
bool invalid;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DropTriggerNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
DropTriggerNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
2009-10-21 02:42:38 +02:00
|
|
|
name(p, aName),
|
|
|
|
silent(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
|
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2009-10-21 02:42:38 +02:00
|
|
|
|
|
|
|
protected:
|
2010-07-26 04:37:57 +02:00
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_drop_trigger_failed) << name;
|
|
|
|
}
|
|
|
|
|
2009-10-21 02:42:38 +02:00
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
bool silent;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-08-02 17:47:36 +02:00
|
|
|
typedef RecreateNode<CreateAlterTriggerNode, DropTriggerNode, isc_dsql_recreate_trigger_failed>
|
|
|
|
RecreateTriggerNode;
|
2009-10-21 02:42:38 +02:00
|
|
|
|
|
|
|
|
2010-06-26 03:52:06 +02:00
|
|
|
class CreateCollationNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
CreateCollationNode(MemoryPool& p, const Firebird::MetaName& aName,
|
|
|
|
const Firebird::MetaName& aForCharSet)
|
|
|
|
: DdlNode(p),
|
2010-06-26 03:52:06 +02:00
|
|
|
name(p, aName),
|
|
|
|
forCharSet(p, aForCharSet),
|
|
|
|
fromName(p),
|
|
|
|
fromExternal(p),
|
|
|
|
specificAttributes(p),
|
|
|
|
attributesOn(0),
|
|
|
|
attributesOff(0),
|
|
|
|
forCharSetId(0),
|
|
|
|
fromCollationId(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
|
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2010-06-26 03:52:06 +02:00
|
|
|
|
|
|
|
void setAttribute(USHORT attribute)
|
|
|
|
{
|
|
|
|
if ((attributesOn | attributesOff) & attribute)
|
|
|
|
{
|
|
|
|
// msg: 222: "Invalid collation attributes"
|
|
|
|
using namespace Firebird;
|
2012-01-19 06:42:04 +01:00
|
|
|
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << Arg::PrivateDyn(222));
|
2010-06-26 03:52:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
attributesOn |= attribute;
|
|
|
|
}
|
|
|
|
|
|
|
|
void unsetAttribute(USHORT attribute)
|
|
|
|
{
|
|
|
|
if ((attributesOn | attributesOff) & attribute)
|
|
|
|
{
|
|
|
|
// msg: 222: "Invalid collation attributes"
|
|
|
|
using namespace Firebird;
|
2012-01-19 06:42:04 +01:00
|
|
|
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << Arg::PrivateDyn(222));
|
2010-06-26 03:52:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
attributesOff |= attribute;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2010-07-26 04:37:57 +02:00
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_create_collation_failed) << name;
|
|
|
|
}
|
|
|
|
|
2010-06-26 03:52:06 +02:00
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
Firebird::MetaName forCharSet;
|
|
|
|
Firebird::MetaName fromName;
|
|
|
|
Firebird::string fromExternal;
|
|
|
|
Firebird::UCharBuffer specificAttributes;
|
|
|
|
|
|
|
|
private:
|
|
|
|
USHORT attributesOn;
|
|
|
|
USHORT attributesOff;
|
|
|
|
USHORT forCharSetId;
|
|
|
|
USHORT fromCollationId;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DropCollationNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
DropCollationNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
2010-06-26 03:52:06 +02:00
|
|
|
name(p, aName)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2010-06-26 03:52:06 +02:00
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_drop_collation_failed) << name;
|
|
|
|
}
|
|
|
|
|
2010-06-26 03:52:06 +02:00
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-07-06 02:49:33 +02:00
|
|
|
class CreateDomainNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2012-12-05 03:07:37 +01:00
|
|
|
CreateDomainNode(MemoryPool& p, ParameterClause* aNameType)
|
2010-08-05 02:47:06 +02:00
|
|
|
: DdlNode(p),
|
2010-07-06 02:49:33 +02:00
|
|
|
nameType(aNameType),
|
|
|
|
notNull(false),
|
|
|
|
check(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2010-07-06 02:49:33 +02:00
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
2012-12-05 03:07:37 +01:00
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_create_domain_failed) << nameType->name;
|
2010-07-26 04:37:57 +02:00
|
|
|
}
|
|
|
|
|
2010-07-06 02:49:33 +02:00
|
|
|
public:
|
2012-12-05 03:07:37 +01:00
|
|
|
NestConst<ParameterClause> nameType;
|
2010-07-06 02:49:33 +02:00
|
|
|
bool notNull;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<BoolSourceClause> check;
|
2010-07-06 02:49:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class AlterDomainNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
AlterDomainNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
2010-07-06 02:49:33 +02:00
|
|
|
name(p, aName),
|
|
|
|
dropConstraint(false),
|
|
|
|
dropDefault(false),
|
|
|
|
setConstraint(NULL),
|
|
|
|
setDefault(NULL),
|
|
|
|
renameTo(p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
static void checkUpdate(const dyn_fld& origFld, const dyn_fld& newFld);
|
|
|
|
static ULONG checkUpdateNumericType(const dyn_fld& origFld, const dyn_fld& newFld);
|
2010-07-26 04:37:57 +02:00
|
|
|
static void getDomainType(thread_db* tdbb, jrd_tra* transaction, dyn_fld& dynFld);
|
2010-07-06 02:49:33 +02:00
|
|
|
static void modifyLocalFieldIndex(thread_db* tdbb, jrd_tra* transaction,
|
|
|
|
const Firebird::MetaName& relationName, const Firebird::MetaName& fieldName,
|
|
|
|
const Firebird::MetaName& newFieldName);
|
|
|
|
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2010-07-06 02:49:33 +02:00
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_alter_domain_failed) << name;
|
|
|
|
}
|
|
|
|
|
2010-07-06 02:49:33 +02:00
|
|
|
private:
|
|
|
|
void rename(thread_db* tdbb, jrd_tra* transaction, SSHORT dimensions);
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
bool dropConstraint;
|
|
|
|
bool dropDefault;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<BoolSourceClause> setConstraint;
|
|
|
|
NestConst<ValueSourceClause> setDefault;
|
2010-07-06 02:49:33 +02:00
|
|
|
Firebird::MetaName renameTo;
|
2012-12-05 03:07:37 +01:00
|
|
|
Firebird::AutoPtr<dsql_fld> type;
|
2010-08-10 17:20:20 +02:00
|
|
|
Nullable<bool> notNullFlag; // true = NOT NULL / false = NULL
|
2010-07-06 02:49:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DropDomainNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
DropDomainNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
2010-07-06 02:49:33 +02:00
|
|
|
name(p, aName)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool deleteDimensionRecords(thread_db* tdbb, jrd_tra* transaction,
|
|
|
|
const Firebird::MetaName& name);
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2010-07-06 02:49:33 +02:00
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_drop_domain_failed) << name;
|
|
|
|
}
|
|
|
|
|
2010-07-06 02:49:33 +02:00
|
|
|
private:
|
|
|
|
void check(thread_db* tdbb, jrd_tra* transaction);
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-07-11 20:21:42 +02:00
|
|
|
class CreateAlterExceptionNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
CreateAlterExceptionNode(MemoryPool& p, const Firebird::MetaName& aName,
|
|
|
|
const Firebird::string& aMessage)
|
|
|
|
: DdlNode(p),
|
2010-07-11 20:21:42 +02:00
|
|
|
name(p, aName),
|
|
|
|
message(p, aMessage),
|
|
|
|
create(true),
|
|
|
|
alter(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2010-07-11 20:21:42 +02:00
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector <<
|
|
|
|
Firebird::Arg::Gds(createAlterCode(create, alter,
|
|
|
|
isc_dsql_create_except_failed, isc_dsql_alter_except_failed,
|
|
|
|
isc_dsql_create_alter_except_failed)) <<
|
|
|
|
name;
|
|
|
|
}
|
|
|
|
|
2010-07-11 20:21:42 +02:00
|
|
|
private:
|
2010-09-17 05:15:32 +02:00
|
|
|
void executeCreate(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
bool executeAlter(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2010-07-11 20:21:42 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
Firebird::string message;
|
|
|
|
bool create;
|
|
|
|
bool alter;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DropExceptionNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
DropExceptionNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
2010-07-11 20:21:42 +02:00
|
|
|
name(p, aName),
|
|
|
|
silent(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2010-07-11 20:21:42 +02:00
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_drop_except_failed) << name;
|
|
|
|
}
|
|
|
|
|
2010-07-11 20:21:42 +02:00
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
bool silent;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-08-02 17:47:36 +02:00
|
|
|
typedef RecreateNode<CreateAlterExceptionNode, DropExceptionNode, isc_dsql_recreate_except_failed>
|
|
|
|
RecreateExceptionNode;
|
2010-07-11 20:21:42 +02:00
|
|
|
|
|
|
|
|
2010-01-10 18:32:40 +01:00
|
|
|
class CreateSequenceNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
CreateSequenceNode(MemoryPool& pool, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(pool),
|
2010-01-10 18:32:40 +01:00
|
|
|
name(pool, aName)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
static void store(thread_db* tdbb, jrd_tra* transaction, const Firebird::MetaName& name,
|
|
|
|
fb_sysflag sysFlag);
|
|
|
|
|
2010-01-10 18:32:40 +01:00
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2010-01-10 18:32:40 +01:00
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_create_sequence_failed) << name;
|
|
|
|
}
|
|
|
|
|
2011-11-10 15:55:06 +01:00
|
|
|
public:
|
2010-07-26 04:37:57 +02:00
|
|
|
Firebird::MetaName name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-09 16:30:00 +01:00
|
|
|
class DropSequenceNode : public DdlNode
|
2010-07-26 04:37:57 +02:00
|
|
|
{
|
2010-01-13 20:14:15 +01:00
|
|
|
public:
|
2012-01-19 05:54:39 +01:00
|
|
|
DropSequenceNode(MemoryPool& pool, const Firebird::MetaName& aName)
|
2011-11-09 16:30:00 +01:00
|
|
|
: DdlNode(pool),
|
2011-11-10 15:55:06 +01:00
|
|
|
name(pool, aName),
|
|
|
|
silent(false)
|
2011-11-09 16:30:00 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void deleteIdentity(thread_db* tdbb, jrd_tra* transaction,
|
2010-07-26 04:37:57 +02:00
|
|
|
const Firebird::MetaName& name);
|
2011-11-09 16:30:00 +01:00
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-09 16:30:00 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_drop_sequence_failed) << name;
|
|
|
|
}
|
|
|
|
|
2011-11-10 15:55:06 +01:00
|
|
|
public:
|
2011-11-09 16:30:00 +01:00
|
|
|
Firebird::MetaName name;
|
2011-11-10 15:55:06 +01:00
|
|
|
bool silent;
|
2010-07-26 04:37:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-10 15:55:06 +01:00
|
|
|
typedef RecreateNode<CreateSequenceNode, DropSequenceNode, isc_dsql_recreate_sequence_failed>
|
|
|
|
RecreateSequenceNode;
|
|
|
|
|
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
class RelationNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-02 04:22:26 +02:00
|
|
|
class FieldDefinition
|
|
|
|
{
|
|
|
|
public:
|
2010-08-09 13:50:12 +02:00
|
|
|
explicit FieldDefinition(MemoryPool& p)
|
2010-08-02 04:22:26 +02:00
|
|
|
: name(p),
|
|
|
|
relationName(p),
|
|
|
|
fieldSource(p),
|
|
|
|
identitySequence(p),
|
|
|
|
defaultSource(p),
|
|
|
|
baseField(p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void modify(thread_db* tdbb, jrd_tra* transaction);
|
|
|
|
void store(thread_db* tdbb, jrd_tra* transaction);
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
Firebird::MetaName relationName;
|
|
|
|
Firebird::MetaName fieldSource;
|
|
|
|
Firebird::MetaName identitySequence;
|
|
|
|
Nullable<USHORT> collationId;
|
2010-08-10 17:20:20 +02:00
|
|
|
Nullable<bool> notNullFlag; // true = NOT NULL / false = NULL
|
2010-08-02 04:22:26 +02:00
|
|
|
Nullable<USHORT> position;
|
|
|
|
Firebird::string defaultSource;
|
|
|
|
Firebird::ByteChunk defaultValue;
|
|
|
|
Nullable<USHORT> viewContext;
|
|
|
|
Firebird::MetaName baseField;
|
|
|
|
};
|
|
|
|
|
2012-03-18 23:22:14 +01:00
|
|
|
struct IndexConstraintClause
|
|
|
|
{
|
2012-04-10 03:52:05 +02:00
|
|
|
explicit IndexConstraintClause(MemoryPool& p)
|
2012-03-18 23:22:14 +01:00
|
|
|
: name(p),
|
|
|
|
descending(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Firebird::MetaName name;
|
|
|
|
bool descending;
|
|
|
|
};
|
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
struct Constraint : public PermanentStorage
|
|
|
|
{
|
|
|
|
enum Type { TYPE_CHECK, TYPE_NOT_NULL, TYPE_PK, TYPE_UNIQUE, TYPE_FK };
|
|
|
|
|
|
|
|
// Specialized BlrWriter for constraints.
|
|
|
|
class BlrWriter : public Jrd::BlrWriter
|
|
|
|
{
|
|
|
|
public:
|
2010-08-09 13:50:12 +02:00
|
|
|
explicit BlrWriter(MemoryPool& p)
|
2010-07-26 04:37:57 +02:00
|
|
|
: Jrd::BlrWriter(p),
|
|
|
|
dsqlScratch(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void init(DsqlCompilerScratch* aDsqlScratch)
|
|
|
|
{
|
|
|
|
dsqlScratch = aDsqlScratch;
|
|
|
|
dsqlScratch->getBlrData().clear();
|
|
|
|
dsqlScratch->getDebugData().clear();
|
|
|
|
appendUChar(isVersion4() ? blr_version4 : blr_version5);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isVersion4()
|
|
|
|
{
|
|
|
|
return dsqlScratch->isVersion4();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
DsqlCompilerScratch* dsqlScratch;
|
|
|
|
};
|
|
|
|
|
2010-08-09 13:50:12 +02:00
|
|
|
explicit Constraint(MemoryPool& p)
|
2010-07-26 04:37:57 +02:00
|
|
|
: PermanentStorage(p),
|
|
|
|
type(TYPE_CHECK), // Just something to initialize. Do not assume it.
|
|
|
|
name(p),
|
|
|
|
columns(p),
|
2012-03-18 23:22:14 +01:00
|
|
|
index(NULL),
|
2010-07-26 04:37:57 +02:00
|
|
|
refRelation(p),
|
|
|
|
refColumns(p),
|
2010-08-03 03:09:39 +02:00
|
|
|
refUpdateAction(RI_RESTRICT),
|
|
|
|
refDeleteAction(RI_RESTRICT),
|
2010-07-26 04:37:57 +02:00
|
|
|
triggers(p),
|
|
|
|
blrWritersHolder(p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Constraint::Type type;
|
|
|
|
Firebird::MetaName name;
|
|
|
|
Firebird::ObjectsArray<Firebird::MetaName> columns;
|
2012-05-03 18:43:29 +02:00
|
|
|
const IndexConstraintClause* index;
|
2010-07-26 04:37:57 +02:00
|
|
|
Firebird::MetaName refRelation;
|
|
|
|
Firebird::ObjectsArray<Firebird::MetaName> refColumns;
|
|
|
|
const char* refUpdateAction;
|
|
|
|
const char* refDeleteAction;
|
|
|
|
Firebird::ObjectsArray<TriggerDefinition> triggers;
|
|
|
|
Firebird::ObjectsArray<BlrWriter> blrWritersHolder;
|
|
|
|
};
|
|
|
|
|
2012-03-18 22:37:13 +01:00
|
|
|
struct Clause : public PermanentStorage
|
|
|
|
{
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
TYPE_ADD_CONSTRAINT,
|
|
|
|
TYPE_ADD_COLUMN,
|
|
|
|
TYPE_ALTER_COL_NAME,
|
|
|
|
TYPE_ALTER_COL_NULL,
|
|
|
|
TYPE_ALTER_COL_POS,
|
|
|
|
TYPE_ALTER_COL_TYPE,
|
|
|
|
TYPE_DROP_COLUMN,
|
|
|
|
TYPE_DROP_CONSTRAINT
|
|
|
|
};
|
|
|
|
|
|
|
|
explicit Clause(MemoryPool& p, Type aType)
|
|
|
|
: PermanentStorage(p),
|
|
|
|
type(aType)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const Type type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RefActionClause
|
|
|
|
{
|
|
|
|
static const unsigned ACTION_CASCADE = 1;
|
|
|
|
static const unsigned ACTION_SET_DEFAULT = 2;
|
|
|
|
static const unsigned ACTION_SET_NULL = 3;
|
|
|
|
static const unsigned ACTION_NONE = 4;
|
|
|
|
|
|
|
|
RefActionClause(MemoryPool& p, unsigned aUpdateAction, unsigned aDeleteAction)
|
|
|
|
: updateAction(aUpdateAction),
|
|
|
|
deleteAction(aDeleteAction)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned updateAction;
|
|
|
|
unsigned deleteAction;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AddConstraintClause : public Clause
|
|
|
|
{
|
|
|
|
enum ConstraintType
|
|
|
|
{
|
|
|
|
CTYPE_NOT_NULL,
|
|
|
|
CTYPE_PK,
|
|
|
|
CTYPE_FK,
|
|
|
|
CTYPE_UNIQUE,
|
|
|
|
CTYPE_CHECK
|
|
|
|
};
|
|
|
|
|
2012-04-10 03:52:05 +02:00
|
|
|
explicit AddConstraintClause(MemoryPool& p)
|
2012-03-18 22:37:13 +01:00
|
|
|
: Clause(p, TYPE_ADD_CONSTRAINT),
|
|
|
|
name(p),
|
|
|
|
constraintType(CTYPE_NOT_NULL),
|
|
|
|
columns(p),
|
2012-03-18 23:22:14 +01:00
|
|
|
index(NULL),
|
2012-03-18 22:37:13 +01:00
|
|
|
refRelation(p),
|
|
|
|
refColumns(p),
|
|
|
|
refAction(NULL),
|
|
|
|
check(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Firebird::MetaName name;
|
|
|
|
ConstraintType constraintType;
|
|
|
|
Firebird::ObjectsArray<Firebird::MetaName> columns;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<IndexConstraintClause> index;
|
2012-03-18 22:37:13 +01:00
|
|
|
Firebird::MetaName refRelation;
|
|
|
|
Firebird::ObjectsArray<Firebird::MetaName> refColumns;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<RefActionClause> refAction;
|
|
|
|
NestConst<BoolSourceClause> check;
|
2012-03-18 22:37:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct AddColumnClause : public Clause
|
|
|
|
{
|
|
|
|
explicit AddColumnClause(MemoryPool& p)
|
|
|
|
: Clause(p, TYPE_ADD_COLUMN),
|
|
|
|
field(NULL),
|
|
|
|
defaultValue(NULL),
|
|
|
|
constraints(p),
|
|
|
|
collate(p),
|
|
|
|
computed(NULL),
|
|
|
|
identity(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
dsql_fld* field;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<ValueSourceClause> defaultValue;
|
2012-03-18 22:37:13 +01:00
|
|
|
Firebird::ObjectsArray<AddConstraintClause> constraints;
|
|
|
|
Firebird::MetaName collate;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<ValueSourceClause> computed;
|
2012-03-18 22:37:13 +01:00
|
|
|
bool identity;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AlterColNameClause : public Clause
|
|
|
|
{
|
|
|
|
explicit AlterColNameClause(MemoryPool& p)
|
|
|
|
: Clause(p, TYPE_ALTER_COL_NAME),
|
|
|
|
fromName(p),
|
|
|
|
toName(p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Firebird::MetaName fromName;
|
|
|
|
Firebird::MetaName toName;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AlterColNullClause : public Clause
|
|
|
|
{
|
|
|
|
explicit AlterColNullClause(MemoryPool& p)
|
|
|
|
: Clause(p, TYPE_ALTER_COL_NULL),
|
|
|
|
name(p),
|
|
|
|
notNullFlag(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Firebird::MetaName name;
|
|
|
|
bool notNullFlag;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AlterColPosClause : public Clause
|
|
|
|
{
|
|
|
|
explicit AlterColPosClause(MemoryPool& p)
|
|
|
|
: Clause(p, TYPE_ALTER_COL_POS),
|
|
|
|
name(p),
|
|
|
|
newPos(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Firebird::MetaName name;
|
|
|
|
SSHORT newPos;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AlterColTypeClause : public Clause
|
|
|
|
{
|
|
|
|
explicit AlterColTypeClause(MemoryPool& p)
|
|
|
|
: Clause(p, TYPE_ALTER_COL_TYPE),
|
|
|
|
field(NULL),
|
|
|
|
defaultValue(NULL),
|
|
|
|
dropDefault(false),
|
|
|
|
computed(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
dsql_fld* field;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<ValueSourceClause> defaultValue;
|
2012-03-18 22:37:13 +01:00
|
|
|
bool dropDefault;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<ValueSourceClause> computed;
|
2012-03-18 22:37:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DropColumnClause : public Clause
|
|
|
|
{
|
|
|
|
explicit DropColumnClause(MemoryPool& p)
|
|
|
|
: Clause(p, TYPE_DROP_COLUMN),
|
|
|
|
name(p),
|
|
|
|
cascade(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Firebird::MetaName name;
|
|
|
|
bool cascade;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DropConstraintClause : public Clause
|
|
|
|
{
|
|
|
|
explicit DropConstraintClause(MemoryPool& p)
|
|
|
|
: Clause(p, TYPE_DROP_CONSTRAINT),
|
|
|
|
name(p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Firebird::MetaName name;
|
|
|
|
};
|
|
|
|
|
2012-04-25 03:42:47 +02:00
|
|
|
RelationNode(MemoryPool& p, RelationSourceNode* aDsqlNode);
|
2010-07-26 04:37:57 +02:00
|
|
|
|
|
|
|
static void deleteLocalField(thread_db* tdbb, jrd_tra* transaction,
|
|
|
|
const Firebird::MetaName& relationName, const Firebird::MetaName& fieldName);
|
|
|
|
|
|
|
|
protected:
|
2010-09-17 05:15:32 +02:00
|
|
|
void defineField(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
|
2012-05-03 18:43:29 +02:00
|
|
|
AddColumnClause* clause, SSHORT position,
|
2012-03-18 22:37:13 +01:00
|
|
|
const Firebird::ObjectsArray<Firebird::MetaName>* pkcols);
|
2010-09-17 05:15:32 +02:00
|
|
|
bool defineDefault(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, dsql_fld* field,
|
2012-05-03 18:43:29 +02:00
|
|
|
ValueSourceClause* clause, Firebird::string& source, BlrWriter::BlrData& value);
|
2010-09-17 05:15:32 +02:00
|
|
|
void makeConstraint(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
|
2012-05-03 18:43:29 +02:00
|
|
|
AddConstraintClause* clause, Firebird::ObjectsArray<Constraint>& constraints,
|
2012-03-18 22:37:13 +01:00
|
|
|
bool* notNull = NULL);
|
2010-09-17 05:15:32 +02:00
|
|
|
void defineConstraint(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
|
|
|
|
Constraint& constraint);
|
|
|
|
void defineCheckConstraint(DsqlCompilerScratch* dsqlScratch, Constraint& constraint,
|
2012-05-03 18:43:29 +02:00
|
|
|
BoolSourceClause* clause);
|
2010-09-17 05:15:32 +02:00
|
|
|
void defineCheckConstraintTrigger(DsqlCompilerScratch* dsqlScratch, Constraint& constraint,
|
2012-05-03 18:43:29 +02:00
|
|
|
BoolSourceClause* clause, FB_UINT64 triggerType);
|
2010-09-17 05:15:32 +02:00
|
|
|
void defineSetDefaultTrigger(DsqlCompilerScratch* dsqlScratch, Constraint& constraint,
|
|
|
|
bool onUpdate);
|
|
|
|
void defineSetNullTrigger(DsqlCompilerScratch* dsqlScratch, Constraint& constraint,
|
|
|
|
bool onUpdate);
|
|
|
|
void defineDeleteCascadeTrigger(DsqlCompilerScratch* dsqlScratch, Constraint& constraint);
|
|
|
|
void defineUpdateCascadeTrigger(DsqlCompilerScratch* dsqlScratch, Constraint& constraint);
|
|
|
|
void generateUnnamedTriggerBeginning(Constraint& constraint, bool onUpdate,
|
|
|
|
BlrWriter& blrWriter);
|
2010-07-26 04:37:57 +02:00
|
|
|
void stuffDefaultBlr(const Firebird::ByteChunk& defaultBlr, BlrWriter& blrWriter);
|
|
|
|
void stuffMatchingBlr(Constraint& constraint, BlrWriter& blrWriter);
|
2010-08-09 13:50:12 +02:00
|
|
|
void stuffTriggerFiringCondition(const Constraint& constraint, BlrWriter& blrWriter);
|
2010-07-26 04:37:57 +02:00
|
|
|
|
|
|
|
public:
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<RelationSourceNode> dsqlNode;
|
2010-07-26 04:37:57 +02:00
|
|
|
Firebird::MetaName name;
|
2012-05-03 18:43:29 +02:00
|
|
|
Firebird::Array<NestConst<Clause> > clauses;
|
2010-07-26 04:37:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CreateRelationNode : public RelationNode
|
|
|
|
{
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
CreateRelationNode(MemoryPool& p, RelationSourceNode* aDsqlNode,
|
2010-08-05 02:47:06 +02:00
|
|
|
const Firebird::PathName* aExternalFile = NULL)
|
|
|
|
: RelationNode(p, aDsqlNode),
|
2010-07-26 04:37:57 +02:00
|
|
|
externalFile(aExternalFile),
|
|
|
|
relationType(rel_persistent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2010-07-26 04:37:57 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_create_table_failed) << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-03-18 22:37:13 +01:00
|
|
|
const Firebird::ObjectsArray<Firebird::MetaName>* findPkColumns();
|
2010-07-26 04:37:57 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
const Firebird::PathName* externalFile;
|
|
|
|
rel_t relationType;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class AlterRelationNode : public RelationNode
|
|
|
|
{
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
AlterRelationNode(MemoryPool& p, RelationSourceNode* aDsqlNode)
|
2010-08-05 02:47:06 +02:00
|
|
|
: RelationNode(p, aDsqlNode)
|
2010-07-26 04:37:57 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2010-07-26 04:37:57 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_alter_table_failed) << name;
|
|
|
|
}
|
2010-01-13 20:14:15 +01:00
|
|
|
|
2010-01-10 18:32:40 +01:00
|
|
|
private:
|
2010-09-17 05:15:32 +02:00
|
|
|
void modifyField(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction,
|
2012-05-03 18:43:29 +02:00
|
|
|
AlterColTypeClause* clause);
|
2010-07-26 04:37:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DropRelationNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
DropRelationNode(MemoryPool& p, const Firebird::MetaName& aName, bool aView = false)
|
|
|
|
: DdlNode(p),
|
2010-07-26 04:37:57 +02:00
|
|
|
name(p, aName),
|
|
|
|
view(aView),
|
|
|
|
silent(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void deleteGlobalField(thread_db* tdbb, jrd_tra* transaction,
|
|
|
|
const Firebird::MetaName& globalName);
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2010-07-26 04:37:57 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_drop_table_failed) << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2010-01-10 18:32:40 +01:00
|
|
|
Firebird::MetaName name;
|
2010-07-26 04:37:57 +02:00
|
|
|
bool view;
|
|
|
|
bool silent;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-08-02 17:47:36 +02:00
|
|
|
typedef RecreateNode<CreateRelationNode, DropRelationNode, isc_dsql_recreate_table_failed>
|
|
|
|
RecreateTableNode;
|
2010-07-26 04:37:57 +02:00
|
|
|
|
|
|
|
|
2010-08-02 04:22:26 +02:00
|
|
|
class CreateAlterViewNode : public RelationNode
|
|
|
|
{
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
CreateAlterViewNode(MemoryPool& p, RelationSourceNode* aDsqlNode, ValueListNode* aViewFields,
|
|
|
|
SelectExprNode* aSelectExpr)
|
2010-08-05 02:47:06 +02:00
|
|
|
: RelationNode(p, aDsqlNode),
|
2010-08-02 04:22:26 +02:00
|
|
|
create(true),
|
|
|
|
alter(false),
|
|
|
|
viewFields(aViewFields),
|
|
|
|
selectExpr(aSelectExpr),
|
|
|
|
source(p),
|
|
|
|
withCheckOption(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-04-01 20:39:41 +02:00
|
|
|
virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
|
2010-09-17 05:15:32 +02:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
2010-08-02 04:22:26 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector <<
|
|
|
|
Firebird::Arg::Gds(createAlterCode(create, alter,
|
|
|
|
isc_dsql_create_view_failed, isc_dsql_alter_view_failed,
|
|
|
|
isc_dsql_create_alter_view_failed)) <<
|
|
|
|
name;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-05-20 21:28:52 +02:00
|
|
|
void createCheckTrigger(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, ValueListNode* items);
|
2010-08-02 04:22:26 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
bool create;
|
|
|
|
bool alter;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<ValueListNode> viewFields;
|
|
|
|
NestConst<SelectExprNode> selectExpr;
|
2010-08-02 04:22:26 +02:00
|
|
|
Firebird::string source;
|
|
|
|
bool withCheckOption;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-08-02 17:47:36 +02:00
|
|
|
class RecreateViewNode :
|
|
|
|
public RecreateNode<CreateAlterViewNode, DropRelationNode, isc_dsql_recreate_view_failed>
|
|
|
|
{
|
|
|
|
public:
|
2010-08-05 02:47:06 +02:00
|
|
|
RecreateViewNode(MemoryPool& p, CreateAlterViewNode* aCreateNode)
|
2010-08-03 01:13:06 +02:00
|
|
|
: RecreateNode<CreateAlterViewNode, DropRelationNode, isc_dsql_recreate_view_failed>(
|
2010-08-05 02:47:06 +02:00
|
|
|
p, aCreateNode)
|
2010-08-02 17:47:36 +02:00
|
|
|
{
|
|
|
|
dropNode.view = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-27 20:08:06 +01:00
|
|
|
class CreateIndexNode : public DdlNode
|
2010-07-26 04:37:57 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct Definition
|
|
|
|
{
|
|
|
|
Definition()
|
|
|
|
: type(0)
|
|
|
|
{
|
|
|
|
expressionBlr.clear();
|
|
|
|
expressionSource.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
Firebird::MetaName relation;
|
|
|
|
Firebird::ObjectsArray<Firebird::MetaName> columns;
|
2010-07-29 02:20:53 +02:00
|
|
|
Nullable<bool> unique;
|
|
|
|
Nullable<bool> descending;
|
|
|
|
Nullable<bool> inactive;
|
2010-07-26 04:37:57 +02:00
|
|
|
SSHORT type;
|
|
|
|
bid expressionBlr;
|
|
|
|
bid expressionSource;
|
|
|
|
Firebird::MetaName refRelation;
|
|
|
|
Firebird::ObjectsArray<Firebird::MetaName> refColumns;
|
|
|
|
};
|
|
|
|
|
2011-11-27 20:08:06 +01:00
|
|
|
public:
|
|
|
|
CreateIndexNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
|
|
|
name(p, aName),
|
|
|
|
unique(false),
|
|
|
|
descending(false),
|
2012-04-25 03:42:47 +02:00
|
|
|
relation(NULL),
|
2012-03-18 22:37:13 +01:00
|
|
|
columns(NULL),
|
|
|
|
computed(NULL)
|
2011-11-27 20:08:06 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2010-07-26 04:37:57 +02:00
|
|
|
static void store(thread_db* tdbb, jrd_tra* transaction, Firebird::MetaName& name,
|
2010-08-09 13:50:12 +02:00
|
|
|
const Definition& definition, Firebird::MetaName* referredIndexName = NULL);
|
2011-11-27 20:08:06 +01:00
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-27 20:08:06 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_create_index_failed) << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
bool unique;
|
|
|
|
bool descending;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<RelationSourceNode> relation;
|
|
|
|
NestConst<ValueListNode> columns;
|
|
|
|
NestConst<ValueSourceClause> computed;
|
2010-07-26 04:37:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-22 17:33:25 +01:00
|
|
|
class AlterIndexNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AlterIndexNode(MemoryPool& p, const Firebird::MetaName& aName, bool aActive)
|
|
|
|
: DdlNode(p),
|
|
|
|
name(p, aName),
|
|
|
|
active(aActive)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-22 17:33:25 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_alter_index_failed) << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
bool active;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SetStatisticsNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SetStatisticsNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
|
|
|
name(p, aName)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-22 17:33:25 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
// ASF: using ALTER INDEX's code.
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_alter_index_failed) << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-13 22:32:12 +01:00
|
|
|
class DropIndexNode : public DdlNode
|
2010-07-26 04:37:57 +02:00
|
|
|
{
|
|
|
|
public:
|
2011-11-13 22:32:12 +01:00
|
|
|
DropIndexNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
|
|
|
name(p, aName)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-07-26 04:37:57 +02:00
|
|
|
static bool deleteSegmentRecords(thread_db* tdbb, jrd_tra* transaction,
|
|
|
|
const Firebird::MetaName& name);
|
2011-11-13 22:32:12 +01:00
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-13 22:32:12 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_drop_index_failed) << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-27 20:08:06 +01:00
|
|
|
class CreateFilterNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct NameNumber
|
|
|
|
{
|
|
|
|
NameNumber(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: name(p, aName),
|
|
|
|
number(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NameNumber(MemoryPool& p, SSHORT aNumber)
|
|
|
|
: name(p),
|
|
|
|
number(aNumber)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Firebird::MetaName name;
|
|
|
|
SSHORT number;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
CreateFilterNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
|
|
|
name(p, aName),
|
|
|
|
inputFilter(NULL),
|
|
|
|
outputFilter(NULL),
|
|
|
|
entryPoint(p),
|
|
|
|
moduleName(p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-27 20:08:06 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_create_filter_failed) << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<NameNumber> inputFilter;
|
|
|
|
NestConst<NameNumber> outputFilter;
|
2011-11-27 20:08:06 +01:00
|
|
|
Firebird::string entryPoint;
|
|
|
|
Firebird::string moduleName;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-13 22:32:12 +01:00
|
|
|
class DropFilterNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DropFilterNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
|
|
|
name(p, aName)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-13 22:32:12 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_drop_filter_failed) << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-22 17:33:25 +01:00
|
|
|
class CreateShadowNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CreateShadowNode(MemoryPool& p, const SSHORT aNumber)
|
|
|
|
: DdlNode(p),
|
|
|
|
number(aNumber),
|
|
|
|
manual(false),
|
|
|
|
conditional(false),
|
|
|
|
files(p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-22 17:33:25 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_create_shadow_failed) << Firebird::Arg::Num(number);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
SSHORT number;
|
|
|
|
bool manual;
|
|
|
|
bool conditional;
|
|
|
|
Nullable<SLONG> firstLength;
|
2012-05-03 18:43:29 +02:00
|
|
|
Firebird::Array<NestConst<DbFileClause> > files;
|
2011-11-22 17:33:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-13 22:32:12 +01:00
|
|
|
class DropShadowNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DropShadowNode(MemoryPool& p, const SSHORT aNumber)
|
|
|
|
: DdlNode(p),
|
|
|
|
number(aNumber)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-13 22:32:12 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_drop_shadow_failed) << Firebird::Arg::Num(number);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
SSHORT number;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CreateRoleNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CreateRoleNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
|
|
|
name(p, aName)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-13 22:32:12 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_create_role_failed) << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool isItUserName(thread_db* tdbb, jrd_tra* transaction);
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-22 17:33:25 +01:00
|
|
|
class AlterRoleNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AlterRoleNode(MemoryPool& p, const Firebird::MetaName& aName, bool aMap)
|
|
|
|
: DdlNode(p),
|
|
|
|
name(p, aName),
|
|
|
|
map(aMap)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-22 17:33:25 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_alter_role_failed) << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
bool map;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-13 22:32:12 +01:00
|
|
|
class DropRoleNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DropRoleNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
|
|
|
name(p, aName)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-13 22:32:12 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_drop_role_failed) << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-01-08 19:33:59 +01:00
|
|
|
class CreateAlterUserNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CreateAlterUserNode(MemoryPool& p, bool creating, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
|
|
|
isCreating(creating),
|
|
|
|
name(p, aName)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2012-01-08 19:33:59 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isCreating ?
|
|
|
|
isc_dsql_create_user_failed : isc_dsql_alter_user_failed) << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
const bool isCreating;
|
|
|
|
const Firebird::MetaName name;
|
2012-03-23 18:44:17 +01:00
|
|
|
const IntlString* password;
|
2012-01-08 19:33:59 +01:00
|
|
|
const Firebird::string* firstName;
|
|
|
|
const Firebird::string* middleName;
|
|
|
|
const Firebird::string* lastName;
|
|
|
|
Nullable<int> adminRole;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-13 22:32:12 +01:00
|
|
|
class DropUserNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DropUserNode(MemoryPool& p, const Firebird::MetaName& aName)
|
|
|
|
: DdlNode(p),
|
|
|
|
name(p, aName)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-13 22:32:12 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_drop_user_failed) << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
Firebird::MetaName name;
|
2010-01-10 18:32:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-04-25 03:42:47 +02:00
|
|
|
typedef Firebird::Pair<Firebird::NonPooled<char, ValueListNode*> > PrivilegeClause;
|
|
|
|
typedef Firebird::Pair<Firebird::NonPooled<SSHORT, Firebird::MetaName> > GranteeClause;
|
|
|
|
|
2012-02-19 03:17:27 +01:00
|
|
|
class GrantRevokeNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GrantRevokeNode(MemoryPool& p, bool aIsGrant)
|
|
|
|
: DdlNode(p),
|
|
|
|
isGrant(aIsGrant),
|
2012-04-25 03:42:47 +02:00
|
|
|
privileges(p),
|
|
|
|
roles(p),
|
2012-02-19 03:17:27 +01:00
|
|
|
table(NULL),
|
2012-04-25 03:42:47 +02:00
|
|
|
users(p),
|
2012-02-19 03:17:27 +01:00
|
|
|
grantAdminOption(NULL),
|
|
|
|
grantor(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2012-02-19 03:17:27 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector <<
|
|
|
|
Firebird::Arg::Gds(isGrant ? isc_dsql_grant_failed : isc_dsql_revoke_failed);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-04-25 03:42:47 +02:00
|
|
|
void modifyPrivileges(thread_db* tdbb, jrd_tra* transaction, SSHORT option, const GranteeClause* user);
|
|
|
|
void grantRevoke(thread_db* tdbb, jrd_tra* transaction, const GranteeClause* table,
|
|
|
|
const GranteeClause* userNod, const char* privs, const Firebird::MetaName& field, int options);
|
2012-02-19 03:17:27 +01:00
|
|
|
static void checkGrantorCanGrant(thread_db* tdbb, jrd_tra* transaction, const char* grantor,
|
|
|
|
const char* privilege, const Firebird::MetaName& relationName,
|
|
|
|
const Firebird::MetaName& fieldName, bool topLevel);
|
|
|
|
static void checkGrantorCanGrantRole(thread_db* tdbb, jrd_tra* transaction,
|
|
|
|
const Firebird::MetaName& grantor, const Firebird::MetaName& roleName);
|
|
|
|
static void storePrivilege(thread_db* tdbb, jrd_tra* transaction,
|
|
|
|
const Firebird::MetaName& object, const Firebird::MetaName& user,
|
|
|
|
const Firebird::MetaName& field, const TEXT* privilege, SSHORT userType,
|
|
|
|
SSHORT objType, int option, const Firebird::MetaName& grantor);
|
|
|
|
static void setFieldClassName(thread_db* tdbb, jrd_tra* transaction,
|
|
|
|
const Firebird::MetaName& relation, const Firebird::MetaName& field);
|
|
|
|
|
|
|
|
// Diagnostics print helper.
|
|
|
|
static const char* privilegeName(char symbol)
|
|
|
|
{
|
|
|
|
switch (UPPER7(symbol))
|
|
|
|
{
|
|
|
|
case 'A': return "All";
|
|
|
|
case 'I': return "Insert";
|
|
|
|
case 'U': return "Update";
|
|
|
|
case 'D': return "Delete";
|
|
|
|
case 'S': return "Select";
|
|
|
|
case 'X': return "Execute";
|
|
|
|
case 'M': return "Role";
|
|
|
|
case 'R': return "Reference";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "<Unknown>";
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool isGrant;
|
2012-04-25 03:42:47 +02:00
|
|
|
Firebird::Array<PrivilegeClause> privileges;
|
|
|
|
Firebird::Array<GranteeClause> roles;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<GranteeClause> table;
|
2012-04-25 03:42:47 +02:00
|
|
|
Firebird::Array<GranteeClause> users;
|
|
|
|
bool grantAdminOption;
|
2012-05-03 18:43:29 +02:00
|
|
|
NestConst<Firebird::MetaName> grantor;
|
2012-02-19 03:17:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-22 17:33:25 +01:00
|
|
|
class AlterDatabaseNode : public DdlNode
|
|
|
|
{
|
|
|
|
public:
|
2012-06-03 05:00:24 +02:00
|
|
|
static const unsigned CLAUSE_BEGIN_BACKUP = 0x01;
|
|
|
|
static const unsigned CLAUSE_END_BACKUP = 0x02;
|
|
|
|
static const unsigned CLAUSE_DROP_DIFFERENCE = 0x04;
|
|
|
|
static const unsigned CLAUSE_DECRYPT = 0x08;
|
2012-05-31 18:53:42 +02:00
|
|
|
|
2012-06-03 05:00:24 +02:00
|
|
|
static const unsigned RDB_DATABASE_MASK =
|
|
|
|
CLAUSE_BEGIN_BACKUP | CLAUSE_END_BACKUP | CLAUSE_DROP_DIFFERENCE;
|
2011-11-22 17:33:25 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
AlterDatabaseNode(MemoryPool& p)
|
|
|
|
: DdlNode(p),
|
|
|
|
create(false),
|
|
|
|
createLength(0),
|
|
|
|
clauses(0),
|
|
|
|
differenceFile(p),
|
|
|
|
setDefaultCharSet(p),
|
|
|
|
setDefaultCollation(p),
|
2012-05-31 18:53:42 +02:00
|
|
|
files(p),
|
|
|
|
cryptPlugin(p)
|
2011-11-22 17:33:25 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual DdlNode* dsqlPass(DsqlCompilerScratch* dsqlScratch)
|
|
|
|
{
|
|
|
|
dsqlScratch->getStatement()->setType(
|
|
|
|
create ? DsqlCompiledStatement::TYPE_CREATE_DB : DsqlCompiledStatement::TYPE_DDL);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-04-25 03:42:47 +02:00
|
|
|
virtual void print(Firebird::string& text) const;
|
2011-11-22 17:33:25 +01:00
|
|
|
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
|
|
|
{
|
|
|
|
statusVector << Firebird::Arg::Gds(isc_dsql_alter_database_failed);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static void changeBackupMode(thread_db* tdbb, jrd_tra* transaction, unsigned clause);
|
|
|
|
static void defineDifference(thread_db* tdbb, jrd_tra* transaction, const Firebird::PathName& file);
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool create; // Is the node created with a CREATE DATABASE command?
|
|
|
|
SLONG createLength;
|
|
|
|
unsigned clauses;
|
|
|
|
Firebird::PathName differenceFile;
|
|
|
|
Firebird::MetaName setDefaultCharSet;
|
|
|
|
Firebird::MetaName setDefaultCollation;
|
2012-05-03 18:43:29 +02:00
|
|
|
Firebird::Array<NestConst<DbFileClause> > files;
|
2012-05-31 18:53:42 +02:00
|
|
|
Firebird::MetaName cryptPlugin;
|
2011-11-22 17:33:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-05-19 15:47:48 +02:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif // DSQL_DDL_NODES_H
|