MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:monty Date:April 1 2005 12:04pm
Subject:bk commit into 5.0 tree (monty:1.1844) BUG#5933
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of monty. When monty does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1844 05/04/01 15:04:50 monty@stripped +42 -0
  Invalid DEFAULT values for CREATE TABLE now generates errors. (Bug #5902)
  CAST() now produces warnings when casting a wrong INTEGER or CHAR values. This also applies to implicite string to number casts. (Bug #5912)
  ALTER TABLE now fails in STRICT mode if it generates warnings.
  Inserting a zero date in a DATE, DATETIME or TIMESTAMP column during TRADITIONAL mode now produces an error. (Bug #5933)

  sql/sql_error.h
    1.1 05/04/01 15:04:45 monty@stripped +42 -0

  sql/unireg.cc
    1.52 05/04/01 15:04:45 monty@stripped +17 -5
    Removed one call to current_thd
    Give errors if one uses a wrong DEFAULT value

  sql/time.cc
    1.55 05/04/01 15:04:45 monty@stripped +3 -3
    Fixed possible wrong call

  sql/sql_table.cc
    1.230 05/04/01 15:04:45 monty@stripped +36 -26
    Made mysql_prepare_table() static
    Changed references to pointers to make code more readable
    ALTER TABLE now aborts if one gets warnings in STRICT mode

  sql/sql_error.h
    1.0 05/04/01 15:04:45 monty@stripped +0 -0
    BitKeeper file /home/my/mysql-5.0/sql/sql_error.h

  sql/sql_parse.cc
    1.435 05/04/01 15:04:44 monty@stripped +4 -3
    Fixed wrong printf()

  sql/sql_load.cc
    1.78 05/04/01 15:04:44 monty@stripped +1 -1
    Removed wrong cast

  sql/sql_class.h
    1.228 05/04/01 15:04:44 monty@stripped +0 -21
    Moved to sql_error.h

  sql/mysqld.cc
    1.447 05/04/01 15:04:44 monty@stripped +2 -2
    Simplify code

  sql/mysql_priv.h
    1.284 05/04/01 15:04:44 monty@stripped +1 -14
    Removed prototype for static function
    Moved defines for error handling to sql_error.h (to be able to use these in field.h)

  sql/my_decimal.cc
    1.8 05/04/01 15:04:44 monty@stripped +1 -1
    Fixed typo in comment

  sql/item_timefunc.cc
    1.78 05/04/01 15:04:44 monty@stripped +22 -14
    Give warnings for wrong CAST of number -> string

  sql/item_sum.cc
    1.136 05/04/01 15:04:44 monty@stripped +1 -2
    Better detection of null values (which doesn't produce warnings)

  sql/item_row.cc
    1.29 05/04/01 15:04:44 monty@stripped +2 -2
    Better detection of null values (which doesn't produce warnings)

  sql/item.h
    1.109 05/04/01 15:04:44 monty@stripped +2 -15
    Moved Item_string::val_real() and ::val_int() to item.cc

  sql/item.cc
    1.128 05/04/01 15:04:44 monty@stripped +57 -3
    Removed compiler warnings
    Give warnings for wrong CAST of strings -> number

  sql/field_conv.cc
    1.43 05/04/01 15:04:44 monty@stripped +14 -2
    Copy date and datetime fields through string in 'traditional' mode to detect zero dates

  sql/field.h
    1.147 05/04/01 15:04:44 monty@stripped +4 -4
    Changed type for 'level' in set_warning() to avoid casts

  sql/field.cc
    1.248 05/04/01 15:04:44 monty@stripped +100 -50
    Added warnings for zero dates for DATE, DATETIME and TIMESTAMP
    Moved Field_blob::max_length() to a more appropriate position
    Changed type for 'level' in set_warning() to avoid casts

  sql/Makefile.am
    1.105 05/04/01 15:04:44 monty@stripped +1 -1
    Added new include file

  mysql-test/t/type_ranges.test
    1.11 05/04/01 15:04:44 monty@stripped +1 -1
    Changed tests to produce less warnings

  mysql-test/t/subselect.test
    1.93 05/04/01 15:04:44 monty@stripped +2 -2
    Changed tests to produce less warnings

  mysql-test/t/strict.test
    1.20 05/04/01 15:04:44 monty@stripped +52 -0
    New tests for CAST() and zero date handling

  mysql-test/t/rpl_session_var.test
    1.3 05/04/01 15:04:44 monty@stripped +1 -1
    Changed tests to produce less warnings

  mysql-test/t/ps_1general.test
    1.20 05/04/01 15:04:44 monty@stripped +2 -2
    Changed tests to produce less warnings

  mysql-test/t/ndb_index_unique.test
    1.14 05/04/01 15:04:44 monty@stripped +4 -4
    Removed wrong default usage

  mysql-test/t/func_str.test
    1.71 05/04/01 15:04:44 monty@stripped +2 -3
    Added missing drop table
    Changed test to produce less warnings
    New warnings

  mysql-test/t/func_if.test
    1.11 05/04/01 15:04:44 monty@stripped +3 -2
    Changed tests to produce less warnings

  mysql-test/t/create.test
    1.51 05/04/01 15:04:43 monty@stripped +15 -4
    Added test for wrong default values (#5902)

  mysql-test/t/cast.test
    1.18 05/04/01 15:04:43 monty@stripped +13 -0
    Added testing of wrong CAST's of strings to numbers and numbers to strings

  mysql-test/r/type_ranges.result
    1.32 05/04/01 15:04:43 monty@stripped +3 -3
    Changed tests to produce less warnings

  mysql-test/r/subselect.result
    1.108 05/04/01 15:04:43 monty@stripped +7 -5
    Changed tests to produce less warnings

  mysql-test/r/strict.result
    1.22 05/04/01 15:04:43 monty@stripped +64 -0
    New tests for CAST() and zero date handling

  mysql-test/r/rpl_session_var.result
    1.3 05/04/01 15:04:43 monty@stripped +3 -3
    Changed tests to produce less warnings

  mysql-test/r/row.result
    1.20 05/04/01 15:04:43 monty@stripped +5 -0
    New warnings

  mysql-test/r/ps_1general.result
    1.36 05/04/01 15:04:43 monty@stripped +8 -8
    Changed tests to produce less warnings

  mysql-test/r/ndb_index_unique.result
    1.16 05/04/01 15:04:43 monty@stripped +4 -4
    Removed wrong default usage

  mysql-test/r/func_str.result
    1.97 05/04/01 15:04:43 monty@stripped +6 -4
    Added missing drop table
    Changed test to produce less warnings
    New warnings

  mysql-test/r/func_misc.result
    1.17 05/04/01 15:04:43 monty@stripped +2 -0
    New warning

  mysql-test/r/func_if.result
    1.17 05/04/01 15:04:43 monty@stripped +11 -6
    Changed tests to produce less warnings

  mysql-test/r/create.result
    1.83 05/04/01 15:04:43 monty@stripped +15 -3
    Added test for wrong default values (#5902)

  mysql-test/r/cast.result
    1.26 05/04/01 15:04:43 monty@stripped +68 -0
    Added testing of wrong CAST's of strings to numbers and numbers to strings

  mysql-test/r/bigint.result
    1.26 05/04/01 15:04:43 monty@stripped +2 -0
    New warning added

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	monty
# Host:	narttu.mysql.com
# Root:	/home/my/mysql-5.0

--- 1.104/sql/Makefile.am	2005-03-25 20:36:55 +02:00
+++ 1.105/sql/Makefile.am	2005-04-01 15:04:44 +03:00
@@ -49,7 +49,7 @@
 			mysql_priv.h item_geofunc.h sql_bitmap.h \
 			procedure.h sql_class.h sql_lex.h sql_list.h \
 			sql_manager.h sql_map.h sql_string.h unireg.h \
-			field.h handler.h mysqld_suffix.h \
+			sql_error.h field.h handler.h mysqld_suffix.h \
 			ha_myisammrg.h\
 			ha_heap.h ha_myisam.h ha_berkeley.h ha_innodb.h \
 			ha_ndbcluster.h opt_range.h protocol.h \

--- 1.247/sql/field.cc	2005-03-30 23:41:38 +03:00
+++ 1.248/sql/field.cc	2005-04-01 15:04:44 +03:00
@@ -3735,6 +3735,13 @@
     set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, 
                          WARN_DATA_TRUNCATED,
                          nr, MYSQL_TIMESTAMP_DATETIME, 1);
+  if (!error && timestamp == 0 &&
+      (table->in_use->variables.sql_mode & MODE_NO_ZERO_DATE))
+  {
+    set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, 
+                         WARN_DATA_TRUNCATED,
+                         nr, MYSQL_TIMESTAMP_DATETIME, 1);
+  }
 
 #ifdef WORDS_BIGENDIAN
   if (table->s->db_low_byte_first)
@@ -4360,6 +4367,12 @@
   }
   else
     tmp=(long) rint(nr);
+
+  /*
+    We don't need to check for zero dates here as this date type is only
+    used in .frm tables from very old MySQL versions
+  */
+
 #ifdef WORDS_BIGENDIAN
   if (table->s->db_low_byte_first)
   {
@@ -4388,6 +4401,7 @@
   }
   else
     tmp=(long) nr;
+
 #ifdef WORDS_BIGENDIAN
   if (table->s->db_low_byte_first)
   {
@@ -4500,6 +4514,7 @@
   res.set_ascii("date", 4);
 }
 
+
 /****************************************************************************
 ** The new date type
 ** This is identical to the old date type, but stored on 3 bytes instead of 4
@@ -4532,17 +4547,17 @@
   return error;
 }
 
+
 int Field_newdate::store(double nr)
 {
   if (nr < 0.0 || nr > 99991231235959.0)
   {
-    (void) Field_newdate::store((longlong) -1);
+    int3store(ptr,(int32) 0);
     set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, 
                          WARN_DATA_TRUNCATED, nr, MYSQL_TIMESTAMP_DATE);
     return 1;
   }
-  else
-    return Field_newdate::store((longlong) rint(nr));
+  return Field_newdate::store((longlong) rint(nr));
 }
 
 
@@ -4562,6 +4577,8 @@
   }
   else
   {
+    uint month, day;
+
     tmp=(int32) nr;
     if (tmp)
     {
@@ -4569,24 +4586,33 @@
 	tmp+= (uint32) 20000000L;
       else if (tmp < 999999L)
 	tmp+= (uint32) 19000000L;
+
+      month= (uint) ((tmp/100) % 100);
+      day=   (uint) (tmp%100);
+      if (month > 12 || day > 31)
+      {
+        tmp=0L;					// Don't allow date to change
+        set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, 
+                             ER_WARN_DATA_OUT_OF_RANGE, nr,
+                             MYSQL_TIMESTAMP_DATE, 1);
+        error= 1;
+      }
+      else
+        tmp= day + month*32 + (tmp/10000)*16*32;
     }
-    uint month= (uint) ((tmp/100) % 100);
-    uint day=   (uint) (tmp%100);
-    if (month > 12 || day > 31)
+    else if (table->in_use->variables.sql_mode & MODE_NO_ZERO_DATE)
     {
-      tmp=0L;					// Don't allow date to change
       set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, 
-                           ER_WARN_DATA_OUT_OF_RANGE, nr,
-                           MYSQL_TIMESTAMP_DATE, 1);
+                           ER_WARN_DATA_OUT_OF_RANGE, 
+                           0, MYSQL_TIMESTAMP_DATE);
       error= 1;
     }
-    else
-      tmp= day + month*32 + (tmp/10000)*16*32;
   }
-  int3store(ptr,(int32) tmp);
+  int3store(ptr, tmp);
   return error;
 }
 
+
 int Field_newdate::store_time(TIME *ltime,timestamp_type type)
 {
   long tmp;
@@ -4603,6 +4629,7 @@
   return error;
 }
 
+
 bool Field_newdate::send_binary(Protocol *protocol)
 {
   TIME tm;
@@ -4610,11 +4637,13 @@
   return protocol->store_date(&tm);
 }
 
+
 double Field_newdate::val_real(void)
 {
   return (double) Field_newdate::val_int();
 }
 
+
 longlong Field_newdate::val_int(void)
 {
   ulong j= uint3korr(ptr);
@@ -4622,6 +4651,7 @@
   return (longlong) j;
 }
 
+
 String *Field_newdate::val_str(String *val_buffer,
 			       String *val_ptr __attribute__((unused)))
 {
@@ -4649,6 +4679,7 @@
   return val_buffer;
 }
 
+
 bool Field_newdate::get_date(TIME *ltime,uint fuzzydate)
 {
   uint32 tmp=(uint32) uint3korr(ptr);
@@ -4661,11 +4692,13 @@
           1 : 0);
 }
 
+
 bool Field_newdate::get_time(TIME *ltime)
 {
   return Field_newdate::get_date(ltime,0);
 }
 
+
 int Field_newdate::cmp(const char *a_ptr, const char *b_ptr)
 {
   uint32 a,b;
@@ -4674,6 +4707,7 @@
   return (a < b) ? -1 : (a > b) ? 1 : 0;
 }
 
+
 void Field_newdate::sort_string(char *to,uint length __attribute__((unused)))
 {
   to[0] = ptr[2];
@@ -4681,6 +4715,7 @@
   to[2] = ptr[0];
 }
 
+
 void Field_newdate::sql_type(String &res) const
 {
   res.set_ascii("date", 4);
@@ -4737,10 +4772,10 @@
     set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, 
                          ER_WARN_DATA_OUT_OF_RANGE,
                          nr, MYSQL_TIMESTAMP_DATETIME);
-    nr=0.0;
+    nr= 0.0;
     error= 1;
   }
-  error |= Field_datetime::store((longlong) rint(nr));
+  error|= Field_datetime::store((longlong) rint(nr));
   return error;
 }
 
@@ -4757,6 +4792,13 @@
     set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, 
                          WARN_DATA_TRUNCATED, initial_nr, 
                          MYSQL_TIMESTAMP_DATETIME, 1);
+  else if (nr == 0 && table->in_use->variables.sql_mode & MODE_NO_ZERO_DATE)
+  {
+    set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, 
+                         ER_WARN_DATA_OUT_OF_RANGE, 
+                         initial_nr, MYSQL_TIMESTAMP_DATE);
+    error= 1;
+  }
 
 #ifdef WORDS_BIGENDIAN
   if (table->s->db_low_byte_first)
@@ -7542,7 +7584,37 @@
 }
 
 
-/* Warning handling */
+/*
+  maximum possible display length for blob
+
+  SYNOPSIS
+    Field_blob::max_length()
+
+  RETURN
+    length
+*/
+uint32 Field_blob::max_length()
+{
+  switch (packlength)
+  {
+  case 1:
+    return 255;
+  case 2:
+    return 65535;
+  case 3:
+    return 16777215;
+  case 4:
+    return (uint32) 4294967295U;
+  default:
+    DBUG_ASSERT(0); // we should never go here
+    return 0;
+  }
+}
+
+
+/*****************************************************************************
+ Warning handling
+*****************************************************************************/
 
 /*
   Produce warning or note about data saved into field
@@ -7558,18 +7630,20 @@
     if count_cuted_fields == FIELD_CHECK_IGNORE for current thread.
 
   RETURN VALUE
-    true  - if count_cuted_fields == FIELD_CHECK_IGNORE
-    false - otherwise
+    1 if count_cuted_fields == FIELD_CHECK_IGNORE
+    0 otherwise
 */
+
 bool 
-Field::set_warning(uint level, uint code, int cuted_increment)
+Field::set_warning(MYSQL_ERROR::enum_warning_level level, uint code,
+                   int cuted_increment)
 {
   THD *thd= table->in_use;
   if (thd->count_cuted_fields)
   {
     thd->cuted_fields+= cuted_increment;
-    push_warning_printf(thd, (MYSQL_ERROR::enum_warning_level) level,
-                        code, ER(code), field_name, thd->row_count);
+    push_warning_printf(thd, level, code, ER(code), field_name,
+                        thd->row_count);
     return 0;
   }
   return 1;
@@ -7593,8 +7667,9 @@
     fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current 
     thread.
 */
+
 void 
-Field::set_datetime_warning(const uint level, const uint code, 
+Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code, 
                             const char *str, uint str_length, 
                             timestamp_type ts_type, int cuted_increment)
 {
@@ -7621,8 +7696,9 @@
     fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current 
     thread.
 */
+
 void 
-Field::set_datetime_warning(const uint level, const uint code, 
+Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code, 
                             longlong nr, timestamp_type ts_type,
                             int cuted_increment)
 {
@@ -7652,8 +7728,9 @@
     fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current 
     thread.
 */
+
 void 
-Field::set_datetime_warning(const uint level, const uint code, 
+Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code, 
                             double nr, timestamp_type ts_type)
 {
   if (table->in_use->really_abort_on_warning() ||
@@ -7664,32 +7741,5 @@
     uint str_len= my_sprintf(str_nr, (str_nr, "%g", nr));
     make_truncated_value_warning(table->in_use, str_nr, str_len, ts_type,
                                  field_name);
-  }
-}
-
-/*
-  maximum possible display length for blob
-
-  SYNOPSIS
-    Field_blob::max_length()
-
-  RETURN
-    length
-*/
-uint32 Field_blob::max_length()
-{
-  switch (packlength)
-  {
-  case 1:
-    return 255;
-  case 2:
-    return 65535;
-  case 3:
-    return 16777215;
-  case 4:
-    return (uint32) 4294967295U;
-  default:
-    DBUG_ASSERT(0); // we should never go here
-    return 0;
   }
 }

--- 1.146/sql/field.h	2005-03-19 02:12:20 +02:00
+++ 1.147/sql/field.h	2005-04-01 15:04:44 +03:00
@@ -279,17 +279,17 @@
   virtual CHARSET_INFO *sort_charset(void) const { return charset(); }
   virtual bool has_charset(void) const { return FALSE; }
   virtual void set_charset(CHARSET_INFO *charset) { }
-  bool set_warning(unsigned int level, unsigned int code,
+  bool set_warning(MYSQL_ERROR::enum_warning_level, unsigned int code,
                    int cuted_increment);
   bool check_int(const char *str, int length, const char *int_end,
                  CHARSET_INFO *cs);
-  void set_datetime_warning(const uint level, const uint code, 
+  void set_datetime_warning(MYSQL_ERROR::enum_warning_level, uint code, 
                             const char *str, uint str_len,
                             timestamp_type ts_type, int cuted_increment);
-  void set_datetime_warning(const uint level, const uint code, 
+  void set_datetime_warning(MYSQL_ERROR::enum_warning_level, uint code, 
                             longlong nr, timestamp_type ts_type,
                             int cuted_increment);
-  void set_datetime_warning(const uint level, const uint code, 
+  void set_datetime_warning(MYSQL_ERROR::enum_warning_level, const uint code, 
                             double nr, timestamp_type ts_type);
   inline bool check_overflow(int op_result)
   {

--- 1.42/sql/field_conv.cc	2005-02-09 00:49:33 +02:00
+++ 1.43/sql/field_conv.cc	2005-04-01 15:04:44 +03:00
@@ -508,8 +508,16 @@
     // Check if identical fields
     if (from->result_type() == STRING_RESULT)
     {
+      /*
+        If we are copying date or datetime's we have to check the dates
+        if we don't allow 'all' dates.
+p      */
       if (to->real_type() != from->real_type() ||
-          !compatible_db_low_byte_first)
+          !compatible_db_low_byte_first ||
+          ((to->table->in_use->variables.sql_mode &
+            (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) &&
+           to->type() == FIELD_TYPE_DATE ||
+           to->type() == FIELD_TYPE_DATETIME))
       {
 	if (from->real_type() == FIELD_TYPE_ENUM ||
 	    from->real_type() == FIELD_TYPE_SET)
@@ -590,7 +598,11 @@
          (to->field_length == from->field_length &&
           (((Field_num*)to)->dec == ((Field_num*)from)->dec))) &&
         from->charset() == to->charset() &&
-	to->table->s->db_low_byte_first == from->table->s->db_low_byte_first)
+	to->table->s->db_low_byte_first == from->table->s->db_low_byte_first &&
+        (!(to->table->in_use->variables.sql_mode &
+           (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) ||
+         to->type() != FIELD_TYPE_DATE &&
+         to->type() != FIELD_TYPE_DATETIME))
     {						// Identical fields
       memcpy(to->ptr,from->ptr,to->pack_length());
       return;

--- 1.127/sql/item.cc	2005-03-22 17:11:29 +02:00
+++ 1.128/sql/item.cc	2005-04-01 15:04:44 +03:00
@@ -46,7 +46,7 @@
 
 const Hybrid_type_traits *Hybrid_type_traits::instance()
 {
-  const static Hybrid_type_traits real_traits;
+  static const Hybrid_type_traits real_traits;
   return &real_traits;
 }
 
@@ -70,7 +70,7 @@
 
 const Hybrid_type_traits_decimal *Hybrid_type_traits_decimal::instance()
 {
-  const static Hybrid_type_traits_decimal decimal_traits;
+  static const Hybrid_type_traits_decimal decimal_traits;
   return &decimal_traits;
 }
 
@@ -146,7 +146,7 @@
 
 const Hybrid_type_traits_integer *Hybrid_type_traits_integer::instance()
 {
-  const static Hybrid_type_traits_integer integer_traits;
+  static const Hybrid_type_traits_integer integer_traits;
   return &integer_traits;
 }
 
@@ -1452,6 +1452,60 @@
   str->append('\'');
   str_value.print(str);
   str->append('\'');
+}
+
+
+inline bool check_if_only_end_space(CHARSET_INFO *cs, char *str, char *end)
+{
+  return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end;
+}
+
+
+double Item_string::val_real()
+{
+  DBUG_ASSERT(fixed == 1);
+  int error;
+  char *end, *org_end;
+  double tmp;
+  CHARSET_INFO *cs= str_value.charset();
+
+  org_end= (char*) str_value.ptr() + str_value.length();
+  tmp= my_strntod(cs, (char*) str_value.ptr(), str_value.length(), &end,
+                  &error);
+  if (error || (end != org_end && !check_if_only_end_space(cs, end, org_end)))
+  {
+    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                        ER_TRUNCATED_WRONG_VALUE,
+                        ER(ER_TRUNCATED_WRONG_VALUE), "DOUBLE",
+                        str_value.ptr());
+  }
+  return tmp;
+}
+
+
+longlong Item_string::val_int()
+{
+  DBUG_ASSERT(fixed == 1);
+  int err;
+  longlong tmp;
+  char *end= (char*) str_value.ptr()+ str_value.length();
+  char *org_end= end;
+  CHARSET_INFO *cs= str_value.charset();
+
+  tmp= (*(cs->cset->my_strtoll10))(cs, str_value.ptr(), &end, &err);
+  /*
+    TODO: Give error if we wanted a signed integer and we got an unsigned
+    one
+  */
+  if (err > 0 ||
+      (end != org_end && !check_if_only_end_space(cs, end, org_end)))
+  {
+    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                        ER_TRUNCATED_WRONG_VALUE,
+                        ER(ER_TRUNCATED_WRONG_VALUE), "INTEGER",
+                        str_value.ptr());
+  }
+  return tmp;
 }
 
 

--- 1.108/sql/item.h	2005-03-17 17:44:19 +02:00
+++ 1.109/sql/item.h	2005-04-01 15:04:44 +03:00
@@ -1097,21 +1097,8 @@
     fixed= 1;
   }
   enum Type type() const { return STRING_ITEM; }
-  double val_real()
-  {
-    DBUG_ASSERT(fixed == 1);
-    int err_not_used;
-    char *end_not_used;
-    return my_strntod(str_value.charset(), (char*) str_value.ptr(),
-		      str_value.length(), &end_not_used, &err_not_used);
-  }
-  longlong val_int()
-  {
-    DBUG_ASSERT(fixed == 1);
-    int err;
-    return my_strntoll(str_value.charset(), str_value.ptr(),
-		       str_value.length(), 10, (char**) 0, &err);
-  }
+  double val_real();
+  longlong val_int();
   String *val_str(String*)
   {
     DBUG_ASSERT(fixed == 1);

--- 1.135/sql/item_sum.cc	2005-03-30 16:57:49 +03:00
+++ 1.136/sql/item_sum.cc	2005-04-01 15:04:44 +03:00
@@ -2966,8 +2966,7 @@
       DBUG_RETURN(TRUE);
     if (item->const_item())
     {
-      (void) item->val_int();
-      if (item->null_value)
+      if (item->is_null())
       {
         always_null= 1;
         DBUG_RETURN(FALSE);

--- 1.77/sql/item_timefunc.cc	2005-03-30 16:00:27 +03:00
+++ 1.78/sql/item_timefunc.cc	2005-04-01 15:04:44 +03:00
@@ -2181,39 +2181,47 @@
   res->set_charset(cast_cs);
 
   /*
-     Cut the tail if cast with length
-     and the result is longer than cast length, e.g.
-     CAST('string' AS CHAR(1))
+    Cut the tail if cast with length
+    and the result is longer than cast length, e.g.
+    CAST('string' AS CHAR(1))
   */
   if (cast_length >= 0 &&
       (res->length() > (length= (uint32) res->charpos(cast_length))))
   {						// Safe even if const arg
+    char char_type[40];
+    my_snprintf(char_type, sizeof(char_type), "CHAR(%lu)", length);
+
     if (!res->alloced_length())
     {						// Don't change const str
       str_value= *res;				// Not malloced string
       res= &str_value;
     }
+    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                        ER_TRUNCATED_WRONG_VALUE,
+                        ER(ER_TRUNCATED_WRONG_VALUE), char_type,
+                        res->c_ptr());
     res->length((uint) length);
   }
   null_value= 0;
   return res;
 }
 
+
 void Item_char_typecast::fix_length_and_dec()
 {
   uint32 char_length;
-  /* 
-     We always force character set conversion if cast_cs
-     is a multi-byte character set. It garantees that the
-     result of CAST is a well-formed string.
-     For single-byte character sets we allow just to copy
-     from the argument. A single-byte character sets string
-     is always well-formed. 
+  /*
+    We always force character set conversion if cast_cs is a
+    multi-byte character set. It garantees that the result of CAST is
+    a well-formed string.  For single-byte character sets we allow
+    just to copy from the argument. A single-byte character sets
+    string is always well-formed.
   */
-  charset_conversion= (cast_cs->mbmaxlen > 1) ||
-                      !my_charset_same(args[0]->collation.collation, cast_cs) &&
-                      args[0]->collation.collation != &my_charset_bin &&
-                      cast_cs != &my_charset_bin;
+  charset_conversion= ((cast_cs->mbmaxlen > 1) ||
+                       !my_charset_same(args[0]->collation.collation,
+                                        cast_cs) &&
+                       args[0]->collation.collation != &my_charset_bin &&
+                       cast_cs != &my_charset_bin);
   collation.set(cast_cs, DERIVATION_IMPLICIT);
   char_length= (cast_length >= 0) ? cast_length : 
 	       args[0]->max_length/args[0]->collation.collation->mbmaxlen;

--- 1.283/sql/mysql_priv.h	2005-03-25 20:11:10 +02:00
+++ 1.284/sql/mysql_priv.h	2005-04-01 15:04:44 +03:00
@@ -442,7 +442,6 @@
 typedef my_bool (*qc_engine_callback)(THD *thd, char *table_key,
                                       uint key_length,
                                       ulonglong *engine_data);
-
 #include "sql_string.h"
 #include "sql_list.h"
 #include "sql_map.h"
@@ -450,6 +449,7 @@
 #include "handler.h"
 #include "parse_file.h"
 #include "table.h"
+#include "sql_error.h"
 #include "field.h"				/* Field definitions */
 #include "protocol.h"
 #include "sql_udf.h"
@@ -651,11 +651,6 @@
 			 uint *blob_columns, 
 			 int *timestamps, int *timestamps_with_niladic,
 			 uint table_flags);
-int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
-		       List<create_field> &fields,
-		       List<Key> &keys, uint &db_options, 
-		       handler *file, KEY *&key_info_buffer,
-		       uint &key_count, int select_field_count);
 bool mysql_create_table(THD *thd,const char *db, const char *table_name,
                         HA_CREATE_INFO *create_info,
                         List<create_field> &fields, List<Key> &keys,
@@ -829,14 +824,6 @@
 void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length);
 void reset_stmt_for_execute(THD *thd, LEX *lex);
 void init_stmt_after_parse(THD*, LEX*);
-
-/* sql_error.cc */
-MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, uint code,
-                          const char *msg);
-void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level,
-			 uint code, const char *format, ...);
-void mysql_reset_errors(THD *thd, bool force);
-bool mysqld_show_warnings(THD *thd, ulong levels_to_show);
 
 /* sql_handler.cc */
 bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen);

--- 1.446/sql/mysqld.cc	2005-03-29 15:22:35 +03:00
+++ 1.447/sql/mysqld.cc	2005-04-01 15:04:44 +03:00
@@ -1036,8 +1036,8 @@
     (void) my_delete(pidfile_name,MYF(0));	// This may not always exist
 #endif
   finish_client_errs();
-  const char **errmsgs= my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST);
-  x_free((gptr) errmsgs);	/* Free messages */
+  my_free((gptr) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST),
+          MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
   DBUG_PRINT("quit", ("Error messages freed"));
   /* Tell main we are ready */
   (void) pthread_mutex_lock(&LOCK_thread_count);

--- 1.227/sql/sql_class.h	2005-03-19 02:12:22 +02:00
+++ 1.228/sql/sql_class.h	2005-04-01 15:04:44 +03:00
@@ -482,27 +482,6 @@
 };
 
 
-class MYSQL_ERROR: public Sql_alloc
-{
-public:
-  enum enum_warning_level
-  { WARN_LEVEL_NOTE, WARN_LEVEL_WARN, WARN_LEVEL_ERROR, WARN_LEVEL_END};
-
-  uint code;
-  enum_warning_level level;
-  char *msg;
-  
-  MYSQL_ERROR(THD *thd, uint code_arg, enum_warning_level level_arg,
-	      const char *msg_arg)
-    :code(code_arg), level(level_arg)
-  {
-    if (msg_arg)
-      set_msg(thd, msg_arg);
-  }
-  void set_msg(THD *thd, const char *msg_arg);
-};
-
-
 class delayed_insert;
 class select_result;
 

--- 1.77/sql/sql_load.cc	2005-03-25 15:51:05 +02:00
+++ 1.78/sql/sql_load.cc	2005-04-01 15:04:44 +03:00
@@ -671,7 +671,7 @@
             if (field->type() == FIELD_TYPE_TIMESTAMP)
               ((Field_timestamp*) field)->set_time();
             else if (field != table->next_number_field)
-              field->set_warning((uint) MYSQL_ERROR::WARN_LEVEL_WARN,
+              field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
                                  ER_WARN_NULL_TO_NOTNULL, 1);
           }
 	}

--- 1.434/sql/sql_parse.cc	2005-03-30 15:51:38 +03:00
+++ 1.435/sql/sql_parse.cc	2005-04-01 15:04:44 +03:00
@@ -1910,10 +1910,11 @@
 #endif
     ulong uptime = (ulong) (thd->start_time - start_time);
     sprintf((char*) buff,
-	    "Uptime: %ld  Threads: %d  Questions: %lu  Slow queries: %ld  Opens: %ld  Flush tables: %ld  Open tables: %u  Queries per second avg: %.3f",
+	    "Uptime: %ld  Threads: %d  Questions: %lu  Slow queries: %lu  Opens: %ld  Flush tables: %ld  Open tables: %u  Queries per second avg: %.3f",
 	    uptime,
-	    (int) thread_count,thd->query_id,thd->status_var.long_query_count,
-	    thd->status_var.opened_tables,refresh_version, cached_tables(),
+	    (int) thread_count, (ulong) thd->query_id,
+            (ulong) thd->status_var.long_query_count,
+	    thd->status_var.opened_tables, refresh_version, cached_tables(),
 	    uptime ? (float)thd->query_id/(float)uptime : 0);
 #ifdef SAFEMALLOC
     if (sf_malloc_cur_memory)				// Using SAFEMALLOC

--- 1.229/sql/sql_table.cc	2005-03-23 10:32:42 +02:00
+++ 1.230/sql/sql_table.cc	2005-04-01 15:04:45 +03:00
@@ -620,11 +620,12 @@
     -1	error
 */
 
-int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
-			List<create_field> &fields,
-			List<Key> &keys, bool tmp_table, uint &db_options,
-			handler *file, KEY *&key_info_buffer,
-			uint *key_count, int select_field_count)
+static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
+                               List<create_field> *fields,
+                               List<Key> *keys, bool tmp_table,
+                               uint *db_options,
+                               handler *file, KEY **key_info_buffer,
+                               uint *key_count, int select_field_count)
 {
   const char	*key_name;
   create_field	*sql_field,*dup_field;
@@ -636,11 +637,11 @@
   int		timestamps= 0, timestamps_with_niladic= 0;
   int		field_no,dup_no;
   int		select_field_pos,auto_increment=0;
-  List_iterator<create_field> it(fields),it2(fields);
+  List_iterator<create_field> it(*fields),it2(*fields);
   uint total_uneven_bit_length= 0;
   DBUG_ENTER("mysql_prepare_table");
 
-  select_field_pos=fields.elements - select_field_count;
+  select_field_pos= fields->elements - select_field_count;
   null_fields=blob_columns=0;
   create_info->varchar= 0;
 
@@ -845,11 +846,11 @@
     if ((sql_field->flags & BLOB_FLAG) ||
 	sql_field->sql_type == MYSQL_TYPE_VARCHAR &&
 	create_info->row_type != ROW_TYPE_FIXED)
-      db_options|= HA_OPTION_PACK_RECORD;
+      (*db_options)|= HA_OPTION_PACK_RECORD;
     it2.rewind();
   }
   /* If fixed row records, we need one bit to check for deleted rows */
