[Commits] b1f8911: MDEV-7015: SET STATEMENT old_passwords has no effect

sanja at mariadb.com sanja at mariadb.com
Thu Nov 20 13:45:09 EET 2014


revision-id: b1f891169c2ad80d82555d99b11dcd1c797688d0
parent(s): b14de6aa993a2d48848db34bda2fd5629043e6c2
committer: Oleksandr Byelkin
branch nick: work-maria-10.1-MDEV-6996
timestamp: 2014-11-20 12:45:06 +0100
message:

MDEV-7015: SET STATEMENT old_passwords has no effect

Make decision on Password format during fix_fields.

---
 mysql-test/r/set_statement.result | 18 ++++++++++++++++--
 mysql-test/t/set_statement.test   |  8 ++++++--
 sql/item_strfunc.cc               | 17 +++++++++++++++++
 sql/item_strfunc.h                |  6 ++++--
 sql/sql_yacc.yy                   |  6 +-----
 sql/sys_vars.cc                   |  2 +-
 6 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/mysql-test/r/set_statement.result b/mysql-test/r/set_statement.result
index e5ecd2b..62ec792 100644
--- a/mysql-test/r/set_statement.result
+++ b/mysql-test/r/set_statement.result
@@ -1092,8 +1092,6 @@ set statement character_set_filesystem=default for select 1;
 ERROR 42000: The system variable character_set_filesystem cannot be set in SET STATEMENT.
 set statement collation_connection=default for select 1;
 ERROR 42000: The system variable collation_connection cannot be set in SET STATEMENT.
-set statement old_passwords=default for select 1;
-ERROR 42000: The system variable old_passwords cannot be set in SET STATEMENT.
 set statement query_cache_type=default for select 1;
 ERROR 42000: The system variable query_cache_type cannot be set in SET STATEMENT.
 set statement wait_timeout=default for select 1;
@@ -1103,3 +1101,19 @@ ERROR 42000: The system variable interactive_timeout cannot be set in SET STATEM
 SET STATEMENT default_week_format = 2 FOR SELECT WEEK('2000-01-01');
 WEEK('2000-01-01')
 52
+set statement OLD_PASSWORDS = 0 for select password('test');
+password('test')
+*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29
+set statement OLD_PASSWORDS = 1 for select password('test');
+password('test')
+378b243e220ca493
+set statement OLD_PASSWORDS = 0 for explain extended select password('test');
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Warnings:
+Note	1003	select password('test') AS `password('test')`
+set statement OLD_PASSWORDS = 1 for explain extended select password('test');
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Warnings:
+Note	1003	select password('test') AS `password('test')`
diff --git a/mysql-test/t/set_statement.test b/mysql-test/t/set_statement.test
index 85c9495..8428a46 100644
--- a/mysql-test/t/set_statement.test
+++ b/mysql-test/t/set_statement.test
@@ -1039,8 +1039,6 @@ set statement character_set_filesystem=default for select 1;
 --error ER_SET_STATEMENT_NOT_SUPPORTED
 set statement collation_connection=default for select 1;
 --error ER_SET_STATEMENT_NOT_SUPPORTED
-set statement old_passwords=default for select 1;
---error ER_SET_STATEMENT_NOT_SUPPORTED
 set statement query_cache_type=default for select 1;
 --error ER_SET_STATEMENT_NOT_SUPPORTED
 set statement wait_timeout=default for select 1;
@@ -1049,3 +1047,9 @@ set statement interactive_timeout=default for select 1;
 
 # MDEV-6996: SET STATEMENT default_week_format = .. has no effect
 SET STATEMENT default_week_format = 2 FOR SELECT WEEK('2000-01-01');
+
+# MDEV-7015: SET STATEMENT old_passwords has no effect
+set statement OLD_PASSWORDS = 0 for select password('test');
+set statement OLD_PASSWORDS = 1 for select password('test');
+set statement OLD_PASSWORDS = 0 for explain extended select password('test');
+set statement OLD_PASSWORDS = 1 for explain extended select password('test');
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 9a3c758..39fadea 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -2168,6 +2168,23 @@ void Item_func_trim::print(String *str, enum_query_type query_type)
 
 /* Item_func_password */
 
+bool Item_func_password::fix_fields(THD *thd, Item **ref)
+{
+  if (thd->variables.old_passwords)
+  {
+    Item_func_old_password *i1=
+      new (thd->mem_root) Item_func_old_password(args[0]);
+    if (!i1)
+      return TRUE;
+    thd->change_item_tree(ref, i1);
+    i1->name= name;
+    i1->deflt= TRUE;
+    return i1->fix_fields(thd, ref);
+  }
+  return Item_str_ascii_func::fix_fields(thd, ref);
+}
+
+
 String *Item_func_password::val_str_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 8377a20..1fb462c 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -411,6 +411,7 @@ class Item_func_password :public Item_str_ascii_func
 public:
   Item_func_password(Item *a) :Item_str_ascii_func(a) {}
   String *val_str_ascii(String *str);
+  bool fix_fields(THD *thd, Item **ref);
   void fix_length_and_dec()
   {
     fix_length_and_charset(SCRAMBLED_PASSWORD_CHAR_LENGTH, default_charset());
@@ -431,13 +432,14 @@ class Item_func_old_password :public Item_str_ascii_func
 {
   char tmp_value[SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1];
 public:
-  Item_func_old_password(Item *a) :Item_str_ascii_func(a) {}
+  bool deflt;
+  Item_func_old_password(Item *a) :Item_str_ascii_func(a), deflt(0) {}
   String *val_str_ascii(String *str);
   void fix_length_and_dec()
   {
     fix_length_and_charset(SCRAMBLED_PASSWORD_CHAR_LENGTH_323, default_charset());
   } 
-  const char *func_name() const { return "old_password"; }
+  const char *func_name() const { return deflt ? "password" : "old_password"; }
   static char *alloc(THD *thd, const char *password, size_t pass_len);
 };
 
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 21016b0..080a8c4 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -9763,11 +9763,7 @@ function_call_conflict:
           }
         | PASSWORD '(' expr ')'
           {
-            Item* i1;
-            if (thd->variables.old_passwords)
-              i1= new (thd->mem_root) Item_func_old_password($3);
-            else
-              i1= new (thd->mem_root) Item_func_password($3);
+            Item* i1= new (thd->mem_root) Item_func_password($3);
             if (i1 == NULL)
               MYSQL_YYABORT;
             $$= i1;
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 975b1f0..897d3be 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -2130,7 +2130,7 @@ static bool check_old_passwords(sys_var *self, THD *thd, set_var *var)
 static Sys_var_mybool Sys_old_passwords(
        "old_passwords",
        "Use old password encryption method (needed for 4.0 and older clients)",
-       NO_SET_STMT SESSION_VAR(old_passwords), CMD_LINE(OPT_ARG),
+       SESSION_VAR(old_passwords), CMD_LINE(OPT_ARG),
        DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG,
        ON_CHECK(check_old_passwords));
 export sys_var *Sys_old_passwords_ptr= &Sys_old_passwords; // for sql_acl.cc


More information about the commits mailing list