2009-12-21 18:53:49 +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): ______________________________________.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef JRD_FUNCTION_H
|
|
|
|
#define JRD_FUNCTION_H
|
|
|
|
|
2009-12-27 23:05:22 +01:00
|
|
|
#include "../jrd/Routine.h"
|
2009-12-21 18:53:49 +01:00
|
|
|
#include "../common/classes/array.h"
|
|
|
|
#include "../jrd/dsc.h"
|
|
|
|
#include "../jrd/val.h"
|
|
|
|
|
|
|
|
namespace Jrd
|
|
|
|
{
|
|
|
|
struct fun_repeat
|
|
|
|
{
|
|
|
|
Parameter* fun_parameter; // parameter info
|
|
|
|
FUN_T fun_mechanism; // passing mechanism
|
|
|
|
};
|
|
|
|
|
2009-12-27 23:05:22 +01:00
|
|
|
class Function : public Routine
|
2009-12-21 18:53:49 +01:00
|
|
|
{
|
2009-12-24 15:15:21 +01:00
|
|
|
static const USHORT MAX_ALTER_COUNT = 64; // Number of times an in-cache function can be altered
|
2009-12-21 18:53:49 +01:00
|
|
|
static const char* const EXCEPTION_MESSAGE;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static Function* lookup(thread_db* tdbb, USHORT id, bool return_deleted, bool noscan, USHORT flags);
|
|
|
|
static Function* lookup(thread_db* tdbb, const Firebird::QualifiedName& name, bool noscan);
|
|
|
|
|
|
|
|
void addRef();
|
|
|
|
void release(thread_db* tdbb);
|
|
|
|
|
|
|
|
bool isUsed() const
|
|
|
|
{
|
|
|
|
return (fun_use_count != 0);
|
|
|
|
}
|
|
|
|
|
2009-12-24 15:15:21 +01:00
|
|
|
USHORT incrementAlterCount();
|
|
|
|
|
2009-12-27 20:05:38 +01:00
|
|
|
dsc* execute(thread_db* tdbb, jrd_nod* args, impure_value* value) const;
|
2009-12-24 15:15:21 +01:00
|
|
|
void releaseLocks(thread_db* tdbb);
|
|
|
|
void remove(thread_db* tdbb);
|
|
|
|
void parseBlr(thread_db* tdbb, bid* blob_id, CompilerScratch* csb);
|
2009-12-21 18:53:49 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
explicit Function(MemoryPool& p)
|
2009-12-27 23:05:22 +01:00
|
|
|
: Routine(p),
|
|
|
|
fun_entrypoint(NULL),
|
|
|
|
fun_inputs(0),
|
|
|
|
fun_defaults(0),
|
|
|
|
fun_return_arg(0),
|
|
|
|
fun_temp_length(0),
|
|
|
|
fun_args(p),
|
|
|
|
fun_flags(0),
|
|
|
|
fun_use_count(0),
|
|
|
|
fun_existence_lock(NULL),
|
|
|
|
fun_alter_count(0),
|
|
|
|
fun_exception_message(p),
|
|
|
|
fun_legacy(true),
|
|
|
|
fun_invariant(false),
|
|
|
|
fun_external(NULL)
|
|
|
|
{
|
|
|
|
}
|
2009-12-21 18:53:49 +01:00
|
|
|
|
|
|
|
static Function* loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT flags);
|
|
|
|
static int blockingAst(void*);
|
|
|
|
|
2009-12-30 02:40:39 +01:00
|
|
|
public:
|
|
|
|
virtual int getObjectType() const
|
|
|
|
{
|
|
|
|
return obj_udf;
|
|
|
|
}
|
|
|
|
|
2010-02-13 09:31:16 +01:00
|
|
|
virtual SLONG getSclType() const
|
2009-12-30 02:40:39 +01:00
|
|
|
{
|
2010-02-13 09:31:16 +01:00
|
|
|
return SCL_object_function;
|
2009-12-30 02:40:39 +01:00
|
|
|
}
|
|
|
|
|
2009-12-21 18:53:49 +01:00
|
|
|
public:
|
|
|
|
int (*fun_entrypoint)(); // function entrypoint
|
|
|
|
USHORT fun_inputs; // input arguments
|
2009-12-25 15:37:44 +01:00
|
|
|
USHORT fun_defaults; // default input arguments
|
2009-12-21 18:53:49 +01:00
|
|
|
USHORT fun_return_arg; // return argument
|
|
|
|
ULONG fun_temp_length; // temporary space required
|
|
|
|
|
|
|
|
Firebird::Array<fun_repeat> fun_args;
|
|
|
|
|
|
|
|
USHORT fun_flags; // flags
|
|
|
|
USHORT fun_use_count; // requests compiled with function
|
|
|
|
Lock* fun_existence_lock; // existence lock, if any
|
|
|
|
USHORT fun_alter_count; // number of times function was altered
|
|
|
|
|
2009-12-21 21:55:07 +01:00
|
|
|
Firebird::string fun_exception_message; // message containing the exception error message
|
|
|
|
|
2009-12-21 18:53:49 +01:00
|
|
|
bool fun_legacy;
|
|
|
|
bool fun_invariant;
|
|
|
|
ExtEngineManager::Function* fun_external;
|
|
|
|
};
|
|
|
|
|
|
|
|
const USHORT FUN_scanned = 1; // Field expressions scanned
|
|
|
|
const USHORT FUN_obsolete = 2; // Procedure known gonzo
|
|
|
|
const USHORT FUN_being_scanned = 4; // New procedure needs dependencies during scan
|
|
|
|
const USHORT FUN_being_altered = 8; // Procedure is getting altered
|
|
|
|
const USHORT FUN_check_existence = 16; // Existence lock released
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // JRD_FUNCTION_H
|