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_array_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// Copyright (C) 2026 Andreas Bacher
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4// Qt-Security score:significant reason:default
5#ifndef QSQL_FIREBIRD_ARRAY_P_H
6#define QSQL_FIREBIRD_ARRAY_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/qbytearray.h>
20#include <QtCore/qhash.h>
21#include <QtCore/qlist.h>
22#include <QtCore/qstring.h>
23#include <QtCore/qvariant.h>
24
25#include <ibase.h> // ISC_QUAD, ISC_ARRAY_DESC
26#include <firebird/Interface.h>
27
29
30// Firebird ARRAY column support (qsql_firebird_array.cpp). The descriptor
31// lookup, slice sizing and (de)serialisation internals are file-static there;
32// only the two whole-column entry points are exposed.
33
34// Identifies the array column an ISC_ARRAY_DESC was resolved for
35struct ArrayFieldKey
36{
37 QByteArray relation;
38 QByteArray field;
39};
40
41inline bool operator==(const ArrayFieldKey &lhs, const ArrayFieldKey &rhs) noexcept
42{
43 return lhs.relation == rhs.relation && lhs.field == rhs.field;
44}
45
46inline size_t qHash(const ArrayFieldKey &key, size_t seed = 0) noexcept
47{
48 return qHashMulti(seed, key.relation, key.field);
49}
50
51using ArrayDescCache = QHash<ArrayFieldKey, ISC_ARRAY_DESC>;
52
53// Fetch array data via OO API (IAttachment::getSlice)
54QVariant fetchArray(Firebird::IAttachment *att, Firebird::ITransaction *tra,
55 Firebird::IStatus *iStatus, Firebird::IMaster *master,
56 ArrayDescCache &descCache,
57 const ISC_QUAD &arrayId, const QString &relation,
58 const QString &field);
59
60// Write array data via OO API (IAttachment::putSlice)
61bool writeArray(Firebird::IAttachment *att, Firebird::ITransaction *tra,
62 Firebird::IStatus *iStatus, Firebird::IMaster *master,
63 ArrayDescCache &descCache,
64 ISC_QUAD *arrayId, const QString &relation,
65 const QString &field, const QList<QVariant> &list);
66
67QT_END_NAMESPACE
68
69#endif // QSQL_FIREBIRD_ARRAY_P_H
void setError(const QString &msg, QSqlError::ErrorType type, const QString &code={})
QHash< QString, QFirebirdEventSubscription * > eventSubscriptions
Firebird::ITransaction * iTrans
Firebird::IAttachment * iAtt
QList< QFirebirdResultPrivate * > activeResults
bool finishTransaction(TxnEnd end)
void setFbError(const QString &context, QSqlError::ErrorType type=QSqlError::UnknownError)
bool commitTransaction() override
This function is called to commit a transaction.
QSqlResult * createResult() const override
Creates an empty SQL result on the database.
bool cancelQuery() override
bool hasFeature(DriverFeature feature) const override
Returns true if the driver supports feature feature; otherwise returns false.
QString escapeIdentifier(const QString &identifier, IdentifierType type) const override
Returns the identifier escaped according to the database rules.
QSqlRecord record(const QString &tableName) const override
Returns a QSqlRecord populated with the names of the fields in table tableName.
QFirebirdDriver(QObject *parent=nullptr)
bool rollbackTransaction() override
This function is called to rollback a transaction.
QSqlIndex primaryIndex(const QString &tableName) const override
Returns the primary index for table tableName.
int maximumIdentifierLength(IdentifierType type) const override
QVariant handle() const override
Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no hand...
bool open(const QString &db, const QString &user, const QString &password, const QString &host, int port, const QString &connOpts) override
Derived classes must reimplement this pure virtual function to open a database connection on database...
QStringList subscribedToNotifications() const override
Returns a list of the names of the event notifications that are currently subscribed to.
bool unsubscribeFromNotification(const QString &name) override
This function is called to unsubscribe from event notifications from the database.
QString formatValue(const QSqlField &field, bool trimStrings) const override
Returns a string representation of the field value for the database.
bool beginTransaction() override
This function is called to begin a transaction.
bool subscribeToNotification(const QString &name) override
This function is called to subscribe to event notifications from the database.
~QFirebirdDriver() override
void close() override
Derived classes must reimplement this pure virtual function in order to close the database connection...
void eventCallbackFunction(unsigned length, const unsigned char *data) override
QFirebirdEventSubscription(QFirebirdDriver *drv, IAttachment *att, const QString &eventName)
Firebird::IStatement * stmt
Firebird::IAttachment * att() const
QString formatFbError(const QString &ctx)
Firebird::IMessageMetadata * inMeta
void adoptReplacementTransaction(Firebird::ITransaction *executedTr, Firebird::ITransaction *newTr)
bool encodeScaledNumeric(char *data, int fbType, int scale, const QVariant &val, QString &errorText)
bool fillInputBuffer(const QList< QVariant > &vals, QString &errorText, BlobWriter blobWriter={})
Firebird::ITransaction * autoTrans
Firebird::IMessageMetadata * outMeta
Firebird::ITransaction * activeTransaction() const
Firebird::IResultSet * cursor
static constexpr int AffectedPending
Firebird::IStatus * status() const
Firebird::ITransaction * ensureTransaction()
bool buildInputMessage(QString &errorText)
void writeInlineBlob(ISC_QUAD &blobId, const QByteArray &blobData)
Firebird::IMaster * master() const
bool execBatch(bool arrayBind=false) override
bool fetchNext() override
Positions the result to the next available record (row) in the result.
bool fetchLast() override
Positions the result to the last record (last row) in the result.
QFirebirdResult(const QFirebirdDriver *driver)
bool isNull(int field) override
Returns true if the field at position index in the current row is null; otherwise returns false.
int numRowsAffected() override
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
void detachFromResultSet() override
bool fetchFirst() override
Positions the result to the first record (row 0) in the result.
QSqlRecord record() const override
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
bool fetchPrevious() override
Positions the result to the previous record (row) in the result.
bool fetch(int i) override
Positions the result to an arbitrary (zero-based) row index.
int size() override
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
bool exec() override
Executes the query, returning true if successful; otherwise returns false.
bool reset(const QString &query) override
Sets the result to use the SQL statement query for subsequent data retrieval.
QVariant data(int field) override
Returns the data for field index in the current row as a QVariant.
QVariant handle() const override
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
bool prepare(const QString &query) override
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
Combined button and popup list for selecting options.
bool writeArray(IAttachment *att, ITransaction *tra, IStatus *iStatus, IMaster *master, ArrayDescCache &descCache, ISC_QUAD *arrayId, const QString &relation, const QString &field, const QList< QVariant > &list)
QVariant fetchArray(IAttachment *att, ITransaction *tra, IStatus *iStatus, IMaster *master, ArrayDescCache &descCache, const ISC_QUAD &arrayId, const QString &relation, const QString &field)
bool operator==(const ArrayFieldKey &lhs, const ArrayFieldKey &rhs) noexcept
size_t qHash(const ArrayFieldKey &key, size_t seed=0) noexcept
QDateTime decodeFirebirdTimestamp(Firebird::IUtil *util, const ISC_TIMESTAMP &ts)
int fbBaseType(int t)
QString fbErrorLog(const QSqlError &err)
static void decFloatFromString(Iface *iface, Firebird::ThrowStatusWrapper &st, const QByteArray &s, Raw *out)
Firebird::ITransaction * startDefaultTransaction(Firebird::IAttachment *att, Firebird::ThrowStatusWrapper &st, TxnWait wait)
QString fbErrorString(Firebird::IMaster *master, Firebird::IStatus *status)
bool decimalToScaledInt64(const QByteArray &decimal, int scale, qint64 *out)
ISC_TIMESTAMP encodeQDateTime(Firebird::IUtil *util, const QDateTime &dt)
ISC_TIME encodeQTime(Firebird::IUtil *util, const QTime &t)
QDate decodeFirebirdDate(Firebird::IUtil *util, ISC_DATE date)
static QVariant applyScale(T val, int scale, QSql::NumericalPrecisionPolicy policy)
QDateTime decodeFirebirdTimeTz(Firebird::IStatus *iStatus, Firebird::IUtil *util, const ISC_TIME_TZ &ttz)
void encodeTextValue(char *data, int fbType, qsizetype length, const QByteArray &bytes)
void finishAndClear(Firebird::ThrowStatusWrapper &st, Firebird::ITransaction *&tr, TxnEnd end)
QDateTime decodeFirebirdTimestampTz(Firebird::IStatus *iStatus, Firebird::IUtil *util, const ISC_TIMESTAMP_TZ &tstz)
QByteArray numericInputString(const QVariant &val)
QMetaType::Type blrTypeToQt(unsigned char blrType, bool hasScale)
QTime decodeFirebirdTime(Firebird::IUtil *util, ISC_TIME time)
ISC_TIMESTAMP_TZ encodeQDateTimeTz(Firebird::IStatus *iStatus, Firebird::IUtil *util, const QDateTime &dt)
static QString decFloatToString(Iface *iface, Firebird::ThrowStatusWrapper &st, const Raw *value)
ISC_TIME_TZ encodeQTimeTz(Firebird::IStatus *iStatus, Firebird::IUtil *util, const QDateTime &dt)
QString int128ToString(Firebird::IUtil *util, Firebird::ThrowStatusWrapper &st, const FB_I128 *value, int scale)
QSqlError fbError(Firebird::IMaster *master, Firebird::IStatus *status, QSqlError::ErrorType type)
ISC_DATE encodeQDate(Firebird::IUtil *util, const QDate &d)
QMetaType::Type fbTypeToQt(int fbType, int scale)
static QString numberToHighPrecision(T val, int scale)
qint64 pow10i(int n)
QMetaType::Type qtType