Skip to content

Commit e9c07c5

Browse files
committed
merge from 5.1
2 parents 3cde3f3 + de90b6d commit e9c07c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1120
-385
lines changed

README

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ For the avoidance of doubt, this particular copy of the software
55
is released under the version 2 of the GNU General Public License.
66
MySQL is brought to you by the MySQL team at Oracle.
77

8-
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
8+
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
99

1010
License information can be found in the COPYING file.
1111

client/my_readline.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ typedef struct st_line_buffer
2525
uint eof;
2626
ulong max_size;
2727
ulong read_length; /* Length of last read string */
28+
int error;
29+
bool truncated;
2830
} LINE_BUFFER;
2931

3032
extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file);
3133
extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str);
32-
extern char *batch_readline(LINE_BUFFER *buffer, bool *truncated);
34+
extern char *batch_readline(LINE_BUFFER *buffer);
3335
extern void batch_readline_end(LINE_BUFFER *buffer);

client/mysql.cc

+10-6
Original file line numberDiff line numberDiff line change
@@ -1872,14 +1872,13 @@ static int read_and_execute(bool interactive)
18721872
ulong line_number=0;
18731873
bool ml_comment= 0;
18741874
COMMANDS *com;
1875-
bool truncated= 0;
18761875
status.exit_status=1;
1877-
1876+
18781877
for (;;)
18791878
{
18801879
if (!interactive)
18811880
{
1882-
line=batch_readline(status.line_buff, &truncated);
1881+
line=batch_readline(status.line_buff);
18831882
/*
18841883
Skip UTF8 Byte Order Marker (BOM) 0xEFBBBF.
18851884
Editors like "notepad" put this marker in
@@ -1953,9 +1952,13 @@ static int read_and_execute(bool interactive)
19531952
if (opt_outfile && line)
19541953
fprintf(OUTFILE, "%s\n", line);
19551954
}
1956-
if (!line) // End of file
1955+
// End of file or system error
1956+
if (!line)
19571957
{
1958-
status.exit_status=0;
1958+
if (status.line_buff && status.line_buff->error)
1959+
status.exit_status= 1;
1960+
else
1961+
status.exit_status= 0;
19591962
break;
19601963
}
19611964

@@ -1976,7 +1979,8 @@ static int read_and_execute(bool interactive)
19761979
#endif
19771980
continue;
19781981
}
1979-
if (add_line(glob_buffer,line,&in_string,&ml_comment, truncated))
1982+
if (add_line(glob_buffer, line, &in_string, &ml_comment,
1983+
status.line_buff ? status.line_buff->truncated : 0))
19801984
break;
19811985
}
19821986
/* if in batch mode, send last query even if it doesn't end with \g or go */

client/readline.cc

+20-13
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static bool init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,
2424
ulong max_size);
2525
static bool init_line_buffer_from_string(LINE_BUFFER *buffer,char * str);
2626
static size_t fill_buffer(LINE_BUFFER *buffer);
27-
static char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated);
27+
static char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length);
2828

2929

3030
LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
@@ -42,13 +42,12 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
4242
}
4343

4444

45-
char *batch_readline(LINE_BUFFER *line_buff, bool *truncated)
45+
char *batch_readline(LINE_BUFFER *line_buff)
4646
{
4747
char *pos;
4848
ulong out_length;
49-
DBUG_ASSERT(truncated != NULL);
5049

51-
if (!(pos=intern_read_line(line_buff,&out_length, truncated)))
50+
if (!(pos=intern_read_line(line_buff, &out_length)))
5251
return 0;
5352
if (out_length && pos[out_length-1] == '\n')
5453
if (--out_length && pos[out_length-1] == '\r') /* Remove '\n' */
@@ -162,7 +161,10 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
162161
if (!(buffer->buffer = (char*) my_realloc(buffer->buffer,
163162
buffer->bufread+1,
164163
MYF(MY_WME | MY_FAE))))
165-
return (uint) -1;
164+
{
165+
buffer->error= my_errno;
166+
return (size_t) -1;
167+
}
166168
buffer->start_of_line=buffer->buffer+start_offset;
167169
buffer->end=buffer->buffer+bufbytes;
168170
}
@@ -177,7 +179,10 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
177179
/* Read in new stuff. */
178180
if ((read_count= my_read(buffer->file, (uchar*) buffer->end, read_count,
179181
MYF(MY_WME))) == MY_FILE_ERROR)
182+
{
183+
buffer->error= my_errno;
180184
return (size_t) -1;
185+
}
181186

182187
DBUG_PRINT("fill_buff", ("Got %lu bytes", (ulong) read_count));
183188

@@ -198,8 +203,7 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
198203
}
199204

200205

201-
202-
char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated)
206+
char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length)
203207
{
204208
char *pos;
205209
size_t length;
@@ -214,22 +218,25 @@ char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated)
214218
if (pos == buffer->end)
215219
{
216220
/*
217-
fill_buffer() can return 0 either on EOF in which case we abort
218-
or when the internal buffer has hit the size limit. In the latter case
219-
return what we have read so far and signal string truncation.
221+
fill_buffer() can return NULL on EOF (in which case we abort),
222+
on error, or when the internal buffer has hit the size limit.
223+
In the latter case return what we have read so far and signal
224+
string truncation.
220225
*/
221-
if (!(length=fill_buffer(buffer)) || length == (uint) -1)
226+
if (!(length= fill_buffer(buffer)))
222227
{
223228
if (buffer->eof)
224229
DBUG_RETURN(0);
225230
}
231+
else if (length == (size_t) -1)
232+
DBUG_RETURN(NULL);
226233
else
227234
continue;
228235
pos--; /* break line here */
229-
*truncated= 1;
236+
buffer->truncated= 1;
230237
}
231238
else
232-
*truncated= 0;
239+
buffer->truncated= 0;
233240
buffer->end_of_line=pos+1;
234241
*out_length=(ulong) (pos + 1 - buffer->eof - buffer->start_of_line);
235242
DBUG_RETURN(buffer->start_of_line);

include/my_pthread.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2000 MySQL AB
1+
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by

include/my_sys.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by

mysql-test/collections/default.weekly

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
perl mysql-test-run.pl --timer --force --comment=1st --experimental=collections/default.experimental 1st
21
perl mysql-test-run.pl --timer --force --comment=big-tests --experimental=collections/default.experimental --vardir=var-big-tests --big-test --testcase-timeout=60 --suite-timeout=600 parts.partition_alter1_2_ndb parts.part_supported_sql_func_innodb parts.partition_alter1_2_innodb parts.partition_alter4_innodb parts.partition_alter1_1_2_ndb parts.partition_alter1_1_2_innodb parts.partition_alter1_1_ndb rpl_ndb.rpl_truncate_7ndb_2 main.archive-big main.sum_distinct-big main.mysqlbinlog_row_big main.alter_table-big main.variables-big main.type_newdecimal-big main.read_many_rows_innodb main.log_tables-big main.count_distinct3 main.events_time_zone main.merge-big main.create-big main.events_stress main.ssl-big funcs_1.myisam_views-big
32
perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam
43
perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-rpl-binlog-row-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=row

mysql-test/collections/mysql-5.1-bugteam.daily

-5
This file was deleted.

mysql-test/collections/mysql-5.1-bugteam.push

-4
This file was deleted.

mysql-test/include/mysqlhotcopy.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ DROP DATABASE hotcopy_save;
107107
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
108108
--list_files $MYSQLD_DATADIR/hotcopy_save
109109
--replace_result $MASTER_MYSOCK MASTER_MYSOCK
110-
--error 9,2304
110+
--error 9,11,2304
111111
--exec $MYSQLHOTCOPY --quiet -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save
112112
--replace_result $MASTER_MYSOCK MASTER_MYSOCK
113113
--exec $MYSQLHOTCOPY --quiet --allowold -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save

