Commit e103da7a authored by unknown's avatar unknown

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
parent 1e4b6643
...@@ -107,14 +107,6 @@ Item *create_func_cot(Item* a) ...@@ -107,14 +107,6 @@ Item *create_func_cot(Item* a)
new Item_func_tan(a)); new Item_func_tan(a));
} }
#ifdef HAVE_COMPRESS
Item *create_func_crc32(Item* a)
{
return new Item_func_crc32(a);
}
#endif
Item *create_func_date_format(Item* a,Item *b) Item *create_func_date_format(Item* a,Item *b)
{ {
return new Item_func_date_format(a,b,0); return new Item_func_date_format(a,b,0);
...@@ -666,13 +658,10 @@ Item *create_func_point(Item *a, Item *b) ...@@ -666,13 +658,10 @@ Item *create_func_point(Item *a, Item *b)
return new Item_func_point(a, b); return new Item_func_point(a, b);
} }
#if !defined(HAVE_COMPRESS) Item *create_func_crc32(Item* a)
{
Item *create_func_compress (Item*a __attribute__((unused))){return 0;} return new Item_func_crc32(a);
Item *create_func_uncompress (Item*a __attribute__((unused))){return 0;} }
Item *create_func_uncompressed_length(Item*a __attribute__((unused))){return 0;}
#else
Item *create_func_compress(Item* a) Item *create_func_compress(Item* a)
{ {
...@@ -689,8 +678,6 @@ Item *create_func_uncompressed_length(Item* a) ...@@ -689,8 +678,6 @@ Item *create_func_uncompressed_length(Item* a)
return new Item_func_uncompressed_length(a); return new Item_func_uncompressed_length(a);
} }
#endif
Item *create_func_datediff(Item *a, Item *b) Item *create_func_datediff(Item *a, Item *b)
{ {
return new Item_func_minus(new Item_func_to_days(a), return new Item_func_minus(new Item_func_to_days(a),
......
...@@ -27,9 +27,6 @@ ...@@ -27,9 +27,6 @@
#include <hash.h> #include <hash.h>
#include <time.h> #include <time.h>
#include <ft_global.h> #include <ft_global.h>
#ifdef HAVE_COMPRESS
#include <zlib.h>
#endif
static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fname) static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fname)
{ {
...@@ -1039,35 +1036,6 @@ longlong Item_func_min_max::val_int() ...@@ -1039,35 +1036,6 @@ longlong Item_func_min_max::val_int()
return value; return value;
} }
#ifdef HAVE_COMPRESS
longlong Item_func_crc32::val_int()
{
String *res=args[0]->val_str(&value);
if (!res)
{
null_value=1;
return 0; /* purecov: inspected */
}
null_value=0;
return (longlong) crc32(0L, (Bytef*)res->ptr(), res->length());
}
longlong Item_func_uncompressed_length::val_int()
{
String *res= args[0]->val_str(&value);
if (!res)
{
null_value=1;
return 0; /* purecov: inspected */
}
null_value=0;
if (res->is_empty()) return 0;
return uint4korr(res->c_ptr()) & 0x3FFFFFFF;
}
#endif /* HAVE_COMPRESS */
longlong Item_func_length::val_int() longlong Item_func_length::val_int()
{ {
String *res=args[0]->val_str(&value); String *res=args[0]->val_str(&value);
......
...@@ -553,27 +553,6 @@ class Item_func_max :public Item_func_min_max ...@@ -553,27 +553,6 @@ class Item_func_max :public Item_func_min_max
}; };
#ifdef HAVE_COMPRESS
class Item_func_crc32 :public Item_int_func
{
String value;
public:
Item_func_crc32(Item *a) :Item_int_func(a) {}
longlong val_int();
const char *func_name() const { return "crc32"; }
void fix_length_and_dec() { max_length=10; }
};
class Item_func_uncompressed_length : public Item_int_func
{
String value;
public:
Item_func_uncompressed_length(Item *a):Item_int_func(a){}
longlong val_int();
const char *func_name() const{return "uncompressed_length";}
void fix_length_and_dec() { max_length=10; }
};
#endif
class Item_func_length :public Item_int_func class Item_func_length :public Item_int_func
{ {
String value; String value;
......
...@@ -167,30 +167,6 @@ class Item_func_spatial_collection: public Item_str_func ...@@ -167,30 +167,6 @@ class Item_func_spatial_collection: public Item_str_func
const char *func_name() const { return "multipoint"; } const char *func_name() const { return "multipoint"; }
}; };
#ifdef HAVE_COMPRESS
class Item_func_compress: public Item_str_func
{
String buffer;
public:
Item_func_compress(Item *a):Item_str_func(a){}
String *val_str(String *);
void fix_length_and_dec(){max_length= (args[0]->max_length*120)/100+12;}
const char *func_name() const{return "compress";}
};
class Item_func_uncompress: public Item_str_func
{
String buffer;
public:
Item_func_uncompress(Item *a): Item_str_func(a){}
String *val_str(String *);
void fix_length_and_dec(){max_length= MAX_BLOB_WIDTH;}
const char *func_name() const{return "uncompress";}
};
#endif
/* /*
Spatial relations Spatial relations
*/ */
......
...@@ -2548,9 +2548,47 @@ String *Item_func_quote::val_str(String *str) ...@@ -2548,9 +2548,47 @@ String *Item_func_quote::val_str(String *str)
return 0; return 0;
} }
longlong Item_func_uncompressed_length::val_int()
{
String *res= args[0]->val_str(&value);
if (!res)
{
null_value=1;
return 0; /* purecov: inspected */
}
null_value=0;
if (res->is_empty()) return 0;
return uint4korr(res->c_ptr()) & 0x3FFFFFFF;
}
#ifdef HAVE_COMPRESS #ifdef HAVE_COMPRESS
#include "zlib.h" #include "zlib.h"
longlong Item_func_crc32::val_int()
{
String *res=args[0]->val_str(&value);
if (!res)
{
null_value=1;
return 0; /* purecov: inspected */
}
null_value=0;
return (longlong) crc32(0L, (Bytef*)res->ptr(), res->length());
}
longlong Item_func_uncompressed_length::val_int()
{
String *res= args[0]->val_str(&value);
if (!res)
{
null_value=1;
return 0; /* purecov: inspected */
}
null_value=0;
if (res->is_empty()) return 0;
return uint4korr(res->c_ptr()) & 0x3FFFFFFF;
}
String *Item_func_compress::val_str(String *str) String *Item_func_compress::val_str(String *str)
{ {
String *res= args[0]->val_str(str); String *res= args[0]->val_str(str);
...@@ -2634,5 +2672,4 @@ String *Item_func_uncompress::val_str(String *str) ...@@ -2634,5 +2672,4 @@ String *Item_func_uncompress::val_str(String *str)
null_value= 1; null_value= 1;
return 0; return 0;
} }
#endif #endif
...@@ -629,3 +629,50 @@ class Item_func_collation :public Item_str_func ...@@ -629,3 +629,50 @@ class Item_func_collation :public Item_str_func
collation.set(system_charset_info); collation.set(system_charset_info);
}; };
}; };
#ifdef HAVE_COMPRESS
#define ZLIB_DEPENDED_FUNCTION ;
#else
#define ZLIB_DEPENDED_FUNCTION { null_value=1; return 0; }
#endif
class Item_func_compress: public Item_str_func
{
String buffer;
public:
Item_func_compress(Item *a):Item_str_func(a){}
void fix_length_and_dec(){max_length= (args[0]->max_length*120)/100+12;}
const char *func_name() const{return "compress";}
String *val_str(String *) ZLIB_DEPENDED_FUNCTION
};
class Item_func_uncompress: public Item_str_func
{
String buffer;
public:
Item_func_uncompress(Item *a): Item_str_func(a){}
void fix_length_and_dec(){max_length= MAX_BLOB_WIDTH;}
const char *func_name() const{return "uncompress";}
String *val_str(String *) ZLIB_DEPENDED_FUNCTION
};
class Item_func_crc32 :public Item_int_func
{
String value;
public:
Item_func_crc32(Item *a) :Item_int_func(a) {}
const char *func_name() const { return "crc32"; }
void fix_length_and_dec() { max_length=10; }
longlong val_int() ZLIB_DEPENDED_FUNCTION
};
class Item_func_uncompressed_length : public Item_int_func
{
String value;
public:
Item_func_uncompressed_length(Item *a):Item_int_func(a){}
const char *func_name() const{return "uncompressed_length";}
void fix_length_and_dec() { max_length=10; }
longlong val_int();
};
...@@ -398,6 +398,7 @@ bool check_global_access(THD *thd, ulong want_access); ...@@ -398,6 +398,7 @@ bool check_global_access(THD *thd, ulong want_access);
int mysql_backup_table(THD* thd, TABLE_LIST* table_list); int mysql_backup_table(THD* thd, TABLE_LIST* table_list);
int mysql_restore_table(THD* thd, TABLE_LIST* table_list); int mysql_restore_table(THD* thd, TABLE_LIST* table_list);
int mysql_checksum_table(THD* thd, TABLE_LIST* table_list);
int mysql_check_table(THD* thd, TABLE_LIST* table_list, int mysql_check_table(THD* thd, TABLE_LIST* table_list,
HA_CHECK_OPT* check_opt); HA_CHECK_OPT* check_opt);
int mysql_repair_table(THD* thd, TABLE_LIST* table_list, int mysql_repair_table(THD* thd, TABLE_LIST* table_list,
......
...@@ -4383,14 +4383,15 @@ struct show_var_st status_vars[]= { ...@@ -4383,14 +4383,15 @@ struct show_var_st status_vars[]= {
{"Bytes_received", (char*) &bytes_received, SHOW_LONG}, {"Bytes_received", (char*) &bytes_received, SHOW_LONG},
{"Bytes_sent", (char*) &bytes_sent, SHOW_LONG}, {"Bytes_sent", (char*) &bytes_sent, SHOW_LONG},
{"Com_admin_commands", (char*) &com_other, SHOW_LONG}, {"Com_admin_commands", (char*) &com_other, SHOW_LONG},
{"Com_alter_table", (char*) (com_stat+(uint) SQLCOM_ALTER_TABLE),SHOW_LONG},
{"Com_alter_db", (char*) (com_stat+(uint) SQLCOM_ALTER_DB),SHOW_LONG}, {"Com_alter_db", (char*) (com_stat+(uint) SQLCOM_ALTER_DB),SHOW_LONG},
{"Com_alter_table", (char*) (com_stat+(uint) SQLCOM_ALTER_TABLE),SHOW_LONG},
{"Com_analyze", (char*) (com_stat+(uint) SQLCOM_ANALYZE),SHOW_LONG}, {"Com_analyze", (char*) (com_stat+(uint) SQLCOM_ANALYZE),SHOW_LONG},
{"Com_backup_table", (char*) (com_stat+(uint) SQLCOM_BACKUP_TABLE),SHOW_LONG}, {"Com_backup_table", (char*) (com_stat+(uint) SQLCOM_BACKUP_TABLE),SHOW_LONG},
{"Com_begin", (char*) (com_stat+(uint) SQLCOM_BEGIN),SHOW_LONG}, {"Com_begin", (char*) (com_stat+(uint) SQLCOM_BEGIN),SHOW_LONG},
{"Com_change_db", (char*) (com_stat+(uint) SQLCOM_CHANGE_DB),SHOW_LONG}, {"Com_change_db", (char*) (com_stat+(uint) SQLCOM_CHANGE_DB),SHOW_LONG},
{"Com_change_master", (char*) (com_stat+(uint) SQLCOM_CHANGE_MASTER),SHOW_LONG}, {"Com_change_master", (char*) (com_stat+(uint) SQLCOM_CHANGE_MASTER),SHOW_LONG},
{"Com_check", (char*) (com_stat+(uint) SQLCOM_CHECK),SHOW_LONG}, {"Com_check", (char*) (com_stat+(uint) SQLCOM_CHECK),SHOW_LONG},
{"Com_checksum", (char*) (com_stat+(uint) SQLCOM_CHECKSUM),SHOW_LONG},
{"Com_commit", (char*) (com_stat+(uint) SQLCOM_COMMIT),SHOW_LONG}, {"Com_commit", (char*) (com_stat+(uint) SQLCOM_COMMIT),SHOW_LONG},
{"Com_create_db", (char*) (com_stat+(uint) SQLCOM_CREATE_DB),SHOW_LONG}, {"Com_create_db", (char*) (com_stat+(uint) SQLCOM_CREATE_DB),SHOW_LONG},
{"Com_create_function", (char*) (com_stat+(uint) SQLCOM_CREATE_FUNCTION),SHOW_LONG}, {"Com_create_function", (char*) (com_stat+(uint) SQLCOM_CREATE_FUNCTION),SHOW_LONG},
...@@ -4403,6 +4404,7 @@ struct show_var_st status_vars[]= { ...@@ -4403,6 +4404,7 @@ struct show_var_st status_vars[]= {
{"Com_drop_function", (char*) (com_stat+(uint) SQLCOM_DROP_FUNCTION),SHOW_LONG}, {"Com_drop_function", (char*) (com_stat+(uint) SQLCOM_DROP_FUNCTION),SHOW_LONG},
{"Com_drop_index", (char*) (com_stat+(uint) SQLCOM_DROP_INDEX),SHOW_LONG}, {"Com_drop_index", (char*) (com_stat+(uint) SQLCOM_DROP_INDEX),SHOW_LONG},
{"Com_drop_table", (char*) (com_stat+(uint) SQLCOM_DROP_TABLE),SHOW_LONG}, {"Com_drop_table", (char*) (com_stat+(uint) SQLCOM_DROP_TABLE),SHOW_LONG},
{"Com_drop_user", (char*) (com_stat+(uint) SQLCOM_DROP_USER),SHOW_LONG},
{"Com_flush", (char*) (com_stat+(uint) SQLCOM_FLUSH),SHOW_LONG}, {"Com_flush", (char*) (com_stat+(uint) SQLCOM_FLUSH),SHOW_LONG},
{"Com_grant", (char*) (com_stat+(uint) SQLCOM_GRANT),SHOW_LONG}, {"Com_grant", (char*) (com_stat+(uint) SQLCOM_GRANT),SHOW_LONG},
{"Com_ha_close", (char*) (com_stat+(uint) SQLCOM_HA_CLOSE),SHOW_LONG}, {"Com_ha_close", (char*) (com_stat+(uint) SQLCOM_HA_CLOSE),SHOW_LONG},
...@@ -4417,6 +4419,7 @@ struct show_var_st status_vars[]= { ...@@ -4417,6 +4419,7 @@ struct show_var_st status_vars[]= {
{"Com_load_master_table", (char*) (com_stat+(uint) SQLCOM_LOAD_MASTER_TABLE),SHOW_LONG}, {"Com_load_master_table", (char*) (com_stat+(uint) SQLCOM_LOAD_MASTER_TABLE),SHOW_LONG},
{"Com_lock_tables", (char*) (com_stat+(uint) SQLCOM_LOCK_TABLES),SHOW_LONG}, {"Com_lock_tables", (char*) (com_stat+(uint) SQLCOM_LOCK_TABLES),SHOW_LONG},
{"Com_optimize", (char*) (com_stat+(uint) SQLCOM_OPTIMIZE),SHOW_LONG}, {"Com_optimize", (char*) (com_stat+(uint) SQLCOM_OPTIMIZE),SHOW_LONG},
{"Com_preload_keys", (char*) (com_stat+(uint) SQLCOM_PRELOAD_KEYS),SHOW_LONG},
{"Com_purge", (char*) (com_stat+(uint) SQLCOM_PURGE),SHOW_LONG}, {"Com_purge", (char*) (com_stat+(uint) SQLCOM_PURGE),SHOW_LONG},
{"Com_purge_before_date", (char*) (com_stat+(uint) SQLCOM_PURGE_BEFORE),SHOW_LONG}, {"Com_purge_before_date", (char*) (com_stat+(uint) SQLCOM_PURGE_BEFORE),SHOW_LONG},
{"Com_rename_table", (char*) (com_stat+(uint) SQLCOM_RENAME_TABLE),SHOW_LONG}, {"Com_rename_table", (char*) (com_stat+(uint) SQLCOM_RENAME_TABLE),SHOW_LONG},
...@@ -4426,12 +4429,14 @@ struct show_var_st status_vars[]= { ...@@ -4426,12 +4429,14 @@ struct show_var_st status_vars[]= {
{"Com_reset", (char*) (com_stat+(uint) SQLCOM_RESET),SHOW_LONG}, {"Com_reset", (char*) (com_stat+(uint) SQLCOM_RESET),SHOW_LONG},
{"Com_restore_table", (char*) (com_stat+(uint) SQLCOM_RESTORE_TABLE),SHOW_LONG}, {"Com_restore_table", (char*) (com_stat+(uint) SQLCOM_RESTORE_TABLE),SHOW_LONG},
{"Com_revoke", (char*) (com_stat+(uint) SQLCOM_REVOKE),SHOW_LONG}, {"Com_revoke", (char*) (com_stat+(uint) SQLCOM_REVOKE),SHOW_LONG},
{"Com_revoke_all", (char*) (com_stat+(uint) SQLCOM_REVOKE_ALL),SHOW_LONG},
{"Com_rollback", (char*) (com_stat+(uint) SQLCOM_ROLLBACK),SHOW_LONG}, {"Com_rollback", (char*) (com_stat+(uint) SQLCOM_ROLLBACK),SHOW_LONG},
{"Com_select", (char*) (com_stat+(uint) SQLCOM_SELECT),SHOW_LONG}, {"Com_select", (char*) (com_stat+(uint) SQLCOM_SELECT),SHOW_LONG},
{"Com_set_option", (char*) (com_stat+(uint) SQLCOM_SET_OPTION),SHOW_LONG}, {"Com_set_option", (char*) (com_stat+(uint) SQLCOM_SET_OPTION),SHOW_LONG},
{"Com_show_binlog_events", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOG_EVENTS),SHOW_LONG},
{"Com_show_binlogs", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOGS),SHOW_LONG}, {"Com_show_binlogs", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOGS),SHOW_LONG},
{"Com_show_binlog_events", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOG_EVENTS),SHOW_LONG},
{"Com_show_charsets", (char*) (com_stat+(uint) SQLCOM_SHOW_CHARSETS),SHOW_LONG}, {"Com_show_charsets", (char*) (com_stat+(uint) SQLCOM_SHOW_CHARSETS),SHOW_LONG},
{"Com_show_collations", (char*) (com_stat+(uint) SQLCOM_SHOW_COLLATIONS),SHOW_LONG},
{"Com_show_column_types", (char*) (com_stat+(uint) SQLCOM_SHOW_COLUMN_TYPES),SHOW_LONG}, {"Com_show_column_types", (char*) (com_stat+(uint) SQLCOM_SHOW_COLUMN_TYPES),SHOW_LONG},
{"Com_show_create_table", (char*) (com_stat+(uint) SQLCOM_SHOW_CREATE),SHOW_LONG}, {"Com_show_create_table", (char*) (com_stat+(uint) SQLCOM_SHOW_CREATE),SHOW_LONG},
{"Com_show_create_db", (char*) (com_stat+(uint) SQLCOM_SHOW_CREATE_DB),SHOW_LONG}, {"Com_show_create_db", (char*) (com_stat+(uint) SQLCOM_SHOW_CREATE_DB),SHOW_LONG},
...@@ -4439,6 +4444,7 @@ struct show_var_st status_vars[]= { ...@@ -4439,6 +4444,7 @@ struct show_var_st status_vars[]= {
{"Com_show_errors", (char*) (com_stat+(uint) SQLCOM_SHOW_ERRORS),SHOW_LONG}, {"Com_show_errors", (char*) (com_stat+(uint) SQLCOM_SHOW_ERRORS),SHOW_LONG},
{"Com_show_fields", (char*) (com_stat+(uint) SQLCOM_SHOW_FIELDS),SHOW_LONG}, {"Com_show_fields", (char*) (com_stat+(uint) SQLCOM_SHOW_FIELDS),SHOW_LONG},
{"Com_show_grants", (char*) (com_stat+(uint) SQLCOM_SHOW_GRANTS),SHOW_LONG}, {"Com_show_grants", (char*) (com_stat+(uint) SQLCOM_SHOW_GRANTS),SHOW_LONG},
{"Com_show_innodb_status", (char*) (com_stat+(uint) SQLCOM_SHOW_INNODB_STATUS),SHOW_LONG},
{"Com_show_keys", (char*) (com_stat+(uint) SQLCOM_SHOW_KEYS),SHOW_LONG}, {"Com_show_keys", (char*) (com_stat+(uint) SQLCOM_SHOW_KEYS),SHOW_LONG},
{"Com_show_logs", (char*) (com_stat+(uint) SQLCOM_SHOW_LOGS),SHOW_LONG}, {"Com_show_logs", (char*) (com_stat+(uint) SQLCOM_SHOW_LOGS),SHOW_LONG},
{"Com_show_master_status", (char*) (com_stat+(uint) SQLCOM_SHOW_MASTER_STAT),SHOW_LONG}, {"Com_show_master_status", (char*) (com_stat+(uint) SQLCOM_SHOW_MASTER_STAT),SHOW_LONG},
...@@ -4449,7 +4455,6 @@ struct show_var_st status_vars[]= { ...@@ -4449,7 +4455,6 @@ struct show_var_st status_vars[]= {
{"Com_show_slave_hosts", (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_HOSTS),SHOW_LONG}, {"Com_show_slave_hosts", (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_HOSTS),SHOW_LONG},
{"Com_show_slave_status", (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_STAT),SHOW_LONG}, {"Com_show_slave_status", (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_STAT),SHOW_LONG},
{"Com_show_status", (char*) (com_stat+(uint) SQLCOM_SHOW_STATUS),SHOW_LONG}, {"Com_show_status", (char*) (com_stat+(uint) SQLCOM_SHOW_STATUS),SHOW_LONG},
{"Com_show_innodb_status", (char*) (com_stat+(uint) SQLCOM_SHOW_INNODB_STATUS),SHOW_LONG},
{"Com_show_tables", (char*) (com_stat+(uint) SQLCOM_SHOW_TABLES),SHOW_LONG}, {"Com_show_tables", (char*) (com_stat+(uint) SQLCOM_SHOW_TABLES),SHOW_LONG},
{"Com_show_table_types", (char*) (com_stat+(uint) SQLCOM_SHOW_TABLE_TYPES),SHOW_LONG}, {"Com_show_table_types", (char*) (com_stat+(uint) SQLCOM_SHOW_TABLE_TYPES),SHOW_LONG},
{"Com_show_variables", (char*) (com_stat+(uint) SQLCOM_SHOW_VARIABLES),SHOW_LONG}, {"Com_show_variables", (char*) (com_stat+(uint) SQLCOM_SHOW_VARIABLES),SHOW_LONG},
......
...@@ -71,7 +71,7 @@ enum enum_sql_command { ...@@ -71,7 +71,7 @@ enum enum_sql_command {
SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_NEW_MASTER, SQLCOM_DO, SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_NEW_MASTER, SQLCOM_DO,
SQLCOM_SHOW_WARNS, SQLCOM_EMPTY_QUERY, SQLCOM_SHOW_ERRORS, SQLCOM_SHOW_WARNS, SQLCOM_EMPTY_QUERY, SQLCOM_SHOW_ERRORS,
SQLCOM_SHOW_COLUMN_TYPES, SQLCOM_SHOW_TABLE_TYPES, SQLCOM_SHOW_PRIVILEGES, SQLCOM_SHOW_COLUMN_TYPES, SQLCOM_SHOW_TABLE_TYPES, SQLCOM_SHOW_PRIVILEGES,
SQLCOM_HELP, SQLCOM_DROP_USER, SQLCOM_REVOKE_ALL, SQLCOM_HELP, SQLCOM_DROP_USER, SQLCOM_REVOKE_ALL, SQLCOM_CHECKSUM,
/* This should be the last !!! */ /* This should be the last !!! */
SQLCOM_END SQLCOM_END
......
...@@ -2264,6 +2264,14 @@ mysql_execute_command(THD *thd) ...@@ -2264,6 +2264,14 @@ mysql_execute_command(THD *thd)
break; break;
} }
#endif #endif
case SQLCOM_CHECKSUM:
{
if (check_db_used(thd,tables) ||
check_table_access(thd, SELECT_ACL | EXTRA_ACL , tables))
goto error; /* purecov: inspected */
res = mysql_checksum_table(thd, tables);
break;
}
case SQLCOM_REPAIR: case SQLCOM_REPAIR:
{ {
if (check_db_used(thd,tables) || if (check_db_used(thd,tables) ||
......
...@@ -2587,3 +2587,67 @@ copy_data_between_tables(TABLE *from,TABLE *to, ...@@ -2587,3 +2587,67 @@ copy_data_between_tables(TABLE *from,TABLE *to,
*deleted=delete_count; *deleted=delete_count;
DBUG_RETURN(error > 0 ? -1 : 0); 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);
}
...@@ -669,7 +669,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -669,7 +669,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
insert_values update delete truncate rename insert_values update delete truncate rename
show describe load alter optimize preload flush show describe load alter optimize preload flush
reset purge begin commit rollback slave master_def master_defs reset purge begin commit rollback slave master_def master_defs
repair restore backup analyze check start repair restore backup analyze check start checksum
field_list field_list_item field_spec kill column_def key_def field_list field_list_item field_spec kill column_def key_def
preload_list preload_keys preload_list preload_keys
select_item_list select_item values_list no_braces select_item_list select_item values_list no_braces
...@@ -727,6 +727,7 @@ verb_clause: ...@@ -727,6 +727,7 @@ verb_clause:
| begin | begin
| change | change
| check | check
| checksum
| commit | commit
| create | create
| delete | delete
...@@ -1753,6 +1754,16 @@ backup: ...@@ -1753,6 +1754,16 @@ backup:
Lex->backup_dir = $6.str; Lex->backup_dir = $6.str;
}; };
checksum:
CHECKSUM_SYM table_or_tables
{
LEX *lex=Lex;
lex->sql_command = SQLCOM_CHECKSUM;
}
table_list
{}
;
repair: repair:
REPAIR opt_no_write_to_binlog table_or_tables REPAIR opt_no_write_to_binlog table_or_tables
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment