------------------------------------------------------------
revno: 2713
committer: Michael Widenius <[email protected]>
branch nick: mysql-maria
timestamp: Tue 2009-06-30 00:03:30 +0300
message:
  Added some changes inspired by Zardosht Kasheff:
  - Added a handler call (prepare_index_scan()) to inform storage engines that 
an index scan is about to take place.
  - Extended the maximun key parts for an index from 16 to 32
  - Extended MyISAM and Maria engines to support up to 32 parts
  
  Added checks for return value from ha_index_init()
modified:
  include/my_handler.h
  include/my_pthread.h
  mysql-test/r/create.result
  mysql-test/r/myisam.result
  mysql-test/r/ps_1general.result
  mysql-test/r/ps_2myisam.result
  mysql-test/r/ps_3innodb.result
  mysql-test/r/ps_4heap.result
  mysql-test/r/ps_5merge.result
  mysql-test/suite/maria/r/maria.result
  mysql-test/suite/maria/r/maria3.result
  mysql-test/suite/maria/r/ps_maria.result
  mysql-test/t/create.test
  mysql-test/t/myisam.test
  sql/handler.cc
  sql/handler.h
  sql/sql_select.cc
  sql/table.cc
  sql/unireg.h
  storage/maria/ha_maria.cc
  storage/myisam/ha_myisam.cc
  storage/myisam/mi_check.c
  tests/mysql_client_test.c

=== modified file 'include/my_handler.h'
--- include/my_handler.h        2008-10-10 15:28:41 +0000
+++ include/my_handler.h        2009-06-29 21:03:30 +0000
@@ -41,7 +41,7 @@
 */
 
 #define HA_MAX_KEY_LENGTH           1000        /* Max length in bytes */
-#define HA_MAX_KEY_SEG              16          /* Max segments for key */
+#define HA_MAX_KEY_SEG              32          /* Max segments for key */
 
 #define HA_MAX_POSSIBLE_KEY_BUFF    (HA_MAX_KEY_LENGTH + 24+ 6+6) 
 #define HA_MAX_KEY_BUFF  (HA_MAX_KEY_LENGTH+HA_MAX_KEY_SEG*6+8+8)

=== modified file 'include/my_pthread.h'
--- include/my_pthread.h        2009-02-19 09:01:25 +0000
+++ include/my_pthread.h        2009-06-29 21:03:30 +0000
@@ -687,15 +687,11 @@
 
 #define THREAD_NAME_SIZE 10
 #ifndef DEFAULT_THREAD_STACK
-#if SIZEOF_CHARP > 4
 /*
-  MySQL can survive with 32K, but some glibc libraries require > 128K stack
-  To resolve hostnames. Also recursive stored procedures needs stack.
+  We need to have at least 256K stack to handle calls to myisamchk_init()
+  with the current number of keys and key parts.
 */
 #define DEFAULT_THREAD_STACK   (256*1024L)
-#else
-#define DEFAULT_THREAD_STACK   (192*1024)
-#endif
 #endif
 
 #define MY_PTHREAD_LOCK_READ 0

=== modified file 'mysql-test/r/create.result'
--- mysql-test/r/create.result  2009-04-25 10:05:32 +0000
+++ mysql-test/r/create.result  2009-06-29 21:03:30 +0000
@@ -1487,10 +1487,10 @@
 drop table t1;
 create table t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, 
 c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, 
-c16 int, c17 int);
+c16 int, c17 int, c18 int,c19 int,c20 int,c21 int,c22 int,c23 int,c24 int,c25 
int,c26 int,c27 int,c28 int,c29 int,c30 int,c31 int,c32 int, c33 int);
 alter table t1 add key i1 (
-c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16, c17);
-ERROR 42000: Too many key parts specified; max 16 parts allowed
+c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16, 
c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28,c29,c30,c31,c32,c33);
+ERROR 42000: Too many key parts specified; max 32 parts allowed
 alter table t1 add key 
 a001_long_123456789_123456789_123456789_123456789_123456789_12345 (c1);
 ERROR 42000: Identifier name 
'a001_long_123456789_123456789_123456789_123456789_123456789_12345' is too long
@@ -1513,7 +1513,23 @@
   `c14` int(11) DEFAULT NULL,
   `c15` int(11) DEFAULT NULL,
   `c16` int(11) DEFAULT NULL,
