Below is the list of changes that have just been committed into a local
5.1 repository of uchum. When uchum does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-11-14 13:48:21+04:00, gshchepa@stripped +4 -0
Fixed bug #32034: On 64bit platforms assigning values of
storage engine system variables was not validated and
unexpected value was assigned.
The check_func_enum function used subtraction from the uint
value with the probably negative result. That result of
type uint was compared with 0 after casting to signed long
type. On architectures where long type is longer than int
type the result of comparison was unexpected.
mysql-test/r/plugin.result@stripped, 2007-11-14 13:48:18+04:00, gshchepa@stripped +10 -0
Added test case for bug #32034.
mysql-test/t/plugin.test@stripped, 2007-11-14 13:48:17+04:00, gshchepa@stripped +15 -0
Added test case for bug #32034.
sql/sql_plugin.cc@stripped, 2007-11-14 13:48:16+04:00, gshchepa@stripped +1 -1
Fixed bug #32034.
The check_func_enum function used subtraction from the uint
value with the probably negative result. That result of
type uint was compared with 0 after casting to signed long
type. On architectures where long type is longer than int
type the result of comparison was unexpected.
uint value has been casted to long type before subtraction.
storage/example/ha_example.cc@stripped, 2007-11-14 13:48:15+04:00, gshchepa@stripped +29 -1
Fixed bug #32034.
Sample system variable example_enum_var has been added to the
EXAMPLE storage to test ENUM variables.
diff -Nrup a/mysql-test/r/plugin.result b/mysql-test/r/plugin.result
--- a/mysql-test/r/plugin.result 2007-05-21 17:48:28 +05:00
+++ b/mysql-test/r/plugin.result 2007-11-14 13:48:18 +04:00
@@ -17,3 +17,13 @@ UNINSTALL PLUGIN EXAMPLE;
ERROR 42000: PLUGIN EXAMPLE does not exist
UNINSTALL PLUGIN non_exist;
ERROR 42000: PLUGIN non_exist does not exist
+#
+# Bug#32034: check_func_enum() does not check correct values but set it
+# to impossible int val
+#
+INSTALL PLUGIN example SONAME 'ha_example.so';
+SET GLOBAL example_enum_var= e1;
+SET GLOBAL example_enum_var= e2;
+SET GLOBAL example_enum_var= impossible;
+ERROR 42000: Variable 'enum_var' can't be set to the value of 'impossible'
+UNINSTALL PLUGIN example;
diff -Nrup a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test
--- a/mysql-test/t/plugin.test 2007-05-21 17:48:28 +05:00
+++ b/mysql-test/t/plugin.test 2007-11-14 13:48:17 +04:00
@@ -24,3 +24,18 @@ UNINSTALL PLUGIN EXAMPLE;
--error 1305
UNINSTALL PLUGIN non_exist;
+
+
+--echo #
+--echo # Bug#32034: check_func_enum() does not check correct values but set it
+--echo # to impossible int val
+--echo #
+
+INSTALL PLUGIN example SONAME 'ha_example.so';
+
+SET GLOBAL example_enum_var= e1;
+SET GLOBAL example_enum_var= e2;
+--error 1231
+SET GLOBAL example_enum_var= impossible;
+
+UNINSTALL PLUGIN example;
diff -Nrup a/sql/sql_plugin.cc b/sql/sql_plugin.cc
--- a/sql/sql_plugin.cc 2007-10-05 05:34:23 +05:00
+++ b/sql/sql_plugin.cc 2007-11-14 13:48:16 +04:00
@@ -1944,7 +1944,7 @@ static int check_func_enum(THD *thd, str
length= sizeof(buff);
if (!(str= value->val_str(value, buff, &length)))
goto err;
- if ((result= find_type(typelib, str, length, 1)-1) < 0)
+ if ((result= (long)find_type(typelib, str, length, 1)-1) < 0)
{
strvalue= str;
goto err;
diff -Nrup a/storage/example/ha_example.cc b/storage/example/ha_example.cc
--- a/storage/example/ha_example.cc 2007-08-27 23:20:00 +05:00
+++ b/storage/example/ha_example.cc 2007-11-14 13:48:15 +04:00
@@ -848,6 +848,34 @@ int ha_example::create(const char *name,
struct st_mysql_storage_engine example_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
+static ulong srv_enum_var= 0;
+
+const char *enum_var_names[]=
+{
+ "e1", "e2", NullS
+};
+
+TYPELIB enum_var_typelib=
+{
+ array_elements(enum_var_names) - 1, "enum_var_typelib",
+ enum_var_names, NULL
+};
+
+static MYSQL_SYSVAR_ENUM(
+ enum_var, // name
+ srv_enum_var, // varname
+ PLUGIN_VAR_RQCMDARG, // opt
+ "Sample ENUM system variable.", // comment
+ NULL, // check
+ NULL, // update
+ 0, // def
+ &enum_var_typelib); // typelib
+
+static struct st_mysql_sys_var* example_system_variables[]= {
+ MYSQL_SYSVAR(enum_var),
+ NULL
+};
+
mysql_declare_plugin(example)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
@@ -860,7 +888,7 @@ mysql_declare_plugin(example)
example_done_func, /* Plugin Deinit */
0x0001 /* 0.1 */,
NULL, /* status variables */
- NULL, /* system variables */
+ example_system_variables, /* system variables */
NULL /* config options */
}
mysql_declare_plugin_end;
| Thread |
|---|
| • bk commit into 5.1 tree (gshchepa:1.2648) BUG#32034 | gshchepa | 14 Nov |