mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 21:23:03 +01:00
Cleanup.
This commit is contained in:
parent
e56d5fc3ab
commit
cc8794d02f
@ -5724,19 +5724,6 @@ jrd_nod* CMP_pass2(thread_db* tdbb, CompilerScratch* csb, jrd_nod* const node, j
|
||||
|
||||
case nod_function:
|
||||
{
|
||||
// For gbak attachments, there is no need to resolve the UDF function
|
||||
// Also if we are dropping a procedure don't bother resolving the
|
||||
// UDF that the procedure invokes.
|
||||
if (!(tdbb->getAttachment()->att_flags & ATT_gbak_attachment) &&
|
||||
!(tdbb->tdbb_flags & TDBB_prc_being_dropped))
|
||||
{
|
||||
jrd_nod* value = node->nod_arg[e_fun_args];
|
||||
UserFunction* function = (UserFunction*) node->nod_arg[e_fun_function];
|
||||
node->nod_arg[e_fun_function] = (jrd_nod*) FUN_resolve(tdbb, csb, function, value);
|
||||
if (!node->nod_arg[e_fun_function]) {
|
||||
ERR_post(Arg::Gds(isc_funmismat) << Arg::Str(function->fun_name.toString()));
|
||||
}
|
||||
}
|
||||
dsc descriptor_a;
|
||||
CMP_get_desc(tdbb, csb, node, &descriptor_a);
|
||||
csb->csb_impure += sizeof(impure_value);
|
||||
|
@ -373,7 +373,6 @@ static TEXT_PTR merge_file[] = { "MERGE EQUIVALENCE FILE BLOCK", 0};
|
||||
static TEXT_PTR River[] = { "SORT MERGE RIVER", 0};
|
||||
static TEXT_PTR UserId[] = { "USER IDENTIFICATION BLOCK ", 0};
|
||||
static TEXT_PTR Attachment[] = { "ATTACHMENT BLOCK", 0};
|
||||
static TEXT_PTR Symbol[] = { "SYMBOL", 0};
|
||||
static TEXT_PTR UserFunction[] = { "FUNCTION", 0};
|
||||
static TEXT_PTR IndexedRelationship[] = { "INDEXED RELATIONSHIP", 0};
|
||||
static TEXT_PTR AccessItem[] = { "ACCESS", 0};
|
||||
@ -384,7 +383,6 @@ static TEXT_PTR Savepoint[] = { "SAVE POINT", 0};
|
||||
static TEXT_PTR VerbAction[] = { "VERB", 0};
|
||||
static TEXT_PTR BlobFilter[] = { "BLOB FILTER", 0};
|
||||
static TEXT_PTR ArrayField[] = { "ARRAY DESCRIPTION", 0};
|
||||
//static TEXT_PTR blb_map[] = { "MAP BLOCK", 0};
|
||||
static TEXT_PTR dir_list[] = { "DIR LIST BLOCK", 0};
|
||||
static TEXT_PTR jrd_prc[] =
|
||||
{
|
||||
|
@ -788,7 +788,6 @@ UserFunction* FUN_lookup_function(thread_db* tdbb, const QualifiedName& name)
|
||||
return function;
|
||||
|
||||
fun_repeat temp[MAX_UDF_ARGUMENTS + 1];
|
||||
UserFunction* prior = NULL;
|
||||
|
||||
jrd_req* request_fun = CMP_find_request(tdbb, irq_l_functions, IRQ_REQUESTS);
|
||||
jrd_req* request_arg = CMP_find_request(tdbb, irq_l_args, IRQ_REQUESTS);
|
||||
@ -854,7 +853,7 @@ UserFunction* FUN_lookup_function(thread_db* tdbb, const QualifiedName& name)
|
||||
function->fun_exception_message.printf(EXCEPTION_MESSAGE, name.toString().c_str(),
|
||||
X.RDB$ENTRYPOINT, X.RDB$MODULE_NAME);
|
||||
|
||||
if (!X.RDB$ENGINE_NAME.NULL) // ODS_12_0
|
||||
if (!X.RDB$ENGINE_NAME.NULL)
|
||||
{
|
||||
HalfStaticArray<char, 512> body;
|
||||
|
||||
@ -888,19 +887,8 @@ UserFunction* FUN_lookup_function(thread_db* tdbb, const QualifiedName& name)
|
||||
}
|
||||
}
|
||||
|
||||
// ASF: All the places handling fun_homonym is something that doesn't work really.
|
||||
// Our current system table rdb$function_arguments doesn't support overloaded
|
||||
// functions as it has a rdb$function_name column instead of an ID.
|
||||
if (prior)
|
||||
{
|
||||
function->fun_homonym = prior->fun_homonym;
|
||||
prior->fun_homonym = function;
|
||||
}
|
||||
else
|
||||
{
|
||||
prior = function;
|
||||
dbb->dbb_functions.put(name, function);
|
||||
}
|
||||
dbb->dbb_functions.put(name, function);
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_l_functions))
|
||||
@ -908,63 +896,7 @@ UserFunction* FUN_lookup_function(thread_db* tdbb, const QualifiedName& name)
|
||||
if (!REQUEST(irq_l_args))
|
||||
REQUEST(irq_l_args) = request_arg;
|
||||
|
||||
return prior;
|
||||
}
|
||||
|
||||
|
||||
UserFunction* FUN_resolve(thread_db* tdbb, CompilerScratch* csb, UserFunction* function, jrd_nod* args)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* F U N _ r e s o l v e
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Resolve instance of potentially overloaded function.
|
||||
*
|
||||
**************************************/
|
||||
DSC arg;
|
||||
|
||||
SET_TDBB(tdbb);
|
||||
|
||||
UserFunction* best = NULL;
|
||||
int best_score = 0;
|
||||
const jrd_nod* const* const end = args->nod_arg + args->nod_count;
|
||||
|
||||
for (; function; function = function->fun_homonym)
|
||||
{
|
||||
if ((function->fun_entrypoint || function->fun_external) && function->fun_args == args->nod_count)
|
||||
{
|
||||
int score = 0;
|
||||
jrd_nod** ptr;
|
||||
const fun_repeat* tail;
|
||||
|
||||
for (ptr = args->nod_arg, tail = function->fun_rpt + 1; ptr < end; ptr++, tail++)
|
||||
{
|
||||
CMP_get_desc(tdbb, csb, *ptr, &arg);
|
||||
if (tail->fun_mechanism == FUN_descriptor)
|
||||
score += 10;
|
||||
else if (tail->fun_desc.dsc_dtype == dtype_blob || arg.dsc_dtype == dtype_blob)
|
||||
{
|
||||
score = 0;
|
||||
break;
|
||||
}
|
||||
else if (tail->fun_desc.dsc_dtype >= arg.dsc_dtype)
|
||||
score += 10 - (arg.dsc_dtype - tail->fun_desc.dsc_dtype);
|
||||
else
|
||||
score += 1;
|
||||
}
|
||||
|
||||
if (!best || score > best_score)
|
||||
{
|
||||
best_score = score;
|
||||
best = function;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return best;
|
||||
return function;
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,7 +41,6 @@ public:
|
||||
|
||||
void FUN_evaluate(Jrd::thread_db*, Jrd::UserFunction*, Jrd::jrd_nod*, Jrd::impure_value*);
|
||||
Jrd::UserFunction* FUN_lookup_function(Jrd::thread_db*, const Firebird::QualifiedName&);
|
||||
Jrd::UserFunction* FUN_resolve(Jrd::thread_db*, Jrd::CompilerScratch*, Jrd::UserFunction*, Jrd::jrd_nod*);
|
||||
|
||||
#endif // JRD_FUN_PROTO_H
|
||||
|
||||
|
@ -126,7 +126,6 @@ class ViewContext;
|
||||
class IndexBlock;
|
||||
class IndexLock;
|
||||
class ArrayField;
|
||||
class Symbol;
|
||||
struct sort_context;
|
||||
class RecordSelExpr;
|
||||
class vcl;
|
||||
|
@ -1481,14 +1481,7 @@ static jrd_nod* par_function(thread_db* tdbb, CompilerScratch* csb, SSHORT blr_o
|
||||
error(csb, Arg::Gds(isc_funnotdef) << Arg::Str(name.toString()));
|
||||
}
|
||||
|
||||
UserFunction* homonyms;
|
||||
for (homonyms = function; homonyms; homonyms = homonyms->fun_homonym)
|
||||
{
|
||||
if (homonyms->fun_entrypoint || homonyms->fun_external)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!homonyms)
|
||||
if (!function->fun_entrypoint && !function->fun_external)
|
||||
{
|
||||
if (tdbb->getAttachment()->att_flags & ATT_gbak_attachment)
|
||||
{
|
||||
|
@ -60,7 +60,6 @@ class blb;
|
||||
class jrd_req;
|
||||
class jrd_tra;
|
||||
class PatternMatcher;
|
||||
class Symbol;
|
||||
|
||||
// Various structures in the impure area
|
||||
|
||||
@ -197,8 +196,6 @@ class UserFunction : public pool_alloc_rpt<fun_repeat, type_fun>
|
||||
public:
|
||||
Firebird::QualifiedName fun_name; // Function name
|
||||
Firebird::string fun_exception_message; // message containing the exception error message
|
||||
UserFunction* fun_homonym; // Homonym functions
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user