2001-05-23 15:26:42 +02:00
|
|
|
/*
|
|
|
|
* PROGRAM: JRD access method
|
|
|
|
* MODULE: val.h
|
|
|
|
* DESCRIPTION: Definitions associated with value handling
|
|
|
|
*
|
|
|
|
* 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): ______________________________________.
|
2002-10-30 07:40:58 +01:00
|
|
|
*
|
|
|
|
* 2002.10.29 Sean Leyne - Removed obsolete "Netware" port
|
|
|
|
*
|
2002-10-31 06:06:02 +01:00
|
|
|
* 2002.10.30 Sean Leyne - Removed support for obsolete "PC_PLATFORM" define
|
|
|
|
*
|
2001-05-23 15:26:42 +02:00
|
|
|
*/
|
|
|
|
|
2003-03-13 13:30:54 +01:00
|
|
|
#ifndef JRD_VAL_H
|
|
|
|
#define JRD_VAL_H
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
#include "../include/fb_blk.h"
|
2006-04-25 19:49:24 +02:00
|
|
|
#include "../common/classes/array.h"
|
2008-01-16 11:17:51 +01:00
|
|
|
#include "../common/classes/MetaName.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
#include "../jrd/dsc.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
#define FLAG_BYTES(n) (((n + BITS_PER_LONG) & ~((ULONG)BITS_PER_LONG - 1)) >> 3)
|
|
|
|
|
2004-05-12 02:02:37 +02:00
|
|
|
const UCHAR DEFAULT_DOUBLE = dtype_double;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2006-07-20 11:55:57 +02:00
|
|
|
const ULONG MAX_FORMAT_SIZE = 65535;
|
|
|
|
|
2004-03-20 15:57:40 +01:00
|
|
|
namespace Jrd {
|
|
|
|
|
2004-03-19 07:14:53 +01:00
|
|
|
class ArrayField;
|
|
|
|
class blb;
|
|
|
|
class jrd_req;
|
|
|
|
class jrd_tra;
|
|
|
|
class Symbol;
|
|
|
|
|
|
|
|
|
2004-03-30 06:10:52 +02:00
|
|
|
class Format : public pool_alloc<type_fmt>
|
2001-12-24 03:51:06 +01:00
|
|
|
{
|
|
|
|
public:
|
2004-03-30 06:10:52 +02:00
|
|
|
Format(MemoryPool& p, int len)
|
2006-04-25 19:49:24 +02:00
|
|
|
: fmt_count(len), fmt_desc(p, fmt_count)
|
2001-12-24 03:51:06 +01:00
|
|
|
{
|
2006-04-25 19:49:24 +02:00
|
|
|
fmt_desc.resize(fmt_count);
|
2001-12-24 03:51:06 +01:00
|
|
|
}
|
2004-03-30 06:10:52 +02:00
|
|
|
static Format* newFormat(MemoryPool& p, int len = 0)
|
|
|
|
{
|
|
|
|
return FB_NEW(p) Format(p, len);
|
|
|
|
}
|
2001-12-24 03:51:06 +01:00
|
|
|
|
2001-05-23 15:26:42 +02:00
|
|
|
USHORT fmt_length;
|
|
|
|
USHORT fmt_count;
|
|
|
|
USHORT fmt_version;
|
2006-04-25 19:49:24 +02:00
|
|
|
Firebird::Array<dsc> fmt_desc;
|
|
|
|
typedef Firebird::Array<dsc>::iterator fmt_desc_iterator;
|
|
|
|
typedef Firebird::Array<dsc>::const_iterator fmt_desc_const_iterator;
|
2001-12-24 03:51:06 +01:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* A macro to define a local vary stack variable of a given length
|
2002-07-01 17:07:18 +02:00
|
|
|
Usage: VARY_STR(5) my_var; */
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
#define VARY_STR(x) struct { USHORT vary_length; UCHAR vary_string [x]; }
|
|
|
|
|
2004-08-27 06:48:54 +02:00
|
|
|
// Parameter passing mechanism. Also used for returning values, except for scalar_array.
|
2004-05-24 19:31:47 +02:00
|
|
|
enum FUN_T {
|
2001-05-23 15:26:42 +02:00
|
|
|
FUN_value,
|
|
|
|
FUN_reference,
|
2003-10-29 11:53:47 +01:00
|
|
|
FUN_descriptor,
|
|
|
|
FUN_blob_struct,
|
2004-08-27 06:48:54 +02:00
|
|
|
FUN_scalar_array,
|
|
|
|
FUN_ref_with_null
|
2004-05-24 19:31:47 +02:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-08-27 06:48:54 +02:00
|
|
|
|
|
|
|
/* Function definition block */
|
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
struct fun_repeat {
|
|
|
|
DSC fun_desc; /* Datatype info */
|
|
|
|
FUN_T fun_mechanism; /* Passing mechanism */
|
|
|
|
};
|
|
|
|
|
2004-03-19 07:14:53 +01:00
|
|
|
|
2004-03-30 06:10:52 +02:00
|
|
|
class UserFunction : public pool_alloc_rpt<fun_repeat, type_fun>
|
2001-12-24 03:51:06 +01:00
|
|
|
{
|
2008-01-16 11:17:51 +01:00
|
|
|
public:
|
|
|
|
Firebird::MetaName fun_name; // Function name
|
2004-03-20 15:57:40 +01:00
|
|
|
Firebird::string fun_exception_message; /* message containing the exception error message */
|
2004-03-30 06:10:52 +02:00
|
|
|
UserFunction* fun_homonym; /* Homonym functions */
|
2004-03-19 07:14:53 +01:00
|
|
|
Symbol* fun_symbol; /* Symbol block */
|
|
|
|
int (*fun_entrypoint) (); /* Function entrypoint */
|
|
|
|
USHORT fun_count; /* Number of arguments (including return) */
|
|
|
|
USHORT fun_args; /* Number of input arguments */
|
|
|
|
USHORT fun_return_arg; /* Return argument */
|
|
|
|
USHORT fun_type; /* Type of function */
|
|
|
|
ULONG fun_temp_length; /* Temporary space required */
|
2001-12-24 03:51:06 +01:00
|
|
|
fun_repeat fun_rpt[1];
|
2008-01-16 11:17:51 +01:00
|
|
|
|
|
|
|
public:
|
2008-03-10 09:16:57 +01:00
|
|
|
explicit UserFunction(MemoryPool& p)
|
2008-01-16 11:17:51 +01:00
|
|
|
: fun_name(p),
|
|
|
|
fun_exception_message(p)
|
|
|
|
{
|
|
|
|
}
|
2001-12-24 03:51:06 +01:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-05-09 07:48:33 +02:00
|
|
|
// Those two defines seems an intention to do something that wasn't completed.
|
|
|
|
// UDfs that return values like now or boolean Udfs. See rdb$functions.rdb$function_type.
|
|
|
|
//#define FUN_value 0
|
|
|
|
//#define FUN_boolean 1
|
|
|
|
|
2001-05-23 15:26:42 +02:00
|
|
|
/* Blob passing structure */
|
2003-10-29 11:53:47 +01:00
|
|
|
// CVC: Moved to fun.epp where it belongs.
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-03-19 07:14:53 +01:00
|
|
|
/* Scalar array descriptor, "external side" seen by UDF's */
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-03-19 07:14:53 +01:00
|
|
|
struct scalar_array_desc {
|
2001-05-23 15:26:42 +02:00
|
|
|
DSC sad_desc;
|
|
|
|
SLONG sad_dimensions;
|
|
|
|
struct sad_repeat {
|
|
|
|
SLONG sad_lower;
|
|
|
|
SLONG sad_upper;
|
|
|
|
} sad_rpt[1];
|
2004-03-19 07:14:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Sorry for the clumsy name, but in blk.h this is referred as array description.
|
|
|
|
// Since we already have Scalar Array Descriptor and Array Description [Slice],
|
|
|
|
// it was too confusing. Therefore, it was renamed ArrayField, since ultimately,
|
|
|
|
// it represents an array field the user can manipulate.
|
2004-03-30 10:37:07 +02:00
|
|
|
// There was also confusion for the casual reader due to the presence of
|
|
|
|
// the structure "slice" in sdl.h that was renamed array_slice.
|
2004-03-19 07:14:53 +01:00
|
|
|
|
2005-11-27 21:53:09 +01:00
|
|
|
class ArrayField : public pool_alloc_rpt<Ods::InternalArrayDesc::iad_repeat, type_arr>
|
2001-12-24 03:51:06 +01:00
|
|
|
{
|
|
|
|
public:
|
2004-03-19 07:14:53 +01:00
|
|
|
UCHAR* arr_data; /* Data block, if allocated */
|
|
|
|
blb* arr_blob; /* Blob for data access */
|
|
|
|
jrd_tra* arr_transaction; /* Parent transaction block */
|
|
|
|
ArrayField* arr_next; /* Next array in transaction */
|
|
|
|
jrd_req* arr_request; /* request */
|
|
|
|
SLONG arr_effective_length; /* Length of array instance */
|
|
|
|
USHORT arr_desc_length; /* Length of array descriptor */
|
|
|
|
ULONG arr_temp_id; // Temporary ID for open array inside the transaction
|
2004-09-13 07:13:05 +02:00
|
|
|
|
|
|
|
// Keep this field last as it is C-style open array !
|
2005-11-27 21:53:09 +01:00
|
|
|
Ods::InternalArrayDesc arr_desc; /* Array descriptor. ! */
|
2001-12-24 03:51:06 +01:00
|
|
|
};
|
2004-03-19 07:14:53 +01:00
|
|
|
|
2004-03-20 15:57:40 +01:00
|
|
|
} //namespace Jrd
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-03-13 13:30:54 +01:00
|
|
|
#endif /* JRD_VAL_H */
|
2003-10-29 11:53:47 +01:00
|
|
|
|