diff options
author | unknown <monty@mashka.mysql.fi> | 2002-07-23 02:08:48 +0300 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2002-07-23 02:08:48 +0300 |
commit | 15013f97caac27f4e6f181e507668a5a623ca781 (patch) | |
tree | 93b9c6369d5c63c2009db5b84760aa1146a39993 /sql | |
parent | a9c52ff7172308af72f062a1cae86671cbb1ed7a (diff) | |
download | mariadb-git-15013f97caac27f4e6f181e507668a5a623ca781.tar.gz |
Fixed problem with auto_increment key as not first key part
Docs/manual.texi:
Changelog
Diffstat (limited to 'sql')
-rw-r--r-- | sql/key.cc | 2 | ||||
-rw-r--r-- | sql/table.cc | 25 |
2 files changed, 15 insertions, 12 deletions
diff --git a/sql/key.cc b/sql/key.cc index 80a33bc45d3..f2488ab74cb 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -59,7 +59,7 @@ int find_ref_key(TABLE *table,Field *field, uint *key_length) { if (key_part->offset == fieldpos) return(i); /* Use this key */ - *key_length+=key_part->length; + *key_length+=key_part->store_length; } } return(-1); /* No key is ok */ diff --git a/sql/table.cc b/sql/table.cc index 66cbe7cfa16..4f71dacfa1d 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -346,17 +346,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, } } if (reg_field->unireg_check == Field::NEXT_NUMBER) - { - if ((int) (outparam->next_number_index= (uint) - find_ref_key(outparam,reg_field, - &outparam->next_number_key_offset)) < 0) - reg_field->unireg_check=Field::NONE; /* purecov: inspected */ - else - { - outparam->found_next_number_field=reg_field; - reg_field->flags|=AUTO_INCREMENT_FLAG; - } - } + outparam->found_next_number_field= reg_field; if (outparam->timestamp_field == reg_field) outparam->timestamp_field_offset=i; if (use_hash) @@ -507,6 +497,19 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, bfill(outparam->null_flags+outparam->rec_buff_length*2,null_length,255); } + if ((reg_field=outparam->found_next_number_field)) + { + if ((int) (outparam->next_number_index= (uint) + find_ref_key(outparam,reg_field, + &outparam->next_number_key_offset)) < 0) + { + reg_field->unireg_check=Field::NONE; /* purecov: inspected */ + outparam->found_next_number_field=0; + } + else + reg_field->flags|=AUTO_INCREMENT_FLAG; + } + if (outparam->blob_fields) { Field **ptr; |