mysql-test/include/rpl_sync.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ while ($_rpl_i) {
8888
{
8989
--echo Sync IO: $_rpl_slave_io_running; Sync SQL: $_rpl_slave_sql_running
9090
}
91-
--let $_rpl_slave_io_running= `SELECT IF('$_rpl_slave_io_running' = 'Yes', 1, '')`
91+
--let $_rpl_slave_io_running= `SELECT IF('$_rpl_slave_io_running' != 'No', 1, '')`
9292
--let $_rpl_slave_sql_running= `SELECT IF('$_rpl_slave_sql_running' = 'Yes', 1, '')`
9393
if ($_rpl_slave_io_running)
9494
{

mysql-test/mysql-test-run.pl

+10
Original file line numberDiff line numberDiff line change
@@ -2055,6 +2055,16 @@ sub environment_setup {
20552055
$ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'} || 3306;
20562056
$ENV{'MYSQL_TMP_DIR'}= $opt_tmpdir;
20572057
$ENV{'MYSQLTEST_VARDIR'}= $opt_vardir;
2058+
2059+
if (IS_WINDOWS)
2060+
{
2061+
$ENV{'SECURE_LOAD_PATH'}= $glob_mysql_test_dir."\\std_data";
2062+
}
2063+
else
2064+
{
2065+
$ENV{'SECURE_LOAD_PATH'}= $glob_mysql_test_dir."/std_data";
2066+
}
2067+
20582068

20592069
# ----------------------------------------------------
20602070
# Setup env for NDB

mysql-test/r/grant.result

+74
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,80 @@ CURRENT_USER()
12521252
root@localhost
12531253
SET PASSWORD FOR CURRENT_USER() = PASSWORD("admin");
12541254
SET PASSWORD FOR CURRENT_USER() = PASSWORD("");
1255+
1256+
# Bug#57952
1257+
1258+
DROP DATABASE IF EXISTS mysqltest1;
1259+
DROP DATABASE IF EXISTS mysqltest2;
1260+
CREATE DATABASE mysqltest1;
1261+
CREATE DATABASE mysqltest2;
1262+
use mysqltest1;
1263+
CREATE TABLE t1(a INT, b INT);
1264+
INSERT INTO t1 VALUES (1, 1);
1265+
CREATE TABLE t2(a INT);
1266+
INSERT INTO t2 VALUES (2);
1267+
CREATE TABLE mysqltest2.t3(a INT);
1268+
INSERT INTO mysqltest2.t3 VALUES (4);
1269+
CREATE USER testuser@localhost;
1270+
GRANT CREATE ROUTINE, EXECUTE ON mysqltest1.* TO testuser@localhost;
1271+
GRANT SELECT(b) ON t1 TO testuser@localhost;
1272+
GRANT SELECT ON t2 TO testuser@localhost;
1273+
GRANT SELECT ON mysqltest2.* TO testuser@localhost;
1274+
1275+
# Connection: bug57952_con1 (testuser@localhost, db: mysqltest1)
1276+
PREPARE s1 FROM 'SELECT b FROM t1';
1277+
PREPARE s2 FROM 'SELECT a FROM t2';
1278+
PREPARE s3 FROM 'SHOW TABLES FROM mysqltest2';
1279+
CREATE PROCEDURE p1() SELECT b FROM t1;
1280+
CREATE PROCEDURE p2() SELECT a FROM t2;
1281+
CREATE PROCEDURE p3() SHOW TABLES FROM mysqltest2;
1282+
CALL p1;
1283+
b
1284+
1
1285+
CALL p2;
1286+
a
1287+
2
1288+
CALL p3;
1289+
Tables_in_mysqltest2
1290+
t3
1291+
1292+
# Connection: default
1293+
REVOKE SELECT ON t1 FROM testuser@localhost;
1294+
GRANT SELECT(a) ON t1 TO testuser@localhost;
1295+
REVOKE SELECT ON t2 FROM testuser@localhost;
1296+
REVOKE SELECT ON mysqltest2.* FROM testuser@localhost;
1297+
1298+
# Connection: bug57952_con1 (testuser@localhost, db: mysqltest1)
1299+
# - Check column-level privileges...
1300+
EXECUTE s1;
1301+
ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'b' in table 't1'
1302+
SELECT b FROM t1;
1303+
ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'b' in table 't1'
1304+
EXECUTE s1;
1305+
ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'b' in table 't1'
1306+
CALL p1;
1307+
ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'b' in table 't1'
1308+
# - Check table-level privileges...
1309+
SELECT a FROM t2;
1310+
ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table 't2'
1311+
EXECUTE s2;
1312+
ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table 't2'
1313+
CALL p2;
1314+
ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table 't2'
1315+
# - Check database-level privileges...
1316+
SHOW TABLES FROM mysqltest2;
1317+
ERROR 42000: Access denied for user 'testuser'@'localhost' to database 'mysqltest2'
1318+
EXECUTE s3;
1319+
ERROR 42000: Access denied for user 'testuser'@'localhost' to database 'mysqltest2'
1320+
CALL p3;
1321+
ERROR 42000: Access denied for user 'testuser'@'localhost' to database 'mysqltest2'
1322+
1323+
# Connection: default
1324+
DROP DATABASE mysqltest1;
1325+
DROP DATABASE mysqltest2;
1326+
DROP USER testuser@localhost;
1327+
use test;
1328+
12551329
End of 5.0 tests
12561330
set names utf8;
12571331
grant select on test.* to юзер_юзер@localhost;

mysql-test/r/order_by.result

+25
Original file line numberDiff line numberDiff line change
@@ -1638,4 +1638,29 @@ id select_type table type possible_keys key key_len ref rows Extra
16381638
1 SIMPLE t1 index NULL a 8 NULL 10 Using index; Using temporary; Using filesort
16391639
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 Using where
16401640
DROP TABLE t1, t2;
1641+
#
1642+
# Bug #59110: Memory leak of QUICK_SELECT_I allocated memory
1643+
# and
1644+
# Bug #59308: Incorrect result for
1645+
SELECT DISTINCT <col>... ORDER BY <col> DESC
1646+
1647+
# Use Valgrind to detect #59110!
1648+
#
1649+
CREATE TABLE t1 (a INT,KEY (a));
1650+
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
1651+
EXPLAIN SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
1652+
id select_type table type possible_keys key key_len ref rows Extra
1653+
1 SIMPLE t1 index a a 5 NULL 10 Using where; Using index; Using filesort
1654+
SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
1655+
a 1
1656+
10 1
1657+
9 1
1658+
8 1
1659+
7 1
1660+
6 1
1661+
5 1
1662+
4 1
1663+
3 1
1664+
2 1
1665+
DROP TABLE t1;
16411666
End of 5.1 tests

mysql-test/r/type_year.result

+14
Original file line numberDiff line numberDiff line change
@@ -341,4 +341,18 @@ ta_y s tb_y s
341341
2001 2001 2001 2001
342342
DROP TABLE t1;
343343
#
344+
# Bug #59211: Select Returns Different Value for min(year) Function
345+
#
346+
CREATE TABLE t1(c1 YEAR(4));
347+
INSERT INTO t1 VALUES (1901),(2155),(0000);
348+
SELECT * FROM t1;
349+
c1
350+
1901
351+
2155
352+
0000
353+
SELECT COUNT(*) AS total_rows, MIN(c1) AS min_value, MAX(c1) FROM t1;
354+
total_rows min_value MAX(c1)
355+
3 0 2155
356+
DROP TABLE t1;
357+
#
344358
End of 5.1 tests

mysql-test/r/user_var.result

+6
Original file line numberDiff line numberDiff line change
@@ -450,4 +450,10 @@ DROP TABLE t1;
450450
select @v:=@v:=sum(1) from dual;
451451
@v:=@v:=sum(1)
452452
1
453+
CREATE TABLE t1(a DECIMAL(31,21));
454+
INSERT INTO t1 VALUES (0);
455+
SELECT (@v:=a) <> (@v:=1) FROM t1;
456+
(@v:=a) <> (@v:=1)
457+
1
458+
DROP TABLE t1;
453459
End of 5.1 tests

mysql-test/suite/binlog/r/binlog_unsafe.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
271271
DROP TABLE t1,t2;
272272
"Should NOT have any warning message issued in the following func7() and trig"
273273
CREATE TABLE t1 (a INT);
274-
CREATE TABLE t2 (a CHAR(40));
274+
CREATE TABLE t2 (a TEXT);
275275
CREATE TABLE trigger_table (a CHAR(7));
276276
CREATE FUNCTION func7()
277277
RETURNS INT

mysql-test/suite/binlog/t/binlog_unsafe.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ DROP TABLE t1,t2;
329329

330330
--echo "Should NOT have any warning message issued in the following func7() and trig"
331331
CREATE TABLE t1 (a INT);
332-
CREATE TABLE t2 (a CHAR(40));
332+
CREATE TABLE t2 (a TEXT);
333333
CREATE TABLE trigger_table (a CHAR(7));
334334
DELIMITER |;
335335
CREATE FUNCTION func7()
Binary file not shown.

mysql-test/suite/engines/funcs/t/ps_string_not_null.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--disable_warnings
2-
DROP TABLE IF EXISTS t2;
2+
DROP TABLE IF EXISTS t1;
33
--enable_warnings
44
CREATE TABLE t1(c1 CHAR(100) NOT NULL);
55
PREPARE stmt1 FROM 'INSERT INTO t1 (c1) VALUES(?)';

0 commit comments

Comments
 (0)