1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00
checkpoint.
does not compile.
This commit is contained in:
Sergei Golubchik
2010-11-25 18:17:28 +01:00
2732 changed files with 867504 additions and 20901 deletions

View File

@ -27,6 +27,9 @@
#include "sql_string.h"
#ifdef MYSQL_CLIENT
#error Attempt to use server-side sql_string on client. Use client/sql_string.cc
#endif
/*****************************************************************************
** String functions
*****************************************************************************/
@ -58,13 +61,13 @@ bool String::real_alloc(uint32 length)
bool String::realloc(uint32 alloc_length)
{
uint32 len=ALIGN_SIZE(alloc_length+1);
DBUG_ASSERT(len > alloc_length);
if (len <= alloc_length)
return TRUE; /* Overflow */
if (Alloced_length < len)
if (Alloced_length <= alloc_length)
{
char *new_ptr;
uint32 len= ALIGN_SIZE(alloc_length+1);
DBUG_ASSERT(len > alloc_length);
if (len <= alloc_length)
return TRUE; /* Overflow */
if (alloced)
{
if (!(new_ptr= (char*) my_realloc(Ptr,len,MYF(MY_WME))))
@ -635,10 +638,10 @@ void String::qs_append(int i)
str_length+= (int) (end-buff);
}
void String::qs_append(uint i)
void String::qs_append(ulonglong i)
{
char *buff= Ptr + str_length;
char *end= int10_to_str(i, buff, 10);
char *end= longlong10_to_str(i, buff,10);
str_length+= (int) (end-buff);
}
@ -913,6 +916,65 @@ my_copy_with_hex_escaping(CHARSET_INFO *cs,
return dst - dst0;
}
/*
Optimized for quick copying of ASCII characters in the range 0x00..0x7F.
*/
uint32
copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
const char *from, uint32 from_length, CHARSET_INFO *from_cs,
uint *errors)
{
/*
If any of the character sets is not ASCII compatible,
immediately switch to slow mb_wc->wc_mb method.
*/
if ((to_cs->state | from_cs->state) & MY_CS_NONASCII)
return copy_and_convert_extended(to, to_length, to_cs,
from, from_length, from_cs, errors);
uint32 length= min(to_length, from_length), length2= length;
#if defined(__i386__)
/*
Special loop for i386, it allows to refer to a
non-aligned memory block as UINT32, which makes
it possible to copy four bytes at once. This
gives about 10% performance improvement comparing
to byte-by-byte loop.
*/
for ( ; length >= 4; length-= 4, from+= 4, to+= 4)
{
if ((*(uint32*)from) & 0x80808080)
break;
*((uint32*) to)= *((const uint32*) from);
}
#endif
for (; ; *to++= *from++, length--)
{
if (!length)
{
*errors= 0;
return length2;
}
if (*((unsigned char*) from) > 0x7F) /* A non-ASCII character */
{
uint32 copied_length= length2 - length;
to_length-= copied_length;
from_length-= copied_length;
return copied_length + copy_and_convert_extended(to, to_length,
to_cs,
from, from_length,
from_cs,
errors);
}
}
DBUG_ASSERT(FALSE); // Should never get to here
return 0; // Make compiler happy
}
/*
copy a string,
with optional character set conversion,