Commit 2c951d4c authored by unknown's avatar unknown

Merge laptop.sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1

into laptop.sanja.is.com.ua:/home/bell/mysql/bk/work-constructors-4.1


sql/item_subselect.cc:
  Auto merged
sql/item_subselect.h:
  Auto merged
parents 1fded9e1 d1ab51eb
......@@ -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;
}
......
This diff is collapsed.
......@@ -64,7 +64,7 @@ class Item_subselect :public Item_result_field
pointer in constructor initialization list, but we need pass pointer
to subselect Item class to select_subselect classes constructor.
*/
virtual void init (THD *thd, st_select_lex *select_lex,
virtual void init (st_select_lex *select_lex,
select_subselect *result);
~Item_subselect();
......@@ -111,7 +111,7 @@ class Item_singlerow_subselect :public Item_subselect
protected:
Item_cache *value, **row;
public:
Item_singlerow_subselect(THD *thd, st_select_lex *select_lex);
Item_singlerow_subselect(st_select_lex *select_lex);
Item_singlerow_subselect() :Item_subselect(), value(0), row (0) {}
subs_type substype() { return SINGLEROW_SUBS; }
......@@ -139,7 +139,7 @@ class Item_singlerow_subselect :public Item_subselect
class Item_maxmin_subselect: public Item_singlerow_subselect
{
public:
Item_maxmin_subselect(THD *thd, st_select_lex *select_lex, bool max);
Item_maxmin_subselect(st_select_lex *select_lex, bool max);
};
/* exists subselect */
......@@ -150,7 +150,7 @@ class Item_exists_subselect :public Item_subselect
longlong value; /* value of this item (boolean: exists/not-exists) */
public:
Item_exists_subselect(THD *thd, st_select_lex *select_lex);
Item_exists_subselect(st_select_lex *select_lex);
Item_exists_subselect(): Item_subselect() {}
subs_type substype() { return EXISTS_SUBS; }
......@@ -187,7 +187,7 @@ class Item_in_subselect :public Item_exists_subselect
public:
Item_func_not_all *upper_not; // point on NOT before ALL subquery
Item_in_subselect(THD *thd, Item * left_expr, st_select_lex *select_lex);
Item_in_subselect(Item * left_expr, st_select_lex *select_lex);
Item_in_subselect()
:Item_exists_subselect(), abort_on_null(0), upper_not(0) {}
......@@ -215,6 +215,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
{
......@@ -222,7 +223,7 @@ class Item_allany_subselect :public Item_in_subselect
compare_func_creator func;
public:
Item_allany_subselect(THD *thd, Item * left_expr, compare_func_creator f,
Item_allany_subselect(Item * left_expr, compare_func_creator f,
st_select_lex *select_lex);
// only ALL subquery has upper not
......@@ -230,6 +231,7 @@ class Item_allany_subselect :public Item_in_subselect
trans_res select_transformer(JOIN *join);
};
class subselect_engine: public Sql_alloc
{
protected:
......@@ -240,16 +242,19 @@ class subselect_engine: public Sql_alloc
bool maybe_null; /* may be null (first item in select) */
public:
subselect_engine(THD *thd, Item_subselect *si, select_subselect *res)
subselect_engine(Item_subselect *si, select_subselect *res)
:thd(0)
{
result= res;
item= si;
this->thd= thd;
res_type= STRING_RESULT;
maybe_null= 0;
}
virtual ~subselect_engine() {}; // to satisfy compiler
// set_thd should be called before prepare()
void set_thd(THD *thd) { this->thd= thd; }
THD * get_thd() { return thd; }
virtual int prepare()= 0;
virtual void fix_length_and_dec(Item_cache** row)= 0;
virtual int exec()= 0;
......@@ -261,6 +266,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 */
......@@ -269,7 +275,7 @@ class subselect_single_select_engine: public subselect_engine
st_select_lex *select_lex; /* corresponding select_lex */
JOIN * join; /* corresponding JOIN structure */
public:
subselect_single_select_engine(THD *thd, st_select_lex *select,
subselect_single_select_engine(st_select_lex *select,
select_subselect *result,
Item_subselect *item);
int prepare();
......@@ -281,12 +287,12 @@ 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 */
public:
subselect_union_engine(THD *thd,
st_select_lex_unit *u,
subselect_union_engine(st_select_lex_unit *u,
select_subselect *result,
Item_subselect *item);
int prepare();
......@@ -298,6 +304,7 @@ class subselect_union_engine: public subselect_engine
void exclude();
};
struct st_join_table;
class subselect_uniquesubquery_engine: public subselect_engine
{
......@@ -306,11 +313,14 @@ class subselect_uniquesubquery_engine: public subselect_engine
Item *cond;
public:
// constructor can assign THD because it will be called after JOIN::prepare
subselect_uniquesubquery_engine(THD *thd, st_join_table *tab_arg,
Item_subselect *subs, Item *where)
:subselect_engine(thd, subs, 0), tab(tab_arg), cond(where)
{}
:subselect_engine(subs, 0), tab(tab_arg), cond(where)
{
set_thd(thd);
}
~subselect_uniquesubquery_engine();
int prepare();
void fix_length_and_dec(Item_cache** row);
int exec();
......@@ -318,13 +328,15 @@ class subselect_uniquesubquery_engine: public subselect_engine
bool dependent() { return 1; }
bool uncacheable() { return 1; }
void exclude();
static int end_exec(TABLE *table);
};
class subselect_indexsubquery_engine: public subselect_uniquesubquery_engine
{
bool check_null;
public:
// constructor can assign THD because it will be called after JOIN::prepare
subselect_indexsubquery_engine(THD *thd, st_join_table *tab_arg,
Item_subselect *subs, Item *where,
bool chk_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,6 +5634,7 @@ static uint set_maximum_open_files(uint max_file_limit)
rlimit.rlim_cur=rlimit.rlim_max=max_file_limit;
if (setrlimit(RLIMIT_NOFILE,&rlimit))
{
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;
......@@ -5629,7 +5642,8 @@ static uint set_maximum_open_files(uint max_file_limit)
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;
......
......@@ -2238,10 +2238,10 @@ expr_expr:
| expr NOT IN_SYM '(' expr_list ')'
{ $5->push_front($1); $$= new Item_func_not(new Item_func_in(*$5)); }
| expr IN_SYM in_subselect
{ $$= new Item_in_subselect(YYTHD, $1, $3); }
{ $$= new Item_in_subselect($1, $3); }
| expr NOT IN_SYM in_subselect
{
$$= new Item_func_not(new Item_in_subselect(YYTHD, $1, $4));
$$= new Item_func_not(new Item_in_subselect($1, $4));
}
| expr BETWEEN_SYM no_and_expr AND expr
{ $$= new Item_func_between($1,$3,$5); }
......@@ -2263,7 +2263,7 @@ expr_expr:
| expr comp_op all_or_any in_subselect %prec EQ
{
Item_allany_subselect *it=
new Item_allany_subselect(YYTHD, $1, (*$2)($3), $4);
new Item_allany_subselect($1, (*$2)($3), $4);
if ($3)
$$ = it->upper_not= new Item_func_not_all(it); /* ALL */
else
......@@ -2309,7 +2309,7 @@ no_in_expr:
| no_in_expr comp_op all_or_any in_subselect %prec EQ
{
Item_allany_subselect *it=
new Item_allany_subselect(YYTHD, $1, (*$2)($3), $4);
new Item_allany_subselect($1, (*$2)($3), $4);
if ($3)
$$ = it->upper_not= new Item_func_not_all(it); /* ALL */
else
......@@ -2340,10 +2340,10 @@ no_and_expr:
| no_and_expr NOT IN_SYM '(' expr_list ')'
{ $5->push_front($1); $$= new Item_func_not(new Item_func_in(*$5)); }
| no_and_expr IN_SYM in_subselect
{ $$= new Item_in_subselect(YYTHD, $1, $3); }
{ $$= new Item_in_subselect($1, $3); }
| no_and_expr NOT IN_SYM in_subselect
{
$$= new Item_func_not(new Item_in_subselect(YYTHD, $1, $4));
$$= new Item_func_not(new Item_in_subselect($1, $4));
}
| no_and_expr BETWEEN_SYM no_and_expr AND expr
{ $$= new Item_func_between($1,$3,$5); }
......@@ -2364,7 +2364,7 @@ no_and_expr:
| no_and_expr comp_op all_or_any in_subselect %prec EQ
{
Item_allany_subselect *it=
new Item_allany_subselect(YYTHD, $1, (*$2)($3), $4);
new Item_allany_subselect($1, (*$2)($3), $4);
if ($3)
$$ = it->upper_not= new Item_func_not_all(it); /* ALL */
else
......@@ -5356,9 +5356,8 @@ singlerow_subselect:
singlerow_subselect_init:
select_init2
{
$$= new Item_singlerow_subselect(YYTHD,
Lex->current_select->master_unit()->
first_select());
$$= new Item_singlerow_subselect(Lex->current_select->
master_unit()->first_select());
};
exists_subselect:
......@@ -5371,8 +5370,7 @@ exists_subselect:
exists_subselect_init:
select_init2
{
$$= new Item_exists_subselect(YYTHD,
Lex->current_select->master_unit()->
$$= new Item_exists_subselect(Lex->current_select->master_unit()->
first_select());
};
......
......@@ -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