summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <sasha@mysql.sashanet.com>2001-12-13 13:17:19 -0700
committerunknown <sasha@mysql.sashanet.com>2001-12-13 13:17:19 -0700
commit961f7be52fa7b4c5f2c3775eef2467b3a441d97a (patch)
treebf4d31e683a20ee0723756ec9d0b6cca15833667 /sql
parent623eedda2601f083c45a6f4af794e5b4b2703901 (diff)
parentb554ef6b10db3d6640935cafe0d7ebaf8034ae13 (diff)
downloadmariadb-git-961f7be52fa7b4c5f2c3775eef2467b3a441d97a.tar.gz
merged
sql/mysqld.cc: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/mysqld.cc58
-rw-r--r--sql/sql_lex.h3
-rw-r--r--sql/sql_parse.cc17
-rw-r--r--sql/table.cc6
-rw-r--r--sql/unireg.cc20
6 files changed, 94 insertions, 11 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index ceb9bd9a691..11bf7d36389 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -542,6 +542,7 @@ extern ulong keybuff_size,sortbuff_size,max_item_sort_length,table_cache_size,
max_tmp_tables,max_heap_table_size,query_buff_size,
lower_case_table_names,thread_stack,thread_stack_min,
binlog_cache_size, max_binlog_cache_size, record_rnd_cache_size;
+extern ulong com_stat[(uint) SQLCOM_END], com_other;
extern ulong specialflag, current_pid;
extern bool low_priority_updates, using_update_log,opt_warnings;
extern bool opt_sql_bin_update, opt_safe_show_db, opt_safe_user_create;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index bb6c3c70a27..19d6ffe19c7 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -270,6 +270,7 @@ ulong keybuff_size,sortbuff_size,max_item_sort_length,table_cache_size,
net_interactive_timeout, slow_launch_time = 2L,
net_read_timeout,net_write_timeout,slave_open_temp_tables=0,
open_files_limit=0, max_binlog_size, record_rnd_cache_size;
+ulong com_stat[(uint) SQLCOM_END], com_other;
ulong slave_net_timeout;
ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0;
volatile ulong cached_thread_count=0;
@@ -3049,6 +3050,63 @@ struct show_var_st status_vars[]= {
{"Aborted_connects", (char*) &aborted_connects, SHOW_LONG},
{"Bytes_received", (char*) &bytes_received, SHOW_LONG},
{"Bytes_sent", (char*) &bytes_sent, SHOW_LONG},
+ {"Com_admin_commands", (char*) &com_other, 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_backup_table", (char*) (com_stat+(uint) SQLCOM_BACKUP_TABLE),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_master", (char*) (com_stat+(uint) SQLCOM_CHANGE_MASTER),SHOW_LONG},
+ {"Com_check", (char*) (com_stat+(uint) SQLCOM_CHECK),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_function", (char*) (com_stat+(uint) SQLCOM_CREATE_FUNCTION),SHOW_LONG},
+ {"Com_create_index", (char*) (com_stat+(uint) SQLCOM_CREATE_INDEX),SHOW_LONG},
+ {"Com_create_table", (char*) (com_stat+(uint) SQLCOM_CREATE_TABLE),SHOW_LONG},
+ {"Com_delete", (char*) (com_stat+(uint) SQLCOM_DELETE),SHOW_LONG},
+ {"Com_drop_db", (char*) (com_stat+(uint) SQLCOM_DROP_DB),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_table", (char*) (com_stat+(uint) SQLCOM_DROP_TABLE),SHOW_LONG},
+ {"Com_flush", (char*) (com_stat+(uint) SQLCOM_FLUSH),SHOW_LONG},
+ {"Com_grant", (char*) (com_stat+(uint) SQLCOM_GRANT),SHOW_LONG},
+ {"Com_insert", (char*) (com_stat+(uint) SQLCOM_INSERT),SHOW_LONG},
+ {"Com_insert_select", (char*) (com_stat+(uint) SQLCOM_INSERT_SELECT),SHOW_LONG},
+ {"Com_kill", (char*) (com_stat+(uint) SQLCOM_KILL),SHOW_LONG},
+ {"Com_load", (char*) (com_stat+(uint) SQLCOM_LOAD),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_optimize", (char*) (com_stat+(uint) SQLCOM_OPTIMIZE),SHOW_LONG},
+ {"Com_purge", (char*) (com_stat+(uint) SQLCOM_PURGE),SHOW_LONG},
+ {"Com_rename_table", (char*) (com_stat+(uint) SQLCOM_RENAME_TABLE),SHOW_LONG},
+ {"Com_repair", (char*) (com_stat+(uint) SQLCOM_REPAIR),SHOW_LONG},
+ {"Com_replace", (char*) (com_stat+(uint) SQLCOM_REPLACE),SHOW_LONG},
+ {"Com_replace_select", (char*) (com_stat+(uint) SQLCOM_REPLACE_SELECT),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_revoke", (char*) (com_stat+(uint) SQLCOM_REVOKE),SHOW_LONG},
+ {"Com_rollback", (char*) (com_stat+(uint) SQLCOM_ROLLBACK),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_show_binlogs", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOGS),SHOW_LONG},
+ {"Com_show_create", (char*) (com_stat+(uint) SQLCOM_SHOW_CREATE),SHOW_LONG},
+ {"Com_show_databases", (char*) (com_stat+(uint) SQLCOM_SHOW_DATABASES),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_keys", (char*) (com_stat+(uint) SQLCOM_SHOW_KEYS),SHOW_LONG},
+ {"Com_show_logs", (char*) (com_stat+(uint) SQLCOM_SHOW_LOGS),SHOW_LONG},
+ {"Com_show_master_STAT", (char*) (com_stat+(uint) SQLCOM_SHOW_MASTER_STAT),SHOW_LONG},
+ {"Com_show_open_tables", (char*) (com_stat+(uint) SQLCOM_SHOW_OPEN_TABLES),SHOW_LONG},
+ {"Com_show_processlist", (char*) (com_stat+(uint) SQLCOM_SHOW_PROCESSLIST),SHOW_LONG},
+ {"Com_show_slave_stat", (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_STAT),SHOW_LONG},
+ {"Com_show_status", (char*) (com_stat+(uint) SQLCOM_SHOW_STATUS),SHOW_LONG},
+ {"Com_show_tables", (char*) (com_stat+(uint) SQLCOM_SHOW_TABLES),SHOW_LONG},
+ {"Com_show_variables", (char*) (com_stat+(uint) SQLCOM_SHOW_VARIABLES),SHOW_LONG},
+ {"Com_slave_start", (char*) (com_stat+(uint) SQLCOM_SLAVE_START),SHOW_LONG},
+ {"Com_slave_stop", (char*) (com_stat+(uint) SQLCOM_SLAVE_STOP),SHOW_LONG},
+ {"Com_truncate", (char*) (com_stat+(uint) SQLCOM_TRUNCATE),SHOW_LONG},
+ {"Com_unlock_tables", (char*) (com_stat+(uint) SQLCOM_UNLOCK_TABLES),SHOW_LONG},
+ {"Com_update", (char*) (com_stat+(uint) SQLCOM_UPDATE),SHOW_LONG},
{"Connections", (char*) &thread_id, SHOW_LONG_CONST},
{"Created_tmp_disk_tables", (char*) &created_tmp_disk_tables,SHOW_LONG},
{"Created_tmp_tables", (char*) &created_tmp_tables, SHOW_LONG},
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 8f81af3b548..e70a8902901 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -53,7 +53,8 @@ enum enum_sql_command {
SQLCOM_BEGIN, SQLCOM_LOAD_MASTER_TABLE, SQLCOM_CHANGE_MASTER,
SQLCOM_RENAME_TABLE, SQLCOM_BACKUP_TABLE, SQLCOM_RESTORE_TABLE,
SQLCOM_RESET, SQLCOM_PURGE, SQLCOM_SHOW_BINLOGS,
- SQLCOM_SHOW_OPEN_TABLES
+ SQLCOM_SHOW_OPEN_TABLES,
+ SQLCOM_END
};
enum lex_states { STATE_START, STATE_CHAR, STATE_IDENT,
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 5804060a25a..2f629ec920c 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -705,7 +705,6 @@ err:
}
-
/* Execute one command from socket (query or simple command) */
bool do_command(THD *thd)
@@ -756,11 +755,13 @@ bool do_command(THD *thd)
thd->lex.options=0; // We store status here
switch(command) {
case COM_INIT_DB:
+ thread_safe_increment(com_stat[SQLCOM_CHANGE_DB],&LOCK_thread_count);
if (!mysql_change_db(thd,packet+1))
mysql_log.write(thd,command,"%s",thd->db);
break;
case COM_TABLE_DUMP:
{
+ thread_safe_increment(com_other,&LOCK_thread_count);
slow_command = TRUE;
char* data = packet + 1;
uint db_len = *data;
@@ -778,6 +779,7 @@ bool do_command(THD *thd)
}
case COM_CHANGE_USER:
{
+ thread_safe_increment(com_other,&LOCK_thread_count);
char *user= (char*) packet+1;
char *passwd= strend(user)+1;
char *db= strend(passwd)+1;
@@ -843,6 +845,7 @@ bool do_command(THD *thd)
{
char *fields;
TABLE_LIST table_list;
+ thread_safe_increment(com_stat[SQLCOM_SHOW_FIELDS],&LOCK_thread_count);
bzero((char*) &table_list,sizeof(table_list));
if (!(table_list.db=thd->db))
{
@@ -866,6 +869,7 @@ bool do_command(THD *thd)
}
#endif
case COM_QUIT:
+ /* We don't calculate statistics for this command */
mysql_log.write(thd,command,NullS);
net->error=0; // Don't give 'abort' message
error=TRUE; // End server
@@ -874,6 +878,7 @@ bool do_command(THD *thd)
case COM_CREATE_DB:
{
char *db=thd->strdup(packet+1);
+ thread_safe_increment(com_stat[SQLCOM_CREATE_DB],&LOCK_thread_count);
// null test to handle EOM
if (!db || !stripp_sp(db) || check_db_name(db))
{
@@ -889,6 +894,7 @@ bool do_command(THD *thd)
case COM_DROP_DB:
{
char *db=thd->strdup(packet+1);
+ thread_safe_increment(com_stat[SQLCOM_DROP_DB],&LOCK_thread_count);
// null test to handle EOM
if (!db || !stripp_sp(db) || check_db_name(db))
{
@@ -903,6 +909,7 @@ bool do_command(THD *thd)
}
case COM_BINLOG_DUMP:
{
+ thread_safe_increment(com_other,&LOCK_thread_count);
slow_command = TRUE;
if(check_access(thd, FILE_ACL, any_db))
break;
@@ -926,6 +933,7 @@ bool do_command(THD *thd)
case COM_REFRESH:
{
uint options=(uchar) packet[1];
+ thread_safe_increment(com_stat[SQLCOM_FLUSH],&LOCK_thread_count);
if (check_access(thd,RELOAD_ACL,any_db))
break;
mysql_log.write(thd,command,NullS);
@@ -936,6 +944,7 @@ bool do_command(THD *thd)
break;
}
case COM_SHUTDOWN:
+ thread_safe_increment(com_other,&LOCK_thread_count);
if (check_access(thd,SHUTDOWN_ACL,any_db))
break; /* purecov: inspected */
DBUG_PRINT("quit",("Got shutdown command"));
@@ -957,6 +966,7 @@ bool do_command(THD *thd)
case COM_STATISTICS:
{
mysql_log.write(thd,command,NullS);
+ thread_safe_increment(com_stat[SQLCOM_SHOW_STATUS],&LOCK_thread_count);
char buff[200];
ulong uptime = (ulong) (thd->start_time - start_time);
sprintf((char*) buff,
@@ -975,9 +985,11 @@ bool do_command(THD *thd)
break;
}
case COM_PING:
+ thread_safe_increment(com_other,&LOCK_thread_count);
send_ok(net); // Tell client we are alive
break;
case COM_PROCESS_INFO:
+ thread_safe_increment(com_stat[SQLCOM_SHOW_PROCESSLIST],&LOCK_thread_count);
if (!thd->priv_user[0] && check_process_priv(thd))
break;
mysql_log.write(thd,command,NullS);
@@ -986,11 +998,13 @@ bool do_command(THD *thd)
break;
case COM_PROCESS_KILL:
{
+ thread_safe_increment(com_stat[SQLCOM_KILL],&LOCK_thread_count);
ulong id=(ulong) uint4korr(packet+1);
kill_one_thread(thd,id);
break;
}
case COM_DEBUG:
+ thread_safe_increment(com_other,&LOCK_thread_count);
if (check_process_priv(thd))
break; /* purecov: inspected */
mysql_print_status(thd);
@@ -1062,6 +1076,7 @@ mysql_execute_command(void)
// rules have been given and the table list says the query should not be
// replicated
+ thread_safe_increment(com_stat[lex->sql_command],&LOCK_thread_count);
switch (lex->sql_command) {
case SQLCOM_SELECT:
{
diff --git a/sql/table.cc b/sql/table.cc
index eed4170c14a..1ab6c50add9 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -120,10 +120,8 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
outparam->db_record_offset=1;
if (db_create_options & HA_OPTION_LONG_BLOB_PTR)
outparam->blob_ptr_size=portable_sizeof_char_ptr;
- outparam->db_low_byte_first=test(outparam->db_type == DB_TYPE_MYISAM ||
- outparam->db_type == DB_TYPE_BERKELEY_DB ||
- outparam->db_type == DB_TYPE_HEAP);
-
+ /* Set temporaryly a good value for db_low_byte_first */
+ outparam->db_low_byte_first=test(outparam->db_type != DB_TYPE_ISAM);
error=4;
outparam->max_rows=uint4korr(head+18);
outparam->min_rows=uint4korr(head+22);
diff --git a/sql/unireg.cc b/sql/unireg.cc
index c5bfbbbea88..0bfc462f01a 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -515,16 +515,23 @@ static bool make_empty_rec(File file,enum db_type table_type,
uchar *buff,*null_pos;
TABLE table;
create_field *field;
+ handler *handler;
DBUG_ENTER("make_empty_rec");
/* We need a table to generate columns for default values */
bzero((char*) &table,sizeof(table));
- table.db_low_byte_first=test(table_type == DB_TYPE_MYISAM ||
- table_type == DB_TYPE_HEAP);
- table.blob_ptr_size=portable_sizeof_char_ptr;
+ handler= get_new_handler((TABLE*) 0, table_type);
- if (!(buff=(uchar*) my_malloc((uint) reclength,MYF(MY_WME | MY_ZEROFILL))))
+ if (!handler ||
+ !(buff=(uchar*) my_malloc((uint) reclength,MYF(MY_WME | MY_ZEROFILL))))
+ {
+ delete handler;
DBUG_RETURN(1);
+ }
+
+ table.db_low_byte_first= handler->low_byte_first();
+ table.blob_ptr_size=portable_sizeof_char_ptr;
+
firstpos=reclength;
null_count=0;
if (!(table_options & HA_OPTION_PACK_RECORD))
@@ -574,8 +581,11 @@ static bool make_empty_rec(File file,enum db_type table_type,
regfield->reset();
delete regfield;
}
- bfill((byte*) buff+null_length,firstpos-null_length,255);/* Fill not used startpos */
+
+ /* Fill not used startpos */
+ bfill((byte*) buff+null_length,firstpos-null_length,255);
error=(int) my_write(file,(byte*) buff,(uint) reclength,MYF_RW);
my_free((gptr) buff,MYF(MY_FAE));
+ delete handler;
DBUG_RETURN(error);
} /* make_empty_rec */