58 #include <QVarLengthArray> 62 #define FBVERSION SQL_DIALECT_V6 64 #ifndef SQLDA_CURRENT_VERSION 65 #define SQLDA_CURRENT_VERSION SQLDA_VERSION1 70 #if defined(FB_API_VER) && FB_API_VER >= 20 76 if (status[0] != 1 || status[1] <= 0)
80 sqlcode = isc_sqlcode(status);
82 #if defined(FB_API_VER) && FB_API_VER >= 20 83 while(fb_interpret(buf, 512, &status)) {
85 while(isc_interprete(buf, &status)) {
99 sqlda = (XSQLDA *) malloc(XSQLDA_LENGTH(1));
100 if (sqlda == (XSQLDA*)0)
return;
104 sqlda->sqlvar[0].sqlind = 0;
105 sqlda->sqlvar[0].sqldata = 0;
110 if (sqlda != (XSQLDA*)0)
112 sqlda = (XSQLDA *) malloc(XSQLDA_LENGTH(n));
113 if (sqlda == (XSQLDA*)0)
return;
120 for (
int i = 0; i < sqlda->sqld; ++i) {
121 switch (sqlda->sqlvar[i].sqltype & ~1) {
132 sqlda->sqlvar[i].sqldata =
new char[sqlda->sqlvar[i].sqllen];
135 sqlda->sqlvar[i].sqldata =
new char[
sizeof(ISC_QUAD)];
136 memset(sqlda->sqlvar[i].sqldata, 0,
sizeof(ISC_QUAD));
139 sqlda->sqlvar[i].sqldata =
new char[sqlda->sqlvar[i].sqllen +
sizeof(short)];
143 sqlda->sqlvar[i].sqldata = 0;
146 if (sqlda->sqlvar[i].sqltype & 1) {
147 sqlda->sqlvar[i].sqlind =
new short[1];
148 *(sqlda->sqlvar[i].sqlind) = 0;
150 sqlda->sqlvar[i].sqlind = 0;
159 for (
int i = 0; i < sqlda->sqld; ++i) {
160 delete [] sqlda->sqlvar[i].sqlind;
161 delete [] sqlda->sqlvar[i].sqldata;
195 qWarning(
"qIBaseTypeName: unknown datatype: %d", iType);
230 static const QTime midnight(0, 0, 0, 0);
231 static const QDate basedate(1858, 11, 17);
233 ts.timestamp_time = midnight.
msecsTo(dt.
time()) * 10;
234 ts.timestamp_date = basedate.
daysTo(dt.
date());
240 static const QDate bd(1858, 11, 17);
246 t = t.
addMSecs(
int(((ISC_TIMESTAMP*)buffer)->timestamp_time / 10));
247 d = bd.
addDays(
int(((ISC_TIMESTAMP*)buffer)->timestamp_date));
254 static const QTime midnight(0, 0, 0, 0);
255 return (ISC_TIME)midnight.
msecsTo(t) * 10;
263 t = t.
addMSecs(
int((*(ISC_TIME*)buffer) / 10));
270 static const QDate basedate(1858, 11, 17);
273 date = basedate.
daysTo(t);
279 static const QDate bd(1858, 11, 17);
284 d = bd.
addDays(
int(((ISC_TIMESTAMP*)buffer)->timestamp_date));
297 #if defined(FB_API_VER) && FB_API_VER >= 20 324 imsg, typ,
int(sqlcode)));
333 ISC_STATUS status[20];
344 qBufferDriverMap()->remove(reinterpret_cast<void *>(eBuffer->
resultBuffer));
364 imsg, typ,
int(sqlcode)));
374 QVariant fetchArray(
int pos, ISC_QUAD *arr);
380 ISC_STATUS status[20];
394 q(d), db(ddb), trans(0), stmt(0), ibase(ddb->d->ibase), sqlda(0), inda(0), queryType(-1), tc(ddb->d->tc)
406 isc_dsql_free_statement(status, &
stmt, DSQL_drop);
419 isc_blob_handle handle = 0;
420 ISC_QUAD *bId = (ISC_QUAD*)
inda->sqlvar[i].sqldata;
421 isc_create_blob2(status, &
ibase, &
trans, &handle, bId, 0, 0);
425 while (i < ba.
size()) {
427 const_cast<char*>(ba.
data()) + i);
433 isc_close_blob(status, &handle);
439 isc_blob_handle handle = 0;
441 isc_open_blob2(status, &
ibase, &
trans, &handle, bId, 0, 0);
446 unsigned short len = 0;
451 while (isc_get_segment(status, &handle, &len, chunkSize, ba.
data() + read) == 0 || status[1] == isc_segment) {
453 ba.
resize(read + chunkSize);
457 bool isErr = (status[1] == isc_segstr_eof ? false :
459 "Unable to read BLOB"),
462 isc_close_blob(status, &handle);
475 for (
int i = 0; i < count; ++i) {
486 for (
int i = 0; i < count; ++i) {
487 if (
sizeof(
int) ==
sizeof(long))
488 res.
append(
int((*(
long*)(*buf))));
491 *buf +=
sizeof(long);
497 short* numElements, ISC_ARRAY_DESC *arrayDesc,
500 const short dim = arrayDesc->array_desc_dimensions - 1;
501 const unsigned char dataType = arrayDesc->array_desc_dtype;
503 unsigned short strLen = arrayDesc->array_desc_length;
506 for(
int i = 0; i < numElements[curDim]; ++i)
517 for (
int i = 0; i < numElements[dim]; ++i) {
518 for(o = 0; o < strLen && buffer[o]!=0; ++o )
530 valList =
toList<long>(&buffer, numElements[dim],
static_cast<long *
>(0));
533 valList = toList<short>(&buffer, numElements[dim]);
536 valList = toList<qint64>(&buffer, numElements[dim]);
539 valList = toList<float>(&buffer, numElements[dim]);
542 valList = toList<double>(&buffer, numElements[dim]);
545 for(
int i = 0; i < numElements[dim]; ++i) {
547 buffer +=
sizeof(ISC_TIMESTAMP);
551 for(
int i = 0; i < numElements[dim]; ++i) {
553 buffer +=
sizeof(ISC_TIME);
557 for(
int i = 0; i < numElements[dim]; ++i) {
559 buffer +=
sizeof(ISC_DATE);
582 isc_array_lookup_bounds(status, &
ibase, &
trans, relname.
data(), sqlname.
data(), &desc);
588 int arraySize = 1, subArraySize;
589 short dimensions = desc.array_desc_dimensions;
592 for(
int i = 0; i < dimensions; ++i) {
593 subArraySize = (desc.array_desc_bounds[i].array_bound_upper -
594 desc.array_desc_bounds[i].array_bound_lower + 1);
595 numElements[i] = subArraySize;
596 arraySize = subArraySize * arraySize;
604 if (desc.array_desc_dtype == blr_varying
605 || desc.array_desc_dtype == blr_varying2) {
606 desc.array_desc_length += 2;
607 bufLen = desc.array_desc_length * arraySize *
sizeof(short);
609 bufLen = desc.array_desc_length * arraySize;
614 isc_array_get_slice(status, &
ibase, &
trans, arr, &desc, ba.
data(), &bufLen);
627 for (
int i = 0; i < list.
size(); ++i) {
630 memcpy(buffer, &val,
sizeof(T));
639 for (
int i = 0; i < list.size(); ++i) {
644 memcpy(buffer, &val2,
sizeof(
float));
645 buffer +=
sizeof(float);
651 short buflen,
bool varying,
bool array,
656 short tmpBuflen = buflen;
657 if (str.
length() < buflen)
660 memcpy(buffer, str.
data(), buflen);
661 memset(buffer + buflen, 0, tmpBuflen - buflen);
663 *(
short*)buffer = buflen;
664 memcpy(buffer +
sizeof(
short), str.
data(), buflen);
669 memcpy(buffer, str.
data(), buflen);
680 ISC_ARRAY_BOUND *bounds = arrayDesc->array_desc_bounds;
681 short dim = arrayDesc->array_desc_dimensions - 1;
683 int elements = (bounds[curDim].array_bound_upper -
684 bounds[curDim].array_bound_lower + 1);
687 error =
QLatin1String(
"Expected size: %1. Supplied size: %2");
694 for(i = 0; i < list.
size(); ++i) {
697 error =
QLatin1String(
"Array dimensons mismatch. Fieldname: %1");
710 if (arrayDesc->array_desc_dtype == blr_short)
711 buffer = fillList<short>(buffer, list);
713 buffer = fillList<int>(buffer, list);
716 if (arrayDesc->array_desc_dtype == blr_float)
719 buffer = fillList<double>(buffer, list);
722 buffer = fillList<qint64>(buffer, list);
725 buffer = fillList<quint64>(buffer, list);
728 for (i = 0; i < list.size(); ++i)
730 arrayDesc->array_desc_length,
731 arrayDesc->array_desc_dtype == blr_varying,
735 for (i = 0; i < list.size(); ++i) {
736 *((ISC_DATE*)buffer) =
toDate(list.at(i).toDate());
737 buffer +=
sizeof(ISC_DATE);
741 for (i = 0; i < list.size(); ++i) {
742 *((ISC_TIME*)buffer) =
toTime(list.at(i).toTime());
743 buffer +=
sizeof(ISC_TIME);
748 for (i = 0; i < list.size(); ++i) {
749 *((ISC_TIMESTAMP*)buffer) =
toTimeStamp(list.at(i).toDateTime());
750 buffer +=
sizeof(ISC_TIMESTAMP);
763 ISC_QUAD *arrayId = (ISC_QUAD*)
inda->sqlvar[column].sqldata;
766 QByteArray relname(
inda->sqlvar[column].relname,
inda->sqlvar[column].relname_length);
767 QByteArray sqlname(
inda->sqlvar[column].aliasname,
inda->sqlvar[column].aliasname_length);
769 isc_array_lookup_bounds(status, &
ibase, &
trans, relname.data(), sqlname.
data(), &desc);
778 short dimensions = desc.array_desc_dimensions;
779 for(
int i = 0; i < dimensions; ++i) {
780 arraySize *= (desc.array_desc_bounds[i].array_bound_upper -
781 desc.array_desc_bounds[i].array_bound_lower + 1);
787 if (desc.array_desc_dtype == blr_varying ||
788 desc.array_desc_dtype == blr_varying2)
789 desc.array_desc_length += 2;
791 bufLen = desc.array_desc_length * arraySize;
795 if (list.
size() > arraySize) {
796 error =
QLatin1String(
"Array size missmatch: size of %1 is %2, size of provided list is %3");
811 if (desc.array_desc_dtype == blr_varying
812 || desc.array_desc_dtype == blr_varying2)
813 desc.array_desc_length -= 2;
815 isc_array_put_slice(status, &
ibase, &
trans, arrayId, &desc, ba.
data(), &bufLen);
823 char qType = isc_info_sql_stmt_type;
824 isc_dsql_sql_info(status, &
stmt, 1, &qType,
sizeof(acBuffer), acBuffer);
828 int iLength = isc_vax_integer(&acBuffer[1], 2);
829 queryType = isc_vax_integer(&acBuffer[3], iLength);
830 return (
queryType == isc_info_sql_stmt_select ||
queryType == isc_info_sql_stmt_exec_procedure);
844 isc_start_transaction(status, &
trans, 1, &
ibase, 0, NULL);
862 isc_commit_transaction(status, &
trans);
891 if (
d->
sqlda == (XSQLDA*)0) {
892 qWarning()<<
"QIOBaseResult: createDA(): failed to allocate memory";
897 if (
d->
inda == (XSQLDA*)0){
898 qWarning()<<
"QIOBaseResult: createDA(): failed to allocate memory";
921 if (
d->
inda == (XSQLDA*)0) {
922 qWarning()<<
"QIOBaseResult: enlargeDA(): failed to allocate memory";
935 if (
d->
sqlda == (XSQLDA*)0) {
936 qWarning()<<
"QIOBaseResult: enlargeDA(): failed to allocate memory";
973 qWarning(
"QIBaseResult::exec: Parameter mismatch, expected %d, got %d parameters",
978 for (i = 0; i < values.
count(); ++i) {
980 if (!
d->
inda->sqlvar[para].sqldata)
984 if (
d->
inda->sqlvar[para].sqltype & 1) {
987 *(
d->
inda->sqlvar[para].sqlind) = -1;
994 *(
d->
inda->sqlvar[para].sqlind) = 0;
996 switch(
d->
inda->sqlvar[para].sqltype & ~1) {
998 if (
d->
inda->sqlvar[para].sqlscale < 0)
1005 if (
d->
inda->sqlvar[para].sqlscale < 0)
1006 *((
long*)
d->
inda->sqlvar[para].sqldata) =
1007 (long)floor(0.5 + val.
toDouble() * pow(10.0,
d->
inda->sqlvar[para].sqlscale * -1));
1012 if (
d->
inda->sqlvar[para].sqlscale < 0)
1013 *((
short*)
d->
inda->sqlvar[para].sqldata) =
1014 (short)floor(0.5 + val.
toDouble() * pow(10.0,
d->
inda->sqlvar[para].sqlscale * -1));
1016 *((
short*)
d->
inda->sqlvar[para].sqldata) = (short)val.
toInt();
1019 *((
float*)
d->
inda->sqlvar[para].sqldata) = (float)val.
toDouble();
1036 d->
inda->sqlvar[para].sqllen,
1037 (
d->
inda->sqlvar[para].sqltype & ~1) == SQL_VARYING,
false,
d->
tc);
1046 qWarning(
"QIBaseResult::exec: Unknown datatype %d",
1047 d->
inda->sqlvar[para].sqltype & ~1);
1055 isc_dsql_free_statement(
d->
status, &
d->
stmt, DSQL_close);
1060 if (
d->
queryType == isc_info_sql_stmt_exec_procedure)
1092 ISC_STATUS
stat = 0;
1096 if (
d->
queryType == isc_info_sql_stmt_exec_procedure) {
1116 for (
int i = 0; i <
d->
sqlda->sqld; ++i) {
1117 int idx = rowIdx + i;
1118 char *buf =
d->
sqlda->sqlvar[i].sqldata;
1122 if ((
d->
sqlda->sqlvar[i].sqltype & 1) && *
d->
sqlda->sqlvar[i].sqlind) {
1143 switch(
d->
sqlda->sqlvar[i].sqltype & ~1) {
1147 row[idx] =
d->
tc->
toUnicode(buf +
sizeof(
short), *(
short*)buf);
1152 if (
d->
sqlda->sqlvar[i].sqlscale < 0)
1153 row[idx] = *(
qint64*)buf * pow(10.0,
d->
sqlda->sqlvar[i].sqlscale);
1158 if (
d->
sqlda->sqlvar[i].sqllen == 4)
1159 if (
d->
sqlda->sqlvar[i].sqlscale < 0)
1167 if (
d->
sqlda->sqlvar[i].sqlscale < 0)
1168 row[idx] =
QVariant(
long((*(
short*)buf)) * pow(10.0,
d->
sqlda->sqlvar[i].sqlscale));
1170 row[idx] =
QVariant(
int((*(
short*)buf)));
1173 row[idx] =
QVariant(
double((*(
float*)buf)));
1176 row[idx] =
QVariant(*(
double*)buf);
1204 if (
d->
sqlda->sqlvar[i].sqlscale < 0) {
1235 static char sizeInfo[] = {isc_info_sql_records}; 1246 isc_dsql_sql_info(
d->
status, &
d->
stmt,
sizeof(sizeInfo), sizeInfo,
sizeof(buf), buf);
1249 for(
int i = 0; i < 66; ++i)
1252 for (
char*
c = buf + 3; *
c != isc_info_end; ) {
1254 len = isc_vax_integer(
c, 2);
1256 val = isc_vax_integer(
c, len);
1258 qDebug() <<
"size" << val;
1259 if (ct == isc_info_req_select_count)
1265 unsigned int i, result_size;
1266 if (buf[0] == isc_info_sql_records) {
1268 result_size = isc_vax_integer(&buf[1],2);
1269 while (buf[i] != isc_info_end && i < result_size) {
1270 len = (short)isc_vax_integer(&buf[i+1],2);
1271 if (buf[i] == isc_info_req_select_count)
1272 return (isc_vax_integer(&buf[i+3],len));
1283 static char acCountInfo[] = {isc_info_sql_records};
1287 case isc_info_sql_stmt_select:
1288 cCountType = isc_info_req_select_count;
1290 case isc_info_sql_stmt_update:
1291 cCountType = isc_info_req_update_count;
1293 case isc_info_sql_stmt_delete:
1294 cCountType = isc_info_req_delete_count;
1296 case isc_info_sql_stmt_insert:
1297 cCountType = isc_info_req_insert_count;
1306 isc_dsql_sql_info(
d->
status, &
d->
stmt,
sizeof(acCountInfo), acCountInfo,
sizeof(acBuffer), acBuffer);
1310 for (
char *pcBuf = acBuffer + 3; *pcBuf != isc_info_end; ) {
1311 char cType = *pcBuf++;
1312 short sLength = isc_vax_integer (pcBuf, 2);
1314 int iValue = isc_vax_integer (pcBuf, sLength);
1317 if (cType == cCountType) {
1332 for (
int i = 0; i <
d->
sqlda->sqld; ++i) {
1337 f.setPrecision(
qAbs(v.sqlscale));
1339 if(v.sqlscale < 0) {
1342 q.
exec(
QLatin1String(
"select b.RDB$FIELD_PRECISION, b.RDB$FIELD_SCALE, b.RDB$FIELD_LENGTH, a.RDB$NULL_FLAG " 1343 "FROM RDB$RELATION_FIELDS a, RDB$FIELDS b " 1344 "WHERE b.RDB$FIELD_NAME = a.RDB$FIELD_SOURCE " 1348 if(v.sqlscale < 0) {
1358 f.setSqlType(v.sqltype);
1366 return QVariant(qRegisterMetaType<isc_stmt_handle>(
"isc_stmt_handle"), &
d->
stmt);
1428 for (
int i = 0; i < opts.count(); ++i) {
1429 QString tmp(opts.at(i).simplified());
1431 if ((idx = tmp.indexOf(
QLatin1Char(
'='))) != -1) {
1444 if (encString.isEmpty())
1449 qWarning(
"Unsupported encoding: %s. Using UNICODE_FFS for ISC_DPB_LC_CTYPE.", encString.toLocal8Bit().constData());
1463 ba.
append(
char(isc_dpb_version1));
1464 ba.
append(
char(isc_dpb_user_name));
1467 ba.
append(
char(isc_dpb_password));
1470 ba.
append(
char(isc_dpb_lc_ctype));
1475 ba.
append(
char(isc_dpb_sql_role_name));
1501 ISC_STATUS status[20];
1511 #if defined(FB_API_VER) 1581 typeFilter +=
QLatin1String(
"RDB$SYSTEM_FLAG != 0 OR RDB$VIEW_BLR NOT NULL");
1588 typeFilter +=
QLatin1String(
"RDB$VIEW_BLR IS NOT NULL AND ");
1597 if (!q.
exec(
QLatin1String(
"select rdb$relation_name from rdb$relations ") + typeFilter))
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 " 1623 "ORDER BY a.RDB$FIELD_POSITION"));
1636 f.setRequired(q.
value(5).
toInt() > 0 ? true :
false);
1654 tablename = tablename.
toUpper();
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 +
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"));
1679 switch (field.
type()) {
1721 return QVariant(qRegisterMetaType<isc_db_handle>(
"isc_db_handle"), &
d->
ibase);
1724 #if defined(FB_API_VER) && FB_API_VER >= 20 1725 static ISC_EVENT_CALLBACK
qEventCallback(
char *result, ISC_USHORT length,
const ISC_UCHAR *updated)
1734 memcpy(result, updated, length);
1736 QIBaseDriver *driver = qBufferDriverMap()->value(result);
1750 qWarning(
"QIBaseDriver::subscribeFromNotificationImplementation: database not open.");
1755 qWarning(
"QIBaseDriver::subscribeToNotificationImplementation: already subscribing to '%s'.",
1768 qBufferDriverMap()->insert(eBuffer->
resultBuffer,
this);
1773 ISC_STATUS status[20];
1774 isc_que_events(status,
1779 #
if defined (FB_API_VER) && FB_API_VER >= 20
1782 (isc_callback)qEventCallback,
1786 if (status[0] == 1 && status[1]) {
1799 qWarning(
"QIBaseDriver::unsubscribeFromNotificationImplementation: database not open.");
1804 qWarning(
"QIBaseDriver::QIBaseSubscriptionState not subscribed to '%s'.",
1810 ISC_STATUS status[20];
1814 if (status[0] == 1 && status[1]) {
1835 if (reinterpret_cast<void *>(eBuffer->
resultBuffer) != updatedResultBuffer)
1838 ISC_ULONG counts[20];
1839 memset(counts, 0,
sizeof(counts));
1848 ISC_STATUS status[20];
1849 isc_que_events(status,
1854 #
if defined (FB_API_VER) && FB_API_VER >= 20
1857 (isc_callback)qEventCallback,
1860 if (status[0] == 1 && status[1]) {
1861 qCritical(
"QIBaseDriver::qHandleEventNotification: could not resubscribe to '%s'",
QVariant fetchBlob(ISC_QUAD *bId)
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QVariant class acts like a union for the most common Qt data types.
The QSqlError class provides SQL database error information.
The QSqlIndex class provides functions to manipulate and describe database indexes.
const QSqlDriver * driver() const
Returns the driver associated with the result.
void truncate(int pos)
Truncates the byte array at index position pos.
bool isActive() const
Returns true if the result has records to be retrieved; otherwise returns false.
int daysTo(const QDate &) const
Returns the number of days from this date to d (which is negative if d is earlier than this date)...
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
bool first()
Retrieves the first record in the result, if available, and positions the query on the retrieved reco...
static ISC_DATE toDate(const QDate &t)
The QMutex class provides access serialization between threads.
virtual void setOpen(bool o)
This function sets the open state of the database to open.
bool gotoNext(QSqlCachedResult::ValueCache &row, int rowIdx)
char * fillList< float >(char *buffer, const QList< QVariant > &list, float *)
static char * qFillBufferWithString(char *buffer, const QString &string, short buflen, bool varying, bool array, QTextCodec *tc)
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
char * data()
Returns a pointer to the data stored in the byte array.
QSqlRecord record() const
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
DriverFeature
This enum contains a list of features a driver might support.
QList< QVariant > toList< long >(char **buf, int count, long *)
bool isValid() const
Returns true if this date is valid; otherwise returns false.
bool commitTransaction()
This function is called to commit a transaction.
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
virtual void setOpenError(bool e)
This function sets the open error state of the database to error.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
QByteArray & append(char c)
Appends the character ch to this byte array.
void append(const QSqlField &field)
Appends the field field to the list of indexed fields.
#define iType(varName, parent)
void start()
Sets this time to the current time.
QVariant value() const
Returns the value of the field as a QVariant.
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
int msecsTo(const QTime &) const
Returns the number of milliseconds from this time to t.
QString & replace(int i, int len, QChar after)
The QByteArray class provides an array of bytes.
void chop(int n)
Removes n characters from the end of the string.
QString & prepend(QChar c)
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
int month() const
Returns the number corresponding to the month of this date, using the following convention: ...
The QSqlQuery class provides a means of executing and manipulating SQL statements.
bool rollbackTransaction()
This function is called to rollback a transaction.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
int size() const
Returns the number of (key, value) pairs in the map.
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
static char * createArrayBuffer(char *buffer, const QList< QVariant > &list, QVariant::Type type, short curDim, ISC_ARRAY_DESC *arrayDesc, QString &error, QTextCodec *tc)
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
int day() const
Returns the day of the month (1 to 31) of this date.
bool exec()
Executes the query, returning true if successful; otherwise returns false.
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
static LibLoadStatus status
#define Q_ARG(type, data)
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
The QDate class provides date functions.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
int msec() const
Returns the millisecond part (0 to 999) of the time.
const Key & key() const
Returns the current item's key.
bool unsubscribeFromNotificationImplementation(const QString &name)
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
The QSqlRecord class encapsulates a database record.
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
The QString class provides a Unicode character string.
static char * readArrayBuffer(QList< QVariant > &list, char *buffer, short curDim, short *numElements, ISC_ARRAY_DESC *arrayDesc, QTextCodec *tc)
static QList< QVariant > toList(char **buf, int count, T *=0)
Q_DECL_CONSTEXPR T qAbs(const T &t)
The QObject class is the base class of all Qt objects.
QVariant fetchArray(int pos, ISC_QUAD *arr)
bool hasFeature(DriverFeature f) const
Returns true if the driver supports feature feature; otherwise returns false.
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Processes all pending events for the calling thread according to the specified flags until there are ...
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
static QDateTime fromTimeStamp(char *buffer)
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
bool isOpenError() const
Returns true if the there was an error opening the database connection; otherwise returns false...
ErrorType
This enum type describes the context in which the error occurred, e.
Q_CORE_EXPORT void qDebug(const char *,...)
void append(const T &t)
Inserts value at the end of the list.
static QTime fromTime(char *buffer)
QSqlRecord record(const QString &tablename) const
Returns a QSqlRecord populated with the names of the fields in table tableName.
The QTime class provides clock time functions.
#define QT_BEGIN_NAMESPACE
This macro expands to.
qlonglong toLongLong(bool *ok=0) const
Returns the variant as a long long int if the variant has type() LongLong , Bool , ByteArray , Char , Double , Int , String , UInt , or ULongLong ; otherwise returns 0.
QByteArray fromUnicode(const QString &uc) const
Converts str from Unicode to the encoding of this codec, and returns the result in a QByteArray...
static bool getIBaseError(QString &msg, ISC_STATUS *status, ISC_LONG &sqlcode, QTextCodec *tc)
virtual void setSelect(bool s)
This function is provided for derived classes to indicate whether or not the current statement is a S...
QIBaseResultPrivate(QIBaseResult *d, const QIBaseDriver *ddb)
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
QStringList tables(QSql::TableType) const
Returns a list of the names of the tables in the database.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QByteArray encodeString(QTextCodec *tc, const QString &str)
const T value(const Key &key) const
Returns the value associated with the key key.
const T & at(int i) const
Returns the item at index position i in the list.
void qHandleEventNotification(void *updatedResultBuffer)
The QStringList class provides a list of strings.
void setLength(int fieldLength)
Sets the field's length to fieldLength.
QByteArray leftJustified(int width, char fill=' ', bool truncate=false) const
Returns a byte array of size width that contains this byte array padded by the fill character...
static char * fillList(char *buffer, const QList< QVariant > &list, T *=0)
static ISC_TIMESTAMP toTimeStamp(const QDateTime &dt)
QVariant handle() const
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Q_CORE_EXPORT void qWarning(const char *,...)
int second() const
Returns the second part (0 to 59) of the time.
static QVariant::Type qIBaseTypeName(int iType, bool hasScale)
QIBaseDriverPrivate(QIBaseDriver *d)
bool writeArray(int i, const QList< QVariant > &list)
void setName(const QString &name)
Sets the name of the index to name.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Type
This enum type defines the types of variable that a QVariant can contain.
friend class QIBaseDriverPrivate
int size()
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
QDate addDays(int days) const
Returns a QDate object containing a date ndays later than the date of this object (or earlier if nday...
QList< Key > keys() const
Returns a list containing all the keys in the map in ascending order.
int minute() const
Returns the minute part (0 to 59) of the time.
bool writeBlob(int i, const QByteArray &ba)
QString formatValue(const QSqlField &field, bool trimStrings) const
Returns a string representation of the field value for the database.
QVariant::Type type() const
Returns the field's type as stored in the database.
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the map.
bool subscribeToNotificationImplementation(const QString &name)
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
static void delDA(XSQLDA *&sqlda)
void setForwardOnly(bool forward)
Sets forward only mode to forward.
bool convert(Type t)
Casts the variant to the requested type, t.
QIBaseResult(const QIBaseDriver *db)
int length() const
Same as size().
const char * constData() const
Returns a pointer to the data stored in the byte array.
QDate date() const
Returns the date part of the datetime.
QString toUnicode(const QByteArray &) const
Converts a from the encoding of this codec to Unicode, and returns the result in a QString...
int remove(const Key &key)
Removes all the items that have the key key from the map.
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...
int elapsed() const
Returns the number of milliseconds that have elapsed since the last time start() or restart() was cal...
QDate toDate() const
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise retu...
The QMap::const_iterator class provides an STL-style const iterator for QMap and QMultiMap.
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the map...
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QStringList subscribedToNotificationsImplementation() const
QString & append(QChar c)
The QDateTime class provides date and time functions.
static void qFreeEventBuffer(QIBaseEventBuffer *eBuffer)
bool reset(const QString &query)
Sets the result to use the SQL statement query for subsequent data retrieval.
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...
void clear()
Clears the contents of the string and makes it empty.
QString escapeIdentifier(const QString &identifier, IdentifierType type) const
Returns the identifier escaped according to the database rules.
bool isError(const char *msg, QSqlError::ErrorType typ=QSqlError::UnknownError)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Type type() const
Returns the storage type of the value stored in the variant.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
QSqlResult * createResult() const
Creates an empty SQL result on the database.
QObject * parent() const
Returns a pointer to the parent object.
QMap< void *, QIBaseDriver * > QIBaseBufferDriverMap
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...
virtual QString formatValue(const QSqlField &field, bool trimStrings=false) const
Returns a string representation of the field value for the database.
void resize(int size)
Sets the size of the byte array to size bytes.
int size() const
Returns the number of items in the list.
QMap< QString, QIBaseEventBuffer * > eventBuffers
void append(const QSqlField &field)
Append a copy of field field to the end of the record.
QVariant handle() const
Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no hand...
static void enlargeDA(XSQLDA *&sqlda, int n)
const T & value() const
Returns the current item's value.
static QTextCodec * codecForName(const QByteArray &name)
Searches all installed QTextCodec objects and returns the one which best matches name; the match is c...
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
T qvariant_cast(const QVariant &)
bool isSelect() const
Returns true if the current result is from a SELECT statement; otherwise returns false.
int size() const
Returns the number of bytes in this byte array.
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
virtual void setActive(bool a)
This function is provided for derived classes to set the internal active state to active...
QSqlIndex primaryIndex(const QString &table) const
Returns the primary index for table tableName.
static const QTextHtmlElement elements[Html_NumElements]
QIBaseSubscriptionState subscriptionState
QTime addMSecs(int ms) const
Returns a QTime object containing a time ms milliseconds later than the time of this object (or earli...
static ISC_TIME toTime(const QTime &t)
int year() const
Returns the year of this date.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
QTime time() const
Returns the time part of the datetime.
QTime toTime() const
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise retu...
The QSqlField class manipulates the fields in SQL database tables and views.
bool exec(const QString &query)
Executes the SQL in query.
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database...
int numRowsAffected()
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
Q_GLOBAL_STATIC(QMutex, qMutex)
The QTextCodec class provides conversions between text encodings.
QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
QVector< QVariant > & boundValues() const
Returns a vector of the result's bound values for the current record (row).
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isError(const char *msg, QSqlError::ErrorType typ=QSqlError::UnknownError)
void reserve(int size)
Attempts to allocate memory for at least size bytes.
#define SQLDA_CURRENT_VERSION
#define qPrintable(string)
QVariant value(int i) const
Returns the value of field index in the current record.
friend class QIBaseResultPrivate
QIBaseDriver(QObject *parent=0)
bool beginTransaction()
This function is called to begin a transaction.
bool next()
Retrieves the next record in the result, if available, and positions the query on the retrieved recor...
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
static void initDA(XSQLDA *sqlda)
static QVariant::Type qIBaseTypeName2(int iType, bool hasScale)
IdentifierType
This enum contains a list of SQL identifier types.
void close()
Derived classes must reimplement this pure virtual function in order to close the database connection...
bool prepare(const QString &query)
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
static void createDA(XSQLDA *&sqlda)
void clear()
Removes all items from the map.
static isc_callback qEventCallback(char *result, short length, char *updated)
The QMap class is a template class that provides a skip-list-based dictionary.
static QDate fromDate(char *buffer)
Q_CORE_EXPORT void qCritical(const char *,...)
bool isValid() const
Returns true if the time is valid; otherwise returns false.
int hour() const
Returns the hour part (0 to 23) of the time.
void notification(const QString &name)
This signal is emitted when the database posts an event notification that the driver subscribes to...