summaryrefslogtreecommitdiff
path: root/sql/set_var.cc
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2005-07-16 03:29:13 +0400
committerunknown <konstantin@mysql.com>2005-07-16 03:29:13 +0400
commite83e10533194cca56596226e5c2c08c7bb6d5b9a (patch)
tree7b2a374b6d05a129d4b7e3e16593f7244bdccf90 /sql/set_var.cc
parent0f41fb4234c58d9f17385c8f77fe02aa6a1f5b96 (diff)
downloadmariadb-git-e83e10533194cca56596226e5c2c08c7bb6d5b9a.tar.gz
A fix and a test case for Bug#9359 "Prepared statements take snapshot
of system vars at PREPARE time": implement a special Item to handle system variables. This item substitutes itself with a basic constant containing variable value at fix_fields. mysql-test/r/ps.result: - test results fixed (Bug#9359). mysql-test/t/ps.test: - add a test case for Bug#9359 "Prepared statements take snapshot of system vars at PREPARE time" sql/item_func.cc: - implement Item_func_get_system_var: we should not evaluate system variables in the parser, but instead should create an item which is evaluated to a constant at execute. - remove an unused function sql/item_func.h: Add a new item, Item_func_get_system_var sql/mysql_priv.h: Move necessary declarations to make set_var.h objects visible in item_func.h sql/set_var.cc: - we should not print to network from get_system_var: if it's called from prepared statement prepare, we get packets out of order when using the binary protocol. Instead report the error to be sent to the user later. This is a backport from 5.0. sql/set_var.h: - declaration of enum_var_type moved to mysql_priv.h
Diffstat (limited to 'sql/set_var.cc')
-rw-r--r--sql/set_var.cc14
1 files changed, 3 insertions, 11 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc
index b0fa61a12bc..f7700d18607 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -1551,15 +1551,7 @@ err:
/*
Return an Item for a variable. Used with @@[global.]variable_name
-
If type is not given, return local value if exists, else global
-
- We have to use netprintf() instead of my_error() here as this is
- called on the parsing stage.
-
- TODO:
- With prepared statements/stored procedures this has to be fixed
- to create an item that gets the current value at fix_fields() stage.
*/
Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base)
@@ -1568,8 +1560,8 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base)
{
if (var_type != OPT_DEFAULT)
{
- net_printf(thd, ER_INCORRECT_GLOBAL_LOCAL_VAR,
- name, var_type == OPT_GLOBAL ? "SESSION" : "GLOBAL");
+ my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0),
+ name, var_type == OPT_GLOBAL ? "SESSION" : "GLOBAL");
return 0;
}
/* As there was no local variable, return the global value */
@@ -1613,7 +1605,7 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base)
return tmp;
}
default:
- net_printf(thd, ER_VAR_CANT_BE_READ, name);
+ my_error(ER_VAR_CANT_BE_READ, MYF(0), name);
}
return 0;
}