mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
marge
This commit is contained in:
311
sql/sql_table.cc
311
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,8 @@ 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_error(ER_TABLE_NOT_LOCKED_FOR_WRITE, MYF(0), tables->real_name);
|
||||
error= TRUE;
|
||||
goto err;
|
||||
}
|
||||
while (global_read_lock && ! thd->killed)
|
||||
@@ -106,9 +105,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 +267,9 @@ 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_error(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;
|
||||
}
|
||||
|
||||
@@ -485,7 +484,7 @@ 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_error(ER_DUP_FIELDNAME, MYF(0), sql_field->field_name);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
else
|
||||
@@ -537,8 +536,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
#ifdef HAVE_SPATIAL
|
||||
if (!(file->table_flags() & HA_CAN_GEOMETRY))
|
||||
{
|
||||
my_printf_error(ER_CHECK_NOT_IMPLEMENTED, ER(ER_CHECK_NOT_IMPLEMENTED),
|
||||
MYF(0), "GEOMETRY");
|
||||
my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "GEOMETRY");
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
sql_field->pack_flag=FIELDFLAG_GEOM |
|
||||
@@ -551,8 +549,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
blob_columns++;
|
||||
break;
|
||||
#else
|
||||
my_printf_error(ER_FEATURE_DISABLED,ER(ER_FEATURE_DISABLED), MYF(0),
|
||||
sym_group_geom.name, sym_group_geom.needed_define);
|
||||
my_error(ER_FEATURE_DISABLED, MYF(0),
|
||||
sym_group_geom.name, sym_group_geom.needed_define);
|
||||
DBUG_RETURN(-1);
|
||||
#endif /*HAVE_SPATIAL*/
|
||||
case FIELD_TYPE_VAR_STRING:
|
||||
@@ -626,24 +624,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 +670,9 @@ 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_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));
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
continue;
|
||||
@@ -770,8 +771,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
key_info->flags= HA_SPATIAL;
|
||||
break;
|
||||
#else
|
||||
my_printf_error(ER_FEATURE_DISABLED,ER(ER_FEATURE_DISABLED),MYF(0),
|
||||
sym_group_geom.name, sym_group_geom.needed_define);
|
||||
my_error(ER_FEATURE_DISABLED, MYF(0),
|
||||
sym_group_geom.name, sym_group_geom.needed_define);
|
||||
DBUG_RETURN(-1);
|
||||
#endif
|
||||
case Key::FOREIGN_KEY:
|
||||
@@ -793,7 +794,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);
|
||||
}
|
||||
}
|
||||
@@ -810,8 +812,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
{
|
||||
if (key_info->key_parts != 1)
|
||||
{
|
||||
my_printf_error(ER_WRONG_ARGUMENTS,
|
||||
ER(ER_WRONG_ARGUMENTS),MYF(0),"SPATIAL INDEX");
|
||||
my_error(ER_WRONG_ARGUMENTS, MYF(0), "SPATIAL INDEX");
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
}
|
||||
@@ -821,17 +822,15 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
#ifdef HAVE_RTREE_KEYS
|
||||
if ((key_info->key_parts & 1) == 1)
|
||||
{
|
||||
my_printf_error(ER_WRONG_ARGUMENTS,
|
||||
ER(ER_WRONG_ARGUMENTS),MYF(0),"RTREE INDEX");
|
||||
my_error(ER_WRONG_ARGUMENTS, MYF(0), "RTREE INDEX");
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
/* TODO: To be deleted */
|
||||
my_printf_error(ER_NOT_SUPPORTED_YET, ER(ER_NOT_SUPPORTED_YET),
|
||||
MYF(0), "RTREE INDEX");
|
||||
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "RTREE INDEX");
|
||||
DBUG_RETURN(-1);
|
||||
#else
|
||||
my_printf_error(ER_FEATURE_DISABLED,ER(ER_FEATURE_DISABLED),MYF(0),
|
||||
sym_group_rtree.name, sym_group_rtree.needed_define);
|
||||
my_error(ER_FEATURE_DISABLED, MYF(0),
|
||||
sym_group_rtree.name, sym_group_rtree.needed_define);
|
||||
DBUG_RETURN(-1);
|
||||
#endif
|
||||
}
|
||||
@@ -849,9 +848,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
field++;
|
||||
if (!sql_field)
|
||||
{
|
||||
my_printf_error(ER_KEY_COLUMN_DOES_NOT_EXITS,
|
||||
ER(ER_KEY_COLUMN_DOES_NOT_EXITS),MYF(0),
|
||||
column->field_name);
|
||||
my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
/* for fulltext keys keyseg length is 1 for blobs (it's ignored in
|
||||
@@ -869,8 +866,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
sql_field->charset->mbminlen > 1 || // ucs2 doesn't work yet
|
||||
(ft_key_charset && sql_field->charset != ft_key_charset))
|
||||
{
|
||||
my_printf_error(ER_BAD_FT_COLUMN,ER(ER_BAD_FT_COLUMN),MYF(0),
|
||||
column->field_name);
|
||||
my_error(ER_BAD_FT_COLUMN, MYF(0), column->field_name);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
ft_key_charset=sql_field->charset;
|
||||
@@ -891,15 +887,12 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
{
|
||||
if (!(file->table_flags() & HA_CAN_INDEX_BLOBS))
|
||||
{
|
||||
my_printf_error(ER_BLOB_USED_AS_KEY,ER(ER_BLOB_USED_AS_KEY),MYF(0),
|
||||
column->field_name);
|
||||
my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->field_name);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
if (!column->length)
|
||||
{
|
||||
my_printf_error(ER_BLOB_KEY_WITHOUT_LENGTH,
|
||||
ER(ER_BLOB_KEY_WITHOUT_LENGTH),MYF(0),
|
||||
column->field_name);
|
||||
my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
}
|
||||
@@ -928,13 +921,13 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
key_info->flags|= HA_NULL_PART_KEY;
|
||||
if (!(file->table_flags() & HA_NULL_IN_KEY))
|
||||
{
|
||||
my_printf_error(ER_NULL_COLUMN_IN_INDEX,ER(ER_NULL_COLUMN_IN_INDEX),
|
||||
MYF(0),column->field_name);
|
||||
my_error(ER_NULL_COLUMN_IN_INDEX, MYF(0), column->field_name);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
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 +973,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))
|
||||
@@ -988,8 +981,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
}
|
||||
else if (length == 0)
|
||||
{
|
||||
my_printf_error(ER_WRONG_KEY_COLUMN, ER(ER_WRONG_KEY_COLUMN), MYF(0),
|
||||
column->field_name);
|
||||
my_error(ER_WRONG_KEY_COLUMN, MYF(0), column->field_name);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
if (length > file->max_key_part_length())
|
||||
@@ -1033,7 +1025,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 +1037,7 @@ 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_error(ER_DUP_KEYNAME, MYF(0), key_name);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
key_info->name=(char*) key_name;
|
||||
@@ -1069,12 +1062,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 +1101,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 +1154,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_error(ER_ILLEGAL_HA, MYF(0), table_name);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1186,7 +1180,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 +1203,10 @@ 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);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (wait_if_global_read_lock(thd, 0, 1))
|
||||
DBUG_RETURN(error);
|
||||
@@ -1224,10 +1218,10 @@ 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_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
@@ -1253,10 +1247,10 @@ 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_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
@@ -1292,7 +1286,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);
|
||||
@@ -1564,7 +1558,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;
|
||||
@@ -1741,20 +1735,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;
|
||||
@@ -1772,7 +1766,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)
|
||||
@@ -1784,9 +1778,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)
|
||||
@@ -1812,7 +1803,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;
|
||||
@@ -1856,9 +1847,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);
|
||||
@@ -1959,16 +1948,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,
|
||||
@@ -1977,7 +1966,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,
|
||||
@@ -1987,7 +1976,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,
|
||||
@@ -1997,7 +1986,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,
|
||||
@@ -2015,11 +2004,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,7 +2021,7 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables,
|
||||
{
|
||||
pthread_mutex_unlock(&LOCK_global_system_variables);
|
||||
my_error(ER_UNKNOWN_KEY_CACHE, MYF(0), key_cache_name->str);
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
pthread_mutex_unlock(&LOCK_global_system_variables);
|
||||
check_opt.key_cache= key_cache;
|
||||
@@ -2090,11 +2079,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,
|
||||
@@ -2114,13 +2103,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];
|
||||
@@ -2128,7 +2117,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,7 +2131,7 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table,
|
||||
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);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
bzero((gptr)&src_tables_list, sizeof(src_tables_list));
|
||||
@@ -2228,7 +2218,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:
|
||||
@@ -2239,7 +2229,7 @@ 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);
|
||||
@@ -2252,7 +2242,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;
|
||||
@@ -2267,7 +2257,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;
|
||||
@@ -2558,13 +2548,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;
|
||||
@@ -2593,7 +2583,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)
|
||||
@@ -2624,8 +2614,8 @@ 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_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_name_buff);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2636,8 +2626,8 @@ 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_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2677,7 +2667,7 @@ 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_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_name);
|
||||
error= -1;
|
||||
}
|
||||
else
|
||||
@@ -2821,8 +2811,8 @@ 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_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0), def->change);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
def->def=alter->def; // Use new default
|
||||
alter_it.remove();
|
||||
@@ -2835,8 +2825,8 @@ 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_error(ER_BAD_FIELD_ERROR, MYF(0), def->change, table_name);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (!def->after)
|
||||
create_list.push_back(def);
|
||||
@@ -2853,22 +2843,23 @@ 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_error(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_error(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,21 +2948,21 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_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);
|
||||
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_error(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_error(ER_CANT_DROP_FIELD_OR_KEY, MYF(0),
|
||||
alter_info->alter_list.head()->name);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -3174,7 +3165,7 @@ 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_error(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;
|
||||
@@ -3312,10 +3303,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -3501,8 +3492,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;
|
||||
@@ -3524,7 +3515,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;
|
||||
@@ -3538,7 +3529,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)
|
||||
{
|
||||
@@ -3557,7 +3548,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
|
||||
{
|
||||
@@ -3619,11 +3610,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