List:Internals« Previous MessageNext Message »
From:monty Date:April 1 2005 2:06pm
Subject:bk commit into 5.0 tree (monty:1.1855)
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.1855 05/04/01 15:06:35 monty@stripped +7 -0
  Merge bk-internal.mysql.com:/home/bk/mysql-5.0
  into mysql.com:/home/my/mysql-5.0

  sql/sql_parse.cc
    1.437 05/04/01 15:06:32 monty@stripped +0 -0
    Auto merged

  sql/item.h
    1.112 05/04/01 15:06:32 monty@stripped +0 -0
    Auto merged

  sql/item.cc
    1.131 05/04/01 15:06:32 monty@stripped +0 -0
    Auto merged

  sql/field.h
    1.149 05/04/01 15:06:32 monty@stripped +0 -0
    Auto merged

  sql/field.cc
    1.249 05/04/01 15:06:31 monty@stripped +0 -0
    Auto merged

  mysql-test/t/subselect.test
    1.95 05/04/01 15:06:31 monty@stripped +0 -0
    Auto merged

  mysql-test/r/subselect.result
    1.109 05/04/01 15:06:31 monty@stripped +0 -0
    Auto merged

# 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/RESYNC

--- 1.248/sql/field.cc	2005-04-01 02:15:30 +03:00
+++ 1.249/sql/field.cc	2005-04-01 15:06:31 +03:00
@@ -4512,6 +4512,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)
@@ -5137,6 +5144,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)
   {
@@ -5165,6 +5178,7 @@
   }
   else
     tmp=(long) nr;
+
 #ifdef WORDS_BIGENDIAN
   if (table->s->db_low_byte_first)
   {
@@ -5277,6 +5291,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
@@ -5309,17 +5324,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));
 }
 
 
@@ -5339,6 +5354,8 @@
   }
   else
   {
+    uint month, day;
+
     tmp=(int32) nr;
     if (tmp)
     {
@@ -5346,24 +5363,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;
@@ -5380,6 +5406,7 @@
   return error;
 }
 
+
 bool Field_newdate::send_binary(Protocol *protocol)
 {
   TIME tm;
@@ -5387,11 +5414,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);
@@ -5399,6 +5428,7 @@
   return (longlong) j;
 }
 
+
 String *Field_newdate::val_str(String *val_buffer,
 			       String *val_ptr __attribute__((unused)))
 {
@@ -5426,6 +5456,7 @@
   return val_buffer;
 }
 
+
 bool Field_newdate::get_date(TIME *ltime,uint fuzzydate)
 {
   uint32 tmp=(uint32) uint3korr(ptr);
@@ -5438,11 +5469,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;
@@ -5451,6 +5484,7 @@
   return (a < b) ? -1 : (a > b) ? 1 : 0;
 }
 
+
 void Field_newdate::sort_string(char *to,uint length __attribute__((unused)))
 {
   to[0] = ptr[2];
@@ -5458,6 +5492,7 @@
   to[2] = ptr[0];
 }
 
+
 void Field_newdate::sql_type(String &res) const
 {
   res.set_ascii("date", 4);
@@ -5514,10 +5549,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;
 }
 
@@ -5534,6 +5569,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)
@@ -8285,7 +8327,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
@@ -8301,18 +8373,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;
@@ -8336,8 +8410,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)
 {
@@ -8364,8 +8439,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)
 {
@@ -8395,8 +8471,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() ||
@@ -8407,32 +8484,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.148/sql/field.h	2005-04-01 02:13:23 +03:00
+++ 1.149/sql/field.h	2005-04-01 15:06:32 +03:00
@@ -280,17 +280,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.130/sql/item.cc	2005-04-01 11:00:33 +03:00
+++ 1.131/sql/item.cc	2005-04-01 15:06:32 +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.111/sql/item.h	2005-04-01 11:00:34 +03:00
+++ 1.112/sql/item.h	2005-04-01 15:06:32 +03:00
@@ -1098,21 +1098,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.436/sql/sql_parse.cc	2005-04-01 02:15:32 +03:00
+++ 1.437/sql/sql_parse.cc	2005-04-01 15:06:32 +03:00
@@ -1909,10 +1909,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.108/mysql-test/r/subselect.result	2005-03-31 10:39:42 +03:00
+++ 1.109/mysql-test/r/subselect.result	2005-04-01 15:06:31 +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.94/mysql-test/t/subselect.test	2005-04-01 02:13:22 +03:00
+++ 1.95/mysql-test/t/subselect.test	2005-04-01 15:06:31 +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
Thread
bk commit into 5.0 tree (monty:1.1855)monty1 Apr