summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc135
1 files changed, 86 insertions, 49 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index d84611ae496..77a5ab340b3 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -78,8 +78,9 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
{
if (thd->global_read_lock)
{
- my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0),
- tables->real_name);
+ my_printf_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,
+ ER(ER_TABLE_NOT_LOCKED_FOR_WRITE), MYF(0),
+ tables->real_name);
error= TRUE;
goto err;
}
@@ -261,9 +262,10 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
if (wrong_tables.length())
{
if (!foreign_key_error)
- my_error(ER_BAD_TABLE_ERROR,MYF(0), wrong_tables.c_ptr());
+ my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0),
+ wrong_tables.c_ptr());
else
- my_error(ER_ROW_IS_REFERENCED, MYF(0));
+ my_message(ER_ROW_IS_REFERENCED, ER(ER_ROW_IS_REFERENCED), MYF(0));
error= 1;
}
@@ -463,7 +465,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
if (check_column_name(sql_field->field_name))
{
- my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->field_name);
+ my_printf_error(ER_WRONG_COLUMN_NAME, ER(ER_WRONG_COLUMN_NAME), MYF(0),
+ sql_field->field_name);
DBUG_RETURN(-1);
}
@@ -480,7 +483,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
*/
if (field_no < select_field_pos || dup_no >= select_field_pos)
{
- my_error(ER_DUP_FIELDNAME,MYF(0),sql_field->field_name);
+ my_printf_error(ER_DUP_FIELDNAME, ER(ER_DUP_FIELDNAME), MYF(0),
+ sql_field->field_name);
DBUG_RETURN(-1);
}
else
@@ -619,24 +623,27 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
}
if (timestamps_with_niladic > 1)
{
- my_error(ER_TOO_MUCH_AUTO_TIMESTAMP_COLS,MYF(0));
+ my_message(ER_TOO_MUCH_AUTO_TIMESTAMP_COLS,
+ ER(ER_TOO_MUCH_AUTO_TIMESTAMP_COLS), MYF(0));
DBUG_RETURN(-1);
}
if (auto_increment > 1)
{
- my_error(ER_WRONG_AUTO_KEY,MYF(0));
+ my_message(ER_WRONG_AUTO_KEY, ER(ER_WRONG_AUTO_KEY), MYF(0));
DBUG_RETURN(-1);
}
if (auto_increment &&
(file->table_flags() & HA_NO_AUTO_INCREMENT))
{
- my_error(ER_TABLE_CANT_HANDLE_AUTO_INCREMENT,MYF(0));
+ my_message(ER_TABLE_CANT_HANDLE_AUTO_INCREMENT,
+ ER(ER_TABLE_CANT_HANDLE_AUTO_INCREMENT), MYF(0));
DBUG_RETURN(-1);
}
if (blob_columns && (file->table_flags() & HA_NO_BLOBS))
{
- my_error(ER_TABLE_CANT_HANDLE_BLOB,MYF(0));
+ my_message(ER_TABLE_CANT_HANDLE_BLOB, ER(ER_TABLE_CANT_HANDLE_BLOB),
+ MYF(0));
DBUG_RETURN(-1);
}
@@ -662,9 +669,11 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
if (fk_key->ref_columns.elements &&
fk_key->ref_columns.elements != fk_key->columns.elements)
{
- my_error(ER_WRONG_FK_DEF, MYF(0), fk_key->name ? fk_key->name :
- "foreign key without name",
- ER(ER_KEY_REF_DO_NOT_MATCH_TABLE_REF));
+ my_printf_error(ER_WRONG_FK_DEF, ER(ER_WRONG_FK_DEF), MYF(0),
+ (fk_key->name ?
+ fk_key->name :
+ "foreign key without name"),
+ ER(ER_KEY_REF_DO_NOT_MATCH_TABLE_REF));
DBUG_RETURN(-1);
}
continue;
@@ -678,7 +687,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
}
if (key->name && strlen(key->name) > NAME_LEN)
{
- my_error(ER_TOO_LONG_IDENT, MYF(0), key->name);
+ my_printf_error(ER_TOO_LONG_IDENT, ER(ER_TOO_LONG_IDENT), MYF(0),
+ key->name);
DBUG_RETURN(-1);
}
key_iterator2.rewind ();
@@ -718,7 +728,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
if (key->name && !tmp_table &&
!my_strcasecmp(system_charset_info,key->name,primary_key_name))
{
- my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name);
+ my_printf_error(ER_WRONG_NAME_FOR_INDEX, ER(ER_WRONG_NAME_FOR_INDEX),
+ MYF(0), key->name);
DBUG_RETURN(-1);
}
}
@@ -786,7 +797,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
{
if (!(file->table_flags() & HA_CAN_FULLTEXT))
{
- my_error(ER_TABLE_CANT_HANDLE_FT, MYF(0));
+ my_message(ER_TABLE_CANT_HANDLE_FT, ER(ER_TABLE_CANT_HANDLE_FT),
+ MYF(0));
DBUG_RETURN(-1);
}
}
@@ -927,7 +939,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
}
if (key->type == Key::SPATIAL)
{
- my_error(ER_SPATIAL_CANT_HAVE_NULL, MYF(0));
+ my_message(ER_SPATIAL_CANT_HAVE_NULL,
+ ER(ER_SPATIAL_CANT_HAVE_NULL), MYF(0));
DBUG_RETURN(-1);
}
}
@@ -973,7 +986,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
(key_info->flags & HA_NOSAME))) &&
column->length != length)))
{
- my_error(ER_WRONG_SUB_KEY,MYF(0));
+ my_message(ER_WRONG_SUB_KEY, ER(ER_WRONG_SUB_KEY), MYF(0));
DBUG_RETURN(-1);
}
else if (!(file->table_flags() & HA_NO_PREFIX_CHAR_KEYS))
@@ -1026,7 +1039,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
{
if (primary_key)
{
- my_error(ER_MULTIPLE_PRI_KEY,MYF(0));
+ my_message(ER_MULTIPLE_PRI_KEY, ER(ER_MULTIPLE_PRI_KEY),
+ MYF(0));
DBUG_RETURN(-1);
}
key_name=primary_key_name;
@@ -1037,7 +1051,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
key_info_buffer,key_info);
if (check_if_keyname_exists(key_name,key_info_buffer,key_info))
{
- my_error(ER_DUP_KEYNAME,MYF(0),key_name);
+ my_printf_error(ER_DUP_KEYNAME, ER(ER_DUP_KEYNAME), MYF(0),
+ key_name);
DBUG_RETURN(-1);
}
key_info->name=(char*) key_name;
@@ -1045,7 +1060,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
}
if (!key_info->name || check_column_name(key_info->name))
{
- my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key_info->name);
+ my_printf_error(ER_WRONG_NAME_FOR_INDEX, ER(ER_WRONG_NAME_FOR_INDEX),
+ MYF(0), key_info->name);
DBUG_RETURN(-1);
}
if (!(key_info->flags & HA_NULL_PART_KEY))
@@ -1062,12 +1078,12 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
if (!unique_key && !primary_key &&
(file->table_flags() & HA_REQUIRE_PRIMARY_KEY))
{
- my_error(ER_REQUIRES_PRIMARY_KEY,MYF(0));
+ my_message(ER_REQUIRES_PRIMARY_KEY, ER(ER_REQUIRES_PRIMARY_KEY), MYF(0));
DBUG_RETURN(-1);
}
if (auto_increment > 0)
{
- my_error(ER_WRONG_AUTO_KEY,MYF(0));
+ my_message(ER_WRONG_AUTO_KEY, ER(ER_WRONG_AUTO_KEY), MYF(0));
DBUG_RETURN(-1);
}
/* Sort keys in optimized order */
@@ -1123,7 +1139,8 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
/* Check for duplicate fields and check type of table to create */
if (!fields.elements)
{
- my_error(ER_TABLE_MUST_HAVE_COLUMNS,MYF(0));
+ my_message(ER_TABLE_MUST_HAVE_COLUMNS, ER(ER_TABLE_MUST_HAVE_COLUMNS),
+ MYF(0));
DBUG_RETURN(TRUE);
}
if ((new_db_type= ha_checktype(create_info->db_type)) !=
@@ -1153,7 +1170,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
if ((create_info->options & HA_LEX_CREATE_TMP_TABLE) &&
(file->table_flags() & HA_NO_TEMP_TABLES))
{
- my_error(ER_ILLEGAL_HA,MYF(0),table_name);
+ my_printf_error(ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), MYF(0), table_name);
DBUG_RETURN(TRUE);
}
#endif
@@ -1204,7 +1221,8 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
create_info->table_existed= 1; // Mark that table existed
DBUG_RETURN(FALSE);
}
- my_error(ER_TABLE_EXISTS_ERROR, MYF(0), alias);
+ my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), MYF(0),
+ alias);
DBUG_RETURN(TRUE);
}
if (wait_if_global_read_lock(thd, 0, 1))
@@ -1220,7 +1238,8 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
error= FALSE;
}
else
- my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
+ my_printf_error(ER_TABLE_EXISTS_ERROR,
+ ER(ER_TABLE_EXISTS_ERROR), MYF(0), table_name);
goto end;
}
}
@@ -1249,7 +1268,8 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
error= FALSE;
}
else
- my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
+ my_printf_error(ER_TABLE_EXISTS_ERROR,
+ ER(ER_TABLE_EXISTS_ERROR), MYF(0), table_name);
goto end;
}
}
@@ -1457,7 +1477,8 @@ mysql_rename_table(enum db_type base,
}
delete file;
if (error)
- my_error(ER_ERROR_ON_RENAME, MYF(0), from, to, error);
+ my_printf_error(ER_ERROR_ON_RENAME, ER(ER_ERROR_ON_RENAME),
+ MYF(0), from, to, error);
DBUG_RETURN(error != 0);
}
@@ -1999,7 +2020,8 @@ bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables,
if (!(key_cache= get_key_cache(key_cache_name)))
{
pthread_mutex_unlock(&LOCK_global_system_variables);
- my_error(ER_UNKNOWN_KEY_CACHE, MYF(0), key_cache_name->str);
+ my_printf_error(ER_UNKNOWN_KEY_CACHE, ER(ER_UNKNOWN_KEY_CACHE), MYF(0),
+ key_cache_name->str);
DBUG_RETURN(TRUE);
}
pthread_mutex_unlock(&LOCK_global_system_variables);
@@ -2109,7 +2131,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
check_table_name(src_table,table_ident->table.length)) ||
table_ident->db.str && check_db_name((src_db= table_ident->db.str)))
{
- my_error(ER_WRONG_TABLE_NAME, MYF(0), src_table);
+ my_printf_error(ER_WRONG_TABLE_NAME, ER(ER_WRONG_TABLE_NAME), MYF(0),
+ src_table);
DBUG_RETURN(TRUE);
}
@@ -2128,7 +2151,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
reg_ext, NullS);
if (access(src_path, F_OK))
{
- my_error(ER_BAD_TABLE_ERROR, MYF(0), src_table);
+ my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0),
+ src_table);
goto err;
}
}
@@ -2211,7 +2235,8 @@ table_exists:
res= FALSE;
}
else
- my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name);
+ my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), MYF(0),
+ table_name);
err:
pthread_mutex_lock(&LOCK_open);
@@ -2467,7 +2492,8 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list,
}
if (idx>= table->keys)
{
- my_error(ER_CANT_DROP_FIELD_OR_KEY, MYF(0), drop_key->name);
+ my_printf_error(ER_CANT_DROP_FIELD_OR_KEY, ER(ER_CANT_DROP_FIELD_OR_KEY),
+ MYF(0), drop_key->name);
/*don't need to free((gptr) key_numbers);*/
DBUG_RETURN(-1);
}
@@ -2590,7 +2616,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
if (find_temporary_table(thd,new_db,new_name_buff))
{
- my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_name_buff);
+ my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
+ MYF(0), new_name_buff);
DBUG_RETURN(TRUE);
}
}
@@ -2600,7 +2627,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
F_OK))
{
/* Table will be closed in do_command() */
- my_error(ER_TABLE_EXISTS_ERROR,MYF(0), new_alias);
+ my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
+ MYF(0), new_alias);
DBUG_RETURN(TRUE);
}
}
@@ -2640,7 +2668,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
error=0;
if (!access(new_name_buff,F_OK))
{
- my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_name);
+ my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
+ MYF(0), new_name);
error= -1;
}
else
@@ -2783,7 +2812,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
if (def->sql_type == FIELD_TYPE_BLOB)
{
- my_error(ER_BLOB_CANT_HAVE_DEFAULT,MYF(0),def->change);
+ my_printf_error(ER_BLOB_CANT_HAVE_DEFAULT,
+ ER(ER_BLOB_CANT_HAVE_DEFAULT), MYF(0), def->change);
DBUG_RETURN(TRUE);
}
def->def=alter->def; // Use new default
@@ -2797,7 +2827,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
if (def->change && ! def->field)
{
- my_error(ER_BAD_FIELD_ERROR,MYF(0),def->change,table_name);
+ my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR), MYF(0),
+ def->change, table_name);
DBUG_RETURN(TRUE);
}
if (!def->after)
@@ -2815,7 +2846,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
if (!find)
{
- my_error(ER_BAD_FIELD_ERROR,MYF(0),def->after,table_name);
+ my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR),
+ MYF(0), def->after, table_name);
DBUG_RETURN(TRUE);
}
find_it.after(def); // Put element after this
@@ -2823,13 +2855,14 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
if (alter_info->alter_list.elements)
{
- my_error(ER_BAD_FIELD_ERROR,MYF(0),alter_info->alter_list.head()->name,
- table_name);
+ my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR), MYF(0),
+ alter_info->alter_list.head()->name, table_name);
DBUG_RETURN(TRUE);
}
if (!create_list.elements)
{
- my_error(ER_CANT_REMOVE_ALL_FIELDS,MYF(0));
+ my_message(ER_CANT_REMOVE_ALL_FIELDS, ER(ER_CANT_REMOVE_ALL_FIELDS),
+ MYF(0));
DBUG_RETURN(TRUE);
}
@@ -2918,7 +2951,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (key->name &&
!my_strcasecmp(system_charset_info,key->name,primary_key_name))
{
- my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name);
+ my_printf_error(ER_WRONG_NAME_FOR_INDEX, ER(ER_WRONG_NAME_FOR_INDEX),
+ MYF(0), key->name);
DBUG_RETURN(TRUE);
}
}
@@ -2926,14 +2960,16 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (alter_info->drop_list.elements)
{
- my_error(ER_CANT_DROP_FIELD_OR_KEY,MYF(0),
- alter_info->drop_list.head()->name);
+ my_printf_error(ER_CANT_DROP_FIELD_OR_KEY,
+ ER(ER_CANT_DROP_FIELD_OR_KEY), MYF(0),
+ alter_info->drop_list.head()->name);
goto err;
}
if (alter_info->alter_list.elements)
{
- my_error(ER_CANT_DROP_FIELD_OR_KEY,MYF(0),
- alter_info->alter_list.head()->name);
+ my_printf_error(ER_CANT_DROP_FIELD_OR_KEY,
+ ER(ER_CANT_DROP_FIELD_OR_KEY), MYF(0),
+ alter_info->alter_list.head()->name);
goto err;
}
@@ -3121,7 +3157,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (!access(new_name_buff,F_OK))
{
error=1;
- my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_name_buff);
+ my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
+ MYF(0), new_name_buff);
VOID(quick_rm_table(new_db_type,new_db,tmp_name));
VOID(pthread_mutex_unlock(&LOCK_open));
goto err;