8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 19:23:03 +01:00

string cleanup

This commit is contained in:
alexpeshkoff 2004-03-31 18:03:51 +00:00
parent b114011b7a
commit 4650f4975f
10 changed files with 123 additions and 146 deletions

View File

@ -45,6 +45,7 @@
#include "../jrd/y_ref.h"
#include "../jrd/ibase.h"
#include "../jrd/jrd.h"
#include "../jrd/sym.h"
#include "../jrd/req.h"
#include "../jrd/val.h"
#include "../jrd/align.h"
@ -4084,7 +4085,10 @@ static void pass1_source(thread_db* tdbb,
if ((*vcx_ptr)->vcx_context ==
(USHORT)(IPTR) source->nod_arg[e_rel_context])
{
element->csb_alias = (*vcx_ptr)->vcx_context_name;
element->csb_alias = FB_NEW(csb->csb_pool)
Firebird::string(csb->csb_pool,
(TEXT*)((*vcx_ptr)->vcx_context_name->str_data),
(*vcx_ptr)->vcx_context_name->str_length);
break;
}
}
@ -4509,7 +4513,7 @@ static jrd_nod* pass2(thread_db* tdbb, CompilerScratch* csb, jrd_nod* const node
(jrd_nod*) FUN_resolve(csb, function, value);
if (!node->nod_arg[e_fun_function]) {
ERR_post(isc_funmismat, isc_arg_string,
function->fun_symbol->sym_string, 0);
function->fun_symbol->sym_string.c_str(), 0);
}
}
}
@ -5174,7 +5178,7 @@ static void plan_set(CompilerScratch* csb, RecordSelExpr* rse, jrd_nod* plan)
jrd_rel* view_relation = 0;
jrd_nod* plan_relation_node = plan->nod_arg[e_retrieve_relation];
const jrd_rel* plan_relation = (jrd_rel*) plan_relation_node->nod_arg[e_rel_relation];
const str* plan_alias = (str*) plan_relation_node->nod_arg[e_rel_alias];
const char* plan_alias = (const char *) plan_relation_node->nod_arg[e_rel_alias];
// find the tail for the relation specified in the RecordSelExpr
@ -5186,13 +5190,7 @@ static void plan_set(CompilerScratch* csb, RecordSelExpr* rse, jrd_nod* plan)
UCHAR* map = 0;
if (tail->csb_map) {
const TEXT* p;
if (plan_alias) {
p = (TEXT *) plan_alias->str_data;
}
else {
p = "\0";
}
const TEXT* p = plan_alias;
// if the user has specified an alias, skip past it to find the alias
// for the base table (if multiple aliases are specified)
@ -5201,8 +5199,7 @@ static void plan_set(CompilerScratch* csb, RecordSelExpr* rse, jrd_nod* plan)
(tail->csb_relation
&& !strcmp_space(tail->csb_relation->rel_name, p))
|| (tail->csb_alias
&& !strcmp_space(reinterpret_cast<
const char*>(tail->csb_alias->str_data), p)))
&& !strcmp_space(tail->csb_alias->c_str(), p)))
{
while (*p && *p != ' ') {
p++;
@ -5275,7 +5272,7 @@ static void plan_set(CompilerScratch* csb, RecordSelExpr* rse, jrd_nod* plan)
for (map++; *map; map++) {
tail = &csb->csb_rpt[*map];
const jrd_rel* relation = tail->csb_relation;
const str* alias = tail->csb_alias;
const Firebird::string& alias = *(tail->csb_alias);
// match the user-supplied alias with the alias supplied
// with the view definition; failing that, try the base
@ -5287,9 +5284,8 @@ static void plan_set(CompilerScratch* csb, RecordSelExpr* rse, jrd_nod* plan)
// a NULL relation. See exe.h for CompilerScratch struct and its inner csb_repeat struct.
if (
(alias
&& !strcmp_space(reinterpret_cast<
const char*>(alias->str_data), p))
(tail->csb_alias
&& !strcmp_space(tail->csb_alias->c_str(), p))
|| (relation && !strcmp_space(relation->rel_name, p)))
{
break;

View File

@ -397,7 +397,7 @@ struct impure_agg_sort {
#define e_dcl_id 0
#define e_dcl_invariants 1
#define e_dcl_desc 2
#define e_dcl_length (2 + sizeof (DSC)/sizeof (Jrd::jrd_nod*)) /* Room for descriptor */
#define e_dcl_length (2 + sizeof (DSC)/sizeof (::Jrd::jrd_nod*)) /* Room for descriptor */
#define e_dep_object 0 /* node for registering dependencies */
#define e_dep_object_type 1
@ -558,6 +558,7 @@ public:
csb_fors(p),
csb_invariants(p),
csb_current_nodes(p),
csb_pool(p),
csb_rpt(p, len)
{}
@ -592,6 +593,7 @@ public:
USHORT csb_msg_number; /* Highest used message number */
SLONG csb_impure; /* Next offset into impure area */
USHORT csb_g_flags;
MemoryPool& csb_pool; /* Memory pool to be used by csb */
struct csb_repeat
{
@ -622,7 +624,7 @@ public:
USHORT csb_indices; /* Number of indices */
jrd_rel* csb_relation;
str* csb_alias; /* SQL alias name for this instance of relation */
Firebird::string* csb_alias; /* SQL alias name for this instance of relation */
jrd_prc* csb_procedure;
jrd_rel* csb_view; /* parent view */
@ -640,7 +642,7 @@ public:
typedef csb_repeat* rpt_itr;
typedef const csb_repeat* rpt_const_itr;
Firebird::Array<csb_repeat> csb_rpt;
Firebird::HalfStaticArray<csb_repeat, 5> csb_rpt;
};
#define csb_internal 0x1 /* "csb_g_flag" switch */

View File

@ -30,7 +30,7 @@
* 2003.08.10 Claudio Valderrama: Fix SF Bugs #544132 and #728839.
*/
/*
$Id: fun.epp,v 1.44 2004-03-30 04:10:49 robocop Exp $
$Id: fun.epp,v 1.45 2004-03-31 18:03:50 alexpeshkoff Exp $
*/
#include "firebird.h"
@ -62,7 +62,7 @@ $Id: fun.epp,v 1.44 2004-03-30 04:10:49 robocop Exp $
#include "../jrd/fun_proto.h"
#include "../jrd/gds_proto.h"
#include "../jrd/mov_proto.h"
#include "../jrd/sym_proto.h"
#include "../jrd/sym.h"
#include "../jrd/thd_proto.h"
#include "../jrd/sch_proto.h"
#include "../jrd/isc_s_proto.h"
@ -778,7 +778,7 @@ void FUN_init(void)
}
UserFunction* FUN_lookup_function(const TEXT* name, bool ShowAccessError)
UserFunction* FUN_lookup_function(const Firebird::string& name, bool ShowAccessError)
{
/**************************************
*
@ -797,9 +797,9 @@ UserFunction* FUN_lookup_function(const TEXT* name, bool ShowAccessError)
#ifdef V4_THREADING
V4_JRD_MUTEX_LOCK(dbb->dbb_mutexes + DBB_MUTX_udf);
#endif
for (Symbol* symbol = SYM_lookup(name); symbol; symbol = symbol->sym_homonym)
for (Symbol* symbol = Symbol::lookup(name); symbol; symbol = symbol->sym_homonym)
{
if (symbol->sym_type == SYM_fun) {
if (symbol->sym_type == Symbol::fun) {
#ifdef V4_THREADING
V4_JRD_MUTEX_UNLOCK(dbb->dbb_mutexes + DBB_MUTX_udf);
#endif
@ -814,7 +814,7 @@ UserFunction* FUN_lookup_function(const TEXT* name, bool ShowAccessError)
jrd_req* request_arg = CMP_find_request(tdbb, irq_l_args, IRQ_REQUESTS);
FOR(REQUEST_HANDLE request_fun) X IN RDB$FUNCTIONS
WITH X.RDB$FUNCTION_NAME EQ name
WITH X.RDB$FUNCTION_NAME EQ name.c_str()
if (!REQUEST(irq_l_functions))
REQUEST(irq_l_functions) = request_fun;
USHORT count = 0, args = 0;
@ -865,7 +865,7 @@ UserFunction* FUN_lookup_function(const TEXT* name, bool ShowAccessError)
/* Prepare the exception message to be used in case this function ever
causes an exception. This is done at this time to save us from preparing
(thus allocating) this message every time the function is called. */
function->fun_exception_message.printf(EXCEPTION_MESSAGE, name,
function->fun_exception_message.printf(EXCEPTION_MESSAGE, name.c_str(),
X.RDB$ENTRYPOINT, X.RDB$MODULE_NAME);
function->fun_entrypoint =
@ -913,14 +913,10 @@ UserFunction* FUN_lookup_function(const TEXT* name, bool ShowAccessError)
else
{
prior = function;
Symbol* new_symbol = FB_NEW(*dbb->dbb_permanent) Symbol;
Symbol* new_symbol = FB_NEW(*dbb->dbb_permanent)
Symbol(*dbb->dbb_permanent, name, Symbol::fun, function);
function->fun_symbol = new_symbol;
new_symbol->sym_object = (BLK) function;
str* string = FB_NEW_RPT(*dbb->dbb_permanent, strlen(name)) str;
strcpy((char*)string->str_data, name);
new_symbol->sym_string = (TEXT *) string->str_data;
new_symbol->sym_type = SYM_fun;
SYM_insert(new_symbol);
new_symbol->insert();
}
END_FOR;

View File

@ -29,7 +29,7 @@ class Jrd::CompilerScratch;
void FUN_evaluate(Jrd::UserFunction*, Jrd::jrd_nod*, Jrd::impure_value*);
void FUN_fini(Jrd::thread_db*);
void FUN_init(void);
Jrd::UserFunction* FUN_lookup_function(const TEXT*, bool ShowAccessError);
Jrd::UserFunction* FUN_lookup_function(const Firebird::string&, bool ShowAccessError);
Jrd::UserFunction* FUN_resolve(Jrd::CompilerScratch*, Jrd::UserFunction*, Jrd::jrd_nod*);
#endif // JRD_FUN_PROTO_H

View File

@ -676,27 +676,26 @@ static FPTR_SHORT lookup_init_function(
/* Still not found, check if there is a UDF in the database defined the right way */
USHORT argcount;
char entry[48];
Firebird::string entry;
switch (type) {
case type_texttype:
sprintf(entry, INTL_USER_ENTRY, parm1);
entry.printf(INTL_USER_ENTRY, parm1);
argcount = 2;
break;
case type_charset:
sprintf(entry, "USER_CHARSET_%03d", parm1);
entry.printf("USER_CHARSET_%03d", parm1);
argcount = 2;
break;
case type_csconvert:
sprintf(entry, "USER_TRANSLATE_%03d_%03d", parm1,
parm2);
entry.printf("USER_TRANSLATE_%03d_%03d", parm1, parm2);
argcount = 3;
break;
default:
BUGCHECK(1);
break;
}
INTL_TRACE(("INTL: trying user fn %s\n", entry));
INTL_TRACE(("INTL: trying user fn %s\n", entry.c_str()));
UserFunction* function_block = FUN_lookup_function(entry, false);
if (function_block) {
INTL_TRACE(("INTL: found a user fn, validating\n"));

View File

@ -257,7 +257,7 @@ public:
Symbol* dbb_hash_table[HASH_SIZE]; /* keep this at the end */
private:
Database(MemoryPool& p)
explicit Database(MemoryPool& p)
: dbb_spare_string(p),
dbb_filename(p),
dbb_encrypt_key(p),
@ -411,7 +411,7 @@ private:
class Attachment : public pool_alloc<type_att>
{
public:
Attachment(Database* dbb) :
explicit Attachment(Database* dbb) :
att_database(dbb),
att_lc_messages(*dbb->dbb_permanent),
att_working_directory(*dbb->dbb_permanent),
@ -540,7 +540,7 @@ class jrd_prc : public pool_alloc_rpt<SCHAR, type_prc>
USHORT prc_alter_count; /* No. of times the procedure was altered */
public:
jrd_prc(MemoryPool& p) : prc_security_name(p), prc_name(p) {}
explicit jrd_prc(MemoryPool& p) : prc_security_name(p), prc_name(p) {}
};
#define PRC_scanned 1 /* Field expressions scanned */
@ -564,10 +564,11 @@ class Parameter : public pool_alloc_rpt<SCHAR, type_prm>
USHORT prm_number;
dsc prm_desc;
jrd_nod* prm_default_val;
Firebird::string prm_name; /* asciiz name */
// Firebird::string prm_name; /* asciiz name */
TEXT prm_string[2]; /* one byte for ALLOC and one for the terminating null */
public:
Parameter(MemoryPool& p) : prm_name(p) { }
// explicit Parameter(MemoryPool& p) : prm_name(p) { }
Parameter() { }
};
@ -832,31 +833,6 @@ typedef struct que {
} *QUE;
/* symbol definitions */
typedef enum sym_t {
SYM_rel, /* relation block */
SYM_fld, /* field block */
SYM_fun, /* UDF function block */
SYM_prc, /* stored procedure block */
SYM_sql, /* SQL request cache block */
SYM_blr, /* BLR request cache block */
SYM_label /* CVC: I need to track labels if LEAVE is implemented. */
} SYM_T;
class Symbol : public pool_alloc<type_sym>
{
public:
TEXT* sym_string; /* address of asciz string */
/* USHORT sym_length; *//* length of asciz string */
SYM_T sym_type; /* symbol type */
BLK sym_object; /* general pointer to object */
Symbol* sym_collision; /* collision pointer */
Symbol* sym_homonym; /* homonym pointer */
};
//
// Transaction element block
//
@ -972,6 +948,18 @@ struct ihndl
void* ihndl_object;
};
// dupilcate context of firebird string to store in jrd_nod::nod_arg
inline char* stringDup(MemoryPool& p, const Firebird::string& s)
{
char* rc = (char*) p.allocate(s.length() + 1, 0
#ifdef DEBYG_GDS_ALLOC
, __FILE__, __LINE__
#endif
);
strcpy(rc, s.c_str());
return rc;
}
} //namespace Jrd

View File

@ -37,8 +37,8 @@ namespace Jrd {
class jrd_rel;
class CompilerScratch;
class jrd_nod;
struct bid;
struct index_desc;
class bid;
}
void MET_activate_shadow(Jrd::thread_db*);
@ -65,9 +65,9 @@ Jrd::BlobFilter* MET_lookup_filter(Jrd::thread_db*, SSHORT, SSHORT);
SLONG MET_lookup_generator(Jrd::thread_db*, const TEXT*);
void MET_lookup_generator_id(Jrd::thread_db*, SLONG, TEXT *);
void MET_lookup_index(Jrd::thread_db*, TEXT*, const TEXT*, USHORT);
SLONG MET_lookup_index_name(Jrd::thread_db*, const TEXT*, SLONG*, SSHORT*);
SLONG MET_lookup_index_name(Jrd::thread_db*, const Firebird::string&, SLONG*, SSHORT*);
bool MET_lookup_partner(Jrd::thread_db*, Jrd::jrd_rel*, struct Jrd::index_desc*, const TEXT*);
Jrd::jrd_prc* MET_lookup_procedure(Jrd::thread_db*, SCHAR *, bool);
Jrd::jrd_prc* MET_lookup_procedure(Jrd::thread_db*, const Firebird::string&, bool);
Jrd::jrd_prc* MET_lookup_procedure_id(Jrd::thread_db*, SSHORT, bool, bool, USHORT);
Jrd::jrd_rel* MET_lookup_relation(Jrd::thread_db*, const char*);
Jrd::jrd_rel* MET_lookup_relation_id(Jrd::thread_db*, SLONG, bool);

View File

@ -5444,7 +5444,7 @@ static STR make_alias(thread_db* tdbb, CompilerScratch* csb,
csb_tail = &csb->csb_rpt[csb_tail->csb_view_stream])
{
if (csb_tail->csb_alias)
alias_length += csb_tail->csb_alias->str_length;
alias_length += csb_tail->csb_alias->length();
else {
alias_length +=
(!(csb_tail->csb_relation) || !(csb_tail->csb_relation->rel_name))
@ -5468,7 +5468,7 @@ static STR make_alias(thread_db* tdbb, CompilerScratch* csb,
{
const TEXT* q;
if (csb_tail->csb_alias)
q = (TEXT *) csb_tail->csb_alias->str_data;
q = (TEXT *) csb_tail->csb_alias->c_str();
else {
q = (!(csb_tail->csb_relation) || !(csb_tail->csb_relation->rel_name))
? NULL : csb_tail->csb_relation->rel_name;

View File

@ -89,13 +89,13 @@ static const TEXT elements[][14] =
using namespace Jrd;
static void error(CompilerScratch*, ...);
static SSHORT find_proc_field(const jrd_prc*, const TEXT*);
static SSHORT find_proc_field(const jrd_prc*, const Firebird::string&);
static jrd_nod* par_args(thread_db*, CompilerScratch*, USHORT);
static jrd_nod* par_cast(thread_db*, CompilerScratch*);
static PsqlException* par_condition(thread_db*, CompilerScratch*);
static PsqlException* par_conditions(thread_db*, CompilerScratch*);
static SSHORT par_context(CompilerScratch*, SSHORT *);
static void par_dependency(thread_db*, CompilerScratch*, SSHORT, SSHORT, const TEXT*);
static void par_dependency(thread_db*, CompilerScratch*, SSHORT, SSHORT, const Firebird::string&);
static jrd_nod* par_exec_proc(thread_db*, CompilerScratch*, SSHORT);
static jrd_nod* par_fetch(thread_db*, CompilerScratch*, jrd_nod*);
static jrd_nod* par_field(thread_db*, CompilerScratch*, SSHORT);
@ -104,7 +104,7 @@ static jrd_nod* par_literal(thread_db*, CompilerScratch*);
static jrd_nod* par_map(thread_db*, CompilerScratch*, USHORT);
static jrd_nod* par_message(thread_db*, CompilerScratch*);
static jrd_nod* par_modify(thread_db*, CompilerScratch*);
static USHORT par_name(CompilerScratch*, TEXT*);
static USHORT par_name(CompilerScratch*, Firebird::string&);
static jrd_nod* par_plan(thread_db*, CompilerScratch*);
static jrd_nod* par_procedure(thread_db*, CompilerScratch*, SSHORT);
static void par_procedure_parms(thread_db*, CompilerScratch*, jrd_prc*, jrd_nod**, jrd_nod**, USHORT);
@ -115,7 +115,7 @@ static jrd_nod* par_stream(thread_db*, CompilerScratch*);
static jrd_nod* par_union(thread_db*, CompilerScratch*);
static USHORT par_word(CompilerScratch*);
static jrd_nod* parse(thread_db*, CompilerScratch*, USHORT, USHORT expected_optional = 0);
static void syntax_error(CompilerScratch*, const TEXT*);
static void syntax_error(CompilerScratch*, const TEXT *);
static void warning(CompilerScratch*, ...);
#define BLR_PEEK *(csb->csb_running)
@ -385,8 +385,9 @@ jrd_nod* PAR_gen_field(thread_db* tdbb, USHORT stream, USHORT id)
}
jrd_nod* PAR_make_field(thread_db* tdbb, CompilerScratch* csb, USHORT context,
const TEXT* base_field)
jrd_nod* PAR_make_field(thread_db* tdbb, CompilerScratch* csb,
USHORT context,
const Firebird::string& base_field)
{
/**************************************
*
@ -411,12 +412,11 @@ jrd_nod* PAR_make_field(thread_db* tdbb, CompilerScratch* csb, USHORT context,
This means a field without entry in rdb$fields. This is the origin of the
mysterious message "cannot access column z x in view VF" when selecting from
such view that has field "z x". This closes Firebird Bug #227758. */
SqlIdentifier name;
strcpy (name, base_field);
Firebird::string name = base_field;
fb_utils::fb_exact_name(name);
const SSHORT id =
MET_lookup_field (tdbb, csb->csb_rpt [stream].csb_relation, name, 0);
MET_lookup_field (tdbb, csb->csb_rpt[stream].csb_relation, name.c_str(), 0);
if (id < 0)
return NULL;
@ -551,7 +551,7 @@ CompilerScratch* PAR_parse(thread_db* tdbb, const UCHAR* blr, USHORT internal_fl
}
SLONG PAR_symbol_to_gdscode(const char* name)
SLONG PAR_symbol_to_gdscode(const Firebird::string& name)
{
/**************************************
*
@ -571,14 +571,13 @@ SLONG PAR_symbol_to_gdscode(const char* name)
*
**************************************/
const char* p = name;
while (*p && *p != ' ') {
p++;
Firebird::string::size_type length = name.find(' ');
if (length == Firebird::string::npos)
{
length = name.length();
}
const size_t length = p - name;
for (int i = 0; codes[i].code_number; ++i) {
if (!strncmp(name, codes[i].code_string, length)) {
if (name.compare(0, length, codes[i].code_string, length) == 0) {
return codes[i].code_number;
}
}
@ -659,7 +658,7 @@ static void error(CompilerScratch* csb, ...)
}
static SSHORT find_proc_field(const jrd_prc* procedure, const TEXT* name)
static SSHORT find_proc_field(const jrd_prc* procedure, const Firebird::string& name)
{
/**************************************
*
@ -680,7 +679,7 @@ static SSHORT find_proc_field(const jrd_prc* procedure, const TEXT* name)
ptr++)
{
const Parameter* param = (Parameter*) * ptr;
if (param->prm_name == name)
if (name == param->prm_string)
return param->prm_number;
}
@ -761,9 +760,8 @@ static PsqlException* par_condition(thread_db* tdbb, CompilerScratch* csb)
*
**************************************/
jrd_nod* dep_node;
SqlIdentifier name;
TEXT* p;
SLONG code_number;
Firebird::string name;
SET_TDBB(tdbb);
@ -790,8 +788,7 @@ static PsqlException* par_condition(thread_db* tdbb, CompilerScratch* csb)
case blr_gds_code:
exception_list->xcp_rpt[0].xcp_type = xcp_gds_code;
par_name(csb, name);
for (p = name; *p; *p++)
*p = LOWWER(*p);
name.lower();
code_number = PAR_symbol_to_gdscode(name);
if (code_number)
exception_list->xcp_rpt[0].xcp_code = code_number;
@ -804,7 +801,7 @@ static PsqlException* par_condition(thread_db* tdbb, CompilerScratch* csb)
exception_list->xcp_rpt[0].xcp_type = xcp_xcp_code;
par_name(csb, name);
if (!(exception_list->xcp_rpt[0].xcp_code =
MET_lookup_exception_number(tdbb, name)))
MET_lookup_exception_number(tdbb, name.c_str())))
error(csb, isc_xcpnotdef, isc_arg_string, ERR_cstring(name), 0);
dep_node = PAR_make_node(tdbb, e_dep_length);
dep_node->nod_type = nod_dependency;
@ -836,9 +833,8 @@ static PsqlException* par_conditions(thread_db* tdbb, CompilerScratch* csb)
*
**************************************/
jrd_nod* dep_node;
SqlIdentifier name;
TEXT* p;
SLONG code_number;
Firebird::string name;
SET_TDBB(tdbb);
@ -858,8 +854,7 @@ static PsqlException* par_conditions(thread_db* tdbb, CompilerScratch* csb)
case blr_gds_code:
exception_list->xcp_rpt[i].xcp_type = xcp_gds_code;
par_name(csb, name);
for (p = name; *p; *p++)
*p = LOWWER(*p);
name.lower();
code_number = PAR_symbol_to_gdscode(name);
if (code_number)
exception_list->xcp_rpt[i].xcp_code = code_number;
@ -872,7 +867,7 @@ static PsqlException* par_conditions(thread_db* tdbb, CompilerScratch* csb)
exception_list->xcp_rpt[i].xcp_type = xcp_xcp_code;
par_name(csb, name);
if (!(exception_list->xcp_rpt[i].xcp_code =
MET_lookup_exception_number(tdbb, name)))
MET_lookup_exception_number(tdbb, name.c_str())))
error(csb, isc_xcpnotdef,
isc_arg_string, ERR_cstring(name), 0);
dep_node = PAR_make_node(tdbb, e_dep_length);
@ -939,7 +934,7 @@ static void par_dependency(thread_db* tdbb,
CompilerScratch* csb,
SSHORT stream,
SSHORT id,
const TEXT* field_name)
const Firebird::string& field_name)
{
/**************************************
*
@ -967,15 +962,12 @@ static void par_dependency(thread_db* tdbb,
node->nod_arg[e_dep_object_type] = (jrd_nod*) obj_procedure;
}
if (field_name) {
if (! field_name.empty()) {
jrd_nod* field_node = PAR_make_node(tdbb, 1);
node->nod_arg[e_dep_field] = field_node;
field_node->nod_type = nod_literal;
const int length = strlen(field_name);
str* string = FB_NEW_RPT(*tdbb->tdbb_default, length) str();
string->str_length = length;
strcpy(reinterpret_cast<char*>(string->str_data), field_name);
field_node->nod_arg[0] = (jrd_nod*) string->str_data;
field_node->nod_arg[0] = (jrd_nod*)
stringDup(*tdbb->tdbb_default, field_name);
}
else if (id >= 0) {
jrd_nod* field_node = PAR_make_node(tdbb, 1);
@ -1004,16 +996,16 @@ static jrd_nod* par_exec_proc(thread_db* tdbb, CompilerScratch* csb, SSHORT blr_
jrd_prc* procedure = NULL;
{
SqlIdentifier name;
Firebird::string name;
if (blr_operator == blr_exec_pid) {
const USHORT pid = BLR_WORD;
if (!(procedure = MET_lookup_procedure_id(tdbb, pid, false, false, 0)))
sprintf(name, "id %d", pid);
name.printf("id %d", pid);
}
else {
par_name(csb, name);
procedure = MET_lookup_procedure(tdbb, name, false);
procedure = MET_lookup_procedure(tdbb, name.c_str(), false);
}
if (!procedure)
error(csb, isc_prcnotdef, isc_arg_string, ERR_cstring(name), 0);
@ -1108,8 +1100,7 @@ static jrd_nod* par_field(thread_db* tdbb, CompilerScratch* csb, SSHORT blr_oper
error(csb, isc_ctxnotdef, 0);
}
SqlIdentifier name;
name[0] = 0;
Firebird::string name;
SSHORT id;
const SSHORT stream = csb->csb_rpt[context].csb_stream;
SSHORT flags = 0;
@ -1156,7 +1147,7 @@ static jrd_nod* par_field(thread_db* tdbb, CompilerScratch* csb, SSHORT blr_oper
}
par_name(csb, name);
if ((id = MET_lookup_field(tdbb, relation, name, 0)) < 0) {
if ((id = MET_lookup_field(tdbb, relation, name.c_str(), 0)) < 0) {
if (csb->csb_g_flags & csb_validation) {
id = 0;
flags |= nod_id;
@ -1185,7 +1176,7 @@ static jrd_nod* par_field(thread_db* tdbb, CompilerScratch* csb, SSHORT blr_oper
if (csb->csb_g_flags & csb_get_dependencies) {
if (blr_operator == blr_fid)
par_dependency(tdbb, csb, stream, id, 0);
par_dependency(tdbb, csb, stream, id, "");
else
par_dependency(tdbb, csb, stream, id, name);
}
@ -1223,7 +1214,7 @@ static jrd_nod* par_function(thread_db* tdbb, CompilerScratch* csb)
**************************************/
SET_TDBB(tdbb);
SqlIdentifier name;
Firebird::string name;
const USHORT count = par_name(csb, name);
UserFunction* function = FUN_lookup_function(name,
@ -1522,7 +1513,7 @@ static jrd_nod* par_modify(thread_db* tdbb, CompilerScratch* csb)
}
static USHORT par_name(CompilerScratch* csb, TEXT* string)
static USHORT par_name(CompilerScratch* csb, Firebird::string& string)
{
/**************************************
*
@ -1535,17 +1526,15 @@ static USHORT par_name(CompilerScratch* csb, TEXT* string)
*
**************************************/
USHORT l = BLR_BYTE;
const USHORT count = l;
string = "";
if (count) {
if (l) {
do {
*string++ = BLR_BYTE;
string += BLR_BYTE;
} while (--l);
}
*string = 0;
return count;
return string.length();
}
@ -1583,7 +1572,7 @@ static jrd_nod* par_plan(thread_db* tdbb, CompilerScratch* csb)
/* we have hit a stream; parse the context number and access type */
if (node_type == blr_retrieve) {
SqlIdentifier name;
Firebird::string name;
jrd_nod* plan = PAR_make_node(tdbb, e_retrieve_length);
plan->nod_type = (NOD_T) (USHORT) blr_table[node_type];
@ -1749,7 +1738,7 @@ static jrd_nod* par_procedure(thread_db* tdbb, CompilerScratch* csb, SSHORT blr_
SET_TDBB(tdbb);
{
SqlIdentifier name;
Firebird::string name;
if (blr_operator == blr_procedure) {
par_name(csb, name);
@ -1758,7 +1747,7 @@ static jrd_nod* par_procedure(thread_db* tdbb, CompilerScratch* csb, SSHORT blr_
else {
const SSHORT pid = BLR_WORD;
if (!(procedure = MET_lookup_procedure_id(tdbb, pid, false, false, 0)))
sprintf(name, "id %d", pid);
name.printf("id %d", pid);
}
if (!procedure)
error(csb, isc_prcnotdef, isc_arg_string, ERR_cstring(name), 0);
@ -1777,7 +1766,7 @@ static jrd_nod* par_procedure(thread_db* tdbb, CompilerScratch* csb, SSHORT blr_
&node->nod_arg[e_prc_inputs], TRUE);
if (csb->csb_g_flags & csb_get_dependencies)
par_dependency(tdbb, csb, stream, (SSHORT) - 1, 0);
par_dependency(tdbb, csb, stream, (SSHORT) - 1, "");
return node;
}
@ -1935,7 +1924,7 @@ static jrd_nod* par_relation(
* Parse a relation reference.
*
**************************************/
SqlIdentifier name;
Firebird::string name;
SET_TDBB(tdbb);
@ -1945,18 +1934,17 @@ static jrd_nod* par_relation(
node->nod_count = 0;
/* Find relation either by id or by name */
str* alias_string = NULL;
jrd_rel* relation = 0;
Firebird::string* alias_string = 0;
if (blr_operator == blr_rid || blr_operator == blr_rid2) {
const SSHORT id = BLR_WORD;
if (blr_operator == blr_rid2) {
const SSHORT length = BLR_PEEK;
alias_string = FB_NEW_RPT(*tdbb->tdbb_default, length + 1) str();
alias_string->str_length = length;
par_name(csb, reinterpret_cast<char*>(alias_string->str_data));
alias_string = FB_NEW(csb->csb_pool) Firebird::string(csb->csb_pool);
par_name(csb, *alias_string);
}
if (!(relation = MET_lookup_relation_id(tdbb, id, false))) {
sprintf(name, "id %d", id);
name.printf("id %d", id);
error(csb, isc_relnotdef, isc_arg_string, ERR_cstring(name), 0);
}
}
@ -1964,18 +1952,20 @@ static jrd_nod* par_relation(
par_name(csb, name);
if (blr_operator == blr_relation2) {
const SSHORT length = BLR_PEEK;
alias_string = FB_NEW_RPT(*tdbb->tdbb_default, length + 1) str();
alias_string->str_length = length;
par_name(csb, reinterpret_cast<char*>(alias_string->str_data));
alias_string = FB_NEW(csb->csb_pool) Firebird::string(csb->csb_pool);
par_name(csb, *alias_string);
}
if (!(relation = MET_lookup_relation(tdbb, name)))
if (!(relation = MET_lookup_relation(tdbb, name.c_str())))
error(csb, isc_relnotdef, isc_arg_string, ERR_cstring(name), 0);
}
/* if an alias was passed, store with the relation */
if (alias_string)
node->nod_arg[e_rel_alias] = (jrd_nod*) alias_string;
{
node->nod_arg[e_rel_alias] =
(jrd_nod*) stringDup(*tdbb->tdbb_default, *alias_string);
}
/* Scan the relation if it hasn't already been scanned for meta data */
@ -2006,7 +1996,11 @@ static jrd_nod* par_relation(
csb->csb_rpt[stream].csb_alias = alias_string;
if (csb->csb_g_flags & csb_get_dependencies)
par_dependency(tdbb, csb, stream, (SSHORT) - 1, 0);
par_dependency(tdbb, csb, stream, (SSHORT) - 1, "");
}
else
{
delete alias_string;
}
node->nod_arg[e_rel_relation] = (jrd_nod*) relation;
@ -2289,6 +2283,8 @@ static jrd_nod* parse(thread_db* tdbb, CompilerScratch* csb, USHORT expected,
* Parse a BLR expression.
*
**************************************/
Firebird::string name;
SET_TDBB(tdbb);
const SSHORT blr_operator = BLR_BYTE;
@ -2424,7 +2420,7 @@ static jrd_nod* parse(thread_db* tdbb, CompilerScratch* csb, USHORT expected,
case blr_user_savepoint:
{
*arg++ = (jrd_nod*) (IPTR) BLR_BYTE;
SqlIdentifier name;
Firebird::string name;
par_name(csb, name);
*arg++ = (jrd_nod*) ALL_cstring(name);
break;
@ -2565,10 +2561,10 @@ static jrd_nod* parse(thread_db* tdbb, CompilerScratch* csb, USHORT expected,
case blr_gen_id:
case blr_set_generator:
{
SqlIdentifier name;
Firebird::string name;
par_name(csb, name);
const SLONG tmp = MET_lookup_generator(tdbb, name);
const SLONG tmp = MET_lookup_generator(tdbb, name.c_str());
if (tmp < 0) {
error(csb, isc_gennotdef,
isc_arg_string, ERR_cstring(name), 0);

View File

@ -38,11 +38,11 @@ Jrd::jrd_nod* PAR_blr(Jrd::thread_db*, Jrd::jrd_rel*, const UCHAR*, Jrd::Compile
Jrd::CompilerScratch**, Jrd::jrd_req**, const bool, USHORT);
USHORT PAR_desc(Jrd::CompilerScratch*, dsc*);
Jrd::jrd_nod* PAR_gen_field(Jrd::thread_db*, USHORT, USHORT);
Jrd::jrd_nod* PAR_make_field(Jrd::thread_db*, Jrd::CompilerScratch*, USHORT, const TEXT*);
Jrd::jrd_nod* PAR_make_field(Jrd::thread_db*, Jrd::CompilerScratch*, USHORT, const Firebird::string&);
Jrd::jrd_nod* PAR_make_list(Jrd::thread_db*, lls*);
Jrd::jrd_nod* PAR_make_node(Jrd::thread_db*, int);
Jrd::CompilerScratch* PAR_parse(Jrd::thread_db*, const UCHAR*, USHORT);
SLONG PAR_symbol_to_gdscode(const char*);
SLONG PAR_symbol_to_gdscode(const Firebird::string&);
#endif // JRD_PAR_PROTO_H