mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.0
into ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.0
This commit is contained in:
commit
36dbdf016d
17 changed files with 183 additions and 15 deletions
|
@ -54,3 +54,19 @@ select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1;
|
|||
collation(a) collation(b) collation(binary 'ccc')
|
||||
cp1251_bin binary binary
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
a varchar(16) character set cp1251 collate cp1251_bin not null,
|
||||
b int(10) default null,
|
||||
primary key(a)
|
||||
) charset=cp1251;
|
||||
insert into t1 (a) values ('air'),
|
||||
('we'),('g'),('we_toshko'), ('s0urce'),('we_ivo'),('we_iliyan'),
|
||||
('we_martin'),('vw_grado'),('vw_vasko'),('tn_vili'),('tn_kalina'),
|
||||
('tn_fakira'),('vw_silvia'),('vw_starshi'),('vw_geo'),('vw_b0x1');
|
||||
select * from t1 where a like 'we_%';
|
||||
a b
|
||||
we_iliyan NULL
|
||||
we_ivo NULL
|
||||
we_martin NULL
|
||||
we_toshko NULL
|
||||
drop table t1;
|
||||
|
|
|
@ -669,12 +669,24 @@ select charset(max(a)), coercibility(max(a)),
|
|||
charset(min(a)), coercibility(min(a)) from t1;
|
||||
charset(max(a)) coercibility(max(a)) charset(min(a)) coercibility(min(a))
|
||||
latin2 2 latin2 2
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(1) character set latin2 default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
create table t2 select max(a),min(a) from t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`max(a)` varchar(1) character set latin2 default NULL,
|
||||
`min(a)` varchar(1) character set latin2 default NULL
|
||||
`max(a)` char(1) character set latin2 default NULL,
|
||||
`min(a)` char(1) character set latin2 default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t2;
|
||||
create table t2 select concat(a) from t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`concat(a)` varchar(1) character set latin2 default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t2,t1;
|
||||
create table t1 (a int);
|
||||
|
@ -757,6 +769,15 @@ one 2
|
|||
two 2
|
||||
three 1
|
||||
drop table t1;
|
||||
create table t1(a int, b datetime);
|
||||
insert into t1 values (1, NOW()), (2, NOW());
|
||||
create table t2 select MAX(b) from t1 group by a;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`MAX(b)` datetime default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1, t2;
|
||||
create table t1(f1 datetime);
|
||||
insert into t1 values (now());
|
||||
create table t2 select f2 from (select max(now()) f2 from t1) a;
|
||||
|
|
|
@ -129,7 +129,7 @@ FOUND_ROWS()
|
|||
1
|
||||
execute stmt1;
|
||||
FOUND_ROWS()
|
||||
0
|
||||
1
|
||||
deallocate prepare stmt1;
|
||||
drop table t1;
|
||||
create table t1
|
||||
|
|
|
@ -246,6 +246,31 @@ SELECT FOUND_ROWS();
|
|||
FOUND_ROWS()
|
||||
0
|
||||
DROP TABLE t1;
|
||||
SELECT 'foo';
|
||||
foo
|
||||
foo
|
||||
SELECT FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
1
|
||||
SELECT SQL_CALC_FOUND_ROWS 'foo';
|
||||
foo
|
||||
foo
|
||||
SELECT FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
1
|
||||
SELECT SQL_CALC_FOUND_ROWS 'foo' limit 0;
|
||||
foo
|
||||
SELECT FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
1
|
||||
SELECT FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
1
|
||||
SELECT SQL_CALC_FOUND_ROWS 'foo' UNION SELECT 'bar' LIMIT 0;
|
||||
foo
|
||||
SELECT FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
2
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
INSERT INTO t1 VALUES (1,2), (1,3), (1,4), (1,5);
|
||||
SELECT SQL_CALC_FOUND_ROWS DISTINCT 'a' FROM t1 GROUP BY b LIMIT 2;
|
||||
|
|
|
@ -78,4 +78,19 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 SIMPLE t2 ref b b 21 test.t1.b 6 Using where
|
||||
SET MAX_SEEKS_FOR_KEY=DEFAULT;
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2),(3),(4),(5);
|
||||
insert into t1 select * from t1;
|
||||
insert into t1 select * from t1;
|
||||
insert into t1 select * from t1;
|
||||
set local max_join_size=8;
|
||||
select * from (select * from t1) x;
|
||||
ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay
|
||||
set local max_join_size=1;
|
||||
select * from (select * from t1 a, t1 b) x;
|
||||
ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay
|
||||
set local max_join_size=1;
|
||||
select * from (select 1 union select 2 union select 3) x;
|
||||
ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay
|
||||
drop table t1;
|
||||
SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT;
|
||||
|
|
|
@ -254,7 +254,7 @@ create table t1 (a int not null);
|
|||
create table t2 select max(a) from t1;
|
||||
show columns from t2;
|
||||
Field Type Null Key Default Extra
|
||||
max(a) bigint(20) YES NULL
|
||||
max(a) int(11) YES NULL
|
||||
drop table t1,t2;
|
||||
create table t1 (c decimal, d double, f float, r real);
|
||||
show columns from t1;
|
||||
|
|
|
@ -32,3 +32,17 @@ select * from t1 where lower(b)='bbb';
|
|||
select charset(a), charset(b), charset(binary 'ccc') from t1 limit 1;
|
||||
select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1;
|
||||
drop table t1;
|
||||
|
||||
# Test for BUG#8560
|
||||
create table t1 (
|
||||
a varchar(16) character set cp1251 collate cp1251_bin not null,
|
||||
b int(10) default null,
|
||||
primary key(a)
|
||||
) charset=cp1251;
|
||||
insert into t1 (a) values ('air'),
|
||||
('we'),('g'),('we_toshko'), ('s0urce'),('we_ivo'),('we_iliyan'),
|
||||
('we_martin'),('vw_grado'),('vw_vasko'),('tn_vili'),('tn_kalina'),
|
||||
('tn_fakira'),('vw_silvia'),('vw_starshi'),('vw_geo'),('vw_b0x1');
|
||||
|
||||
select * from t1 where a like 'we_%';
|
||||
drop table t1;
|
||||
|
|
|
@ -395,8 +395,12 @@ create table t1 (a char character set latin2);
|
|||
insert into t1 values ('a'),('b');
|
||||
select charset(max(a)), coercibility(max(a)),
|
||||
charset(min(a)), coercibility(min(a)) from t1;
|
||||
show create table t1;
|
||||
create table t2 select max(a),min(a) from t1;
|
||||
show create table t2;
|
||||
drop table t2;
|
||||
create table t2 select concat(a) from t1;
|
||||
show create table t2;
|
||||
drop table t2,t1;
|
||||
|
||||
#
|
||||
|
@ -479,6 +483,15 @@ INSERT INTO t1 VALUES
|
|||
select val, count(*) from t1 group by val;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug #5615: type of aggregate function column wrong when using group by
|
||||
#
|
||||
|
||||
create table t1(a int, b datetime);
|
||||
insert into t1 values (1, NOW()), (2, NOW());
|
||||
create table t2 select MAX(b) from t1 group by a;
|
||||
show create table t2;
|
||||
drop table t1, t2;
|
||||
|
||||
#
|
||||
# Bug 7833: Wrong datatype of aggregate column is returned
|
||||
|
|
|
@ -167,6 +167,21 @@ SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a = 0 GROUP BY a HAVING a > 10;
|
|||
SELECT FOUND_ROWS();
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #6089: queries which don't use any tables
|
||||
#
|
||||
|
||||
SELECT 'foo';
|
||||
SELECT FOUND_ROWS();
|
||||
SELECT SQL_CALC_FOUND_ROWS 'foo';
|
||||
SELECT FOUND_ROWS();
|
||||
SELECT SQL_CALC_FOUND_ROWS 'foo' limit 0;
|
||||
SELECT FOUND_ROWS();
|
||||
SELECT FOUND_ROWS();
|
||||
|
||||
SELECT SQL_CALC_FOUND_ROWS 'foo' UNION SELECT 'bar' LIMIT 0;
|
||||
SELECT FOUND_ROWS();
|
||||
|
||||
#
|
||||
# Bug #7945: group by + distinct with constant expression + limit
|
||||
#
|
||||
|
|
|
@ -66,4 +66,24 @@ SET MAX_SEEKS_FOR_KEY=DEFAULT;
|
|||
|
||||
drop table t1;
|
||||
|
||||
# BUG#8726
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2),(3),(4),(5);
|
||||
insert into t1 select * from t1;
|
||||
insert into t1 select * from t1;
|
||||
insert into t1 select * from t1;
|
||||
|
||||
set local max_join_size=8;
|
||||
--error 1104
|
||||
select * from (select * from t1) x;
|
||||
|
||||
set local max_join_size=1;
|
||||
--error 1104
|
||||
select * from (select * from t1 a, t1 b) x;
|
||||
|
||||
set local max_join_size=1;
|
||||
--error 1104
|
||||
select * from (select 1 union select 2 union select 3) x;
|
||||
drop table t1;
|
||||
|
||||
SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#endif
|
||||
|
||||
#include "mysql_priv.h"
|
||||
#include "sql_select.h"
|
||||
|
||||
Item_sum::Item_sum(List<Item> &list)
|
||||
:arg_count(list.elements)
|
||||
|
@ -303,6 +304,21 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table,
|
||||
uint convert_blob_length)
|
||||
{
|
||||
if (args[0]->type() == Item::FIELD_ITEM)
|
||||
{
|
||||
Field *field= ((Item_field*) args[0])->field;
|
||||
|
||||
if ((field= create_tmp_field_from_field(current_thd, field, this, table,
|
||||
0, convert_blob_length)))
|
||||
field->flags&= ~NOT_NULL_FLAG;
|
||||
return field;
|
||||
}
|
||||
return Item_sum::create_tmp_field(group, table, convert_blob_length);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
** reset and add of sum_func
|
||||
|
@ -2075,8 +2091,6 @@ my_decimal *Item_variance_field::val_decimal(my_decimal *dec_buf)
|
|||
** COUNT(DISTINCT ...)
|
||||
****************************************************************************/
|
||||
|
||||
#include "sql_select.h"
|
||||
|
||||
int simple_str_key_cmp(void* arg, byte* key1, byte* key2)
|
||||
{
|
||||
Item_sum_count_distinct* item = (Item_sum_count_distinct*)arg;
|
||||
|
|
|
@ -94,7 +94,6 @@ public:
|
|||
Item *get_tmp_table_item(THD *thd);
|
||||
virtual Field *create_tmp_field(bool group, TABLE *table,
|
||||
uint convert_blob_length);
|
||||
|
||||
bool walk (Item_processor processor, byte *argument);
|
||||
};
|
||||
|
||||
|
@ -525,6 +524,8 @@ protected:
|
|||
void cleanup();
|
||||
bool any_value() { return was_values; }
|
||||
void no_rows_in_result();
|
||||
Field *create_tmp_field(bool group, TABLE *table,
|
||||
uint convert_blob_length);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -4268,7 +4268,7 @@ struct my_option my_long_options[] =
|
|||
(gptr*) &abort_slave_event_count, (gptr*) &abort_slave_event_count,
|
||||
0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#endif /* HAVE_REPLICATION */
|
||||
{"ansi", 'a', "Use ANSI SQL syntax instead of MySQL syntax.", 0, 0, 0,
|
||||
{"ansi", 'a', "Use ANSI SQL syntax instead of MySQL syntax. This mode will also set transaction isolation level 'serializable'.", 0, 0, 0,
|
||||
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"auto-increment-increment", OPT_AUTO_INCREMENT,
|
||||
"Auto-increment columns are incremented by this",
|
||||
|
|
|
@ -183,6 +183,7 @@ THD::THD()
|
|||
lock=locked_tables=0;
|
||||
used_tables=0;
|
||||
cuted_fields= sent_row_count= 0L;
|
||||
limit_found_rows= 0;
|
||||
statement_id_counter= 0UL;
|
||||
// Must be reset to handle error with THD's created for init of mysqld
|
||||
lex->current_select= 0;
|
||||
|
|
|
@ -664,7 +664,7 @@ JOIN::optimize()
|
|||
!(select_options & SELECT_DESCRIBE))
|
||||
{ /* purecov: inspected */
|
||||
my_message(ER_TOO_BIG_SELECT, ER(ER_TOO_BIG_SELECT), MYF(0));
|
||||
error= 1; /* purecov: inspected */
|
||||
error= -1;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (const_tables && !thd->locked_tables &&
|
||||
|
@ -1194,7 +1194,9 @@ JOIN::exec()
|
|||
else
|
||||
error=(int) result->send_eof();
|
||||
}
|
||||
thd->limit_found_rows= thd->examined_row_count= 0;
|
||||
/* Single select (without union and limit) always returns 1 row */
|
||||
thd->limit_found_rows= 1;
|
||||
thd->examined_row_count= 0;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
thd->limit_found_rows= thd->examined_row_count= 0;
|
||||
|
@ -7591,10 +7593,10 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item)
|
|||
new_created field
|
||||
*/
|
||||
|
||||
static Field* create_tmp_field_from_field(THD *thd, Field* org_field,
|
||||
Item *item, TABLE *table,
|
||||
bool modify_item,
|
||||
uint convert_blob_length)
|
||||
Field* create_tmp_field_from_field(THD *thd, Field* org_field,
|
||||
Item *item, TABLE *table,
|
||||
bool modify_item,
|
||||
uint convert_blob_length)
|
||||
{
|
||||
Field *new_field;
|
||||
|
||||
|
|
|
@ -399,6 +399,10 @@ void copy_funcs(Item **func_ptr);
|
|||
bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
|
||||
int error, bool ignore_last_dupp_error);
|
||||
uint find_shortest_key(TABLE *table, const key_map *usable_keys);
|
||||
Field* create_tmp_field_from_field(THD *thd, Field* org_field,
|
||||
Item *item, TABLE *table,
|
||||
bool modify_item,
|
||||
uint convert_blob_length);
|
||||
|
||||
/* functions from opt_sum.cc */
|
||||
bool simple_pred(Item_func *func_item, Item **args, bool *inv_order);
|
||||
|
|
|
@ -67,6 +67,13 @@ static uchar bin_char_array[] =
|
|||
};
|
||||
|
||||
|
||||
static my_bool
|
||||
my_coll_init_8bit_bin(CHARSET_INFO *cs,
|
||||
void *(*alloc)(uint) __attribute__((unused)))
|
||||
{
|
||||
cs->max_sort_char=255;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int my_strnncoll_binary(CHARSET_INFO * cs __attribute__((unused)),
|
||||
const uchar *s, uint slen,
|
||||
|
@ -443,7 +450,7 @@ skip:
|
|||
|
||||
MY_COLLATION_HANDLER my_collation_8bit_bin_handler =
|
||||
{
|
||||
NULL, /* init */
|
||||
my_coll_init_8bit_bin,
|
||||
my_strnncoll_8bit_bin,
|
||||
my_strnncollsp_8bit_bin,
|
||||
my_strnxfrm_8bit_bin,
|
||||
|
|
Loading…
Reference in a new issue