mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 18:43:02 +01:00
Integrate IAttachment and ITransaction in the external engines API.
This commit is contained in:
parent
7915153e51
commit
69dc52ba48
@ -342,6 +342,9 @@ fb_ping
|
||||
|
||||
fb_get_master_interface
|
||||
|
||||
fb_get_database_handle
|
||||
fb_get_transaction_handle
|
||||
|
||||
# Other misc functions
|
||||
|
||||
isc_ftof
|
||||
|
@ -352,6 +352,8 @@ EXPORTS
|
||||
|
||||
fb_ping
|
||||
fb_get_master_interface
|
||||
fb_get_database_handle
|
||||
fb_get_transaction_handle
|
||||
|
||||
gds__trace
|
||||
gds__trace_raw
|
||||
|
@ -158,8 +158,6 @@ FB_UDR_BEGIN_FUNCTION(wait_event)
|
||||
|
||||
unsigned char* eveBuffer;
|
||||
unsigned char* eveResult;
|
||||
// NOTE: isc_event_block leaks the two memory buffers allocated.
|
||||
// You should manually construct the EPB if you care.
|
||||
int eveLen = funcEventBlock(&eveBuffer, &eveResult, 1, s);
|
||||
|
||||
ISC_STATUS_ARRAY statusVector = {0};
|
||||
@ -173,6 +171,9 @@ FB_UDR_BEGIN_FUNCTION(wait_event)
|
||||
statusVector);
|
||||
funcEventCounts(&counter, eveLen, eveBuffer, eveResult);
|
||||
|
||||
isc_free((char*) eveBuffer);
|
||||
isc_free((char*) eveResult);
|
||||
|
||||
// returns the counter
|
||||
result->setInt(ThrowError(), counter);
|
||||
}
|
||||
|
@ -720,6 +720,18 @@ public:
|
||||
fb_assert(false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual IAttachment* registerAttachment(IProvider* /*provider*/, IAttachment* /*attachment*/)
|
||||
{
|
||||
fb_assert(false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual ITransaction* registerTransaction(IAttachment* /*attachment*/, ITransaction* /*transaction*/)
|
||||
{
|
||||
fb_assert(false);
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -106,25 +106,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class Attachment : public Disposable
|
||||
{
|
||||
public:
|
||||
// Get an ISC compatible attachment handle.
|
||||
virtual Handle FB_CALL getHandle(Error* error) const = 0;
|
||||
|
||||
virtual const char* FB_CALL getUserName() const = 0;
|
||||
virtual const char* FB_CALL getDatabaseName() const = 0;
|
||||
};
|
||||
|
||||
|
||||
class Transaction
|
||||
{
|
||||
public:
|
||||
// Get an ISC compatible transaction handle.
|
||||
virtual Handle FB_CALL getHandle(Error* error) const = 0;
|
||||
};
|
||||
|
||||
|
||||
// Represents a parameter or column.
|
||||
class Value
|
||||
{
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include "FirebirdApi.h"
|
||||
#include "FirebirdPluginApi.h"
|
||||
#include "ProviderInterface.h"
|
||||
|
||||
|
||||
namespace Firebird {
|
||||
@ -58,11 +59,14 @@ public:
|
||||
virtual ExternalEngine* FB_CALL getEngine(Error* error) = 0;
|
||||
|
||||
// Gets the Attachment associated with this context.
|
||||
virtual Attachment* FB_CALL getAttachment(Error* error) = 0;
|
||||
virtual IAttachment* FB_CALL getAttachment(Error* error) = 0;
|
||||
|
||||
// Obtained transaction is valid only before control is returned to the engine
|
||||
// or in ExternalResultSet::fetch calls of correspondent ExternalProcedure::open.
|
||||
virtual Transaction* FB_CALL getTransaction(Error* error) = 0;
|
||||
virtual ITransaction* FB_CALL getTransaction(Error* error) = 0;
|
||||
|
||||
virtual const char* FB_CALL getUserName() = 0;
|
||||
virtual const char* FB_CALL getDatabaseName() = 0;
|
||||
|
||||
// Get user attachment character set.
|
||||
virtual const Utf8* FB_CALL getClientCharSet() = 0;
|
||||
|
@ -438,14 +438,20 @@ class Helper
|
||||
public:
|
||||
static isc_db_handle getIscDbHandle(ExternalContext* context)
|
||||
{
|
||||
Attachment* att = context->getAttachment(ThrowError());
|
||||
return att->getHandle(ThrowError());
|
||||
ISC_STATUS_ARRAY status = {0};
|
||||
isc_db_handle handle = 0;
|
||||
fb_get_database_handle(status, &handle, context->getAttachment(ThrowError()));
|
||||
ThrowError::check(status);
|
||||
return handle;
|
||||
}
|
||||
|
||||
static isc_tr_handle getIscTrHandle(ExternalContext* context)
|
||||
{
|
||||
Transaction* tra = context->getTransaction(ThrowError());
|
||||
return tra->getHandle(ThrowError());
|
||||
ISC_STATUS_ARRAY status = {0};
|
||||
isc_tr_handle handle = 0;
|
||||
fb_get_transaction_handle(status, &handle, context->getTransaction(ThrowError()));
|
||||
ThrowError::check(status);
|
||||
return handle;
|
||||
}
|
||||
|
||||
static void* getEntryPoint(ExternalContext* /*context*/, const char* entryPoint)
|
||||
|
@ -77,6 +77,8 @@ public:
|
||||
class IProvider;
|
||||
class IPluginManager;
|
||||
class ITimerControl;
|
||||
class IAttachment;
|
||||
class ITransaction;
|
||||
|
||||
// Master interface is used to access almost all other interfaces.
|
||||
class IMaster : public IDisposable
|
||||
@ -91,6 +93,8 @@ public:
|
||||
virtual int FB_CARG upgradeInterface(IInterface* toUpgrade, int desiredVersion, void* missingFunctionClass) = 0;
|
||||
virtual const char* FB_CARG circularAlloc(const char* s, size_t len, intptr_t thr) = 0;
|
||||
virtual ITimerControl* FB_CARG getTimerControl() = 0;
|
||||
virtual IAttachment* registerAttachment(IProvider* provider, IAttachment* attachment) = 0;
|
||||
virtual ITransaction* registerTransaction(IAttachment* attachment, ITransaction* transaction) = 0;
|
||||
};
|
||||
|
||||
} // namespace Firebird
|
||||
|
@ -178,8 +178,7 @@ public:
|
||||
unsigned int bufferLength, unsigned char* buffer) = 0;
|
||||
// virtual ITransaction* FB_CARG startTransaction(IStatus* status, unsigned int tpbLength, const unsigned char* tpb) = 0;
|
||||
// second form is tmp - not to rewrite external engines right now
|
||||
virtual ITransaction* FB_CARG startTransaction(IStatus* status, unsigned int tpbLength, const unsigned char* tpb,
|
||||
FB_API_HANDLE api) = 0;
|
||||
virtual ITransaction* FB_CARG startTransaction(IStatus* status, unsigned int tpbLength, const unsigned char* tpb) = 0;
|
||||
virtual ITransaction* FB_CARG reconnectTransaction(IStatus* status, unsigned int length, const unsigned char* id) = 0;
|
||||
virtual IStatement* FB_CARG allocateStatement(IStatus* status) = 0;
|
||||
virtual IRequest* FB_CARG compileRequest(IStatus* status, unsigned int blrLength, const unsigned char* blr) = 0;
|
||||
@ -230,10 +229,10 @@ public:
|
||||
class IProvider : public IPluginBase
|
||||
{
|
||||
public:
|
||||
virtual void FB_CARG attachDatabase(IStatus* status, IAttachment** ptr, FB_API_HANDLE api, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb) = 0;
|
||||
virtual void FB_CARG createDatabase(IStatus* status, IAttachment** ptr, FB_API_HANDLE api, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb) = 0;
|
||||
virtual IAttachment* FB_CARG attachDatabase(IStatus* status, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb) = 0;
|
||||
virtual IAttachment* FB_CARG createDatabase(IStatus* status, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb) = 0;
|
||||
virtual IService* FB_CARG attachServiceManager(IStatus* status, const char* service,
|
||||
unsigned int spbLength, const unsigned char* spb) = 0;
|
||||
//virtual ITransaction* FB_CARG startTransaction(IStatus* status, unsigned int count, ...) = 0;
|
||||
|
@ -48,13 +48,13 @@ using namespace Firebird;
|
||||
|
||||
|
||||
// static method
|
||||
Jrd::Attachment* Jrd::Attachment::create(Database* dbb, FB_API_HANDLE publicHandle)
|
||||
Jrd::Attachment* Jrd::Attachment::create(Database* dbb)
|
||||
{
|
||||
MemoryPool* const pool = dbb->createPool();
|
||||
|
||||
try
|
||||
{
|
||||
Attachment* const attachment = FB_NEW(*pool) Attachment(pool, dbb, publicHandle);
|
||||
Attachment* const attachment = FB_NEW(*pool) Attachment(pool, dbb);
|
||||
pool->setStatsGroup(attachment->att_memory_stats);
|
||||
return attachment;
|
||||
}
|
||||
@ -135,11 +135,10 @@ void Jrd::Attachment::backupStateReadUnLock(thread_db* tdbb)
|
||||
}
|
||||
|
||||
|
||||
Jrd::Attachment::Attachment(MemoryPool* pool, Database* dbb, FB_API_HANDLE publicHandle)
|
||||
Jrd::Attachment::Attachment(MemoryPool* pool, Database* dbb)
|
||||
: att_pool(pool),
|
||||
att_memory_stats(&dbb->dbb_memory_stats),
|
||||
att_database(dbb),
|
||||
att_public_handle(publicHandle),
|
||||
att_requests(*pool),
|
||||
att_lock_owner_id(Database::getLockOwnerId()),
|
||||
att_backup_state_counter(0),
|
||||
@ -157,7 +156,8 @@ Jrd::Attachment::Attachment(MemoryPool* pool, Database* dbb, FB_API_HANDLE publi
|
||||
att_ext_connection(NULL),
|
||||
att_ext_call_depth(0),
|
||||
att_trace_manager(FB_NEW(*att_pool) TraceManager(this)),
|
||||
att_interface(NULL)
|
||||
att_interface(NULL),
|
||||
att_public_interface(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -121,14 +121,13 @@ struct bid;
|
||||
class Attachment : public pool_alloc<type_att>
|
||||
{
|
||||
public:
|
||||
static Attachment* create(Database* dbb, FB_API_HANDLE publicHandle);
|
||||
static Attachment* create(Database* dbb);
|
||||
static void destroy(Attachment* const attachment);
|
||||
|
||||
MemoryPool* const att_pool; // Memory pool
|
||||
Firebird::MemoryStats att_memory_stats;
|
||||
|
||||
Database* att_database; // Parent database block
|
||||
FB_API_HANDLE att_public_handle; // Public handle
|
||||
Attachment* att_next; // Next attachment to database
|
||||
UserId* att_user; // User identification
|
||||
jrd_tra* att_transactions; // Transactions belonging to attachment
|
||||
@ -177,6 +176,7 @@ public:
|
||||
TraceManager* att_trace_manager; // Trace API manager
|
||||
|
||||
JAttachment* att_interface;
|
||||
Firebird::IAttachment* att_public_interface;
|
||||
|
||||
bool locksmith() const;
|
||||
jrd_tra* getSysTransaction();
|
||||
@ -216,7 +216,7 @@ public:
|
||||
void backupStateReadUnLock(thread_db* tdbb);
|
||||
|
||||
private:
|
||||
Attachment(MemoryPool* pool, Database* dbb, FB_API_HANDLE publicHandle);
|
||||
Attachment(MemoryPool* pool, Database* dbb);
|
||||
~Attachment();
|
||||
};
|
||||
|
||||
|
@ -256,8 +256,8 @@ public:
|
||||
virtual void FB_CARG getInfo(Firebird::IStatus* status,
|
||||
unsigned int itemsLength, const unsigned char* items,
|
||||
unsigned int bufferLength, unsigned char* buffer);
|
||||
virtual JTransaction* FB_CARG startTransaction(Firebird::IStatus* status, unsigned int tpbLength, const unsigned char* tpb,
|
||||
FB_API_HANDLE api);
|
||||
virtual JTransaction* FB_CARG startTransaction(Firebird::IStatus* status,
|
||||
unsigned int tpbLength, const unsigned char* tpb);
|
||||
virtual JTransaction* FB_CARG reconnectTransaction(Firebird::IStatus* status, unsigned int length, const unsigned char* id);
|
||||
virtual JStatement* FB_CARG allocateStatement(Firebird::IStatus* status);
|
||||
virtual JRequest* FB_CARG compileRequest(Firebird::IStatus* status, unsigned int blr_length, const unsigned char* blr);
|
||||
@ -353,10 +353,10 @@ public:
|
||||
}
|
||||
|
||||
// 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 JAttachment* FB_CARG attachDatabase(Firebird::IStatus* status, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual JAttachment* FB_CARG createDatabase(Firebird::IStatus* status, 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);
|
||||
//virtual ITransaction* startTransaction(Firebird::IStatus* status, unsigned int count, ...);
|
||||
|
@ -60,40 +60,6 @@ using namespace Firebird;
|
||||
namespace Jrd {
|
||||
|
||||
|
||||
class ExtEngineManager::AttachmentImpl : public Firebird::Attachment
|
||||
{
|
||||
public:
|
||||
AttachmentImpl(ExternalContextImpl* aContext, Handle aHandle, Jrd::Attachment* aAttachment);
|
||||
virtual ~AttachmentImpl();
|
||||
|
||||
public:
|
||||
virtual void FB_CALL dispose(Error* error);
|
||||
|
||||
virtual Handle FB_CALL getHandle(Error* error) const;
|
||||
virtual const char* FB_CALL getUserName() const;
|
||||
virtual const char* FB_CALL getDatabaseName() const;
|
||||
|
||||
private:
|
||||
ExternalContextImpl* context;
|
||||
FB_API_HANDLE handle;
|
||||
Jrd::Attachment* attachment;
|
||||
};
|
||||
|
||||
|
||||
class ExtEngineManager::TransactionImpl : public Firebird::Transaction
|
||||
{
|
||||
public:
|
||||
TransactionImpl(Handle aHandle);
|
||||
virtual ~TransactionImpl();
|
||||
|
||||
public:
|
||||
virtual Handle FB_CALL getHandle(Error* error) const;
|
||||
|
||||
private:
|
||||
FB_API_HANDLE handle;
|
||||
};
|
||||
|
||||
|
||||
template <typename T> class ExtEngineManager::ContextManager
|
||||
{
|
||||
public:
|
||||
@ -200,89 +166,18 @@ private:
|
||||
//---------------------
|
||||
|
||||
|
||||
ExtEngineManager::AttachmentImpl::AttachmentImpl(ExternalContextImpl* aContext, Handle aHandle,
|
||||
Jrd::Attachment* aAttachment)
|
||||
: context(aContext),
|
||||
handle(aHandle),
|
||||
attachment(aAttachment)
|
||||
{
|
||||
}
|
||||
|
||||
ExtEngineManager::AttachmentImpl::~AttachmentImpl()
|
||||
{
|
||||
context->attachment.release();
|
||||
handle = 0;
|
||||
dispose(LogError());
|
||||
}
|
||||
|
||||
void FB_CALL ExtEngineManager::AttachmentImpl::dispose(Error* error)
|
||||
{
|
||||
ISC_STATUS_ARRAY statusVector;
|
||||
|
||||
if (handle)
|
||||
{
|
||||
if (isc_detach_database(statusVector, &handle) != 0)
|
||||
{
|
||||
ErrorImpl::statusVectorToError(statusVector, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
context->attachment = NULL;
|
||||
}
|
||||
|
||||
Handle FB_CALL ExtEngineManager::AttachmentImpl::getHandle(Error* /*error*/) const
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
const char* FB_CALL ExtEngineManager::AttachmentImpl::getUserName() const
|
||||
{
|
||||
return attachment->att_user->usr_user_name.c_str();
|
||||
}
|
||||
|
||||
|
||||
const char* FB_CALL ExtEngineManager::AttachmentImpl::getDatabaseName() const
|
||||
{
|
||||
return attachment->att_database->dbb_database_name.c_str();
|
||||
}
|
||||
|
||||
|
||||
//---------------------
|
||||
|
||||
|
||||
ExtEngineManager::TransactionImpl::TransactionImpl(Handle aHandle)
|
||||
: handle(aHandle)
|
||||
{
|
||||
}
|
||||
|
||||
ExtEngineManager::TransactionImpl::~TransactionImpl()
|
||||
{
|
||||
}
|
||||
|
||||
Handle FB_CALL ExtEngineManager::TransactionImpl::getHandle(Error* /*error*/) const
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
//---------------------
|
||||
|
||||
|
||||
ExtEngineManager::ExternalContextImpl::ExternalContextImpl(thread_db* tdbb,
|
||||
ExternalEngine* aEngine)
|
||||
: engine(aEngine),
|
||||
internalAttachment(tdbb->getAttachment()),
|
||||
miscInfo(*internalAttachment->att_pool),
|
||||
traHandle(0)
|
||||
internalTransaction(NULL),
|
||||
externalAttachment(NULL),
|
||||
externalTransaction(NULL),
|
||||
miscInfo(*internalAttachment->att_pool)
|
||||
{
|
||||
//// TODO: admin rights
|
||||
|
||||
attHandle = internalAttachment->att_public_handle;
|
||||
clientCharSet = INTL_charset_lookup(tdbb, internalAttachment->att_client_charset)->getName();
|
||||
|
||||
setTransaction(tdbb);
|
||||
}
|
||||
|
||||
ExtEngineManager::ExternalContextImpl::~ExternalContextImpl()
|
||||
@ -292,21 +187,48 @@ ExtEngineManager::ExternalContextImpl::~ExternalContextImpl()
|
||||
|
||||
void ExtEngineManager::ExternalContextImpl::releaseTransaction()
|
||||
{
|
||||
if (traHandle)
|
||||
if (externalTransaction)
|
||||
{
|
||||
traHandle = 0;
|
||||
transaction = NULL;
|
||||
externalTransaction->release();
|
||||
externalTransaction = NULL;
|
||||
}
|
||||
|
||||
if (externalAttachment)
|
||||
{
|
||||
externalAttachment->release();
|
||||
externalAttachment = NULL;
|
||||
}
|
||||
|
||||
internalTransaction = NULL;
|
||||
}
|
||||
|
||||
void ExtEngineManager::ExternalContextImpl::setTransaction(thread_db* tdbb)
|
||||
{
|
||||
jrd_tra* newTransaction = tdbb->getTransaction();
|
||||
|
||||
if (newTransaction == internalTransaction)
|
||||
return;
|
||||
|
||||
releaseTransaction();
|
||||
fb_assert(!externalAttachment && !externalTransaction);
|
||||
|
||||
jrd_tra* tra = tdbb->getTransaction();
|
||||
traHandle = tra ? tra->tra_public_handle : 0;
|
||||
MasterInterfacePtr master;
|
||||
|
||||
transaction = FB_NEW(*internalAttachment->att_pool) TransactionImpl(traHandle);
|
||||
if (internalAttachment)
|
||||
{
|
||||
internalAttachment->att_interface->addRef();
|
||||
|
||||
externalAttachment = master->registerAttachment(currentProvider(),
|
||||
internalAttachment->att_interface);
|
||||
}
|
||||
|
||||
if ((internalTransaction = newTransaction))
|
||||
{
|
||||
internalTransaction->tra_interface->addRef();
|
||||
|
||||
externalTransaction = master->registerTransaction(externalAttachment,
|
||||
internalTransaction->tra_interface);
|
||||
}
|
||||
}
|
||||
|
||||
ExternalEngine* ExtEngineManager::ExternalContextImpl::getEngine(Error* /*error*/)
|
||||
@ -314,37 +236,37 @@ ExternalEngine* ExtEngineManager::ExternalContextImpl::getEngine(Error* /*error*
|
||||
return engine;
|
||||
}
|
||||
|
||||
Firebird::Attachment* FB_CALL ExtEngineManager::ExternalContextImpl::getAttachment(Error* /*error*/)
|
||||
Firebird::IAttachment* FB_CALL ExtEngineManager::ExternalContextImpl::getAttachment(Error* /*error*/)
|
||||
{
|
||||
if (!this->attachment)
|
||||
{
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
attachment = FB_NEW(*internalAttachment->att_pool) AttachmentImpl(this, attHandle,
|
||||
tdbb->getAttachment());
|
||||
}
|
||||
|
||||
return attachment;
|
||||
return externalAttachment;
|
||||
}
|
||||
|
||||
Firebird::Transaction* FB_CALL ExtEngineManager::ExternalContextImpl::getTransaction(Error* /*error*/)
|
||||
Firebird::ITransaction* FB_CALL ExtEngineManager::ExternalContextImpl::getTransaction(Error* /*error*/)
|
||||
{
|
||||
return transaction;
|
||||
return externalTransaction;
|
||||
}
|
||||
|
||||
const char* FB_CALL ExtEngineManager::ExternalContextImpl::getUserName()
|
||||
{
|
||||
return internalAttachment->att_user->usr_user_name.c_str();
|
||||
}
|
||||
|
||||
const char* FB_CALL ExtEngineManager::ExternalContextImpl::getDatabaseName()
|
||||
{
|
||||
return internalAttachment->att_database->dbb_database_name.c_str();
|
||||
}
|
||||
|
||||
const Utf8* FB_CALL ExtEngineManager::ExternalContextImpl::getClientCharSet()
|
||||
{
|
||||
return clientCharSet.c_str();
|
||||
}
|
||||
|
||||
|
||||
int FB_CALL ExtEngineManager::ExternalContextImpl::obtainInfoCode()
|
||||
{
|
||||
static AtomicCounter counter;
|
||||
return ++counter;
|
||||
}
|
||||
|
||||
|
||||
void* FB_CALL ExtEngineManager::ExternalContextImpl::getInfo(int code)
|
||||
{
|
||||
void* value = NULL;
|
||||
@ -352,7 +274,6 @@ void* FB_CALL ExtEngineManager::ExternalContextImpl::getInfo(int code)
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
void* FB_CALL ExtEngineManager::ExternalContextImpl::setInfo(int code, void* value)
|
||||
{
|
||||
void* oldValue = getInfo(code);
|
||||
@ -705,8 +626,11 @@ void ExtEngineManager::closeAttachment(thread_db* tdbb, Attachment* /*attachment
|
||||
|
||||
if (attInfo)
|
||||
{
|
||||
ContextManager<ExternalFunction> ctxManager(tdbb, attInfo, attInfo->adminCharSet);
|
||||
engine->closeAttachment(LogError(), attInfo->context);
|
||||
{ // scope
|
||||
ContextManager<ExternalFunction> ctxManager(tdbb, attInfo, attInfo->adminCharSet);
|
||||
engine->closeAttachment(LogError(), attInfo->context);
|
||||
}
|
||||
|
||||
delete attInfo;
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ namespace Jrd {
|
||||
|
||||
class thread_db;
|
||||
class jrd_prc;
|
||||
class jrd_tra;
|
||||
class Attachment;
|
||||
class Database;
|
||||
class Format;
|
||||
@ -72,8 +73,10 @@ private:
|
||||
void setTransaction(thread_db* tdbb);
|
||||
|
||||
virtual Firebird::ExternalEngine* FB_CALL getEngine(Firebird::Error* error);
|
||||
virtual Firebird::Attachment* FB_CALL getAttachment(Firebird::Error* error);
|
||||
virtual Firebird::Transaction* FB_CALL getTransaction(Firebird::Error* error);
|
||||
virtual Firebird::IAttachment* FB_CALL getAttachment(Firebird::Error* error);
|
||||
virtual Firebird::ITransaction* FB_CALL getTransaction(Firebird::Error* error);
|
||||
virtual const char* FB_CALL getUserName();
|
||||
virtual const char* FB_CALL getDatabaseName();
|
||||
virtual const Firebird::Utf8* FB_CALL getClientCharSet();
|
||||
virtual int FB_CALL obtainInfoCode();
|
||||
virtual void* FB_CALL getInfo(int code);
|
||||
@ -82,12 +85,11 @@ private:
|
||||
private:
|
||||
Firebird::ExternalEngine* engine;
|
||||
Attachment* internalAttachment;
|
||||
jrd_tra* internalTransaction;
|
||||
Firebird::IAttachment* externalAttachment;
|
||||
Firebird::ITransaction* externalTransaction;
|
||||
Firebird::GenericMap<Firebird::NonPooled<int, void*> > miscInfo;
|
||||
FB_API_HANDLE traHandle;
|
||||
FB_API_HANDLE attHandle;
|
||||
Firebird::MetaName clientCharSet;
|
||||
Firebird::AutoPtr<AttachmentImpl> attachment;
|
||||
Firebird::AutoPtr<TransactionImpl> transaction;
|
||||
};
|
||||
|
||||
struct EngineAttachment
|
||||
|
@ -163,7 +163,7 @@ void InternalConnection::attach(thread_db* tdbb, const Firebird::string& dbName,
|
||||
|
||||
{
|
||||
EngineCallbackGuard guard(tdbb, *this);
|
||||
currentProvider()->attachDatabase(&status, &a, 0, m_dbName.c_str(),
|
||||
a = currentProvider()->attachDatabase(&status, m_dbName.c_str(),
|
||||
m_dpb.getBufferLength(), m_dpb.getBuffer());
|
||||
}
|
||||
|
||||
@ -277,8 +277,7 @@ void InternalTransaction::doStart(ISC_STATUS* status, thread_db* tdbb, ClumpletW
|
||||
|
||||
EngineCallbackGuard guard(tdbb, *this);
|
||||
IntStatus s(status);
|
||||
m_transaction = att->startTransaction(&s, tpb.getBufferLength(), tpb.getBuffer(), 0);
|
||||
//// FIXME: public_handle
|
||||
m_transaction = att->startTransaction(&s, tpb.getBufferLength(), tpb.getBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1154,6 +1154,13 @@ ISC_STATUS ISC_EXPORT fb_cancel_operation(ISC_STATUS*,
|
||||
|
||||
ISC_STATUS ISC_EXPORT fb_ping(ISC_STATUS*, isc_db_handle*);
|
||||
|
||||
/***********************/
|
||||
/* Object interface */
|
||||
/***********************/
|
||||
|
||||
ISC_STATUS ISC_EXPORT fb_get_database_handle(ISC_STATUS*, isc_db_handle*, void*);
|
||||
ISC_STATUS ISC_EXPORT fb_get_transaction_handle(ISC_STATUS*, isc_tr_handle*, void*);
|
||||
|
||||
/********************************/
|
||||
/* Client information functions */
|
||||
/********************************/
|
||||
|
@ -788,8 +788,7 @@ static void ExtractDriveLetter(const TEXT*, ULONG*);
|
||||
static Database* init(thread_db*, const PathName&, RefPtr<Config>, bool);
|
||||
static void prepare_tra(thread_db*, jrd_tra*, USHORT, const UCHAR*);
|
||||
static void start_transaction(thread_db* tdbb, bool transliterate, jrd_tra** tra_handle,
|
||||
Jrd::Attachment* attachment, unsigned int tpb_length, const UCHAR* tpb,
|
||||
FB_API_HANDLE public_handle = 0);
|
||||
Jrd::Attachment* attachment, unsigned int tpb_length, const UCHAR* tpb);
|
||||
static void release_attachment(thread_db*, Jrd::Attachment*);
|
||||
static void rollback(thread_db*, jrd_tra*, const bool);
|
||||
static void shutdown_database(Database*, const bool);
|
||||
@ -1076,12 +1075,8 @@ static void trace_failed_attach(TraceManager* traceManager, const char* filename
|
||||
|
||||
namespace Jrd {
|
||||
|
||||
void JProvider::attachDatabase(IStatus* user_status,
|
||||
Firebird::IAttachment** handle,
|
||||
FB_API_HANDLE public_handle,
|
||||
const char* filename,
|
||||
unsigned int dpb_length,
|
||||
const unsigned char* dpb)
|
||||
JAttachment* FB_CARG JProvider::attachDatabase(IStatus* user_status, const char* filename,
|
||||
unsigned int dpb_length, const unsigned char* dpb)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -1094,8 +1089,6 @@ void JProvider::attachDatabase(IStatus* user_status,
|
||||
* sullied by user data.
|
||||
*
|
||||
**************************************/
|
||||
*handle = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
ThreadContextHolder tdbb(user_status);
|
||||
@ -1223,7 +1216,7 @@ void JProvider::attachDatabase(IStatus* user_status,
|
||||
}
|
||||
}
|
||||
|
||||
attachment = Jrd::Attachment::create(dbb, public_handle);
|
||||
attachment = Jrd::Attachment::create(dbb);
|
||||
tdbb->setAttachment(attachment);
|
||||
attachment->att_filename = is_alias ? file_name : expanded_name;
|
||||
attachment->att_network_protocol = options.dpb_network_protocol;
|
||||
@ -1662,7 +1655,6 @@ void JProvider::attachDatabase(IStatus* user_status,
|
||||
attachment->att_interface = jAtt;
|
||||
|
||||
MutexLockGuard guard(*(jAtt->getMutex()));
|
||||
*handle = jAtt;
|
||||
|
||||
if (attachment->att_trace_manager->needs(TRACE_EVENT_ATTACH))
|
||||
{
|
||||
@ -1706,7 +1698,6 @@ void JProvider::attachDatabase(IStatus* user_status,
|
||||
}
|
||||
catch (const Exception&)
|
||||
{
|
||||
*handle = NULL;
|
||||
attachment->att_flags = save_flags;
|
||||
if (!(dbb->dbb_flags & DBB_bugcheck) && transaction)
|
||||
TRA_rollback(tdbb, transaction, false, false);
|
||||
@ -1717,7 +1708,7 @@ void JProvider::attachDatabase(IStatus* user_status,
|
||||
// guardDatabases.leave();
|
||||
|
||||
jAtt->addRef();
|
||||
return;
|
||||
return jAtt;
|
||||
} // try
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
@ -1733,7 +1724,8 @@ void JProvider::attachDatabase(IStatus* user_status,
|
||||
{
|
||||
ex.stuffException(user_status);
|
||||
}
|
||||
*handle = NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -2161,9 +2153,8 @@ JBlob* JAttachment::createBlob(IStatus* user_status, ITransaction* tra, ISC_QUAD
|
||||
}
|
||||
|
||||
|
||||
void JProvider::createDatabase(IStatus* user_status, Firebird::IAttachment** handle,
|
||||
FB_API_HANDLE public_handle, const char* filename, unsigned int dpb_length,
|
||||
const unsigned char* dpb)
|
||||
JAttachment* FB_CARG JProvider::createDatabase(IStatus* user_status, const char* filename,
|
||||
unsigned int dpb_length, const unsigned char* dpb)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -2175,8 +2166,6 @@ void JProvider::createDatabase(IStatus* user_status, Firebird::IAttachment** han
|
||||
* Create a nice, squeeky clean database, uncorrupted by user data.
|
||||
*
|
||||
**************************************/
|
||||
*handle = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
ThreadContextHolder tdbb(user_status);
|
||||
@ -2277,7 +2266,7 @@ void JProvider::createDatabase(IStatus* user_status, Firebird::IAttachment** han
|
||||
dbb->dbb_encrypt_key = options.dpb_key;
|
||||
}
|
||||
|
||||
attachment = Jrd::Attachment::create(dbb, public_handle);
|
||||
attachment = Jrd::Attachment::create(dbb);
|
||||
tdbb->setAttachment(attachment);
|
||||
attachment->att_filename = is_alias ? file_name : expanded_name;
|
||||
attachment->att_network_protocol = options.dpb_network_protocol;
|
||||
@ -2348,7 +2337,7 @@ void JProvider::createDatabase(IStatus* user_status, Firebird::IAttachment** han
|
||||
{
|
||||
if (options.dpb_overwrite)
|
||||
{
|
||||
attachDatabase(user_status, handle, public_handle, filename, dpb_length, dpb);
|
||||
JAttachment* attachment2 = attachDatabase(user_status, filename, dpb_length, dpb);
|
||||
if (user_status->get()[1] == isc_adm_task_denied)
|
||||
{
|
||||
throw;
|
||||
@ -2356,10 +2345,10 @@ void JProvider::createDatabase(IStatus* user_status, Firebird::IAttachment** han
|
||||
|
||||
bool allow_overwrite = false;
|
||||
|
||||
if (*handle)
|
||||
if (attachment2)
|
||||
{
|
||||
allow_overwrite = reinterpret_cast<Attachment*>(*handle)->att_user->locksmith();
|
||||
(*handle)->detach(user_status);
|
||||
allow_overwrite = attachment2->getHandle()->att_user->locksmith();
|
||||
attachment2->detach(user_status);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2506,9 +2495,8 @@ void JProvider::createDatabase(IStatus* user_status, Firebird::IAttachment** han
|
||||
JAttachment* jAtt = new JAttachment(attachment);
|
||||
jAtt->addRef();
|
||||
attachment->att_interface = jAtt;
|
||||
*handle = jAtt;
|
||||
|
||||
return;
|
||||
return jAtt;
|
||||
} // try
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
@ -2525,7 +2513,7 @@ void JProvider::createDatabase(IStatus* user_status, Firebird::IAttachment** han
|
||||
ex.stuffException(user_status);
|
||||
}
|
||||
|
||||
*handle = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -3910,7 +3898,7 @@ void JProvider::shutdown(IStatus* status, unsigned int timeout, const int reason
|
||||
|
||||
|
||||
JTransaction* JAttachment::startTransaction(IStatus* user_status,
|
||||
unsigned int tpbLength, const unsigned char* tpb, FB_API_HANDLE public_handle)
|
||||
unsigned int tpbLength, const unsigned char* tpb)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -3929,7 +3917,7 @@ JTransaction* JAttachment::startTransaction(IStatus* user_status,
|
||||
EngineContextHolder tdbb(user_status, this);
|
||||
check_database(tdbb);
|
||||
|
||||
start_transaction(tdbb, true, &tra, getHandle(), tpbLength, tpb, public_handle);
|
||||
start_transaction(tdbb, true, &tra, getHandle(), tpbLength, tpb);
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
@ -7147,8 +7135,7 @@ void JRD_start_and_send(thread_db* tdbb, jrd_req* request, jrd_tra* transaction,
|
||||
|
||||
|
||||
static void start_transaction(thread_db* tdbb, bool transliterate, jrd_tra** tra_handle,
|
||||
Jrd::Attachment* attachment, unsigned int tpb_length, const UCHAR* tpb,
|
||||
FB_API_HANDLE public_handle)
|
||||
Jrd::Attachment* attachment, unsigned int tpb_length, const UCHAR* tpb)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -7172,7 +7159,6 @@ static void start_transaction(thread_db* tdbb, bool transliterate, jrd_tra** tra
|
||||
{
|
||||
jrd_tra* transaction = TRA_start(tdbb, tpb_length, tpb);
|
||||
|
||||
transaction->tra_public_handle = public_handle;
|
||||
transaction->tra_sibling = NULL;
|
||||
*tra_handle = transaction;
|
||||
|
||||
@ -7318,6 +7304,7 @@ bool JRD_verify_database_access(const PathName& name)
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
namespace
|
||||
{
|
||||
typedef Array<FB_API_HANDLE> PingQueue;
|
||||
@ -7336,6 +7323,7 @@ namespace
|
||||
return 0;
|
||||
}
|
||||
} // namespace
|
||||
#endif
|
||||
|
||||
|
||||
void JRD_shutdown_attachments(const Database* dbb)
|
||||
@ -7352,6 +7340,7 @@ void JRD_shutdown_attachments(const Database* dbb)
|
||||
**************************************/
|
||||
fb_assert(dbb);
|
||||
|
||||
#if 0 //// FIXME:
|
||||
try
|
||||
{
|
||||
MemoryPool& pool = *getDefaultMemoryPool();
|
||||
@ -7370,6 +7359,7 @@ void JRD_shutdown_attachments(const Database* dbb)
|
||||
}
|
||||
catch (const Exception&)
|
||||
{} // no-op
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -161,6 +161,7 @@ public:
|
||||
tra_transactions(*p),
|
||||
tra_sorts(*p),
|
||||
tra_interface(NULL),
|
||||
tra_public_interface(NULL),
|
||||
tra_blob_space(NULL),
|
||||
tra_undo_space(NULL),
|
||||
tra_undo_record(NULL),
|
||||
@ -262,6 +263,7 @@ public:
|
||||
EDS::Transaction *tra_ext_common;
|
||||
//Transaction *tra_ext_two_phase;
|
||||
JTransaction* tra_interface;
|
||||
Firebird::ITransaction* tra_public_interface;
|
||||
|
||||
private:
|
||||
TempSpace* tra_blob_space; // temp blob storage
|
||||
|
@ -577,12 +577,7 @@ void Engine::loadModule(const string& str, PathName* moduleName, string* entryPo
|
||||
PathName path;
|
||||
PathUtils::concatPath(path, *i, *moduleName);
|
||||
|
||||
ModuleLoader::Module* module = ModuleLoader::loadModule(path);
|
||||
if (!module)
|
||||
{
|
||||
ModuleLoader::doctorModuleExtension(path);
|
||||
module = ModuleLoader::loadModule(path);
|
||||
}
|
||||
ModuleLoader::Module* module = ModuleLoader::fixAndLoadModule(path);
|
||||
|
||||
if (module)
|
||||
{
|
||||
|
@ -354,8 +354,8 @@ public:
|
||||
unsigned int bufferLength, unsigned char* buffer);
|
||||
// virtual Firebird::ITransaction* startTransaction(IStatus* status, unsigned int tpbLength, const unsigned char* tpb);
|
||||
// second form is tmp - not to rewrite external engines right now
|
||||
virtual Firebird::ITransaction* FB_CARG startTransaction(IStatus* status, unsigned int tpbLength, const unsigned char* tpb,
|
||||
FB_API_HANDLE api);
|
||||
virtual Firebird::ITransaction* FB_CARG startTransaction(IStatus* status,
|
||||
unsigned int tpbLength, const unsigned char* tpb);
|
||||
virtual Firebird::ITransaction* FB_CARG reconnectTransaction(IStatus* status, unsigned int length, const unsigned char* id);
|
||||
virtual Firebird::IStatement* FB_CARG allocateStatement(IStatus* status);
|
||||
virtual Firebird::IRequest* FB_CARG compileRequest(IStatus* status, unsigned int blr_length, const unsigned char* blr);
|
||||
@ -460,10 +460,10 @@ public:
|
||||
}
|
||||
|
||||
// IProvider implementation
|
||||
virtual void FB_CARG attachDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE api, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual void FB_CARG createDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE api, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual IAttachment* FB_CARG attachDatabase(IStatus* status, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual IAttachment* FB_CARG createDatabase(IStatus* status, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual Firebird::IService* FB_CARG attachServiceManager(IStatus* status, const char* service,
|
||||
unsigned int spbLength, const unsigned char* spb);
|
||||
//virtual Firebird::ITransaction* startTransaction(IStatus* status, unsigned int count, ...);
|
||||
@ -502,10 +502,10 @@ public:
|
||||
}
|
||||
|
||||
// IProvider implementation
|
||||
virtual void FB_CARG attachDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE api, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual void FB_CARG createDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE api, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual IAttachment* FB_CARG attachDatabase(IStatus* status, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual IAttachment* FB_CARG createDatabase(IStatus* status, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual Firebird::IService* FB_CARG attachServiceManager(IStatus* status, const char* service,
|
||||
unsigned int spbLength, const unsigned char* spb);
|
||||
};
|
||||
@ -669,8 +669,8 @@ Firebird::IAttachment* Provider::attach(IStatus* status, const char* filename,
|
||||
}
|
||||
|
||||
|
||||
void Provider::attachDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE /*public_handle*/,
|
||||
const char* filename, unsigned int dpb_length, const unsigned char* dpb)
|
||||
IAttachment* Provider::attachDatabase(IStatus* status, const char* filename,
|
||||
unsigned int dpb_length, const unsigned char* dpb)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -683,12 +683,12 @@ void Provider::attachDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_A
|
||||
*
|
||||
**************************************/
|
||||
|
||||
*ptr = attach(status, filename, dpb_length, dpb, false);
|
||||
return attach(status, filename, dpb_length, dpb, false);
|
||||
}
|
||||
|
||||
|
||||
void Loopback::attachDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE /*public_handle*/,
|
||||
const char* filename, unsigned int dpb_length, const unsigned char* dpb)
|
||||
IAttachment* Loopback::attachDatabase(IStatus* status, const char* filename,
|
||||
unsigned int dpb_length, const unsigned char* dpb)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -701,7 +701,7 @@ void Loopback::attachDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_A
|
||||
*
|
||||
**************************************/
|
||||
|
||||
*ptr = attach(status, filename, dpb_length, dpb, true);
|
||||
return attach(status, filename, dpb_length, dpb, true);
|
||||
}
|
||||
|
||||
|
||||
@ -1154,8 +1154,8 @@ Firebird::IAttachment* Provider::create(IStatus* status, const char* filename,
|
||||
}
|
||||
|
||||
|
||||
void Provider::createDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE /*public_handle*/,
|
||||
const char* fileName, unsigned int dpbLength, const unsigned char* dpb)
|
||||
IAttachment* Provider::createDatabase(IStatus* status, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -1168,12 +1168,12 @@ void Provider::createDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_A
|
||||
*
|
||||
**************************************/
|
||||
|
||||
*ptr = create(status, fileName, dpbLength, dpb, false);
|
||||
return create(status, fileName, dpbLength, dpb, false);
|
||||
}
|
||||
|
||||
|
||||
void Loopback::createDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_API_HANDLE /*public_handle*/,
|
||||
const char* fileName, unsigned int dpbLength, const unsigned char* dpb)
|
||||
IAttachment* Loopback::createDatabase(IStatus* status, const char* fileName,
|
||||
unsigned int dpbLength, const unsigned char* dpb)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -1186,7 +1186,7 @@ void Loopback::createDatabase(IStatus* status, Firebird::IAttachment** ptr, FB_A
|
||||
*
|
||||
**************************************/
|
||||
|
||||
*ptr = create(status, fileName, dpbLength, dpb, true);
|
||||
return create(status, fileName, dpbLength, dpb, true);
|
||||
}
|
||||
|
||||
|
||||
@ -4338,9 +4338,8 @@ void Request::start(IStatus* status, Firebird::ITransaction* tra, int level)
|
||||
}
|
||||
|
||||
|
||||
Firebird::ITransaction* Attachment::startTransaction(IStatus* status,
|
||||
unsigned int tpbLength, const unsigned char* tpb,
|
||||
FB_API_HANDLE /*api*/)
|
||||
Firebird::ITransaction* Attachment::startTransaction(IStatus* status, unsigned int tpbLength,
|
||||
const unsigned char* tpb)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "Timer.h"
|
||||
|
||||
#include "../yvalve/MasterImplementation.h"
|
||||
#include "../common/classes/ImplementHelper.h"
|
||||
#include "../common/classes/init.h"
|
||||
#include "../common/StatusHolder.h"
|
||||
#include "../yvalve/PluginManager.h"
|
||||
@ -48,18 +47,6 @@ using namespace Firebird;
|
||||
|
||||
namespace Why {
|
||||
|
||||
class MasterImplementation : public StackIface<IMaster>
|
||||
{
|
||||
public:
|
||||
// IMaster implementation
|
||||
IStatus* FB_CARG getStatus();
|
||||
IProvider* FB_CARG getDispatcher();
|
||||
IPluginManager* FB_CARG getPluginManager();
|
||||
int FB_CARG upgradeInterface(IInterface* toUpgrade, int desiredVersion, void* missingFunctionClass);
|
||||
const char* FB_CARG circularAlloc(const char* s, size_t len, intptr_t thr);
|
||||
ITimerControl* FB_CARG getTimerControl();
|
||||
};
|
||||
|
||||
//
|
||||
// getStatus()
|
||||
//
|
||||
|
@ -31,11 +31,28 @@
|
||||
|
||||
#include "firebird.h"
|
||||
#include "Interface.h"
|
||||
#include "../common/classes/ImplementHelper.h"
|
||||
|
||||
namespace Why
|
||||
{
|
||||
extern Firebird::IProvider* dispatcherPtr;
|
||||
|
||||
class MasterImplementation : public Firebird::StackIface<Firebird::IMaster>
|
||||
{
|
||||
public:
|
||||
// IMaster implementation
|
||||
Firebird::IStatus* FB_CARG getStatus();
|
||||
Firebird::IProvider* FB_CARG getDispatcher();
|
||||
Firebird::IPluginManager* FB_CARG getPluginManager();
|
||||
int FB_CARG upgradeInterface(Firebird::IInterface* toUpgrade, int desiredVersion, void* missingFunctionClass);
|
||||
const char* FB_CARG circularAlloc(const char* s, size_t len, intptr_t thr);
|
||||
Firebird::ITimerControl* FB_CARG getTimerControl();
|
||||
Firebird::IAttachment* registerAttachment(Firebird::IProvider* provider,
|
||||
Firebird::IAttachment* attachment);
|
||||
Firebird::ITransaction* registerTransaction(Firebird::IAttachment* attachment,
|
||||
Firebird::ITransaction* transaction);
|
||||
};
|
||||
|
||||
void shutdownTimers();
|
||||
} // namespace Why
|
||||
|
||||
|
@ -926,7 +926,7 @@ void FB_CARG PluginManager::releasePlugin(IPluginBase* plugin)
|
||||
|
||||
if (plugin->release() == 0)
|
||||
{
|
||||
fb_assert(parent);
|
||||
///fb_assert(parent);
|
||||
if (parent)
|
||||
{
|
||||
parent->release();
|
||||
|
@ -681,7 +681,7 @@ namespace
|
||||
|
||||
YEvents(YAttachment* aAttachment, IEvents* aNext, IEventCallback* aCallback);
|
||||
|
||||
virtual ~YEvents()
|
||||
~YEvents()
|
||||
{
|
||||
if (deleteCallback)
|
||||
delete callback;
|
||||
@ -696,7 +696,7 @@ namespace
|
||||
{
|
||||
if (next)
|
||||
{
|
||||
next->release();
|
||||
next = NULL;
|
||||
destroy();
|
||||
}
|
||||
|
||||
@ -732,7 +732,7 @@ namespace
|
||||
{
|
||||
if (next)
|
||||
{
|
||||
next->release();
|
||||
next = NULL;
|
||||
destroy();
|
||||
}
|
||||
|
||||
@ -798,7 +798,7 @@ namespace
|
||||
{
|
||||
if (next)
|
||||
{
|
||||
next->release();
|
||||
next = NULL;
|
||||
destroy();
|
||||
}
|
||||
|
||||
@ -850,7 +850,7 @@ namespace
|
||||
{
|
||||
if (next)
|
||||
{
|
||||
next->release();
|
||||
next = NULL;
|
||||
destroy();
|
||||
}
|
||||
|
||||
@ -891,7 +891,7 @@ namespace
|
||||
{
|
||||
if (next)
|
||||
{
|
||||
next->release();
|
||||
next = NULL;
|
||||
destroy();
|
||||
}
|
||||
|
||||
@ -968,12 +968,10 @@ namespace
|
||||
handle = makeHandle(&attachments, this);
|
||||
}
|
||||
|
||||
virtual ~YAttachment()
|
||||
~YAttachment()
|
||||
{
|
||||
if (provider)
|
||||
{
|
||||
PluginManagerInterfacePtr()->releasePlugin(provider);
|
||||
}
|
||||
}
|
||||
|
||||
void destroy();
|
||||
@ -986,7 +984,7 @@ namespace
|
||||
{
|
||||
if (next)
|
||||
{
|
||||
next->release();
|
||||
next = NULL;
|
||||
destroy();
|
||||
}
|
||||
|
||||
@ -1000,7 +998,7 @@ namespace
|
||||
virtual void FB_CARG getInfo(IStatus* status, unsigned int itemsLength,
|
||||
const unsigned char* items, unsigned int bufferLength, unsigned char* buffer);
|
||||
virtual YTransaction* FB_CARG startTransaction(IStatus* status, unsigned int tpbLength,
|
||||
const unsigned char* tpb, FB_API_HANDLE api);
|
||||
const unsigned char* tpb);
|
||||
virtual YTransaction* FB_CARG reconnectTransaction(IStatus* status, unsigned int length,
|
||||
const unsigned char* id);
|
||||
virtual YStatement* FB_CARG allocateStatement(IStatus* status);
|
||||
@ -1059,12 +1057,10 @@ namespace
|
||||
handle = makeHandle(&services, this);
|
||||
}
|
||||
|
||||
virtual ~YService()
|
||||
~YService()
|
||||
{
|
||||
if (provider)
|
||||
{
|
||||
PluginManagerInterfacePtr()->releasePlugin(provider);
|
||||
}
|
||||
}
|
||||
|
||||
void destroy();
|
||||
@ -1076,7 +1072,7 @@ namespace
|
||||
{
|
||||
if (next)
|
||||
{
|
||||
next->release();
|
||||
next = NULL;
|
||||
destroy();
|
||||
}
|
||||
|
||||
@ -1109,10 +1105,10 @@ namespace
|
||||
}
|
||||
|
||||
// IProvider implementation
|
||||
virtual void FB_CARG attachDatabase(IStatus* status, IAttachment** attachment,
|
||||
FB_API_HANDLE api, const char* filename, unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual void FB_CARG createDatabase(IStatus* status, IAttachment** ptr,
|
||||
FB_API_HANDLE api, const char* filename, unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual YAttachment* FB_CARG attachDatabase(IStatus* status, const char* filename,
|
||||
unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual YAttachment* FB_CARG createDatabase(IStatus* status, const char* filename,
|
||||
unsigned int dpbLength, const unsigned char* dpb);
|
||||
virtual YService* FB_CARG attachServiceManager(IStatus* status, const char* serviceName,
|
||||
unsigned int spbLength, const unsigned char* spb);
|
||||
virtual void FB_CARG shutdown(IStatus* status, unsigned int timeout, const int reason);
|
||||
@ -1763,15 +1759,13 @@ ISC_STATUS API_ROUTINE isc_attach_database(ISC_STATUS* userStatus, SSHORT fileLe
|
||||
|
||||
PathName pathName(filename, fileLength ? fileLength : strlen(filename));
|
||||
|
||||
IAttachment* attachment = NULL;
|
||||
dispatcher->attachDatabase(&status, &attachment, 0, pathName.c_str(), dpbLength,
|
||||
YAttachment* attachment = dispatcher->attachDatabase(&status, pathName.c_str(), dpbLength,
|
||||
reinterpret_cast<const UCHAR*>(dpb));
|
||||
|
||||
if (!status.isSuccess())
|
||||
return status[1];
|
||||
|
||||
YAttachment* yAttach = static_cast<YAttachment*>(attachment);
|
||||
*publicHandle = yAttach->handle;
|
||||
*publicHandle = attachment->handle;
|
||||
}
|
||||
catch (const Exception& e)
|
||||
{
|
||||
@ -2044,15 +2038,13 @@ ISC_STATUS API_ROUTINE isc_create_database(ISC_STATUS* userStatus, USHORT fileLe
|
||||
|
||||
PathName pathName(filename, fileLength ? fileLength : strlen(filename));
|
||||
|
||||
IAttachment* attachment = NULL;
|
||||
dispatcher->createDatabase(&status, &attachment, 0, pathName.c_str(), dpbLength,
|
||||
YAttachment* attachment = dispatcher->createDatabase(&status, pathName.c_str(), dpbLength,
|
||||
reinterpret_cast<const UCHAR*>(dpb));
|
||||
|
||||
if (!status.isSuccess())
|
||||
return status[1];
|
||||
|
||||
YAttachment* yAttach = static_cast<YAttachment*>(attachment);
|
||||
*publicHandle = yAttach->handle;
|
||||
*publicHandle = attachment->handle;
|
||||
}
|
||||
catch (const Exception& e)
|
||||
{
|
||||
@ -3530,7 +3522,7 @@ ISC_STATUS API_ROUTINE isc_start_multiple(ISC_STATUS* userStatus, FB_API_HANDLE*
|
||||
|
||||
RefPtr<YAttachment> attachment(translateHandle(attachments, vector->teb_database));
|
||||
YTransaction* transaction = attachment->startTransaction(&status,
|
||||
vector->teb_tpb_length, vector->teb_tpb, 0);
|
||||
vector->teb_tpb_length, vector->teb_tpb);
|
||||
|
||||
if (!status.isSuccess())
|
||||
status_exception::raise(status);
|
||||
@ -3747,6 +3739,59 @@ ISC_STATUS API_ROUTINE fb_ping(ISC_STATUS* userStatus, FB_API_HANDLE* dbHandle)
|
||||
}
|
||||
|
||||
|
||||
// Get the legacy handle of a database.
|
||||
ISC_STATUS API_ROUTINE fb_get_database_handle(ISC_STATUS* userStatus, FB_API_HANDLE* handle, void* obj)
|
||||
{
|
||||
StatusVector status(userStatus);
|
||||
|
||||
try
|
||||
{
|
||||
YAttachment* yObject = static_cast<YAttachment*>(obj);
|
||||
*handle = yObject->handle;
|
||||
}
|
||||
catch (const Exception& e)
|
||||
{
|
||||
e.stuffException(&status);
|
||||
}
|
||||
|
||||
return status[1];
|
||||
}
|
||||
|
||||
|
||||
// Get the legacy handle of a transaction.
|
||||
ISC_STATUS API_ROUTINE fb_get_transaction_handle(ISC_STATUS* userStatus, FB_API_HANDLE* handle, void* obj)
|
||||
{
|
||||
StatusVector status(userStatus);
|
||||
|
||||
try
|
||||
{
|
||||
YTransaction* yObject = static_cast<YTransaction*>(obj);
|
||||
*handle = yObject->handle;
|
||||
}
|
||||
catch (const Exception& e)
|
||||
{
|
||||
e.stuffException(&status);
|
||||
}
|
||||
|
||||
return status[1];
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
|
||||
IAttachment* MasterImplementation::registerAttachment(IProvider* provider, IAttachment* attachment)
|
||||
{
|
||||
return new YAttachment(provider, attachment, "");
|
||||
}
|
||||
|
||||
ITransaction* MasterImplementation::registerTransaction(IAttachment* attachment,
|
||||
ITransaction* transaction)
|
||||
{
|
||||
return new YTransaction(static_cast<YAttachment*>(attachment), transaction);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
|
||||
@ -3766,8 +3811,11 @@ void YEvents::destroy()
|
||||
|
||||
removeHandle(&events, handle);
|
||||
|
||||
next = NULL;
|
||||
release();
|
||||
if (next)
|
||||
{
|
||||
next = NULL;
|
||||
release();
|
||||
}
|
||||
}
|
||||
|
||||
void YEvents::cancel(IStatus* status)
|
||||
@ -3812,8 +3860,11 @@ void YRequest::destroy()
|
||||
|
||||
removeHandle(&requests, handle);
|
||||
|
||||
next = NULL;
|
||||
release();
|
||||
if (next)
|
||||
{
|
||||
next = NULL;
|
||||
release();
|
||||
}
|
||||
}
|
||||
|
||||
void YRequest::receive(IStatus* status, int level, unsigned int msgType,
|
||||
@ -3940,8 +3991,11 @@ void YBlob::destroy()
|
||||
|
||||
removeHandle(&blobs, handle);
|
||||
|
||||
next = NULL;
|
||||
release();
|
||||
if (next)
|
||||
{
|
||||
next = NULL;
|
||||
release();
|
||||
}
|
||||
}
|
||||
|
||||
void YBlob::getInfo(IStatus* status, unsigned int itemsLength,
|
||||
@ -4061,8 +4115,11 @@ void YStatement::destroy()
|
||||
|
||||
removeHandle(&statements, handle);
|
||||
|
||||
next = NULL;
|
||||
release();
|
||||
if (next)
|
||||
{
|
||||
next = NULL;
|
||||
release();
|
||||
}
|
||||
}
|
||||
|
||||
void YStatement::prepare(IStatus* status, ITransaction* transaction,
|
||||
@ -4334,8 +4391,11 @@ void YTransaction::destroy()
|
||||
|
||||
removeHandle(&transactions, handle);
|
||||
|
||||
next = NULL;
|
||||
release();
|
||||
if (next)
|
||||
{
|
||||
next = NULL;
|
||||
release();
|
||||
}
|
||||
}
|
||||
|
||||
void YTransaction::getInfo(IStatus* status, unsigned int itemsLength,
|
||||
@ -4674,8 +4734,11 @@ void YAttachment::destroy()
|
||||
|
||||
removeHandle(&attachments, handle);
|
||||
|
||||
next = NULL;
|
||||
release();
|
||||
if (next)
|
||||
{
|
||||
next = NULL;
|
||||
release();
|
||||
}
|
||||
}
|
||||
|
||||
// Get the full database pathname and put it in the transaction description record.
|
||||
@ -4715,13 +4778,13 @@ void YAttachment::getInfo(IStatus* status, unsigned int itemsLength,
|
||||
}
|
||||
|
||||
YTransaction* YAttachment::startTransaction(IStatus* status, unsigned int tpbLength,
|
||||
const unsigned char* tpb, FB_API_HANDLE api)
|
||||
const unsigned char* tpb)
|
||||
{
|
||||
try
|
||||
{
|
||||
YEntry entry(status, this);
|
||||
|
||||
ITransaction* transaction = next->startTransaction(status, tpbLength, tpb, api);
|
||||
ITransaction* transaction = next->startTransaction(status, tpbLength, tpb);
|
||||
if (transaction)
|
||||
transaction = new YTransaction(this, transaction);
|
||||
|
||||
@ -5064,8 +5127,11 @@ void YService::destroy()
|
||||
{
|
||||
removeHandle(&services, handle);
|
||||
|
||||
next = NULL;
|
||||
release();
|
||||
if (next)
|
||||
{
|
||||
next = NULL;
|
||||
release();
|
||||
}
|
||||
}
|
||||
|
||||
void YService::detach(IStatus* status)
|
||||
@ -5118,15 +5184,13 @@ void YService::start(IStatus* status, unsigned int spbLength, const unsigned cha
|
||||
|
||||
|
||||
// Attach a database through the first subsystem that recognizes it.
|
||||
void Dispatcher::attachDatabase(IStatus* status, IAttachment** attachment, FB_API_HANDLE /*api*/,
|
||||
const char* filename, unsigned int dpbLength, const unsigned char* dpb)
|
||||
YAttachment* Dispatcher::attachDatabase(IStatus* status, const char* filename,
|
||||
unsigned int dpbLength, const unsigned char* dpb)
|
||||
{
|
||||
try
|
||||
{
|
||||
YEntry entry(status);
|
||||
|
||||
*attachment = NULL;
|
||||
|
||||
if (shutdownStarted)
|
||||
status_exception::raise(Arg::Gds(isc_att_shutdown));
|
||||
|
||||
@ -5213,18 +5277,15 @@ void Dispatcher::attachDatabase(IStatus* status, IAttachment** attachment, FB_AP
|
||||
{
|
||||
IProvider* provider = providerIterator.plugin();
|
||||
|
||||
provider->attachDatabase(currentStatus, attachment, 0, expandedFilename.c_str(),
|
||||
newDpb.getBufferLength(), newDpb.getBuffer());
|
||||
IAttachment* attachment = provider->attachDatabase(currentStatus,
|
||||
expandedFilename.c_str(), newDpb.getBufferLength(), newDpb.getBuffer());
|
||||
|
||||
if (currentStatus->isSuccess())
|
||||
{
|
||||
*attachment = new YAttachment(provider, *attachment, expandedFilename);
|
||||
status->set(currentStatus->get());
|
||||
return;
|
||||
return new YAttachment(provider, attachment, expandedFilename);
|
||||
}
|
||||
|
||||
*attachment = NULL;
|
||||
|
||||
if (currentStatus->get()[1] != isc_unavailable)
|
||||
currentStatus = &temp;
|
||||
|
||||
@ -5236,22 +5297,19 @@ void Dispatcher::attachDatabase(IStatus* status, IAttachment** attachment, FB_AP
|
||||
}
|
||||
catch (const Exception& e)
|
||||
{
|
||||
if (*attachment)
|
||||
(*attachment)->release();
|
||||
|
||||
e.stuffException(status);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Dispatcher::createDatabase(IStatus* status, IAttachment** attachment, FB_API_HANDLE /*api*/,
|
||||
const char* filename, unsigned int dpbLength, const unsigned char* dpb)
|
||||
YAttachment* Dispatcher::createDatabase(IStatus* status, const char* filename,
|
||||
unsigned int dpbLength, const unsigned char* dpb)
|
||||
{
|
||||
try
|
||||
{
|
||||
YEntry entry(status);
|
||||
|
||||
*attachment = NULL;
|
||||
|
||||
if (shutdownStarted)
|
||||
status_exception::raise(Arg::Gds(isc_att_shutdown));
|
||||
|
||||
@ -5342,8 +5400,8 @@ void Dispatcher::createDatabase(IStatus* status, IAttachment** attachment, FB_AP
|
||||
{
|
||||
IProvider* provider = providerIterator.plugin();
|
||||
|
||||
provider->createDatabase(currentStatus, attachment, 0, expandedFilename.c_str(),
|
||||
newDpb.getBufferLength(), newDpb.getBuffer());
|
||||
IAttachment* attachment = provider->createDatabase(currentStatus,
|
||||
expandedFilename.c_str(), newDpb.getBufferLength(), newDpb.getBuffer());
|
||||
|
||||
if (currentStatus->isSuccess())
|
||||
{
|
||||
@ -5354,13 +5412,10 @@ void Dispatcher::createDatabase(IStatus* status, IAttachment** attachment, FB_AP
|
||||
PathName path(orgFilename);
|
||||
#endif
|
||||
|
||||
*attachment = new YAttachment(provider, *attachment, path);
|
||||
status->set(currentStatus->get());
|
||||
return;
|
||||
return new YAttachment(provider, attachment, path);
|
||||
}
|
||||
|
||||
*attachment = NULL;
|
||||
|
||||
if (currentStatus->get()[1] != isc_unavailable)
|
||||
currentStatus = &temp;
|
||||
|
||||
@ -5372,14 +5427,10 @@ void Dispatcher::createDatabase(IStatus* status, IAttachment** attachment, FB_AP
|
||||
}
|
||||
catch (const Exception& e)
|
||||
{
|
||||
if (*attachment)
|
||||
{
|
||||
StatusVector temp(NULL);
|
||||
(*attachment)->drop(&temp);
|
||||
}
|
||||
|
||||
e.stuffException(status);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Attach a service through the first subsystem that recognizes it.
|
||||
|
@ -244,6 +244,9 @@ ISC_STATUS API_ROUTINE fb_shutdown_callback(ISC_STATUS* user_status, FB_SHUTDOWN
|
||||
|
||||
ISC_STATUS API_ROUTINE fb_ping(ISC_STATUS*, FB_API_HANDLE*);
|
||||
|
||||
ISC_STATUS API_ROUTINE fb_get_database_handle(ISC_STATUS*, FB_API_HANDLE*, void*);
|
||||
ISC_STATUS API_ROUTINE fb_get_transaction_handle(ISC_STATUS*, FB_API_HANDLE*, void*);
|
||||
|
||||
typedef void AttachmentCleanupRoutine(FB_API_HANDLE*, void*);
|
||||
typedef void TransactionCleanupRoutine(FB_API_HANDLE, void*);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user