summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/Makefile.am2
-rw-r--r--sql/field.cc365
-rw-r--r--sql/field.h126
-rw-r--r--sql/ha_heap.cc180
-rw-r--r--sql/init.cc17
-rw-r--r--sql/item.cc50
-rw-r--r--sql/item.h20
-rw-r--r--sql/item_cmpfunc.cc3
-rw-r--r--sql/item_create.cc5
-rw-r--r--sql/item_create.h1
-rw-r--r--sql/item_func.cc13
-rw-r--r--sql/item_func.h10
-rw-r--r--sql/item_strfunc.cc51
-rw-r--r--sql/item_strfunc.h25
-rw-r--r--sql/item_subselect.cc2
-rw-r--r--sql/item_timefunc.cc4
-rw-r--r--sql/item_timefunc.h4
-rw-r--r--sql/lex.h2
-rw-r--r--sql/mysql_priv.h10
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/opt_range.cc2
-rw-r--r--sql/share/charsets/Index7
-rw-r--r--sql/share/charsets/cp866.conf91
-rw-r--r--sql/share/charsets/dos.conf2
-rw-r--r--sql/share/charsets/keybcs2.conf91
-rw-r--r--sql/share/charsets/latvian.conf95
-rw-r--r--sql/share/charsets/latvian1.conf94
-rw-r--r--sql/share/charsets/macce.conf91
-rw-r--r--sql/share/charsets/macroman.conf91
-rw-r--r--sql/share/charsets/pclatin2.conf91
-rw-r--r--sql/spatial.cc11
-rw-r--r--sql/spatial.h2
-rw-r--r--sql/sql_base.cc4
-rw-r--r--sql/sql_handler.cc2
-rw-r--r--sql/sql_lex.h4
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_select.cc2
-rw-r--r--sql/sql_select.h4
-rw-r--r--sql/sql_select.h.rej96
-rw-r--r--sql/sql_show.cc4
-rw-r--r--sql/sql_table.cc45
-rw-r--r--sql/sql_yacc.yy18
-rw-r--r--sql/unireg.cc2
43 files changed, 1308 insertions, 435 deletions
diff --git a/sql/Makefile.am b/sql/Makefile.am
index 81fe927ce5a..9cfdf4c4d9b 100644
--- a/sql/Makefile.am
+++ b/sql/Makefile.am
@@ -56,7 +56,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
sql_select.h structs.h table.h sql_udf.h hash_filo.h\
lex.h lex_symbol.h sql_acl.h sql_crypt.h \
log_event.h mini_client.h sql_repl.h slave.h \
- stacktrace.h sql_sort.h sql_cache.h
+ stacktrace.h sql_sort.h sql_cache.h spatial.h gstream.h
mysqld_SOURCES = sql_lex.cc sql_handler.cc \
item.cc item_sum.cc item_buff.cc item_func.cc \
item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
diff --git a/sql/field.cc b/sql/field.cc
index a475612fbb0..462088d26a6 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -424,7 +424,7 @@ void Field_decimal::overflow(bool negative)
}
-void Field_decimal::store(const char *from,uint len,CHARSET_INFO *cs)
+int Field_decimal::store(const char *from,uint len,CHARSET_INFO *cs)
{
reg3 int i;
uint tmp_dec;
@@ -459,7 +459,7 @@ void Field_decimal::store(const char *from,uint len,CHARSET_INFO *cs)
if (!error)
current_thd->cuted_fields++;
Field_decimal::overflow(1);
- return;
+ return 1;
}
}
}
@@ -485,7 +485,7 @@ void Field_decimal::store(const char *from,uint len,CHARSET_INFO *cs)
current_thd->cuted_fields++;
// too big number, change to max or min number
Field_decimal::overflow(decstr.sign && decstr.sign_char == '-');
- return;
+ return 1;
}
char *to=ptr;
for (i=(int) (field_length-tmp_dec-decstr.nr_length-decstr.extra - decstr.sign) ;
@@ -520,16 +520,17 @@ void Field_decimal::store(const char *from,uint len,CHARSET_INFO *cs)
}
}
}
+ return (error) ? 1 : 0;
}
-void Field_decimal::store(double nr)
+int Field_decimal::store(double nr)
{
if (unsigned_flag && nr < 0)
{
overflow(1);
current_thd->cuted_fields++;
- return;
+ return 1;
}
reg4 uint i,length;
char fyllchar,*to;
@@ -548,6 +549,7 @@ void Field_decimal::store(double nr)
{
overflow(nr < 0.0);
current_thd->cuted_fields++;
+ return 1;
}
else
{
@@ -555,17 +557,18 @@ void Field_decimal::store(double nr)
for (i=field_length-length ; i-- > 0 ;)
*to++ = fyllchar;
memcpy(to,buff,length);
+ return 0;
}
}
-void Field_decimal::store(longlong nr)
+int Field_decimal::store(longlong nr)
{
if (unsigned_flag && nr < 0)
{
overflow(1);
current_thd->cuted_fields++;
- return;
+ return 1;
}
char buff[22];
uint length=(uint) (longlong10_to_str(nr,buff,-10)-buff);
@@ -575,6 +578,7 @@ void Field_decimal::store(longlong nr)
{
overflow(test(nr < 0L)); /* purecov: inspected */
current_thd->cuted_fields++; /* purecov: inspected */
+ return 1;
}
else
{
@@ -588,6 +592,7 @@ void Field_decimal::store(longlong nr)
to[length]='.';
bfill(to+length+1,dec,'0');
}
+ return 0;
}
}
@@ -704,10 +709,11 @@ void Field_decimal::sql_type(String &res) const
** tiny int
****************************************************************************/
-void Field_tiny::store(const char *from,uint len,CHARSET_INFO *cs)
+int Field_tiny::store(const char *from,uint len,CHARSET_INFO *cs)
{
String tmp_str(from,len,default_charset_info);
long tmp= strtol(tmp_str.c_ptr(),NULL,10);
+ int error=0;
if (unsigned_flag)
{
@@ -715,14 +721,19 @@ void Field_tiny::store(const char *from,uint len,CHARSET_INFO *cs)
{
tmp=0; /* purecov: inspected */
current_thd->cuted_fields++; /* purecov: inspected */
+ error = 1;
}
else if (tmp > 255)
{
tmp= 255;
current_thd->cuted_fields++;
+ error = 1;
}
else if (current_thd->count_cuted_fields && !test_if_int(from,len))
+ {
current_thd->cuted_fields++;
+ error = 1;
+ }
}
else
{
@@ -730,21 +741,28 @@ void Field_tiny::store(const char *from,uint len,CHARSET_INFO *cs)
{
tmp= -128;
current_thd->cuted_fields++;
+ error = 1;
}
else if (tmp >= 128)
{
tmp= 127;
current_thd->cuted_fields++;
+ error = 1;
}
else if (current_thd->count_cuted_fields && !test_if_int(from,len))
+ {
current_thd->cuted_fields++;
+ error = 1;
+ }
}
ptr[0]= (char) tmp;
+ return error;
}
-void Field_tiny::store(double nr)
+int Field_tiny::store(double nr)
{
+ int error=0;
nr=rint(nr);
if (unsigned_flag)
{
@@ -752,11 +770,13 @@ void Field_tiny::store(double nr)
{
*ptr=0;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr > 255.0)
{
*ptr=(char) 255;
current_thd->cuted_fields++;
+ error = 1;
}
else
*ptr=(char) nr;
@@ -767,30 +787,36 @@ void Field_tiny::store(double nr)
{
*ptr= (char) -128;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr > 127.0)
{
*ptr=127;
current_thd->cuted_fields++;
+ error = 1;
}
else
*ptr=(char) nr;
}
+ return error;
}
-void Field_tiny::store(longlong nr)
+int Field_tiny::store(longlong nr)
{
+ int error=0;
if (unsigned_flag)
{
if (nr < 0L)
{
*ptr=0;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr > 255L)
{
*ptr= (char) 255;
current_thd->cuted_fields++;
+ error = 1;
}
else
*ptr=(char) nr;
@@ -801,15 +827,18 @@ void Field_tiny::store(longlong nr)
{
*ptr= (char) -128;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr > 127L)
{
*ptr=127;
current_thd->cuted_fields++;
+ error = 1;
}
else
*ptr=(char) nr;
}
+ return error;
}
@@ -875,24 +904,30 @@ void Field_tiny::sql_type(String &res) const
// Note: Sometimes this should be fixed to use one strtol() to use
// len and check for garbage after number.
-void Field_short::store(const char *from,uint len,CHARSET_INFO *cs)
+int Field_short::store(const char *from,uint len,CHARSET_INFO *cs)
{
String tmp_str(from,len,default_charset_info);
long tmp= strtol(tmp_str.c_ptr(),NULL,10);
+ int error=0;
if (unsigned_flag)
{
if (tmp < 0)
{
tmp=0;
current_thd->cuted_fields++;
+ error = 1;
}
else if (tmp > (uint16) ~0)
{
tmp=(uint16) ~0;
current_thd->cuted_fields++;
+ error = 1;
}
else if (current_thd->count_cuted_fields && !test_if_int(from,len))
+ {
current_thd->cuted_fields++;
+ error = 1;
+ }
}
else
{
@@ -900,14 +935,19 @@ void Field_short::store(const char *from,uint len,CHARSET_INFO *cs)
{
tmp= INT_MIN16;
current_thd->cuted_fields++;
+ error = 1;
}
else if (tmp > INT_MAX16)
{
tmp=INT_MAX16;
current_thd->cuted_fields++;
+ error = 1;
}
else if (current_thd->count_cuted_fields && !test_if_int(from,len))
+ {
current_thd->cuted_fields++;
+ error = 1;
+ }
}
#ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first)
@@ -917,11 +957,13 @@ void Field_short::store(const char *from,uint len,CHARSET_INFO *cs)
else
#endif
shortstore(ptr,(short) tmp);
+ return error;
}
-void Field_short::store(double nr)
+int Field_short::store(double nr)
{
+ int error=0;
int16 res;
nr=rint(nr);
if (unsigned_flag)
@@ -930,11 +972,13 @@ void Field_short::store(double nr)
{
res=0;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr > (double) (uint16) ~0)
{
res=(int16) (uint16) ~0;
current_thd->cuted_fields++;
+ error = 1;
}
else
res=(int16) (uint16) nr;
@@ -945,11 +989,13 @@ void Field_short::store(double nr)
{
res=INT_MIN16;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr > (double) INT_MAX16)
{
res=INT_MAX16;
current_thd->cuted_fields++;
+ error = 1;
}
else
res=(int16) nr;
@@ -962,10 +1008,12 @@ void Field_short::store(double nr)
else
#endif
shortstore(ptr,res);
+ return error;
}
-void Field_short::store(longlong nr)
+int Field_short::store(longlong nr)
{
+ int error=0;
int16 res;
if (unsigned_flag)
{
@@ -973,11 +1021,13 @@ void Field_short::store(longlong nr)
{
res=0;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr > (longlong) (uint16) ~0)
{
res=(int16) (uint16) ~0;
current_thd->cuted_fields++;
+ error = 1;
}
else
res=(int16) (uint16) nr;
@@ -988,11 +1038,13 @@ void Field_short::store(longlong nr)
{
res=INT_MIN16;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr > INT_MAX16)
{
res=INT_MAX16;
current_thd->cuted_fields++;
+ error = 1;
}
else
res=(int16) nr;
@@ -1005,6 +1057,7 @@ void Field_short::store(longlong nr)
else
#endif
shortstore(ptr,res);
+ return error;
}
@@ -1115,10 +1168,11 @@ void Field_short::sql_type(String &res) const
// Note: Sometimes this should be fixed to use one strtol() to use
// len and check for garbage after number.
-void Field_medium::store(const char *from,uint len,CHARSET_INFO *cs)
+int Field_medium::store(const char *from,uint len,CHARSET_INFO *cs)
{
String tmp_str(from,len,default_charset_info);
long tmp= strtol(tmp_str.c_ptr(),NULL,10);
+ int error=0;
if (unsigned_flag)
{
@@ -1126,14 +1180,19 @@ void Field_medium::store(const char *from,uint len,CHARSET_INFO *cs)
{
tmp=0;
current_thd->cuted_fields++;
+ error = 1;
}
else if (tmp >= (long) (1L << 24))
{
tmp=(long) (1L << 24)-1L;
current_thd->cuted_fields++;
+ error = 1;
}
else if (current_thd->count_cuted_fields && !test_if_int(from,len))
+ {
current_thd->cuted_fields++;
+ error = 1;
+ }
}
else
{
@@ -1141,22 +1200,29 @@ void Field_medium::store(const char *from,uint len,CHARSET_INFO *cs)
{
tmp= INT_MIN24;
current_thd->cuted_fields++;
+ error = 1;
}
else if (tmp > INT_MAX24)
{
tmp=INT_MAX24;
current_thd->cuted_fields++;
+ error = 1;
}
else if (current_thd->count_cuted_fields && !test_if_int(from,len))
+ {
current_thd->cuted_fields++;
+ error = 1;
+ }
}
int3store(ptr,tmp);
+ return error;
}
-void Field_medium::store(double nr)
+int Field_medium::store(double nr)
{
+ int error=0;
nr=rint(nr);
if (unsigned_flag)
{
@@ -1164,12 +1230,14 @@ void Field_medium::store(double nr)
{
int3store(ptr,0);
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr >= (double) (long) (1L << 24))
{
uint32 tmp=(uint32) (1L << 24)-1L;
int3store(ptr,tmp);
current_thd->cuted_fields++;
+ error = 1;
}
else
int3store(ptr,(uint32) nr);
@@ -1181,32 +1249,38 @@ void Field_medium::store(double nr)
long tmp=(long) INT_MIN24;
int3store(ptr,tmp);
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr > (double) INT_MAX24)
{
long tmp=(long) INT_MAX24;
int3store(ptr,tmp);
current_thd->cuted_fields++;
+ error = 1;
}
else
int3store(ptr,(long) nr);
}
+ return error;
}
-void Field_medium::store(longlong nr)
+int Field_medium::store(longlong nr)
{
+ int error=0;
if (unsigned_flag)
{
if (nr < 0L)
{
int3store(ptr,0);
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr >= (longlong) (long) (1L << 24))
{
long tmp=(long) (1L << 24)-1L;;
int3store(ptr,tmp);
current_thd->cuted_fields++;
+ error = 1;
}
else
int3store(ptr,(uint32) nr);
@@ -1218,16 +1292,19 @@ void Field_medium::store(longlong nr)
long tmp=(long) INT_MIN24;
int3store(ptr,tmp);
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr > (longlong) INT_MAX24)
{
long tmp=(long) INT_MAX24;
int3store(ptr,tmp);
current_thd->cuted_fields++;
+ error = 1;
}
else
int3store(ptr,(long) nr);
}
+ return error;
}
@@ -1300,13 +1377,14 @@ void Field_medium::sql_type(String &res) const
// Note: Sometimes this should be fixed to use one strtol() to use
// len and check for garbage after number.
-void Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
+int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
{
while (len && my_isspace(system_charset_info,*from))
{
len--; from++;
}
long tmp;
+ int error=0;
String tmp_str(from,len,default_charset_info);
errno=0;
if (unsigned_flag)
@@ -1315,6 +1393,7 @@ void Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
{
tmp=0; // Set negative to 0
errno=ERANGE;
+ error = 1;
}
else
tmp=(long) strtoul(tmp_str.c_ptr(),NULL,10);
@@ -1322,7 +1401,10 @@ void Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
else
tmp=strtol(tmp_str.c_ptr(),NULL,10);
if (errno || current_thd->count_cuted_fields && !test_if_int(from,len))
+ {
current_thd->cuted_fields++;
+ error = 1;
+ }
#ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first)
{
@@ -1331,11 +1413,13 @@ void Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
else
#endif
longstore(ptr,tmp);
+ return error;
}
-void Field_long::store(double nr)
+int Field_long::store(double nr)
{
+ int error=0;
int32 res;
nr=rint(nr);
if (unsigned_flag)
@@ -1344,11 +1428,13 @@ void Field_long::store(double nr)
{
res=0;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr > (double) (ulong) ~0L)
{
res=(int32) (uint32) ~0L;
current_thd->cuted_fields++;
+ error = 1;
}
else
res=(int32) (ulong) nr;
@@ -1359,11 +1445,13 @@ void Field_long::store(double nr)
{
res=(int32) INT_MIN32;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr > (double) INT_MAX32)
{
res=(int32) INT_MAX32;
current_thd->cuted_fields++;
+ error = 1;
}
else
res=(int32) nr;
@@ -1376,11 +1464,13 @@ void Field_long::store(double nr)
else
#endif
longstore(ptr,res);
+ return error;
}
-void Field_long::store(longlong nr)
+int Field_long::store(longlong nr)
{
+ int error=0;
int32 res;
if (unsigned_flag)
{
@@ -1388,11 +1478,13 @@ void Field_long::store(longlong nr)
{
res=0;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr >= (LL(1) << 32))
{
res=(int32) (uint32) ~0L;
current_thd->cuted_fields++;
+ error = 1;
}
else
res=(int32) (uint32) nr;
@@ -1403,11 +1495,13 @@ void Field_long::store(longlong nr)
{
res=(int32) INT_MIN32;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr > (longlong) INT_MAX32)
{
res=(int32) INT_MAX32;
current_thd->cuted_fields++;
+ error = 1;
}
else
res=(int32) nr;
@@ -1420,6 +1514,7 @@ void Field_long::store(longlong nr)
else
#endif
longstore(ptr,res);
+ return error;
}
@@ -1528,7 +1623,7 @@ void Field_long::sql_type(String &res) const
** longlong int
****************************************************************************/
-void Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
+int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
{
while (len && my_isspace(system_charset_info,*from))
{ // For easy error check
@@ -1536,6 +1631,7 @@ void Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
}
longlong tmp;
String tmp_str(from,len,default_charset_info);
+ int error=0;
errno=0;
if (unsigned_flag)
{
@@ -1543,6 +1639,7 @@ void Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
{
tmp=0; // Set negative to 0
errno=ERANGE;
+ error = 1;
}
else
tmp=(longlong) strtoull(tmp_str.c_ptr(),NULL,10);
@@ -1550,7 +1647,10 @@ void Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
else
tmp=strtoll(tmp_str.c_ptr(),NULL,10);
if (errno || current_thd->count_cuted_fields && !test_if_int(from,len))
+ {
current_thd->cuted_fields++;
+ error = 1;
+ }
#ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first)
{
@@ -1559,11 +1659,13 @@ void Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
else
#endif
longlongstore(ptr,tmp);
+ return error;
}
-void Field_longlong::store(double nr)
+int Field_longlong::store(double nr)
{
+ int error=0;
longlong res;
nr=rint(nr);
if (unsigned_flag)
@@ -1572,11 +1674,13 @@ void Field_longlong::store(double nr)
{
res=0;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr >= (double) ~ (ulonglong) 0)
{
res= ~(longlong) 0;
current_thd->cuted_fields++;
+ error = 1;
}
else
res=(longlong) (ulonglong) nr;
@@ -1587,11 +1691,13 @@ void Field_longlong::store(double nr)
{
res=(longlong) LONGLONG_MIN;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr >= (double) LONGLONG_MAX)
{
res=(longlong) LONGLONG_MAX;
current_thd->cuted_fields++;
+ error = 1;
}
else
res=(longlong) nr;
@@ -1604,10 +1710,11 @@ void Field_longlong::store(double nr)
else
#endif
longlongstore(ptr,res);
+ return error;
}
-void Field_longlong::store(longlong nr)
+int Field_longlong::store(longlong nr)
{
#ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first)
@@ -1617,6 +1724,7 @@ void Field_longlong::store(longlong nr)
else
#endif
longlongstore(ptr,nr);
+ return 0;
}
@@ -1735,35 +1843,43 @@ void Field_longlong::sql_type(String &res) const
** single precision float
****************************************************************************/
-void Field_float::store(const char *from,uint len,CHARSET_INFO *cs)
+int Field_float::store(const char *from,uint len,CHARSET_INFO *cs)
{
String tmp_str(from,len,default_charset_info);
errno=0;
Field_float::store(atof(tmp_str.c_ptr()));
if (errno || current_thd->count_cuted_fields && !test_if_real(from,len))
+ {
current_thd->cuted_fields++;
+ return 1;
+ }
+ return (errno) ? 1 : 0;
}
-void Field_float::store(double nr)
+int Field_float::store(double nr)
{
float j;
+ int error=0;
if (dec < NOT_FIXED_DEC)
nr=floor(nr*log_10[dec]+0.5)/log_10[dec]; // To fixed point
if (unsigned_flag && nr < 0)
{
current_thd->cuted_fields++;
nr=0;
+ error = 1;
}
if (nr < -FLT_MAX)
{
j= -FLT_MAX;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr > FLT_MAX)
{
j=FLT_MAX;
current_thd->cuted_fields++;
+ error = 1;
}
else
j= (float) nr;
@@ -1775,16 +1891,19 @@ void Field_float::store(double nr)
else
#endif
memcpy_fixed(ptr,(byte*) &j,sizeof(j));
+ return error;
}
-void Field_float::store(longlong nr)
+int Field_float::store(longlong nr)
{
+ int error=0;
float j= (float) nr;
if (unsigned_flag && j < 0)
{
current_thd->cuted_fields++;
j=0;
+ error = 1;
}
#ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first)
@@ -1794,6 +1913,7 @@ void Field_float::store(longlong nr)
else
#endif
memcpy_fixed(ptr,(byte*) &j,sizeof(j));
+ return error;
}
@@ -1985,17 +2105,22 @@ void Field_float::sql_type(String &res) const
** double precision floating point numbers
****************************************************************************/
-void Field_double::store(const char *from,uint len,CHARSET_INFO *cs)
+int Field_double::store(const char *from,uint len,CHARSET_INFO *cs)
{
String tmp_str(from,len,default_charset_info);
errno=0;
+ int error=0;
double j= atof(tmp_str.c_ptr());
if (errno || current_thd->count_cuted_fields && !test_if_real(from,len))
+ {
current_thd->cuted_fields++;
+ error = 1;
+ }
if (unsigned_flag && j < 0)
{
current_thd->cuted_fields++;
j=0;
+ error = 1;
}
#ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first)
@@ -2005,17 +2130,20 @@ void Field_double::store(const char *from,uint len,CHARSET_INFO *cs)
else
#endif
doublestore(ptr,j);
+ return error;
}
-void Field_double::store(double nr)
+int Field_double::store(double nr)
{
+ int error=0;
if (dec < NOT_FIXED_DEC)
nr=floor(nr*log_10[dec]+0.5)/log_10[dec]; // To fixed point
if (unsigned_flag && nr < 0)
{
current_thd->cuted_fields++;
nr=0;
+ error = 1;
}
#ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first)
@@ -2025,15 +2153,18 @@ void Field_double::store(double nr)
else
#endif
doublestore(ptr,nr);
+ return error;
}
-void Field_double::store(longlong nr)
+int Field_double::store(longlong nr)
{
double j= (double) nr;
+ int error=0;
if (unsigned_flag && j < 0)
{
current_thd->cuted_fields++;
+ error = 1;
j=0;
}
#ifdef WORDS_BIGENDIAN
@@ -2044,6 +2175,7 @@ void Field_double::store(longlong nr)
else
#endif
doublestore(ptr,j);
+ return error;
}
@@ -2241,7 +2373,7 @@ Field_timestamp::Field_timestamp(char *ptr_arg, uint32 len_arg,
}
-void Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
+int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
{
long tmp=(long) str_to_timestamp(from,len);
#ifdef WORDS_BIGENDIAN
@@ -2252,9 +2384,10 @@ void Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
else
#endif
longstore(ptr,tmp);
+ return 0;
}
-void Field_timestamp::fill_and_store(char *from,uint len)
+void Field_timestamp::fill_and_store(char *from,uint len)
{
uint res_length;
if (len <= field_length)
@@ -2283,14 +2416,17 @@ void Field_timestamp::fill_and_store(char *from,uint len)
}
-void Field_timestamp::store(double nr)
+int Field_timestamp::store(double nr)
{
+ int error=0;
if (nr < 0 || nr > 99991231235959.0)
{
nr=0; // Avoid overflow on buff
current_thd->cuted_fields++;
+ error = 1;
}
- Field_timestamp::store((longlong) rint(nr));
+ error |= Field_timestamp::store((longlong) rint(nr));
+ return error;
}
@@ -2331,7 +2467,7 @@ static longlong fix_datetime(longlong nr)
}
-void Field_timestamp::store(longlong nr)
+int Field_timestamp::store(longlong nr)
{
TIME l_time;
time_t timestamp;
@@ -2359,6 +2495,7 @@ void Field_timestamp::store(longlong nr)
else
#endif
longstore(ptr,(uint32) timestamp);
+ return 0;
}
@@ -2580,12 +2717,16 @@ void Field_timestamp::set_time()
** Stored as a 3 byte unsigned int
****************************************************************************/
-void Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
+int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
{
TIME ltime;
long tmp;
+ int error=0;
if (str_to_time(from,len,&ltime))
+ {
tmp=0L;
+ error = 1;
+ }
else
{
if (ltime.month)
@@ -2595,26 +2736,31 @@ void Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
{
tmp=8385959;
current_thd->cuted_fields++;
+ error = 1;
}
}
if (ltime.neg)
tmp= -tmp;
- Field_time::store((longlong) tmp);
+ error |= Field_time::store((longlong) tmp);
+ return error;
}
-void Field_time::store(double nr)
+int Field_time::store(double nr)
{
long tmp;
+ int error=0;
if (nr > 8385959.0)
{
tmp=8385959L;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr < -8385959.0)
{
tmp= -8385959L;
current_thd->cuted_fields++;
+ error = 1;
}
else
{
@@ -2625,24 +2771,29 @@ void Field_time::store(double nr)
{
tmp=0;
current_thd->cuted_fields++;
+ error = 1;
}
}
int3store(ptr,tmp);
+ return error;
}
-void Field_time::store(longlong nr)
+int Field_time::store(longlong nr)
{
long tmp;
+ int error=0;
if (nr > (longlong) 8385959L)
{
tmp=8385959L;
current_thd->cuted_fields++;
+ error = 1;
}
else if (nr < (longlong) -8385959L)
{
tmp= -8385959L;
current_thd->cuted_fields++;
+ error = 1;
}
else
{
@@ -2651,9 +2802,11 @@ void Field_time::store(longlong nr)
{
tmp=0;
current_thd->cuted_fields++;
+ error = 1;
}
}
int3store(ptr,tmp);
+ return error;
}
@@ -2729,7 +2882,7 @@ void Field_time::sql_type(String &res) const
** Can handle 2 byte or 4 byte years!
****************************************************************************/
-void Field_year::store(const char *from, uint len,CHARSET_INFO *cs)
+int Field_year::store(const char *from, uint len,CHARSET_INFO *cs)
{
String tmp_str(from,len,default_charset_info);
long nr= strtol(tmp_str.c_ptr(),NULL,10);
@@ -2738,7 +2891,7 @@ void Field_year::store(const char *from, uint len,CHARSET_INFO *cs)
{
*ptr=0;
current_thd->cuted_fields++;
- return;
+ return 1;
}
else if (current_thd->count_cuted_fields && !test_if_int(from,len))
current_thd->cuted_fields++;
@@ -2750,23 +2903,27 @@ void Field_year::store(const char *from, uint len,CHARSET_INFO *cs)
nr-= 1900;
}
*ptr= (char) (unsigned char) nr;
+ return 0;
}
-void Field_year::store(double nr)
+int Field_year::store(double nr)
{
if (nr < 0.0 || nr >= 2155.0)
- Field_year::store((longlong) -1);
+ {
+ (void) Field_year::store((longlong) -1);
+ return 1;
+ }
else
- Field_year::store((longlong) nr);
+ return Field_year::store((longlong) nr);
}
-void Field_year::store(longlong nr)
+int Field_year::store(longlong nr)
{
if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155)
{
*ptr=0;
current_thd->cuted_fields++;
- return;
+ return 1;
}
if (nr != 0 || field_length != 4) // 0000 -> 0; 00 -> 2000
{
@@ -2776,6 +2933,7 @@ void Field_year::store(longlong nr)
nr-= 1900;
}
*ptr= (char) (unsigned char) nr;
+ return 0;
}
@@ -2818,12 +2976,16 @@ void Field_year::sql_type(String &res) const
** Stored as a 4 byte unsigned int
****************************************************************************/
-void Field_date::store(const char *from, uint len,CHARSET_INFO *cs)
+int Field_date::store(const char *from, uint len,CHARSET_INFO *cs)
{
TIME l_time;
uint32 tmp;
+ int error=0;
if (str_to_TIME(from,len,&l_time,1) == TIMESTAMP_NONE)
+ {
tmp=0;
+ error = 1;
+ }
else
tmp=(uint32) l_time.year*10000L + (uint32) (l_time.month*100+l_time.day);
#ifdef WORDS_BIGENDIAN
@@ -2834,18 +2996,21 @@ void Field_date::store(const char *from, uint len,CHARSET_INFO *cs)
else
#endif
longstore(ptr,tmp);
+ return error;
}
-void Field_date::store(double nr)
+int Field_date::store(double nr)
{
long tmp;
+ int error=0;
if (nr >= 19000000000000.0 && nr <= 99991231235959.0)
nr=floor(nr/1000000.0); // Timestamp to date
if (nr < 0.0 || nr > 99991231.0)
{
tmp=0L;
current_thd->cuted_fields++;
+ error = 1;
}
else
tmp=(long) rint(nr);
@@ -2857,18 +3022,21 @@ void Field_date::store(double nr)
else
#endif
longstore(ptr,tmp);
+ return error;
}
-void Field_date::store(longlong nr)
+int Field_date::store(longlong nr)
{
long tmp;
+ int error=0;
if (nr >= LL(19000000000000) && nr < LL(99991231235959))
nr=nr/LL(1000000); // Timestamp to date
if (nr < 0 || nr > LL(99991231))
{
tmp=0L;
current_thd->cuted_fields++;
+ error = 1;
}
else
tmp=(long) nr;
@@ -2880,6 +3048,7 @@ void Field_date::store(longlong nr)
else
#endif
longstore(ptr,tmp);
+ return error;
}
@@ -2975,35 +3144,45 @@ void Field_date::sql_type(String &res) const
** In number context: YYYYMMDD
****************************************************************************/
-void Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
+int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
{
TIME l_time;
long tmp;
+ int error=0;
if (str_to_TIME(from,len,&l_time,1) == TIMESTAMP_NONE)
+ {
tmp=0L;
+ error = 1;
+ }
else
tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
int3store(ptr,tmp);
+ return error;
}
-void Field_newdate::store(double nr)
+int Field_newdate::store(double nr)
{
if (nr < 0.0 || nr > 99991231235959.0)
- Field_newdate::store((longlong) -1);
+ {
+ (void) Field_newdate::store((longlong) -1);
+ return 1;
+ }
else
- Field_newdate::store((longlong) rint(nr));
+ return Field_newdate::store((longlong) rint(nr));
}
-void Field_newdate::store(longlong nr)
+int Field_newdate::store(longlong nr)
{
int32 tmp;
+ int error=0;
if (nr >= LL(100000000) && nr <= LL(99991231235959))
nr=nr/LL(1000000); // Timestamp to date
if (nr < 0L || nr > 99991231L)
{
tmp=0;
current_thd->cuted_fields++;
+ error = 1;
}
else
{
@@ -3021,11 +3200,13 @@ void Field_newdate::store(longlong nr)
{
tmp=0L; // Don't allow date to change
current_thd->cuted_fields++;
+ error = 1;
}
else
tmp= day + month*32 + (tmp/10000)*16*32;
}
int3store(ptr,(int32) tmp);
+ return error;
}
void Field_newdate::store_time(TIME *ltime,timestamp_type type)
@@ -3128,7 +3309,7 @@ void Field_newdate::sql_type(String &res) const
** Stored as a 8 byte unsigned int. Should sometimes be change to a 6 byte int.
****************************************************************************/
-void Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs)
+int Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs)
{
longlong tmp=str_to_datetime(from,len,1);
#ifdef WORDS_BIGENDIAN
@@ -3139,26 +3320,32 @@ void Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs)
else
#endif
longlongstore(ptr,tmp);
+ return 0;
}
-void Field_datetime::store(double nr)
+int Field_datetime::store(double nr)
{
+ int error=0;
if (nr < 0.0 || nr > 99991231235959.0)
{
nr=0.0;
current_thd->cuted_fields++;
+ error = 1;
}
- Field_datetime::store((longlong) rint(nr));
+ error |= Field_datetime::store((longlong) rint(nr));
+ return error;
}
-void Field_datetime::store(longlong nr)
+int Field_datetime::store(longlong nr)
{
+ int error=0;
if (nr < 0 || nr > LL(99991231235959))
{
nr=0;
current_thd->cuted_fields++;
+ error = 1;
}
else
nr=fix_datetime(nr);
@@ -3170,6 +3357,7 @@ void Field_datetime::store(longlong nr)
else
#endif
longlongstore(ptr,nr);
+ return error;
}
void Field_datetime::store_time(TIME *ltime,timestamp_type type)
@@ -3344,9 +3532,10 @@ void Field_datetime::sql_type(String &res) const
/* Copy a string and fill with space */
-void Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
+int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
{
field_charset=cs;
+ int error=0;
#ifdef USE_TIS620
if(!binary_flag) {
ThNormalize((uchar *)ptr, field_length, (uchar *)from, length);
@@ -3372,30 +3561,32 @@ void Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
if (!my_isspace(field_charset,*from))
{
current_thd->cuted_fields++;
+ error=1;
break;
}
}
}
}
#endif /* USE_TIS620 */
+ return error;
}
-void Field_string::store(double nr)
+int Field_string::store(double nr)
{
char buff[MAX_FIELD_WIDTH],*end;
int width=min(field_length,DBL_DIG+5);
sprintf(buff,"%-*.*g",width,max(width-5,0),nr);
end=strcend(buff,' ');
- Field_string::store(buff,(uint) (end - buff), default_charset_info);
+ return Field_string::store(buff,(uint) (end - buff), default_charset_info);
}
-void Field_string::store(longlong nr)
+int Field_string::store(longlong nr)
{
char buff[22];
char *end=longlong10_to_str(nr,buff,-10);
- Field_string::store(buff,(uint) (end-buff), default_charset_info);
+ return Field_string::store(buff,(uint) (end-buff), default_charset_info);
}
@@ -3554,8 +3745,9 @@ uint Field_string::max_packed_col_length(uint max_length)
****************************************************************************/
-void Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
+int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
{
+ int error=0;
field_charset=cs;
#ifdef USE_TIS620
if(!binary_flag)
@@ -3572,27 +3764,29 @@ void Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
length=field_length;
memcpy(ptr+2,from,field_length);
current_thd->cuted_fields++;
+ error = 1;
}
#endif /* USE_TIS620 */
int2store(ptr,length);
+ return error;
}
-void Field_varstring::store(double nr)
+int Field_varstring::store(double nr)
{
char buff[MAX_FIELD_WIDTH],*end;
int width=min(field_length,DBL_DIG+5);
sprintf(buff,"%-*.*g",width,max(width-5,0),nr);
end=strcend(buff,' ');
- Field_varstring::store(buff,(uint) (end - buff), default_charset_info);
+ return Field_varstring::store(buff,(uint) (end - buff), default_charset_info);
}
-void Field_varstring::store(longlong nr)
+int Field_varstring::store(longlong nr)
{
char buff[22];
char *end=longlong10_to_str(nr,buff,-10);
- Field_varstring::store(buff,(uint) (end-buff), default_charset_info);
+ return Field_varstring::store(buff,(uint) (end-buff), default_charset_info);
}
@@ -3877,7 +4071,7 @@ uint32 Field_blob::get_length(const char *pos)
}
-void Field_blob::store(const char *from,uint len,CHARSET_INFO *cs)
+int Field_blob::store(const char *from,uint len,CHARSET_INFO *cs)
{
field_charset=cs;
if (!len)
@@ -3911,20 +4105,21 @@ void Field_blob::store(const char *from,uint len,CHARSET_INFO *cs)
}
bmove(ptr+packlength,(char*) &from,sizeof(char*));
}
+ return 0;
}
-void Field_blob::store(double nr)
+int Field_blob::store(double nr)
{
value.set(nr);
- Field_blob::store(value.ptr(),(uint) value.length(), default_charset_info);
+ return Field_blob::store(value.ptr(),(uint) value.length(), default_charset_info);
}
-void Field_blob::store(longlong nr)
+int Field_blob::store(longlong nr)
{
value.set(nr);
- Field_blob::store(value.ptr(), (uint) value.length(), default_charset_info);
+ return Field_blob::store(value.ptr(), (uint) value.length(), default_charset_info);
}
@@ -4071,7 +4266,7 @@ void Field_blob::get_key_image(char *buff,uint length, imagetype type)
void Field_blob::set_key_image(char *buff,uint length)
{
length=uint2korr(buff);
- Field_blob::store(buff+2,length, default_charset_info);
+ (void) Field_blob::store(buff+2,length, default_charset_info);
}
void Field_geom::get_key_image(char *buff,uint length, imagetype type)
@@ -4392,8 +4587,9 @@ uint find_enum(TYPELIB *lib,const char *x, uint length)
** (if there isn't a empty value in the enum)
*/
-void Field_enum::store(const char *from,uint length,CHARSET_INFO *cs)
+int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs)
{
+ int error=0;
uint tmp=find_enum(typelib,from,length);
if (!tmp)
{
@@ -4413,29 +4609,34 @@ void Field_enum::store(const char *from,uint length,CHARSET_INFO *cs)
{
tmp=0;
current_thd->cuted_fields++;
+ error=1;
}
}
else
current_thd->cuted_fields++;
}
store_type((ulonglong) tmp);
+ return error;
}
-void Field_enum::store(double nr)
+int Field_enum::store(double nr)
{
- Field_enum::store((longlong) nr);
+ return Field_enum::store((longlong) nr);
}
-void Field_enum::store(longlong nr)
+int Field_enum::store(longlong nr)
{
+ int error=0;
if ((uint) nr > typelib->count || nr == 0)
{
current_thd->cuted_fields++;
nr=0;
+ error=1;
}
store_type((ulonglong) (uint) nr);
+ return error;
}
@@ -4583,8 +4784,9 @@ ulonglong find_set(TYPELIB *lib,const char *x,uint length)
}
-void Field_set::store(const char *from,uint length,CHARSET_INFO *cs)
+int Field_set::store(const char *from,uint length,CHARSET_INFO *cs)
{
+ int error=0;
ulonglong tmp=find_set(typelib,from,length);
if (!tmp && length && length < 22)
{
@@ -4600,23 +4802,30 @@ void Field_set::store(const char *from,uint length,CHARSET_INFO *cs)
tmp=strtoull(conv,&end,10);
if (my_errno || end != conv+length ||
tmp > (ulonglong) (((longlong) 1 << typelib->count) - (longlong) 1))
+ {
tmp=0;
+ error=1;
+ }
else
current_thd->cuted_fields--; // Remove warning from find_set
}
store_type(tmp);
+ return error;
}
-void Field_set::store(longlong nr)
+int Field_set::store(longlong nr)
{
+ int error=0;
if ((ulonglong) nr > (ulonglong) (((longlong) 1 << typelib->count) -
(longlong) 1))
{
nr&= (longlong) (((longlong) 1 << typelib->count) - (longlong) 1);
current_thd->cuted_fields++;
+ error=1;
}
store_type((ulonglong) nr);
+ return error;
}
diff --git a/sql/field.h b/sql/field.h
index 5bc463af48d..88187b2b7aa 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -60,9 +60,9 @@ public:
utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg);
virtual ~Field() {}
- virtual void store(const char *to,uint length,CHARSET_INFO *cs)=0;
- virtual void store(double nr)=0;
- virtual void store(longlong nr)=0;
+ virtual int store(const char *to,uint length,CHARSET_INFO *cs)=0;
+ virtual int store(double nr)=0;
+ virtual int store(longlong nr)=0;
virtual void store_time(TIME *ltime,timestamp_type t_type);
virtual double val_real(void)=0;
virtual longlong val_int(void)=0;
@@ -281,9 +281,9 @@ public:
enum ha_base_keytype key_type() const
{ return zerofill ? HA_KEYTYPE_BINARY : HA_KEYTYPE_NUM; }
void reset(void);
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -310,9 +310,9 @@ public:
enum_field_types type() const { return FIELD_TYPE_TINY;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_BINARY : HA_KEYTYPE_INT8; }
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
void reset(void) { ptr[0]=0; }
double val_real(void);
longlong val_int(void);
@@ -339,9 +339,9 @@ public:
enum_field_types type() const { return FIELD_TYPE_SHORT;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_USHORT_INT : HA_KEYTYPE_SHORT_INT;}
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=0; }
double val_real(void);
longlong val_int(void);
@@ -368,9 +368,9 @@ public:
enum_field_types type() const { return FIELD_TYPE_INT24;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_UINT24 : HA_KEYTYPE_INT24; }
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
double val_real(void);
longlong val_int(void);
@@ -402,9 +402,9 @@ public:
enum_field_types type() const { return FIELD_TYPE_LONG;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_ULONG_INT : HA_KEYTYPE_LONG_INT; }
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
double val_real(void);
longlong val_int(void);
@@ -438,9 +438,9 @@ public:
enum_field_types type() const { return FIELD_TYPE_LONGLONG;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_ULONGLONG : HA_KEYTYPE_LONGLONG; }
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; }
double val_real(void);
longlong val_int(void);
@@ -465,9 +465,9 @@ public:
{}
enum_field_types type() const { return FIELD_TYPE_FLOAT;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_FLOAT; }
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
void reset(void) { bzero(ptr,sizeof(float)); }
double val_real(void);
longlong val_int(void);
@@ -497,9 +497,9 @@ public:
{}
enum_field_types type() const { return FIELD_TYPE_DOUBLE;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_DOUBLE; }
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
void reset(void) { bzero(ptr,sizeof(double)); }
double val_real(void);
longlong val_int(void);
@@ -523,9 +523,9 @@ public:
unireg_check_arg, field_name_arg, table_arg, default_charset_info)
{}
enum_field_types type() const { return FIELD_TYPE_NULL;}
- void store(const char *to, uint length, CHARSET_INFO *cs) { null[0]=1; }
- void store(double nr) { null[0]=1; }
- void store(longlong nr) { null[0]=1; }
+ int store(const char *to, uint length, CHARSET_INFO *cs) { null[0]=1; return 0; }
+ int store(double nr) { null[0]=1; return 0; }
+ int store(longlong nr) { null[0]=1; return 0; }
void reset(void) {}
double val_real(void) { return 0.0;}
longlong val_int(void) { return 0;}
@@ -547,9 +547,9 @@ public:
enum Item_result result_type () const { return field_length == 8 || field_length == 14 ? INT_RESULT : STRING_RESULT; }
enum_field_types type() const { return FIELD_TYPE_TIMESTAMP;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
double val_real(void);
longlong val_int(void);
@@ -587,9 +587,9 @@ public:
unireg_check_arg, field_name_arg, table_arg, 1, 1)
{}
enum_field_types type() const { return FIELD_TYPE_YEAR;}
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -612,9 +612,9 @@ public:
enum_field_types type() const { return FIELD_TYPE_DATE;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
enum Item_result cmp_type () const { return INT_RESULT; }
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
double val_real(void);
longlong val_int(void);
@@ -639,9 +639,9 @@ public:
enum_field_types real_type() const { return FIELD_TYPE_NEWDATE; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_UINT24; }
enum Item_result cmp_type () const { return INT_RESULT; }
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
void store_time(TIME *ltime,timestamp_type type);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
double val_real(void);
@@ -673,9 +673,9 @@ public:
enum_field_types type() const { return FIELD_TYPE_TIME;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
enum Item_result cmp_type () const { return INT_RESULT; }
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
double val_real(void);
longlong val_int(void);
@@ -707,9 +707,9 @@ public:
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
#endif
enum Item_result cmp_type () const { return INT_RESULT; }
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
void store_time(TIME *ltime,timestamp_type type);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; }
double val_real(void);
@@ -761,9 +761,9 @@ public:
bool zero_pack() const { return 0; }
bool binary() const { return binary_flag; }
void reset(void) { bfill(ptr,field_length,' '); }
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -813,9 +813,9 @@ public:
void reset(void) { bzero(ptr,field_length+2); }
uint32 pack_length() const { return (uint32) field_length+2; }
uint32 key_length() const { return (uint32) field_length; }
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -856,9 +856,9 @@ public:
enum_field_types type() const { return FIELD_TYPE_BLOB;}
enum ha_base_keytype key_type() const
{ return binary_flag ? HA_KEYTYPE_VARBINARY : HA_KEYTYPE_VARTEXT; }
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -962,9 +962,9 @@ public:
enum_field_types type() const { return FIELD_TYPE_STRING; }
enum Item_result cmp_type () const { return INT_RESULT; }
enum ha_base_keytype key_type() const;
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr);
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr);
void reset() { bzero(ptr,packlength); }
double val_real(void);
longlong val_int(void);
@@ -997,9 +997,9 @@ public:
{
flags=(flags & ~ENUM_FLAG) | SET_FLAG;
}
- void store(const char *to,uint length,CHARSET_INFO *charset);
- void store(double nr) { Field_set::store((longlong) nr); }
- void store(longlong nr);
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr) { return Field_set::store((longlong) nr); }
+ int store(longlong nr);
virtual bool zero_pack() const { return 1; }
String *val_str(String*,String *);
void sql_type(String &str) const;
diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc
index 70409be4e42..f56bfe74265 100644
--- a/sql/ha_heap.cc
+++ b/sql/ha_heap.cc
@@ -33,92 +33,12 @@ const char **ha_heap::bas_ext() const
int ha_heap::open(const char *name, int mode, uint test_if_locked)
{
- uint key,parts,mem_per_row=0;
- ulong max_rows;
- HP_KEYDEF *keydef;
- HA_KEYSEG *seg;
-
- for (key=parts=0 ; key < table->keys ; key++)
+ if (!(file= heap_open(name, mode)) && my_errno == ENOENT)
{
- parts+=table->key_info[key].key_parts;
- if (table->key_info[key].algorithm == HA_KEY_ALG_BTREE)
- parts++; /* additional HA_KEYTYPE_END keyseg */
+ if (!create(name, table, NULL))
+ file= heap_open(name, mode);
}
-
- if (!(keydef=(HP_KEYDEF*) my_malloc(table->keys*sizeof(HP_KEYDEF)+
- parts*sizeof(HA_KEYSEG),MYF(MY_WME))))
- return my_errno;
- seg=my_reinterpret_cast(HA_KEYSEG*) (keydef+table->keys);
- for (key=0 ; key < table->keys ; key++)
- {
- KEY *pos=table->key_info+key;
- KEY_PART_INFO *key_part= pos->key_part;
- KEY_PART_INFO *key_part_end= key_part + pos->key_parts;
-
- mem_per_row+= (pos->key_length + (sizeof(char*) * 2));
-
- keydef[key].keysegs= (uint) pos->key_parts;
- keydef[key].flag= (pos->flags & (HA_NOSAME | HA_NULL_ARE_EQUAL));
- keydef[key].seg= seg;
- keydef[key].algorithm= pos->algorithm == HA_KEY_ALG_UNDEF ?
- HA_KEY_ALG_HASH : pos->algorithm;
-
- for (; key_part != key_part_end ; key_part++, seg++)
- {
- uint flag= key_part->key_type;
- Field *field= key_part->field;
- if (pos->algorithm == HA_KEY_ALG_BTREE)
- {
- seg->type= field->key_type();
- }
- else
- {
- if (!f_is_packed(flag) &&
- f_packtype(flag) == (int) FIELD_TYPE_DECIMAL &&
- !(flag & FIELDFLAG_BINARY))
- seg->type= (int) HA_KEYTYPE_TEXT;
- else
- seg->type= (int) HA_KEYTYPE_BINARY;
- }
- seg->start= (uint) key_part->offset;
- seg->length= (uint) key_part->length;
- seg->flag = 0;
- seg->charset= field->binary() ? NULL : ((Field_str*)field)->charset();
- if (field->null_ptr)
- {
- seg->null_bit= field->null_bit;
- seg->null_pos= (uint) (field->null_ptr-
- (uchar*) table->record[0]);
- }
- else
- {
- seg->null_bit= 0;
- seg->null_pos= 0;
- }
- }
- if (pos->algorithm == HA_KEY_ALG_BTREE)
- {
- /* additional HA_KEYTYPE_END keyseg */
- seg->type= HA_KEYTYPE_END;
- seg->length= sizeof(byte*);
- seg->flag= 0;
- seg->null_bit= 0;
- seg++;
- }
- }
- mem_per_row += MY_ALIGN(table->reclength+1, sizeof(char*));
- max_rows = (ulong) (max_heap_table_size / mem_per_row);
- file=heap_open(name,mode,
- table->keys,keydef,
- table->reclength,
- ((table->max_rows < max_rows && table->max_rows) ?
- table->max_rows : max_rows),
- table->min_rows);
- my_free((gptr) keydef,MYF(0));
- if (file)
- info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE);
- ref_length=sizeof(HEAP_PTR);
- return (!file ? errno : 0);
+ return (file ? 0 : 1);
}
int ha_heap::close(void)
@@ -274,7 +194,6 @@ THR_LOCK_DATA **ha_heap::store_lock(THD *thd,
return to;
}
-
/*
We have to ignore ENOENT entries as the HEAP table is created on open and
not when doing a CREATE on the table.
@@ -291,7 +210,6 @@ int ha_heap::rename_table(const char * from, const char * to)
return heap_rename(from,to);
}
-
ha_rows ha_heap::records_in_range(int inx,
const byte *start_key,uint start_key_len,
enum ha_rkey_function start_search_flag,
@@ -315,10 +233,92 @@ ha_rows ha_heap::records_in_range(int inx,
}
}
-
-int ha_heap::create(const char *name, TABLE *form, HA_CREATE_INFO *create_info)
-
+int ha_heap::create(const char *name, TABLE *table, HA_CREATE_INFO *create_info)
{
+ uint key, parts, mem_per_row= 0;
+ ulong max_rows;
+ HP_KEYDEF *keydef;
+ HA_KEYSEG *seg;
char buff[FN_REFLEN];
- return heap_create(fn_format(buff,name,"","",4+2));
+ int error;
+
+ for (key= parts= 0; key < table->keys; key++)
+ {
+ parts+= table->key_info[key].key_parts;
+ if (table->key_info[key].algorithm == HA_KEY_ALG_BTREE)
+ parts++; /* additional HA_KEYTYPE_END keyseg */
+ }
+
+ if (!(keydef= (HP_KEYDEF*) my_malloc(table->keys * sizeof(HP_KEYDEF) +
+ parts * sizeof(HA_KEYSEG), MYF(MY_WME))))
+ return my_errno;
+ seg= my_reinterpret_cast(HA_KEYSEG*) (keydef + table->keys);
+ for (key= 0; key < table->keys; key++)
+ {
+ KEY *pos= table->key_info+key;
+ KEY_PART_INFO *key_part= pos->key_part;
+ KEY_PART_INFO *key_part_end= key_part + pos->key_parts;
+
+ mem_per_row+= (pos->key_length + (sizeof(char*) * 2));
+
+ keydef[key].keysegs= (uint) pos->key_parts;
+ keydef[key].flag= (pos->flags & (HA_NOSAME | HA_NULL_ARE_EQUAL));
+ keydef[key].seg= seg;
+ keydef[key].algorithm= pos->algorithm == HA_KEY_ALG_UNDEF ?
+ HA_KEY_ALG_HASH : pos->algorithm;
+
+ for (; key_part != key_part_end; key_part++, seg++)
+ {
+ uint flag= key_part->key_type;
+ Field *field= key_part->field;
+ if (pos->algorithm == HA_KEY_ALG_BTREE)
+ {
+ seg->type= field->key_type();
+ }
+ else
+ {
+ if (!f_is_packed(flag) &&
+ f_packtype(flag) == (int) FIELD_TYPE_DECIMAL &&
+ !(flag & FIELDFLAG_BINARY))
+ seg->type= (int) HA_KEYTYPE_TEXT;
+ else
+ seg->type= (int) HA_KEYTYPE_BINARY;
+ }
+ seg->start= (uint) key_part->offset;
+ seg->length= (uint) key_part->length;
+ seg->flag = 0;
+ seg->charset= field->binary() ? NULL : ((Field_str*)field)->charset();
+ if (field->null_ptr)
+ {
+ seg->null_bit= field->null_bit;
+ seg->null_pos= (uint) (field->null_ptr - (uchar*) table->record[0]);
+ }
+ else
+ {
+ seg->null_bit= 0;
+ seg->null_pos= 0;
+ }
+ }
+ if (pos->algorithm == HA_KEY_ALG_BTREE)
+ {
+ /* additional HA_KEYTYPE_END keyseg */
+ seg->type= HA_KEYTYPE_END;
+ seg->length= sizeof(byte*);
+ seg->flag= 0;
+ seg->null_bit= 0;
+ seg++;
+ }
+ }
+ mem_per_row+= MY_ALIGN(table->reclength + 1, sizeof(char*));
+ max_rows= (ulong) (max_heap_table_size / mem_per_row);
+ error= heap_create(fn_format(buff,name,"","",4+2),
+ table->keys,keydef, table->reclength,
+ ((table->max_rows < max_rows && table->max_rows) ?
+ table->max_rows : max_rows),
+ table->min_rows);
+ my_free((gptr) keydef, MYF(0));
+ if (file)
+ info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE);
+ ref_length= sizeof(HEAP_PTR);
+ return (error);
}
diff --git a/sql/init.cc b/sql/init.cc
index ac0ff701649..052ee16925e 100644
--- a/sql/init.cc
+++ b/sql/init.cc
@@ -53,23 +53,6 @@ void unireg_init(ulong options)
}
specialflag|=options; /* Set options from argv */
- // The following is needed because of like optimization in select.cc
-
- for (cs=compiled_charsets; cs->number; cs++)
- {
- uchar max_char;
- if (!cs->sort_order)
- continue;
- max_char=cs->sort_order[(uchar) cs->max_sort_char];
- for (i = 0; i < 256; i++)
- {
- if ((uchar) cs->sort_order[i] > max_char)
- {
- max_char=(uchar) cs->sort_order[i];
- cs->max_sort_char= (char) i;
- }
- }
- }
thread_stack_min=thread_stack - STACK_MIN_SIZE;
DBUG_VOID_RETURN;
}
diff --git a/sql/item.cc b/sql/item.cc
index 47171206e3d..86ddbc0b6e0 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -340,7 +340,7 @@ void Item_param::set_long_end()
item_result_type = STRING_RESULT;
};
-bool Item_param::save_in_field(Field *field)
+int Item_param::save_in_field(Field *field)
{
if (null_value)
return set_field_to_null(field);
@@ -349,20 +349,17 @@ bool Item_param::save_in_field(Field *field)
if (item_result_type == INT_RESULT)
{
longlong nr=val_int();
- field->store(nr);
- return 0;
+ return (field->store(nr)) ? -1 : 0;
}
if (item_result_type == REAL_RESULT)
{
double nr=val();
- field->store(nr);
- return 0;
+ return (field->store(nr)) ? -1 : 0;
}
String *result;
CHARSET_INFO *cs=default_charset_info;//fix this
result=val_str(&str_value);
- field->store(result->ptr(),result->length(),cs);
- return 0;
+ return (field->store(result->ptr(),result->length(),cs)) ? -1 : 0;
}
void Item_param::make_field(Send_field *tmp_field)
@@ -621,7 +618,7 @@ void Item_field::save_org_in_field(Field *to)
}
}
-bool Item_field::save_in_field(Field *to)
+int Item_field::save_in_field(Field *to)
{
if (result_field->is_null())
{
@@ -638,14 +635,15 @@ bool Item_field::save_in_field(Field *to)
}
-bool Item_null::save_in_field(Field *field)
+int Item_null::save_in_field(Field *field)
{
return set_field_to_null(field);
}
-bool Item::save_in_field(Field *field)
+int Item::save_in_field(Field *field)
{
+ int error;
if (result_type() == STRING_RESULT ||
result_type() == REAL_RESULT &&
field->result_type() == STRING_RESULT)
@@ -658,7 +656,7 @@ bool Item::save_in_field(Field *field)
if (null_value)
return set_field_to_null(field);
field->set_notnull();
- field->store(result->ptr(),result->length(),cs);
+ error=field->store(result->ptr(),result->length(),cs);
str_value.set_quick(0, 0, cs);
}
else if (result_type() == REAL_RESULT)
@@ -667,7 +665,7 @@ bool Item::save_in_field(Field *field)
if (null_value)
return set_field_to_null(field);
field->set_notnull();
- field->store(nr);
+ error=field->store(nr);
}
else
{
@@ -675,12 +673,12 @@ bool Item::save_in_field(Field *field)
if (null_value)
return set_field_to_null(field);
field->set_notnull();
- field->store(nr);
+ error=field->store(nr);
}
- return 0;
+ return (error) ? -1 : 0;
}
-bool Item_string::save_in_field(Field *field)
+int Item_string::save_in_field(Field *field)
{
String *result;
CHARSET_INFO *cs=field->binary()?default_charset_info:((Field_str*)field)->charset();
@@ -688,28 +686,25 @@ bool Item_string::save_in_field(Field *field)
if (null_value)
return set_field_to_null(field);
field->set_notnull();
- field->store(result->ptr(),result->length(),cs);
- return 0;
+ return (field->store(result->ptr(),result->length(),cs)) ? -1 : 0;
}
-bool Item_int::save_in_field(Field *field)
+int Item_int::save_in_field(Field *field)
{
longlong nr=val_int();
if (null_value)
return set_field_to_null(field);
field->set_notnull();
- field->store(nr);
- return 0;
+ return (field->store(nr)) ? -1 : 0;
}
-bool Item_real::save_in_field(Field *field)
+int Item_real::save_in_field(Field *field)
{
double nr=val();
if (null_value)
return set_field_to_null(field);
field->set_notnull();
- field->store(nr);
- return 0;
+ return (field->store(nr)) ? -1 : 0;
}
/****************************************************************************
@@ -757,20 +752,21 @@ longlong Item_varbinary::val_int()
}
-bool Item_varbinary::save_in_field(Field *field)
+int Item_varbinary::save_in_field(Field *field)
{
+ int error;
CHARSET_INFO *cs=field->binary()?default_charset_info:((Field_str*)field)->charset();
field->set_notnull();
if (field->result_type() == STRING_RESULT)
{
- field->store(str_value.ptr(),str_value.length(),cs);
+ error=field->store(str_value.ptr(),str_value.length(),cs);
}
else
{
longlong nr=val_int();
- field->store(nr);
+ error=field->store(nr);
}
- return 0;
+ return (error) ? -1 : 0;
}
diff --git a/sql/item.h b/sql/item.h
index 187e3903b84..a0b637b6030 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -53,7 +53,7 @@ public:
void set_name(char* str,uint length=0);
void init_make_field(Send_field *tmp_field,enum enum_field_types type);
virtual bool fix_fields(THD *, struct st_table_list *, Item **);
- virtual bool save_in_field(Field *field);
+ virtual int save_in_field(Field *field);
virtual void save_org_in_field(Field *field)
{ (void) save_in_field(field); }
virtual bool send(THD *thd, String *str);
@@ -124,7 +124,7 @@ public:
bool send(THD *thd, String *str_arg) { return result_field->send(thd,str_arg); }
void make_field(Send_field *field);
bool fix_fields(THD *, struct st_table_list *, Item **);
- bool save_in_field(Field *field);
+ int save_in_field(Field *field);
void save_org_in_field(Field *field);
table_map used_tables() const;
enum Item_result result_type () const
@@ -149,7 +149,7 @@ public:
longlong val_int();
String *val_str(String *str);
void make_field(Send_field *field);
- bool save_in_field(Field *field);
+ int save_in_field(Field *field);
enum Item_result result_type () const
{ return STRING_RESULT; }
bool send(THD *thd, String *str);
@@ -178,7 +178,7 @@ public:
longlong val_int();
String *val_str(String*);
void make_field(Send_field *field);
- bool save_in_field(Field *field);
+ int save_in_field(Field *field);
void set_null();
void set_int(longlong i);
void set_double(float i);
@@ -215,7 +215,7 @@ public:
double val() { return (double) value; }
String *val_str(String*);
void make_field(Send_field *field);
- bool save_in_field(Field *field);
+ int save_in_field(Field *field);
bool basic_const_item() const { return 1; }
Item *new_item() { return new Item_int(name,value,max_length); }
void print(String *str);
@@ -254,7 +254,7 @@ public:
max_length=length;
}
Item_real(double value_par) :value(value_par) {}
- bool save_in_field(Field *field);
+ int save_in_field(Field *field);
enum Type type() const { return REAL_ITEM; }
double val() { return value; }
longlong val_int() { return (longlong) (value+(value > 0 ? 0.5 : -0.5));}
@@ -297,7 +297,7 @@ public:
double val() { return atof(str_value.ptr()); }
longlong val_int() { return strtoll(str_value.ptr(),(char**) 0,10); }
String *val_str(String*) { return (String*) &str_value; }
- bool save_in_field(Field *field);
+ int save_in_field(Field *field);
void make_field(Send_field *field);
enum Item_result result_type () const { return STRING_RESULT; }
bool basic_const_item() const { return 1; }
@@ -334,7 +334,7 @@ public:
double val() { return (double) Item_varbinary::val_int(); }
longlong val_int();
String *val_str(String*) { return &str_value; }
- bool save_in_field(Field *field);
+ int save_in_field(Field *field);
void make_field(Send_field *field);
enum Item_result result_type () const { return INT_RESULT; }
};
@@ -394,7 +394,7 @@ public:
bool send(THD *thd, String *tmp) { return (*ref)->send(thd, tmp); }
void make_field(Send_field *field) { (*ref)->make_field(field); }
bool fix_fields(THD *, struct st_table_list *, Item **);
- bool save_in_field(Field *field) { return (*ref)->save_in_field(field); }
+ int save_in_field(Field *field) { return (*ref)->save_in_field(field); }
void save_org_in_field(Field *field) { (*ref)->save_org_in_field(field); }
enum Item_result result_type () const { return (*ref)->result_type(); }
table_map used_tables() const { return (*ref)->used_tables(); }
@@ -413,7 +413,7 @@ class Item_int_with_ref :public Item_int
public:
Item_int_with_ref(longlong i, Item *ref_arg) :Item_int(i), ref(ref_arg)
{}
- bool save_in_field(Field *field)
+ int save_in_field(Field *field)
{
return ref->save_in_field(field);
}
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index d1a130aa12b..bc723801aba 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -43,7 +43,8 @@ static bool convert_constant_item(Field *field, Item **item)
{
if ((*item)->const_item())
{
- (*item)->save_in_field(field);
+ if ((*item)->save_in_field(field))
+ return 0;
if (!((*item)->null_value))
{
Item *tmp=new Item_int_with_ref(field->val_int(), *item);
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 9204d23b8c2..a41ba1cc526 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -86,6 +86,11 @@ Item *create_func_cot(Item* a)
new Item_func_tan(a));
}
+Item *create_func_crc32(Item* a)
+{
+ return new Item_func_crc32(a);
+}
+
Item *create_func_date_format(Item* a,Item *b)
{
return new Item_func_date_format(a,b,0);
diff --git a/sql/item_create.h b/sql/item_create.h
index 6f7e8ebf89a..fd9a856f283 100644
--- a/sql/item_create.h
+++ b/sql/item_create.h
@@ -29,6 +29,7 @@ Item *create_func_connection_id(void);
Item *create_func_conv(Item* a, Item *b, Item *c);
Item *create_func_cos(Item* a);
Item *create_func_cot(Item* a);
+Item *create_func_crc32(Item* a);
Item *create_func_date_format(Item* a,Item *b);
Item *create_func_dayname(Item* a);
Item *create_func_dayofmonth(Item* a);
diff --git a/sql/item_func.cc b/sql/item_func.cc
index ae3fc7cb8f0..8728187718c 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -26,6 +26,7 @@
#include <hash.h>
#include <time.h>
#include <ft_global.h>
+#include <zlib.h>
#include "slave.h" // for wait_for_master_pos
#include "gstream.h"
@@ -801,6 +802,18 @@ longlong Item_func_min_max::val_int()
return value;
}
+longlong Item_func_crc32::val_int()
+{
+ String *res=args[0]->val_str(&value);
+ if (!res)
+ {
+ null_value=1;
+ return 0; /* purecov: inspected */
+ }
+ null_value=0;
+ return (longlong) crc32(0L, (Bytef*)res->ptr(), res->length());
+}
+
longlong Item_func_length::val_int()
{
diff --git a/sql/item_func.h b/sql/item_func.h
index 86b2a17931d..2e61ed87c3c 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -518,6 +518,16 @@ public:
const char *func_name() const { return "greatest"; }
};
+class Item_func_crc32 :public Item_int_func
+{
+ String value;
+public:
+ Item_func_crc32(Item *a) :Item_int_func(a) {}
+ longlong val_int();
+ const char *func_name() const { return "crc32"; }
+ void fix_length_and_dec() { max_length=10; }
+};
+
class Item_func_length :public Item_int_func
{
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 1aee4e7d553..dc9d57b1d9d 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1843,9 +1843,11 @@ outp:
void Item_func_conv_charset::fix_length_and_dec()
{
max_length = args[0]->max_length*(conv_charset->mbmaxlen?conv_charset->mbmaxlen:1);
+ str_value.set_charset(conv_charset);
}
+
String *Item_func_conv_charset3::val_str(String *str)
{
my_wc_t wc;
@@ -1913,7 +1915,7 @@ outp:
}
-bool Item_func_conv_charset::fix_fields(THD *thd,struct st_table_list *tables)
+bool Item_func_conv_charset::fix_fields(THD *thd,struct st_table_list *tables, Item **ref)
{
char buff[STACK_BUFF_ALLOC]; // Max argument in function
binary=0;
@@ -1938,6 +1940,53 @@ void Item_func_conv_charset3::fix_length_and_dec()
max_length = args[0]->max_length;
}
+String *Item_func_set_collation::val_str(String *str)
+{
+ str=args[0]->val_str(str);
+ null_value=args[0]->null_value;
+ str->set_charset(set_collation);
+ return str;
+}
+
+bool Item_func_set_collation::fix_fields(THD *thd,struct st_table_list *tables, Item **ref)
+{
+ char buff[STACK_BUFF_ALLOC]; // Max argument in function
+ binary=0;
+ used_tables_cache=0;
+ const_item_cache=1;
+
+ if (thd && check_stack_overrun(thd,buff))
+ return 0; // Fatal error if flag is set!
+ if (args[0]->fix_fields(thd, tables, args))
+ return 1;
+ maybe_null=args[0]->maybe_null;
+ binary=args[0]->binary;
+ const_item_cache=args[0]->const_item();
+ str_value.set_charset(set_collation);
+ fix_length_and_dec();
+ return 0;
+}
+
+bool Item_func_set_collation::eq(const Item *item, bool binary_cmp) const
+{
+ /* Assume we don't have rtti */
+ if (this == item)
+ return 1;
+ if (item->type() != FUNC_ITEM)
+ return 0;
+ Item_func *item_func=(Item_func*) item;
+ if (arg_count != item_func->arg_count ||
+ func_name() != item_func->func_name())
+ return 0;
+ Item_func_set_collation *item_func_sc=(Item_func_set_collation*) item;
+ if (set_collation != item_func_sc->set_collation)
+ return 0;
+ for (uint i=0; i < arg_count ; i++)
+ if (!args[i]->eq(item_func_sc->args[i], binary_cmp))
+ return 0;
+ return 1;
+}
+
String *Item_func_charset::val_str(String *str)
{
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 7b5bd7ae90b..997d9c8d834 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -472,7 +472,7 @@ class Item_func_export_set: public Item_str_func
const char *func_name() const { return "export_set"; }
};
- class Item_func_inet_ntoa : public Item_str_func
+class Item_func_inet_ntoa : public Item_str_func
{
public:
Item_func_inet_ntoa(Item *a) :Item_str_func(a)
@@ -488,15 +488,30 @@ class Item_func_conv_charset :public Item_str_func
CHARSET_INFO *conv_charset;
public:
Item_func_conv_charset(Item *a, CHARSET_INFO *cs) :Item_str_func(a)
- {
- conv_charset=cs;
- }
- bool fix_fields(THD *thd,struct st_table_list *tables);
+ { conv_charset=cs; }
+ bool fix_fields(THD *thd,struct st_table_list *tables,Item **ref);
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "conv_charset"; }
};
+class Item_func_set_collation :public Item_str_func
+{
+ CHARSET_INFO *set_collation;
+public:
+ Item_func_set_collation(Item *a, CHARSET_INFO *cs) :Item_str_func(a)
+ { set_collation=cs; }
+ bool fix_fields(THD *thd,struct st_table_list *tables, Item **ref);
+ String *val_str(String *);
+ void fix_length_and_dec()
+ {
+ max_length = args[0]->max_length;
+ str_value.set_charset(set_collation);
+ }
+ bool eq(const Item *item, bool binary_cmp) const;
+ const char *func_name() const { return "set_collation"; }
+};
+
class Item_func_conv_charset3 :public Item_str_func
{
public:
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 18e9f51925a..29034549367 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -126,7 +126,7 @@ String *Item_singleval_subselect::val_str (String *str)
Item_exists_subselect::Item_exists_subselect(THD *thd,
st_select_lex *select_lex):
- Item_subselect(thd, select_lex, new select_singleval_subselect(this))
+ Item_subselect(thd, select_lex, new select_exists_subselect(this))
{
max_columns= UINT_MAX;
null_value= 0; //can't be NULL
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 9bbb9e4fe19..297ff30bd9c 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -410,7 +410,7 @@ String *Item_date::val_str(String *str)
}
-bool Item_date::save_in_field(Field *field)
+int Item_date::save_in_field(Field *field)
{
TIME ltime;
timestamp_type t_type=TIMESTAMP_FULL;
@@ -525,7 +525,7 @@ bool Item_func_now::get_date(TIME *res,
}
-bool Item_func_now::save_in_field(Field *to)
+int Item_func_now::save_in_field(Field *to)
{
to->set_notnull();
to->store_time(&ltime,TIMESTAMP_FULL);
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 53beb78e1d4..6d016df6eb7 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -228,7 +228,7 @@ public:
double val() { return (double) val_int(); }
const char *func_name() const { return "date"; }
void fix_length_and_dec() { decimals=0; max_length=10; }
- bool save_in_field(Field *to);
+ int save_in_field(Field *to);
void make_field(Send_field *tmp_field)
{
init_make_field(tmp_field,FIELD_TYPE_DATE);
@@ -311,7 +311,7 @@ public:
enum Item_result result_type () const { return STRING_RESULT; }
double val() { return (double) value; }
longlong val_int() { return value; }
- bool save_in_field(Field *to);
+ int save_in_field(Field *to);
String *val_str(String *str)
{ str_value.set(buff,buff_length,default_charset_info); return &str_value; }
const char *func_name() const { return "now"; }
diff --git a/sql/lex.h b/sql/lex.h
index 4af36df58af..cd25c3883fe 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -89,6 +89,7 @@ static SYMBOL symbols[] = {
{ "CHECKSUM", SYM(CHECKSUM_SYM),0,0},
{ "CIPHER", SYM(CIPHER_SYM),0,0},
{ "CLOSE", SYM(CLOSE_SYM),0,0},
+ { "COLLATE", SYM(COLLATE_SYM),0,0},
{ "COLUMN", SYM(COLUMN_SYM),0,0},
{ "COLUMNS", SYM(COLUMNS),0,0},
{ "COMMENT", SYM(COMMENT_SYM),0,0},
@@ -430,6 +431,7 @@ static SYMBOL sql_functions[] = {
{ "COUNT", SYM(COUNT_SYM),0,0},
{ "COS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_cos)},
{ "COT", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_cot)},
+ { "CRC32", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_crc32)},
{ "CROSSES", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_crosses)},
{ "CURDATE", SYM(CURDATE),0,0},
{ "CURTIME", SYM(CURTIME),0,0},
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 155d056db42..d3901770230 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -382,9 +382,13 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
int mysql_create_table(THD *thd,const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
List<create_field> &fields, List<Key> &keys,
- bool tmp_table, bool no_log);
-// no_log is needed for the case of CREATE TABLE ... SELECT , as the logging
-// will be done later in sql_insert.cc
+ bool tmp_table, bool no_log, uint select_field_count);
+/*
+ no_log is needed for the case of CREATE ... SELECT,
+ as the logging will be done later in sql_insert.cc
+ select_field_count is also used for CREATE ... SELECT,
+ and must be zero for standart create of table
+*/
TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
const char *db, const char *name,
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 830c7324771..99099ff1bac 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1841,7 +1841,7 @@ int main(int argc, char **argv)
if (set_default_charset_by_name(default_charset, MYF(MY_WME)))
exit( 1 );
- charsets_list = list_charsets(MYF(MY_COMPILED_SETS|MY_CONFIG_SETS));
+ charsets_list = list_charsets(MYF(MY_CS_COMPILED|MY_CS_CONFIG));
#ifdef HAVE_OPENSSL
if (opt_use_ssl)
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index ccee7192682..a99a701e4b4 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1028,7 +1028,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
field->cmp_type() != value->result_type())
DBUG_RETURN(0);
- if (value->save_in_field(field))
+ if (value->save_in_field(field) > 0)
{
if (type == Item_func::EQUAL_FUNC)
{
diff --git a/sql/share/charsets/Index b/sql/share/charsets/Index
index 52cb6b99705..c8ae877887e 100644
--- a/sql/share/charsets/Index
+++ b/sql/share/charsets/Index
@@ -40,3 +40,10 @@ armscii8 32
utf8 33
win1250ch 34
ucs2 35
+cp866 36
+keybcs2 37
+macce 38
+macroman 39
+pclatin2 40
+latvian 41
+latvian1 42
diff --git a/sql/share/charsets/cp866.conf b/sql/share/charsets/cp866.conf
new file mode 100644
index 00000000000..e6b5c064fd7
--- /dev/null
+++ b/sql/share/charsets/cp866.conf
@@ -0,0 +1,91 @@
+# ctype array (must be 257 elements)
+ 00
+ 20 20 20 20 20 20 20 20 20 28 28 28 28 28 20 20
+ 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
+ 48 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 84 84 84 84 84 84 84 84 84 84 10 10 10 10 10 10
+ 10 81 81 81 81 81 81 01 01 01 01 01 01 01 01 01
+ 01 01 01 01 01 01 01 01 01 01 01 10 10 10 10 10
+ 10 82 82 82 82 82 82 02 02 02 02 02 02 02 02 02
+ 02 02 02 02 02 02 02 02 02 02 02 10 10 10 10 00
+ 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+ 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+ 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+ 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+ 01 02 01 02 01 02 01 02 00 00 00 00 00 00 00 48
+
+# to_lower array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+ 70 71 72 73 74 75 76 77 78 79 7A 5B 5C 5D 5E 5F
+ 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+ 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
+ A0 A1 A2 A3 A4 A5 86 87 88 89 AA AB AC AD AE AF
+ E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
+ A0 A1 A2 A3 A4 A5 86 87 88 89 AA AB AC AD AE AF
+ B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
+ C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
+ E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
+ F1 F1 F3 F3 F5 F5 F7 F7 F8 F9 FA FB FC FD FE FF
+
+# to_upper array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+ 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+ 60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+ 50 51 52 53 54 55 56 57 58 59 5A 7B 7C 7D 7E 7F
+ 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
+ 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
+ 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
+ B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
+ C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
+ 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
+ F0 F0 F2 F2 F4 F4 F6 F6 F8 F9 FA FB FC FD FE FF
+
+# sort_order array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 41 42 43 44 45 56 57 58 59 5A 5B 5C 5E 5F 62
+ 67 68 69 6C 71 74 75 76 77 78 7B B0 B1 B2 B3 B4
+ B5 41 42 43 44 45 56 57 58 59 5A 5B 5C 5E 5F 62
+ 67 68 69 6C 71 74 75 76 77 78 7B B6 B7 B8 B9 BA
+ 80 81 82 83 84 85 88 89 8A 8C 8D 8E 8F 90 91 92
+ 93 94 95 96 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3
+ 80 81 82 83 84 85 88 89 8A 8C 8D 8E 8F 90 91 92
+ BB BD BE C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC
+ CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD
+ DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 F3 F4 F5 F6 F7
+ 93 94 95 96 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3
+ 86 86 87 87 8B 8B 97 97 F8 F9 FA FB FC FD FE FF
+
+# Unicode mappping (must be 256 elements)
+ 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
+ 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 001A 001B 001C 001D 001E 001F
+ 0020 0021 0022 0023 0024 0025 0026 0027 0028 0029 002A 002B 002C 002D 002E 002F
+ 0030 0031 0032 0033 0034 0035 0036 0037 0038 0039 003A 003B 003C 003D 003E 003F
+ 0040 0041 0042 0043 0044 0045 0046 0047 0048 0049 004A 004B 004C 004D 004E 004F
+ 0050 0051 0052 0053 0054 0055 0056 0057 0058 0059 005A 005B 005C 005D 005E 005F
+ 0060 0061 0062 0063 0064 0065 0066 0067 0068 0069 006A 006B 006C 006D 006E 006F
+ 0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 007A 007B 007C 007D 007E 007F
+ 0410 0411 0412 0413 0414 0415 0416 0417 0418 0419 041A 041B 041C 041D 041E 041F
+ 0420 0421 0422 0423 0424 0425 0426 0427 0428 0429 042A 042B 042C 042D 042E 042F
+ 0430 0431 0432 0433 0434 0435 0436 0437 0438 0439 043A 043B 043C 043D 043E 043F
+ 2591 2592 2593 2502 2524 2561 2562 2556 2555 2563 2551 2557 255D 255C 255B 2510
+ 2514 2534 252C 251C 2500 253C 255E 255F 255A 2554 2569 2566 2560 2550 256C 2567
+ 2568 2564 2565 2559 2558 2552 2553 256B 256A 2518 250C 2588 2584 258C 2590 2580
+ 0440 0441 0442 0443 0444 0445 0446 0447 0448 0449 044A 044B 044C 044D 044E 044F
+ 0401 0451 0404 0454 0407 0457 040E 045E 00B0 2219 00B7 221A 207F 00B2 25A0 00A0
+
diff --git a/sql/share/charsets/dos.conf b/sql/share/charsets/dos.conf
index fc4d4cee5c4..205202711b8 100644
--- a/sql/share/charsets/dos.conf
+++ b/sql/share/charsets/dos.conf
@@ -1,4 +1,4 @@
-# Configuration file for the dos character set
+# Configuration file for the dos (aka cp437 DOSLatinUS) character set
# ctype array (must have 257 elements)
00
diff --git a/sql/share/charsets/keybcs2.conf b/sql/share/charsets/keybcs2.conf
new file mode 100644
index 00000000000..f272960b683
--- /dev/null
+++ b/sql/share/charsets/keybcs2.conf
@@ -0,0 +1,91 @@
+# ctype array (must be 257 elements)
+ 00
+ 20 20 20 20 20 20 20 20 20 28 28 28 28 28 20 20
+ 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
+ 48 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 84 84 84 84 84 84 84 84 84 84 10 10 10 10 10 10
+ 10 81 81 81 81 81 81 01 01 01 01 01 01 01 01 01
+ 01 01 01 01 01 01 01 01 01 01 01 10 10 10 10 10
+ 10 82 82 82 82 82 82 02 02 02 02 02 02 02 02 02
+ 02 02 02 02 02 02 02 02 02 02 02 10 10 10 10 00
+ 01 02 82 02 02 01 01 02 82 81 01 01 02 02 01 01
+ 81 02 01 02 02 01 02 01 02 01 01 01 01 01 01 02
+ 02 02 02 02 02 01 01 01 02 02 02 01 00 00 00 00
+ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+ 02 02 01 02 01 02 00 02 01 01 01 02 00 02 02 00
+ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48
+
+# to_lower array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+ 70 71 72 73 74 75 76 77 78 79 7A 5B 5C 5D 5E 5F
+ 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+ 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
+ 87 81 82 83 84 83 86 87 88 88 8D A1 8C 8D 84 A0
+ 82 91 91 93 94 A2 96 A3 98 94 81 9B 8C 98 A9 9F
+ A0 A1 A2 A3 A4 A4 96 93 9B A9 AA AA AC AD AE AF
+ B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
+ C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
+ E0 E1 E2 E3 E4 E5 E6 E7 ED E9 EA EB EC ED EE EF
+ F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
+
+# to_upper array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+ 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+ 60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+ 50 51 52 53 54 55 56 57 68 59 5A 7B 7C 7D 7E 7F
+ 87 9A 90 85 8E 85 86 80 89 89 8A 8B 9C 8A 8E 8F
+ 90 92 92 A7 99 95 A6 97 9D 99 9A A8 9C 9D 9E 9F
+ 8F 8B 95 97 A5 A5 A6 A7 A8 9E AB AB AC AD AE AF
+ B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
+ C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
+ E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC E8 EE EF
+ F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
+
+# sort_order array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 41 44 45 47 49 50 51 52 53 54 55 56 57 58 5A
+ 5E 5F 60 63 66 68 6C 6D 6E 6F 72 90 91 92 93 94
+ 95 41 44 45 47 49 50 51 52 53 54 55 56 57 58 5A
+ 5E 5F 60 63 66 68 6C 6D 6E 6F 72 96 97 98 99 9A
+ 45 68 49 47 41 47 66 45 49 49 56 53 56 56 41 41
+ 49 72 72 5A 5A 5A 68 68 6F 5A 68 63 56 6F 60 66
+ 41 53 5A 68 58 58 68 5A 63 60 60 60 A0 A1 A2 A3
+ A4 A5 A6 B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC
+ BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC
+ CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC
+ 80 65 83 87 88 89 DD 8A 85 8B 84 81 DE 85 82 DF
+ F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
+
+# Unicode mappping (must be 256 elements)
+ 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
+ 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 001A 001B 001C 001D 001E 001F
+ 0020 0021 0022 0023 0024 0025 0026 0027 0028 0029 002A 002B 002C 002D 002E 002F
+ 0030 0031 0032 0033 0034 0035 0036 0037 0038 0039 003A 003B 003C 003D 003E 003F
+ 0040 0041 0042 0043 0044 0045 0046 0047 0048 0049 004A 004B 004C 004D 004E 004F
+ 0050 0051 0052 0053 0054 0055 0056 0057 0058 0059 005A 005B 005C 005D 005E 005F
+ 0060 0061 0062 0063 0064 0065 0066 0067 0068 0069 006A 006B 006C 006D 006E 006F
+ 0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 007A 007B 007C 007D 007E 007F
+ 010C 00FC 00E9 010F 00E4 010E 0164 010D 011B 011A 0139 00CD 013E 013A 00C4 00C1
+ 00C9 017E 017D 00F4 00F6 00D3 016F 00DA 00FD 00D6 00DC 0160 013D 00DD 0158 0165
+ 00E1 00ED 00F3 00FA 0148 0147 016E 00D4 0161 0159 0155 0154 00BC 00A1 00AB 00BB
+ 2591 2592 2593 2502 2524 2561 2562 2556 2555 2563 2551 2557 255D 255C 255B 2510
+ 2514 2534 252C 251C 2500 253C 255E 255F 255A 2554 2569 2566 2560 2550 256C 2567
+ 2568 2564 2565 2559 2558 2552 2553 256B 256A 2518 250C 2588 2584 258C 2590 2580
+ 03B1 00DF 0393 03C0 03A3 03C3 00B5 03C4 03A6 0398 03A9 03B4 221E 03C6 03B5 2229
+ 2261 00B1 2265 2264 2320 2321 00F7 2248 00B0 2219 00B7 221A 207F 00B2 25A0 00A0
+
diff --git a/sql/share/charsets/latvian.conf b/sql/share/charsets/latvian.conf
new file mode 100644
index 00000000000..c3dee95d55c
--- /dev/null
+++ b/sql/share/charsets/latvian.conf
@@ -0,0 +1,95 @@
+# Configuration file for the latvian character set.
+# Created for case-sensitive record search
+# Created accord with windows-1257 (iso-8859-4) codepage
+# Created by Andis Grasis & Rihards Grasis e-mail:andis@cata.lv
+
+# The ctype array must have 257 elements.
+ 00
+ 20 20 20 20 20 20 20 20 20 28 28 28 28 28 20 20
+ 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
+ 48 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 84 84 84 84 84 84 84 84 84 84 10 10 10 10 10 10
+ 10 81 81 81 81 81 81 01 01 01 01 01 01 01 01 01
+ 01 01 01 01 01 01 01 01 01 01 01 10 10 10 10 10
+ 10 82 82 82 82 82 82 02 02 02 02 02 02 02 02 02
+ 02 02 02 02 02 02 02 02 02 02 02 10 10 10 10 20
+ 01 20 10 20 10 10 00 00 20 10 20 10 20 10 10 10
+ 20 10 10 10 10 10 10 10 20 00 20 10 20 10 10 20
+ 48 20 10 10 10 20 10 10 10 10 01 10 10 10 10 01
+ 10 10 10 10 10 10 10 10 10 10 02 10 10 10 10 02
+ 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+ 01 01 01 01 01 01 01 10 01 01 01 01 01 01 01 02
+ 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+ 02 02 02 02 02 02 02 10 02 02 02 02 02 02 02 10
+
+# The to_lower array must have 256 elements.
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+ 70 71 72 73 74 75 76 77 78 79 7A 5B 5C 5D 5E 5F
+ 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+ 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
+ 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
+ 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
+ A0 A1 A2 A3 A4 A5 A6 A7 B8 A9 BA AB AC AD AE BF
+ B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
+ E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
+ F0 F1 F2 F3 F4 F5 F6 D7 F8 F9 FA FB FC FD FE DF
+ E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
+ F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
+
+# The to_upper array must have 256 elements.
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+ 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+ 60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+ 50 51 52 53 54 55 56 57 58 59 5A 7B 7C 7D 7E 7F
+ 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
+ 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
+ A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
+ B0 B1 B2 B3 B4 B5 B6 B7 A8 B9 AA BB BC BD BE AF
+ C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
+ C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ D0 D1 D2 D3 D4 D5 D6 F7 D8 D9 DA DB DC DD DE FF
+
+# The sort_order array must have 256 elements.
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 30 32 33 34 35 36 37 2B 38 39 3A 5C 3B 2C 3C 3D
+ 76 7A 7C 7E 80 81 82 83 84 85 3E 3F 5D 5E 5F 40
+ 41 86 92 94 9A 9C A6 A8 AC AE B4 B6 BA C0 C2 C8
+ D4 D6 D8 DC E3 E6 EE F0 F2 F4 F6 42 43 44 45 46
+ 47 87 93 95 9B 9D A7 A9 AD AF B5 B7 BB C1 C3 C9
+ D5 D7 D9 DD E4 E7 EF F1 F3 F5 F7 48 49 4A 4B 20
+ 75 21 56 22 59 73 70 71 23 74 24 5A 25 4D 51 50
+ 26 54 55 57 58 72 2E 2F 27 E5 28 5B 29 4E 53 2A
+ 31 FE 65 66 67 FF 4C 68 D3 69 DA 61 6A 2D 6B 90
+ 6C 60 7D 7F 4F 6D 6E 6F D2 7B DB 62 77 78 79 91
+ 8E B2 8A 96 88 8C A4 A2 98 9E F8 A0 AA B8 B0 BE
+ E1 C4 C6 CA CE D0 CC 63 EC BC DE EA E8 FA FC E0
+ 8F B3 8B 97 89 8D A5 A3 99 9F F9 A1 AB B9 B1 BF
+ E2 C5 C7 CB CF D1 CD 64 ED BD DF EB E9 FB FD 52
+
+# Unicode mapping (256 elements)
+0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
+0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 001A 001B 001C 001D 001E 001F
+0020 0021 0022 0023 0024 0025 0026 0027 0028 0029 002A 002B 002C 002D 002E 002F
+0030 0031 0032 0033 0034 0035 0036 0037 0038 0039 003A 003B 003C 003D 003E 003F
+0040 0041 0042 0043 0044 0045 0046 0047 0048 0049 004A 004B 004C 004D 004E 004F
+0050 0051 0052 0053 0054 0055 0056 0057 0058 0059 005A 005B 005C 005D 005E 005F
+0060 0061 0062 0063 0064 0065 0066 0067 0068 0069 006A 006B 006C 006D 006E 006F
+0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 007A 007B 007C 007D 007E 007F
+0080 0081 0082 0083 0084 0085 0086 0087 0088 0089 008A 008B 008C 008D 008E 008F
+0090 0091 0092 0093 0094 0095 0096 0097 0098 0099 009A 009B 009C 009D 009E 009F
+00A0 201D 00A2 00A3 00A4 201E 00A6 00A7 00D8 00A9 0156 00AB 00AC 00AD 00AE 00C6
+00B0 00B1 00B2 00B3 201C 00B5 00B6 00B7 00F8 00B9 0157 00BB 00BC 00BD 00BE 00E6
+0104 012E 0100 0106 00C4 00C5 0118 0112 010C 00C9 0179 0116 0122 0136 012A 013B
+0160 0143 0145 00D3 014C 00D5 00D6 00D7 0172 0141 015A 016A 00DC 017B 017D 00DF
+0105 012F 0101 0107 00E4 00E5 0119 0113 010D 00E9 017A 0117 0123 0137 012B 013C
+0161 0144 0146 00F3 014D 00F5 00F6 00F7 0173 0142 015B 016B 00FC 017C 017E 2019
diff --git a/sql/share/charsets/latvian1.conf b/sql/share/charsets/latvian1.conf
new file mode 100644
index 00000000000..3094525052d
--- /dev/null
+++ b/sql/share/charsets/latvian1.conf
@@ -0,0 +1,94 @@
+# Configuration file for the latvian character set.
+# Created for case-insensitive record search
+# Created by Andis & Rihards
+
+# The ctype array must have 257 elements.
+ 00
+ 20 20 20 20 20 20 20 20 20 28 28 28 28 28 20 20
+ 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
+ 48 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 84 84 84 84 84 84 84 84 84 84 10 10 10 10 10 10
+ 10 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+ 01 01 01 01 01 01 01 01 01 01 01 10 10 10 10 10
+ 10 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+ 02 02 02 02 02 02 02 02 02 02 02 10 10 10 10 20
+ 00 00 10 00 10 10 00 00 00 00 00 10 00 10 10 10
+ 00 10 10 10 10 10 10 10 00 00 00 10 00 10 10 00
+ 48 00 10 10 10 00 10 10 10 10 01 10 10 10 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+ 01 01 01 01 01 01 01 10 01 01 01 01 01 01 01 02
+ 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+ 02 02 02 02 02 02 02 10 02 02 02 02 02 02 02 10
+
+# The to_lower array must have 256 elements.
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+ 70 71 72 73 74 75 76 77 78 79 7A 5B 5C 5D 5E 5F
+ 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+ 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
+ 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
+ 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
+ A0 A1 A2 A3 A4 A5 A6 A7 B8 A9 BA AB AC AD AE BF
+ B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
+ E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
+ F0 F1 F2 F3 F4 F5 F6 D7 F8 F9 FA FB FC FD FE DF
+ E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
+ F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
+
+# The to_upper array must have 256 elements.
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+ 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+ 60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+ 50 51 52 53 54 55 56 57 58 59 5A 7B 7C 7D 7E 7F
+ 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
+ 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
+ A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
+ B0 B1 B2 B3 B4 B5 B6 B7 A8 B9 AA BB BC BD BE AF
+ C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
+ C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ D0 D1 D2 D3 D4 D5 D6 F7 D8 D9 DA DB DC DD DE FF
+
+# The sort_order array must have 256 elements.
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 30 32 33 34 35 36 37 2B 38 39 3A 5C 3B 2C 3C 3D
+ 76 7A 7C 7E 80 81 82 83 84 85 3E 3F 5D 5E 5F 40
+ 41 86 92 94 9A 9C A6 A8 AC AE B4 B6 BA C0 C2 C8
+ D4 D6 D8 DC E3 E6 EE F0 F2 F4 F6 42 43 44 45 46
+ 47 86 92 94 9A 9C A6 A8 AC AE B4 B6 BA C0 C2 C8
+ D4 D6 D8 DC E2 E6 EE F0 F2 F4 F6 48 49 4A 4B 20
+ 75 21 56 22 59 73 70 71 23 74 24 5A 25 4D 51 50
+ 26 54 55 57 58 72 2E 2F 27 E5 28 5B 29 4E 53 2A
+ 31 FE 65 66 67 FF 4C 68 2D 69 DA 61 6A 2D 6B 90
+ 6C 60 7D 7F 4F 6D 6E 6F D3 7B DB 62 77 78 79 90
+ 8E B2 8A 96 88 8C A4 A2 98 9E F8 A0 AA B8 B0 BE
+ E1 C4 C6 CA CE D0 CC 63 EC BC DE EA E8 FA FC E0
+ 8E B2 8A 96 88 8C A4 A2 98 9E F8 A0 AA B8 B0 BE
+ E1 C4 C6 CA CE D0 CC 64 EC BC DE EA E8 FA FC 52
+
+# Unicode mapping (256 elements)
+0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
+0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 001A 001B 001C 001D 001E 001F
+0020 0021 0022 0023 0024 0025 0026 0027 0028 0029 002A 002B 002C 002D 002E 002F
+0030 0031 0032 0033 0034 0035 0036 0037 0038 0039 003A 003B 003C 003D 003E 003F
+0040 0041 0042 0043 0044 0045 0046 0047 0048 0049 004A 004B 004C 004D 004E 004F
+0050 0051 0052 0053 0054 0055 0056 0057 0058 0059 005A 005B 005C 005D 005E 005F
+0060 0061 0062 0063 0064 0065 0066 0067 0068 0069 006A 006B 006C 006D 006E 006F
+0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 007A 007B 007C 007D 007E 007F
+0080 0081 0082 0083 0084 0085 0086 0087 0088 0089 008A 008B 008C 008D 008E 008F
+0090 0091 0092 0093 0094 0095 0096 0097 0098 0099 009A 009B 009C 009D 009E 009F
+00A0 201D 00A2 00A3 00A4 201E 00A6 00A7 00D8 00A9 0156 00AB 00AC 00AD 00AE 00C6
+00B0 00B1 00B2 00B3 201C 00B5 00B6 00B7 00F8 00B9 0157 00BB 00BC 00BD 00BE 00E6
+0104 012E 0100 0106 00C4 00C5 0118 0112 010C 00C9 0179 0116 0122 0136 012A 013B
+0160 0143 0145 00D3 014C 00D5 00D6 00D7 0172 0141 015A 016A 00DC 017B 017D 00DF
+0105 012F 0101 0107 00E4 00E5 0119 0113 010D 00E9 017A 0117 0123 0137 012B 013C
+0161 0144 0146 00F3 014D 00F5 00F6 00F7 0173 0142 015B 016B 00FC 017C 017E 2019
diff --git a/sql/share/charsets/macce.conf b/sql/share/charsets/macce.conf
new file mode 100644
index 00000000000..f3ac08df087
--- /dev/null
+++ b/sql/share/charsets/macce.conf
@@ -0,0 +1,91 @@
+# ctype array (must be 257 elements)
+ 00
+ 20 20 20 20 20 20 20 20 20 28 28 28 28 28 20 20
+ 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
+ 48 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 84 84 84 84 84 84 84 84 84 84 10 10 10 10 10 10
+ 10 81 81 81 81 81 81 01 01 01 01 01 01 01 01 01
+ 01 01 01 01 01 01 01 01 01 01 01 10 10 10 10 10
+ 10 82 82 82 82 82 82 02 02 02 02 02 02 02 02 02
+ 02 02 02 02 02 02 02 02 02 02 02 10 10 10 10 00
+ 01 01 02 01 01 01 01 02 02 01 02 02 01 02 02 01
+ 02 01 02 02 01 02 01 02 02 02 02 02 02 01 02 02
+ 00 00 01 00 00 00 00 02 00 00 00 02 00 00 02 01
+ 02 01 00 00 02 01 00 00 02 01 02 01 02 01 02 01
+ 02 01 00 00 02 01 00 00 00 00 00 02 01 01 02 01
+ 00 00 00 00 00 00 00 00 02 01 02 01 00 00 02 01
+ 02 01 00 00 02 01 02 01 01 02 01 01 02 01 01 01
+ 02 01 01 02 01 02 01 02 01 02 02 01 01 02 01 00
+
+# to_lower array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+ 70 71 72 73 54 75 76 77 78 79 7A 5B 5C 5D 5E 5F
+ 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+ 70 71 72 73 54 75 76 77 78 79 7A 7B 7C 7D 7E 7F
+ 8A 82 82 8E 88 9A 9F 87 88 8B 8A 8B 8D 8D 8E 90
+ 90 93 92 93 95 95 98 97 98 99 9A 9B 9C 9E 9E 9F
+ A0 A1 AB A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE B0
+ B0 B4 B2 B3 B4 FA B6 B7 B8 BA BA BC BC BE BE C0
+ C0 C4 C2 C3 C4 CB C6 C7 C8 C9 CA CB CE 9B CE D8
+ D0 D1 D2 D3 D4 D5 D6 D7 D8 DA DA DE DC DD DE E0
+ E0 E4 E2 E3 E4 E6 E6 87 E9 E9 92 EC EC F0 97 99
+ F0 F3 9C F3 F5 F5 F7 F7 F9 F9 FA FD B8 FD AE FF
+
+# to_upper array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+ 50 51 52 53 74 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+ 60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+ 50 51 52 53 74 55 56 57 58 59 5A 7B 7C 7D 7E 7F
+ 80 81 81 83 84 85 86 E7 84 89 80 89 8C 8C 83 8F
+ 8F 91 EA 91 94 94 96 EE 96 EF 85 CD F2 9D 9D 86
+ A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA A2 AC AD FE AF
+ AF B1 B2 B3 B1 B5 B6 B7 FC B9 B9 BB BB BD BD BF
+ BF C1 C2 C3 C1 C5 C6 C7 C8 C9 CA C5 CC CD CC CF
+ D0 D1 D2 D3 D4 D5 D6 D7 CF D9 D9 DB DC DD DB DF
+ DF E1 E2 E3 E1 E5 E5 E7 E8 E8 EA EB EB ED EE EF
+ ED F1 F2 F1 F4 F4 F6 F6 F8 F8 B5 FB FC FB FE FF
+
+# sort_order array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 41 46 47 4A 4C 52 53 55 56 5A 5B 5D 62 62 67
+ 6F 70 71 75 79 81 88 89 8A 8B 8D 90 91 92 93 94
+ 95 41 46 47 4A 4C 52 53 55 56 5A 5B 5D 62 62 67
+ 6F 70 71 75 79 81 88 89 8A 8B 8D 96 97 98 99 9A
+ 41 41 41 4C 41 67 81 41 41 47 41 47 47 47 4C 8D
+ 8D 4A 56 4A 4C 4C 4C 67 4C 67 67 67 81 4C 4C 81
+ A0 A1 4C A3 A4 A5 A6 75 A8 A9 AA 4C AC AD 53 56
+ 56 56 B2 B3 56 5B B6 B7 5D 5D 5D 5D 5D 5D 5D 62
+ 62 62 C2 C3 62 62 C6 C7 C8 C9 CA 62 67 67 67 67
+ D0 D1 D2 D3 D4 D5 D6 D7 67 71 71 71 DC DD 71 71
+ 71 75 E2 E3 75 75 75 41 79 79 56 8D 8D 81 67 67
+ 81 81 81 81 81 81 81 81 8B 8B 5B 8D 5D 8D 53 FF
+
+# Unicode mappping (must be 256 elements)
+ 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
+ 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 001A 001B 001C 001D 001E 001F
+ 0020 0021 0022 0023 0024 0025 0026 0027 0028 0029 002A 002B 002C 002D 002E 002F
+ 0030 0031 0032 0033 0034 0035 0036 0037 0038 0039 003A 003B 003C 003D 003E 003F
+ 0040 0041 0042 0043 0044 0045 0046 0047 0048 0049 004A 004B 004C 004D 004E 004F
+ 0050 0051 0052 0053 0054 0055 0056 0057 0058 0059 005A 005B 005C 005D 005E 005F
+ 0060 0061 0062 0063 0064 0065 0066 0067 0068 0069 006A 006B 006C 006D 006E 006F
+ 0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 007A 007B 007C 007D 007E 007F
+ 00C4 0100 0101 00C9 0104 00D6 00DC 00E1 0105 010C 00E4 010D 0106 0107 00E9 0179
+ 017A 010E 00ED 010F 0112 0113 0116 00F3 0117 00F4 00F6 00F5 00FA 011A 011B 00FC
+ 2020 00B0 0118 00A3 00A7 2022 00B6 00DF 00AE 00A9 2122 0119 00A8 2260 0123 012E
+ 012F 012A 2264 2265 012B 0136 2202 2211 0142 013B 013C 013D 013E 0139 013A 0145
+ 0146 0143 00AC 221A 0144 0147 2206 00AB 00BB 2026 00A0 0148 0150 00D5 0151 014C
+ 2013 2014 201C 201D 2018 2019 00F7 25CA 014D 0154 0155 0158 2039 203A 0159 0156
+ 0157 0160 201A 201E 0161 015A 015B 00C1 0164 0165 00CD 017D 017E 016A 00D3 00D4
+ 016B 016E 00DA 016F 0170 0171 0172 0173 00DD 00FD 0137 017B 0141 017C 0122 02C7
+
diff --git a/sql/share/charsets/macroman.conf b/sql/share/charsets/macroman.conf
new file mode 100644
index 00000000000..11cbee40e94
--- /dev/null
+++ b/sql/share/charsets/macroman.conf
@@ -0,0 +1,91 @@
+# ctype array (must be 257 elements)
+ 00
+ 20 20 20 20 20 20 20 20 20 28 28 28 28 28 20 20
+ 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
+ 48 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 84 84 84 84 84 84 84 84 84 84 10 10 10 10 10 10
+ 10 81 81 81 81 81 81 01 01 01 01 01 01 01 01 01
+ 01 01 01 01 01 01 01 01 01 01 01 10 10 10 10 10
+ 10 82 82 82 82 82 82 02 02 02 02 02 02 02 02 02
+ 02 02 02 02 02 02 02 02 02 02 02 10 10 10 10 10
+ 20 01 01 01 01 01 01 02 02 02 02 02 02 02 02 02
+ 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+ 00 00 00 00 00 00 00 02 00 00 00 00 00 00 01 01
+ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 02
+ 00 00 00 00 02 00 00 00 00 00 00 20 01 01 00 00
+ 00 00 00 00 00 00 00 00 02 01 00 00 00 00 00 00
+ 00 00 00 00 00 20 01 01 01 01 01 01 01 01 01 01
+ 00 01 01 01 01 02 00 00 00 00 00 00 00 00 00 00
+
+# to_lower array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+ 70 71 72 73 74 75 76 77 78 79 7A 5B 5C 5D 5E 5F
+ 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+ 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
+ 8A 8C 8D 8E 96 9A 9F 87 88 89 8A 8B 8C 8D 8E 8F
+ 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
+ A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD BE BF
+ B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
+ C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA 88 8B 9B CE CF
+ D0 D1 D2 D3 D4 D5 D6 D7 D8 D8 DA DB DC DD DE DF
+ E0 E1 E2 E3 E4 89 90 87 91 8F 92 94 95 93 97 99
+ F0 98 9C 9E 9D F5 F6 F7 F8 F9 FA FB FC FD FE FF
+
+# to_upper array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+ 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+ 60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+ 50 51 52 53 54 55 56 57 58 59 5A 7B 7C 7D 7E 7F
+ 80 81 82 83 84 85 86 E7 CB E5 80 CC 81 82 83 E9
+ E6 E8 EA ED EB EC 84 EE F1 EF 85 CD F2 F4 F3 86
+ A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
+ B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD AE AF
+ C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ D0 D1 D2 D3 D4 D5 D6 D7 D9 D9 DA DB DC DD DE DF
+ E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
+ F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
+
+# sort_order array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 41 49 50 52 53 57 59 60 61 67 68 69 70 71 72
+ 79 80 81 82 84 85 90 91 92 93 95 A0 A1 A2 A3 A4
+ A5 41 49 50 52 53 57 59 60 61 67 68 69 70 71 72
+ 79 80 81 82 84 85 90 91 92 93 95 A6 A7 A8 A9 AA
+ 41 41 50 53 71 72 85 41 41 41 41 41 41 50 53 53
+ 53 53 61 61 61 61 71 72 72 72 72 72 85 85 85 85
+ AB AC AD AE AF B0 B1 82 B2 B3 B4 B5 B6 B7 48 72
+ B8 B9 BA BB BC BD BE BF C0 C1 C2 C3 C4 C5 48 72
+ C6 C7 C8 C9 57 CA CB CC CD CE CF 41 41 72 D0 D1
+ D2 D3 D4 D5 D6 D7 D8 D9 93 93 DA DB DC DD DE DF
+ E0 E1 E2 E3 E4 41 53 41 53 53 61 61 61 61 72 72
+ F0 72 85 85 85 61 F6 F7 F8 F9 FA FB FC FD FE FF
+
+# Unicode mappping (must be 256 elements)
+ 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
+ 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 001A 001B 001C 001D 001E 001F
+ 0020 0021 0022 0023 0024 0025 0026 0027 0028 0029 002A 002B 002C 002D 002E 002F
+ 0030 0031 0032 0033 0034 0035 0036 0037 0038 0039 003A 003B 003C 003D 003E 003F
+ 0040 0041 0042 0043 0044 0045 0046 0047 0048 0049 004A 004B 004C 004D 004E 004F
+ 0050 0051 0052 0053 0054 0055 0056 0057 0058 0059 005A 005B 005C 005D 005E 005F
+ 0060 0061 0062 0063 0064 0065 0066 0067 0068 0069 006A 006B 006C 006D 006E 006F
+ 0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 007A 007B 007C 007D 007E 007F
+ 00C4 00C5 00C7 00C9 00D1 00D6 00DC 00E1 00E0 00E2 00E4 00E3 00E5 00E7 00E9 00E8
+ 00EA 00EB 00ED 00EC 00EE 00EF 00F1 00F3 00F2 00F4 00F6 00F5 00FA 00F9 00FB 00FC
+ 2020 00B0 00A2 00A3 00A7 2022 00B6 00DF 00AE 00A9 2122 00B4 00A8 2260 00C6 00D8
+ 221E 00B1 2264 2265 00A5 00B5 2202 2211 220F 03C0 222B 00AA 00BA 03A9 00E6 00F8
+ 00BF 00A1 00AC 221A 0192 2248 2206 00AB 00BB 2026 00A0 00C0 00C3 00D5 0152 0153
+ 2013 2014 201C 201D 2018 2019 00F7 25CA 00FF 0178 2044 20AC 2039 203A FB01 FB02
+ 2021 00B7 201A 201E 2030 00C2 00CA 00C1 00CB 00C8 00CD 00CE 00CF 00CC 00D3 00D4
+ F8FF 00D2 00DA 00DB 00D9 0131 02C6 02DC 00AF 02D8 02D9 02DA 00B8 02DD 02DB 02C7
+
diff --git a/sql/share/charsets/pclatin2.conf b/sql/share/charsets/pclatin2.conf
new file mode 100644
index 00000000000..dea8d085595
--- /dev/null
+++ b/sql/share/charsets/pclatin2.conf
@@ -0,0 +1,91 @@
+# ctype array (must be 257 elements)
+ 00
+ 20 20 20 20 20 20 20 20 20 28 28 28 28 28 20 20
+ 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
+ 48 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 84 84 84 84 84 84 84 84 84 84 10 10 10 10 10 10
+ 10 81 81 81 81 81 81 01 01 01 01 01 01 01 01 01
+ 01 01 01 01 01 01 01 01 01 01 01 10 10 10 10 10
+ 10 82 82 82 82 82 82 02 02 02 02 02 02 02 02 02
+ 02 02 02 02 02 02 02 02 02 02 02 10 10 10 10 00
+ 01 02 02 02 02 02 02 02 02 02 01 02 02 01 01 01
+ 01 01 02 02 02 01 02 01 02 01 01 01 02 01 00 02
+ 02 02 02 02 01 02 01 02 01 02 00 02 01 01 00 00
+ 00 00 00 00 00 01 01 01 02 00 00 00 00 01 02 00
+ 00 00 00 00 00 00 01 02 00 00 00 00 00 00 00 00
+ 02 01 01 01 02 01 01 01 02 00 00 00 00 01 01 00
+ 01 02 01 01 02 02 01 02 01 01 02 01 02 01 02 00
+ 00 00 00 00 00 00 00 00 00 00 00 02 01 02 00 48
+
+# to_lower array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+ 70 71 72 73 74 75 76 77 78 79 7A 5B 5C 5D 5E 5F
+ 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+ 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
+ 87 81 82 83 84 85 86 87 88 89 8B 8B 8C AB 84 86
+ 82 92 92 93 94 96 96 98 98 94 81 9C 9C 88 9E 9F
+ A0 A1 A2 A3 A5 A5 A7 A7 A9 A9 AA AB 9F B8 AE AF
+ B0 B1 B2 B3 B4 A0 83 D8 B8 B9 BA BB BC BE BE BF
+ C0 C1 C2 C3 C4 C5 C7 C7 C8 C9 CA CB CC CD CE CF
+ D0 D0 D4 89 D4 E5 A1 8C D8 D9 DA DB DC EE 85 DF
+ A2 E1 93 E4 E4 E5 E7 E7 EA A3 E8 FB EC EC EE EF
+ F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
+
+# to_upper array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+ 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+ 60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+ 50 51 52 53 54 55 56 57 58 59 5A 7B 7C 7D 7E 7F
+ 80 9A 90 B6 8E DE 8F 80 9D D3 8A 8A D7 8D 8E 8F
+ 90 91 91 E2 99 95 95 97 97 99 9A 9B 9B 9D 9E AC
+ B5 D6 E0 E9 A4 A4 A6 A6 A8 A8 AA 8D AC AD AE AF
+ B0 B1 B2 B3 B4 B5 B6 B7 AD B9 BA BB BC BE BD BF
+ C0 C1 C2 C3 C4 C5 C6 C6 C8 C9 CA CB CC CD CE CF
+ D1 D1 D2 D3 D2 D5 D6 D7 B7 D9 DA DB DC DD DE DF
+ E0 E1 E2 E3 E3 D5 E6 E6 E8 E9 E8 EB ED ED DD EF
+ F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA EB FC FC FE FF
+
+# sort_order array (must be 256 elements)
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+ 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+ 40 41 47 48 4C 4F 54 55 56 57 5A 5B 5C 5E 5F 62
+ 67 68 69 6C 71 74 75 76 77 78 7B 90 91 92 93 94
+ 95 41 47 48 4C 4F 54 55 56 57 5A 5B 5C 5E 5F 62
+ 67 68 69 6C 71 74 75 76 77 78 7B 96 97 98 99 9A
+ 48 74 4F 41 41 74 48 48 5C 4F 62 62 57 7B 41 48
+ 4F 5C 5C 62 62 5C 5C 6C 6C 62 74 71 71 5C 9E 48
+ 41 57 62 74 41 41 7B 7B 4F 4F AA 7B 48 6C AE AF
+ B0 B1 B2 B3 B4 41 41 4F 6C B5 BA BB BC 7B 7B BF
+ C0 C1 C2 C3 C4 C5 41 41 C8 C9 CA CB CC CD CE CF
+ 4C 4C 4C 4F 4C 60 57 57 4F D9 DA DB DC 71 74 DF
+ 62 70 62 60 60 60 6C 6C 69 74 69 74 78 78 71 EF
+ F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA 74 69 69 FE FF
+
+# Unicode mappping (must be 256 elements)
+ 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
+ 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 001A 001B 001C 001D 001E 001F
+ 0020 0021 0022 0023 0024 0025 0026 0027 0028 0029 002A 002B 002C 002D 002E 002F
+ 0030 0031 0032 0033 0034 0035 0036 0037 0038 0039 003A 003B 003C 003D 003E 003F
+ 0040 0041 0042 0043 0044 0045 0046 0047 0048 0049 004A 004B 004C 004D 004E 004F
+ 0050 0051 0052 0053 0054 0055 0056 0057 0058 0059 005A 005B 005C 005D 005E 005F
+ 0060 0061 0062 0063 0064 0065 0066 0067 0068 0069 006A 006B 006C 006D 006E 006F
+ 0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 007A 007B 007C 007D 007E 007F
+ 00C7 00FC 00E9 00E2 00E4 016F 0107 00E7 0142 00EB 0150 0151 00EE 0179 00C4 0106
+ 00C9 0139 013A 00F4 00F6 013D 013E 015A 015B 00D6 00DC 0164 0165 0141 00D7 010D
+ 00E1 00ED 00F3 00FA 0104 0105 017D 017E 0118 0119 00AC 017A 010C 015F 00AB 00BB
+ 2591 2592 2593 2502 2524 00C1 00C2 011A 015E 2563 2551 2557 255D 017B 017C 2510
+ 2514 2534 252C 251C 2500 253C 0102 0103 255A 2554 2569 2566 2560 2550 256C 00A4
+ 0111 0110 010E 00CB 010F 0147 00CD 00CE 011B 2518 250C 2588 2584 0162 016E 2580
+ 00D3 00DF 00D4 0143 0144 0148 0160 0161 0154 00DA 0155 0170 00FD 00DD 0163 00B4
+ 00AD 02DD 02DB 02C7 02D8 00A7 00F7 00B8 00B0 00A8 02D9 0171 0158 0159 25A0 00A0
+
diff --git a/sql/spatial.cc b/sql/spatial.cc
index bb6e03c3c03..b21d30e4b53 100644
--- a/sql/spatial.cc
+++ b/sql/spatial.cc
@@ -285,7 +285,7 @@ int GLineString::get_mbr(MBR *mbr) const
return 1;
for (; n_points>0; --n_points)
{
- mbr->add_xy((double *)data, (double *)(data + 8));
+ mbr->add_xy(data, data + 8);
data += 8+8;
}
@@ -551,7 +551,7 @@ int GPolygon::get_mbr(MBR *mbr) const
return 1;
for (; n_points>0; --n_points)
{
- mbr->add_xy((double *)data, (double *)(data + 8));
+ mbr->add_xy(data, data + 8);
data += 8+8;
}
}
@@ -838,8 +838,7 @@ int GMultiPoint::get_mbr(MBR *mbr) const
return 1;
for (; n_points>0; --n_points)
{
- mbr->add_xy((double *)(data + WKB_HEADER_SIZE),
- (double *)(data + 8 + WKB_HEADER_SIZE));
+ mbr->add_xy(data + WKB_HEADER_SIZE, data + 8 + WKB_HEADER_SIZE);
data += (8+8+WKB_HEADER_SIZE);
}
return 0;
@@ -963,7 +962,7 @@ int GMultiLineString::get_mbr(MBR *mbr) const
for (; n_points>0; --n_points)
{
- mbr->add_xy((double *)data, (double *)(data + 8));
+ mbr->add_xy(data, data + 8);
data += 8+8;
}
}
@@ -1156,7 +1155,7 @@ int GMultiPolygon::get_mbr(MBR *mbr) const
for (; n_points>0; --n_points)
{
- mbr->add_xy((double *)data, (double *)(data + 8));
+ mbr->add_xy(data, data + 8);
data += 8+8;
}
}
diff --git a/sql/spatial.h b/sql/spatial.h
index 2daa8e856c9..c6e30a44fbf 100644
--- a/sql/spatial.h
+++ b/sql/spatial.h
@@ -71,7 +71,7 @@ struct MBR
}
}
- void add_xy(double *px, double *py)
+ void add_xy(const char *px, const char *py)
{ /* Not using "else" for proper one point MBR calculation */
double x, y;
float8get(x, px);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 95f9e15331f..a15cb23fbee 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2117,7 +2117,7 @@ fill_record(List<Item> &fields,List<Item> &values)
while ((field=(Item_field*) f++))
{
value=v++;
- if (value->save_in_field(field->field))
+ if (value->save_in_field(field->field) > 0)
DBUG_RETURN(1);
}
DBUG_RETURN(0);
@@ -2135,7 +2135,7 @@ fill_record(Field **ptr,List<Item> &values)
while ((field = *ptr++))
{
value=v++;
- if (value->save_in_field(field))
+ if (value->save_in_field(field) == 1)
DBUG_RETURN(1);
}
DBUG_RETURN(0);
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index a98012653b3..3668a817165 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -179,7 +179,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
Item *item;
for (key_len=0 ; (item=it_ke++) ; key_part++)
{
- item->save_in_field(key_part->field);
+ (void) item->save_in_field(key_part->field);
key_len+=key_part->store_length;
}
if (!(key= (byte*) sql_calloc(ALIGN_SIZE(key_len))))
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 26b59207f5d..b75826663ca 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -260,7 +260,7 @@ private:
bool create_total_list_n_last_return(THD *thd, st_lex *lex,
TABLE_LIST ***result);
};
-typedef struct st_select_lex_unit SELECT_LEX_UNIT;
+typedef class st_select_lex_unit SELECT_LEX_UNIT;
/*
SELECT_LEX - store information of parsed SELECT_LEX statment
@@ -312,7 +312,7 @@ public:
friend void mysql_init_query(THD *thd);
};
-typedef struct st_select_lex SELECT_LEX;
+typedef class st_select_lex SELECT_LEX;
class Set_option :public Sql_alloc {
public:
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 49a961c1a78..9977eaad0ff 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1600,7 +1600,7 @@ mysql_execute_command(void)
res = mysql_create_table(thd,tables->db ? tables->db : thd->db,
tables->real_name, &lex->create_info,
lex->create_list,
- lex->key_list,0, 0); // do logging
+ lex->key_list,0,0,0); // do logging
if (!res)
send_ok(&thd->net);
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 690270d6407..d071743aec4 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2486,7 +2486,7 @@ store_val_in_field(Field *field,Item *item)
THD *thd=current_thd;
ulong cuted_fields=thd->cuted_fields;
thd->count_cuted_fields=1;
- item->save_in_field(field);
+ (void) item->save_in_field(field);
thd->count_cuted_fields=0;
return cuted_fields != thd->cuted_fields;
}
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 0f7e08d268e..495dd7f7ab7 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -340,7 +340,7 @@ public:
{}
bool copy()
{
- item->save_in_field(to_field);
+ (void) item->save_in_field(to_field);
return err != 0;
}
const char *name() const { return "func"; }
@@ -364,7 +364,7 @@ public:
if (!inited)
{
inited=1;
- item->save_in_field(to_field);
+ (void)item->save_in_field(to_field);
}
return err != 0;
}
diff --git a/sql/sql_select.h.rej b/sql/sql_select.h.rej
deleted file mode 100644
index 07b1c4403f9..00000000000
--- a/sql/sql_select.h.rej
+++ /dev/null
@@ -1,96 +0,0 @@
-***************
-*** 173,178 ****
- select_result *result;
- TMP_TABLE_PARAM tmp_table_param;
- MYSQL_LOCK *lock;
- };
-
-
---- 172,240 ----
- select_result *result;
- TMP_TABLE_PARAM tmp_table_param;
- MYSQL_LOCK *lock;
-+
-+ bool select_distinct, //Is select distinct?
-+ no_order, simple_order, simple_group,
-+ skip_sort_order, need_tmp,
-+ hidden_group_fields,
-+ buffer_result;
-+ DYNAMIC_ARRAY keyuse;
-+ Item::cond_result cond_value;
-+ List<Item> all_fields;
-+ List<Item> & fields_list; // hold field list passed to mysql_select
-+ int error;
-+
-+ ORDER *order, *group_list, *proc_param; //hold parameters of mysql_select
-+ COND *conds; // ---"---
-+ TABLE_LIST *tables_list; //hold 'tables' parameter of mysql_select
-+ SQL_SELECT *select; //created in optimisation phase
-+ TABLE *exec_tmp_table; //used in 'exec' to hold temporary table
-+ SELECT_LEX *select_lex; //corresponding select_lex
-+
-+ my_bool test_function_query; // need to return select items 1 row
-+ const char *zero_result_cause; // not 0 if exec must return zero result
-+
-+ JOIN(THD *thd, List<Item> &fields,
-+ ulong select_options, select_result *result):
-+ join_tab(0),
-+ table(0),
-+ tables(0), const_tables(0),
-+ sort_and_group(0), first_record(0),
-+ do_send_rows(1),
-+ send_records(0), found_records(0), examined_rows(0),
-+ thd(thd),
-+ sum_funcs(0),
-+ having(0),
-+ select_options(select_options),
-+ result(result),
-+ lock(thd->lock),
-+ select_distinct(test(select_options & SELECT_DISTINCT)),
-+ no_order(0), simple_order(0), simple_group(0), skip_sort_order(0),
-+ need_tmp(0),
-+ hidden_group_fields (0), /*safety*/
-+ buffer_result(test(select_options & OPTION_BUFFER_RESULT) &&
-+ !test(select_options & OPTION_FOUND_ROWS)),
-+ all_fields(fields),
-+ fields_list(fields),
-+ select(0),
-+ exec_tmp_table(0),
-+ select_lex(0), //for safety
-+ test_function_query(0),
-+ zero_result_cause(0)
-+ {
-+ fields_list = fields;
-+ bzero((char*) &keyuse,sizeof(keyuse));
-+ tmp_table_param.copy_field=0;
-+ tmp_table_param.end_write_records= HA_POS_ERROR;
-+ }
-+
-+ int prepare(TABLE_LIST *tables,
-+ COND *conds, ORDER *order, ORDER *group, Item *having,
-+ ORDER *proc_param, SELECT_LEX *select);
-+ int optimize();
-+ int global_optimize();
-+ void exec();
-+ int cleanup(THD *thd);
- };
-
-
-***************
-*** 187,193 ****
- bool store_val_in_field(Field *field,Item *val);
- TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
- ORDER *group, bool distinct, bool save_sum_fields,
-- bool allow_distinct_limit, ulong select_options);
- void free_tmp_table(THD *thd, TABLE *entry);
- void count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields,
- bool reset_with_sum_func);
---- 249,256 ----
- bool store_val_in_field(Field *field,Item *val);
- TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
- ORDER *group, bool distinct, bool save_sum_fields,
-+ bool allow_distinct_limit, ulong select_options,
-+ SELECT_LEX *first_select);
- void free_tmp_table(THD *thd, TABLE *entry);
- void count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields,
- bool reset_with_sum_func);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 494607c7fff..e227a5bf5ca 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1381,8 +1381,10 @@ int mysqld_show_charsets(THD *thd, const char *wild)
if (send_fields(thd,field_list,1))
DBUG_RETURN(1);
- for (cs=compiled_charsets ; cs->name ; cs++ )
+ for (cs=all_charsets ; cs < all_charsets+255 ; cs++ )
{
+ if (!cs->name)
+ continue;
if (!(wild && wild[0] && wild_case_compare(system_charset_info,cs->name,wild)))
{
packet2.length(0);
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index d8012c0c102..3652b2512f4 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -70,7 +70,7 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
}
error=mysql_rm_table_part2(thd,tables,if_exists,0);
- err:
+ err:
VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh
pthread_mutex_unlock(&LOCK_open);
@@ -209,7 +209,6 @@ int quick_rm_table(enum db_type base,const char *db,
PRIMARY keys are prioritized.
*/
-
static int sort_keys(KEY *a, KEY *b)
{
if (a->flags & HA_NOSAME)
@@ -251,7 +250,8 @@ static int sort_keys(KEY *a, KEY *b)
int mysql_create_table(THD *thd,const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
List<create_field> &fields,
- List<Key> &keys,bool tmp_table,bool no_log)
+ List<Key> &keys,bool tmp_table,bool no_log,
+ uint select_field_count)
{
char path[FN_REFLEN];
const char *key_name;
@@ -259,10 +259,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
int error= -1;
uint db_options,field,null_fields,blob_columns;
ulong pos;
- KEY *key_info,*key_info_buffer;
+ KEY *key_info,*key_info_buffer;
KEY_PART_INFO *key_part_info;
int auto_increment=0;
handler *file;
+ int field_no,dup_no;
DBUG_ENTER("mysql_create_table");
/*
@@ -275,6 +276,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
DBUG_RETURN(-1);
}
List_iterator<create_field> it(fields),it2(fields);
+ int select_field_pos=fields.elements - select_field_count;
null_fields=blob_columns=0;
db_options=create_info->table_options;
if (create_info->row_type == ROW_TYPE_DYNAMIC)
@@ -288,10 +290,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
DBUG_RETURN(-1);
}
- /* Don't pack keys in old tables if the user has requested this */
- while ((sql_field=it++))
+ for(field_no=0; (sql_field=it++) ; field_no++)
{
+ /* Don't pack keys in old tables if the user has requested this */
if ((sql_field->flags & BLOB_FLAG) ||
sql_field->sql_type == FIELD_TYPE_VAR_STRING &&
create_info->row_type != ROW_TYPE_FIXED)
@@ -300,14 +302,29 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
}
if (!(sql_field->flags & NOT_NULL_FLAG))
null_fields++;
- while ((dup_field=it2++) != sql_field)
+ for(dup_no=0; (dup_field=it2++) != sql_field; dup_no++)
{
- if (my_strcasecmp(system_charset_info,
- sql_field->field_name,
+ if (my_strcasecmp(system_charset_info,
+ sql_field->field_name,
dup_field->field_name) == 0)
{
- my_error(ER_DUP_FIELDNAME,MYF(0),sql_field->field_name);
- DBUG_RETURN(-1);
+ if (field_no<select_field_pos || dup_no>=select_field_pos)
+ {
+ my_error(ER_DUP_FIELDNAME,MYF(0),sql_field->field_name);
+ DBUG_RETURN(-1);
+ }
+ else
+ {
+ sql_field->length=dup_field->length;
+ sql_field->decimals=dup_field->decimals;
+ sql_field->flags=dup_field->flags;
+ sql_field->pack_length=dup_field->pack_length;
+ sql_field->unireg_check=dup_field->unireg_check;
+ sql_field->sql_type=dup_field->sql_type;
+ it2.remove();
+ select_field_pos--;
+ break;
+ }
}
}
it2.rewind();
@@ -793,6 +810,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
TABLE tmp_table; // Used during 'create_field()'
TABLE *table;
tmp_table.table_name=0;
+ uint select_field_count=0;
DBUG_ENTER("create_table_from_items");
/* Add selected items to field list */
@@ -826,11 +844,12 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
(Field*) 0))))
DBUG_RETURN(0);
extra_fields->push_back(cr_field);
+ select_field_count++;
}
/* create and lock table */
/* QQ: This should be done atomic ! */
if (mysql_create_table(thd,db,name,create_info,*extra_fields,
- *keys,0,1)) // no logging
+ *keys,0,1,select_field_count)) // no logging
DBUG_RETURN(0);
if (!(table=open_table(thd,db,name,name,(bool*) 0)))
{
@@ -1719,7 +1738,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
if ((error=mysql_create_table(thd, new_db, tmp_name,
create_info,
- create_list,key_list,1,1))) // no logging
+ create_list,key_list,1,1,0))) // no logging
DBUG_RETURN(error);
if (table->tmp_table)
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index b762388d9be..e9eb5f67b0d 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -167,6 +167,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token CHECK_SYM
%token CIPHER
%token COMMITTED_SYM
+%token COLLATE_SYM
%token COLUMNS
%token COLUMN_SYM
%token CONCURRENT
@@ -522,7 +523,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%left '*' '/' '%'
%left NEG '~'
%right NOT
-%right BINARY
+%right BINARY COLLATE_SYM
%type <lex_str>
IDENT TEXT_STRING REAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM LEX_HOSTNAME
@@ -1129,7 +1130,7 @@ charset:
{
if (!(Lex->charset=get_charset_by_name($1.str,MYF(0))))
{
- net_printf(&current_thd->net,ER_UNKNOWN_CHARACTER_SET,$1);
+ net_printf(&current_thd->net,ER_UNKNOWN_CHARACTER_SET,$1.str);
YYABORT;
}
};
@@ -1658,7 +1659,16 @@ expr_expr:
| expr '+' INTERVAL_SYM expr interval
{ $$= new Item_date_add_interval($1,$4,$5,0); }
| expr '-' INTERVAL_SYM expr interval
- { $$= new Item_date_add_interval($1,$4,$5,1); };
+ { $$= new Item_date_add_interval($1,$4,$5,1); }
+ | expr COLLATE_SYM ident
+ {
+ if (!(Lex->charset=get_charset_by_name($3.str,MYF(0))))
+ {
+ net_printf(&current_thd->net,ER_UNKNOWN_CHARACTER_SET,$3.str);
+ YYABORT;
+ }
+ $$= new Item_func_set_collation($1,Lex->charset);
+ };
/* expressions that begin with 'expr' that do NOT follow IN_SYM */
no_in_expr:
@@ -3446,7 +3456,7 @@ option_value:
CONVERT *tmp;
if (!(tmp=get_convert_set($3.str)))
{
- net_printf(&current_thd->net,ER_UNKNOWN_CHARACTER_SET,$3);
+ net_printf(&current_thd->net,ER_UNKNOWN_CHARACTER_SET,$3.str);
YYABORT;
}
current_thd->convert_set=tmp;
diff --git a/sql/unireg.cc b/sql/unireg.cc
index f2d8d6532a9..57a1407ea06 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -590,7 +590,7 @@ static bool make_empty_rec(File file,enum db_type table_type,
if (field->def &&
(regfield->real_type() != FIELD_TYPE_YEAR ||
field->def->val_int() != 0))
- field->def->save_in_field(regfield);
+ (void) field->def->save_in_field(regfield);
else if (regfield->real_type() == FIELD_TYPE_ENUM &&
(field->flags & NOT_NULL_FLAG))
{