diff options
author | unknown <monty@donna.mysql.com> | 2000-09-12 03:02:33 +0300 |
---|---|---|
committer | unknown <monty@donna.mysql.com> | 2000-09-12 03:02:33 +0300 |
commit | fe4cccd6a43496395ec52e9043cd4350e5eac69d (patch) | |
tree | 051686baf31e5363765879f2437ada3abea6b71b /sql/sql_table.cc | |
parent | 1dc6a46936306fbccaf19275e6f9dc4acc1e48a1 (diff) | |
download | mariadb-git-fe4cccd6a43496395ec52e9043cd4350e5eac69d.tar.gz |
Update to new root alloc, OPTIMIZE TABLE and some other changes
Docs/manual.texi:
Added chapter for binary log, updated the changelog, linux section, OPTIMIZE TABLE...
client/mysqladmin.c:
Fixed bug with pid-file handling.
client/mysqldump.c:
Version change
configure.in:
Version change
include/Makefile.am:
Fix for SCO to get sched.h removed.
include/global.h:
Increased MY_NFILE; Added thread_safe_increment
include/my_sys.h:
Better root_alloc
include/mysql.h:
Better root_alloc
include/mysys_err.h:
Fix for PREAD/PWRITE on windows
libmysql/libmysql.c:
Better root_alloc
myisam/mi_locking.c:
Fix for PREAD/PWRITE on windows
myisam/mi_static.c:
Fix for PREAD/PWRITE on windows
mysys/default.c:
Better root_alloc
mysys/errors.c:
Fix for PREAD/PWRITE on windows
mysys/my_alloc.c:
Better root_alloc
mysys/my_create.c:
Fix for PREAD/PWRITE on windows
mysys/my_fopen.c:
Fix for PREAD/PWRITE on windows
mysys/my_open.c:
Fix for PREAD/PWRITE on windows
mysys/my_pread.c:
Fix for PREAD/PWRITE on windows
mysys/tree.c:
Better root_alloc
readline/bind.c:
Removed compiler warning
readline/isearch.c:
Removed compiler warning
scripts/safe_mysqld.sh:
Allow use of MYSQL_UNIX_PORT and MYSQL_TCP_PORT
sql-bench/crash-me.sh:
Version change
sql-bench/limits/mysql-3.23.cfg:
Update to latest MySQL version
sql/filesort.cc:
Added more statistics
sql/ha_berkeley.h:
Fixed bug with ORDER BY
sql/ha_myisam.cc:
Added OPTIMIZE TABLE and cleaned up the repair code
sql/ha_myisam.h:
Added OPTIMIZE TABLE and cleaned up the repair code
sql/handler.cc:
Added OPTIMIZE TABLE and cleaned up the repair code
sql/handler.h:
Added OPTIMIZE TABLE and cleaned up the repair code
sql/item_func.cc:
Fixed comment
sql/item_timefunc.cc:
Fixed possible month bug
sql/mini_client.cc:
Use of new root_alloc
sql/mysql_priv.h:
Added OPTIMIZE TABLE and cleaned up the repair code
sql/mysqld.cc:
Added more statistics
sql/opt_range.cc:
Use of new root_alloc
sql/slave.cc:
Use of new root_alloc
sql/sql_acl.cc:
Use of new root_alloc
sql/sql_class.cc:
Use of new root_alloc
sql/sql_parse.cc:
Use of new root_alloc
sql/sql_select.cc:
Added more statistics
sql/sql_table.cc:
Added OPTIMIZE TABLE and cleaned up the repair code
sql/sql_udf.cc:
Use of new root_alloc
sql/sql_yacc.yy:
Fixed that OPTIMIZE TABLE can take many tables as arguments
sql/table.cc:
Use of new root_alloc
sql/thr_malloc.cc:
Use of new root_alloc
support-files/mysql.server.sh:
Removed usage of AWK
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 255 |
1 files changed, 66 insertions, 189 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ce434fd43d7..a3da4daa9f4 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -718,105 +718,19 @@ bool close_cached_table(THD *thd,TABLE *table) } -int mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) -{ - TABLE_LIST *table; - List<Item> field_list; - Item* item; - String* packet = &thd->packet; - - DBUG_ENTER("mysql_repair_table"); - - field_list.push_back(item = new Item_empty_string("Table", NAME_LEN*2)); - item->maybe_null = 1; - field_list.push_back(item = new Item_empty_string("Op", 10)); - item->maybe_null = 1; - field_list.push_back(item = new Item_empty_string("Msg_type", 10)); - item->maybe_null = 1; - field_list.push_back(item = new Item_empty_string("Msg_text", 255)); - item->maybe_null = 1; - if (send_fields(thd, field_list, 1)) - DBUG_RETURN(-1); - - - for (table = tables; table; table = table->next) - { - char table_name[NAME_LEN*2+2]; - char* db = (table->db) ? table->db : thd->db; - strxmov(table_name,db ? db : "",".",table->name,NullS); - - table->table = open_ltable(thd, table, TL_WRITE); - packet->length(0); - - if (!table->table) - { - const char *err_msg; - net_store_data(packet, table_name); - net_store_data(packet, "repair"); - net_store_data(packet, "error"); - if (!(err_msg=thd->net.last_error)) - err_msg=ER(ER_CHECK_NO_SUCH_TABLE); - net_store_data(packet, err_msg); - thd->net.last_error[0]=0; - if (my_net_write(&thd->net, (char*) thd->packet.ptr(), - packet->length())) - goto err; - continue; - } - - int repair_code = table->table->file->repair(thd, check_opt); - packet->length(0); - net_store_data(packet, table_name); - net_store_data(packet, "repair"); - - switch(repair_code) { - case HA_REPAIR_NOT_IMPLEMENTED: - net_store_data(packet, "error"); - net_store_data(packet, ER(ER_CHECK_NOT_IMPLEMENTED)); - break; - - case HA_REPAIR_OK: - net_store_data(packet, "status"); - net_store_data(packet, "OK"); - break; - - case HA_REPAIR_FAILED: - net_store_data(packet, "status"); - net_store_data(packet, "Not repaired"); - break; - - default: - net_store_data(packet, "Unknown - internal error during repair"); - break; - } - close_thread_tables(thd); - if (my_net_write(&thd->net, (char*) packet->ptr(), - packet->length())) - goto err; - } - - close_thread_tables(thd); - send_eof(&thd->net); - DBUG_RETURN(0); - err: - close_thread_tables(thd); - DBUG_RETURN(-1); -} - -int mysql_optimize_table(THD* thd, TABLE_LIST* tables) -{ - net_printf(&thd->net, ER_PARSE_ERROR, "Sorry; This doesn't work yet", "", - 0); - return 1; -} - -int mysql_analyze_table(THD* thd, TABLE_LIST* tables) +static int mysql_admin_table(THD* thd, TABLE_LIST* tables, + HA_CHECK_OPT* check_opt, + thr_lock_type lock_type, + bool open_for_modify, + const char *operator_name, + int (handler::*operator_func) + (THD *, HA_CHECK_OPT *)) { TABLE_LIST *table; List<Item> field_list; Item* item; String* packet = &thd->packet; - DBUG_ENTER("mysql_analyze_table"); + DBUG_ENTER("mysql_admin_table"); field_list.push_back(item = new Item_empty_string("Table", NAME_LEN*2)); item->maybe_null = 1; @@ -829,21 +743,20 @@ int mysql_analyze_table(THD* thd, TABLE_LIST* tables) if (send_fields(thd, field_list, 1)) DBUG_RETURN(-1); - for (table = tables; table; table = table->next) { char table_name[NAME_LEN*2+2]; char* db = (table->db) ? table->db : thd->db; strxmov(table_name,db ? db : "",".",table->name,NullS); - table->table = open_ltable(thd, table, TL_READ_NO_INSERT); + table->table = open_ltable(thd, table, lock_type); packet->length(0); if (!table->table) { const char *err_msg; net_store_data(packet, table_name); - net_store_data(packet, "analyze"); + net_store_data(packet, operator_name); net_store_data(packet, "error"); if (!(err_msg=thd->net.last_error)) err_msg=ER(ER_CHECK_NO_SUCH_TABLE); @@ -854,126 +767,53 @@ int mysql_analyze_table(THD* thd, TABLE_LIST* tables) goto err; continue; } - if (table->table->db_stat & HA_READ_ONLY) + if ((table->table->db_stat & HA_READ_ONLY) && open_for_modify) { net_store_data(packet, table_name); - net_store_data(packet, "analyze"); + net_store_data(packet, operator_name); net_store_data(packet, "error"); net_store_data(packet, ER(ER_OPEN_AS_READONLY)); + close_thread_tables(thd); if (my_net_write(&thd->net, (char*) thd->packet.ptr(), packet->length())) goto err; continue; } - int analyze_code = table->table->file->analyze(thd); + int result_code = (table->table->file->*operator_func)(thd, check_opt); packet->length(0); net_store_data(packet, table_name); - net_store_data(packet, "analyze"); + net_store_data(packet, operator_name); - switch(analyze_code) { - case HA_ANALYZE_NOT_IMPLEMENTED: + switch (result_code) { + case HA_ADMIN_NOT_IMPLEMENTED: net_store_data(packet, "error"); net_store_data(packet, ER(ER_CHECK_NOT_IMPLEMENTED)); break; - case HA_ANALYZE_OK: + case HA_ADMIN_OK: net_store_data(packet, "status"); net_store_data(packet, "OK"); break; - default: - net_store_data(packet, "Unknown - internal error during analyze"); - break; - } - close_thread_tables(thd); - if (my_net_write(&thd->net, (char*) packet->ptr(), - packet->length())) - goto err; - } - - close_thread_tables(thd); - send_eof(&thd->net); - DBUG_RETURN(0); - err: - close_thread_tables(thd); - DBUG_RETURN(-1); -} - -int mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt) -{ - TABLE_LIST *table; - List<Item> field_list; - Item* item; - String* packet = &thd->packet; - - DBUG_ENTER("mysql_check_table"); - - field_list.push_back(item = new Item_empty_string("Table", NAME_LEN*2)); - item->maybe_null = 1; - field_list.push_back(item = new Item_empty_string("Op", 10)); - item->maybe_null = 1; - field_list.push_back(item = new Item_empty_string("Msg_type", 10)); - item->maybe_null = 1; - field_list.push_back(item = new Item_empty_string("Msg_text", 255)); - item->maybe_null = 1; - if (send_fields(thd, field_list, 1)) - DBUG_RETURN(-1); - - - for (table = tables; table; table = table->next) - { - char table_name[NAME_LEN*2+2]; - char* db = (table->db) ? table->db : thd->db; - strxmov(table_name,db ? db : "",".",table->name,NullS); - - table->table = open_ltable(thd, table, TL_READ_NO_INSERT); - packet->length(0); - - if (!table->table) - { - const char *err_msg; - net_store_data(packet, table_name); - net_store_data(packet, "check"); - net_store_data(packet, "error"); - if (!(err_msg=thd->net.last_error)) - err_msg=ER(ER_CHECK_NO_SUCH_TABLE); - net_store_data(packet, err_msg); - thd->net.last_error[0]=0; - if (my_net_write(&thd->net, (char*) thd->packet.ptr(), - packet->length())) - goto err; - continue; - } - - int check_code = table->table->file->check(thd, check_opt); - packet->length(0); - net_store_data(packet, table_name); - net_store_data(packet, "check"); - - switch(check_code) { - case HA_CHECK_NOT_IMPLEMENTED: - net_store_data(packet, "error"); - net_store_data(packet, ER(ER_CHECK_NOT_IMPLEMENTED)); - break; - - case HA_CHECK_OK: + case HA_ADMIN_FAILED: net_store_data(packet, "status"); - net_store_data(packet, "OK"); + net_store_data(packet, "Operation failed"); break; - case HA_CHECK_ALREADY_CHECKED: + case HA_ADMIN_ALREADY_DONE: net_store_data(packet, "status"); - net_store_data(packet, "Not checked"); + net_store_data(packet, "Table is already up to date"); break; - case HA_CHECK_CORRUPT: - net_store_data(packet, "status"); + case HA_ADMIN_CORRUPT: + net_store_data(packet, "error"); net_store_data(packet, "Corrupt"); break; - default: - net_store_data(packet, "Unknown - internal error during check"); + default: // Probably HA_ADMIN_INTERNAL_ERROR + net_store_data(packet, "error"); + net_store_data(packet, "Unknown - internal error during operation"); break; } close_thread_tables(thd); @@ -982,15 +822,52 @@ int mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt) goto err; } - close_thread_tables(thd); send_eof(&thd->net); DBUG_RETURN(0); err: - close_thread_tables(thd); + close_thread_tables(thd); // Shouldn't be needed DBUG_RETURN(-1); } +int 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, + TL_WRITE, 1, + "repair", + &handler::repair)); +} + +int 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, + TL_WRITE, 1, + "optimize", + &handler::optimize)); +} + + +int mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) +{ + DBUG_ENTER("mysql_analyze_table"); + DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, + TL_READ_NO_INSERT, 1, + "analyze", + &handler::analyze)); +} + + +int mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt) +{ + DBUG_ENTER("mysql_check_table"); + DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, + TL_READ_NO_INSERT, 0, + "check", + &handler::check)); +} + int mysql_alter_table(THD *thd,char *new_db, char *new_name, HA_CREATE_INFO *create_info, |