Commit 784b5d7b authored by gkodinov/kgeorge@magare.gmz's avatar gkodinov/kgeorge@magare.gmz

Merge magare.gmz:/home/kgeorge/mysql/work/mysql-5.0-opt

into  magare.gmz:/home/kgeorge/mysql/work/merge-5.1-opt
parents 5f1966d1 3f163915
......@@ -958,6 +958,12 @@ COUNT(*)
2
DROP TABLE t1, t2;
End of 5.0 tests
create table `t1` (`col002` point)engine=myisam;
insert into t1 values (),(),();
select min(`col002`) from t1 union select `col002` from t1;
min(`col002`)
NULL
drop table t1;
End of 5.0 tests
create table t1 (f1 tinyint(1), f2 char(1), f3 varchar(1), f4 geometry, f5 datetime);
create view v1 as select * from t1;
......
......@@ -82,4 +82,22 @@ c1 c2
-r- =raker=
DROP TABLE t2;
DROP TABLE t1;
#
# Bug#32533: SELECT INTO OUTFILE never escapes multibyte character
#
CREATE TABLE t1 (c1 VARCHAR(256));
INSERT INTO t1 VALUES (0xC3);
SELECT HEX(c1) FROM t1;
HEX(c1)
C3
SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug32533.txt' FIELDS ENCLOSED BY 0xC3 FROM t1;
TRUNCATE t1;
SELECT HEX(LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug32533.txt'));
HEX(LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug32533.txt'))
C35CC3C30A
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug32533.txt' INTO TABLE t1 FIELDS ENCLOSED BY 0xC3;
SELECT HEX(c1) FROM t1;
HEX(c1)
C3
DROP TABLE t1;
# End of 5.0 tests.
......@@ -672,6 +672,16 @@ COUNT(DISTINCT b,c)
2
2
DROP TABLE t2;
CREATE TABLE t1(a BIT(13), KEY(a));
INSERT INTO t1(a) VALUES
(65535),(65525),(65535),(65535),(65535),(65535),(65535),(65535),(65535),(65535);
EXPLAIN SELECT 1 FROM t1 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL a 3 NULL 6 Using index for group-by
SELECT 1 FROM t1 GROUP BY a;
1
1
DROP TABLE t1;
End of 5.0 tests
create table t1(a bit(7));
insert into t1 values(0x40);
......
......@@ -807,4 +807,18 @@ set @@sql_mode='TRADITIONAL';
create table t1 (a text default '');
ERROR 42000: BLOB/TEXT column 'a' can't have a default value
set @@sql_mode='';
CREATE TABLE t (c TEXT CHARSET ASCII);
INSERT INTO t (c) VALUES (REPEAT('1',65537));
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
INSERT INTO t (c) VALUES (REPEAT('2',65536));
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
INSERT INTO t (c) VALUES (REPEAT('3',65535));
SELECT LENGTH(c), CHAR_LENGTH(c) FROM t;
LENGTH(c) CHAR_LENGTH(c)
65535 65535
65535 65535
65535 65535
DROP TABLE t;
End of 5.0 tests
......@@ -632,6 +632,15 @@ SELECT 1;
-- source include/gis_keys.inc
#
# Bug #31155 gis types in union'd select cause crash
#
create table `t1` (`col002` point)engine=myisam;
insert into t1 values (),(),();
select min(`col002`) from t1 union select `col002` from t1;
drop table t1;
--echo End of 5.0 tests
......
......@@ -86,4 +86,28 @@ DROP TABLE t2;
DROP TABLE t1;
--echo #
--echo # Bug#32533: SELECT INTO OUTFILE never escapes multibyte character
--echo #
CREATE TABLE t1 (c1 VARCHAR(256));
INSERT INTO t1 VALUES (0xC3);
SELECT HEX(c1) FROM t1;
--let $file=$MYSQLTEST_VARDIR/tmp/bug32533.txt
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval SELECT * INTO OUTFILE '$file' FIELDS ENCLOSED BY 0xC3 FROM t1
TRUNCATE t1;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval SELECT HEX(LOAD_FILE('$file'))
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval LOAD DATA INFILE '$file' INTO TABLE t1 FIELDS ENCLOSED BY 0xC3
SELECT HEX(c1) FROM t1;
--remove_file $file
DROP TABLE t1;
--echo # End of 5.0 tests.
......@@ -2987,6 +2987,100 @@ SELECT (SELECT SUM(t1.a) FROM t2 WHERE a!=0) FROM t1;
SELECT (SELECT SUM(t1.a) FROM t2 WHERE a=1) FROM t1;
DROP TABLE t1,t2;
#
# Bug31048: Many nested subqueries may cause server crash.
#
create table t1(a int,b int,key(a),key(b));
insert into t1(a,b) values (1,2),(2,1),(2,3),(3,4),(5,4),(5,5),
(6,7),(7,4),(5,3);
# test for the stack overflow bug
select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1
)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
--replace_regex /overrun.*$/overrun detected/
--error 1436
select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
# test for the memory consumption & subquery slowness bug
explain select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1
)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
--replace_regex /overrun.*$/overrun detected/
--error 1436
explain select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
drop table t1;
#
# Bug #31884: Assertion + crash in subquery in the SELECT clause.
#
......
......@@ -318,6 +318,21 @@ INSERT INTO t2 VALUES (3, 2, 'two'), (2, 3, 'three'), (2, 0, 'zero'),
SELECT COUNT(DISTINCT b,c) FROM t2 GROUP BY a;
DROP TABLE t2;
#
# BUG#32556 assert in "using index for group-by" : is_last_prefix <= 0,
# file .\opt_range.cc
CREATE TABLE t1(a BIT(13), KEY(a));
--disable_warnings
INSERT INTO t1(a) VALUES
(65535),(65525),(65535),(65535),(65535),(65535),(65535),(65535),(65535),(65535);
--enable_warnings
EXPLAIN SELECT 1 FROM t1 GROUP BY a;
SELECT 1 FROM t1 GROUP BY a;
DROP TABLE t1;
--echo End of 5.0 tests
#
......
......@@ -436,4 +436,15 @@ set @@sql_mode='TRADITIONAL';
create table t1 (a text default '');
set @@sql_mode='';
#
# Bug #32282: TEXT silently truncates when value is exactly 65536 bytes
#
CREATE TABLE t (c TEXT CHARSET ASCII);
INSERT INTO t (c) VALUES (REPEAT('1',65537));
INSERT INTO t (c) VALUES (REPEAT('2',65536));
INSERT INTO t (c) VALUES (REPEAT('3',65535));
SELECT LENGTH(c), CHAR_LENGTH(c) FROM t;
DROP TABLE t;
--echo End of 5.0 tests
......@@ -1843,7 +1843,9 @@ int subselect_single_select_engine::exec()
DBUG_RETURN(1);
}
}
if (select_lex->uncacheable && executed)
if (select_lex->uncacheable &&
select_lex->uncacheable != UNCACHEABLE_EXPLAIN
&& executed)
{
if (join->reinit())
{
......
......@@ -127,19 +127,6 @@ void key_copy(uchar *to_key, uchar *from_record, KEY *key_info,
key_part->null_bit);
key_length--;
}
if (key_part->type == HA_KEYTYPE_BIT)
{
Field_bit *field= (Field_bit *) (key_part->field);
if (field->bit_len)
{
uchar bits= get_rec_bits(from_record +
key_part->null_offset +
(key_part->null_bit == 128),
field->bit_ofs, field->bit_len);
*to_key++= bits;
key_length--;
}
}
if (key_part->key_part_flag & HA_BLOB_PART ||
key_part->key_part_flag & HA_VAR_LENGTH_PART)
{
......
......@@ -2161,12 +2161,18 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
keys_to_use.intersect(head->keys_in_use_for_query);
if (!keys_to_use.is_clear_all())
{
#ifndef EMBEDDED_LIBRARY // Avoid compiler warning
char buff[STACK_BUFF_ALLOC];
#endif
MEM_ROOT alloc;
SEL_TREE *tree= NULL;
KEY_PART *key_parts;
KEY *key_info;
PARAM param;
if (check_stack_overrun(thd, 2*STACK_MIN_SIZE, buff))
DBUG_RETURN(0); // Fatal error flag is set
/* set up parameter that is passed to all functions */
param.thd= thd;
param.baseflag= head->file->ha_table_flags();
......
......@@ -1579,16 +1579,18 @@ select_export::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
}
}
field_term_length=exchange->field_term->length();
field_term_char= field_term_length ? (*exchange->field_term)[0] : INT_MAX;
field_term_char= field_term_length ?
(int) (uchar) (*exchange->field_term)[0] : INT_MAX;
if (!exchange->line_term->length())
exchange->line_term=exchange->field_term; // Use this if it exists
field_sep_char= (exchange->enclosed->length() ? (*exchange->enclosed)[0] :
field_term_char);
escape_char= (exchange->escaped->length() ? (*exchange->escaped)[0] : -1);
field_sep_char= (exchange->enclosed->length() ?
(int) (uchar) (*exchange->enclosed)[0] : field_term_char);
escape_char= (exchange->escaped->length() ?
(int) (uchar) (*exchange->escaped)[0] : -1);
is_ambiguous_field_sep= test(strchr(ESCAPE_CHARS, field_sep_char));
is_unsafe_field_sep= test(strchr(NUMERIC_CHARS, field_sep_char));
line_sep_char= (exchange->line_term->length() ?
(*exchange->line_term)[0] : INT_MAX);
(int) (uchar) (*exchange->line_term)[0] : INT_MAX);
if (!field_term_length)
exchange->opt_enclosed=0;
if (!exchange->enclosed->length())
......@@ -1745,10 +1747,11 @@ bool select_export::send_data(List<Item> &items)
Don't escape field_term_char by doubling - doubling is only
valid for ENCLOSED BY characters:
*/
(enclosed || !is_ambiguous_field_term || *pos != field_term_char))
(enclosed || !is_ambiguous_field_term ||
(int) (uchar) *pos != field_term_char))
{
char tmp_buff[2];
tmp_buff[0]= ((int) *pos == field_sep_char &&
tmp_buff[0]= ((int) (uchar) *pos == field_sep_char &&
is_ambiguous_field_sep) ?
field_sep_char : escape_char;
tmp_buff[1]= *pos ? *pos : '0';
......
......@@ -2157,14 +2157,13 @@ class select_insert :public select_result_interceptor {
ulonglong autoinc_value_of_last_inserted_row; // autogenerated or not
COPY_INFO info;
bool insert_into_view;
bool is_bulk_insert_mode;
select_insert(TABLE_LIST *table_list_par,
TABLE *table_par, List<Item> *fields_par,
List<Item> *update_fields, List<Item> *update_values,
enum_duplicates duplic, bool ignore);
~select_insert();
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
int prepare2(void);
virtual int prepare2(void);
bool send_data(List<Item> &items);
virtual void store_values(List<Item> &values);
virtual bool can_rollback_data() { return 0; }
......@@ -2212,6 +2211,7 @@ class select_create: public select_insert {
// Needed for access from local class MY_HOOKS in prepare(), since thd is proteted.
const THD *get_thd(void) { return thd; }
const HA_CREATE_INFO *get_create_info() { return create_info; };
int prepare2(void) { return 0; }
};
#include <myisam.h>
......
......@@ -2789,8 +2789,7 @@ select_insert::select_insert(TABLE_LIST *table_list_par, TABLE *table_par,
bool ignore_check_option_errors)
:table_list(table_list_par), table(table_par), fields(fields_par),
autoinc_value_of_last_inserted_row(0),
insert_into_view(table_list_par && table_list_par->view != 0),
is_bulk_insert_mode(FALSE)
insert_into_view(table_list_par && table_list_par->view != 0)
{
bzero((char*) &info,sizeof(info));
info.handle_duplicates= duplic;
......@@ -2903,14 +2902,14 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
Is table which we are changing used somewhere in other parts of
query
*/
if (!(lex->current_select->options & OPTION_BUFFER_RESULT) &&
unique_table(thd, table_list, table_list->next_global, 0))
if (unique_table(thd, table_list, table_list->next_global, 0))
{
/* Using same table for INSERT and SELECT */
lex->current_select->options|= OPTION_BUFFER_RESULT;
lex->current_select->join->select_options|= OPTION_BUFFER_RESULT;
}
else if (!thd->prelocked_mode)
else if (!(lex->current_select->options & OPTION_BUFFER_RESULT) &&
!thd->prelocked_mode)
{
/*
We must not yet prepare the result table if it is the same as one of the
......@@ -2976,11 +2975,8 @@ int select_insert::prepare2(void)
{
DBUG_ENTER("select_insert::prepare2");
if (thd->lex->current_select->options & OPTION_BUFFER_RESULT &&
!thd->prelocked_mode && !is_bulk_insert_mode)
{
!thd->prelocked_mode)
table->file->ha_start_bulk_insert((ha_rows) 0);
is_bulk_insert_mode= TRUE;
}
DBUG_RETURN(0);
}
......@@ -3099,7 +3095,6 @@ bool select_insert::send_eof()
trans_table, table->file->table_type()));
error= (!thd->prelocked_mode) ? table->file->ha_end_bulk_insert():0;
is_bulk_insert_mode= FALSE;
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
......@@ -3550,10 +3545,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
if (info.handle_duplicates == DUP_UPDATE)
table->file->extra(HA_EXTRA_INSERT_WITH_UPDATE);
if (!thd->prelocked_mode)
{
table->file->ha_start_bulk_insert((ha_rows) 0);
is_bulk_insert_mode= TRUE;
}
thd->abort_on_warning= (!info.ignore &&
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
......
......@@ -2366,6 +2366,11 @@ static ha_rows get_quick_record_count(THD *thd, SQL_SELECT *select,
{
int error;
DBUG_ENTER("get_quick_record_count");
#ifndef EMBEDDED_LIBRARY // Avoid compiler warning
char buff[STACK_BUFF_ALLOC];
#endif
if (check_stack_overrun(thd, STACK_MIN_SIZE, buff))
DBUG_RETURN(0); // Fatal error flag is set
if (select)
{
select->head=table;
......
......@@ -846,7 +846,7 @@ copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
with optional left padding (for binary -> UCS2 conversion)
SYNOPSIS
well_formed_copy_nhars()
well_formed_copy_nchars()
to Store result here
to_length Maxinum length of "to" string
to_cs Character set of "to" string
......@@ -983,8 +983,11 @@ well_formed_copy_nchars(CHARSET_INFO *to_cs,
goto outp;
}
else
{
from= from_prev;
break;
}
}
*from_end_pos= from;
res= to - to_start;
}
......
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