List:Commits« Previous MessageNext Message »
From:Frazer Clement Date:March 25 2008 2:26pm
Subject:bk commit into 5.1 tree (frazer:1.2536) BUG#35413
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of frazer.  When frazer 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@stripped, 2008-03-25 13:26:15+00:00, frazer@stripped +6 -0
  Bug#35413
  Fix to NdbInterpretedCode dynamic buffer extension

  mysql-test/suite/ndb/r/ndb_condition_pushdown.result@stripped, 2008-03-25 13:25:55+00:00,
frazer@stripped +5 -0
    Add testcase to check NdbInterpretedCode buffer extension.

  mysql-test/suite/ndb/r/ndb_read_multi_range.result@stripped, 2008-03-25 13:25:57+00:00,
frazer@stripped +30 -0
    Add MRR testcase which broke due to bad buffer extension

  mysql-test/suite/ndb/t/ndb_condition_pushdown.test@stripped, 2008-03-25 13:25:59+00:00,
frazer@stripped +8 -0
    Add testcase to check NdbInterpretedCode buffer extension.

  mysql-test/suite/ndb/t/ndb_read_multi_range.test@stripped, 2008-03-25 13:26:01+00:00,
frazer@stripped +23 -0
    Add MRR testcase which broke due to bad buffer extension

  storage/ndb/include/ndbapi/NdbInterpretedCode.hpp@stripped, 2008-03-25 13:26:03+00:00,
frazer@stripped +0 -1
    Remove Dynamic buf start size

  storage/ndb/src/ndbapi/NdbInterpretedCode.cpp@stripped, 2008-03-25 13:26:05+00:00,
frazer@stripped +32 -25
    Modify NdbInterpretedCode dynamic buffer extension code to check that extension is
enough.

diff -Nrup a/mysql-test/suite/ndb/r/ndb_condition_pushdown.result
b/mysql-test/suite/ndb/r/ndb_condition_pushdown.result
--- a/mysql-test/suite/ndb/r/ndb_condition_pushdown.result	2008-01-31 13:30:12 +00:00
+++ b/mysql-test/suite/ndb/r/ndb_condition_pushdown.result	2008-03-25 13:25:55 +00:00
@@ -1916,5 +1916,10 @@ a	b	d
 50	5	21845
 Warnings:
 Warning	4294	Scan filter is too large, discarded
+drop table t1;
+create table t1 (a int primary key, b varchar(5000) character set latin1) engine=ndb;
+insert into t1 values (0, 'I just cant beg you, any-more');
+select * from t1 where b="value";
+a	b
 set engine_condition_pushdown = @old_ecpd;
 DROP TABLE t1,t2,t3,t4,t5;
diff -Nrup a/mysql-test/suite/ndb/r/ndb_read_multi_range.result
b/mysql-test/suite/ndb/r/ndb_read_multi_range.result
--- a/mysql-test/suite/ndb/r/ndb_read_multi_range.result	2007-10-26 12:09:30 +01:00
+++ b/mysql-test/suite/ndb/r/ndb_read_multi_range.result	2008-03-25 13:25:57 +00:00
@@ -507,3 +507,33 @@ delete from t1 where a in (7,8) or a >= 
 select * from t1 order by a;
 a	b
 drop table t1;
