diff options
author | monty@donna.mysql.com <> | 2000-09-20 04:59:34 +0300 |
---|---|---|
committer | monty@donna.mysql.com <> | 2000-09-20 04:59:34 +0300 |
commit | 2780278f35ae9ec1a73fb4d5ecedecf9f44d0c8b (patch) | |
tree | 47e17b2858b02fa9f69cb087e6add8a937bbd62f /sql | |
parent | b4e2076bed1d068656cd7e6b4f9d3009074a7c8b (diff) | |
parent | dc4525636ce2912fb9a455503260760621e2eb46 (diff) | |
download | mariadb-git-2780278f35ae9ec1a73fb4d5ecedecf9f44d0c8b.tar.gz |
merge
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ChangeLog | 5 | ||||
-rw-r--r-- | sql/ha_myisam.cc | 11 | ||||
-rw-r--r-- | sql/log.cc | 4 | ||||
-rw-r--r-- | sql/mysql_priv.h | 3 | ||||
-rw-r--r-- | sql/mysqld.cc | 14 | ||||
-rw-r--r-- | sql/sql_class.h | 4 | ||||
-rw-r--r-- | sql/sql_delete.cc | 8 | ||||
-rw-r--r-- | sql/sql_parse.cc | 12 | ||||
-rw-r--r-- | sql/sql_table.cc | 4 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 16 | ||||
-rw-r--r-- | sql/table.cc | 6 |
11 files changed, 63 insertions, 24 deletions
diff --git a/sql/ChangeLog b/sql/ChangeLog index df9b2567113..08bbd3bb0db 100644 --- a/sql/ChangeLog +++ b/sql/ChangeLog @@ -1,3 +1,8 @@ +2000-09-17 Michael Widenius <monty@mysql.com> + +* Added option QUICK to DELETE to tell MySQL not to balance the + trees on delete. + 2000-09-15 Michael Widenius <monty@mysql.com> * Added a thd argument to log::write() to get more speed. diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index aac53c5667d..77e9ac6b1dc 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -417,7 +417,8 @@ int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt) param.op_name = (char*) "optimize"; param.testflag = (check_opt->flags | T_SILENT | T_FORCE_CREATE | T_REP_BY_SORT | T_STATISTICS | T_SORT_INDEX); - param.opt_rep_quick++; + if (check_opt->quick) + param.opt_rep_quick++; param.sort_buffer_length= check_opt->sort_buffer_size; return repair(thd,param,1); } @@ -440,8 +441,10 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize) VOID(fn_format(fixed_name,file->filename,"",MI_NAME_IEXT, 4+ (param.opt_follow_links ? 16 : 0))); - if (!optimize || file->state->del || - share->state.split != file->state->records) + if (!optimize || + ((file->state->del || share->state.split != file->state->records) && + (!param.opt_rep_quick || + !(share->state.changed & STATE_NOT_OPTIMIZED_KEYS)))) { optimize_done=1; if (mi_test_if_sort_rep(file,file->state->records)) @@ -548,7 +551,7 @@ bool ha_myisam::activate_all_index(THD *thd) myisamchk_init(¶m); param.op_name = (char*) "recreating_index"; param.testflag = (T_SILENT | T_REP_BY_SORT | - T_STATISTICS | T_CREATE_MISSING_KEYS | T_TRUST_HEADER); + T_CREATE_MISSING_KEYS | T_TRUST_HEADER); param.myf_rw&= ~MY_WAIT_IF_FULL; param.sort_buffer_length= myisam_sort_buffer_size; param.opt_rep_quick++; diff --git a/sql/log.cc b/sql/log.cc index c5862621cfd..d23c71e6ef3 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -158,9 +158,9 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, if (log_type == LOG_NORMAL) { #ifdef __NT__ - fprintf( file, "%s, Version: %s, started with:\nTCP Port: %d, Named Pipe: %s\n", my_progname, server_version, mysql_port, mysql_unix_port); + fprintf(file, "%s, Version: %s, started with:\nTCP Port: %d, Named Pipe: %s\n", my_progname, server_version, mysql_port, mysql_unix_port); #else - fprintf(file,"%s, Version: %s, started with:\nTcp port: %d Unix socket: %s\n", my_progname,server_version,mysql_port,mysql_unix_port); + fprintf(file, "%s, Version: %s, started with:\nTcp port: %d Unix socket: %s\n", my_progname,server_version,mysql_port,mysql_unix_port); #endif fprintf(file,"Time Id Command Argument\n"); (void) fflush(file); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index f74dd0f281c..dd87f40efe9 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -156,6 +156,7 @@ void sql_element_free(void *ptr); #define OPTION_BIN_LOG OPTION_BUFFER_RESULT*2 #define OPTION_AUTO_COMMIT OPTION_BIN_LOG*2 #define OPTION_BEGIN OPTION_AUTO_COMMIT*2 +#define OPTION_QUICK OPTION_BEGIN*2 #define RAID_BLOCK_SIZE 1024 @@ -324,7 +325,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table,List<Item> &fields, thr_lock_type lock_type); void kill_delayed_threads(void); int mysql_delete(THD *thd,TABLE_LIST *table,COND *conds,ha_rows rows, - thr_lock_type lock_type); + thr_lock_type lock_type, ulong options); TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update); TABLE *open_table(THD *thd,const char *db,const char *table,const char *alias, bool *refresh); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b8c77d81bd9..cb82c2782da 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -26,6 +26,10 @@ #include <thr_alarm.h> #include <ft_global.h> +#ifndef DBUG_OFF +#define ONE_THREAD +#endif + #ifdef __cplusplus extern "C" { // Because of SCO 3.2V4.2 #endif @@ -915,7 +919,7 @@ void end_thread(THD *thd, bool put_in_cache) (void) pthread_cond_broadcast(&COND_thread_count); (void) pthread_mutex_unlock(&LOCK_thread_count); DBUG_PRINT("info", ("unlocked thread_count mutex")) -#ifndef DBUG_OFF +#ifdef ONE_THREAD if (!(test_flags & TEST_NO_THREADS)) // For debugging under Linux #endif { @@ -1805,7 +1809,7 @@ static void create_new_thread(THD *thd) thd->real_id=pthread_self(); // Keep purify happy /* Start a new thread to handle connection */ -#ifndef DBUG_OFF +#ifdef ONE_THREAD if (test_flags & TEST_NO_THREADS) // For debugging under Linux { thread_cache_size=0; // Safety @@ -2256,7 +2260,7 @@ static struct option long_options[] = { {"memlock", no_argument, 0, (int) OPT_MEMLOCK}, {"new", no_argument, 0, 'n'}, {"old-protocol", no_argument, 0, 'o'}, -#ifndef DBUG_OFF +#ifdef ONE_THREAD {"one-thread", no_argument, 0, (int) OPT_ONE_THREAD}, #endif {"pid-file", required_argument, 0, (int) OPT_PID_FILE}, @@ -2509,7 +2513,7 @@ static void print_version(void) static void use_help(void) { print_version(); - printf("Use %s --help for a list of available options\n",my_progname); + printf("Use '--help' or '--no-defaults --help' for a list of available options\n"); } static void usage(void) @@ -2569,7 +2573,7 @@ static void usage(void) -n, --new Use very new possible 'unsafe' functions\n\ -o, --old-protocol Use the old (3.20) protocol\n\ -P, --port=... Port number to use for connection\n"); -#ifndef DBUG_OFF +#ifdef ONE_THREAD puts("\ --one-thread Only use one thread (for debugging under Linux)\n"); #endif diff --git a/sql/sql_class.h b/sql/sql_class.h index 34379baedd6..7c67b0e7a4a 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -275,8 +275,8 @@ public: ~THD(); bool store_globals(); inline time_t query_start() { query_start_used=1; return start_time; } - inline void set_time() { if (!user_time) time(&start_time); } - inline void set_time(time_t t) { start_time=t; user_time=1; } + inline void set_time() { if (!user_time) time_after_lock=time(&start_time); } + inline void set_time(time_t t) { time_after_lock=start_time=t; user_time=1; } inline void lock_time() { time(&time_after_lock); } inline void insert_id(ulonglong id) { last_insert_id=id; insert_id_used=1; } diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 3662895a4a3..9cd3c2f0e9b 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -101,7 +101,7 @@ int generate_table(THD *thd, TABLE_LIST *table_list, int mysql_delete(THD *thd,TABLE_LIST *table_list,COND *conds,ha_rows limit, - thr_lock_type lock_type) + thr_lock_type lock_type, ulong options) { int error; TABLE *table; @@ -162,6 +162,8 @@ int mysql_delete(THD *thd,TABLE_LIST *table_list,COND *conds,ha_rows limit, } (void) table->file->extra(HA_EXTRA_NO_READCHECK); + if (options & OPTION_QUICK) + (void) table->file->extra(HA_EXTRA_QUICK); init_read_record(&info,thd,table,select,1,1); ulong deleted=0L; thd->proc_info="updating"; @@ -188,7 +190,9 @@ int mysql_delete(THD *thd,TABLE_LIST *table_list,COND *conds,ha_rows limit, } thd->proc_info="end"; end_read_record(&info); - VOID(table->file->extra(HA_EXTRA_READCHECK)); + (void) table->file->extra(HA_EXTRA_READCHECK); + if (options & OPTION_QUICK) + (void) table->file->extra(HA_EXTRA_NORMAL); if (deleted) { mysql_update_log.write(thd,thd->query, thd->query_length); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 25fd8b0c9ea..e3347aebd5d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -394,6 +394,7 @@ pthread_handler_decl(handle_one_connection,arg) thd->client_capabilities|=CLIENT_IGNORE_SPACE; thd->proc_info=0; // Remove 'login' + thd->command=COM_SLEEP; thd->version=refresh_version; thd->set_time(); init_sql_alloc(&thd->mem_root,8192,8192); @@ -754,7 +755,7 @@ bool do_command(THD *thd) { mysql_log.write(thd,command,NullS); char buff[200]; - ulong uptime = (ulong) (time((time_t*) 0) - start_time); + ulong uptime = (ulong) (thd->start_time - start_time); sprintf((char*) buff, "Uptime: %ld Threads: %d Questions: %lu Slow queries: %ld Opens: %ld Flush tables: %ld Open tables: %d Queries per second avg: %.3f", uptime, @@ -813,7 +814,9 @@ bool do_command(THD *thd) time_t start_of_query=thd->start_time; thd->set_time(); - if ((ulong) (thd->start_time - start_of_query) > long_query_time) + /* If not reading from backup and if the query took too long */ + if (!thd->user_time && + (ulong) (thd->start_time - start_of_query) > long_query_time) { long_query_count++; mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query); @@ -1355,7 +1358,7 @@ mysql_execute_command(void) // Set privilege for the WHERE clause tables->grant.want_privilege=(SELECT_ACL & ~tables->grant.privilege); res = mysql_delete(thd,tables,lex->where,lex->select_limit, - lex->lock_option); + lex->lock_option, lex->options); #ifdef DELETE_ITEMS delete lex->where; #endif @@ -1818,7 +1821,10 @@ check_table_access(THD *thd,uint want_access,TABLE_LIST *tables) return TRUE; // Access denied } if (grant_option) + { + want_access &= ~EXTRA_ACL; // Remove SHOW attribute return check_grant(thd,want_access,org_tables); + } return FALSE; } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 19973ffd77b..27072a501aa 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1023,7 +1023,11 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, { strmov(new_name_buff,new_name); fn_same(new_name_buff,table_name,3); +#ifdef FN_LOWER_CASE + if (!strcasecmp(new_name_buff,table_name)) // Check if name changed +#else if (!strcmp(new_name_buff,table_name)) // Check if name changed +#endif new_name=table_name; // No. Make later check easier else { diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 5e6863178b9..ead4e38628d 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -501,6 +501,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); grant revoke set lock unlock string_list field_options field_option field_opt_list opt_binary table_lock_list table_lock varchar references opt_on_delete opt_on_delete_list opt_on_delete_item use + opt_delete_options opt_delete_option opt_outer table_list table opt_option opt_place opt_low_priority opt_attribute opt_attribute_list attribute column_list column_list_id opt_column_list grant_privileges opt_table user_list grant_option @@ -2085,10 +2086,21 @@ opt_low_priority: /* Delete rows from a table */ delete: - DELETE_SYM opt_low_priority FROM table where_clause delete_limit_clause - { Lex->sql_command= SQLCOM_DELETE; } + DELETE_SYM + { Lex->sql_command= SQLCOM_DELETE; Lex->options=0; + Lex->lock_option= current_thd->update_lock_default; } + opt_delete_options FROM table + where_clause delete_limit_clause +opt_delete_options: + /* empty */ {} + | opt_delete_option opt_delete_options {} + +opt_delete_option: + QUICK { Lex->options|= OPTION_QUICK; } + | LOW_PRIORITY { Lex->lock_option= TL_WRITE_LOW_PRIORITY; } + /* Show things */ show: SHOW { Lex->wild=0;} show_param diff --git a/sql/table.cc b/sql/table.cc index e0270838651..682cd880fe1 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -44,7 +44,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, { reg1 uint i; reg2 uchar *strpos; - int j,flag,error; + int j,error; uint rec_buff_length,n_length,int_length,records,key_parts,keys, interval_count,interval_parts,read_length,db_create_options; ulong pos; @@ -80,8 +80,8 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, if (!outparam->real_name || !outparam->table_name) goto err_end; - flag= (prgflag & CHANGE_FRM) ? O_RDWR : O_RDONLY | O_SHARE; - if ((file=my_open(fn_format(index_file,name,"",reg_ext,4),flag, + if ((file=my_open(fn_format(index_file,name,"",reg_ext,4), + O_RDONLY | O_SHARE, MYF(0))) < 0) { |