Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsql_firebird_helpers_p.h File Reference

(cb715f20fe6de23940ca27a0e24012b1ef34d3b0)

#include <QtCore/qbytearray.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qloggingcategory.h>
#include <QtCore/qmetatype.h>
#include <QtCore/qvariant.h>
#include <QtSql/qtsqlglobal.h>
#include <QtSql/qsqlerror.h>
#include <QtSql/private/qsqlnumeric_p.h>
#include <ibase.h>
#include <firebird/Interface.h>
Include dependency graph for qsql_firebird_helpers_p.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  FbGuard< T >

Enumerations

enum class  TxnEnd : quint8 { Commit , Rollback }
enum class  TxnWait : quint8 { Wait , NoWait }

Functions

template<typename T>
static QT_BEGIN_NAMESPACE void fbRelease (T *hh)
template<typename T>
static void fbDispose (T *hh)
int fbBaseType (int tt)
QString fbErrorString (Firebird::IMaster *master, Firebird::IStatus *status)
QSqlError fbError (Firebird::IMaster *master, Firebird::IStatus *status, QSqlError::ErrorType typetype)
QString fbErrorLog (const QSqlError &err)
void finishAndClear (Firebird::ThrowStatusWrapper &st, Firebird::ITransaction *&tr, TxnEnd endend)
Firebird::ITransaction * startDefaultTransaction (Firebird::IAttachment *att, Firebird::ThrowStatusWrapper &st, TxnWait wait)
QMetaType::Type blrTypeToQt (unsigned char blrType, bool hasScale)
void encodeTextValue (char *datadata, int fbType, qsizetype lengthlength, const QByteArray &bytes)
QMetaType::Type fbTypeToQt (int fbType, int scalescale)
bool encodeInt128Slot (const QVariant &valval, int scalescale, char *slot, Firebird::IMaster *master, Firebird::IStatus *status, QString &errorText)
QVariant decodeInt128Slot (const char *slot, int scalescale, QSql::NumericalPrecisionPolicy policy, Firebird::IMaster *master, Firebird::IStatus *status, QString *overflowText=nullptr)
template<typename Iface, typename Raw>
static QString decFloatToString (Iface *iface, Firebird::ThrowStatusWrapper &st, const Raw *valuevalue)
template<typename Iface, typename Raw>
static void decFloatFromString (Iface *iface, Firebird::ThrowStatusWrapper &st, const QByteArray &ss, Raw *out)
ISC_DATE encodeQDate (Firebird::IUtil *util, const QDate &d)
ISC_TIME encodeQTime (Firebird::IUtil *util, const QTime &tt)
ISC_TIMESTAMP encodeQDateTime (Firebird::IUtil *util, const QDateTime &dt)
ISC_TIMESTAMP_TZ encodeQDateTimeTz (Firebird::IStatus *iStatus, Firebird::IUtil *util, const QDateTime &dt)
ISC_TIME_TZ encodeQTimeTz (Firebird::IStatus *iStatus, Firebird::IUtil *util, const QDateTime &dt)
QDate decodeFirebirdDate (Firebird::IUtil *util, ISC_DATE date)
QTime decodeFirebirdTime (Firebird::IUtil *util, ISC_TIME time)
QDateTime decodeFirebirdTimestamp (Firebird::IUtil *util, const ISC_TIMESTAMP &ts)
QDateTime decodeFirebirdTimestampTz (Firebird::IStatus *iStatus, Firebird::IUtil *util, const ISC_TIMESTAMP_TZ &tstz)
QDateTime decodeFirebirdTimeTz (Firebird::IStatus *iStatus, Firebird::IUtil *util, const ISC_TIME_TZ &ttz)

Enumeration Type Documentation

◆ TxnEnd

enum class TxnEnd : quint8
strong
Enumerator
Commit 
Rollback 

Definition at line 125 of file qsql_firebird_helpers_p.h.

◆ TxnWait

enum class TxnWait : quint8
strong
Enumerator
Wait 
NoWait 

Definition at line 131 of file qsql_firebird_helpers_p.h.

Function Documentation

◆ blrTypeToQt()

QMetaType::Type blrTypeToQt ( unsigned char blrType,
bool hasScale )

Definition at line 107 of file qsql_firebird_helpers.cpp.

◆ decFloatFromString()

template<typename Iface, typename Raw>
void decFloatFromString ( Iface * iface,
Firebird::ThrowStatusWrapper & st,
const QByteArray & s,
Raw * out )
static

Definition at line 196 of file qsql_firebird_helpers_p.h.

◆ decFloatToString()

template<typename Iface, typename Raw>
QString decFloatToString ( Iface * iface,
Firebird::ThrowStatusWrapper & st,
const Raw * value )
static

IDecFloat16 and IDecFloat34 share identical toString()/fromString() shapes; templated on the interface so one helper serves both DECFLOAT widths. The 64-char caller buffer is ample for DECFLOAT's 34 digits.

Definition at line 188 of file qsql_firebird_helpers_p.h.

◆ decodeFirebirdDate()

QDate decodeFirebirdDate ( Firebird::IUtil * util,
ISC_DATE date )

◆ decodeFirebirdTime()

QTime decodeFirebirdTime ( Firebird::IUtil * util,
ISC_TIME time )

◆ decodeFirebirdTimestamp()

QDateTime decodeFirebirdTimestamp ( Firebird::IUtil * util,
const ISC_TIMESTAMP & ts )

◆ decodeFirebirdTimestampTz()

QDateTime decodeFirebirdTimestampTz ( Firebird::IStatus * iStatus,
Firebird::IUtil * util,
const ISC_TIMESTAMP_TZ & tstz )

◆ decodeFirebirdTimeTz()

