NCBI C++ ToolKit
conn_impl.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: conn_impl.cpp 102711 2024-06-28 14:39:22Z ucko $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * File Name: $Id: conn_impl.cpp 102711 2024-06-28 14:39:22Z ucko $
27 *
28 * Author: Michael Kholodov
29 *
30 * File Description: Connection implementation
31 *
32 *
33 *
34 */
35 
36 #include <ncbi_pch.hpp>
37 #include <dbapi/driver/public.hpp>
38 #include <dbapi/error_codes.hpp>
40 
41 #include <corelib/version_api.hpp>
42 
43 #include "conn_impl.hpp"
44 #include "ds_impl.hpp"
45 #include "stmt_impl.hpp"
46 #include "cstmt_impl.hpp"
47 #include "cursor_impl.hpp"
48 #include "bulkinsert.hpp"
49 #include "err_handler.hpp"
50 
51 
52 #define NCBI_USE_ERRCODE_X Dbapi_ObjImpls
53 
55 
56 NCBI_PARAM_DECL(bool, dbapi, set_xact_abort);
57 typedef NCBI_PARAM_TYPE(dbapi, set_xact_abort) TDbapi_SetXactAbort;
58 NCBI_PARAM_DEF_EX(bool, dbapi, set_xact_abort, true, eParam_NoThread, NULL);
59 
60 
61 // Implementation
63  : m_ds(ds), m_connection(0), m_connCounter(1), m_connUsed(false),
64  m_modeMask(0), m_forceSingle(false), m_multiExH(0),
65  m_msgToEx(false), m_ownership(ownership)
66 {
67  _TRACE("Default connection " << (void *)this << " created...");
68  SetIdent("CConnection");
69 }
70 
72  : m_ds(ds), m_connection(conn), m_connCounter(-1), m_connUsed(false),
73  m_modeMask(0), m_forceSingle(false), m_multiExH(0),
74  m_msgToEx(false), m_ownership(eNoOwnership)
75 {
76  _TRACE("Auxiliary connection " << (void *)this << " created...");
77  SetIdent("CConnection");
78 }
79 
80 
82 {
83  m_modeMask |= mode;
84 }
85 
87 {
88  m_modeMask &= ~mode;
89 }
90 
92 {
93  return m_ds;
94 }
95 
97 {
98  return m_modeMask;
99 }
100 
101 void CConnection::ForceSingle(bool enable)
102 {
103  m_forceSingle = enable;
104 }
105 
108 {
109  CHECK_NCBI_DBAPI(m_connection == 0, "Database connection has not been initialized");
110  return m_connection;
111 }
112 
113 void CConnection::Connect(const string& user,
114  const string& password,
115  const string& server,
116  const string& database)
117 {
118  CDBDefaultConnParams def_params(
119  server,
120  user,
121  password,
122  GetModeMask(),
123  m_ds->IsPoolUsed()
124  );
125  const CCPPToolkitConnParams params(def_params);
126 
127  def_params.SetDatabaseName(database);
128 
129  Connect(params);
130 }
131 
132 
134 {
135  CHECK_NCBI_DBAPI(m_connection != 0, "Connection is already open");
136  CHECK_NCBI_DBAPI(m_ds == NULL, "m_ds is not initialized");
137 
139  // Explicitly set member value ...
141  x_SendXactAbort();
142 }
143 
144 
146  const string& user,
147  const string& password,
148  const string& server,
149  const string& database)
150 {
151  CDBDefaultConnParams def_params(
152  server,
153  user,
154  password,
155  GetModeMask(),
156  m_ds->IsPoolUsed()
157  );
158  const CCPPToolkitConnParams params(def_params);
159 
160  def_params.SetDatabaseName(database);
161  def_params.SetConnValidator(CRef<IConnValidator>(&validator));
162 
163  Connect(params);
164 }
165 
167 {
168  try {
169  if( IsAux() ) {
170  _TRACE("Auxiliary connection " << (void*)this << " is being deleted...");
171  } else {
172  _TRACE("Default connection " << (void*)this << " is being deleted...");
173  }
174  FreeResources();
175  Notify(CDbapiDeletedEvent(this));
176  _TRACE(GetIdent() << " " << (void*)this << " deleted.");
177  }
179 }
180 
181 
182 void CConnection::SetDatabase(const string& name)
183 {
184  SetDbName(name);
185 }
186 
188 {
189  return m_database;
190 }
191 
193 {
194  return m_connection == 0 ? false : m_connection->IsAlive();
195 }
196 
197 void CConnection::SetDbName(const string& name, CDB_Connection* conn)
198 {
199  m_database = name;
200 
201  if( GetDatabase().empty() )
202  return;
203 
204  CDB_Connection* work = (conn == 0 ? GetCDB_Connection() : conn);
205  work->SetDatabaseName(name);
206 }
207 
209 {
210  CHECK_NCBI_DBAPI(m_ds == NULL, "m_ds is not initialized");
211 
212  CDBDefaultConnParams def_params(
213  GetCDB_Connection()->ServerName(),
214  GetCDB_Connection()->UserName(),
215  GetCDB_Connection()->Password(),
216  GetModeMask(),
217  true
218  );
219  const CCPPToolkitConnParams params(def_params);
220 
221  def_params.SetHost(GetCDB_Connection()->Host());
222  def_params.SetPort(GetCDB_Connection()->Port());
223  def_params.SetDatabaseName(GetDatabase());
224  def_params.SetParam("do_not_dispatch", "true");
225  def_params.SetParam("do_not_read_conf", "true");
226 
228  CDB_Connection* tmp_conn = dctx->MakeConnection(params);
229 
230  // If the original connection was known to be in a transaction,
231  // operations using the new one could block on its completion,
232  // possibly yielding a deadlock. In such cases, ensure that the
233  // new connection has a reasonable timeout. (MS SQL offers a
234  // finer-grained LOCK_TIMEOUT setting, but that's not portable,
235  // even to Sybase, which is more prone to such deadlocks in the
236  // first place.)
237  if (GetCDB_Connection()->HasTransaction() && dctx->GetTimeout() == 0) {
238  tmp_conn->SetTimeout(5);
239  }
240 
241  _TRACE("CDB_Connection " << (void*)GetCDB_Connection()
242  << " cloned, new CDB_Connection: " << (void*)tmp_conn);
243 
244  return tmp_conn;
245 }
246 
248 {
249  CHECK_NCBI_DBAPI(m_ds == NULL, "m_ds is not initialized");
250 
252 
253  if( m_msgToEx )
254  conn->MsgToEx(true);
255 
256  ++m_connCounter;
257  return conn;
258 }
259 
261 {
262  CHECK_NCBI_DBAPI(m_ds == NULL, "m_ds is not initialized");
263 
264  CDB_Connection *cdbConn = CloneCDB_Conn();
265  CConnection *conn = new CConnection(m_ds, ownership);
266 
267  conn->m_modeMask = this->GetModeMask();
268  conn->m_forceSingle = this->m_forceSingle;
269  conn->m_database = this->GetDatabase();
270  conn->m_connection = cdbConn;
271  if( m_msgToEx )
272  conn->MsgToEx(true);
273 
274  conn->AddListener(m_ds);
276 
277  conn->x_SendXactAbort();
278  return conn;
279 }
280 
282 {
283  if( m_connCounter < 0 )
284  return 0;
285 
286  CConnection *conn = this;
287  CHECK_NCBI_DBAPI( m_connUsed && m_forceSingle, "GetAuxConn(): Extra connections not permitted" );
288  if( m_connUsed ) {
289  conn = Clone();
290  _TRACE("GetAuxConn(): Server: " << GetCDB_Connection()->ServerName()
291  << ", open aux connection, total: " << m_connCounter);
292  }
293  else {
294  m_connUsed = true;
295 
296  _TRACE("GetAuxconn(): server: " << GetCDB_Connection()->ServerName()
297  << ", no aux connections necessary, using default...");
298  }
299 
300  return conn;
301 
302 }
303 
304 
306 {
307  FreeResources();
308 }
309 
311 {
313  //FreeResources();
314 }
315 
316 void CConnection::SetTimeout(size_t nof_secs)
317 {
318  GetCDB_Connection()->SetTimeout(nof_secs);
319 }
320 
321 void CConnection::SetCancelTimeout(size_t nof_secs)
322 {
323  GetCDB_Connection()->SetCancelTimeout(nof_secs);
324 }
325 
327 {
328  delete m_connection;
329  m_connection = 0;
330 }
331 
332 // New part
334 {
335  CHECK_NCBI_DBAPI(m_connection == 0, "No connection established");
336 
338  m_connUsed,
339  "CConnection::GetStatement(): Connection taken, cannot use this method"
340  );
341  CStatement *stmt = new CStatement(this);
342  AddListener(stmt);
343  stmt->AddListener(this);
344  return stmt;
345 }
346 
349 {
351  m_connUsed,
352  "CConnection::GetCallableStatement(): Connection taken, cannot use this method"
353  );
354 /*
355  if( m_cstmt != 0 ) {
356  //m_cstmt->PurgeResults();
357  delete m_cstmt;
358  }
359  m_cstmt = new CCallableStatement(proc, this);
360  AddListener(m_cstmt);
361  m_cstmt->AddListener(this);
362  return m_cstmt;
363 */
364  CCallableStatement *cstmt = new CCallableStatement(proc, this);
365  AddListener(cstmt);
366  cstmt->AddListener(this);
367  return cstmt;
368 }
369 
370 ICursor* CConnection::GetCursor(const string& name,
371  const string& sql,
372  int batchSize)
373 {
374 // if( m_connUsed )
375 // throw CDbapiException("CConnection::GetCursor(): Connection taken, cannot use this method");
376 /*
377  if( m_cursor != 0 ) {
378  delete m_cursor;
379  }
380  m_cursor = new CCursor(name, sql, batchSize, this);
381  AddListener(m_cursor);
382  m_cursor->AddListener(this);
383  return m_cursor;
384 */
385  CCursor *cursor = new CCursor(name, sql, batchSize, this);
386  AddListener(cursor);
387  cursor->AddListener(this);
388  return cursor;
389 }
390 
392 {
393 // if( m_connUsed )
394 // throw CDbapiException("CConnection::GetBulkInsert(): Connection taken, cannot use this method");
395 /*
396  if( m_bulkInsert != 0 ) {
397  delete m_bulkInsert;
398  }
399  m_bulkInsert = new CDBAPIBulkInsert(table_name, nof_cols, this);
400  AddListener(m_bulkInsert);
401  m_bulkInsert->AddListener(this);
402  return m_bulkInsert;
403 */
404  CDBAPIBulkInsert *bulkInsert = new CDBAPIBulkInsert(table_name, this);
405  AddListener(bulkInsert);
406  bulkInsert->AddListener(this);
407  return bulkInsert;
408 }
409 // New part end
410 
411 
413 {
414 // if( m_getUsed )
415 // throw CDbapiException("CConnection::CreateStatement(): Get...() methods used");
416 
418  AddListener(stmt);
419  stmt->AddListener(this);
420  return stmt;
421 }
422 
425 {
426 // if( m_getUsed )
427 // throw CDbapiException("CConnection::CreateCallableStatement(): Get...() methods used");
428 
430  AddListener(cstmt);
431  cstmt->AddListener(this);
432  return cstmt;
433 }
434 
435 ICursor* CConnection::CreateCursor(const string& name,
436  const string& sql,
437  int batchSize)
438 {
439  // if( m_getUsed )
440  // throw CDbapiException("CConnection::CreateCursor(): Get...() methods used");
441 
442  CCursor *cur = new CCursor(name, sql, batchSize, GetAuxConn());
443  AddListener(cur);
444  cur->AddListener(this);
445  return cur;
446 }
447 
449 {
450 // if( m_getUsed )
451 // throw CDbapiException("CConnection::CreateBulkInsert(): Get...() methods used");
452 
454  AddListener(bcp);
455  bcp->AddListener(this);
456  return bcp;
457 }
458 
460 {
461  _TRACE(GetIdent() << " " << (void*)this << ": '" << e.GetName()
462  << "' received from " << e.GetSource()->GetIdent() << " " << (void*)e.GetSource());
463 
464  if(dynamic_cast<const CDbapiClosedEvent*>(&e) != 0 ) {
465 /*
466  CStatement *stmt;
467  CCallableStatement *cstmt;
468  CCursor *cursor;
469  CDBAPIBulkInsert *bulkInsert;
470  if( (cstmt = dynamic_cast<CCallableStatement*>(e.GetSource())) != 0 ) {
471  if( cstmt == m_cstmt ) {
472  _TRACE("CConnection: Clearing cached callable statement " << (void*)m_cstmt);
473  m_cstmt = 0;
474  }
475  }
476  else if( (stmt = dynamic_cast<CStatement*>(e.GetSource())) != 0 ) {
477  if( stmt == m_stmt ) {
478  _TRACE("CConnection: Clearing cached statement " << (void*)m_stmt);
479  m_stmt = 0;
480  }
481  }
482  else if( (cursor = dynamic_cast<CCursor*>(e.GetSource())) != 0 ) {
483  if( cursor == m_cursor ) {
484  _TRACE("CConnection: Clearing cached cursor " << (void*)m_cursor);
485  m_cursor = 0;
486  }
487  }
488  else if( (bulkInsert = dynamic_cast<CDBAPIBulkInsert*>(e.GetSource())) != 0 ) {
489  if( bulkInsert == m_bulkInsert ) {
490  _TRACE("CConnection: Clearing cached bulkinsert " << (void*)m_bulkInsert);
491  m_bulkInsert = 0;
492  }
493  }
494 */
495  if( m_connCounter == 1 )
496  m_connUsed = false;
497  }
498  else if(dynamic_cast<const CDbapiAuxDeletedEvent*>(&e) != 0 ) {
499  if( m_connCounter > 1 ) {
500  --m_connCounter;
501  _TRACE("Server: " << GetCDB_Connection()->ServerName()
502  <<", connections left: " << m_connCounter);
503  }
504  else
505  m_connUsed = false;
506  }
507  else if(dynamic_cast<const CDbapiDeletedEvent*>(&e) != 0 ) {
509  if(dynamic_cast<CDataSource*>(e.GetSource()) != 0 ) {
510  if( m_ownership == eNoOwnership ) {
511  delete this;
512  }
513  }
514  }
515 }
516 
518 {
519  if( !v ) {
520  // Clear the previous handlers if present
522  _TRACE("MsqToEx(): connection " << (void*)this
523  << ": message handler " << (void*)GetHandler()
524  << " removed from CDB_Connection " << (void*)GetCDB_Connection());
525  m_msgToEx = false;
526  }
527  else {
529  _TRACE("MsqToEx(): connection " << (void*)this
530  << ": message handler " << (void*)GetHandler()
531  << " installed on CDB_Connection " << (void*)GetCDB_Connection());
532  m_msgToEx = true;
533  }
534 }
535 
537 {
538  if (m_multiExH.Empty()) {
540  }
541  return m_multiExH.GetPointerOrNull();
542 }
543 
545 {
546  return GetHandler()->GetMultiEx();
547 }
548 
550 {
553  h.HandleIt(GetHandler()->GetMultiEx());
554  // Install new handler
556 /*
557  GetCDB_Connection()->PopMsgHandler(GetHandler());
558  delete m_multiExH;
559  m_multiExH = new CToMultiExHandler;
560  GetCDB_Connection()->PushMsgHandler(GetHandler());
561 */
563 }
564 
566 {
567  if (m_versionInfo.get() == nullptr) {
568  string name;
569  unique_ptr<CVersionInfo> info(new CVersionInfo);
571  &name, info.get());
572  m_versionInfo = move(info);
573  }
574  return *m_versionInfo;
575 }
576 
577 /*
578 void CConnection::DeleteConn(CConnection* conn)
579 {
580  if( m_connCounter > 1) {
581  delete conn;
582  --m_connCounter;
583  }
584 
585  _TRACE("Connection deleted, total left: " << m_connCounter);
586  return;
587 }
588 */
589 
591 {
592  static TDbapi_SetXactAbort sx_set_xact_abort;
593 
594  if (sx_set_xact_abort.Get()) {
595  // Note: SET XACT_ABORT ON is supported by MS SQL and is not supported
596  // by Sybase. So we first check the server brand.
597  bool is_ms_sql = false;
598 
599  unique_ptr<CDB_LangCmd> cmd(m_connection->LangCmd("SELECT @@version"));
600  cmd->Send();
601 
602  while (cmd->HasMoreResults()) {
603  unique_ptr<CDB_Result> result;
604  try {
605  // Note: in case of connecting to PSOS cmd->HasFailed() returns
606  // false however cmd->Result() generates an exception. The way
607  // to identify an error in the command execution without an
608  // exception was NOT found so here are try-catch blocks.
609  // The error code was picked as the one used in PSOS scenario
610  // at lang_cmd.cpp:698 (DATABASE_DRIVER_WARNING macro).
611  result.reset(cmd->Result());
612  } catch (const CDB_ClientEx & ex) {
613  if (ex.GetDBErrCode() == 120016)
614  return;
615  throw;
616  }
617 
618  if (!result.get())
619  continue;
620 
621  while (result->Fetch()) {
623  result->GetItem(&value);
624  if (NStr::Find(value.AsString(),
625  "Microsoft", NStr::eNocase) != NPOS)
626  is_ms_sql = true;
627  }
628  }
629 
630  if (is_ms_sql) {
631  unique_ptr<CDB_LangCmd> xact_cmd(
632  m_connection->LangCmd("SET XACT_ABORT ON"));
633  xact_cmd->Send();
634 
635  // Dump results triggers calling the Check() method a few levels
636  // below which properly checks if there were problems during the
637  // command execution. If so then an exception is thrown.
638  xact_cmd->DumpResults();
639  }
640  }
641 }
642 
void RemoveListener(CActiveObject *obj)
Definition: active_obj.cpp:60
void SetIdent(const string &name)
Definition: active_obj.cpp:98
void AddListener(CActiveObject *obj)
Definition: active_obj.cpp:50
string GetIdent() const
Definition: active_obj.cpp:93
void Notify(const CDbapiEvent &e)
Definition: active_obj.cpp:71
CRef< CToMultiExHandler > m_multiExH
Definition: conn_impl.hpp:154
CConnection * Clone()
Definition: conn_impl.cpp:247
virtual string GetErrorInfo()
Returns all error messages as a single string.
Definition: conn_impl.cpp:549
virtual void Action(const CDbapiEvent &e)
Definition: conn_impl.cpp:459
virtual CDB_MultiEx * GetErrorAsEx()
Returns all error messages as a CDB_MultiEx object.
Definition: conn_impl.cpp:544
bool m_forceSingle
Definition: conn_impl.hpp:153
virtual ICursor * GetCursor(const string &name, const string &sql, int batchSize)
Get cursor object.
Definition: conn_impl.cpp:370
CDB_Connection * m_connection
Definition: conn_impl.hpp:149
virtual ICallableStatement * PrepareCall(const string &proc)
Get callable statement object for stored procedures.
Definition: conn_impl.cpp:424
virtual void SetMode(EConnMode mode)
Set connection mode.
Definition: conn_impl.cpp:81
virtual void SetDatabase(const string &name)
Set current database.
Definition: conn_impl.cpp:182
unique_ptr< CVersionInfo > m_versionInfo
Definition: conn_impl.hpp:156
virtual ICursor * CreateCursor(const string &name, const string &sql, int batchSize)
Get cursor object.
Definition: conn_impl.cpp:435
virtual void Abort()
Abort connection.
Definition: conn_impl.cpp:310
bool IsAux()
Definition: conn_impl.hpp:116
virtual void MsgToEx(bool v)
If enabled, redirects all error messages to CDB_MultiEx object (see below).
Definition: conn_impl.cpp:517
virtual ICallableStatement * GetCallableStatement(const string &proc)
Get callable statement object for stored procedures.
Definition: conn_impl.cpp:348
virtual IConnection * CloneConnection(EOwnership ownership)
Clone existing connection.
Definition: conn_impl.cpp:260
virtual IDataSource * GetDataSource()
Get parent datasource object.
Definition: conn_impl.cpp:91
EOwnership m_ownership
Definition: conn_impl.hpp:158
virtual unsigned int GetModeMask()
Get mode mask.
Definition: conn_impl.cpp:96
unsigned int m_modeMask
Definition: conn_impl.hpp:152
class CDataSource * m_ds
Definition: conn_impl.hpp:148
void SetDbName(const string &name, CDB_Connection *conn=0)
Definition: conn_impl.cpp:197
virtual IBulkInsert * CreateBulkInsert(const string &table_name)
Create bulk insert object.
Definition: conn_impl.cpp:448
virtual void Close()
Close connecti.
Definition: conn_impl.cpp:305
virtual IStatement * GetStatement()
Get statement object for regular SQL queries.
Definition: conn_impl.cpp:333
bool m_msgToEx
Definition: conn_impl.hpp:155
CDB_Connection * CloneCDB_Conn()
Definition: conn_impl.cpp:208
virtual ~CConnection()
Definition: conn_impl.cpp:166
CConnection * GetAuxConn()
Definition: conn_impl.cpp:281
virtual void SetTimeout(size_t nof_secs)
Set connection timeout.
Definition: conn_impl.cpp:316
virtual const CVersionInfo & GetVersionInfo() const
Definition: conn_impl.cpp:565
virtual void ResetMode(EConnMode mode)
Reset connection mode.
Definition: conn_impl.cpp:86
void FreeResources()
Definition: conn_impl.cpp:326
virtual void ForceSingle(bool enable)
Force single connection mode, default false.
Definition: conn_impl.cpp:101
virtual IBulkInsert * GetBulkInsert(const string &table_name)
Create bulk insert object.
Definition: conn_impl.cpp:391
virtual IStatement * CreateStatement()
Get statement object for regular SQL queries.
Definition: conn_impl.cpp:412
CConnection(CDataSource *ds, EOwnership ownership)
Definition: conn_impl.cpp:62
virtual void ConnectValidated(IConnValidator &validator, const string &user, const string &password, const string &server, const string &database=kEmptyStr)
Connect to a database using connect validator.
Definition: conn_impl.cpp:145
virtual string GetDatabase()
Get current database.
Definition: conn_impl.cpp:187
virtual CDB_Connection * GetCDB_Connection()
Returns the internal driver connection object.
Definition: conn_impl.cpp:107
bool m_connUsed
Definition: conn_impl.hpp:151
virtual void SetCancelTimeout(size_t nof_secs)
Set timeout for command cancellation and connection closing.
Definition: conn_impl.cpp:321
int m_connCounter
Definition: conn_impl.hpp:150
virtual bool IsAlive()
Check if the connection is alive.
Definition: conn_impl.cpp:192
virtual void Connect(const string &user, const string &password, const string &server, const string &database=kEmptyStr)
Connect to a database.
Definition: conn_impl.cpp:113
string m_database
Definition: conn_impl.hpp:147
void x_SendXactAbort(void)
Definition: conn_impl.cpp:590
class CToMultiExHandler * GetHandler()
Definition: conn_impl.cpp:536
Class has deliberately obscure name to not mix it with CBulkInsert in SDBAPI and to avoid direct usag...
Definition: bulkinsert.hpp:47
CDBConnParams::
Definition: interfaces.hpp:258
void SetConnValidator(const CRef< IConnValidator > &validator)
void SetDatabaseName(const string &name)
void SetParam(const string &key, const string &value)
virtual I_DriverContext * GetDriverContext()
Returns the pointer to the general driver interface.
Definition: ds_impl.cpp:158
bool IsPoolUsed()
Definition: ds_impl.hpp:79
string GetName() const
Definition: active_obj.hpp:57
CActiveObject * GetSource() const
Definition: active_obj.hpp:55
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
CDB_MultiEx * GetMultiEx()
Definition: err_handler.hpp:51
CVersionInfo –.
IBulkInsert –.
Definition: dbapi.hpp:671
ICallableStatement –.
Definition: dbapi.hpp:516
ICursor –.
Definition: dbapi.hpp:570
IDataSource –.
Definition: dbapi.hpp:971
NCBI_PARAM_DECL(bool, dbapi, set_xact_abort)
NCBI_PARAM_DEF_EX(bool, dbapi, set_xact_abort, true, eParam_NoThread, NULL)
typedef NCBI_PARAM_TYPE(dbapi, set_xact_abort) TDbapi_SetXactAbort
#define CHECK_NCBI_DBAPI(failed, message)
Definition: dbexception.hpp:62
std::ofstream out("events_result.xml")
main entry point for tests
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
#define false
Definition: bool.h:36
static const char table_name[]
Definition: bcp.c:249
static char sql[1024]
Definition: putdata.c:19
static HSTMT stmt
Definition: rebindpar.c:12
static const char * proc
Definition: stats.c:21
@ eNoOwnership
No ownership is assumed.
Definition: ncbi_types.h:135
string
Definition: cgiapp.hpp:690
#define NULL
Definition: ncbistd.hpp:225
EConnMode
Which connection mode.
Definition: dbapi.hpp:737
int GetDBErrCode(void) const
Definition: exception.hpp:184
virtual bool HandleIt(CDB_Exception *ex)
Handle the exceptions resulting from a native API call, one-by-one.
Definition: exception.cpp:765
virtual unsigned int GetTimeout(void) const =0
Get connection timeout.
virtual CDB_Connection * MakeConnection(const CDBConnParams &params)=0
Create connection object using Load Balancer / connection factory.
virtual void SetCancelTimeout(size_t nof_secs)
Set timeout for command cancellation and connection closing.
Definition: public.cpp:550
virtual string GetVersionString(void) const
Driver version, supplied here rather than by the context for ODBC's sake.
Definition: public.cpp:580
virtual bool IsAlive()
Check out if connection is alive.
Definition: public.cpp:292
virtual bool Abort()
Abort the connection.
Definition: public.cpp:516
void SetDatabaseName(const string &name)
Set database name.
Definition: public.cpp:403
virtual CDB_LangCmd * LangCmd(const string &lang_query)
Make language command.
Definition: public.cpp:355
virtual void PushMsgHandler(CDB_UserHandler *h, EOwnership ownership=eNoOwnership)
Put the message handler into message handler stack.
Definition: public.cpp:486
virtual const string & DatabaseName(void) const
Get the database name.
Definition: public.cpp:450
virtual void PopMsgHandler(CDB_UserHandler *h)
Remove the message handler (and all above it) from the stack.
Definition: public.cpp:493
virtual void SetTimeout(size_t nof_secs)
Set connection timeout.
Definition: public.cpp:544
#define _TRACE(message)
Definition: ncbidbg.hpp:122
#define NCBI_CATCH_ALL_X(err_subcode, message)
Definition: ncbiexpt.hpp:619
TObjectType * GetPointerOrNull(void) THROWS_NONE
Get pointer value.
Definition: ncbiobj.hpp:986
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
Definition: ncbiobj.hpp:719
@ eParam_NoThread
Do not use per-thread values.
Definition: ncbi_param.hpp:418
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
#define NPOS
Definition: ncbistr.hpp:133
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
Definition: ncbistr.cpp:2882
@ eNocase
Case insensitive compare.
Definition: ncbistr.hpp:1206
enum ENcbiOwnership EOwnership
Ownership relations between objects.
void ParseVersionString(const string &vstr, string *program_name, CVersionInfo *ver)
Parse string, extract version info and program name (case insensitive)
Definition: version.cpp:271
Definition of all error codes used in dbapi libraries (dbapi_driver.lib and others).
use only n Cassandra database for the lookups</td > n</tr > n< tr > n< td > yes</td > n< td > do not use tables BIOSEQ_INFO and BLOB_PROP in the Cassandra database
static MDB_envinfo info
Definition: mdb_load.c:37
constexpr bool empty(list< Ts... >) noexcept
mdb_mode_t mode
Definition: lmdb++.h:38
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
else result
Definition: token2.c:20
Modified on Fri Sep 20 14:57:48 2024 by modify_doxy.py rev. 669887