-  `c17` int(11) DEFAULT NULL
+  `c17` int(11) DEFAULT NULL,
+  `c18` int(11) DEFAULT NULL,
+  `c19` int(11) DEFAULT NULL,
+  `c20` int(11) DEFAULT NULL,
+  `c21` int(11) DEFAULT NULL,
+  `c22` int(11) DEFAULT NULL,
+  `c23` int(11) DEFAULT NULL,
+  `c24` int(11) DEFAULT NULL,
+  `c25` int(11) DEFAULT NULL,
+  `c26` int(11) DEFAULT NULL,
+  `c27` int(11) DEFAULT NULL,
+  `c28` int(11) DEFAULT NULL,
+  `c29` int(11) DEFAULT NULL,
+  `c30` int(11) DEFAULT NULL,
+  `c31` int(11) DEFAULT NULL,
+  `c32` int(11) DEFAULT NULL,
+  `c33` int(11) DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
 

=== modified file 'mysql-test/r/myisam.result'
--- mysql-test/r/myisam.result  2009-02-19 09:01:25 +0000
+++ mysql-test/r/myisam.result  2009-06-29 21:03:30 +0000
@@ -2251,4 +2251,10 @@
 Table  Checksum
 test.t3        326284887
 drop table t1,t2,t3;
+create table t1 (a1 int,a2 int,a3 int,a4 int,a5 int,a6 int,a7 int,a8 int,a9 
int,a10 int,a11 int,a12 int,a13 int,a14 int,a15 int,a16 int,a17 int,a18 int,a19 
int,a20 int,a21 int,a22 int,a23 int,a24 int,a25 int,a26 int,a27 int,a28 int,a29 
int,a30 int,a31 int,a32 int,
+key(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32))
 engine=myisam;
+drop table t1;
+create table t1 (a1 int,a2 int,a3 int,a4 int,a5 int,a6 int,a7 int,a8 int,a9 
int,a10 int,a11 int,a12 int,a13 int,a14 int,a15 int,a16 int,a17 int,a18 int,a19 
int,a20 int,a21 int,a22 int,a23 int,a24 int,a25 int,a26 int,a27 int,a28 int,a29 
int,a30 int,a31 int,a32 int, a33 int,
+key(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33))
 engine=myisam;
+ERROR 42000: Too many key parts specified; max 32 parts allowed
 End of 5.1 tests

=== modified file 'mysql-test/r/ps_1general.result'
--- mysql-test/r/ps_1general.result     2008-09-06 00:51:17 +0000
+++ mysql-test/r/ps_1general.result     2009-06-29 21:03:30 +0000
@@ -447,7 +447,7 @@
 def                                    possible_keys   253     4096    0       
Y       0       31      8
 def                                    key     253     64      0       Y       
0       31      8
 def                                    key_len 253     4096    0       Y       
0       31      8
-def                                    ref     253     1024    0       Y       
0       31      8
+def                                    ref     253     2048    0       Y       
0       31      8
 def                                    rows    8       10      1       Y       
32928   0       63
 def                                    Extra   253     255     14      N       
1       31      8
 id     select_type     table   type    possible_keys   key     key_len ref     
rows    Extra
@@ -463,7 +463,7 @@
 def                                    possible_keys   253     4096    7       
Y       0       31      8
 def                                    key     253     64      7       Y       
0       31      8
 def                                    key_len 253     4096    1       Y       
0       31      8
-def                                    ref     253     1024    0       Y       
0       31      8
+def                                    ref     253     2048    0       Y       
0       31      8
 def                                    rows    8       10      1       Y       
32928   0       63
 def                                    Extra   253     255     27      N       
1       31      8
 id     select_type     table   type    possible_keys   key     key_len ref     
rows    Extra

=== modified file 'mysql-test/r/ps_2myisam.result'
--- mysql-test/r/ps_2myisam.result      2009-03-11 15:32:42 +0000
+++ mysql-test/r/ps_2myisam.result      2009-06-29 21:03:30 +0000
@@ -1159,7 +1159,7 @@
 def                                    possible_keys   253     4096    0       
Y       0       31      8
 def                                    key     253     64      0       Y       
0       31      8
 def                                    key_len 253     4096    0       Y       
0       31      8
-def                                    ref     253     1024    0       Y       
0       31      8
+def                                    ref     253     2048    0       Y       
0       31      8
 def                                    rows    8       10      1       Y       
32928   0       63
 def                                    Extra   253     255     0       N       
1       31      8
 id     select_type     table   type    possible_keys   key     key_len ref     
rows    Extra

=== modified file 'mysql-test/r/ps_3innodb.result'
--- mysql-test/r/ps_3innodb.result      2009-03-11 15:32:42 +0000
+++ mysql-test/r/ps_3innodb.result      2009-06-29 21:03:30 +0000
@@ -1159,7 +1159,7 @@
 def                                    possible_keys   253     4096    0       
