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

Go to the SVN repository for this file.

1 /* $Id: dbapi.cpp 93420 2021-04-12 13:27:11Z ucko $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * File Name: $Id: dbapi.cpp 93420 2021-04-12 13:27:11Z ucko $
27 *
28 * Author: Michael Kholodov
29 *
30 * File Description: DataSource implementation
31 *
32 */
33 
34 #include <ncbi_pch.hpp>
35 #include <dbapi/dbapi.hpp>
36 
38 
40 {
41 }
42 
43 void IDataSource::SetApplicationName(const string& app_name)
44 {
46 }
47 
49 {
50  const_cast<I_DriverContext*>(GetDriverContext())->InitApplicationName();
52 }
53 
54 
56 {
57 }
58 
59 size_t IConnection::GetTimeout(void) const
60 {
61  return const_cast<IConnection*>(this)->GetCDB_Connection()->GetTimeout();
62 }
63 
65 {
66  return const_cast<IConnection*>(this)->GetCDB_Connection()
67  ->GetCancelTimeout();
68 }
69 
71 {
72 }
73 
75  EAllowLog log_it)
76 {
77  return GetBlobWriter(d, blob_size,
78  (log_it == eDisableLog) ? fBOS_SkipLogging : 0);
79 }
80 
82  EAllowLog log_it, size_t buf_size)
83 {
84  return GetBlobOStream(d, blob_size,
85  (log_it == eDisableLog) ? fBOS_SkipLogging : 0,
86  buf_size);
87 }
88 
90 {
91 }
92 
93 void ICallableStatement::Execute(const string& /*sql*/)
94 {
95 }
96 
97 void ICallableStatement::ExecuteUpdate(const string& /*sql*/)
98 {
99 }
100 
101 void ICallableStatement::SendSql(const string& /*sql*/)
102 {
103 }
104 
106 {
107  return 0;
108 }
109 
111 {
112 }
113 
115  size_t buf_size)
116 {
117  return GetBlobOStream(blob_size,
118  (log_it == eDisableLog) ? fBOS_SkipLogging : 0,
119  buf_size);
120 }
121 
123  EAllowLog log_it, size_t buf_size)
124 {
125  return GetBlobOStream(conn, blob_size,
126  (log_it == eDisableLog) ? fBOS_SkipLogging : 0,
127  buf_size);
128 }
129 
131 {
132 }
133 
135 {
136  unsigned int n = GetTotalColumns();
137  if (param.IsPositional()) { // 1-based
138  return param.GetPosition() > 0 && param.GetPosition() <= n;
139  }
140  for (unsigned int i = 1; i <= n; ++i) {
141  if (GetName(i) == param.GetName()) {
142  return true;
143  }
144  }
145  return false;
146 }
147 
149 {
150 }
151 
152 CNcbiOstream& ICursor::GetBlobOStream(unsigned int col, size_t blob_size,
153  EAllowLog log_it, size_t buf_size)
154 {
155  return GetBlobOStream(col, blob_size,
156  (log_it == eDisableLog) ? fBOS_SkipLogging : 0,
157  buf_size);
158 }
159 
160 IWriter* ICursor::GetBlobWriter(unsigned int col, size_t blob_size,
161  EAllowLog log_it)
162 {
163  return GetBlobWriter(col, blob_size,
164  (log_it == eDisableLog) ? fBOS_SkipLogging : 0);
165 }
166 
168 {
169 }
A very basic data-write interface.
I_BlobDescriptor::
Definition: interfaces.hpp:369
USING_NCBI_SCOPE
Definition: dbapi.cpp:37
Defines the database API innterfaces for a variety of DBMS.
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
virtual IWriter * GetBlobWriter(unsigned int col, size_t blob_size, TBlobOStreamFlags flags=0)=0
Get Blob Writer.
virtual string GetName(const CDBParamVariant &param) const =0
Get name of column.
virtual ~ICursor()
Destructor.
Definition: dbapi.cpp:148
virtual ~IConnection()
Destructor.
Definition: dbapi.cpp:55
void SetApplicationName(const string &app_name)
Definition: dbapi.cpp:43
virtual CNcbiOstream & GetBlobOStream(unsigned int col, size_t blob_size, TBlobOStreamFlags flags=0, size_t buf_size=0)=0
Get output stream for BLOB updates, requires BLOB column number.
virtual void Execute()=0
Execute stored procedure.
virtual size_t GetCancelTimeout(void) const
Get timeout for command cancellation and connection closing.
Definition: dbapi.cpp:64
virtual CDB_Connection * GetCDB_Connection()=0
Returns the internal driver connection object.
virtual size_t GetTimeout(void) const
Get connection timeout.
Definition: dbapi.cpp:59
virtual ~ICallableStatement()
Destructor.
Definition: dbapi.cpp:89
virtual CNcbiOstream & GetBlobOStream(I_BlobDescriptor &d, size_t blob_size, TBlobOStreamFlags flags=0, size_t buf_size=0)=0
Get an ostream for writing BLOBs using previously created CDB_BlobDescriptor.
virtual ~IResultSetMetaData(void)
Destructor.
Definition: dbapi.cpp:130
virtual unsigned int GetTotalColumns(void) const =0
Get total number of columns in resultset.
virtual ~IResultSet()
Destructor.
Definition: dbapi.cpp:110
virtual I_DriverContext * GetDriverContext()=0
Returns the pointer to the general driver interface.
virtual void ExecuteUpdate()=0
Executes stored procedure no results returned.
virtual void SendSql(const string &)
Sends one or more SQL statements to the SQL server.
Definition: dbapi.cpp:101
virtual ~IBulkInsert()
Destructor.
Definition: dbapi.cpp:167
virtual IResultSet * ExecuteQuery(const string &)
Exectues SQL statement and returns the first resultset.
Definition: dbapi.cpp:105
virtual IWriter * GetBlobWriter(I_BlobDescriptor &d, size_t blob_size, TBlobOStreamFlags flags=0)=0
Get a writer for writing BLOBs using previously created CDB_BlobDescriptor.
virtual ~IStatement()
Destructor.
Definition: dbapi.cpp:70
EAllowLog
EDataSource –.
Definition: dbapi.hpp:72
virtual ~IDataSource()
Protected Destructor.
Definition: dbapi.cpp:39
string GetApplicationName(void) const
Definition: dbapi.cpp:48
bool HasColumn(const CDBParamVariant &param) const
Convenience method to check whether a column with a given name (or number) actually exists.
Definition: dbapi.cpp:134
virtual CNcbiOstream & GetBlobOStream(size_t blob_size, TBlobOStreamFlags flags=0, size_t buf_size=0)=0
Get Blob output stream.
@ eDisableLog
Disables log.
Definition: dbapi.hpp:73
@ fBOS_SkipLogging
Definition: dbapi.hpp:94
bool IsPositional(void) const
Definition: interfaces.hpp:115
virtual string GetApplicationName(void) const =0
Return application name.
unsigned int GetPosition(void) const
Definition: interfaces.hpp:119
virtual void SetApplicationName(const string &app_name)=0
Set application name.
const string & GetName(void) const
Definition: interfaces.hpp:129
size_t GetCancelTimeout(void) const
Get timeout for command cancellation and connection closing.
Definition: public.cpp:562
size_t GetTimeout(void) const
Get connection timeout.
Definition: public.cpp:556
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
int i
yy_size_t n
Modified on Sun Apr 14 05:29:35 2024 by modify_doxy.py rev. 669887