summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <malff/marcsql@weblab.(none)>2007-02-06 16:01:22 -0700
committerunknown <malff/marcsql@weblab.(none)>2007-02-06 16:01:22 -0700
commit372fc7e443eaa6fcffd1cb33e9f8a28e2e76542a (patch)
tree0c4a2c6ba76f2b7a97d111e415fdf692fe7cdbb4 /sql
parent86b715a79f06d0a276e1e6f72fca3cb384890bfe (diff)
downloadmariadb-git-372fc7e443eaa6fcffd1cb33e9f8a28e2e76542a.tar.gz
Bug#12976 (stored procedures local variables of type bit)
Before this change, a local variables in stored procedures / stored functions or triggers, when declared with a type of bit(N), would not evaluate their value properly. The problem was that the data was incorrectly typed as a string, causing for example bit b'1', implemented as a byte 0x01, to be interpreted as a string starting with the character 0x01. This later would cause implicit conversions to integers or booleans to fail. The root cause of this problem was an incorrect translation between field types, like bit(N), and internal types used when representing values in Item objects. Also, before this change, the function HEX() would sometime print extra "0" characters when invoked with bit(N) values. With this fix, the type translation (sp_map_result_type, sp_map_item_type) has been changed so that bit(N) fields are represented with integer values. A consequence is that, for the function HEX(), when called with a stored procedure local variable of type bit(N) as argument, HEX() is provided with an integer instead of a string, and therefore does not print "0" padding. A test case for Bug 12976 was present in the test suite, and has been updated. mysql-test/r/sp-vars.result: Local stored procedure variables of type bit(N) are integer values. mysql-test/t/sp-vars.test: Local stored procedure variables of type bit(N) are integer values. sql/sp_head.cc: Local stored procedure variables of type bit(N) are integer values.
Diffstat (limited to 'sql')
-rw-r--r--sql/sp_head.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index de0edabda3e..2e8ecd20000 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -36,6 +36,7 @@ Item_result
sp_map_result_type(enum enum_field_types type)
{
switch (type) {
+ case MYSQL_TYPE_BIT:
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_LONG:
@@ -58,6 +59,7 @@ Item::Type
sp_map_item_type(enum enum_field_types type)
{
switch (type) {
+ case MYSQL_TYPE_BIT:
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_LONG: