Qt 4.8
Public Functions | Protected Slots | Private Slots | Properties | Friends | List of all members
QIBaseDriver Class Reference

#include <qsql_ibase.h>

Inheritance diagram for QIBaseDriver:
QSqlDriver QObject

Public Functions

bool beginTransaction ()
 This function is called to begin a transaction. More...
 
void close ()
 Derived classes must reimplement this pure virtual function in order to close the database connection. More...
 
bool commitTransaction ()
 This function is called to commit a transaction. More...
 
QSqlResultcreateResult () const
 Creates an empty SQL result on the database. More...
 
QString escapeIdentifier (const QString &identifier, IdentifierType type) const
 Returns the identifier escaped according to the database rules. More...
 
QString formatValue (const QSqlField &field, bool trimStrings) const
 Returns a string representation of the field value for the database. More...
 
QVariant handle () const
 Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no handle. More...
 
bool hasFeature (DriverFeature f) const
 Returns true if the driver supports feature feature; otherwise returns false. More...
 
bool open (const QString &db, const QString &user, const QString &password, const QString &host, int port, const QString &connOpts)
 Derived classes must reimplement this pure virtual function to open a database connection on database db, using user name user, password password, host host, port port and connection options options. More...
 
bool open (const QString &db, const QString &user, const QString &password, const QString &host, int port)
 
QSqlIndex primaryIndex (const QString &table) const
 Returns the primary index for table tableName. More...
 
 QIBaseDriver (QObject *parent=0)
 
 QIBaseDriver (isc_db_handle connection, QObject *parent=0)
 
QSqlRecord record (const QString &tablename) const
 Returns a QSqlRecord populated with the names of the fields in table tableName. More...
 
bool rollbackTransaction ()
 This function is called to rollback a transaction. More...
 
QStringList tables (QSql::TableType) const
 Returns a list of the names of the tables in the database. More...
 
virtual ~QIBaseDriver ()
 
- Public Functions inherited from QSqlDriver
bool isIdentifierEscaped (const QString &identifier, IdentifierType type) const
 Returns whether identifier is escaped according to the database rules. More...
 
virtual bool isOpen () const
 Returns true if the database connection is open; otherwise returns false. More...
 
bool isOpenError () const
 Returns true if the there was an error opening the database connection; otherwise returns false. More...
 
QSqlError lastError () const
 Returns a QSqlError object which contains information about the last error that occurred on the database. More...
 
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy () const
 Returns the current default precision policy for the database connection. More...
 
 QSqlDriver (QObject *parent=0)
 Constructs a new driver with the given parent. More...
 
void setNumericalPrecisionPolicy (QSql::NumericalPrecisionPolicy precisionPolicy)
 Sets the default numerical precision policy used by queries created by this driver to precisionPolicy. More...
 
virtual QString sqlStatement (StatementType type, const QString &tableName, const QSqlRecord &rec, bool preparedStatement) const
 Returns a SQL statement of type type for the table tableName with the values from rec. More...
 
QString stripDelimiters (const QString &identifier, IdentifierType type) const
 Returns the identifier with the leading and trailing delimiters removed, identifier can either be a table name or field name, dependent on type. More...
 
QStringList subscribedToNotifications () const
 Returns a list of the names of the event notifications that are currently subscribed to. More...
 
bool subscribeToNotification (const QString &name)
 This function is called to subscribe to event notifications from the database. More...
 
bool unsubscribeFromNotification (const QString &name)
 This function is called to unsubscribe from event notifications from the database. More...
 
 ~QSqlDriver ()
 Destroys the object and frees any allocated resources. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Protected Slots

QStringList subscribedToNotificationsImplementation () const
 
bool subscribeToNotificationImplementation (const QString &name)
 
bool unsubscribeFromNotificationImplementation (const QString &name)
 
- Protected Slots inherited from QSqlDriver
bool isIdentifierEscapedImplementation (const QString &identifier, IdentifierType type) const
 This slot returns whether identifier is escaped according to the database rules. More...
 
QString stripDelimitersImplementation (const QString &identifier, IdentifierType type) const
 This slot returns identifier with the leading and trailing delimiters removed, identifier can either be a tablename or field name, dependent on type. More...
 
QStringList subscribedToNotificationsImplementation () const
 Returns a list of the names of the event notifications that are currently subscribed to. More...
 
bool subscribeToNotificationImplementation (const QString &name)
 This slot is called to subscribe to event notifications from the database. More...
 
bool unsubscribeFromNotificationImplementation (const QString &name)
 This slot is called to unsubscribe from event notifications from the database. More...
 

Private Slots

void qHandleEventNotification (void *updatedResultBuffer)
 

Properties

QIBaseDriverPrivated
 

Friends

class QIBaseDriverPrivate
 
class QIBaseResultPrivate
 

Additional Inherited Members

- Public Types inherited from QSqlDriver
enum  DriverFeature {
  Transactions, QuerySize, BLOB, Unicode,
  PreparedQueries, NamedPlaceholders, PositionalPlaceholders, LastInsertId,
  BatchOperations, SimpleLocking, LowPrecisionNumbers, EventNotifications,
  FinishQuery, MultipleResultSets
}
 This enum contains a list of features a driver might support. More...
 
enum  IdentifierType { FieldName, TableName }
 This enum contains a list of SQL identifier types. More...
 
enum  StatementType {
  WhereStatement, SelectStatement, UpdateStatement, InsertStatement,
  DeleteStatement
}
 This enum contains a list of SQL statement (or clause) types the driver can create. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QSqlDriver
void notification (const QString &name)
 This signal is emitted when the database posts an event notification that the driver subscribes to. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QSqlDriver
