mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
Merge dl145s.mysql.com:/data0/bk/team_tree_merge/mysql-5.0
into dl145s.mysql.com:/data0/bk/team_tree_merge/MERGE/mysql-5.0-opt
This commit is contained in:
commit
03431eb78a
24 changed files with 470 additions and 28 deletions
|
@ -222,11 +222,13 @@ struct st_connection
|
|||
char *name;
|
||||
MYSQL_STMT* stmt;
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
const char *cur_query;
|
||||
int cur_query_len;
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
int query_done;
|
||||
#endif /*EMBEDDED_LIBRARY*/
|
||||
};
|
||||
struct st_connection connections[128];
|
||||
struct st_connection* cur_con, *next_con, *connections_end;
|
||||
|
|
|
@ -46,6 +46,10 @@ create table t1 (a tinyint(1),b binary(1));
|
|||
insert into t1 values (0x01,0x01);
|
||||
select * from t1 where a=b;
|
||||
a b
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: ''
|
||||
select * from t1 where a=b and b=0x01;
|
||||
a b
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: ''
|
||||
drop table if exists t1;
|
||||
|
|
|
@ -69,6 +69,25 @@ grp group_concat(a order by d+c-ascii(c),a)
|
|||
1 1
|
||||
2 3,2
|
||||
3 7,8,4,6,9,5
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'c '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'E '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'C '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'D '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'd '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'd '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'd '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'd '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'c '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'D '
|
||||
select grp,group_concat(c order by 1) from t1 group by grp;
|
||||
grp group_concat(c order by 1)
|
||||
1 a
|
||||
|
|
|
@ -62,6 +62,13 @@ NULL NULL
|
|||
1 7
|
||||
2 20.25
|
||||
3 45.483163247594
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'c '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'C '
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'E '
|
||||
create table t2 (grp int, a bigint unsigned, c char(10));
|
||||
insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp;
|
||||
replace into t2 select grp, a, c from t1 limit 2,1;
|
||||
|
|
|
@ -2162,3 +2162,127 @@ SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;
|
|||
MIN(c)
|
||||
2
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (a INT, b INT, INDEX (a,b));
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),
|
||||
(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
|
||||
EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
FLUSH STATUS;
|
||||
SELECT max(b), a FROM t1 GROUP BY a;
|
||||
max(b) a
|
||||
5 1
|
||||
3 2
|
||||
1 3
|
||||
6 4
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
Variable_name Value
|
||||
Handler_read_key 8
|
||||
Handler_read_next 0
|
||||
EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
FLUSH STATUS;
|
||||
CREATE TABLE t2 SELECT max(b), a FROM t1 GROUP BY a;
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
Variable_name Value
|
||||
Handler_read_key 8
|
||||
Handler_read_next 0
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b;
|
||||
max(b) a
|
||||
5 1
|
||||
3 2
|
||||
1 3
|
||||
6 4
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
Variable_name Value
|
||||
Handler_read_key 8
|
||||
Handler_read_next 0
|
||||
FLUSH STATUS;
|
||||
(SELECT max(b), a FROM t1 GROUP BY a) UNION
|
||||
(SELECT max(b), a FROM t1 GROUP BY a);
|
||||
max(b) a
|
||||
5 1
|
||||
3 2
|
||||
1 3
|
||||
6 4
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
Variable_name Value
|
||||
Handler_read_key 16
|
||||
Handler_read_next 0
|
||||
EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION
|
||||
(SELECT max(b), a FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
2 UNION t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
|
||||
EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
|
||||
FROM t1 AS t1_outer;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS
|
||||
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 8 Using index
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
|
||||
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
|
||||
a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 index NULL a 10 NULL 8 Using index
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING
|
||||
a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_outer range NULL a 5 NULL 8 Using index for group-by
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2
|
||||
ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2)
|
||||
AND t1_outer1.b = t1_outer2.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_outer1 ref a a 5 const 1 Using where; Using index
|
||||
1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
|
||||
FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using index
|
||||
2 SUBQUERY t1_outer index NULL a 10 NULL 15 Using index
|
||||
3 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
CREATE TABLE t3 LIKE t1;
|
||||
FLUSH STATUS;
|
||||
INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a;
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
Variable_name Value
|
||||
Handler_read_key 8
|
||||
Handler_read_next 0
|
||||
DELETE FROM t3;
|
||||
FLUSH STATUS;
|
||||
INSERT INTO t3 SELECT 1, (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2)
|
||||
FROM t1 LIMIT 1;
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
Variable_name Value
|
||||
Handler_read_key 8
|
||||
Handler_read_next 0
|
||||
FLUSH STATUS;
|
||||
DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000;
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
Variable_name Value
|
||||
Handler_read_key 8
|
||||
Handler_read_next 0
|
||||
FLUSH STATUS;
|
||||
DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x
|
||||
FROM t1) > 10000;
|
||||
Warnings:
|
||||
Error 1242 Subquery returns more than 1 row
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
Variable_name Value
|
||||
Handler_read_key 8
|
||||
Handler_read_next 1
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
|
|
@ -1478,6 +1478,24 @@ i
|
|||
1
|
||||
DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1 (i INT);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
SELECT t1.i FROM t1 JOIN v1 ON t1.i = v1.i
|
||||
WHERE EXISTS (SELECT * FROM t1 WHERE v1.i = 1);
|
||||
i
|
||||
1
|
||||
PREPARE stmt FROM "SELECT t1.i FROM t1 JOIN v1 ON t1.i = v1.i
|
||||
WHERE EXISTS (SELECT * FROM t1 WHERE v1.i = 1)";
|
||||
EXECUTE stmt;
|
||||
i
|
||||
1
|
||||
EXECUTE stmt;
|
||||
i
|
||||
1
|
||||
DEALLOCATE PREPARE stmt;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
flush status;
|
||||
prepare sq from 'show status like "slow_queries"';
|
||||
|
|
|
@ -453,3 +453,38 @@ id name_id id en cz
|
|||
2 3 2 en string 2 cz string 2
|
||||
3 3 3 en string 3 cz string 3
|
||||
drop table t1, t2, t3;
|
||||
CREATE TABLE t1 (a CHAR(2));
|
||||
INSERT INTO t1 VALUES (10), (50), (30), ('1a'), (60), ('t');
|
||||
SELECT a,(a + 0) FROM t1 ORDER BY a;
|
||||
a (a + 0)
|
||||
10 10
|
||||
1a 1
|
||||
30 30
|
||||
50 50
|
||||
60 60
|
||||
t 0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: '1a'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 't '
|
||||
SELECT a,(a DIV 2) FROM t1 ORDER BY a;
|
||||
a (a DIV 2)
|
||||
10 5
|
||||
1a 0
|
||||
30 15
|
||||
50 25
|
||||
60 30
|
||||
t 0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1a'
|
||||
Warning 1292 Truncated incorrect INTEGER value: 't '
|
||||
SELECT a,CAST(a AS SIGNED) FROM t1 ORDER BY a;
|
||||
a CAST(a AS SIGNED)
|
||||
10 10
|
||||
1a 1
|
||||
30 30
|
||||
50 50
|
||||
60 60
|
||||
t 0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1a'
|
||||
Warning 1292 Truncated incorrect INTEGER value: 't'
|
||||
|
|
|
@ -712,3 +712,22 @@ DROP FUNCTION f1;
|
|||
DROP VIEW v2;
|
||||
DROP VIEW v1;
|
||||
DROP USER mysqltest_u1@localhost;
|
||||
CREATE DATABASE db17254;
|
||||
USE db17254;
|
||||
CREATE TABLE t1 (f1 INT);
|
||||
INSERT INTO t1 VALUES (10),(20);
|
||||
CREATE USER def_17254@localhost;
|
||||
GRANT SELECT ON db17254.* TO def_17254@localhost;
|
||||
CREATE USER inv_17254@localhost;
|
||||
GRANT SELECT ON db17254.t1 TO inv_17254@localhost;
|
||||
GRANT CREATE VIEW ON db17254.* TO def_17254@localhost;
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
DROP USER def_17254@localhost;
|
||||
for a user
|
||||
SELECT * FROM v1;
|
||||
ERROR 42000: SELECT command denied to user 'inv_17254'@'localhost' for table 'v1'
|
||||
for a superuser
|
||||
SELECT * FROM v1;
|
||||
ERROR HY000: There is no 'def_17254'@'localhost' registered
|
||||
DROP USER inv_17254@localhost;
|
||||
DROP DATABASE db17254;
|
||||
|
|
|
@ -29,7 +29,9 @@ select grp,group_concat(c order by c) from t1 group by grp;
|
|||
select grp,group_concat(c order by c desc) from t1 group by grp;
|
||||
select grp,group_concat(d order by a) from t1 group by grp;
|
||||
select grp,group_concat(d order by a desc) from t1 group by grp;
|
||||
--disable_warnings
|
||||
select grp,group_concat(a order by a,d+c-ascii(c)-a) from t1 group by grp;
|
||||
--enable_warnings
|
||||
select grp,group_concat(a order by d+c-ascii(c),a) from t1 group by grp;
|
||||
select grp,group_concat(c order by 1) from t1 group by grp;
|
||||
select grp,group_concat(distinct c order by c) from t1 group by grp;
|
||||
|
|
|
@ -810,3 +810,63 @@ explain SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;
|
|||
SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
#
|
||||
# Bug#24156: Loose index scan not used with CREATE TABLE ...SELECT and similar statements
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (a INT, b INT, INDEX (a,b));
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),
|
||||
(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
|
||||
EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
|
||||
FLUSH STATUS;
|
||||
SELECT max(b), a FROM t1 GROUP BY a;
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
|
||||
FLUSH STATUS;
|
||||
CREATE TABLE t2 SELECT max(b), a FROM t1 GROUP BY a;
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b;
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
FLUSH STATUS;
|
||||
(SELECT max(b), a FROM t1 GROUP BY a) UNION
|
||||
(SELECT max(b), a FROM t1 GROUP BY a);
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION
|
||||
(SELECT max(b), a FROM t1 GROUP BY a);
|
||||
|
||||
EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
|
||||
FROM t1 AS t1_outer;
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS
|
||||
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
|
||||
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
|
||||
a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING
|
||||
a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2
|
||||
ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2)
|
||||
AND t1_outer1.b = t1_outer2.b;
|
||||
EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
|
||||
FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2;
|
||||
|
||||
CREATE TABLE t3 LIKE t1;
|
||||
FLUSH STATUS;
|
||||
INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a;
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
DELETE FROM t3;
|
||||
FLUSH STATUS;
|
||||
INSERT INTO t3 SELECT 1, (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2)
|
||||
FROM t1 LIMIT 1;
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
FLUSH STATUS;
|
||||
DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000;
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
FLUSH STATUS;
|
||||
DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x
|
||||
FROM t1) > 10000;
|
||||
SHOW STATUS LIKE 'handler_read__e%';
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
|
|
@ -1507,6 +1507,29 @@ DEALLOCATE PREPARE stmt;
|
|||
DROP TABLE t1, t2;
|
||||
|
||||
|
||||
#
|
||||
# BUG#20327: Marking of a wrong field leads to a wrong result on select with
|
||||
# view, prepared statement and subquery.
|
||||
#
|
||||
CREATE TABLE t1 (i INT);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
|
||||
let $query = SELECT t1.i FROM t1 JOIN v1 ON t1.i = v1.i
|
||||
WHERE EXISTS (SELECT * FROM t1 WHERE v1.i = 1);
|
||||
eval $query;
|
||||
eval PREPARE stmt FROM "$query";
|
||||
# Statement execution should return '1'.
|
||||
EXECUTE stmt;
|
||||
# Check re-execution.
|
||||
EXECUTE stmt;
|
||||
|
||||
DEALLOCATE PREPARE stmt;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
#
|
||||
# BUG#21856: Prepared Statments: crash if bad create
|
||||
#
|
||||
|
|
|
@ -187,3 +187,12 @@ left join t3 on t1.id=t3.id order by t3.id;
|
|||
--disable_metadata
|
||||
--enable_ps_protocol
|
||||
drop table t1, t2, t3;
|
||||
|
||||
#
|
||||
# Bug #11927: Warnings shown for CAST( chr as signed) but not (chr + 0)
|
||||
#
|
||||
CREATE TABLE t1 (a CHAR(2));
|
||||
INSERT INTO t1 VALUES (10), (50), (30), ('1a'), (60), ('t');
|
||||
SELECT a,(a + 0) FROM t1 ORDER BY a;
|
||||
SELECT a,(a DIV 2) FROM t1 ORDER BY a;
|
||||
SELECT a,CAST(a AS SIGNED) FROM t1 ORDER BY a;
|
||||
|
|
|
@ -927,4 +927,41 @@ DROP VIEW v2;
|
|||
DROP VIEW v1;
|
||||
DROP USER mysqltest_u1@localhost;
|
||||
|
||||
#
|
||||
# Bug#17254: Error for DEFINER security on VIEW provides too much info
|
||||
#
|
||||
connect (root,localhost,root,,);
|
||||
connection root;
|
||||
CREATE DATABASE db17254;
|
||||
USE db17254;
|
||||
CREATE TABLE t1 (f1 INT);
|
||||
INSERT INTO t1 VALUES (10),(20);
|
||||
CREATE USER def_17254@localhost;
|
||||
GRANT SELECT ON db17254.* TO def_17254@localhost;
|
||||
CREATE USER inv_17254@localhost;
|
||||
GRANT SELECT ON db17254.t1 TO inv_17254@localhost;
|
||||
GRANT CREATE VIEW ON db17254.* TO def_17254@localhost;
|
||||
|
||||
connect (def,localhost,def_17254,,db17254);
|
||||
connection def;
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
|
||||
connection root;
|
||||
DROP USER def_17254@localhost;
|
||||
|
||||
connect (inv,localhost,inv_17254,,db17254);
|
||||
connection inv;
|
||||
--echo for a user
|
||||
--error 1142
|
||||
SELECT * FROM v1;
|
||||
|
||||
connection root;
|
||||
--echo for a superuser
|
||||
--error 1449
|
||||
SELECT * FROM v1;
|
||||
DROP USER inv_17254@localhost;
|
||||
DROP DATABASE db17254;
|
||||
disconnect def;
|
||||
disconnect inv;
|
||||
|
||||
# End of 5.0 tests.
|
||||
|
|
60
sql/field.cc
60
sql/field.cc
|
@ -47,6 +47,8 @@ uchar Field_null::null[1]={1};
|
|||
const char field_separator=',';
|
||||
|
||||
#define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE 320
|
||||
#define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
|
||||
#define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
|
||||
#define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
|
||||
((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
|
||||
|
||||
|
@ -6056,19 +6058,49 @@ int Field_longstr::store_decimal(const my_decimal *d)
|
|||
|
||||
double Field_string::val_real(void)
|
||||
{
|
||||
int not_used;
|
||||
char *end_not_used;
|
||||
int error;
|
||||
char *end;
|
||||
CHARSET_INFO *cs= charset();
|
||||
return my_strntod(cs,ptr,field_length,&end_not_used,¬_used);
|
||||
double result;
|
||||
|
||||
result= my_strntod(cs,ptr,field_length,&end,&error);
|
||||
if (!table->in_use->no_errors &&
|
||||
(error || (field_length != (uint32)(end - ptr) &&
|
||||
!check_if_only_end_space(cs, end, ptr + field_length))))
|
||||
{
|
||||
char buf[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
|
||||
String tmp(buf, sizeof(buf), cs);
|
||||
tmp.copy(ptr, field_length, cs);
|
||||
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_TRUNCATED_WRONG_VALUE,
|
||||
ER(ER_TRUNCATED_WRONG_VALUE),
|
||||
"DOUBLE", tmp.c_ptr());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
longlong Field_string::val_int(void)
|
||||
{
|
||||
int not_used;
|
||||
char *end_not_used;
|
||||
CHARSET_INFO *cs=charset();
|
||||
return my_strntoll(cs,ptr,field_length,10,&end_not_used,¬_used);
|
||||
int error;
|
||||
char *end;
|
||||
CHARSET_INFO *cs= charset();
|
||||
longlong result;
|
||||
|
||||
result= my_strntoll(cs,ptr,field_length,10,&end,&error);
|
||||
if (!table->in_use->no_errors &&
|
||||
(error || (field_length != (uint32)(end - ptr) &&
|
||||
!check_if_only_end_space(cs, end, ptr + field_length))))
|
||||
{
|
||||
char buf[LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE];
|
||||
String tmp(buf, sizeof(buf), cs);
|
||||
tmp.copy(ptr, field_length, cs);
|
||||
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_TRUNCATED_WRONG_VALUE,
|
||||
ER(ER_TRUNCATED_WRONG_VALUE),
|
||||
"INTEGER", tmp.c_ptr());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -6085,8 +6117,20 @@ String *Field_string::val_str(String *val_buffer __attribute__((unused)),
|
|||
|
||||
my_decimal *Field_string::val_decimal(my_decimal *decimal_value)
|
||||
{
|
||||
str2my_decimal(E_DEC_FATAL_ERROR, ptr, field_length, charset(),
|
||||
int err= str2my_decimal(E_DEC_FATAL_ERROR, ptr, field_length, charset(),
|
||||
decimal_value);
|
||||
if (!table->in_use->no_errors && err)
|
||||
{
|
||||
char buf[DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE];
|
||||
CHARSET_INFO *cs= charset();
|
||||
String tmp(buf, sizeof(buf), cs);
|
||||
tmp.copy(ptr, field_length, cs);
|
||||
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_TRUNCATED_WRONG_VALUE,
|
||||
ER(ER_TRUNCATED_WRONG_VALUE),
|
||||
"DECIMAL", tmp.c_ptr());
|
||||
}
|
||||
|
||||
return decimal_value;
|
||||
}
|
||||
|
||||
|
|
24
sql/item.cc
24
sql/item.cc
|
@ -2175,12 +2175,6 @@ void Item_string::print(String *str)
|
|||
}
|
||||
|
||||
|
||||
inline bool check_if_only_end_space(CHARSET_INFO *cs, char *str, char *end)
|
||||
{
|
||||
return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end;
|
||||
}
|
||||
|
||||
|
||||
double Item_string::val_real()
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
|
@ -4764,6 +4758,22 @@ bool Item_field::send(Protocol *protocol, String *buffer)
|
|||
}
|
||||
|
||||
|
||||
void Item_field::update_null_value()
|
||||
{
|
||||
/*
|
||||
need to set no_errors to prevent warnings about type conversion
|
||||
popping up.
|
||||
*/
|
||||
THD *thd= field->table->in_use;
|
||||
int no_errors;
|
||||
|
||||
no_errors= thd->no_errors;
|
||||
thd->no_errors= 1;
|
||||
Item::update_null_value();
|
||||
thd->no_errors= no_errors;
|
||||
}
|
||||
|
||||
|
||||
Item_ref::Item_ref(Name_resolution_context *context_arg,
|
||||
Item **item, const char *table_name_arg,
|
||||
const char *field_name_arg)
|
||||
|
@ -6120,7 +6130,7 @@ bool Item_cache_row::null_inside()
|
|||
}
|
||||
else
|
||||
{
|
||||
values[i]->val_int();
|
||||
values[i]->update_null_value();
|
||||
if (values[i]->null_value)
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -703,6 +703,11 @@ public:
|
|||
*/
|
||||
virtual bool is_null() { return 0; }
|
||||
|
||||
/*
|
||||
Make sure the null_value member has a correct value.
|
||||
*/
|
||||
virtual void update_null_value () { (void) val_int(); }
|
||||
|
||||
/*
|
||||
Inform the item that there will be no distinction between its result
|
||||
being FALSE or NULL.
|
||||
|
@ -1270,6 +1275,7 @@ public:
|
|||
bool get_date_result(TIME *ltime,uint fuzzydate);
|
||||
bool get_time(TIME *ltime);
|
||||
bool is_null() { return field->is_null(); }
|
||||
void update_null_value();
|
||||
Item *get_tmp_table_item(THD *thd);
|
||||
bool collect_item_field_processor(byte * arg);
|
||||
bool find_item_in_field_list_processor(byte *arg);
|
||||
|
|
|
@ -157,7 +157,7 @@ public:
|
|||
return (null_value=args[0]->get_time(ltime));
|
||||
}
|
||||
bool is_null() {
|
||||
(void) val_int(); /* Discard result. It sets null_value as side-effect. */
|
||||
update_null_value();
|
||||
return null_value;
|
||||
}
|
||||
void signal_divide_by_null();
|
||||
|
@ -241,7 +241,7 @@ public:
|
|||
virtual double real_op()= 0;
|
||||
virtual my_decimal *decimal_op(my_decimal *)= 0;
|
||||
virtual String *str_op(String *)= 0;
|
||||
bool is_null() { (void) val_real(); return null_value; }
|
||||
bool is_null() { update_null_value(); return null_value; }
|
||||
};
|
||||
|
||||
/* function where type of result detected by first argument */
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
enum Type type() const;
|
||||
bool is_null()
|
||||
{
|
||||
val_int();
|
||||
update_null_value();
|
||||
return null_value;
|
||||
}
|
||||
bool fix_fields(THD *thd, Item **ref);
|
||||
|
|
|
@ -1054,7 +1054,7 @@ bool Item_sum_count::add()
|
|||
count++;
|
||||
else
|
||||
{
|
||||
(void) args[0]->val_int();
|
||||
args[0]->update_null_value();
|
||||
if (!args[0]->null_value)
|
||||
count++;
|
||||
}
|
||||
|
@ -1961,7 +1961,7 @@ void Item_sum_count::reset_field()
|
|||
nr=1;
|
||||
else
|
||||
{
|
||||
(void) args[0]->val_int();
|
||||
args[0]->update_null_value();
|
||||
if (!args[0]->null_value)
|
||||
nr=1;
|
||||
}
|
||||
|
@ -2071,7 +2071,7 @@ void Item_sum_count::update_field()
|
|||
nr++;
|
||||
else
|
||||
{
|
||||
(void) args[0]->val_int();
|
||||
args[0]->update_null_value();
|
||||
if (!args[0]->null_value)
|
||||
nr++;
|
||||
}
|
||||
|
@ -2551,7 +2551,7 @@ bool Item_sum_count_distinct::setup(THD *thd)
|
|||
return TRUE; // End of memory
|
||||
if (item->const_item())
|
||||
{
|
||||
(void) item->val_int();
|
||||
item->update_null_value();
|
||||
if (item->null_value)
|
||||
always_null=1;
|
||||
}
|
||||
|
|
|
@ -618,7 +618,7 @@ public:
|
|||
double val_real();
|
||||
longlong val_int();
|
||||
my_decimal *val_decimal(my_decimal *);
|
||||
bool is_null() { (void) val_int(); return null_value; }
|
||||
bool is_null() { update_null_value(); return null_value; }
|
||||
String *val_str(String*);
|
||||
enum_field_types field_type() const
|
||||
{
|
||||
|
@ -685,7 +685,7 @@ public:
|
|||
{ /* can't be fix_fields()ed */ return (longlong) rint(val_real()); }
|
||||
String *val_str(String*);
|
||||
my_decimal *val_decimal(my_decimal *);
|
||||
bool is_null() { (void) val_int(); return null_value; }
|
||||
bool is_null() { update_null_value(); return null_value; }
|
||||
enum_field_types field_type() const
|
||||
{
|
||||
return hybrid_type == DECIMAL_RESULT ?
|
||||
|
|
|
@ -7445,7 +7445,7 @@ static TRP_GROUP_MIN_MAX *
|
|||
get_best_group_min_max(PARAM *param, SEL_TREE *tree)
|
||||
{
|
||||
THD *thd= param->thd;
|
||||
JOIN *join= thd->lex->select_lex.join;
|
||||
JOIN *join= thd->lex->current_select->join;
|
||||
TABLE *table= param->table;
|
||||
bool have_min= FALSE; /* TRUE if there is a MIN function. */
|
||||
bool have_max= FALSE; /* TRUE if there is a MAX function. */
|
||||
|
@ -7466,7 +7466,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
|
|||
DBUG_ENTER("get_best_group_min_max");
|
||||
|
||||
/* Perform few 'cheap' tests whether this access method is applicable. */
|
||||
if (!join || (thd->lex->sql_command != SQLCOM_SELECT))
|
||||
if (!join)
|
||||
DBUG_RETURN(NULL); /* This is not a select statement. */
|
||||
if ((join->tables != 1) || /* The query must reference one table. */
|
||||
((!join->group_list) && /* Neither GROUP BY nor a DISTINCT query. */
|
||||
|
@ -8316,7 +8316,7 @@ TRP_GROUP_MIN_MAX::make_quick(PARAM *param, bool retrieve_full_rows,
|
|||
DBUG_ENTER("TRP_GROUP_MIN_MAX::make_quick");
|
||||
|
||||
quick= new QUICK_GROUP_MIN_MAX_SELECT(param->table,
|
||||
param->thd->lex->select_lex.join,
|
||||
param->thd->lex->current_select->join,
|
||||
have_min, have_max, min_max_arg_part,
|
||||
group_prefix_len, used_key_parts,
|
||||
index_info, index, read_cost, records,
|
||||
|
|
|
@ -3308,6 +3308,12 @@ find_field_in_tables(THD *thd, Item_ident *item,
|
|||
{
|
||||
if (found == WRONG_GRANT)
|
||||
return (Field*) 0;
|
||||
|
||||
/*
|
||||
Only views fields should be marked as dependent, not an underlying
|
||||
fields.
|
||||
*/
|
||||
if (!table_ref->belong_to_view)
|
||||
{
|
||||
SELECT_LEX *current_sel= thd->lex->current_select;
|
||||
SELECT_LEX *last_select= table_ref->select_lex;
|
||||
|
|
|
@ -363,3 +363,9 @@ public:
|
|||
return (s->alloced && Ptr >= s->Ptr && Ptr < s->Ptr + s->str_length);
|
||||
}
|
||||
};
|
||||
|
||||
static inline bool check_if_only_end_space(CHARSET_INFO *cs, char *str,
|
||||
char *end)
|
||||
{
|
||||
return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end;
|
||||
}
|
||||
|
|
13
sql/table.cc
13
sql/table.cc
|
@ -2458,7 +2458,18 @@ bool st_table_list::prepare_view_securety_context(THD *thd)
|
|||
}
|
||||
else
|
||||
{
|
||||
my_error(ER_NO_SUCH_USER, MYF(0), definer.user.str, definer.host.str);
|
||||
if (thd->security_ctx->master_access & SUPER_ACL)
|
||||
{
|
||||
my_error(ER_NO_SUCH_USER, MYF(0), definer.user.str, definer.host.str);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
|
||||
thd->security_ctx->priv_user,
|
||||
thd->security_ctx->priv_host,
|
||||
(thd->password ? ER(ER_YES) : ER(ER_NO)));
|
||||
}
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue