List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:January 8 2009 6:28pm
Subject:bzr commit into mysql-5.1-bugteam branch (davi:2729)
View as plain text  
# At a local mysql-5.1-bugteam repository of davi

 2729 Davi Arnaut	2009-01-08 [merge]
      Auto-merge from upstream 5.1-bugteam
modified:
  client/mysqltest.c
  mysql-test/r/partition_pruning.result
  mysql-test/suite/binlog/r/binlog_innodb.result
  mysql-test/suite/binlog/t/binlog_innodb.test
  mysql-test/t/partition_pruning.test
  sql/ha_partition.cc
  sql/mysqld.cc
  sql/set_var.cc
  sql/sql_partition.cc

=== modified file 'client/mysqltest.c'
--- a/client/mysqltest.c	2008-07-21 09:20:03 +0000
+++ b/client/mysqltest.c	2009-01-05 22:25:03 +0000
@@ -1327,6 +1327,35 @@ static int run_tool(const char *tool_pat
   DBUG_RETURN(ret);
 }
 
+/*
+  Test if diff is present.  This is needed on Windows systems
+  as the OS returns 1 whether diff is successful or if it is
+  not present.
+  
+  We run diff -v and look for output in stdout.
+  We don't redirect stderr to stdout to make for a simplified check
+  Windows will output '"diff"' is not recognized... to stderr if it is
+  not present.
+*/
+
+int diff_check()
+{
+ char buf[512]= {0};
+ FILE *res_file;
+ char *cmd = "diff -v";
+ int have_diff = 0;
+
+  if (!(res_file= popen(cmd, "r")))
+    die("popen(\"%s\", \"r\") failed", cmd);
+
+/* if diff is not present, nothing will be in stdout to increment have_diff */
+  if (fgets(buf, sizeof(buf), res_file))
+  {
+    have_diff += 1;
+  } 
+ pclose(res_file);
+ return have_diff;
+}
 
 /*
   Show the diff of two files using the systems builtin diff
@@ -1346,34 +1375,51 @@ void show_diff(DYNAMIC_STRING* ds,
 {
 
   DYNAMIC_STRING ds_tmp;
+  int have_diff = 0;
 
   if (init_dynamic_string(&ds_tmp, "", 256, 256))
     die("Out of memory");
+  
+  /* determine if we have diff on Windows
+     needs special processing due to return values
+     on that OS
+  */
+  have_diff = diff_check();
 
