mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 18:03:04 +01:00
Misc; reinterpret to static casts; correction in YRequest version.
This commit is contained in:
parent
256cb1e853
commit
9754526943
@ -158,7 +158,8 @@ Jrd::Attachment::Attachment(MemoryPool* pool, Database* dbb, FB_API_HANDLE publi
|
||||
att_ext_call_depth(0),
|
||||
att_trace_manager(FB_NEW(*att_pool) TraceManager(this)),
|
||||
att_interface(NULL)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Jrd::Attachment::~Attachment()
|
||||
|
@ -57,7 +57,10 @@ public:
|
||||
virtual int FB_CARG seek(Firebird::IStatus* status, int mode, int offset); // returns position
|
||||
|
||||
public:
|
||||
JBlob(blb* handle, JAttachment* ja) : blob(handle), jAtt(ja) { }
|
||||
JBlob(blb* handle, JAttachment* ja)
|
||||
: blob(handle), jAtt(ja)
|
||||
{
|
||||
}
|
||||
|
||||
JAttachment* getAttachment()
|
||||
{
|
||||
@ -93,7 +96,10 @@ public:
|
||||
virtual void FB_CARG disconnect(Firebird::IStatus* status);
|
||||
|
||||
public:
|
||||
JTransaction(jrd_tra* handle, JAttachment* ja) : transaction(handle), jAtt(ja) { }
|
||||
JTransaction(jrd_tra* handle, JAttachment* ja)
|
||||
: transaction(handle), jAtt(ja)
|
||||
{
|
||||
}
|
||||
|
||||
jrd_tra* getHandle()
|
||||
{
|
||||
@ -150,7 +156,8 @@ public:
|
||||
public:
|
||||
JStatement(dsql_req* handle, JAttachment* ja)
|
||||
: statement(handle), jAtt(ja), metadata(getPool(), this)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
JAttachment* getAttachment()
|
||||
{
|
||||
@ -189,7 +196,10 @@ public:
|
||||
virtual void FB_CARG free(Firebird::IStatus* status);
|
||||
|
||||
public:
|
||||
JRequest(JrdStatement* handle, JAttachment* ja) : rq(handle), jAtt(ja) { }
|
||||
JRequest(JrdStatement* handle, JAttachment* ja)
|
||||
: rq(handle), jAtt(ja)
|
||||
{
|
||||
}
|
||||
|
||||
JAttachment* getAttachment()
|
||||
{
|
||||
@ -216,7 +226,10 @@ public:
|
||||
virtual void FB_CARG cancel(Firebird::IStatus* status);
|
||||
|
||||
public:
|
||||
JEvents(int aId, JAttachment* ja) : id(aId), jAtt(ja) { }
|
||||
JEvents(int aId, JAttachment* ja)
|
||||
: id(aId), jAtt(ja)
|
||||
{
|
||||
}
|
||||
|
||||
JEvents* getHandle()
|
||||
{
|
||||
@ -336,15 +349,16 @@ class JProvider : public Firebird::StdPlugin<Firebird::IProvider, FB_I_PROVIDER_
|
||||
{
|
||||
public:
|
||||
explicit JProvider(Firebird::IPluginConfig*)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
// IProvider implementation
|
||||
virtual void FB_CARG attachDatabase(Firebird::IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE api, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual void FB_CARG createDatabase(Firebird::IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE api, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual void FB_CARG attachDatabase(Firebird::IStatus* status, Firebird::IAttachment** ptr,
|
||||
FB_API_HANDLE api, const char* fileName, unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual void FB_CARG createDatabase(Firebird::IStatus* status, Firebird::IAttachment** ptr,
|
||||
FB_API_HANDLE api, const char* fileName, unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual JService* FB_CARG attachServiceManager(Firebird::IStatus* status, const char* service,
|
||||
unsigned int spbLength, const unsigned char* spb);
|
||||
unsigned int spbLength, const unsigned char* spb);
|
||||
//virtual ITransaction* startTransaction(Firebird::IStatus* status, unsigned int count, ...);
|
||||
//virtual ITransaction* startMultiple(Firebird::IStatus* status, MultipleTransaction* multi);
|
||||
virtual void FB_CARG shutdown(Firebird::IStatus* status, unsigned int timeout, const int reason);
|
||||
|
@ -148,7 +148,8 @@ class blb : public pool_alloc<type_blb>
|
||||
public:
|
||||
blb(MemoryPool& pool, USHORT page_size)
|
||||
: blb_buffer(pool, page_size / sizeof(SLONG)),
|
||||
blb_has_buffer(true), blb_interface(NULL)
|
||||
blb_has_buffer(true),
|
||||
blb_interface(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ void InternalConnection::attach(thread_db* tdbb, const Firebird::string& dbName,
|
||||
if (!status.isSuccess())
|
||||
raise(status, tdbb, "attach");
|
||||
|
||||
m_attachment = reinterpret_cast<JAttachment*>(a);
|
||||
m_attachment = static_cast<JAttachment*>(a);
|
||||
}
|
||||
|
||||
m_sqlDialect = (m_attachment->getHandle()->att_database->dbb_flags & DBB_DB_SQL_dialect_3) ?
|
||||
@ -419,33 +419,35 @@ void InternalStatement::doPrepare(thread_db* tdbb, const string& sql)
|
||||
|
||||
if (statement->getSendMsg())
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
PreparedStatement::parseDsqlMessage(statement->getSendMsg(), m_inDescs,
|
||||
m_inBlr, m_in_buffer);
|
||||
m_inputs = m_inDescs.getCount() / 2;
|
||||
}
|
||||
catch (const Exception&) {
|
||||
catch (const Exception&)
|
||||
{
|
||||
raise(tdbb->tdbb_status_vector, tdbb, "parse input message", &sql);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
m_inputs = 0;
|
||||
}
|
||||
|
||||
if (statement->getReceiveMsg())
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
PreparedStatement::parseDsqlMessage(statement->getReceiveMsg(), m_outDescs,
|
||||
m_outBlr, m_out_buffer);
|
||||
m_outputs = m_outDescs.getCount() / 2;
|
||||
}
|
||||
catch (const Exception&) {
|
||||
catch (const Exception&)
|
||||
{
|
||||
raise(tdbb->tdbb_status_vector, tdbb, "parse output message", &sql);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
m_outputs = 0;
|
||||
}
|
||||
|
||||
m_stmt_selectable = false;
|
||||
|
||||
@ -609,7 +611,7 @@ void InternalBlob::open(thread_db* tdbb, Transaction& tran, const dsc& desc, con
|
||||
fb_assert(sizeof(m_blob_id) == desc.dsc_length);
|
||||
|
||||
JAttachment* att = m_connection.getJrdAtt();
|
||||
JTransaction* transaction = ((InternalTransaction&) tran).getJrdTran();
|
||||
JTransaction* transaction = static_cast<InternalTransaction&>(tran).getJrdTran();
|
||||
memcpy(&m_blob_id, desc.dsc_address, sizeof(m_blob_id));
|
||||
|
||||
LocalStatus status;
|
||||
|
136
src/jrd/jrd.cpp
136
src/jrd/jrd.cpp
@ -183,7 +183,6 @@ int JTransaction::release()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int JStatement::release()
|
||||
{
|
||||
if (--refCounter != 0)
|
||||
@ -240,7 +239,8 @@ int JEvents::release()
|
||||
|
||||
JAttachment::JAttachment(Attachment* handle)
|
||||
: att(handle)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
int JAttachment::release()
|
||||
{
|
||||
@ -262,7 +262,8 @@ int JAttachment::release()
|
||||
|
||||
JService::JService(Service* handle)
|
||||
: svc(handle)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
int JService::release()
|
||||
{
|
||||
@ -368,9 +369,7 @@ namespace
|
||||
return;
|
||||
|
||||
if (!attachment || !attachment->att_database)
|
||||
{
|
||||
status_exception::raise(Arg::Gds(isc_bad_db_handle));
|
||||
}
|
||||
|
||||
tdbb->setAttachment(attachment);
|
||||
tdbb->setDatabase(attachment->att_database);
|
||||
@ -429,17 +428,18 @@ namespace
|
||||
: mutex(ja->getMutex(lockAsync))
|
||||
{
|
||||
mutex->enter();
|
||||
|
||||
Jrd::Attachment* attachment = ja->getHandle();
|
||||
|
||||
try
|
||||
{
|
||||
if ((!attachment) || engineShuttingDown)
|
||||
{
|
||||
if (!attachment || engineShuttingDown)
|
||||
status_exception::raise(Arg::Gds(isc_att_shutdown));
|
||||
}
|
||||
|
||||
tdbb->setAttachment(attachment);
|
||||
tdbb->setDatabase(attachment->att_database);
|
||||
}
|
||||
catch(const Firebird::Exception&)
|
||||
catch (const Firebird::Exception&)
|
||||
{
|
||||
mutex->leave();
|
||||
throw;
|
||||
@ -497,7 +497,7 @@ namespace
|
||||
private DatabaseContextHolder
|
||||
{
|
||||
public:
|
||||
template <class I>
|
||||
template <typename I>
|
||||
EngineContextHolder(IStatus* status, I* interfacePtr, bool lockAsync = false)
|
||||
: ThreadContextHolder(status),
|
||||
AttachmentHolder(*this, interfacePtr->getAttachment(), lockAsync),
|
||||
@ -2120,9 +2120,10 @@ JBlob* JAttachment::createBlob(IStatus* user_status, ITransaction* tra, ISC_QUAD
|
||||
EngineContextHolder tdbb(user_status, this);
|
||||
check_database(tdbb);
|
||||
|
||||
JTransaction* jt = reinterpret_cast<JTransaction*>(tra);
|
||||
JTransaction* jt = static_cast<JTransaction*>(tra);
|
||||
if (!jt)
|
||||
status_exception::raise(Arg::Gds(isc_bad_trans_handle));
|
||||
|
||||
validateHandle(tdbb, jt->getHandle());
|
||||
|
||||
try
|
||||
@ -2607,50 +2608,46 @@ void JAttachment::freeEngineData(IStatus* user_status)
|
||||
**************************************/
|
||||
try
|
||||
{
|
||||
{ // guard scope
|
||||
MutexLockGuard guard(databases_mutex);
|
||||
{ // holder scope
|
||||
EngineContextHolder tdbb(user_status, this, true);
|
||||
MutexLockGuard guard(databases_mutex);
|
||||
EngineContextHolder tdbb(user_status, this, true);
|
||||
|
||||
try
|
||||
{
|
||||
JRD_cancel_operation(tdbb, getHandle(), fb_cancel_raise);
|
||||
try
|
||||
{
|
||||
JRD_cancel_operation(tdbb, getHandle(), fb_cancel_raise);
|
||||
|
||||
MutexLockGuard guard(*getMutex());
|
||||
MutexLockGuard guard(*getMutex());
|
||||
|
||||
if (getHandle()->att_in_use)
|
||||
status_exception::raise(Arg::Gds(isc_attachment_in_use));
|
||||
if (getHandle()->att_in_use)
|
||||
status_exception::raise(Arg::Gds(isc_attachment_in_use));
|
||||
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
// if this is the last attachment, mark dbb as not in use
|
||||
// if this is the last attachment, mark dbb as not in use
|
||||
|
||||
if (dbb->dbb_attachments == getHandle() && !getHandle()->att_next &&
|
||||
!(dbb->dbb_flags & DBB_being_opened))
|
||||
{
|
||||
dbb->dbb_flags |= DBB_not_in_use;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Purge attachment, don't rollback open transactions
|
||||
getHandle()->att_flags |= ATT_cancel_disable;
|
||||
purge_attachment(tdbb, getHandle(), false);
|
||||
}
|
||||
catch (const Exception&)
|
||||
{
|
||||
dbb->dbb_flags &= ~DBB_not_in_use;
|
||||
throw;
|
||||
}
|
||||
|
||||
att = NULL;
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
transliterateException(tdbb, ex, user_status);
|
||||
return;
|
||||
}
|
||||
if (dbb->dbb_attachments == getHandle() && !getHandle()->att_next &&
|
||||
!(dbb->dbb_flags & DBB_being_opened))
|
||||
{
|
||||
dbb->dbb_flags |= DBB_not_in_use;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Purge attachment, don't rollback open transactions
|
||||
getHandle()->att_flags |= ATT_cancel_disable;
|
||||
purge_attachment(tdbb, getHandle(), false);
|
||||
}
|
||||
catch (const Exception&)
|
||||
{
|
||||
dbb->dbb_flags &= ~DBB_not_in_use;
|
||||
throw;
|
||||
}
|
||||
|
||||
att = NULL;
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
transliterateException(tdbb, ex, user_status);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
@ -2865,7 +2862,7 @@ int JAttachment::getSlice(IStatus* user_status, ITransaction* tra, ISC_QUAD* arr
|
||||
|
||||
if (!tra)
|
||||
status_exception::raise(Arg::Gds(isc_bad_trans_handle));
|
||||
validateHandle(tdbb, reinterpret_cast<JTransaction*>(tra)->getHandle());
|
||||
validateHandle(tdbb, static_cast<JTransaction*>(tra)->getHandle());
|
||||
|
||||
check_database(tdbb);
|
||||
|
||||
@ -2919,10 +2916,9 @@ JBlob* JAttachment::openBlob(IStatus* user_status, ITransaction* tra, ISC_QUAD*
|
||||
EngineContextHolder tdbb(user_status, this);
|
||||
|
||||
if (!tra)
|
||||
{
|
||||
status_exception::raise(Arg::Gds(isc_bad_trans_handle));
|
||||
}
|
||||
validateHandle(tdbb, reinterpret_cast<JTransaction*>(tra)->getHandle());
|
||||
|
||||
validateHandle(tdbb, static_cast<JTransaction*>(tra)->getHandle());
|
||||
|
||||
check_database(tdbb);
|
||||
|
||||
@ -3047,10 +3043,9 @@ void JAttachment::putSlice(IStatus* user_status, ITransaction* tra, ISC_QUAD* ar
|
||||
EngineContextHolder tdbb(user_status, this);
|
||||
|
||||
if (!tra)
|
||||
{
|
||||
status_exception::raise(Arg::Gds(isc_bad_trans_handle));
|
||||
}
|
||||
validateHandle(tdbb, reinterpret_cast<JTransaction*>(tra)->getHandle());
|
||||
|
||||
validateHandle(tdbb, static_cast<JTransaction*>(tra)->getHandle());
|
||||
|
||||
check_database(tdbb);
|
||||
|
||||
@ -3698,7 +3693,7 @@ void JRequest::startAndSend(IStatus* user_status, Firebird::ITransaction* tra, i
|
||||
{
|
||||
status_exception::raise(Arg::Gds(isc_bad_trans_handle));
|
||||
}
|
||||
validateHandle(tdbb, reinterpret_cast<JTransaction*>(tra)->getHandle());
|
||||
validateHandle(tdbb, static_cast<JTransaction*>(tra)->getHandle());
|
||||
|
||||
check_database(tdbb);
|
||||
|
||||
@ -3759,10 +3754,9 @@ void JRequest::start(IStatus* user_status, Firebird::ITransaction* tra, int leve
|
||||
EngineContextHolder tdbb(user_status, this);
|
||||
|
||||
if (!tra)
|
||||
{
|
||||
status_exception::raise(Arg::Gds(isc_bad_trans_handle));
|
||||
}
|
||||
validateHandle(tdbb, reinterpret_cast<JTransaction*>(tra)->getHandle());
|
||||
|
||||
validateHandle(tdbb, static_cast<JTransaction*>(tra)->getHandle());
|
||||
|
||||
check_database(tdbb);
|
||||
|
||||
@ -3954,10 +3948,9 @@ void JAttachment::transactRequest(IStatus* user_status, ITransaction* tra,
|
||||
EngineContextHolder tdbb(user_status, this);
|
||||
|
||||
if (!tra)
|
||||
{
|
||||
status_exception::raise(Arg::Gds(isc_bad_trans_handle));
|
||||
}
|
||||
validateHandle(tdbb, reinterpret_cast<JTransaction*>(tra)->getHandle());
|
||||
|
||||
validateHandle(tdbb, static_cast<JTransaction*>(tra)->getHandle());
|
||||
|
||||
check_database(tdbb);
|
||||
|
||||
@ -4172,7 +4165,7 @@ JStatement* JAttachment::allocateStatement(IStatus* user_status)
|
||||
JTransaction* JStatement::execute(IStatus* user_status, Firebird::ITransaction* apiTra,
|
||||
unsigned int in_msg_type, const FbMessage* inMsgBuffer, const FbMessage* outMsgBuffer)
|
||||
{
|
||||
JTransaction* jt = reinterpret_cast<JTransaction*>(apiTra);
|
||||
JTransaction* jt = static_cast<JTransaction*>(apiTra);
|
||||
jrd_tra* tra = jt ? jt->getHandle() : NULL;
|
||||
|
||||
try
|
||||
@ -4180,9 +4173,7 @@ JTransaction* JStatement::execute(IStatus* user_status, Firebird::ITransaction*
|
||||
EngineContextHolder tdbb(user_status, this);
|
||||
|
||||
if (tra)
|
||||
{
|
||||
validateHandle(tdbb, tra);
|
||||
}
|
||||
|
||||
check_database(tdbb);
|
||||
|
||||
@ -4242,7 +4233,7 @@ JTransaction* JAttachment::execute(IStatus* user_status, Firebird::ITransaction*
|
||||
unsigned int /*in_msg_type*/, const FbMessage* inMsgBuffer,
|
||||
const FbMessage* outMsgBuffer)
|
||||
{
|
||||
JTransaction* jt = reinterpret_cast<JTransaction*>(apiTra);
|
||||
JTransaction* jt = static_cast<JTransaction*>(apiTra);
|
||||
jrd_tra* tra = jt ? jt->getHandle() : NULL;
|
||||
|
||||
try
|
||||
@ -4250,9 +4241,7 @@ JTransaction* JAttachment::execute(IStatus* user_status, Firebird::ITransaction*
|
||||
EngineContextHolder tdbb(user_status, this);
|
||||
|
||||
if (tra)
|
||||
{
|
||||
validateHandle(tdbb, tra);
|
||||
}
|
||||
|
||||
check_database(tdbb);
|
||||
|
||||
@ -4426,11 +4415,10 @@ void JStatement::prepare(IStatus* user_status, Firebird::ITransaction* apiTra,
|
||||
{
|
||||
EngineContextHolder tdbb(user_status, this);
|
||||
|
||||
jrd_tra* tra = apiTra ? reinterpret_cast<JTransaction*>(apiTra)->getHandle() : NULL;
|
||||
jrd_tra* tra = apiTra ? static_cast<JTransaction*>(apiTra)->getHandle() : NULL;
|
||||
|
||||
if (tra)
|
||||
{
|
||||
validateHandle(tdbb, tra);
|
||||
}
|
||||
|
||||
check_database(tdbb);
|
||||
|
||||
@ -6300,8 +6288,7 @@ void JTransaction::freeEngineData(Firebird::IStatus* user_status)
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* release or rollback transaction
|
||||
* depending upon prepared it or not
|
||||
* Release or rollback transaction depending upon prepared it or not.
|
||||
*
|
||||
**************************************/
|
||||
try
|
||||
@ -6319,9 +6306,8 @@ void JTransaction::freeEngineData(Firebird::IStatus* user_status)
|
||||
TRA_release_transaction(tdbb, transaction);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRA_rollback(tdbb, transaction, false, false);
|
||||
}
|
||||
|
||||
transaction = NULL;
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
|
@ -716,7 +716,7 @@ namespace
|
||||
bool deleteCallback;
|
||||
};
|
||||
|
||||
class YRequest : public YHelper<IRequest, FB_I_STATEMENT_VERSION>
|
||||
class YRequest : public YHelper<IRequest, FB_I_REQUEST_VERSION>
|
||||
{
|
||||
public:
|
||||
static const ISC_STATUS ERROR_CODE = isc_bad_req_handle;
|
||||
@ -937,7 +937,8 @@ namespace
|
||||
public:
|
||||
EnterCount()
|
||||
: enterCount(0)
|
||||
{ }
|
||||
{}
|
||||
|
||||
~EnterCount()
|
||||
{
|
||||
fb_assert(enterCount == 0);
|
||||
@ -5560,8 +5561,7 @@ void Dispatcher::shutdown(IStatus* userStatus, unsigned int timeout, const int r
|
||||
} while (accessor.getNext());
|
||||
}
|
||||
}
|
||||
}
|
||||
while (hasThreads);
|
||||
} while (hasThreads);
|
||||
|
||||
// ... and wait for all providers to go away
|
||||
PluginManager::waitForType(PluginType::Provider);
|
||||
|
Loading…
Reference in New Issue
Block a user