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

Go to the SVN repository for this file.

1 /* $Id: public.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  * Author: Vladimir Soussov
27  *
28  * File Description: Data Server public interfaces
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 #include <dbapi/driver/public.hpp>
37 #include <dbapi/error_codes.hpp>
38 
39 #ifdef NCBI_OS_MSWIN
40 # include <winsock2.h>
41 #elif !defined(NCBI_OS_SOLARIS)
42 # include <sys/fcntl.h>
43 # include <sys/types.h>
44 # include <sys/socket.h>
45 #endif
46 
47 #define NCBI_USE_ERRCODE_X Dbapi_DataServer
48 
49 
51 
52 
53 
54 #ifdef _DEBUG
55 static void s_TraceParams(const CDBParams& params,
56  const CDiagCompileInfo& info) {
57  if (dynamic_cast<const impl::CCachedRowInfo*>(&params)) {
58  return;
59  }
60  for (unsigned int i = 0, n = params.GetNum(); i < n; ++i) {
61  const CDB_Object* obj = params.GetValue(i);
62  const string& name = params.GetName(i);
63  string value = obj ? obj->GetLogString() : string("(null)");
64  if (name.empty()) { // insertion, typically bulk
66  << "Column #" << (i + 1) << " = " << value
67  << Endm;
68  } else {
70  << "Parameter #" << (i + 1) << " (" << name << ") = " << value
71  << Endm;
72  }
73  }
74 }
75 // Cite caller.
76 # define TRACE_PARAMS(params) s_TraceParams(params, DIAG_COMPILE_INFO)
77 #else
78 # define TRACE_PARAMS(params) ((void)0)
79 #endif
80 
81 
82 
83 ////////////////////////////////////////////////////////////////////////////
84 // CDBParamVariant::
85 //
86 inline
87 unsigned int ConvertI2UI(int value)
88 {
89  CHECK_DRIVER_ERROR( (value < 0), "Negative parameter's position not allowed.", 200001 );
90 
91  return static_cast<unsigned int>(value);
92 }
93 
95 : m_IsPositional(true)
96 , m_Pos(ConvertI2UI(pos))
97 {
98 }
99 
100 
102 : m_IsPositional(true)
103 , m_Pos(pos)
104 {
105 }
106 
107 
109 : m_IsPositional(false)
110 , m_Pos(0)
111 , m_Name(MakeName(name, m_Format))
112 {
113 }
114 
116 : m_IsPositional(false)
117 , m_Pos(0)
118 , m_Name(MakeName(name, m_Format))
119 {
120 }
121 
122 
124 {
125 }
126 
127 // Not finished yet ...
128 string
130 {
131  if (format != GetFormat()) {
132  switch (format) {
133  case ePlainName:
134  return MakePlainName(m_Name);
135  case eQMarkName: // '...WHERE name=?'
136  return "?";
137  case eNumericName: // '...WHERE name=:1'
138  case eNamedName: // '...WHERE name=:name'
139  return ':' + MakePlainName(m_Name);
140  case eFormatName: // ANSI C printf format codes, e.g. '...WHERE name=%s'
141  return '%' + MakePlainName(m_Name);
142  case eSQLServerName: // '...WHERE name=@name'
143  return '@' + MakePlainName(m_Name);
144  }
145  }
146 
147  return m_Name;
148 }
149 
150 
153 {
154  // Do not make copy of name to process it ...
155 
156  CTempString new_name;
157  CTempString::const_iterator begin_str = NULL, c = name.data();
158 
159  format = ePlainName;
160 
161  for (; c != NULL && c != name.end(); ++c) {
162  char ch = *c;
163  if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') {
164  if (begin_str == NULL) {
165  // Remove whitespace ...
166  continue;
167  } else {
168  // Look forward for non-space characters.
169  bool space_chars_only = true;
170  for (const char* tc = c; tc != NULL && *tc != '\0'; ++tc) {
171  char tch = *tc;
172  if (tch == ' ' || tch == '\t' || tch == '\n' || tch == '\r') {
173  continue;
174  } else {
175  space_chars_only = false;
176  break;
177  }
178  }
179 
180  if (space_chars_only) {
181  // Remove trailing whitespace ...
182  break;
183  }
184  }
185  }
186  // Check for leading symbol ...
187  if (begin_str == NULL) {
188  begin_str = c;
189 
190  switch (ch) {
191  case '?' :
192  format = eQMarkName;
193  break;
194  case ':' :
195  if (*(c + 1)) {
196  if (isdigit(*(c + 1))) {
198  } else {
199  format = eNamedName;
200  }
201  } else {
202  DATABASE_DRIVER_ERROR("Invalid parameter format: "
203  + string(name), 1);
204  }
205  break;
206  case '@' :
208  break;
209  case '%' :
211  break;
212  case '$' :
213  // !!!!
215  break;
216  }
217  }
218  }
219 
220  if (begin_str != NULL) {
221  new_name.assign(begin_str, c - begin_str);
222  }
223 
224  return new_name;
225 }
226 
227 
229 {
230  // Do not make copy of name to process it ...
231 
232  CTempString plain_name;
233  CTempString::const_iterator begin_str = NULL, c = name.data();
234 
235  for (; c != NULL && c != name.end(); ++c) {
236  char ch = *c;
237  if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') {
238  if (begin_str == NULL) {
239  // Remove whitespaces ...
240  continue;
241  } else {
242  // Look forward for non-space characters.
243  bool space_chars_only = true;
244  for (const char* tc = c; tc != NULL && *tc != '\0'; ++tc) {
245  char tch = *tc;
246  if (tch == ' ' || tch == '\t' || tch == '\n' || tch == '\r') {
247  continue;
248  } else {
249  space_chars_only = false;
250  break;
251  }
252  }
253 
254  if (space_chars_only) {
255  // Remove trailing whitespace ...
256  break;
257  }
258  }
259  }
260  // Check for leading symbol ...
261  if (begin_str == NULL) {
262  begin_str = c;
263  if (ch == ':' || ch == '@' || ch == '$' || ch == '%') {
264  // Skip leading symbol ...
265  ++begin_str;
266  }
267  }
268  }
269 
270  if (begin_str != NULL) {
271  plain_name.assign(begin_str, c - begin_str);
272  }
273 
274  return plain_name;
275 }
276 
277 
278 ////////////////////////////////////////////////////////////////////////////
279 // CCDB_Connection::
280 //
281 
283  : m_ConnImpl(c), m_HasTransaction(false)
284 {
285  CHECK_DRIVER_ERROR( !c, "No valid connection provided", 200001 );
286 
287  m_ConnImpl->AttachTo(this);
288  m_ConnImpl->SetResultProcessor(0); // to clean up the result processor if any
289 }
290 
291 
293 {
294  if (m_ConnImpl == NULL || !m_ConnImpl->IsAlive()) {
295  return false;
296  } else {
297  return x_IsAlive();
298  }
299 }
300 
302 {
303  // Try to confirm that the network connection hasn't closed.
304  // (Done only when no separate network library is necessary.)
305  // XXX - consider caching GetLowLevelHandle result, or at least
306  // availability.
307 #ifndef NCBI_OS_SOLARIS
308  try {
310  char c;
311 # ifdef NCBI_OS_UNIX
312  // On Windows, the non-blocking flag is write-only(!); leave it
313  // alone, since only the ftds driver implements
314  // GetLowLevelHandle, and FreeTDS normally enables non-blocking
315  // mode itself. (It does so on Unix too, but explicitly
316  // restoring settings is still best practice.)
317  int orig_flags = fcntl(s, F_GETFL, 0);
318  fcntl(s, F_SETFL, orig_flags | O_NONBLOCK);
319 # endif
320  int n = recv(s, &c, 1, MSG_PEEK);
321 # ifdef NCBI_OS_UNIX
322  if ((orig_flags & O_NONBLOCK) != O_NONBLOCK) {
323  fcntl(s, F_SETFL, orig_flags);
324  }
325 # endif
326  if (n > 0) {
327  return true; // open, with unread data available
328  } else if (n == 0) {
329  return false; // closed
330  } else {
331 # ifdef NCBI_OS_MSWIN
332  return WSAGetLastError() == WSAEWOULDBLOCK;
333 # else
334  switch (errno) {
335  case EAGAIN:
336 # if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
337  case EWOULDBLOCK:
338 # endif
339  return true; // open, but no data immediately available
340  default:
341  return false; // something else is wrong
342  }
343 # endif
344  }
345  } catch (CDB_Exception&) { // Presumably unimplemented
346  return true;
347  }
348 #endif
349  return true;
350 }
351 
352 #define CHECK_CONNECTION( conn ) \
353  CHECK_DRIVER_WARNING( !conn, "Connection has been closed", 200002 )
354 
355 CDB_LangCmd* CDB_Connection::LangCmd(const string& lang_query)
356 {
358  _TRACE("Sending SQL: " << lang_query);
359  return m_ConnImpl->LangCmd(lang_query);
360 }
361 
362 CDB_RPCCmd* CDB_Connection::RPC(const string& rpc_name)
363 {
365  // _TRACE-d in CDB_RPCCmd::Send, which performs the actual I/O.
366  return m_ConnImpl->RPC(rpc_name);
367 }
368 
370 {
372  _TRACE("Performing bulk insertion into " << table_name);
373  return m_ConnImpl->BCPIn(table_name);
374 }
375 
376 CDB_CursorCmd* CDB_Connection::Cursor(const string& cursor_name,
377  const string& query,
378  unsigned int batch_size)
379 {
381  _TRACE("Opening cursor for " << query);
382  return m_ConnImpl->Cursor(cursor_name, query, batch_size);
383 }
384 
386  size_t data_size,
387  bool log_it,
388  bool dump_results)
389 {
391  _TRACE("Sending " << data_size << " byte(s) of data");
392  return m_ConnImpl->SendDataCmd(desc, data_size, log_it, dump_results);
393 }
394 
396  bool log_it)
397 {
399  _TRACE("Sending " << lob.Size() << " byte(s) of data");
400  return m_ConnImpl->SendData(desc, lob, log_it);
401 }
402 
403 void CDB_Connection::SetDatabaseName(const string& name)
404 {
405  if (name.empty()) {
406  return;
407  }
408 
410  _TRACE("Now using database " << name);
412 }
413 
415 {
417  return m_ConnImpl->Refresh() && x_IsAlive();
418 }
419 
420 const string& CDB_Connection::ServerName() const
421 {
423  return m_ConnImpl->ServerName();
424 }
425 
427 {
429  return m_ConnImpl->Host();
430 }
431 
433 {
435  return m_ConnImpl->Port();
436 }
437 
438 const string& CDB_Connection::UserName() const
439 {
441  return m_ConnImpl->UserName();
442 }
443 
444 const string& CDB_Connection::Password() const
445 {
447  return m_ConnImpl->Password();
448 }
449 
450 const string& CDB_Connection::DatabaseName() const
451 {
453  return m_ConnImpl->GetDatabaseName();
454 }
455 
457 {
459  return m_ConnImpl->ConnectMode();
460 }
461 
463 {
465  return m_ConnImpl->IsReusable();
466 }
467 
468 unsigned int CDB_Connection::GetReuseCount() const
469 {
471  return m_ConnImpl->GetReuseCount();
472 }
473 
474 const string& CDB_Connection::PoolName() const
475 {
477  return m_ConnImpl->PoolName();
478 }
479 
481 {
483  return m_ConnImpl->Context();
484 }
485 
487  EOwnership ownership)
488 {
490  m_ConnImpl->PushMsgHandler(h, ownership);
491 }
492 
494 {
497 }
498 
501 {
503 }
504 
506 {
507  try {
508  if ( m_ConnImpl ) {
509  Close();
510  }
511  }
513 }
514 
515 
517 {
519  if (m_ConnImpl->Abort()) {
520  Close();
521  return true;
522  }
523  return false;
524 }
525 
526 
528 {
530  try {
533  unique_ptr<CDB_LangCmd> lcmd(LangCmd("IF @@TRANCOUNT > 0 ROLLBACK"));
534  lcmd->Send();
535  lcmd->DumpResults();
536  }
537  } catch (CDB_Exception&) {
538  }
539  m_ConnImpl->Release();
540  m_ConnImpl = NULL;
541  return true;
542 }
543 
544 void CDB_Connection::SetTimeout(size_t nof_secs)
545 {
547  m_ConnImpl->SetTimeout(nof_secs);
548 }
549 
550 void CDB_Connection::SetCancelTimeout(size_t nof_secs)
551 {
553  m_ConnImpl->SetCancelTimeout(nof_secs);
554 }
555 
556 size_t CDB_Connection::GetTimeout(void) const
557 {
559  return m_ConnImpl->GetTimeout();
560 }
561 
563 {
565  return m_ConnImpl->GetCancelTimeout();
566 }
567 
569 {
571  return *m_ConnImpl;
572 }
573 
575 {
577  return m_ConnImpl->GetDriverName();
578 }
579 
581 {
583  return m_ConnImpl->GetVersionString();
584 }
585 
587 {
590 }
591 
592 ////////////////////////////////////////////////////////////////////////////
593 // CDB_Result::
594 //
595 
597  m_ResImpl(r)
598 {
599  CHECK_DRIVER_ERROR( !m_ResImpl, "No valid result provided", 200004 );
600 
601  m_ResImpl->AttachTo(this);
602 }
603 
604 
605 #define CHECK_RESULT( res ) \
606  CHECK_DRIVER_WARNING( !res, "This result is not available anymore", 200003 )
607 
608 
610 {
612  return GetIResult().ResultType();
613 }
614 
615 
617 {
619  return GetIResult().GetDefineParams();
620 }
621 
622 
623 unsigned int CDB_Result::NofItems() const
624 {
626  return GetIResult().GetDefineParams().GetNum();
627 }
628 
629 const char*
630 CDB_Result::ItemName(unsigned int item_num) const
631 {
633 
634  const string& name = GetIResult().GetDefineParams().GetName(item_num);
635 
636  if (!name.empty()) {
637  return name.c_str();
638  }
639 
640  return NULL;
641 }
642 
643 size_t CDB_Result::ItemMaxSize(unsigned int item_num) const
644 {
646  return GetIResult().GetDefineParams().GetMaxSize(item_num);
647 }
648 
649 EDB_Type CDB_Result::ItemDataType(unsigned int item_num) const
650 {
652  return GetIResult().GetDefineParams().GetDataType(item_num);
653 }
654 
656 {
657  // An exception should be thrown from this place. We cannot omit this exception
658  // because it is expected by ftds driver in CursorResult::Fetch.
660 // if ( !GetIResultPtr() ) {
661 // return false;
662 // }
663  return GetIResult().Fetch();
664 }
665 
667 {
669  return GetIResult().CurrentItemNo();
670 }
671 
673 {
675  return GetIResult().GetColumnNum();
676 }
677 
679 {
681  return GetIResult().GetItem(item_buf, policy);
682 }
683 
684 size_t CDB_Result::ReadItem(void* buffer, size_t buffer_size, bool* is_null)
685 {
687  return GetIResult().ReadItem(buffer, buffer_size, is_null);
688 }
689 
691 {
693  return GetIResult().GetBlobDescriptor();
694 }
695 
697 {
699  return GetIResult().SkipItem();
700 }
701 
702 
704 {
705  try {
706  if ( GetIResultPtr() ) {
707  GetIResult().Release();
708  }
709  }
711 }
712 
713 
714 
715 ////////////////////////////////////////////////////////////////////////////
716 // CDB_LangCmd::
717 //
718 
720 {
721  CHECK_DRIVER_ERROR( !c, "No valid command provided", 200004 );
722 
723  m_CmdImpl = c;
724  m_CmdImpl->AttachTo(this);
725 }
726 
727 
728 #define CHECK_COMMAND( cmd ) \
729  CHECK_DRIVER_WARNING( !cmd, "This command cannot be used anymore", 200005 )
730 
731 
732 bool CDB_LangCmd::More(const string& query_text)
733 {
735  return m_CmdImpl->More(query_text);
736 }
737 
739 {
741  return m_CmdImpl->GetBindParams();
742 }
743 
744 
746 {
748  return m_CmdImpl->GetDefineParams();
749 }
750 
752 {
756  return m_CmdImpl->Send();
757 }
758 
760 {
762  return m_CmdImpl->WasSent();
763 }
764 
766 {
768  return m_CmdImpl->Cancel();
769 }
770 
772 {
774  return m_CmdImpl->WasCanceled();
775 }
776 
778 {
780  return m_CmdImpl->Result();
781 }
782 
784 {
786  return m_CmdImpl->HasMoreResults();
787 }
788 
790 {
792  return m_CmdImpl->HasFailed();
793 }
794 
796 {
798  return m_CmdImpl->RowCount();
799 }
800 
802 {
805 }
806 
808 {
809  try {
810  if ( m_CmdImpl ) {
811  m_CmdImpl->Release();
812  }
813  }
815 }
816 
817 
818 
819 /////////////////////////////////////////////////////////////////////////////
820 // CDB_RPCCmd::
821 //
822 
824 {
825  CHECK_DRIVER_ERROR( !c, "No valid command provided", 200006 );
826  m_CmdImpl = c;
827  m_CmdImpl->AttachTo(this);
828 }
829 
830 
832 {
834  return m_CmdImpl->GetBindParams();
835 }
836 
837 
839 {
841  return m_CmdImpl->GetDefineParams();
842 }
843 
844 
846 {
848  _TRACE("Calling remote procedure " << GetProcName());
851  return m_CmdImpl->Send();
852 }
853 
855 {
857  return m_CmdImpl->WasSent();
858 }
859 
861 {
863  return m_CmdImpl->Cancel();
864 }
865 
867 {
869  return m_CmdImpl->WasCanceled();
870 }
871 
873 {
875  return m_CmdImpl->Result();
876 }
877 
879 {
881  return m_CmdImpl->HasMoreResults();
882 }
883 
885 {
887  return m_CmdImpl->HasFailed();
888 }
889 
891 {
893  return m_CmdImpl->RowCount();
894 }
895 
897 {
900 }
901 
902 void CDB_RPCCmd::SetRecompile(bool recompile)
903 {
905  m_CmdImpl->SetRecompile(recompile);
906 }
907 
908 const string& CDB_RPCCmd::GetProcName(void) const
909 {
911  return m_CmdImpl->GetQuery();
912 }
913 
914 
916 {
917  try {
918  if ( m_CmdImpl ) {
919  m_CmdImpl->Release();
920  }
921  }
923 }
924 
925 
926 
927 ////////////////////////////////////////////////////////////////////////////
928 // CDB_BCPInCmd::
929 //
930 
932 {
933  CHECK_DRIVER_ERROR( !c, "No valid command provided", 200007 );
934 
935  m_CmdImpl = c;
936  m_CmdImpl->AttachTo(this);
937 }
938 
939 
941 {
943  m_CmdImpl->SetHints(hints);
944 }
945 
946 
947 void CDB_BCPInCmd::AddHint(EBCP_Hints hint, unsigned int value /* = 0 */)
948 {
950  m_CmdImpl->AddHint(hint, value);
951 }
952 
953 
955 {
958 }
959 
960 
962 {
964  return m_CmdImpl->GetBindParams();
965 }
966 
967 
968 bool CDB_BCPInCmd::Bind(unsigned int column_num, CDB_Object* value)
969 {
970  GetBindParams().Bind(column_num, value);
971  return true;
972 }
973 
974 
976 {
978  if (m_CmdImpl->m_RowsSent++ == 0) {
980  } else if (m_CmdImpl->m_AtStartOfBatch) {
982  }
983  m_CmdImpl->m_AtStartOfBatch = false;
985  return m_CmdImpl->Send();
986 }
987 
989 {
991  return m_CmdImpl->Cancel();
992 }
993 
995 {
997  if (m_CmdImpl->m_BatchesSent++ == 0 && m_CmdImpl->m_RowsSent > 1) {
998  _TRACE("Sent a batch of " << m_CmdImpl->GetRowsInCurrentBatch()
999  << " rows");
1000  }
1001  m_CmdImpl->m_AtStartOfBatch = true;
1002  return m_CmdImpl->CommitBCPTrans();
1003 }
1004 
1006 {
1008  if (m_CmdImpl->m_BatchesSent > 1) {
1009  _TRACE("Sent " << m_CmdImpl->m_RowsSent << " rows, in "
1010  << m_CmdImpl->m_BatchesSent << " batches");
1011  }
1012  return m_CmdImpl->EndBCP();
1013 }
1014 
1015 
1017 {
1018  try {
1019  if ( m_CmdImpl ) {
1020  m_CmdImpl->Release();
1021  }
1022  }
1024 }
1025 
1026 
1027 
1028 /////////////////////////////////////////////////////////////////////////////
1029 // CDB_CursorCmd::
1030 //
1031 
1033 {
1034  CHECK_DRIVER_ERROR( !c, "No valid command provided", 200006 );
1035  m_CmdImpl = c;
1036  m_CmdImpl->AttachTo(this);
1037 }
1038 
1039 
1041 {
1043  return m_CmdImpl->GetBindParams();
1044 }
1045 
1046 
1048 {
1050  return m_CmdImpl->GetDefineParams();
1051 }
1052 
1053 
1055 {
1058  return m_CmdImpl->OpenCursor();
1059 }
1060 
1061 bool CDB_CursorCmd::Update(const string& table_name, const string& upd_query)
1062 {
1065  return m_CmdImpl->Update(table_name, upd_query);
1066 }
1067 
1068 bool CDB_CursorCmd::UpdateBlob(unsigned int item_num, CDB_Stream& data,
1069  bool log_it)
1070 {
1072  return m_CmdImpl->UpdateBlob(item_num, data, log_it);
1073 }
1074 
1076  size_t size,
1077  bool log_it,
1078  bool dump_results)
1079 {
1081  return m_CmdImpl->SendDataCmd(item_num, size, log_it, dump_results);
1082 }
1083 
1084 
1086 {
1088  return m_CmdImpl->Delete(table_name);
1089 }
1090 
1092 {
1094  return m_CmdImpl->RowCount();
1095 }
1096 
1098 {
1100  return m_CmdImpl->CloseCursor();
1101 }
1102 
1103 
1105 {
1106  try {
1107  if ( m_CmdImpl ) {
1108  m_CmdImpl->Release();
1109  }
1110  }
1112 }
1113 
1114 
1115 
1116 /////////////////////////////////////////////////////////////////////////////
1117 // CDB_SendDataCmd::
1118 //
1119 
1121 {
1122  CHECK_DRIVER_ERROR( !c, "No valid command provided", 200006 );
1123 
1124  m_CmdImpl = c;
1125  m_CmdImpl->AttachTo(this);
1126 }
1127 
1128 
1129 size_t CDB_SendDataCmd::SendChunk(const void* pChunk, size_t nofBytes)
1130 {
1131  CHECK_DRIVER_WARNING( !m_CmdImpl, "This command cannot be used anymore", 200005 );
1132 
1133  return m_CmdImpl->SendChunk(pChunk, nofBytes);
1134 }
1135 
1136 
1138 {
1139  CHECK_DRIVER_WARNING( !m_CmdImpl, "This command cannot be used anymore", 200005 );
1140 
1141  return m_CmdImpl->Cancel();
1142 }
1143 
1145 {
1147  return m_CmdImpl->Result();
1148 }
1149 
1151 {
1153  return m_CmdImpl->HasMoreResults();
1154 }
1155 
1157 {
1160 }
1161 
1163 {
1164  try {
1165  if ( m_CmdImpl ) {
1166  m_CmdImpl->Release();
1167  }
1168  }
1170 }
1171 
1172 
1173 
1174 /////////////////////////////////////////////////////////////////////////////
1175 // CDB_BlobDescriptor::
1176 //
1177 
1179  const string& column_name,
1180  const string& search_conditions,
1181  ETDescriptorType column_type,
1182  ETriState has_legacy_type)
1183 : m_TableName(table_name)
1184 , m_ColumnName(column_name)
1185 , m_SearchConditions(search_conditions)
1186 , m_ColumnType(column_type)
1187 , m_HasLegacyType(has_legacy_type)
1188 {
1189 }
1190 
1192 {
1193 }
1194 
1196 {
1197  return 0;
1198 }
1199 
1200 
1201 
1202 /////////////////////////////////////////////////////////////////////////////
1203 // CDB_ResultProcessor::
1204 //
1205 
1207  m_Con(NULL),
1208  m_Prev(NULL),
1209  m_Next(NULL)
1210 {
1211  SetConn(c);
1212 }
1213 
1215 {
1216  while (res.Fetch()) // fetch and forget
1217  continue;
1218 }
1219 
1220 
1222 {
1223  try {
1224  if ( m_Con ) {
1226  }
1227 
1228  if(m_Prev) {
1229  m_Prev->m_Next = m_Next;
1230  }
1231 
1232  if(m_Next) {
1233  m_Next->m_Prev = m_Prev;
1234  }
1235  }
1237 }
1238 
1240 {
1241  // Clear previously used connection ...
1242  if ( m_Con ) {
1244  }
1245 
1246  m_Con = c;
1247 
1248  if ( m_Con ) {
1249  _ASSERT(m_Prev == NULL);
1250  m_Prev = m_Con->SetResultProcessor(this);
1251 
1252  if (m_Prev) {
1253  _ASSERT(m_Prev->m_Next == NULL);
1254  m_Prev->m_Next = this;
1255  }
1256  }
1257 }
1258 
1260 {
1261  m_Con = NULL;
1262 }
1263 
1264 
1265 ////////////////////////////////////////////////////////////////////////////////
1267 : m_Abort(true)
1268 , m_Conn(subject.m_Connection)
1269 , m_TranCount(0)
1270 {
1271  BeginTransaction();
1273  if (m_TranCount > 1) {
1274  m_SavepointName = "ncbi_dbapi_txn_"
1275  + NStr::NumericToString(reinterpret_cast<intptr_t>(this), 0, 16);
1276  unique_ptr<CDB_LangCmd> auto_stmt
1277  (m_Conn.LangCmd("SAVE TRANSACTION " + m_SavepointName));
1278  auto_stmt->Send();
1279  auto_stmt->DumpResults();
1280  }
1281 }
1282 
1283 
1285 {
1286  try
1287  {
1288  const int curr_TranCount = GetTranCount();
1289 
1290  if (curr_TranCount >= m_TranCount) {
1291  if (curr_TranCount > m_TranCount) {
1292  // A nested transaction is started and not finished yet ...
1293  ERR_POST_X(1, Warning << "A nested transaction was started and "
1294  "it is not finished yet.");
1295  }
1296 
1297  // Assume that we are on the same level of transaction nesting.
1298  if(m_Abort) {
1299  Rollback();
1300  } else {
1301  Commit();
1302  }
1303  }
1304  m_Conn.m_HasTransaction = (curr_TranCount <= 1);
1305 
1306  // Skip commit/rollback if this transaction was previously
1307  // explicitly finished ...
1308  }
1310 }
1311 
1312 void
1314 {
1315  m_Conn.m_HasTransaction = true;
1316  unique_ptr<CDB_LangCmd> auto_stmt(m_Conn.LangCmd("BEGIN TRANSACTION"));
1317  auto_stmt->Send();
1318  auto_stmt->DumpResults();
1319 }
1320 
1321 
1322 void
1324 {
1325  unique_ptr<CDB_LangCmd> auto_stmt(m_Conn.LangCmd("COMMIT"));
1326  auto_stmt->Send();
1327  auto_stmt->DumpResults();
1328 }
1329 
1330 
1331 void
1333 {
1334  unique_ptr<CDB_LangCmd> auto_stmt
1335  (m_Conn.LangCmd("ROLLBACK TRANSACTION " + m_SavepointName));
1336  auto_stmt->Send();
1337  auto_stmt->DumpResults();
1338  if (m_SavepointName.empty()) {
1339  _ASSERT(m_TranCount == 1);
1340  } else {
1341  // Formally unwind via an empty commit, as a rollback would
1342  // also cancel outer transactions.
1343  Commit();
1344  }
1345 }
1346 
1347 
1348 int
1350 {
1351  int result = 0;
1352  unique_ptr<CDB_LangCmd> auto_stmt(m_Conn.LangCmd("SELECT @@trancount as tc"));
1353 
1354  if (auto_stmt->Send()) {
1355  while(auto_stmt->HasMoreResults()) {
1356  unique_ptr<CDB_Result> rs(auto_stmt->Result());
1357 
1358  if (rs.get() == NULL) {
1359  continue;
1360  }
1361 
1362  if (rs->ResultType() != eDB_RowResult) {
1363  continue;
1364  }
1365 
1366  if (rs->Fetch()) {
1367  CDB_Int tran_count;
1368  rs->GetItem(&tran_count);
1369  result = tran_count.Value();
1370  }
1371 
1372  while(rs->Fetch()) {
1373  }
1374  }
1375  }
1376 
1377  return result;
1378 }
1379 
1380 
1382 
1383 
Helper class to allow safe initialization from higher-layer objects.
Definition: public.hpp:1058
CDBParams.
Definition: interfaces.hpp:154
CDB_Exception –.
Definition: exception.hpp:118
Incapsulate compile time information such as __FILE__, __LINE__, NCBI_MODULE, current function.
Definition: ncbidiag.hpp:65
CNcbiDiag –.
Definition: ncbidiag.hpp:924
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
I_BlobDescriptor::
Definition: interfaces.hpp:369
I_ConnectionExtra.
virtual CDBParams & GetDefineParams(void)
Get meta-information about defined parameters.
const string & GetQuery(void) const
virtual CDBParams & GetBindParams(void)
Binding.
bool WasCanceled(void) const
unsigned int m_RowsSentAtBatchStart
virtual bool Update(const string &table_name, const string &upd_query)
Update the last fetched row.
virtual bool CommitBCPTrans(void)
Complete batch – to store all rows transferred by far in this batch into the table.
void SetRecompile(bool recompile=true)
Set the "recompile before execute" flag for the stored proc.
virtual void AddOrderHint(CTempString columns)
Add "ORDER" hint.
virtual CDB_Result * Result(void)
Get result set.
virtual void AddHint(CDB_BCPInCmd::EBCP_Hints hint, unsigned int value)
Add hint with value.
virtual bool HasFailed(void) const
virtual void SetHints(CTempString hints)
Set hints by one call.
void DumpResults(void)
Dump the results of the command if result processor is installed for this connection,...
virtual bool UpdateBlob(unsigned int item_num, CDB_Stream &data, bool log_it=true)
virtual CDB_Result * OpenCursor(void)
Open the cursor.
virtual bool EndBCP(void)
Complete the BCP and store all rows transferred in last batch into the table.
virtual CDB_SendDataCmd * SendDataCmd(unsigned int item_num, size_t size, bool log_it=true, bool dump_results=true)
void AttachTo(CDB_LangCmd *interface)
virtual bool Delete(const string &table_name)
Delete the last fetched row.
virtual bool CloseCursor(void)
Close the cursor.
void SaveInParams(void)
unsigned int m_BatchesSent
virtual bool Cancel(void)
Cancel the command execution.
unsigned int m_RowsSent
virtual bool HasMoreResults(void) const
virtual bool Send(void)
Send command to the server.
unsigned int GetRowsInCurrentBatch(void) const
bool More(const string &query_text)
Add more text to the language command.
virtual int RowCount(void) const =0
Get the number of rows affected by the command Special case: negative on error or if there is no way ...
bool WasSent(void) const
void Release(void)
virtual bool Abort(void)=0
abort the connection Attention: it is not recommended to use this method unless you absolutely have t...
virtual void SetTimeout(size_t nof_secs)=0
virtual TSockHandle GetLowLevelHandle(void) const
Get OS handle of the socket represented by the connection.
void AttachTo(CDB_Connection *interface)
virtual CDB_SendDataCmd * SendDataCmd(I_BlobDescriptor &desc, size_t data_size, bool log_it=true, bool dump_results=true)=0
"Send-data" command
virtual string GetVersionString(void) const
const string & UserName(void) const
I_DriverContext * Context(void) const
Get pointer to the driver context.
const string & GetDatabaseName(void) const
virtual CDB_RPCCmd * RPC(const string &rpc_name)=0
Remote procedure call.
CDB_ResultProcessor * SetResultProcessor(CDB_ResultProcessor *rp)
bool IsReusable(void) const
Check if this connection is a reusable one.
CDBConnParams::EServerType GetServerType(void)
unsigned int GetReuseCount(void) const
const string & Password(void) const
virtual string GetDriverName(void) const
virtual void SetCancelTimeout(size_t nof_secs)=0
virtual bool IsAlive(void)=0
Check out if connection is alive (this function doesn't ping the server, it just checks the status of...
virtual CDB_BCPInCmd * BCPIn(const string &table_name)=0
"Bulk copy in" command
const string & ServerName(void) const
Get the server name, user login name, and password.
virtual I_DriverContext::TConnectionMode ConnectMode(void) const =0
Get the bitmask for the connection mode (BCP, secure login, ...)
virtual bool Refresh(void)=0
Reset the connection to the "ready" state (cancel all active commands)
const string & PoolName(void) const
Find out which connection pool this connection belongs to.
virtual void SetDatabaseName(const string &name)
virtual bool SendData(I_BlobDescriptor &desc, CDB_Stream &lob, bool log_it=true)=0
Shortcut to send text and image to the server without using the "Send-data" command (SendDataCmd)
virtual size_t GetCancelTimeout(void) const
void PushMsgHandler(CDB_UserHandler *h, EOwnership ownership=eNoOwnership)
Put the message handler into message handler stack.
virtual CDB_CursorCmd * Cursor(const string &cursor_name, const string &query, unsigned int batch_size=1)=0
Cursor.
void PopMsgHandler(CDB_UserHandler *h)
Remove the message handler (and all above it) from the stack.
virtual size_t GetTimeout(void) const
virtual CDB_LangCmd * LangCmd(const string &lang_query)=0
These methods: LangCmd(), RPC(), BCPIn(), Cursor() and SendDataCmd() create and return a "command" ob...
virtual CDB_Object * GetItem(CDB_Object *item_buf=0, I_Result::EGetItem policy=I_Result::eAppendLOB)=0
Get a result item (you can use either GetItem or ReadItem).
virtual I_BlobDescriptor * GetBlobDescriptor(void)=0
Get a descriptor for a BLOB column (for SendData).
virtual const CDBParams & GetDefineParams(void) const
virtual int CurrentItemNo(void) const =0
Return current item number we can retrieve (0,1,...) Return "-1" if no more items left (or available)...
virtual bool SkipItem(void)=0
Skip result item.
virtual int GetColumnNum(void) const =0
Return number of columns in the recordset.
virtual size_t ReadItem(void *buffer, size_t buffer_size, bool *is_null=0)=0
Read a result item body (for BLOB columns, mostly).
void AttachTo(CDB_Result *interface)
virtual EDB_ResType ResultType(void) const =0
Get type of the result.
virtual bool Fetch(void)=0
Fetch next row.
void AttachTo(CDB_SendDataCmd *interface)
virtual size_t SendChunk(const void *pChunk, size_t nofBytes)=0
Send chunk of data to the server.
virtual bool Cancel(void)=0
void DumpResults(void)
Dump the results of the command if result processor is installed for this connection,...
virtual bool HasMoreResults(void) const
virtual CDB_Result * Result(void)
Get result set.
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
static const char table_name[]
Definition: bcp.c:249
static const column_t columns[]
Definition: utf8_2.c:22
char data[12]
Definition: iconv.c:80
ETriState
Enumeration to represent a tristate value.
Definition: ncbimisc.hpp:128
string
Definition: cgiapp.hpp:690
#define NULL
Definition: ncbistd.hpp:225
#define CHECK_DRIVER_WARNING(failed, message, err_code)
Definition: exception.hpp:768
#define DATABASE_DRIVER_ERROR(message, err_code)
Definition: exception.hpp:740
#define CHECK_DRIVER_ERROR(failed, message, err_code)
Definition: exception.hpp:765
virtual EDB_Type GetDataType(const CDBParamVariant &param) const =0
Get data type for column in the resultset.
virtual const string & GetName(const CDBParamVariant &param, CDBParamVariant::ENameFormat format=CDBParamVariant::eSQLServerName) const =0
Get name of column.
virtual size_t GetMaxSize(const CDBParamVariant &param) const =0
Get maximum size in bytes for column.
static CTempString MakeName(const CTempString &name, ENameFormat &format)
Definition: public.cpp:151
virtual unsigned int GetNum(void) const =0
Get total number of columns in resultset.
virtual CDBParams & Bind(const CDBParamVariant &param, CDB_Object *value, bool out_param=false)
This method stores pointer to data.
Definition: interfaces.cpp:150
static string MakePlainName(const CTempString &name)
Definition: public.cpp:228
ENameFormat GetFormat(void) const
Definition: interfaces.hpp:125
virtual const CDB_Object * GetValue(const CDBParamVariant &param) const =0
Get value of column.
~CDBParamVariant(void)
Definition: public.cpp:123
EDB_ResType
EDB_ResType::
Definition: interfaces.hpp:386
CDBParamVariant(int pos)
Definition: public.cpp:94
const string m_Name
Definition: interfaces.hpp:144
const string & GetName(void) const
Definition: interfaces.hpp:129
@ eDB_RowResult
Definition: interfaces.hpp:387
virtual EDB_ResType ResultType() const
Get type of the result.
Definition: public.cpp:609
impl::CResult * GetIResultPtr(void) const
Definition: public.hpp:560
virtual I_ConnectionExtra & GetExtraFeatures(void)
Get interface for extra features that could be implemented in the driver.
Definition: public.cpp:568
CDB_Connection & m_Conn
Definition: public.hpp:1091
virtual ~CDB_SendDataCmd()
Definition: public.cpp:1162
size_t GetCancelTimeout(void) const
Get timeout for command cancellation and connection closing.
Definition: public.cpp:562
virtual bool SendRow()
Send row to the server.
Definition: public.cpp:975
virtual int GetColumnNum(void) const
Return number of columns in the recordset.
Definition: public.cpp:672
virtual bool CompleteBatch()
Complete batch – to store all rows transferred by far in this batch into the table.
Definition: public.cpp:994
CAutoTrans(const CSubject &subject)
Definition: public.cpp:1266
virtual void SetRecompile(bool recompile=true)
Set the "recompile before execute" flag for the stored proc Implementation-specific.
Definition: public.cpp:902
virtual CDB_SendDataCmd * SendDataCmd(unsigned int item_num, size_t size, bool log_it=true, bool discard_results=true)
Make "send-data" command.
Definition: public.cpp:1075
virtual size_t ItemMaxSize(unsigned int item_num) const
Get size (in bytes) of a result item.
Definition: public.cpp:643
virtual int RowCount() const
Get the number of fetched rows Special case: negative on error or if there is no way that this comman...
Definition: public.cpp:1091
virtual CDB_Result * Result()
Get result set.
Definition: public.cpp:777
string m_SavepointName
Definition: public.hpp:1093
virtual CDB_BCPInCmd * BCPIn(const string &table_name)
Make "bulk copy in" command.
Definition: public.cpp:369
virtual ~CDB_ResultProcessor()
Definition: public.cpp:1221
virtual CDB_SendDataCmd * SendDataCmd(I_BlobDescriptor &desc, size_t data_size, bool log_it=true, bool discard_results=true)
Make "send-data" command.
Definition: public.cpp:385
impl::CConnection * m_ConnImpl
Definition: public.hpp:388
virtual bool WasCanceled() const
Implementation-specific.
Definition: public.cpp:866
virtual void SetCancelTimeout(size_t nof_secs)
Set timeout for command cancellation and connection closing.
Definition: public.cpp:550
virtual const string & UserName() const
Get the user user.
Definition: public.cpp:438
virtual ~CDB_Result()
Destructor.
Definition: public.cpp:703
virtual bool WasSent() const
Implementation-specific.
Definition: public.cpp:759
virtual string GetDriverName(void) const
Definition: public.cpp:574
virtual bool WasCanceled() const
Implementation-specific.
Definition: public.cpp:771
virtual CDB_Result * Result()
Get result set.
Definition: public.cpp:872
impl::CResult * m_ResImpl
Definition: public.hpp:576
impl::CResult & GetIResult(void) const
Definition: public.hpp:564
virtual bool Cancel()
Cancel the command execution.
Definition: public.cpp:860
impl::CSendDataCmd * m_CmdImpl
Definition: public.hpp:956
virtual bool HasFailed() const
Check if command has failed.
Definition: public.cpp:789
void SetConn(CDB_Connection *c)
Definition: public.cpp:1239
virtual int RowCount() const
Get the number of rows affected by the command.
Definition: public.cpp:795
virtual CDB_Result * Result()
Get result set.
Definition: public.cpp:1144
impl::CBaseCmd * m_CmdImpl
Definition: public.hpp:821
virtual bool Refresh()
Reset the connection to the "ready" state (cancel all active commands)
Definition: public.cpp:414
virtual bool UpdateBlob(unsigned int item_num, CDB_Stream &data, bool log_it=true)
Definition: public.cpp:1068
virtual CDBParams & GetDefineParams(void)
Get meta-information about defined parameters.
Definition: public.cpp:1047
virtual bool More(const string &query_text)
Add more text to the language command.
Definition: public.cpp:732
virtual ~CDB_LangCmd()
Definition: public.cpp:807
virtual CDB_Result * Open()
Open the cursor.
Definition: public.cpp:1054
virtual bool WasSent() const
Implementation-specific.
Definition: public.cpp:854
virtual Uint4 Host() const
Get the host.
Definition: public.cpp:426
void AddOrderHint(CTempString columns)
Add "ORDER" hint.
Definition: public.cpp:954
virtual bool Send()
Send command to the server.
Definition: public.cpp:845
bool m_Abort
Definition: public.hpp:1090
virtual CDBParams & GetBindParams(void)
Get meta-information about parameters.
Definition: public.cpp:831
void AddHint(EBCP_Hints hint, unsigned int value=0)
Add hint with value.
Definition: public.cpp:947
virtual CDBParams & GetBindParams(void)
Get meta-information about parameters.
Definition: public.cpp:961
virtual ~CDB_RPCCmd()
Definition: public.cpp:915
virtual ~CDB_Connection()
Destructor.
Definition: public.cpp:505
virtual I_DriverContext::TConnectionMode ConnectMode() const
Get the bitmask for the connection mode (BCP, secure login, ...)
Definition: public.cpp:456
virtual bool Send()
Send command to the server.
Definition: public.cpp:751
virtual bool Delete(const string &table_name)
Delete the last fetched row.
Definition: public.cpp:1085
void ReleaseConn(void)
Definition: public.cpp:1259
bool m_HasTransaction
Definition: public.hpp:389
virtual bool HasMoreResults() const
Definition: public.cpp:1150
bool Bind(unsigned int column_num, CDB_Object *value)
Definition: public.cpp:968
virtual ~CDB_BlobDescriptor(void)
Definition: public.cpp:1191
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)
Definition: public.cpp:395
virtual bool CompleteBCP()
Complete the BCP and store all rows transferred in last batch into the table.
Definition: public.cpp:1005
CDB_ResultProcessor * m_Next
Definition: public.hpp:1047
CDB_ResultProcessor * m_Prev
Definition: public.hpp:1046
virtual void DumpResults()
Dump the results of the command If result processor is installed for this connection,...
Definition: public.cpp:1156
virtual CDBParams & GetBindParams(void)
Get meta-information about parameters.
Definition: public.cpp:738
impl::CBaseCmd * m_CmdImpl
Definition: public.hpp:655
CDB_BlobDescriptor(const string &table_name, const string &column_name, const string &search_conditions, ETDescriptorType column_type=eUnknown, ETriState has_legacy_type=eTriState_Unknown)
Definition: public.cpp:1178
virtual string GetVersionString(void) const
Driver version, supplied here rather than by the context for ODBC's sake.
Definition: public.cpp:580
unsigned int GetReuseCount() const
Indicate how many times (if at all) this connection has been previously used.
Definition: public.cpp:468
virtual EDB_Type ItemDataType(unsigned int item_num) const
Get datatype of a result item.
Definition: public.cpp:649
~CAutoTrans(void)
Definition: public.cpp:1284
virtual bool Close()
Close the cursor.
Definition: public.cpp:1097
virtual I_DriverContext * Context() const
Get pointer to the driver context.
Definition: public.cpp:480
virtual int CurrentItemNo() const
Return current item number we can retrieve (0,1,...)
Definition: public.cpp:666
impl::CBaseCmd * m_CmdImpl
Definition: public.hpp:750
virtual bool IsAlive()
Check out if connection is alive.
Definition: public.cpp:292
virtual bool IsReusable() const
Check if this connection is a reusable one.
Definition: public.cpp:462
void Commit(void)
Definition: public.cpp:1323
virtual CDBParams & GetDefineParams(void)
Get meta-information about defined parameters.
Definition: public.cpp:838
virtual void DumpResults()
Dump the results of the command If result processor is installed for this connection,...
Definition: public.cpp:801
virtual bool SkipItem()
Skip result item.
Definition: public.cpp:696
virtual bool Abort()
Abort the connection.
Definition: public.cpp:516
virtual void DumpResults()
Dump the results of the command If result processor is installed for this connection,...
Definition: public.cpp:896
void SetDatabaseName(const string &name)
Set database name.
Definition: public.cpp:403
virtual size_t SendChunk(const void *data, size_t size)
Send chunk of data to the server.
Definition: public.cpp:1129
virtual CDB_LangCmd * LangCmd(const string &lang_query)
Make language command.
Definition: public.cpp:355
virtual CDB_CursorCmd * Cursor(const string &cursor_name, const string &query, unsigned int batch_size)
Make cursor command.
Definition: public.cpp:376
virtual bool HasFailed() const
Check if command has failed.
Definition: public.cpp:884
virtual bool Close(void)
Close an open connection.
Definition: public.cpp:527
size_t GetTimeout(void) const
Get connection timeout.
Definition: public.cpp:556
virtual size_t ReadItem(void *buffer, size_t buffer_size, bool *is_null=0)
Read a result item body (for BLOB columns, mostly).
Definition: public.cpp:684
virtual const string & PoolName() const
Find out which connection pool this connection belongs to.
Definition: public.cpp:474
virtual void PushMsgHandler(CDB_UserHandler *h, EOwnership ownership=eNoOwnership)
Put the message handler into message handler stack.
Definition: public.cpp:486
virtual const string & ServerName() const
Get the server name.
Definition: public.cpp:420
EBCP_Hints
Type of hint that can be set.
Definition: public.hpp:778
virtual const string & DatabaseName(void) const
Get the database name.
Definition: public.cpp:450
virtual Uint2 Port() const
Get the port.
Definition: public.cpp:432
virtual CDB_Object * GetItem(CDB_Object *item_buf=0, EGetItem policy=eAppendLOB)
Get a result item (you can use either GetItem or ReadItem).
Definition: public.cpp:678
bool x_IsAlive(void)
Definition: public.cpp:301
virtual ~CDB_CursorCmd()
Definition: public.cpp:1104
virtual bool Cancel()
Cancel the BCP command.
Definition: public.cpp:988
void Rollback(void)
Definition: public.cpp:1332
virtual const char * ItemName(unsigned int item_num) const
Get name of a result item.
Definition: public.cpp:630
virtual unsigned int NofItems() const
Get # of items (columns) in the result.
Definition: public.cpp:623
virtual void PopMsgHandler(CDB_UserHandler *h)
Remove the message handler (and all above it) from the stack.
Definition: public.cpp:493
virtual CDBParams & GetBindParams(void)
Get meta-information about parameters.
Definition: public.cpp:1040
virtual I_BlobDescriptor * GetBlobDescriptor()
Get a descriptor for a BLOB column (for SendData).
Definition: public.cpp:690
impl::CBaseCmd * m_CmdImpl
Definition: public.hpp:914
virtual void ProcessResult(CDB_Result &res)
The default implementation just dumps all rows.
Definition: public.cpp:1214
void FinishOpening(void)
Definition: public.cpp:586
virtual CDB_RPCCmd * RPC(const string &rpc_name)
Make remote procedure call command.
Definition: public.cpp:362
int m_TranCount
Definition: public.hpp:1092
virtual bool Cancel(void)
Definition: public.cpp:1137
virtual void SetTimeout(size_t nof_secs)
Set connection timeout.
Definition: public.cpp:544
void BeginTransaction(void)
Definition: public.cpp:1313
int GetTranCount(void)
Definition: public.cpp:1349
virtual bool HasMoreResults() const
Return TRUE if it makes sense (at all) to call Result()
Definition: public.cpp:878
virtual ~CDB_BCPInCmd()
Definition: public.cpp:1016
virtual int DescriptorType(void) const
Definition: public.cpp:1195
CDB_Result(void)
virtual bool Cancel()
Cancel the command execution.
Definition: public.cpp:765
void SetHints(CTempString hints)
Set hints by one call. Resets everything that was set by Add*Hint().
Definition: public.cpp:940
virtual bool HasMoreResults() const
Definition: public.cpp:783
virtual const string & GetProcName(void) const
Get a name of the procedure.
Definition: public.cpp:908
CDB_Connection * m_Con
Definition: public.hpp:1045
virtual bool Update(const string &table_name, const string &upd_query)
Update the last fetched row.
Definition: public.cpp:1061
virtual const string & Password() const
Get the password.
Definition: public.cpp:444
virtual const CDBParams & GetDefineParams(void) const
Get meta-information about rows in resultset.
Definition: public.cpp:616
virtual CDBParams & GetDefineParams(void)
Get meta-information about defined parameters.
Definition: public.cpp:745
virtual int RowCount() const
Get the number of rows affected by the command Special case: negative on error or if there is no way ...
Definition: public.cpp:890
virtual CDB_ResultProcessor * SetResultProcessor(CDB_ResultProcessor *rp)
Set new result-processor.
Definition: public.cpp:500
virtual bool Fetch()
Fetch next row.
Definition: public.cpp:655
EDB_Type
Definition: types.hpp:52
string GetLogString(void) const
Definition: types.cpp:624
Int4 Value() const
Definition: types.hpp:373
virtual size_t Size() const
Definition: types.cpp:2014
#define _TRACE(message)
Definition: ncbidbg.hpp:122
#define NCBI_CURRENT_FUNCTION
Get current function name.
Definition: ncbidiag.hpp:142
const CNcbiDiag & GetRef(void) const
Some compilers (e.g.
Definition: ncbidiag.hpp:946
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
@ eDiag_Trace
Trace message.
Definition: ncbidiag.hpp:657
#define NCBI_CATCH_ALL_X(err_subcode, message)
Definition: ncbiexpt.hpp:619
void Warning(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1191
int intptr_t
Definition: ncbitype.h:185
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
uint16_t Uint2
2-byte (16-bit) unsigned integer
Definition: ncbitype.h:101
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
const_iterator end() const
Return an iterator to the string's ending position (one past the end of the represented sequence)
Definition: tempstr.hpp:306
CTempString & assign(const char *src_str, size_type len)
Assign new values to the content of the a string.
Definition: tempstr.hpp:733
const char * const_iterator
Definition: tempstr.hpp:71
const char * data(void) const
Return a pointer to the array represented.
Definition: tempstr.hpp:313
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
enum ENcbiOwnership EOwnership
Ownership relations between objects.
Definition of all error codes used in dbapi libraries (dbapi_driver.lib and others).
int i
yy_size_t n
static MDB_envinfo info
Definition: mdb_load.c:37
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
int isdigit(Uchar c)
Definition: ncbictype.hpp:64
static Format format
Definition: njn_ioutil.cpp:53
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static uint8_t * buffer
Definition: pcre2test.c:1016
#define TRACE_PARAMS(params)
Definition: public.cpp:76
unsigned int ConvertI2UI(int value)
Definition: public.cpp:87
#define CHECK_COMMAND(cmd)
Definition: public.cpp:728
#define CHECK_CONNECTION(conn)
Definition: public.cpp:352
#define CHECK_RESULT(res)
Definition: public.cpp:605
static void s_TraceParams(const CDBParams &params, const CDiagCompileInfo &info)
Definition: public.cpp:55
static string subject
static string query
#define _ASSERT
else result
Definition: token2.c:20
Modified on Fri Sep 20 14:57:53 2024 by modify_doxy.py rev. 669887