QDateTime decodeFirebirdTimeTz ( Firebird::IStatus * iStatus,
Firebird::IUtil * util,
const ISC_TIME_TZ & ttz )

◆ decodeInt128Slot()

QVariant decodeInt128Slot ( const char * slot,
int scale,
QSql::NumericalPrecisionPolicy policy,
Firebird::IMaster * master,
Firebird::IStatus * status,
QString * overflowText = nullptr )

◆ encodeInt128Slot()

bool encodeInt128Slot ( const QVariant & val,
int scale,
char * slot,
Firebird::IMaster * master,
Firebird::IStatus * status,
QString & errorText )

INT128 slot adapters

The two adapters own the single native/fallback switch for a 16-byte INT128 message slot (scale 0 for a plain INT128 parameter or array element), so the scalar paths and the array codec cannot diverge. With a 128-bit integer type (QSQL_HAS_INT128 from qsqlnumeric_p.h: qint128 on GCC/Clang, std::_Signed128 on MSVC via Qt's private qinternalint128 alias) the slot is packed and unpacked word-wise and converted with the QtPrivate::sql* helpers; without one, Firebird's IInt128 interface converts to and from the same canonical decimal string. Behaviour is identical either way.

Encoding reports a failure through errorText/false in both builds — never as FbException; callers wrap errorText with their own context. Decoding applies the numerical precision policy; when an integer part does not fit a LowPrecisionInt target it returns a double instead and, if overflowText is given, stores the value's decimal text there so the caller can warn at the rate it sees fit (QFirebirdResult::data() runs on every access of a cell).

◆ encodeQDate()

ISC_DATE encodeQDate ( Firebird::IUtil * util,
const QDate & d )

◆ encodeQDateTime()

ISC_TIMESTAMP encodeQDateTime ( Firebird::IUtil * util,
const QDateTime & dt )

◆ encodeQDateTimeTz()

ISC_TIMESTAMP_TZ encodeQDateTimeTz ( Firebird::IStatus * iStatus,
Firebird::IUtil * util,
const QDateTime & dt )

◆ encodeQTime()

ISC_TIME encodeQTime ( Firebird::IUtil * util,
const QTime & t )

◆ encodeQTimeTz()

ISC_TIME_TZ encodeQTimeTz ( Firebird::IStatus * iStatus,
Firebird::IUtil * util,
const QDateTime & dt )

◆ encodeTextValue()

void encodeTextValue ( char * data,
int fbType,
qsizetype length,
const QByteArray & bytes )

Encode a UTF-8 string into a CHAR/VARCHAR message slot: VARYING gets a 2-byte length prefix, TEXT is space-padded; data beyond the declared length is truncated. Shared by fillInputBuffer and lookupArrayDesc's bind loop so the Firebird text wire format lives in one place.

Definition at line 460 of file qsql_firebird_helpers.cpp.

◆ fbBaseType()

int fbBaseType ( int t)
inline

Definition at line 113 of file qsql_firebird_helpers_p.h.

Referenced by QFirebirdResult::data(), QFirebirdResultPrivate::encodeScaledNumeric(), fbTypeToQt(), and QFirebirdResultPrivate::fillInputBuffer().

Here is the caller graph for this function:

◆ fbDispose()

template<typename T>
void fbDispose ( T * h)
static

Definition at line 56 of file qsql_firebird_helpers_p.h.

◆ fbError()

QSqlError fbError ( Firebird::IMaster * master,
Firebird::IStatus * status,
QSqlError::ErrorType type )

◆ fbErrorLog()

QString fbErrorLog ( const QSqlError & err)

Definition at line 53 of file qsql_firebird_helpers.cpp.

◆ fbErrorString()

QString fbErrorString ( Firebird::IMaster * master,
Firebird::IStatus * status )

◆ fbRelease()

template<typename T>
QT_BEGIN_NAMESPACE void fbRelease ( T * h)
static

RAII guard for Firebird OO-API handles

The Firebird OO API splits cleanup across two families: reference-counted interfaces freed with release() (IStatement, IResultSet, IBlob, …) and IDisposable ones freed with dispose() (IXpbBuilder, IBatchCompletionState). FbGuard centralises the "free on every error path" bookkeeping so it is not repeated at every call site.

FbGuard owns one handle and frees it on scope exit with the action supplied at construction, unless it has been dismissed. closeWith() performs the type-specific graceful shutdown (IResultSet::close, IStatement::free, ITransaction::commit, …) which itself consumes the interface reference on success — so on success the guard is dismissed (no extra free), and only on a failed close does the destructor release the handle. This mirrors exactly the "close on the happy path, release on the error path" idiom used throughout.

Definition at line 55 of file qsql_firebird_helpers_p.h.

◆ fbTypeToQt()

QMetaType::Type fbTypeToQt ( int fbType,
int scale )

Definition at line 137 of file qsql_firebird_helpers.cpp.

References fbBaseType().

Here is the call graph for this function:

◆ finishAndClear()

void finishAndClear ( Firebird::ThrowStatusWrapper & st,
Firebird::ITransaction *& tr,
TxnEnd end )

Commit (or roll back) a transaction whose handle must not outlive a failure: on a throw the interface is released and the member cleared before the rethrow, on success commit/rollback already released it, so the member is cleared too. Taking the handle by reference makes "released implies cleared" structural — every finish site shares this discipline instead of repeating it. (The bare-COMMIT path in exec() intentionally does NOT use this: a failed user COMMIT keeps the still-valid handle so it can be retried.)

Definition at line 74 of file qsql_firebird_helpers.cpp.

References Commit.

◆ startDefaultTransaction()

Firebird::ITransaction * startDefaultTransaction ( Firebird::IAttachment * att,
Firebird::ThrowStatusWrapper & st,
TxnWait wait )