Commit 8f8f6974 authored by unknown's avatar unknown
Browse files

Merge bk-internal:/home/bk/mysql-5.0

into serg.mylan:/usr/home/serg/Abk/mysql-5.0


sql/sql_class.h:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
parents cb121e0c db10586e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -90,5 +90,5 @@ drop user drop_user@localhost;
prepare stmt4 from ' show full processlist ';
execute stmt4;
Id	User	Host	db	Command	Time	State	Info
number	root	localhost	test	Query	time	NULL	show full processlist
number	root	localhost	test	Execute	time	NULL	show full processlist
deallocate prepare stmt4;
+2 −0
Original line number Diff line number Diff line
@@ -599,6 +599,7 @@ bool mysql_execute_command(THD *thd);
bool do_command(THD *thd);
bool dispatch_command(enum enum_server_command command, THD *thd,
		      char* packet, uint packet_length);
void log_slow_statement(THD *thd);
bool check_dup(const char *db, const char *name, TABLE_LIST *tables);

bool table_cache_init(void);
@@ -1116,6 +1117,7 @@ extern my_bool opt_slave_compressed_protocol, use_temp_pool;
extern my_bool opt_readonly, lower_case_file_system;
extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
extern my_bool opt_secure_auth;
extern my_bool opt_log_slow_admin_statements;
extern my_bool sp_automatic_privileges, opt_noacl;
extern my_bool opt_old_style_user_limits, trust_routine_creators;
extern uint opt_crash_binlog_innodb;
+22 −3
Original line number Diff line number Diff line
@@ -326,6 +326,7 @@ ulong opt_ndb_nodeid;
my_bool opt_readonly, use_temp_pool, relay_log_purge;
my_bool opt_sync_frm, opt_allow_suspicious_udfs;
my_bool opt_secure_auth= 0;
my_bool opt_log_slow_admin_statements= 0;
my_bool lower_case_file_system= 0;
my_bool opt_large_pages= 0;
uint    opt_large_page_size= 0;
@@ -4333,7 +4334,8 @@ enum options_mysqld
  OPT_AUTO_INCREMENT, OPT_AUTO_INCREMENT_OFFSET,
  OPT_ENABLE_LARGE_PAGES,
  OPT_TIMED_MUTEXES,
  OPT_OLD_STYLE_USER_LIMITS
  OPT_OLD_STYLE_USER_LIMITS,
  OPT_LOG_SLOW_ADMIN_STATEMENTS
};


@@ -4658,7 +4660,7 @@ Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite,
   "Log some extra information to update log. Please note that this option is deprecated; see --log-short-format option.", 
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
  {"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES,
   "Log queries that are executed without benefit of any index.",
   "Log queries that are executed without benefit of any index to the slow log if it is open.",
   (gptr*) &opt_log_queries_not_using_indexes, (gptr*) &opt_log_queries_not_using_indexes,
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
  {"log-short-format", OPT_SHORT_LOG_FORMAT,
@@ -4669,8 +4671,13 @@ Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite,
   "Tells the slave to log the updates from the slave thread to the binary log. You will need to turn it on if you plan to daisy-chain the slaves.",
   (gptr*) &opt_log_slave_updates, (gptr*) &opt_log_slave_updates, 0, GET_BOOL,
   NO_ARG, 0, 0, 0, 0, 0, 0},
  {"log-slow-admin-statements", OPT_LOG_SLOW_ADMIN_STATEMENTS,
   "Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements to the slow log if it is open.",
   (gptr*) &opt_log_slow_admin_statements,
   (gptr*) &opt_log_slow_admin_statements,
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
  {"log-slow-queries", OPT_SLOW_QUERY_LOG,
   "Log slow queries to this log file. Defaults logging to hostname-slow.log file.",
    "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.",
   (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
   0, 0, 0, 0, 0, 0},
  {"log-tc", OPT_LOG_TC,
@@ -5718,6 +5725,12 @@ struct show_var_st status_vars[]= {
  {"Com_show_warnings",        (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS},
  {"Com_slave_start",	       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_START]), SHOW_LONG_STATUS},
  {"Com_slave_stop",	       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_STOP]), SHOW_LONG_STATUS},
  {"Com_stmt_prepare",         (char*) offsetof(STATUS_VAR, com_stmt_prepare), SHOW_LONG_STATUS},
  {"Com_stmt_execute",         (char*) offsetof(STATUS_VAR, com_stmt_execute), SHOW_LONG_STATUS},
  {"Com_stmt_fetch",           (char*) offsetof(STATUS_VAR, com_stmt_fetch), SHOW_LONG_STATUS},
  {"Com_stmt_send_long_data",  (char*) offsetof(STATUS_VAR, com_stmt_send_long_data), SHOW_LONG_STATUS},
  {"Com_stmt_reset",           (char*) offsetof(STATUS_VAR, com_stmt_reset), SHOW_LONG_STATUS},
  {"Com_stmt_close",           (char*) offsetof(STATUS_VAR, com_stmt_close), SHOW_LONG_STATUS},
  {"Com_truncate",	       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_TRUNCATE]), SHOW_LONG_STATUS},
  {"Com_unlock_tables",	       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
  {"Com_update",	       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
@@ -6345,6 +6358,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
  case (int) OPT_SLOW_QUERY_LOG:
    opt_slow_log=1;
    break;
  case (int) OPT_LOG_SLOW_ADMIN_STATEMENTS:
    opt_log_slow_admin_statements= 1;
    break;
  case (int) OPT_SKIP_NEW:
    opt_specialflag|= SPECIAL_NO_NEW_FUNC;
    delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE;
@@ -6733,6 +6749,9 @@ static void get_options(int argc,char **argv)
  if (opt_bdb)
    sql_print_warning("this binary does not contain BDB storage engine");
#endif
  if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes) &&
      !opt_slow_log)
    sql_print_warning("options --log-slow-admin-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");

  /*
    Check that the default storage engine is actually available.
+9 −2
Original line number Diff line number Diff line
@@ -631,6 +631,13 @@ typedef struct system_status_var
  ulong filesort_range_count;
  ulong filesort_rows;
  ulong filesort_scan_count;
  /* Ppepared statements and binary protocol */
  ulong com_stmt_prepare;
  ulong com_stmt_execute;
  ulong com_stmt_send_long_data;
  ulong com_stmt_fetch;
  ulong com_stmt_reset;
  ulong com_stmt_close;

  double last_query_cost;
} STATUS_VAR;
@@ -640,7 +647,7 @@ typedef struct system_status_var
  variable in system_status_var
*/

#define last_system_status_var filesort_scan_count
#define last_system_status_var com_stmt_close


void free_tmp_table(THD *thd, TABLE *entry);
@@ -1186,7 +1193,7 @@ class THD :public ilink,
  bool       query_error, bootstrap, cleanup_done;
  bool	     tmp_table_used;
  bool	     charset_is_system_charset, charset_is_collation_connection;
  bool       slow_command;
  bool       enable_slow_log;   /* enable slow log for current statement */
  bool	     no_trans_update, abort_on_warning;
  bool 	     got_warning;       /* Set on call to push_warning() */
  bool	     no_warnings_for_error; /* no warnings on call to my_error() */
+23 −19
Original line number Diff line number Diff line
@@ -71,7 +71,6 @@ static void remove_escape(char *name);
static void refresh_status(void);
static bool append_file_to_dir(THD *thd, const char **filename_ptr,
			       const char *table_name);
static void log_slow_query(THD *thd);

const char *any_db="*any*";	// Special symbol for check_access

@@ -1508,10 +1507,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd,

  thd->command=command;
  /*
    Commands which will always take a long time should be marked with
    this so that they will not get logged to the slow query log
    Commands which always take a long time are logged into
    the slow log only if opt_log_slow_admin_statements is set.
  */
  thd->slow_command=FALSE;
  thd->enable_slow_log= TRUE;
  thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
  thd->set_time();
  VOID(pthread_mutex_lock(&LOCK_thread_count));
@@ -1551,7 +1550,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
    uint tbl_len= *(uchar*) (packet + db_len + 1);

    statistic_increment(thd->status_var.com_other, &LOCK_status);
    thd->slow_command= TRUE;
    thd->enable_slow_log= opt_log_slow_admin_statements;
    db= thd->alloc(db_len + tbl_len + 2);
    tbl_name= strmake(db, packet + 1, db_len)+1;
    strmake(tbl_name, packet + db_len + 2, tbl_len);
@@ -1689,7 +1688,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
#endif
      ulong length= (ulong)(packet_end-packet);

      log_slow_query(thd);
      log_slow_statement(thd);

      /* Remove garbage at start of query */
      while (my_isspace(thd->charset(), *packet) && length > 0)
@@ -1858,7 +1857,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
      uint32 slave_server_id;

      statistic_increment(thd->status_var.com_other,&LOCK_status);
      thd->slow_command = TRUE;
      thd->enable_slow_log= opt_log_slow_admin_statements;
      if (check_global_access(thd, REPL_SLAVE_ACL))
	break;

@@ -2043,7 +2042,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
  if (thd->net.report_error)
    net_send_error(thd);

  log_slow_query(thd);
  log_slow_statement(thd);

  thd->proc_info="cleaning up";
  VOID(pthread_mutex_lock(&LOCK_thread_count)); // For process list
@@ -2059,13 +2058,16 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
}


static void log_slow_query(THD *thd)
void log_slow_statement(THD *thd)
{
  time_t start_of_query=thd->start_time;
  thd->end_time();				// Set start time

  /* If not reading from backup and if the query took too long */
  if (!thd->slow_command && !thd->user_time) // do not log 'slow_command' queries
  /*
    Do not log administrative statements unless the appropriate option is
    set; do not log into slow log if reading from backup.
  */
  if (thd->enable_slow_log && !thd->user_time)
  {
    thd->proc_info="logging slow query";

@@ -2520,6 +2522,8 @@ mysql_execute_command(THD *thd)
    DBUG_PRINT("info", ("DEALLOCATE PREPARE: %.*s\n", 
                        lex->prepared_stmt_name.length,
                        lex->prepared_stmt_name.str));
    /* We account deallocate in the same manner as mysql_stmt_close */
    statistic_increment(thd->status_var.com_stmt_close, &LOCK_status);
    if ((stmt= thd->stmt_map.find_by_name(&lex->prepared_stmt_name)))
    {
      thd->stmt_map.erase(stmt);
@@ -2637,7 +2641,7 @@ mysql_execute_command(THD *thd)
	check_table_access(thd, SELECT_ACL, all_tables, 0) ||
	check_global_access(thd, FILE_ACL))
      goto error; /* purecov: inspected */
    thd->slow_command=TRUE;
    thd->enable_slow_log= opt_log_slow_admin_statements;
    res = mysql_backup_table(thd, first_table);

    break;
@@ -2649,7 +2653,7 @@ mysql_execute_command(THD *thd)
	check_table_access(thd, INSERT_ACL, all_tables, 0) ||
	check_global_access(thd, FILE_ACL))
      goto error; /* purecov: inspected */
    thd->slow_command=TRUE;
    thd->enable_slow_log= opt_log_slow_admin_statements;
    res = mysql_restore_table(thd, first_table);
    break;
  }
@@ -2920,7 +2924,7 @@ mysql_execute_command(THD *thd)
    DBUG_ASSERT(first_table == all_tables && first_table != 0);
    if (check_one_table_access(thd, INDEX_ACL, all_tables))
      goto error; /* purecov: inspected */
    thd->slow_command=TRUE;
    thd->enable_slow_log= opt_log_slow_admin_statements;
    if (end_active_trans(thd))
      goto error;
    else
@@ -3009,7 +3013,7 @@ mysql_execute_command(THD *thd)
	goto error;
      else
      {
        thd->slow_command=TRUE;
        thd->enable_slow_log= opt_log_slow_admin_statements;
	res= mysql_alter_table(thd, select_lex->db, lex->name,
			       &lex->create_info,
			       first_table, lex->create_list,
@@ -3108,7 +3112,7 @@ mysql_execute_command(THD *thd)
    if (check_db_used(thd, all_tables) ||
	check_table_access(thd, SELECT_ACL | INSERT_ACL, all_tables, 0))
      goto error; /* purecov: inspected */
    thd->slow_command=TRUE;
    thd->enable_slow_log= opt_log_slow_admin_statements;
    res= mysql_repair_table(thd, first_table, &lex->check_opt);
    /* ! we write after unlocking the table */
    if (!res && !lex->no_write_to_binlog)
@@ -3128,7 +3132,7 @@ mysql_execute_command(THD *thd)
    if (check_db_used(thd, all_tables) ||
	check_table_access(thd, SELECT_ACL | EXTRA_ACL , all_tables, 0))
      goto error; /* purecov: inspected */
    thd->slow_command=TRUE;
    thd->enable_slow_log= opt_log_slow_admin_statements;
    res = mysql_check_table(thd, first_table, &lex->check_opt);
    break;
  }
@@ -3138,7 +3142,7 @@ mysql_execute_command(THD *thd)
    if (check_db_used(thd, all_tables) ||
	check_table_access(thd, SELECT_ACL | INSERT_ACL, all_tables, 0))
      goto error; /* purecov: inspected */
    thd->slow_command=TRUE;
    thd->enable_slow_log= opt_log_slow_admin_statements;
    res = mysql_analyze_table(thd, first_table, &lex->check_opt);
    /* ! we write after unlocking the table */
    if (!res && !lex->no_write_to_binlog)
@@ -3159,7 +3163,7 @@ mysql_execute_command(THD *thd)
    if (check_db_used(thd, all_tables) ||
	check_table_access(thd, SELECT_ACL | INSERT_ACL, all_tables, 0))
      goto error; /* purecov: inspected */
    thd->slow_command=TRUE;
    thd->enable_slow_log= opt_log_slow_admin_statements;
    res= (specialflag & (SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC)) ?
      mysql_recreate_table(thd, first_table, 1) :
      mysql_optimize_table(thd, first_table, &lex->check_opt);
Loading