summaryrefslogtreecommitdiffstats
path: root/src/plugins/sqldrivers
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-08-13 18:34:28 -0700
committerThiago Macieira <thiago.macieira@intel.com>2021-08-18 15:39:05 -0700
commit6feb28918924d80c94b6f435bc3bc981855d59d6 (patch)
tree29b7f38884e50b202bf0686e953c51a2cce76d7d /src/plugins/sqldrivers
parentddea7e6ce95a59ce926d667657d8c39de9422769 (diff)
MySQL: pedantism: create and destroy the MYSQL_TIME type
This is a no-op. But take the opportunity to make a drive-by update on the loop, which improves it. Change-Id: I4a40ccbd3321467a8429fffd169b08590d28c928 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src/plugins/sqldrivers')
-rw-r--r--src/plugins/sqldrivers/mysql/qsql_mysql.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
index 1f07171ca5..96bba79da1 100644
--- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
@@ -375,6 +375,8 @@ bool QMYSQLResultPrivate::bindInValues()
char *field = bind->buffer_length ? new char[bind->buffer_length + 1]{} : nullptr;
bind->buffer = f.outField = field;
+ if (qIsTimeOrDate(fieldInfo->type))
+ new (field) MYSQL_TIME;
++i;
}
@@ -425,9 +427,11 @@ void QMYSQLResult::cleanup()
d->meta = 0;
}
- int i;
- for (i = 0; i < d->fields.count(); ++i)
- delete[] d->fields[i].outField;
+ for (const auto &field : qAsConst(d->fields)) {
+ if (qIsTimeOrDate(field.myField->type))
+ reinterpret_cast<MYSQL_TIME *>(field.outField)->~MYSQL_TIME();
+ delete[] field.outField;
+ }
if (d->outBinds) {
delete[] d->outBinds;