685
685
/* Check if we have used the same field name before */
686
686
for (dup_no=0; (dup_field=it2++) != sql_field; dup_no++)
688
if (system_charset_info->strcasecmp(sql_field->field_name, dup_field->field_name) == 0)
688
if (my_strcasecmp(system_charset_info,
689
sql_field->field_name,
690
dup_field->field_name) == 0)
691
693
If this was a CREATE ... SELECT statement, accept a field
816
818
fk_key->ref_columns.size() != fk_key->columns.size())
818
820
my_error(ER_WRONG_FK_DEF, MYF(0),
819
(fk_key->name.data() ? fk_key->name.data() : "foreign key without name"),
821
(fk_key->name.str ? fk_key->name.str :
822
"foreign key without name"),
820
823
ER(ER_KEY_REF_DO_NOT_MATCH_TABLE_REF));
829
832
my_error(ER_TOO_MANY_KEY_PARTS,MYF(0),tmp);
832
if (check_identifier_name(key->name, ER_TOO_LONG_IDENT))
835
if (check_identifier_name(&key->name, ER_TOO_LONG_IDENT))
834
837
key_iterator2= alter_info->key_list.begin();
835
838
if (key->type != Key::FOREIGN_KEY)
842
845
Then we do not need the generated shorter key.
844
847
if ((key2->type != Key::FOREIGN_KEY &&
845
key2->name.data() != ignore_key &&
848
key2->name.str != ignore_key &&
846
849
!foreign_key_prefix(key, key2)))
848
851
/* @todo issue warning message */
850
853
if (!key2->generated ||
851
854
(key->generated && key->columns.size() <
852
855
key2->columns.size()))
853
key->name.assign(ignore_key, 1);
856
key->name.str= ignore_key;
856
key2->name.assign(ignore_key, 1);
859
key2->name.str= ignore_key;
857
860
key_parts-= key2->columns.size();
864
if (key->name.data() != ignore_key)
867
if (key->name.str != ignore_key)
865
868
key_parts+=key->columns.size();
868
if (key->name.data() && !tmp_table && (key->type != Key::PRIMARY) && is_primary_key(key->name.data()))
871
if (key->name.str && !tmp_table && (key->type != Key::PRIMARY) && is_primary_key(key->name.str))
870
my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name.data());
873
my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name.str);
888
891
uint32_t key_length=0;
889
892
Key_part_spec *column;
891
if (key->name.data() == ignore_key)
894
if (key->name.str == ignore_key)
893
896
/* ignore redundant keys */
895
898
key=key_iterator++;
896
while (key && key->name.data() == ignore_key);
899
while (key && key->name.str == ignore_key);
918
921
key_info->algorithm= key->key_create_info.algorithm;
920
923
uint32_t tmp_len= system_charset_info->cset->charpos(system_charset_info,
921
key->key_create_info.comment.begin(),
922
key->key_create_info.comment.end(),
924
key->key_create_info.comment.str,
925
key->key_create_info.comment.str +
926
key->key_create_info.comment.length,
923
927
INDEX_COMMENT_MAXLEN);
925
if (tmp_len < key->key_create_info.comment.size())
929
if (tmp_len < key->key_create_info.comment.length)
927
my_error(ER_WRONG_STRING_LENGTH, MYF(0), key->key_create_info.comment.data(), "INDEX COMMENT", (uint32_t) INDEX_COMMENT_MAXLEN);
931
my_error(ER_WRONG_STRING_LENGTH, MYF(0),
932
key->key_create_info.comment.str,"INDEX COMMENT",
933
(uint32_t) INDEX_COMMENT_MAXLEN);
931
key_info->comment.assign(key_info->comment.data(), key->key_create_info.comment.size());
932
if (key_info->comment.size() > 0)
937
key_info->comment.length= key->key_create_info.comment.length;
938
if (key_info->comment.length > 0)
934
940
key_info->flags|= HA_USES_COMMENT;
935
key_info->comment.assign(key->key_create_info.comment.data(), key_info->comment.size()); // weird
941
key_info->comment.str= key->key_create_info.comment.str;
938
944
message::Table::Field *protofield= NULL;
948
954
it= alter_info->create_list.begin();
950
956
while ((sql_field=it++) && ++proto_field_nr &&
951
system_charset_info->strcasecmp(column->field_name.data(), sql_field->field_name))
957
my_strcasecmp(system_charset_info,
958
column->field_name.str,
959
sql_field->field_name))
958
my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name.data());
966
my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name.str);
962
970
while ((dup_column= cols2++) != column)
964
if (!system_charset_info->strcasecmp(column->field_name.data(), dup_column->field_name.data()))
972
if (!my_strcasecmp(system_charset_info,
973
column->field_name.str, dup_column->field_name.str))
966
975
my_printf_error(ER_DUP_FIELDNAME,
967
976
ER(ER_DUP_FIELDNAME),MYF(0),
968
column->field_name.data());
977
column->field_name.str);
982
991
if (! (engine->check_flag(HTON_BIT_CAN_INDEX_BLOBS)))
984
my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->field_name.data());
993
my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->field_name.str);
987
996
if (! column->length)
989
my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name.data());
998
my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name.str);
1012
1021
key_info->flags|= HA_NULL_PART_KEY;
1013
1022
if (! (engine->check_flag(HTON_BIT_NULL_IN_KEY)))
1015
my_error(ER_NULL_COLUMN_IN_INDEX, MYF(0), column->field_name.data());
1024
my_error(ER_NULL_COLUMN_IN_INDEX, MYF(0), column->field_name.str);
1070
1079
else if (length == 0)
1072
my_error(ER_WRONG_KEY_COLUMN, MYF(0), column->field_name.data());
1081
my_error(ER_WRONG_KEY_COLUMN, MYF(0), column->field_name.str);
1075
1084
if (length > engine->max_key_part_length())
1131
1140
key_name=pkey_name;
1134
else if (!(key_name= key->name.data()))
1143
else if (!(key_name= key->name.str))
1135
1144
key_name=make_unique_key_name(sql_field->field_name,
1136
1145
*key_info_buffer, key_info);
1137
1146
if (check_if_keyname_exists(key_name, *key_info_buffer, key_info))
1527
1536
check_if_keyname_exists(const char *name, KeyInfo *start, KeyInfo *end)
1529
for (KeyInfo *key= start; key != end; key++)
1531
if (!system_charset_info->strcasecmp(name, key->name))
1538
for (KeyInfo *key=start ; key != end ; key++)
1539
if (!my_strcasecmp(system_charset_info,name,key->name))
1803
1810
session->getClient()->store(table_name.c_str());
1804
1811
session->getClient()->store(operator_name);
1805
session->getClient()->store(warning_level_names[err->level].data(), warning_level_names[err->level].size());
1812
session->getClient()->store(warning_level_names[err->level].str, warning_level_names[err->level].length);
1806
1813
session->getClient()->store(err->msg);
1807
1814
if (session->getClient()->flush())