From b62fafaa1507f057988c1d0fa7a2bda81ca71cec Mon Sep 17 00:00:00 2001 From: "bar@gw.udmsearch.izhnet.ru" <> Date: Wed, 5 Jun 2002 21:16:18 +0500 Subject: [PATCH 1/3] configure.in: changed version number --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index b4c25021b7e..53c235fd9e1 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! -AM_INIT_AUTOMAKE(mysql, 4.0.2-alpha) +AM_INIT_AUTOMAKE(mysql, 4.1.0-alpha) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 From 1a91646854196e7690ef6d915ae3f7fdf6d05543 Mon Sep 17 00:00:00 2001 From: "bar@gw.udmsearch.izhnet.ru" <> Date: Fri, 7 Jun 2002 17:23:33 +0500 Subject: [PATCH 2/3] Charset of any string field now can be specified during CREATE TABLE --- mysql-test/r/alter_table.result | 4 ++-- mysql-test/r/create.result | 4 ++-- mysql-test/r/fulltext.result | 2 +- mysql-test/r/innodb.result | 2 +- mysql-test/r/merge.result | 2 +- mysql-test/r/select.result | 16 ++++++++-------- mysql-test/r/show_check.result | 10 +++++----- mysql-test/r/symlink.result | 4 ++-- mysql-test/r/type_blob.result | 8 ++++---- mysql-test/r/type_ranges.result | 22 +++++++++++----------- sql/field.cc | 15 +++++++++++++++ sql/mysql_priv.h | 2 +- sql/sql_parse.cc | 4 ++-- sql/sql_yacc.yy | 15 ++++++++------- 14 files changed, 63 insertions(+), 47 deletions(-) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 0356f14db8a..159421e8f88 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -53,7 +53,7 @@ SHOW FULL COLUMNS FROM t1; Field Type Null Key Default Extra Privileges Comment GROUP_ID int(10) unsigned PRI 0 select,insert,update,references LANG_ID smallint(5) unsigned PRI 0 select,insert,update,references -NAME char(80) MUL select,insert,update,references +NAME char(80) character set latin1 MUL select,insert,update,references DROP TABLE t1; create table t1 (n int); insert into t1 values(9),(3),(12),(10); @@ -120,5 +120,5 @@ alter table t2 rename t1, add c char(10) comment "no comment"; show columns from t1; Field Type Null Key Default Extra i int(10) unsigned PRI NULL auto_increment -c char(10) YES NULL +c char(10) character set latin1 YES NULL drop table t1; diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index ef44e840a79..c3438ae211a 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -72,10 +72,10 @@ create table t1(x varchar(50) ); create table t2 select x from t1 where 1=2; describe t1; Field Type Null Key Default Extra -x varchar(50) YES NULL +x varchar(50) character set latin1 YES NULL describe t2; Field Type Null Key Default Extra -x char(50) YES NULL +x char(50) character set latin1 YES NULL drop table t2; create table t2 select now() as a , curtime() as b, curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f; describe t2; diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 5ecab7278db..e6598ca9ca4 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -136,7 +136,7 @@ show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `ticket` int(11) default NULL, - `inhalt` text, + `inhalt` text character set latin1, KEY `tig` (`ticket`), FULLTEXT KEY `tix` (`inhalt`) ) TYPE=MyISAM diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 89a857ef098..b75248b5d5a 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -805,7 +805,7 @@ create table t1 (a char(20), index (a(5))) type=innodb; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` char(20) default NULL, + `a` char(20) character set latin1 default NULL, KEY `a` (`a`) ) TYPE=InnoDB drop table t1; diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 9b72ff26350..6de77f7bdaa 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -172,7 +172,7 @@ show create table t3; Table Create Table t3 CREATE TABLE `t3` ( `a` int(11) NOT NULL default '0', - `b` char(20) default NULL, + `b` char(20) character set latin1 default NULL, KEY `a` (`a`) ) TYPE=MRG_MyISAM UNION=(t1,t2) create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2); diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 8c8e3b492b6..49ce0608fc5 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -3211,17 +3211,17 @@ Field Type Null Key Default Extra Privileges Comment auto int(11) PRI NULL auto_increment select,insert,update,references fld1 int(6) unsigned zerofill UNI 000000 select,insert,update,references companynr tinyint(2) unsigned zerofill 00 select,insert,update,references -fld3 char(30) MUL select,insert,update,references -fld4 char(35) select,insert,update,references -fld5 char(35) select,insert,update,references -fld6 char(4) select,insert,update,references +fld3 char(30) character set latin1 MUL select,insert,update,references +fld4 char(35) character set latin1 select,insert,update,references +fld5 char(35) character set latin1 select,insert,update,references +fld6 char(4) character set latin1 select,insert,update,references show full columns from t2 from test like 'f%'; Field Type Null Key Default Extra Privileges Comment fld1 int(6) unsigned zerofill UNI 000000 select,insert,update,references -fld3 char(30) MUL select,insert,update,references -fld4 char(35) select,insert,update,references -fld5 char(35) select,insert,update,references -fld6 char(4) select,insert,update,references +fld3 char(30) character set latin1 MUL select,insert,update,references +fld4 char(35) character set latin1 select,insert,update,references +fld5 char(35) character set latin1 select,insert,update,references +fld6 char(4) character set latin1 select,insert,update,references show full columns from t2 from test like 's%'; Field Type Null Key Default Extra Privileges Comment show keys from t2; diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index 3766332cf39..1f83bc61cdc 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -94,13 +94,13 @@ show create table t1 ; Table Create Table t1 CREATE TABLE `t1` ( `test_set` set('val1','val2','val3') NOT NULL default '', - `name` char(20) default 'O''Brien' COMMENT 'O''Brien as default', + `name` char(20) character set latin1 default 'O''Brien' COMMENT 'O''Brien as default', `c` int(11) NOT NULL default '0' COMMENT 'int column' ) TYPE=MyISAM COMMENT='it''s a table' show full columns from t1; Field Type Null Key Default Extra Privileges Comment test_set set('val1','val2','val3') select,insert,update,references -name char(20) YES O'Brien select,insert,update,references O'Brien as default +name char(20) character set latin1 YES O'Brien select,insert,update,references O'Brien as default c int(11) 0 select,insert,update,references int column drop table t1; create table t1 (a int not null, unique aa (a)); @@ -133,7 +133,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0', - `b` char(10) default NULL, + `b` char(10) character set latin1 default NULL, KEY `b` (`b`) ) TYPE=MyISAM MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test' alter table t1 MAX_ROWS=200 ROW_FORMAT=dynamic PACK_KEYS=0; @@ -141,7 +141,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0', - `b` varchar(10) default NULL, + `b` varchar(10) character set latin1 default NULL, KEY `b` (`b`) ) TYPE=MyISAM MIN_ROWS=10 MAX_ROWS=200 AVG_ROW_LENGTH=10 PACK_KEYS=0 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='test' ALTER TABLE t1 AVG_ROW_LENGTH=0 CHECKSUM=0 COMMENT="" MIN_ROWS=0 MAX_ROWS=0 PACK_KEYS=DEFAULT DELAY_KEY_WRITE=0 ROW_FORMAT=default; @@ -149,7 +149,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0', - `b` varchar(10) default NULL, + `b` varchar(10) character set latin1 default NULL, KEY `b` (`b`) ) TYPE=MyISAM drop table t1; diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index 5626bc0fe11..b5b5b774ee5 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -36,7 +36,7 @@ show create table t9; Table Create Table t9 CREATE TABLE `t9` ( `a` int(11) NOT NULL auto_increment, - `b` char(16) NOT NULL default '', + `b` char(16) character set latin1 NOT NULL default '', `c` int(11) NOT NULL default '0', PRIMARY KEY (`a`) ) TYPE=MyISAM @@ -57,7 +57,7 @@ show create table test_mysqltest.t9; Table Create Table t9 CREATE TABLE `t9` ( `a` int(11) NOT NULL auto_increment, - `b` char(16) NOT NULL default '', + `b` char(16) character set latin1 NOT NULL default '', `c` int(11) NOT NULL default '0', `d` int(11) NOT NULL default '0', PRIMARY KEY (`a`) diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index 6778679bda9..c99d22c2889 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -38,15 +38,15 @@ update t1 set c="",b=null where c="1"; lock tables t1 READ; show full fields from t1; Field Type Null Key Default Extra Privileges Comment -t text YES NULL select,insert,update,references -c varchar(10) YES NULL select,insert,update,references +t text character set latin1 YES NULL select,insert,update,references +c varchar(10) character set latin1 YES NULL select,insert,update,references b blob YES NULL select,insert,update,references d varchar(10) binary YES NULL select,insert,update,references lock tables t1 WRITE; show full fields from t1; Field Type Null Key Default Extra Privileges Comment -t text YES NULL select,insert,update,references -c varchar(10) YES NULL select,insert,update,references +t text character set latin1 YES NULL select,insert,update,references +c varchar(10) character set latin1 YES NULL select,insert,update,references b blob YES NULL select,insert,update,references d varchar(10) binary YES NULL select,insert,update,references unlock tables; diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result index 54d8ff87b37..01149b68935 100644 --- a/mysql-test/r/type_ranges.result +++ b/mysql-test/r/type_ranges.result @@ -40,7 +40,7 @@ KEY (options,flags) show full fields from t1; Field Type Null Key Default Extra Privileges Comment auto int(5) unsigned PRI NULL auto_increment select,insert,update,references -string varchar(10) YES hello select,insert,update,references +string varchar(10) character set latin1 YES hello select,insert,update,references tiny tinyint(4) MUL 0 select,insert,update,references short smallint(6) MUL 1 select,insert,update,references medium mediumint(8) MUL 0 select,insert,update,references @@ -170,7 +170,7 @@ update t2 set string="changed" where auto=16; show full columns from t1; Field Type Null Key Default Extra Privileges Comment auto int(5) unsigned MUL NULL auto_increment select,insert,update,references -string varchar(10) YES new defaul select,insert,update,references +string varchar(10) character set latin1 YES new defaul select,insert,update,references tiny tinyint(4) MUL 0 select,insert,update,references short smallint(6) MUL 0 select,insert,update,references medium mediumint(8) MUL 0 select,insert,update,references @@ -184,19 +184,19 @@ umedium mediumint(8) unsigned MUL 0 select,insert,update,references ulong int(11) unsigned MUL 0 select,insert,update,references ulonglong bigint(13) unsigned MUL 0 select,insert,update,references time_stamp timestamp(14) YES NULL select,insert,update,references -date_field varchar(10) YES NULL select,insert,update,references +date_field varchar(10) character set latin1 YES NULL select,insert,update,references time_field time YES NULL select,insert,update,references date_time datetime YES NULL select,insert,update,references -new_blob_col varchar(20) YES NULL select,insert,update,references +new_blob_col varchar(20) character set latin1 YES NULL select,insert,update,references tinyblob_col tinyblob YES NULL select,insert,update,references mediumblob_col mediumblob select,insert,update,references options enum('one','two','tree') MUL one select,insert,update,references flags set('one','two','tree') select,insert,update,references -new_field varchar(10) new select,insert,update,references +new_field varchar(10) character set latin1 new select,insert,update,references show full columns from t2; Field Type Null Key Default Extra Privileges Comment auto int(5) unsigned 0 select,insert,update,references -string varchar(10) YES new defaul select,insert,update,references +string varchar(10) character set latin1 YES new defaul select,insert,update,references tiny tinyint(4) 0 select,insert,update,references short smallint(6) 0 select,insert,update,references medium mediumint(8) 0 select,insert,update,references @@ -210,15 +210,15 @@ umedium mediumint(8) unsigned 0 select,insert,update,references ulong int(11) unsigned 0 select,insert,update,references ulonglong bigint(13) unsigned 0 select,insert,update,references time_stamp timestamp(14) YES NULL select,insert,update,references -date_field varchar(10) YES NULL select,insert,update,references +date_field varchar(10) character set latin1 YES NULL select,insert,update,references time_field time YES NULL select,insert,update,references date_time datetime YES NULL select,insert,update,references -new_blob_col varchar(20) YES NULL select,insert,update,references +new_blob_col varchar(20) character set latin1 YES NULL select,insert,update,references tinyblob_col tinyblob YES NULL select,insert,update,references mediumblob_col mediumblob select,insert,update,references options enum('one','two','tree') one select,insert,update,references flags set('one','two','tree') select,insert,update,references -new_field varchar(10) new select,insert,update,references +new_field varchar(10) character set latin1 new select,insert,update,references select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and ((t1.string<>t2.string and (t1.string is not null or t2.string is not null)) or (t1.tiny<>t2.tiny and (t1.tiny is not null or t2.tiny is not null)) or (t1.short<>t2.short and (t1.short is not null or t2.short is not null)) or (t1.medium<>t2.medium and (t1.medium is not null or t2.medium is not null)) or (t1.long_int<>t2.long_int and (t1.long_int is not null or t2.long_int is not null)) or (t1.longlong<>t2.longlong and (t1.longlong is not null or t2.longlong is not null)) or (t1.real_float<>t2.real_float and (t1.real_float is not null or t2.real_float is not null)) or (t1.real_double<>t2.real_double and (t1.real_double is not null or t2.real_double is not null)) or (t1.utiny<>t2.utiny and (t1.utiny is not null or t2.utiny is not null)) or (t1.ushort<>t2.ushort and (t1.ushort is not null or t2.ushort is not null)) or (t1.umedium<>t2.umedium and (t1.umedium is not null or t2.umedium is not null)) or (t1.ulong<>t2.ulong and (t1.ulong is not null or t2.ulong is not null)) or (t1.ulonglong<>t2.ulonglong and (t1.ulonglong is not null or t2.ulonglong is not null)) or (t1.time_stamp<>t2.time_stamp and (t1.time_stamp is not null or t2.time_stamp is not null)) or (t1.date_field<>t2.date_field and (t1.date_field is not null or t2.date_field is not null)) or (t1.time_field<>t2.time_field and (t1.time_field is not null or t2.time_field is not null)) or (t1.date_time<>t2.date_time and (t1.date_time is not null or t2.date_time is not null)) or (t1.new_blob_col<>t2.new_blob_col and (t1.new_blob_col is not null or t2.new_blob_col is not null)) or (t1.tinyblob_col<>t2.tinyblob_col and (t1.tinyblob_col is not null or t2.tinyblob_col is not null)) or (t1.mediumblob_col<>t2.mediumblob_col and (t1.mediumblob_col is not null or t2.mediumblob_col is not null)) or (t1.options<>t2.options and (t1.options is not null or t2.options is not null)) or (t1.flags<>t2.flags and (t1.flags is not null or t2.flags is not null)) or (t1.new_field<>t2.new_field and (t1.new_field is not null or t2.new_field is not null))); auto auto 16 16 @@ -231,8 +231,8 @@ show full columns from t2; Field Type Null Key Default Extra Privileges Comment auto bigint(17) unsigned PRI 0 select,insert,update,references t1 bigint(1) 0 select,insert,update,references -t2 char(1) select,insert,update,references -t3 mediumtext select,insert,update,references +t2 char(1) character set latin1 select,insert,update,references +t3 mediumtext character set latin1 select,insert,update,references t4 mediumblob select,insert,update,references select * from t2; auto t1 t2 t3 t4 diff --git a/sql/field.cc b/sql/field.cc index 39e32a9cdc4..1561f1831de 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3471,6 +3471,11 @@ void Field_string::sql_type(String &res) const res.length((uint) strlen(res.ptr())); if (binary_flag) res.append(" binary"); + else + { + res.append(" character set "); + res.append(field_charset->name); + } } @@ -3667,6 +3672,11 @@ void Field_varstring::sql_type(String &res) const res.length((uint) strlen(res.ptr())); if (binary_flag) res.append(" binary"); + else + { + res.append(" character set "); + res.append(field_charset->name); + } } char *Field_varstring::pack(char *to, const char *from, uint max_length) @@ -4154,6 +4164,11 @@ void Field_blob::sql_type(String &res) const } res.set(str,(uint) strlen(str),default_charset_info); res.append(binary_flag ? "blob" : "text"); + if (!binary_flag) + { + res.append(" character set "); + res.append(field_charset->name); + } } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index e6c44f949ab..6d26f5a1b9a 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -484,7 +484,7 @@ bool add_field_to_list(char *field_name, enum enum_field_types type, char *length, char *decimal, uint type_modifier, Item *default_value, Item *comment, - char *change, TYPELIB *interval); + char *change, TYPELIB *interval,CHARSET_INFO *cs); void store_position_for_column(const char *name); bool add_to_list(SQL_LIST &list,Item *group,bool asc=0); TABLE_LIST *add_table_to_list(Table_ident *table,LEX_STRING *alias, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 790994b897e..b8ec541225a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2824,7 +2824,7 @@ bool add_field_to_list(char *field_name, enum_field_types type, char *length, char *decimals, uint type_modifier, Item *default_value, Item *comment, - char *change, TYPELIB *interval) + char *change, TYPELIB *interval, CHARSET_INFO *cs) { register create_field *new_field; THD *thd=current_thd; @@ -2877,7 +2877,7 @@ bool add_field_to_list(char *field_name, enum_field_types type, new_field->change=change; new_field->interval=0; new_field->pack_length=0; - new_field->charset=0; // QQ: To be fixed + new_field->charset=cs; if (!comment) { diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index d9595e841b3..316996ac7c2 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -958,6 +958,7 @@ field_spec: LEX *lex=Lex; lex->length=lex->dec=0; lex->type=0; lex->interval=0; lex->default_value=lex->comment=0; + lex->charset=default_charset_info; } type opt_attribute { @@ -966,7 +967,7 @@ field_spec: (enum enum_field_types) $3, lex->length,lex->dec,lex->type, lex->default_value, lex->comment, - lex->change,lex->interval)) + lex->change,lex->interval,lex->charset)) YYABORT; }; @@ -1009,11 +1010,11 @@ type: $$=FIELD_TYPE_LONG_BLOB; } | LONG_SYM VARBINARY { Lex->type|=BINARY_FLAG; $$=FIELD_TYPE_MEDIUM_BLOB; } - | LONG_SYM varchar { $$=FIELD_TYPE_MEDIUM_BLOB; } - | TINYTEXT { $$=FIELD_TYPE_TINY_BLOB; } - | TEXT_SYM { $$=FIELD_TYPE_BLOB; } - | MEDIUMTEXT { $$=FIELD_TYPE_MEDIUM_BLOB; } - | LONGTEXT { $$=FIELD_TYPE_LONG_BLOB; } + | LONG_SYM varchar opt_binary { $$=FIELD_TYPE_MEDIUM_BLOB; } + | TINYTEXT opt_binary { $$=FIELD_TYPE_TINY_BLOB; } + | TEXT_SYM opt_binary { $$=FIELD_TYPE_BLOB; } + | MEDIUMTEXT opt_binary { $$=FIELD_TYPE_MEDIUM_BLOB; } + | LONGTEXT opt_binary { $$=FIELD_TYPE_LONG_BLOB; } | DECIMAL_SYM float_options field_options { $$=FIELD_TYPE_DECIMAL;} | NUMERIC_SYM float_options field_options @@ -1287,7 +1288,7 @@ alter_list_item: (enum enum_field_types) $5, lex->length,lex->dec,lex->type, lex->default_value, lex->comment, - $3.str, lex->interval)) + $3.str, lex->interval, lex->charset)) YYABORT; } opt_place From e33a1c5440080f4a53746c119217d216be59468b Mon Sep 17 00:00:00 2001 From: "ram@gw.udmsearch.izhnet.ru" <> Date: Fri, 7 Jun 2002 22:13:59 +0500 Subject: [PATCH 3/3] check_one_rb_key() func --- heap/_check.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/heap/_check.c b/heap/_check.c index 3498625bffc..3b2fc9afad9 100644 --- a/heap/_check.c +++ b/heap/_check.c @@ -20,10 +20,12 @@ static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records, ulong blength, my_bool print_status); +static int check_one_rb_key(HP_INFO *info, uint keynr, ulong records, + my_bool print_status); /* Returns 0 if the HEAP is ok */ -int heap_check_heap(HP_INFO *info,my_bool print_status) +int heap_check_heap(HP_INFO *info, my_bool print_status) { int error; uint key; @@ -32,9 +34,11 @@ int heap_check_heap(HP_INFO *info,my_bool print_status) for (error=key=0 ; key < share->keys ; key++) { - if (!(share->keydef[key].algorithm == HA_KEY_ALG_BTREE)) - error|=check_one_key(share->keydef+key,key, share->records,share->blength, - print_status); + if (share->keydef[key].algorithm == HA_KEY_ALG_BTREE) + error|= check_one_rb_key(info, key, share->records, print_status); + else + error|= check_one_key(share->keydef + key, key, share->records, + share->blength, print_status); } DBUG_RETURN(error); @@ -90,3 +94,46 @@ static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records, (float) seek / (float) (records ? records : 1)); return error; } + +static int check_one_rb_key(HP_INFO *info, uint keynr, ulong records, + my_bool print_status) +{ + HP_KEYDEF *keydef= info->s->keydef + keynr; + int error= 0; + ulong found= 0; + byte *key, *recpos; + uint key_length; + uint not_used; + + if ((key= tree_search_edge(&keydef->rb_tree, info->parents, + &info->last_pos, offsetof(TREE_ELEMENT, left)))) + { + do + { + memcpy(&recpos, key + (*keydef->get_key_length)(keydef,key), sizeof(byte*)); + key_length= hp_rb_make_key(keydef, info->recbuf, recpos, 0); + if (ha_key_cmp(keydef->seg, info->recbuf, key, key_length, + SEARCH_FIND | SEARCH_SAME, ¬_used)) + { + error= 1; + DBUG_PRINT("error",("Record in wrong link: Link %d Record: %lx\n", + link, recpos)); + } + else + { + found++; + } + key= tree_search_next(&keydef->rb_tree, &info->last_pos, + offsetof(TREE_ELEMENT, left), + offsetof(TREE_ELEMENT, right)); + } while (key); + } + if (found != records) + { + DBUG_PRINT("error",("Found %ld of %ld records")); + error= 1; + } + if (print_status) + printf("Key: %d records: %ld\n", keynr, records); + return error; +}