+create table t1 (a varchar(1536) not null,
+b varchar(1536) not null,
+c int, primary key (a,b)) engine=ndb;
+insert into t1 values ('a', 'a', 1), ('b', 'b', 2), ('c', 'c', 3),
+('d', 'd', 4), ('e', 'e', 5), ('f', 'f', 6),
+('g', 'g', 7), ('h', 'h', 8), ('i', 'i', 9),
+('j', 'j', 10), ('k', 'k', 11), ('l', 'l', 12),
+('m', 'm', 13), ('n', 'n', 14), ('o', 'o', 15),
+('p', 'p', 16), ('q', 'q', 17), ('r', 'r', 18),
+('s', 's', 19), ('t', 't', 20), ('u', 'u', 21),
+('v', 'v', 22), ('w', 'w', 23), ('x', 'x', 24);
+select * from t1
+where (a >= 'aa' and b >= 'x' and a <= 'c' and b <= 'c')
+or (a = 'd')
+or (a = 'e')
+or (a = 'f')
+or (a > 'g' and a < 'ii')
+or (a >= 'j' and b >= 'x' and a <= 'k' and b <= 'k')
+or (a = 'm' and b = 'm')
+or (a = 'v')
+order by a asc, b asc;
+a	b	c
+d	d	4
+e	e	5
+f	f	6
+h	h	8
+i	i	9
+m	m	13
+v	v	22
+drop table t1;
diff -Nrup a/mysql-test/suite/ndb/t/ndb_condition_pushdown.test
b/mysql-test/suite/ndb/t/ndb_condition_pushdown.test
--- a/mysql-test/suite/ndb/t/ndb_condition_pushdown.test	2008-02-19 15:00:26 +00:00
+++ b/mysql-test/suite/ndb/t/ndb_condition_pushdown.test	2008-03-25 13:25:59 +00:00
@@ -2050,5 +2050,13 @@ select a,b,d from t1
     order by b;
 --enable_query_log
 
+
+# Bug 35413, NdbInterpretedCode buffer extension problem
+drop table t1;
+
+create table t1 (a int primary key, b varchar(5000) character set latin1) engine=ndb;
+insert into t1 values (0, 'I just cant beg you, any-more');
+select * from t1 where b="value";
+
 set engine_condition_pushdown = @old_ecpd;
 DROP TABLE t1,t2,t3,t4,t5;
diff -Nrup a/mysql-test/suite/ndb/t/ndb_read_multi_range.test
b/mysql-test/suite/ndb/t/ndb_read_multi_range.test
--- a/mysql-test/suite/ndb/t/ndb_read_multi_range.test	2007-10-26 12:09:30 +01:00
+++ b/mysql-test/suite/ndb/t/ndb_read_multi_range.test	2008-03-25 13:26:01 +00:00
@@ -353,3 +353,26 @@ delete from t1 where a in (7,8) or a >= 
 select * from t1 order by a;
 
 drop table t1;
+
+create table t1 (a varchar(1536) not null,
+                 b varchar(1536) not null,
+                 c int, primary key (a,b)) engine=ndb;
+insert into t1 values ('a', 'a', 1), ('b', 'b', 2), ('c', 'c', 3),
+                      ('d', 'd', 4), ('e', 'e', 5), ('f', 'f', 6),
+                      ('g', 'g', 7), ('h', 'h', 8), ('i', 'i', 9),
+                      ('j', 'j', 10), ('k', 'k', 11), ('l', 'l', 12),
+                      ('m', 'm', 13), ('n', 'n', 14), ('o', 'o', 15),
+                      ('p', 'p', 16), ('q', 'q', 17), ('r', 'r', 18),
+                      ('s', 's', 19), ('t', 't', 20), ('u', 'u', 21),
+                      ('v', 'v', 22), ('w', 'w', 23), ('x', 'x', 24);
+select * from t1
+ where (a >= 'aa' and b >= 'x' and a <= 'c' and b <= 'c')
+    or (a = 'd')
+    or (a = 'e')
+    or (a = 'f')
+    or (a > 'g' and a < 'ii')
+    or (a >= 'j' and b >= 'x' and a <= 'k' and b <= 'k')
+    or (a = 'm' and b = 'm')
+    or (a = 'v')
+    order by a asc, b asc;
+drop table t1;
diff -Nrup a/storage/ndb/include/ndbapi/NdbInterpretedCode.hpp
b/storage/ndb/include/ndbapi/NdbInterpretedCode.hpp
--- a/storage/ndb/include/ndbapi/NdbInterpretedCode.hpp	2008-02-20 08:12:02 +00:00
+++ b/storage/ndb/include/ndbapi/NdbInterpretedCode.hpp	2008-03-25 13:26:03 +00:00
@@ -489,7 +489,6 @@ private:
   static const Uint32 MaxReg= 8;
   static const Uint32 MaxLabels= 65535;
   static const Uint32 MaxSubs=65535;
