Commit 64ed42d0 authored by Sergey Petrunia's avatar Sergey Petrunia

Merge @@optimizer_switch no_xxx -> xxx=off change to 6.0

parents 5b8156e0 fe1b3b94
...@@ -29,5 +29,5 @@ typedef struct st_line_buffer ...@@ -29,5 +29,5 @@ typedef struct st_line_buffer
extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file); extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file);
extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str); extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str);
extern char *batch_readline(LINE_BUFFER *buffer); extern char *batch_readline(LINE_BUFFER *buffer, bool *truncated);
extern void batch_readline_end(LINE_BUFFER *buffer); extern void batch_readline_end(LINE_BUFFER *buffer);
...@@ -115,6 +115,8 @@ extern "C" { ...@@ -115,6 +115,8 @@ extern "C" {
#define PROMPT_CHAR '\\' #define PROMPT_CHAR '\\'
#define DEFAULT_DELIMITER ";" #define DEFAULT_DELIMITER ";"
#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L)
typedef struct st_status typedef struct st_status
{ {
int exit_status; int exit_status;
...@@ -1045,7 +1047,7 @@ static void fix_history(String *final_command); ...@@ -1045,7 +1047,7 @@ static void fix_history(String *final_command);
static COMMANDS *find_command(char *name,char cmd_name); static COMMANDS *find_command(char *name,char cmd_name);
static bool add_line(String &buffer,char *line,char *in_string, static bool add_line(String &buffer,char *line,char *in_string,
bool *ml_comment); bool *ml_comment, bool truncated);
static void remove_cntrl(String &buffer); static void remove_cntrl(String &buffer);
static void print_table_data(MYSQL_RES *result); static void print_table_data(MYSQL_RES *result);
static void print_table_data_html(MYSQL_RES *result); static void print_table_data_html(MYSQL_RES *result);
...@@ -1117,7 +1119,7 @@ int main(int argc,char *argv[]) ...@@ -1117,7 +1119,7 @@ int main(int argc,char *argv[])
exit(1); exit(1);
} }
if (status.batch && !status.line_buff && if (status.batch && !status.line_buff &&
!(status.line_buff=batch_readline_init(opt_max_allowed_packet+512,stdin))) !(status.line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, stdin)))
{ {
free_defaults(defaults_argv); free_defaults(defaults_argv);
my_end(0); my_end(0);
...@@ -1198,7 +1200,7 @@ int main(int argc,char *argv[]) ...@@ -1198,7 +1200,7 @@ int main(int argc,char *argv[])
#endif #endif
sprintf(buff, "%s", sprintf(buff, "%s",
#ifndef NOT_YET #ifndef NOT_YET
"Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n"); "Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n");
#else #else
"Type 'help [[%]function name[%]]' to get help on usage of function.\n"); "Type 'help [[%]function name[%]]' to get help on usage of function.\n");
#endif #endif
...@@ -1810,13 +1812,14 @@ static int read_and_execute(bool interactive) ...@@ -1810,13 +1812,14 @@ static int read_and_execute(bool interactive)
ulong line_number=0; ulong line_number=0;
bool ml_comment= 0; bool ml_comment= 0;
COMMANDS *com; COMMANDS *com;
bool truncated= 0;
status.exit_status=1; status.exit_status=1;
for (;;) for (;;)
{ {
if (!interactive) if (!interactive)
{ {
line=batch_readline(status.line_buff); line=batch_readline(status.line_buff, &truncated);
/* /*
Skip UTF8 Byte Order Marker (BOM) 0xEFBBBF. Skip UTF8 Byte Order Marker (BOM) 0xEFBBBF.
Editors like "notepad" put this marker in Editors like "notepad" put this marker in
...@@ -1913,7 +1916,7 @@ static int read_and_execute(bool interactive) ...@@ -1913,7 +1916,7 @@ static int read_and_execute(bool interactive)
#endif #endif
continue; continue;
} }
if (add_line(glob_buffer,line,&in_string,&ml_comment)) if (add_line(glob_buffer,line,&in_string,&ml_comment, truncated))
break; break;
} }
/* if in batch mode, send last query even if it doesn't end with \g or go */ /* if in batch mode, send last query even if it doesn't end with \g or go */
...@@ -1999,7 +2002,7 @@ static COMMANDS *find_command(char *name,char cmd_char) ...@@ -1999,7 +2002,7 @@ static COMMANDS *find_command(char *name,char cmd_char)
static bool add_line(String &buffer,char *line,char *in_string, static bool add_line(String &buffer,char *line,char *in_string,
bool *ml_comment) bool *ml_comment, bool truncated)
{ {
uchar inchar; uchar inchar;
char buff[80], *pos, *out; char buff[80], *pos, *out;
...@@ -2247,9 +2250,10 @@ static bool add_line(String &buffer,char *line,char *in_string, ...@@ -2247,9 +2250,10 @@ static bool add_line(String &buffer,char *line,char *in_string,
{ {
uint length=(uint) (out-line); uint length=(uint) (out-line);
if (length < 9 || if (!truncated &&
my_strnncoll (charset_info, (length < 9 ||
(uchar *)line, 9, (const uchar *) "delimiter", 9)) my_strnncoll (charset_info,
(uchar *)line, 9, (const uchar *) "delimiter", 9)))
{ {
/* /*
Don't add a new line in case there's a DELIMITER command to be Don't add a new line in case there's a DELIMITER command to be
...@@ -3921,7 +3925,7 @@ static int com_source(String *buffer, char *line) ...@@ -3921,7 +3925,7 @@ static int com_source(String *buffer, char *line)
return put_info(buff, INFO_ERROR, 0); return put_info(buff, INFO_ERROR, 0);
} }
if (!(line_buff=batch_readline_init(opt_max_allowed_packet+512,sql_file))) if (!(line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, sql_file)))
{ {
my_fclose(sql_file,MYF(0)); my_fclose(sql_file,MYF(0));
return put_info("Can't initialize batch_readline", INFO_ERROR, 0); return put_info("Can't initialize batch_readline", INFO_ERROR, 0);
......
...@@ -4588,7 +4588,8 @@ char check_if_ignore_table(const char *table_name, char *table_type) ...@@ -4588,7 +4588,8 @@ char check_if_ignore_table(const char *table_name, char *table_type)
*/ */
if (!opt_no_data && if (!opt_no_data &&
(!my_strcasecmp(&my_charset_latin1, table_type, "MRG_MyISAM") || (!my_strcasecmp(&my_charset_latin1, table_type, "MRG_MyISAM") ||
!strcmp(table_type,"MRG_ISAM"))) !strcmp(table_type,"MRG_ISAM") ||
!strcmp(table_type,"FEDERATED")))
result= IGNORE_DATA; result= IGNORE_DATA;
} }
mysql_free_result(res); mysql_free_result(res);
......
...@@ -24,7 +24,7 @@ static bool init_line_buffer(LINE_BUFFER *buffer,File file,ulong size, ...@@ -24,7 +24,7 @@ static bool init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,
ulong max_size); ulong max_size);
static bool init_line_buffer_from_string(LINE_BUFFER *buffer,char * str); static bool init_line_buffer_from_string(LINE_BUFFER *buffer,char * str);
static size_t fill_buffer(LINE_BUFFER *buffer); static size_t fill_buffer(LINE_BUFFER *buffer);
static char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length); static char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated);
LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file) LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
...@@ -42,12 +42,13 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file) ...@@ -42,12 +42,13 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
} }
char *batch_readline(LINE_BUFFER *line_buff) char *batch_readline(LINE_BUFFER *line_buff, bool *truncated)
{ {
char *pos; char *pos;
ulong out_length; ulong out_length;
DBUG_ASSERT(truncated != NULL);
if (!(pos=intern_read_line(line_buff,&out_length))) if (!(pos=intern_read_line(line_buff,&out_length, truncated)))
return 0; return 0;
if (out_length && pos[out_length-1] == '\n') if (out_length && pos[out_length-1] == '\n')
if (--out_length && pos[out_length-1] == '\r') /* Remove '\n' */ if (--out_length && pos[out_length-1] == '\r') /* Remove '\n' */
...@@ -149,6 +150,14 @@ static size_t fill_buffer(LINE_BUFFER *buffer) ...@@ -149,6 +150,14 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
read_count=(buffer->bufread - bufbytes)/IO_SIZE; read_count=(buffer->bufread - bufbytes)/IO_SIZE;
if ((read_count*=IO_SIZE)) if ((read_count*=IO_SIZE))
break; break;
if (buffer->bufread * 2 > buffer->max_size)
{
/*
So we must grow the buffer but we cannot due to the max_size limit.
Return 0 w/o setting buffer->eof to signal this condition.
*/
return 0;
}
buffer->bufread *= 2; buffer->bufread *= 2;
if (!(buffer->buffer = (char*) my_realloc(buffer->buffer, if (!(buffer->buffer = (char*) my_realloc(buffer->buffer,
buffer->bufread+1, buffer->bufread+1,
...@@ -172,11 +181,15 @@ static size_t fill_buffer(LINE_BUFFER *buffer) ...@@ -172,11 +181,15 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
DBUG_PRINT("fill_buff", ("Got %lu bytes", (ulong) read_count)); DBUG_PRINT("fill_buff", ("Got %lu bytes", (ulong) read_count));
/* Kludge to pretend every nonempty file ends with a newline. */ if (!read_count)
if (!read_count && bufbytes && buffer->end[-1] != '\n')
{ {
buffer->eof = read_count = 1; buffer->eof = 1;
*buffer->end = '\n'; /* Kludge to pretend every nonempty file ends with a newline. */
if (bufbytes && buffer->end[-1] != '\n')
{
read_count = 1;
*buffer->end = '\n';
}
} }
buffer->end_of_line=(buffer->start_of_line=buffer->buffer)+bufbytes; buffer->end_of_line=(buffer->start_of_line=buffer->buffer)+bufbytes;
buffer->end+=read_count; buffer->end+=read_count;
...@@ -186,7 +199,7 @@ static size_t fill_buffer(LINE_BUFFER *buffer) ...@@ -186,7 +199,7 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length) char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated)
{ {
char *pos; char *pos;
size_t length; size_t length;
...@@ -200,14 +213,23 @@ char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length) ...@@ -200,14 +213,23 @@ char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length)
pos++; pos++;
if (pos == buffer->end) if (pos == buffer->end)
{ {
if ((uint) (pos - buffer->start_of_line) < buffer->max_size) /*
fill_buffer() can return 0 either on EOF in which case we abort
or when the internal buffer has hit the size limit. In the latter case
return what we have read so far and signal string truncation.
*/
if (!(length=fill_buffer(buffer)) || length == (uint) -1)
{ {
if (!(length=fill_buffer(buffer)) || length == (size_t) -1) if (buffer->eof)
DBUG_RETURN(0); DBUG_RETURN(0);
continue;
} }
else
continue;
pos--; /* break line here */ pos--; /* break line here */
*truncated= 1;
} }
else
*truncated= 0;
buffer->end_of_line=pos+1; buffer->end_of_line=pos+1;
*out_length=(ulong) (pos + 1 - buffer->eof - buffer->start_of_line); *out_length=(ulong) (pos + 1 - buffer->eof - buffer->start_of_line);
DBUG_RETURN(buffer->start_of_line); DBUG_RETURN(buffer->start_of_line);
......
...@@ -611,3 +611,22 @@ check table t1 extended; ...@@ -611,3 +611,22 @@ check table t1 extended;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
drop table t1; drop table t1;
select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci);
least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci)
a
create table t1
select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) as f1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` varchar(1) CHARACTER SET latin5 NOT NULL DEFAULT ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate
latin5_turkish_ci then 2 else 3 end;
case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate
latin5_turkish_ci then 2 else 3 end
3
select concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci);
concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci)
abc
...@@ -192,6 +192,15 @@ delimiter ...@@ -192,6 +192,15 @@ delimiter
1 1
1 1
1 1
set @old_max_allowed_packet = @@global.max_allowed_packet;
set @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024;
CREATE TABLE t1(data LONGBLOB);
INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024);
SELECT LENGTH(data) FROM t1;
LENGTH(data)
2097152
DROP TABLE t1;
set @@global.max_allowed_packet = @old_max_allowed_packet;
End of 5.0 tests End of 5.0 tests
WARNING: --server-arg option not supported in this configuration. WARNING: --server-arg option not supported in this configuration.
Warning (Code 1286): Unknown table engine 'nonexistent' Warning (Code 1286): Unknown table engine 'nonexistent'
......
...@@ -2130,6 +2130,26 @@ SELECT t1.a FROM t1, t1 as t2 WHERE t2.b NOT LIKE t1.b; ...@@ -2130,6 +2130,26 @@ SELECT t1.a FROM t1, t1 as t2 WHERE t2.b NOT LIKE t1.b;
a a
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t1; DROP TABLE t1;
#
# BUG#21360 - mysqldump error on federated tables
#
#Switch to Connection Slave
CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id));
INSERT INTO t1 VALUES ('text1'),('text2'),('text3'),('text4');
#Switch to Connection Master
CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id)) ENGINE=FEDERATED
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1';
# Dump table t1 using mysqldump tool
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`id` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=FEDERATED DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1';
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE t1;
#Switch to Connection Slave
DROP TABLE t1;
End of 5.0 tests End of 5.0 tests
create server 's1' foreign data wrapper 'mysql' options (port 3306); create server 's1' foreign data wrapper 'mysql' options (port 3306);
drop server 's1'; drop server 's1';
......
...@@ -1942,6 +1942,28 @@ DROP TABLE t1; ...@@ -1942,6 +1942,28 @@ DROP TABLE t1;
connection master; connection master;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # BUG#21360 - mysqldump error on federated tables
--echo #
connection slave;
--echo #Switch to Connection Slave
CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id));
INSERT INTO t1 VALUES ('text1'),('text2'),('text3'),('text4');
connection master;
--echo #Switch to Connection Master
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id)) ENGINE=FEDERATED
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
--echo # Dump table t1 using mysqldump tool
--replace_result $SLAVE_MYPORT SLAVE_PORT
--exec $MYSQL_DUMP --compact test t1
DROP TABLE t1;
connection slave;
--echo #Switch to Connection Slave
DROP TABLE t1;
connection default; connection default;
--echo End of 5.0 tests --echo End of 5.0 tests
......
...@@ -29,3 +29,28 @@ a ...@@ -29,3 +29,28 @@ a
2 2
3 3
drop table t1; drop table t1;
==== Bug22504 Initialize ====
[on master]
SET sql_mode='ignore_space';
CREATE TABLE t1(a int);
insert into t1 values (1), (2), (3), (4);
select * into outfile 'MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' from t1;
truncate table t1;
load data local infile 'MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' into table t1;
SELECT * FROM t1 ORDER BY a;
a
1
2
3
4
[on slave]
SELECT * FROM t1 ORDER BY a;
a
1
2
3
4
==== Clean up ====
[on master]
DROP TABLE t1;
[on slave]
...@@ -218,7 +218,7 @@ slave-bin.000001 # Query 1 # use `test`; insert into t1 values (NULL) ...@@ -218,7 +218,7 @@ slave-bin.000001 # Query 1 # use `test`; insert into t1 values (NULL)
slave-bin.000001 # Query 1 # use `test`; drop table t1 slave-bin.000001 # Query 1 # use `test`; drop table t1
slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM
slave-bin.000001 # Begin_load_query 1 # ;file_id=1;block_len=581 slave-bin.000001 # Begin_load_query 1 # ;file_id=1;block_len=581
slave-bin.000001 # Execute_load_query 1 # use `test`; load data INFILE '../../tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1 slave-bin.000001 # Execute_load_query 1 # use `test`; load data INFILE '../../tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1
slave-bin.000001 # Query 1 # use `test`; create table t3 (a int)ENGINE=MyISAM slave-bin.000001 # Query 1 # use `test`; create table t3 (a int)ENGINE=MyISAM
slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4 slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4
show binlog events in 'slave-bin.000002' from 4; show binlog events in 'slave-bin.000002' from 4;
......
...@@ -64,3 +64,37 @@ drop table t1; ...@@ -64,3 +64,37 @@ drop table t1;
save_master_pos; save_master_pos;
connection slave; connection slave;
sync_with_master; sync_with_master;
#
# Bug22504 load data infile sql statement in replication architecture get error
#
--echo ==== Bug22504 Initialize ====
--echo [on master]
--connection master
SET sql_mode='ignore_space';
CREATE TABLE t1(a int);
insert into t1 values (1), (2), (3), (4);
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval select * into outfile '$MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' from t1;
truncate table t1;
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval load data local infile '$MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' into table t1;
--remove_file $MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile
SELECT * FROM t1 ORDER BY a;
--echo [on slave]
sync_slave_with_master;
SELECT * FROM t1 ORDER BY a;
--echo ==== Clean up ====
--echo [on master]
connection master;
DROP TABLE t1;
--echo [on slave]
sync_slave_with_master;
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
# Creation Date: 2008-03-07 # # Creation Date: 2008-03-07 #
# Author: Salman Rawala # # Author: Salman Rawala #
# # # #
# Modified: HHunger 2009-02-23 Inserted a wait condition right after the #
# "INSERT ..record_6" to wait for the end of #
# the insert. #
# mleich This test needs some inporovements #
# #
# Description: Test Cases of Dynamic System Variable "concurrent_insert" # # Description: Test Cases of Dynamic System Variable "concurrent_insert" #
# that checks functionality of this variable # # that checks functionality of this variable #
# # # #
...@@ -62,7 +67,6 @@ connection test_con1; ...@@ -62,7 +67,6 @@ connection test_con1;
INSERT INTO t1(name) VALUES('Record_4'); INSERT INTO t1(name) VALUES('Record_4');
SELECT * FROM t1; SELECT * FROM t1;
--echo ## unlocking tables ## --echo ## unlocking tables ##
--echo connection default; --echo connection default;
connection default; connection default;
...@@ -106,6 +110,8 @@ UNLOCK TABLES; ...@@ -106,6 +110,8 @@ UNLOCK TABLES;
--echo ## table contens after UNLOCK ## --echo ## table contens after UNLOCK ##
SELECT * FROM t1; SELECT * FROM t1;
INSERT INTO t1(name) VALUES('Record_6'); INSERT INTO t1(name) VALUES('Record_6');
let $wait_condition= SELECT COUNT(*) = 5 FROM t1;
--source include/wait_condition.inc
--echo connection test_con1; --echo connection test_con1;
connection test_con1; connection test_con1;
......
...@@ -229,3 +229,17 @@ insert into t1 set a=0x6c; ...@@ -229,3 +229,17 @@ insert into t1 set a=0x6c;
insert into t1 set a=0x4c98; insert into t1 set a=0x4c98;
check table t1 extended; check table t1 extended;
drop table t1; drop table t1;
#
# Bug#41627 Illegal mix of collations in LEAST / GREATEST / CASE
#
select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci);
create table t1
select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) as f1;
show create table t1;
drop table t1;
select case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate
latin5_turkish_ci then 2 else 3 end;
select concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci);
...@@ -342,6 +342,39 @@ EOF ...@@ -342,6 +342,39 @@ EOF
remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql; remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql;
#
# Bug #41486: extra character appears in BLOB for every ~40Mb after
# mysqldump/import
#
# Have to change the global variable as the session variable is
# read-only.
set @old_max_allowed_packet = @@global.max_allowed_packet;
# 2 MB blob length + some space for the rest of INSERT query
set @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024;
# Create a new connection since the global max_allowed_packet
# has no effect for the current connection
connect (con1, localhost, root,,);
connection con1;
CREATE TABLE t1(data LONGBLOB);
INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024);
--exec $MYSQL_DUMP test t1 >$MYSQLTEST_VARDIR/tmp/bug41486.sql
# Check that the mysql client does not insert extra newlines when loading
# strings longer than client's max_allowed_packet
--exec $MYSQL --max_allowed_packet=1M test < $MYSQLTEST_VARDIR/tmp/bug41486.sql 2>&1
SELECT LENGTH(data) FROM t1;
remove_file $MYSQLTEST_VARDIR/tmp/bug41486.sql;
DROP TABLE t1;
connection default;
disconnect con1;
set @@global.max_allowed_packet = @old_max_allowed_packet;
--echo End of 5.0 tests --echo End of 5.0 tests
# #
......
...@@ -252,11 +252,16 @@ const char **my_error_unregister(int first, int last) ...@@ -252,11 +252,16 @@ const char **my_error_unregister(int first, int last)
void my_error_unregister_all(void) void my_error_unregister_all(void)
{ {
struct my_err_head *list, *next; struct my_err_head *cursor, *saved_next;
for (list= my_errmsgs_globerrs.meh_next; list; list= next)
for (cursor= my_errmsgs_globerrs.meh_next; cursor != NULL; cursor= saved_next)
{ {
next= list->meh_next; /* We need this ptr, but we're about to free its container, so save it. */
my_free((uchar*) list, MYF(0)); saved_next= cursor->meh_next;
my_free((uchar*) cursor, MYF(0));
} }
my_errmsgs_globerrs.meh_next= NULL; /* Freed in first iteration above. */
my_errmsgs_list= &my_errmsgs_globerrs; my_errmsgs_list= &my_errmsgs_globerrs;
} }
...@@ -18,7 +18,7 @@ niceness=0 ...@@ -18,7 +18,7 @@ niceness=0
logging=init logging=init
want_syslog=0 want_syslog=0
syslog_tag= syslog_tag=
user=@MYSQLD_USER@ user='@MYSQLD_USER@'
pid_file= pid_file=
err_log= err_log=
...@@ -64,9 +64,10 @@ my_which () ...@@ -64,9 +64,10 @@ my_which ()
{ {
save_ifs="${IFS-UNSET}" save_ifs="${IFS-UNSET}"
IFS=: IFS=:
ret=0
for file for file
do do
for dir in $PATH for dir in "$PATH"
do do
if [ -f "$dir/$file" ] if [ -f "$dir/$file" ]
then then
...@@ -74,15 +75,18 @@ my_which () ...@@ -74,15 +75,18 @@ my_which ()
continue 2 continue 2
fi fi
done done
return 1 # Failure, didn't find file in path
ret=1 #signal an error
break
done done
if [ "$save_ifs" = UNSET ] if [ "$save_ifs" = UNSET ]
then then
unset IFS unset IFS
else else
IFS="$save_ifs" IFS="$save_ifs"
fi fi
return 0 # Success return $ret # Success
} }
log_generic () { log_generic () {
...@@ -212,19 +216,30 @@ fi ...@@ -212,19 +216,30 @@ fi
MY_PWD=`pwd` MY_PWD=`pwd`
# Check for the directories we would expect from a binary release install # Check for the directories we would expect from a binary release install
if test -f "$relpkgdata"/english/errmsg.sys -a -x ./bin/mysqld if test -n "$MY_BASEDIR_VERSION" -a -d "$MY_BASEDIR_VERSION"
then
# BASEDIR is already overridden on command line. Do not re-set.
# Use BASEDIR to discover le.
if test -x "$MY_BASEDIR_VERSION/libexec/mysqld"
then
ledir="$MY_BASEDIR_VERSION/libexec"
else
ledir="$MY_BASEDIR_VERSION/bin"
fi
elif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/bin/mysqld"
then then
MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are MY_BASEDIR_VERSION="$MY_PWD" # Where bin, share and data are
ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is ledir="$MY_PWD/bin" # Where mysqld is
# Check for the directories we would expect from a source install # Check for the directories we would expect from a source install
elif test -f "$relpkgdata"/english/errmsg.sys -a -x ./libexec/mysqld elif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/libexec/mysqld"
then then
MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are MY_BASEDIR_VERSION="$MY_PWD" # Where libexec, share and var are
ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is ledir="$MY_PWD/libexec" # Where mysqld is
# Since we didn't find anything, used the compiled-in defaults # Since we didn't find anything, used the compiled-in defaults
else else
MY_BASEDIR_VERSION=@prefix@ MY_BASEDIR_VERSION='@prefix@'
ledir=@libexecdir@ ledir='@libexecdir@'
fi fi
...@@ -274,7 +289,10 @@ export MYSQL_HOME ...@@ -274,7 +289,10 @@ export MYSQL_HOME
# Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe] # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
# and then merge with the command line arguments # and then merge with the command line arguments
if test -x ./bin/my_print_defaults if test -x "$MY_BASEDIR_VERSION/bin/my_print_defaults"
then
print_defaults="$MY_BASEDIR_VERSION/bin/my_print_defaults"
elif test -x ./bin/my_print_defaults
then then
print_defaults="./bin/my_print_defaults" print_defaults="./bin/my_print_defaults"
elif test -x @bindir@/my_print_defaults elif test -x @bindir@/my_print_defaults
...@@ -399,7 +417,7 @@ then ...@@ -399,7 +417,7 @@ then
MYSQLD=mysqld MYSQLD=mysqld
fi fi
if test ! -x $ledir/$MYSQLD if test ! -x "$ledir/$MYSQLD"
then then
log_error "The file $ledir/$MYSQLD log_error "The file $ledir/$MYSQLD
does not exist or is not executable. Please cd to the mysql installation does not exist or is not executable. Please cd to the mysql installation
...@@ -411,7 +429,7 @@ fi ...@@ -411,7 +429,7 @@ fi
if test -z "$pid_file" if test -z "$pid_file"
then then
pid_file=$DATADIR/`@HOSTNAME@`.pid pid_file="$DATADIR/`@HOSTNAME@`.pid"
else else
case "$pid_file" in case "$pid_file" in
/* ) ;; /* ) ;;
......
...@@ -1531,7 +1531,8 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) ...@@ -1531,7 +1531,8 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags)
else else
{ {
// Cannot apply conversion // Cannot apply conversion
set(0, DERIVATION_NONE, 0); set(&my_charset_bin, DERIVATION_NONE,
(dt.repertoire|repertoire));
return 1; return 1;
} }
} }
...@@ -1614,15 +1615,31 @@ bool agg_item_collations(DTCollation &c, const char *fname, ...@@ -1614,15 +1615,31 @@ bool agg_item_collations(DTCollation &c, const char *fname,
{ {
uint i; uint i;
Item **arg; Item **arg;
bool unknown_cs= 0;
c.set(av[0]->collation); c.set(av[0]->collation);
for (i= 1, arg= &av[item_sep]; i < count; i++, arg++) for (i= 1, arg= &av[item_sep]; i < count; i++, arg++)
{ {
if (c.aggregate((*arg)->collation, flags)) if (c.aggregate((*arg)->collation, flags))
{ {
if (c.derivation == DERIVATION_NONE &&
c.collation == &my_charset_bin)
{
unknown_cs= 1;
continue;
}
my_coll_agg_error(av, count, fname, item_sep); my_coll_agg_error(av, count, fname, item_sep);
return TRUE; return TRUE;
} }
} }
if (unknown_cs &&
c.derivation != DERIVATION_EXPLICIT)
{
my_coll_agg_error(av, count, fname, item_sep);
return TRUE;
}
if ((flags & MY_COLL_DISALLOW_NONE) && if ((flags & MY_COLL_DISALLOW_NONE) &&
c.derivation == DERIVATION_NONE) c.derivation == DERIVATION_NONE)
{ {
......
...@@ -6618,7 +6618,7 @@ void Execute_load_query_log_event::print(FILE* file, ...@@ -6618,7 +6618,7 @@ void Execute_load_query_log_event::print(FILE* file,
my_b_printf(&cache, "\'"); my_b_printf(&cache, "\'");
if (dup_handling == LOAD_DUP_REPLACE) if (dup_handling == LOAD_DUP_REPLACE)
my_b_printf(&cache, " REPLACE"); my_b_printf(&cache, " REPLACE");
my_b_printf(&cache, " INTO"); my_b_printf(&cache, " INTO ");
my_b_write(&cache, (uchar*) query + fn_pos_end, q_len-fn_pos_end); my_b_write(&cache, (uchar*) query + fn_pos_end, q_len-fn_pos_end);
my_b_printf(&cache, "\n%s\n", print_event_info->delimiter); my_b_printf(&cache, "\n%s\n", print_event_info->delimiter);
} }
...@@ -6699,7 +6699,7 @@ Execute_load_query_log_event::do_apply_event(Relay_log_info const *rli) ...@@ -6699,7 +6699,7 @@ Execute_load_query_log_event::do_apply_event(Relay_log_info const *rli)
/* Ordinary load data */ /* Ordinary load data */
break; break;
} }
p= strmake(p, STRING_WITH_LEN(" INTO")); p= strmake(p, STRING_WITH_LEN(" INTO "));
p= strmake(p, query+fn_pos_end, q_len-fn_pos_end); p= strmake(p, query+fn_pos_end, q_len-fn_pos_end);
error= Query_log_event::do_apply_event(rli, buf, p-buf); error= Query_log_event::do_apply_event(rli, buf, p-buf);
......
...@@ -1825,6 +1825,13 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) ...@@ -1825,6 +1825,13 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
#ifdef ABBR_ARE_USED #ifdef ABBR_ARE_USED
char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))]; char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
#endif #endif
/*
Used as a temporary tz_info until we decide that we actually want to
allocate and keep the tz info and tz name in tz_storage.
*/
TIME_ZONE_INFO tmp_tz_info;
memset(&tmp_tz_info, 0, sizeof(TIME_ZONE_INFO));
DBUG_ENTER("tz_load_from_open_tables"); DBUG_ENTER("tz_load_from_open_tables");
/* Prepare tz_info for loading also let us make copy of time zone name */ /* Prepare tz_info for loading also let us make copy of time zone name */
...@@ -1866,7 +1873,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) ...@@ -1866,7 +1873,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
Most probably user has mistyped time zone name, so no need to bark here Most probably user has mistyped time zone name, so no need to bark here
unless we need it for debugging. unless we need it for debugging.
*/ */
sql_print_error("Can't find description of time zone '%s'", tz_name_buff); sql_print_error("Can't find description of time zone '%.*s'",
tz_name->length(), tz_name->ptr());
#endif #endif
goto end; goto end;
} }
...@@ -1895,8 +1903,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) ...@@ -1895,8 +1903,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
/* If Uses_leap_seconds == 'Y' */ /* If Uses_leap_seconds == 'Y' */
if (table->field[1]->val_int() == 1) if (table->field[1]->val_int() == 1)
{ {
tz_info->leapcnt= tz_leapcnt; tmp_tz_info.leapcnt= tz_leapcnt;
tz_info->lsis= tz_lsis; tmp_tz_info.lsis= tz_lsis;
} }
(void)table->file->ha_index_end(); (void)table->file->ha_index_end();
...@@ -1932,18 +1940,18 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) ...@@ -1932,18 +1940,18 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
#ifdef ABBR_ARE_USED #ifdef ABBR_ARE_USED
// FIXME should we do something with duplicates here ? // FIXME should we do something with duplicates here ?
table->field[4]->val_str(&abbr, &abbr); table->field[4]->val_str(&abbr, &abbr);
if (tz_info->charcnt + abbr.length() + 1 > sizeof(chars)) if (tmp_tz_info.charcnt + abbr.length() + 1 > sizeof(chars))
{ {
sql_print_error("Error while loading time zone description from " sql_print_error("Error while loading time zone description from "
"mysql.time_zone_transition_type table: not enough " "mysql.time_zone_transition_type table: not enough "
"room for abbreviations"); "room for abbreviations");
goto end; goto end;
} }
ttis[ttid].tt_abbrind= tz_info->charcnt; ttis[ttid].tt_abbrind= tmp_tz_info.charcnt;
memcpy(chars + tz_info->charcnt, abbr.ptr(), abbr.length()); memcpy(chars + tmp_tz_info.charcnt, abbr.ptr(), abbr.length());
tz_info->charcnt+= abbr.length(); tmp_tz_info.charcnt+= abbr.length();
chars[tz_info->charcnt]= 0; chars[tmp_tz_info.charcnt]= 0;
tz_info->charcnt++; tmp_tz_info.charcnt++;
DBUG_PRINT("info", DBUG_PRINT("info",
("time_zone_transition_type table: tz_id=%u tt_id=%u tt_gmtoff=%ld " ("time_zone_transition_type table: tz_id=%u tt_id=%u tt_gmtoff=%ld "
...@@ -1956,9 +1964,9 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) ...@@ -1956,9 +1964,9 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
#endif #endif
/* ttid is increasing because we are reading using index */ /* ttid is increasing because we are reading using index */
DBUG_ASSERT(ttid >= tz_info->typecnt); DBUG_ASSERT(ttid >= tmp_tz_info.typecnt);
tz_info->typecnt= ttid + 1; tmp_tz_info.typecnt= ttid + 1;
res= table->file->index_next_same(table->record[0], res= table->file->index_next_same(table->record[0],
table->field[0]->ptr, 4); table->field[0]->ptr, 4);
...@@ -1990,14 +1998,14 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) ...@@ -1990,14 +1998,14 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
ttime= (my_time_t)table->field[1]->val_int(); ttime= (my_time_t)table->field[1]->val_int();
ttid= (uint)table->field[2]->val_int(); ttid= (uint)table->field[2]->val_int();
if (tz_info->timecnt + 1 > TZ_MAX_TIMES) if (tmp_tz_info.timecnt + 1 > TZ_MAX_TIMES)
{ {
sql_print_error("Error while loading time zone description from " sql_print_error("Error while loading time zone description from "
"mysql.time_zone_transition table: " "mysql.time_zone_transition table: "
"too much transitions"); "too much transitions");
goto end; goto end;
} }
if (ttid + 1 > tz_info->typecnt) if (ttid + 1 > tmp_tz_info.typecnt)
{ {
sql_print_error("Error while loading time zone description from " sql_print_error("Error while loading time zone description from "
"mysql.time_zone_transition table: " "mysql.time_zone_transition table: "
...@@ -2005,9 +2013,9 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) ...@@ -2005,9 +2013,9 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
goto end; goto end;
} }
ats[tz_info->timecnt]= ttime; ats[tmp_tz_info.timecnt]= ttime;
types[tz_info->timecnt]= ttid; types[tmp_tz_info.timecnt]= ttid;
tz_info->timecnt++; tmp_tz_info.timecnt++;
DBUG_PRINT("info", DBUG_PRINT("info",
("time_zone_transition table: tz_id: %u tt_time: %lu tt_id: %u", ("time_zone_transition table: tz_id: %u tt_time: %lu tt_id: %u",
...@@ -2031,6 +2039,34 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) ...@@ -2031,6 +2039,34 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
(void)table->file->ha_index_end(); (void)table->file->ha_index_end();
table= 0; table= 0;
/*
Let us check how correct our time zone description is. We don't check for
tz->timecnt < 1 since it is ok for GMT.
*/
if (tmp_tz_info.typecnt < 1)
{
sql_print_error("loading time zone without transition types");
goto end;
}
/* Allocate memory for the timezone info and timezone name in tz_storage. */
if (!(alloc_buff= (char*) alloc_root(&tz_storage, sizeof(TIME_ZONE_INFO) +
tz_name->length() + 1)))
{
sql_print_error("Out of memory while loading time zone description");
return 0;
}
/* Move the temporary tz_info into the allocated area */
tz_info= (TIME_ZONE_INFO *)alloc_buff;
memcpy(tz_info, &tmp_tz_info, sizeof(TIME_ZONE_INFO));
tz_name_buff= alloc_buff + sizeof(TIME_ZONE_INFO);
/*
By writing zero to the end we guarantee that we can call ptr()
instead of c_ptr() for time zone name.
*/
strmake(tz_name_buff, tz_name->ptr(), tz_name->length());
/* /*
Now we will allocate memory and init TIME_ZONE_INFO structure. Now we will allocate memory and init TIME_ZONE_INFO structure.
*/ */
...@@ -2062,15 +2098,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) ...@@ -2062,15 +2098,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
tz_info->ttis= (TRAN_TYPE_INFO *)alloc_buff; tz_info->ttis= (TRAN_TYPE_INFO *)alloc_buff;
memcpy(tz_info->ttis, ttis, tz_info->typecnt * sizeof(TRAN_TYPE_INFO)); memcpy(tz_info->ttis, ttis, tz_info->typecnt * sizeof(TRAN_TYPE_INFO));
/* /* Build reversed map. */
Let us check how correct our time zone description and build
reversed map. We don't check for tz->timecnt < 1 since it ok for GMT.
*/
if (tz_info->typecnt < 1)
{
sql_print_error("loading time zone without transition types");
goto end;
}
if (prepare_tz_info(tz_info, &tz_storage)) if (prepare_tz_info(tz_info, &tz_storage))
{ {
sql_print_error("Unable to build mktime map for time zone"); sql_print_error("Unable to build mktime map for time zone");
......
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