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

Go to the SVN repository for this file.

1 /* $Id: public.cpp 91591 2020-11-18 15:39:15Z 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 {
584 }
585 
586 ////////////////////////////////////////////////////////////////////////////
587 // CDB_Result::
588 //
589 
591  m_ResImpl(r)
592 {
593  CHECK_DRIVER_ERROR( !m_ResImpl, "No valid result provided", 200004 );
594 
595  m_ResImpl->AttachTo(this);
596 }
597 
598 
599 #define CHECK_RESULT( res ) \
600  CHECK_DRIVER_WARNING( !res, "This result is not available anymore", 200003 )
601 
602 
604 {
606  return GetIResult().ResultType();
607 }
608 
609 
611 {
613  return GetIResult().GetDefineParams();
614 }
615 
616 
617 unsigned int CDB_Result::NofItems() const
618 {
620  return GetIResult().GetDefineParams().GetNum();
621 }
622 
623 const char*
624 CDB_Result::ItemName(unsigned int item_num) const
625 {
627 
628  const string& name = GetIResult().GetDefineParams().GetName(item_num);
629 
630  if (!name.empty()) {
631  return name.c_str();
632  }
633 
634  return NULL;
635 }
636 
637 size_t CDB_Result::ItemMaxSize(unsigned int item_num) const
638 {
640  return GetIResult().GetDefineParams().GetMaxSize(item_num);
641 }
642 
643 EDB_Type CDB_Result::ItemDataType(unsigned int item_num) const
644 {
646  return GetIResult().GetDefineParams().GetDataType(item_num);
647 }
648 
650 {
651  // An exception should be thrown from this place. We cannot omit this exception
652  // because it is expected by ftds driver in CursorResult::Fetch.
654 // if ( !GetIResultPtr() ) {
655 // return false;
656 // }
657  return GetIResult().Fetch();
658 }
659 
661 {
663  return GetIResult().CurrentItemNo();
664 }
665 
667 {
669  return GetIResult().GetColumnNum();
670 }
671 
673 {
675  return GetIResult().GetItem(item_buf, policy);
676 }
677 
678 size_t CDB_Result::ReadItem(void* buffer, size_t buffer_size, bool* is_null)
679 {
681  return GetIResult().ReadItem(buffer, buffer_size, is_null);
682 }
683 
685 {
687  return GetIResult().GetBlobDescriptor();
688 }
689 
691 {
693  return GetIResult().SkipItem();
694 }
695 
696 
698 {
699  try {
700  if ( GetIResultPtr() ) {
701  GetIResult().Release();
702  }
703  }
705 }
706 
707 
708 
709 ////////////////////////////////////////////////////////////////////////////
710 // CDB_LangCmd::
711 //
712 
714 {
715  CHECK_DRIVER_ERROR( !c, "No valid command provided", 200004 );
716 
717  m_CmdImpl = c;
718  m_CmdImpl->AttachTo(this);
719 }
720 
721 
722 #define CHECK_COMMAND( cmd ) \
723  CHECK_DRIVER_WARNING( !cmd, "This command cannot be used anymore", 200005 )
724 
725 
726 bool CDB_LangCmd::More(const string& query_text)
727 {
729  return m_CmdImpl->More(query_text);
730 }
731 
733 {
735  return m_CmdImpl->GetBindParams();
736 }
737 
738 
740 {
742  return m_CmdImpl->GetDefineParams();
743 }
744 
746 {
750  return m_CmdImpl->Send();
751 }
752 
754 {
756  return m_CmdImpl->WasSent();
757 }
758 
760 {
762  return m_CmdImpl->Cancel();
763 }
764 
766 {
768  return m_CmdImpl->WasCanceled();
769 }
770 
772 {
774  return m_CmdImpl->Result();
775 }
776 
778 {
780  return m_CmdImpl->HasMoreResults();
781 }
782 
784 {
786  return m_CmdImpl->HasFailed();
787 }
788 
790 {
792  return m_CmdImpl->RowCount();
793 }
794 
796 {
799 }
800 
802 {
803  try {
804  if ( m_CmdImpl ) {
805  m_CmdImpl->Release();
806  }
807  }
809 }
810 
811 
812 
813 /////////////////////////////////////////////////////////////////////////////
814 // CDB_RPCCmd::
815 //
816 
818 {
819  CHECK_DRIVER_ERROR( !c, "No valid command provided", 200006 );
820  m_CmdImpl = c;
821  m_CmdImpl->AttachTo(this);
822 }
823 
824 
826 {
828  return m_CmdImpl->GetBindParams();
829 }
830 
831 
833 {
835  return m_CmdImpl->GetDefineParams();
836 }
837 
838 
840 {
842  _TRACE("Calling remote procedure " << GetProcName());
845  return m_CmdImpl->Send();
846 }
847 
849 {
851  return m_CmdImpl->WasSent();
852 }
853 
855 {
857  return m_CmdImpl->Cancel();
858 }
859 
861 {
863  return m_CmdImpl->WasCanceled();
864 }
865 
867 {
869  return m_CmdImpl->Result();
870 }
871 
873 {
875  return m_CmdImpl->HasMoreResults();
876 }
877 
879 {
881  return m_CmdImpl->HasFailed();
882 }
883 
885 {
887  return m_CmdImpl->RowCount();
888 }
889 
891 {
894 }
895 
896 void CDB_RPCCmd::SetRecompile(bool recompile)
897 {
899  m_CmdImpl->SetRecompile(recompile);
900 }
901 
902 const string& CDB_RPCCmd::GetProcName(void) const
903 {
905  return m_CmdImpl->GetQuery();
906 }
907 
908 
910 {
911  try {
912  if ( m_CmdImpl ) {
913  m_CmdImpl->Release();
914  }
915  }
917 }
918 
919 
920 
921 ////////////////////////////////////////////////////////////////////////////
922 // CDB_BCPInCmd::
923 //
924 
926 {
927  CHECK_DRIVER_ERROR( !c, "No valid command provided", 200007 );
928 
929  m_CmdImpl = c;
930  m_CmdImpl->AttachTo(this);
931 }
932 
933 
935 {
937  m_CmdImpl->SetHints(hints);
938 }
939 
940 
941 void CDB_BCPInCmd::AddHint(EBCP_Hints hint, unsigned int value /* = 0 */)
942 {
944  m_CmdImpl->AddHint(hint, value);
945 }
946 
947 
949 {
952 }
953 
954 
956 {
958  return m_CmdImpl->GetBindParams();
959 }
960 
961 
962 bool CDB_BCPInCmd::Bind(unsigned int column_num, CDB_Object* value)
963 {
964  GetBindParams().Bind(column_num, value);
965  return true;
966 }
967 
968 
970 {
972  if (m_CmdImpl->m_RowsSent++ == 0) {
974  } else if (m_CmdImpl->m_AtStartOfBatch) {
976  }
977  m_CmdImpl->m_AtStartOfBatch = false;
979  return m_CmdImpl->Send();
980 }
981 
983 {
985  return m_CmdImpl->Cancel();
986 }
987 
989 {
991  if (m_CmdImpl->m_BatchesSent++ == 0 && m_CmdImpl->m_RowsSent > 1) {
992  _TRACE("Sent a batch of " << m_CmdImpl->GetRowsInCurrentBatch()
993  << " rows");
994  }
995  m_CmdImpl->m_AtStartOfBatch = true;
996  return m_CmdImpl->CommitBCPTrans();
997 }
998 
1000 {
1002  if (m_CmdImpl->m_BatchesSent > 1) {
1003  _TRACE("Sent " << m_CmdImpl->m_RowsSent << " rows, in "
1004  << m_CmdImpl->m_BatchesSent << " batches");
1005  }
1006  return m_CmdImpl->EndBCP();
1007 }
1008 
1009 
1011 {
1012  try {
1013  if ( m_CmdImpl ) {
1014  m_CmdImpl->Release();
1015  }
1016  }
1018 }
1019 
1020 
1021 
1022 /////////////////////////////////////////////////////////////////////////////
1023 // CDB_CursorCmd::
1024 //
1025 
1027 {
1028  CHECK_DRIVER_ERROR( !c, "No valid command provided", 200006 );
1029  m_CmdImpl = c;
1030  m_CmdImpl->AttachTo(this);
1031 }
1032 
1033 
1035 {
1037  return m_CmdImpl->GetBindParams();
1038 }
1039 
1040 
1042 {
1044  return m_CmdImpl->GetDefineParams();
1045 }
1046 
1047 
1049 {
1052  return m_CmdImpl->OpenCursor();
1053 }
1054 
1055 bool CDB_CursorCmd::Update(const string& table_name, const string& upd_query)
1056 {
1059  return m_CmdImpl->Update(table_name, upd_query);
1060 }
1061 
1062 bool CDB_CursorCmd::UpdateBlob(unsigned int item_num, CDB_Stream& data,
1063  bool log_it)
1064 {
1066  return m_CmdImpl->UpdateBlob(item_num, data, log_it);
1067 }
1068 
1070  size_t size,
1071  bool log_it,
1072  bool dump_results)
1073 {
1075  return m_CmdImpl->SendDataCmd(item_num, size, log_it, dump_results);
1076 }
1077 
1078 
1080 {
1082  return m_CmdImpl->Delete(table_name);
1083 }
1084 
1086 {
1088  return m_CmdImpl->RowCount();
1089 }
1090 
1092 {
1094  return m_CmdImpl->CloseCursor();
1095 }
1096 
1097 
1099 {
1100  try {
1101  if ( m_CmdImpl ) {
1102  m_CmdImpl->Release();
1103  }
1104  }
1106 }
1107 
1108 
1109 
1110 /////////////////////////////////////////////////////////////////////////////
1111 // CDB_SendDataCmd::
1112 //
1113 
1115 {
1116  CHECK_DRIVER_ERROR( !c, "No valid command provided", 200006 );
1117 
1118  m_CmdImpl = c;
1119  m_CmdImpl->AttachTo(this);
1120 }
1121 
1122 
1123 size_t CDB_SendDataCmd::SendChunk(const void* pChunk, size_t nofBytes)
1124 {
1125  CHECK_DRIVER_WARNING( !m_CmdImpl, "This command cannot be used anymore", 200005 );
1126 
1127  return m_CmdImpl->SendChunk(pChunk, nofBytes);
1128 }
1129 
1130 
1132 {
1133  CHECK_DRIVER_WARNING( !m_CmdImpl, "This command cannot be used anymore", 200005 );
1134 
1135  return m_CmdImpl->Cancel();
1136 }
1137 
1139 {
1141  return m_CmdImpl->Result();
1142 }
1143 
1145 {
1147  return m_CmdImpl->HasMoreResults();
1148 }
1149 
1151 {
1154 }
1155 
1157 {
1158  try {
1159  if ( m_CmdImpl ) {
1160  m_CmdImpl->Release();
1161  }
1162  }
1164 }
1165 
1166 
1167 
1168 /////////////////////////////////////////////////////////////////////////////
1169 // CDB_BlobDescriptor::
1170 //
1171 
1173  const string& column_name,
1174  const string& search_conditions,
1175  ETDescriptorType column_type,
1176  ETriState has_legacy_type)
1177 : m_TableName(table_name)
1178 , m_ColumnName(column_name)
1179 , m_SearchConditions(search_conditions)
1180 , m_ColumnType(column_type)
1181 , m_HasLegacyType(has_legacy_type)
1182 {
1183 }
1184 
1186 {
1187 }
1188 
1190 {
1191  return 0;
1192 }
1193 
1194 
1195 
1196 /////////////////////////////////////////////////////////////////////////////
1197 // CDB_ResultProcessor::
1198 //
1199 
1201  m_Con(NULL),
1202  m_Prev(NULL),
1203  m_Next(NULL)
1204 {
1205  SetConn(c);
1206 }
1207 
1209 {
1210  while (res.Fetch()) // fetch and forget
1211  continue;
1212 }
1213 
1214 
1216 {
1217  try {
1218  if ( m_Con ) {
1220  }
1221 
1222  if(m_Prev) {
1223  m_Prev->m_Next = m_Next;
1224  }
1225 
1226  if(m_Next) {
1227  m_Next->m_Prev = m_Prev;
1228  }
1229  }
1231 }
1232 
1234 {
1235  // Clear previously used connection ...
1236  if ( m_Con ) {
1238  }
1239 
1240  m_Con = c;
1241 
1242  if ( m_Con ) {
1243  _ASSERT(m_Prev == NULL);
1244  m_Prev = m_Con->SetResultProcessor(this);
1245 
1246  if (m_Prev) {
1247  _ASSERT(m_Prev->m_Next == NULL);
1248  m_Prev->m_Next = this;
1249  }
1250  }
1251 }
1252 
1254 {
1255  m_Con = NULL;
1256 }
1257 
1258 
1259 ////////////////////////////////////////////////////////////////////////////////
1261 : m_Abort(true)
1262 , m_Conn(subject.m_Connection)
1263 , m_TranCount(0)
1264 {
1265  BeginTransaction();
1267  if (m_TranCount > 1) {
1268  m_SavepointName = "ncbi_dbapi_txn_"
1269  + NStr::NumericToString(reinterpret_cast<intptr_t>(this), 0, 16);
1270  unique_ptr<CDB_LangCmd> auto_stmt
1271  (m_Conn.LangCmd("SAVE TRANSACTION " + m_SavepointName));
1272  auto_stmt->Send();
1273  auto_stmt->DumpResults();
1274  }
1275 }
1276 
1277 
1279 {
1280  try
1281  {
1282  const int curr_TranCount = GetTranCount();
1283 
1284  if (curr_TranCount >= m_TranCount) {
1285  if (curr_TranCount > m_TranCount) {
1286  // A nested transaction is started and not finished yet ...
1287  ERR_POST_X(1, Warning << "A nested transaction was started and "
1288  "it is not finished yet.");
1289  }
1290 
1291  // Assume that we are on the same level of transaction nesting.
1292  if(m_Abort) {
1293  Rollback();
1294  } else {
1295  Commit();
1296  }
1297  }
1298  m_Conn.m_HasTransaction = (curr_TranCount <= 1);
1299 
1300  // Skip commit/rollback if this transaction was previously
1301  // explicitly finished ...
1302  }
1304 }
1305 
1306 void
1308 {
1309  m_Conn.m_HasTransaction = true;
1310  unique_ptr<CDB_LangCmd> auto_stmt(m_Conn.LangCmd("BEGIN TRANSACTION"));
1311  auto_stmt->Send();
1312  auto_stmt->DumpResults();
1313 }
1314 
1315 
1316 void
1318 {
1319  unique_ptr<CDB_LangCmd> auto_stmt(m_Conn.LangCmd("COMMIT"));
1320  auto_stmt->Send();
1321  auto_stmt->DumpResults();
1322 }
1323 
1324 
1325 void
1327 {
1328  unique_ptr<CDB_LangCmd> auto_stmt
1329  (m_Conn.LangCmd("ROLLBACK TRANSACTION " + m_SavepointName));
1330  auto_stmt->Send();
1331  auto_stmt->DumpResults();
1332  if (m_SavepointName.empty()) {
1333  _ASSERT(m_TranCount == 1);
1334  } else {
1335  // Formally unwind via an empty commit, as a rollback would
1336  // also cancel outer transactions.
1337  Commit();
1338  }
1339 }
1340 
1341 
1342 int
1344 {
1345  int result = 0;
1346  unique_ptr<CDB_LangCmd> auto_stmt(m_Conn.LangCmd("SELECT @@trancount as tc"));
1347 
1348  if (auto_stmt->Send()) {
1349  while(auto_stmt->HasMoreResults()) {
1350  unique_ptr<CDB_Result> rs(auto_stmt->Result());
1351 
1352  if (rs.get() == NULL) {
1353  continue;
1354  }
1355 
1356  if (rs->ResultType() != eDB_RowResult) {
1357  continue;
1358  }
1359 
1360  if (rs->Fetch()) {
1361  CDB_Int tran_count;
1362  rs->GetItem(&tran_count);
1363  result = tran_count.Value();
1364  }
1365 
1366  while(rs->Fetch()) {
1367  }
1368  }
1369  }
1370 
1371  return result;
1372 }
1373 
1374 
1376 
1377 
Helper class to allow safe initialization from higher-layer objects.
Definition: public.hpp:1056
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
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:687
#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:603
impl::CResult * GetIResultPtr(void) const
Definition: public.hpp:558
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:1089
virtual ~CDB_SendDataCmd()
Definition: public.cpp:1156
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:969
virtual int GetColumnNum(void) const
Return number of columns in the recordset.
Definition: public.cpp:666
virtual bool CompleteBatch()
Complete batch – to store all rows transferred by far in this batch into the table.
Definition: public.cpp:988
CAutoTrans(const CSubject &subject)
Definition: public.cpp:1260
virtual void SetRecompile(bool recompile=true)
Set the "recompile before execute" flag for the stored proc Implementation-specific.
Definition: public.cpp:896
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:1069
virtual size_t ItemMaxSize(unsigned int item_num) const
Get size (in bytes) of a result item.
Definition: public.cpp:637
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:1085
virtual CDB_Result * Result()
Get result set.
Definition: public.cpp:771
string m_SavepointName
Definition: public.hpp:1091
virtual CDB_BCPInCmd * BCPIn(const string &table_name)
Make "bulk copy in" command.
Definition: public.cpp:369
virtual ~CDB_ResultProcessor()
Definition: public.cpp:1215
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:386
virtual bool WasCanceled() const
Implementation-specific.
Definition: public.cpp:860
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:697
virtual bool WasSent() const
Implementation-specific.
Definition: public.cpp:753
virtual string GetDriverName(void) const
Definition: public.cpp:574
virtual bool WasCanceled() const
Implementation-specific.
Definition: public.cpp:765
virtual CDB_Result * Result()
Get result set.
Definition: public.cpp:866
impl::CResult * m_ResImpl
Definition: public.hpp:574
impl::CResult & GetIResult(void) const
Definition: public.hpp:562
virtual bool Cancel()
Cancel the command execution.
Definition: public.cpp:854
impl::CSendDataCmd * m_CmdImpl
Definition: public.hpp:954
virtual bool HasFailed() const
Check if command has failed.
Definition: public.cpp:783
void SetConn(CDB_Connection *c)
Definition: public.cpp:1233
virtual int RowCount() const
Get the number of rows affected by the command.
Definition: public.cpp:789
virtual CDB_Result * Result()
Get result set.
Definition: public.cpp:1138
impl::CBaseCmd * m_CmdImpl
Definition: public.hpp:819
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:1062
virtual CDBParams & GetDefineParams(void)
Get meta-information about defined parameters.
Definition: public.cpp:1041
virtual bool More(const string &query_text)
Add more text to the language command.
Definition: public.cpp:726
virtual ~CDB_LangCmd()
Definition: public.cpp:801
virtual CDB_Result * Open()
Open the cursor.
Definition: public.cpp:1048
virtual bool WasSent() const
Implementation-specific.
Definition: public.cpp:848
virtual Uint4 Host() const
Get the host.
Definition: public.cpp:426
void AddOrderHint(CTempString columns)
Add "ORDER" hint.
Definition: public.cpp:948
virtual bool Send()
Send command to the server.
Definition: public.cpp:839
bool m_Abort
Definition: public.hpp:1088
virtual CDBParams & GetBindParams(void)
Get meta-information about parameters.
Definition: public.cpp:825
void AddHint(EBCP_Hints hint, unsigned int value=0)
Add hint with value.
Definition: public.cpp:941
virtual CDBParams & GetBindParams(void)
Get meta-information about parameters.
Definition: public.cpp:955
virtual ~CDB_RPCCmd()
Definition: public.cpp:909
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:745
virtual bool Delete(const string &table_name)
Delete the last fetched row.
Definition: public.cpp:1079
void ReleaseConn(void)
Definition: public.cpp:1253
bool m_HasTransaction
Definition: public.hpp:387
virtual bool HasMoreResults() const
Definition: public.cpp:1144
bool Bind(unsigned int column_num, CDB_Object *value)
Definition: public.cpp:962
virtual ~CDB_BlobDescriptor(void)
Definition: public.cpp:1185
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:999
CDB_ResultProcessor * m_Next
Definition: public.hpp:1045
CDB_ResultProcessor * m_Prev
Definition: public.hpp:1044
virtual void DumpResults()
Dump the results of the command If result processor is installed for this connection,...
Definition: public.cpp:1150
virtual CDBParams & GetBindParams(void)
Get meta-information about parameters.
Definition: public.cpp:732
impl::CBaseCmd * m_CmdImpl
Definition: public.hpp:653
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:1172
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:643
~CAutoTrans(void)
Definition: public.cpp:1278
virtual bool Close()
Close the cursor.
Definition: public.cpp:1091
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:660
impl::CBaseCmd * m_CmdImpl
Definition: public.hpp:748
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:1317
virtual CDBParams & GetDefineParams(void)
Get meta-information about defined parameters.
Definition: public.cpp:832
virtual void DumpResults()
Dump the results of the command If result processor is installed for this connection,...
Definition: public.cpp:795
virtual bool SkipItem()
Skip result item.
Definition: public.cpp:690
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:890
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:1123
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:878
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:678
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:776
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:672
bool x_IsAlive(void)
Definition: public.cpp:301
virtual ~CDB_CursorCmd()
Definition: public.cpp:1098
virtual bool Cancel()
Cancel the BCP command.
Definition: public.cpp:982
void Rollback(void)
Definition: public.cpp:1326
virtual const char * ItemName(unsigned int item_num) const
Get name of a result item.
Definition: public.cpp:624
virtual unsigned int NofItems() const
Get # of items (columns) in the result.
Definition: public.cpp:617
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:1034
virtual I_BlobDescriptor * GetBlobDescriptor()
Get a descriptor for a BLOB column (for SendData).
Definition: public.cpp:684
impl::CBaseCmd * m_CmdImpl
Definition: public.hpp:912
virtual void ProcessResult(CDB_Result &res)
The default implementation just dumps all rows.
Definition: public.cpp:1208
void FinishOpening(void)
Definition: public.cpp:580
virtual CDB_RPCCmd * RPC(const string &rpc_name)
Make remote procedure call command.
Definition: public.cpp:362
int m_TranCount
Definition: public.hpp:1090
virtual bool Cancel(void)
Definition: public.cpp:1131
virtual void SetTimeout(size_t nof_secs)
Set connection timeout.
Definition: public.cpp:544
void BeginTransaction(void)
Definition: public.cpp:1307
int GetTranCount(void)
Definition: public.cpp:1343
virtual bool HasMoreResults() const
Return TRUE if it makes sense (at all) to call Result()
Definition: public.cpp:872
virtual ~CDB_BCPInCmd()
Definition: public.cpp:1010
virtual int DescriptorType(void) const
Definition: public.cpp:1189
CDB_Result(void)
virtual bool Cancel()
Cancel the command execution.
Definition: public.cpp:759
void SetHints(CTempString hints)
Set hints by one call. Resets everything that was set by Add*Hint().
Definition: public.cpp:934
virtual bool HasMoreResults() const
Definition: public.cpp:777
virtual const string & GetProcName(void) const
Get a name of the procedure.
Definition: public.cpp:902
CDB_Connection * m_Con
Definition: public.hpp:1043
virtual bool Update(const string &table_name, const string &upd_query)
Update the last fetched row.
Definition: public.cpp:1055
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:610
virtual CDBParams & GetDefineParams(void)
Get meta-information about defined parameters.
Definition: public.cpp:739
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:884
virtual CDB_ResultProcessor * SetResultProcessor(CDB_ResultProcessor *rp)
Set new result-processor.
Definition: public.cpp:500
virtual bool Fetch()
Fetch next row.
Definition: public.cpp:649
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 pcre_uint8 * buffer
Definition: pcretest.c:1051
static int buffer_size
Definition: pcretest.c:1050
#define TRACE_PARAMS(params)
Definition: public.cpp:76
unsigned int ConvertI2UI(int value)
Definition: public.cpp:87
#define CHECK_COMMAND(cmd)
Definition: public.cpp:722
#define CHECK_CONNECTION(conn)
Definition: public.cpp:352
#define CHECK_RESULT(res)
Definition: public.cpp:599
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 Tue Apr 23 07:37:53 2024 by modify_doxy.py rev. 669887