summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.cc
diff options
context:
space:
mode:
authorunknown <gluh@mysql.com>2005-07-13 16:08:13 +0500
committerunknown <gluh@mysql.com>2005-07-13 16:08:13 +0500
commit3b7a17d891de13a556b4d6fdd048415f85e5b414 (patch)
treed821f7795c8b47e6a869f53c811cfb022212dbdc /sql/item_strfunc.cc
parent9ea8a51178e5315957d862de2eed38df2afe9161 (diff)
parent3ae23d5b9e91fad8bb9e3c265acca93a792d8e53 (diff)
downloadmariadb-git-3b7a17d891de13a556b4d6fdd048415f85e5b414.tar.gz
Merge mysql.com:/home/gluh/MySQL/Merge/4.1
into mysql.com:/home/gluh/MySQL/Merge/5.0 mysql-test/r/func_str.result: Auto merged mysql-test/t/func_str.test: Auto merged sql/item_strfunc.cc: Auto merged
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r--sql/item_strfunc.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index dcb539476a1..a8fd7dcf75d 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -2380,9 +2380,21 @@ String *Item_func_hex::val_str(String *str)
DBUG_ASSERT(fixed == 1);
if (args[0]->result_type() != STRING_RESULT)
{
- /* Return hex of unsigned longlong value */
- longlong dec= args[0]->val_int();
+ ulonglong dec;
char ans[65],*ptr;
+ /* Return hex of unsigned longlong value */
+ if (args[0]->result_type() == REAL_RESULT)
+ {
+ double val= args[0]->val();
+ if ((val <= (double) LONGLONG_MIN) ||
+ (val >= (double) (ulonglong) ULONGLONG_MAX))
+ dec= ~(longlong) 0;
+ else
+ dec= (ulonglong) (val + (val > 0 ? 0.5 : -0.5));
+ }
+ else
+ dec= (ulonglong) args[0]->val_int();
+
if ((null_value= args[0]->null_value))
return 0;
ptr= longlong2str(dec,ans,16);