diff options
author | monty@donna.mysql.com <> | 2000-11-20 02:57:02 +0200 |
---|---|---|
committer | monty@donna.mysql.com <> | 2000-11-20 02:57:02 +0200 |
commit | 61fd6baf4b466e52192f68fec8e09aa9cca7ead4 (patch) | |
tree | d3f52866508b583c2d4549b66887b4b50aa9fe22 /sql | |
parent | b31d0768794e964852562c0ba307e6eea35f101b (diff) | |
download | mariadb-git-61fd6baf4b466e52192f68fec8e09aa9cca7ead4.tar.gz |
Bug fix for NATURAL JOIN, Split manual sections and more statistic variables
Diffstat (limited to 'sql')
-rw-r--r-- | sql/filesort.cc | 2 | ||||
-rw-r--r-- | sql/mysql_priv.h | 6 | ||||
-rw-r--r-- | sql/mysqld.cc | 3 | ||||
-rw-r--r-- | sql/sql_base.cc | 2 | ||||
-rw-r--r-- | sql/sql_delete.cc | 40 | ||||
-rw-r--r-- | sql/sql_parse.cc | 4 | ||||
-rw-r--r-- | sql/sql_select.cc | 6 | ||||
-rw-r--r-- | sql/sql_update.cc | 16 | ||||
-rw-r--r-- | sql/structs.h | 1 |
9 files changed, 52 insertions, 28 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index 220ff69a3e8..115698a9d79 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -716,6 +716,8 @@ static int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, volatile bool *killed= ¤t_thd->killed; DBUG_ENTER("merge_buffers"); + statistic_increment(filesort_merge_passes, &LOCK_status); + count=error=0; offset=param->sort_length-param->ref_length; maxcount=(ulong) (param->keys/((uint) (Tb-Fb) +1)); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 7081c52ad1d..0fe3b725e34 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -160,6 +160,10 @@ void kill_one_thread(THD *thd, ulong id); #define OPTION_QUICK OPTION_BEGIN*2 #define OPTION_QUOTE_SHOW_CREATE OPTION_QUICK*2 +/* The following is set when parsing the query */ +#define OPTION_NO_INDEX_USED OPTION_QUOTE_SHOW_CREATE*2 +#define OPTION_NO_GOOD_INDEX_USED OPTION_NO_INDEX_USED*2 + #define RAID_BLOCK_SIZE 1024 /* BINLOG_DUMP options */ @@ -445,6 +449,7 @@ extern ulong refresh_version,flush_version, thread_id,query_id,opened_tables, delayed_insert_threads, delayed_insert_writes, delayed_rows_in_use,delayed_insert_errors; extern ulong filesort_rows, filesort_range_count, filesort_scan_count; +extern ulong filesort_merge_passes; extern ulong select_range_check_count, select_range_count, select_scan_count; extern ulong select_full_range_join_count,select_full_join_count; extern uint test_flags,select_errors,mysql_port,ha_open_options; @@ -615,6 +620,7 @@ inline bool add_group_to_list(Item *item,bool asc) inline void mark_as_null_row(TABLE *table) { table->null_row=1; + table->status|=STATUS_NULL_ROW; bfill(table->null_flags,table->null_bytes,255); } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ca529417172..bbacf46dd01 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -222,6 +222,7 @@ ulong query_id=1L,long_query_count,long_query_time,aborted_threads, delayed_queue_size,delayed_insert_threads,delayed_insert_writes, delayed_rows_in_use,delayed_insert_errors,flush_time; ulong filesort_rows, filesort_range_count, filesort_scan_count; +ulong filesort_merge_passes; ulong select_range_check_count, select_range_count, select_scan_count; ulong select_full_range_join_count,select_full_join_count; ulong specialflag=0,opened_tables=0,created_tmp_tables=0, @@ -2517,6 +2518,7 @@ struct show_var_st status_vars[]= { {"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}, + {"Created_tmp_files", (char*) &my_tmp_file_created, SHOW_LONG}, {"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG}, {"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG}, {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG}, @@ -2551,6 +2553,7 @@ struct show_var_st status_vars[]= { {"Slave_running", (char*) &slave_running, SHOW_BOOL}, {"Slow_launch_threads", (char*) &slow_launch_threads, SHOW_LONG}, {"Slow_queries", (char*) &long_query_count, SHOW_LONG}, + {"Sort_merge_passes", (char*) &filesort_merge_passes, SHOW_LONG}, {"Sort_range", (char*) &filesort_range_count, SHOW_LONG}, {"Sort_rows", (char*) &filesort_rows, SHOW_LONG}, {"Sort_scan", (char*) &filesort_scan_count, SHOW_LONG}, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d0877aed1bd..4a5f5e582f3 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1783,6 +1783,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) DBUG_RETURN(1); tmp->fix_length_and_dec(); // Update cmp_type tmp->const_item_cache=0; + /* Mark field used for table cache */ + t1->field[i]->query_id=t2->field[j]->query_id=thd->query_id; cond_and->list.push_back(tmp); if ((tmp_map=t1->field[i]->part_of_key)) { diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 29526b4d7d5..4875be9be6c 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -35,21 +35,21 @@ int generate_table(THD *thd, TABLE_LIST *table_list, thd->proc_info="generate_table"; if(global_read_lock) + { + if(thd->global_read_lock) { - if(thd->global_read_lock) - { - my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0), - table_list->real_name); - DBUG_RETURN(-1); - } - pthread_mutex_lock(&LOCK_open); - while (global_read_lock && ! thd->killed || - thd->version != refresh_version) - { - (void) pthread_cond_wait(&COND_refresh,&LOCK_open); - } - pthread_mutex_unlock(&LOCK_open); + my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0), + table_list->real_name); + DBUG_RETURN(-1); + } + pthread_mutex_lock(&LOCK_open); + while (global_read_lock && ! thd->killed || + thd->version != refresh_version) + { + (void) pthread_cond_wait(&COND_refresh,&LOCK_open); } + pthread_mutex_unlock(&LOCK_open); + } /* If it is a temporary table, close and regenerate it */ @@ -173,14 +173,16 @@ int mysql_delete(THD *thd,TABLE_LIST *table_list,COND *conds,ha_rows limit, } /* If running in safe sql mode, don't allow updates without keys */ - if ((thd->options & OPTION_SAFE_UPDATES) && !table->quick_keys && - limit == HA_POS_ERROR) + if (!table->quick_keys) { - delete select; - send_error(&thd->net,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE); - DBUG_RETURN(1); + thd->options|=OPTION_NO_INDEX_USED; + if ((thd->options & OPTION_SAFE_UPDATES) && limit == HA_POS_ERROR) + { + delete select; + send_error(&thd->net,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE); + DBUG_RETURN(1); + } } - (void) table->file->extra(HA_EXTRA_NO_READCHECK); if (options & OPTION_QUICK) (void) table->file->extra(HA_EXTRA_QUICK); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 79c36431cb1..b2e68e914eb 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -825,7 +825,9 @@ bool do_command(THD *thd) /* If not reading from backup and if the query took too long */ if (!thd->user_time) { - if ((ulong) (thd->start_time - thd->time_after_lock) > long_query_time) + if ((ulong) (thd->start_time - thd->time_after_lock) > long_query_time || + ((thd->options & (OPTION_NO_INDEX_USED | OPTION_NO_GOOD_INDEX_USED)) && + (specialflag & SPECIAL_LONG_LOG_FORMAT))) { long_query_count++; mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9d6742884a5..3aec452fe88 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2420,6 +2420,7 @@ make_join_readinfo(JOIN *join,uint options) /* These init changes read_record */ if (tab->use_quick == 2) { + join->thd->options|=OPTION_NO_GOOD_INDEX_USED; tab->read_first_record= join_init_quick_read_record; statistic_increment(select_range_check_count, &LOCK_status); } @@ -2434,6 +2435,7 @@ make_join_readinfo(JOIN *join,uint options) } else { + join->thd->options|=OPTION_NO_INDEX_USED; statistic_increment(select_scan_count, &LOCK_status); } } @@ -2445,6 +2447,7 @@ make_join_readinfo(JOIN *join,uint options) } else { + join->thd->options|=OPTION_NO_INDEX_USED; statistic_increment(select_full_join_count, &LOCK_status); } } @@ -4234,7 +4237,7 @@ join_read_key(JOIN_TAB *tab) TABLE *table= tab->table; if (cmp_buffer_with_ref(tab) || - (table->status & (STATUS_GARBAGE | STATUS_NO_PARENT))) + (table->status & (STATUS_GARBAGE | STATUS_NO_PARENT | STATUS_NULL_ROW))) { if (tab->ref.key_err) { @@ -4252,6 +4255,7 @@ join_read_key(JOIN_TAB *tab) return 1; } } + table->null_row=0; return table->status ? -1 : 0; } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 29e9c8b8aac..41a1a9be7c2 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -100,15 +100,17 @@ int mysql_update(THD *thd,TABLE_LIST *table_list,List<Item> &fields, DBUG_RETURN(0); } /* If running in safe sql mode, don't allow updates without keys */ - if ((thd->options & OPTION_SAFE_UPDATES) && !table->quick_keys && - limit == HA_POS_ERROR) + if (!table->quick_keys) { - delete select; - table->time_stamp=save_time_stamp; - send_error(&thd->net,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE); - DBUG_RETURN(1); + thd->options|=OPTION_NO_INDEX_USED; + if ((thd->options & OPTION_SAFE_UPDATES) && limit == HA_POS_ERROR) + { + delete select; + table->time_stamp=save_time_stamp; + send_error(&thd->net,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE); + DBUG_RETURN(1); + } } - /* Check if we are modifying a key that we are used to search with */ if (select && select->quick) used_key_is_modified= (!select->quick->unique_key_range() && diff --git a/sql/structs.h b/sql/structs.h index aa28a2b41fb..f1db62f5d9e 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -161,3 +161,4 @@ typedef struct st_lex_user { #define STATUS_NO_PARENT 4 /* Parent record wasn't found */ #define STATUS_NOT_READ 8 /* Record isn't read */ #define STATUS_UPDATED 16 /* Record is updated by formula */ +#define STATUS_NULL_ROW 32 /* table->null_row is set */ |