summaryrefslogtreecommitdiff
path: root/sql/set_var.cc
diff options
context:
space:
mode:
authorunknown <anozdrin/alik@quad.opbmk>2008-03-28 18:10:04 +0300
committerunknown <anozdrin/alik@quad.opbmk>2008-03-28 18:10:04 +0300
commitfba9e7c878359b0808e0f656d72aceedf34f0f56 (patch)
treedc8481ecdd397cf4753a4fb4ae0b826a319ed232 /sql/set_var.cc
parent1abfb6e040c7c3b9b157d213cc4e46af3773ce20 (diff)
downloadmariadb-git-fba9e7c878359b0808e0f656d72aceedf34f0f56.tar.gz
A patch for Bug#34820: log_output can be set to illegal value.
We have "set" variables, which can accept empty values (like sql_mode), and which can not (like log_output). The problem was that the code does not distinguish them and allow empty values for every set variable. The fix is to introduce an attribute of a set variable telling whether it can accept empty values. mysql-test/r/variables.result: Update result file. mysql-test/t/variables.test: A test case for Bug#34820: log_output can be set to illegal value. sql/set_var.cc: Don't allow empty values if it is prohibitted. sql/set_var.h: Add a flag (m_allow_empty_value) telling if an empty value is acceptable for this variable.
Diffstat (limited to 'sql/set_var.cc')
-rw-r--r--sql/set_var.cc25
1 files changed, 21 insertions, 4 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 46a64b1a87c..6b07d81125a 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -1664,6 +1664,14 @@ bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
strmov(buff, "NULL");
goto err;
}
+
+ if (!m_allow_empty_value &&
+ res->length() == 0)
+ {
+ buff[0]= 0;
+ goto err;
+ }
+
var->save_result.ulong_value= ((ulong)
find_set(enum_names, res->c_ptr(),
res->length(),
@@ -1679,10 +1687,19 @@ bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
else
{
ulonglong tmp= var->value->val_int();
- /*
- For when the enum is made to contain 64 elements, as 1ULL<<64 is
- undefined, we guard with a "count<64" test.
- */
+
+ if (!m_allow_empty_value &&
+ tmp == 0)
+ {
+ buff[0]= '0';
+ buff[1]= 0;
+ goto err;
+ }
+
+ /*
+ For when the enum is made to contain 64 elements, as 1ULL<<64 is
+ undefined, we guard with a "count<64" test.
+ */
if (unlikely((tmp >= ((ULL(1)) << enum_names->count)) &&
(enum_names->count < 64)))
{