Y       0       31      8
 def                                    key     253     64      0       Y       
0       31      8
 def                                    key_len 253     4096    0       Y       
0       31      8
-def                                    ref     253     1024    0       Y       
0       31      8
+def                                    ref     253     2048    0       Y       
0       31      8
 def                                    rows    8       10      1       Y       
32928   0       63
 def                                    Extra   253     255     0       N       
1       31      8
 id     select_type     table   type    possible_keys   key     key_len ref     
rows    Extra

=== modified file 'mysql-test/r/ps_4heap.result'
--- mysql-test/r/ps_4heap.result        2009-03-11 15:32:42 +0000
+++ mysql-test/r/ps_4heap.result        2009-06-29 21:03:30 +0000
@@ -1160,7 +1160,7 @@
 def                                    possible_keys   253     4096    0       
Y       0       31      8
 def                                    key     253     64      0       Y       
0       31      8
 def                                    key_len 253     4096    0       Y       
0       31      8
-def                                    ref     253     1024    0       Y       
0       31      8
+def                                    ref     253     2048    0       Y       
0       31      8
 def                                    rows    8       10      1       Y       
32928   0       63
 def                                    Extra   253     255     0       N       
1       31      8
 id     select_type     table   type    possible_keys   key     key_len ref     
rows    Extra

=== modified file 'mysql-test/r/ps_5merge.result'
--- mysql-test/r/ps_5merge.result       2009-03-11 15:32:42 +0000
+++ mysql-test/r/ps_5merge.result       2009-06-29 21:03:30 +0000
@@ -1202,7 +1202,7 @@
 def                                    possible_keys   253     4096    0       
Y       0       31      8
 def                                    key     253     64      0       Y       
0       31      8
 def                                    key_len 253     4096    0       Y       
0       31      8
-def                                    ref     253     1024    0       Y       
0       31      8
+def                                    ref     253     2048    0       Y       
0       31      8
 def                                    rows    8       10      1       Y       
32928   0       63
 def                                    Extra   253     255     0       N       
1       31      8
 id     select_type     table   type    possible_keys   key     key_len ref     
rows    Extra
@@ -4224,7 +4224,7 @@
 def                                    possible_keys   253     4096    0       
Y       0       31      8
 def                                    key     253     64      0       Y       
0       31      8
 def                                    key_len 253     4096    0       Y       
0       31      8
-def                                    ref     253     1024    0       Y       
0       31      8
+def                                    ref     253     2048    0       Y       
0       31      8
 def                                    rows    8       10      1       Y       
32928   0       63
 def                                    Extra   253     255     0       N       
1       31      8
 id     select_type     table   type    possible_keys   key     key_len ref     
rows    Extra

=== modified file 'mysql-test/suite/maria/r/maria.result'
--- mysql-test/suite/maria/r/maria.result       2009-02-19 09:01:25 +0000
+++ mysql-test/suite/maria/r/maria.result       2009-06-29 21:03:30 +0000
@@ -340,14 +340,14 @@
 test.t1        check   status  OK
 drop table t1;
 CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), d 
varchar(255), e varchar(255), KEY t1 (a, b, c, d, e));
-ERROR 42000: Specified key was too long; max key length is 1112 bytes
+ERROR 42000: Specified key was too long; max key length is 1208 bytes
 CREATE TABLE t1 (a varchar(32000), unique key(a));
-ERROR 42000: Specified key was too long; max key length is 1112 bytes
+ERROR 42000: Specified key was too long; max key length is 1208 bytes
 CREATE TABLE t1 (a varchar(1), b varchar(1), key 
(a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b));
-ERROR 42000: Too many key parts specified; max 16 parts allowed
+ERROR 42000: Too many key parts specified; max 32 parts allowed
 CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), d 
varchar(255), e varchar(255));
 ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e);
-ERROR 42000: Specified key was too long; max key length is 1112 bytes
+ERROR 42000: Specified key was too long; max key length is 1208 bytes
 DROP TABLE t1;
 CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), 
key(c,a));
 INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), 
(1,1,4);
@@ -1551,7 +1551,7 @@
 drop table t1;
 create table t1 (v varchar(65530), key(v));
 Warnings:
-Warning        1071    Specified key was too long; max key length is 1112 bytes
+Warning        1071    Specified key was too long; max key length is 1208 bytes
 drop table if exists t1;
 create table t1 (v varchar(65536));
 Warnings:
@@ -1789,34 +1789,34 @@
 drop table t1;
 create table t1 (a varchar(2048), key `a` (a));
 Warnings:
