mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
merge
include/mysqld_error.h: Auto merged libmysqld/lib_sql.cc: Auto merged mysql-test/r/rpl_charset.result: Auto merged mysql-test/r/sp.result: Auto merged mysql-test/t/rpl_charset.test: Auto merged mysql-test/t/sp.test: Auto merged sql/filesort.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_innodb.h: Auto merged sql/handler.cc: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged sql/item_row.cc: Auto merged sql/item_strfunc.cc: Auto merged sql/item_timefunc.cc: Auto merged sql/item_uniq.h: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/mysqld.cc: Auto merged sql/parse_file.cc: Auto merged sql/protocol.cc: Auto merged sql/protocol.h: Auto merged sql/protocol_cursor.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/repl_failsafe.h: Auto merged sql/set_var.cc: Auto merged sql/slave.cc: Auto merged sql/slave.h: Auto merged sql/sp.cc: Auto merged sql/sp_head.cc: Auto merged sql/sql_analyse.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_error.cc: Auto merged sql/sql_help.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_repl.h: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/share/czech/errmsg.txt: Auto merged sql/share/danish/errmsg.txt: Auto merged sql/share/dutch/errmsg.txt: Auto merged sql/share/english/errmsg.txt: Auto merged sql/share/estonian/errmsg.txt: Auto merged sql/share/french/errmsg.txt: Auto merged sql/share/german/errmsg.txt: Auto merged sql/share/greek/errmsg.txt: Auto merged sql/share/hungarian/errmsg.txt: Auto merged sql/share/italian/errmsg.txt: Auto merged sql/share/japanese/errmsg.txt: Auto merged sql/share/korean/errmsg.txt: Auto merged sql/share/norwegian-ny/errmsg.txt: Auto merged sql/share/norwegian/errmsg.txt: Auto merged sql/share/polish/errmsg.txt: Auto merged sql/share/portuguese/errmsg.txt: Auto merged sql/sql_udf.cc: Auto merged sql/sql_view.cc: Auto merged sql/table.cc: Auto merged sql/unireg.cc: Auto merged sql/share/romanian/errmsg.txt: Auto merged sql/share/russian/errmsg.txt: Auto merged sql/share/serbian/errmsg.txt: Auto merged sql/share/slovak/errmsg.txt: Auto merged sql/share/spanish/errmsg.txt: Auto merged sql/share/swedish/errmsg.txt: Auto merged sql/share/ukrainian/errmsg.txt: Auto merged
This commit is contained in:
321
sql/sql_table.cc
321
sql/sql_table.cc
@@ -63,15 +63,15 @@ static int copy_data_between_tables(TABLE *from,TABLE *to,
|
||||
Wait if global_read_lock (FLUSH TABLES WITH READ LOCK) is set.
|
||||
|
||||
RETURN
|
||||
0 ok. In this case ok packet is sent to user
|
||||
-1 Error (Error message given but not sent to user)
|
||||
FALSE OK. In this case ok packet is sent to user
|
||||
TRUE Error
|
||||
|
||||
*/
|
||||
|
||||
int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
|
||||
my_bool drop_temporary)
|
||||
bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
|
||||
my_bool drop_temporary)
|
||||
{
|
||||
int error= 0;
|
||||
bool error= FALSE;
|
||||
DBUG_ENTER("mysql_rm_table");
|
||||
|
||||
/* mark for close and remove all cached entries */
|
||||
@@ -84,9 +84,10 @@ int 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);
|
||||
error= 1;
|
||||
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;
|
||||
}
|
||||
while (global_read_lock && ! thd->killed)
|
||||
@@ -106,9 +107,9 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
|
||||
pthread_mutex_unlock(&thd->mysys_var->mutex);
|
||||
|
||||
if (error)
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(TRUE);
|
||||
send_ok(thd);
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
|
||||
@@ -268,9 +269,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;
|
||||
}
|
||||
|
||||
@@ -468,7 +470,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);
|
||||
}
|
||||
|
||||
@@ -485,7 +488,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
|
||||
@@ -626,24 +630,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);
|
||||
}
|
||||
|
||||
@@ -669,9 +676,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;
|
||||
@@ -685,7 +694,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 ();
|
||||
@@ -725,7 +735,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);
|
||||
}
|
||||
}
|
||||
@@ -793,7 +804,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);
|
||||
}
|
||||
}
|
||||
@@ -934,7 +946,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);
|
||||
}
|
||||
}
|
||||
@@ -980,7 +993,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))
|
||||
@@ -1033,7 +1046,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;
|
||||
@@ -1044,7 +1058,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;
|
||||
@@ -1052,7 +1067,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))
|
||||
@@ -1069,12 +1085,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 */
|
||||
@@ -1108,30 +1124,31 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
and must be zero for standard create of table.
|
||||
|
||||
RETURN VALUES
|
||||
0 ok
|
||||
-1 error
|
||||
FALSE OK
|
||||
TRUE error
|
||||
*/
|
||||
|
||||
int mysql_create_table(THD *thd,const char *db, const char *table_name,
|
||||
HA_CREATE_INFO *create_info,
|
||||
List<create_field> &fields,
|
||||
List<Key> &keys,bool tmp_table,
|
||||
uint select_field_count)
|
||||
bool mysql_create_table(THD *thd,const char *db, const char *table_name,
|
||||
HA_CREATE_INFO *create_info,
|
||||
List<create_field> &fields,
|
||||
List<Key> &keys,bool tmp_table,
|
||||
uint select_field_count)
|
||||
{
|
||||
char path[FN_REFLEN];
|
||||
const char *alias;
|
||||
int error= -1;
|
||||
uint db_options, key_count;
|
||||
KEY *key_info_buffer;
|
||||
handler *file;
|
||||
bool error= TRUE;
|
||||
enum db_type new_db_type;
|
||||
DBUG_ENTER("mysql_create_table");
|
||||
|
||||
/* Check for duplicate fields and check type of table to create */
|
||||
if (!fields.elements)
|
||||
{
|
||||
my_error(ER_TABLE_MUST_HAVE_COLUMNS,MYF(0));
|
||||
DBUG_RETURN(-1);
|
||||
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)) !=
|
||||
create_info->db_type)
|
||||
@@ -1160,8 +1177,8 @@ int 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);
|
||||
DBUG_RETURN(-1);
|
||||
my_printf_error(ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), MYF(0), table_name);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1186,7 +1203,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
|
||||
keys, tmp_table, db_options, file,
|
||||
key_info_buffer, &key_count,
|
||||
select_field_count))
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
/* Check if table exists */
|
||||
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
|
||||
@@ -1209,10 +1226,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
|
||||
if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
|
||||
{
|
||||
create_info->table_existed= 1; // Mark that table existed
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), alias);
|
||||
DBUG_RETURN(-1);
|
||||
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))
|
||||
DBUG_RETURN(error);
|
||||
@@ -1224,10 +1242,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
|
||||
if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
|
||||
{
|
||||
create_info->table_existed= 1; // Mark that table existed
|
||||
error= 0;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1253,10 +1272,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
|
||||
if (create_if_not_exists)
|
||||
{
|
||||
create_info->table_existed= 1; // Mark that table existed
|
||||
error= 0;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1292,7 +1312,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
|
||||
HA_LEX_CREATE_TMP_TABLE));
|
||||
mysql_bin_log.write(&qinfo);
|
||||
}
|
||||
error=0;
|
||||
error= FALSE;
|
||||
end:
|
||||
VOID(pthread_mutex_unlock(&LOCK_open));
|
||||
start_waiting_global_read_lock(thd);
|
||||
@@ -1475,7 +1495,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);
|
||||
}
|
||||
|
||||
@@ -1565,7 +1586,7 @@ static int send_check_errmsg(THD *thd, TABLE_LIST* table,
|
||||
protocol->store((char*) operator_name, system_charset_info);
|
||||
protocol->store("error", 5, system_charset_info);
|
||||
protocol->store(errmsg, system_charset_info);
|
||||
thd->net.last_error[0]=0;
|
||||
thd->clear_error();
|
||||
if (protocol->write())
|
||||
return -1;
|
||||
return 1;
|
||||
@@ -1742,20 +1763,20 @@ end:
|
||||
|
||||
/*
|
||||
RETURN VALUES
|
||||
0 Message sent to net (admin operation went ok)
|
||||
-1 Message should be sent by caller
|
||||
(admin operation or network communication failed)
|
||||
FALSE Message sent to net (admin operation went ok)
|
||||
TRUE Message should be sent by caller
|
||||
(admin operation or network communication failed)
|
||||
*/
|
||||
static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
HA_CHECK_OPT* check_opt,
|
||||
const char *operator_name,
|
||||
thr_lock_type lock_type,
|
||||
bool open_for_modify,
|
||||
uint extra_open_options,
|
||||
int (*prepare_func)(THD *, TABLE_LIST *,
|
||||
HA_CHECK_OPT *),
|
||||
int (handler::*operator_func)
|
||||
(THD *, HA_CHECK_OPT *))
|
||||
static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
HA_CHECK_OPT* check_opt,
|
||||
const char *operator_name,
|
||||
thr_lock_type lock_type,
|
||||
bool open_for_modify,
|
||||
uint extra_open_options,
|
||||
int (*prepare_func)(THD *, TABLE_LIST *,
|
||||
HA_CHECK_OPT *),
|
||||
int (handler::*operator_func)
|
||||
(THD *, HA_CHECK_OPT *))
|
||||
{
|
||||
TABLE_LIST *table;
|
||||
List<Item> field_list;
|
||||
@@ -1773,7 +1794,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
item->maybe_null = 1;
|
||||
if (protocol->send_fields(&field_list,
|
||||
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
mysql_ha_flush(thd, tables, MYSQL_HA_CLOSE_FINAL);
|
||||
for (table= tables; table; table= table->next_local)
|
||||
@@ -1785,9 +1806,6 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
|
||||
thd->open_options|= extra_open_options;
|
||||
table->table = open_ltable(thd, table, lock_type);
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
thd->net.last_errno= 0; // these errors shouldn't get client
|
||||
#endif
|
||||
thd->open_options&= ~extra_open_options;
|
||||
|
||||
if (prepare_func)
|
||||
@@ -1813,7 +1831,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
if (!(err_msg=thd->net.last_error))
|
||||
err_msg=ER(ER_CHECK_NO_SUCH_TABLE);
|
||||
protocol->store(err_msg, system_charset_info);
|
||||
thd->net.last_error[0]=0;
|
||||
thd->clear_error();
|
||||
if (protocol->write())
|
||||
goto err;
|
||||
continue;
|
||||
@@ -1857,9 +1875,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
}
|
||||
|
||||
int result_code = (table->table->file->*operator_func)(thd, check_opt);
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
thd->net.last_errno= 0; // these errors shouldn't get client
|
||||
#endif
|
||||
thd->clear_error(); // these errors shouldn't get client
|
||||
protocol->prepare_for_resend();
|
||||
protocol->store(table_name, system_charset_info);
|
||||
protocol->store(operator_name, system_charset_info);
|
||||
@@ -1960,16 +1976,16 @@ send_result_message:
|
||||
}
|
||||
|
||||
send_eof(thd);
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(FALSE);
|
||||
err:
|
||||
close_thread_tables(thd); // Shouldn't be needed
|
||||
if (table)
|
||||
table->table=0;
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
|
||||
int mysql_backup_table(THD* thd, TABLE_LIST* table_list)
|
||||
bool mysql_backup_table(THD* thd, TABLE_LIST* table_list)
|
||||
{
|
||||
DBUG_ENTER("mysql_backup_table");
|
||||
DBUG_RETURN(mysql_admin_table(thd, table_list, 0,
|
||||
@@ -1978,7 +1994,7 @@ int mysql_backup_table(THD* thd, TABLE_LIST* table_list)
|
||||
}
|
||||
|
||||
|
||||
int mysql_restore_table(THD* thd, TABLE_LIST* table_list)
|
||||
bool mysql_restore_table(THD* thd, TABLE_LIST* table_list)
|
||||
{
|
||||
DBUG_ENTER("mysql_restore_table");
|
||||
DBUG_RETURN(mysql_admin_table(thd, table_list, 0,
|
||||
@@ -1988,7 +2004,7 @@ int mysql_restore_table(THD* thd, TABLE_LIST* table_list)
|
||||
}
|
||||
|
||||
|
||||
int mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
|
||||
bool mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
|
||||
{
|
||||
DBUG_ENTER("mysql_repair_table");
|
||||
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
|
||||
@@ -1998,7 +2014,7 @@ int mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
|
||||
}
|
||||
|
||||
|
||||
int mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
|
||||
bool mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
|
||||
{
|
||||
DBUG_ENTER("mysql_optimize_table");
|
||||
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
|
||||
@@ -2016,11 +2032,11 @@ int mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
|
||||
tables Table list (one table only)
|
||||
|
||||
RETURN VALUES
|
||||
0 ok
|
||||
-1 error
|
||||
FALSE ok
|
||||
TRUE error
|
||||
*/
|
||||
|
||||
int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables,
|
||||
bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables,
|
||||
LEX_STRING *key_cache_name)
|
||||
{
|
||||
HA_CHECK_OPT check_opt;
|
||||
@@ -2032,8 +2048,9 @@ int 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);
|
||||
DBUG_RETURN(-1);
|
||||
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);
|
||||
check_opt.key_cache= key_cache;
|
||||
@@ -2091,11 +2108,11 @@ int reassign_keycache_tables(THD *thd, KEY_CACHE *src_cache,
|
||||
tables Table list (one table only)
|
||||
|
||||
RETURN VALUES
|
||||
0 ok
|
||||
-1 error
|
||||
FALSE ok
|
||||
TRUE error
|
||||
*/
|
||||
|
||||
int mysql_preload_keys(THD* thd, TABLE_LIST* tables)
|
||||
bool mysql_preload_keys(THD* thd, TABLE_LIST* tables)
|
||||
{
|
||||
DBUG_ENTER("mysql_preload_keys");
|
||||
DBUG_RETURN(mysql_admin_table(thd, tables, 0,
|
||||
@@ -2115,13 +2132,13 @@ int mysql_preload_keys(THD* thd, TABLE_LIST* tables)
|
||||
table_ident Src table_ident
|
||||
|
||||
RETURN VALUES
|
||||
0 ok
|
||||
-1 error
|
||||
FALSE OK
|
||||
TRUE error
|
||||
*/
|
||||
|
||||
int mysql_create_like_table(THD* thd, TABLE_LIST* table,
|
||||
HA_CREATE_INFO *create_info,
|
||||
Table_ident *table_ident)
|
||||
bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
|
||||
HA_CREATE_INFO *create_info,
|
||||
Table_ident *table_ident)
|
||||
{
|
||||
TABLE **tmp_table;
|
||||
char src_path[FN_REFLEN], dst_path[FN_REFLEN];
|
||||
@@ -2129,7 +2146,8 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table,
|
||||
char *table_name= table->real_name;
|
||||
char *src_db= thd->db;
|
||||
char *src_table= table_ident->table.str;
|
||||
int err, res= -1;
|
||||
int err;
|
||||
bool res= TRUE;
|
||||
TABLE_LIST src_tables_list;
|
||||
DBUG_ENTER("mysql_create_like_table");
|
||||
|
||||
@@ -2141,8 +2159,9 @@ int 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);
|
||||
DBUG_RETURN(-1);
|
||||
my_printf_error(ER_WRONG_TABLE_NAME, ER(ER_WRONG_TABLE_NAME), MYF(0),
|
||||
src_table);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
bzero((gptr)&src_tables_list, sizeof(src_tables_list));
|
||||
@@ -2160,7 +2179,8 @@ int 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;
|
||||
}
|
||||
}
|
||||
@@ -2229,7 +2249,7 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table,
|
||||
HA_LEX_CREATE_TMP_TABLE));
|
||||
mysql_bin_log.write(&qinfo);
|
||||
}
|
||||
res= 0;
|
||||
res= FALSE;
|
||||
goto err;
|
||||
|
||||
table_exists:
|
||||
@@ -2240,10 +2260,11 @@ table_exists:
|
||||
ER(ER_TABLE_EXISTS_ERROR), table_name);
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
|
||||
ER_TABLE_EXISTS_ERROR,warn_buff);
|
||||
res= 0;
|
||||
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);
|
||||
@@ -2253,7 +2274,7 @@ err:
|
||||
}
|
||||
|
||||
|
||||
int mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
|
||||
bool mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
|
||||
{
|
||||
#ifdef OS2
|
||||
thr_lock_type lock_type = TL_WRITE;
|
||||
@@ -2268,7 +2289,7 @@ int mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
|
||||
}
|
||||
|
||||
|
||||
int mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt)
|
||||
bool mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt)
|
||||
{
|
||||
#ifdef OS2
|
||||
thr_lock_type lock_type = TL_WRITE;
|
||||
@@ -2502,7 +2523,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);
|
||||
}
|
||||
@@ -2559,13 +2581,13 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list,
|
||||
Alter table
|
||||
*/
|
||||
|
||||
int mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
HA_CREATE_INFO *create_info,
|
||||
TABLE_LIST *table_list,
|
||||
List<create_field> &fields, List<Key> &keys,
|
||||
uint order_num, ORDER *order,
|
||||
enum enum_duplicates handle_duplicates,
|
||||
ALTER_INFO *alter_info, bool do_send_ok)
|
||||
bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
HA_CREATE_INFO *create_info,
|
||||
TABLE_LIST *table_list,
|
||||
List<create_field> &fields, List<Key> &keys,
|
||||
uint order_num, ORDER *order,
|
||||
enum enum_duplicates handle_duplicates,
|
||||
ALTER_INFO *alter_info, bool do_send_ok)
|
||||
{
|
||||
TABLE *table,*new_table=0;
|
||||
int error;
|
||||
@@ -2594,7 +2616,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
DBUG_RETURN(mysql_discard_or_import_tablespace(thd,table_list,
|
||||
alter_info->tablespace_op));
|
||||
if (!(table=open_ltable(thd,table_list,TL_WRITE_ALLOW_READ)))
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
/* Check that we are not trying to rename to an existing table */
|
||||
if (new_name)
|
||||
@@ -2625,8 +2647,9 @@ int 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);
|
||||
DBUG_RETURN(-1);
|
||||
my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
|
||||
MYF(0), new_name_buff);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2637,8 +2660,9 @@ int 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);
|
||||
DBUG_RETURN(-1);
|
||||
my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
|
||||
MYF(0), new_alias);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2678,7 +2702,8 @@ int 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
|
||||
@@ -2822,8 +2847,9 @@ int 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);
|
||||
DBUG_RETURN(-1);
|
||||
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
|
||||
alter_it.remove();
|
||||
@@ -2836,8 +2862,9 @@ int 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);
|
||||
DBUG_RETURN(-1);
|
||||
my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR), MYF(0),
|
||||
def->change, table_name);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (!def->after)
|
||||
create_list.push_back(def);
|
||||
@@ -2854,22 +2881,24 @@ int 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);
|
||||
DBUG_RETURN(-1);
|
||||
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
|
||||
}
|
||||
}
|
||||
if (alter_info->alter_list.elements)
|
||||
{
|
||||
my_error(ER_BAD_FIELD_ERROR,MYF(0),alter_info->alter_list.head()->name,
|
||||
table_name);
|
||||
DBUG_RETURN(-1);
|
||||
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));
|
||||
DBUG_RETURN(-1);
|
||||
my_message(ER_CANT_REMOVE_ALL_FIELDS, ER(ER_CANT_REMOVE_ALL_FIELDS),
|
||||
MYF(0));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2957,22 +2986,25 @@ int 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);
|
||||
DBUG_RETURN(-1);
|
||||
my_printf_error(ER_WRONG_NAME_FOR_INDEX, ER(ER_WRONG_NAME_FOR_INDEX),
|
||||
MYF(0), key->name);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -3175,7 +3207,8 @@ int 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;
|
||||
@@ -3313,10 +3346,10 @@ end_temporary:
|
||||
if (do_send_ok)
|
||||
send_ok(thd,copied+deleted,0L,tmp_name);
|
||||
thd->some_tables_deleted=0;
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
err:
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
|
||||
@@ -3502,8 +3535,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,
|
||||
RETURN
|
||||
Like mysql_alter_table().
|
||||
*/
|
||||
int mysql_recreate_table(THD *thd, TABLE_LIST *table_list,
|
||||
bool do_send_ok)
|
||||
bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list,
|
||||
bool do_send_ok)
|
||||
{
|
||||
DBUG_ENTER("mysql_recreate_table");
|
||||
LEX *lex= thd->lex;
|
||||
@@ -3525,7 +3558,7 @@ int mysql_recreate_table(THD *thd, TABLE_LIST *table_list,
|
||||
}
|
||||
|
||||
|
||||
int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
|
||||
bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
|
||||
{
|
||||
TABLE_LIST *table;
|
||||
List<Item> field_list;
|
||||
@@ -3539,7 +3572,7 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
|
||||
item->maybe_null= 1;
|
||||
if (protocol->send_fields(&field_list,
|
||||
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
for (table= tables; table; table= table->next_local)
|
||||
{
|
||||
@@ -3558,7 +3591,7 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
|
||||
{
|
||||
/* Table didn't exist */
|
||||
protocol->store_null();
|
||||
thd->net.last_error[0]=0;
|
||||
thd->clear_error();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3620,11 +3653,11 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
|
||||
}
|
||||
|
||||
send_eof(thd);
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
err:
|
||||
close_thread_tables(thd); // Shouldn't be needed
|
||||
if (table)
|
||||
table->table=0;
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user