Commit fae46f7c authored by unknown's avatar unknown

merge


sql/item_subselect.h:
  Auto merged
parents 4d9cbc26 bcf562fc
......@@ -898,7 +898,7 @@ int ha_myisam::index_read(byte * buf, const byte * key,
uint key_len, enum ha_rkey_function find_flag)
{
statistic_increment(ha_read_key_count,&LOCK_status);
int error=mi_rkey(file,buf,active_index, key, key_len, (enum ha_rkey_function)find_flag);
int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
table->status=error ? STATUS_NOT_FOUND: 0;
return error;
}
......@@ -907,7 +907,7 @@ int ha_myisam::index_read_idx(byte * buf, uint index, const byte * key,
uint key_len, enum ha_rkey_function find_flag)
{
statistic_increment(ha_read_key_count,&LOCK_status);
int error=mi_rkey(file,buf,index, key, key_len, (enum ha_rkey_function)find_flag);
int error=mi_rkey(file,buf,index, key, key_len, find_flag);
table->status=error ? STATUS_NOT_FOUND: 0;
return error;
}
......
......@@ -36,7 +36,7 @@ inline Item * and_items(Item* cond, Item *item)
Item_subselect::Item_subselect():
Item_result_field(), engine_owner(1), value_assigned(0), substitution(0),
have_to_be_excluded(0), engine_changed(0)
engine(0), have_to_be_excluded(0), engine_changed(0)
{
reset();
/*
......@@ -46,6 +46,7 @@ Item_subselect::Item_subselect():
null_value= 1;
}
void Item_subselect::init(st_select_lex *select_lex,
select_subselect *result)
{
......@@ -61,6 +62,7 @@ void Item_subselect::init(st_select_lex *select_lex,
DBUG_VOID_RETURN;
}
Item_subselect::~Item_subselect()
{
if (engine_owner)
......@@ -763,6 +765,7 @@ Item_in_subselect::row_value_transformer(JOIN *join,
DBUG_RETURN(RES_OK);
}
Item_subselect::trans_res
Item_in_subselect::select_transformer(JOIN *join)
{
......@@ -772,6 +775,7 @@ Item_in_subselect::select_transformer(JOIN *join)
return row_value_transformer(join, left_expr);
}
Item_subselect::trans_res
Item_allany_subselect::select_transformer(JOIN *join)
{
......@@ -798,6 +802,7 @@ subselect_single_select_engine(st_select_lex *select,
this->select_lex= select_lex;
}
subselect_union_engine::subselect_union_engine(st_select_lex_unit *u,
select_subselect *result,
Item_subselect *item)
......@@ -991,6 +996,7 @@ int subselect_union_engine::exec()
return res;
}
int subselect_uniquesubquery_engine::exec()
{
DBUG_ENTER("subselect_uniquesubquery_engine::exec");
......@@ -1012,34 +1018,22 @@ int subselect_uniquesubquery_engine::exec()
{
error= 0;
table->null_row= 0;
if (table->status)
((Item_in_subselect *) item)->value= 0;
else
((Item_in_subselect *) item)->value= (!cond || cond->val_int()?1:0);
((Item_in_subselect *) item)->value= (!table->status &&
(!cond || cond->val_int()) ? 1 :
0);
}
}
DBUG_RETURN(end_exec(table) || (error != 0));
DBUG_RETURN(error != 0);
}
int subselect_uniquesubquery_engine::end_exec(TABLE *table)
subselect_uniquesubquery_engine::~subselect_uniquesubquery_engine()
{
DBUG_ENTER("subselect_uniquesubquery_engine::end_exec");
int error=0, tmp;
if ((tmp= table->file->extra(HA_EXTRA_NO_CACHE)))
{
DBUG_PRINT("error", ("extra(HA_EXTRA_NO_CACHE) failed"));
error= 1;
}
if ((tmp= table->file->index_end()))
{
DBUG_PRINT("error", ("index_end() failed"));
error= 1;
}
if (error == 1)
table->file->print_error(tmp, MYF(0));
DBUG_RETURN(error != 0);
/* Tell handler we don't need the index anymore */
tab->table->file->index_end();
}
int subselect_indexsubquery_engine::exec()
{
DBUG_ENTER("subselect_indexsubselect_engine::exec");
......@@ -1048,9 +1042,11 @@ int subselect_indexsubquery_engine::exec()
TABLE *table= tab->table;
((Item_in_subselect *) item)->value= 0;
if (check_null)
{
*tab->null_ref_key= 0;
/* We need to check for NULL if there wasn't a matching value */
*tab->null_ref_key= 0; // Search first for not null
((Item_in_subselect *) item)->was_null= 0;
}
......@@ -1068,7 +1064,7 @@ int subselect_indexsubquery_engine::exec()
error= report_error(table, error);
else
{
for(;;)
for (;;)
{
error= 0;
table->null_row= 0;
......@@ -1080,7 +1076,7 @@ int subselect_indexsubquery_engine::exec()
((Item_in_subselect *) item)->was_null= 1;
else
((Item_in_subselect *) item)->value= 1;
goto finish;
break;
}
error= table->file->index_next_same(table->record[0],
tab->ref.key_buff,
......@@ -1088,25 +1084,26 @@ int subselect_indexsubquery_engine::exec()
if (error && error != HA_ERR_END_OF_FILE)
{
error= report_error(table, error);
goto finish;
break;
}
}
else
{
if (!check_null || null_finding)
goto finish;
break; /* We don't need to check nulls */
*tab->null_ref_key= 1;
null_finding= 1;
if (safe_index_read(tab))
goto finish;
/* Check if there exists a row with a null value in the index */
if ((error= safe_index_read(tab)))
break;
}
}
}
}
finish:
DBUG_RETURN(end_exec(table) || (error != 0));
DBUG_RETURN(error != 0);
}
uint subselect_single_select_engine::cols()
{
return select_lex->item_list.elements;
......
......@@ -243,6 +243,7 @@ class Item_in_subselect :public Item_exists_subselect
friend class subselect_indexsubquery_engine;
};
/* ALL/ANY/SOME subselect */
class Item_allany_subselect :public Item_in_subselect
{
......@@ -258,6 +259,7 @@ class Item_allany_subselect :public Item_in_subselect
trans_res select_transformer(JOIN *join);
};
class subselect_engine: public Sql_alloc
{
protected:
......@@ -292,6 +294,7 @@ class subselect_engine: public Sql_alloc
bool may_be_null() { return maybe_null; };
};
class subselect_single_select_engine: public subselect_engine
{
my_bool prepared; /* simple subselect is prepared */
......@@ -312,6 +315,7 @@ class subselect_single_select_engine: public subselect_engine
void exclude();
};
class subselect_union_engine: public subselect_engine
{
st_select_lex_unit *unit; /* corresponding unit structure */
......@@ -328,6 +332,7 @@ class subselect_union_engine: public subselect_engine
void exclude();
};
struct st_join_table;
class subselect_uniquesubquery_engine: public subselect_engine
{
......@@ -343,17 +348,17 @@ class subselect_uniquesubquery_engine: public subselect_engine
{
set_thd(thd);
}
~subselect_uniquesubquery_engine();
int prepare();
void fix_length_and_dec(Item_cache** row);
int exec();
uint cols() { return 1; }
bool dependent() { return 1; }
bool uncacheable() { return 1; }
void exclude();
static int end_exec(TABLE *table);
void exclude();
};
class subselect_indexsubquery_engine: public subselect_uniquesubquery_engine
{
bool check_null;
......
......@@ -1564,7 +1564,7 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
VOID(pthread_mutex_unlock(&LOCK_log));
return 0;
}
if ((specialflag & SPECIAL_LONG_LOG_FORMAT) || query_start_arg)
if (!(specialflag & SPECIAL_SHORT_LOG_FORMAT) || query_start_arg)
{
current_time=time(NULL);
if (current_time != last_time)
......@@ -1617,7 +1617,7 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
// Save value if we do an insert.
if (thd->insert_id_used)
{
if (specialflag & SPECIAL_LONG_LOG_FORMAT)
if (!(specialflag & SPECIAL_SHORT_LOG_FORMAT))
{
end=strmov(end,",insert_id=");
end=longlong10_to_str((longlong) thd->last_insert_id,end,-10);
......
......@@ -262,6 +262,8 @@ my_bool opt_log_slave_updates= 0;
my_bool opt_console= 0, opt_bdb, opt_innodb, opt_isam;
my_bool opt_readonly, use_temp_pool, relay_log_purge;
my_bool opt_secure_auth= 0;
my_bool opt_short_log_format= 0;
my_bool opt_log_queries_not_using_indexes= 0;
volatile bool mqh_used = 0;
uint mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options;
......@@ -3455,7 +3457,7 @@ enum options
OPT_SKIP_PRIOR, OPT_BIG_TABLES,
OPT_STANDALONE, OPT_ONE_THREAD,
OPT_CONSOLE, OPT_LOW_PRIORITY_UPDATES,
OPT_SKIP_HOST_CACHE, OPT_LONG_FORMAT,
OPT_SKIP_HOST_CACHE, OPT_SHORT_LOG_FORMAT,
OPT_FLUSH, OPT_SAFE,
OPT_BOOTSTRAP, OPT_SKIP_SHOW_DB,
OPT_TABLE_TYPE, OPT_INIT_FILE,
......@@ -3562,7 +3564,8 @@ enum options
OPT_DEFAULT_WEEK_FORMAT,
OPT_GROUP_CONCAT_MAX_LEN,
OPT_DEFAULT_COLLATION,
OPT_SECURE_AUTH
OPT_SECURE_AUTH,
OPT_LOG_QUERIES_NOT_USING_INDEXES
};
......@@ -3769,9 +3772,17 @@ Disable with --skip-bdb (will save memory).",
"Log slow queries to this log file. Defaults logging to hostname-slow.log file.",
(gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
0, 0, 0, 0, 0, 0},
{"log-long-format", OPT_LONG_FORMAT,
"Log some extra information to update log.", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0},
{"log-long-format", '0',
"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-short-format", OPT_SHORT_LOG_FORMAT,
"Don't log extra information to update and slow-query logs.",
(gptr*) &opt_short_log_format, (gptr*) &opt_short_log_format,
0, GET_BOOL, 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.",
(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-slave-updates", OPT_LOG_SLAVE_UPDATES,
"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,
......@@ -5166,9 +5177,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case (int) OPT_SKIP_RESOLVE:
opt_specialflag|=SPECIAL_NO_RESOLVE;
break;
case (int) OPT_LONG_FORMAT:
opt_specialflag|=SPECIAL_LONG_LOG_FORMAT;
break;
case (int) OPT_SKIP_NETWORKING:
opt_disable_networking=1;
mysqld_port=0;
......@@ -5508,6 +5516,10 @@ static void get_options(int argc,char **argv)
keybuff_size= (((KEY_CACHE *) find_named(&key_caches, "default", 7,
&not_used))->size);
}
if (opt_short_log_format)
opt_specialflag|= SPECIAL_SHORT_LOG_FORMAT;
if (opt_log_queries_not_using_indexes)
opt_specialflag|= SPECIAL_LOG_QUERIES_NOT_USING_INDEXES;
}
......@@ -5622,14 +5634,16 @@ static uint set_maximum_open_files(uint max_file_limit)
rlimit.rlim_cur=rlimit.rlim_max=max_file_limit;
if (setrlimit(RLIMIT_NOFILE,&rlimit))
{
sql_print_error("Warning: setrlimit couldn't increase number of open files to more than %lu (request: %u)",
old_cur, max_file_limit); /* purecov: inspected */
if (global_system_variables.log_warnings)
sql_print_error("Warning: setrlimit couldn't increase number of open files to more than %lu (request: %u)",
old_cur, max_file_limit); /* purecov: inspected */
max_file_limit=old_cur;
}
else
{
(void) getrlimit(RLIMIT_NOFILE,&rlimit);
if ((uint) rlimit.rlim_cur != max_file_limit)
if ((uint) rlimit.rlim_cur != max_file_limit &&
global_system_variables.log_warnings)
sql_print_error("Warning: setrlimit returned ok, but didn't change limits. Max open files is %ld (request: %u)",
(ulong) rlimit.rlim_cur,
max_file_limit); /* purecov: inspected */
......
......@@ -1566,7 +1566,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->variables.long_query_time ||
((thd->lex.select_lex.options &
(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED)) &&
(specialflag & SPECIAL_LONG_LOG_FORMAT)))
(specialflag & SPECIAL_LOG_QUERIES_NOT_USING_INDEXES)))
{
long_query_count++;
mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
......
......@@ -6661,7 +6661,9 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
usable_keys=0;
break;
}
usable_keys&=((Item_field*) (*tmp_order->item))->field->part_of_sortkey;
if (!(usable_keys&= (((Item_field*) (*tmp_order->item))->field->
part_of_sortkey)))
break; // No usable keys
}
ref_key= -1;
......
......@@ -107,8 +107,9 @@
#define SPECIAL_NO_PRIOR 128 /* Don't prioritize threads */
#define SPECIAL_BIG_SELECTS 256 /* Don't use heap tables */
#define SPECIAL_NO_HOST_CACHE 512 /* Don't cache hosts */
#define SPECIAL_LONG_LOG_FORMAT 1024
#define SPECIAL_SHORT_LOG_FORMAT 1024
#define SPECIAL_SAFE_MODE 2048
#define SPECIAL_LOG_QUERIES_NOT_USING_INDEXES 4096 /* Log q not using indexes */
/* Extern defines */
#define store_record(A,B) bmove_align((A)->B,(A)->record[0],(size_t) (A)->reclength)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment