>Description:
My udf function and an equal udf function I found in the internet
seem to work well as does substring_index. Only when I call them
together I get a bug. As my function (quotet below) is so simple
that it doubtly has a bug I guess substring_index has one.
>How-To-Repeat:
mysql> select substring_index("1.2.3.4/24","/",1) ;
+-------------------------------------+
| substring_index("1.2.3.4/24","/",1) |
+-------------------------------------+
| 1.2.3.4 |
+-------------------------------------+
1 row in set (0.00 sec)
mysql> select ewu_aton("1.2.3.4");
+---------------------+
| ewu_aton("1.2.3.4") |
+---------------------+
| 16909060 |
+---------------------+
1 row in set (0.01 sec)
mysql> select ewu_aton( substring_index("1.2.3.4/24","/",1) );
+-------------------------------------------------+
| ewu_aton( substring_index("1.2.3.4/24","/",1) ) |
+-------------------------------------------------+
| 3772388104 |
+-------------------------------------------------+
1 row in set (0.00 sec)
Here the correct value should had been 16909060 (0x01020304), too!
My Function:
/*
** inet_aton()
*/
my_bool ewu_aton_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
if (args->arg_count != 1 || args->arg_type[0] != STRING_RESULT)
{
strmov(message,"Wrong arguments to ewu_aton; Use the source!");
return 1;
}
initid->max_length=20;
initid->maybe_null=0;
return 0;
}
long long ewu_aton(UDF_INIT *initid, UDF_ARGS *args,
char *is_null, char *error)
{
struct in_addr in;
inet_aton(((char*) args->args[0]), &in);
*is_null=0;
return htonl(in.s_addr);
}
>Fix:
I'd wish I'd have one :-)
>Submitter-Id: <submitter ID>
>Originator: Christian Hammers
>Organization: WESTEND GmbH
>MySQL support: none
>Synopsis: substring_index bug with udf function
>Severity: serious
>Priority: medium
>Category: mysql
>Class: sw-bug
>Release: mysql-3.23.30-gamma (Source distribution)
>Server: /usr/bin/mysqladmin Ver 8.13 Distrib 3.23.30-gamma, for pc-linux-gnu on i586
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Server version 3.23.30-gamma and 3.21.30
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 5 days 17 hours 34 min 27 sec
Threads: 3 Questions: 128800303 Slow queries: 1299 Opens: 260 Flush tables: 1
Open tables: 48 Queries per second avg: 260.062
>Environment:
Testet on two different i386 architecture machins running with two
versions of Debian GNU/Linux (an old and the latest)
System: Linux han 2.4.0-test12 #1 Fre Dez 22 15:58:55 CET 2000 i686 unknown
Architecture: i686
Some paths: /usr/bin/perl /usr/bin/make /usr/local/bin/gcc /usr/bin/cc
GCC: Reading specs from /usr/local/pgcc/lib/gcc-lib/i686-pc-linux-gnu/pgcc-2.95.2/specs
gcc version pgcc-2.95.2 19991024 (release)
Compilation info: CC='gcc' CFLAGS='-O2 -fomit-frame-pointer -g' CXX='g++'
CXXFLAGS='-O2 -fomit-frame-pointer -g -felide-constructors -fno-exceptions -fno-rtti'
LDFLAGS=''
LIBC:
lrwxrwxrwx 1 root root 13 Jan 19 09:25 /lib/libc.so.6 -> libc-2.2.1.so
-rwxr-xr-x 1 root root 1078540 Jan 14 07:51 /lib/libc-2.2.1.so
-rw-r--r-- 1 root root 2471916 Jan 14 07:53 /usr/lib/libc.a
-rw-r--r-- 1 root root 178 Jan 14 07:53 /usr/lib/libc.so
-rw-r--r-- 1 root root 2024202 Sep 6 15:18 /usr/lib/libc-client.a
-rw-r--r-- 1 root root 665260 Sep 6 15:18 /usr/lib/libc-client.so
-rw-r--r-- 1 root root 665260 Sep 6 15:18 /usr/lib/libc-client.so.4.7
Configure command: ./configure --prefix=/usr --exec-prefix=/usr
--libexecdir=/usr/sbin --datadir=/usr/share --sysconfdir=/etc/mysql
--localstatedir=/var/lib/mysql --includedir=/usr/include --infodir=/usr/share/info
--mandir=/usr/share/man --enable-shared --with-libwrap --enable-assembler
--with-berkeley-db-includes=/home/ch/debian/mysql/mysql-3.23.30/debian/db-3.2.3g/build_unix
--with-berkeley-db-libs=/home/ch/debian/mysql/mysql-3.23.30/debian/db-3.2.3g/build_unix
--enable-static --enable-shared --with-raid
--with-unix-socket-path=/var/run/mysqld/mysqld.sock --with-mysqld-user=mysql
--without-bench --without-readline --with-extra-charsets=all
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php