Bug #19026 Proper error message should be returned on creating index on BIT field
Submitted: 11 Apr 2006 22:27 Modified: 27 Apr 2006 6:51
Reporter: Nikolay Grishakin Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:5.0 -> OS:Linux (Linux)
Assigned to: Martin Skold CPU Architecture:Any

[11 Apr 2006 22:27] Nikolay Grishakin
Description:
The following test case crashes with core:

#### Try to ALTER DD Tables and add columns

CREATE TABLE test.t1 (a1 INT PRIMARY KEY) TABLESPACE ts STORAGE DISK ENGINE=NDB;
ALTER TABLE test.t1 ADD a2 FLOAT, ADD a3 DOUBLE, ADD a4 BIT, ADD a5 TINYINT, ADD a6 BIGINT, ADD a7 DATE, ADD a8 TIME, ADD a9 DATETIME, ADD a10 TINYTEXT, ADD a11 MEDIUMTEXT, ADD a12 LONGTEXT, ADD a13 TEXT, ADD a14 BLOB;
SHOW CREATE TABLE test.t1;

#### Try to ALTER DD Tables and add Indexes
ALTER TABLE test.t1 ADD INDEX (a2), ADD INDEX (a3), ADD INDEX (a4), ADD INDEX (a5), ADD INDEX (a6), ADD INDEX (a7), ADD INDEX (a8);

Last operation crashes the server. Here is a core back trace:

[root@nik-linux mysql-test]# gdb ../sql/mysqld ./var/master1-data/core.20187
GNU gdb Red Hat Linux (6.3.0.0-1.21rh)
Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0x1b2000
Core was generated by `/source/mysql-5.1-new/sql/mysqld --no-defaults --console --basedir=/source/mysq'.
Program terminated with signal 11, Segmentation fault.

warning: svr4_current_sos: Can't read pathname for load map: Input/output error

Reading symbols from /usr/lib/libz.so.1...done.
Loaded symbols for /usr/lib/libz.so.1
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libpthread.so.0...done.
Loaded symbols for /lib/libpthread.so.0
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
#0  0x001b2402 in __kernel_vsyscall ()
(gdb) bt
#0  0x001b2402 in __kernel_vsyscall ()
#1  0x0074655f in pthread_kill () from /lib/libpthread.so.0
#2  0x082e826c in write_core (sig=20187) at stacktrace.c:220
#3  0x081e0757 in handle_segfault (sig=11) at mysqld.cc:2179
#4  <signal handler called>
#5  0x0850b0da in NdbDictionary::Column::getColumnNo (this=0x0) at NdbDictionary.cpp:225
#6  0x084f768b in NdbDictInterface::create_index_obj_from_table (dst=0x0, tab=0x94cc338,
    prim=0x94d5868) at NdbDictionaryImpl.cpp:2976
#7  0x084fae00 in NdbDictionaryImpl::getIndexImpl (this=0x915bdc4,
    externalName=0x94c9609 "PRIMARY", internalName=@0xf38b8c)
    at NdbDictionaryImpl.cpp:2934
#8  0x0850eb3e in NdbDictionary::Dictionary::getIndex (this=0x0,
    indexName=0x94c9609 "PRIMARY", tableName=0xf38f69 "t1") at NdbDictionaryImpl.hpp:918
#9  0x0832d6c1 in ha_ndbcluster::add_index_handle (this=0xf38d94, thd=0x9115258,
    dict=0x915bdc4, key_info=0x94cb8b0, index_name=0x94c9609 "PRIMARY", index_no=0)
    at ha_ndbcluster.cc:1227
#10 0x0832db4b in ha_ndbcluster::open_indexes (this=0xf38d94, ndb=0x9153d28,
    tab=0x94c9078, ignore_error=true) at ha_ndbcluster.cc:1284
#11 0x0833ec77 in ndb_handle_schema_change (thd=0x9115258, ndb=0x9153d28, pOp=0x91140e8,
    share=0x94c8998) at ha_ndbcluster_binlog.cc:1412
#12 0x08342b71 in ndb_binlog_thread_func (arg=0x0) at ha_ndbcluster_binlog.cc:2705
#13 0x00743b80 in start_thread () from /lib/libpthread.so.0
#14 0x0069bdee in clone () from /lib/libc.so.6

How to repeat:
see above
[11 Apr 2006 22:40] Nikolay Grishakin
No core with non NDB table. CREATE TABLE test.t1 (a1 INT PRIMARY KEY);
In this case MyISAM engine is used.
[11 Apr 2006 22:59] Nikolay Grishakin
Got rid of all TEXT and BLOB fields in table t1 but it did not help still see the core.
[12 Apr 2006 5:41] Jonas Oreland
Do you need DD ?
[12 Apr 2006 15:42] Nikolay Grishakin
Got the core with DD too. To reproduce change create statment in test case to
CREATE TABLE test.t1 (a1 INT PRIMARY KEY) ENGINE=NDB;

core back trace:

(gdb) bt
#0  0x00966402 in __kernel_vsyscall ()
#1  0x0074655f in pthread_kill () from /lib/libpthread.so.0
#2  0x082e826c in write_core (sig=3012) at stacktrace.c:220
#3  0x081e0757 in handle_segfault (sig=11) at mysqld.cc:2179
#4  <signal handler called>
#5  0x0850b0da in NdbDictionary::Column::getColumnNo (this=0x0) at NdbDictionary.cpp:225
#6  0x084f768b in NdbDictInterface::create_index_obj_from_table (dst=0x0, tab=0xa0d6338,
    prim=0xa0df868) at NdbDictionaryImpl.cpp:2976
#7  0x084fae00 in NdbDictionaryImpl::getIndexImpl (this=0x9d65dc4,
    externalName=0xa0d3609 "PRIMARY", internalName=@0x3cdb8c)
    at NdbDictionaryImpl.cpp:2934
#8  0x0850eb3e in NdbDictionary::Dictionary::getIndex (this=0x0,
    indexName=0xa0d3609 "PRIMARY", tableName=0x3cdf69 "t1") at NdbDictionaryImpl.hpp:918
#9  0x0832d6c1 in ha_ndbcluster::add_index_handle (this=0x3cdd94, thd=0x9d1f258,
    dict=0x9d65dc4, key_info=0xa0d58b0, index_name=0xa0d3609 "PRIMARY", index_no=0)
    at ha_ndbcluster.cc:1227
#10 0x0832db4b in ha_ndbcluster::open_indexes (this=0x3cdd94, ndb=0x9d5dd28,
    tab=0xa0d3078, ignore_error=true) at ha_ndbcluster.cc:1284
#11 0x0833ec77 in ndb_handle_schema_change (thd=0x9d1f258, ndb=0x9d5dd28, pOp=0x9d1e0e8,
    share=0xa0d2998) at ha_ndbcluster_binlog.cc:1412
#12 0x08342b71 in ndb_binlog_thread_func (arg=0x0) at ha_ndbcluster_binlog.cc:2705
#13 0x00743b80 in start_thread () from /lib/libpthread.so.0
#14 0x0069bdee in clone () from /lib/libc.so.6
[12 Apr 2006 16:18] Jonas Oreland
looks like online add index
[12 Apr 2006 16:29] Nikolay Grishakin
Removed DD from bug description.
[19 Apr 2006 16:58] Nikolay Grishakin
Just tried with latest mysql-5.1-new build and don't see the core any more. I see the error : "query 'ALTER TABLE test.t1 ADD INDEX (a4)' failed: 1005: Can't create table #'test.#sql-5711_2' (errno: 140)" trying to create index on BIT field.
The test case to reproduce:

-- source include/have_ndb.inc

 CREATE LOGFILE GROUP lg
 ADD UNDOFILE './lg_group/undofile.dat'
 INITIAL_SIZE 16M
 UNDO_BUFFER_SIZE = 1M
 ENGINE=NDB;

 CREATE TABLESPACE ts
 ADD DATAFILE './table_space/datafile.dat'
 USE LOGFILE GROUP lg
 INITIAL_SIZE 12M
 ENGINE NDB;

CREATE TABLE test.t1 (a1 INT PRIMARY KEY) TABLESPACE ts STORAGE DISK ENGINE=NDB;

ALTER TABLE test.t1 ADD a2 FLOAT, ADD a3 DOUBLE, ADD a4 BIT, ADD a5 TINYINT, ADD a6 BIGINT, ADD a7 DATE, ADD a8 TIME, ADD a9 DATETIME, ADD a10 TINYTEXT, ADD a11 MEDIUMTEXT, ADD a12 LONGTEXT, ADD a13 TEXT, ADD a14 BLOB;
SHOW CREATE TABLE test.t1;

ALTER TABLE test.t1 ADD INDEX (a4);

#query 'ALTER TABLE test.t1 ADD INDEX (a4)' failed: 1005: Can't create table #'test.#sql-5711_2' (errno: 140)

SHOW CREATE TABLE test.t1;

DROP TABLE test.t1;

 ALTER TABLESPACE ts
 DROP DATAFILE './table_space/datafile.dat'
 ENGINE NDB;
 DROP TABLESPACE ts ENGINE NDB;
 DROP LOGFILE GROUP lg
 ENGINE=NDB;
[21 Apr 2006 6:52] Martin Skold
This one appears to have been fixed in 5.1.10, since it is
no longer reproducable.
[21 Apr 2006 14:21] Nikolay Grishakin
Core is no longer here. Changing bug description to 
"Proper error message should be returned on creating index on BIT field" and removing P1 priority.
[24 Apr 2006 6:40] Tomas Ulin
this gives correct message for:

master> CREATE TABLE test.t2 (a1 INT PRIMARY KEY, a4 bit) engine=ndb;
Query OK, 0 rows affected (1.23 sec)

master>  ALTER TABLE test.t2 ADD INDEX (a4);
ERROR 1296 (HY000): Got error 906 'Unsupported attribute type in index' from NDBCLUSTER

But when using the longer create sequence above it gives:

master> ALTER TABLE test.t1 ADD INDEX (a4);
ERROR 1005 (HY000): Can't create table 'test.#sql-1cb7_2' (errno: 906)

So still "906" is given as the correct originating error code.

Therefore lowering to p4.