NCBI C++ ToolKit
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
CTL_Connection Class Reference

Search Toolkit Book for CTL_Connection

#include <dbapi/driver/ctlib/interfaces.hpp>

+ Inheritance diagram for CTL_Connection:
+ Collaboration diagram for CTL_Connection:

Classes

class  CCancelModeGuard
 

Public Member Functions

CS_RETCODE Check (CS_RETCODE rc)
 
CS_RETCODE Check (CS_RETCODE rc, const TDbgInfo &dbg_info)
 
CS_INT GetBLKVersion (void) const
 
const CTLibContextGetCTLibContext (void) const
 
CTLibContextGetCTLibContext (void)
 
ctlib::ConnectionGetNativeConnection (void)
 
const ctlib::ConnectionGetNativeConnection (void) const
 
virtual bool IsAlive (void)
 Check out if connection is alive (this function doesn't ping the server, it just checks the status of connection which was set by the last i/o operation) More...
 
bool IsOpen (void)
 
void DeferTimeout (void)
 
- Public Member Functions inherited from impl::CConnection
 CConnection (CDriverContext &dc, const CDBConnParams &params, bool isBCPable=false)
 
virtual ~CConnection (void)
 
CDB_ResultProcessorGetResultProcessor (void) const
 
CDriverContextGetCDriverContext (void)
 
const CDriverContextGetCDriverContext (void) const
 
bool IsMultibyteClientEncoding (void) const
 
EEncoding GetClientEncoding (void) const
 
void SetExtraMsg (const string &msg)
 
const stringGetExtraMsg (void) const
 
const stringGetServerName (void) const
 
const stringGetUserName (void) const
 
const stringGetPassword (void) const
 
const stringGetDatabaseName (void) const
 
const stringGetRequestedServer (void) const
 
bool IsOpeningFinished (void) const
 
void FinishOpening (void)
 
bool IsValid (void) const
 
virtual void SetDatabaseName (const string &name)
 
void Invalidate (void)
 
const stringServerName (void) const
 Get the server name, user login name, and password. More...
 
Uint4 Host (void) const
 
Uint2 Port (void) const
 
const stringUserName (void) const
 
const stringPassword (void) const
 
bool IsReusable (void) const
 Check if this connection is a reusable one. More...
 
const stringPoolName (void) const
 Find out which connection pool this connection belongs to. More...
 
I_DriverContextContext (void) const
 Get pointer to the driver context. More...
 
void PushMsgHandler (CDB_UserHandler *h, EOwnership ownership=eNoOwnership)
 Put the message handler into message handler stack. More...
 
void PopMsgHandler (CDB_UserHandler *h)
 Remove the message handler (and all above it) from the stack. More...
 
CDB_ResultProcessorSetResultProcessor (CDB_ResultProcessor *rp)
 
virtual void SetBlobSize (size_t nof_bytes)
 
void SetTextImageSize (size_t nof_bytes)
 
virtual string GetDriverName (void) const
 
CDBConnParams::EServerType GetServerType (void)
 
CDB_BigDateTime::ESyntax GetDateTimeSyntax (void)
 
CDBConnParams::EServerType CalculateServerType (CDBConnParams::EServerType server_type)
 
void SetUserData (CObject *data)
 
- Public Member Functions inherited from I_ConnectionExtra
virtual ~I_ConnectionExtra (void)
 
template<typename T >
TGetUserData (void)
 
template<typename T >
const TGetUserData (void) const
 

Protected Member Functions

 CTL_Connection (CTLibContext &cntx, const CDBConnParams &params)
 
virtual ~CTL_Connection (void)
 
virtual CDB_LangCmdLangCmd (const string &lang_query)
 These methods: LangCmd(), RPC(), BCPIn(), Cursor() and SendDataCmd() create and return a "command" object, register it for later use with this (and only this!) connection. More...
 
virtual CDB_RPCCmdRPC (const string &rpc_name)
 Remote procedure call. More...
 
virtual CDB_BCPInCmdBCPIn (const string &table_name)
 "Bulk copy in" command More...
 
virtual CDB_CursorCmdCursor (const string &cursor_name, const string &query, unsigned int batch_size=1)
 Cursor. More...
 
virtual CDB_SendDataCmdSendDataCmd (I_BlobDescriptor &desc, size_t data_size, bool log_it=true, bool dump_results=true)
 "Send-data" command More...
 
virtual bool SendData (I_BlobDescriptor &desc, CDB_Stream &lob, bool log_it=true)
 Shortcut to send text and image to the server without using the "Send-data" command (SendDataCmd) More...
 
virtual bool Refresh (void)
 Reset the connection to the "ready" state (cancel all active commands) More...
 
virtual I_DriverContext::TConnectionMode ConnectMode (void) const
 Get the bitmask for the connection mode (BCP, secure login, ...) More...
 
CTL_LangCmdxLangCmd (const string &lang_query)
 
virtual bool Abort (void)
 abort the connection Attention: it is not recommended to use this method unless you absolutely have to. More...
 
virtual bool Close (void)
 Close an open connection. More...
 
CS_RETCODE CheckWhileOpening (CS_RETCODE rc)
 
CS_RETCODE CheckSFB (CS_RETCODE rc, const char *msg, unsigned int msg_num)
 
bool IsDead (void) const
 
void SetDead (bool flag=true)
 
const TDbgInfoGetDbgInfo (void) const
 
virtual void SetTimeout (size_t nof_secs)
 
virtual void SetCancelTimeout (size_t nof_secs)
 
virtual size_t GetTimeout (void) const
 
virtual size_t GetCancelTimeout (void) const
 
virtual unsigned int GetRowsInCurrentBatch (void) const
 
size_t PrepareToCancel (void)
 
void CancelFinished (size_t was_timeout)
 
bool IsCancelInProgress (void) const
 
virtual TSockHandle GetLowLevelHandle (void) const
 Get OS handle of the socket represented by the connection. More...
 
void CompleteBlobDescriptor (I_BlobDescriptor &desc, const string &cursor_name, int item_num)
 
void CompleteBlobDescriptors (vector< I_BlobDescriptor * > &descs, const string &cursor_name)
 
- Protected Member Functions inherited from impl::CConnection
CDB_LangCmdCreate_LangCmd (CBaseCmd &lang_cmd)
 These methods to allow the children of CConnection to create various command-objects. More...
 
CDB_RPCCmdCreate_RPCCmd (CBaseCmd &rpc_cmd)
 
CDB_BCPInCmdCreate_BCPInCmd (CBaseCmd &bcpin_cmd)
 
CDB_CursorCmdCreate_CursorCmd (CBaseCmd &cursor_cmd)
 
CDB_SendDataCmdCreate_SendDataCmd (CSendDataCmd &senddata_cmd)
 
void Release (void)
 
const CDBHandlerStackGetMsgHandlers (void) const
 
CDBHandlerStackGetMsgHandlers (void)
 
void DropCmd (impl::CCommand &cmd)
 
void DeleteAllCommands (void)
 
void AttachTo (CDB_Connection *interface)
 
void ReleaseInterface (void)
 
void DetachResultProcessor (void)
 
void CheckCanOpen (void)
 
void MarkClosed (void)
 
unsigned int GetReuseCount (void) const
 
bool IsBCPable (void) const
 
bool HasSecureLogin (void) const
 
TDbgInfoSetDbgInfo (void)
 
void SetServerType (CDBConnParams::EServerType type)
 
const CDBHandlerStackGetOpeningMsgHandlers (void) const
 
CObjectx_GetUserData (void) const
 
void x_RecordServer (const CDBServer &server)
 
void x_DisableReuse (void)
 

Private Member Functions

void x_LoadTextPtrProcs (void)
 
void x_CmdAlloc (CS_COMMAND **cmd)
 
void x_SetExtraMsg (const I_BlobDescriptor &descr, size_t data_size)
 
bool x_SendData (I_BlobDescriptor &desc, CDB_Stream &img, bool log_it=true)
 
bool x_SendUpdateWrite (CDB_BlobDescriptor &desc, CDB_Stream &img, size_t size)
 
I_BlobDescriptorx_GetNativeBlobDescriptor (const CDB_BlobDescriptor &d)
 
bool x_IsLegacyBlobColumnType (const string &table_name, const string &column_name)
 
CS_CONNECTIONx_GetSybaseConn (void) const
 
bool x_ProcessResultInternal (CS_COMMAND *cmd, CS_INT res_type)
 
const CDBParamsGetLastParams (void) const
 

Private Attributes

CTLibContextm_Cntx
 
CTL_CmdBasem_ActiveCmd
 
ctlib::Connection m_Handle
 
int m_TDSVersion
 
bool m_TextPtrProcsLoaded
 
bool m_CancelInProgress
 
bool m_CancelRequested
 
unsigned int m_ActivityLevel
 
CMutex m_CancelLogisticsMutex
 

Friends

class CTLibContext
 
class ctlib::Connection
 
class ncbi::CDB_Connection
 
class CTL_Cmd
 
class CTL_CmdBase
 
class CTL_LRCmd
 
class CTL_LangCmd
 
class CTL_RPCCmd
 
class CTL_SendDataCmd
 
class CTL_BCPInCmd
 
class CTL_CursorCmd
 
class CTL_CursorCmdExpl
 
class CTL_CursorResultExpl
 
class CTL_RowResult
 
class CCancelModeGuard
 

Additional Inherited Members

- Public Types inherited from impl::CConnection
typedef CDB_Exception::SContext TDbgInfo
 
- Public Types inherited from I_ConnectionExtra
typedef SOCKET TSockHandle
 
- Static Protected Member Functions inherited from impl::CConnection
static CDB_ResultCreate_Result (impl::CResult &result)
 

Detailed Description

Definition at line 374 of file interfaces.hpp.

Constructor & Destructor Documentation

◆ CTL_Connection()

CTL_Connection::CTL_Connection ( CTLibContext cntx,
const CDBConnParams params 
)
protected

◆ ~CTL_Connection()

CTL_Connection::~CTL_Connection ( void  )
protectedvirtual

Member Function Documentation

◆ Abort()

bool CTL_Connection::Abort ( void  )
protectedvirtual

abort the connection Attention: it is not recommended to use this method unless you absolutely have to.

The expected implementation is - close underlying file descriptor[s] without destroing any objects associated with a connection. Returns: true - if succeed false - if not

Implements impl::CConnection.

Definition at line 1441 of file connection.cpp.

References Check(), close(), CS_GET, CS_SUCCEED, CS_UNUSED, ct_con_props(), impl::CConnection::MarkClosed(), and x_GetSybaseConn().

◆ BCPIn()

CDB_BCPInCmd * CTL_Connection::BCPIn ( const string table_name)
protectedvirtual

"Bulk copy in" command

Implements impl::CConnection.

Definition at line 792 of file connection.cpp.

References impl::CConnection::Create_BCPInCmd(), CTL_BCPInCmd, impl::CConnection::SetExtraMsg(), and table_name.

◆ CancelFinished()

void CTL_Connection::CancelFinished ( size_t  was_timeout)
protected

◆ Check() [1/2]

CS_RETCODE CTL_Connection::Check ( CS_RETCODE  rc)

◆ Check() [2/2]

CS_RETCODE CTL_Connection::Check ( CS_RETCODE  rc,
const TDbgInfo dbg_info 
)

◆ CheckSFB()

CS_RETCODE CTL_Connection::CheckSFB ( CS_RETCODE  rc,
const char *  msg,
unsigned int  msg_num 
)
protected

Definition at line 489 of file connection.cpp.

References Check(), CS_BUSY, CS_FAIL, CS_SUCCEED, DATABASE_DRIVER_ERROR, and IsAlive().

Referenced by x_CmdAlloc().

◆ CheckWhileOpening()

CS_RETCODE CTL_Connection::CheckWhileOpening ( CS_RETCODE  rc)
protected

◆ Close()

bool CTL_Connection::Close ( void  )
protectedvirtual

◆ CompleteBlobDescriptor()

void CTL_Connection::CompleteBlobDescriptor ( I_BlobDescriptor desc,
const string cursor_name,
int  item_num 
)
protected

◆ CompleteBlobDescriptors()

void CTL_Connection::CompleteBlobDescriptors ( vector< I_BlobDescriptor * > &  descs,
const string cursor_name 
)
protected

◆ ConnectMode()

I_DriverContext::TConnectionMode CTL_Connection::ConnectMode ( void  ) const
protectedvirtual

Get the bitmask for the connection mode (BCP, secure login, ...)

Implements impl::CConnection.

Definition at line 899 of file connection.cpp.

References I_DriverContext::fBcpIn, I_DriverContext::fPasswordEncrypted, and impl::CConnection::HasSecureLogin().

◆ Cursor()

CDB_CursorCmd * CTL_Connection::Cursor ( const string cursor_name,
const string query,
unsigned int  batch_size = 1 
)
protectedvirtual

◆ DeferTimeout()

void CTL_Connection::DeferTimeout ( void  )

Definition at line 1631 of file connection.cpp.

Referenced by CTL_RowResult::CheckIsDead().

◆ GetBLKVersion()

CS_INT CTL_Connection::GetBLKVersion ( void  ) const

◆ GetCancelTimeout()

size_t CTL_Connection::GetCancelTimeout ( void  ) const
protectedvirtual

Reimplemented from impl::CConnection.

Definition at line 598 of file connection.cpp.

References impl::CDriverContext::GetCancelTimeout(), and GetCTLibContext().

Referenced by PrepareToCancel().

◆ GetCTLibContext() [1/2]

CTLibContext& CTL_Connection::GetCTLibContext ( void  )
inline

Definition at line 406 of file interfaces.hpp.

References _ASSERT.

◆ GetCTLibContext() [2/2]

const CTLibContext& CTL_Connection::GetCTLibContext ( void  ) const
inline

◆ GetDbgInfo()

const CTL_Connection::TDbgInfo & CTL_Connection::GetDbgInfo ( void  ) const
inlineprotectedvirtual

◆ GetLastParams()

const CDBParams * CTL_Connection::GetLastParams ( void  ) const
inlineprivate

Definition at line 1403 of file interfaces.hpp.

References NULL.

Referenced by Check(), CheckWhileOpening(), and CTL_RowResult::GetLastParams().

◆ GetLowLevelHandle()

I_ConnectionExtra::TSockHandle CTL_Connection::GetLowLevelHandle ( void  ) const
protectedvirtual

Get OS handle of the socket represented by the connection.

Reimplemented from impl::CConnection.

Definition at line 622 of file connection.cpp.

References impl::CConnection::GetLowLevelHandle(), and x_GetSybaseConn().

◆ GetNativeConnection() [1/2]

ctlib::Connection& CTL_Connection::GetNativeConnection ( void  )
inline

Definition at line 412 of file interfaces.hpp.

◆ GetNativeConnection() [2/2]

const ctlib::Connection& CTL_Connection::GetNativeConnection ( void  ) const
inline

Definition at line 416 of file interfaces.hpp.

◆ GetRowsInCurrentBatch()

unsigned int CTL_Connection::GetRowsInCurrentBatch ( void  ) const
inlineprotectedvirtual

Reimplemented from impl::CConnection.

Definition at line 1408 of file interfaces.hpp.

◆ GetTimeout()

size_t CTL_Connection::GetTimeout ( void  ) const
protectedvirtual

◆ IsAlive()

bool CTL_Connection::IsAlive ( void  )
virtual

Check out if connection is alive (this function doesn't ping the server, it just checks the status of connection which was set by the last i/o operation)

Implements impl::CConnection.

Definition at line 558 of file connection.cpp.

References ctlib::Connection::IsAlive(), and m_Handle.

Referenced by CheckSFB().

◆ IsCancelInProgress()

bool CTL_Connection::IsCancelInProgress ( void  ) const
inlineprotected

Definition at line 501 of file interfaces.hpp.

◆ IsDead()

bool CTL_Connection::IsDead ( void  ) const
inlineprotected

Definition at line 480 of file interfaces.hpp.

References IsValid().

Referenced by CTL_RowResult::IsDead(), and x_SendData().

◆ IsOpen()

bool CTL_Connection::IsOpen ( void  )
inline

Definition at line 422 of file interfaces.hpp.

◆ LangCmd()

CDB_LangCmd * CTL_Connection::LangCmd ( const string lang_query)
protectedvirtual

These methods: LangCmd(), RPC(), BCPIn(), Cursor() and SendDataCmd() create and return a "command" object, register it for later use with this (and only this!) connection.

On error, an exception will be thrown (they never return NULL!). It is the user's responsibility to delete the returned "command" object. Language command

Implements impl::CConnection.

Definition at line 764 of file connection.cpp.

References impl::CConnection::Create_LangCmd(), CTL_LangCmd, and impl::CConnection::SetExtraMsg().

Referenced by CTL_CursorCmdExpl::Delete(), x_GetNativeBlobDescriptor(), x_IsLegacyBlobColumnType(), and x_SendUpdateWrite().

◆ PrepareToCancel()

size_t CTL_Connection::PrepareToCancel ( void  )
protected

◆ Refresh()

bool CTL_Connection::Refresh ( void  )
protectedvirtual

Reset the connection to the "ready" state (cancel all active commands)

Implements impl::CConnection.

Definition at line 884 of file connection.cpp.

References ctlib::Connection::Cancel(), impl::CConnection::DeleteAllCommands(), ctlib::Connection::IsAlive(), and m_Handle.

Referenced by Close().

◆ RPC()

CDB_RPCCmd * CTL_Connection::RPC ( const string rpc_name)
protectedvirtual

Remote procedure call.

Implements impl::CConnection.

Definition at line 778 of file connection.cpp.

References impl::CConnection::Create_RPCCmd(), CTL_RPCCmd, and impl::CConnection::SetExtraMsg().

Referenced by CompleteBlobDescriptor(), and CompleteBlobDescriptors().

◆ SendData()

bool CTL_Connection::SendData ( I_BlobDescriptor desc,
CDB_Stream lob,
bool  log_it = true 
)
protectedvirtual

Shortcut to send text and image to the server without using the "Send-data" command (SendDataCmd)

Implements impl::CConnection.

Definition at line 878 of file connection.cpp.

References x_SendData().

◆ SendDataCmd()

CDB_SendDataCmd * CTL_Connection::SendDataCmd ( I_BlobDescriptor desc,
size_t  data_size,
bool  log_it = true,
bool  dump_results = true 
)
protectedvirtual

◆ SetCancelTimeout()

void CTL_Connection::SetCancelTimeout ( size_t  nof_secs)
protectedvirtual

Implements impl::CConnection.

Definition at line 577 of file connection.cpp.

References GetCTLibContext(), and impl::CDriverContext::SetCancelTimeout().

◆ SetDead()

void CTL_Connection::SetDead ( bool  flag = true)
inlineprotected

Definition at line 484 of file interfaces.hpp.

◆ SetTimeout()

void CTL_Connection::SetTimeout ( size_t  nof_secs)
protectedvirtual

◆ x_CmdAlloc()

void CTL_Connection::x_CmdAlloc ( CS_COMMAND **  cmd)
private

Definition at line 1026 of file connection.cpp.

References CheckSFB(), cmd, ct_cmd_alloc(), and x_GetSybaseConn().

Referenced by x_SendData().

◆ x_GetNativeBlobDescriptor()

I_BlobDescriptor * CTL_Connection::x_GetNativeBlobDescriptor ( const CDB_BlobDescriptor d)
private

◆ x_GetSybaseConn()

CS_CONNECTION* CTL_Connection::x_GetSybaseConn ( void  ) const
inlineprivate

◆ x_IsLegacyBlobColumnType()

bool CTL_Connection::x_IsLegacyBlobColumnType ( const string table_name,
const string column_name 
)
private

◆ x_LoadTextPtrProcs()

void CTL_Connection::x_LoadTextPtrProcs ( void  )
private

◆ x_ProcessResultInternal()

bool CTL_Connection::x_ProcessResultInternal ( CS_COMMAND cmd,
CS_INT  res_type 
)
private

◆ x_SendData()

bool CTL_Connection::x_SendData ( I_BlobDescriptor desc,
CDB_Stream img,
bool  log_it = true 
)
private

◆ x_SendUpdateWrite()

bool CTL_Connection::x_SendUpdateWrite ( CDB_BlobDescriptor desc,
CDB_Stream img,
size_t  size 
)
private

◆ x_SetExtraMsg()

void CTL_Connection::x_SetExtraMsg ( const I_BlobDescriptor descr,
size_t  data_size 
)
private

◆ xLangCmd()

CTL_LangCmd * CTL_Connection::xLangCmd ( const string lang_query)
protected

Definition at line 923 of file connection.cpp.

References CTL_LangCmd, and impl::CConnection::SetExtraMsg().

Friends And Related Function Documentation

◆ CCancelModeGuard

friend class CCancelModeGuard
friend

Definition at line 563 of file interfaces.hpp.

◆ CTL_BCPInCmd

friend class CTL_BCPInCmd
friend

Definition at line 385 of file interfaces.hpp.

Referenced by BCPIn().

◆ CTL_Cmd

friend class CTL_Cmd
friend

Definition at line 379 of file interfaces.hpp.

◆ CTL_CmdBase

friend class CTL_CmdBase
friend

Definition at line 380 of file interfaces.hpp.

◆ CTL_CursorCmd

friend class CTL_CursorCmd
friend

Definition at line 386 of file interfaces.hpp.

Referenced by Cursor().

◆ CTL_CursorCmdExpl

friend class CTL_CursorCmdExpl
friend

Definition at line 387 of file interfaces.hpp.

Referenced by Cursor().

◆ CTL_CursorResultExpl

friend class CTL_CursorResultExpl
friend

Definition at line 388 of file interfaces.hpp.

◆ CTL_LangCmd

friend class CTL_LangCmd
friend

Definition at line 382 of file interfaces.hpp.

Referenced by LangCmd(), and xLangCmd().

◆ CTL_LRCmd

friend class CTL_LRCmd
friend

Definition at line 381 of file interfaces.hpp.

◆ CTL_RowResult

friend class CTL_RowResult
friend

Definition at line 389 of file interfaces.hpp.

Referenced by x_ProcessResultInternal().

◆ CTL_RPCCmd

friend class CTL_RPCCmd
friend

Definition at line 383 of file interfaces.hpp.

Referenced by RPC().

◆ CTL_SendDataCmd

friend class CTL_SendDataCmd
friend

Definition at line 384 of file interfaces.hpp.

Referenced by SendDataCmd().

◆ ctlib::Connection

friend class ctlib::Connection
friend

Definition at line 377 of file interfaces.hpp.

◆ CTLibContext

friend class CTLibContext
friend

Definition at line 376 of file interfaces.hpp.

◆ ncbi::CDB_Connection

friend class ncbi::CDB_Connection
friend

Definition at line 378 of file interfaces.hpp.

Member Data Documentation

◆ m_ActiveCmd

CTL_CmdBase* CTL_Connection::m_ActiveCmd
private

Definition at line 530 of file interfaces.hpp.

Referenced by x_SendData(), CTL_CmdBase::~CTL_CmdBase(), and ~CTL_Connection().

◆ m_ActivityLevel

unsigned int CTL_Connection::m_ActivityLevel
private

Definition at line 536 of file interfaces.hpp.

◆ m_CancelInProgress

bool CTL_Connection::m_CancelInProgress
private

Definition at line 534 of file interfaces.hpp.

Referenced by CancelFinished(), and PrepareToCancel().

◆ m_CancelLogisticsMutex

CMutex CTL_Connection::m_CancelLogisticsMutex
private

Definition at line 537 of file interfaces.hpp.

◆ m_CancelRequested

bool CTL_Connection::m_CancelRequested
private

Definition at line 535 of file interfaces.hpp.

Referenced by CTL_Cmd::MarkEndOfReply(), and CTL_LRCmd::x_Cancel().

◆ m_Cntx

CTLibContext* CTL_Connection::m_Cntx
private

Definition at line 529 of file interfaces.hpp.

Referenced by GetBLKVersion().

◆ m_Handle

ctlib::Connection CTL_Connection::m_Handle
private

Definition at line 531 of file interfaces.hpp.

Referenced by Close(), CTL_Connection(), IsAlive(), and Refresh().

◆ m_TDSVersion

int CTL_Connection::m_TDSVersion
private

◆ m_TextPtrProcsLoaded

bool CTL_Connection::m_TextPtrProcsLoaded
private

Definition at line 533 of file interfaces.hpp.

Referenced by x_LoadTextPtrProcs().


The documentation for this class was generated from the following files:
Modified on Mon Mar 04 05:10:04 2024 by modify_doxy.py rev. 669887