-Warning        1071    Specified key was too long; max key length is 1112 bytes
+Warning        1071    Specified key was too long; max key length is 1208 bytes
 show create table t1;
 Table  Create Table
 t1     CREATE TABLE `t1` (
   `a` varchar(2048) DEFAULT NULL,
-  KEY `a` (`a`(1112))
+  KEY `a` (`a`(1208))
 ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
 drop table t1;
 create table t1 (a varchar(2048), key `a` (a) key_block_size=1024);
 Warnings:
-Warning        1071    Specified key was too long; max key length is 1112 bytes
+Warning        1071    Specified key was too long; max key length is 1208 bytes
 show create table t1;
 Table  Create Table
 t1     CREATE TABLE `t1` (
   `a` varchar(2048) DEFAULT NULL,
-  KEY `a` (`a`(1112)) KEY_BLOCK_SIZE=8192
+  KEY `a` (`a`(1208)) KEY_BLOCK_SIZE=8192
 ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
 drop table t1;
 create table t1 (a int not null, b varchar(2048), key (a), key(b)) 
key_block_size=1024;
 Warnings:
-Warning        1071    Specified key was too long; max key length is 1112 bytes
+Warning        1071    Specified key was too long; max key length is 1208 bytes
 show create table t1;
 Table  Create Table
 t1     CREATE TABLE `t1` (
   `a` int(11) NOT NULL,
   `b` varchar(2048) DEFAULT NULL,
   KEY `a` (`a`) KEY_BLOCK_SIZE=8192,
-  KEY `b` (`b`(1112)) KEY_BLOCK_SIZE=8192
+  KEY `b` (`b`(1208)) KEY_BLOCK_SIZE=8192
 ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 KEY_BLOCK_SIZE=1024
 alter table t1 key_block_size=2048;
 show create table t1;
@@ -1825,7 +1825,7 @@
   `a` int(11) NOT NULL,
   `b` varchar(2048) DEFAULT NULL,
   KEY `a` (`a`) KEY_BLOCK_SIZE=8192,
-  KEY `b` (`b`(1112)) KEY_BLOCK_SIZE=8192
+  KEY `b` (`b`(1208)) KEY_BLOCK_SIZE=8192
 ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 KEY_BLOCK_SIZE=2048
 alter table t1 add c int, add key (c);
 show create table t1;
@@ -1835,7 +1835,7 @@
   `b` varchar(2048) DEFAULT NULL,
   `c` int(11) DEFAULT NULL,
   KEY `a` (`a`) KEY_BLOCK_SIZE=8192,
-  KEY `b` (`b`(1112)) KEY_BLOCK_SIZE=8192,
+  KEY `b` (`b`(1208)) KEY_BLOCK_SIZE=8192,
   KEY `c` (`c`) KEY_BLOCK_SIZE=8192
 ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 KEY_BLOCK_SIZE=2048
 alter table t1 key_block_size=0;
@@ -1848,33 +1848,33 @@
   `c` int(11) DEFAULT NULL,
   `d` int(11) DEFAULT NULL,
   KEY `a` (`a`) KEY_BLOCK_SIZE=8192,
-  KEY `b` (`b`(1112)) KEY_BLOCK_SIZE=8192,
+  KEY `b` (`b`(1208)) KEY_BLOCK_SIZE=8192,
   KEY `c` (`c`) KEY_BLOCK_SIZE=8192,
   KEY `d` (`d`)
 ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
 drop table t1;
 create table t1 (a int not null, b varchar(2048), key (a), key(b)) 
key_block_size=8192;
 Warnings:
-Warning        1071    Specified key was too long; max key length is 1112 bytes
+Warning        1071    Specified key was too long; max key length is 1208 bytes
 show create table t1;
 Table  Create Table
 t1     CREATE TABLE `t1` (
   `a` int(11) NOT NULL,
   `b` varchar(2048) DEFAULT NULL,
   KEY `a` (`a`),
-  KEY `b` (`b`(1112))
+  KEY `b` (`b`(1208))
 ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 KEY_BLOCK_SIZE=8192
 drop table t1;
 create table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, 
key(b)) key_block_size=8192;
 Warnings:
-Warning        1071    Specified key was too long; max key length is 1112 bytes
+Warning        1071    Specified key was too long; max key length is 1208 bytes
 show create table t1;
 Table  Create Table
 t1     CREATE TABLE `t1` (
   `a` int(11) NOT NULL,
   `b` varchar(2048) DEFAULT NULL,
   KEY `a` (`a`),
-  KEY `b` (`b`(1112))
+  KEY `b` (`b`(1208))
 ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0 KEY_BLOCK_SIZE=8192
 drop table t1;
 create table t1 (a int not null, b int, key (a) key_block_size=1024, key(b) 
key_block_size=8192) key_block_size=16384;
@@ -1897,12 +1897,12 @@
 drop table t1;
 create table t1 (a varchar(2048), key `a` (a) 
key_block_size=1000000000000000000);
 Warnings:
-Warning        1071    Specified key was too long; max key length is 1112 bytes
+Warning        1071    Specified key was too long; max key length is 1208 bytes
 show create table t1;
 Table  Create Table
 t1     CREATE TABLE `t1` (
   `a` varchar(2048) DEFAULT NULL,
-  KEY `a` (`a`(1112)) KEY_BLOCK_SIZE=8192
+  KEY `a` (`a`(1208)) KEY_BLOCK_SIZE=8192
 ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
 drop table t1;
 create table t1 (a int not null, key `a` (a) key_block_size=1025);

=== modified file 'mysql-test/suite/maria/r/maria3.result'
--- mysql-test/suite/maria/r/maria3.result      2009-06-02 09:58:27 +0000
+++ mysql-test/suite/maria/r/maria3.result      2009-06-29 21:03:30 +0000
@@ -17,12 +17,12 @@
 drop table t1;
 create table t1 (a varchar(2048), key `a` (a) 
key_block_size=1000000000000000000);
 Warnings:
-Warning        1071    Specified key was too long; max key length is 1112 bytes
+Warning        1071    Specified key was too long; max key length is 1208 bytes
 show create table t1;
 Table  Create Table
 t1     CREATE TABLE `t1` (
   `a` varchar(2048) DEFAULT NULL,
-  KEY `a` (`a`(1112)) KEY_BLOCK_SIZE=8192
+  KEY `a` (`a`(1208)) KEY_BLOCK_SIZE=8192
 ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
 drop table t1;
 create table t1 (a int not null, key `a` (a) key_block_size=1025);

=== modified file 'mysql-test/suite/maria/r/ps_maria.result'
--- mysql-test/suite/maria/r/ps_maria.result    2009-03-11 15:32:42 +0000
+++ mysql-test/suite/maria/r/ps_maria.result    2009-06-29 21:03:30 +0000
@@ -1159,7 +1159,7 @@
 def                                    possible_keys   253     4096    0       
Y       0       31      8
 def                                    key     253     64      0       Y       
0       31      8
 def                                    key_len 253     4096    0       Y       
0       31      8
-def                                    ref     253     1024    0       Y       
0       31      8
+def                                    ref     253     2048    0       Y       
0       31      8
 def                                    rows    8       10      1       Y       
32928   0       63
 def                                    Extra   253     255     0       N       
1       31      8
 id     select_type     table   type    possible_keys   key     key_len ref     
rows    Extra

=== modified file 'mysql-test/t/create.test'
--- mysql-test/t/create.test    2009-02-19 09:01:25 +0000
+++ mysql-test/t/create.test    2009-06-29 21:03:30 +0000
@@ -1106,12 +1106,12 @@
 
 create table t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, 
 c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, 
-c16 int, c17 int);
+c16 int, c17 int, c18 int,c19 int,c20 int,c21 int,c22 int,c23 int,c24 int,c25 
int,c26 int,c27 int,c28 int,c29 int,c30 int,c31 int,c32 int, c33 int);
 
 # Get error for max key parts
 --error 1070
 alter table t1 add key i1 (
- c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16, c17);
+ c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16, 
c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28,c29,c30,c31,c32,c33);
 
 # Get error for max key-name length
 --error 1059

=== modified file 'mysql-test/t/myisam.test'
--- mysql-test/t/myisam.test    2009-02-19 09:01:25 +0000
+++ mysql-test/t/myisam.test    2009-06-29 21:03:30 +0000
@@ -1498,4 +1498,17 @@
 CREATE TABLE t3 select * from t1;
 checksum table t3;
 drop table t1,t2,t3;
+
+#
+# Test number of supported key parts (32 is max)
+#
+
+create table t1 (a1 int,a2 int,a3 int,a4 int,a5 int,a6 int,a7 int,a8 int,a9 
int,a10 int,a11 int,a12 int,a13 int,a14 int,a15 int,a16 int,a17 int,a18 int,a19 
int,a20 int,a21 int,a22 int,a23 int,a24 int,a25 int,a26 int,a27 int,a28 int,a29 
int,a30 int,a31 int,a32 int,
+key(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32))
 engine=myisam;
+drop table t1;
+
+--error 1070
+create table t1 (a1 int,a2 int,a3 int,a4 int,a5 int,a6 int,a7 int,a8 int,a9 
int,a10 int,a11 int,a12 int,a13 int,a14 int,a15 int,a16 int,a17 int,a18 int,a19 
int,a20 int,a21 int,a22 int,a23 int,a24 int,a25 int,a26 int,a27 int,a28 int,a29 
int,a30 int,a31 int,a32 int, a33 int,
+key(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33))
 engine=myisam;
+
 --echo End of 5.1 tests

=== modified file 'sql/handler.cc'
--- sql/handler.cc      2009-05-22 12:38:50 +0000
+++ sql/handler.cc      2009-06-29 21:03:30 +0000
@@ -2102,8 +2102,8 @@
   else
   {
     /* Find the first row through the primary key */
-    (void) ha_index_init(primary_key, 0);
-    error=index_first(buf);
+    if (!(error = ha_index_init(primary_key, 0)))
+      error= index_first(buf);
     (void) ha_index_end();
   }
   DBUG_RETURN(error);

=== modified file 'sql/handler.h'
--- sql/handler.h       2009-02-19 09:01:25 +0000
+++ sql/handler.h       2009-06-29 21:03:30 +0000
@@ -1184,6 +1184,8 @@
     inited=NONE;
     DBUG_RETURN(index_end());
   }
+  /* This is called after index_init() if we need to do a index scan */
+  virtual int prepare_index_scan() { return 0; }
   int ha_rnd_init(bool scan)
   {
     int result;

=== modified file 'sql/sql_select.cc'
--- sql/sql_select.cc   2009-05-19 09:28:05 +0000
+++ sql/sql_select.cc   2009-06-29 21:03:30 +0000
@@ -11019,7 +11019,14 @@
     empty_record(table);
     if (table->group && join->tmp_table_param.sum_func_count &&
         table->s->keys && !table->file->inited)
-      table->file->ha_index_init(0, 0);
+    {
+      int tmp_error;
+      if ((tmp_error= table->file->ha_index_init(0, 0)))
+      {
+        table->file->print_error(tmp_error, MYF(0)); /* purecov: inspected */
+        DBUG_RETURN(-1);                             /* purecov: inspected */
+      }
+    }
   }
   /* Set up select_end */
   Next_select_func end_select= setup_end_select_func(join);
@@ -11810,7 +11817,11 @@
 
   if (!table->file->inited)
   {
-    table->file->ha_index_init(tab->ref.key, tab->sorted);
+    if ((error= table->file->ha_index_init(tab->ref.key, tab->sorted)))
+    {
+      table->file->print_error(error, MYF(0));/* purecov: inspected */
+      return 1;                               /* purecov: inspected */
+    }
   }
   if (cmp_buffer_with_ref(tab) ||
       (table->status & (STATUS_GARBAGE | STATUS_NO_PARENT | STATUS_NULL_ROW)))
@@ -11859,8 +11870,14 @@
 
   /* Initialize the index first */
   if (!table->file->inited)
-    table->file->ha_index_init(tab->ref.key, tab->sorted);
- 
+  {
+    if ((error= table->file->ha_index_init(tab->ref.key, tab->sorted)))
+    {
+      table->file->print_error(error, MYF(0));/* purecov: inspected */
+      return(1);                              /* purecov: inspected */
+    }
+  }
+
   /* Perform "Late NULLs Filtering" (see internals manual for explanations) */
   for (uint i= 0 ; i < tab->ref.key_parts ; i++)
   {
@@ -11895,7 +11912,13 @@
   TABLE *table= tab->table;
 
   if (!table->file->inited)
-    table->file->ha_index_init(tab->ref.key, tab->sorted);
+  {
+    if ((error= table->file->ha_index_init(tab->ref.key, tab->sorted)))
+    {
+      table->file->print_error(error, MYF(0));/* purecov: inspected */
+      return(1);                              /* purecov: inspected */
+    }
+  }
   if (cp_buffer_from_ref(tab->join->thd, table, &tab->ref))
     return -1;
   if ((error=table->file->index_read_last_map(table->record[0],
@@ -11999,7 +12022,7 @@
 static int
 join_read_first(JOIN_TAB *tab)
 {
-  int error;
+  int error= 0;
   TABLE *table=tab->table;
   if (!table->key_read && table->covering_keys.is_set(tab->index) &&
       !table->no_keyread)
@@ -12014,8 +12037,10 @@
   tab->read_record.index=tab->index;
   tab->read_record.record=table->record[0];
   if (!table->file->inited)
-    table->file->ha_index_init(tab->index, tab->sorted);
-  if ((error=tab->table->file->index_first(tab->table->record[0])))
+    error= table->file->ha_index_init(tab->index, tab->sorted);
+  if (!error)
+    error= table->file->prepare_index_scan();
+  if (error || (error=tab->table->file->index_first(tab->table->record[0])))
   {
     if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
       report_error(table, error);
@@ -12039,7 +12064,7 @@
 join_read_last(JOIN_TAB *tab)
 {
   TABLE *table=tab->table;
-  int error;
+  int error= 0;
   if (!table->key_read && table->covering_keys.is_set(tab->index) &&
       !table->no_keyread)
   {
@@ -12053,8 +12078,10 @@
   tab->read_record.index=tab->index;
   tab->read_record.record=table->record[0];
   if (!table->file->inited)
-    table->file->ha_index_init(tab->index, 1);
-  if ((error= tab->table->file->index_last(tab->table->record[0])))
+    error= table->file->ha_index_init(tab->index, 1);
+  if (!error)
+    error= table->file->prepare_index_scan();
+  if (error || (error= tab->table->file->index_last(tab->table->record[0])))
     return report_error(table, error);
   return 0;
 }
@@ -12076,8 +12103,12 @@
   int error;
   TABLE *table= tab->table;
 
-  if (!table->file->inited)
-    table->file->ha_index_init(tab->ref.key, 1);
+  if (!table->file->inited &&
+      (error= table->file->ha_index_init(tab->ref.key, 1)))
+  {
+    table->file->print_error(error, MYF(0));  /* purecov: inspected */
+    return(1);                                /* purecov: inspected */
+  }
 #if NOT_USED_YET
   /* as ft-key doesn't use store_key's, see also FT_SELECT::init() */
   if (cp_buffer_from_ref(tab->join->thd, table, &tab->ref))
@@ -12474,11 +12505,16 @@
   copy_funcs(join->tmp_table_param.items_to_copy);
   if ((error=table->file->ha_write_row(table->record[0])))
   {
-    if (create_internal_tmp_table_from_heap(join->thd, table, 
&join->tmp_table_param,
-                               error, 0))
+    if (create_internal_tmp_table_from_heap(join->thd, table,
+                                            &join->tmp_table_param,
+                                            error, 0))
       DBUG_RETURN(NESTED_LOOP_ERROR);            // Not a table_is_full error
     /* Change method to update rows */
-    table->file->ha_index_init(0, 0);
+    if ((error= table->file->ha_index_init(0, 0)))
+    {
+      table->file->print_error(error, MYF(0));/* purecov: inspected */
+      DBUG_RETURN(NESTED_LOOP_ERROR);         /* purecov: inspected */
+    }
     join->join_tab[join->tables-1].next_select=end_unique_update;
   }
   join->send_records++;

=== modified file 'sql/table.cc'
--- sql/table.cc        2009-05-19 09:28:05 +0000
+++ sql/table.cc        2009-06-29 21:03:30 +0000
@@ -2448,7 +2448,7 @@
 
   if ((file= my_create(name, CREATE_MODE, create_flags, MYF(0))) >= 0)
   {
-    uint key_length, tmp_key_length;
+    ulong key_length, tmp_key_length;
     uint tmp;
     bzero((char*) fileinfo,64);
     /* header */

=== modified file 'sql/unireg.h'
--- sql/unireg.h        2009-01-15 18:11:25 +0000
+++ sql/unireg.h        2009-06-29 21:03:30 +0000
@@ -51,7 +51,7 @@
 #define MAX_FIELD_NAME 34                      /* Max colum name length +2 */
 #define MAX_SYS_VAR_LENGTH 32
 #define MAX_KEY MAX_INDEXES                     /* Max used keys */
-#define MAX_REF_PARTS 16                       /* Max parts used as ref */
+#define MAX_REF_PARTS 32                       /* Max parts used as ref */
 #define MAX_KEY_LENGTH 3072                    /* max possible key */
 #if SIZEOF_OFF_T > 4
 #define MAX_REFLENGTH 8                                /* Max length for 
record ref */

=== modified file 'storage/maria/ha_maria.cc'
--- storage/maria/ha_maria.cc   2009-05-19 09:28:05 +0000
+++ storage/maria/ha_maria.cc   2009-06-29 21:03:30 +0000
@@ -1130,14 +1130,21 @@
 
 err:
   {
-    HA_CHECK param;
-    maria_chk_init(&param);
-    param.thd= thd;
-    param.op_name= "restore";
-    param.db_name= table->s->db.str;
-    param.table_name= table->s->table_name.str;
-    param.testflag= 0;
-    _ma_check_print_error(&param, errmsg, my_errno);
+    /*
+      Don't allocate param on stack here as this may be huge and it's
+      also allocated by repair()
+    */
+    HA_CHECK *param;
+    if (!(param= (HA_CHECK*) my_malloc(sizeof(*param), MYF(MY_WME | MY_FAE))))
+      DBUG_RETURN(error);
+    maria_chk_init(param);
+    param->thd= thd;
+    param->op_name= "restore";
+    param->db_name= table->s->db.str;
+    param->table_name= table->s->table_name.str;
+    param->testflag= 0;
+    _ma_check_print_error(param, errmsg, my_errno);
+    my_free(param, MYF(0));
     DBUG_RETURN(error);
   }
 }

=== modified file 'storage/myisam/ha_myisam.cc'
--- storage/myisam/ha_myisam.cc 2009-04-25 10:05:32 +0000
+++ storage/myisam/ha_myisam.cc 2009-06-29 21:03:30 +0000
@@ -910,14 +910,21 @@
 
  err:
   {
-    HA_CHECK param;
-    myisamchk_init(&param);
-    param.thd= thd;
-    param.op_name=    "restore";
-    param.db_name=    table->s->db.str;
-    param.table_name= table->s->table_name.str;
-    param.testflag= 0;
-    mi_check_print_error(&param, errmsg, my_errno);
+    /*
+      Don't allocate param on stack here as this may be huge and it's
+      also allocated by repair()
+    */
+    HA_CHECK *param;
+    if (!(param= (HA_CHECK*) my_malloc(sizeof(*param), MYF(MY_WME | MY_FAE))))
+      DBUG_RETURN(error);
+    myisamchk_init(param);
+    param->thd= thd;
+    param->op_name=    "restore";
+    param->db_name=    table->s->db.str;
+    param->table_name= table->s->table_name.str;
+    param->testflag= 0;
+    mi_check_print_error(param, errmsg, my_errno);
+    my_free(param, MYF(0));
     DBUG_RETURN(error);
   }
 }

=== modified file 'storage/myisam/mi_check.c'
--- storage/myisam/mi_check.c   2009-05-19 09:28:05 +0000
+++ storage/myisam/mi_check.c   2009-06-29 21:03:30 +0000
@@ -4629,8 +4629,9 @@
       let's ensure it is not
     */
     set_if_bigger(tmp,1);
-    if (tmp >= (ulonglong) ~(ulong) 0)
-      tmp=(ulonglong) ~(ulong) 0;
+    /* Keys are stored as 32 byte int's; Ensure we don't get an overflow */
+    if (tmp >= (ulonglong) ~(uint32) 0)
+      tmp=(ulonglong) ~(uint32) 0;
 
     *rec_per_key_part=(ulong) tmp;
     rec_per_key_part++;

=== modified file 'tests/mysql_client_test.c'
--- tests/mysql_client_test.c   2009-04-25 10:05:32 +0000
+++ tests/mysql_client_test.c   2009-06-29 21:03:30 +0000
@@ -33,6 +33,7 @@
 #include <my_getopt.h>
 #include <m_string.h>
 #include <mysqld_error.h>
+#include <my_handler.h>
 
 #define VER "2.1"
 #define MAX_TEST_QUERY_LENGTH 300 /* MAX QUERY BUFFER LENGTH */
@@ -789,8 +790,10 @@
   */
   if (length && (field->length != expected_field_length))
   {
+    fflush(stdout);
     fprintf(stderr, "Expected field length: %llu,  got length: %lu\n",
             expected_field_length, field->length);
+    fflush(stderr);
     DIE_UNLESS(field->length == expected_field_length);
   }
   if (def)
@@ -7809,8 +7812,9 @@
                          "", "", NAME_CHAR_LEN*MAX_KEY, 0);
   }
 
+  /* The length of this may verify between MariaDB versions (1024 / 2048) */
   verify_prepare_field(result, 7, "ref", "", MYSQL_TYPE_VAR_STRING,
-                       "", "", "", NAME_CHAR_LEN*16, 0);
+                       "", "", "", NAME_CHAR_LEN * HA_MAX_KEY_SEG, 0);
 
   verify_prepare_field(result, 8, "rows", "", MYSQL_TYPE_LONGLONG,
                        "", "", "", 10, 0);



--
lp:maria
https://code.launchpad.net/~maria-captains/maria/5.1

Your team Maria developers is subscribed to branch lp:maria.
To unsubscribe from this branch go to 
https://code.launchpad.net/~maria-captains/maria/5.1/+edit-subscription.

_______________________________________________
Mailing list: https://launchpad.net/~maria-developers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to