-  if (!(db_options & HA_OPTION_PACK_RECORD))
+  if (!((*db_options) & HA_OPTION_PACK_RECORD))
     null_fields++;
   pos= (null_fields + total_uneven_bit_length + 7) / 8;
 
@@ -897,7 +898,7 @@
 
   /* Create keys */
 
-  List_iterator<Key> key_iterator(keys), key_iterator2(keys);
+  List_iterator<Key> key_iterator(*keys), key_iterator2(*keys);
   uint key_parts=0, fk_key_count=0;
   bool primary_key=0,unique_key=0;
   Key *key, *key2;
@@ -984,9 +985,9 @@
     DBUG_RETURN(-1);
   }
 
-  key_info_buffer=key_info=(KEY*) sql_calloc(sizeof(KEY)* *key_count);
+  (*key_info_buffer) = key_info= (KEY*) sql_calloc(sizeof(KEY)* *key_count);
   key_part_info=(KEY_PART_INFO*) sql_calloc(sizeof(KEY_PART_INFO)*key_parts);
-  if (!key_info_buffer || ! key_part_info)
+  if (!*key_info_buffer || ! key_part_info)
     DBUG_RETURN(-1);				// Out of memory
 
   key_iterator.rewind();
@@ -1260,7 +1261,7 @@
       }
       key_part_info->length=(uint16) length;
       /* Use packed keys for long strings on the first column */
-      if (!(db_options & HA_OPTION_NO_PACK_KEYS) &&
+      if (!((*db_options) & HA_OPTION_NO_PACK_KEYS) &&
 	  (length >= KEY_DEFAULT_PACK_LENGTH &&
 	   (sql_field->sql_type == MYSQL_TYPE_STRING ||
 	    sql_field->sql_type == MYSQL_TYPE_VARCHAR ||
@@ -1291,8 +1292,8 @@
 	}
 	else if (!(key_name = key->name))
 	  key_name=make_unique_key_name(sql_field->field_name,
-					key_info_buffer,key_info);
-	if (check_if_keyname_exists(key_name,key_info_buffer,key_info))
+					*key_info_buffer, key_info);
+	if (check_if_keyname_exists(key_name, *key_info_buffer, key_info))
 	{
 	  my_error(ER_DUP_KEYNAME, MYF(0), key_name);
 	  DBUG_RETURN(-1);
@@ -1327,7 +1328,7 @@
     DBUG_RETURN(-1);
   }
   /* Sort keys in optimized order */
-  qsort((gptr) key_info_buffer, *key_count, sizeof(KEY),
+  qsort((gptr) *key_info_buffer, *key_count, sizeof(KEY),
 	(qsort_cmp) sort_keys);
 
   DBUG_RETURN(0);
@@ -1393,7 +1394,7 @@
 			ha_get_storage_engine(new_db_type),
 			table_name);
   }
-  db_options=create_info->table_options;
+  db_options= create_info->table_options;
   if (create_info->row_type == ROW_TYPE_DYNAMIC)
     db_options|=HA_OPTION_PACK_RECORD;
   alias= table_case_name(create_info, table_name);
@@ -1432,9 +1433,9 @@
     create_info->default_table_charset= db_info.default_table_charset;
   }
 
-  if (mysql_prepare_table(thd, create_info, fields,
-			  keys, internal_tmp_table, db_options, file,
-			  key_info_buffer, &key_count,
+  if (mysql_prepare_table(thd, create_info, &fields,
+			  &keys, internal_tmp_table, &db_options, file,
+			  &key_info_buffer, &key_count,
 			  select_field_count))
     DBUG_RETURN(TRUE);
 
@@ -2706,9 +2707,9 @@
   create_info.db_type=DB_TYPE_DEFAULT;
   create_info.default_table_charset= thd->variables.collation_database;
   db_options= 0;
-  if (mysql_prepare_table(thd, &create_info, fields,
-			  keys, /*tmp_table*/ 0, db_options, table->file,
-			  key_info_buffer, key_count,
+  if (mysql_prepare_table(thd, &create_info, &fields,
+			  &keys, /*tmp_table*/ 0, &db_options, table->file,
+			  &key_info_buffer, key_count,
 			  /*select_field_count*/ 0))
     DBUG_RETURN(-1);
 
@@ -2839,9 +2840,9 @@
   {
     db_options= 0;
     if (table->file->drop_index(table, key_numbers, key_count)||
-	mysql_prepare_table(thd, &create_info, fields,
-			    keys, /*tmp_table*/ 0, db_options, table->file,
-			    key_info_buffer, key_count,
+	mysql_prepare_table(thd, &create_info, &fields,
+			    &keys, /*tmp_table*/ 0, &db_options, table->file,
+			    &key_info_buffer, key_count,
 			    /*select_field_count*/ 0)||
 	(snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home,
 		  table_list->db, (lower_case_table_names == 2)?
@@ -3666,6 +3667,13 @@
 
   if (to->file->external_lock(thd, F_WRLCK))
     DBUG_RETURN(-1);
+
+  /* We can abort alter table for any table type */
+  thd->no_trans_update= 0;
+  thd->abort_on_warning= !ignore && test(thd->variables.sql_mode &
+                                         (MODE_STRICT_TRANS_TABLES |
+                                          MODE_STRICT_ALL_TABLES));
+
   from->file->info(HA_STATUS_VARIABLE);
   to->file->start_bulk_insert(from->file->records);
 
@@ -3745,6 +3753,7 @@
       else
         to->next_number_field->reset();
     }
+    
     for (Copy_field *copy_ptr=copy ; copy_ptr != copy_end ; copy_ptr++)
     {
       copy_ptr->do_copy(copy_ptr);
@@ -3789,6 +3798,7 @@
 
  err:
   thd->variables.sql_mode= save_sql_mode;
+  thd->abort_on_warning= 0;
   free_io_cache(from);
   *copied= found_count;
   *deleted=delete_count;

--- 1.54/sql/time.cc	2005-01-03 22:14:12 +02:00
+++ 1.55/sql/time.cc	2005-04-01 15:04:45 +03:00
@@ -712,9 +712,9 @@
   else
     cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
                        ER(ER_TRUNCATED_WRONG_VALUE),
-                       type_str, str.ptr());
-  push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-		      ER_TRUNCATED_WRONG_VALUE, warn_buff);
+                       type_str, str.c_ptr());
+  push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+               ER_TRUNCATED_WRONG_VALUE, warn_buff);
 }
 
 

--- 1.51/sql/unireg.cc	2005-03-04 23:14:18 +02:00
+++ 1.52/sql/unireg.cc	2005-04-01 15:04:45 +03:00
@@ -40,7 +40,7 @@
 static uint get_interval_id(uint *int_count,List<create_field> &create_fields,
 			    create_field *last_field);
 static bool pack_fields(File file, List<create_field> &create_fields);
-static bool make_empty_rec(int file, enum db_type table_type,
+static bool make_empty_rec(THD *thd, int file, enum db_type table_type,
 			   uint table_options,
 			   List<create_field> &create_fields,
 			   uint reclength,uint null_fields);
@@ -134,7 +134,7 @@
   VOID(my_seek(file,
 	       (ulong) uint2korr(fileinfo+6)+ (ulong) key_buff_length,
 	       MY_SEEK_SET,MYF(0)));
-  if (make_empty_rec(file,create_info->db_type,create_info->table_options,
+  if (make_empty_rec(thd,file,create_info->db_type,create_info->table_options,
 		     create_fields,reclength,null_fields))
     goto err;
 
@@ -640,7 +640,7 @@
 
 	/* save an empty record on start of formfile */
 
-static bool make_empty_rec(File file,enum db_type table_type,
+static bool make_empty_rec(THD *thd, File file,enum db_type table_type,
 			   uint table_options,
 			   List<create_field> &create_fields,
 			   uint reclength, uint null_fields)
@@ -652,6 +652,7 @@
   TABLE table;
   create_field *field;
   handler *handler;
+  enum_check_fields old_count_cuted_fields= thd->count_cuted_fields;
   DBUG_ENTER("make_empty_rec");
 
   /* We need a table to generate columns for default values */
@@ -666,7 +667,7 @@
     DBUG_RETURN(1);
   }
 
-  table.in_use= current_thd;
+  table.in_use= thd;
   table.s->db_low_byte_first= handler->low_byte_first();
   table.s->blob_ptr_size= portable_sizeof_char_ptr;
 
@@ -681,6 +682,7 @@
   null_pos=buff;
 
   List_iterator<create_field> it(create_fields);
+  thd->count_cuted_fields= CHECK_FIELD_WARN;    // To find wrong default values
   while ((field=it++))
   {
     Field *regfield=make_field((char*) buff+field->offset,field->length,
@@ -709,7 +711,14 @@
     if (field->def &&
 	(regfield->real_type() != FIELD_TYPE_YEAR ||
 	 field->def->val_int() != 0))
-      (void) field->def->save_in_field(regfield, 1);
+    {
+      if (field->def->save_in_field(regfield, 1))
+      {
+        my_error(ER_INVALID_DEFAULT, MYF(0), regfield->field_name);
+        error= 1;
+        goto err;
+      }
+    }
     else if (regfield->real_type() == FIELD_TYPE_ENUM &&
 	     (field->flags & NOT_NULL_FLAG))
     {
@@ -728,7 +737,10 @@
   /* Fill not used startpos */
   bfill((byte*) buff+null_length,firstpos-null_length,255);
   error=(int) my_write(file,(byte*) buff,(uint) reclength,MYF_RW);
+
+err:
   my_free((gptr) buff,MYF(MY_FAE));
   delete handler;
+  thd->count_cuted_fields= old_count_cuted_fields;
   DBUG_RETURN(error);
 } /* make_empty_rec */

--- 1.19/mysql-test/r/row.result	2005-02-09 00:49:32 +02:00
+++ 1.20/mysql-test/r/row.result	2005-04-01 15:04:43 +03:00
@@ -16,12 +16,17 @@
 1
 Warnings:
 Error	1366	Incorrect decimal value: '' for column '' at row -1
+Warning	1292	Truncated incorrect INTEGER value: 'a'
 select row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3));
 row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3))
 1
 select row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3));
+Warnings:
+Warning	1292	Truncated incorrect INTEGER value: 'a'
 row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3))
 1
+Warnings:
+Warning	1292	Truncated incorrect INTEGER value: 'a'
 select row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3));
 row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3))
 1

--- 1.107/mysql-test/r/subselect.result	2005-02-24 23:33:37 +02:00
+++ 1.108/mysql-test/r/subselect.result	2005-04-01 15:04:43 +03:00
@@ -117,15 +117,17 @@
 SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b');
 (SELECT 1.5,2,'a') = ROW(1.5,2,'b')
 0
-SELECT (SELECT 1.5,2,'a') = ROW('b',2,'b');
-(SELECT 1.5,2,'a') = ROW('b',2,'b')
+SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b');
+(SELECT 1.5,2,'a') = ROW('1.5b',2,'b')
 0
+Warnings:
+Warning	1292	Truncated incorrect DOUBLE value: '1.5b'
 SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a');
 (SELECT 'b',2,'a') = ROW(1.5,2,'a')
 0
-SELECT (SELECT 1.5,2,'a') = ROW(1.5,'c','a');
-(SELECT 1.5,2,'a') = ROW(1.5,'c','a')
-0
+SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a');
+(SELECT 1.5,2,'a') = ROW(1.5,'2','a')
+1
 SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a');
 (SELECT 1.5,'c','a') = ROW(1.5,2,'a')
 0

--- 1.92/mysql-test/t/subselect.test	2005-02-21 17:19:12 +02:00
+++ 1.93/mysql-test/t/subselect.test	2005-04-01 15:04:44 +03:00
@@ -46,9 +46,9 @@
 SELECT ROW(1,2,3) = (SELECT 1,2,NULL);
 SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a');
 SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b');
-SELECT (SELECT 1.5,2,'a') = ROW('b',2,'b');
+SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b');
 SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a');
-SELECT (SELECT 1.5,2,'a') = ROW(1.5,'c','a');
+SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a');
 SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a');
 
 -- error 1241

--- 1.28/sql/item_row.cc	2005-02-10 02:27:34 +02:00
+++ 1.29/sql/item_row.cc	2005-04-01 15:04:44 +03:00
@@ -73,8 +73,8 @@
 	with_null|= item->null_inside();
       else
       {
-	item->val_int();
-	with_null|= item->null_value;
+	if (item->is_null())
+          with_null|= 1;
       }
     }
     maybe_null|= item->maybe_null;

--- 1.35/mysql-test/r/ps_1general.result	2005-03-30 16:00:27 +03:00
+++ 1.36/mysql-test/r/ps_1general.result	2005-04-01 15:04:43 +03:00
@@ -464,17 +464,17 @@
 ab
 prepare stmt4 from ' SET sql_mode="" ';
 execute stmt4;
-select 'a' || 'b' ;
-'a' || 'b'
-0
-prepare stmt5 from ' select ''a'' || ''b'' ' ;
+select '2' || '3' ;
+'2' || '3'
+1
+prepare stmt5 from ' select ''2'' || ''3'' ' ;
 execute stmt5;
-'a' || 'b'
-0
+'2' || '3'
+1
 SET sql_mode=ansi;
 execute stmt5;
-'a' || 'b'
-0
+'2' || '3'
+1
 SET sql_mode="";
 prepare stmt1 from ' flush local privileges ' ;
 ERROR HY000: This command is not supported in the prepared statement protocol yet

--- 1.19/mysql-test/t/ps_1general.test	2005-02-22 15:46:56 +02:00
+++ 1.20/mysql-test/t/ps_1general.test	2005-04-01 15:04:44 +03:00
@@ -500,10 +500,10 @@
 prepare stmt4 from ' SET sql_mode="" ';
 execute stmt4;
 # check if the sql_mode is not ansi
-select 'a' || 'b' ;
+select '2' || '3' ;
 # Will a switch of the sqlmode affect the execution of already prepared 
 # statements ?
-prepare stmt5 from ' select ''a'' || ''b'' ' ;
+prepare stmt5 from ' select ''2'' || ''3'' ' ;
 execute stmt5;
 SET sql_mode=ansi;
 execute stmt5;

--- 1.2/mysql-test/r/rpl_session_var.result	2003-12-19 23:25:31 +02:00
+++ 1.3/mysql-test/r/rpl_session_var.result	2005-04-01 15:04:43 +03:00
@@ -11,14 +11,14 @@
 set @@session.sql_mode=pipes_as_concat;
 insert into t1 values('My'||'SQL', 1);
 set @@session.sql_mode=default;
-insert into t1 values('My'||'SQL', 2);
+insert into t1 values('1'||'2', 2);
 select * from t1 where b<3 order by a;
 a	b
-0	2
+1	2
 MySQL	1
 select * from t1 where b<3 order by a;
 a	b
-0	2
+1	2
 MySQL	1
 set @@session.sql_mode=ignore_space;
 insert into t1 values(password          ('MySQL'), 3);

--- 1.2/mysql-test/t/rpl_session_var.test	2003-12-19 23:29:34 +02:00
+++ 1.3/mysql-test/t/rpl_session_var.test	2005-04-01 15:04:44 +03:00
@@ -7,7 +7,7 @@
 set @@session.sql_mode=pipes_as_concat;
 insert into t1 values('My'||'SQL', 1);
 set @@session.sql_mode=default;
-insert into t1 values('My'||'SQL', 2);
+insert into t1 values('1'||'2', 2);
 select * from t1 where b<3 order by a;
 save_master_pos;
 connection slave;

--- 1.7/sql/my_decimal.cc	2005-03-21 14:58:28 +02:00
+++ 1.8/sql/my_decimal.cc	2005-04-01 15:04:44 +03:00
@@ -175,7 +175,7 @@
   err= string2decimal((char *)from, (decimal_t*) decimal_value, &end);
   if (end != from_end && !err)
   {
-    /* Give warining if there is something other than end space */
+    /* Give warning if there is something other than end space */
     for ( ; end < from_end; end++)
     {
       if (!my_isspace(&my_charset_latin1, *end))

--- 1.15/mysql-test/r/ndb_index_unique.result	2005-01-27 11:33:00 +02:00
+++ 1.16/mysql-test/r/ndb_index_unique.result	2005-04-01 15:04:43 +03:00
@@ -248,8 +248,8 @@
 CREATE TABLE t4 (
 uid bigint(20) unsigned NOT NULL default '0',
 gid bigint(20) unsigned NOT NULL,
-rid bigint(20) unsigned NOT NULL default '-1',
-cid bigint(20) unsigned NOT NULL default '-1',
+rid bigint(20) unsigned NOT NULL,
+cid bigint(20) unsigned NOT NULL,
 UNIQUE KEY m (uid,gid,rid,cid)
 ) engine=ndbcluster;
 INSERT INTO t4 VALUES (1,1,2,4);
@@ -275,8 +275,8 @@
 mid bigint(20) unsigned NOT NULL PRIMARY KEY,
 uid bigint(20) unsigned NOT NULL default '0',
 gid bigint(20) unsigned NOT NULL,
-rid bigint(20) unsigned NOT NULL default '-1',
-cid bigint(20) unsigned NOT NULL default '-1',
+rid bigint(20) unsigned NOT NULL,
+cid bigint(20) unsigned NOT NULL,
 UNIQUE KEY m (uid,gid,rid,cid)
 ) engine=ndbcluster;
 INSERT INTO t7 VALUES(1, 1, 1, 1, 1);

--- 1.13/mysql-test/t/ndb_index_unique.test	2005-01-27 11:33:00 +02:00
+++ 1.14/mysql-test/t/ndb_index_unique.test	2005-04-01 15:04:44 +03:00
@@ -182,8 +182,8 @@
 CREATE TABLE t4 (
   uid bigint(20) unsigned NOT NULL default '0',
   gid bigint(20) unsigned NOT NULL,
-  rid bigint(20) unsigned NOT NULL default '-1',
-  cid bigint(20) unsigned NOT NULL default '-1',
+  rid bigint(20) unsigned NOT NULL,
+  cid bigint(20) unsigned NOT NULL,
   UNIQUE KEY m (uid,gid,rid,cid)
 ) engine=ndbcluster;
 INSERT INTO t4 VALUES (1,1,2,4);
@@ -209,8 +209,8 @@
   mid bigint(20) unsigned NOT NULL PRIMARY KEY,
   uid bigint(20) unsigned NOT NULL default '0',
   gid bigint(20) unsigned NOT NULL,
-  rid bigint(20) unsigned NOT NULL default '-1',
-  cid bigint(20) unsigned NOT NULL default '-1',
+  rid bigint(20) unsigned NOT NULL,
+  cid bigint(20) unsigned NOT NULL,
   UNIQUE KEY m (uid,gid,rid,cid)
 ) engine=ndbcluster;
 INSERT INTO t7 VALUES(1, 1, 1, 1, 1);

--- 1.25/mysql-test/r/bigint.result	2005-03-04 00:44:32 +02:00
+++ 1.26/mysql-test/r/bigint.result	2005-04-01 15:04:43 +03:00
@@ -87,6 +87,8 @@
 SELECT '0x8000000000000001'+0;
 '0x8000000000000001'+0
 0
+Warnings:
+Warning	1292	Truncated incorrect DOUBLE value: '0x8000000000000001'
 create table t1 (
 value64  bigint unsigned  not null,
 value32  integer          not null,

--- 1.82/mysql-test/r/create.result	2005-02-09 00:49:32 +02:00
+++ 1.83/mysql-test/r/create.result	2005-04-01 15:04:43 +03:00
@@ -44,12 +44,24 @@
 ERROR 42000: Incorrect table name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
 create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int);
 ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long
-create table test (a datetime default now());
+create table t1 (a datetime default now());
 ERROR 42000: Invalid default value for 'a'
-create table test (a datetime on update now());
+create table t1 (a datetime on update now());
 ERROR HY000: Invalid ON UPDATE clause for 'a' column
-create table test (a int default 100 auto_increment);
+create table t1 (a int default 100 auto_increment);
 ERROR 42000: Invalid default value for 'a'
+create table t1 (a tinyint default 1000);
+ERROR 42000: Invalid default value for 'a'
+create table t1 (a varchar(5) default 'abcdef');
+ERROR 42000: Invalid default value for 'a'
+create table t1 (a varchar(5) default 'abcde');
+insert into t1 values();
+select * from t1;
+a
+abcde
+alter table t1 alter column a set default 'abcdef';
+ERROR 42000: Invalid default value for 'a'
+drop table t1;
 create table 1ea10 (1a20 int,1e int);
 insert into 1ea10 values(1,1);
 select 1ea10.1a20,1e+ 1e+10 from 1ea10;

--- 1.16/mysql-test/r/func_misc.result	2005-02-04 08:14:20 +02:00
+++ 1.17/mysql-test/r/func_misc.result	2005-04-01 15:04:43 +03:00
@@ -25,6 +25,8 @@
 select length(format('nan', 2)) > 0;
 length(format('nan', 2)) > 0
 1
+Warnings:
+Warning	1292	Truncated incorrect DOUBLE value: 'nan'
 select concat("$",format(2500,2));
 concat("$",format(2500,2))
 $2,500.00

--- 1.31/mysql-test/r/type_ranges.result	2005-02-09 00:49:32 +02:00
+++ 1.32/mysql-test/r/type_ranges.result	2005-04-01 15:04:43 +03:00
@@ -133,7 +133,7 @@
 add new_field char(10) default "new" not null,
 change blob_col new_blob_col varchar(20),
 change date_field date_field char(10),
-alter column string set default "new default",
+alter column string set default "newdefault",
 alter short drop default,
 DROP INDEX utiny,
 DROP INDEX ushort,
@@ -211,7 +211,7 @@
 show full columns from t1;
 Field	Type	Collation	Null	Key	Default	Extra	Privileges	Comment
 auto	int(5) unsigned	NULL	NO	MUL	NULL	auto_increment	select,insert,update,references	
-string	char(10)	latin1_swedish_ci	YES		new defaul		select,insert,update,references	
+string	char(10)	latin1_swedish_ci	YES		newdefault		select,insert,update,references	
 tiny	tinyint(4)	NULL	NO	MUL	0		select,insert,update,references	
 short	smallint(6)	NULL	NO	MUL	0		select,insert,update,references	
 medium	mediumint(8)	NULL	NO	MUL	0		select,insert,update,references	
@@ -237,7 +237,7 @@
 show full columns from t2;
 Field	Type	Collation	Null	Key	Default	Extra	Privileges	Comment
 auto	int(5) unsigned	NULL	NO		0		select,insert,update,references	
-string	char(10)	latin1_swedish_ci	YES		new defaul		select,insert,update,references	
+string	char(10)	latin1_swedish_ci	YES		newdefault		select,insert,update,references	
 tiny	tinyint(4)	NULL	NO		0		select,insert,update,references	
 short	smallint(6)	NULL	NO		0		select,insert,update,references	
 medium	mediumint(8)	NULL	NO		0		select,insert,update,references	

--- 1.50/mysql-test/t/create.test	2005-01-18 20:16:09 +02:00
+++ 1.51/mysql-test/t/create.test	2005-04-01 15:04:43 +03:00
@@ -49,14 +49,25 @@
 create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int);
 
 #
-# Some wrong defaults, so these creates should fail too
+# Some wrong defaults, so these creates should fail too (Bug #5902)
 #
 --error 1067
-create table test (a datetime default now());
+create table t1 (a datetime default now());
 --error 1294
-create table test (a datetime on update now());
+create table t1 (a datetime on update now());
 --error 1067
-create table test (a int default 100 auto_increment);
+create table t1 (a int default 100 auto_increment);
+--error 1067
+create table t1 (a tinyint default 1000);
+--error 1067
+create table t1 (a varchar(5) default 'abcdef');
+
+create table t1 (a varchar(5) default 'abcde');
+insert into t1 values();
+select * from t1;
+--error 1067
+alter table t1 alter column a set default 'abcdef';
+drop table t1;
 
 #
 # test of dummy table names

--- 1.10/mysql-test/t/type_ranges.test	2004-12-07 15:46:55 +02:00
+++ 1.11/mysql-test/t/type_ranges.test	2005-04-01 15:04:44 +03:00
@@ -69,7 +69,7 @@
 add new_field char(10) default "new" not null,
 change blob_col new_blob_col varchar(20),
 change date_field date_field char(10),
-alter column string set default "new default",
+alter column string set default "newdefault",
 alter short drop default,
 DROP INDEX utiny,
 DROP INDEX ushort,

--- 1.25/mysql-test/r/cast.result	2005-03-07 18:53:47 +02:00
+++ 1.26/mysql-test/r/cast.result	2005-04-01 15:04:43 +03:00
@@ -7,6 +7,9 @@
 select CONVERT('-1',UNSIGNED);
 CONVERT('-1',UNSIGNED)
 18446744073709551615
+select CAST('10 ' as unsigned integer);
+CAST('10 ' as unsigned integer)
+10
 select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
 cast(-5 as unsigned) | 1	cast(-5 as unsigned) & -1
 18446744073709551611	18446744073709551611
@@ -42,6 +45,15 @@
 select CONVERT("2004-01-22 21:45:33",DATE);
 CONVERT("2004-01-22 21:45:33",DATE)
 2004-01-22
+select 10+'10';
+10+'10'
+20
+select 10.0+'10';
+10.0+'10'
+20
+select 10E+0+'10';
+10E+0+'10'
+20
 select CONVERT(DATE "2004-01-22 21:45:33" USING latin1);
 CONVERT(DATE "2004-01-22 21:45:33" USING latin1)
 2004-01-22 21:45:33
@@ -51,12 +63,43 @@
 select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4));
 CONVERT(DATE "2004-01-22 21:45:33",CHAR(4))
 2004
+Warnings:
+Warning	1292	Truncated incorrect CHAR(4) value: '2004-01-22 21:45:33'
 select CONVERT(DATE "2004-01-22 21:45:33",BINARY(4));
 CONVERT(DATE "2004-01-22 21:45:33",BINARY(4))
 2004
+Warnings:
+Warning	1292	Truncated incorrect CHAR(4) value: '2004-01-22 21:45:33'
 select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4));
 CAST(DATE "2004-01-22 21:45:33" AS BINARY(4))
 2004
+Warnings:
+Warning	1292	Truncated incorrect CHAR(4) value: '2004-01-22 21:45:33'
+select cast('-10a' as signed integer);
+cast('-10a' as signed integer)
+-10
+Warnings:
+Warning	1292	Truncated incorrect INTEGER value: '-10a'
+select cast('a10' as unsigned integer);
+cast('a10' as unsigned integer)
+0
+Warnings:
+Warning	1292	Truncated incorrect INTEGER value: 'a10'
+select 10+'a';
+10+'a'
+10
+Warnings:
+Warning	1292	Truncated incorrect DOUBLE value: 'a'
+select 10.0+cast('a' as decimal);
+10.0+cast('a' as decimal)
+10.00
+Warnings:
+Error	1366	Incorrect decimal value: '' for column '' at row -1
+select 10E+0+'a';
+10E+0+'a'
+10
+Warnings:
+Warning	1292	Truncated incorrect DOUBLE value: 'a'
 set names binary;
 select cast(_latin1'test' as char character set latin2);
 cast(_latin1'test' as char character set latin2)
@@ -79,12 +122,23 @@
 cast(_latin1'a'   AS char(2)) as c5;
 c1	c2	c3	c4	c5
 ab	a 	ab	a 	a
+Warnings:
+Warning	1292	Truncated incorrect CHAR(2) value: 'abc'
+Warning	1292	Truncated incorrect CHAR(2) value: 'a  '
+select cast(1000 as CHAR(3));
+cast(1000 as CHAR(3))
+100
+Warnings:
+Warning	1292	Truncated incorrect CHAR(3) value: '1000'
 create table t1 select
 cast(_latin1'ab'  AS char)    as c1,
 cast(_latin1'a '  AS char)    as c2,
 cast(_latin1'abc' AS char(2)) as c3,
 cast(_latin1'a  ' AS char(2)) as c4,
 cast(_latin1'a'   AS char(2)) as c5;
+Warnings:
+Warning	1292	Truncated incorrect CHAR(2) value: 'abc'
+Warning	1292	Truncated incorrect CHAR(2) value: 'a  '
 select * from t1;
 c1	c2	c3	c4	c5
 ab	a 	ab	a 	a
@@ -106,12 +160,18 @@
 c1	c2	c3	c4	c5
 фг	ф 	фг	ф 	ф
+Warnings:
+Warning	1292	Truncated incorrect CHAR(4) value: 'фгх'
+Warning	1292	Truncated incorrect CHAR(3) value: 'ф  '
 create table t1 select
+Warnings:
+Warning	1292	Truncated incorrect CHAR(4) value: 'фгх'
+Warning	1292	Truncated incorrect CHAR(3) value: 'ф  '
 select * from t1;
 c1	c2	c3	c4	c5
 фг	ф 	фг	ф 	ф
@@ -167,6 +227,10 @@
 aac	aac
 aab	aab
 aaa	aaa
+Warnings:
+Warning	1292	Truncated incorrect CHAR(2) value: 'aaa'
+Warning	1292	Truncated incorrect CHAR(2) value: 'aab'
+Warning	1292	Truncated incorrect CHAR(2) value: 'aac'
 SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ;
 a	CAST(a AS UNSIGNED)
 aaa	3
@@ -177,6 +241,10 @@
 aaa	aa
 aab	aa
 aac	aa
+Warnings:
+Warning	1292	Truncated incorrect CHAR(2) value: 'aaa'
+Warning	1292	Truncated incorrect CHAR(2) value: 'aab'
+Warning	1292	Truncated incorrect CHAR(2) value: 'aac'
 DROP TABLE t1;
 select date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour);
 date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour)

--- 1.17/mysql-test/t/cast.test	2005-03-07 18:53:47 +02:00
+++ 1.18/mysql-test/t/cast.test	2005-04-01 15:04:43 +03:00
@@ -5,6 +5,7 @@
 select CAST(1-2 AS UNSIGNED);
 select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
 select CONVERT('-1',UNSIGNED);
+select CAST('10 ' as unsigned integer);
 select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
 select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
 select ~5, cast(~5 as signed);
@@ -16,11 +17,22 @@
 select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
 select cast("1:2:3" as TIME);
 select CONVERT("2004-01-22 21:45:33",DATE);
+select 10+'10';
+select 10.0+'10';
+select 10E+0+'10';
+
+# The following cast creates warnings
+
 select CONVERT(DATE "2004-01-22 21:45:33" USING latin1);
 select CONVERT(DATE "2004-01-22 21:45:33",CHAR);
 select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4));
 select CONVERT(DATE "2004-01-22 21:45:33",BINARY(4));
 select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4));
+select cast('-10a' as signed integer);
+select cast('a10' as unsigned integer);
+select 10+'a';
+select 10.0+cast('a' as decimal);
+select 10E+0+'a';
 
 #
 # Character set convertion
@@ -41,6 +53,7 @@
   cast(_latin1'abc' AS char(2)) as c3,
   cast(_latin1'a  ' AS char(2)) as c4,
   cast(_latin1'a'   AS char(2)) as c5;
+select cast(1000 as CHAR(3));
 
 create table t1 select
   cast(_latin1'ab'  AS char)    as c1,

--- 1.21/mysql-test/r/strict.result	2005-03-30 23:41:38 +03:00
+++ 1.22/mysql-test/r/strict.result	2005-04-01 15:04:43 +03:00
@@ -1089,4 +1089,68 @@
 Error	1411	Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_time
 Error	1411	Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_time
 drop table t1;
+create table t1 (col1 char(3), col2 integer);
+insert into t1 (col1) values (cast(1000 as char(3)));
+ERROR 22007: Truncated incorrect CHAR(3) value: '1000'
+insert into t1 (col1) values (cast(1000E+0 as char(3)));
+ERROR 22007: Truncated incorrect CHAR(3) value: '1000'
+insert into t1 (col1) values (cast(1000.0 as char(3)));
+ERROR 22007: Truncated incorrect CHAR(3) value: '1000.0'
+insert into t1 (col2) values (cast('abc' as signed integer));
+ERROR 22007: Truncated incorrect INTEGER value: 'abc'
+insert into t1 (col2) values (10E+0 + 'a');
+ERROR 22007: Truncated incorrect DOUBLE value: 'a'
+insert into t1 (col2) values (cast('10a' as unsigned integer));
+ERROR 22007: Truncated incorrect INTEGER value: '10a'
+insert into t1 (col2) values (cast('10' as unsigned integer));
+insert into t1 (col2) values (cast('10' as signed integer));
+insert into t1 (col2) values (10E+0 + '0 ');
+select * from t1;
+col1	col2
+NULL	10
+NULL	10
+NULL	10
+drop table t1;
+create table t1 (col1 date, col2 datetime, col3 timestamp);
+insert into t1 values (0,0,0);
+ERROR 22007: Incorrect date value: '0' for column 'col1' at row 1
+insert into t1 values (0.0,0.0,0.0);
+ERROR 22007: Incorrect date value: '0' for column 'col1' at row 1
+set sql_mode='no_zero_date';
+insert into t1 values (0,0,0);
+Warnings:
+Warning	1264	Out of range value adjusted for column 'col1' at row 1
+Warning	1264	Out of range value adjusted for column 'col2' at row 1
+Warning	1265	Data truncated for column 'col3' at row 1
+insert into t1 values (0.0,0.0,0.0);
+Warnings:
+Warning	1264	Out of range value adjusted for column 'col1' at row 1
+Warning	1264	Out of range value adjusted for column 'col2' at row 1
+Warning	1265	Data truncated for column 'col3' at row 1
+drop table t1;
+set sql_mode='traditional';
+create table t1 (col1 date);
+insert ignore into t1 values ('0000-00-00');
+Warnings:
+Warning	1265	Data truncated for column 'col1' at row 1
+insert into t1 select * from t1;
+ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
+insert ignore into t1 values ('0000-00-00');
+Warnings:
+Warning	1265	Data truncated for column 'col1' at row 1
+insert into t1 select * from t1;
+ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
+alter table t1 modify col1 datetime;
+ERROR 22007: Incorrect datetime value: '0000-00-00' for column 'col1' at row 1
+alter ignore table t1 modify col1 datetime;
+Warnings:
+Warning	1264	Out of range value adjusted for column 'col1' at row 1
+Warning	1264	Out of range value adjusted for column 'col1' at row 2
+insert into t1 select * from t1;
+ERROR 22007: Incorrect datetime value: '0000-00-00 00:00:00' for column 'col1' at row 1
+select * from t1;
+col1
+0000-00-00 00:00:00
+0000-00-00 00:00:00
+drop table t1;
 set sql_mode=@org_mode;

--- 1.19/mysql-test/t/strict.test	2005-03-30 23:41:38 +03:00
+++ 1.20/mysql-test/t/strict.test	2005-04-01 15:04:44 +03:00
@@ -978,6 +978,58 @@
 drop table t1;
 
 #
+# Check insert with wrong CAST() (Bug #5912)
+#
+
+create table t1 (col1 char(3), col2 integer);
+--error 1292
+insert into t1 (col1) values (cast(1000 as char(3)));
+--error 1292
+insert into t1 (col1) values (cast(1000E+0 as char(3)));
+--error 1292
+insert into t1 (col1) values (cast(1000.0 as char(3)));
+--error 1292
+insert into t1 (col2) values (cast('abc' as signed integer));
+--error 1292
+insert into t1 (col2) values (10E+0 + 'a');
+--error 1292
+insert into t1 (col2) values (cast('10a' as unsigned integer));
+insert into t1 (col2) values (cast('10' as unsigned integer));
+insert into t1 (col2) values (cast('10' as signed integer));
+insert into t1 (col2) values (10E+0 + '0 ');
+select * from t1;
+drop table t1;
+
+#
+# Zero dates using numbers was not checked properly (Bug #5933)
+#
+
+create table t1 (col1 date, col2 datetime, col3 timestamp);
+--error 1292
+insert into t1 values (0,0,0);
+--error 1292
+insert into t1 values (0.0,0.0,0.0);
+set sql_mode='no_zero_date';
+insert into t1 values (0,0,0);
+insert into t1 values (0.0,0.0,0.0);
+drop table t1;
+set sql_mode='traditional';
+create table t1 (col1 date);
+insert ignore into t1 values ('0000-00-00');
+--error 1292
+insert into t1 select * from t1;
+insert ignore into t1 values ('0000-00-00');
+--error 1292
+insert into t1 select * from t1;
+--error 1292
+alter table t1 modify col1 datetime;
+alter ignore table t1 modify col1 datetime;
+--error 1292
+insert into t1 select * from t1;
+select * from t1;
+drop table t1;
+
+#
 # Restore mode
 #
 set sql_mode=@org_mode;
--- New file ---
+++ sql/sql_error.h	05/04/01 15:04:45
/* Copyright (C) 2000-2003 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

class MYSQL_ERROR: public Sql_alloc
{
public:
  enum enum_warning_level
  { WARN_LEVEL_NOTE, WARN_LEVEL_WARN, WARN_LEVEL_ERROR, WARN_LEVEL_END};

  uint code;
  enum_warning_level level;
  char *msg;
  
  MYSQL_ERROR(THD *thd, uint code_arg, enum_warning_level level_arg,
	      const char *msg_arg)
    :code(code_arg), level(level_arg)
  {
    if (msg_arg)
      set_msg(thd, msg_arg);
  }
  void set_msg(THD *thd, const char *msg_arg);
};

MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
                          uint code, const char *msg);
void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level,
			 uint code, const char *format, ...);
void mysql_reset_errors(THD *thd, bool force);
bool mysqld_show_warnings(THD *thd, ulong levels_to_show);


--- 1.96/mysql-test/r/func_str.result	2005-03-25 09:45:19 +02:00
+++ 1.97/mysql-test/r/func_str.result	2005-04-01 15:04:43 +03:00
@@ -1,4 +1,4 @@
-drop table if exists t1;
+drop table if exists t1,t2;
 set names latin1;
 select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
 hello	'hello'	""hello""	'h'e'l'l'o'	hel"lo	hel'lo
@@ -236,6 +236,8 @@
 select position("0" in "baaa" in (1)),position("0" in "1" in (1,2,3)),position("sql" in ("mysql"));
 position("0" in "baaa" in (1))	position("0" in "1" in (1,2,3))	position("sql" in ("mysql"))
 1	0	3
+Warnings:
+Warning	1292	Truncated incorrect DOUBLE value: 'baaa'
 select position(("1" in (1,2,3)) in "01");
 position(("1" in (1,2,3)) in "01")
 2
@@ -393,9 +395,9 @@
 ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field'
 select FIELD('b',_latin2'A','B');
 ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field'
-select FIELD('b',_latin2'A','B',1);
-FIELD('b',_latin2'A','B',1)
-1
+select FIELD('1',_latin2'3','2',1);
+FIELD('1',_latin2'3','2',1)
+3
 select POSITION(_latin1'B' IN _latin1'abcd');
 POSITION(_latin1'B' IN _latin1'abcd')
 2

--- 1.70/mysql-test/t/func_str.test	2005-03-25 08:39:02 +02:00
+++ 1.71/mysql-test/t/func_str.test	2005-04-01 15:04:44 +03:00
@@ -3,7 +3,7 @@
 # Testing string functions
 
 --disable_warnings
-drop table if exists t1;
+drop table if exists t1,t2;
 --enable_warnings
 
 set names latin1;
@@ -244,7 +244,7 @@
 select FIELD(_latin2'b','A','B');
 --error 1270
 select FIELD('b',_latin2'A','B');
-select FIELD('b',_latin2'A','B',1);
+select FIELD('1',_latin2'3','2',1);
 
 select POSITION(_latin1'B' IN _latin1'abcd');
 select POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin);
@@ -523,4 +523,3 @@
  ORDER BY t1.id;
 
 DROP TABLE t1, t2;
-

--- 1.16/mysql-test/r/func_if.result	2004-10-28 15:44:55 +03:00
+++ 1.17/mysql-test/r/func_if.result	2005-04-01 15:04:43 +03:00
@@ -44,21 +44,26 @@
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	7	Using where; Using filesort
 Warnings:
 Note	1003	select if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,cast(`test`.`t1`.`st` as char charset binary)) AS `s` from `test`.`t1` where (`test`.`t1`.`st` like _latin1'%a%') order by if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,cast(`test`.`t1`.`st` as char charset binary))
-select nullif(u=0, 'test') from t1;
-nullif(u=0, 'test')
+select nullif(u, 1) from t1;
+nullif(u, 1)
 NULL
 NULL
 NULL
 NULL
 NULL
-1
-1
-explain extended select nullif(u=0, 'test') from t1;
+0
+0
+explain extended select nullif(u, 1) from t1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	7	
 Warnings:
-Note	1003	select nullif((`test`.`t1`.`u` = 0),_latin1'test') AS `nullif(u=0, 'test')` from `test`.`t1`
+Note	1003	select nullif(`test`.`t1`.`u`,1) AS `nullif(u, 1)` from `test`.`t1`
 drop table t1;
+select nullif(1,'test');
+nullif(1,'test')
+1
+Warnings:
+Warning	1292	Truncated incorrect DOUBLE value: 'test'
 select NULLIF(NULL,NULL), NULLIF(NULL,1), NULLIF(NULL,1.0), NULLIF(NULL,"test");
 NULLIF(NULL,NULL)	NULLIF(NULL,1)	NULLIF(NULL,1.0)	NULLIF(NULL,"test")
 NULL	NULL	NULL	NULL

--- 1.10/mysql-test/t/func_if.test	2004-10-06 19:14:30 +03:00
+++ 1.11/mysql-test/t/func_if.test	2005-04-01 15:04:44 +03:00
@@ -25,9 +25,10 @@
 #
 # NULLIF test
 #
-select nullif(u=0, 'test') from t1;
-explain extended select nullif(u=0, 'test') from t1;
+select nullif(u, 1) from t1;
+explain extended select nullif(u, 1) from t1;
 drop table t1;
+select nullif(1,'test');
 
 #
 # Bug 2629
Thread
bk commit into 5.0 tree (monty:1.1844) BUG#5933monty1 Apr