mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Code cleanup
Fixed bug in optimizer where it didn't choose right table order in some cases myisam/mi_delete.c: Remove not needed include errno.h myisam/mi_delete_table.c: Remove not needed include errno.h myisam/mi_extra.c: Remove not needed include errno.h myisam/mi_locking.c: Remove not needed include errno.h myisam/mi_log.c: Remove not needed include errno.h myisam/mi_page.c: Remove not needed include errno.h myisam/mi_rename.c: Remove not needed include errno.h myisam/mi_update.c: Remove not needed include errno.h myisam/mi_write.c: Remove not needed include errno.h mysql-test/r/subselect.result: Update of test after optimzier fix mysys/charset.c: Code cleanup sql/item_cmpfunc.cc: Removed not needed comment Indentation cleanup sql/item_cmpfunc.h: Indentation cleanup sql/mysqld.cc: Updated comment for expire_logs_days sql/set_var.cc: Remved duplicate code sql/sql_select.cc: Fixed bug in optimizer where it didn't choose right table order in some cases (Bug found and fixed by Igor)
This commit is contained in:
@ -20,10 +20,6 @@
|
||||
#include "rt_index.h"
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef __WIN__
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
static int d_search(MI_INFO *info,MI_KEYDEF *keyinfo,uint comp_flag,
|
||||
uchar *key,uint key_length,my_off_t page,uchar *anc_buff);
|
||||
static int del(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *key,uchar *anc_buff,
|
||||
|
@ -19,9 +19,6 @@
|
||||
*/
|
||||
|
||||
#include "fulltext.h"
|
||||
#ifdef __WIN__
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
int mi_delete_table(const char *name)
|
||||
{
|
||||
|
@ -18,9 +18,6 @@
|
||||
#ifdef HAVE_MMAP
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#ifdef __WIN__
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
Set options and buffers to optimize table handling
|
||||
|
@ -22,9 +22,6 @@
|
||||
*/
|
||||
|
||||
#include "myisamdef.h"
|
||||
#ifdef __WIN__
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
/* lock table by F_UNLCK, F_RDLCK or F_WRLCK */
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include "myisamdef.h"
|
||||
#if defined(MSDOS) || defined(__WIN__)
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#ifndef __WIN__
|
||||
#include <process.h>
|
||||
|
@ -17,9 +17,6 @@
|
||||
/* Read and write key blocks */
|
||||
|
||||
#include "myisamdef.h"
|
||||
#ifdef __WIN__
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
/* Fetch a key-page in memory */
|
||||
|
||||
|
@ -19,9 +19,6 @@
|
||||
*/
|
||||
|
||||
#include "fulltext.h"
|
||||
#ifdef __WIN__
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
int mi_rename(const char *old_name, const char *new_name)
|
||||
{
|
||||
|
@ -19,11 +19,6 @@
|
||||
#include "fulltext.h"
|
||||
#include "rt_index.h"
|
||||
|
||||
#ifdef __WIN__
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
|
||||
int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec)
|
||||
{
|
||||
int flag,key_changed,save_errno;
|
||||
|
@ -20,10 +20,6 @@
|
||||
#include "rt_index.h"
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef __WIN__
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#define MAX_POINTER_LENGTH 8
|
||||
|
||||
/* Functions declared in this file */
|
||||
|
@ -1340,8 +1340,8 @@ a
|
||||
explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 Using index
|
||||
2 DEPENDENT SUBQUERY t1 ref a a 10 func,test.t3.a 1000 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 ref a a 5 func 1001 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 Using where; Using index
|
||||
Warnings:
|
||||
Note 1003 select high_priority test.t2.a AS `a` from test.t2 where <in_optimizer>(test.t2.a,<exists>(select 1 AS `Not_used` from test.t1 join test.t3 where ((test.t1.b = test.t3.a) and (<cache>(test.t2.a) = test.t1.a)) limit 1))
|
||||
insert into t1 values (3,31);
|
||||
|
@ -533,14 +533,15 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags)
|
||||
*/
|
||||
pthread_mutex_lock(&THR_LOCK_charset);
|
||||
|
||||
cs= all_charsets[cs_number];
|
||||
|
||||
if (cs && !(cs->state & MY_CS_COMPILED) && !(cs->state & MY_CS_LOADED))
|
||||
if ((cs= all_charsets[cs_number]))
|
||||
{
|
||||
if (!(cs->state & MY_CS_COMPILED) && !(cs->state & MY_CS_LOADED))
|
||||
{
|
||||
strxmov(get_charsets_dir(buf), cs->csname, ".xml", NullS);
|
||||
my_read_charset_file(buf,flags);
|
||||
}
|
||||
cs= (cs->state & MY_CS_AVAILABLE) ? cs : NULL;
|
||||
}
|
||||
pthread_mutex_unlock(&THR_LOCK_charset);
|
||||
return cs;
|
||||
}
|
||||
|
@ -1658,19 +1658,11 @@ Item_cond::Item_cond(THD *thd, Item_cond &item)
|
||||
and_tables_cache(item.and_tables_cache)
|
||||
{
|
||||
/*
|
||||
here should be following text:
|
||||
|
||||
List_iterator_fast<Item*> li(item.list);
|
||||
while(Item *it= li++)
|
||||
list.push_back(it);
|
||||
|
||||
but it do not need,
|
||||
because this constructor used only for AND/OR and
|
||||
argument list will be copied by copy_andor_arguments call
|
||||
item->list will be copied by copy_andor_arguments() call
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Item_cond::copy_andor_arguments(THD *thd, Item_cond *item)
|
||||
{
|
||||
List_iterator_fast<Item> li(item->list);
|
||||
@ -1678,6 +1670,7 @@ void Item_cond::copy_andor_arguments(THD *thd, Item_cond *item)
|
||||
list.push_back(it->copy_andor_structure(thd));
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
|
||||
{
|
||||
|
@ -4619,7 +4619,7 @@ The minimum value for this variable is 4096.",
|
||||
(gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
|
||||
REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
|
||||
{"expire_logs_days", OPT_EXPIRE_LOGS_DAYS,
|
||||
"Logs will be rotated after expire-log-days days ",
|
||||
"Binary logs will be rotated after expire-log-days days ",
|
||||
(gptr*) &expire_logs_days,
|
||||
(gptr*) &expire_logs_days, 0, GET_ULONG,
|
||||
REQUIRED_ARG, 0, 0, 99, 0, 1, 0},
|
||||
|
@ -2629,11 +2629,6 @@ ulong fix_sql_mode(ulong sql_mode)
|
||||
MODE_IGNORE_SPACE |
|
||||
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
||||
MODE_NO_FIELD_OPTIONS);
|
||||
if (sql_mode & MODE_MSSQL)
|
||||
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
||||
MODE_IGNORE_SPACE |
|
||||
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
||||
MODE_NO_FIELD_OPTIONS);
|
||||
if (sql_mode & MODE_POSTGRESQL)
|
||||
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
||||
MODE_IGNORE_SPACE |
|
||||
@ -2644,11 +2639,6 @@ ulong fix_sql_mode(ulong sql_mode)
|
||||
MODE_IGNORE_SPACE |
|
||||
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
||||
MODE_NO_FIELD_OPTIONS);
|
||||
if (sql_mode & MODE_DB2)
|
||||
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
||||
MODE_IGNORE_SPACE |
|
||||
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
||||
MODE_NO_FIELD_OPTIONS);
|
||||
if (sql_mode & MODE_MAXDB)
|
||||
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
||||
MODE_IGNORE_SPACE |
|
||||
|
@ -2688,22 +2688,35 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
|
||||
do
|
||||
{
|
||||
uint keypart=keyuse->keypart;
|
||||
uint found_part_ref_or_null= KEY_OPTIMIZE_REF_OR_NULL;
|
||||
table_map best_part_found_ref= 0;
|
||||
double best_prev_record_reads= DBL_MAX;
|
||||
do
|
||||
{
|
||||
if (!(rest_tables & keyuse->used_tables) &&
|
||||
!(found_ref_or_null & keyuse->optimize))
|
||||
{
|
||||
found_part|=keyuse->keypart_map;
|
||||
found_ref|= keyuse->used_tables;
|
||||
double tmp= prev_record_reads(join,
|
||||
(found_ref |
|
||||
keyuse->used_tables));
|
||||
if (tmp < best_prev_record_reads)
|
||||
{
|
||||
best_part_found_ref= keyuse->used_tables;
|
||||
best_prev_record_reads= tmp;
|
||||
}
|
||||
if (rec > keyuse->ref_table_rows)
|
||||
rec= keyuse->ref_table_rows;
|
||||
found_part_ref_or_null&= keyuse->optimize;
|
||||
/*
|
||||
If there is one 'key_column IS NULL' expression, we can
|
||||
use this ref_or_null optimsation of this field
|
||||
*/
|
||||
found_ref_or_null|= (keyuse->optimize &
|
||||
KEY_OPTIMIZE_REF_OR_NULL);
|
||||
}
|
||||
keyuse++;
|
||||
found_ref_or_null|= found_part_ref_or_null;
|
||||
} while (keyuse->table == table && keyuse->key == key &&
|
||||
keyuse->keypart == keypart);
|
||||
found_ref|= best_part_found_ref;
|
||||
} while (keyuse->table == table && keyuse->key == key);
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user