![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
#include "qsql_firebird_helpers_p.h"#include <QtCore/qtimezone.h>#include <firebird/impl/blr.h>#include <algorithm>#include <cstring>#include <limits>#include <iterator>Go to the source code of this file.
Functions | |
| QString | fbErrorString (IMaster *master, IStatus *status) |
| QSqlError | fbError (IMaster *master, IStatus *status, QSqlError::ErrorType type) |
| QString | fbErrorLog (const QSqlError &err) |
| void | finishAndClear (Firebird::ThrowStatusWrapper &st, Firebird::ITransaction *&tr, TxnEnd end) |
| ITransaction * | startDefaultTransaction (IAttachment *att, ThrowStatusWrapper &st, TxnWait wait) |
| QMetaType::Type | blrTypeToQt (unsigned char blrType, bool hasScale) |
| qint64 | pow10i (int n) |
| QMetaType::Type | fbTypeToQt (int fbType, int scale) |
| QByteArray | numericInputString (const QVariant &val) |
| bool | decimalToScaledInt64 (const QByteArray &decimal, int scale, qint64 *out) |
| QString | int128ToString (IUtil *util, ThrowStatusWrapper &st, const FB_I128 *value, int scale) |
| ISC_DATE | encodeQDate (IUtil *util, const QDate &d) |
| ISC_TIME | encodeQTime (IUtil *util, const QTime &t) |
| ISC_TIMESTAMP | encodeQDateTime (IUtil *util, const QDateTime &dt) |
| static QByteArray | toFirebirdZoneId (const QTimeZone &zone) |
| static QTimeZone | fromFirebirdZoneId (const QByteArray &id) |
| 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 *data, int fbType, qsizetype length, const QByteArray &bytes) |
| QMetaType::Type blrTypeToQt | ( | unsigned char | blrType, |
| bool | hasScale ) |
Definition at line 107 of file qsql_firebird_helpers.cpp.
| bool decimalToScaledInt64 | ( | const QByteArray & | decimal, |
| int | scale, | ||
| qint64 * | out ) |
Convert a plain decimal string (as produced by numericInputString) into the scaled integer Firebird stores for a NUMERIC/DECIMAL column: shift the decimal point by -scale digits (right for the usual negative scale), round half away from zero, and detect qint64 overflow. Works on the digit string, never through double — a double round-trip silently drops digits above 2^53 and an out-of-range double-to-integer cast is undefined behaviour. The read path (applyScale) avoids double for the same reason. Exponent notation is rejected, matching IInt128::fromString on the INT128 path.
Definition at line 218 of file qsql_firebird_helpers.cpp.
| QDate decodeFirebirdDate | ( | IUtil * | util, |
| ISC_DATE | date ) |
Definition at line 399 of file qsql_firebird_helpers.cpp.
| QTime decodeFirebirdTime | ( | IUtil * | util, |
| ISC_TIME | time ) |
Definition at line 408 of file qsql_firebird_helpers.cpp.
| QDateTime decodeFirebirdTimestamp | ( | IUtil * | util, |
| const ISC_TIMESTAMP & | ts ) |
Definition at line 419 of file qsql_firebird_helpers.cpp.
| QDateTime decodeFirebirdTimestampTz | ( | IStatus * | iStatus, |
| IUtil * | util, | ||
| const ISC_TIMESTAMP_TZ & | tstz ) |
Definition at line 429 of file qsql_firebird_helpers.cpp.
| QDateTime decodeFirebirdTimeTz | ( | IStatus * | iStatus, |
| IUtil * | util, | ||
| const ISC_TIME_TZ & | ttz ) |
Definition at line 450 of file qsql_firebird_helpers.cpp.
| ISC_DATE encodeQDate | ( | IUtil * | util, |
| const QDate & | d ) |
Definition at line 297 of file qsql_firebird_helpers.cpp.
| ISC_TIMESTAMP encodeQDateTime | ( | IUtil * | util, |
| const QDateTime & | dt ) |
Definition at line 323 of file qsql_firebird_helpers.cpp.
| ISC_TIMESTAMP_TZ encodeQDateTimeTz | ( | IStatus * | iStatus, |
| IUtil * | util, | ||
| const QDateTime & | dt ) |
Definition at line 358 of file qsql_firebird_helpers.cpp.
| ISC_TIME encodeQTime | ( | IUtil * | util, |
| const QTime & | t ) |
Definition at line 313 of file qsql_firebird_helpers.cpp.
| ISC_TIME_TZ encodeQTimeTz | ( | IStatus * | iStatus, |
| IUtil * | util, | ||
| const QDateTime & | dt ) |
Definition at line 380 of file qsql_firebird_helpers.cpp.
| 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 473 of file qsql_firebird_helpers.cpp.
| 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 43 of file qsql_firebird_helpers.cpp.
Definition at line 53 of file qsql_firebird_helpers.cpp.
| QString fbErrorString | ( | IMaster * | master, |
| IStatus * | status ) |
Definition at line 27 of file qsql_firebird_helpers.cpp.
| QMetaType::Type fbTypeToQt | ( | int | fbType, |
| int | scale ) |
Definition at line 150 of file qsql_firebird_helpers.cpp.
References fbBaseType().
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.
|
static |
Definition at line 349 of file qsql_firebird_helpers.cpp.
| QString int128ToString | ( | IUtil * | util, |
| ThrowStatusWrapper & | st, | ||
| const FB_I128 * | value, | ||
| int | scale ) |
Definition at line 287 of file qsql_firebird_helpers.cpp.
| QByteArray numericInputString | ( | const QVariant & | val | ) |
Canonical decimal string for binding a value to an INT128/DECFLOAT parameter via Firebird's fromString(). Integer and string variants are already plain C-locale decimals; floating-point variants are reformatted only when QVariant::toByteArray() yields exponential notation (e.g. a large double), which IInt128::fromString does not accept.
Definition at line 191 of file qsql_firebird_helpers.cpp.
| qint64 pow10i | ( | int | n | ) |
10^n as a 64-bit integer (n >= 0). Firebird numeric scale magnitudes are small (NUMERIC/DECIMAL precision <= 38, INT64 <= 18), so this never overflows for the integer-backed types it is used with.
Definition at line 142 of file qsql_firebird_helpers.cpp.
| 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 96 of file qsql_firebird_helpers.cpp.
|
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 341 of file qsql_firebird_helpers.cpp.