virtual void setLastError (const QSqlError &e)
 This function is used to set the value of the last error, error, that occurred on the database. More...
 
virtual void setOpen (bool o)
 This function sets the open state of the database to open. More...
 
virtual void setOpenError (bool e)
 This function sets the open error state of the database to error. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 80 of file qsql_ibase.h.

Constructors and Destructors

◆ QIBaseDriver() [1/2]

QIBaseDriver::QIBaseDriver ( QObject parent = 0)
explicit

Definition at line 1371 of file qsql_ibase.cpp.

1372  : QSqlDriver(parent)
1373 {
1374  d = new QIBaseDriverPrivate(this);
1375 }
QIBaseDriverPrivate * d
Definition: qsql_ibase.h:125
friend class QIBaseDriverPrivate
Definition: qsql_ibase.h:83
QSqlDriver(QObject *parent=0)
Constructs a new driver with the given parent.
Definition: qsqldriver.cpp:112

◆ QIBaseDriver() [2/2]

QIBaseDriver::QIBaseDriver ( isc_db_handle  connection,
QObject parent = 0 
)
explicit

Definition at line 1377 of file qsql_ibase.cpp.

1378  : QSqlDriver(parent)
1379 {
1380  d = new QIBaseDriverPrivate(this);
1381  d->ibase = connection;
1382  setOpen(true);
1383  setOpenError(false);
1384 }
QIBaseDriverPrivate * d
Definition: qsql_ibase.h:125
virtual void setOpen(bool o)
This function sets the open state of the database to open.
Definition: qsqldriver.cpp:283
virtual void setOpenError(bool e)
This function sets the open error state of the database to error.
Definition: qsqldriver.cpp:297
friend class QIBaseDriverPrivate
Definition: qsql_ibase.h:83
isc_db_handle ibase
Definition: qsql_ibase.cpp:330
QSqlDriver(QObject *parent=0)
Constructs a new driver with the given parent.
Definition: qsqldriver.cpp:112

◆ ~QIBaseDriver()

QIBaseDriver::~QIBaseDriver ( )
virtual

Definition at line 1386 of file qsql_ibase.cpp.

1387 {
1388  delete d;
1389 }
QIBaseDriverPrivate * d
Definition: qsql_ibase.h:125

Functions

◆ beginTransaction()

bool QIBaseDriver::beginTransaction ( )
virtual

This function is called to begin a transaction.

If successful, return true, otherwise return false. The default implementation does nothing and returns false.

See also
commitTransaction(), rollbackTransaction()

Reimplemented from QSqlDriver.

Definition at line 1532 of file qsql_ibase.cpp.

