summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2004-11-21 10:12:11 +0200
committerunknown <bell@sanja.is.com.ua>2004-11-21 10:12:11 +0200
commitb3c99639710165e0c4df77602c399623dabdf187 (patch)
tree72959949463882de03bcb3e5a6905ba6382fe180 /sql/sql_table.cc
parentdc8acb6fdb6d63563d0ef29782ebf3aef6eebb1a (diff)
parent4f553314edfc04e2551fed2dc94d72f060b722e2 (diff)
downloadmariadb-git-b3c99639710165e0c4df77602c399623dabdf187.tar.gz
merge
sql/handler.h: Auto merged sql/sql_table.cc: Auto merged sql/sql_view.cc: Auto merged
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc66
1 files changed, 54 insertions, 12 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 8ff2fa5faa8..a12a08d1170 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1748,12 +1748,15 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
int (*prepare_func)(THD *, TABLE_LIST *,
HA_CHECK_OPT *),
int (handler::*operator_func)
- (THD *, HA_CHECK_OPT *))
+ (THD *, HA_CHECK_OPT *),
+ int (view_operator_func)
+ (THD *, TABLE_LIST*))
{
- TABLE_LIST *table;
+ TABLE_LIST *table, *next_global_table;
List<Item> field_list;
Item *item;
Protocol *protocol= thd->protocol;
+ int result_code;
DBUG_ENTER("mysql_admin_table");
field_list.push_back(item = new Item_empty_string("Table", NAME_LEN*2));
@@ -1777,7 +1780,18 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
strxmov(table_name,db ? db : "",".",table->real_name,NullS);
thd->open_options|= extra_open_options;
- table->table = open_ltable(thd, table, lock_type);
+ table->lock_type= lock_type;
+ /* open only one table from local list of command */
+ next_global_table= table->next_global;
+ table->next_global= 0;
+ open_and_lock_tables(thd, table);
+ table->next_global= next_global_table;
+ /* if view are unsupported */
+ if (table->view && !view_operator_func)
+ {
+ result_code= HA_ADMIN_NOT_IMPLEMENTED;
+ goto send_result;
+ }
thd->open_options&= ~extra_open_options;
if (prepare_func)
@@ -1793,8 +1807,13 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
}
}
+ /*
+ for this command used only temporary table method (without
+ filling tables), so if opening succeed, table will be opened
+ */
if (!table->table)
{
+ char buf[ERRMSGSIZE+25];
const char *err_msg;
protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info);
@@ -1802,12 +1821,26 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
protocol->store("error",5, system_charset_info);
if (!(err_msg=thd->net.last_error))
err_msg=ER(ER_CHECK_NO_SUCH_TABLE);
+ /* if it was a view will check md5 sum */
+ if (table->view &&
+ view_checksum(thd, table) == HA_ADMIN_WRONG_CHECKSUM)
+ {
+ strxmov(buf, "View checksum failed and ", err_msg, NullS);
+ err_msg= (const char *)buf;
+ }
protocol->store(err_msg, system_charset_info);
thd->clear_error();
if (protocol->write())
goto err;
continue;
}
+
+ if (table->view)
+ {
+ result_code= (*view_operator_func)(thd, table);
+ goto send_result;
+ }
+
table->table->pos_in_table_list= table;
if ((table->table->db_stat & HA_READ_ONLY) && open_for_modify)
{
@@ -1846,7 +1879,10 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
open_for_modify=0;
}
- int result_code = (table->table->file->*operator_func)(thd, check_opt);
+ result_code = (table->table->file->*operator_func)(thd, check_opt);
+
+send_result:
+
thd->clear_error(); // these errors shouldn't get client
protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info);
@@ -1922,6 +1958,12 @@ send_result_message:
table->next_global= save_next_global;
goto send_result_message;
}
+ case HA_ADMIN_WRONG_CHECKSUM:
+ {
+ protocol->store("note", 4, system_charset_info);
+ protocol->store("Checksum error", 14, system_charset_info);
+ break;
+ }
default: // Probably HA_ADMIN_INTERNAL_ERROR
protocol->store("error", 5, system_charset_info);
@@ -1962,7 +2004,7 @@ bool mysql_backup_table(THD* thd, TABLE_LIST* table_list)
DBUG_ENTER("mysql_backup_table");
DBUG_RETURN(mysql_admin_table(thd, table_list, 0,
"backup", TL_READ, 0, 0, 0,
- &handler::backup));
+ &handler::backup, 0));
}
@@ -1972,7 +2014,7 @@ bool mysql_restore_table(THD* thd, TABLE_LIST* table_list)
DBUG_RETURN(mysql_admin_table(thd, table_list, 0,
"restore", TL_WRITE, 1, 0,
&prepare_for_restore,
- &handler::restore));
+ &handler::restore, 0));
}
@@ -1982,7 +2024,7 @@ bool mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
"repair", TL_WRITE, 1, HA_OPEN_FOR_REPAIR,
&prepare_for_repair,
- &handler::repair));
+ &handler::repair, 0));
}
@@ -1991,7 +2033,7 @@ 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,
"optimize", TL_WRITE, 1,0,0,
- &handler::optimize));
+ &handler::optimize, 0));
}
@@ -2027,7 +2069,7 @@ bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables,
check_opt.key_cache= key_cache;
DBUG_RETURN(mysql_admin_table(thd, tables, &check_opt,
"assign_to_keycache", TL_READ_NO_INSERT, 0,
- 0, 0, &handler::assign_to_keycache));
+ 0, 0, &handler::assign_to_keycache, 0));
}
@@ -2088,7 +2130,7 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables)
DBUG_ENTER("mysql_preload_keys");
DBUG_RETURN(mysql_admin_table(thd, tables, 0,
"preload_keys", TL_READ, 0, 0, 0,
- &handler::preload_keys));
+ &handler::preload_keys, 0));
}
@@ -2253,7 +2295,7 @@ bool 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,
"analyze", lock_type, 1,0,0,
- &handler::analyze));
+ &handler::analyze, 0));
}
@@ -2269,7 +2311,7 @@ bool mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt)
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
"check", lock_type,
0, HA_OPEN_FOR_REPAIR, 0,
- &handler::check));
+ &handler::check, &view_checksum));
}