ansible/ansible — pull request #4630 by mmoya (2013-10-22 08:04:04+00:00)
Title: Add support for string values

The `SET GLOBAL` query doesn't quote strings values. For example, the following correct queries will fail if quotes are toggled:

mysql> SET GLOBAL innodb_lru_scan_depth = 2000;
mysql> SET GLOBAL master_info_repository = "TABLE";

In ansible:

# will pass, 2000 is passed without quotes
- name: set a numeric value
mysql_variable: variable=innodb_lru_scan_depth value=2000

# will fail, TABLE is passed without quotes
- name: set a string value
mysql_variable: variable=master_info_repository value=TABLE

With this patch prepared statements are used. Proper quoting will be done automatically based on the type of the variables thus an attempt to convert to _int_, then to _float_ is done in first place.

Booleans values, ie: _ON_, _OFF_, are not specially handled because they can be quoted. For example, the following queries are correct:

mysql> SET GLOBAL innodb_file_per_table = "ON";
mysql> SET GLOBAL innodb_file_per_table = ON;
mysql> SET GLOBAL innodb_file_per_table = 1;

Tested in mysql 5.5 and 5.6.

This is the patch referred to as 2/3 in #4581.