Commit 235f0ffe authored by ingo@mysql.com's avatar ingo@mysql.com

Merge istruewing@bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/home/mydev/mysql/mysql-4.1
parents 3d13fb00 54c1debc
......@@ -48,6 +48,7 @@ hf@deer.mysql.r18.ru
hf@genie.(none)
igor@hundin.mysql.fi
igor@rurik.mysql.com
ingo@mysql.com
jani@dsl-jkl1657.dial.inet.fi
jani@dsl-kpogw4gb5.dial.inet.fi
jani@hynda.(none)
......
......@@ -192,6 +192,15 @@ length(quote(concat(char(0),"test")))
select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))));
hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))))
27E0E3E6E7E8EAEB27
select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678");
unhex(hex("foobar")) hex(unhex("1234567890ABCDEF")) unhex("345678")
foobar 1234567890ABCDEF 4Vx
select hex(unhex("1")), hex(unhex("12")), hex(unhex("123")), hex(unhex("1234")), hex(unhex("12345")), hex(unhex("123456"));
hex(unhex("1")) hex(unhex("12")) hex(unhex("123")) hex(unhex("1234")) hex(unhex("12345")) hex(unhex("123456"))
01 12 0123 1234 012345 123456
select length(unhex(md5("abrakadabra")));
length(unhex(md5("abrakadabra")))
16
select reverse("");
reverse("")
......
......@@ -78,6 +78,9 @@ select quote(concat('abc\'', '\\cba'));
select quote(1/0), quote('\0\Z');
select length(quote(concat(char(0),"test")));
select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))));
select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678");
select hex(unhex("1")), hex(unhex("12")), hex(unhex("123")), hex(unhex("1234")), hex(unhex("12345")), hex(unhex("123456"));
select length(unhex(md5("abrakadabra")));
#
# Wrong usage of functions
......
......@@ -18,6 +18,10 @@
/* thus to get the current time we should use the system function
with the highest possible resolution */
#ifdef __NETWARE__
#include <nks/time.h>
#endif
#include "mysys_priv.h"
ulonglong my_getsystime()
{
......@@ -31,6 +35,10 @@ ulonglong my_getsystime()
struct _timeb tb;
_ftime(&tb);
return (ulonglong)tb.time*10000000+(ulonglong)tb.millitm*10000;
#elif defined(__NETWARE__)
NXTime_t tm;
NXGetTime(NX_SINCE_1970, NX_NSECONDS, &tm);
return (ulonglong)tm/100;
#else
/* TODO: check for other possibilities for hi-res timestamping */
struct timeval tv;
......
......@@ -426,6 +426,11 @@ Item *create_func_ucase(Item* a)
return new Item_func_ucase(a);
}
Item *create_func_unhex(Item* a)
{
return new Item_func_unhex(a);
}
Item *create_func_uuid(void)
{
return new Item_func_uuid();
......
......@@ -92,6 +92,7 @@ Item *create_func_time_format(Item *a, Item *b);
Item *create_func_time_to_sec(Item* a);
Item *create_func_to_days(Item* a);
Item *create_func_ucase(Item* a);
Item *create_func_unhex(Item* a);
Item *create_func_uuid(void);
Item *create_func_version(void);
Item *create_func_weekday(Item* a);
......
......@@ -2231,7 +2231,7 @@ String *Item_func_hex::val_str(String *str)
null_value=0;
tmp_value.length(res->length()*2);
for (from=res->ptr(), end=from+res->length(), to= (char*) tmp_value.ptr();
from != end ;
from < end ;
from++, to+=2)
{
uint tmp=(uint) (uchar) *from;
......@@ -2241,6 +2241,48 @@ String *Item_func_hex::val_str(String *str)
return &tmp_value;
}
int inline hexchar_to_int(char c)
{
if (c <= '9' && c >= '0')
return c-'0';
c|=32;
if (c <= 'f' && c >= 'a')
return c-'a'+10;
return -1;
}
String *Item_func_unhex::val_str(String *str)
{
/* Convert given hex string to a binary string */
String *res= args[0]->val_str(str);
const char *from=res->ptr(), *end;
char *to;
int r;
if (!res || tmp_value.alloc((1+res->length())/2))
{
null_value=1;
return 0;
}
null_value=0;
tmp_value.length((1+res->length())/2);
to= (char*) tmp_value.ptr();
if (res->length() % 2)
{
*to++= r= hexchar_to_int(*from++);
if ((null_value= (r == -1)))
return 0;
}
for (end=res->ptr()+res->length(); from < end ; from+=2, to++)
{
*to= (r= hexchar_to_int(from[0])) << 4;
if ((null_value= (r == -1)))
return 0;
*to|= r= hexchar_to_int(from[1]);
if ((null_value= (r == -1)))
return 0;
}
return &tmp_value;
}
void Item_func_binary::print(String *str)
{
......
......@@ -523,6 +523,21 @@ public:
}
};
class Item_func_unhex :public Item_str_func
{
String tmp_value;
public:
Item_func_unhex(Item *a) :Item_str_func(a) {}
const char *func_name() const { return "unhex"; }
String *val_str(String *);
void fix_length_and_dec()
{
collation.set(&my_charset_bin);
decimals=0;
max_length=(1+args[0]->max_length)/2;
}
};
class Item_func_binary :public Item_str_func
{
......
......@@ -671,6 +671,7 @@ static SYMBOL sql_functions[] = {
{ "UCASE", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ucase)},
{ "UNCOMPRESS", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_uncompress)},
{ "UNCOMPRESSED_LENGTH", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_uncompressed_length)},
{ "UNHEX", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_unhex)},
{ "UNIQUE_USERS", SYM(UNIQUE_USERS)},
{ "UNIX_TIMESTAMP", SYM(UNIX_TIMESTAMP)},
{ "UPPER", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ucase)},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment