From: Alexander Nozdrin Date: April 15 2011 9:04am Subject: bzr commit into mysql-trunk branch (alexander.nozdrin:3320) WL#5787 List-Archive: http://lists.mysql.com/commits/135507 Message-Id: <201104150904.p3F94Wti006006@acsmt356.oracle.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7452936300700762056==" --===============7452936300700762056== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///home/alik/MySQL/bzr/00/wl5787/mysql-trunk-wl5787.2/ based on revid:sergey.glukhov@stripped 3320 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:04:21 +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:04:21 +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:04:21 +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:04:21 +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 === 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:04:21 +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:04:21 +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; --===============7452936300700762056== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/alexander.nozdrin@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: alexander.nozdrin@stripped\ # io2etb9tn2knwl73 # target_branch: file:///home/alik/MySQL/bzr/00/wl5787/mysql-trunk-\ # wl5787.2/ # testament_sha1: 0bb7cdd1270ba494a5e211e500c2efcd360992ff # timestamp: 2011-04-15 13:04:28 +0400 # source_branch: file:///home/alik/MySQL/bzr/00/wl5787/mysql-trunk-\ # wl5787/ # base_revision_id: sergey.glukhov@stripped\ # rj95aq0qmvhk8cky # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWYrKwDUABFlfgAAQWGP/93on xIC////wYAhOXwAAAEEFCqqigBCSSJintA1I8hT9ABPVNMaIwnkj9UHMAAAAAAAAAAHMAAAAAAAA AAENQEYppoNDIAAAAAAcwAAAAAAAAAAJJAQBMTEaEwgmmUTNEeo9TNRLPBjK66XBwe2OPx3EXvz0 XVBmezOj+ztElmaLnaBK19bjKAMiYpZoetz2he1zY0MgJHxzEcxHAjAAAAABkBW5GUnpbQ8SsJ1R RKSgAU1JYDlZEEuEQaCaEPq+ofV7eXxLomFiR9NMXhsopNzTaLxSP+WksyCojliSCt8J1ZZajbV0 tRl36XMVnQVlYtqceT7/qkSZC0YS/bs88s89xuBgvwPwgW8XqXVLxkYkThT4AIiLZrjsKztUL0wq wu8ljE5MhhmEJ5daoAPQGa0FlGYsxbXukhJ93J9wj0IkMxsBExEECajgOH1KJH3iCjIHCRIAwNSc nlBcUBwIlaawrmtkgfUkXTQ9lOaaBN8zP+l+alkirJwVgFniwR+nvcPEMkiHkZ+cUCpjaRlHW2bX aZs/Qad9kSKmvxqA37m7DIej+8OJSkGw4qxVOqvcb9DXDrPmImVCjQb9wnmhA3uwiCbfcV6r+riu LMp16zppSFXrLeP8+VQBCqKxLNS/guGEyErpEN1prqgmS1GDuWkzj9QDAVngA+p0NhUruOLy9jhG CT2SzdhWkb1AkMZkyM9iDik0e9PWY9a9aFM2LyZePqVsJEZFNNwt5qbqNq+wtDoKA88POJdpoaaG b7GengSZk5IN45wBfwMokibERghMYourMSSoLLCRjRl04yKWa9KwrGLThofkyExRMa2bkgxC8yMD kpbbVidhWUFm6xjY0sH2PX7QRkZ10lAigkGI9VnvOBoNxKD9SZmeWZ09R486nQwo5L2uWwU3st0J bnETq6o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