-  static const Uint32 DynamicBufStartWords= 64;
   static const Uint32 MaxDynamicBufSize= NDB_MAX_SCANFILTER_SIZE_IN_WORDS;
 
   const NdbTableImpl *m_table_impl;
diff -Nrup a/storage/ndb/src/ndbapi/NdbInterpretedCode.cpp
b/storage/ndb/src/ndbapi/NdbInterpretedCode.cpp
--- a/storage/ndb/src/ndbapi/NdbInterpretedCode.cpp	2008-02-19 15:00:27 +00:00
+++ b/storage/ndb/src/ndbapi/NdbInterpretedCode.cpp	2008-03-25 13:26:05 +00:00
@@ -81,47 +81,54 @@ NdbInterpretedCode::error(Uint32 code)
 bool 
 NdbInterpretedCode::have_space_for(Uint32 wordsRequired)
 {
+  assert(m_last_meta_pos <= m_buffer_length);
+  assert(m_last_meta_pos >= m_instructions_length);
+  assert(m_available_length == m_last_meta_pos - m_instructions_length);
   if (likely(m_available_length >= wordsRequired))
     return true;
 
-  if (m_buffer_length == 0)
+  if ((m_internal_buffer != NULL) || (m_buffer_length == 0))
   {
-    /* First dynamic allocation */
-    m_buffer= m_internal_buffer= new Uint32 [ DynamicBufStartWords ];
-    
-    if (m_buffer != NULL)
-    {
-      m_last_meta_pos= m_available_length= m_buffer_length= 
-        DynamicBufStartWords;
-      return true;
-    }
-  }
-  else if (m_internal_buffer != NULL)
-  {
-    /* Dynamically double buffer length */
-    Uint32 newSize= m_buffer_length << 1;
+    Uint32 newSize= m_buffer_length;
+    const Uint32 extraRequired= wordsRequired - m_available_length; 
+
+    /* Initial allocation of dynamic buffer */
+    if (newSize == 0)
+      newSize= 1;
 
+    do {
+      /* Double buffer length until there's enough space, or 
+       * we reach the maximum size
+       */
+      newSize= newSize << 1;
+    } while (((newSize - m_buffer_length) < extraRequired) &&
+             (newSize < MaxDynamicBufSize));
+    
     if (newSize > MaxDynamicBufSize)
       newSize= MaxDynamicBufSize;
     
-    if (newSize > m_buffer_length)
+    /* Were we able to get enough extra space? */
+    if ((newSize - m_buffer_length) >= extraRequired)
     {
       Uint32 *newBuf= new Uint32[ newSize ];
       
       if (newBuf != NULL)
       {
-        /* Copy instruction words to start of new buffer */
-        memcpy(newBuf, m_internal_buffer, m_instructions_length << 2);
-        
         Uint32 metaInfoWords= m_buffer_length - m_last_meta_pos;
         Uint32 newLastMetaInfoPos= newSize - metaInfoWords;
+
+        if (m_buffer_length > 0)
+        {
+          /* Copy instruction words to start of new buffer */
+          memcpy(newBuf, m_internal_buffer, m_instructions_length << 2);
+          
+          /* Copy metainfo words to end of new buffer */
+          memcpy(&newBuf[ newLastMetaInfoPos ],
+                 &m_buffer[ m_last_meta_pos ],
+                 metaInfoWords << 2);
         
-        /* Copy metainfo words to end of new buffer */
-        memcpy(&newBuf[ newLastMetaInfoPos ],
-               &m_buffer[ m_last_meta_pos ],
-               metaInfoWords << 2);
-        
-        delete [] m_internal_buffer;
+          delete [] m_internal_buffer;
+        }
         
         m_buffer= m_internal_buffer= newBuf;
         m_available_length+= (newSize - m_buffer_length);
Thread
bk commit into 5.1 tree (frazer:1.2536) BUG#35413Frazer Clement25 Mar 2008