Commit Graph

26 Commits

Author SHA1 Message Date
e17ce0fa59 Allow building the MySQL driver with MariaDB libraries.
Closes #505
2023-07-14 15:07:03 +02:00
5f669c98eb Add option for setting zlib/zstd compression algorithms 2023-05-07 16:29:46 +02:00
ead2689ac6 SQL API: add multiple result sets API
MySQL may return multiple result sets from a call to a stored
procedure (the CALL statement), or when multiple queries are specified
in a single client request. The application is supposed to process those
multiple result sets one by one with calls to `mysql_next_result()`, or
its prepared statements counterpart, `mysql_stmt_next_result()`.

Additionally, there is the `mysql_more_results()` call which allows the
application to check if more result sets are available and works for
both regular queries and prepared statements API.

One way to handle multiple results in sysbench would be consuming all
result sets silently in the MySQL driver, but that would make it
impossible for scripts to get access to individual result sets returned
by a stored procedure.

Now sysbench exposes those MySQL client API calls to the SQL API, so it
is up to the script authors to handle multiple result sets when either
stored procedures are used in a benchmark script, or multiple queries
are passed to `sql_connection:query()`:

- sql_connection:next_result()
- sql_connection:more_results()
- sql_statement:next_results()

Here is an example how multiple results can be handled in a benchmark
script:

```lua
   local rs = con:query([[CALL p1("foo")]])
   while rs ~= nil do
      -- handle the result set
      rs = con:next_result()
   end
```

Here is a prepared statement example:

```lua
   stmt = con:prepare("CALL p1(?)")
   param = stmt:bind_create(sysbench.sql.type.CHAR, 10)
   stmt:bind_param(param)
   param:set("bar")
   rs = stmt:execute()

   while rs ~= nil do
      rs = stmt:next_result()
   end
```

Fixes GH-304.
2021-03-25 21:20:15 +03:00
672be3e61a Addendum to the fix for #287: fix MySQL 5.6 builds again. 2019-01-16 18:38:27 +03:00
f98859a649 Addendum to the fix for #287: fix MySQL 5.6 builds. 2019-01-16 18:25:29 +03:00
0fcd22cc44 Merge branch 'gh-287' 2019-01-16 16:33:04 +03:00
f30a30c875 Fix #287: Issue of MYSQL_OPT_SSL_MODE
In drv_mysql.c do not assume MYSQL_OPT_SSL_MODE to be a preprocessor
define. It is an mysql_option enum value with all MySQL
versions. Instead, do a configure-time check if that value is defined in
mysql.h.
2019-01-16 14:57:37 +03:00
ad2b1bf1e7 Merge branch '1.0' 2018-12-16 17:27:36 +03:00
b017a998ef Fix GH-282: Mysql's fetch_row() is broken
Fix both MySQL and PostgreSQL drivers to return an error when
fetch_row() is called after retrieving all rows in the result set.
2018-12-16 17:21:39 +03:00
3a5475b53e Remove Windows support which was broken in 1.0. 2018-04-21 15:19:36 +03:00
e5c8052027 Make --mysql-ssl behave like --ssl-mode in MySQL client utilities.
The problem with MySQL 5.7+ client libraries was that there was no way
to disable SSL usage from the sysbench command line, because the client
library defaults to MYSQL_OPT_SSL_MODE = SSL_MODE_REQUIRED, even if
--mysql-ssl is not used. So the only way to disable it was disabling SSL
on the server.

Now --mysql-ssl behaves like the --ssl-mode option in MySQL client
utilities. It accepts the following values (with "disabled" being the
default):

disabled, preferred, required, verify_ca, verify_identity.

When sysbench is built With pre-5.6 MySQL client libraries or MariaDB
client libraries, where support for SSL modes is not available,
--mysql-ssl behavior is not affected by this change, i.e. it remains a
boolean variable accepting the on/off values, with "off" being the
default.
2018-03-31 20:32:09 +03:00
9ebe81693f Update copyright year in drv_mysql.c 2018-03-31 16:03:25 +03:00
b1a0694cc0 Added --mysql-ssl-key, --mysql-ca and --mysql-ssl-cert.
Replace hard-coded values for client SSL path names with driver options,
at the same time making it possible to skip those options even when
--mysql-ssl is used.
2018-03-31 15:28:29 +03:00
81ae246691 Do not error if SSL files are missing 2018-03-29 12:52:08 +02:00
f5fa7800cb A better version of the fix for #172. 2017-09-17 23:32:38 +03:00
cd13882cb6 Fix #172: sysbench 1.0.9 doesn't build with mariadb 10.2.8
Add a configure check for <server/mysql_version.h> which appears to be
the most portable way to fix MariaDB builds (see MDEV-13773).
2017-09-17 22:23:30 +03:00
9ca119c9c7 Add workaround for MySQL #87337 to build against 8.0.2. 2017-08-21 19:24:13 +03:00
0c12758222 Fix building against MariaDB 10.2 (thanks to Xavier Bachelot). 2017-07-13 15:29:02 +03:00
538521184a Compatibility fix for MySQL 8.0 client libraries.
The type of MYSQL_BIND::is_null has been changed from my_bool* to bool*
in MySQL 8.0. Since the size bool is not defined by the standard, we
either need to change the DB and Lua APIs to ensure is_null points to a
large enough buffer for MySQL API to store a bool, or do conversions
between sysbench and MySQL data structures. For now, just assert that
sizeof(bool) == 1, which is likely the case on all supported platforms.
2017-05-15 14:17:21 +03:00
75b530c7fc Fix builds with MariaDB client libraries. 2017-04-12 19:34:30 +03:00
6ad3f09a07 Fix builds with MySQL 8.0.1 client libraries.
my_bool has been replaced with bool in MySQL 8.0.1.
2017-04-12 00:24:34 +03:00
3348e8dfa3 Remove unused gresults variable from drv_mysql.c. 2017-04-12 00:21:46 +03:00
40c14789aa Export mysql_drv_reconnect() to Lua SQL API. 2017-02-02 10:59:51 +03:00
1363264c61 Handle more cases where drv_pgsql.c may leak memory. 2017-01-30 16:04:39 +03:00
1cf5b33eda Move counters code from db_driver.c to sb_counter.c. 2017-01-29 13:45:26 +03:00
06d4f99cb6 Rename the 'sysbench' subdirectory to 'src'. 2017-01-27 09:39:28 +03:00