diff -Nur a/storage/innobase/include/row0sel.h b/storage/innobase/include/row0sel.h --- a/storage/innobase/include/row0sel.h +++ b/storage/innobase/include/row0sel.h @@ -400,6 +400,8 @@ of a fixed length column) */ }; +UNIV_INLINE void swap_u4(uint *t, uint *s); +UNIV_INLINE void swap_u8(ulint *t, ulint *s); #ifndef UNIV_NONINL #include "row0sel.ic" #endif diff -Nur a/storage/innobase/include/row0sel.ic b/storage/innobase/include/row0sel.ic --- a/storage/innobase/include/row0sel.ic +++ b/storage/innobase/include/row0sel.ic @@ -103,3 +103,23 @@ return(thr); } + +UNIV_INLINE void swap_u4(uint *t, uint *s) { + __asm__ __volatile__ ( + "bswap %0" + :"=r" (*t) // output : register 0 => ret + :"0" (*s) // input : x => register 0 + :"0" // clobbered register + ); +} + +UNIV_INLINE void swap_u8(ulint *t, ulint *s) { + __asm__ __volatile__ ( + "bswapq %0" + :"=r" (*t) // output : register 0 => ret + :"0" (*s) // input : x => register 0 + :"0" // clobbered register + ); +} + + diff -Nur a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -357,15 +357,26 @@ sign bit negated if the data is a signed integer. In MySQL, integers are stored in a little-endian format. */ - byte* p = buf + col_len; - - for (;;) { - p--; - *p = *mysql_data; - if (p == buf) { - break; + if (col_len == 4) + { + swap_u4((uint*)buf, (uint*)mysql_data); + } + else if (col_len == 8) + { + swap_u8((uint*)buf, (uint*)mysql_data); + } + else + { + byte* p = buf + col_len; + + for (;;) { + p--; + *p = *mysql_data; + if (p == buf) { + break; + } + mysql_data++; } - mysql_data++; } if (!(dtype->prtype & DATA_UNSIGNED)) { diff -Nur a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c --- a/storage/innobase/row/row0sel.c +++ b/storage/innobase/row/row0sel.c @@ -2568,15 +2568,26 @@ /* Convert integer data from Innobase to a little-endian format, sign bit restored to normal */ - ptr = dest + len; - - for (;;) { - ptr--; - *ptr = *data; - if (ptr == dest) { - break; + if (len == 4) + { + swap_u4((uint*)dest, (uint*)data); + } + else if (len == 8) + { + swap_u8((uint*)dest, (uint*)data); + } + else + { + ptr = dest + len; + + for (;;) { + ptr--; + *ptr = *data; + if (ptr == dest) { + break; + } + data++; } - data++; } if (!templ->is_unsigned) {