Skip to content

Commit

Permalink
upgraded to MySQL v9.0
Browse files Browse the repository at this point in the history
 - workflows, tools, docs, qmake, CMake, ...
  • Loading branch information
silverqx committed Jul 3, 2024
1 parent d5819e2 commit afe299e
Show file tree
Hide file tree
Showing 23 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .env.win32.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ TINY_VCPKG_ROOT = $$quote(E:/xyz/vcpkg/)
TINY_VCPKG_TRIPLET = x64-windows

# MySQL C library (default installation path is auto-detected)
#TINY_MYSQL_ROOT = $$quote($$(ProgramFiles)/MySQL/MySQL Server 8.4/)
#TINY_MYSQL_ROOT = $$quote($$(ProgramFiles)/MySQL/MySQL Server 9.0/)
2 changes: 1 addition & 1 deletion .github/workflows/msvc2022-qt6-drivers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
# Settings (constant variables)
TINY_QT_VERSION: 6.7.2
TINY_QT_SPEC: win64_msvc2019_64
TINY_MYSQL_SERVICE: MySQL84
TINY_MYSQL_SERVICE: MySQL90
# My system is unresponsive with 10
TINY_PARALLEL: 8

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/msys2-ucrt64-drivers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
# Don't user more than 3 for GCC, it would need 64GB RAM (no money 💵)
TINY_PARALLEL_GCC: 3
TINY_PARALLEL_CLANG_OR_VCPKG: 9
TINY_MYSQL_SERVICE: MySQL84
TINY_MYSQL_SERVICE: MySQL90
# Used by the msys2.cmd script and cygpath.exe
MSYS2_ROOT: C:\msys64

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/vcpkg-windows-drivers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

env:
# Settings (constant variables)
TINY_MYSQL_SERVICE: MySQL84
TINY_MYSQL_SERVICE: MySQL90
TINY_PARALLEL: 10

# State variables
Expand Down
18 changes: 9 additions & 9 deletions NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ MySQL Timezone tables:
mysql_config_editor print --all
mysql --login-path=root -p mysql
source timezone_posix.sql;
Restart-Service MySQL84
Restart-Service MySQL90


Versions info:
Expand Down Expand Up @@ -1153,7 +1153,7 @@ TinyDrivers output of operator<<()-s:

Output of all TinyDrivers operator<<()-s SqlDatabase, SqlRecord, SqlField, DummySqlError

