diff options
author | Michael Widenius <monty@askmonty.org> | 2011-10-26 20:25:18 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-10-26 20:25:18 +0300 |
commit | fa36a7426bf505e83cbd03d8e54e433b3df4d72e (patch) | |
tree | 182fd923b34d7ca56906140214c1c4730d1c47ea /storage | |
parent | 16942bc5ca0f239c2aa2c2cde4eaba144495e9aa (diff) | |
download | mariadb-git-fa36a7426bf505e83cbd03d8e54e433b3df4d72e.tar.gz |
Fixed lp:879939 "assertion in ha_maria::enable_indexes with derived_with_keys=on"
Honor unique/not unique when creating keys for internal tempory tables.
Added new variables to be used to limit how keys are created for internal temporary tables.
include/maria.h:
Added maria_max_key_length() and maria_max_key_segments()
include/myisam.h:
Added myisam_max_key_length() and myisam_max_key_segments()
mysql-test/r/mysql.result:
Drop all used tables
mysql-test/r/subselect4.result:
Added test case for lp:879939
mysql-test/t/mysql.test:
Drop all used tables
mysql-test/t/subselect4.test:
Added test case for lp:879939
sql/mysql_priv.h:
Added internal_tmp_table_max_key_length and internal_tmp_table_max_key_segments to be used to limit how keys for derived tables are created.
sql/mysqld.cc:
Added internal_tmp_table_max_key_length and internal_tmp_table_max_key_segments to be used to limit how keys for derived tables are created.
sql/share/errmsg.txt:
Added new error message for internal errors
sql/sql_select.cc:
Give error if we try to create a wrong key (this error should never happen)
Honor unique/not unique when creating keys for internal tempory tables.
storage/maria/ha_maria.cc:
Added change_table_ptr() to ensure that external_ref points always to the correct table.
(Not having this caused an assert in the included test)
storage/maria/ha_maria.h:
Added change_table_ptr() to ensure that external_ref points always to the correct table.
storage/maria/ma_check.c:
Fixed bug in Duplicate key error printing (now row position is printed correctly)
storage/maria/ma_create.c:
maria_max_key_length() -> _ma_max_key_length()
storage/maria/ma_info.c:
Added extern function maria_max_key_length() to calculate the max key length based on current block size.
storage/maria/ma_open.c:
maria_max_key_length() -> _ma_max_key_length()
storage/maria/maria_def.h:
maria_max_key_length() -> _ma_max_key_length()
storage/myisam/ha_myisam.cc:
Added change_table_ptr() to ensure that external_ref points always to the correct table.
(Not having this caused an assert in the included test)
storage/myisam/ha_myisam.h:
Added change_table_ptr() to ensure that external_ref points always to the correct table.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/maria/ha_maria.cc | 11 | ||||
-rw-r--r-- | storage/maria/ha_maria.h | 1 | ||||
-rw-r--r-- | storage/maria/ma_check.c | 3 | ||||
-rw-r--r-- | storage/maria/ma_create.c | 2 | ||||
-rw-r--r-- | storage/maria/ma_info.c | 6 | ||||
-rw-r--r-- | storage/maria/ma_open.c | 2 | ||||
-rw-r--r-- | storage/maria/maria_def.h | 2 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.cc | 8 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.h | 2 |
9 files changed, 29 insertions, 8 deletions
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index e65ac7e443c..12c291ac99d 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -935,8 +935,7 @@ double ha_maria::scan_time() uint ha_maria::max_supported_key_length() const { - uint tmp= (maria_max_key_length() - 8 - HA_MAX_KEY_SEG*3); - return min(HA_MAX_KEY_BUFF, tmp); + return maria_max_key_length(); } @@ -2601,6 +2600,14 @@ void ha_maria::drop_table(const char *name) } +void ha_maria::change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) +{ + handler::change_table_ptr(table_arg, share); + if (file) + file->external_ref= table_arg; +} + + int ha_maria::external_lock(THD *thd, int lock_type) { DBUG_ENTER("ha_maria::external_lock"); diff --git a/storage/maria/ha_maria.h b/storage/maria/ha_maria.h index 0ba134a5b45..26b616e9682 100644 --- a/storage/maria/ha_maria.h +++ b/storage/maria/ha_maria.h @@ -77,6 +77,7 @@ public: { return max_supported_key_length(); } enum row_type get_row_type() const; uint checksum() const; + void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share); virtual double scan_time(); int open(const char *name, int mode, uint test_if_locked); diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 689786cab21..637303d1547 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -5671,7 +5671,8 @@ static my_off_t get_record_for_key(MARIA_KEYDEF *keyinfo, MARIA_KEY key; key.keyinfo= keyinfo; key.data= (uchar*) key_data; - key.data_length= _ma_keylength(keyinfo, key_data); + key.data_length= (_ma_keylength(keyinfo, key_data) - + keyinfo->share->rec_reflength); return _ma_row_pos_from_key(&key); } /* get_record_for_key */ diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c index ea9671d4b07..b773e930e82 100644 --- a/storage/maria/ma_create.c +++ b/storage/maria/ma_create.c @@ -623,7 +623,7 @@ int maria_create(const char *name, enum data_file_type datafile_type, to be able to put at least 2 keys on an index block for the key algorithms to work). */ - if (length > maria_max_key_length()) + if (length > _ma_max_key_length()) { my_errno=HA_WRONG_CREATE_OPTION; goto err_no_lock; diff --git a/storage/maria/ma_info.c b/storage/maria/ma_info.c index 1bbfa3cbf7e..af0e46ee239 100644 --- a/storage/maria/ma_info.c +++ b/storage/maria/ma_info.c @@ -28,6 +28,12 @@ MARIA_RECORD_POS maria_position(MARIA_HA *info) } +uint maria_max_key_length() +{ + uint tmp= (_ma_max_key_length() - 8 - HA_MAX_KEY_SEG*3); + return min(HA_MAX_KEY_BUFF, tmp); +} + /* Get information about the table */ /* if flag == 2 one get current info (no sync from database */ diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index de1daa544b7..a7287e75127 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -468,7 +468,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) } key_parts+=fulltext_keys*FT_SEGS; - if (share->base.max_key_length > maria_max_key_length() || + if (share->base.max_key_length > _ma_max_key_length() || keys > MARIA_MAX_KEY || key_parts > MARIA_MAX_KEY * HA_MAX_KEY_SEG) { DBUG_PRINT("error",("Wrong key info: Max_key_length: %d keys: %d key_parts: %d", share->base.max_key_length, keys, key_parts)); diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index 392e0f8d95c..d21d438d64b 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -747,7 +747,7 @@ struct st_maria_handler { length=mi_uint2korr((key)+1)+3; } \ } -#define maria_max_key_length() ((maria_block_size - MAX_KEYPAGE_HEADER_SIZE)/3 - MARIA_INDEX_OVERHEAD_SIZE) +#define _ma_max_key_length() ((maria_block_size - MAX_KEYPAGE_HEADER_SIZE)/3 - MARIA_INDEX_OVERHEAD_SIZE) #define get_pack_length(length) ((length) >= 255 ? 3 : 1) #define _ma_have_versioning(info) ((info)->row_flag & ROW_FLAG_TRANSID) diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index e6ad635c885..84c16caebe1 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -551,7 +551,6 @@ my_bool mi_killed_in_mariadb(MI_INFO *info) } - ha_myisam::ha_myisam(handlerton *hton, TABLE_SHARE *table_arg) :handler(hton, table_arg), file(0), int_table_flags(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER | @@ -2005,6 +2004,13 @@ int ha_myisam::delete_table(const char *name) return mi_delete_table(name); } +void ha_myisam::change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) +{ + handler::change_table_ptr(table_arg, share); + if (file) + file->external_ref= table_arg; +} + int ha_myisam::external_lock(THD *thd, int lock_type) { diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index f895a5bf449..e25cbee03e6 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -68,7 +68,7 @@ class ha_myisam: public handler uint max_supported_key_length() const { return HA_MAX_KEY_LENGTH; } uint max_supported_key_part_length() const { return HA_MAX_KEY_LENGTH; } uint checksum() const; - + void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share); int open(const char *name, int mode, uint test_if_locked); int close(void); int write_row(uchar * buf); |