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.
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.
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.
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.
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.