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 102711 2024-06-28 14:39:22Z 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:
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  virtual string GetVersionString(void) const;
505 
506  void CompleteBlobDescriptor(I_BlobDescriptor& desc,
507  const string& cursor_name,
508  int item_num);
509 
510  void CompleteBlobDescriptors(vector<I_BlobDescriptor*>& descs,
511  const string& cursor_name);
512 
513 private:
514  void x_LoadTextPtrProcs(void);
515  void x_CmdAlloc(CS_COMMAND** cmd);
516  void x_SetExtraMsg(const I_BlobDescriptor& descr, size_t data_size);
517  bool x_SendData(I_BlobDescriptor& desc, CDB_Stream& img,
518  bool log_it = true);
519  bool x_SendUpdateWrite(CDB_BlobDescriptor& desc, CDB_Stream& img,
520  size_t size);
521 
522  I_BlobDescriptor* x_GetNativeBlobDescriptor(const CDB_BlobDescriptor& d);
523  bool x_IsLegacyBlobColumnType(const string& table_name,
524  const string& column_name);
525  CS_CONNECTION* x_GetSybaseConn(void) const { return m_Handle.GetNativeHandle(); }
526  bool x_ProcessResultInternal(CS_COMMAND* cmd, CS_INT res_type);
527 
528  const CDBParams* GetLastParams(void) const;
529 
533  int m_TDSVersion; // as CS_TDS_nn
537  unsigned int m_ActivityLevel;
539 
541  {
542  public:
543  enum EContext {
546  eOther
547  };
548 
550  ~CCancelModeGuard();
551 
552  bool IsForCancelInProgress(void) { return m_ForCancelInProgress; }
553 
554  private:
555  // For the sake of DATABASE_DRIVER_ERROR
556  const TDbgInfo& GetDbgInfo() { return m_Conn.GetDbgInfo(); }
557  CTL_Connection& GetConnection() { return m_Conn; }
558  const CDBParams* GetLastParams() { return m_Conn.GetLastParams(); }
559 
562  };
563 
564  friend class CCancelModeGuard;
565 
566 #ifdef FTDS_IN_USE
567  class CAsyncCancelGuard
568  {
569  public:
570  CAsyncCancelGuard(CTL_Connection& conn);
571  ~CAsyncCancelGuard(void);
572  private:
573  CTL_Connection &m_Conn;
574  };
575  friend class CAsyncCancelGuard;
576 
577  bool AsyncCancel(CTL_CmdBase& cmd);
578 
579 # if NCBI_FTDS_VERSION >= 95
580  static int x_IntHandler(void* param);
581  typedef int (*FIntHandler)(void*);
582  FIntHandler m_OrigIntHandler;
583 
584  // The variable is used to handle the following scenarios:
585  // an SQL server request has timed out; this leads to sending a cancel
586  // request to the SQL server; the SQL server is supposed to answer to this
587  // within a short time. If the SQL server does not answer on the cancel
588  // request within one iteration over the poll() call i.e. 1 sec then this
589  // variable is set to true. It happens in CTL_Connection::x_IntHandler()
590  // and the checked in the CTLibContext::CTLIB_cterr_handler().
591  bool m_CancelTimedOut;
592 # else
593  static int x_TimeoutFunc(void* param, unsigned int total_timeout);
594  int (*m_OrigTimeoutFunc)(void*, unsigned int);
595  void *m_OrigTimeoutParam;
596 # endif
597 
598  CFastMutex m_AsyncCancelMutex;
599  size_t m_OrigTimeout;
600  unsigned int m_BaseTimeout;
601  unsigned int m_TotalTimeout;
602  bool m_AsyncCancelAllowed;
603  bool m_AsyncCancelRequested;
604 #endif
605 };
606 
607 
608 
609 /////////////////////////////////////////////////////////////////////////////
610 //
611 // CTL_CmdBase::
612 //
613 
615 {
616  friend class CTL_Connection;
617 public:
618  CTL_CmdBase(CTL_Connection& conn, const string& query);
619  CTL_CmdBase(CTL_Connection& conn, const string& cursor_name,
620  const string& query);
621  virtual ~CTL_CmdBase(void);
622 
623 protected:
625  {
626  public:
627  void SetValue(const CTempString& s);
628  CTempString GetValue(void) const;
629  private:
630 #ifdef USE_STRUCT_CS_VARCHAR
632 #else
634 #endif
635  };
636 
638 
639 protected:
640  inline CTL_Connection& GetConnection(void);
641  inline const CTL_Connection& GetConnection(void) const;
642 
643  inline void DropCmd(impl::CCommand& cmd);
644  inline bool x_SendData(I_BlobDescriptor& desc,
645  CDB_Stream& img,
646  bool log_it = true);
647  inline CDB_SendDataCmd* ConnSendDataCmd (I_BlobDescriptor& desc,
648  size_t data_size,
649  bool log_it = true,
650  bool dump_results = true);
651 
652  bool IsMultibyteClientEncoding(void) const
653  {
654  return GetConnection().IsMultibyteClientEncoding();
655  }
656 
658  {
659  return GetConnection().GetClientEncoding();
660  }
661 
663  {
664  eAsyncCancel = CS_CANCEL_ATTN,
665  eSyncCancel = CS_CANCEL_ALL
666  };
667 
668  virtual bool x_Cancel(ECancelType)
669  {
670  return Cancel();
671  }
672 
673 
674 protected:
675  // Result-related ...
676  void SetExecCntxInfo(const string& info)
677  {
678  m_DbgInfo->extra_msg = info;
679  }
680  const string& GetExecCntxInfo(void) const
681  {
682  return m_DbgInfo->extra_msg;
683  }
684 
685  bool IsDead(void) const
686  {
687  return GetConnection().IsDead();
688  }
689  void SetDead(bool flag = true)
690  {
691  GetConnection().SetDead(flag);
692  }
693  void CheckIsDead(void) // const
694  {
695  if (IsDead()) {
696  NCBI_DATABASE_THROW_ANNOTATED(CDB_ClientEx, "Connection has died.",
697  122010, eDiag_Error, GetDbgInfo(),
698  GetConnection(), GetLastParams());
699  }
700  }
701  virtual void SetHasFailed(bool flag = true)
702  {
703  CBaseCmd::SetHasFailed(flag);
704  if (flag && !GetConnection().IsAlive()) {
705  NCBI_DATABASE_THROW_ANNOTATED(CDB_ClientEx, "Connection has died.",
706  122010, eDiag_Error, GetDbgInfo(),
707  GetConnection(), GetLastParams());
708  }
709  }
710 
712  const TDbgInfo& GetDbgInfo(void) const
713  {
714  return *m_DbgInfo;
715  }
716 
717 protected:
718  bool GetTimedOut(void) const
719  {
720  return m_TimedOut;
721  }
722 
723  void SetTimedOut(bool val)
724  {
725  m_TimedOut = val;
726  }
727 
729  {
730  return m_Retriable;
731  }
732 
734  {
735  m_Retriable = val;
736  }
737 
738  void EnsureActiveStatus(void);
739 
740 protected:
743 
744 private:
746 
747  // Support for a better exception in case of a suppressed timeout
748  // exception.
751 };
752 
753 
754 /////////////////////////////////////////////////////////////////////////////
755 //
756 // CTL_Cmd::
757 //
758 
759 class CTL_Cmd : public CTL_CmdBase
760 {
761  friend class CTL_CursorCmdExpl;
762  friend class CTL_CursorResultExpl;
763 
764 public:
765  CTL_Cmd(CTL_Connection& conn, const string& query);
766  CTL_Cmd(CTL_Connection& conn, const string& cursor_name,
767  const string& query);
768  virtual ~CTL_Cmd(void);
769 
770 protected:
771  inline CS_COMMAND* x_GetSybaseCmd(void) const;
772  inline void SetSybaseCmd(CS_COMMAND* cmd);
773 
774  bool AssignCmdParam(CDB_Object& param,
775  const string& param_name,
776  CS_DATAFMT& param_fmt,
777  bool declare_only = false
778  );
779  void GetRowCount(int* cnt);
780 
781 protected:
782  // Result-related ...
783 
784  inline CTL_RowResult& GetResult(void);
785  inline void DeleteResult(void);
786  inline void DeleteResultInternal(void);
787  inline void MarkEndOfReply(void);
788 
789  inline bool HaveResult(void) const;
791  {
792  m_Res = result;
793  }
794 
795  inline CTL_RowResult* MakeCursorResult(void);
796  inline CTL_RowResult* MakeRowResult(void);
797  inline CTL_RowResult* MakeParamResult(void);
798  inline CTL_RowResult* MakeComputeResult(void);
799  inline CTL_RowResult* MakeStatusResult(void);
800 
801  bool ProcessResultInternal(CDB_Result& res);
802  inline bool ProcessResultInternal(CS_INT res_type);
803 
804  CS_RETCODE CheckSFB_Internal(CS_RETCODE rc,
805  const char* msg,
806  unsigned int msg_num);
807 
808 protected:
809  void DropSybaseCmd(void);
810 
811 private:
812  void x_Init(void);
813 
816 };
817 
818 
819 /////////////////////////////////////////////////////////////////////////////
820 //
821 // CTL_LangCmd::
822 //
823 class CTL_LRCmd : public CTL_Cmd
824 {
825 public:
827  const string& query);
828  virtual ~CTL_LRCmd(void);
829 
830 public:
831  CTL_RowResult* MakeResultInternal(void);
832  CDB_Result* MakeResult(void);
833  bool Cancel(void) override;
834 
835 protected:
836  CS_RETCODE CheckSFB(CS_RETCODE rc, const char* msg, unsigned int msg_num);
837 
838  bool SendInternal(void);
839  bool x_Cancel(ECancelType cancel_type) override;
840 };
841 
842 
843 /////////////////////////////////////////////////////////////////////////////
844 //
845 // CTL_LangCmd::
846 //
847 
849 {
850  friend class CTL_Connection;
851  friend class CTL_CursorCmdExpl;
852  friend class CTL_CursorResultExpl;
853  friend struct default_delete<CTL_LangCmd>;
854 
855 protected:
857  const string& lang_query);
858  virtual ~CTL_LangCmd(void);
859 
860  void Close(void);
861 
862 protected:
863  virtual bool Send(void);
864  virtual CDB_Result* Result(void);
865  virtual bool HasMoreResults(void) const;
866  virtual int RowCount(void) const;
867 
868 private:
869  bool x_AssignParams(void);
870  CTempString x_GetDynamicID(void);
871 
872  string m_DynamicID;
873 };
874 
875 
876 
877 /////////////////////////////////////////////////////////////////////////////
878 //
879 // CTL_RPCCmd::
880 //
881 
883 {
884  friend class CTL_Connection;
885 
886 protected:
888  const string& proc_name
889  );
890  virtual ~CTL_RPCCmd(void);
891 
892 protected:
893  virtual CDBParams& GetBindParams(void);
894 
895  virtual bool Send(void);
896  virtual CDB_Result* Result(void);
897  virtual bool HasMoreResults(void) const;
898  virtual int RowCount(void) const;
899 
900 private:
901  bool x_AssignParams(void);
902  void x_Close(void);
903 
904  unique_ptr<CDBParams> m_InParams;
905 };
906 
907 
908 
909 /////////////////////////////////////////////////////////////////////////////
910 //
911 // CTL_CursorCmd::
912 //
913 
915 {
916  friend class CTL_Connection;
917 
918 protected:
920  const string& cursor_name,
921  const string& query,
922  unsigned int fetch_size
923  );
924  virtual ~CTL_CursorCmd(void);
925 
926  void CloseForever(void);
927 
928 protected:
929  virtual CDB_Result* OpenCursor(void);
930  virtual bool Update(const string& table_name, const string& upd_query);
931  virtual bool UpdateBlob(unsigned int item_num, CDB_Stream& data,
932  bool log_it = true);
933  virtual CDB_SendDataCmd* SendDataCmd(unsigned int item_num, size_t size,
934  bool log_it = true,
935  bool dump_results = true);
936  virtual bool Delete(const string& table_name);
937  virtual int RowCount(void) const;
938  virtual bool CloseCursor(void);
939 
940  CS_RETCODE CheckSFB(CS_RETCODE rc, const char* msg, unsigned int msg_num);
941  CS_RETCODE CheckSFBCP(CS_RETCODE rc, const char* msg, unsigned int msg_num);
942 
943  bool ProcessResults(void);
944 
945 private:
946  bool x_AssignParams(bool just_declare = false);
947  I_BlobDescriptor* x_GetBlobDescriptor(unsigned int item_num);
948 
949 private:
950  unsigned int m_FetchSize;
951 };
952 
953 
954 /////////////////////////////////////////////////////////////////////////////
955 //
956 // CTL_CursorCmdExpl::
957 // Explicit cursor (based on T-SQL)
958 
960 {
961  friend class CTL_Connection;
962 
963 protected:
965  const string& cursor_name,
966  const string& query,
967  unsigned int fetch_size);
968  virtual ~CTL_CursorCmdExpl(void);
969 
970 protected:
971  virtual CDB_Result* OpenCursor(void);
972  virtual bool Update(const string& table_name, const string& upd_query);
973  virtual bool UpdateBlob(unsigned int item_num, CDB_Stream& data,
974  bool log_it = true);
975  virtual CDB_SendDataCmd* SendDataCmd(unsigned int item_num, size_t size,
976  bool log_it = true,
977  bool dump_results = true);
978  virtual bool Delete(const string& table_name);
979  virtual int RowCount(void) const;
980  virtual bool CloseCursor(void);
981 
982 private:
983  CTL_CursorResultExpl* GetResultSet(void) const;
984  void SetResultSet(CTL_CursorResultExpl* res);
985  void ClearResultSet(void);
986  const string GetCombinedQuery(void) const
987  {
988  return m_CombinedQuery;
989  }
990 
991 private:
992  bool x_AssignParams(void);
993  I_BlobDescriptor* x_GetBlobDescriptor(unsigned int item_num);
994 
995  unique_ptr<CTL_LangCmd> m_LCmd;
996  unique_ptr<CTL_CursorResultExpl> m_Res;
998  unsigned int m_FetchSize;
999 };
1000 
1001 
1002 /////////////////////////////////////////////////////////////////////////////
1003 //
1004 // CTL_BCPInCmd::
1005 //
1006 
1008 {
1009  friend class CTL_Connection;
1010 
1011 protected:
1013  const string& table_name);
1014  virtual ~CTL_BCPInCmd(void);
1015 
1016  void Close(void);
1017 
1018 protected:
1019  virtual void SetHints(CTempString hints);
1020  virtual void AddHint(CDB_BCPInCmd::EBCP_Hints hint, unsigned int value);
1021  virtual void AddOrderHint(CTempString columns);
1022  virtual bool Bind(unsigned int column_num, CDB_Object* param_ptr);
1023  virtual bool Send(void);
1024  virtual bool CommitBCPTrans(void);
1025  virtual bool Cancel(void);
1026  virtual bool EndBCP(void);
1027  virtual int RowCount(void) const;
1028 
1029  CS_RETCODE CheckSF(CS_RETCODE rc, const char* msg, unsigned int msg_num);
1030  CS_RETCODE CheckSFB(CS_RETCODE rc, const char* msg, unsigned int msg_num);
1031  CS_RETCODE CheckSentSFB(CS_RETCODE rc, const char* msg, unsigned int msg_num);
1032 
1033 private:
1034  bool x_AssignParams(void);
1035  bool x_IsUnicodeClientAPI(void) const;
1036  CTempString x_GetStringValue(unsigned int i);
1038  {
1039  return m_Cmd;
1040  }
1041  void x_BlkSetHints(void);
1042 
1043 private:
1044  struct SBcpBind {
1048  char buffer[80];
1049  };
1050 
1052 
1057 
1059  {
1060  unsigned int param_num = GetBindParamsImpl().NofParams();
1061  _ASSERT(param_num);
1062 
1063  if (!m_BindArray) {
1064  m_BindArray = AutoArray<SBcpBind>(param_num);
1065  }
1066 
1067  return m_BindArray;
1068  }
1069 
1070 };
1071 
1072 
1073 
1074 /////////////////////////////////////////////////////////////////////////////
1075 //
1076 // CTL_SendDataCmd::
1077 //
1078 
1080 {
1081  friend class CTL_Connection;
1082 
1083 protected:
1085  I_BlobDescriptor& descr_in,
1086  size_t nof_bytes,
1087  bool log_it,
1088  bool dump_results);
1089  virtual ~CTL_SendDataCmd(void);
1090 
1091  void Close(void);
1092  virtual bool Cancel(void);
1093 
1094 protected:
1095  virtual size_t SendChunk(const void* chunk_ptr, size_t nof_bytes);
1096  virtual CDB_Result* Result(void);
1097  virtual bool HasMoreResults(void) const;
1098  virtual int RowCount(void) const;
1099 
1100 private:
1102 #ifdef FTDS_IN_USE
1103  string m_SQL;
1104  string m_UTF8Fragment;
1105 #endif
1108 };
1109 
1110 
1111 
1112 /////////////////////////////////////////////////////////////////////////////
1113 //
1114 // CTL_RowResult::
1115 //
1116 
1118 {
1119  friend class CTL_Connection;
1120  friend class CTL_Cmd;
1121  friend class CTL_CursorCmd;
1122  friend class CTL_CursorCmdExpl;
1123  friend class CTL_CursorResultExpl;
1124 
1125 protected:
1127  virtual ~CTL_RowResult(void);
1128 
1129  void Close(void);
1130 
1131 protected:
1132  virtual EDB_ResType ResultType(void) const;
1133  virtual bool Fetch(void);
1134  virtual int CurrentItemNo(void) const;
1135  virtual int GetColumnNum(void) const;
1136  virtual CDB_Object* GetItem(CDB_Object* item_buf = 0,
1138  virtual size_t ReadItem(void* buffer, size_t buffer_size,
1139  bool* is_null = 0);
1140  virtual I_BlobDescriptor* GetBlobDescriptor(void);
1141  virtual bool SkipItem(void);
1142 
1143  I_BlobDescriptor* GetBlobDescriptor(int item_num);
1144 
1146  CS_INT item,
1147  CS_VOID* buffer,
1148  CS_INT buflen,
1149  CS_INT *outlen,
1150  bool& is_null);
1152  I_Result::EGetItem policy,
1153  CS_COMMAND* cmd,
1154  CS_INT item_no,
1155  CS_DATAFMT& fmt,
1156  CDB_Object* item_buf
1157  );
1158  CS_COMMAND* x_GetSybaseCmd(void) const { return m_Cmd; }
1160  {
1161  _ASSERT(m_Connect);
1162  return m_Connect->Check(rc);
1163  }
1164 
1165  //
1167  {
1168  _ASSERT(m_Connect);
1169  return *m_Connect;
1170  }
1171  const CTL_Connection& GetConnection(void) const
1172  {
1173  _ASSERT(m_Connect);
1174  return *m_Connect;
1175  }
1176 
1177  //
1179  {
1180  return GetConnection().GetDbgInfo();
1181  }
1182 
1183  static EDB_Type ConvDataType_Ctlib2DBAPI(const CS_DATAFMT& fmt);
1184 
1185  void SetCurrentItemNum(int num)
1186  {
1187  m_CurrItem = num;
1188  }
1189  int GetCurrentItemNum(void) const
1190  {
1191  return m_CurrItem;
1192  }
1194  {
1195  ++m_CurrItem;
1196  }
1197 
1198 protected:
1200 
1201  bool IsDead(void) const
1202  {
1203  return GetConnection().IsDead();
1204  }
1205 
1206  const CDBParams* GetLastParams(void) const
1207  {
1208  return m_Connect ? m_Connect->GetLastParams() : NULL;
1209  }
1210 
1211  void CheckIsDead(void) const
1212  {
1213  if (IsDead()) {
1214  NCBI_DATABASE_THROW_ANNOTATED(CDB_ClientEx, "Connection has died.",
1215  122011, eDiag_Error, GetDbgInfo(),
1217  } else {
1219  }
1220  }
1221 
1222  // data
1226  bool m_EOR;
1233  unsigned char m_BindBuff[2048];
1234 };
1235 
1236 
1237 
1238 /////////////////////////////////////////////////////////////////////////////
1239 //
1240 // CTL_ParamResult::
1241 // CTL_ComputeResult::
1242 // CTL_StatusResult::
1243 // CTL_CursorResult::
1244 //
1245 
1246 ////////////////////////////////////////////////////////////////////////////////
1248 {
1249  friend class CTL_Connection;
1250  friend class CTL_Cmd;
1251 
1252 protected:
1254  CTL_RowResult(pCmd, conn)
1255  {
1256  }
1257 
1258 protected:
1259  virtual EDB_ResType ResultType(void) const;
1260 };
1261 
1262 
1263 ////////////////////////////////////////////////////////////////////////////////
1265 {
1266  friend class CTL_Connection;
1267  friend class CTL_Cmd;
1268 
1269 protected:
1271  CTL_RowResult(pCmd, conn)
1272  {
1273  }
1274 
1275 protected:
1276  virtual EDB_ResType ResultType(void) const;
1277 };
1278 
1279 
1280 ////////////////////////////////////////////////////////////////////////////////
1282 {
1283  friend class CTL_Connection;
1284  friend class CTL_Cmd;
1285 
1286 protected:
1288  CTL_RowResult(pCmd, conn)
1289  {
1290  }
1291 
1292 protected:
1293  virtual EDB_ResType ResultType(void) const;
1294 };
1295 
1296 
1297 ////////////////////////////////////////////////////////////////////////////////
1299 {
1300  friend class CTL_Cmd;
1301 
1302 public:
1303  const string& GetCursorName(void) const { return m_CursorName; }
1305  { m_Descriptors.insert(&desc); }
1307  { m_Descriptors.erase(&desc); }
1308 
1309 protected:
1311  const string& cursor_name) :
1312  CTL_RowResult(pCmd, conn), m_CursorName(cursor_name)
1313  {
1314  }
1315  virtual ~CTL_CursorResult(void);
1316 
1317 protected:
1318  virtual EDB_ResType ResultType(void) const;
1319  virtual bool SkipItem(void);
1320  virtual bool Fetch(void);
1321 
1322  void x_InvalidateDescriptors(void);
1323 
1324 private:
1327 };
1328 
1329 ////////////////////////////////////////////////////////////////////////////////
1331 {
1332  friend class CTL_CursorCmdExpl;
1333  friend struct default_delete<CTL_CursorResultExpl>;
1334 
1335 protected:
1336  CTL_CursorResultExpl(CTL_LangCmd* cmd, const string& cursor_name);
1337  virtual ~CTL_CursorResultExpl(void);
1338 
1339 protected:
1340  virtual EDB_ResType ResultType(void) const;
1341  virtual bool Fetch(void);
1342  virtual int CurrentItemNo(void) const;
1343  virtual int GetColumnNum(void) const;
1344  virtual CDB_Object* GetItem(CDB_Object* item_buff = 0,
1346  virtual size_t ReadItem(void* buffer, size_t buffer_size,
1347  bool* is_null = 0);
1349  {
1350  return GetBlobDescriptor(m_CurItemNo);
1351  }
1352  I_BlobDescriptor* GetBlobDescriptor(int item_num);
1353  virtual bool SkipItem(void);
1354 
1355 private:
1356  CDB_Result* GetResultSet(void) const;
1358  void ClearResultSet(void);
1359  void DumpResultSet(void);
1360  void FetchAllResultSet(void);
1361 
1363  {
1364  _ASSERT(m_Cmd);
1365  return *m_Cmd;
1366  }
1367  CTL_LangCmd const& GetCmd(void) const
1368  {
1369  _ASSERT(m_Cmd);
1370  return *m_Cmd;
1371  }
1372 
1373  void ClearFields(void);
1374 
1375 private:
1376  // data
1378  // CTL_RowResult* m_Res;
1380  vector<CDB_Object*> m_Fields;
1381  vector<I_BlobDescriptor*> m_BlobDescrs;
1383  size_t m_ReadBytes;
1386 };
1387 
1388 
1389 /////////////////////////////////////////////////////////////////////////////
1390 namespace ctlib {
1391  inline
1392  CS_RETCODE Connection::CheckWhileOpening(CS_RETCODE rc)
1393  {
1394  return GetCTLConn().CheckWhileOpening(rc);
1395  }
1396 }
1397 
1398 inline
1400  return m_ActiveCmd ? m_ActiveCmd->GetDbgInfo() : CConnection::GetDbgInfo();
1401 }
1402 
1403 inline
1405  return m_ActiveCmd ? m_ActiveCmd->GetLastParams() : NULL;
1406 }
1407 
1408 inline
1410 {
1411  return m_ActiveCmd ? m_ActiveCmd->GetRowsInCurrentBatch() : 0U;
1412 }
1413 
1414 #ifdef FTDS_IN_USE
1415 inline
1416 CTL_Connection::CAsyncCancelGuard::CAsyncCancelGuard(CTL_Connection& conn)
1417  : m_Conn(conn)
1418 {
1419  CFastMutexGuard LOCK(conn.m_AsyncCancelMutex);
1420  conn.m_OrigTimeout = conn.GetTimeout();
1421  conn.m_BaseTimeout = 0;
1422 # if NCBI_FTDS_VERSION >= 95
1423  conn.m_TotalTimeout = 0;
1424 # endif
1425  conn.m_AsyncCancelAllowed = true;
1426  conn.m_AsyncCancelRequested = false;
1427 # if NCBI_FTDS_VERSION < 95
1428  if (conn.m_OrigTimeout == 0) {
1429  conn.SetTimeout(kMax_Int / 1000);
1430  }
1431 # endif
1432 }
1433 
1434 inline
1435 CTL_Connection::CAsyncCancelGuard::~CAsyncCancelGuard(void)
1436 {
1437  CFastMutexGuard LOCK(m_Conn.m_AsyncCancelMutex);
1438  m_Conn.SetTimeout(m_Conn.m_OrigTimeout);
1439  m_Conn.m_AsyncCancelAllowed = false;
1440 }
1441 #endif
1442 
1443 #ifdef USE_STRUCT_CS_VARCHAR
1444 inline
1446 {
1447  m_Data.reset
1448  (static_cast<CS_VARCHAR*>
1449  (malloc(sizeof(CS_VARCHAR) - sizeof(m_Data->str) + s.size())));
1450  m_Data->len = static_cast<CS_SMALLINT>(s.size());
1451  memcpy(m_Data->str, s.data(), s.size());
1452 }
1453 
1454 inline
1456 {
1457  return CTempString((char*)m_Data.get(),
1458  sizeof(CS_VARCHAR) - sizeof(m_Data->str) + m_Data->len);
1459 }
1460 #else
1461 inline
1463 {
1464  m_Data = s;
1465 }
1466 
1467 inline
1469 {
1470  return m_Data;
1471 }
1472 #endif
1473 
1474 
1475 inline
1478 {
1479  return static_cast<CTL_Connection&>(GetConnImpl());
1480 }
1481 
1482 inline
1483 const CTL_Connection&
1485 {
1486  return static_cast<CTL_Connection&>(GetConnImpl());
1487 }
1488 
1489 inline
1490 void
1492 {
1494 }
1495 
1496 inline
1497 bool
1499 {
1500  return GetConnection().x_SendData(desc, img, log_it);
1501 }
1502 
1503 inline
1506  size_t data_size,
1507  bool log_it,
1508  bool dump_results)
1509 {
1510  return GetConnection().SendDataCmd(desc, data_size, log_it, dump_results);
1511 }
1512 
1513 
1514 /////////////////////////////////////////////////////////////////////////////
1515 inline
1516 CS_COMMAND*
1518 {
1519  return m_Cmd;
1520 }
1521 
1522 inline
1523 void
1525 {
1526  m_Cmd = cmd;
1527 }
1528 
1529 inline
1530 bool
1532 {
1533  return GetConnection().x_ProcessResultInternal(x_GetSybaseCmd(), res_type);
1534 }
1535 
1536 inline
1537 bool
1539 {
1540  return (m_Res != NULL);
1541 }
1542 
1543 inline
1546 {
1547  return new CTL_CursorResult(x_GetSybaseCmd(), GetConnection(),
1548  GetCmdName());
1549 }
1550 
1551 inline
1554 {
1555  return new CTL_RowResult(x_GetSybaseCmd(), GetConnection());
1556 }
1557 
1558 inline
1561 {
1562  return new CTL_ParamResult(x_GetSybaseCmd(), GetConnection());
1563 }
1564 
1565 inline
1568 {
1569  return new CTL_ComputeResult(x_GetSybaseCmd(), GetConnection());
1570 }
1571 
1572 inline
1575 {
1576  return new CTL_StatusResult(x_GetSybaseCmd(), GetConnection());
1577 }
1578 
1579 inline
1582 {
1583  _ASSERT(HaveResult());
1584  return *m_Res;
1585 }
1586 
1587 inline
1588 void
1590 {
1591  delete m_Res;
1592  m_Res = NULL;
1593 }
1594 
1595 inline
1596 void
1598 {
1599  MarkEndOfReply();
1600  if ( HaveResult() ) {
1601  DeleteResult();
1602  }
1603 }
1604 
1605 inline
1607 {
1608  // to prevent ct_cancel(NULL, x_GetSybaseCmd(), CS_CANCEL_CURRENT) call:
1609  if (HaveResult()) {
1610  m_Res->m_EOR = true;
1611  }
1612  GetConnection().m_CancelRequested = false;
1613 }
1614 
1615 /////////////////////////////////////////////////////////////////////////////
1616 inline
1619 {
1620  return m_Res.get();
1621 }
1622 
1623 inline
1624 void
1626 {
1627  m_Res.reset(res);
1628 }
1629 
1630 inline
1631 void
1633 {
1634  m_Res.reset(NULL);
1635 }
1636 
1637 
1638 
1639 /////////////////////////////////////////////////////////////////////////////
1640 //
1641 // CTL_BlobDescriptor::
1642 //
1643 
1644 #define CTL_BLOB_DESCRIPTOR_TYPE_MAGNUM 0xc00
1645 #define CTL_BLOB_DESCRIPTOR_TYPE_CURSOR 0xc01
1646 
1648  : public I_BlobDescriptor
1649 {
1650  friend class CTL_RowResult;
1651  friend class CTL_CursorResultExpl;
1652  friend class CTL_Connection;
1653  friend class CTL_CursorCmd;
1654  friend class CTL_CursorCmdExpl;
1655  friend class CTL_SendDataCmd;
1656 
1657 public:
1658  virtual int DescriptorType(void) const;
1659  virtual ~CTL_BlobDescriptor(void);
1660 
1661 protected:
1662  CTL_BlobDescriptor(void);
1663  CTL_BlobDescriptor& operator=(const CTL_BlobDescriptor& desc);
1664 
1666  /// Set only when m_Desc lacks a valid textptr
1667  unique_ptr<CDB_Exception> m_Context;
1668 };
1669 
1671  : public CDB_BlobDescriptor
1672 {
1673 public:
1675  const string& table_name,
1676  const string& column_name,
1677  CS_INT datatype);
1679 
1680  int DescriptorType(void) const;
1681 
1682  void Invalidate(void) { m_CursorResult = NULL; }
1683 
1684  bool IsValid(void) const { return m_CursorResult != NULL; }
1685 
1686 private:
1688 };
1689 
1690 // historical names
1691 #define CTL_ITDESCRIPTOR_TYPE_MAGNUM CTL_BLOB_DESCRIPTOR_TYPE_MAGNUM
1692 #define CTL_ITDESCRIPTOR_TYPE_CURSOR CTL_BLOB_DESCRIPTOR_TYPE_CURSOR
1695 
1696 #ifdef FTDS_IN_USE
1697 } // namespace NCBI_NS_FTDS_CTLIB
1698 #endif
1699 
1701 
1702 
1703 #endif /* DBAPI_DRIVER_CTLIB___INTERFACES__HPP */
1704 
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:668
CTL_Connection::TDbgInfo TDbgInfo
Definition: interfaces.hpp:711
bool x_SendData(I_BlobDescriptor &desc, CDB_Stream &img, bool log_it=true)
void SetDead(bool flag=true)
Definition: interfaces.hpp:689
void SetTimedOut(bool val)
Definition: interfaces.hpp:723
void DropCmd(impl::CCommand &cmd)
CRef< TDbgInfo > m_DbgInfo
Definition: interfaces.hpp:742
ERetriable m_Retriable
Definition: interfaces.hpp:750
void SetRetriable(ERetriable val)
Definition: interfaces.hpp:733
CTL_Connection & GetConnection(void)
bool IsMultibyteClientEncoding(void) const
Definition: interfaces.hpp:652
bool IsDead(void) const
Definition: interfaces.hpp:685
const string & GetExecCntxInfo(void) const
Definition: interfaces.hpp:680
ERetriable GetRetriable(void) const
Definition: interfaces.hpp:728
bool GetTimedOut(void) const
Definition: interfaces.hpp:718
void CheckIsDead(void)
Definition: interfaces.hpp:693
virtual void SetHasFailed(bool flag=true)
Definition: interfaces.hpp:701
void SetExecCntxInfo(const string &info)
Definition: interfaces.hpp:676
const TDbgInfo & GetDbgInfo(void) const
Definition: interfaces.hpp:712
EEncoding GetClientEncoding(void) const
Definition: interfaces.hpp:657
CTL_RowResult * MakeStatusResult(void)
void SetResult(CTL_RowResult *result)
Definition: interfaces.hpp:790
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:815
bool HaveResult(void) const
CTL_RowResult * MakeComputeResult(void)
CS_COMMAND * m_Cmd
Definition: interfaces.hpp:814
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:557
const CDBParams * GetLastParams()
Definition: interfaces.hpp:558
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:490
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:459
CTLibContext * m_Cntx
Definition: interfaces.hpp:530
ctlib::Connection m_Handle
Definition: interfaces.hpp:532
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:534
virtual unsigned int GetRowsInCurrentBatch(void) const
ctlib::Connection & GetNativeConnection(void)
Definition: interfaces.hpp:412
CTL_CmdBase * m_ActiveCmd
Definition: interfaces.hpp:531
unsigned int m_ActivityLevel
Definition: interfaces.hpp:537
CMutex m_CancelLogisticsMutex
Definition: interfaces.hpp:538
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:535
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:893
bool m_CancelRequested
Definition: interfaces.hpp:536
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:525
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:995
unsigned int m_FetchSize
Definition: interfaces.hpp:998
const string GetCombinedQuery(void) const
Definition: interfaces.hpp:986
void SetResultSet(CTL_CursorResultExpl *res)
unique_ptr< CTL_CursorResultExpl > m_Res
Definition: interfaces.hpp:996
unsigned int m_FetchSize
Definition: interfaces.hpp:950
virtual bool SkipItem(void)
Skip result item.
Definition: result.cpp:1564
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:1330
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:1370
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:1324
virtual I_BlobDescriptor * GetBlobDescriptor(void)
Get a descriptor for a BLOB column (for SendData).
virtual bool Fetch(void)
Fetch next row.
Definition: result.cpp:1239
void SetResultSet(CDB_Result *res)
virtual EDB_ResType ResultType(void) const
Get type of the result.
Definition: result.cpp:1233
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:1318
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:872
CTL_ParamResult(CS_COMMAND *pCmd, CTL_Connection &conn)
unique_ptr< CDBParams > m_InParams
Definition: interfaces.hpp:904
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:176
AutoArray< CS_SMALLINT > m_Indicator
virtual ~CTL_RowResult(void)
Definition: result.cpp:1018
CDB_Object * GetItemInternal(I_Result::EGetItem policy, CS_COMMAND *cmd, CS_INT item_no, CS_DATAFMT &fmt, CDB_Object *item_buf)
Definition: result.cpp:477
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:1028
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:318
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
CTL_BlobDescriptor CTL_ITDescriptor
CTL_CursorBlobDescriptor CTL_CursorITDescriptor
CS_INT GetCtlibTdsVersion(int version=0)
Definition: context.cpp:1676
#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
static const char table_name[]
Definition: bcp.c:249
#define option
static const column_t columns[]
Definition: utf8_2.c:22
char data[12]
Definition: iconv.c:80
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:778
EDB_Type
Definition: types.hpp:52
NCBI_XNCBI_EXPORT void Abort(void)
Smart abort function.
Definition: ncbidiag.cpp:8150
@ 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
const string version
version string
Definition: variables.hpp:66
void Check(const string &value)
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
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
#define U
static uint8_t * buffer
Definition: pcre2test.c:1016
CRef< T > MakeResult(CRef< T > result)
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
static string query
Definition: type.c:6
#define _ASSERT
else result
Definition: token2.c:20
static CS_CONTEXT * context
Definition: will_convert.c:21
voidp malloc(uInt size)
Modified on Fri Sep 20 14:58:13 2024 by modify_doxy.py rev. 669887