List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:October 16 2008 2:14am
Subject:bzr commit into mysql-6.0 branch (davi:2880)
View as plain text  
# At a local mysql-6.0 repository of davi

 2880 Davi Arnaut	2008-10-15 [merge]
      Merge mysql-5.1-bugteam into mysql-6.0-bugteam.
modified:
  include/my_pthread.h
  mysql-test/r/limit.result
  mysql-test/r/sp.result
  mysql-test/t/limit.test
  mysql-test/t/sp.test
  mysys/thr_mutex.c
  sql/item.cc
  sql/sql_lex.cc

=== modified file 'include/my_pthread.h'
--- a/include/my_pthread.h	2008-10-15 22:53:18 +0000
+++ b/include/my_pthread.h	2008-10-16 02:13:16 +0000
@@ -508,6 +508,7 @@ typedef struct st_my_pthread_fastmutex_t
 {
   pthread_mutex_t mutex;
   uint spins;
+  uint rng_state;
 } my_pthread_fastmutex_t;
 void fastmutex_global_init(void);
 

=== modified file 'mysql-test/r/limit.result'
--- a/mysql-test/r/limit.result	2008-02-28 14:34:08 +0000
+++ b/mysql-test/r/limit.result	2008-10-15 21:34:51 +0000
@@ -111,3 +111,6 @@ set @a=-14632475938453979136;
 execute s using @a, @a;
 ERROR HY000: Incorrect arguments to EXECUTE
 End of 5.0 tests
+select 1 as a limit 4294967296,10;
+a
+End of 5.1 tests

