Commit 9d4af785 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

change the auto_increment field filter to only allow the first field in the...

change the auto_increment field filter to only allow the first field in the primary key or the first field in the row if there is no primary key. closes #738

git-svn-id: file:///svn/mysql/tokudb-engine/src@3596 c7de825b-a66e-492c-adef-691d508d4ae1
parent 584d43ab
...@@ -2768,24 +2768,49 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in ...@@ -2768,24 +2768,49 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in
char newname[get_name_length(name) + 32]; char newname[get_name_length(name) + 32];
uint i; uint i;
for (i=0; i<form->s->keys; i++) { if (tokudb_debug & TOKUDB_DEBUG_OPEN) {
for (i = 0; i < form->s->fields; i++) {
Field *field = form->s->field[i];
TOKUDB_TRACE("field:%d:%s:type=%d:flags=%x\n", i, field->field_name, field->type(), field->flags);
}
for (i = 0; i < form->s->keys; i++) {
KEY *key = &form->s->key_info[i];
TOKUDB_TRACE("key:%d:%s:%d\n", i, key->name, key->key_parts);
uint p;
for (p = 0; p < key->key_parts; p++) {
KEY_PART_INFO *key_part = &key->key_part[p];
Field *field = key_part->field;
TOKUDB_TRACE("key:%d:%d:length=%d:%s:type=%d:flags=%x\n",
i, p, key_part->length, field->field_name, field->type(), field->flags);
}
}
}
// tokudb only supports auto increment on the first field in the primary key
// or the first field in the row
int pk_found = 0;
int ai_found = 0;
for (i = 0; i < form->s->keys; i++) {
KEY *key = &form->s->key_info[i]; KEY *key = &form->s->key_info[i];
if (tokudb_debug & TOKUDB_DEBUG_OPEN) int is_primary = (strcmp(key->name, "PRIMARY") == 0);
printf("%d:%s:%d:key:%s:%d\n", my_tid(), __FILE__, __LINE__, key->name, key->key_parts); if (is_primary) pk_found = 1;
uint p; uint p;
for (p=0; p<key->key_parts; p++) { for (p = 0; p < key->key_parts; p++) {
KEY_PART_INFO *key_part = &key->key_part[p]; KEY_PART_INFO *key_part = &key->key_part[p];
Field *field = key_part->field; Field *field = key_part->field;
if (tokudb_debug & TOKUDB_DEBUG_OPEN) if (field->flags & AUTO_INCREMENT_FLAG) {
printf("%d:%s:%d:key:%d:%d:length=%d:%s:type=%d:flags=%x\n", my_tid(), __FILE__, __LINE__, ai_found = 1;
i, p, key_part->length, field->field_name, field->type(), field->flags); if (is_primary && p > 0)
TOKUDB_DBUG_RETURN(HA_ERR_UNSUPPORTED);
/* tokudb only supports auto increment on the first field in a key */
if ((field->flags & AUTO_INCREMENT_FLAG) && (i > 0 || p > 0)) {
TOKUDB_DBUG_RETURN(HA_ERR_UNSUPPORTED);
} }
} }
} }
if (!pk_found && ai_found) {
Field *field = form->s->field[0];
if (!(field->flags & AUTO_INCREMENT_FLAG))
TOKUDB_DBUG_RETURN(HA_ERR_UNSUPPORTED);
}
// a table is a directory of dictionaries // a table is a directory of dictionaries
make_name(dirname, name, 0); make_name(dirname, name, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment