Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsql_odbc.cpp File Reference

(efd6786e52639ef1ceab819265b0c33d7ef8294e)

#include "qsql_odbc_p.h"
#include <qsqlrecord.h>
#include <qcoreapplication.h>
#include <qdatetime.h>
#include <qlist.h>
#include <qloggingcategory.h>
#include <qmath.h>
#include <qsqlerror.h>
#include <qsqlfield.h>
#include <qsqlindex.h>
#include <qstringconverter.h>
#include <qstringlist.h>
#include <qvariant.h>
#include <qvarlengtharray.h>
#include <QDebug>
#include <QSqlQuery>
#include <QtSql/private/qsqldriver_p.h>
#include <QtSql/private/qsqlresult_p.h>
#include "private/qtools_p.h"
#include "moc_qsql_odbc_p.cpp"
+ Include dependency graph for qsql_odbc.cpp:

Go to the source code of this file.

Classes

class  SqlStmtHandle
 
class  QODBCDriverPrivate
 
class  QODBCResult
 
class  QODBCResultPrivate
 
struct  DiagRecord
 

Macros

#define SQL_SS_TIME2   (-154)
 
#define ODBC_CHECK_DRIVER
 

Functions

template<typename C , int SIZE = sizeof(SQLTCHAR)>
static QString fromSQLTCHAR (const C &input, qsizetype size=-1)
 
template<int SIZE = sizeof(SQLTCHAR)>
QStringConverter::Encoding encodingForSqlTChar ()
 
static QVarLengthArray< SQLTCHAR > toSQLTCHAR (QStringView input)
 
static QList< DiagRecordqWarnODBCHandle (int handleType, SQLHANDLE handle)
 
static QList< DiagRecordqODBCWarn (const SQLHANDLE hStmt, const SQLHANDLE envHandle=nullptr, const SQLHANDLE pDbC=nullptr)
 
static QList< DiagRecordqODBCWarn (const QODBCResultPrivate *odbc)
 
static QList< DiagRecordqODBCWarn (const QODBCDriverPrivate *odbc)
 
static DiagRecord combineRecords (const QList< DiagRecord > &records)
 
static QSqlError errorFromDiagRecords (const QString &err, QSqlError::ErrorType type, const QList< DiagRecord > &records)
 
static QString errorStringFromDiagRecords (const QList< DiagRecord > &records)
 
template<class T >
static void qSqlWarning (const QString &message, T &&val)
 
static QSqlError qMakeError (const QString &err, QSqlError::ErrorType type, const QODBCResultPrivate *p)
 
static QSqlError qMakeError (const QString &err, QSqlError::ErrorType type, const QODBCDriverPrivate *p)
 
static QMetaType qDecodeODBCType (SQLSMALLINT sqltype, bool isSigned=true)
 
template<typename CT >
static QVariant getStringDataImpl (SQLHANDLE hStmt, SQLUSMALLINT column, qsizetype colSize, SQLSMALLINT targetType)
 
static QVariant qGetStringData (SQLHANDLE hStmt, SQLUSMALLINT column, int colSize, bool unicode)
 
static QVariant qGetBinaryData (SQLHANDLE hStmt, int column)
 
static QVariant qGetIntData (SQLHANDLE hStmt, int column, bool isSigned=true)
 
static QVariant qGetDoubleData (SQLHANDLE hStmt, int column)
 
static QVariant qGetBigIntData (SQLHANDLE hStmt, int column, bool isSigned=true)
 
static bool isAutoValue (const SQLHANDLE hStmt, int column)
 
static QSqlField qMakeFieldInfo (const SQLHANDLE hStmt, const QODBCDriverPrivate *p)
 
static QSqlField qMakeFieldInfo (const QODBCResultPrivate *p, int i)
 
static size_t qGetODBCVersion (const QString &connOpts)
 
static SQLRETURN qt_string_SQLSetConnectAttr (SQLHDBC handle, SQLINTEGER attr, QStringView val)
 

Variables

static constexpr int COLNAMESIZE = 256
 
static constexpr SQLSMALLINT TABLENAMESIZE = 128
 
static constexpr SQLSMALLINT qParamType [4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, SQL_PARAM_INPUT_OUTPUT }
 

Macro Definition Documentation

◆ ODBC_CHECK_DRIVER

#define ODBC_CHECK_DRIVER

Definition at line 40 of file qsql_odbc.cpp.

◆ SQL_SS_TIME2

#define SQL_SS_TIME2   (-154)

Definition at line 36 of file qsql_odbc.cpp.

Referenced by qDecodeODBCType().

Function Documentation

◆ combineRecords()

static DiagRecord combineRecords ( const QList< DiagRecord > & records)
static

Definition at line 293 of file qsql_odbc.cpp.

References add(), and DiagRecord::description.

Referenced by errorFromDiagRecords(), and errorStringFromDiagRecords().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ encodingForSqlTChar()

template<int SIZE = sizeof(SQLTCHAR)>
QStringConverter::Encoding encodingForSqlTChar ( )

Definition at line 89 of file qsql_odbc.cpp.

References SIZE, QStringConverter::Utf16, QStringConverter::Utf32, and QStringConverter::Utf8.

Referenced by toSQLTCHAR().

+ Here is the caller graph for this function:

◆ errorFromDiagRecords()

static QSqlError errorFromDiagRecords ( const QString & err,
QSqlError::ErrorType type,
const QList< DiagRecord > & records )
static

Definition at line 305 of file qsql_odbc.cpp.

References combineRecords().

Referenced by qMakeError(), and qMakeError().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ errorStringFromDiagRecords()

static QString errorStringFromDiagRecords ( const QList< DiagRecord > & records)
static

Definition at line 316 of file qsql_odbc.cpp.

References combineRecords().

Referenced by qSqlWarning().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromSQLTCHAR()

template<typename C , int SIZE = sizeof(SQLTCHAR)>
static QString fromSQLTCHAR ( const C & input,
qsizetype size = -1 )
inlinestatic

Definition at line 71 of file qsql_odbc.cpp.

References QString::fromUcs4(), QString::fromUtf16(), QString::fromUtf8(), qMin(), and SIZE.

Referenced by QODBCDriverPrivate::checkDBMS(), QODBCDriverPrivate::checkHasMultiResults(), QODBCDriverPrivate::checkUnicode(), QODBCResult::exec(), qMakeFieldInfo(), and qWarnODBCHandle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStringDataImpl()

template<typename CT >
static QVariant getStringDataImpl ( SQLHANDLE hStmt,
SQLUSMALLINT column,
qsizetype colSize,
SQLSMALLINT targetType )
static

Definition at line 411 of file qsql_odbc.cpp.

References qSqlWarning().

+ Here is the call graph for this function:

◆ isAutoValue()

static bool isAutoValue ( const SQLHANDLE hStmt,
int column )
static

Definition at line 591 of file qsql_odbc.cpp.

References arg, QString::number(), and qSqlWarning().

Referenced by qMakeFieldInfo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qDecodeODBCType()

static QMetaType qDecodeODBCType ( SQLSMALLINT sqltype,
bool isSigned = true )
static

Definition at line 346 of file qsql_odbc.cpp.

References SQL_SS_TIME2, and QMetaType::UnknownType.

Referenced by qMakeFieldInfo(), and qMakeFieldInfo().

+ Here is the caller graph for this function:

◆ qGetBigIntData()

static QVariant qGetBigIntData ( SQLHANDLE hStmt,
int column,
bool isSigned = true )
static

Definition at line 570 of file qsql_odbc.cpp.

Referenced by QODBCResult::data().

+ Here is the caller graph for this function:

◆ qGetBinaryData()

static QVariant qGetBinaryData ( SQLHANDLE hStmt,
int column )
static

Definition at line 473 of file qsql_odbc.cpp.

References arg, COLNAMESIZE, QString::number(), qSqlWarning(), and read().

Referenced by QODBCResult::data().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qGetDoubleData()

static QVariant qGetDoubleData ( SQLHANDLE hStmt,
int column )
static

Definition at line 550 of file qsql_odbc.cpp.

Referenced by QODBCResult::data().

+ Here is the caller graph for this function:

◆ qGetIntData()

static QVariant qGetIntData ( SQLHANDLE hStmt,
int column,
bool isSigned = true )
static

Definition at line 530 of file qsql_odbc.cpp.

Referenced by QODBCResult::data(), and qMakeFieldInfo().

+ Here is the caller graph for this function:

◆ qGetODBCVersion()

static size_t qGetODBCVersion ( const QString & connOpts)
static

Definition at line 688 of file qsql_odbc.cpp.

References Qt::CaseInsensitive.

Referenced by QODBCDriver::open().

+ Here is the caller graph for this function:

◆ qGetStringData()

static QVariant qGetStringData ( SQLHANDLE hStmt,
SQLUSMALLINT column,
int colSize,
bool unicode )
static

Definition at line 460 of file qsql_odbc.cpp.

Referenced by QODBCResult::data(), and qMakeFieldInfo().

+ Here is the caller graph for this function:

◆ qMakeError() [1/2]

static QSqlError qMakeError ( const QString & err,
QSqlError::ErrorType type,
const QODBCDriverPrivate * p )
static

Definition at line 339 of file qsql_odbc.cpp.

References errorFromDiagRecords(), and qODBCWarn().

+ Here is the call graph for this function:

◆ qMakeError() [2/2]

static QSqlError qMakeError ( const QString & err,
QSqlError::ErrorType type,
const QODBCResultPrivate * p )
static

Definition at line 332 of file qsql_odbc.cpp.

References errorFromDiagRecords(), and qODBCWarn().