=== modified file 'mysql-test/r/sp.result'
--- a/mysql-test/r/sp.result	2008-09-25 11:46:17 +0000
+++ b/mysql-test/r/sp.result	2008-10-16 02:13:16 +0000
@@ -6828,6 +6828,19 @@ select substr(`str`, `pos`+ 1 ) into `st
 end $
 call `p2`('s s s s s s');
 drop procedure `p2`;
+drop table if exists t1;
+drop procedure if exists p1;
+create procedure p1() begin select * from t1; end$
+call p1$
+ERROR 42S02: Table 'test.t1' doesn't exist
+create table t1 (a integer)$
+call p1$
+a
+alter table t1 add b integer;
+call p1$
+a
+drop table t1;
+drop procedure p1;
 # ------------------------------------------------------------------
 # -- End of 5.0 tests
 # ------------------------------------------------------------------

=== modified file 'mysql-test/t/limit.test'
--- a/mysql-test/t/limit.test	2008-02-28 23:22:50 +0000
+++ b/mysql-test/t/limit.test	2008-10-16 01:50:56 +0000
@@ -95,3 +95,11 @@ set @a=-14632475938453979136;
 execute s using @a, @a;
 
 --echo End of 5.0 tests
+
+#
+# Bug#37075: offset of limit clause might be truncated to 0 on 32-bits server w/o big tables
+#
+
+select 1 as a limit 4294967296,10;
+
+--echo End of 5.1 tests

=== modified file 'mysql-test/t/sp.test'
--- a/mysql-test/t/sp.test	2008-09-25 11:46:17 +0000
+++ b/mysql-test/t/sp.test	2008-10-16 02:13:16 +0000
@@ -8038,6 +8038,28 @@ delimiter ;$
 call `p2`('s s s s s s');
 drop procedure `p2`;
 
+#
+# Bug#38823: Invalid memory access when a SP statement does wildcard expansion
+#
+
+--disable_warnings
+drop table if exists t1;
+drop procedure if exists p1;
+--enable_warnings
+
+delimiter $;
+create procedure p1() begin select * from t1; end$
+--error ER_NO_SUCH_TABLE
+call p1$
+create table t1 (a integer)$
+call p1$
+alter table t1 add b integer;
+call p1$
+delimiter ;$
+
+drop table t1;
+drop procedure p1;
+
 --echo # ------------------------------------------------------------------
 --echo # -- End of 5.0 tests
 --echo # ------------------------------------------------------------------

=== modified file 'mysys/thr_mutex.c'
--- a/mysys/thr_mutex.c	2007-12-16 15:03:44 +0000
+++ b/mysys/thr_mutex.c	2008-10-16 02:13:16 +0000
@@ -458,9 +458,33 @@ int my_pthread_fastmutex_init(my_pthread
     mp->spins= MY_PTHREAD_FASTMUTEX_SPINS; 
   else
     mp->spins= 0;
+  mp->rng_state= 1;
   return pthread_mutex_init(&mp->mutex, attr); 
 }
 
+/**
+  Park-Miller random number generator. A simple linear congruential
+  generator that operates in multiplicative group of integers modulo n.
+
+  x_{k+1} = (x_k g) mod n
+
+  Popular pair of parameters: n = 2^32 − 5 = 4294967291 and g = 279470273.
+  The period of the generator is about 2^31.
+  Largest value that can be returned: 2147483646 (RAND_MAX)
+
+  Reference:
+
+  S. K. Park and K. W. Miller
+  "Random number generators: good ones are hard to find"
+  Commun. ACM, October 1988, Volume 31, No 10, pages 1192-1201.
+*/
+
+static double park_rng(my_pthread_fastmutex_t *mp)
+{
+  mp->rng_state= ((my_ulonglong)mp->rng_state * 279470273U) % 4294967291U;
+  return (mp->rng_state / 2147483647.0);
+}
+
 int my_pthread_fastmutex_lock(my_pthread_fastmutex_t *mp)
 {
   int   res;
@@ -478,8 +502,7 @@ int my_pthread_fastmutex_lock(my_pthread
       return res;
 
     mutex_delay(maxdelay);
-    maxdelay += ((double) random() / (double) RAND_MAX) * 
-	        MY_PTHREAD_FASTMUTEX_DELAY + 1;
+    maxdelay += park_rng(mp) * MY_PTHREAD_FASTMUTEX_DELAY + 1;
   }
   return pthread_mutex_lock(&mp->mutex);
 }

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2008-10-13 10:44:56 +0000
+++ b/sql/item.cc	2008-10-16 02:13:16 +0000
@@ -1802,7 +1802,8 @@ Item_field::Item_field(THD *thd, Name_re
     be allocated in the statement memory, not in table memory (the table
     structure can go away and pop up again between subsequent executions
     of a prepared statement or after the close_tables_for_reopen() call
-    in mysql_multi_update_prepare()).
+    in mysql_multi_update_prepare() or due to wildcard expansion in stored
+    procedures).
   */
   {
     if (db_name)

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2008-10-07 22:05:23 +0000
+++ b/sql/sql_lex.cc	2008-10-16 02:13:16 +0000
@@ -2479,15 +2479,20 @@ void st_select_lex_unit::set_limit(st_se
   val= sl->select_limit ? sl->select_limit->val_uint() : HA_POS_ERROR;
   select_limit_val= (ha_rows)val;
 #ifndef BIG_TABLES
-  /* 
+  /*
     Check for overflow : ha_rows can be smaller then ulonglong if
     BIG_TABLES is off.
     */
   if (val != (ulonglong)select_limit_val)
     select_limit_val= HA_POS_ERROR;
 #endif
-  offset_limit_cnt= (ha_rows)(sl->offset_limit ? sl->offset_limit->val_uint() :
-                                                 ULL(0));
+  val= sl->offset_limit ? sl->offset_limit->val_uint() : ULL(0);
+  offset_limit_cnt= (ha_rows)val;
+#ifndef BIG_TABLES
+  /* Check for truncation. */
+  if (val != (ulonglong)offset_limit_cnt)
+    offset_limit_cnt= HA_POS_ERROR;
+#endif
   select_limit_cnt= select_limit_val + offset_limit_cnt;
   if (select_limit_cnt < select_limit_val)
     select_limit_cnt= HA_POS_ERROR;		// no limit

Thread
bzr commit into mysql-6.0 branch (davi:2880) Davi Arnaut16 Oct