40 #define NCBI_USE_ERRCODE_X Dbapi_Odbc_Results
42 #undef NCBI_DATABASE_THROW
43 #undef NCBI_DATABASE_RETHROW
45 #define NCBI_DATABASE_THROW(ex_class, message, err_code, severity) \
46 NCBI_ODBC_THROW(ex_class, message, err_code, severity)
47 #define NCBI_DATABASE_RETHROW(prev_ex, ex_class, message, err_code, severity) \
48 NCBI_ODBC_RETHROW(prev_ex, ex_class, message, err_code, severity)
55 #define GetDbgInfo() 0
61 static const char*
wrong_type =
"Wrong type of CDB_Object.";
90 if (prec <= 16 && dec_digits <= 0) {
92 }
else if (prec <= 23 && dec_digits <= 3) {
116 , m_RowCountPtr( row_count )
117 , m_HasMoreData(
false)
127 for (
unsigned int n = 0;
n < (
unsigned int)nof_cols; ++
n) {
148 string err_message =
"SQLDescribeCol failed." +
GetDbgInfo();
153 string err_message =
"SQLDescribeCol failed (memory corruption suspected)." +
GetDbgInfo();
197 string err_message =
"SQLFetch failed." +
GetDbgInfo();
202 string err_message =
"SQLFetch failed (memory corruption suspected)." +
GetDbgInfo();
257 string err_message =
"SQLGetData failed." +
GetDbgInfo();
267 list<string> extra_buffers;
268 char * current_buffer =
buffer.get();
273 switch (target_type) {
275 case SQL_C_WCHAR: nul_size =
sizeof(wchar_t);
break;
276 default: nul_size = 0;
break;
278 while ((
n =
xGetData(target_type, current_buffer, current_size, &more))
279 >= current_size && more) {
280 if (
n > current_size) {
282 current_size =
static_cast<int>(
n) + 2 * nul_size - current_size;
284 extra_buffers.emplace_back(
string(current_size,
'\0'));
285 current_buffer =
const_cast<char*
>(extra_buffers.back().data());
287 if (extra_buffers.empty()) {
291 const char * orig_buffer =
buffer.get();
293 extra_buffers.back().resize(
n);
295 for (
const auto & it : extra_buffers) {
298 buffer.reset(
new char[
n + nul_size]);
301 for (
const auto & it : extra_buffers) {
302 if (nul_size > 0 && pos >= nul_size) {
304 for (
int i = 1;
i <= nul_size; ++
i) {
305 if (
buffer.get()[pos -
i] !=
'\0') {
315 memcpy(
buffer.get() + pos, it.data(), it.size());
318 memset(
buffer.get() + pos,
'\0', nul_size);
362 string(
"SQLGetData failed while retrieving BLOB into C") +
394 f =
f /
sizeof(wchar_t);
397 val->Append(encoded_value.data(), encoded_value.size());
407 string(
"SQLGetData failed while retrieving BLOB into C") +
439 string(
"SQLGetData failed while retrieving BLOB into C") +
450 char base_buf[8*1024];
547 switch ( item_buf->
GetType() ) {
590 switch ( item_buf->
GetType() ) {
609 else *((
CDB_Int*) item_buf) = v ? 1 : 0;
622 switch ( item_buf->
GetType() ) {
662 switch ( item_buf->
GetType() ) {
689 switch ( item_buf->
GetType() ) {
711 switch ( item_buf->
GetType() ) {
729 switch ( item_buf->
GetType() ) {
746 switch ( item_buf->
GetType() ) {
764 switch ( item_buf->
GetType() ) {
862 string err_message =
"Unsupported column type." +
GetDbgInfo();
872 char base_buf[8*1024];
935 buffer.get(), (
size_t) outlen);
1051 string err_message =
"Unsupported column type." +
GetDbgInfo();
1081 if(is_null) *is_null=
false;
1089 size_t next_len = 0;
1099 if(is_null) *is_null=
true;
1107 next_len =
static_cast<size_t>(
f);
1111 next_data.append((
char*)
buffer, next_len);
1117 if(is_null) *is_null=
true;
1120 next_len = (
f >= 0)? ((
size_t)
f) : 0;
1121 next_data.append((
char*)
buffer, next_len);
1126 if(is_null) *is_null=
true;
1134 string err_message =
"SQLGetData failed." +
GetDbgInfo();
1143 next_data.size() /
sizeof(
wchar_t))
1172 enum {eNameStrLen = 128};
1190 string err_message =
"SQLColAttribute failed." +
GetDbgInfo();
1210 string err_message =
"SQLColAttribute failed." +
GetDbgInfo();
1220 NULL,
sizeof(column_type),
1221 &slp, &column_type)) {
1231 string err_message =
"SQLColAttribute failed." +
GetDbgInfo();
1237 switch (column_type) {
1350 string err_message =
"Failed to get the results." +
GetDbgInfo();
1403 string err_message =
"Failed to fetch the results." +
GetDbgInfo();
1526 string err_message =
"Failed to fetch the results." +
GetDbgInfo();
virtual ~CODBC_CursorResultExpl(void)
virtual bool Fetch(void)
Fetch next row.
CODBC_CursorResultExpl(CODBC_LangCmd *cmd)
virtual I_BlobDescriptor * GetBlobDescriptor(void)
Get a descriptor for a BLOB column (for SendData).
virtual int CurrentItemNo(void) const
Return current item number we can retrieve (0,1,...) Return "-1" if no more items left (or available)...
virtual bool SkipItem(void)
Skip result item.
virtual bool Fetch(void)
Fetch next row.
virtual ~CODBC_CursorResult(void)
virtual EDB_ResType ResultType(void) const
Get type of the result.
virtual const CDBParams & GetDefineParams(void) const
const CODBC_Connection::TDbgInfo & GetDbgInfo(void) const
virtual int GetColumnNum(void) const
Return number of columns in the recordset.
CODBC_CursorResult(CODBC_LangCmd *cmd)
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).
virtual size_t ReadItem(void *buffer, size_t buffer_size, bool *is_null=0)
Read a result item body (for BLOB columns, mostly).
virtual bool HasMoreResults(void) const
virtual CDB_Result * Result(void)
Get result set.
virtual bool Send(void)
Send command to the server.
virtual EDB_ResType ResultType(void) const
Get type of the result.
CODBC_ParamResult(CStatementBase &stmt, SQLSMALLINT nof_cols)
virtual ~CODBC_ParamResult(void)
virtual ~CODBC_RowResult(void)
SQLLEN *const m_RowCountPtr
int xGetData(SQLSMALLINT target_type, SQLPOINTER buffer, SQLINTEGER buffer_size, bool *more=NULL)
const CODBC_Connection::TDbgInfo & GetDbgInfo(void) const
virtual EDB_ResType ResultType(void) const
Get type of the result.
SQLHSTMT GetHandle(void) const
CDB_Object * x_LoadItem(I_Result::EGetItem policy, CDB_Object *item_buf)
bool CheckSIENoD_Binary(CDB_Stream *val)
virtual bool SkipItem(void)
Skip result item.
virtual int GetColumnNum(void) const
Return number of columns in the recordset.
ssize_t x_GetVarLenData(SQLSMALLINT target_type, TItemBuffer &buffer, SQLINTEGER buffer_size)
virtual bool Fetch(void)
Fetch next row.
virtual size_t ReadItem(void *buffer, size_t buffer_size, bool *is_null=0)
Read a result item body (for BLOB columns, mostly).
EEncoding GetClientEncoding(void) const
virtual CDB_Object * GetItem(CDB_Object *item_buf=0, I_Result::EGetItem policy=I_Result::eAppendLOB)
Get a result item (you can use either GetItem or ReadItem).
virtual I_BlobDescriptor * GetBlobDescriptor(void)
Get a descriptor for a BLOB column (for SendData).
virtual int CurrentItemNo(void) const
Return current item number we can retrieve (0,1,...) Return "-1" if no more items left (or available)...
CODBC_RowResult(CStatementBase &stmt, SQLSMALLINT nof_cols, SQLLEN *row_count)
bool CheckSIENoD_WText(CDB_Stream *val)
bool CheckSIENoD_Text(CDB_Stream *val)
CDB_Object * x_MakeItem(void)
SODBC_ColDescr * m_ColFmt
virtual ~CODBC_StatusResult(void)
virtual EDB_ResType ResultType(void) const
Get type of the result.
CODBC_StatusResult(CStatementBase &stmt)
void Add(const string &name, size_t max_size, EDB_Type data_type=eDB_UnsupportedType, EDirection direction=eOut) const
virtual const CDBParams & GetDefineParams(void) const
CCachedRowInfo m_CachedRowInfo
@ eNoOwnership
No ownership is assumed.
#define DATABASE_DRIVER_ERROR(message, err_code)
#define DATABASE_DRIVER_ERROR_EX(prev_exception, message, err_code)
virtual unsigned int GetNum(void) const =0
Get total number of columns in resultset.
virtual EDB_ResType ResultType() const
Get type of the result.
virtual int GetColumnNum(void) const
Return number of columns in the recordset.
virtual int CurrentItemNo() const
Return current item number we can retrieve (0,1,...)
virtual bool SkipItem()
Skip result item.
virtual size_t ReadItem(void *buffer, size_t buffer_size, bool *is_null=0)
Read a result item body (for BLOB columns, mostly).
virtual CDB_Object * GetItem(CDB_Object *item_buf=0, EGetItem policy=eAppendLOB)
Get a result item (you can use either GetItem or ReadItem).
virtual I_BlobDescriptor * GetBlobDescriptor()
Get a descriptor for a BLOB column (for SendData).
virtual const CDBParams & GetDefineParams(void) const
Get meta-information about rows in resultset.
virtual bool Fetch()
Fetch next row.
virtual void AssignNULL()
const string & ConvertTo(EEncoding to_enc, EEncoding from_enc=eEncoding_Unknown) const
CDB_Numeric & Assign(unsigned int precision, unsigned int scale, const unsigned char *arr)
static CDB_Object * Create(EDB_Type type, size_t size=1)
virtual EDB_Type GetType() const =0
static const char * GetTypeName(EDB_Type db_type, bool throw_on_unknown=true)
#define NCBI_CURRENT_FUNCTION
Get current function name.
#define NCBI_CATCH_ALL_X(err_subcode, message)
uint8_t Uint1
1-byte (8-bit) unsigned integer
int16_t Int2
2-byte (16-bit) signed integer
int32_t Int4
4-byte (32-bit) signed integer
int64_t Int8
8-byte (64-bit) signed integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
CTime Truncate(const CTime &t)
unsigned int
A callback function used to compare two keys in a database.
Definition of all error codes used in dbapi libraries (dbapi_driver.lib and others).
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
double f(double x_, const double &y_)
void swap_numeric_endian(unsigned int precision, unsigned char *num)
static EDB_Type s_GetDataType(SQLSMALLINT t, SQLSMALLINT dec_digits, SQLULEN prec)
static void xConvert2CDB_Numeric(CDB_Numeric *d, SQL_NUMERIC_STRUCT &s)
static const char * wrong_type
static pcre_uint8 * buffer
#define SQL_ATTR_APP_ROW_DESC
SQLRETURN SQLFetch(SQLHSTMT StatementHandle)
#define SQL_TYPE_TIMESTAMP
#define SQL_DESC_PRECISION
SQLRETURN SQLDescribeCol(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName, SQLSMALLINT BufferLength, SQLSMALLINT *NameLength, SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize, SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
#define SQL_SUCCESS_WITH_INFO
SQLRETURN SQLGetStmtAttr(SQLHSTMT StatementHandle, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER *StringLength)
SQLRETURN SQLGetData(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, SQLPOINTER TargetValue, SQLINTEGER BufferLength, SQLINTEGER *StrLen_or_Ind)
SQLRETURN SQLColAttribute(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength, SQLINTEGER *NumericAttribute)
SQLRETURN SQLSetDescField(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, SQLPOINTER Value, SQLINTEGER BufferLength)
#define SQL_C_TYPE_TIMESTAMP
#define SQL_LONGVARBINARY
#define SQL_DESC_BASE_COLUMN_NAME
#define SQL_DESC_BASE_TABLE_NAME
signed short int SQLSMALLINT