MXS-1639 Discard results when executing sql text files
This removes the limitation of not returning resultsets.
This commit is contained in:
parent
fa7cd9450a
commit
2a38902aa6
@ -446,10 +446,15 @@ servers_no_promotion=backup_dc_server1,backup_dc_server2
|
||||
|
||||
#### `promotion_sql_file` and `demotion_sql_file`
|
||||
|
||||
These are paths to text files with SQL statements in them. During promotion or
|
||||
demotion, the contents are read line-by-line and executed on the backend. Empty
|
||||
lines or lines starting with '#' are ignored. All statements must succeed and
|
||||
none may return results, otherwise the switchover or failover fails.
|
||||
These optional settings are paths to text files with SQL statements in them.
|
||||
During promotion or demotion, the contents are read line-by-line and executed on
|
||||
the backend. Use these settings to execute custom statements on the servers to
|
||||
complement the built-in operations.
|
||||
|
||||
Empty lines or lines starting with '#' are ignored. Any results returned by the
|
||||
statements are ignored. All statements must succeed for the failover, switchover
|
||||
or rejoin to continue. The monitor user may require additional privileges and
|
||||
grants for the custom commands to succeed.
|
||||
|
||||
When promoting a slave to master during switchover or failover, the
|
||||
`promotion_sql_file` is read and executed on the new master server after its
|
||||
|
@ -4919,7 +4919,8 @@ static int64_t scan_server_id(const char* id_string)
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the file contents and send them as sql queries to the server. Queries should not return any data.
|
||||
* Read the file contents and send them as sql queries to the server. Any data returned by the queries is
|
||||
* discarded.
|
||||
*
|
||||
* @param server Server to send queries to
|
||||
* @param path Text file path.
|
||||
@ -4953,6 +4954,12 @@ static bool run_sql_from_file(MXS_MONITORED_SERVER* server, const string& path,
|
||||
if (mxs_mysql_query(conn, line.c_str()) == 0)
|
||||
{
|
||||
lines_executed++;
|
||||
// Discard results if any.
|
||||
MYSQL_RES* res = mysql_store_result(conn);
|
||||
if (res != NULL)
|
||||
{
|
||||
mysql_free_result(res);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user