summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-11-02 21:08:49 +0100
committerSergei Golubchik <serg@mariadb.org>2016-12-12 20:27:22 +0100
commit660355c1acf70cc30e6a69000a1c5357a84fdc60 (patch)
treecf4fd2a43460a523a40efc24ebb222685cc66112
parent96bb5f44d87e31e38237411ae8d532d4df89a10d (diff)
downloadmariadb-git-660355c1acf70cc30e6a69000a1c5357a84fdc60.tar.gz
bugfix: Item_func_get_system_var::print()
-rw-r--r--mysql-test/r/variables.result20
-rw-r--r--mysql-test/t/variables.test8
-rw-r--r--sql/item_func.cc17
-rw-r--r--sql/sql_string.h6
4 files changed, 46 insertions, 5 deletions
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index 6c2a331d66b..760e11e8193 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -1801,3 +1801,23 @@ select * from information_schema.session_variables where variable_name='sql_mode
VARIABLE_NAME VARIABLE_VALUE
SQL_MODE ANSI_QUOTES
End of 5.5 tests
+explain extended select @@VERsion from dual where rand() > @@verSION;
+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 @@VERsion AS "@@VERsion" from DUAL where (rand() > @@version)
+explain extended select @@SESsion.SQL_mode from dual where rand() > @@sesSION.sql_MODE;
+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 @@SESsion.SQL_mode AS "@@SESsion.SQL_mode" from DUAL where (rand() > @@sql_mode)
+explain extended select @@GLObal.COLLATION_connection from dual where rand() > @@gloBAL.collation_CONNECTION;
+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 @@GLObal.COLLATION_connection AS "@@GLObal.COLLATION_connection" from DUAL where (rand() > @@global.collation_connection)
+explain extended select @@FOObar.KEY_BUFfer_size from dual where rand() > @@fooBAR.key_bufFER_SIZE;
+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 @@FOObar.KEY_BUFfer_size AS "@@FOObar.KEY_BUFfer_size" from DUAL where (rand() > @@fooBAR.key_buffer_size)
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 4d97f380dff..ed6e92f145e 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -1532,3 +1532,11 @@ show global status like 'foobar';
select * from information_schema.session_variables where variable_name='sql_mode';
--echo End of 5.5 tests
+
+#
+# test Item_func_get_system_var::print()
+#
+explain extended select @@VERsion from dual where rand() > @@verSION;
+explain extended select @@SESsion.SQL_mode from dual where rand() > @@sesSION.sql_MODE;
+explain extended select @@GLObal.COLLATION_connection from dual where rand() > @@gloBAL.collation_CONNECTION;
+explain extended select @@FOObar.KEY_BUFfer_size from dual where rand() > @@fooBAR.key_bufFER_SIZE;
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 3b98dd0d345..b03e65a2431 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -5841,7 +5841,22 @@ void Item_func_get_system_var::fix_length_and_dec()
void Item_func_get_system_var::print(String *str, enum_query_type query_type)
{
- str->append(name, name_length);
+ if (name_length)
+ str->append(name, name_length);
+ else
+ {
+ str->append(STRING_WITH_LEN("@@"));
+ if (component.length)
+ {
+ str->append(&component);
+ str->append('.');
+ }
+ else if (var_type == SHOW_OPT_GLOBAL && var->scope() != sys_var::GLOBAL)
+ {
+ str->append(STRING_WITH_LEN("global."));
+ }
+ str->append(&var->name);
+ }
}
bool Item_func_get_system_var::check_vcol_func_processor(void *arg)
diff --git a/sql/sql_string.h b/sql/sql_string.h
index e51d089709e..8be23184741 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -466,10 +466,8 @@ public:
}
bool append(const String &s);
bool append(const char *s);
- bool append(const LEX_STRING *ls)
- {
- return append(ls->str, ls->length);
- }
+ bool append(const LEX_STRING *ls) { return append(ls->str, ls->length); }
+ bool append(const LEX_CSTRING *ls) { return append(ls->str, ls->length); }
bool append(const char *s, uint32 arg_length);
bool append(const char *s, uint32 arg_length, CHARSET_INFO *cs);
bool append_ulonglong(ulonglong val);