-  /* First try with unified diff */
-  if (run_tool("diff",
-               &ds_tmp, /* Get output from diff in ds_tmp */
-               "-u",
-               filename1,
-               filename2,
-               "2>&1",
-               NULL) > 1) /* Most "diff" tools return >1 if error */
+  if (have_diff)
   {
-    dynstr_set(&ds_tmp, "");
-
-    /* Fallback to context diff with "diff -c" */
+    /* First try with unified diff */
     if (run_tool("diff",
                  &ds_tmp, /* Get output from diff in ds_tmp */
-                 "-c",
+                 "-u",
                  filename1,
                  filename2,
                  "2>&1",
                  NULL) > 1) /* Most "diff" tools return >1 if error */
     {
-      /*
-        Fallback to dump both files to result file and inform
-        about installing "diff"
-      */
+      dynstr_set(&ds_tmp, "");
+
+      /* Fallback to context diff with "diff -c" */
+      if (run_tool("diff",
+                   &ds_tmp, /* Get output from diff in ds_tmp */
+                   "-c",
+                   filename1,
+                   filename2,
+                   "2>&1",
+                   NULL) > 1) /* Most "diff" tools return >1 if error */
+      {
+        have_diff= 1;
+      }  
+    }
+  }
+
+if (!(have_diff))
+  {
+    /*
+      Fallback to dump both files to result file and inform
+      about installing "diff"
+    */
+      
       dynstr_set(&ds_tmp, "");
 
       dynstr_append(&ds_tmp,
@@ -1397,8 +1443,7 @@ void show_diff(DYNAMIC_STRING* ds,
       dynstr_append(&ds_tmp, " >>>\n");
       cat_file(&ds_tmp, filename2);
       dynstr_append(&ds_tmp, "<<<<\n");
-    }
-  }
+  } 
 
   if (ds)
   {

=== modified file 'mysql-test/r/partition_pruning.result'
--- a/mysql-test/r/partition_pruning.result	2008-07-07 20:42:19 +0000
+++ b/mysql-test/r/partition_pruning.result	2008-12-28 11:33:49 +0000
@@ -1,4 +1,16 @@
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+CREATE TABLE t1
+(a INT NOT NULL AUTO_INCREMENT,
+b DATETIME,
+PRIMARY KEY (a,b),
+KEY (b))
+PARTITION BY RANGE (to_days(b))
+(PARTITION p0 VALUES LESS THAN (733681) COMMENT = 'LESS THAN 2008-10-01',
+PARTITION p1 VALUES LESS THAN (733712) COMMENT = 'LESS THAN 2008-11-01',
+PARTITION pX VALUES LESS THAN MAXVALUE);
+SELECT a,b FROM t1 WHERE b >= '2008-12-01' AND b < '2009-12-00';
+a	b
+DROP TABLE t1;
 create table t1 ( a int not null) partition by hash(a) partitions 2;
 insert into t1 values (1),(2),(3);
 explain select * from t1 where a=5 and a=6;

=== modified file 'mysql-test/suite/binlog/r/binlog_innodb.result'
--- a/mysql-test/suite/binlog/r/binlog_innodb.result	2008-12-15 22:58:16 +0000
+++ b/mysql-test/suite/binlog/r/binlog_innodb.result	2009-01-08 02:06:54 +0000
@@ -113,16 +113,17 @@ master-bin.000001	#	Table_map	#	#	table_
 master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
 DROP TABLE t1;
+flush status;
 show status like "binlog_cache_use";
 Variable_name	Value
-Binlog_cache_use	13
+Binlog_cache_use	0
 show status like "binlog_cache_disk_use";
 Variable_name	Value
 Binlog_cache_disk_use	0
 create table t1 (a int) engine=innodb;
 show status like "binlog_cache_use";
 Variable_name	Value
-Binlog_cache_use	14
+Binlog_cache_use	1
 show status like "binlog_cache_disk_use";
 Variable_name	Value
 Binlog_cache_disk_use	1
@@ -131,7 +132,7 @@ delete from t1;
 commit;
 show status like "binlog_cache_use";
 Variable_name	Value
-Binlog_cache_use	15
+Binlog_cache_use	2
 show status like "binlog_cache_disk_use";
 Variable_name	Value
 Binlog_cache_disk_use	1

=== modified file 'mysql-test/suite/binlog/t/binlog_innodb.test'
--- a/mysql-test/suite/binlog/t/binlog_innodb.test	2007-08-14 21:35:19 +0000
+++ b/mysql-test/suite/binlog/t/binlog_innodb.test	2009-01-08 02:06:54 +0000
@@ -101,6 +101,7 @@ DROP TABLE t1;
 # Actually this test has nothing to do with innodb per se, it just requires
 # transactional table.
 #
+flush status;
 show status like "binlog_cache_use";
 show status like "binlog_cache_disk_use";
 

=== modified file 'mysql-test/t/partition_pruning.test'
--- a/mysql-test/t/partition_pruning.test	2007-09-14 10:18:42 +0000
+++ b/mysql-test/t/partition_pruning.test	2008-12-28 11:33:49 +0000
@@ -8,6 +8,22 @@
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 --enable_warnings
 
+#
+# Bug#40972: some sql execution lead the whole database crashing
+#
+# Setup so the start is at partition pX and end is at p1
+# Pruning does handle 'bad' dates differently.
+CREATE TABLE t1
+(a INT NOT NULL AUTO_INCREMENT,
+ b DATETIME,
+ PRIMARY KEY (a,b),
+ KEY (b))
+PARTITION BY RANGE (to_days(b))
+(PARTITION p0 VALUES LESS THAN (733681) COMMENT = 'LESS THAN 2008-10-01',
+ PARTITION p1 VALUES LESS THAN (733712) COMMENT = 'LESS THAN 2008-11-01',
+ PARTITION pX VALUES LESS THAN MAXVALUE);
+SELECT a,b FROM t1 WHERE b >= '2008-12-01' AND b < '2009-12-00';
+DROP TABLE t1;
 
 # Check if we can infer from condition on partition fields that 
 # no records will match.

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2009-01-05 16:10:20 +0000
+++ b/sql/ha_partition.cc	2009-01-07 22:30:10 +0000
@@ -4815,7 +4815,7 @@ int ha_partition::info(uint flag)
     /*
       Calculates statistical variables
       records:           Estimate of number records in table
-      We report sum (always at least 2)
+      We report sum (always at least 2 if not empty)
       deleted:           Estimate of number holes in the table due to
       deletes
       We report sum
@@ -4854,13 +4854,13 @@ int ha_partition::info(uint flag)
           stats.check_time= file->stats.check_time;
       }
     } while (*(++file_array));
-    if (stats.records < 2 &&
+    if (stats.records && stats.records < 2 &&
         !(m_file[0]->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT))
       stats.records= 2;
     if (stats.records > 0)
       stats.mean_rec_length= (ulong) (stats.data_file_length / stats.records);
     else
-      stats.mean_rec_length= 1; //? What should we set here 
+      stats.mean_rec_length= 0;
   }
   if (flag & HA_STATUS_CONST)
   {

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2009-01-05 16:10:20 +0000
+++ b/sql/mysqld.cc	2009-01-07 12:44:32 +0000
@@ -230,7 +230,7 @@ extern "C" sig_handler handle_segfault(i
 #if defined(__linux__)
 #define ENABLE_TEMP_POOL 1
 #else
-#define ENABLE_TEMP_TOOL 0
+#define ENABLE_TEMP_POOL 0
 #endif
 
 /* Constants */

=== modified file 'sql/set_var.cc'
--- a/sql/set_var.cc	2009-01-05 16:10:20 +0000
+++ b/sql/set_var.cc	2009-01-08 02:16:22 +0000
@@ -1527,14 +1527,14 @@ bool sys_var_thd_ulong::update(THD *thd,
   ulonglong tmp= var->save_result.ulonglong_value;
 
   /* Don't use bigger value than given with --maximum-variable-name=.. */
-  if ((ulong) tmp > max_system_variables.*offset)
+  if (tmp > max_system_variables.*offset)
   {
     throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) tmp);
     tmp= max_system_variables.*offset;
   }
 
   if (option_limits)