Referenced by QODBCResult::exec(), QODBCResult::fetch(), QODBCResult::fetchFirst(), QODBCResult::fetchLast(), QODBCResult::fetchNext(), QODBCResult::fetchPrevious(), QODBCResult::nextResult(), QODBCResult::prepare(), and QODBCResult::reset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qMakeFieldInfo() [1/2]

static QSqlField qMakeFieldInfo ( const QODBCResultPrivate * p,
int i )
static

Definition at line 625 of file qsql_odbc.cpp.

References arg, COLNAMESIZE, fromSQLTCHAR(), i, isAutoValue(), QString::number(), qDecodeODBCType(), qSqlWarning(), and TABLENAMESIZE.

+ Here is the call graph for this function:

◆ qMakeFieldInfo() [2/2]

static QSqlField qMakeFieldInfo ( const SQLHANDLE hStmt,
const QODBCDriverPrivate * p )
static

Definition at line 606 of file qsql_odbc.cpp.

References QVariant::isNull(), qDecodeODBCType(), qGetIntData(), qGetStringData(), QVariant::toInt(), and var.

Referenced by QODBCResult::exec(), QODBCResult::nextResult(), and QODBCResult::reset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qODBCWarn() [1/3]

static QList< DiagRecord > qODBCWarn ( const QODBCDriverPrivate * odbc)
static

Definition at line 288 of file qsql_odbc.cpp.

References qODBCWarn().

+ Here is the call graph for this function:

◆ qODBCWarn() [2/3]

static QList< DiagRecord > qODBCWarn ( const QODBCResultPrivate * odbc)
static

Definition at line 283 of file qsql_odbc.cpp.

References qODBCWarn().

+ Here is the call graph for this function:

◆ qODBCWarn() [3/3]

static QList< DiagRecord > qODBCWarn ( const SQLHANDLE hStmt,
const SQLHANDLE envHandle = nullptr,
const SQLHANDLE pDbC = nullptr )
static

Definition at line 272 of file qsql_odbc.cpp.

References qWarnODBCHandle().

Referenced by qMakeError(), qMakeError(), qODBCWarn(), qODBCWarn(), and qSqlWarning().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qSqlWarning()

template<class T >
static void qSqlWarning ( const QString & message,
T && val )
static

Definition at line 323 of file qsql_odbc.cpp.

References errorStringFromDiagRecords(), qCWarning, and qODBCWarn().

Referenced by QODBCResult::~QODBCResult(), QODBCDriverPrivate::checkDriver(), QODBCDriverPrivate::checkHasSQLFetchScroll(), QODBCResult::data(), QODBCResult::exec(), getStringDataImpl(), isAutoValue(), QODBCResult::lastInsertId(), QODBCResult::nextResult(), QODBCResult::numRowsAffected(), QODBCResult::prepare(), qGetBinaryData(), qMakeFieldInfo(), QODBCResult::reset(), QODBCDriverPrivate::setConnectionOptions(), and QODBCDriverPrivate::splitTableQualifier().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_string_SQLSetConnectAttr()

static SQLRETURN qt_string_SQLSetConnectAttr ( SQLHDBC handle,
SQLINTEGER attr,
QStringView val )
static

Definition at line 726 of file qsql_odbc.cpp.

References QByteArray::data(), encoded, QByteArray::size(), and toSQLTCHAR().

Referenced by QODBCDriverPrivate::setConnectionOptions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qWarnODBCHandle()

static QList< DiagRecord > qWarnODBCHandle ( int handleType,
SQLHANDLE handle )
static

Definition at line 235 of file qsql_odbc.cpp.

References fromSQLTCHAR(), i, QString::number(), and state.

Referenced by qODBCWarn().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toSQLTCHAR()

static QVarLengthArray< SQLTCHAR > toSQLTCHAR ( QStringView input)
inlinestatic

Definition at line 102 of file qsql_odbc.cpp.

References encodingForSqlTChar().

Referenced by QODBCDriverPrivate::checkUnicode(), QODBCResult::exec(), QODBCDriver::open(), QODBCResult::prepare(), QODBCDriver::primaryIndex(), qt_string_SQLSetConnectAttr(), QODBCDriver::record(), QODBCResult::reset(), and QODBCDriver::tables().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ COLNAMESIZE

constexpr int COLNAMESIZE = 256
staticconstexpr

Definition at line 42 of file qsql_odbc.cpp.

Referenced by qGetBinaryData(), and qMakeFieldInfo().

◆ qParamType

constexpr SQLSMALLINT qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, SQL_PARAM_INPUT_OUTPUT }
staticconstexpr

Definition at line 45 of file qsql_odbc.cpp.

Referenced by QODBCResult::exec().

◆ TABLENAMESIZE

constexpr SQLSMALLINT TABLENAMESIZE = 128
staticconstexpr

Definition at line 43 of file qsql_odbc.cpp.

Referenced by qMakeFieldInfo().