NCBI C++ ToolKit
interfaces.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef DBAPI_DRIVER_CTLIB___INTERFACES__HPP
2 #define DBAPI_DRIVER_CTLIB___INTERFACES__HPP
3 
4 /* $Id: interfaces.hpp 94141 2021-06-29 14:36:29Z ucko $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Author: Vladimir Soussov
30  *
31  * File Description: Driver for CTLib server
32  *
33  */
34 
35 #include <dbapi/driver/public.hpp> // Kept for compatibility reasons ...
40 
42 
43 #include <ctpublic.h>
44 #include <bkpublic.h>
45 
46 #ifdef FTDS_IN_USE
47 
48 # if defined(NCBI_FTDS_VERSION_NAME) && defined(NCBI_IS_FTDS_DEFAULT)
49 # undef NCBI_FTDS_VERSION_NAME
50 # undef NCBI_FTDS_VERSION_NAME2
51 # define NCBI_FTDS_VERSION_NAME(X) X
52 # define NCBI_FTDS_VERSION_NAME2(X,Y) X ## Y
53 # elif defined(NCBI_DBAPI_RENAME_CTLIB)
54 # include <../impl/ncbi_ftds_ver.h>
55 # else
56 # define NCBI_FTDS_VERSION 0
57 # define NCBI_FTDS_VERSION_NAME(X) X
58 # define NCBI_FTDS_VERSION_NAME2(X,Y) X ## Y
59 # endif
60 
61 # define NCBI_NS_FTDS_CTLIB NCBI_FTDS_VERSION_NAME2(ftds,_ctlib)
62 
63 // Make it look like the ftds driver ...
64 # define CTLibContext CTDSContext
65 # define CTL_Connection CTDS_Connection
66 # define CTL_Cmd CTDS_Cmd
67 # define CTL_CmdBase CTDS_CmdBase
68 # define CTL_LangCmd CTDS_LangCmd
69 # define CTL_RPCCmd CTDS_RPCCmd
70 # define CTL_CursorCmd CTDS_CursorCmd
71 # define CTL_BCPInCmd CTDS_BCPInCmd
72 # define CTL_SendDataCmd CTDS_SendDataCmd
73 # define CTL_Result CTDS_Result
74 # define CTL_RowResult CTDS_RowResult
75 # define CTL_ParamResult CTDS_ParamResult
76 # define CTL_ComputeResult CTDS_ComputeResult
77 # define CTL_StatusResult CTDS_StatusResult
78 # define CTL_CursorResult CTDS_CursorResult
79 # define CTL_CursorResultExpl CTDS_CursorResultExpl
80 # define CTL_BlobResult CTDS_BlobResult
81 # define CTL_BlobDescriptor CTDS_BlobDescriptor
82 # define CTL_CursorBlobDescriptor CTDS_CursorBlobDescriptor
83 # define CTLibContextRegistry CTDSContextRegistry
84 
85 // historical names
86 # define CTL_ITDescriptor CTDS_ITDescriptor
87 # define CTL_CursorITDescriptor CTDS_CursorITDescriptor
88 
89 # define CTLIB_SetApplicationName TDS_SetApplicationName
90 # define CTLIB_SetHostName TDS_SetHostName
91 # define CTLIB_SetPacketSize TDS_SetPacketSize
92 # define CTLIB_SetMaxNofConns TDS_SetMaxNofConns
93 
94 # define NCBI_CS_STRING_TYPE CS_VARCHAR_TYPE
95 # if NCBI_FTDS_VERSION >= 91
96 # define USE_STRUCT_CS_VARCHAR 1
97 # endif
98 
99 #else
100 
101 // There is a problem with CS_VARCHAR_TYPE on x86_64 ...
102 # define NCBI_CS_STRING_TYPE CS_CHAR_TYPE
103 
104 #endif // FTDS_IN_USE
105 
107 
108 #ifdef FTDS_IN_USE
109 namespace NCBI_NS_FTDS_CTLIB
110 {
111 #endif
112 
113 class CTLibContext;
114 class CTL_Connection;
115 class CTL_Cmd;
116 class CTL_CmdBase;
117 class CTL_LangCmd;
118 class CTL_RPCCmd;
119 class CTL_CursorCmd;
120 class CTL_CursorCmdExpl;
121 class CTL_BCPInCmd;
122 class CTL_SendDataCmd;
123 class CTL_RowResult;
124 class CTL_ParamResult;
125 class CTL_ComputeResult;
126 class CTL_StatusResult;
127 class CTL_CursorResult;
131 
132 
134 
135 /////////////////////////////////////////////////////////////////////////////
136 namespace ctlib
137 {
138 
140 {
141 public:
142  Connection(CTLibContext& context, CTL_Connection& ctl_conn);
143  ~Connection(void) noexcept;
144  /// Drop allocated connection.
145  bool Drop(void);
146 
147 public:
149  {
150  return m_Handle;
151  }
152 
153  bool IsOpen(void) const
154  {
155  return m_IsOpen;
156  }
157  bool Open(const CDBConnParams& params);
158  bool Close(void);
159  // cancel all pending commands
160  bool Cancel(void);
161  bool IsAlive(void);
162  // Ask ctlib directly whether a connection is open or not ...
163  bool IsOpen_native(void);
164 
165  bool IsDead(void) const
166  {
167  return m_IsDead;
168  }
169  void SetDead(bool flag = true)
170  {
171  // When connection is dead it doen't mean that it was automatically
172  // closed from ctlib's point of view.
173  m_IsDead = flag;
174  }
175 
176 protected:
177  const CTL_Connection& GetCTLConn(void) const;
178  CTL_Connection& GetCTLConn(void);
179 
180  const CTLibContext& GetCTLContext(void) const
181  {
182  _ASSERT(m_CTL_Context);
183  return *m_CTL_Context;
184  }
186  {
187  _ASSERT(m_CTL_Context);
188  return *m_CTL_Context;
189  }
190 
191  CS_RETCODE CheckWhileOpening(CS_RETCODE rc);
192 
193 private:
198  bool m_IsOpen;
199  bool m_IsDead;
200 };
201 
202 ////////////////////////////////////////////////////////////////////////////////
203 class Command
204 {
205 public:
206  Command(CTL_Connection& ctl_conn);
207  ~Command(void);
208 
209 public:
211  {
212  return m_Handle;
213  }
214 
215  bool Open(CS_INT type, CS_INT option, const string& arg = kEmptyCStr);
216  bool GetDataInfo(CS_IODESC& desc);
217  bool SendData(CS_VOID* buff, CS_INT buff_len);
218  bool Send(void);
219  CS_RETCODE GetResults(CS_INT& res_type);
220  CS_RETCODE Fetch(void);
221 
222 protected:
223  const CTL_Connection& GetCTLConn(void) const
224  {
225  _ASSERT(m_CTL_Conn);
226  return *m_CTL_Conn;
227  }
229  {
230  _ASSERT(m_CTL_Conn);
231  return *m_CTL_Conn;
232  }
233 
234  void Drop(void);
235  void Close(void);
236 
237 private:
241  bool m_IsOpen;
242 };
243 
244 } // namespace ctlib
245 
246 /////////////////////////////////////////////////////////////////////////////
247 //
248 // CTLibContext::
249 //
250 
252  public impl::CDriverContext,
253  public impl::CWinSock
254 {
255  friend class ncbi::CDB_Connection;
256 
257 public:
258  CTLibContext(bool reuse_context = true,
260  virtual ~CTLibContext(void);
261 
262 public:
263  //
264  // GENERIC functionality (see in <dbapi/driver/interfaces.hpp>)
265  //
266 
267  virtual bool SetLoginTimeout (unsigned int nof_secs = 0);
268  virtual bool SetTimeout (unsigned int nof_secs = 0);
269  virtual bool SetMaxBlobSize (size_t nof_bytes);
270 
271  virtual void InitApplicationName(void);
272 
273  virtual unsigned int GetLoginTimeout(void) const;
274  virtual unsigned int GetTimeout (void) const;
275 
276  virtual string GetDriverName(void) const;
277 
278  //
279  // CTLIB specific functionality
280  //
281 
282  // the following methods are optional (driver will use the default values
283  // if not called), the values will affect the new connections only
284 
285  // Deprecated. Use SetApplicationName instead.
287  virtual void CTLIB_SetApplicationName(const string& a_name);
288  // Deprecated. Use SetHostName instead.
290  virtual void CTLIB_SetHostName(const string& host_name);
291  virtual void CTLIB_SetPacketSize(CS_INT packet_size);
292  virtual void CTLIB_SetLoginRetryCount(CS_INT n);
293  virtual void CTLIB_SetLoginLoopDelay(CS_INT nof_sec);
294 
295  virtual bool IsAbleTo(ECapability cpb) const;
296 
297  /// Set maximal number of open connections.
298  /// Default value is 30.
299  bool SetMaxConnect(unsigned int num);
300  unsigned int GetMaxConnect(void);
301 
302  virtual CS_CONTEXT* CTLIB_GetContext(void) const;
303  CS_LOCALE* GetLocale(void) const
304  {
305  return m_Locale;
306  }
307 
308  static CS_RETCODE CS_PUBLIC CTLIB_cserr_handler(CS_CONTEXT* context,
309  CS_CLIENTMSG* msg);
310  static CS_RETCODE CS_PUBLIC CTLIB_cterr_handler(CS_CONTEXT* context,
311  CS_CONNECTION* con,
312  CS_CLIENTMSG* msg);
313  static CS_RETCODE CS_PUBLIC CTLIB_srverr_handler(CS_CONTEXT* context,
314  CS_CONNECTION* con,
315  CS_SERVERMSG* msg);
316 
317  CS_INT GetTDSVersion(void) const
318  {
319  return m_TDSVersion;
320  }
321  CS_INT GetPacketSize(void) const
322  {
323  return m_PacketSize;
324  }
326  {
327  return m_LoginRetryCount;
328  }
330  {
331  return m_LoginLoopDelay;
332  }
333 
334  virtual void SetClientCharset(const string& charset);
335  CS_RETCODE Check(CS_RETCODE rc) const;
336 
337 protected:
338  virtual impl::CConnection* MakeIConnection(const CDBConnParams& params);
339  CRWLock& x_GetCtxLock(void) const;
340 
341 private:
350 
351  void x_AddToRegistry(void);
352  void x_RemoveFromRegistry(void);
353  void x_SetRegistry(CTLibContextRegistry* registry);
354  // Deinitialize all internal structures.
355  void x_Close(bool delete_conn = true);
356  bool x_SafeToFinalize(void) const;
357 
358 #if defined(FTDS_IN_USE) && NCBI_FTDS_VERSION >= 95
359  typedef int (*FIntHandler)(void*);
360  FIntHandler m_OrigIntHandler;
361 #endif
362 
363  friend class CTLibContextRegistry;
364  friend class ctlib::Connection;
365 };
366 
367 
368 
369 /////////////////////////////////////////////////////////////////////////////
370 //
371 // CTL_Connection::
372 //
373 
375 {
376  friend class CTLibContext;
377  friend class ctlib::Connection;
378  friend class ncbi::CDB_Connection;
379  friend class CTL_Cmd;
380  friend class CTL_CmdBase;
381  friend class CTL_LRCmd;
382  friend class CTL_LangCmd;
383  friend class CTL_RPCCmd;
384  friend class CTL_SendDataCmd;
385  friend class CTL_BCPInCmd;
386  friend class CTL_CursorCmd;
387  friend class CTL_CursorCmdExpl;
388  friend class CTL_CursorResultExpl;
389  friend class CTL_RowResult;
390 
391 protected:
393  const CDBConnParams& params);
394  virtual ~CTL_Connection(void);
395 
396 public:
398  CS_RETCODE Check(CS_RETCODE rc, const TDbgInfo& dbg_info);
399  CS_INT GetBLKVersion(void) const;
400 
401  const CTLibContext& GetCTLibContext(void) const
402  {
403  _ASSERT(m_Cntx);
404  return *m_Cntx;
405  }
407  {
408  _ASSERT(m_Cntx);
409  return *m_Cntx;
410  }
411 
413  {
414  return m_Handle;
415  }
417  {
418  return m_Handle;
419  }
420 
421  virtual bool IsAlive(void);
422  bool IsOpen(void)
423  {
424  return m_Handle.IsOpen();
425  }
426 
427  void DeferTimeout(void);
428 
429 #if defined(FTDS_IN_USE) && NCBI_FTDS_VERSION >= 95
430  void SetCancelTimedOut(bool val)
431  {
432  m_CancelTimedOut = val;
433  }
434 
435  bool GetCancelTimedOut(void) const
436  {
437  return m_CancelTimedOut;
438  }
439 #endif
440 
441 
442 protected:
443  virtual CDB_LangCmd* LangCmd (const string& lang_query);
444  virtual CDB_RPCCmd* RPC (const string& rpc_name);
445  virtual CDB_BCPInCmd* BCPIn (const string& table_name);
446  virtual CDB_CursorCmd* Cursor (const string& cursor_name,
447  const string& query,
448  unsigned int batch_size = 1);
449  virtual CDB_SendDataCmd* SendDataCmd (I_BlobDescriptor& desc,
450  size_t data_size,
451  bool log_it = true,
452  bool dump_results = true);
453 
454  virtual bool SendData(I_BlobDescriptor& desc, CDB_Stream& lob,
455  bool log_it = true);
456 
457  virtual bool Refresh(void);
458  virtual I_DriverContext::TConnectionMode ConnectMode(void) const;
459 
460  // This method is required for CTL_CursorCmdExpl only ...
461  CTL_LangCmd* xLangCmd(const string& lang_query);
462 
463  // abort the connection
464  // Attention: it is not recommended to use this method unless you absolutely have to.
465  // The expected implementation is - close underlying file descriptor[s] without
466  // destroing any objects associated with a connection.
467  // Returns: true - if succeed
468  // false - if not
469  virtual bool Abort(void);
470 
471  /// Close an open connection.
472  /// Returns: true - if successfully closed an open connection.
473  /// false - if not
474  virtual bool Close(void);
475 
476  CS_RETCODE CheckWhileOpening(CS_RETCODE rc);
477 
478  CS_RETCODE CheckSFB(CS_RETCODE rc, const char* msg, unsigned int msg_num);
479 
480  bool IsDead(void) const
481  {
482  return !IsValid() || GetNativeConnection().IsDead();
483  }
484  void SetDead(bool flag = true)
485  {
486  GetNativeConnection().SetDead(flag);
487  }
488 
489  const TDbgInfo& GetDbgInfo(void) const;
490 
491  virtual void SetTimeout(size_t nof_secs);
492  virtual void SetCancelTimeout(size_t nof_secs);
493 
494  virtual size_t GetTimeout(void) const;
495  virtual size_t GetCancelTimeout(void) const;
496 
497  virtual unsigned int GetRowsInCurrentBatch(void) const;
498 
499  size_t PrepareToCancel(void);
500  void CancelFinished(size_t was_timeout);
501  bool IsCancelInProgress(void) const { return m_CancelInProgress; }
502 
503  virtual TSockHandle GetLowLevelHandle(void) const;
504 
505  void CompleteBlobDescriptor(I_BlobDescriptor& desc,
506  const string& cursor_name,
507  int item_num);
508 
509  void CompleteBlobDescriptors(vector<I_BlobDescriptor*>& descs,
510  const string& cursor_name);
511 
512 private:
513  void x_LoadTextPtrProcs(void);
514  void x_CmdAlloc(CS_COMMAND** cmd);
515  void x_SetExtraMsg(const I_BlobDescriptor& descr, size_t data_size);
516  bool x_SendData(I_BlobDescriptor& desc, CDB_Stream& img,
517  bool log_it = true);
518  bool x_SendUpdateWrite(CDB_BlobDescriptor& desc, CDB_Stream& img,
519  size_t size);
520 
521  I_BlobDescriptor* x_GetNativeBlobDescriptor(const CDB_BlobDescriptor& d);
522  bool x_IsLegacyBlobColumnType(const string& table_name,
523  const string& column_name);
524  CS_CONNECTION* x_GetSybaseConn(void) const { return m_Handle.GetNativeHandle(); }
525  bool x_ProcessResultInternal(CS_COMMAND* cmd, CS_INT res_type);
526 
527  const CDBParams* GetLastParams(void) const;
528 
532  int m_TDSVersion; // as CS_TDS_nn
536  unsigned int m_ActivityLevel;
538 
540  {
541  public:
542  enum EContext {
545  eOther
546  };
547 
549  ~CCancelModeGuard();
550 
551  bool IsForCancelInProgress(void) { return m_ForCancelInProgress; }
552 
553  private:
554  // For the sake of DATABASE_DRIVER_ERROR
555  const TDbgInfo& GetDbgInfo() { return m_Conn.GetDbgInfo(); }
556  CTL_Connection& GetConnection() { return m_Conn; }
557  const CDBParams* GetLastParams() { return m_Conn.GetLastParams(); }
558 
561  };
562 
563  friend class CCancelModeGuard;
564 
565 #ifdef FTDS_IN_USE
566  class CAsyncCancelGuard
567  {
568  public:
569  CAsyncCancelGuard(CTL_Connection& conn);
570  ~CAsyncCancelGuard(void);
571  private:
572  CTL_Connection &m_Conn;
573  };
574  friend class CAsyncCancelGuard;
575 
576  bool AsyncCancel(CTL_CmdBase& cmd);
577 
578 # if NCBI_FTDS_VERSION >= 95
579  static int x_IntHandler(void* param);
580  typedef int (*FIntHandler)(void*);
581  FIntHandler m_OrigIntHandler;
582 
583  // The variable is used to handle the following scenarios:
584  // an SQL server request has timed out; this leads to sending a cancel
585  // request to the SQL server; the SQL server is supposed to answer to this
586  // within a short time. If the SQL server does not answer on the cancel
587  // request within one iteration over the poll() call i.e. 1 sec then this
588  // variable is set to true. It happens in CTL_Connection::x_IntHandler()
589  // and the checked in the CTLibContext::CTLIB_cterr_handler().
590  bool m_CancelTimedOut;
591 # else
592  static int x_TimeoutFunc(void* param, unsigned int total_timeout);
593  int (*m_OrigTimeoutFunc)(void*, unsigned int);
594  void *m_OrigTimeoutParam;
595 # endif
596 
597  CFastMutex m_AsyncCancelMutex;
598  size_t m_OrigTimeout;
599  unsigned int m_BaseTimeout;
600  unsigned int m_TotalTimeout;
601  bool m_AsyncCancelAllowed;
602  bool m_AsyncCancelRequested;
603 #endif
604 };
605 
606 
607 
608 /////////////////////////////////////////////////////////////////////////////
609 //
610 // CTL_CmdBase::
611 //
612 
614 {
615  friend class CTL_Connection;
616 public:
617  CTL_CmdBase(CTL_Connection& conn, const string& query);
618  CTL_CmdBase(CTL_Connection& conn, const string& cursor_name,
619  const string& query);
620  virtual ~CTL_CmdBase(void);
621 
622 protected:
624  {
625  public:
626  void SetValue(const CTempString& s);
627  CTempString GetValue(void) const;
628  private:
629 #ifdef USE_STRUCT_CS_VARCHAR
631 #else
633 #endif
634  };
635 
637 
638 protected:
639  inline CTL_Connection& GetConnection(void);
640  inline const CTL_Connection& GetConnection(void) const;
641 
642  inline void DropCmd(impl::CCommand& cmd);
643  inline bool x_SendData(I_BlobDescriptor& desc,
644  CDB_Stream& img,
645  bool log_it = true);
646  inline CDB_SendDataCmd* ConnSendDataCmd (I_BlobDescriptor& desc,
647  size_t data_size,
648  bool log_it = true,
649  bool dump_results = true);
650 
651  bool IsMultibyteClientEncoding(void) const
652  {
653  return GetConnection().IsMultibyteClientEncoding();
654  }
655 
657  {
658  return GetConnection().GetClientEncoding();
659  }
660 
662  {
663  eAsyncCancel = CS_CANCEL_ATTN,
664  eSyncCancel = CS_CANCEL_ALL
665  };
666 
667  virtual bool x_Cancel(ECancelType)
668  {
669  return Cancel();
670  }
671 
672 
673 protected:
674  // Result-related ...
675  void SetExecCntxInfo(const string& info)
676  {
677  m_DbgInfo->extra_msg = info;
678  }
679  const string& GetExecCntxInfo(void) const
680  {
681  return m_DbgInfo->extra_msg;
682  }
683 
684  bool IsDead(void) const
685  {
686  return GetConnection().IsDead();
687  }
688  void SetDead(bool flag = true)
689  {
690  GetConnection().SetDead(flag);
691  }
692  void CheckIsDead(void) // const
693  {
694  if (IsDead()) {
695  NCBI_DATABASE_THROW_ANNOTATED(CDB_ClientEx, "Connection has died.",
696  122010, eDiag_Error, GetDbgInfo(),
697  GetConnection(), GetLastParams());
698  }
699  }
700  virtual void SetHasFailed(bool flag = true)
701  {
702  CBaseCmd::SetHasFailed(flag);
703  if (flag && !GetConnection().IsAlive()) {
704  NCBI_DATABASE_THROW_ANNOTATED(CDB_ClientEx, "Connection has died.",
705  122010, eDiag_Error, GetDbgInfo(),
706  GetConnection(), GetLastParams());
707  }
708  }
709 
711  const TDbgInfo& GetDbgInfo(void) const
712  {
713  return *m_DbgInfo;
714  }
715 
716 protected:
717  bool GetTimedOut(void) const
718  {
719  return m_TimedOut;
720  }
721 
722  void SetTimedOut(bool val)
723  {
724  m_TimedOut = val;
725  }
726 
728  {
729  return m_Retriable;
730  }
731 
733  {
734  m_Retriable = val;
735  }
736 
737  void EnsureActiveStatus(void);
738 
739 protected:
742 
743 private:
745 
746  // Support for a better exception in case of a suppressed timeout
747  // exception.
750 };
751 
752 
753 /////////////////////////////////////////////////////////////////////////////
754 //
755 // CTL_Cmd::
756 //
757 
758 class CTL_Cmd : public CTL_CmdBase
759 {
760  friend class CTL_CursorCmdExpl;
761  friend class CTL_CursorResultExpl;
762 
763 public:
764  CTL_Cmd(CTL_Connection& conn, const string& query);
765  CTL_Cmd(CTL_Connection& conn, const string& cursor_name,
766  const string& query);
767  virtual ~CTL_Cmd(void);
768 
769 protected:
770  inline CS_COMMAND* x_GetSybaseCmd(void) const;
771  inline void SetSybaseCmd(CS_COMMAND* cmd);
772 
773  bool AssignCmdParam(CDB_Object& param,
774  const string& param_name,
775  CS_DATAFMT& param_fmt,
776  bool declare_only = false
777  );
778  void GetRowCount(int* cnt);
779 
780 protected:
781  // Result-related ...
782 
783  inline CTL_RowResult& GetResult(void);
784  inline void DeleteResult(void);
785  inline void DeleteResultInternal(void);
786  inline void MarkEndOfReply(void);
787 
788  inline bool HaveResult(void) const;
790  {
791  m_Res = result;
792  }
793 
794  inline CTL_RowResult* MakeCursorResult(void);
795  inline CTL_RowResult* MakeRowResult(void);
796  inline CTL_RowResult* MakeParamResult(void);
797  inline CTL_RowResult* MakeComputeResult(void);
798  inline CTL_RowResult* MakeStatusResult(void);
799 
800  bool ProcessResultInternal(CDB_Result& res);
801  inline bool ProcessResultInternal(CS_INT res_type);
802 
803  CS_RETCODE CheckSFB_Internal(CS_RETCODE rc,
804  const char* msg,
805  unsigned int msg_num);
806 
807 protected:
808  void DropSybaseCmd(void);
809 
810 private:
811  void x_Init(void);
812 
815 };
816 
817 
818 /////////////////////////////////////////////////////////////////////////////
819 //
820 // CTL_LangCmd::
821 //
822 class CTL_LRCmd : public CTL_Cmd
823 {
824 public:
826  const string& query);
827  virtual ~CTL_LRCmd(void);
828 
829 public:
830  CTL_RowResult* MakeResultInternal(void);
831  CDB_Result* MakeResult(void);
832  bool Cancel(void) override;
833 
834 protected:
835  CS_RETCODE CheckSFB(CS_RETCODE rc, const char* msg, unsigned int msg_num);
836 
837  bool SendInternal(void);
838  bool x_Cancel(ECancelType cancel_type) override;
839 };
840 
841 
842 /////////////////////////////////////////////////////////////////////////////
843 //
844 // CTL_LangCmd::
845 //
846 
848 {
849  friend class CTL_Connection;
850  friend class CTL_CursorCmdExpl;
851  friend class CTL_CursorResultExpl;
852  friend struct default_delete<CTL_LangCmd>;
853 
854 protected:
856  const string& lang_query);
857  virtual ~CTL_LangCmd(void);
858 
859  void Close(void);
860 
861 protected:
862  virtual bool Send(void);
863  virtual CDB_Result* Result(void);
864  virtual bool HasMoreResults(void) const;
865  virtual int RowCount(void) const;
866 
867 private:
868  bool x_AssignParams(void);
869  CTempString x_GetDynamicID(void);
870 
871  string m_DynamicID;
872 };
873 
874 
875 
876 /////////////////////////////////////////////////////////////////////////////
877 //
878 // CTL_RPCCmd::
879 //
880 
882 {
883  friend class CTL_Connection;
884 
885 protected:
887  const string& proc_name
888  );
889  virtual ~CTL_RPCCmd(void);
890 
891 protected:
892  virtual CDBParams& GetBindParams(void);
893 
894  virtual bool Send(void);
895  virtual CDB_Result* Result(void);
896  virtual bool HasMoreResults(void) const;
897  virtual int RowCount(void) const;
898 
899 private:
900  bool x_AssignParams(void);
901  void x_Close(void);
902 
903  unique_ptr<CDBParams> m_InParams;
904 };
905 
906 
907 
908 /////////////////////////////////////////////////////////////////////////////
909 //
910 // CTL_CursorCmd::
911 //
912 
914 {
915  friend class CTL_Connection;
916 
917 protected:
919  const string& cursor_name,
920  const string& query,
921  unsigned int fetch_size
922  );
923  virtual ~CTL_CursorCmd(void);
924 
925  void CloseForever(void);
926 
927 protected:
928  virtual CDB_Result* OpenCursor(void);
929  virtual bool Update(const string& table_name, const string& upd_query);
930  virtual bool UpdateBlob(unsigned int item_num, CDB_Stream& data,
931  bool log_it = true);
932  virtual CDB_SendDataCmd* SendDataCmd(unsigned int item_num, size_t size,
933  bool log_it = true,
934  bool dump_results = true);
935  virtual bool Delete(const string& table_name);
936  virtual int RowCount(void) const;
937  virtual bool CloseCursor(void);
938 
939  CS_RETCODE CheckSFB(CS_RETCODE rc, const char* msg, unsigned int msg_num);
940  CS_RETCODE CheckSFBCP(CS_RETCODE rc, const char* msg, unsigned int msg_num);
941 
942  bool ProcessResults(void);
943 
944 private:
945  bool x_AssignParams(bool just_declare = false);
946  I_BlobDescriptor* x_GetBlobDescriptor(unsigned int item_num);
947 
948 private:
949  unsigned int m_FetchSize;
950 };
951 
952 
953 /////////////////////////////////////////////////////////////////////////////
954 //
955 // CTL_CursorCmdExpl::
956 // Explicit cursor (based on T-SQL)
957 
959 {
960  friend class CTL_Connection;
961 
962 protected:
964  const string& cursor_name,
965  const string& query,
966  unsigned int fetch_size);
967  virtual ~CTL_CursorCmdExpl(void);
968 
969 protected:
970  virtual CDB_Result* OpenCursor(void);
971  virtual bool Update(const string& table_name, const string& upd_query);
972  virtual bool UpdateBlob(unsigned int item_num, CDB_Stream& data,
973  bool log_it = true);
974  virtual CDB_SendDataCmd* SendDataCmd(unsigned int item_num, size_t size,
975  bool log_it = true,
976  bool dump_results = true);
977  virtual bool Delete(const string& table_name);
978  virtual int RowCount(void) const;
979  virtual bool CloseCursor(void);
980 
981 private:
982  CTL_CursorResultExpl* GetResultSet(void) const;
983  void SetResultSet(CTL_CursorResultExpl* res);
984  void ClearResultSet(void);
985  const string GetCombinedQuery(void) const
986  {
987  return m_CombinedQuery;
988  }
989 
990 private:
991  bool x_AssignParams(void);
992  I_BlobDescriptor* x_GetBlobDescriptor(unsigned int item_num);
993 
994  unique_ptr<CTL_LangCmd> m_LCmd;
995  unique_ptr<CTL_CursorResultExpl> m_Res;
997  unsigned int m_FetchSize;
998 };
999 
1000 
1001 /////////////////////////////////////////////////////////////////////////////
1002 //
1003 // CTL_BCPInCmd::
1004 //
1005 
1007 {
1008  friend class CTL_Connection;
1009 
1010 protected:
1012  const string& table_name);
1013  virtual ~CTL_BCPInCmd(void);
1014 
1015  void Close(void);
1016 
1017 protected:
1018  virtual void SetHints(CTempString hints);
1019  virtual void AddHint(CDB_BCPInCmd::EBCP_Hints hint, unsigned int value);
1020  virtual void AddOrderHint(CTempString columns);
1021  virtual bool Bind(unsigned int column_num, CDB_Object* param_ptr);
1022  virtual bool Send(void);
1023  virtual bool CommitBCPTrans(void);
1024  virtual bool Cancel(void);
1025  virtual bool EndBCP(void);
1026  virtual int RowCount(void) const;
1027 
1028  CS_RETCODE CheckSF(CS_RETCODE rc, const char* msg, unsigned int msg_num);
1029  CS_RETCODE CheckSFB(CS_RETCODE rc, const char* msg, unsigned int msg_num);
1030  CS_RETCODE CheckSentSFB(CS_RETCODE rc, const char* msg, unsigned int msg_num);
1031 
1032 private:
1033  bool x_AssignParams(void);
1034  bool x_IsUnicodeClientAPI(void) const;
1035  CTempString x_GetStringValue(unsigned int i);
1037  {
1038  return m_Cmd;
1039  }
1040  void x_BlkSetHints(void);
1041 
1042 private:
1043  struct SBcpBind {
1047  char buffer[80];
1048  };
1049 
1051 
1056 
1058  {
1059  unsigned int param_num = GetBindParamsImpl().NofParams();
1060  _ASSERT(param_num);
1061 
1062  if (!m_BindArray) {
1063  m_BindArray = AutoArray<SBcpBind>(param_num);
1064  }
1065 
1066  return m_BindArray;
1067  }
1068 
1069 };
1070 
1071 
1072 
1073 /////////////////////////////////////////////////////////////////////////////
1074 //
1075 // CTL_SendDataCmd::
1076 //
1077 
1079 {
1080  friend class CTL_Connection;
1081 
1082 protected:
1084  I_BlobDescriptor& descr_in,
1085  size_t nof_bytes,
1086  bool log_it,
1087  bool dump_results);
1088  virtual ~CTL_SendDataCmd(void);
1089 
1090  void Close(void);
1091  virtual bool Cancel(void);
1092 
1093 protected:
1094  virtual size_t SendChunk(const void* chunk_ptr, size_t nof_bytes);
1095  virtual CDB_Result* Result(void);
1096  virtual bool HasMoreResults(void) const;
1097  virtual int RowCount(void) const;
1098 
1099 private:
1101 #ifdef FTDS_IN_USE
1102  string m_SQL;
1103  string m_UTF8Fragment;
1104 #endif
1107 };
1108 
1109 
1110 
1111 /////////////////////////////////////////////////////////////////////////////
1112 //
1113 // CTL_RowResult::
1114 //
1115 
1117 {
1118  friend class CTL_Connection;
1119  friend class CTL_Cmd;
1120  friend class CTL_CursorCmd;
1121  friend class CTL_CursorCmdExpl;
1122  friend class CTL_CursorResultExpl;
1123 
1124 protected:
1126  virtual ~CTL_RowResult(void);
1127 
1128  void Close(void);
1129 
1130 protected:
1131  virtual EDB_ResType ResultType(void) const;
1132  virtual bool Fetch(void);
1133  virtual int CurrentItemNo(void) const;
1134  virtual int GetColumnNum(void) const;
1135  virtual CDB_Object* GetItem(CDB_Object* item_buf = 0,
1137  virtual size_t ReadItem(void* buffer, size_t buffer_size,
1138  bool* is_null = 0);
1139  virtual I_BlobDescriptor* GetBlobDescriptor(void);
1140  virtual bool SkipItem(void);
1141 
1142  I_BlobDescriptor* GetBlobDescriptor(int item_num);
1143 
1145  CS_INT item,
1146  CS_VOID* buffer,
1147  CS_INT buflen,
1148  CS_INT *outlen,
1149  bool& is_null);
1151  I_Result::EGetItem policy,
1152  CS_COMMAND* cmd,
1153  CS_INT item_no,
1154  CS_DATAFMT& fmt,
1155  CDB_Object* item_buf
1156  );
1157  CS_COMMAND* x_GetSybaseCmd(void) const { return m_Cmd; }
1159  {
1160  _ASSERT(m_Connect);
1161  return m_Connect->Check(rc);
1162  }
1163 
1164  //
1166  {
1167  _ASSERT(m_Connect);
1168  return *m_Connect;
1169  }
1170  const CTL_Connection& GetConnection(void) const
1171  {
1172  _ASSERT(m_Connect);
1173  return *m_Connect;
1174  }
1175 
1176  //
1178  {
1179  return GetConnection().GetDbgInfo();
1180  }
1181 
1182  static EDB_Type ConvDataType_Ctlib2DBAPI(const CS_DATAFMT& fmt);
1183 
1184  void SetCurrentItemNum(int num)
1185  {
1186  m_CurrItem = num;
1187  }
1188  int GetCurrentItemNum(void) const
1189  {
1190  return m_CurrItem;
1191  }
1193  {
1194  ++m_CurrItem;
1195  }
1196 
1197 protected:
1199 
1200  bool IsDead(void) const
1201  {
1202  return GetConnection().IsDead();
1203  }
1204 
1205  const CDBParams* GetLastParams(void) const
1206  {
1207  return m_Connect ? m_Connect->GetLastParams() : NULL;
1208  }
1209 
1210  void CheckIsDead(void) const
1211  {
1212  if (IsDead()) {
1213  NCBI_DATABASE_THROW_ANNOTATED(CDB_ClientEx, "Connection has died.",
1214  122011, eDiag_Error, GetDbgInfo(),
1216  } else {
1218  }
1219  }
1220 
1221  // data
1225  bool m_EOR;
1232  unsigned char m_BindBuff[2048];
1233 };
1234 
1235 
1236 
1237 /////////////////////////////////////////////////////////////////////////////
1238 //
1239 // CTL_ParamResult::
1240 // CTL_ComputeResult::
1241 // CTL_StatusResult::
1242 // CTL_CursorResult::
1243 //
1244 
1245 ////////////////////////////////////////////////////////////////////////////////
1247 {
1248  friend class CTL_Connection;
1249  friend class CTL_Cmd;
1250 
1251 protected:
1253  CTL_RowResult(pCmd, conn)
1254  {
1255  }
1256 
1257 protected:
1258  virtual EDB_ResType ResultType(void) const;
1259 };
1260 
1261 
1262 ////////////////////////////////////////////////////////////////////////////////
1264 {
1265  friend class CTL_Connection;
1266  friend class CTL_Cmd;
1267 
1268 protected:
1270  CTL_RowResult(pCmd, conn)
1271  {
1272  }
1273 
1274 protected:
1275  virtual EDB_ResType ResultType(void) const;
1276 };
1277 
1278 
1279 ////////////////////////////////////////////////////////////////////////////////
1281 {
1282  friend class CTL_Connection;
1283  friend class CTL_Cmd;
1284 
1285 protected:
1287  CTL_RowResult(pCmd, conn)
1288  {
1289  }
1290 
1291 protected:
1292  virtual EDB_ResType ResultType(void) const;
1293 };
1294 
1295 
1296 ////////////////////////////////////////////////////////////////////////////////
1298 {
1299  friend class CTL_Cmd;
1300 
1301 public:
1302  const string& GetCursorName(void) const { return m_CursorName; }
1304  { m_Descriptors.insert(&desc); }
1306  { m_Descriptors.erase(&desc); }
1307 
1308 protected:
1310  const string& cursor_name) :
1311  CTL_RowResult(pCmd, conn), m_CursorName(cursor_name)
1312  {
1313  }
1314  virtual ~CTL_CursorResult(void);
1315 
1316 protected:
1317  virtual EDB_ResType ResultType(void) const;
1318  virtual bool SkipItem(void);
1319  virtual bool Fetch(void);
1320 
1321  void x_InvalidateDescriptors(void);
1322 
1323 private:
1326 };
1327 
1328 ////////////////////////////////////////////////////////////////////////////////
1330 {
1331  friend class CTL_CursorCmdExpl;
1332  friend struct default_delete<CTL_CursorResultExpl>;
1333 
1334 protected:
1335  CTL_CursorResultExpl(CTL_LangCmd* cmd, const string& cursor_name);
1336  virtual ~CTL_CursorResultExpl(void);
1337 
1338 protected:
1339  virtual EDB_ResType ResultType(void) const;
1340  virtual bool Fetch(void);
1341  virtual int CurrentItemNo(void) const;
1342  virtual int GetColumnNum(void) const;
1343  virtual CDB_Object* GetItem(CDB_Object* item_buff = 0,
1345  virtual size_t ReadItem(void* buffer, size_t buffer_size,
1346  bool* is_null = 0);
1348  {
1349  return GetBlobDescriptor(m_CurItemNo);
1350  }
1351  I_BlobDescriptor* GetBlobDescriptor(int item_num);
1352  virtual bool SkipItem(void);
1353 
1354 private:
1355  CDB_Result* GetResultSet(void) const;
1357  void ClearResultSet(void);
1358  void DumpResultSet(void);
1359  void FetchAllResultSet(void);
1360 
1362  {
1363  _ASSERT(m_Cmd);
1364  return *m_Cmd;
1365  }
1366  CTL_LangCmd const& GetCmd(void) const
1367  {
1368  _ASSERT(m_Cmd);
1369  return *m_Cmd;
1370  }
1371 
1372  void ClearFields(void);
1373 
1374 private:
1375  // data
1377  // CTL_RowResult* m_Res;
1379  vector<CDB_Object*> m_Fields;
1380  vector<I_BlobDescriptor*> m_BlobDescrs;
1382  size_t m_ReadBytes;
1385 };
1386 
1387 
1388 /////////////////////////////////////////////////////////////////////////////
1389 namespace ctlib {
1390  inline
1391  CS_RETCODE Connection::CheckWhileOpening(CS_RETCODE rc)
1392  {
1393  return GetCTLConn().CheckWhileOpening(rc);
1394  }
1395 }
1396 
1397 inline
1399  return m_ActiveCmd ? m_ActiveCmd->GetDbgInfo() : CConnection::GetDbgInfo();
1400 }
1401 
1402 inline
1404  return m_ActiveCmd ? m_ActiveCmd->GetLastParams() : NULL;
1405 }
1406 
1407 inline
1409 {
1410  return m_ActiveCmd ? m_ActiveCmd->GetRowsInCurrentBatch() : 0U;
1411 }
1412 
1413 #ifdef FTDS_IN_USE
1414 inline
1415 CTL_Connection::CAsyncCancelGuard::CAsyncCancelGuard(CTL_Connection& conn)
1416  : m_Conn(conn)
1417 {
1418  CFastMutexGuard LOCK(conn.m_AsyncCancelMutex);
1419  conn.m_OrigTimeout = conn.GetTimeout();
1420  conn.m_BaseTimeout = 0;
1421 # if NCBI_FTDS_VERSION >= 95
1422  conn.m_TotalTimeout = 0;
1423 # endif
1424  conn.m_AsyncCancelAllowed = true;
1425  conn.m_AsyncCancelRequested = false;
1426 # if NCBI_FTDS_VERSION < 95
1427  if (conn.m_OrigTimeout == 0) {
1428  conn.SetTimeout(kMax_Int / 1000);
1429  }
1430 # endif
1431 }
1432 
1433 inline
1434 CTL_Connection::CAsyncCancelGuard::~CAsyncCancelGuard(void)
1435 {
1436  CFastMutexGuard LOCK(m_Conn.m_AsyncCancelMutex);
1437  m_Conn.SetTimeout(m_Conn.m_OrigTimeout);
1438  m_Conn.m_AsyncCancelAllowed = false;
1439 }
1440 #endif
1441 
1442 #ifdef USE_STRUCT_CS_VARCHAR
1443 inline
1445 {
1446  m_Data.reset
1447  (static_cast<CS_VARCHAR*>
1448  (malloc(sizeof(CS_VARCHAR) - sizeof(m_Data->str) + s.size())));
1449  m_Data->len = static_cast<CS_SMALLINT>(s.size());
1450  memcpy(m_Data->str, s.data(), s.size());
1451 }
1452 
1453 inline
1455 {
1456  return CTempString((char*)m_Data.get(),
1457  sizeof(CS_VARCHAR) - sizeof(m_Data->str) + m_Data->len);
1458 }
1459 #else
1460 inline
1462 {
1463  m_Data = s;
1464 }
1465 
1466 inline
1468 {
1469  return m_Data;
1470 }
1471 #endif
1472 
1473 
1474 inline
1477 {
1478  return static_cast<CTL_Connection&>(GetConnImpl());
1479 }
1480 
1481 inline
1482 const CTL_Connection&
1484 {
1485  return static_cast<CTL_Connection&>(GetConnImpl());
1486 }
1487 
1488 inline
1489 void
1491 {
1493 }
1494 
1495 inline
1496 bool
1498 {
1499  return GetConnection().x_SendData(desc, img, log_it);
1500 }
1501 
1502 inline
1505  size_t data_size,
1506  bool log_it,
1507  bool dump_results)
1508 {
1509  return GetConnection().SendDataCmd(desc, data_size, log_it, dump_results);
1510 }
1511 
1512 
1513 /////////////////////////////////////////////////////////////////////////////
1514 inline
1515 CS_COMMAND*
1517 {
1518  return m_Cmd;
1519 }
1520 
1521 inline
1522 void
1524 {
1525  m_Cmd = cmd;
1526 }
1527 
1528 inline
1529 bool
1531 {
1532  return GetConnection().x_ProcessResultInternal(x_GetSybaseCmd(), res_type);
1533 }
1534 
1535 inline
1536 bool
1538 {
1539  return (m_Res != NULL);
1540 }
1541 
1542 inline
1545 {
1546  return new CTL_CursorResult(x_GetSybaseCmd(), GetConnection(),
1547  GetCmdName());
1548 }
1549 
1550 inline
1553 {
1554  return new CTL_RowResult(x_GetSybaseCmd(), GetConnection());
1555 }
1556 
1557 inline
1560 {
1561  return new CTL_ParamResult(x_GetSybaseCmd(), GetConnection());
1562 }
1563 
1564 inline
1567 {
1568  return new CTL_ComputeResult(x_GetSybaseCmd(), GetConnection());
1569 }
1570 
1571 inline
1574 {
1575  return new CTL_StatusResult(x_GetSybaseCmd(), GetConnection());
1576 }
1577 
1578 inline
1581 {
1582  _ASSERT(HaveResult());
1583  return *m_Res;
1584 }
1585 
1586 inline
1587 void
1589 {
1590  delete m_Res;
1591  m_Res = NULL;
1592 }
1593 
1594 inline
1595 void
1597 {
1598  MarkEndOfReply();
1599  if ( HaveResult() ) {
1600  DeleteResult();
1601  }
1602 }
1603 
1604 inline
1606 {
1607  // to prevent ct_cancel(NULL, x_GetSybaseCmd(), CS_CANCEL_CURRENT) call:
1608  if (HaveResult()) {
1609  m_Res->m_EOR = true;
1610  }
1611  GetConnection().m_CancelRequested = false;
1612 }
1613 
1614 /////////////////////////////////////////////////////////////////////////////
1615 inline
1618 {
1619  return m_Res.get();
1620 }
1621 
1622 inline
1623 void
1625 {
1626  m_Res.reset(res);
1627 }
1628 
1629 inline
1630 void
1632 {
1633  m_Res.reset(NULL);
1634 }
1635 
1636 
1637 
1638 /////////////////////////////////////////////////////////////////////////////
1639 //
1640 // CTL_BlobDescriptor::
1641 //
1642 
1643 #define CTL_BLOB_DESCRIPTOR_TYPE_MAGNUM 0xc00
1644 #define CTL_BLOB_DESCRIPTOR_TYPE_CURSOR 0xc01
1645 
1647  : public I_BlobDescriptor
1648 {
1649  friend class CTL_RowResult;
1650  friend class CTL_CursorResultExpl;
1651  friend class CTL_Connection;
1652  friend class CTL_CursorCmd;
1653  friend class CTL_CursorCmdExpl;
1654  friend class CTL_SendDataCmd;
1655 
1656 public:
1657  virtual int DescriptorType(void) const;
1658  virtual ~CTL_BlobDescriptor(void);
1659 
1660 protected:
1661  CTL_BlobDescriptor(void);
1662  CTL_BlobDescriptor& operator=(const CTL_BlobDescriptor& desc);
1663 
1665  /// Set only when m_Desc lacks a valid textptr
1666  unique_ptr<CDB_Exception> m_Context;
1667 };
1668 
1670  : public CDB_BlobDescriptor
1671 {
1672 public:
1674  const string& table_name,
1675  const string& column_name,
1676  CS_INT datatype);
1678 
1679  int DescriptorType(void) const;
1680 
1681  void Invalidate(void) { m_CursorResult = NULL; }
1682 
1683  bool IsValid(void) const { return m_CursorResult != NULL; }
1684 
1685 private:
1687 };
1688 
1689 // historical names
1690 #define CTL_ITDESCRIPTOR_TYPE_MAGNUM CTL_BLOB_DESCRIPTOR_TYPE_MAGNUM
1691 #define CTL_ITDESCRIPTOR_TYPE_CURSOR CTL_BLOB_DESCRIPTOR_TYPE_CURSOR
1694 
1695 #ifdef FTDS_IN_USE
1696 } // namespace NCBI_NS_FTDS_CTLIB
1697 #endif
1698 
1700 
1701 
1702 #endif /* DBAPI_DRIVER_CTLIB___INTERFACES__HPP */
1703 
AutoArray –.
Definition: ncbimisc.hpp:527
AutoPtr –.
Definition: ncbimisc.hpp:401
CDBConnParams::
Definition: interfaces.hpp:258
CDBParams.
Definition: interfaces.hpp:154
CFastMutex –.
Definition: ncbimtx.hpp:667
CMutex –.
Definition: ncbimtx.hpp:749
CRWLock –.
Definition: ncbimtx.hpp:953
THintsMap m_Hints
CS_BLKDESC * m_Cmd
AutoArray< SBcpBind > & GetBind(void)
AutoArray< SBcpBind > m_BindArray
CS_BLKDESC * x_GetSybaseCmd(void) const
map< CDB_BCPInCmd::EBCP_Hints, string > THintsMap
unique_ptr< CDB_Exception > m_Context
Set only when m_Desc lacks a valid textptr.
void SetValue(const CTempString &s)
CTempString GetValue(void) const
CDB_SendDataCmd * ConnSendDataCmd(I_BlobDescriptor &desc, size_t data_size, bool log_it=true, bool dump_results=true)
virtual bool x_Cancel(ECancelType)
Definition: interfaces.hpp:667
CTL_Connection::TDbgInfo TDbgInfo
Definition: interfaces.hpp:710
bool x_SendData(I_BlobDescriptor &desc, CDB_Stream &img, bool log_it=true)
void SetDead(bool flag=true)
Definition: interfaces.hpp:688
void SetTimedOut(bool val)
Definition: interfaces.hpp:722
void DropCmd(impl::CCommand &cmd)
CRef< TDbgInfo > m_DbgInfo
Definition: interfaces.hpp:741
ERetriable m_Retriable
Definition: interfaces.hpp:749
void SetRetriable(ERetriable val)
Definition: interfaces.hpp:732
CTL_Connection & GetConnection(void)
bool IsMultibyteClientEncoding(void) const
Definition: interfaces.hpp:651
bool IsDead(void) const
Definition: interfaces.hpp:684
const string & GetExecCntxInfo(void) const
Definition: interfaces.hpp:679
ERetriable GetRetriable(void) const
Definition: interfaces.hpp:727
bool GetTimedOut(void) const
Definition: interfaces.hpp:717
void CheckIsDead(void)
Definition: interfaces.hpp:692
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
EEncoding GetClientEncoding(void) const
Definition: interfaces.hpp:656
CTL_RowResult * MakeStatusResult(void)
void SetResult(CTL_RowResult *result)
Definition: interfaces.hpp:789
CTL_RowResult * MakeRowResult(void)
void MarkEndOfReply(void)
bool ProcessResultInternal(CDB_Result &res)
Definition: lang_cmd.cpp:220
void SetSybaseCmd(CS_COMMAND *cmd)
CTL_RowResult * m_Res
Definition: interfaces.hpp:814
bool HaveResult(void) const
CTL_RowResult * MakeComputeResult(void)
CS_COMMAND * m_Cmd
Definition: interfaces.hpp:813
CTL_RowResult * MakeCursorResult(void)
CS_COMMAND * x_GetSybaseCmd(void) const
void DeleteResult(void)
void DeleteResultInternal(void)
CTL_RowResult & GetResult(void)
CTL_RowResult * MakeParamResult(void)
CTL_ComputeResult(CS_COMMAND *pCmd, CTL_Connection &conn)
CTL_Connection & GetConnection()
Definition: interfaces.hpp:556
const CDBParams * GetLastParams()
Definition: interfaces.hpp:557
const CDBParams * GetLastParams(void) const
const CTLibContext & GetCTLibContext(void) const
Definition: interfaces.hpp:401
CS_RETCODE CheckSFB(CS_RETCODE rc, const char *msg, unsigned int msg_num)
Definition: connection.cpp:489
void DeferTimeout(void)
friend class CTL_CursorCmdExpl
Definition: interfaces.hpp:387
friend class CTL_SendDataCmd
Definition: interfaces.hpp:384
CS_RETCODE Check(CS_RETCODE rc)
Definition: connection.cpp:458
CTLibContext * m_Cntx
Definition: interfaces.hpp:529
ctlib::Connection m_Handle
Definition: interfaces.hpp:531
bool IsCancelInProgress(void) const
Definition: interfaces.hpp:501
bool x_SendData(I_BlobDescriptor &desc, CDB_Stream &img, bool log_it=true)
void SetDead(bool flag=true)
Definition: interfaces.hpp:484
friend class CTL_CursorCmd
Definition: interfaces.hpp:386
bool m_TextPtrProcsLoaded
Definition: interfaces.hpp:533
virtual unsigned int GetRowsInCurrentBatch(void) const
ctlib::Connection & GetNativeConnection(void)
Definition: interfaces.hpp:412
CTL_CmdBase * m_ActiveCmd
Definition: interfaces.hpp:530
unsigned int m_ActivityLevel
Definition: interfaces.hpp:536
CMutex m_CancelLogisticsMutex
Definition: interfaces.hpp:537
bool IsOpen(void)
Definition: interfaces.hpp:422
bool x_ProcessResultInternal(CS_COMMAND *cmd, CS_INT res_type)
const TDbgInfo & GetDbgInfo(void) const
CTLibContext & GetCTLibContext(void)
Definition: interfaces.hpp:406
bool m_CancelInProgress
Definition: interfaces.hpp:534
virtual CDB_SendDataCmd * SendDataCmd(I_BlobDescriptor &desc, size_t data_size, bool log_it=true, bool dump_results=true)
"Send-data" command
Definition: connection.cpp:862
bool m_CancelRequested
Definition: interfaces.hpp:535
bool IsDead(void) const
Definition: interfaces.hpp:480
friend class CTL_CmdBase
Definition: interfaces.hpp:380
friend class CTL_RPCCmd
Definition: interfaces.hpp:383
virtual bool Close(void)
Close an open connection.
const ctlib::Connection & GetNativeConnection(void) const
Definition: interfaces.hpp:416
friend class CTL_BCPInCmd
Definition: interfaces.hpp:385
CS_CONNECTION * x_GetSybaseConn(void) const
Definition: interfaces.hpp:524
bool IsValid(void) const
CTL_CursorResult * m_CursorResult
CTL_CursorResultExpl * GetResultSet(void) const
void ClearResultSet(void)
unique_ptr< CTL_LangCmd > m_LCmd
Definition: interfaces.hpp:994
unsigned int m_FetchSize
Definition: interfaces.hpp:997
const string GetCombinedQuery(void) const
Definition: interfaces.hpp:985
void SetResultSet(CTL_CursorResultExpl *res)
unique_ptr< CTL_CursorResultExpl > m_Res
Definition: interfaces.hpp:995
unsigned int m_FetchSize
Definition: interfaces.hpp:949
virtual bool SkipItem(void)
Skip result item.
Definition: result.cpp:1563
void ClearResultSet(void)
CTL_LangCmd * m_Cmd
vector< I_BlobDescriptor * > m_BlobDescrs
virtual CDB_Object * GetItem(CDB_Object *item_buff=0, I_Result::EGetItem policy=I_Result::eAppendLOB)
Get a result item (you can use either GetItem or ReadItem).
Definition: result.cpp:1329
CTL_LangCmd & GetCmd(void)
virtual size_t ReadItem(void *buffer, size_t buffer_size, bool *is_null=0)
Read a result item body (for BLOB columns, mostly).
Definition: result.cpp:1369
CTL_LangCmd const & GetCmd(void) const
vector< CDB_Object * > m_Fields
virtual int GetColumnNum(void) const
Return number of columns in the recordset.
Definition: result.cpp:1323
virtual I_BlobDescriptor * GetBlobDescriptor(void)
Get a descriptor for a BLOB column (for SendData).
virtual bool Fetch(void)
Fetch next row.
Definition: result.cpp:1238
void SetResultSet(CDB_Result *res)
virtual EDB_ResType ResultType(void) const
Get type of the result.
Definition: result.cpp:1232
void DumpResultSet(void)
void FetchAllResultSet(void)
CDB_Result * GetResultSet(void) const
virtual int CurrentItemNo(void) const
Return current item number we can retrieve (0,1,...) Return "-1" if no more items left (or available)...
Definition: result.cpp:1317
const string & GetCursorName(void) const
CTL_CursorResult(CS_COMMAND *pCmd, CTL_Connection &conn, const string &cursor_name)
void RegisterDescriptor(CTL_CursorBlobDescriptor &desc)
void UnregisterDescriptor(CTL_CursorBlobDescriptor &desc)
friend class CTL_Cmd
set< CTL_CursorBlobDescriptor * > m_Descriptors
string m_DynamicID
Definition: interfaces.hpp:871
CTL_ParamResult(CS_COMMAND *pCmd, CTL_Connection &conn)
unique_ptr< CDBParams > m_InParams
Definition: interfaces.hpp:903
unsigned char m_BindBuff[2048]
bool IsDead(void) const
CTL_RowResult(CS_COMMAND *cmd, CTL_Connection &conn)
Definition: result.cpp:67
AutoArray< CS_VOID * > m_BindItem
AutoArray< CS_DATAFMT > m_ColFmt
CS_COMMAND * m_Cmd
AutoArray< ENullValue > m_NullValue
const CTL_Connection & GetConnection(void) const
void SetCurrentItemNum(int num)
void CheckIsDead(void) const
static EDB_Type ConvDataType_Ctlib2DBAPI(const CS_DATAFMT &fmt)
Definition: result.cpp:175
AutoArray< CS_SMALLINT > m_Indicator
virtual ~CTL_RowResult(void)
Definition: result.cpp:1017
CDB_Object * GetItemInternal(I_Result::EGetItem policy, CS_COMMAND *cmd, CS_INT item_no, CS_DATAFMT &fmt, CDB_Object *item_buf)
Definition: result.cpp:476
CTL_Connection * m_Connect
CTL_Connection & GetConnection(void)
CS_RETCODE Check(CS_RETCODE rc)
AutoArray< CS_INT > m_Copied
CS_COMMAND * x_GetSybaseCmd(void) const
const CDBParams * GetLastParams(void) const
friend class CTL_Connection
const CTL_Connection::TDbgInfo & GetDbgInfo(void) const
void Close(void)
Definition: result.cpp:1027
void IncCurrentItemNum(void)
CS_RETCODE my_ct_get_data(CS_COMMAND *cmd, CS_INT item, CS_VOID *buffer, CS_INT buflen, CS_INT *outlen, bool &is_null)
Definition: result.cpp:317
int GetCurrentItemNum(void) const
CDB_BlobDescriptor::ETDescriptorType m_DescrType
CTL_StatusResult(CS_COMMAND *pCmd, CTL_Connection &conn)
CS_INT GetLoginRetryCount(void) const
Definition: interfaces.hpp:325
bool m_ReusingContext
Definition: interfaces.hpp:349
CS_INT GetPacketSize(void) const
Definition: interfaces.hpp:321
CS_INT m_TDSVersion
Definition: interfaces.hpp:347
CTLibContextRegistry * m_Registry
Definition: interfaces.hpp:348
CS_INT GetLoginLoopDelay(void) const
Definition: interfaces.hpp:329
CS_CONTEXT * m_Context
Definition: interfaces.hpp:342
CS_INT m_LoginRetryCount
Definition: interfaces.hpp:345
CS_INT GetTDSVersion(void) const
Definition: interfaces.hpp:317
CS_LOCALE * GetLocale(void) const
Definition: interfaces.hpp:303
CS_LOCALE * m_Locale
Definition: interfaces.hpp:343
CS_INT m_PacketSize
Definition: interfaces.hpp:344
CS_INT m_LoginLoopDelay
Definition: interfaces.hpp:346
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
CS_COMMAND * m_Handle
Definition: interfaces.hpp:239
const CTL_Connection & GetCTLConn(void) const
Definition: interfaces.hpp:223
CS_COMMAND * GetNativeHandle(void) const
Definition: interfaces.hpp:210
CTL_Connection & GetCTLConn(void)
Definition: interfaces.hpp:228
CTL_Connection * m_CTL_Conn
Definition: interfaces.hpp:238
CS_CONNECTION * GetNativeHandle(void) const
Definition: interfaces.hpp:148
CS_CONNECTION * m_Handle
Definition: interfaces.hpp:196
bool IsDead(void) const
Definition: interfaces.hpp:165
const CTLibContext & GetCTLContext(void) const
Definition: interfaces.hpp:180
bool IsOpen(void) const
Definition: interfaces.hpp:153
CTLibContext * m_CTL_Context
Definition: interfaces.hpp:194
CTL_Connection * m_CTL_Conn
Definition: interfaces.hpp:195
CTLibContext & GetCTLContext(void)
Definition: interfaces.hpp:185
void SetDead(bool flag=true)
Definition: interfaces.hpp:169
string GetCmdName(void) const
impl::CConnection & GetConnImpl(void) const
void DropCmd(impl::CCommand &cmd)
static CMemoryRegistry registry
Definition: cn3d_tools.cpp:81
char value[7]
Definition: config.c:431
#define option
#define CS_CANCEL_ATTN
Definition: cspublic.h:467
#define CS_CANCEL_ALL
Definition: cspublic.h:466
#define CS_PUBLIC
Definition: cspublic.h:37
Int4 CS_INT
Definition: cstypes.h:41
Int2 CS_SMALLINT
Definition: cstypes.h:45
void CS_VOID
Definition: cstypes.h:53
CS_INT CS_RETCODE
Definition: cstypes.h:63
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
CS_CONTEXT * ctx
Definition: t0006.c:12
CTL_BlobDescriptor CTL_ITDescriptor
CTL_CursorBlobDescriptor CTL_CursorITDescriptor
CS_INT GetCtlibTdsVersion(int version=0)
Definition: context.cpp:1675
ERetriable
Can the action be retried?
Definition: ncbimisc.hpp:167
#define NULL
Definition: ncbistd.hpp:225
#define NCBI_DATABASE_THROW_ANNOTATED(ex_class, message, err_code, severity, dbg_info, conn, params)
Definition: exception.hpp:726
ECapability
Report if the driver supports this functionality.
EDB_ResType
EDB_ResType::
Definition: interfaces.hpp:386
EBCP_Hints
Type of hint that can be set.
Definition: public.hpp:776
EDB_Type
Definition: types.hpp:52
NCBI_XNCBI_EXPORT void Abort(void)
Smart abort function.
Definition: ncbidiag.cpp:8147
@ eDiag_Error
Error message.
Definition: ncbidiag.hpp:653
bool IsValid(const CSeq_point &pt, CScope *scope)
Checks that point >= 0 and point < length of Bioseq.
#define NCBI_DEPRECATED
#define kMax_Int
Definition: ncbi_limits.h:184
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
EEncoding
Definition: ncbistr.hpp:199
const char * data(void) const
Return a pointer to the array represented.
Definition: tempstr.hpp:313
const char *const kEmptyCStr
Empty "C" string (points to a '\0').
Definition: ncbistr.cpp:68
size_type size(void) const
Return the length of the represented array.
Definition: tempstr.hpp:327
#define NCBI_DBAPIDRIVER_CTLIB_EXPORT
Definition: ncbi_export.h:400
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
int i
yy_size_t n
static MDB_envinfo info
Definition: mdb_load.c:37
static int version
Definition: mdb_load.c:29
void Check(const string &value)
const struct ncbi::grid::netcache::search::fields::SIZE size
static void x_Close(SHttpConnector *uuu)
Static variables safety - create on demand, destroy on application termination.
static unsigned cnt[256]
#define GetDbgInfo()
Definition: bcp.cpp:56
static const char table_name[]
Definition: bcp.c:249
static pcre_uint8 * buffer
Definition: pcretest.c:1051
static int buffer_size
Definition: pcretest.c:1050
CRef< T > MakeResult(CRef< T > result)
static string query
Definition: type.c:6
#define _ASSERT
else result
Definition: token2.c:20
voidp malloc(uInt size)
Modified on Thu Feb 29 12:20:13 2024 by modify_doxy.py rev. 669887