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

Misc/cleanup

This commit is contained in:
asfernandes 2010-06-22 00:53:35 +00:00
parent 56c738c09d
commit 75af3ccf65
13 changed files with 40 additions and 79 deletions

View File

@ -274,8 +274,6 @@ void AggNode::setParameterName(dsql_par* parameter) const
void AggNode::genBlr() void AggNode::genBlr()
{ {
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
if (aggInfo.blr) // Is this a standard aggregate function? if (aggInfo.blr) // Is this a standard aggregate function?
dsqlScratch->appendUChar((distinct ? aggInfo.distinctBlr : aggInfo.blr)); dsqlScratch->appendUChar((distinct ? aggInfo.distinctBlr : aggInfo.blr));
else // This is a new window function. else // This is a new window function.

View File

@ -129,8 +129,6 @@ void DdlNode::putType(const TypeClause& type, bool useSubType)
} }
#endif #endif
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
if (type.notNull) if (type.notNull)
dsqlScratch->appendUChar(blr_not_nullable); dsqlScratch->appendUChar(blr_not_nullable);
@ -894,7 +892,6 @@ bool CreateAlterFunctionNode::executeAlter(thread_db* tdbb, jrd_tra* transaction
bool secondPass, bool runTriggers) bool secondPass, bool runTriggers)
{ {
Attachment* attachment = transaction->getAttachment(); Attachment* attachment = transaction->getAttachment();
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
bool modified = false; bool modified = false;
@ -2462,8 +2459,6 @@ bool CreateAlterTriggerNode::executeAlter(thread_db* tdbb, jrd_tra* transaction,
} }
else if (body) else if (body)
{ {
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
TRG.RDB$TRIGGER_BLR.NULL = FALSE; TRG.RDB$TRIGGER_BLR.NULL = FALSE;
attachment->storeBinaryBlob(tdbb, transaction, &TRG.RDB$TRIGGER_BLR, attachment->storeBinaryBlob(tdbb, transaction, &TRG.RDB$TRIGGER_BLR,
dsqlScratch->getBlrData().begin(), dsqlScratch->getBlrData().begin(),

View File

@ -475,7 +475,6 @@ public:
dropNode.silent = true; dropNode.silent = true;
} }
protected: protected:
virtual CreateAlterTriggerNode* getCreateAlterNode() virtual CreateAlterTriggerNode* getCreateAlterNode()
{ {

View File

@ -898,8 +898,6 @@ void SysFuncCallNode::setParameterName(dsql_par* parameter) const
void SysFuncCallNode::genBlr() void SysFuncCallNode::genBlr()
{ {
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
dsqlScratch->appendUChar(blr_sys_function); dsqlScratch->appendUChar(blr_sys_function);
dsqlScratch->appendMetaString(function->name.c_str()); dsqlScratch->appendMetaString(function->name.c_str());
dsqlScratch->appendUChar(dsqlArgs->nod_count); dsqlScratch->appendUChar(dsqlArgs->nod_count);
@ -1124,8 +1122,6 @@ void UdfCallNode::setParameterName(dsql_par* parameter) const
void UdfCallNode::genBlr() void UdfCallNode::genBlr()
{ {
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
if (dsqlFunction->udf_name.package.isEmpty()) if (dsqlFunction->udf_name.package.isEmpty())
dsqlScratch->appendUChar(blr_function); dsqlScratch->appendUChar(blr_function);
else else

View File

@ -67,8 +67,6 @@ void BlockNode::putDtype(DsqlCompilerScratch* dsqlScratch, const dsql_fld* field
} }
#endif #endif
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
if (field->fld_not_nullable) if (field->fld_not_nullable)
dsqlScratch->appendUChar(blr_not_nullable); dsqlScratch->appendUChar(blr_not_nullable);
@ -213,7 +211,6 @@ void BlockNode::putLocalVariables(DsqlCompilerScratch* dsqlScratch, const dsql_n
void BlockNode::putLocalVariable(DsqlCompilerScratch* dsqlScratch, dsql_var* variable, void BlockNode::putLocalVariable(DsqlCompilerScratch* dsqlScratch, dsql_var* variable,
dsql_nod* hostParam, const dsql_str* collationName) dsql_nod* hostParam, const dsql_str* collationName)
{ {
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
dsql_fld* field = variable->var_field; dsql_fld* field = variable->var_field;
dsqlScratch->appendUChar(blr_dcl_variable); dsqlScratch->appendUChar(blr_dcl_variable);
@ -365,8 +362,6 @@ void SavepointEncloseNode::print(string& text, Array<dsql_nod*>& nodes) const
void SavepointEncloseNode::genBlr() void SavepointEncloseNode::genBlr()
{ {
DsqlCompiledStatement* const statement = dsqlScratch->getStatement();
dsqlScratch->appendUChar(blr_begin); dsqlScratch->appendUChar(blr_begin);
dsqlScratch->appendUChar(blr_start_savepoint); dsqlScratch->appendUChar(blr_start_savepoint);
stmt->genBlr(); stmt->genBlr();
@ -1900,8 +1895,6 @@ void ReturnNode::print(string& text, Array<dsql_nod*>& nodes) const
void ReturnNode::genBlr() void ReturnNode::genBlr()
{ {
DsqlCompiledStatement* const statement = dsqlScratch->getStatement();
dsqlScratch->appendUChar(blr_assignment); dsqlScratch->appendUChar(blr_assignment);
GEN_expr(dsqlScratch, value); GEN_expr(dsqlScratch, value);
dsqlScratch->appendUChar(blr_variable); dsqlScratch->appendUChar(blr_variable);

View File

@ -2981,9 +2981,10 @@ static void define_view(DsqlCompilerScratch* dsqlScratch, NOD_TYPE op)
dsqlScratch->appendNullString(isc_dyn_def_local_fld, field_string); dsqlScratch->appendNullString(isc_dyn_def_local_fld, field_string);
dsqlScratch->appendString(isc_dyn_fld_base_fld, field->fld_name); dsqlScratch->appendString(isc_dyn_fld_base_fld, field->fld_name);
if (field->fld_dtype <= dtype_any_text) {
if (field->fld_dtype <= dtype_any_text)
dsqlScratch->appendNumber(isc_dyn_fld_collation, field->fld_collation_id); dsqlScratch->appendNumber(isc_dyn_fld_collation, field->fld_collation_id);
}
dsqlScratch->appendNumber(isc_dyn_view_context, context->ctx_context); dsqlScratch->appendNumber(isc_dyn_view_context, context->ctx_context);
} }
else else
@ -3299,7 +3300,6 @@ static void delete_exception (DsqlCompilerScratch* dsqlScratch, dsql_nod* node,
} }
} }
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
dsqlScratch->appendNullString(isc_dyn_del_exception, string->str_data); dsqlScratch->appendNullString(isc_dyn_del_exception, string->str_data);
dsqlScratch->appendUChar(isc_dyn_end); dsqlScratch->appendUChar(isc_dyn_end);
} }
@ -3354,7 +3354,6 @@ static void delete_relation_view (DsqlCompilerScratch* dsqlScratch, dsql_nod* no
} }
if (relation) if (relation)
{ {
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
dsqlScratch->appendNullString(isc_dyn_delete_rel, string->str_data); dsqlScratch->appendNullString(isc_dyn_delete_rel, string->str_data);
dsqlScratch->appendUChar(isc_dyn_end); dsqlScratch->appendUChar(isc_dyn_end);
} }
@ -3867,8 +3866,6 @@ static void make_index( DsqlCompilerScratch* dsqlScratch,
if (string) if (string)
index_name = string->str_data; index_name = string->str_data;
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
if (element->nod_type == nod_primary) if (element->nod_type == nod_primary)
dsqlScratch->appendNullString(isc_dyn_def_primary_key, index_name); dsqlScratch->appendNullString(isc_dyn_def_primary_key, index_name);
else if (element->nod_type == nod_unique) else if (element->nod_type == nod_unique)
@ -4076,9 +4073,8 @@ static void modify_database( DsqlCompilerScratch* dsqlScratch)
drop_difference = true; drop_difference = true;
} }
if (drop_difference) { if (drop_difference)
dsqlScratch->appendUChar(isc_dyn_drop_difference); dsqlScratch->appendUChar(isc_dyn_drop_difference);
}
SLONG start = 0; SLONG start = 0;
@ -4269,12 +4265,10 @@ static void modify_index( DsqlCompilerScratch* dsqlScratch)
dsqlScratch->appendNullString(isc_dyn_mod_idx, index_name->str_data); dsqlScratch->appendNullString(isc_dyn_mod_idx, index_name->str_data);
if (index_node->nod_type == nod_idx_active) { if (index_node->nod_type == nod_idx_active)
dsqlScratch->appendNumber(isc_dyn_idx_inactive, 0); dsqlScratch->appendNumber(isc_dyn_idx_inactive, 0);
} else if (index_node->nod_type == nod_idx_inactive)
else if (index_node->nod_type == nod_idx_inactive) {
dsqlScratch->appendNumber(isc_dyn_idx_inactive, 1); dsqlScratch->appendNumber(isc_dyn_idx_inactive, 1);
}
dsqlScratch->appendUChar(isc_dyn_end); dsqlScratch->appendUChar(isc_dyn_end);
} }
@ -4292,7 +4286,6 @@ static void put_user_grant(DsqlCompilerScratch* dsqlScratch, const dsql_nod* use
* Stuff a user/role/obj option in grant/revoke * Stuff a user/role/obj option in grant/revoke
* *
**************************************/ **************************************/
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
const dsql_str* name = (dsql_str*) user->nod_arg[0]; const dsql_str* name = (dsql_str*) user->nod_arg[0];
switch (user->nod_type) switch (user->nod_type)
@ -4302,12 +4295,10 @@ static void put_user_grant(DsqlCompilerScratch* dsqlScratch, const dsql_nod* use
break; break;
case nod_user_name: case nod_user_name:
if (user->nod_count == 2) { if (user->nod_count == 2)
dsqlScratch->appendNullString(isc_dyn_grant_user_explicit, name->str_data); dsqlScratch->appendNullString(isc_dyn_grant_user_explicit, name->str_data);
} else
else {
dsqlScratch->appendNullString(isc_dyn_grant_user, name->str_data); dsqlScratch->appendNullString(isc_dyn_grant_user, name->str_data);
}
break; break;
case nod_package_obj: case nod_package_obj:
@ -4363,8 +4354,6 @@ static void modify_privilege(DsqlCompilerScratch* dsqlScratch,
* *
**************************************/ **************************************/
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
if (type == nod_grant) if (type == nod_grant)
dsqlScratch->appendUChar(isc_dyn_grant); dsqlScratch->appendUChar(isc_dyn_grant);
else else
@ -4374,6 +4363,7 @@ static void modify_privilege(DsqlCompilerScratch* dsqlScratch,
SSHORT priv_count = 0; SSHORT priv_count = 0;
dsqlScratch->appendUShort(0); dsqlScratch->appendUShort(0);
for (; *privs; privs++) for (; *privs; privs++)
{ {
priv_count++; priv_count++;
@ -4381,9 +4371,8 @@ static void modify_privilege(DsqlCompilerScratch* dsqlScratch,
} }
UCHAR* dynsave = dsqlScratch->getBlrData().end(); UCHAR* dynsave = dsqlScratch->getBlrData().end();
for (SSHORT i = priv_count + 2; i; i--) { for (SSHORT i = priv_count + 2; i; i--)
--dynsave; --dynsave;
}
*dynsave++ = (UCHAR) priv_count; *dynsave++ = (UCHAR) priv_count;
*dynsave = (UCHAR) (priv_count >> 8); *dynsave = (UCHAR) (priv_count >> 8);
@ -4408,14 +4397,11 @@ static void modify_privilege(DsqlCompilerScratch* dsqlScratch,
put_user_grant(dsqlScratch, user); put_user_grant(dsqlScratch, user);
if (field_name) { if (field_name)
dsqlScratch->appendNullString(isc_dyn_fld_name, field_name->str_data); dsqlScratch->appendNullString(isc_dyn_fld_name, field_name->str_data);
}
if (option) if (option)
{
dsqlScratch->appendNumber(isc_dyn_grant_options, option); dsqlScratch->appendNumber(isc_dyn_grant_options, option);
}
put_grantor(dsqlScratch, grantor); put_grantor(dsqlScratch, grantor);
@ -4808,14 +4794,10 @@ static void process_role_nm_list(DsqlCompilerScratch* dsqlScratch,
* Build req_blr for grant & revoke role stmt * Build req_blr for grant & revoke role stmt
* *
**************************************/ **************************************/
DsqlCompiledStatement* statement = dsqlScratch->getStatement(); if (type == nod_grant)
if (type == nod_grant) {
dsqlScratch->appendUChar(isc_dyn_grant); dsqlScratch->appendUChar(isc_dyn_grant);
} else
else {
dsqlScratch->appendUChar(isc_dyn_revoke); dsqlScratch->appendUChar(isc_dyn_revoke);
}
dsqlScratch->appendUShort(1); dsqlScratch->appendUShort(1);
dsqlScratch->appendUChar('M'); dsqlScratch->appendUChar('M');
@ -4850,7 +4832,6 @@ static void put_grantor(DsqlCompilerScratch* dsqlScratch, const dsql_nod* granto
**************************************/ **************************************/
if (grantor) if (grantor)
{ {
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
fb_assert(grantor->nod_type == nod_user_name); fb_assert(grantor->nod_type == nod_user_name);
const dsql_str* name = (const dsql_str*) grantor->nod_arg[0]; const dsql_str* name = (const dsql_str*) grantor->nod_arg[0];
dsqlScratch->appendNullString(isc_dyn_grant_grantor, name->str_data); dsqlScratch->appendNullString(isc_dyn_grant_grantor, name->str_data);
@ -4872,8 +4853,6 @@ static void put_descriptor(DsqlCompilerScratch* dsqlScratch, const dsc* desc)
* *
**************************************/ **************************************/
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
dsqlScratch->appendNumber(isc_dyn_fld_type, blr_dtypes[desc->dsc_dtype]); dsqlScratch->appendNumber(isc_dyn_fld_type, blr_dtypes[desc->dsc_dtype]);
if (desc->dsc_dtype == dtype_varying) { if (desc->dsc_dtype == dtype_varying) {
dsqlScratch->appendNumber(isc_dyn_fld_length, (SSHORT) (desc->dsc_length - sizeof(USHORT))); dsqlScratch->appendNumber(isc_dyn_fld_length, (SSHORT) (desc->dsc_length - sizeof(USHORT)));
@ -4918,8 +4897,6 @@ static void put_field( DsqlCompilerScratch* dsqlScratch, dsql_fld* field, bool u
* *
**************************************/ **************************************/
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
if (field->fld_not_nullable) if (field->fld_not_nullable)
dsqlScratch->appendUChar(isc_dyn_fld_not_null); dsqlScratch->appendUChar(isc_dyn_fld_not_null);

View File

@ -369,7 +369,7 @@ enum intlsym_flags_vals {
// Compiled statement - shared by multiple requests. // Compiled statement - shared by multiple requests.
class DsqlCompiledStatement : public Firebird::PermanentStorage class DsqlCompiledStatement : public Firebird::PermanentStorage
{ {
friend class DsqlCompilerScratch; ///friend class DsqlCompilerScratch;
public: public:
enum Type // statement type enum Type // statement type
@ -626,13 +626,13 @@ protected:
virtual bool isVersion4() virtual bool isVersion4()
{ {
return statement->flags & DsqlCompiledStatement::FLAG_BLR_VERSION4; return statement->getFlags() & DsqlCompiledStatement::FLAG_BLR_VERSION4;
} }
virtual bool isDdlDyn() virtual bool isDdlDyn()
{ {
return (statement->type == DsqlCompiledStatement::TYPE_DDL || statement->ddlNode) && return (statement->getType() == DsqlCompiledStatement::TYPE_DDL || statement->getDdlNode()) &&
!statement->blockNode; !statement->getBlockNode();
} }
public: public:

View File

@ -1782,6 +1782,7 @@ static void gen_exec_stmt(DsqlCompilerScratch* dsqlScratch, const dsql_nod* node
GEN_expr(dsqlScratch, temp->nod_arg[i]); GEN_expr(dsqlScratch, temp->nod_arg[i]);
} }
} }
dsqlScratch->appendUChar(blr_end); dsqlScratch->appendUChar(blr_end);
} }

View File

@ -6323,7 +6323,6 @@ static dsql_nod* pass1_merge(DsqlCompilerScratch* dsqlScratch, dsql_nod* input)
virtual void genBlr() virtual void genBlr()
{ {
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
dsql_msg* message = dsqlScratch->getStatement()->getReceiveMsg(); dsql_msg* message = dsqlScratch->getStatement()->getReceiveMsg();
if (!dsqlScratch->isPsql() && message) if (!dsqlScratch->isPsql() && message)

View File

@ -2452,6 +2452,7 @@ int ISC_mutex_init(sh_mem* shmem_data, struct mtx* mutex, struct mtx** mapped)
{ {
return -1; // no errno known here... return -1; // no errno known here...
} }
mutex = *mapped; mutex = *mapped;
if (!getSem5(mutex)) if (!getSem5(mutex))
@ -2608,6 +2609,7 @@ int ISC_mutex_init(sh_mem* shmem_data, struct mtx* mutex, struct mtx** mapped)
{ {
return -1; // no errno known here... return -1; // no errno known here...
} }
mutex = *mapped; mutex = *mapped;
#ifdef BUGGY_LINUX_MUTEX #ifdef BUGGY_LINUX_MUTEX

View File

@ -5046,7 +5046,7 @@ static void store_dependencies(thread_db* tdbb,
int dpdo_type = (int) (IPTR) node->nod_arg[e_dep_object_type]; int dpdo_type = (int) (IPTR) node->nod_arg[e_dep_object_type];
jrd_rel* relation = NULL; jrd_rel* relation = NULL;
jrd_prc* procedure = NULL; jrd_prc* procedure = NULL;
const MetaName* dpdo_name = 0; const MetaName* dpdo_name = NULL;
MetaName packageName; MetaName packageName;
SubtypeInfo info; SubtypeInfo info;

View File

@ -2322,7 +2322,8 @@ void LockManager::initialize(sh_mem* shmem_data, bool initializeMemory)
} }
#endif #endif
if (!initializeMemory) { if (!initializeMemory)
{
#ifndef WIN_NT #ifndef WIN_NT
if (ISC_map_mutex(shmem_data, &m_header->lhb_mutex, &(MUTEX))) { if (ISC_map_mutex(shmem_data, &m_header->lhb_mutex, &(MUTEX))) {
bug(NULL, "mutex map failed"); bug(NULL, "mutex map failed");