Bug #5975 InnoDB: error clustered record for sec rec not found
Submitted: 8 Oct 2004 12:05 Modified: 8 Oct 2004 14:58
Reporter: Jan Lindström
Status: Closed
Category:Server: InnoDB Severity:S1 (Critical)
Version:4.1.6 OS:Linux (Linux/Debian 2.4.27-1)
Assigned to: Heikki Tuuri Target Version:

[8 Oct 2004 12:05] Jan Lindström
Description:
While testing utf8 support on MySQL/InnoDB I had following error message on
log:

041008 12:28:40  InnoDB: error clustered record for sec rec not found
InnoDB: index `c` of table `test/jbtest09`
InnoDB: sec index record PHYSICAL RECORD: n_fields 3; 1-byte offs FALSE; info bits 0
 0: len 30; hex 6b6b6b6b6b6b6b6b6b612020202020202020202020202020202020202020; asc
kkkkkkkkka                    ;...(truncated); 1: len 8; hex 8000000000000002; asc       
 ;; 2: len 5; hex 6b6b6b6b6b; asc kkkkk;;

InnoDB: clust index record PHYSICAL RECORD: n_fields 5; 1-byte offs FALSE; info bits 0
 0: len 8; hex 8000000000000002; asc         ;; 1: len 5; hex 6b6b6b6b6b; asc kkkkk;; 2:
len 6; hex 000000000501; asc       ;; 3: len 7; hex 800000002d009a; asc     -  ;; 4: len
30; hex 6b6b6b6b6b6b6b6b6b612020202020202020202020202020202020202020; asc kkkkkkkkka     
              ;...(truncated);

TRANSACTION 0 1283, ACTIVE 90 sec, process no 7495, OS thread id 147466starting index
read, thread declared inside InnoDB 500
mysql tables in use 1, locked 0
MySQL thread id 1, query id 13 localhost jan Sending data
select * from jbtest09 where c = 'kkkkkkkkka'

InnoDB: Submit a detailed bug report to http://bugs.mysql.com

How to repeat:
set autocommit = 0;
drop table jbtest09 if exists;
create table jbtest09(a bigint not null auto_increment,c char(175),primary key(a,c(5)),
index (c(150))) type = innodb default charset utf8;
insert into jbtest09 values(1,'kkkkkkkkkkkkkkkd');
insert into jbtest09 values(2,'kkkkkkkkka');
insert into jbtest09 values(3,'kkkkkkkkkb');
delete from jbtest09 where a = 3;
select * from jbtest09 where c = 'kkkkkkkkkb';
commit;
select * from jbtest09 where c = 'kkkkkkkkkb';
select * from jbtest09 where c = 'kkkkkkkkka';
[8 Oct 2004 12:57] Heikki Tuuri
Hi!

I assigned Jan Lindström to fix this. The bug suddenly appeared to 4.1 when Monty merged
my bug fix from 4.0 to 4.1 on Wednesday :). My bugfix was not aware of multi-byte
charsets. The code below in row0row.c should in 4.1 use innobase_get_at_most_n_mbchars()
to construct the clustered index column prefix.

Thank you,

Heikki

                /* If the primary key contains a column prefix, then the
                secondary index may contain a longer prefix of the same
                column, or the full column, and we must adjust the length
                accordingly. */

                clust_col_prefix_len =
                        dict_index_get_nth_field(clust_index, i)->prefix_len;

                if (clust_col_prefix_len > 0) {
                        if (len != UNIV_SQL_NULL
                            && len > clust_col_prefix_len) {

                                dfield_set_len(dfield, clust_col_prefix_len);
                        }
                }
[8 Oct 2004 14:58] Heikki Tuuri
http://lists.mysql.com/internals/17496

fixes this in the latest 4.1 source tree, as well as another UTF-8 bug where InnoDB
printed in SELECTs to the .err log warnings about a prefix being > 255 bytes long.

Regards,

Heikki