summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2003-08-21 16:15:06 +0200
committerunknown <serg@serg.mylan>2003-08-21 16:15:06 +0200
commite103da7acc6f3563a2f7207e59c34b9d9ff64295 (patch)
tree5d947ccbb3381780780dbd2338b587ce9cbe0855 /sql/sql_table.cc
parent1e4b664311fd561ef459db689fd9f0c0abe8ffad (diff)
downloadmariadb-git-e103da7acc6f3563a2f7207e59c34b9d9ff64295.tar.gz
fixed a crash on COMPRESS() and other zlib-dependent functions when compiled w/o zlib
moved them all from different places to item_strfunc.{h,cc} checksum table command Com_xxx status variables updated sql/item_create.cc: fixed a crash on COMPRESS() and other zlib-dependent functions when compiled w/o zlib moved them all from different places to item_strfunc.{h,cc} sql/item_func.cc: fixed a crash on COMPRESS() and other zlib-dependent functions when compiled w/o zlib moved them all from different places to item_strfunc.{h,cc} sql/item_func.h: fixed a crash on COMPRESS() and other zlib-dependent functions when compiled w/o zlib moved them all from different places to item_strfunc.{h,cc} sql/item_geofunc.h: fixed a crash on COMPRESS() and other zlib-dependent functions when compiled w/o zlib moved them all from different places to item_strfunc.{h,cc} sql/item_strfunc.cc: fixed a crash on COMPRESS() and other zlib-dependent functions when compiled w/o zlib moved them all from different places to item_strfunc.{h,cc} sql/item_strfunc.h: fixed a crash on COMPRESS() and other zlib-dependent functions when compiled w/o zlib moved them all from different places to item_strfunc.{h,cc} sql/mysql_priv.h: checksum table command sql/mysqld.cc: Com_xxx updated sql/sql_lex.h: checksum table command sql/sql_parse.cc: checksum table command sql/sql_table.cc: checksum table command sql/sql_yacc.yy: checksum table command
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc66
1 files changed, 65 insertions, 1 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 7cb8dfaae0d..d63a15c13a8 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2555,7 +2555,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
delete_count++;
}
else
- found_count++;
+ found_count++;
}
end_read_record(&info);
free_io_cache(from);
@@ -2587,3 +2587,67 @@ copy_data_between_tables(TABLE *from,TABLE *to,
*deleted=delete_count;
DBUG_RETURN(error > 0 ? -1 : 0);
}
+
+int mysql_checksum_table(THD* thd, TABLE_LIST* tables)
+{
+ TABLE_LIST *table;
+ List<Item> field_list;
+ Item *item;
+ Protocol *protocol= thd->protocol;
+ DBUG_ENTER("mysql_admin_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_int("Checksum",(longlong) 1,21));
+ item->maybe_null= 1;
+ if (protocol->send_fields(&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;
+ bool fatal_error=0;
+ strxmov(table_name,db ? db : "",".",table->real_name,NullS);
+
+ table->table = open_ltable(thd, table, TL_READ_NO_INSERT);
+#ifdef EMBEDDED_LIBRARY
+ thd->net.last_errno= 0; // these errors shouldn't get client
+#endif
+
+ protocol->prepare_for_resend();
+ protocol->store(table_name, system_charset_info);
+
+ if (!table->table)
+ {
+ protocol->store_null();
+ thd->net.last_error[0]=0;
+ }
+ else
+ {
+ table->table->pos_in_table_list= table;
+
+ if (table->table->file->table_flags() & HA_HAS_CHECKSUM)
+ protocol->store((ulonglong)table->table->file->checksum());
+ else
+ protocol->store_null();
+#ifdef EMBEDDED_LIBRARY
+ thd->net.last_errno= 0; // these errors shouldn't get client
+#endif
+
+ close_thread_tables(thd);
+ table->table=0; // For query cache
+ }
+ if (protocol->write())
+ goto err;
+ }
+
+ send_eof(thd);
+ DBUG_RETURN(0);
+ err:
+ close_thread_tables(thd); // Shouldn't be needed
+ if (table)
+ table->table=0;
+ DBUG_RETURN(-1);
+}
+