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 83966 2018-10-04 14:52:03Z 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 83966 2018-10-04 14:52:03Z 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 "conn_impl.hpp"
42 #include "ds_impl.hpp"
43 #include "stmt_impl.hpp"
44 #include "cstmt_impl.hpp"
45 #include "cursor_impl.hpp"
46 #include "bulkinsert.hpp"
47 #include "err_handler.hpp"
48 
49 
50 #define NCBI_USE_ERRCODE_X Dbapi_ObjImpls
51 
53 
54 NCBI_PARAM_DECL(bool, dbapi, set_xact_abort);
55 typedef NCBI_PARAM_TYPE(dbapi, set_xact_abort) TDbapi_SetXactAbort;
56 NCBI_PARAM_DEF_EX(bool, dbapi, set_xact_abort, true, eParam_NoThread, NULL);
57 
58 
59 // Implementation
61  : m_ds(ds), m_connection(0), m_connCounter(1), m_connUsed(false),
62  m_modeMask(0), m_forceSingle(false), m_multiExH(0),
63  m_msgToEx(false), m_ownership(ownership)
64 {
65  _TRACE("Default connection " << (void *)this << " created...");
66  SetIdent("CConnection");
67 }
68 
70  : m_ds(ds), m_connection(conn), m_connCounter(-1), m_connUsed(false),
71  m_modeMask(0), m_forceSingle(false), m_multiExH(0),
72  m_msgToEx(false), m_ownership(eNoOwnership)
73 {
74  _TRACE("Auxiliary connection " << (void *)this << " created...");
75  SetIdent("CConnection");
76 }
77 
78 
80 {
81  m_modeMask |= mode;
82 }
83 
85 {
86  m_modeMask &= ~mode;
87 }
88 
90 {
91  return m_ds;
92 }
93 
95 {
96  return m_modeMask;
97 }
98 
99 void CConnection::ForceSingle(bool enable)
100 {
101  m_forceSingle = enable;
102 }
103 
106 {
107  CHECK_NCBI_DBAPI(m_connection == 0, "Database connection has not been initialized");
108  return m_connection;
109 }
110 
111 void CConnection::Connect(const string& user,
112  const string& password,
113  const string& server,
114  const string& database)
115 {
116  CDBDefaultConnParams def_params(
117  server,
118  user,
119  password,
120  GetModeMask(),
121  m_ds->IsPoolUsed()
122  );
123  const CCPPToolkitConnParams params(def_params);
124 
125  def_params.SetDatabaseName(database);
126 
127  Connect(params);
128 }
129 
130 
132 {
133  CHECK_NCBI_DBAPI(m_connection != 0, "Connection is already open");
134  CHECK_NCBI_DBAPI(m_ds == NULL, "m_ds is not initialized");
135 
137  // Explicitly set member value ...
139  x_SendXactAbort();
140 }
141 
142 
144  const string& user,
145  const string& password,
146  const string& server,
147  const string& database)
148 {
149  CDBDefaultConnParams def_params(
150  server,
151  user,
152  password,
153  GetModeMask(),
154  m_ds->IsPoolUsed()
155  );
156  const CCPPToolkitConnParams params(def_params);
157 
158  def_params.SetDatabaseName(database);
159  def_params.SetConnValidator(CRef<IConnValidator>(&validator));
160 
161  Connect(params);
162 }
163 
165 {
166  try {
167  if( IsAux() ) {
168  _TRACE("Auxiliary connection " << (void*)this << " is being deleted...");
169  } else {
170  _TRACE("Default connection " << (void*)this << " is being deleted...");
171  }
172  FreeResources();
173  Notify(CDbapiDeletedEvent(this));
174  _TRACE(GetIdent() << " " << (void*)this << " deleted.");
175  }
177 }
178 
179 
180 void CConnection::SetDatabase(const string& name)
181 {
182  SetDbName(name);
183 }
184 
186 {
187  return m_database;
188 }
189 
191 {
192  return m_connection == 0 ? false : m_connection->IsAlive();
193 }
194 
195 void CConnection::SetDbName(const string& name, CDB_Connection* conn)
196 {
197  m_database = name;
198 
199  if( GetDatabase().empty() )
200  return;
201 
202  CDB_Connection* work = (conn == 0 ? GetCDB_Connection() : conn);
203  work->SetDatabaseName(name);
204 }
205 
207 {
208  CHECK_NCBI_DBAPI(m_ds == NULL, "m_ds is not initialized");
209 
210  CDBDefaultConnParams def_params(
211  GetCDB_Connection()->ServerName(),
212  GetCDB_Connection()->UserName(),
213  GetCDB_Connection()->Password(),
214  GetModeMask(),
215  true
216  );
217  const CCPPToolkitConnParams params(def_params);
218 
219  def_params.SetHost(GetCDB_Connection()->Host());
220  def_params.SetPort(GetCDB_Connection()->Port());
221  def_params.SetDatabaseName(GetDatabase());
222  def_params.SetParam("do_not_dispatch", "true");
223  def_params.SetParam("do_not_read_conf", "true");
224 
226  CDB_Connection* tmp_conn = dctx->MakeConnection(params);
227 
228  // If the original connection was known to be in a transaction,
229  // operations using the new one could block on its completion,
230  // possibly yielding a deadlock. In such cases, ensure that the
231  // new connection has a reasonable timeout. (MS SQL offers a
232  // finer-grained LOCK_TIMEOUT setting, but that's not portable,
233  // even to Sybase, which is more prone to such deadlocks in the
234  // first place.)
235  if (GetCDB_Connection()->HasTransaction() && dctx->GetTimeout() == 0) {
236  tmp_conn->SetTimeout(5);
237  }
238 
239  _TRACE("CDB_Connection " << (void*)GetCDB_Connection()
240  << " cloned, new CDB_Connection: " << (void*)tmp_conn);
241 
242  return tmp_conn;
243 }
244 
246 {
247  CHECK_NCBI_DBAPI(m_ds == NULL, "m_ds is not initialized");
248 
250 
251  if( m_msgToEx )
252  conn->MsgToEx(true);
253 
254  ++m_connCounter;
255  return conn;
256 }
257 
259 {
260  CHECK_NCBI_DBAPI(m_ds == NULL, "m_ds is not initialized");
261 
262  CDB_Connection *cdbConn = CloneCDB_Conn();
263  CConnection *conn = new CConnection(m_ds, ownership);
264 
265  conn->m_modeMask = this->GetModeMask();
266  conn->m_forceSingle = this->m_forceSingle;
267  conn->m_database = this->GetDatabase();
268  conn->m_connection = cdbConn;
269  if( m_msgToEx )
270  conn->MsgToEx(true);
271 
272  conn->AddListener(m_ds);
274 
275  conn->x_SendXactAbort();
276  return conn;
277 }
278 
280 {
281  if( m_connCounter < 0 )
282  return 0;
283 
284  CConnection *conn = this;
285  CHECK_NCBI_DBAPI( m_connUsed && m_forceSingle, "GetAuxConn(): Extra connections not permitted" );
286  if( m_connUsed ) {
287  conn = Clone();
288  _TRACE("GetAuxConn(): Server: " << GetCDB_Connection()->ServerName()
289  << ", open aux connection, total: " << m_connCounter);
290  }
291  else {
292  m_connUsed = true;
293 
294  _TRACE("GetAuxconn(): server: " << GetCDB_Connection()->ServerName()
295  << ", no aux connections necessary, using default...");
296  }
297 
298  return conn;
299 
300 }
301 
302 
304 {
305  FreeResources();
306 }
307 
309 {
311  //FreeResources();
312 }
313 
314 void CConnection::SetTimeout(size_t nof_secs)
315 {
316  GetCDB_Connection()->SetTimeout(nof_secs);
317 }
318 
319 void CConnection::SetCancelTimeout(size_t nof_secs)
320 {
321  GetCDB_Connection()->SetCancelTimeout(nof_secs);
322 }
323 
325 {
326  delete m_connection;
327  m_connection = 0;
328 }
329 
330 // New part
332 {
333  CHECK_NCBI_DBAPI(m_connection == 0, "No connection established");
334 
336  m_connUsed,
337  "CConnection::GetStatement(): Connection taken, cannot use this method"
338  );
339  CStatement *stmt = new CStatement(this);
340  AddListener(stmt);
341  stmt->AddListener(this);
342  return stmt;
343 }
344 
347 {
349  m_connUsed,
350  "CConnection::GetCallableStatement(): Connection taken, cannot use this method"
351  );
352 /*
353  if( m_cstmt != 0 ) {
354  //m_cstmt->PurgeResults();
355  delete m_cstmt;
356  }
357  m_cstmt = new CCallableStatement(proc, this);
358  AddListener(m_cstmt);
359  m_cstmt->AddListener(this);
360  return m_cstmt;
361 */
362  CCallableStatement *cstmt = new CCallableStatement(proc, this);
363  AddListener(cstmt);
364  cstmt->AddListener(this);
365  return cstmt;
366 }
367 
368 ICursor* CConnection::GetCursor(const string& name,
369  const string& sql,
370  int batchSize)
371 {
372 // if( m_connUsed )
373 // throw CDbapiException("CConnection::GetCursor(): Connection taken, cannot use this method");
374 /*
375  if( m_cursor != 0 ) {
376  delete m_cursor;
377  }
378  m_cursor = new CCursor(name, sql, batchSize, this);
379  AddListener(m_cursor);
380  m_cursor->AddListener(this);
381  return m_cursor;
382 */
383  CCursor *cursor = new CCursor(name, sql, batchSize, this);
384  AddListener(cursor);
385  cursor->AddListener(this);
386  return cursor;
387 }
388 
390 {
391 // if( m_connUsed )
392 // throw CDbapiException("CConnection::GetBulkInsert(): Connection taken, cannot use this method");
393 /*
394  if( m_bulkInsert != 0 ) {
395  delete m_bulkInsert;
396  }
397  m_bulkInsert = new CDBAPIBulkInsert(table_name, nof_cols, this);
398  AddListener(m_bulkInsert);
399  m_bulkInsert->AddListener(this);
400  return m_bulkInsert;
401 */
402  CDBAPIBulkInsert *bulkInsert = new CDBAPIBulkInsert(table_name, this);
403  AddListener(bulkInsert);
404  bulkInsert->AddListener(this);
405  return bulkInsert;
406 }
407 // New part end
408 
409 
411 {
412 // if( m_getUsed )
413 // throw CDbapiException("CConnection::CreateStatement(): Get...() methods used");
414 
416  AddListener(stmt);
417  stmt->AddListener(this);
418  return stmt;
419 }
420 
423 {
424 // if( m_getUsed )
425 // throw CDbapiException("CConnection::CreateCallableStatement(): Get...() methods used");
426 
428  AddListener(cstmt);
429  cstmt->AddListener(this);
430  return cstmt;
431 }
432 
433 ICursor* CConnection::CreateCursor(const string& name,
434  const string& sql,
435  int batchSize)
436 {
437  // if( m_getUsed )
438  // throw CDbapiException("CConnection::CreateCursor(): Get...() methods used");
439 
440  CCursor *cur = new CCursor(name, sql, batchSize, GetAuxConn());
441  AddListener(cur);
442  cur->AddListener(this);
443  return cur;
444 }
445 
447 {
448 // if( m_getUsed )
449 // throw CDbapiException("CConnection::CreateBulkInsert(): Get...() methods used");
450 
452  AddListener(bcp);
453  bcp->AddListener(this);
454  return bcp;
455 }
456 
458 {
459  _TRACE(GetIdent() << " " << (void*)this << ": '" << e.GetName()
460  << "' received from " << e.GetSource()->GetIdent() << " " << (void*)e.GetSource());
461 
462  if(dynamic_cast<const CDbapiClosedEvent*>(&e) != 0 ) {
463 /*
464  CStatement *stmt;
465  CCallableStatement *cstmt;
466  CCursor *cursor;
467  CDBAPIBulkInsert *bulkInsert;
468  if( (cstmt = dynamic_cast<CCallableStatement*>(e.GetSource())) != 0 ) {
469  if( cstmt == m_cstmt ) {
470  _TRACE("CConnection: Clearing cached callable statement " << (void*)m_cstmt);
471  m_cstmt = 0;
472  }
473  }
474  else if( (stmt = dynamic_cast<CStatement*>(e.GetSource())) != 0 ) {
475  if( stmt == m_stmt ) {
476  _TRACE("CConnection: Clearing cached statement " << (void*)m_stmt);
477  m_stmt = 0;
478  }
479  }
480  else if( (cursor = dynamic_cast<CCursor*>(e.GetSource())) != 0 ) {
481  if( cursor == m_cursor ) {
482  _TRACE("CConnection: Clearing cached cursor " << (void*)m_cursor);
483  m_cursor = 0;
484  }
485  }
486  else if( (bulkInsert = dynamic_cast<CDBAPIBulkInsert*>(e.GetSource())) != 0 ) {
487  if( bulkInsert == m_bulkInsert ) {
488  _TRACE("CConnection: Clearing cached bulkinsert " << (void*)m_bulkInsert);
489  m_bulkInsert = 0;
490  }
491  }
492 */
493  if( m_connCounter == 1 )
494  m_connUsed = false;
495  }
496  else if(dynamic_cast<const CDbapiAuxDeletedEvent*>(&e) != 0 ) {
497  if( m_connCounter > 1 ) {
498  --m_connCounter;
499  _TRACE("Server: " << GetCDB_Connection()->ServerName()
500  <<", connections left: " << m_connCounter);
501  }
502  else
503  m_connUsed = false;
504  }
505  else if(dynamic_cast<const CDbapiDeletedEvent*>(&e) != 0 ) {
507  if(dynamic_cast<CDataSource*>(e.GetSource()) != 0 ) {
508  if( m_ownership == eNoOwnership ) {
509  delete this;
510  }
511  }
512  }
513 }
514 
516 {
517  if( !v ) {
518  // Clear the previous handlers if present
520  _TRACE("MsqToEx(): connection " << (void*)this
521  << ": message handler " << (void*)GetHandler()
522  << " removed from CDB_Connection " << (void*)GetCDB_Connection());
523  m_msgToEx = false;
524  }
525  else {
527  _TRACE("MsqToEx(): connection " << (void*)this
528  << ": message handler " << (void*)GetHandler()
529  << " installed on CDB_Connection " << (void*)GetCDB_Connection());
530  m_msgToEx = true;
531  }
532 }
533 
535 {
536  if (m_multiExH.Empty()) {
538  }
539  return m_multiExH.GetPointerOrNull();
540 }
541 
543 {
544  return GetHandler()->GetMultiEx();
545 }
546 
548 {
551  h.HandleIt(GetHandler()->GetMultiEx());
552  // Install new handler
554 /*
555  GetCDB_Connection()->PopMsgHandler(GetHandler());
556  delete m_multiExH;
557  m_multiExH = new CToMultiExHandler;
558  GetCDB_Connection()->PushMsgHandler(GetHandler());
559 */
561 }
562 
563 /*
564 void CConnection::DeleteConn(CConnection* conn)
565 {
566  if( m_connCounter > 1) {
567  delete conn;
568  --m_connCounter;
569  }
570 
571  _TRACE("Connection deleted, total left: " << m_connCounter);
572  return;
573 }
574 */
575 
577 {
578  static TDbapi_SetXactAbort sx_set_xact_abort;
579 
580  if (sx_set_xact_abort.Get()) {
581  // Note: SET XACT_ABORT ON is supported by MS SQL and is not supported
582  // by Sybase. So we first check the server brand.
583  bool is_ms_sql = false;
584 
585  unique_ptr<CDB_LangCmd> cmd(m_connection->LangCmd("SELECT @@version"));
586  cmd->Send();
587 
588  while (cmd->HasMoreResults()) {
589  unique_ptr<CDB_Result> result;
590  try {
591  // Note: in case of connecting to PSOS cmd->HasFailed() returns
592  // false however cmd->Result() generates an exception. The way
593  // to identify an error in the command execution without an
594  // exception was NOT found so here are try-catch blocks.
595  // The error code was picked as the one used in PSOS scenario
596  // at lang_cmd.cpp:698 (DATABASE_DRIVER_WARNING macro).
597  result.reset(cmd->Result());
598  } catch (const CDB_ClientEx & ex) {
599  if (ex.GetDBErrCode() == 120016)
600  return;
601  throw;
602  }
603 
604  if (!result.get())
605  continue;
606 
607  while (result->Fetch()) {
609  result->GetItem(&value);
610  if (NStr::Find(value.AsString(),
611  "Microsoft", NStr::eNocase) != NPOS)
612  is_ms_sql = true;
613  }
614  }
615 
616  if (is_ms_sql) {
617  unique_ptr<CDB_LangCmd> xact_cmd(
618  m_connection->LangCmd("SET XACT_ABORT ON"));
619  xact_cmd->Send();
620 
621  // Dump results triggers calling the Check() method a few levels
622  // below which properly checks if there were problems during the
623  // command execution. If so then an exception is thrown.
624  xact_cmd->DumpResults();
625  }
626  }
627 }
628 
#define false
Definition: bool.h:36
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:152
CConnection * Clone()
Definition: conn_impl.cpp:245
virtual string GetErrorInfo()
Returns all error messages as a single string.
Definition: conn_impl.cpp:547
virtual void Action(const CDbapiEvent &e)
Definition: conn_impl.cpp:457
virtual CDB_MultiEx * GetErrorAsEx()
Returns all error messages as a CDB_MultiEx object.
Definition: conn_impl.cpp:542
bool m_forceSingle
Definition: conn_impl.hpp:151
virtual ICursor * GetCursor(const string &name, const string &sql, int batchSize)
Get cursor object.
Definition: conn_impl.cpp:368
CDB_Connection * m_connection
Definition: conn_impl.hpp:147
virtual ICallableStatement * PrepareCall(const string &proc)
Get callable statement object for stored procedures.
Definition: conn_impl.cpp:422
virtual void SetMode(EConnMode mode)
Set connection mode.
Definition: conn_impl.cpp:79
virtual void SetDatabase(const string &name)
Set current database.
Definition: conn_impl.cpp:180
virtual ICursor * CreateCursor(const string &name, const string &sql, int batchSize)
Get cursor object.
Definition: conn_impl.cpp:433
virtual void Abort()
Abort connection.
Definition: conn_impl.cpp:308
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:515
virtual ICallableStatement * GetCallableStatement(const string &proc)
Get callable statement object for stored procedures.
Definition: conn_impl.cpp:346
virtual IConnection * CloneConnection(EOwnership ownership)
Clone existing connection.
Definition: conn_impl.cpp:258
virtual IDataSource * GetDataSource()
Get parent datasource object.
Definition: conn_impl.cpp:89
EOwnership m_ownership
Definition: conn_impl.hpp:155
virtual unsigned int GetModeMask()
Get mode mask.
Definition: conn_impl.cpp:94
unsigned int m_modeMask
Definition: conn_impl.hpp:150
class CDataSource * m_ds
Definition: conn_impl.hpp:146
void SetDbName(const string &name, CDB_Connection *conn=0)
Definition: conn_impl.cpp:195
virtual IBulkInsert * CreateBulkInsert(const string &table_name)
Create bulk insert object.
Definition: conn_impl.cpp:446
virtual void Close()
Close connecti.
Definition: conn_impl.cpp:303
virtual IStatement * GetStatement()
Get statement object for regular SQL queries.
Definition: conn_impl.cpp:331
bool m_msgToEx
Definition: conn_impl.hpp:153
CDB_Connection * CloneCDB_Conn()
Definition: conn_impl.cpp:206
virtual ~CConnection()
Definition: conn_impl.cpp:164
CConnection * GetAuxConn()
Definition: conn_impl.cpp:279
virtual void SetTimeout(size_t nof_secs)
Set connection timeout.
Definition: conn_impl.cpp:314
virtual void ResetMode(EConnMode mode)
Reset connection mode.
Definition: conn_impl.cpp:84
void FreeResources()
Definition: conn_impl.cpp:324
virtual void ForceSingle(bool enable)
Force single connection mode, default false.
Definition: conn_impl.cpp:99
virtual IBulkInsert * GetBulkInsert(const string &table_name)
Create bulk insert object.
Definition: conn_impl.cpp:389
virtual IStatement * CreateStatement()
Get statement object for regular SQL queries.
Definition: conn_impl.cpp:410
CConnection(CDataSource *ds, EOwnership ownership)
Definition: conn_impl.cpp:60
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:143
virtual string GetDatabase()
Get current database.
Definition: conn_impl.cpp:185
virtual CDB_Connection * GetCDB_Connection()
Returns the internal driver connection object.
Definition: conn_impl.cpp:105
bool m_connUsed
Definition: conn_impl.hpp:149
virtual void SetCancelTimeout(size_t nof_secs)
Set timeout for command cancellation and connection closing.
Definition: conn_impl.cpp:319
int m_connCounter
Definition: conn_impl.hpp:148
virtual bool IsAlive()
Check if the connection is alive.
Definition: conn_impl.cpp:190
virtual void Connect(const string &user, const string &password, const string &server, const string &database=kEmptyStr)
Connect to a database.
Definition: conn_impl.cpp:111
string m_database
Definition: conn_impl.hpp:145
void x_SendXactAbort(void)
Definition: conn_impl.cpp:576
class CToMultiExHandler * GetHandler()
Definition: conn_impl.cpp:534
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
IBulkInsert –.
Definition: dbapi.hpp:665
ICallableStatement –.
Definition: dbapi.hpp:510
ICursor –.
Definition: dbapi.hpp:564
IDataSource –.
Definition: dbapi.hpp:963
char value[7]
Definition: config.c:431
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
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
#define CHECK_NCBI_DBAPI(failed, message)
Definition: dbexception.hpp:62
std::ofstream out("events_result.xml")
main entry point for tests
@ eNoOwnership
No ownership is assumed.
Definition: ncbi_types.h:135
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
EConnMode
Which connection mode.
Definition: dbapi.hpp:731
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 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:2887
@ eNocase
Case insensitive compare.
Definition: ncbistr.hpp:1206
enum ENcbiOwnership EOwnership
Ownership relations between objects.
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
constexpr bool empty(list< Ts... >) noexcept
mdb_mode_t mode
Definition: lmdb++.h:38
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
else result
Definition: token2.c:20
Modified on Tue Nov 28 02:22:37 2023 by modify_doxy.py rev. 669887