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

Go to the SVN repository for this file.

1 /* $Id: lang_cmd.cpp 99071 2023-02-09 17:00:30Z 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: CTLib language command
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
36 #include <dbapi/driver/public.hpp>
37 #include <dbapi/error_codes.hpp>
38 
39 #include "ctlib_utils.hpp"
40 
41 
42 #define NCBI_USE_ERRCODE_X Dbapi_CTlib_Cmds
43 
44 #undef NCBI_DATABASE_THROW
45 #define NCBI_DATABASE_THROW(ex_class, message, err_code, severity) \
46  NCBI_DATABASE_THROW_ANNOTATED(ex_class, message, err_code, severity, \
47  GetDbgInfo(), GetConnection(), GetLastParams())
48 // No use of NCBI_DATABASE_RETHROW or DATABASE_DRIVER_*_EX here.
49 
51 
52 #ifdef FTDS_IN_USE
53 namespace NCBI_NS_FTDS_CTLIB
54 {
55 #endif
56 
57 /////////////////////////////////////////////////////////////////////////////
58 //
59 // CTL_CmdBase::
60 //
61 
63 : CBaseCmd(conn, query)
64 , m_RowCount(-1)
65 , m_DbgInfo(new TDbgInfo(conn.GetDbgInfo()))
66 , m_IsActive(true)
67 , m_TimedOut(false)
68 , m_Retriable(eRetriable_Unknown)
69 {
70  if (conn.m_ActiveCmd) {
71  conn.m_ActiveCmd->m_IsActive = false;
72  }
73  conn.m_ActiveCmd = this;
74 }
75 
76 
77 CTL_CmdBase::CTL_CmdBase(CTL_Connection& conn, const string& cursor_name,
78  const string& query)
79 : CBaseCmd(conn, cursor_name, query)
80 , m_RowCount(-1)
81 , m_DbgInfo(new TDbgInfo(conn.GetDbgInfo()))
82 , m_IsActive(true)
83 , m_TimedOut(false)
84 , m_Retriable(eRetriable_Unknown)
85 {
86  if (conn.m_ActiveCmd) {
87  conn.m_ActiveCmd->m_IsActive = false;
88  }
89  conn.m_ActiveCmd = this;
90 }
91 
92 
94 {
95  if (m_IsActive) {
97  }
98 }
99 
100 
103 {
104  // The connection::Check() may or may not throw an exception.
105  // If it did not then an exception may be thrown later (e.g. in case of
106  // a timeout). Two attributes: retriability and the fact that it was a
107  // timeout needs to be memorized in the command.
108  SetTimedOut(GetCTLExceptionStorage().GetHasTimeout());
110  return GetConnection().Check(rc, GetDbgInfo());
111 }
112 
113 
115 {
116  if ( !m_IsActive ) {
118  if (conn.m_ActiveCmd) {
119  conn.m_ActiveCmd->m_IsActive = false;
120  }
121  conn.m_ActiveCmd = this;
122  m_IsActive = true;
123  }
124 }
125 
126 /////////////////////////////////////////////////////////////////////////////
127 //
128 // CTL_Cmd::
129 //
130 
133 , m_Cmd(NULL)
134 , m_Res(NULL)
135 {
136  x_Init();
137 }
138 
139 CTL_Cmd::CTL_Cmd(CTL_Connection& conn, const string& cursor_name,
140  const string& query)
141 : CTL_CmdBase(conn, cursor_name, query)
142 , m_Cmd(NULL)
143 , m_Res(NULL)
144 {
145  x_Init();
146 }
147 
148 void CTL_Cmd::x_Init(void)
149 {
150  CHECK_DRIVER_ERROR(!GetConnection().IsAlive() || !GetConnection().IsOpen(),
151  "Connection is not open or already dead." + GetDbgInfo(),
152  110003 );
153 
155  ct_cmd_alloc(
156  GetConnection().GetNativeConnection().GetNativeHandle(),
157  &m_Cmd
158  ),
159  "ct_cmd_alloc failed", 110001
160  );
161 }
162 
163 
165 {
167 
168  try {
169  if (!IsDead()) {
170  // Check(ct_cancel(NULL, x_GetSybaseCmd(), CS_CANCEL_CURRENT));
171  // Check(ct_cancel(NULL, x_GetSybaseCmd(), CS_CANCEL_ALL));
172  }
174  }
176 
178 }
179 
180 
182 CTL_Cmd::CheckSFB_Internal(CS_RETCODE rc, const char* msg, unsigned int msg_num)
183 {
184  switch (Check(rc)) {
185  case CS_SUCCEED:
186  break;
187  case CS_FAIL:
188  if (GetConnection().IsAlive()) {
189  DATABASE_DRIVER_ERROR(msg, msg_num);
190  } else {
191  DATABASE_DRIVER_ERROR("Connection has died.", 122010);
192  }
193 #ifdef CS_BUSY
194  case CS_BUSY:
195  DATABASE_DRIVER_ERROR( "the connection is busy", 122002 );
196 #endif
197  }
198 
199  return rc;
200 }
201 
202 
203 
205 {
206  if (!IsDead()) {
207 #if 0
209  DATABASE_DRIVER_FATAL("ct_cmd_drop failed", 122060);
210  }
211 #else
213 #endif
214  }
215 
216  m_Cmd = NULL;
217 }
218 
219 bool
221 {
222  if(GetConnection().GetResultProcessor()) {
224  return true;
225  }
226 
227  return false;
228 }
229 
231  const string& param_name,
232  CS_DATAFMT& param_fmt,
233  bool declare_only)
234 {
235  CS_SMALLINT indicator = param.IsNULL() ? -1 : 0;
236 
237  {{
238  CS_INT l = (CS_INT) param_name.copy(param_fmt.name, CS_MAX_NAME-1);
239  param_fmt.name[l] = '\0';
240  param_fmt.namelen = l;
241  }}
242  param_fmt.maxlength = 0;
243 
244 
245  CS_RETCODE ret_code = CS_FAIL;
246 
247  // We HAVE to pass correct data type even in case of NULL value.
248  switch ( param.GetType() ) {
249  case eDB_Int: {
250  CDB_Int& par = dynamic_cast<CDB_Int&> (param);
251  param_fmt.datatype = CS_INT_TYPE;
252  if ( declare_only ) {
253  break;
254  }
255 
256  CS_INT value = (CS_INT) par.Value();
257  ret_code = Check(ct_param(x_GetSybaseCmd(), &param_fmt,
258  (CS_VOID*) &value, CS_UNUSED, indicator));
259  break;
260  }
261  case eDB_SmallInt: {
262  CDB_SmallInt& par = dynamic_cast<CDB_SmallInt&> (param);
263  param_fmt.datatype = CS_SMALLINT_TYPE;
264  if ( declare_only ) {
265  break;
266  }
267 
269  ret_code = Check(ct_param(x_GetSybaseCmd(), &param_fmt,
270  (CS_VOID*) &value, CS_UNUSED, indicator));
271  break;
272  }
273  case eDB_TinyInt: {
274  CDB_TinyInt& par = dynamic_cast<CDB_TinyInt&> (param);
275  param_fmt.datatype = CS_TINYINT_TYPE;
276  if ( declare_only ) {
277  break;
278  }
279 
280  CS_TINYINT value = (CS_TINYINT) par.Value();
281  ret_code = Check(ct_param(x_GetSybaseCmd(), &param_fmt,
282  (CS_VOID*) &value, CS_UNUSED, indicator));
283  break;
284  }
285  case eDB_Bit: {
286  CDB_Bit& par = dynamic_cast<CDB_Bit&> (param);
287  param_fmt.datatype = CS_BIT_TYPE;
288  if ( declare_only ) {
289  break;
290  }
291 
292  CS_BIT value = (CS_BIT) par.Value();
293  ret_code = Check(ct_param(x_GetSybaseCmd(), &param_fmt,
294  (CS_VOID*) &value, CS_UNUSED, indicator));
295  break;
296  }
297  case eDB_BigInt: {
298  CDB_BigInt& par = dynamic_cast<CDB_BigInt&> (param);
299 
300  param_fmt.datatype = CS_NUMERIC_TYPE;
301  if ( declare_only ) {
302  break;
303  }
304 
306  Int8 v8 = par.Value();
307  memset(&value, 0, sizeof(value));
308  value.precision = 19;
309  if (longlong_to_numeric(v8, 19, value.array) == 0) {
310  return false;
311  }
312  param_fmt.scale = 0;
313  param_fmt.precision = 19;
314 
315  ret_code = Check(ct_param(x_GetSybaseCmd(), &param_fmt,
316  (CS_VOID*) &value, sizeof(value), indicator));
317  break;
318  }
319  case eDB_Char: {
320  CDB_Char& par = dynamic_cast<CDB_Char&> (param);
321  param_fmt.datatype = CS_CHAR_TYPE;
322  if ( (param_fmt.status & CS_RETURN) != 0) {
323  param_fmt.maxlength = 8000;
324  }
325  if ( declare_only ) {
326  break;
327  }
328 
329  ret_code = Check(ct_param(x_GetSybaseCmd(),
330  &param_fmt,
331  (CS_VOID*) par.Data(),
332  (CS_INT) par.Size(),
333  indicator)
334  );
335  break;
336  }
337  case eDB_LongChar: {
338  CDB_LongChar& par = dynamic_cast<CDB_LongChar&> (param);
339  param_fmt.datatype = CS_LONGCHAR_TYPE;
340  if ( (param_fmt.status & CS_RETURN) != 0) {
341  param_fmt.maxlength = 8000;
342  }
343  if ( declare_only ) {
344  break;
345  }
346 
347  ret_code = Check(ct_param(x_GetSybaseCmd(),
348  &param_fmt,
349  (CS_VOID*) par.Data(),
350  (CS_INT) par.Size(),
351  indicator)
352  );
353  break;
354  }
355  case eDB_VarChar: {
356  CDB_VarChar& par = dynamic_cast<CDB_VarChar&> (param);
357 
358  param_fmt.datatype = NCBI_CS_STRING_TYPE;
359  if ( (param_fmt.status & CS_RETURN) != 0) {
360  param_fmt.maxlength = 8000;
361  }
362 #ifdef FTDS_IN_USE
364  && !par.IsNULL())
365  {
366  CStringUTF8 str_check(CUtf8::AsUTF8(par.AsString(),
368  CUtf8::AsBasicString<TCharUCS2>(str_check);
369  }
370 #endif
371 
372  if ( declare_only ) {
373  break;
374  }
375 
376  CTempString ts;
377  CTempVarChar varchar;
378  if (par.Size() <= kMax_UI1) {
379  varchar.SetValue(par.Value());
380  ts = varchar.GetValue();
381  } else {
382  param_fmt.datatype = CS_LONGCHAR_TYPE;
383  ts.assign(par.Data(), par.Size());
384  }
385 
386  ret_code = Check(ct_param(x_GetSybaseCmd(),
387  &param_fmt,
388  (CS_VOID*) ts.data(),
389  (CS_INT) ts.size(),
390  indicator)
391  );
392  break;
393  }
394  case eDB_Binary: {
395  CDB_Binary& par = dynamic_cast<CDB_Binary&> (param);
396  param_fmt.datatype = CS_BINARY_TYPE;
397  if ( (param_fmt.status & CS_RETURN) != 0) {
398  param_fmt.maxlength = 8000;
399  }
400  if ( declare_only ) {
401  break;
402  }
403 
404  ret_code = Check(ct_param(x_GetSybaseCmd(),
405  &param_fmt,
406  (CS_VOID*) par.Value(),
407  (CS_INT) par.Size(),
408  indicator)
409  );
410  break;
411  }
412  case eDB_LongBinary: {
413  CDB_LongBinary& par = dynamic_cast<CDB_LongBinary&> (param);
414 #ifdef FTDS_IN_USE
416 # ifdef CS_TDS_72
418  param_fmt.datatype = CS_IMAGE_TYPE;
419  else
420 # endif
421  {
422  param_fmt.datatype = CS_BINARY_TYPE;
423  if ( (param_fmt.status & CS_RETURN) != 0) {
424  param_fmt.maxlength = 8000;
425  }
426  }
427  } else
428 #endif
429  {
430  param_fmt.datatype = CS_LONGBINARY_TYPE;
431  if ( (param_fmt.status & CS_RETURN) != 0) {
432  param_fmt.maxlength = 8000;
433  }
434  }
435 
436  if ( declare_only ) {
437  break;
438  }
439  ret_code = Check(ct_param(x_GetSybaseCmd(),
440  &param_fmt,
441  (CS_VOID*) par.Value(),
442  (CS_INT) par.Size(),
443  indicator)
444  );
445  break;
446  }
447  case eDB_VarBinary: {
448  CDB_VarBinary& par = dynamic_cast<CDB_VarBinary&> (param);
449 #if defined(FTDS_IN_USE) && defined(CS_TDS_72)
451  param_fmt.datatype = CS_IMAGE_TYPE;
452  else
453 #endif
454  {
455  param_fmt.datatype = CS_BINARY_TYPE;
456  if ( (param_fmt.status & CS_RETURN) != 0) {
457  param_fmt.maxlength = 8000;
458  }
459  }
460  if ( declare_only ) {
461  break;
462  }
463 
464  ret_code = Check(ct_param(x_GetSybaseCmd(),
465  &param_fmt,
466  (CS_VOID*) par.Value(),
467  (CS_INT) par.Size(),
468  indicator)
469  );
470  break;
471  }
472  case eDB_Float: {
473  CDB_Float& par = dynamic_cast<CDB_Float&> (param);
474  param_fmt.datatype = CS_REAL_TYPE;
475  if ( declare_only ) {
476  break;
477  }
478 
479  CS_REAL value = (CS_REAL) par.Value();
480  ret_code = Check(ct_param(x_GetSybaseCmd(),
481  &param_fmt,
482  (CS_VOID*) &value,
483  CS_UNUSED,
484  indicator)
485  );
486  break;
487  }
488  case eDB_Double: {
489  CDB_Double& par = dynamic_cast<CDB_Double&> (param);
490  param_fmt.datatype = CS_FLOAT_TYPE;
491  if ( declare_only ) {
492  break;
493  }
494 
495  CS_FLOAT value = (CS_FLOAT) par.Value();
496  ret_code = Check(ct_param(x_GetSybaseCmd(),
497  &param_fmt,
498  (CS_VOID*) &value,
499  CS_UNUSED,
500  indicator)
501  );
502  break;
503  }
504  case eDB_SmallDateTime: {
505  CDB_SmallDateTime& par = dynamic_cast<CDB_SmallDateTime&> (param);
506  param_fmt.datatype = CS_DATETIME4_TYPE;
507  if ( declare_only ) {
508  break;
509  }
510 
511  CS_DATETIME4 dt;
512  if (param.IsNULL()) {
513  dt.days = 0;
514  dt.minutes = 0;
515  } else {
516  dt.days = par.GetDays();
517  dt.minutes = par.GetMinutes();
518  }
519 
520  ret_code = Check(ct_param(x_GetSybaseCmd(),
521  &param_fmt,
522  (CS_VOID*) &dt,
523  CS_UNUSED,
524  indicator)
525  );
526  break;
527  }
528  case eDB_DateTime: {
529  CDB_DateTime& par = dynamic_cast<CDB_DateTime&> (param);
530  param_fmt.datatype = CS_DATETIME_TYPE;
531  if ( declare_only ) {
532  break;
533  }
534 
535  CS_DATETIME dt;
536  if (param.IsNULL()) {
537  dt.dtdays = 0;
538  dt.dttime = 0;
539  } else {
540  dt.dtdays = par.GetDays();
541  dt.dttime = par.Get300Secs();
542  }
543 
544  ret_code = Check(ct_param(x_GetSybaseCmd(),
545  &param_fmt,
546  (CS_VOID*) &dt,
547  CS_UNUSED,
548  indicator)
549  );
550  break;
551  }
552  case eDB_BigDateTime: {
553  CDB_BigDateTime& par = dynamic_cast<CDB_BigDateTime&> (param);
554  const CTime& t = par.GetCTime();
555  CS_DATETIME dt = { 0, 0 };
556  param_fmt.datatype = CS_DATETIME_TYPE;
557  if ( !param.IsNULL() ) {
558  TDBTimeI dbt = t.GetTimeDBI();
559  if (CTime().SetTimeDBI(dbt) == t) {
560  dt.dtdays = dbt.days;
561  dt.dttime = dbt.time;
562  } else {
563  param_fmt.datatype = CS_CHAR_TYPE;
564  }
565  }
566  if (declare_only) {
567  break;
568  }
569 
570  if (param_fmt.datatype == CS_CHAR_TYPE) {
571  CTime lt = t.GetLocalTime();
572  lt.SetNanoSecond(lt.NanoSecond() / 100 * 100);
573  string s = lt.AsString(CDB_BigDateTime::GetTimeFormat
574  (GetConnection().GetDateTimeSyntax(),
575  par.GetSQLType(), par.GetOffset()));
576  ret_code = Check(ct_param(x_GetSybaseCmd(), &param_fmt,
577  (CS_VOID*) s.data(), (CS_INT) s.size(),
578  indicator));
579  } else {
580  ret_code = Check(ct_param(x_GetSybaseCmd(), &param_fmt,
581  (CS_VOID*) &dt, CS_UNUSED, indicator));
582  }
583  break;
584  }
585  case eDB_Text:
586  case eDB_Image:
587  case eDB_VarCharMax:
588  case eDB_VarBinaryMax:
589  {
590  CDB_Stream& par = dynamic_cast<CDB_Stream&> (param);
591  switch (CDB_Object::GetBlobType(param.GetType())) {
592  case eBlobType_Text: param_fmt.datatype = CS_TEXT_TYPE; break;
593  case eBlobType_Binary: param_fmt.datatype = CS_IMAGE_TYPE; break;
594  default: _TROUBLE;
595  }
596  if (declare_only) {
597  break;
598  } else if (par.IsNULL()) {
599  ret_code = Check(ct_param(x_GetSybaseCmd(), &param_fmt, NULL, 0,
600  indicator));
601  } else {
602  size_t n = par.Size();
604  par.MoveTo(0);
605  CS_INT n2 = static_cast<CS_INT>(par.Read(buf.get(), n));
606  _ASSERT(n2 == n);
607  ret_code = Check(ct_param(x_GetSybaseCmd(), &param_fmt,
608  buf.get(), n2, indicator));
609  }
610  break;
611  }
612  case eDB_Numeric:
613  case eDB_UnsupportedType:
614  ret_code = CS_FAIL;
615  return false;
616  }
617 
618  if ( declare_only ) {
619  ret_code = Check(ct_param(x_GetSybaseCmd(),
620  &param_fmt,
621  0,
622  CS_UNUSED,
623  0)
624  );
625  }
626 
627  return (ret_code == CS_SUCCEED);
628 }
629 
630 
632 {
633  CS_INT n;
634  CS_INT outlen;
635  if (cnt &&
637  CS_ROW_COUNT,
638  &n,
639  CS_UNUSED,
640  &outlen
641  ) == CS_SUCCEED
642  && n >= 0 && n != CS_NO_COUNT) {
643  *cnt = (int) n;
644  }
645 }
646 
647 
648 /////////////////////////////////////////////////////////////////////////////
649 //
650 // CTL_LRCmd::
651 //
652 
654  const string& query)
655  : CTL_Cmd(conn, query)
656 {
657 }
658 
659 
661 {
662  try {
663  // In test mode ... Mon Jul 9 15:20:21 EDT 2007
664  // This call is supposed to cancel brocken resultset.
666  Cancel();
667  }
669 }
670 
671 
673 CTL_LRCmd::CheckSFB(CS_RETCODE rc, const char* msg, unsigned int msg_num)
674 {
675  try {
676  switch (Check(rc)) {
677  case CS_SUCCEED:
678  break;
679  case CS_FAIL:
680  SetHasFailed();
681  DATABASE_DRIVER_ERROR( msg, msg_num );
682  #ifdef CS_BUSY
683  case CS_BUSY:
684  DATABASE_DRIVER_ERROR( "the connection is busy", 122002 );
685  #endif
686  }
687  } catch (...) {
688  SetHasFailed();
689  throw;
690  }
691 
692  return rc;
693 }
694 
697 {
698  DeleteResult();
699 
701  !WasSent(),
702  "You need to send a command first." + GetDbgInfo(),
703  120010 );
704 
705  if (IsDead()) {
706  SetHasFailed();
707  SetWasSent(false);
708  DATABASE_DRIVER_ERROR( "Connection has died." + GetDbgInfo(), 121009 );
709  // return NULL;
710  }
711 
713 #ifdef FTDS_IN_USE
714  unique_ptr<CTL_Connection::CAsyncCancelGuard> async_guard
715  (new CTL_Connection::CAsyncCancelGuard(GetConnection()));
716 #endif
717 
718  for (;;) {
719  CS_INT res_type;
720  CS_RETCODE rc = 0;
721 
722 #ifdef FTDS_IN_USE
723  try {
724  rc = Check(ct_results(x_GetSybaseCmd(), &res_type));
725  } catch (CDB_TimeoutEx&) {
726  if (GetConnection().m_AsyncCancelRequested) {
727  rc = CS_CANCELED;
728  } else {
729  throw;
730  }
731  }
732 #else
733  rc = Check(ct_results(x_GetSybaseCmd(), &res_type));
734 #endif
735 
736  /* This code causes problems with Test_DropConnection.
737  try {
738  rc = Check(ct_results(x_GetSybaseCmd(), &res_type));
739  } catch (...) {
740  // We have to fech out all pending results ...
741  // while (ct_results(x_GetSybaseCmd(), &res_type) == CS_SUCCEED) {
742  // continue;
743  // }
744 
745  SetHasFailed();
746  DeleteResultInternal();
747  Cancel();
748  SetWasSent(false);
749 
750  throw;
751  }
752  */
753 
754  switch (rc) {
755  case CS_SUCCEED:
756  break;
757  case CS_END_RESULTS:
758  SetWasSent(false);
759  return NULL;
760  case CS_FAIL:
761  SetHasFailed();
763  Cancel();
764  SetWasSent(false);
765  DATABASE_DRIVER_ERROR( "ct_result failed." + GetDbgInfo(), 120013 );
766  case CS_CANCELED:
767 #ifdef FTDS_IN_USE
768  if (GetConnection().m_AsyncCancelRequested) {
769  async_guard.reset();
772  }
773 #endif
774  SetWasSent(false);
775  if (GetTimedOut()) {
776  // This branch is for a very specific scenario:
777  // - the user sets up a message handler which does not throw
778  // any exceptions
779  // - a command execution has timed out
780  // - a command is used to retrieve data
781  // In this case there is no usual timeout exception due to a
782  // message handler. However the fact of the timeout is
783  // memorized for the command and it is checked here.
785  "Your command has been canceled due to timeout",
786  eDiag_Error, 20003);
787  ex.SetRetriable(GetRetriable());
788  throw ex;
789  } else {
790  DATABASE_DRIVER_ERROR( "Your command has been canceled." + GetDbgInfo(), 120011 );
791  }
792 #ifdef CS_BUSY
793  case CS_BUSY:
794  DATABASE_DRIVER_ERROR( "Connection has another request pending." + GetDbgInfo(), 120014 );
795 #endif
796  default:
797  DATABASE_DRIVER_ERROR( "Your request is pending." + GetDbgInfo(), 120015 );
798  }
799 
800  switch ( res_type ) {
801  case CS_CMD_SUCCEED:
802  case CS_CMD_DONE: // done with this command
803  // check the number of affected rows
805  continue;
806  case CS_CMD_FAIL: // the command has failed
807  // check the number of affected rows
809  SetHasFailed();
810  DATABASE_DRIVER_WARNING( "The server encountered an error while "
811  "executing a command", 120016 );
812  case CS_ROW_RESULT:
814  break;
815  case CS_PARAM_RESULT:
817  break;
818  case CS_COMPUTE_RESULT:
820  break;
821  case CS_STATUS_RESULT:
823  break;
825  DATABASE_DRIVER_INFO( "CS_COMPUTEFMT_RESULT has arrived", 120017 );
826  case CS_ROWFMT_RESULT:
827  DATABASE_DRIVER_INFO( "CS_ROWFMT_RESULT has arrived", 120018 );
828  case CS_MSG_RESULT:
829  DATABASE_DRIVER_INFO( "CS_MSG_RESULT has arrived", 120019 );
830  default:
831  DATABASE_DRIVER_WARNING( "Unexpected result type has arrived", 120020 );
832  }
833 
834  return &GetResult();
835  }
836 }
837 
838 
839 CDB_Result*
841 {
843 
844  return result ? Create_Result(*result) : NULL;
845 }
846 
847 
848 bool
850 {
851  if (WasSent()) {
852  auto& conn = GetConnection();
853 #ifdef FTDS_IN_USE
854  if (conn.AsyncCancel(*this)) {
855  return true;
856  }
857 #endif
858  CMutexGuard guard(conn.m_CancelLogisticsMutex);
859  conn.m_CancelRequested = true;
860  return x_Cancel(conn.m_ActivityLevel > 0 ? eAsyncCancel : eSyncCancel);
861  } else {
862  return true;
863  }
864 }
865 
866 bool
868 {
869  if (WasSent()) {
870  MarkEndOfReply(); // clears m_CancelRequested along the way
871 
872  if (!IsDead() && GetConnection().IsAlive()) {
873  size_t was_timeout = GetConnection().PrepareToCancel();
874  try {
875  typedef CTL_Connection::CCancelModeGuard TGuard;
876  TGuard::EContext guard_ctx;
877  switch (cancel_type) {
878  case eAsyncCancel: guard_ctx = TGuard::eAsyncCancel; break;
879  case eSyncCancel: guard_ctx = TGuard::eSyncCancel; break;
880  }
881  TGuard guard(GetConnection(), guard_ctx);
882  if ( !guard.IsForCancelInProgress() ) {
883  return true;
884  }
886  cancel_type));
887  CS_INT ignored_results_type;
888  // Force full cancellation processing in FreeTDS 0.91.
889  ct_results(x_GetSybaseCmd(), &ignored_results_type);
890  GetConnection().CancelFinished(was_timeout);
891 
892  switch (retcode) {
893  case CS_SUCCEED:
894  SetWasSent(false);
895  return true;
896  case CS_FAIL:
897  if (GetConnection().IsAlive()) {
898  DATABASE_DRIVER_ERROR("ct_cancel failed."
899  + GetDbgInfo(),
900  120008);
901  } else {
902  DATABASE_DRIVER_ERROR("Connection has died."
903  + GetDbgInfo(),
904  122010);
905  }
906 #ifdef CS_BUSY
907  case CS_BUSY:
908  DATABASE_DRIVER_ERROR( "Connection has another request pending." + GetDbgInfo(), 120009 );
909 #endif
910  default:
911  return false;
912  }
913  }
914  catch (CDB_Exception&) {
915  GetConnection().CancelFinished(was_timeout);
916  throw;
917  }
918  } else {
919  return false;
920  }
921  } else {
923  }
924 
925  return true;
926 }
927 
928 bool
930 {
931  CS_RETCODE rc;
932 
933  if (IsDead()) {
934  SetHasFailed();
935  DATABASE_DRIVER_ERROR( "Connection has died." + GetDbgInfo(), 121008 );
936  }
937 
938  try {
940  rc = Check(ct_send(x_GetSybaseCmd()));
941  } catch (...) {
942  SetHasFailed();
944  Cancel();
945  throw;
946  }
947 
948  switch (rc) {
949  case CS_SUCCEED:
950  break;
951  case CS_FAIL:
952  SetHasFailed();
954  Cancel();
955  // IsAlive digs deeper than IsDead, and sockets whose peers have
956  // disconnected remain nominally open until their owners try to
957  // use them, so checking after trying to send is most effective.
958  if (GetConnection().IsAlive()) {
959  DATABASE_DRIVER_ERROR("ct_send failed." + GetDbgInfo(), 121005);
960  } else {
961  DATABASE_DRIVER_ERROR("Connection has died." + GetDbgInfo(),
962  121008);
963  }
964  case CS_CANCELED:
965  DATABASE_DRIVER_ERROR( "Command was canceled." + GetDbgInfo(), 121006 );
966 #ifdef CS_BUSY
967  case CS_BUSY:
968  DATABASE_DRIVER_ERROR( "Connection has another request pending." + GetDbgInfo(), 121007 );
969 #endif
970  case CS_PENDING:
971  default:
972  SetWasSent();
973  return false;
974  }
975 
976  SetWasSent();
977  return true;
978 }
979 
980 
981 /////////////////////////////////////////////////////////////////////////////
982 //
983 // CTL_LangCmd::
984 //
985 
987  const string& lang_query
988  )
989 : CTL_LRCmd(conn, lang_query)
990 {
991  SetExecCntxInfo("SQL Command: \"" + lang_query + "\"");
992 }
993 
994 
996 {
998 
1000  Cancel();
1001 
1002  SetHasFailed(false);
1003 
1004  CTempString dyn_id = x_GetDynamicID();
1005  if (dyn_id.empty()) {
1008  const_cast<char*>(GetQuery().data()),
1009  static_cast<CS_INT>(GetQuery().size()), CS_END),
1010  "ct_command failed", 120001);
1011  } else if (dyn_id == "!") {
1012  return false;
1013  } else {
1016  const_cast<char*>(dyn_id.data()),
1017  static_cast<CS_INT>(dyn_id.size()), NULL, 0),
1018  "ct_dynamic(CS_EXECUTE) failed", 120004);
1019  }
1020 
1022  CHECK_DRIVER_ERROR( HasFailed(), "Cannot assign the params." + GetDbgInfo(), 120003 );
1023 
1024  return SendInternal();
1025 }
1026 
1027 
1029 {
1030  return MakeResult();
1031 }
1032 
1034 {
1035  return WasSent();
1036 }
1037 
1038 
1040 {
1041  return m_RowCount;
1042 }
1043 
1044 
1046 {
1047  if ( !m_DynamicID.empty() ) {
1048  try {
1050  const_cast<char*>(m_DynamicID.data()),
1051  static_cast<CS_INT>(m_DynamicID.size()),
1052  NULL, 0),
1053  "ct_dynamic(CS_DEALLOC) failed", 120005);
1054  if (SendInternal()) {
1055  while (HasMoreResults()) {
1056  unique_ptr<CDB_Result> r(Result());
1057  }
1058  }
1059  }
1061  }
1062  try {
1063  DropCmd(*this);
1064 
1065  Close();
1066  }
1068 }
1069 
1070 
1071 void
1073 {
1074  // ????
1075  DetachInterface();
1076 
1077  try {
1079  SetDead(!Cancel());
1080  } catch (...) {
1081  SetDead();
1082  throw;
1083  }
1084 }
1085 
1086 
1088 {
1089  CS_DATAFMT param_fmt;
1090  memset(&param_fmt, 0, sizeof(param_fmt));
1091  param_fmt.status = CS_INPUTVALUE;
1092 
1093  for (unsigned int i = 0; i < GetBindParamsImpl().NofParams(); i++) {
1094  auto status = GetBindParamsImpl().GetParamStatus(i);
1095  if (status == 0) {
1096  continue;
1097  } else if ((status & impl::CDB_Params::fOutput) != 0) {
1098  param_fmt.status |= CS_RETURN;
1099  } else {
1100  param_fmt.status &= ~CS_RETURN;
1101  }
1102 
1103  CDB_Object& param = *GetBindParamsImpl().GetParam(i);
1104  const string& param_name = GetBindParamsImpl().GetParamName(i);
1105 
1106  if ( !AssignCmdParam(param,
1107  param_name,
1108  param_fmt,
1109  false/*!declare_only*/) )
1110  {
1111  return false;
1112  }
1113  }
1114 
1116  return true;
1117 }
1118 
1119 
1121 {
1123  static const char kValid[] =
1124  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@$#_";
1125 
1126  if ( !m_DynamicID.empty() ) {
1127  // Perhaps double check that we still want to use it?
1128  return m_DynamicID;
1129  }
1130 
1131  if (GetBindParamsImpl().NofParams() == 0 || query.find('?') == NPOS) {
1132  return kEmptyStr;
1133  } else if (query.find('@') != NPOS) {
1134  if (count(query.begin(), query.end(), '?')
1135  < GetBindParamsImpl().NofParams()) {
1136  ERR_POST_X(7, Info << "Query " << NStr::CEncode(query)
1137  << " contains both ? and @. Treating @ as the"
1138  " parameter indicator because there are more"
1139  " parameters than question marks.");
1140  }
1141  set<CTempString> used, found, not_found;
1142  SIZE_TYPE pos = query.find('@');
1143  do {
1144  SIZE_TYPE pos2 = query.find_first_not_of(kValid, pos);
1145  if (pos2 == NPOS) {
1146  used.insert(query.substr(pos));
1147  break;
1148  } else {
1149  used.insert(query.substr(pos, pos2 - pos));
1150  pos = query.find('@', pos2);
1151  }
1152  } while (pos != NPOS);
1153  for (unsigned int i = 0; i < GetBindParamsImpl().NofParams(); i++) {
1154  if (GetBindParamsImpl().GetParamStatus(i) == 0) continue;
1155  const string& name = GetBindParamsImpl().GetParamName(i);
1156  if (used.find(name) == used.end()) {
1157  not_found.insert(name);
1158  } else {
1159  found.insert(name);
1160  }
1161  }
1162  if (not_found.empty()) {
1163  ERR_POST_X(7, Info << "Query " << NStr::CEncode(query)
1164  << " contains both ? and @. Treating @ as the"
1165  " parameter indicator because all supplied parameter"
1166  " names appear: "
1167  << NStr::Join(found, ", "));
1168  return kEmptyStr;
1169  } else {
1170  ERR_POST_X(8, Info << "Query " << NStr::CEncode(query)
1171  << " contains both ? and @. Treating ? as the"
1172  " parameter indicator because there are enough"
1173  " question marks and some or all supplied"
1174  " parameter names are absent: "
1175  << NStr::Join(not_found, ", "));
1176  }
1177  }
1178 
1179  m_DynamicID = NStr::NumericToString(reinterpret_cast<uintptr_t>(this),
1180  0, 16);
1182  const_cast<char*>(m_DynamicID.data()),
1183  static_cast<CS_INT>(m_DynamicID.size()),
1184  const_cast<char*>(query.data()),
1185  static_cast<CS_INT>(query.size())),
1186  "ct_dynamic(CS_PREPARE) failed", 120002);
1187  if ( !SendInternal() ) {
1188  return "!";
1189  }
1190  while (HasMoreResults()) {
1191  unique_ptr<CDB_Result> r(Result());
1192  }
1193  return m_DynamicID;
1194 }
1195 
1196 #ifdef FTDS_IN_USE
1197 } // namespace NCBI_NS_FTDS_CTLIB
1198 #endif
1199 
1201 
1202 
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
CDB_Exception –.
Definition: exception.hpp:118
void SetValue(const CTempString &s)
CTempString GetValue(void) const
void SetDead(bool flag=true)
Definition: interfaces.hpp:688
void SetTimedOut(bool val)
Definition: interfaces.hpp:722
void DropCmd(impl::CCommand &cmd)
virtual ~CTL_CmdBase(void)
Definition: lang_cmd.cpp:93
void SetRetriable(ERetriable val)
Definition: interfaces.hpp:732
CS_RETCODE Check(CS_RETCODE rc)
Definition: lang_cmd.cpp:102
CTL_Connection & GetConnection(void)
bool IsDead(void) const
Definition: interfaces.hpp:684
void EnsureActiveStatus(void)
Definition: lang_cmd.cpp:114
CTL_CmdBase(CTL_Connection &conn, const string &query)
Definition: lang_cmd.cpp:62
ERetriable GetRetriable(void) const
Definition: interfaces.hpp:727
bool GetTimedOut(void) const
Definition: interfaces.hpp:717
virtual void SetHasFailed(bool flag=true)
Definition: interfaces.hpp:700
void SetExecCntxInfo(const string &info)
Definition: interfaces.hpp:675
const TDbgInfo & GetDbgInfo(void) const
Definition: interfaces.hpp:711
CTL_RowResult * MakeStatusResult(void)
void SetResult(CTL_RowResult *result)
Definition: interfaces.hpp:789
CTL_RowResult * MakeRowResult(void)
bool AssignCmdParam(CDB_Object &param, const string &param_name, CS_DATAFMT &param_fmt, bool declare_only=false)
Definition: lang_cmd.cpp:230
void MarkEndOfReply(void)
bool ProcessResultInternal(CDB_Result &res)
Definition: lang_cmd.cpp:220
void DropSybaseCmd(void)
Definition: lang_cmd.cpp:204
CTL_RowResult * MakeComputeResult(void)
CTL_Cmd(CTL_Connection &conn, const string &query)
Definition: lang_cmd.cpp:131
CS_COMMAND * m_Cmd
Definition: interfaces.hpp:813
CS_COMMAND * x_GetSybaseCmd(void) const
virtual ~CTL_Cmd(void)
Definition: lang_cmd.cpp:164
void GetRowCount(int *cnt)
Definition: lang_cmd.cpp:631
void DeleteResult(void)
void DeleteResultInternal(void)
void x_Init(void)
Definition: lang_cmd.cpp:148
CTL_RowResult & GetResult(void)
CTL_RowResult * MakeParamResult(void)
CS_RETCODE CheckSFB_Internal(CS_RETCODE rc, const char *msg, unsigned int msg_num)
Definition: lang_cmd.cpp:182
const CTLibContext & GetCTLibContext(void) const
Definition: interfaces.hpp:401
CS_RETCODE Check(CS_RETCODE rc)
Definition: connection.cpp:458
size_t PrepareToCancel(void)
Definition: connection.cpp:604
void CancelFinished(size_t was_timeout)
Definition: connection.cpp:614
CTL_CmdBase * m_ActiveCmd
Definition: interfaces.hpp:530
bool m_CancelRequested
Definition: interfaces.hpp:535
CS_RETCODE CheckSFB(CS_RETCODE rc, const char *msg, unsigned int msg_num)
Definition: lang_cmd.cpp:673
bool x_Cancel(ECancelType cancel_type) override
Definition: lang_cmd.cpp:867
CTL_RowResult * MakeResultInternal(void)
Definition: lang_cmd.cpp:696
CTL_LRCmd(CTL_Connection &conn, const string &query)
Definition: lang_cmd.cpp:653
virtual ~CTL_LRCmd(void)
Definition: lang_cmd.cpp:660
bool SendInternal(void)
Definition: lang_cmd.cpp:929
CDB_Result * MakeResult(void)
Definition: lang_cmd.cpp:840
bool Cancel(void) override
Cancel the command execution.
Definition: lang_cmd.cpp:849
virtual bool Send(void)
Send command to the server.
Definition: lang_cmd.cpp:995
void Close(void)
Definition: lang_cmd.cpp:1072
virtual CDB_Result * Result(void)
Get result set.
Definition: lang_cmd.cpp:1028
string m_DynamicID
Definition: interfaces.hpp:871
bool x_AssignParams(void)
Definition: lang_cmd.cpp:1087
virtual int RowCount(void) const
Get the number of rows affected by the command Special case: negative on error or if there is no way ...
Definition: lang_cmd.cpp:1039
CTL_LangCmd(CTL_Connection &conn, const string &lang_query)
Definition: lang_cmd.cpp:986
CTempString x_GetDynamicID(void)
Definition: lang_cmd.cpp:1120
virtual ~CTL_LangCmd(void)
Definition: lang_cmd.cpp:1045
virtual bool HasMoreResults(void) const
Definition: lang_cmd.cpp:1033
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
CTime –.
Definition: ncbitime.hpp:296
const string & GetQuery(void) const
virtual bool HasFailed(void) const
const CDB_Params & GetBindParamsImpl(void) const
void DetachInterface(void)
void SetWasSent(bool flag=true)
bool WasSent(void) const
static CDB_Result * Create_Result(CResult &result)
CDB_ResultProcessor * GetResultProcessor(void) const
CDBConnParams::EServerType GetServerType(void)
CDB_Object * GetParam(unsigned int param_no) const
Definition: parameters.hpp:63
void LockBinding(void)
Definition: parameters.hpp:87
const string & GetParamName(unsigned int param_no) const
Definition: parameters.hpp:67
TStatus GetParamStatus(unsigned int param_no) const
Definition: parameters.hpp:83
unsigned int NofParams() const
Definition: parameters.hpp:59
EEncoding GetClientEncoding(void) const
Definition: set.hpp:45
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
char value[7]
Definition: config.c:431
#define CS_CMD_DONE
Definition: cspublic.h:436
#define CS_CANCELED
Definition: cspublic.h:53
#define CS_LONGCHAR_TYPE
Definition: cspublic.h:552
#define CS_SMALLINT_TYPE
Definition: cspublic.h:557
#define CS_CMD_SUCCEED
Definition: cspublic.h:437
#define CS_BINARY_TYPE
Definition: cspublic.h:551
#define CS_FAIL
Definition: cspublic.h:41
#define CS_INPUTVALUE
Definition: cspublic.h:293
#define CS_PENDING
Definition: cspublic.h:43
#define CS_DATETIME4_TYPE
Definition: cspublic.h:563
#define CS_PARAM_RESULT
Definition: cspublic.h:540
#define CS_LANG_CMD
Definition: cspublic.h:441
#define CS_COMPUTEFMT_RESULT
Definition: cspublic.h:543
#define CS_FLOAT_TYPE
Definition: cspublic.h:560
#define CS_LONGBINARY_TYPE
Definition: cspublic.h:553
#define CS_RETURN
Definition: cspublic.h:295
#define CS_MSG_RESULT
Definition: cspublic.h:545
#define CS_BIT_TYPE
Definition: cspublic.h:561
#define CS_BUSY
Definition: cspublic.h:45
#define CS_REAL_TYPE
Definition: cspublic.h:559
#define CS_STATUS_RESULT
Definition: cspublic.h:542
#define CS_DEALLOC
Definition: cspublic.h:506
#define CS_CHAR_TYPE
Definition: cspublic.h:550
@ CS_TDS_72
Definition: cspublic.h:276
#define CS_DATETIME_TYPE
Definition: cspublic.h:562
#define CS_INT_TYPE
Definition: cspublic.h:558
#define CS_EXECUTE
Definition: cspublic.h:502
#define CS_TINYINT_TYPE
Definition: cspublic.h:556
#define CS_ROWFMT_RESULT
Definition: cspublic.h:544
#define CS_UNUSED
Definition: cspublic.h:425
#define CS_ROW_COUNT
Definition: cspublic.h:469
#define CS_ROW_RESULT
Definition: cspublic.h:541
#define CS_TEXT_TYPE
Definition: cspublic.h:554
#define CS_COMPUTE_RESULT
Definition: cspublic.h:538
#define CS_SUCCEED
Definition: cspublic.h:40
#define CS_CMD_FAIL
Definition: cspublic.h:438
@ CS_END
Definition: cspublic.h:381
#define CS_PREPARE
Definition: cspublic.h:501
#define CS_END_RESULTS
Definition: cspublic.h:56
#define CS_IMAGE_TYPE
Definition: cspublic.h:555
#define CS_NUMERIC_TYPE
Definition: cspublic.h:566
#define CS_NO_COUNT
Definition: cspublic.h:490
Int4 CS_INT
Definition: cstypes.h:41
double CS_FLOAT
Definition: cstypes.h:51
float CS_REAL
Definition: cstypes.h:50
#define CS_MAX_NAME
Definition: cstypes.h:65
unsigned char CS_BIT
Definition: cstypes.h:61
Int2 CS_SMALLINT
Definition: cstypes.h:45
unsigned char CS_TINYINT
Definition: cstypes.h:47
void CS_VOID
Definition: cstypes.h:53
CS_INT CS_RETCODE
Definition: cstypes.h:63
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
impl::CDBExceptionStorage & GetCTLExceptionStorage(void)
Definition: ctlib_utils.cpp:41
CS_RETCODE ct_dynamic(CS_COMMAND *cmd, CS_INT type, CS_CHAR *id, CS_INT idlen, CS_CHAR *buffer, CS_INT buflen)
Definition: ct.c:3300
CS_RETCODE ct_command(CS_COMMAND *cmd, CS_INT type, const CS_VOID *buffer, CS_INT buflen, CS_INT option)
Definition: ct.c:760
CS_RETCODE ct_results(CS_COMMAND *cmd, CS_INT *result_type)
Definition: ct.c:1172
CS_RETCODE ct_res_info(CS_COMMAND *cmd, CS_INT type, CS_VOID *buffer, CS_INT buflen, CS_INT *out_len)
Definition: ct.c:2491
CS_RETCODE ct_cmd_drop(CS_COMMAND *cmd)
Definition: ct.c:1881
CS_RETCODE ct_cmd_alloc(CS_CONNECTION *con, CS_COMMAND **cmd)
Definition: ct.c:728
CS_RETCODE ct_param(CS_COMMAND *cmd, CS_DATAFMT *datafmt, CS_VOID *data, CS_INT datalen, CS_SMALLINT indicator)
Definition: ct.c:3365
CS_RETCODE ct_send(CS_COMMAND *cmd)
Definition: ct.c:913
CS_RETCODE ct_cancel(CS_CONNECTION *conn, CS_COMMAND *cmd, CS_INT type)
Definition: ct.c:2201
#define NCBI_CS_STRING_TYPE
Definition: interfaces.hpp:102
@ eRetriable_Unknown
It is unknown if the action can succeed if retried.
Definition: ncbimisc.hpp:169
#define NULL
Definition: ncbistd.hpp:225
#define DATABASE_DRIVER_ERROR(message, err_code)
Definition: exception.hpp:740
#define DATABASE_DRIVER_INFO(message, err_code)
Definition: exception.hpp:758
#define CHECK_DRIVER_ERROR(failed, message, err_code)
Definition: exception.hpp:765
#define DATABASE_DRIVER_WARNING(message, err_code)
Definition: exception.hpp:746
#define DATABASE_DRIVER_FATAL(message, err_code)
Definition: exception.hpp:752
virtual void ProcessResult(CDB_Result &res)
The default implementation just dumps all rows.
Definition: public.cpp:1208
Uint2 GetMinutes(void) const
Definition: types.cpp:2401
double Value() const
Definition: types.hpp:850
const void * Value() const
Definition: types.hpp:756
static EBlobType GetBlobType(EDB_Type db_type)
Definition: types.hpp:1216
float Value() const
Definition: types.hpp:825
const TOffset & GetOffset(void) const
Definition: types.hpp:1109
@ eBlobType_Binary
Definition: types.hpp:81
@ eBlobType_Text
Definition: types.hpp:80
const char * Value(void) const
Definition: types.hpp:537
size_t Size() const
Definition: types.hpp:693
size_t Size() const
Definition: types.hpp:759
virtual EDB_Type GetType() const =0
const CTime & GetCTime(void) const
Definition: types.hpp:1107
Int4 Value() const
Definition: types.hpp:373
Int2 Value() const
Definition: types.hpp:400
virtual bool MoveTo(size_t byte_number)
Definition: types.cpp:2008
Uint2 GetDays(void) const
Definition: types.cpp:2391
size_t Size(void) const
Definition: types.hpp:522
int Value() const
Definition: types.hpp:1145
Uint1 Value() const
Definition: types.hpp:427
ESQLType GetSQLType(void) const
Definition: types.hpp:1111
const string & AsString(void) const
Definition: types.hpp:517
static CTimeFormat GetTimeFormat(ESyntax syntax, ESQLType sql_type=eDateTime, TOffset offset=null)
Definition: types.cpp:2623
Int4 GetDays(void) const
Definition: types.cpp:2501
virtual size_t Read(void *buff, size_t nof_bytes)
Definition: types.cpp:1987
Int4 Get300Secs(void) const
Definition: types.cpp:2511
const char * Data(void) const
Definition: types.hpp:527
virtual size_t Size() const
Definition: types.cpp:2014
Int8 Value() const
Definition: types.hpp:454
bool IsNULL() const
Definition: types.hpp:303
@ eDB_Bit
Definition: types.hpp:68
@ eDB_Char
Definition: types.hpp:58
@ eDB_UnsupportedType
Definition: types.hpp:75
@ eDB_SmallDateTime
Definition: types.hpp:65
@ eDB_VarChar
Definition: types.hpp:57
@ eDB_TinyInt
Definition: types.hpp:55
@ eDB_LongChar
Definition: types.hpp:70
@ eDB_Double
Definition: types.hpp:62
@ eDB_Image
Definition: types.hpp:67
@ eDB_Float
Definition: types.hpp:61
@ eDB_Int
Definition: types.hpp:53
@ eDB_VarCharMax
Definition: types.hpp:72
@ eDB_Numeric
Definition: types.hpp:69
@ eDB_BigInt
Definition: types.hpp:56
@ eDB_BigDateTime
Definition: types.hpp:64
@ eDB_Binary
Definition: types.hpp:60
@ eDB_Text
Definition: types.hpp:66
@ eDB_SmallInt
Definition: types.hpp:54
@ eDB_DateTime
Definition: types.hpp:63
@ eDB_LongBinary
Definition: types.hpp:71
@ eDB_VarBinary
Definition: types.hpp:59
@ eDB_VarBinaryMax
Definition: types.hpp:73
#define DIAG_COMPILE_INFO
Make compile time diagnostic information object to use in CNcbiDiag and CException.
Definition: ncbidiag.hpp:170
#define NCBI_CURRENT_FUNCTION
Get current function name.
Definition: ncbidiag.hpp:142
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
@ eDiag_Error
Error message.
Definition: ncbidiag.hpp:653
#define NCBI_CATCH_ALL_X(err_subcode, message)
Definition: ncbiexpt.hpp:619
void Info(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1185
unsigned int uintptr_t
Definition: ncbitype.h:197
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
#define kMax_UI1
Definition: ncbi_limits.h:213
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
std::string CStringUTF8
Definition: ncbistl.hpp:254
NCBI_NS_STD::string::size_type SIZE_TYPE
Definition: ncbistr.hpp:132
#define kEmptyStr
Definition: ncbistr.hpp:123
#define NPOS
Definition: ncbistr.hpp:133
CTempString & assign(const char *src_str, size_type len)
Assign new values to the content of the a string.
Definition: tempstr.hpp:733
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
Definition: ncbistr.hpp:2697
const char * data(void) const
Return a pointer to the array represented.
Definition: tempstr.hpp:313
bool empty(void) const
Return true if the represented string is empty (i.e., the length is zero)
Definition: tempstr.hpp:334
static CStringUTF8 AsUTF8(const CTempString &src, EEncoding encoding, EValidate validate=eNoValidate)
Convert into UTF8 from a C/C++ string.
Definition: ncbistr.hpp:3888
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
static string CEncode(const CTempString str, EQuoted quoted=eQuoted)
Encode a string for C/C++.
Definition: ncbistr.cpp:3963
size_type size(void) const
Return the length of the represented array.
Definition: tempstr.hpp:327
@ eEncoding_UTF8
Definition: ncbistr.hpp:201
@ eValidate
Definition: ncbistr.hpp:3877
Int4 days
days from 1/1/1900
Definition: ncbitime.hpp:115
CTime & SetTimeDBI(const TDBTimeI &t)
Set time using database format time, TDBTimeI.
Definition: ncbitime.cpp:1495
Int4 time
x/300 seconds from the beginning of current day
Definition: ncbitime.hpp:116
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
Definition of all error codes used in dbapi libraries (dbapi_driver.lib and others).
char * buf
int i
if(yy_accept[yy_current_state])
yy_size_t n
void Check(const string &value)
const struct ncbi::grid::netcache::search::fields::SIZE size
EIPRangeType t
Definition: ncbi_localip.c:101
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
unsigned char * longlong_to_numeric(Int8 l_num, unsigned int prec, unsigned char *cs_num)
static unsigned cnt[256]
#define GetDbgInfo()
Definition: lang_cmd.cpp:53
Database format for time where day and time is signed 32 bit.
Definition: ncbitime.hpp:114
CS_INT maxlength
Definition: cstypes.h:127
CS_INT precision
Definition: cstypes.h:129
CS_INT datatype
Definition: cstypes.h:125
CS_INT scale
Definition: cstypes.h:128
CS_INT namelen
Definition: cstypes.h:124
CS_CHAR name[132]
Definition: cstypes.h:123
CS_INT status
Definition: cstypes.h:130
CS_USHORT minutes
Definition: cstypes.h:163
CS_USHORT days
Definition: cstypes.h:162
CS_INT dttime
Definition: cstypes.h:157
CS_INT dtdays
Definition: cstypes.h:156
static string query
#define _TROUBLE
#define _ASSERT
else result
Definition: token2.c:20
Modified on Sat Dec 09 04:48:52 2023 by modify_doxy.py rev. 669887