-    tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
+    tmp= fix_unsigned(thd, tmp, option_limits);
 #if SIZEOF_LONG < SIZEOF_LONG_LONG
   else if (tmp > ULONG_MAX)
   {
@@ -1543,6 +1543,7 @@ bool sys_var_thd_ulong::update(THD *thd,
   }
 #endif
 
+  DBUG_ASSERT(tmp <= ULONG_MAX);
   if (var->type == OPT_GLOBAL)
     global_system_variables.*offset= (ulong) tmp;
   else

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2009-01-05 16:10:20 +0000
+++ b/sql/sql_partition.cc	2009-01-07 22:28:49 +0000
@@ -6760,7 +6760,7 @@ int get_part_iter_for_interval_via_mappi
     store_key_image_to_rec(field, max_value, field_len);
     bool include_endp= !test(flags & NEAR_MAX);
     part_iter->part_nums.end= get_endpoint(part_info, 0, include_endp);
-    if (part_iter->part_nums.start == part_iter->part_nums.end &&
+    if (part_iter->part_nums.start >= part_iter->part_nums.end &&
         !part_iter->ret_null_part)
       return 0; /* No partitions */
   }
@@ -6938,7 +6938,7 @@ int get_part_iter_for_interval_via_walki
 
 uint32 get_next_partition_id_range(PARTITION_ITERATOR* part_iter)
 {
-  if (part_iter->part_nums.cur == part_iter->part_nums.end)
+  if (part_iter->part_nums.cur >= part_iter->part_nums.end)
   {
     part_iter->part_nums.cur= part_iter->part_nums.start;
     return NOT_A_PARTITION_ID;

Thread
bzr commit into mysql-5.1-bugteam branch (davi:2729) Davi Arnaut8 Jan