16#if defined(Q_OS_WIN32)
17# include <QtCore/qt_windows.h>
19#include <QtSql/private/qsqlresult_p.h>
20#include <QtSql/private/qsqldriver_p.h>
23#define MIMER_DEFAULT_DATATYPE 1000
71 bool fetch(
int i)
override;
82 bool execBatch(
bool arrayBind =
false)
override;
140 str_len = (rc = MimerGetError(
p->sessionhandle, &e_code, NULL, 0)) + 1;
141 if (!MIMER_SUCCEEDED(rc)) {
146 if (!MIMER_SUCCEEDED(
147 rc = MimerGetError(
p->sessionhandle, &e_code, tmp_buff.
data(), str_len)))
183 d->sessionhandle = *conn;
207 case MIMER_BINARY_VARYING:
210 case MIMER_NATIVE_BLOB:
214 case MIMER_NATIVE_CLOB:
215 case MIMER_NATIVE_NCLOB:
221 case MIMER_TIMESTAMP:
223 case MIMER_INTERVAL_DAY:
225 case MIMER_INTERVAL_DAY_TO_HOUR:
226 case MIMER_INTERVAL_DAY_TO_MINUTE:
227 case MIMER_INTERVAL_DAY_TO_SECOND:
228 case MIMER_INTERVAL_HOUR:
229 case MIMER_INTERVAL_HOUR_TO_MINUTE:
230 case MIMER_INTERVAL_HOUR_TO_SECOND:
231 case MIMER_INTERVAL_MINUTE:
232 case MIMER_INTERVAL_MINUTE_TO_SECOND:
233 case MIMER_INTERVAL_MONTH:
234 case MIMER_INTERVAL_SECOND:
235 case MIMER_INTERVAL_YEAR:
236 case MIMER_INTERVAL_YEAR_TO_MONTH:
238 case MIMER_CHARACTER:
239 case MIMER_CHARACTER_VARYING:
240 case MIMER_NCHAR_VARYING:
247 case MIMER_T_UNSIGNED_BIGINT:
248 case MIMER_NATIVE_BIGINT_NULLABLE:
249 case MIMER_NATIVE_BIGINT:
254 case MIMER_NATIVE_REAL_NULLABLE:
255 case MIMER_NATIVE_REAL:
257 case MIMER_NATIVE_DOUBLE_NULLABLE:
258 case MIMER_NATIVE_DOUBLE:
261 case MIMER_NATIVE_INTEGER:
262 case MIMER_NATIVE_INTEGER_NULLABLE:
264 case MIMER_NATIVE_SMALLINT_NULLABLE:
265 case MIMER_NATIVE_SMALLINT:
266 case MIMER_T_INTEGER:
267 case MIMER_T_SMALLINT:
272 qWarning() <<
"QMimerSQLDriver::mimerMapColumnTypes: Unknown data type: " <<
t;
281 case MIMER_BINARY_VARYING:
283 case MIMER_NATIVE_BLOB:
284 return QMetaType::QByteArray;
287 case MIMER_NATIVE_CLOB:
288 case MIMER_NATIVE_NCLOB:
289 case MIMER_INTERVAL_DAY:
291 case MIMER_INTERVAL_DAY_TO_HOUR:
292 case MIMER_INTERVAL_DAY_TO_MINUTE:
293 case MIMER_INTERVAL_DAY_TO_SECOND:
294 case MIMER_INTERVAL_HOUR:
295 case MIMER_INTERVAL_HOUR_TO_MINUTE:
296 case MIMER_INTERVAL_HOUR_TO_SECOND:
297 case MIMER_INTERVAL_MINUTE:
298 case MIMER_INTERVAL_MINUTE_TO_SECOND:
299 case MIMER_INTERVAL_MONTH:
300 case MIMER_INTERVAL_SECOND:
301 case MIMER_INTERVAL_YEAR:
302 case MIMER_INTERVAL_YEAR_TO_MONTH:
304 case MIMER_CHARACTER:
305 case MIMER_CHARACTER_VARYING:
306 case MIMER_NCHAR_VARYING:
309 return QMetaType::QString;
311 return QMetaType::Bool;
313 case MIMER_T_UNSIGNED_BIGINT:
314 case MIMER_NATIVE_BIGINT_NULLABLE:
315 case MIMER_NATIVE_BIGINT:
316 return QMetaType::LongLong;
319 return QMetaType::Float;
320 case MIMER_NATIVE_REAL_NULLABLE:
321 case MIMER_NATIVE_REAL:
323 case MIMER_NATIVE_DOUBLE_NULLABLE:
324 case MIMER_NATIVE_DOUBLE:
326 return QMetaType::Double;
327 case MIMER_NATIVE_INTEGER_NULLABLE:
328 case MIMER_T_INTEGER:
330 return QMetaType::Int;
331 case MIMER_NATIVE_SMALLINT_NULLABLE:
332 case MIMER_T_SMALLINT:
333 return QMetaType::Int;
335 return QMetaType::QDate;
337 return QMetaType::QTime;
339 case MIMER_TIMESTAMP:
340 return QMetaType::QDateTime;
342 return QMetaType::QUuid;
344 qWarning() <<
"QMimerSQLDriver::qDecodeMSQLType: Unknown data type: " <<
t;
353 if (
s == u
"BINARY VARYING")
354 return MIMER_BINARY_VARYING;
355 if (
s == u
"BINARY LARGE OBJECT")
357 if (
s == u
"CHARACTER LARGE OBJECT")
359 if (
s == u
"NATIONAL CHAR LARGE OBJECT")
361 if (
s == u
"INTERVAL DAY")
362 return MIMER_INTERVAL_DAY;
364 return MIMER_DECIMAL;
365 if (
s == u
"INTERVAL DAY TO HOUR")
366 return MIMER_INTERVAL_DAY_TO_HOUR;
367 if (
s == u
"INTERVAL DAY TO MINUTE")
368 return MIMER_INTERVAL_DAY_TO_MINUTE;
369 if (
s == u
"INTERVAL DAY TO SECOND")
370 return MIMER_INTERVAL_DAY_TO_SECOND;
371 if (
s == u
"INTERVAL HOUR")
372 return MIMER_INTERVAL_HOUR;
373 if (
s == u
"INTERVAL HOUR TO MINUTE")
374 return MIMER_INTERVAL_HOUR_TO_MINUTE;
375 if (
s == u
"INTERVAL HOUR TO SECOND")
376 return MIMER_INTERVAL_HOUR_TO_SECOND;
377 if (
s == u
"INTERVAL MINUTE")
378 return MIMER_INTERVAL_MINUTE;
379 if (
s == u
"INTERVAL MINUTE TO SECOND")
380 return MIMER_INTERVAL_MINUTE_TO_SECOND;
381 if (
s == u
"INTERVAL MONTH")
382 return MIMER_INTERVAL_MONTH;
383 if (
s == u
"INTERVAL SECOND")
384 return MIMER_INTERVAL_SECOND;
385 if (
s == u
"INTERVAL YEAR")
386 return MIMER_INTERVAL_YEAR;
387 if (
s == u
"INTERVAL YEAR TO MONTH")
388 return MIMER_INTERVAL_YEAR_TO_MONTH;
389 if (
s == u
"NATIONAL CHARACTER")
391 if (
s == u
"CHARACTER")
392 return MIMER_CHARACTER;
393 if (
s == u
"CHARACTER VARYING")
394 return MIMER_CHARACTER_VARYING;
395 if (
s == u
"NATIONAL CHARACTER VARYING")
396 return MIMER_NCHAR_VARYING;
400 return MIMER_BOOLEAN;
402 return MIMER_T_BIGINT;
406 return MIMER_T_FLOAT;
407 if (
s == u
"DOUBLE PRECISION")
408 return MIMER_T_DOUBLE;
410 return MIMER_INTEGER;
411 if (
s == u
"SMALLINT")
412 return MIMER_T_SMALLINT;
417 if (
s == u
"TIMESTAMP")
418 return MIMER_TIMESTAMP;
419 if (
s == u
"BUILTIN.UUID")
421 if (
s == u
"USER-DEFINED")
423 qWarning() <<
"QMimerSQLDriver::qLookupMimDataType: Unhandled data type: " <<
s;
433void QMimerSQLResult::cleanup()
437 d->openCursor =
false;
438 d->openStatement =
false;
442 const int32_t err = MimerCloseCursor(
d->statementhandle);
443 if (!MIMER_SUCCEEDED(err))
447 d->openCursor =
false;
449 if (
d->openStatement) {
450 const int32_t err = MimerEndStatement(&
d->statementhandle);
451 if (!MIMER_SUCCEEDED(err))
455 d->openStatement =
false;
460qint64 QMimerSQLResult::currentRow()
463 return d->currentRow;
484 }
while (rc && currentRow() <
i);
487 err = MimerFetchScroll(
d->statementhandle, MIMER_ABSOLUTE,
i + 1);
488 if (err == MIMER_NO_DATA)
491 if (!MIMER_SUCCEEDED(err)) {
497 setAt(MimerCurrentRow(
d->statementhandle) - 1);
508 if (currentRow() < 0)
510 else if (currentRow() == 0)
515 err = MimerFetchScroll(
d->statementhandle, MIMER_FIRST, 0);
516 if (MIMER_SUCCEEDED(err) && err != MIMER_NO_DATA)
519 if (!MIMER_SUCCEEDED(err)) {
525 if (err == MIMER_NO_DATA)
543 return currentRow() >= 0;
545 err = MimerFetchScroll(
d->statementhandle,
static_cast<std::int32_t
>(MIMER_LAST), 0);
546 if (err == MIMER_NO_DATA)
548 if (MIMER_SUCCEEDED(err)) {
549 row = MimerCurrentRow(
d->statementhandle) - 1;
574 err = MimerFetch(
d->statementhandle);
576 err = MimerFetchScroll(
d->statementhandle, MIMER_NEXT, 0);
577 if (!MIMER_SUCCEEDED(err)) {
585 if (err == MIMER_NO_DATA)
590 setAt(MimerCurrentRow(
d->statementhandle) - 1);
599 if (
d->callWithOut) {
600 if (
i >= MimerParameterCount(
d->statementhandle)) {
607 mType = MimerParameterType(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1);
609 if (
i >= MimerColumnCount(
d->statementhandle)) {
616 mType = MimerColumnType(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1);
620 err = MimerIsNull(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1);
624 switch (mimDataType) {
627 err = MimerGetString(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1, dateString_w,
628 sizeof(dateString_w) /
sizeof(dateString_w[0]));
629 if (!MIMER_SUCCEEDED(err)) {
638 err = MimerGetString(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1, timeString_w,
639 sizeof(timeString_w) /
sizeof(timeString_w[0]));
640 if (!MIMER_SUCCEEDED(err)) {
646 QString timeFormatString =
"HH:mm:ss"_L1;
647 if (timeString.
size() > 8) {
648 timeFormatString.
append(
".zzz"_L1);
649 timeString = timeString.
left(12);
651 return QTime::fromString(timeString, timeFormatString);
655 err = MimerGetString(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1,
657 sizeof(dateTimeString_w) /
sizeof(dateTimeString_w[0]));
658 if (!MIMER_SUCCEEDED(err)) {
665 QString dateTimeFormatString =
"yyyy-MM-dd HH:mm:ss"_L1;
666 if (dateTimeString.
size() > 19) {
667 dateTimeFormatString.
append(
".zzz"_L1);
668 dateTimeString = dateTimeString.
left(23);
670 return QDateTime::fromString(dateTimeString, dateTimeFormatString);
674 err = MimerGetInt32(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1, &resInt);
675 if (!MIMER_SUCCEEDED(err)) {
684 err = MimerGetInt64(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1, &resLongLong);
685 if (!MIMER_SUCCEEDED(err)) {
693 err = MimerGetBoolean(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1);
694 if (!MIMER_SUCCEEDED(err)) {
704 err = MimerGetFloat(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1, &resFloat);
705 if (!MIMER_SUCCEEDED(err)) {
714 err = MimerGetDouble(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1, &resDouble);
715 if (!MIMER_SUCCEEDED(err)) {
723 return static_cast<std::int32_t
>(resDouble);
725 return static_cast<qint64>(resDouble);
736 err = MimerGetBinary(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1, NULL, 0);
737 if (MIMER_SUCCEEDED(err)) {
739 err = MimerGetBinary(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1,
740 byteArray.
data(), err);
742 if (!MIMER_SUCCEEDED(err)) {
753 err = MimerGetLob(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1, &
size,
755 if (MIMER_SUCCEEDED(err)) {
759 size_t left_to_return =
size;
760 while (left_to_return > 0) {
761 const size_t bytesToReceive =
762 left_to_return <= maxSize ? left_to_return : maxSize;
763 err = MimerGetBlobData(&
d->lobhandle, blobchar.
data(), bytesToReceive);
765 left_to_return -= bytesToReceive;
766 if (!MIMER_SUCCEEDED(err)) {
782 err = MimerGetString(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1, resString_w,
784 if (MIMER_SUCCEEDED(err)) {
788 err = MimerGetString(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1,
790 if (MIMER_SUCCEEDED(err))
794 err = MimerGetString(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1,
796 if (MIMER_SUCCEEDED(err))
806 err = MimerGetLob(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1, &
size,
808 if (MIMER_SUCCEEDED(err)) {
812 size_t left_to_return =
size;
814 while (left_to_return > 0) {
815 const size_t bytesToReceive =
816 left_to_return <= maxSize ? left_to_return : maxSize;
817 err = MimerGetNclobData(&
d->lobhandle, clobstring_w.
data(), bytesToReceive + 1);
819 left_to_return -= bytesToReceive;
820 if (!MIMER_SUCCEEDED(err)) {
833 unsigned char uuidChar[16];
834 err = MimerGetUUID(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1, uuidChar);
835 if (!MIMER_SUCCEEDED(err)) {
856 const int32_t rc = MimerIsNull(
d->statementhandle,
static_cast<std::int16_t
>(
index) + 1);
857 if (!MIMER_SUCCEEDED(rc)) {
880 if (
d->currentSize != -1)
881 return d->currentSize;
883 const int currentRow = MimerCurrentRow(
d->statementhandle);
884 MimerFetchScroll(
d->statementhandle,
static_cast<std::int32_t
>(MIMER_LAST), 0);
885 int size = MimerCurrentRow(
d->statementhandle);
886 if (!MIMER_SUCCEEDED(
size))
888 MimerFetchScroll(
d->statementhandle, MIMER_ABSOLUTE, currentRow);
889 d->currentSize =
size;
896 return d->rowsAffected;
906 const int colSize = MimerColumnCount(
d->statementhandle);
907 for (
int i = 0;
i < colSize;
i++) {
908 wchar_t colName_w[100];
909 MimerColumnName(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1, colName_w,
910 sizeof(colName_w) /
sizeof(colName_w[0]));
912 const int32_t mType = MimerColumnType(
d->statementhandle,
static_cast<std::int16_t
>(
i) + 1);
932 if (!
d->preparedQuery)
938 err = MimerBeginStatement8(
d->drv_d_func()->sessionhandle,
query.toUtf8().constData(),
option,
939 &
d->statementhandle);
940 if (err == MIMER_STATEMENT_CANNOT_BE_PREPARED) {
941 err = MimerExecuteStatement8(
d->drv_d_func()->sessionhandle,
query.toUtf8().constData());
942 if (MIMER_SUCCEEDED(err)) {
943 d->executedStatement =
true;
944 d->openCursor =
false;
945 d->openStatement =
false;
949 if (!MIMER_SUCCEEDED(err)) {
951 "Could not prepare/execute statement"),
955 d->openStatement =
true;
965 if (!
d->preparedQuery)
967 if (
d->executedStatement) {
968 d->executedStatement =
false;
973 err = MimerCloseCursor(
d->statementhandle);
974 d->openCursor =
false;
980 int mimParamCount = MimerParameterCount(
d->statementhandle);
981 if (!MIMER_SUCCEEDED(mimParamCount))
983 if (mimParamCount !=
values.size()) {
989 for (
int i = 0;
i < mimParamCount;
i++) {
991 d->callWithOut =
true;
996 err = MimerSetNull(
d->statementhandle,
i + 1);
997 if (!MIMER_SUCCEEDED(err)) {
1006 const int mimParamType = MimerParameterType(
d->statementhandle,
i + 1);
1008 switch (mimDataType) {
1011 err = MimerSetInt32(
d->statementhandle,
i + 1,
val.toInt(&convertOk));
1012 if (!convertOk || !MIMER_SUCCEEDED(err)) {
1016 convertOk ?
d->drv_d_func() :
nullptr));
1023 err = MimerSetInt64(
d->statementhandle,
i + 1,
val.toLongLong(&convertOk));
1024 if (!convertOk || !MIMER_SUCCEEDED(err)) {
1028 convertOk ?
d->drv_d_func() :
nullptr));
1035 err = MimerSetFloat(
d->statementhandle,
i + 1,
val.toFloat(&convertOk));
1036 if (!convertOk || !MIMER_SUCCEEDED(err)) {
1040 convertOk ?
d->drv_d_func() :
nullptr));
1047 err = MimerSetDouble(
d->statementhandle,
i + 1,
val.toDouble(&convertOk));
1048 if (!convertOk || !MIMER_SUCCEEDED(err)) {
1052 convertOk ?
d->drv_d_func() :
nullptr));
1059 size_t size =
static_cast<std::size_t
>(binArr.
size());
1060 err = MimerSetBinary(
d->statementhandle,
i + 1, binArr.
data(),
size);
1061 if (!MIMER_SUCCEEDED(err)) {
1070 err = MimerSetBoolean(
d->statementhandle,
i + 1,
val.toBool() ==
true ? 1 : 0);
1071 if (!MIMER_SUCCEEDED(err)) {
1082 const unsigned char *uuid =
1083 reinterpret_cast<const unsigned char *
>(uuidArray.
constData());
1084 err = MimerSetUUID(
d->statementhandle,
i + 1, uuid);
1085 if (!MIMER_SUCCEEDED(err)) {
1095 const char *string_u = string_b.
constData();
1096 err = MimerSetString8(
d->statementhandle,
i + 1, string_u);
1097 if (!MIMER_SUCCEEDED(err)) {
1106 err = MimerSetString8(
d->statementhandle,
i + 1,
val.toString().toUtf8().constData());
1107 if (!MIMER_SUCCEEDED(err)) {
1116 QString timeFormatString =
"hh:mm:ss"_L1;
1117 const QTime timeVal =
val.toTime();
1118 if (timeVal.
msec() > 0)
1119 timeFormatString.
append(
".zzz"_L1);
1120 err = MimerSetString8(
d->statementhandle,
i + 1,
1121 timeVal.toString(timeFormatString).toUtf8().constData());
1122 if (!MIMER_SUCCEEDED(err)) {
1131 QString dateTimeFormatString =
"yyyy-MM-dd hh:mm:ss"_L1;
1134 dateTimeFormatString.
append(
".zzz"_L1);
1135 err = MimerSetString8(
1136 d->statementhandle,
i + 1,
1137 val.toDateTime().toString(dateTimeFormatString).toUtf8().constData());
1138 if (!MIMER_SUCCEEDED(err)) {
1147 const char *blobData = blobArr.
constData();
1149 err = MimerSetLob(
d->statementhandle,
i + 1,
size, &
d->lobhandle);
1150 if (MIMER_SUCCEEDED(err)) {
1152 if (
size > maxSize) {
1154 for (
qsizetype k = 0; left_to_send > 0; k++) {
1155 if (left_to_send <= maxSize) {
1156 err = MimerSetBlobData(&
d->lobhandle, &blobData[k * maxSize],
1160 err = MimerSetBlobData(&
d->lobhandle, &blobData[k * maxSize], maxSize);
1161 left_to_send = left_to_send - maxSize;
1164 if (!MIMER_SUCCEEDED(err)) {
1171 err = MimerSetBlobData(&
d->lobhandle, blobArr,
size);
1174 if (!MIMER_SUCCEEDED(err)) {
1183 const char *string_u = string_b.
constData();
1186 while (string_u[
size++])
1187 if ((string_u[
size] & 0xc0) != 0x80)
1189 err = MimerSetLob(
d->statementhandle,
i + 1, size_c, &
d->lobhandle);
1190 if (MIMER_SUCCEEDED(err)) {
1192 if (
size > maxSize) {
1193 size_t left_to_send =
size;
1196 while (left_to_send > 0 && step_back < maxSize) {
1198 if (left_to_send <= maxSize) {
1199 err = MimerSetNclobData8(&
d->lobhandle, &string_u[
pos], left_to_send);
1203 while (
pos + maxSize - step_back > 0
1204 && (string_u[
pos + maxSize - step_back] & 0xc0) == 0x80)
1206 err = MimerSetNclobData8(&
d->lobhandle, &string_u[
pos],
1207 maxSize - step_back);
1208 left_to_send = left_to_send - maxSize + step_back;
1209 pos += maxSize - step_back;
1211 if (!MIMER_SUCCEEDED(err)) {
1218 err = MimerSetNclobData8(&
d->lobhandle, string_u,
size);
1221 if (!MIMER_SUCCEEDED(err)) {
1240 err = MimerExecute(
d->statementhandle);
1241 if (MIMER_SUCCEEDED(err)) {
1242 d->rowsAffected = err;
1250 d->callWithOut =
false;
1253 if (MIMER_SEQUENCE_ERROR == err) {
1254 err = MimerOpenCursor(
d->statementhandle);
1255 d->rowsAffected = err;
1256 d->openCursor =
true;
1260 if (!MIMER_SUCCEEDED(err)) {
1263 "Could not execute statement/open cursor"),
1284 "Only input parameter can be used in batch operations"),
1286 d->execBatch =
false;
1289 d->execBatch =
true;
1292 d->batch_vector.append(
values.at(
j).toList().at(
i));
1294 if (
i != (
values.at(0).toList().size() - 1)) {
1295 err = MimerAddBatch(
d->statementhandle);
1296 if (!MIMER_SUCCEEDED(err)) {
1301 d->execBatch =
false;
1305 d->batch_vector.clear();
1307 d->execBatch =
false;
1308 err = MimerExecute(
d->statementhandle);
1309 if (!MIMER_SUCCEEDED(err)) {
1321 int64_t lastSequence;
1322 const int32_t err = MimerGetSequenceInt64(
d->statementhandle, &lastSequence);
1323 if (!MIMER_SUCCEEDED(err))
1361 const int32_t err = MimerBeginSession8(
db.toUtf8().constData(), user.
toUtf8().
constData(),
1363 if (!MIMER_SUCCEEDED(err)) {
1382 const int end_err = MimerEndSession(&
d->sessionhandle);
1383 if (MIMER_SUCCEEDED(end_err)) {
1404 sql =
"select table_name from information_schema.tables where "
1405 "table_type=\'BASE TABLE\' AND table_schema = CURRENT_USER"_L1;
1409 sql =
"select table_name from information_schema.tables where "
1410 "table_type=\'BASE TABLE\' AND table_schema = \'SYSTEM\'"_L1;
1414 sql =
"select table_name from information_schema.tables where "
1415 "table_type=\'VIEW\' AND table_schema = CURRENT_USER"_L1;
1419 sql =
"select table_name from information_schema.tables where "
1420 "(table_type=\'VIEW\' or table_type=\'BASE TABLE\')"
1421 " AND (table_schema = CURRENT_USER OR table_schema =\'SYSTEM\')"_L1;
1430 tl.append(
t.value(0).toString());
1447 d->splitTableQualifier(qualifiedName, &schema, &
table);
1449 "select information_schema.ext_access_paths.column_name,"
1450 "case when data_type = 'INTERVAL' then 'INTERVAL '|| interval_type "
1451 "when data_type = 'INTEGER' and numeric_precision > 10 then 'BIGINT' "
1452 "when data_type = 'INTEGER' and numeric_precision <= 10 AND NUMERIC_PRECISION > 5 "
1453 "then 'INTEGER' when data_type = 'INTEGER' and numeric_precision <= 5 then 'SMALLINT' "
1454 "else upper(data_type) end as data_type "
1455 "from information_schema.ext_access_paths full outer join "
1456 "information_schema.columns on information_schema.ext_access_paths.column_name = "
1457 "information_schema.columns.column_name and "
1458 "information_schema.ext_access_paths.table_name = "
1459 "information_schema.columns.table_name where "
1460 "information_schema.ext_access_paths.table_name = \'"_L1;
1462 .
append(
"\' and index_type = \'PRIMARY KEY\'"_L1);
1463 if (schema.
length() == 0)
1464 sql.
append(
" and table_schema = CURRENT_USER"_L1);
1476 index.setName(
t.value(0).toString());
1489 QString qualifiedName = tablename;
1493 d->splitTableQualifier(qualifiedName, &schema, &
table);
1496 "select column_name, case when data_type = 'INTERVAL' then 'INTERVAL '|| interval_type "
1497 "when data_type = 'INTEGER' and numeric_precision > 10 then 'BIGINT' "
1498 "when data_type = 'INTEGER' and numeric_precision <= 10 AND numeric_precision > 5 "
1499 "then 'INTEGER' when data_type = 'INTEGER' and numeric_precision <= 5 then 'SMALLINT' "
1500 "else UPPER(data_type) end as data_type, case when is_nullable = 'YES' then false else "
1501 "true end as required, "
1502 "coalesce(numeric_precision, coalesce(datetime_precision,coalesce(interval_precision, "
1503 "-1))) as prec from information_schema.columns where table_name = \'"_L1;
1504 if (schema.
length() == 0)
1508 sql.
append(
" order by ordinal_position"_L1);
1517 if (
t.value(3).toInt() != -1)
1546 const int32_t err = MimerBeginTransaction(
d->sessionhandle, MIMER_TRANS_READWRITE);
1547 if (!MIMER_SUCCEEDED(err)) {
1559 const int32_t err = MimerEndTransaction(
d->sessionhandle, MIMER_COMMIT);
1560 if (!MIMER_SUCCEEDED(err)) {
1572 const int32_t err = MimerEndTransaction(
d->sessionhandle, MIMER_ROLLBACK);
1573 if (!MIMER_SUCCEEDED(err)) {
1589 }
else if (
n == 1) {
1593 *schema = l.
at(0).toString();
QByteArray trimmed() const &
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
static QByteArray fromHex(const QByteArray &hexEncoded)
Returns a decoded copy of the hex encoded array hexEncoded.
void reserve(qsizetype size)
Attempts to allocate memory for at least size bytes.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
QByteArray & append(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QByteArray fromRawData(const char *data, qsizetype size)
Constructs a QByteArray that uses the first size bytes of the data array.
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
\inmodule QtCore\reentrant
QTime time() const
Returns the time part of the datetime.
const_reference at(qsizetype i) const noexcept
qsizetype count() const noexcept
MimerSession sessionhandle
void splitTableQualifier(const QString &qualifier, QString *schema, QString *table) const
~QMimerSQLDriver() override
QSqlIndex primaryIndex(const QString &tablename) const override
Returns the primary index for table tableName.
bool rollbackTransaction() override
This function is called to rollback a transaction.
bool commitTransaction() override
This function is called to commit a transaction.
bool beginTransaction() override
This function is called to begin a transaction.
QStringList tables(QSql::TableType type) const override
Returns a list of the names of the tables in the database.
void close() override
Derived classes must reimplement this pure virtual function in order to close the database connection...
QString escapeIdentifier(const QString &identifier, IdentifierType type) const override
Returns the identifier escaped according to the database rules.
QMimerSQLDriver(QObject *parent=nullptr)
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...
bool hasFeature(DriverFeature f) const override
Returns true if the driver supports feature feature; otherwise returns false.
QSqlResult * createResult() const override
Creates an empty SQL result on the database.
QSqlRecord record(const QString &tablename) const override
Returns a QSqlRecord populated with the names of the fields in table tableName.
QVariant handle() const override
Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no hand...
MimerStatement statementhandle
QVector< QVariant > batch_vector
static constexpr int maxTimestampStringSize
static constexpr int lobChunkMaxSizeSet
bool fetchNext() override
Positions the result to the next available record (row) in the result.
bool reset(const QString &query) override
Sets the result to use the SQL statement query for subsequent data retrieval.
static constexpr int maxDateStringSize
bool prepare(const QString &query) override
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
QVariant data(int i) override
Returns the data for field index in the current row as a QVariant.
QSqlRecord record() const override
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
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...
QVariant handle() const override
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
bool fetchLast() override
Positions the result to the last record (last row) in the result.
bool fetch(int i) override
Positions the result to an arbitrary (zero-based) row index.
bool execBatch(bool arrayBind=false) override
bool isNull(int index) override
Returns true if the field at position index in the current row is null; otherwise returns false.
bool fetchFirst() override
Positions the result to the first record (row 0) in the result.
int numRowsAffected() override
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
static constexpr int maxTimeStringSize
static constexpr int genericError
static constexpr int lobChunkMaxSizeFetch
QMimerSQLResult(const QMimerSQLDriver *db)
virtual ~QMimerSQLResult() override
bool exec() override
Executes the query, returning true if successful; otherwise returns false.
static constexpr int maxStackStringSize
QVariant lastInsertId() const override
Returns the object ID of the most recent inserted row if the database supports it.
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
IdentifierType
This enum contains a list of SQL identifier types.
virtual QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
DriverFeature
This enum contains a list of features a driver might support.
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database.
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
virtual void setOpenError(bool e)
This function sets the open error state of the database to error.
virtual bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
virtual void setOpen(bool o)
This function sets the open state of the database to open.
The QSqlError class provides SQL database error information.
ErrorType
This enum type describes the context in which the error occurred, e.g., a connection error,...
The QSqlField class manipulates the fields in SQL database tables and views.
QMetaType metaType() const
Returns the field's type as stored in the database.
void setValue(const QVariant &value)
Sets the value of the field to value.
void setName(const QString &name)
Sets the name of the field to name.
void setMetaType(QMetaType type)
Set's the field's variant type to type.
void setRequired(bool required)
Sets the required status of this field to \l Required if required is true; otherwise sets it to \l Op...
void setPrecision(int precision)
Sets the field's precision.
void setSqlType(int type)
The QSqlIndex class provides functions to manipulate and describe database indexes.
The QSqlQuery class provides a means of executing and manipulating SQL statements.
The QSqlRecord class encapsulates a database record.
void append(const QSqlField &field)
Append a copy of field field to the end of the record.
void insert(int pos, const QSqlField &field)
Inserts the field field at position pos in the record.
static bool isVariantNull(const QVariant &variant)
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases.
bool isForwardOnly() const
Returns true if you can only scroll forward through the result set; otherwise returns false.
QSql::ParamType bindValueType(const QString &placeholder) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
int at() const
Returns the current (zero-based) row position of the result.
virtual bool prepare(const QString &query)
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
virtual bool exec()
Executes the query, returning true if successful; otherwise returns false.
bool isSelect() const
Returns true if the current result is from a SELECT statement; otherwise returns false.
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index.
virtual void setSelect(bool s)
This function is provided for derived classes to indicate whether or not the current statement is a S...
virtual void setActive(bool a)
This function is provided for derived classes to set the internal active state to active.
QVariantList & boundValues(QT6_DECL_NEW_OVERLOAD)
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
const QSqlDriver * driver() const
Returns the driver associated with the result.
virtual void bindValue(int pos, const QVariant &val, QSql::ParamType type)
Binds the value val of parameter type paramType to position index in the current record (row).
bool isActive() const
Returns true if the result has records to be retrieved; otherwise returns false.
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the view into substring views wherever sep occurs, and returns the list of those string views.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QString & replace(qsizetype i, qsizetype len, QChar after)
qsizetype size() const
Returns the number of characters in this string.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
qlonglong toLongLong(bool *ok=nullptr, int base=10) const
Returns the string converted to a {long long} using base base, which is 10 by default and must be bet...
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString fromWCharArray(const wchar_t *string, qsizetype size=-1)
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & append(QChar c)
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
QByteArray toUtf8() const &
qsizetype length() const
Returns the number of characters in this string.
\inmodule QtCore \reentrant
int msec() const
Returns the millisecond part (0 to 999) of the time.
static QUuid fromRfc4122(QByteArrayView) noexcept
Creates a QUuid object from the binary representation of the UUID, as specified by RFC 4122 section 4...
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Combined button and popup list for selecting options.
GLenum GLsizei GLsizei GLint * values
[15]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
GLenum GLenum GLsizei void * table
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p)
static QList< QVariant > toList(char **buf, int count)
static QSqlError qMakeError(const QString &err, const int errCode, QSqlError::ErrorType type, const QMimerSQLDriverPrivate *p)
static MimerColumnTypes mimerMapColumnTypes(int32_t t)
static QString msgCouldNotGet(const char *type, int column)
static QMetaType::Type qDecodeMSQLType(int32_t t)
static QString msgCouldNotSet(const char *type, int column)
static int32_t qLookupMimDataType(QStringView s)
#define MIMER_DEFAULT_DATATYPE
#define Q_DECLARE_SQLDRIVER_PRIVATE(Class)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent