2009-12-27 23:05:22 +01:00
|
|
|
/*
|
|
|
|
* The contents of this file are subject to the Interbase 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.Inprise.com/IPL.html
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an
|
|
|
|
* "AS IS" basis, 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 Inprise Corporation
|
|
|
|
* and its predecessors. Portions created by Inprise Corporation are
|
|
|
|
* Copyright (C) Inprise Corporation.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
|
|
|
* Adriano dos Santos Fernandes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef JRD_ROUTINE_H
|
|
|
|
#define JRD_ROUTINE_H
|
|
|
|
|
|
|
|
#include "../common/classes/array.h"
|
|
|
|
#include "../common/classes/alloc.h"
|
2013-03-31 17:55:01 +02:00
|
|
|
#include "../common/classes/BlrReader.h"
|
2009-12-27 23:05:22 +01:00
|
|
|
#include "../common/classes/MetaName.h"
|
2013-03-27 02:34:10 +01:00
|
|
|
#include "../common/classes/QualifiedName.h"
|
|
|
|
#include "../common/classes/NestConst.h"
|
|
|
|
#include "../common/MsgMetadata.h"
|
2009-12-27 23:05:22 +01:00
|
|
|
|
|
|
|
namespace Jrd
|
|
|
|
{
|
2013-03-31 17:55:01 +02:00
|
|
|
class thread_db;
|
|
|
|
class CompilerScratch;
|
2010-04-19 00:19:11 +02:00
|
|
|
class JrdStatement;
|
2013-03-27 02:34:10 +01:00
|
|
|
class Format;
|
2011-10-16 22:36:07 +02:00
|
|
|
class Parameter;
|
2009-12-27 23:05:22 +01:00
|
|
|
|
|
|
|
class Routine : public Firebird::PermanentStorage
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
explicit Routine(MemoryPool& p)
|
|
|
|
: PermanentStorage(p),
|
|
|
|
id(0),
|
|
|
|
name(p),
|
|
|
|
securityName(p),
|
2010-04-19 00:19:11 +02:00
|
|
|
statement(NULL),
|
2011-10-03 00:11:41 +02:00
|
|
|
subRoutine(false),
|
2011-10-16 22:36:07 +02:00
|
|
|
implemented(true),
|
2011-11-10 15:35:40 +01:00
|
|
|
defined(true),
|
2011-10-16 22:36:07 +02:00
|
|
|
defaultCount(0),
|
|
|
|
inputFormat(NULL),
|
|
|
|
outputFormat(NULL),
|
|
|
|
inputFields(p),
|
|
|
|
outputFields(p)
|
2009-12-27 23:05:22 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~Routine()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-03-27 02:34:10 +01:00
|
|
|
public:
|
|
|
|
static Firebird::MsgMetadata* createMetadata(
|
|
|
|
const Firebird::Array<NestConst<Parameter> >& parameters);
|
2013-03-27 02:34:44 +01:00
|
|
|
static Format* createFormat(MemoryPool& pool, Firebird::IMessageMetadata* params, bool addEof);
|
2013-03-27 02:34:10 +01:00
|
|
|
|
2009-12-27 23:05:22 +01:00
|
|
|
public:
|
2011-10-03 00:11:41 +02:00
|
|
|
USHORT getId() const
|
|
|
|
{
|
|
|
|
fb_assert(!subRoutine);
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2009-12-27 23:05:22 +01:00
|
|
|
void setId(USHORT value) { id = value; }
|
|
|
|
|
|
|
|
const Firebird::QualifiedName& getName() const { return name; }
|
|
|
|
void setName(const Firebird::QualifiedName& value) { name = value; }
|
|
|
|
|
|
|
|
const Firebird::MetaName& getSecurityName() const { return securityName; }
|
|
|
|
void setSecurityName(const Firebird::MetaName& value) { securityName = value; }
|
|
|
|
|
2010-04-19 00:19:11 +02:00
|
|
|
/*const*/ JrdStatement* getStatement() const { return statement; }
|
|
|
|
void setStatement(JrdStatement* value) { statement = value; }
|
2009-12-27 23:05:22 +01:00
|
|
|
|
2011-10-03 00:11:41 +02:00
|
|
|
bool isSubRoutine() const { return subRoutine; }
|
|
|
|
void setSubRoutine(bool value) { subRoutine = value; }
|
|
|
|
|
2010-10-12 13:36:51 +02:00
|
|
|
bool isImplemented() const { return implemented; }
|
|
|
|
void setImplemented(bool value) { implemented = value; }
|
|
|
|
|
2011-11-10 15:35:40 +01:00
|
|
|
bool isDefined() const { return defined; }
|
|
|
|
void setDefined(bool value) { defined = value; }
|
|
|
|
|
2011-10-16 22:36:07 +02:00
|
|
|
USHORT getDefaultCount() const { return defaultCount; }
|
|
|
|
void setDefaultCount(USHORT value) { defaultCount = value; }
|
|
|
|
|
|
|
|
const Format* getInputFormat() const { return inputFormat; }
|
|
|
|
void setInputFormat(const Format* value) { inputFormat = value; }
|
|
|
|
|
|
|
|
const Format* getOutputFormat() const { return outputFormat; }
|
|
|
|
void setOutputFormat(const Format* value) { outputFormat = value; }
|
|
|
|
|
|
|
|
const Firebird::Array<NestConst<Parameter> >& getInputFields() const { return inputFields; }
|
|
|
|
Firebird::Array<NestConst<Parameter> >& getInputFields() { return inputFields; }
|
|
|
|
|
|
|
|
const Firebird::Array<NestConst<Parameter> >& getOutputFields() const { return outputFields; }
|
|
|
|
Firebird::Array<NestConst<Parameter> >& getOutputFields() { return outputFields; }
|
|
|
|
|
2013-03-31 17:55:01 +02:00
|
|
|
void parseBlr(thread_db* tdbb, CompilerScratch* csb, bid* blob_id);
|
|
|
|
void parseMessages(thread_db* tdbb, CompilerScratch* csb, Firebird::BlrReader blrReader);
|
|
|
|
|
2009-12-30 02:40:39 +01:00
|
|
|
public:
|
|
|
|
virtual int getObjectType() const = 0;
|
2010-02-13 09:31:16 +01:00
|
|
|
virtual SLONG getSclType() const = 0;
|
2009-12-30 02:40:39 +01:00
|
|
|
|
2009-12-27 23:05:22 +01:00
|
|
|
private:
|
|
|
|
USHORT id; // routine ID
|
|
|
|
Firebird::QualifiedName name; // routine name
|
|
|
|
Firebird::MetaName securityName; // security class name
|
2010-04-29 07:13:03 +02:00
|
|
|
JrdStatement* statement; // compiled routine statement
|
2011-10-03 00:11:41 +02:00
|
|
|
bool subRoutine; // Is this a subroutine?
|
2011-11-10 15:35:40 +01:00
|
|
|
bool implemented; // Is the packaged routine missing the body/entrypoint?
|
|
|
|
bool defined; // UDF has its implementation module available
|
2011-10-16 22:36:07 +02:00
|
|
|
USHORT defaultCount; // default input arguments
|
|
|
|
const Format* inputFormat; // input format
|
|
|
|
const Format* outputFormat; // output format
|
|
|
|
Firebird::Array<NestConst<Parameter> > inputFields; // array of field blocks
|
|
|
|
Firebird::Array<NestConst<Parameter> > outputFields; // array of field blocks
|
2009-12-27 23:05:22 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // JRD_ROUTINE_H
|