SqlDatabase(driver="QMYSQL", database="tinyorm_test_1", host="mysql.test", port=3306, user="szachara", open=true", options="SSL_CERT=C:/mysql/mysql_8.4/data/client-cert.pem;SSL_CA=C:/mysql/mysql_8.4/data/ca.pem;SSL_KEY=C:/mysql/mysql_8.4/data/client-key.pem")
SqlDatabase(driver="QMYSQL", database="tinyorm_test_1", host="mysql.test", port=3306, user="szachara", open=true", options="SSL_CERT=C:/mysql/mysql_9.0/data/client-cert.pem;SSL_CA=C:/mysql/mysql_9.0/data/ca.pem;SSL_KEY=C:/mysql/mysql_9.0/data/client-key.pem")
--
SqlRecord(7)
0: SqlField(name: "id", type: qulonglong, value: "1", isNull: false, isValid: true, length: 20, precision: 0, required: true, sqlType: 8, sqlTypeName: BIGINT, autoIncrement: true, tableName: "users")
Expand Down Expand Up @@ -3329,10 +3329,10 @@ MariaDB11
NT SERVICE\MariaDB11
mysqld.exe --install MariaDB11 --defaults-file="E:\mysql\mariadb_11\data\my.ini"

MySQL84
"C:\Program Files\MySQL\MySQL Server 8.4\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.4\my.ini" MySQL84
NT SERVICE\MySQL84
mysqld.exe --install MySQL84 --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.4\my.ini"
MySQL90
"C:\Program Files\MySQL\MySQL Server 9.0\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 9.0\my.ini" MySQL90
NT SERVICE\MySQL90
mysqld.exe --install MySQL90 --defaults-file="C:\ProgramData\MySQL\MySQL Server 9.0\my.ini"

postgresql-x64-16
"C:\Program Files\PostgreSQL\16\bin\pg_ctl.exe" runservice -N "postgresql-x64-16" -D "E:\postgres\16\data" -w
Expand Down Expand Up @@ -3418,11 +3418,11 @@ MySQL option files syntax:
- C API client library as well
- [mysql] is applied for MySQL programs only
- options in last sections override the previous one
- the best order is: [client], [mysqlXYZ], [mysqld], [mysqld-8.4]
- [mysqld-8.4] targets specific MySQL version
- the best order is: [client], [mysqlXYZ], [mysqld], [mysqld-9.0]
- [mysqld-9.0] targets specific MySQL version
- the [DEFAULT] section can be used for own variables, if some variable value can't be resolved
the this section is checked at first
- https://dev.mysql.com/doc/refman/8.4/en/option-files.html#option-file-syntax
- https://dev.mysql.com/doc/refman/9.0/en/option-files.html#option-file-syntax


vcpkg CMake build command:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Whole library is documented as markdown documents:
The following list summarizes all the `TinyDrivers` and `TinyMySql` libraries' features. 🆕

- both, normal and prepared statements are supported
- TLS/SSL connections using [`MYSQL_OPT_SSL_MODE`](https://dev.mysql.com/doc/c-api/8.4/en/mysql-options.html) (verify_ca, verify_identity) 🔥
- TLS/SSL connections using [`MYSQL_OPT_SSL_MODE`](https://dev.mysql.com/doc/c-api/9.0/en/mysql-options.html) (verify_ca, verify_identity) 🔥
- setting many other connection options (see [`mysqldriver_p.cpp`](https://github.com/silverqx/TinyORM/blob/main/drivers/mysql/src/orm/drivers/mysql/mysqldriver_p.cpp))
- building and linking against the [`MariaDB Connector/C`](https://mariadb.com/kb/en/mariadb-connector-c/)
- transactions
Expand Down
14 changes: 7 additions & 7 deletions conf.pri.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
# environment variable.
# - TINY_MYSQL_ROOT - Path to the MySQL installation folder.
# If not defined, then it tries to guess the MySQL installation folder:
# $$(ProgramFiles)/MySQL/MySQL Server (8.4|8.3|8.2|8.1|8.0|5.7)/)
# $$(ProgramFiles)/MySQL/MySQL Server (9.0|8.4|8.3|8.2|8.1|8.0|5.7)/)
#
# You can set these variables in the .env (recommended) or conf.pri files,
# in the .qmake.conf file (or wherever you want), or as environment variables.
#
# These variables will be set after auto-configuration is done:
#
# - TINY_VCPKG_INCLUDE - Path to the vcpkg include folder (vcpkg/installed/<triplet>/include/).
# - TINY_MYSQL_INCLUDE - Path to the MySQL include folder (MySQL Server 8.4/include/).
# - TINY_MYSQL_LIB - Path to the MySQL lib folder (MySQL Server 8.4/lib/).
# - TINY_MYSQL_INCLUDE - Path to the MySQL include folder (MySQL Server 9.0/include/).
# - TINY_MYSQL_LIB - Path to the MySQL lib folder (MySQL Server 9.0/lib/).
#
# The TINY_MYSQL_INCLUDE and TINY_MYSQL_LIB are only set on win32 platform except mingw.

Expand Down Expand Up @@ -158,7 +158,7 @@ else:win32-msvc|win32-clang-msvc {
# Explicitly specify the MySQL root installation path using the $$TINY_MYSQL_ROOT
# !disable_autoconf {
# # Used in the tiny_find_mysql()
# TINY_MYSQL_ROOT = $$quote($$(ProgramFiles)/MySQL/MySQL Server 8.4/)
# TINY_MYSQL_ROOT = $$quote($$(ProgramFiles)/MySQL/MySQL Server 9.0/)
# return()
# }

Expand All @@ -172,12 +172,12 @@ else:win32-msvc|win32-clang-msvc {
mysql_ping {
# Find the MySQL C library and add it on system include path and library path
tiny_find_mysql()
# tiny_find_mysql($$quote($$(ProgramFiles)/MySQL/MySQL Server 8.4/))
# tiny_find_mysql($$quote($$(ProgramFiles)/MySQL/MySQL Server 9.0/))

# tiny_add_system_includepath(\
# $$quote(C:/Program Files/MySQL/MySQL Server 8.4/include/))
# $$quote(C:/Program Files/MySQL/MySQL Server 9.0/include/))

# LIBS_PRIVATE += $$quote(-LC:/Program Files/MySQL/MySQL Server 8.4/lib/)
# LIBS_PRIVATE += $$quote(-LC:/Program Files/MySQL/MySQL Server 9.0/lib/)
# LIBS_PRIVATE += -llibmysql
}
}
Expand Down
6 changes: 3 additions & 3 deletions docs/building/tinyorm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ These are <u>`qmake`</u> and <u>`environment`</u> variables that affect the `Aut
| -------------------- | ----------- |
| `TINY_VCPKG_ROOT` | Path to the `vcpkg` installation folder.<br/>If not defined, then it tries to use the `VCPKG_ROOT` environment variable. |
| `TINY_VCPKG_TRIPLET` | The `vcpkg` `triplet` to use <small>(vcpkg/installed/$$TINY_VCPKG_TRIPLET/)</small>.<br/>If not defined, then it tries to guess the `vcpkg` `triplet` based on the current compiler and OS (based on the `QMAKESPEC`), and as the last thing, it tries to use the `VCPKG_DEFAULT_TRIPLET` environment variable. |
| `TINY_MYSQL_ROOT` | Path to the `MySQL` installation folder.<br/>If not defined, then it tries to guess the `MySQL` installation folder (`win32` only): <code>$$(ProgramFiles)/MySQL/MySQL Server (8.4&vert;8.3&vert;8.2&vert;8.1&vert;8.0&vert;5.7)/</code> |
| `TINY_MYSQL_ROOT` | Path to the `MySQL` installation folder.<br/>If not defined, then it tries to guess the `MySQL` installation folder (`win32` only): <code>$$(ProgramFiles)/MySQL/MySQL Server (9.0&vert;8.4&vert;8.3&vert;8.2&vert;8.1&vert;8.0&vert;5.7)/</code> |

You can set these variables in the `.env` (recommended) or `conf.pri` files, in the `.qmake.conf` file (or wherever you want), or as environment variables.

Expand All @@ -1003,8 +1003,8 @@ These variables will be set after `auto-configuration` is done:
| Variable Name | Description |
| -------------------- | ----------- |
| `TINY_VCPKG_INCLUDE` | Path to the `vcpkg` `include` folder <small>(vcpkg/installed/&lt;triplet&gt;/include/)</small>. |
| `TINY_MYSQL_INCLUDE` | Path to the `MySQL` `include` folder <small>(MySQL Server 8.4/include/)</small>. |
| `TINY_MYSQL_LIB` | Path to the `MySQL` `lib` folder <small>(MySQL Server 8.4/lib/)</small>. |
| `TINY_MYSQL_INCLUDE` | Path to the `MySQL` `include` folder <small>(MySQL Server 9.0/include/)</small>. |
| `TINY_MYSQL_LIB` | Path to the `MySQL` `lib` folder <small>(MySQL Server 9.0/lib/)</small>. |

The `TINY_MYSQL_INCLUDE` and `TINY_MYSQL_LIB` are only set on `win32` platform except `mingw`.

Expand Down
6 changes: 3 additions & 3 deletions docs/database/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ The first argument is configuration hash which is of type `QVariantHash` and the

You may also configure connection options by `options` key as `QVariantHash` or `QString`, you can pass any [connection options](https://doc.qt.io/qt/qsqldatabase.html#setConnectOptions) supported by `QSqlDatabase`.

You can also configure [Transaction Isolation Levels](https://dev.mysql.com/doc/refman/8.4/en/innodb-transaction-isolation-levels.html) for MySQL connection with the `isolation_level` configuration option.
You can also configure [Transaction Isolation Levels](https://dev.mysql.com/doc/refman/9.0/en/innodb-transaction-isolation-levels.html) for MySQL connection with the `isolation_level` configuration option.

The `version` option is relevant only for the MySQL connections and you can save/avoid one database query (select version()) if you provide it manually. On the base of this version will be decided which [session variables](https://github.com/silverqx/TinyORM/blob/main/src/orm/connectors/mysqlconnector.cpp#L154) will be set if strict mode is enabled and whether to use an [alias](https://github.com/silverqx/TinyORM/blob/main/src/orm/query/grammars/mysqlgrammar.cpp#L36) during the `upsert` method call.

Expand Down Expand Up @@ -794,13 +794,13 @@ Since unprepared statements do not bind parameters, they may be vulnerable to SQ

#### Implicit Commits

When using the `DB` facade's `statement` methods within transactions, you must be careful to avoid statements that cause [implicit commits](https://dev.mysql.com/doc/refman/8.4/en/implicit-commit.html). These statements will cause the database engine to indirectly commit the entire transaction, leaving TinyORM unaware of the database's transaction level. An example of such a statement is creating a database table:
When using the `DB` facade's `statement` methods within transactions, you must be careful to avoid statements that cause [implicit commits](https://dev.mysql.com/doc/refman/9.0/en/implicit-commit.html). These statements will cause the database engine to indirectly commit the entire transaction, leaving TinyORM unaware of the database's transaction level. An example of such a statement is creating a database table:

```cpp
DB::statement("create table users (name varchar(255) null)");
```
Please refer to the MySQL manual for [a list of all statements](https://dev.mysql.com/doc/refman/8.4/en/implicit-commit.html) that trigger implicit commits.
Please refer to the MySQL manual for [a list of all statements](https://dev.mysql.com/doc/refman/9.0/en/implicit-commit.html) that trigger implicit commits.
### Using Multiple Database Connections
Expand Down
2 changes: 1 addition & 1 deletion docs/database/query-builder.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ All databases except SQL Server require the columns in the second argument of th
:::
:::info
Row and column aliases will be used with the MySQL server >=8.0.19 instead of the VALUES() function as is described in the MySQL [documentation](https://dev.mysql.com/doc/refman/8.4/en/insert-on-duplicate.html). The MySQL server version is auto-detected and can be overridden in the [configuration](/database/getting-started.mdx#configuration).
Row and column aliases will be used with the MySQL server >=8.0.19 instead of the VALUES() function as is described in the MySQL [documentation](https://dev.mysql.com/doc/refman/9.0/en/insert-on-duplicate.html). The MySQL server version is auto-detected and can be overridden in the [configuration](/database/getting-started.mdx#configuration).
:::
## Update Statements
Expand Down
2 changes: 1 addition & 1 deletion docs/dependencies.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Be aware that the standard support for the last release of the __Qt v5__ series

##### Optional

- &gt;= [MySQL Connector/C 8](https://dev.mysql.com/downloads/c-api/) - used only for the [`mysql_ping`](https://dev.mysql.com/doc/c-api/8.4/en/mysql-ping.html) function and provided by [MySQL 8 Server](https://dev.mysql.com/downloads/mysql/)
- &gt;= [MySQL Connector/C 8](https://dev.mysql.com/downloads/c-api/) - used only for the [`mysql_ping`](https://dev.mysql.com/doc/c-api/9.0/en/mysql-ping.html) function and provided by [MySQL 8 Server](https://dev.mysql.com/downloads/mysql/)

:::info
The `TinyORM` will support `Qt` versions that aren't [end-of-life](https://endoflife.date/qt).
Expand Down
10 changes: 5 additions & 5 deletions docs/tinydrivers/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ It was designed to drop the `QtSql` dependency while maintaining backward compat
##### Features summary

- both, normal and prepared statements are supported
- TLS/SSL connections using [`MYSQL_OPT_SSL_MODE`](https://dev.mysql.com/doc/c-api/8.4/en/mysql-options.html) (verify_ca, verify_identity) 🔥
- TLS/SSL connections using [`MYSQL_OPT_SSL_MODE`](https://dev.mysql.com/doc/c-api/9.0/en/mysql-options.html) (verify_ca, verify_identity) 🔥
- setting many other connection options (see [`mysqldriver_p.cpp`](https://github.com/silverqx/TinyORM/blob/main/drivers/mysql/src/orm/drivers/mysql/mysqldriver_p.cpp))
- building and linking against the [`MariaDB Connector/C`](https://mariadb.com/kb/en/mariadb-connector-c/)
- transactions
Expand Down Expand Up @@ -52,9 +52,9 @@ Currently, only the `MySQL` database driver is supported and finished.

The following describes the differences between `QMYSQL` and `TinyMySql` drivers.

The `QMYSQL` driver doesn't support setting `MySQL` non-flag [connection options](https://dev.mysql.com/doc/c-api/8.4/en/mysql-options.html) like `MYSQL_OPT_RECONNECT` without the value, it needs to be defined with value like `=1` or `=TRUE` (case-sensitive), only real flag options like `CLIENT_INTERACTIVE` can be set without the value and `=` character.
The `QMYSQL` driver doesn't support setting `MySQL` non-flag [connection options](https://dev.mysql.com/doc/c-api/9.0/en/mysql-options.html) like `MYSQL_OPT_RECONNECT` without the value, it needs to be defined with value like `=1` or `=TRUE` (case-sensitive), only real flag options like `CLIENT_INTERACTIVE` can be set without the value and `=` character.

On the other hand, the `TinyMySql` driver allows setting non-flag [connection options](https://dev.mysql.com/doc/c-api/8.4/en/mysql-options.html) options without the value and `=` character, which are considered enabled (ON or TRUE).
On the other hand, the `TinyMySql` driver allows setting non-flag [connection options](https://dev.mysql.com/doc/c-api/9.0/en/mysql-options.html) options without the value and `=` character, which are considered enabled (ON or TRUE).

##### Removed features

Expand Down Expand Up @@ -102,7 +102,7 @@ To control shared and static build use [`static`](building/tinyorm.mdx#qmake-sta

Performance is several milliseconds faster compared to `QtSql` with the `QMYSQL` driver. It was tuned using the `KCacheGrind` to be so. It's ~40ms faster on [`TinyOrmPlayground`](https://github.com/silverqx/TinyOrmPlayground) project with __620__ database queries compiled using `GCC v13.2.1` Debug build on Linux. Similar results can be expected on other platforms but it's not guaranteed.

This means performance is very similar to `QtSql`. There is not much to speed up because `TinyDrivers` code is swift and 90% of the time is spent inside the [`MySQL C API`](https://dev.mysql.com/doc/c-api/8.4/en/) because we always have to wait for the database server, especially when creating database connections using eg. [`mysql_real_connect()`](https://dev.mysql.com/doc/c-api/8.4/en/mysql-real-connect.html) (this function is king among the slowest functions 😎, which is understandable of course).
This means performance is very similar to `QtSql`. There is not much to speed up because `TinyDrivers` code is swift and 90% of the time is spent inside the [`MySQL C API`](https://dev.mysql.com/doc/c-api/9.0/en/) because we always have to wait for the database server, especially when creating database connections using eg. [`mysql_real_connect()`](https://dev.mysql.com/doc/c-api/9.0/en/mysql-real-connect.html) (this function is king among the slowest functions 😎, which is understandable of course).

## Internals

Expand All @@ -112,7 +112,7 @@ This means performance is very similar to `QtSql`. There is not much to speed up
- SQL API layer
- Public API layer

The Driver layer is eg. `TinyMySql` library which is responsible for communicating with the underlying database driver (eg. [`MySQL C API`](https://dev.mysql.com/doc/c-api/8.4/en/)).
The Driver layer is eg. `TinyMySql` library which is responsible for communicating with the underlying database driver (eg. [`MySQL C API`](https://dev.mysql.com/doc/c-api/9.0/en/)).

The SQL API layer is a semi-layer that glues everything up and sits between the Public interface API and the Driver layer.

Expand Down
2 changes: 1 addition & 1 deletion docs/tinyorm/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ All databases except SQL Server require the columns in the second argument of th
:::
:::info
Row and column aliases will be used with the MySQL server >=8.0.19 instead of the VALUES() function as is described in the MySQL [documentation](https://dev.mysql.com/doc/refman/8.4/en/insert-on-duplicate.html). The MySQL server version is auto-detected and can be overridden in the [configuration](/database/getting-started.mdx#configuration).
Row and column aliases will be used with the MySQL server >=8.0.19 instead of the VALUES() function as is described in the MySQL [documentation](https://dev.mysql.com/doc/refman/9.0/en/insert-on-duplicate.html). The MySQL server version is auto-detected and can be overridden in the [configuration](/database/getting-started.mdx#configuration).
:::
## Deleting Models
Expand Down
2 changes: 1 addition & 1 deletion drivers/common/src/orm/drivers/sqlfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ operator<<(QDebug debug, const TINYORM_PREPEND_NAMESPACE(Orm::Drivers::SqlField)
in MySQL v8.3, what means connector C API doesn't provide this default field value,
also both IS_NULLABLE and COLUMN_DEFAULT must be checked to correctly obtain this
information, there is also some info at about NO_DEFAULT_VALUE_FLAG:
https://dev.mysql.com/doc/c-api/8.4/en/c-api-data-structures.html:
https://dev.mysql.com/doc/c-api/9.0/en/c-api-data-structures.html:
- SHOW COLUMNS FROM users;
- describe users; (the same as SHOW COLUMNS)
- select c.COLUMN_NAME, c.IS_NULLABLE, c.COLUMN_DEFAULT from information_schema.`COLUMNS` c where c.TABLE_SCHEMA = 'tinyorm_test_1' and c.TABLE_NAME = 'users'; (this select-s as little info as possible)
Expand Down
2 changes: 1 addition & 1 deletion drivers/mysql/include/orm/drivers/mysql/mysqldriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace Orm::Drivers::MySql
int
MySqlDriver::maximumIdentifierLength(const IdentifierType /*unused*/) const noexcept
{
// https://dev.mysql.com/doc/refman/8.4/en/identifier-length.html
// https://dev.mysql.com/doc/refman/9.0/en/identifier-length.html
return 64;
}

Expand Down
2 changes: 1 addition & 1 deletion include/orm/databaseconnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ namespace Orm
const QString &queryString, const QList<QVariant> &preparedBindings,
const RunCallback<Return> &callback) const
{
// TODO would be good to call KILL on lost connection to free locks, https://dev.mysql.com/doc/c-api/8.4/en/c-api-auto-reconnect.html silverqx
// TODO would be good to call KILL on lost connection to free locks, https://dev.mysql.com/doc/c-api/9.0/en/c-api-auto-reconnect.html silverqx
if (!causedByLostConnection(errorMessage))
std::rethrow_exception(ePtr);

Expand Down
Loading

0 comments on commit afe299e

Please sign in to comment.