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.cpp File Reference

(bc79443baf3f974ad8717c88a6c84aaa63b33fdc)

#include "qsql_firebird_helpers_p.h"
#include <QtCore/qtimezone.h>
#include <QtCore/private/qflatmap_p.h>
#include <firebird/impl/blr.h>
#include <algorithm>
#include <cstring>
#include <limits>
#include <iterator>
Include dependency graph for qsql_firebird_helpers.cpp:

Go to the source code of this file.

Functions

QString fbErrorString (IMaster *master, IStatus *status)
QSqlError fbError (IMaster *master, IStatus *status, QSqlError::ErrorType typetype)
QString fbErrorLog (const QSqlError &err)
void finishAndClear (Firebird::ThrowStatusWrapper &st, Firebird::ITransaction *&tr, TxnEnd endend)
ITransaction * startDefaultTransaction (IAttachment *att, ThrowStatusWrapper &st, TxnWait wait)
QMetaType::Type blrTypeToQt (unsigned char blrType, bool hasScale)
QMetaType::Type fbTypeToQt (int fbType, int scalescale)
static QString int128SlotToString (const char *slot, int scalescale, IMaster *master, IStatus *status)
bool encodeInt128Slot (const QVariant &valval, int scalescale, char *slot, IMaster *master, IStatus *status, QString &errorText)
QVariant decodeInt128Slot (const char *slot, int scalescale, QSql::NumericalPrecisionPolicy policy, IMaster *master, IStatus *status, QString *overflowText)
ISC_DATE encodeQDate (IUtil *util, const QDate &d)
ISC_TIME encodeQTime (IUtil *util, const QTime &tt)
ISC_TIMESTAMP encodeQDateTime (IUtil *util, const QDateTime &dt)
static QByteArray toFirebirdZoneId (const QTimeZone &zone)
static QTimeZone fromFirebirdZoneId (const QByteArray &idid)
static QTimeZone zoneForFirebirdId (ISC_USHORT zoneId, const char *tzName)
ISC_TIMESTAMP_TZ encodeQDateTimeTz (IStatus *iStatus, IUtil *util, const QDateTime &dt)
ISC_TIME_TZ encodeQTimeTz (IStatus *iStatus, IUtil *util, const QDateTime &dt)
QDate decodeFirebirdDate (IUtil *util, ISC_DATE date)
QTime decodeFirebirdTime (IUtil *util, ISC_TIME time)
QDateTime decodeFirebirdTimestamp (IUtil *util, const ISC_TIMESTAMP &ts)
QDateTime decodeFirebirdTimestampTz (IStatus *iStatus, IUtil *util, const ISC_TIMESTAMP_TZ &tstz)
QDateTime decodeFirebirdTimeTz (IStatus *iStatus, IUtil *util, const ISC_TIME_TZ &ttz)
void encodeTextValue (char *datadata, int fbType, qsizetype lengthlength, const QByteArray &bytes)

Function Documentation

◆ blrTypeToQt()

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

Definition at line 108 of file qsql_firebird_helpers.cpp.

◆ decodeFirebirdDate()

QDate decodeFirebirdDate ( IUtil * util,
ISC_DATE date )

Definition at line 407 of file qsql_firebird_helpers.cpp.

◆ decodeFirebirdTime()

QTime decodeFirebirdTime ( IUtil * util,
ISC_TIME time )

Definition at line 416 of file qsql_firebird_helpers.cpp.

◆ decodeFirebirdTimestamp()

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

Definition at line 427 of file qsql_firebird_helpers.cpp.

◆ decodeFirebirdTimestampTz()

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

Definition at line 437 of file qsql_firebird_helpers.cpp.

◆ decodeFirebirdTimeTz()

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

Definition at line 458 of file qsql_firebird_helpers.cpp.

◆ decodeInt128Slot()

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

Definition at line 233 of file qsql_firebird_helpers.cpp.

◆ encodeInt128Slot()

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

Definition at line 188 of file qsql_firebird_helpers.cpp.

◆ encodeQDate()

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

Definition at line 285 of file qsql_firebird_helpers.cpp.

◆ encodeQDateTime()

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

Definition at line 311 of file qsql_firebird_helpers.cpp.

◆ encodeQDateTimeTz()

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

Definition at line 366 of file qsql_firebird_helpers.cpp.

◆ encodeQTime()

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

Definition at line 301 of file qsql_firebird_helpers.cpp.

◆ encodeQTimeTz()

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

Definition at line 388 of file qsql_firebird_helpers.cpp.

◆ 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 481 of file qsql_firebird_helpers.cpp.

◆ fbError()

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

Convert a Firebird status vector into a QSqlError. type is the context in which the error occurred, supplied by the caller (open() -> ConnectionError, prepare()/exec() -> StatementError, begin/commit/rollback -> TransactionError); QSqlError::ErrorType categorises errors by that context, not by the underlying Firebird cause. The SQLCODE is carried through as the native error code.

Definition at line 44 of file qsql_firebird_helpers.cpp.

◆ fbErrorLog()

QString fbErrorLog ( const QSqlError & err)

Definition at line 54 of file qsql_firebird_helpers.cpp.

◆ fbErrorString()

QString fbErrorString ( IMaster * master,
IStatus * status )

Definition at line 28 of file qsql_firebird_helpers.cpp.

◆ fbTypeToQt()

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

Definition at line 138 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 75 of file qsql_firebird_helpers.cpp.

References Commit.

◆ fromFirebirdZoneId()

QTimeZone fromFirebirdZoneId ( const QByteArray & id)
static

Definition at line 337 of file qsql_firebird_helpers.cpp.

◆ int128SlotToString()

QString int128SlotToString ( const char * slot,
int scale,
IMaster * master,
IStatus * status )
static

Definition at line 177 of file qsql_firebird_helpers.cpp.

◆ startDefaultTransaction()

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

Start a transaction with the driver's default TPB: read-committed, record-version, read-write. wait selects isc_tpb_wait vs isc_tpb_nowait — the only axis on which the auto-started transaction (wait) and the explicit user transaction (nowait) differ.

Definition at line 97 of file qsql_firebird_helpers.cpp.

◆ toFirebirdZoneId()

QByteArray toFirebirdZoneId ( const QTimeZone & zone)
static

Firebird names fixed-offset zones by their bare displacement ("+05:30"), while Qt uses "UTC+05:30"-style ids for them. Map between the two so offset-tagged QDateTimes bind and read back cleanly.

Definition at line 329 of file qsql_firebird_helpers.cpp.

◆ zoneForFirebirdId()

QTimeZone zoneForFirebirdId ( ISC_USHORT zoneId,
const char * tzName )
static

QTimeZone for the zone of a decoded TIMESTAMP/TIME WITH TIME ZONE value. Constructing a QTimeZone from its id is a lookup in the system's zone database and by far the most expensive step of decoding such a value, while a result set typically carries only a handful of distinct zones. Firebird's numeric zone id identifies the zone process-wide (region ids are fixed, offset ids encode the displacement), so resolve each id once per thread. tzName is the name fbclient decoded for zoneId.

Definition at line 355 of file qsql_firebird_helpers.cpp.