1533 {
1534  if (!isOpen() || isOpenError())
1535  return false;
1536  if (d->trans)
1537  return false;
1538 
1539  isc_start_transaction(d->status, &d->trans, 1, &d->ibase, 0, NULL);
1540  return !d->isError(QT_TRANSLATE_NOOP("QIBaseDriver", "Could not start transaction"),
1542 }
QIBaseDriverPrivate * d
Definition: qsql_ibase.h:125
isc_tr_handle trans
Definition: qsql_ibase.cpp:331
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
Definition: qglobal.h:2487
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
bool isOpenError() const
Returns true if the there was an error opening the database connection; otherwise returns false...
Definition: qsqldriver.cpp:192
ISC_STATUS status[20]
Definition: qsql_ibase.cpp:333
isc_db_handle ibase
Definition: qsql_ibase.cpp:330
bool isError(const char *msg, QSqlError::ErrorType typ=QSqlError::UnknownError)
Definition: qsql_ibase.cpp:316

◆ close()

void QIBaseDriver::close ( )
virtual

Derived classes must reimplement this pure virtual function in order to close the database connection.

Return true on success, false on failure.

See also
open(), setOpen()

Implements QSqlDriver.

Definition at line 1496 of file qsql_ibase.cpp.

Referenced by open().

1497 {
1498  if (isOpen()) {
1499 
1500  if (d->eventBuffers.size()) {
1501  ISC_STATUS status[20];
1503  for (i = d->eventBuffers.constBegin(); i != d->eventBuffers.constEnd(); ++i) {
1504  QIBaseEventBuffer *eBuffer = i.value();
1506  isc_cancel_events(status, &d->ibase, &eBuffer->eventId);
1507  qFreeEventBuffer(eBuffer);
1508  }
1509  d->eventBuffers.clear();
1510 
1511 #if defined(FB_API_VER)
1512  // Workaround for Firebird crash
1513  QTime timer;
1514  timer.start();
1515  while (timer.elapsed() < 500)
1517 #endif
1518  }
1519 
1520  isc_detach_database(d->status, &d->ibase);
1521  d->ibase = 0;
1522  setOpen(false);
1523  setOpenError(false);
1524  }
1525 }
QIBaseDriverPrivate * d
Definition: qsql_ibase.h:125
virtual void setOpen(bool o)
This function sets the open state of the database to open.
Definition: qsqldriver.cpp:283
virtual void setOpenError(bool e)
This function sets the open error state of the database to error.
Definition: qsqldriver.cpp:297
void start()
Sets this time to the current time.
Definition: qdatetime.cpp:2070
int size() const
Returns the number of (key, value) pairs in the map.
Definition: qmap.h:201
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
EventLoopTimerRef timer
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Processes all pending events for the calling thread according to the specified flags until there are ...
The QTime class provides clock time functions.
Definition: qdatetime.h:148
ISC_STATUS status[20]
Definition: qsql_ibase.cpp:333
isc_db_handle ibase
Definition: qsql_ibase.cpp:330
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the map.
Definition: qmap.h:374
int elapsed() const
Returns the number of milliseconds that have elapsed since the last time start() or restart() was cal...
Definition: qdatetime.cpp:2123
The QMap::const_iterator class provides an STL-style const iterator for QMap and QMultiMap.
Definition: qmap.h:301
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:380
static void qFreeEventBuffer(QIBaseEventBuffer *eBuffer)
Definition: qsql_ibase.cpp:341
QMap< QString, QIBaseEventBuffer * > eventBuffers
Definition: qsql_ibase.cpp:334
const T & value() const
Returns the current item&#39;s value.
Definition: qmap.h:325
QIBaseSubscriptionState subscriptionState
Definition: qsql_ibase.cpp:308
void clear()
Removes all items from the map.
Definition: qmap.h:444

◆ commitTransaction()

bool QIBaseDriver::commitTransaction ( )
virtual

This function is called to commit a transaction.

If successful, return true, otherwise return false. The default implementation does nothing and returns false.

See also
beginTransaction(), rollbackTransaction()

Reimplemented from QSqlDriver.

Definition at line 1544 of file qsql_ibase.cpp.

1545 {
1546  if (!isOpen() || isOpenError())
1547  return false;
1548  if (!d->trans)
1549  return false;
1550 
1551  isc_commit_transaction(d->status, &d->trans);
1552  d->trans = 0;
1553  return !d->isError(QT_TRANSLATE_NOOP("QIBaseDriver", "Unable to commit transaction"),
1555 }
QIBaseDriverPrivate * d
Definition: qsql_ibase.h:125
isc_tr_handle trans
Definition: qsql_ibase.cpp:331
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
Definition: qglobal.h:2487
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
bool isOpenError() const
Returns true if the there was an error opening the database connection; otherwise returns false...
Definition: qsqldriver.cpp:192
ISC_STATUS status[20]
Definition: qsql_ibase.cpp:333
bool isError(const char *msg, QSqlError::ErrorType typ=QSqlError::UnknownError)
Definition: qsql_ibase.cpp:316

◆ createResult()

QSqlResult * QIBaseDriver::createResult ( ) const
virtual

Creates an empty SQL result on the database.

Derived classes must reimplement this function and return a QSqlResult object appropriate for their database to the caller.

Implements QSqlDriver.

Definition at line 1527 of file qsql_ibase.cpp.

Referenced by primaryIndex(), record(), and tables().

1528 {
1529  return new QIBaseResult(this);
1530 }

◆ escapeIdentifier()

QString QIBaseDriver::escapeIdentifier ( const QString identifier,
IdentifierType  type 
) const
virtual

Returns the identifier escaped according to the database rules.

identifier can either be a table name or field name, dependent on type.

The default implementation does nothing.

See also
isIdentifierEscaped()

Reimplemented from QSqlDriver.

Definition at line 1870 of file qsql_ibase.cpp.

1871 {
1872  QString res = identifier;
1873  if(!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('"')) && !identifier.endsWith(QLatin1Char('"')) ) {
1874  res.replace(QLatin1Char('"'), QLatin1String("\"\""));
1875  res.prepend(QLatin1Char('"')).append(QLatin1Char('"'));
1876  res.replace(QLatin1Char('.'), QLatin1String("\".\""));
1877  }
1878  return res;
1879 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
QString & prepend(QChar c)
Definition: qstring.h:261
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString & append(QChar c)
Definition: qstring.cpp:1777
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ formatValue()

QString QIBaseDriver::formatValue ( const QSqlField field,
bool  trimStrings 
) const
virtual

Returns a string representation of the field value for the database.

Use the other formatValue() overload instead.

This is used, for example, when constructing INSERT and UPDATE statements.

The default implementation returns the value formatted as a string according to the following rules:

  • If field is character data, the value is returned enclosed in single quotation marks, which is appropriate for many SQL databases. Any embedded single-quote characters are escaped (replaced with two single-quote characters). If trimStrings is true (the default is false), all trailing whitespace is trimmed from the field.

  • If field is date/time data, the value is formatted in ISO format and enclosed in single quotation marks. If the date/time data is invalid, "NULL" is returned.

  • If field is bytearray data, and the driver can edit binary fields, the value is formatted as a hexadecimal string.

  • For any other field type, toString() is called on its value and the result of this is returned.

See also
QVariant::toString()

Reimplemented from QSqlDriver.

Definition at line 1677 of file qsql_ibase.cpp.

1678 {
1679  switch (field.type()) {
1680  case QVariant::DateTime: {
1681  QDateTime datetime = field.value().toDateTime();
1682  if (datetime.isValid())
1683  return QLatin1Char('\'') + QString::number(datetime.date().year()) + QLatin1Char('-') +
1684  QString::number(datetime.date().month()) + QLatin1Char('-') +
1685  QString::number(datetime.date().day()) + QLatin1Char(' ') +
1686  QString::number(datetime.time().hour()) + QLatin1Char(':') +
1687  QString::number(datetime.time().minute()) + QLatin1Char(':') +
1688  QString::number(datetime.time().second()) + QLatin1Char('.') +
1689  QString::number(datetime.time().msec()).rightJustified(3, QLatin1Char('0'), true) +
1690  QLatin1Char('\'');
1691  else
1692  return QLatin1String("NULL");
1693  }
1694  case QVariant::Time: {
1695  QTime time = field.value().toTime();
1696  if (time.isValid())
1697  return QLatin1Char('\'') + QString::number(time.hour()) + QLatin1Char(':') +
1698  QString::number(time.minute()) + QLatin1Char(':') +
1699  QString::number(time.second()) + QLatin1Char('.') +
1700  QString::number(time.msec()).rightJustified(3, QLatin1Char('0'), true) +
1701  QLatin1Char('\'');
1702  else
1703  return QLatin1String("NULL");
1704  }
1705  case QVariant::Date: {
1706  QDate date = field.value().toDate();
1707  if (date.isValid())
1708  return QLatin1Char('\'') + QString::number(date.year()) + QLatin1Char('-') +
1709  QString::number(date.month()) + QLatin1Char('-') +
1710  QString::number(date.day()) + QLatin1Char('\'');
1711  else
1712  return QLatin1String("NULL");
1713  }
1714  default:
1715  return QSqlDriver::formatValue(field, trimStrings);
1716  }
1717 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
bool isValid() const
Returns true if this date is valid; otherwise returns false.
Definition: qdatetime.cpp:340
QVariant value() const
Returns the value of the field as a QVariant.
Definition: qsqlfield.h:71
int month() const
Returns the number corresponding to the month of this date, using the following convention: ...
Definition: qdatetime.cpp:382
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349
int day() const
Returns the day of the month (1 to 31) of this date.
Definition: qdatetime.cpp:395
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
Definition: qdatetime.cpp:2346
The QDate class provides date functions.
Definition: qdatetime.h:55
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int msec() const
Returns the millisecond part (0 to 999) of the time.
Definition: qdatetime.cpp:1611
The QTime class provides clock time functions.
Definition: qdatetime.h:148
int second() const
Returns the second part (0 to 59) of the time.
Definition: qdatetime.cpp:1600
int minute() const
Returns the minute part (0 to 59) of the time.
Definition: qdatetime.cpp:1589
QVariant::Type type() const
Returns the field&#39;s type as stored in the database.
Definition: qsqlfield.cpp:394
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
QDate toDate() const
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2311
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
virtual QString formatValue(const QSqlField &field, bool trimStrings=false) const
Returns a string representation of the field value for the database.
Definition: qsqldriver.cpp:597
int year() const
Returns the year of this date.
Definition: qdatetime.cpp:353
QTime time() const
Returns the time part of the datetime.
Definition: qdatetime.cpp:2368
QTime toTime() const
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2330
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
bool isValid() const
Returns true if the time is valid; otherwise returns false.
Definition: qdatetime.cpp:1566
int hour() const
Returns the hour part (0 to 23) of the time.
Definition: qdatetime.cpp:1578

◆ handle()

QVariant QIBaseDriver::handle ( ) const
virtual

Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no handle.

Warning
Use this with uttermost care and only if you know what you're doing.
The handle returned here can become a stale pointer if the connection is modified (for example, if you close the connection).
The handle can be NULL if the connection is not open yet.

The handle returned here is database-dependent, you should query the type name of the variant before accessing it.

This example retrieves the handle for a connection to sqlite:

QSqlDatabase db = ...;
QVariant v = db.driver()->handle();
if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*") == 0) {
// v.data() returns a pointer to the handle
sqlite3 *handle = *static_cast<sqlite3 **>(v.data());
if (handle != 0) { // check that it is not NULL
...
}
}

This snippet returns the handle for PostgreSQL or MySQL:

if (qstrcmp(v.typeName(), "PGconn*") == 0) {
PGconn *handle = *static_cast<PGconn **>(v.data());
if (handle != 0) ...
}
if (qstrcmp(v.typeName(), "MYSQL*") == 0) {
MYSQL *handle = *static_cast<MYSQL **>(v.data());
if (handle != 0) ...
}
See also
QSqlResult::handle()

Reimplemented from QSqlDriver.

Definition at line 1719 of file qsql_ibase.cpp.

1720 {
1721  return QVariant(qRegisterMetaType<isc_db_handle>("isc_db_handle"), &d->ibase);
1722 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QIBaseDriverPrivate * d
Definition: qsql_ibase.h:125
isc_db_handle ibase
Definition: qsql_ibase.cpp:330

◆ hasFeature()

bool QIBaseDriver::hasFeature ( DriverFeature  feature) const
virtual

Returns true if the driver supports feature feature; otherwise returns false.

Note that some databases need to be open() before this can be determined.

See also
DriverFeature

Implements QSqlDriver.

Definition at line 1391 of file qsql_ibase.cpp.

◆ open() [1/2]

bool QIBaseDriver::open ( const QString db,
const QString user,
const QString password,
const QString host,
int  port,
const QString options 
)
virtual

Derived classes must reimplement this pure virtual function to open a database connection on database db, using user name user, password password, host host, port port and connection options options.

The function must return true on success and false on failure.

See also
setOpen()

Implements QSqlDriver.

Definition at line 1414 of file qsql_ibase.cpp.

1420 {
1421  if (isOpen())
1422  close();
1423 
1424  const QStringList opts(connOpts.split(QLatin1Char(';'), QString::SkipEmptyParts));
1425 
1426  QString encString;
1427  QByteArray role;
1428  for (int i = 0; i < opts.count(); ++i) {
1429  QString tmp(opts.at(i).simplified());
1430  int idx;
1431  if ((idx = tmp.indexOf(QLatin1Char('='))) != -1) {
1432  QString val = tmp.mid(idx + 1).simplified();
1433  QString opt = tmp.left(idx).simplified();
1434  if (opt.toUpper() == QLatin1String("ISC_DPB_LC_CTYPE"))
1435  encString = val;
1436  else if (opt.toUpper() == QLatin1String("ISC_DPB_SQL_ROLE_NAME")) {
1437  role = val.toLocal8Bit();
1438  role.truncate(255);
1439  }
1440  }
1441  }
1442 
1443  // Use UNICODE_FSS when no ISC_DPB_LC_CTYPE is provided
1444  if (encString.isEmpty())
1445  encString = QLatin1String("UNICODE_FSS");
1446  else {
1447  d->tc = QTextCodec::codecForName(encString.toLocal8Bit());
1448  if (!d->tc) {
1449  qWarning("Unsupported encoding: %s. Using UNICODE_FFS for ISC_DPB_LC_CTYPE.", encString.toLocal8Bit().constData());
1450  encString = QLatin1String("UNICODE_FSS"); // Fallback to UNICODE_FSS
1451  }
1452  }
1453 
1454  QByteArray enc = encString.toLocal8Bit();
1455  QByteArray usr = user.toLocal8Bit();
1456  QByteArray pass = password.toLocal8Bit();
1457  enc.truncate(255);
1458  usr.truncate(255);
1459  pass.truncate(255);
1460 
1461  QByteArray ba;
1462  ba.reserve(usr.length() + pass.length() + enc.length() + role.length() + 9);
1463  ba.append(char(isc_dpb_version1));
1464  ba.append(char(isc_dpb_user_name));
1465  ba.append(char(usr.length()));
1466  ba.append(usr.data(), usr.length());
1467  ba.append(char(isc_dpb_password));
1468  ba.append(char(pass.length()));
1469  ba.append(pass.data(), pass.length());
1470  ba.append(char(isc_dpb_lc_ctype));
1471  ba.append(char(enc.length()));
1472  ba.append(enc.data(), enc.length());
1473 
1474  if (!role.isEmpty()) {
1475  ba.append(char(isc_dpb_sql_role_name));
1476  ba.append(char(role.length()));
1477  ba.append(role.data(), role.length());
1478  }
1479 
1480  QString ldb;
1481  if (!host.isEmpty())
1482  ldb += host + QLatin1Char(':');
1483  ldb += db;
1484  isc_attach_database(d->status, 0, const_cast<char *>(ldb.toLocal8Bit().constData()),
1485  &d->ibase, ba.size(), ba.data());
1486  if (d->isError(QT_TRANSLATE_NOOP("QIBaseDriver", "Error opening database"),
1488  setOpenError(true);
1489  return false;
1490  }
1491 
1492  setOpen(true);
1493  return true;
1494 }
void truncate(int pos)
Truncates the byte array at index position pos.
QIBaseDriverPrivate * d
Definition: qsql_ibase.h:125
virtual void setOpen(bool o)
This function sets the open state of the database to open.
Definition: qsqldriver.cpp:283
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
virtual void setOpenError(bool e)
This function sets the open error state of the database to error.
Definition: qsqldriver.cpp:297
QByteArray & append(char c)
Appends the character ch to this byte array.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
Definition: qstring.cpp:5483
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
Definition: qglobal.h:2487
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
ISC_STATUS status[20]
Definition: qsql_ibase.cpp:333
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
Q_CORE_EXPORT void qWarning(const char *,...)
isc_db_handle ibase
Definition: qsql_ibase.cpp:330
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
int length() const
Same as size().
Definition: qbytearray.h:356
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
QString simplified() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end, and that has each sequence o...
Definition: qstring.cpp:4415
bool isError(const char *msg, QSqlError::ErrorType typ=QSqlError::UnknownError)
Definition: qsql_ibase.cpp:316
static QTextCodec * codecForName(const QByteArray &name)
Searches all installed QTextCodec objects and returns the one which best matches name; the match is c...
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
void reserve(int size)
Attempts to allocate memory for at least size bytes.
Definition: qbytearray.h:449
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
void close()
Derived classes must reimplement this pure virtual function in order to close the database connection...

◆ open() [2/2]

bool QIBaseDriver::open ( const QString db,
const QString user,
const QString password,
const QString host,
int  port 
)
inline

Definition at line 96 of file qsql_ibase.h.

100  { return open (db, user, password, host, port, QString()); }
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool open(const QString &db, const QString &user, const QString &password, const QString &host, int port, const QString &connOpts)
Derived classes must reimplement this pure virtual function to open a database connection on database...

◆ primaryIndex()

QSqlIndex QIBaseDriver::primaryIndex ( const QString tableName) const
virtual

Returns the primary index for table tableName.

Returns an empty QSqlIndex if the table doesn't have a primary index. The default implementation returns an empty index.

Reimplemented from QSqlDriver.

Definition at line 1644 of file qsql_ibase.cpp.

1645 {
1646  QSqlIndex index(table);
1647  if (!isOpen())
1648  return index;
1649 
1650  QString tablename = table;
1652  tablename = stripDelimiters(tablename, QSqlDriver::TableName);
1653  else
1654  tablename = tablename.toUpper();
1655 
1656  QSqlQuery q(createResult());
1657  q.setForwardOnly(true);
1658  q.exec(QLatin1String("SELECT a.RDB$INDEX_NAME, b.RDB$FIELD_NAME, d.RDB$FIELD_TYPE, d.RDB$FIELD_SCALE "
1659  "FROM RDB$RELATION_CONSTRAINTS a, RDB$INDEX_SEGMENTS b, RDB$RELATION_FIELDS c, RDB$FIELDS d "
1660  "WHERE a.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY' "
1661  "AND a.RDB$RELATION_NAME = '") + tablename +
1662  QLatin1String(" 'AND a.RDB$INDEX_NAME = b.RDB$INDEX_NAME "
1663  "AND c.RDB$RELATION_NAME = a.RDB$RELATION_NAME "
1664  "AND c.RDB$FIELD_NAME = b.RDB$FIELD_NAME "
1665  "AND d.RDB$FIELD_NAME = c.RDB$FIELD_SOURCE "
1666  "ORDER BY b.RDB$FIELD_POSITION"));
1667 
1668  while (q.next()) {
1669  QSqlField field(q.value(1).toString().simplified(), qIBaseTypeName(q.value(2).toInt(), q.value(3).toInt() < 0));
1670  index.append(field); //TODO: asc? desc?
1671  index.setName(q.value(0).toString());
1672  }
1673 
1674  return index;
1675 }
The QSqlIndex class provides functions to manipulate and describe database indexes.
Definition: qsqlindex.h:55
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
Definition: qstring.cpp:5483
The QSqlQuery class provides a means of executing and manipulating SQL statements.
Definition: qsqlquery.h:63
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
Definition: qsqldriver.cpp:429
static QVariant::Type qIBaseTypeName(int iType, bool hasScale)
Definition: qsql_ibase.cpp:167
QSqlResult * createResult() const
Creates an empty SQL result on the database.
quint16 index
The QSqlField class manipulates the fields in SQL database tables and views.
Definition: qsqlfield.h:56
QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
Definition: qsqldriver.cpp:455

◆ qHandleEventNotification

void QIBaseDriver::qHandleEventNotification ( void *  updatedResultBuffer)
privateslot

Definition at line 1830 of file qsql_ibase.cpp.

1831 {
1833  for (i = d->eventBuffers.constBegin(); i != d->eventBuffers.constEnd(); ++i) {
1834  QIBaseEventBuffer* eBuffer = i.value();
1835  if (reinterpret_cast<void *>(eBuffer->resultBuffer) != updatedResultBuffer)
1836  continue;
1837 
1838  ISC_ULONG counts[20];
1839  memset(counts, 0, sizeof(counts));
1840  isc_event_counts(counts, eBuffer->bufferLength, eBuffer->eventBuffer, eBuffer->resultBuffer);
1841  if (counts[0]) {
1842 
1844  emit notification(i.key());
1845  else if (eBuffer->subscriptionState == QIBaseEventBuffer::Starting)
1847 
1848  ISC_STATUS status[20];
1849  isc_que_events(status,
1850  &d->ibase,
1851  &eBuffer->eventId,
1852  eBuffer->bufferLength,
1853  eBuffer->eventBuffer,
1854 #if defined (FB_API_VER) && FB_API_VER >= 20
1855  (ISC_EVENT_CALLBACK)qEventCallback,
1856 #else
1857  (isc_callback)qEventCallback,
1858 #endif
1859  eBuffer->resultBuffer);
1860  if (status[0] == 1 && status[1]) {
1861  qCritical("QIBaseDriver::qHandleEventNotification: could not resubscribe to '%s'",
1862  qPrintable(i.key()));
1863  }
1864 
1865  return;
1866  }
1867  }
1868 }
QIBaseDriverPrivate * d
Definition: qsql_ibase.h:125
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
const Key & key() const
Returns the current item&#39;s key.
Definition: qmap.h:324
ISC_LONG bufferLength
Definition: qsql_ibase.cpp:304
#define emit
Definition: qobjectdefs.h:76
isc_db_handle ibase
Definition: qsql_ibase.cpp:330
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the map.
Definition: qmap.h:374
The QMap::const_iterator class provides an STL-style const iterator for QMap and QMultiMap.
Definition: qmap.h:301
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:380
QMap< QString, QIBaseEventBuffer * > eventBuffers
Definition: qsql_ibase.cpp:334
const T & value() const
Returns the current item&#39;s value.
Definition: qmap.h:325
QIBaseSubscriptionState subscriptionState
Definition: qsql_ibase.cpp:308
#define qPrintable(string)
Definition: qglobal.h:1750
static isc_callback qEventCallback(char *result, short length, char *updated)
Q_CORE_EXPORT void qCritical(const char *,...)
void notification(const QString &name)
This signal is emitted when the database posts an event notification that the driver subscribes to...

◆ record()

QSqlRecord QIBaseDriver::record ( const QString tableName) const
virtual

Returns a QSqlRecord populated with the names of the fields in table tableName.

Use query.

If no such table exists, an empty record is returned. The default implementation returns an empty record.

record() instead.

Reimplemented from QSqlDriver.

Definition at line 1605 of file qsql_ibase.cpp.

1606 {
1607  QSqlRecord rec;
1608  if (!isOpen())
1609  return rec;
1610 
1611  QSqlQuery q(createResult());
1612  q.setForwardOnly(true);
1613  QString table = tablename;
1615  table = stripDelimiters(table, QSqlDriver::TableName);
1616  else
1617  table = table.toUpper();
1618  q.exec(QLatin1String("SELECT a.RDB$FIELD_NAME, b.RDB$FIELD_TYPE, b.RDB$FIELD_LENGTH, "
1619  "b.RDB$FIELD_SCALE, b.RDB$FIELD_PRECISION, a.RDB$NULL_FLAG "
1620  "FROM RDB$RELATION_FIELDS a, RDB$FIELDS b "
1621  "WHERE b.RDB$FIELD_NAME = a.RDB$FIELD_SOURCE "
1622  "AND a.RDB$RELATION_NAME = '") + table + QLatin1String("' "
1623  "ORDER BY a.RDB$FIELD_POSITION"));
1624 
1625  while (q.next()) {
1626  int type = q.value(1).toInt();
1627  bool hasScale = q.value(3).toInt() < 0;
1628  QSqlField f(q.value(0).toString().simplified(), qIBaseTypeName(type, hasScale));
1629  if(hasScale) {
1630  f.setLength(q.value(4).toInt());
1631  f.setPrecision(qAbs(q.value(3).toInt()));
1632  } else {
1633  f.setLength(q.value(2).toInt());
1634  f.setPrecision(0);
1635  }
1636  f.setRequired(q.value(5).toInt() > 0 ? true : false);
1637  f.setSqlType(type);
1638 
1639  rec.append(f);
1640  }
1641  return rec;
1642 }
int type
Definition: qmetatype.cpp:239
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
Definition: qstring.cpp:5483
The QSqlQuery class provides a means of executing and manipulating SQL statements.
Definition: qsqlquery.h:63
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
The QSqlRecord class encapsulates a database record.
Definition: qsqlrecord.h:58
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
Definition: qsqldriver.cpp:429
void setLength(int fieldLength)
Sets the field&#39;s length to fieldLength.
Definition: qsqlfield.cpp:254
static QVariant::Type qIBaseTypeName(int iType, bool hasScale)
Definition: qsql_ibase.cpp:167
QSqlResult * createResult() const
Creates an empty SQL result on the database.
void append(const QSqlField &field)
Append a copy of field field to the end of the record.
Definition: qsqlrecord.cpp:312
The QSqlField class manipulates the fields in SQL database tables and views.
Definition: qsqlfield.h:56
QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
Definition: qsqldriver.cpp:455

◆ rollbackTransaction()

bool QIBaseDriver::rollbackTransaction ( )
virtual

This function is called to rollback a transaction.

If successful, return true, otherwise return false. The default implementation does nothing and returns false.

See also
beginTransaction(), commitTransaction()

Reimplemented from QSqlDriver.

Definition at line 1557 of file qsql_ibase.cpp.

1558 {
1559  if (!isOpen() || isOpenError())
1560  return false;
1561  if (!d->trans)
1562  return false;
1563 
1564  isc_rollback_transaction(d->status, &d->trans);
1565  d->trans = 0;
1566  return !d->isError(QT_TRANSLATE_NOOP("QIBaseDriver", "Unable to rollback transaction"),
1568 }
QIBaseDriverPrivate * d
Definition: qsql_ibase.h:125
isc_tr_handle trans
Definition: qsql_ibase.cpp:331
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
Definition: qglobal.h:2487
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
bool isOpenError() const
Returns true if the there was an error opening the database connection; otherwise returns false...
Definition: qsqldriver.cpp:192
ISC_STATUS status[20]
Definition: qsql_ibase.cpp:333
bool isError(const char *msg, QSqlError::ErrorType typ=QSqlError::UnknownError)
Definition: qsql_ibase.cpp:316

◆ subscribedToNotificationsImplementation

QStringList QIBaseDriver::subscribedToNotificationsImplementation ( ) const
protectedslot

Definition at line 1825 of file qsql_ibase.cpp.

1826 {
1827  return QStringList(d->eventBuffers.keys());
1828 }
QIBaseDriverPrivate * d
Definition: qsql_ibase.h:125
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QList< Key > keys() const
Returns a list containing all the keys in the map in ascending order.
Definition: qmap.h:818
QMap< QString, QIBaseEventBuffer * > eventBuffers
Definition: qsql_ibase.cpp:334

◆ subscribeToNotificationImplementation

bool QIBaseDriver::subscribeToNotificationImplementation ( const QString name)
protectedslot

Definition at line 1747 of file qsql_ibase.cpp.

1748 {
1749  if (!isOpen()) {
1750  qWarning("QIBaseDriver::subscribeFromNotificationImplementation: database not open.");
1751  return false;
1752  }
1753 
1754  if (d->eventBuffers.contains(name)) {
1755  qWarning("QIBaseDriver::subscribeToNotificationImplementation: already subscribing to '%s'.",
1756  qPrintable(name));
1757  return false;
1758  }
1759 
1760  QIBaseEventBuffer *eBuffer = new QIBaseEventBuffer;
1762  eBuffer->bufferLength = isc_event_block(&eBuffer->eventBuffer,
1763  &eBuffer->resultBuffer,
1764  1,
1765  name.toLocal8Bit().constData());
1766 
1767  qMutex()->lock();
1768  qBufferDriverMap()->insert(eBuffer->resultBuffer, this);
1769  qMutex()->unlock();
1770 
1771  d->eventBuffers.insert(name, eBuffer);
1772 
1773  ISC_STATUS status[20];
1774  isc_que_events(status,
1775  &d->ibase,
1776  &eBuffer->eventId,
1777  eBuffer->bufferLength,
1778  eBuffer->eventBuffer,
1779 #if defined (FB_API_VER) && FB_API_VER >= 20
1780  (ISC_EVENT_CALLBACK)qEventCallback,
1781 #else
1782  (isc_callback)qEventCallback,
1783 #endif
1784  eBuffer->resultBuffer);
1785 
1786  if (status[0] == 1 && status[1]) {
1787  setLastError(QSqlError(QString::fromLatin1("Could not subscribe to event notifications for %1.").arg(name)));
1788  d->eventBuffers.remove(name);
1789  qFreeEventBuffer(eBuffer);
1790  return false;
1791  }
1792 
1793  return true;
1794 }
The QSqlError class provides SQL database error information.
Definition: qsqlerror.h:53
QIBaseDriverPrivate * d
Definition: qsql_ibase.h:125
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
ISC_LONG bufferLength
Definition: qsql_ibase.cpp:304
Q_CORE_EXPORT void qWarning(const char *,...)
isc_db_handle ibase
Definition: qsql_ibase.cpp:330
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int remove(const Key &key)
Removes all the items that have the key key from the map.
Definition: qmap.h:662
static void qFreeEventBuffer(QIBaseEventBuffer *eBuffer)
Definition: qsql_ibase.cpp:341
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
QMap< QString, QIBaseEventBuffer * > eventBuffers
Definition: qsql_ibase.cpp:334
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
Definition: qmap.h:553
QIBaseSubscriptionState subscriptionState
Definition: qsql_ibase.cpp:308
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database...
Definition: qsqldriver.cpp:350
#define qPrintable(string)
Definition: qglobal.h:1750
static isc_callback qEventCallback(char *result, short length, char *updated)

◆ tables()

QStringList QIBaseDriver::tables ( QSql::TableType  tableType) const
virtual

Returns a list of the names of the tables in the database.

The default implementation returns an empty list.

The tableType argument describes what types of tables should be returned. Due to binary compatibility, the string contains the value of the enum QSql::TableTypes as text. An empty string should be treated as QSql::Tables for backward compatibility.

Reimplemented from QSqlDriver.

Definition at line 1570 of file qsql_ibase.cpp.

1571 {
1572  QStringList res;
1573  if (!isOpen())
1574  return res;
1575 
1576  QString typeFilter;
1577 
1578  if (type == QSql::SystemTables) {
1579  typeFilter += QLatin1String("RDB$SYSTEM_FLAG != 0");
1580  } else if (type == (QSql::SystemTables | QSql::Views)) {
1581  typeFilter += QLatin1String("RDB$SYSTEM_FLAG != 0 OR RDB$VIEW_BLR NOT NULL");
1582  } else {
1583  if (!(type & QSql::SystemTables))
1584  typeFilter += QLatin1String("RDB$SYSTEM_FLAG = 0 AND ");
1585  if (!(type & QSql::Views))
1586  typeFilter += QLatin1String("RDB$VIEW_BLR IS NULL AND ");
1587  if (!(type & QSql::Tables))
1588  typeFilter += QLatin1String("RDB$VIEW_BLR IS NOT NULL AND ");
1589  if (!typeFilter.isEmpty())
1590  typeFilter.chop(5);
1591  }
1592  if (!typeFilter.isEmpty())
1593  typeFilter.prepend(QLatin1String("where "));
1594 
1595  QSqlQuery q(createResult());
1596  q.setForwardOnly(true);
1597  if (!q.exec(QLatin1String("select rdb$relation_name from rdb$relations ") + typeFilter))
1598  return res;
1599  while(q.next())
1600  res << q.value(0).toString().simplified();
1601 
1602  return res;
1603 }
int type
Definition: qmetatype.cpp:239
void chop(int n)
Removes n characters from the end of the string.
Definition: qstring.cpp:4623
QString & prepend(QChar c)
Definition: qstring.h:261
The QSqlQuery class provides a means of executing and manipulating SQL statements.
Definition: qsqlquery.h:63
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
T value(int i) const
Returns the value at index position i in the list.
Definition: qlist.h:661
QString simplified() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end, and that has each sequence o...
Definition: qstring.cpp:4415
QSqlResult * createResult() const
Creates an empty SQL result on the database.

◆ unsubscribeFromNotificationImplementation

bool QIBaseDriver::unsubscribeFromNotificationImplementation ( const QString name)
protectedslot

Definition at line 1796 of file qsql_ibase.cpp.

1797 {
1798  if (!isOpen()) {
1799  qWarning("QIBaseDriver::unsubscribeFromNotificationImplementation: database not open.");
1800  return false;
1801  }
1802 
1803  if (!d->eventBuffers.contains(name)) {
1804  qWarning("QIBaseDriver::QIBaseSubscriptionState not subscribed to '%s'.",
1805  qPrintable(name));
1806  return false;
1807  }
1808 
1809  QIBaseEventBuffer *eBuffer = d->eventBuffers.value(name);
1810  ISC_STATUS status[20];
1812  isc_cancel_events(status, &d->ibase, &eBuffer->eventId);
1813 
1814  if (status[0] == 1 && status[1]) {
1815  setLastError(QSqlError(QString::fromLatin1("Could not unsubscribe from event notifications for %1.").arg(name)));
1816  return false;
1817  }
1818 
1819  d->eventBuffers.remove(name);
1820  qFreeEventBuffer(eBuffer);
1821 
1822  return true;
1823 }
The QSqlError class provides SQL database error information.
Definition: qsqlerror.h:53
QIBaseDriverPrivate * d
Definition: qsql_ibase.h:125
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
const T value(const Key &key) const
Returns the value associated with the key key.
Definition: qmap.h:499
Q_CORE_EXPORT void qWarning(const char *,...)
isc_db_handle ibase
Definition: qsql_ibase.cpp:330
int remove(const Key &key)
Removes all the items that have the key key from the map.
Definition: qmap.h:662
static void qFreeEventBuffer(QIBaseEventBuffer *eBuffer)
Definition: qsql_ibase.cpp:341
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
QMap< QString, QIBaseEventBuffer * > eventBuffers
Definition: qsql_ibase.cpp:334
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
Definition: qmap.h:553
QIBaseSubscriptionState subscriptionState
Definition: qsql_ibase.cpp:308
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database...
Definition: qsqldriver.cpp:350
#define qPrintable(string)
Definition: qglobal.h:1750

Friends and Related Functions

◆ QIBaseDriverPrivate

friend class QIBaseDriverPrivate
friend

Definition at line 83 of file qsql_ibase.h.

Referenced by QIBaseDriver().

◆ QIBaseResultPrivate

friend class QIBaseResultPrivate
friend

Definition at line 84 of file qsql_ibase.h.

Properties

◆ d

QIBaseDriverPrivate* QIBaseDriver::d
private

The documentation for this class was generated from the following files: