List:Commits« Previous MessageNext Message »
From:msvensson Date:February 7 2006 6:18pm
Subject:bk commit into 5.1 tree (msvensson:1.2084)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of msvensson. When msvensson 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.2084 06/02/07 18:17:57 msvensson@neptunus.(none) +4 -0
  Merge
neptunus.(none):/home/msvensson/mysql/mysqltest_float_result/my51-mysqltest_float_result
  into  neptunus.(none):/home/msvensson/mysql/mysql-5.1-new

  mysql-test/t/variables.test
    1.54 06/02/07 18:17:51 msvensson@neptunus.(none) +0 -0
    Auto merged

  mysql-test/t/type_float.test
    1.29 06/02/07 18:17:51 msvensson@neptunus.(none) +0 -0
    Auto merged

  mysql-test/r/type_float.result
    1.45 06/02/07 18:17:51 msvensson@neptunus.(none) +0 -0
    Auto merged

  client/mysqltest.c
    1.179 06/02/07 18:17:50 msvensson@neptunus.(none) +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:	msvensson
# Host:	neptunus.(none)
# Root:	/home/msvensson/mysql/mysql-5.1-new/RESYNC

--- 1.44/mysql-test/r/type_float.result	2006-02-01 15:00:28 +01:00
+++ 1.45/mysql-test/r/type_float.result	2006-02-07 18:17:51 +01:00
@@ -240,6 +240,28 @@
   `d` double(22,9) default NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1, t2, t3;
+create table t1 select  105213674794682365.00 + 0.0 x;
+show warnings;
+Level	Code	Message
+desc  t1;
+Field	Type	Null	Key	Default	Extra
+x	decimal(21,2) unsigned	NO		0.00	
+drop table t1;
+create table t1 select 0.0 x;
+desc t1;
+Field	Type	Null	Key	Default	Extra
+x	decimal(2,1) unsigned	NO		0.0	
+create table t2 select 105213674794682365.00 y;
+desc t2;
+Field	Type	Null	Key	Default	Extra
+y	decimal(20,2) unsigned	NO		0.00	
+create table t3 select x+y a from t1,t2;
+show warnings;
+Level	Code	Message
+desc t3;
+Field	Type	Null	Key	Default	Extra
+a	decimal(21,2) unsigned	NO		0.00	
+drop table t1,t2,t3;
 create table t1 (s1 float(0,2));
 ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column
's1').
 create table t1 (s1 float(1,2));

--- 1.28/mysql-test/t/type_float.test	2006-01-21 15:39:33 +01:00
+++ 1.29/mysql-test/t/type_float.test	2006-02-07 18:17:51 +01:00
@@ -6,9 +6,7 @@
 drop table if exists t1,t2;
 --enable_warnings
 
---replace_result e-0 e- e+0 e+
 SELECT 10,10.0,10.,.1e+2,100.0e-1;
---replace_result e-00 e-0 
 SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000;
 SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1;
 SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01;
@@ -21,7 +19,6 @@
 show full columns from t1;
 insert into t1
values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150);
 insert into t1
values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150);
---replace_result e-0 e- e+0 e+
 select * from t1;
 drop table t1;
 

--- 1.53/mysql-test/t/variables.test	2006-02-01 15:00:28 +01:00
+++ 1.54/mysql-test/t/variables.test	2006-02-07 18:17:51 +01:00
@@ -47,7 +47,7 @@
 #
 # Test system variables
 #
-
+set GLOBAL max_join_size=10;
 set max_join_size=100;
 show variables like 'max_join_size';
 --replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR

--- 1.178/client/mysqltest.c	2006-02-07 18:12:16 +01:00
+++ 1.179/client/mysqltest.c	2006-02-07 18:17:50 +01:00
@@ -3605,6 +3605,59 @@
 
 
 /*
+  Append the result for one field to the dynamic string ds
+*/
+
+static void append_field(DYNAMIC_STRING *ds, uint col_idx, MYSQL_FIELD* field,
+                         const char* val, ulonglong len, bool is_null)
+{
+
+  char buf[256];
+  if (col_idx < max_replace_column && replace_column[col_idx])
+  {
+    val= replace_column[col_idx];
+    len= strlen(val);
+  }
+  else if (is_null)
+  {
+    val= "NULL";
+    len= 4;
+  }
+#ifdef __WIN__
+  else if ((field->type == MYSQL_TYPE_DOUBLE ||
+            field->type == MYSQL_TYPE_FLOAT ) &&
+           field->decimals >= 31)
+  {
+    /* Convert 1.2e+018 to 1.2e+18 and 1.2e-018 to 1.2e-18 */
+    char *start= strchr(val, 'e');
+    if (start && strlen(start) >= 5 &&
+        (start[1] == '-' || start[1] == '+') && start[2] == '0')
+    {
+      start+=2; /* Now points at first '0' */
+      /* Move all chars after the first '0' one step left */
+      memmove(start, start + 1, strlen(start));
+      len--;
+    }
+  }
+#endif
+
+  if (!display_result_vertically)
+  {
+    if (col_idx)
+      dynstr_append_mem(ds, "\t", 1);
+    replace_dynstr_append_mem(ds, val, (int)len);
+  }
+  else
+  {
+    dynstr_append(ds, field->name);
+    dynstr_append_mem(ds, "\t", 1);
+    replace_dynstr_append_mem(ds, val, (int)len);
+    dynstr_append_mem(ds, "\n", 1);
+  }
+}
+
+
+/*
   Append all results to the dynamic string separated with '\t'
   Values may be converted with 'replace_column'
 */
@@ -3613,41 +3666,16 @@
 {
   MYSQL_ROW row;
   uint num_fields= mysql_num_fields(res);
-  MYSQL_FIELD *fields= !display_result_vertically ? 0 : mysql_fetch_fields(res);
+  MYSQL_FIELD *fields= mysql_fetch_fields(res);
   ulong *lengths;
+
   while ((row = mysql_fetch_row(res)))
   {
     uint i;
     lengths = mysql_fetch_lengths(res);
     for (i = 0; i < num_fields; i++)
-    {
-      const char *val= row[i];
-      ulonglong len= lengths[i];
-
-      if (i < max_replace_column && replace_column[i])
-      {
-	val= replace_column[i];
-	len= strlen(val);
-      }
-      if (!val)
-      {
-	val= "NULL";
-	len= 4;
-      }
-      if (!display_result_vertically)
-      {
-	if (i)
-	  dynstr_append_mem(ds, "\t", 1);
-	replace_dynstr_append_mem(ds, val, (int)len);
-      }
-      else
-      {
-	dynstr_append(ds, fields[i].name);
-	dynstr_append_mem(ds, "\t", 1);
-	replace_dynstr_append_mem(ds, val, (int)len);
-	dynstr_append_mem(ds, "\n", 1);
-      }
-    }
+      append_field(ds, i, &fields[i],
+                   (const char*)row[i], lengths[i], !row[i]);
     if (!display_result_vertically)
       dynstr_append_mem(ds, "\n", 1);
   }
@@ -3661,13 +3689,12 @@
 */
 
 static void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
-			       MYSQL_FIELD *field, uint num_fields)
+                               MYSQL_FIELD *fields, uint num_fields)
 {
   MYSQL_BIND *bind;
   my_bool *is_null;
   ulong *length;
-  ulonglong num_rows;
-  uint col_idx, row_idx;
+  uint i;
 
   /* Allocate array with bind structs, lengths and NULL flags */
   bind= (MYSQL_BIND*) my_malloc(num_fields * sizeof(MYSQL_BIND),
@@ -3677,71 +3704,29 @@
   is_null= (my_bool*) my_malloc(num_fields * sizeof(my_bool),
 				MYF(MY_WME | MY_FAE));
 
-  for (col_idx= 0; col_idx < num_fields; col_idx++)
+  /* Allocate data for the result of each field */
+  for (i= 0; i < num_fields; i++)
   {
-    /* Allocate data for output */
-    uint max_length= field[col_idx].max_length + 1;
-    char *str_data= (char *) my_malloc(max_length, MYF(MY_WME | MY_FAE));
-
-    bind[col_idx].buffer_type= MYSQL_TYPE_STRING;
-    bind[col_idx].buffer= (char *)str_data;
-    bind[col_idx].buffer_length= max_length;
-    bind[col_idx].is_null= &is_null[col_idx];
-    bind[col_idx].length= &length[col_idx];
+    uint max_length= fields[i].max_length + 1;
+    bind[i].buffer_type= MYSQL_TYPE_STRING;
+    bind[i].buffer= (char *)my_malloc(max_length, MYF(MY_WME | MY_FAE));
+    bind[i].buffer_length= max_length;
+    bind[i].is_null= &is_null[i];
+    bind[i].length= &length[i];
 
     DBUG_PRINT("bind", ("col[%d]: buffer_type: %d, buffer_length: %d",
-			col_idx,
-			bind[col_idx].buffer_type,
-			bind[col_idx].buffer_length));
+			i, bind[i].buffer_type, bind[i].buffer_length));
   }
 
-  /* Fill in the data into the structures created above */
   if (mysql_stmt_bind_result(stmt, bind))
     die("mysql_stmt_bind_result failed: %d: %s",
 	mysql_stmt_errno(stmt), mysql_stmt_error(stmt));
 
-  /* Read result from each row */
-  num_rows= mysql_stmt_num_rows(stmt);
-  for (row_idx= 0; row_idx < num_rows; row_idx++)
-  {
-    if (mysql_stmt_fetch(stmt))
-      die("mysql_stmt_fetch failed: %d %s",
-	  mysql_stmt_errno(stmt), mysql_stmt_error(stmt));
-
-    /* Read result from each column */
-    for (col_idx= 0; col_idx < num_fields; col_idx++)
-    {
-      const char *val;
-      ulonglong len;
-      if (col_idx < max_replace_column && replace_column[col_idx])
-      {
-	val= replace_column[col_idx];
-	len= strlen(val);
-      }
-      else if (*bind[col_idx].is_null)
-      {
-	val= "NULL";
-	len= 4;
-      }
-      else
-      {
-	val= (const char *) bind[col_idx].buffer;
-	len= *bind[col_idx].length;
-      }
-      if (!display_result_vertically)
-      {
-	if (col_idx)                      /* No tab before first col */
-	  dynstr_append_mem(ds, "\t", 1);
-	replace_dynstr_append_mem(ds, val, (int)len);
-      }
-      else
-      {
-	dynstr_append(ds, field[col_idx].name);
-	dynstr_append_mem(ds, "\t", 1);
-	replace_dynstr_append_mem(ds, val, (int)len);
-	dynstr_append_mem(ds, "\n", 1);
-      }
-    }
+  while (mysql_stmt_fetch(stmt) == 0)
+  {
+    for (i= 0; i < num_fields; i++)
+      append_field(ds, i, &fields[i], (const char *) bind[i].buffer,
+                   *bind[i].length, *bind[i].is_null);
     if (!display_result_vertically)
       dynstr_append_mem(ds, "\n", 1);
   }
@@ -3752,10 +3737,10 @@
 
   free_replace_column();
 
-  for (col_idx= 0; col_idx < num_fields; col_idx++)
+  for (i= 0; i < num_fields; i++)
   {
     /* Free data for output */
-    my_free((gptr)bind[col_idx].buffer, MYF(MY_WME | MY_FAE));
+    my_free((gptr)bind[i].buffer, MYF(MY_WME | MY_FAE));
   }
   /* Free array with bind structs, lengths and NULL flags */
   my_free((gptr)bind    , MYF(MY_WME | MY_FAE));
Thread
bk commit into 5.1 tree (msvensson:1.2084)msvensson7 Feb