diff options
author | unknown <serg@serg.mylan> | 2004-02-17 16:57:39 +0100 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2004-02-17 16:57:39 +0100 |
commit | a0040b0bdabae307e19fa5bd46fc13968db17135 (patch) | |
tree | 10dd74bbc0033df4fdbb4f4c120fd51f31d5ad98 /sql/sql_table.cc | |
parent | 66a266203fe162b2ebd78651032777d5c5f15f22 (diff) | |
download | mariadb-git-a0040b0bdabae307e19fa5bd46fc13968db17135.tar.gz |
if a key length exceeds the supported maximum and it is safe to auto-decrease it, do it.
include/my_global.h:
do macro correctly
mysql-test/r/ctype_utf8.result:
updated
mysql-test/r/myisam.result:
updated
mysql-test/r/type_blob.result:
updated
mysql-test/t/ctype_utf8.test:
updated
mysql-test/t/type_blob.test:
new tests
sql/share/english/errmsg.txt:
specify that max key length is in BYTES
sql/share/russian/errmsg.txt:
specify that max key length is in BYTES
sql/share/ukrainian/errmsg.txt:
specify that max key length is in BYTES
sql/sql_table.cc:
if a key length exceeds the supported maximum and it is safe to auto-decrease it, do it.
cleanup
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9faabb265e1..1557cf042a1 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -850,26 +850,35 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, { if ((length=column->length) > file->max_key_length() || length > file->max_key_part_length()) - { - my_error(ER_WRONG_SUB_KEY,MYF(0)); - DBUG_RETURN(-1); - } - } - /* TODO HF What's this for??? */ - else if (f_is_geom(sql_field->pack_flag)) - { - } - else if (column->length > length || - ((f_is_packed(sql_field->pack_flag) || - ((file->table_flags() & HA_NO_PREFIX_CHAR_KEYS) && - (key_info->flags & HA_NOSAME))) && - column->length != length)) - { - my_error(ER_WRONG_SUB_KEY,MYF(0)); - DBUG_RETURN(-1); + { + length=min(file->max_key_length(), file->max_key_part_length()); + if (key->type == Key::MULTIPLE) + { + /* not a critical problem */ + char warn_buff[MYSQL_ERRMSG_SIZE]; + sprintf(warn_buff,ER(ER_TOO_LONG_KEY),length); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TOO_LONG_KEY, warn_buff); + } + else + { + my_error(ER_TOO_LONG_KEY,MYF(0),length); + DBUG_RETURN(-1); + } + } } - if (!(file->table_flags() & HA_NO_PREFIX_CHAR_KEYS)) - length=column->length; + else if (!f_is_geom(sql_field->pack_flag) && + (column->length > length || + ((f_is_packed(sql_field->pack_flag) || + ((file->table_flags() & HA_NO_PREFIX_CHAR_KEYS) && + (key_info->flags & HA_NOSAME))) && + column->length != length))) + { + my_error(ER_WRONG_SUB_KEY,MYF(0)); + DBUG_RETURN(-1); + } + else if (!(file->table_flags() & HA_NO_PREFIX_CHAR_KEYS)) + length=column->length; } else if (length == 0) { @@ -879,8 +888,20 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, } if (length > file->max_key_part_length()) { - my_error(ER_WRONG_SUB_KEY,MYF(0)); - DBUG_RETURN(-1); + length=file->max_key_part_length(); + if (key->type == Key::MULTIPLE) + { + /* not a critical problem */ + char warn_buff[MYSQL_ERRMSG_SIZE]; + sprintf(warn_buff,ER(ER_TOO_LONG_KEY),length); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TOO_LONG_KEY, warn_buff); + } + else + { + my_error(ER_TOO_LONG_KEY,MYF(0),length); + DBUG_RETURN(-1); + } } key_part_info->length=(uint16) length; /* Use packed keys for long strings on the first column */ |