diff options
author | Sachin <sachin.setiya@mariadb.com> | 2019-02-18 22:44:01 +0530 |
---|---|---|
committer | Sachin <sachin.setiya@mariadb.com> | 2019-02-18 22:44:01 +0530 |
commit | b72e778120c94ce1df9d11b7c4a9455032c9385e (patch) | |
tree | 6502a773904a295629cb6be45618e35bb9ce08b7 | |
parent | 15e5313020cadb7a67ff3a6ebef75bf088259f11 (diff) | |
download | mariadb-git-bb-10.4-blob-index.tar.gz |
final commit -2bb-10.4-blob-index
-rw-r--r-- | mysql-test/main/long_unique.result | 38 | ||||
-rw-r--r-- | mysql-test/main/long_unique_debug.result | 95 | ||||
-rw-r--r-- | mysql-test/main/long_unique_debug.test | 10 | ||||
-rw-r--r-- | sql/handler.h | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 6 | ||||
-rw-r--r-- | storage/heap/ha_heap.h | 2 |
6 files changed, 125 insertions, 30 deletions
diff --git a/mysql-test/main/long_unique.result b/mysql-test/main/long_unique.result index ce8e8bc841c..77efa7f9905 100644 --- a/mysql-test/main/long_unique.result +++ b/mysql-test/main/long_unique.result @@ -43,7 +43,7 @@ MyISAM file: DATADIR/test/t1 Record format: Packed Character set: latin1_swedish_ci (8) Data records: 10 Deleted blocks: 0 -Recordlength: 12 +Recordlength: 20 table description: Key Start Len Index Type @@ -131,7 +131,7 @@ MyISAM file: DATADIR/test/t1 Record format: Packed Character set: latin1_swedish_ci (8) Data records: 7 Deleted blocks: 0 -Recordlength: 12 +Recordlength: 20 table description: Key Start Len Index Type @@ -366,14 +366,14 @@ MyISAM file: DATADIR/test/t1 Record format: Packed Character set: latin1_swedish_ci (8) Data records: 8 Deleted blocks: 0 -Recordlength: 3040 +Recordlength: 3072 table description: Key Start Len Index Type -1 3039 8 multip. ulonglong NULL -2 3047 8 multip. ulonglong NULL -3 3055 8 multip. ulonglong NULL -4 3063 8 multip. ulonglong NULL +1 3063 8 multip. ulonglong NULL +2 3055 8 multip. ulonglong NULL +3 3047 8 multip. ulonglong NULL +4 3039 8 multip. ulonglong NULL select * from information_schema.columns where table_schema = 'test' and table_name = 't1'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT IS_GENERATED GENERATION_EXPRESSION def test t1 a 1 NULL YES blob 65535 65535 NULL NULL NULL NULL NULL blob UNI select,insert,update,references NEVER NULL @@ -723,14 +723,14 @@ MyISAM file: DATADIR/test/t1 Record format: Packed Character set: latin1_swedish_ci (8) Data records: 9 Deleted blocks: 0 -Recordlength: 5059 +Recordlength: 5092 table description: Key Start Len Index Type -1 5057 8 multip. ulonglong NULL -2 5065 8 multip. ulonglong NULL -3 5073 8 multip. ulonglong NULL -4 5081 8 multip. ulonglong NULL +1 5081 8 multip. ulonglong NULL +2 5073 8 multip. ulonglong NULL +3 5065 8 multip. ulonglong NULL +4 5057 8 multip. ulonglong NULL select * from information_schema.columns where table_schema = 'test' and table_name = 't1'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT IS_GENERATED GENERATION_EXPRESSION def test t1 a 1 NULL YES blob 65535 65535 NULL NULL NULL NULL NULL blob MUL select,insert,update,references NEVER NULL @@ -1385,9 +1385,17 @@ drop table t1; #partition create table t1(a blob unique) partition by hash(a); ERROR HY000: A BLOB field is not allowed in partition function -#key length > 2^15 -1 -create table t1(a blob, unique(a(100001))); -ERROR 42000: Specified key was too long; max key length is 1000 bytes +#key length > 2^16 -1 +create table t1(a blob, unique(a(65536))); +ERROR HY000: Max key segment length is 65535 +create table t1(a blob, unique(a(65535))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` blob DEFAULT NULL, + UNIQUE KEY `a` (`a`(65535)) USING HASH +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; #64 indexes create table t1 ( a63 blob unique, a62 blob unique, a61 blob unique, a60 blob unique, a59 blob unique, a58 blob unique, a57 blob unique, a56 blob unique, a55 blob unique, a54 blob unique, a53 blob unique, a52 blob unique, a51 blob unique, a50 blob unique, a49 blob unique, a48 blob unique, a47 blob unique, a46 blob unique, a45 blob unique, a44 blob unique, a43 blob unique, a42 blob unique, a41 blob unique, a40 blob unique, a39 blob unique, a38 blob unique, a37 blob unique, a36 blob unique, a35 blob unique, a34 blob unique, a33 blob unique, a32 blob unique, a31 blob unique, a30 blob unique, a29 blob unique, a28 blob unique, a27 blob unique, a26 blob unique, a25 blob unique, a24 blob unique, a23 blob unique, a22 blob unique, a21 blob unique, a20 blob unique, a19 blob unique, a18 blob unique, a17 blob unique, a16 blob unique, a15 blob unique, a14 blob unique, a13 blob unique, a12 blob unique, a11 blob unique, a10 blob unique, a9 blob unique, a8 blob unique, a7 blob unique, a6 blob unique, a5 blob unique, a4 blob unique, a3 blob unique, a2 blob unique, a1 blob unique, a blob unique);; insert into t1 values( 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);; diff --git a/mysql-test/main/long_unique_debug.result b/mysql-test/main/long_unique_debug.result index 2655418a457..c8a03ced82f 100644 --- a/mysql-test/main/long_unique_debug.result +++ b/mysql-test/main/long_unique_debug.result @@ -1,6 +1,7 @@ #In this test case we will check what will happen in the case of hash collision SET debug_dbug="d,same_long_unique_hash"; create table t1(a blob unique); +FLUSH STATUS; insert into t1 values('xyz'); insert into t1 values('abc'); insert into t1 values('sachin'); @@ -10,6 +11,25 @@ insert into t1 values('maria'); insert into t1 values('maria'); ERROR 23000: Duplicate entry 'maria' for key 'a' drop table t1; +SHOW STATUS LIKE 'handler_read_next'; +Variable_name Value +Handler_read_next 11 +SET debug_dbug=""; +create table t1(a blob unique); +FLUSH STATUS; +insert into t1 values('xyz'); +insert into t1 values('abc'); +insert into t1 values('sachin'); +insert into t1 values('sachin'); +ERROR 23000: Duplicate entry 'sachin' for key 'a' +insert into t1 values('maria'); +insert into t1 values('maria'); +ERROR 23000: Duplicate entry 'maria' for key 'a' +drop table t1; +SHOW STATUS LIKE 'handler_read_next'; +Variable_name Value +Handler_read_next 0 +SET debug_dbug="d,same_long_unique_hash"; create table t1(a blob unique, b blob unique); insert into t1 values('xyz', 11); insert into t1 values('abc', 22); @@ -384,7 +404,7 @@ Printing table->fields table->field[0]->field_name a table->field[0]->offset = 1 table->field[0]->field_length = 4 -table->field[0]->null_pos wrt to record 0 = -1276691232 +table->field[0]->null_pos wrt to record 0 = 1475936336 table->field[0]->null_bit_pos = 0 table->field[1]->field_name b @@ -396,7 +416,7 @@ table->field[1]->null_bit_pos = 1 table->field[2]->field_name c table->field[2]->offset = 15 table->field[2]->field_length = 10 -table->field[2]->null_pos wrt to record 0 = -1276691232 +table->field[2]->null_pos wrt to record 0 = 1475936336 table->field[2]->null_bit_pos = 0 table->field[3]->field_name DB_ROW_HASH_1 @@ -408,7 +428,7 @@ table->field[3]->null_bit_pos = 2 table->field[4]->field_name DB_ROW_HASH_2 table->field[4]->offset = 33 table->field[4]->field_length = 8 -table->field[4]->null_pos wrt to record 0 = -1276691232 +table->field[4]->null_pos wrt to record 0 = 1475936336 table->field[4]->null_bit_pos = 0 SET debug_dbug=""; @@ -488,3 +508,72 @@ table->field[3]->null_bit_pos = 16 SET debug_dbug=""; drop table t1; +##Using hash but with memory engine so no long unique column +SET debug_dbug="d,print_long_unique_internal_state"; +create table t1(a int ,b int , c int, unique(a, b, c) using hash) engine=memory; +Warnings: +Note 1 Printing Table state, It will print table fields, fields->offset,field->null_bit, field->null_pos and key_info ... + +Printing Table keyinfo + +table->s->reclength 13 +table->s->fields 3 + +table->key_info[0] user_defined_key_parts = 3 +table->key_info[0] algorithm == HA_KEY_ALG_LONG_HASH = 0 +table->key_info[0] flags & HA_NOSAME = 1 + +table->s->key_info[0] user_defined_key_parts = 3 +table->s->key_info[0] algorithm == HA_KEY_ALG_LONG_HASH = 0 +table->s->key_info[0] flags & HA_NOSAME = 1 + +Printing table->key_info->key_part[0] info +key_part->offset = 1 +key_part->field_name = a +key_part->length = 4 +key_part->null_bit = 2 +key_part->null_offset = 0 + +Printing share->key_info->key_part[0] info +key_part->offset = 1 +key_part->field_name = a +key_part->length = 4 +key_part->null_bit = 2 +key_part->null_offset = 0 + +Printing share->key_info->key_part[1] info +key_part->offset = 5 +key_part->field_name = b +key_part->length = 4 +key_part->null_bit = 4 +key_part->null_offset = 0 + +Printing share->key_info->key_part[2] info +key_part->offset = 9 +key_part->field_name = c +key_part->length = 4 +key_part->null_bit = 8 +key_part->null_offset = 0 + +Printing table->fields + +table->field[0]->field_name a +table->field[0]->offset = 1 +table->field[0]->field_length = 4 +table->field[0]->null_pos wrt to record 0 = 0 +table->field[0]->null_bit_pos = 2 + +table->field[1]->field_name b +table->field[1]->offset = 5 +table->field[1]->field_length = 4 +table->field[1]->null_pos wrt to record 0 = 0 +table->field[1]->null_bit_pos = 4 + +table->field[2]->field_name c +table->field[2]->offset = 9 +table->field[2]->field_length = 4 +table->field[2]->null_pos wrt to record 0 = 0 +table->field[2]->null_bit_pos = 8 + +SET debug_dbug=""; +drop table t1; diff --git a/mysql-test/main/long_unique_debug.test b/mysql-test/main/long_unique_debug.test index cb10d7a0b2f..6d95c14e7e1 100644 --- a/mysql-test/main/long_unique_debug.test +++ b/mysql-test/main/long_unique_debug.test @@ -85,8 +85,8 @@ create table t1(a int ,b int , c int, unique(a, b, c) using hash); SET debug_dbug=""; drop table t1; -#--echo ##Using hash but with memory engine so no long unique column -#SET debug_dbug="d,print_long_unique_internal_state"; -#create table t1(a int ,b int , c int, unique(a, b, c) using hash) engine=memory; -#SET debug_dbug=""; -#drop table t1; +--echo ##Using hash but with memory engine so no long unique column +SET debug_dbug="d,print_long_unique_internal_state"; +create table t1(a int ,b int , c int, unique(a, b, c) using hash) engine=memory; +SET debug_dbug=""; +drop table t1; diff --git a/sql/handler.h b/sql/handler.h index 878968bf7e9..70fdaa7f3e3 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -144,7 +144,6 @@ enum enum_alter_inplace_result { #define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1ULL << 16) #define HA_CAN_RTREEKEYS (1ULL << 17) #define HA_NOT_DELETE_WITH_CACHE (1ULL << 18) /* unused */ -#define HA_CAN_HASH_KEYS (1ULL << 19) /* The following is we need to a primary key to delete (and update) a row. If there is no primary key, all columns needs to be read on update and delete @@ -320,6 +319,9 @@ enum enum_alter_inplace_result { /* Safe for online backup */ #define HA_CAN_ONLINE_BACKUPS (1ULL << 56) +/* Support native hash index */ +#define HA_CAN_HASH_KEYS (1ULL << 57) + /* bits in index_flags(index_number) for what you can do with index */ #define HA_READ_NEXT 1 /* TODO really use this flag */ #define HA_READ_PREV 2 /* supports ::index_prev */ diff --git a/sql/sql_table.cc b/sql/sql_table.cc index bb5d33e4044..4d06b1e61e6 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4193,7 +4193,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, } if (is_hash_field_needed || (key_info->algorithm == HA_KEY_ALG_HASH && - create_info->db_type->flags)) + !(file->ha_table_flags() & HA_CAN_HASH_KEYS ))) { Create_field *hash_fld= add_hash_field(thd, &alter_info->create_list, create_info->default_table_charset, @@ -4208,10 +4208,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, hash_fld->pack_flag&= ~FIELDFLAG_MAYBE_NULL; } } - // If user forces hash index for storage engine other then memory -// else if (key_info->algorithm == HA_KEY_ALG_HASH && - // create_info->db_type->db_type != DB_TYPE_HEAP) - // key_info->algorithm= HA_KEY_ALG_LONG_HASH; if (validate_comment_length(thd, &key->key_create_info.comment, INDEX_COMMENT_MAXLEN, ER_TOO_LONG_INDEX_COMMENT, diff --git a/storage/heap/ha_heap.h b/storage/heap/ha_heap.h index 3a7e0060a05..c765e8e2f62 100644 --- a/storage/heap/ha_heap.h +++ b/storage/heap/ha_heap.h @@ -51,7 +51,7 @@ public: HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE | HA_CAN_SQL_HANDLER | HA_CAN_ONLINE_BACKUPS | HA_REC_NOT_IN_SEQ | HA_CAN_INSERT_DELAYED | HA_NO_TRANSACTIONS | - HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT); + HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT | HA_CAN_HASH_KEYS); } ulong index_flags(uint inx, uint part, bool all_parts) const { |