#At file:///home/alik/MySQL/bzr/00/wl5787/mysql-trunk-wl5787.2/ based on revid:tor.didriksen@stripped
3319 Alexander Nozdrin 2011-04-15
Preliminatry patch for WL#5787 (IPv6-capable INET_ATON and
INET_NTOA functions).
The patch just moves Item_func_inet_aton and Item_func_inet_ntoa
implementations into new files item_inetfunc.h and
item_inetfunc.cc. Those new files will be used to hold
implementations of new functions in the next patch.
modified:
sql/CMakeLists.txt
sql/item_create.cc
sql/item_func.cc
sql/item_func.h
sql/item_strfunc.cc
sql/item_strfunc.h
=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt 2011-02-02 08:30:13 +0000
+++ b/sql/CMakeLists.txt 2011-04-15 09:02:36 +0000
@@ -64,6 +64,7 @@ SET(SQL_SHARED_SOURCES
item_sum.cc
item_timefunc.cc
item_xmlfunc.cc
+ item_inetfunc.cc
key.cc
keycaches.cc
lock.cc
=== modified file 'sql/item_create.cc'
--- a/sql/item_create.cc 2011-03-09 20:54:55 +0000
+++ b/sql/item_create.cc 2011-04-15 09:02:36 +0000
@@ -30,6 +30,7 @@
#include "set_var.h"
#include "sp_head.h"
#include "sp.h"
+#include "item_inetfunc.h"
/*
=============================================================================
=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc 2011-04-08 13:41:38 +0000
+++ b/sql/item_func.cc 2011-04-15 09:02:36 +0000
@@ -5711,61 +5711,6 @@ void Item_func_get_system_var::cleanup()
}
-longlong Item_func_inet_aton::val_int()
-{
- DBUG_ASSERT(fixed == 1);
- uint byte_result = 0;
- ulonglong result = 0; // We are ready for 64 bit addresses
- const char *p,* end;
- char c = '.'; // we mark c to indicate invalid IP in case length is 0
- char buff[36];
- int dot_count= 0;
-
- String *s, tmp(buff, sizeof(buff), &my_charset_latin1);
- if (!(s = args[0]->val_str_ascii(&tmp))) // If null value
- goto err;
- null_value=0;
-
- end= (p = s->ptr()) + s->length();
- while (p < end)
- {
- c = *p++;
- int digit = (int) (c - '0');
- if (digit >= 0 && digit <= 9)
- {
- if ((byte_result = byte_result * 10 + digit) > 255)
- goto err; // Wrong address
- }
- else if (c == '.')
- {
- dot_count++;
- result= (result << 8) + (ulonglong) byte_result;
- byte_result = 0;
- }
- else
- goto err; // Invalid character
- }
- if (c != '.') // IP number can't end on '.'
- {
- /*
- Handle short-forms addresses according to standard. Examples:
- 127 -> 0.0.0.127
- 127.1 -> 127.0.0.1
- 127.2.1 -> 127.2.0.1
- */
- switch (dot_count) {
- case 1: result<<= 8; /* Fall through */
- case 2: result<<= 8; /* Fall through */
- }
- return (result << 8) + (ulonglong) byte_result;
- }
-
-err:
- null_value=1;
- return 0;
-}
-
-
void Item_func_match::init_search(bool no_order)
{
DBUG_ENTER("Item_func_match::init_search");
=== modified file 'sql/item_func.h'
--- a/sql/item_func.h 2011-04-08 13:41:38 +0000
+++ b/sql/item_func.h 2011-04-15 09:02:36 +0000
@@ -1635,17 +1635,6 @@ public:
};
-class Item_func_inet_aton : public Item_int_func
-{
-public:
- Item_func_inet_aton(Item *a) :Item_int_func(a) {}
- longlong val_int();
- const char *func_name() const { return "inet_aton"; }
- void fix_length_and_dec()
- { decimals= 0; max_length= 21; maybe_null= 1; unsigned_flag= 1;}
-};
-
-
/* for fulltext search */
#include <ft_global.h>
=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc 2011-04-08 13:41:38 +0000
+++ b/sql/item_strfunc.cc 2011-04-15 09:02:36 +0000
@@ -3513,48 +3513,6 @@ void Item_func_export_set::fix_length_an
fix_char_length(length * 64 + sep_length * 63);
}
-String* Item_func_inet_ntoa::val_str(String* str)
-{
- DBUG_ASSERT(fixed == 1);
- uchar buf[8], *p;
- ulonglong n = (ulonglong) args[0]->val_int();
- char num[4];
-
- /*
- We do not know if args[0] is NULL until we have called
- some val function on it if args[0] is not a constant!
-
- Also return null if n > 255.255.255.255
- */
- if ((null_value= (args[0]->null_value || n > (ulonglong) LL(4294967295))))
- return 0; // Null value
-
- str->set_charset(collation.collation);
- str->length(0);
- int4store(buf,n);
-
- /* Now we can assume little endian. */
-
- num[3]='.';
- for (p=buf+4 ; p-- > buf ; )
- {
- uint c = *p;
- uint n1,n2; // Try to avoid divisions
- n1= c / 100; // 100 digits
- c-= n1*100;
- n2= c / 10; // 10 digits
- c-=n2*10; // last digit
- num[0]=(char) n1+'0';
- num[1]=(char) n2+'0';
- num[2]=(char) c+'0';
- uint length= (n1 ? 4 : n2 ? 3 : 2); // Remove pre-zero
- uint dot_length= (p <= buf) ? 1 : 0;
- (void) str->append(num + 4 - length, length - dot_length,
- &my_charset_latin1);
- }
- return str;
-}
-
#define get_esc_bit(mask, num) (1 & (*((mask) + ((num) >> 3))) >> ((num) & 7))
=== modified file 'sql/item_strfunc.h'
--- a/sql/item_strfunc.h 2011-03-22 11:44:40 +0000
+++ b/sql/item_strfunc.h 2011-04-15 09:02:36 +0000
@@ -780,22 +780,6 @@ class Item_func_export_set: public Item_
const char *func_name() const { return "export_set"; }
};
-class Item_func_inet_ntoa : public Item_str_func
-{
-public:
- Item_func_inet_ntoa(Item *a) :Item_str_func(a)
- {
- }
- String* val_str(String* str);
- const char *func_name() const { return "inet_ntoa"; }
- void fix_length_and_dec()
- {
- decimals= 0;
- fix_length_and_charset(3 * 8 + 7, default_charset());
- maybe_null= 1;
- }
-};
-
class Item_func_quote :public Item_str_func
{
String tmp_value;
Attachment: [text/bzr-bundle] bzr/alexander.nozdrin@oracle.com-20110415090236-zu5dkfmaxf5omrv0.bundle
| Thread |
|---|
| • bzr commit into mysql-trunk branch (alexander.nozdrin:3319) WL#5787 | Alexander Nozdrin | 15 Apr |