Merge siva.hindu.god:/home/tsmith/m/bk/50

into  siva.hindu.god:/home/tsmith/m/bk/maint/50
This commit is contained in:
tsmith@siva.hindu.god 2007-05-17 14:17:50 -06:00
commit 30bc713c77
133 changed files with 6641 additions and 3614 deletions

View file

@ -120,6 +120,9 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG
${CMAKE_CXX_FLAGS_DEBUG})
# generate map files
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MAP /MAPINFO:EXPORTS")
# remove support for Exception handling
STRING(REPLACE "/GX" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})

View file

@ -64,13 +64,13 @@ link_sources:
for f in $(sql_src) ; do \
rm -f $$f; \
@LN_CP_F@ $(top_srcdir)/sql/$$f $$f; \
done; \
for f in $(strings_src) ; do \
rm -f $(srcdir)/$$f; \
@LN_CP_F@ $(top_srcdir)/strings/$$f $$f; \
done; \
rm -f $(srcdir)/my_user.c; \
@LN_CP_F@ $(top_srcdir)/sql-common/my_user.c my_user.c;
done; \
for f in $(strings_src) ; do \
rm -f $(srcdir)/$$f; \
@LN_CP_F@ $(top_srcdir)/strings/$$f $$f; \
done; \
rm -f $(srcdir)/my_user.c; \
@LN_CP_F@ $(top_srcdir)/sql-common/my_user.c my_user.c;
# Don't update the files from bitkeeper

View file

@ -47,6 +47,7 @@ int decimal_bin_size(int precision, int scale);
int decimal_result_size(decimal_t *from1, decimal_t *from2, char op,
int param);
int decimal_intg(decimal_t *from);
int decimal_add(decimal_t *from1, decimal_t *from2, decimal_t *to);
int decimal_sub(decimal_t *from1, decimal_t *from2, decimal_t *to);
int decimal_cmp(decimal_t *from1, decimal_t *from2);

View file

@ -127,11 +127,11 @@ link_sources:
for f in $(sqlsources); do \
rm -f $$f; \
if test -e $(top_srcdir)/sql/$$f ; \
then \
then \
@LN_CP_F@ $(top_srcdir)/sql/$$f $$f; \
else \
else \
@LN_CP_F@ $(top_builddir)/sql/$$f $$f; \
fi ; \
fi ; \
done; \
for f in $(libmysqlsources); do \
rm -f $$f; \

View file

@ -13,9 +13,11 @@ TimeBetweenGlobalCheckpoints= 500
NoOfFragmentLogFiles= 3
#
# Increase deadlock-timeout to cater for slow test-machines
# Increase timeouts to cater for slow test-machines
# (possibly running several tests in parallell)
#
HeartbeatIntervalDbDb= 30000
HeartbeatIntervalDbApi= 30000
#TransactionDeadlockDetectionTimeout= 7500
[ndbd]

View file

@ -13,9 +13,11 @@ TimeBetweenGlobalCheckpoints= 500
NoOfFragmentLogFiles= 3
#
# Increase deadlock-timeout to cater for slow test-machines
# Increase timeouts to cater for slow test-machines
# (possibly running several tests in parallell)
#
HeartbeatIntervalDbDb= 30000
HeartbeatIntervalDbApi= 30000
#TransactionDeadlockDetectionTimeout= 7500
[ndbd]

View file

@ -13,9 +13,11 @@ TimeBetweenGlobalCheckpoints= 500
NoOfFragmentLogFiles= 3
#
# Increase deadlock-timeout to cater for slow test-machines
# Increase timeouts to cater for slow test-machines
# (possibly running several tests in parallell)
#
HeartbeatIntervalDbDb= 30000
HeartbeatIntervalDbApi= 30000
#TransactionDeadlockDetectionTimeout= 7500
[ndbd]

View file

@ -103,7 +103,7 @@ Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a'
select 10.0+cast('a' as decimal);
10.0+cast('a' as decimal)
10.00
10.0
Warnings:
Warning 1292 Truncated incorrect DECIMAL value: 'a'
select 10E+0+'a';
@ -351,6 +351,12 @@ DROP TABLE t1;
select isnull(date(NULL)), isnull(cast(NULL as DATE));
isnull(date(NULL)) isnull(cast(NULL as DATE))
1 1
SELECT CAST(cast('01-01-01' as date) AS UNSIGNED);
CAST(cast('01-01-01' as date) AS UNSIGNED)
20010101
SELECT CAST(cast('01-01-01' as date) AS SIGNED);
CAST(cast('01-01-01' as date) AS SIGNED)
20010101
End of 4.1 tests
select cast('1.2' as decimal(3,2));
cast('1.2' as decimal(3,2))
@ -372,7 +378,9 @@ create table t1(s1 time);
insert into t1 values ('11:11:11');
select cast(s1 as decimal(7,2)) from t1;
cast(s1 as decimal(7,2))
111111.00
99999.99
Warnings:
Error 1264 Out of range value adjusted for column 'cast(s1 as decimal(7,2))' at row 1
drop table t1;
CREATE TABLE t1 (v varchar(10), tt tinytext, t text,
mt mediumtext, lt longtext);
@ -380,7 +388,7 @@ INSERT INTO t1 VALUES ('1.01', '2.02', '3.03', '4.04', '5.05');
SELECT CAST(v AS DECIMAL), CAST(tt AS DECIMAL), CAST(t AS DECIMAL),
CAST(mt AS DECIMAL), CAST(lt AS DECIMAL) from t1;
CAST(v AS DECIMAL) CAST(tt AS DECIMAL) CAST(t AS DECIMAL) CAST(mt AS DECIMAL) CAST(lt AS DECIMAL)
1.01 2.02 3.03 4.04 5.05
1 2 3 4 5
DROP TABLE t1;
select cast(NULL as decimal(6)) as t1;
t1

View file

@ -769,6 +769,100 @@ t1 CREATE TABLE `t1` (
`i` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 MAX_ROWS=4294967295
drop table t1;
create table t1 select * from t2;
ERROR 42S02: Table 'test.t2' doesn't exist
create table t1 select * from t1;
ERROR HY000: You can't specify target table 't1' for update in FROM clause
create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin);
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce'
create table t1 (primary key(a)) select "b" as b;
ERROR 42000: Key column 'a' doesn't exist in table
create table t1 (a int);
create table if not exists t1 select 1 as a, 2 as b;
ERROR 21S01: Column count doesn't match value count at row 1
drop table t1;
create table t1 (primary key (a)) (select 1 as a) union all (select 1 as a);
ERROR 23000: Duplicate entry '1' for key 1
create table t1 (i int);
create table t1 select 1 as i;
ERROR 42S01: Table 't1' already exists
create table if not exists t1 select 1 as i;
Warnings:
Note 1050 Table 't1' already exists
select * from t1;
i
1
create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin);
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce'
select * from t1;
i
1
alter table t1 add primary key (i);
create table if not exists t1 (select 2 as i) union all (select 2 as i);
ERROR 23000: Duplicate entry '2' for key 1
select * from t1;
i
1
2
drop table t1;
create temporary table t1 (j int);
create table if not exists t1 select 1;
Warnings:
Note 1050 Table 't1' already exists
select * from t1;
j
1
drop temporary table t1;
select * from t1;
ERROR 42S02: Table 'test.t1' doesn't exist
drop table t1;
ERROR 42S02: Unknown table 't1'
create table t1 (i int);
insert into t1 values (1), (2);
lock tables t1 read;
create table t2 select * from t1;
ERROR HY000: Table 't2' was not locked with LOCK TABLES
create table if not exists t2 select * from t1;
ERROR HY000: Table 't2' was not locked with LOCK TABLES
unlock tables;
create table t2 (j int);
lock tables t1 read;
create table t2 select * from t1;
ERROR HY000: Table 't2' was not locked with LOCK TABLES
create table if not exists t2 select * from t1;
ERROR HY000: Table 't2' was not locked with LOCK TABLES
unlock tables;
lock table t1 read, t2 read;
create table t2 select * from t1;
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
create table if not exists t2 select * from t1;
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
unlock tables;
lock table t1 read, t2 write;
create table t2 select * from t1;
ERROR 42S01: Table 't2' already exists
create table if not exists t2 select * from t1;
Warnings:
Note 1050 Table 't2' already exists
select * from t1;
i
1
2
unlock tables;
drop table t2;
lock tables t1 read;
create temporary table t2 select * from t1;
create temporary table if not exists t2 select * from t1;
Warnings:
Note 1050 Table 't2' already exists
select * from t2;
i
1
2
1
2
unlock tables;
drop table t1, t2;
create table t1 (upgrade int);
drop table t1;
End of 5.0 tests

View file

@ -467,6 +467,7 @@ CREATE TABLE t4 (a DATE);
INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29');
SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29');
a
1972-02-06
Warnings:
Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1
DROP TABLE t1,t2,t3,t4;

View file

@ -1105,4 +1105,23 @@ ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table '
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_1@localhost;
use test;
CREATE TABLE t1 (f1 int, f2 int);
INSERT INTO t1 VALUES(1,1), (2,2);
CREATE DATABASE db27878;
GRANT UPDATE(f1) ON t1 TO 'mysqltest_1'@'localhost';
GRANT SELECT ON `test`.* TO 'mysqltest_1'@'localhost';
GRANT ALL ON db27878.* TO 'mysqltest_1'@'localhost';
use db27878;
CREATE SQL SECURITY INVOKER VIEW db27878.v1 AS SELECT * FROM test.t1;
use db27878;
UPDATE v1 SET f2 = 4;
ERROR HY000: View 'db27878.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
SELECT * FROM test.t1;
f1 f2
1 1
2 2
DROP DATABASE db27878;
use test;
DROP TABLE t1;
End of 5.0 tests

View file

@ -544,4 +544,56 @@ id c counter
3 b 2
4 a 2
drop table t1;
CREATE TABLE t1(
id int AUTO_INCREMENT PRIMARY KEY,
stat_id int NOT NULL,
acct_id int DEFAULT NULL,
INDEX idx1 (stat_id, acct_id),
INDEX idx2 (acct_id)
) ENGINE=MyISAM;
CREATE TABLE t2(
id int AUTO_INCREMENT PRIMARY KEY,
stat_id int NOT NULL,
acct_id int DEFAULT NULL,
INDEX idx1 (stat_id, acct_id),
INDEX idx2 (acct_id)
) ENGINE=InnoDB;
INSERT INTO t1(stat_id,acct_id) VALUES
(1,759), (2,831), (3,785), (4,854), (1,921),
(1,553), (2,589), (3,743), (2,827), (2,545),
(4,779), (4,783), (1,597), (1,785), (4,832),
(1,741), (1,833), (3,788), (2,973), (1,907);
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
UPDATE t1 SET acct_id=785
WHERE MOD(stat_id,2)=0 AND MOD(id,stat_id)=MOD(acct_id,stat_id);
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
SELECT COUNT(*) FROM t1;
COUNT(*)
40960
SELECT COUNT(*) FROM t1 WHERE acct_id=785;
COUNT(*)
8702
EXPLAIN SELECT COUNT(*) FROM t1 WHERE stat_id IN (1,3) AND acct_id=785;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx1,idx2 idx1 9 NULL 2 Using where; Using index
INSERT INTO t2 SELECT * FROM t1;
OPTIMIZE TABLE t2;
Table Op Msg_type Msg_text
test.t2 optimize status OK
EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx1,idx2 idx1 9 NULL 2 Using where; Using index
DROP TABLE t1,t2;
End of 5.0 tests

View file

@ -346,3 +346,119 @@ f1 f2
12 NULL
drop view v1;
drop table t1,t2;
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS f1;
DROP FUNCTION IF EXISTS f2;
CREATE TABLE t1 (i INT);
CREATE FUNCTION f1() RETURNS INT
BEGIN
INSERT INTO t1 VALUES (1);
RETURN 1;
END |
CREATE FUNCTION f2() RETURNS INT
BEGIN
INSERT DELAYED INTO t1 VALUES (2);
RETURN 1;
END |
SELECT f1();
f1()
1
SELECT f2();
f2()
1
INSERT INTO t1 VALUES (3);
INSERT DELAYED INTO t1 VALUES (4);
INSERT INTO t1 VALUES (f1());
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
INSERT DELAYED INTO t1 VALUES (f1());
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
INSERT INTO t1 VALUES (f2());
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
INSERT DELAYED INTO t1 VALUES (f2());
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
INSERT INTO t1 VALUES (NEW.i);
INSERT INTO t1 VALUES (1);
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
INSERT DELAYED INTO t1 VALUES (1);
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
SELECT * FROM t1;
i
1
2
3
4
DROP FUNCTION f2;
DROP FUNCTION f1;
DROP TABLE t1;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (i INT);
CREATE TABLE t2 (i INT);
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (NEW.i);
CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (NEW.i);
CREATE TRIGGER t1_bd BEFORE DELETE ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (OLD.i);
INSERT INTO t1 VALUES (1);
INSERT DELAYED INTO t1 VALUES (2);
SELECT * FROM t1;
i
1
2
UPDATE t1 SET i = 3 WHERE i = 1;
SELECT * FROM t1;
i
3
2
DELETE FROM t1 WHERE i = 3;
SELECT * FROM t1;
i
2
SELECT * FROM t2;
i
1
2
3
3
DROP TABLE t1, t2;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (i INT);
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
SET @a= NEW.i;
SET @a= 0;
INSERT DELAYED INTO t1 VALUES (1);
SELECT @a;
@a
1
INSERT DELAYED INTO t1 VALUES (2);
SELECT @a;
@a
2
DROP TABLE t1;
CREATE TABLE t1 (i INT);
CREATE TABLE t2 (i INT);
CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
INSERT INTO t2 VALUES (NEW.i);
CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (NEW.i);
CREATE TRIGGER t1_ad AFTER DELETE ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (OLD.i);
INSERT DELAYED INTO t1 VALUES (1);
SELECT * FROM t1;
i
1
UPDATE t1 SET i = 2 WHERE i = 1;
SELECT * FROM t1;
i
2
DELETE FROM t1 WHERE i = 2;
SELECT * FROM t1;
i
SELECT * FROM t2;
i
1
2
2
DROP TABLE t1, t2;
End of 5.0 tests.

View file

@ -336,3 +336,60 @@ id f1
0 test1
DROP TABLE t1;
SET SQL_MODE='';
CREATE TABLE t1 (
id INT AUTO_INCREMENT PRIMARY KEY,
c1 CHAR(1) UNIQUE KEY,
cnt INT DEFAULT 1
);
INSERT INTO t1 (c1) VALUES ('A'), ('B'), ('C');
SELECT * FROM t1;
id c1 cnt
1 A 1
2 B 1
3 C 1
INSERT INTO t1 (c1) VALUES ('A'), ('X'), ('Y'), ('Z')
ON DUPLICATE KEY UPDATE cnt=cnt+1;
SELECT * FROM t1;
id c1 cnt
1 A 2
2 B 1
3 C 1
4 X 1
5 Y 1
6 Z 1
DROP TABLE t1;
CREATE TABLE t1 (
id INT AUTO_INCREMENT PRIMARY KEY,
c1 INT NOT NULL,
cnt INT DEFAULT 1
);
INSERT INTO t1 (id,c1) VALUES (1,10);
SELECT * FROM t1;
id c1 cnt
1 10 1
CREATE TABLE t2 (id INT, c1 INT);
INSERT INTO t2 VALUES (1,NULL), (2,2);
INSERT INTO t1 (id,c1) SELECT 1,NULL
ON DUPLICATE KEY UPDATE c1=NULL;
ERROR 23000: Column 'c1' cannot be null
SELECT * FROM t1;
id c1 cnt
1 10 1
INSERT IGNORE INTO t1 (id,c1) SELECT 1,NULL
ON DUPLICATE KEY UPDATE c1=NULL, cnt=cnt+1;
Warnings:
Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'c1' at row 1
Error 1048 Column 'c1' cannot be null
SELECT * FROM t1;
id c1 cnt
1 0 2
INSERT IGNORE INTO t1 (id,c1) SELECT * FROM t2
ON DUPLICATE KEY UPDATE c1=NULL, cnt=cnt+1;
Warnings:
Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'c1' at row 1
Error 1048 Column 'c1' cannot be null
SELECT * FROM t1;
id c1 cnt
1 0 3
2 2 1
DROP TABLE t1;

View file

@ -391,6 +391,56 @@ i i i
2 NULL 4
2 2 2
drop table t1,t2,t3;
CREATE TABLE t1 (a int, b int default 0, c int default 1);
INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8);
INSERT INTO t1 (a) SELECT a + 8 FROM t1;
INSERT INTO t1 (a) SELECT a + 16 FROM t1;
CREATE TABLE t2 (a int, d int, e int default 0);
INSERT INTO t2 (a, d) VALUES (1,1),(2,2),(3,3),(4,4);
INSERT INTO t2 (a, d) SELECT a+4, a+4 FROM t2;
INSERT INTO t2 (a, d) SELECT a+8, a+8 FROM t2;
EXPLAIN
SELECT STRAIGHT_JOIN t2.e FROM t1,t2 WHERE t2.d=1 AND t1.b=t2.e
ORDER BY t1.b, t1.c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 32 Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 16 Using where
SELECT STRAIGHT_JOIN t2.e FROM t1,t2 WHERE t2.d=1 AND t1.b=t2.e
ORDER BY t1.b, t1.c;
e
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
DROP TABLE t1,t2;
create table t1 (c int, b int);
create table t2 (a int, b int);
create table t3 (b int, c int);

View file

@ -1214,3 +1214,28 @@ SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='Bla';
f1 f2 f3
bla blah sheep
DROP TABLE t1,t2;
CREATE TABLE t1 (id int PRIMARY KEY, a varchar(8));
CREATE TABLE t2 (id int NOT NULL, b int NOT NULL, INDEX idx(id));
INSERT INTO t1 VALUES
(1,'aaaaaaa'), (5,'eeeeeee'), (4,'ddddddd'), (2,'bbbbbbb'), (3,'ccccccc');
INSERT INTO t2 VALUES
(3,10), (2,20), (5,30), (3,20), (5,10), (3,40), (3,30), (2,10), (2,40);
EXPLAIN
SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ref idx idx 4 test.t1.id 2 Using where; Not exists
flush status;
SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL;
id a
1 aaaaaaa
4 ddddddd
show status like 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 5
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 6
DROP TABLE t1,t2;

View file

@ -165,3 +165,22 @@ f2
2
SET @@SQL_MODE=@OLD_SQL_MODE;
drop table t1,t2;
create table t1(f1 int, f2 timestamp not null default current_timestamp);
create table t2(f1 int);
insert into t2 values(1),(2);
Warnings:
Warning 1261 Row 1 doesn't contain data for all columns
Warning 1261 Row 2 doesn't contain data for all columns
select f1 from t1 where f2 <> '0000-00-00 00:00:00' order by f1;
f1
1
2
delete from t1;
Warnings:
Warning 1261 Row 1 doesn't contain data for all columns
Warning 1261 Row 2 doesn't contain data for all columns
select f1 from t1 where f2 <> '0000-00-00 00:00:00' order by f1;
f1
1
2
drop table t1,t2;

View file

@ -667,6 +667,12 @@ counter datavalue
57 newval
58 newval
drop table t1;
create table t1 (a int primary key auto_increment) engine = ndb;
insert into t1() values (),(),(),(),(),(),(),(),(),(),(),();
insert into t1(a) values (20),(28);
insert into t1() values (),(),(),(),(),(),(),(),(),(),(),();
insert into t1() values (21), (22);
drop table t1;
CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb;
select * from t1;
b

View file

@ -649,3 +649,11 @@ pk a
6 NULL
7 4
DROP TABLE t1;
create table t1(a int primary key, b int, unique key(b)) engine=ndb;
insert ignore into t1 values (1,0), (2,0), (2,null), (3,null);
select * from t1 order by a;
a b
1 0
2 NULL
3 NULL
drop table t1;

Binary file not shown.

View file

@ -26,11 +26,11 @@ ERROR HY000: Unknown prepared statement handler (no_such_statement) given to DEA
execute stmt1;
ERROR HY000: Incorrect arguments to EXECUTE
prepare stmt2 from 'prepare nested_stmt from "select 1"';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"select 1"' at line 1
ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt2 from 'execute stmt1';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'stmt1' at line 1
ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt2 from 'deallocate prepare z';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'z' at line 1
ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt3 from 'insert into t1 values (?,?)';
set @arg1=5, @arg2='five';
execute stmt3 using @arg1, @arg2;

View file

@ -391,11 +391,11 @@ drop table t5 ;
deallocate prepare stmt_do ;
deallocate prepare stmt_set ;
prepare stmt1 from ' prepare stmt2 from '' select 1 '' ' ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' select 1 '' at line 1
ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt1 from ' execute stmt2 ' ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'stmt2' at line 1
ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt1 from ' deallocate prepare never_prepared ' ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'never_prepared' at line 1
ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt4 from ' use test ' ;
ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt3 from ' create database mysqltest ';

View file

@ -1315,3 +1315,97 @@ insert into t1(c1) select c1 from v1;
drop table t1, t2, t3;
drop view v1;
set global query_cache_size=0;
create table t1 (a int);
insert into t1 values (1),(2),(3);
set GLOBAL query_cache_type=1;
set GLOBAL query_cache_limit=10000;
set GLOBAL query_cache_min_res_unit=0;
set GLOBAL query_cache_size= 100000;
reset query cache;
set LOCAL default_week_format = 0;
select week('2007-01-04');
week('2007-01-04')
0
select week('2007-01-04') from t1;
week('2007-01-04')
0
0
0
select extract(WEEK FROM '2007-01-04') from t1;
extract(WEEK FROM '2007-01-04')
0
0
0
set LOCAL default_week_format = 2;
select week('2007-01-04');
week('2007-01-04')
53
select week('2007-01-04') from t1;
week('2007-01-04')
53
53
53
select extract(WEEK FROM '2007-01-04') from t1;
extract(WEEK FROM '2007-01-04')
53
53
53
reset query cache;
set LOCAL div_precision_increment=2;
select 1/7;
1/7
0.14
select 1/7 from t1;
1/7
0.14
0.14
0.14
set LOCAL div_precision_increment=4;
select 1/7;
1/7
0.1429
select 1/7 from t1;
1/7
0.1429
0.1429
0.1429
drop table t1;
CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
('Full-text indexes', 'are called collections'),
('Only MyISAM tables','support collections'),
('Function MATCH ... AGAINST()','is used to do a search'),
('Full-text search in MySQL', 'implements vector space model');
set GLOBAL ft_boolean_syntax='+ -><()~*:""&|';
select *, MATCH(a,b) AGAINST("+called +collections" IN BOOLEAN MODE) as x from t1;
a b x
MySQL has now support for full-text search 0
Full-text indexes are called collections 1
Only MyISAM tables support collections 0
Function MATCH ... AGAINST() is used to do a search 0
Full-text search in MySQL implements vector space model 0
set GLOBAL ft_boolean_syntax='- +><()~*:""&|';
select *, MATCH(a,b) AGAINST("+called +collections" IN BOOLEAN MODE) as x from t1;
a b x
MySQL has now support for full-text search 0
Full-text indexes are called collections 0
Only MyISAM tables support collections 0
Function MATCH ... AGAINST() is used to do a search 0
Full-text search in MySQL implements vector space model 0
create function change_global() returns integer
begin
set global ft_boolean_syntax='+ -><()~*:""&|';
return 1;
end|
select *, change_global() from t1;
a b change_global()
MySQL has now support for full-text search 1
Full-text indexes are called collections 1
Only MyISAM tables support collections 1
Function MATCH ... AGAINST() is used to do a search 1
Full-text search in MySQL implements vector space model 1
drop function change_global;
set GLOBAL query_cache_type=default;
set GLOBAL query_cache_limit=default;
set GLOBAL query_cache_min_res_unit=default;
set GLOBAL query_cache_size= default;

View file

@ -620,4 +620,117 @@ SHOW PROCEDURE CODE p1;
Pos Instruction
0 stmt 2 "CREATE INDEX idx ON t1 (c1)"
DROP PROCEDURE p1;
drop table if exists t1;
drop procedure if exists proc_26977_broken;
drop procedure if exists proc_26977_works;
create table t1(a int unique);
create procedure proc_26977_broken(v int)
begin
declare i int default 5;
declare continue handler for sqlexception
begin
select 'caught something';
retry:
while i > 0 do
begin
set i = i - 1;
select 'looping', i;
end;
end while retry;
end;
select 'do something';
insert into t1 values (v);
select 'do something again';
insert into t1 values (v);
end//
create procedure proc_26977_works(v int)
begin
declare i int default 5;
declare continue handler for sqlexception
begin
select 'caught something';
retry:
while i > 0 do
begin
set i = i - 1;
select 'looping', i;
end;
end while retry;
select 'optimizer: keep hreturn';
end;
select 'do something';
insert into t1 values (v);
select 'do something again';
insert into t1 values (v);
end//
show procedure code proc_26977_broken;
Pos Instruction
0 set i@1 5
1 hpush_jump 8 2 CONTINUE
2 stmt 0 "select 'caught something'"
3 jump_if_not 7(7) (i@1 > 0)
4 set i@1 (i@1 - 1)
5 stmt 0 "select 'looping', i"
6 jump 3
7 hreturn 2
8 stmt 0 "select 'do something'"
9 stmt 5 "insert into t1 values (v)"
10 stmt 0 "select 'do something again'"
11 stmt 5 "insert into t1 values (v)"
12 hpop 1
show procedure code proc_26977_works;
Pos Instruction
0 set i@1 5
1 hpush_jump 9 2 CONTINUE
2 stmt 0 "select 'caught something'"
3 jump_if_not 7(7) (i@1 > 0)
4 set i@1 (i@1 - 1)
5 stmt 0 "select 'looping', i"
6 jump 3
7 stmt 0 "select 'optimizer: keep hreturn'"
8 hreturn 2
9 stmt 0 "select 'do something'"
10 stmt 5 "insert into t1 values (v)"
11 stmt 0 "select 'do something again'"
12 stmt 5 "insert into t1 values (v)"
13 hpop 1
call proc_26977_broken(1);
do something
do something
do something again
do something again
caught something
caught something
looping i
looping 4
looping i
looping 3
looping i
looping 2
looping i
looping 1
looping i
looping 0
call proc_26977_works(2);
do something
do something
do something again
do something again
caught something
caught something
looping i
looping 4
looping i
looping 3
looping i
looping 2
looping i
looping 1
looping i
looping 0
optimizer: keep hreturn
optimizer: keep hreturn
drop table t1;
drop procedure proc_26977_broken;
drop procedure proc_26977_works;
End of 5.0 tests.

View file

@ -690,12 +690,12 @@ END|
CALL p1(NOW());
Table Create Table
t1 CREATE TABLE "t1" (
"x" varbinary(19) default NULL
"x" datetime default NULL
)
CALL p1('test');
Table Create Table
t1 CREATE TABLE "t1" (
"x" varbinary(19) default NULL
"x" datetime default NULL
)
Warnings:
Warning 1264 Out of range value adjusted for column 'x' at row 1

View file

@ -6118,6 +6118,13 @@ Warning 1265 Data truncated for column 'bug5274_f1' at row 1
Warning 1265 Data truncated for column 'bug5274_f1' at row 1
DROP FUNCTION bug5274_f1|
DROP FUNCTION bug5274_f2|
drop procedure if exists proc_21513|
create procedure proc_21513()`my_label`:BEGIN END|
show create procedure proc_21513|
Procedure sql_mode Create Procedure
proc_21513 CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_21513`()
`my_label`:BEGIN END
drop procedure proc_21513|
End of 5.0 tests.
drop table t1,t2;
CREATE TABLE t1 (a int auto_increment primary key) engine=MyISAM;

View file

@ -4034,4 +4034,11 @@ SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING XXA < 12) ) FROM t2) )
FROM t1;
ERROR HY000: Invalid use of group function
DROP TABLE t1,t2;
CREATE TABLE t1 (a int, b int, KEY (a));
INSERT INTO t1 VALUES (1,1),(2,1);
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
DROP TABLE t1;
End of 5.0 tests.

View file

@ -711,3 +711,34 @@ a
1
4
DROP TABLE t1,t2;
CREATE TABLE t1 (id int);
CREATE TABLE t2 (id int PRIMARY KEY);
CREATE TABLE t3 (id int PRIMARY KEY, name varchar(10));
INSERT INTO t1 VALUES (2), (NULL), (3), (1);
INSERT INTO t2 VALUES (234), (345), (457);
INSERT INTO t3 VALUES (222,'bbb'), (333,'ccc'), (111,'aaa');
EXPLAIN
SELECT * FROM t1
WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3
WHERE t3.name='xxx' AND t2.id=t3.id);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
2 DEPENDENT SUBQUERY t2 eq_ref PRIMARY PRIMARY 4 func 1 Using where; Using index; Full scan on NULL key
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 func 1 Using where; Full scan on NULL key
SELECT * FROM t1
WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3
WHERE t3.name='xxx' AND t2.id=t3.id);
id
2
NULL
3
1
SELECT (t1.id IN (SELECT t2.id FROM t2,t3
WHERE t3.name='xxx' AND t2.id=t3.id)) AS x
FROM t1;
x
0
0
0
0
DROP TABLE t1,t2,t3;

View file

@ -1414,4 +1414,39 @@ id val
DROP TRIGGER trg27006_a_insert;
DROP TRIGGER trg27006_a_update;
drop table t1,t2;
drop table if exists t1, t2, t3;
create table t1 (i int);
create trigger t1_bi before insert on t1 for each row set new.i = 7;
create trigger t1_ai after insert on t1 for each row set @a := 7;
create table t2 (j int);
insert into t2 values (1), (2);
set @a:="";
create table if not exists t1 select * from t2;
Warnings:
Note 1050 Table 't1' already exists
select * from t1;
i
7
7
select @a;
@a
7
drop trigger t1_bi;
drop trigger t1_ai;
create table t3 (isave int);
create trigger t1_bi before insert on t1 for each row insert into t3 values (new.i);
create table if not exists t1 select * from t2;
Warnings:
Note 1050 Table 't1' already exists
select * from t1;
i
7
7
1
2
select * from t3;
isave
1
2
drop table t1, t2, t3;
End of 5.0 tests

View file

@ -299,3 +299,85 @@ f2
SELECT 1 from dual where NOW() BETWEEN CURRENT_DATE() - INTERVAL 1 DAY AND CURRENT_DATE();
1
drop table t1;
create table t1 (f1 date);
insert into t1 values('01-01-01'),('01-01-02'),('01-01-03');
select * from t1 where f1 in ('01-01-01','2001-01-02','2001-01-03 00:00:00');
f1
2001-01-01
2001-01-02
2001-01-03
create table t2(f2 datetime);
insert into t2 values('01-01-01 00:00:00'),('01-02-03 12:34:56'),('02-04-06 11:22:33');
select * from t2 where f2 in ('01-01-01','01-02-03 12:34:56','01-02-03');
f2
2001-01-01 00:00:00
2001-02-03 12:34:56
select * from t1,t2 where '01-01-02' in (f1, cast(f2 as date));
f1 f2
2001-01-02 2001-01-01 00:00:00
2001-01-02 2001-02-03 12:34:56
2001-01-02 2002-04-06 11:22:33
select * from t1,t2 where '01-01-01' in (f1, '01-02-03');
f1 f2
2001-01-01 2001-01-01 00:00:00
2001-01-01 2001-02-03 12:34:56
2001-01-01 2002-04-06 11:22:33
select * from t1,t2 where if(1,'01-02-03 12:34:56','') in (f1, f2);
f1 f2
2001-01-01 2001-02-03 12:34:56
2001-01-02 2001-02-03 12:34:56
2001-01-03 2001-02-03 12:34:56
create table t3(f3 varchar(20));
insert into t3 select * from t2;
select * from t2,t3 where f2 in (f3,'03-04-05');
f2 f3
2001-01-01 00:00:00 2001-01-01 00:00:00
2001-02-03 12:34:56 2001-02-03 12:34:56
2002-04-06 11:22:33 2002-04-06 11:22:33
select f1,f2,f3 from t1,t2,t3 where (f1,'1') in ((f2,'1'),(f3,'1'));
f1 f2 f3
2001-01-01 2001-01-01 00:00:00 2001-01-01 00:00:00
2001-01-01 2001-02-03 12:34:56 2001-01-01 00:00:00
2001-01-01 2002-04-06 11:22:33 2001-01-01 00:00:00
2001-01-01 2001-01-01 00:00:00 2001-02-03 12:34:56
2001-01-01 2001-01-01 00:00:00 2002-04-06 11:22:33
select f1 from t1 where ('1',f1) in (('1','01-01-01'),('1','2001-1-1 0:0:0'),('1','02-02-02'));
f1
2001-01-01
drop table t1,t2,t3;
select least(cast('01-01-01' as date), '01-01-02');
least(cast('01-01-01' as date), '01-01-02')
2001-01-01
select greatest(cast('01-01-01' as date), '01-01-02');
greatest(cast('01-01-01' as date), '01-01-02')
01-01-02
select least(cast('01-01-01' as date), '01-01-02') + 0;
least(cast('01-01-01' as date), '01-01-02') + 0
20010101
select greatest(cast('01-01-01' as date), '01-01-02') + 0;
greatest(cast('01-01-01' as date), '01-01-02') + 0
20010102
select least(cast('01-01-01' as datetime), '01-01-02') + 0;
least(cast('01-01-01' as datetime), '01-01-02') + 0
20010101000000
select cast(least(cast('01-01-01' as datetime), '01-01-02') as signed);
cast(least(cast('01-01-01' as datetime), '01-01-02') as signed)
20010101000000
select cast(least(cast('01-01-01' as datetime), '01-01-02') as decimal(20,2));
cast(least(cast('01-01-01' as datetime), '01-01-02') as decimal(20,2))
20010101000000.00
DROP PROCEDURE IF EXISTS test27759 ;
CREATE PROCEDURE test27759()
BEGIN
declare v_a date default '2007-4-10';
declare v_b date default '2007-4-11';
declare v_c datetime default '2004-4-9 0:0:0';
select v_a as a,v_b as b,
least( v_a, v_b ) as a_then_b,
least( v_b, v_a ) as b_then_a,
least( v_c, v_a ) as c_then_a;
END;|
call test27759();
a b a_then_b b_then_a c_then_a
2007-04-10 2007-04-11 2007-04-10 2007-04-10 2004-04-09 00:00:00
drop procedure test27759;

View file

@ -1430,4 +1430,39 @@ select * from t1;
a
123456789012345678
drop table t1;
select cast(11.1234 as DECIMAL(3,2));
cast(11.1234 as DECIMAL(3,2))
9.99
Warnings:
Error 1264 Out of range value adjusted for column 'cast(11.1234 as DECIMAL(3,2))' at row 1
select * from (select cast(11.1234 as DECIMAL(3,2))) t;
cast(11.1234 as DECIMAL(3,2))
9.99
Warnings:
Error 1264 Out of range value adjusted for column 'cast(11.1234 as DECIMAL(3,2))' at row 1
select cast(a as DECIMAL(3,2))
from (select 11.1233 as a
UNION select 11.1234
UNION select 12.1234
) t;
cast(a as DECIMAL(3,2))
9.99
9.99
9.99
Warnings:
Error 1264 Out of range value adjusted for column 'cast(a as DECIMAL(3,2))' at row 1
Error 1264 Out of range value adjusted for column 'cast(a as DECIMAL(3,2))' at row 1
Error 1264 Out of range value adjusted for column 'cast(a as DECIMAL(3,2))' at row 1
select cast(a as DECIMAL(3,2)), count(*)
from (select 11.1233 as a
UNION select 11.1234
UNION select 12.1234
) t group by 1;
cast(a as DECIMAL(3,2)) count(*)
9.99 3
Warnings:
Error 1264 Out of range value adjusted for column 'cast(a as DECIMAL(3,2))' at row 1
Error 1264 Out of range value adjusted for column 'cast(a as DECIMAL(3,2))' at row 1
Error 1264 Out of range value adjusted for column 'cast(a as DECIMAL(3,2))' at row 1
Error 1264 Out of range value adjusted for column 'cast(a as DECIMAL(3,2))' at row 1
End of 5.0 tests

View file

@ -1789,7 +1789,7 @@ drop table t1;
create view v1 as select cast(1 as decimal);
select * from v1;
cast(1 as decimal)
1.00
1
drop view v1;
create table t1(f1 int);
create table t2(f2 int);
@ -3354,4 +3354,17 @@ id select_type table type possible_keys key key_len ref rows Extra
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL Using filesort
DROP VIEW v1;
DROP TABLE t1;
CREATE VIEW v1 AS SELECT CAST( 1.23456789 AS DECIMAL( 7,5 ) ) AS col;
SELECT * FROM v1;
col
1.23457
DESCRIBE v1;
Field Type Null Key Default Extra
col decimal(7,5) NO 0.00000
DROP VIEW v1;
CREATE VIEW v1 AS SELECT CAST(1.23456789 AS DECIMAL(8,0)) AS col;
SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(1.23456789 as decimal(8,0)) AS `col`
DROP VIEW v1;
End of 5.0 tests.

View file

@ -44,7 +44,8 @@ if (0)
# ------------------------------------------------------------------------------
# prepare a variable to be able to suppress machine dependant diffs
# this can be used in: --replace_result $SERVER_NAME <SERVER_NAME>
let $SERVER_NAME= `SELECT DISTINCT host FROM mysql.user WHERE host LIKE "%\%" AND host NOT In ("localhost", "127.0.0.1", "%")`;
# let $SERVER_NAME= `SELECT DISTINCT host FROM mysql.user WHERE host LIKE "%\%" AND host NOT In ("localhost", "127.0.0.1", "%")`;
let $SERVER_NAME= `SELECT DISTINCT host FROM mysql.user WHERE host NOT In ("localhost", "127.0.0.1", "%")`;
################################################################################

View file

@ -105,7 +105,7 @@ SELECT DISTINCT u,
AS Server_Clean
FROM db_datadict.vu1;
--replace_result $SERVER_NAME <SERVER_NAME>
SELECT * FROM db_datadict.vu;
SELECT * FROM db_datadict.vu order by u;
delimiter //;
CREATE PROCEDURE db_datadict.sp_1()
@ -141,8 +141,9 @@ if ($have_bug_11589)
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
# 17 CHECK_TIME
# 20 CREATE_OPTIONS
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
SELECT * FROM tables
WHERE table_schema = 'information_schema';
# 9 AVG_ROW_LENGTH
@ -152,7 +153,8 @@ SELECT * FROM tables
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss"
# 17 CHECK_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
SELECT * FROM tables
WHERE NOT( table_schema = 'information_schema');
--horizontal_results
@ -177,7 +179,7 @@ select count(*) from routines;
select * from statistics;
select * from views;
--replace_result $SERVER_NAME <SERVER_NAME>
select * from user_privileges;
select * from user_privileges order by grantee, privilege_type;
select * from schema_privileges;
select * from table_privileges;
select * from column_privileges;
@ -199,7 +201,8 @@ select concat("Table or view '", table_name,
--replace_result $SERVER_NAME <SERVER_NAME>
select grantee as "user's having select privilege",
substring( grantee, length(SUBSTRING_INDEX(grantee,_utf8'@',1))+2 )
from user_privileges where privilege_type = 'select';
from user_privileges where privilege_type = 'select'
order by grantee;
select all table_schema from schema_privileges limit 0,5;
@ -293,13 +296,14 @@ select * from information_schema.schemata ORDER BY 2 DESC;
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
# 17 CHRCK_TIME
# 20 CREATE_OPTIONS
if ($have_bug_11589)
{
--disable_ps_protocol
}
--vertical_results
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
SELECT * FROM information_schema.tables
WHERE table_schema = 'information_schema';
# 9 AVG_ROW_LENGTH
@ -309,7 +313,8 @@ SELECT * FROM information_schema.tables
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss"
# 17 CHRCK_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
SELECT * FROM information_schema.tables
WHERE NOT( table_schema = 'information_schema');
--horizontal_results
@ -385,7 +390,7 @@ select concat(table_schema, ', ', table_name) "Table_info"
from tables ORDER BY 1;
--replace_result $SERVER_NAME <SERVER_NAME>
select distinct grantee from user_privileges;
select distinct grantee from user_privileges order by grantee, privilege_type;
select * from schema_privileges where table_catalog is null limit 0, 5;
select * from table_privileges where grantee like '%r%' limit 0, 5;
@ -399,7 +404,7 @@ select * from schemata limit 0,5;
--replace_result $SERVER_NAME <SERVER_NAME>
select distinct grantee from user_privileges;
--replace_result $SERVER_NAME <SERVER_NAME>
select all grantee from user_privileges;
select all grantee from user_privileges order by grantee, privilege_type;
select id , character_set_name from collations order by id asc limit 10;
@ -455,8 +460,9 @@ eval SELECT *
LINES TERMINATED BY '\n'
FROM information_schema.schemata
WHERE schema_name LIKE 'db_%';
# FIXME: why do we get different error numbers with and without OUTFILE ?
#FIXME this should fail! --error 1146
# The above will fail with access error as long as
# BUBG#28181 - a regression introduced in 5.0.42 is not fixed
eval SELECT *
FROM information_schema.schemata
WHERE schema_name LIKE 'db_%';
@ -469,7 +475,9 @@ eval SELECT *
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM schemata LIMIT 0, 5;
# FIXME 3.2.1.2: why do we get different error numbers with and without OUTFILE ?
# The above will fail with access error as long as
# BUBG#28181 - a regression introduced in 5.0.42 is not fixed
eval SELECT *
FROM schemata LIMIT 0, 5;
@ -479,8 +487,9 @@ eval SELECT *
LINES TERMINATED BY '\n'
FROM information_schema.schemata
WHERE schema_name LIKE 'db_%';
# FIXME: why do we get different error numbers with and without OUTFILE ?
#FIXME this should fail! --error 1146
# The above will fail with access error as long as
# BUBG#28181 - a regression introduced in 5.0.42 is not fixed
eval SELECT *
FROM information_schema.schemata
WHERE schema_name LIKE 'db_%';
@ -3014,12 +3023,13 @@ GRANT SELECT ON db_datadict.v3 to 'user_3'@'localhost';
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
# 17 CHECK_TIME
# 20 CREATE_OPTIONS
if ($have_bug_11589)
{
--disable_ps_protocol
}
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
SELECT * FROM information_schema.tables
WHERE table_schema = 'information_schema';
# 9 AVG_ROW_LENGTH
@ -3029,7 +3039,8 @@ SELECT * FROM information_schema.tables
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss"
# 17 CHECK_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
SELECT * FROM information_schema.tables
WHERE NOT( table_schema = 'information_schema');
--enable_ps_protocol
@ -3049,12 +3060,13 @@ connect (user_12_2, localhost, user_2, , db_datadict);
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
# 17 CHECK_TIME
# 20 CREATE_OPTIONS
if ($have_bug_11589)
{
--disable_ps_protocol
}
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
SELECT * FROM information_schema.tables
WHERE table_schema = 'information_schema';
# 9 AVG_ROW_LENGTH
@ -3064,7 +3076,8 @@ SELECT * FROM information_schema.tables
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss"
# 17 CHECK_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
SELECT * FROM information_schema.tables
WHERE NOT( table_schema = 'information_schema');
--enable_ps_protocol
@ -3085,12 +3098,13 @@ connect (user_12_3, localhost, user_3, , db_datadict);
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
# 17 CHECK_TIME
# 20 CREATE_OPTIONS
if ($have_bug_11589)
{
--disable_ps_protocol
}
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
SELECT * FROM information_schema.tables
WHERE table_schema = 'information_schema';
# 9 AVG_ROW_LENGTH
@ -3100,7 +3114,8 @@ SELECT * FROM information_schema.tables
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss"
# 17 CHECK_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
SELECT * FROM information_schema.tables
WHERE NOT( table_schema = 'information_schema');
--enable_ps_protocol
@ -3121,12 +3136,13 @@ connection default;
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
# 17 CHECK_TIME
# 20 CREATE_OPTIONS
if ($have_bug_11589)
{
--disable_ps_protocol
}
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss" 20 "#CO#"
SELECT * FROM information_schema.tables
WHERE table_schema = 'information_schema';
# 9 AVG_ROW_LENGTH
@ -3136,7 +3152,8 @@ SELECT * FROM information_schema.tables
# 13 DATA_FREE
# 15 CREATE_TIME
# 16 UPDATE_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss"
# 17 CHECK_TIME
--replace_column 9 "#ARL#" 10 "#DL#" 11 "#MDL#" 12 "#IL#" 13 "#DF#" 15 "YYYY-MM-DD hh:mm:ss" 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
SELECT * FROM information_schema.tables
WHERE NOT( table_schema = 'information_schema');
--enable_ps_protocol

View file

@ -36,7 +36,7 @@ eval select table_name, index_schema, index_name, index_type
--replace_result $SERVER_NAME <SERVER_NAME>
eval select *
from information_schema.user_privileges;
from information_schema.user_privileges order by grantee, privilege_type;
# where grantee="'u_6_401013'@'%'";
eval select *

View file

@ -1,11 +0,0 @@
. Just show the version string for which the results in suite
. funcs_1 have been checked.
.
. I know that the .result file of this check needs to
. updated with each new version --- THIS IS INTENDED!
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
funcs_1 checked with version: 5.0.36
Warnings:
Warning 1466 Leading spaces are removed from name ' '

File diff suppressed because it is too large Load diff

View file

@ -3814,13 +3814,11 @@ CAST(my_time AS DATETIME) my_time id
NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2
0000-00-00 00:00:00 838:59:59 3
0000-00-00 00:00:00 13:00:00 4
0000-00-00 00:00:00 10:00:00 5
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 13:00:00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:00:00'
SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as datetime) AS `CAST(my_time AS DATETIME)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values`
@ -3831,13 +3829,11 @@ CAST(my_time AS DATETIME) my_time id
NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2
0000-00-00 00:00:00 838:59:59 3
0000-00-00 00:00:00 13:00:00 4
0000-00-00 00:00:00 10:00:00 5
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 13:00:00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:00:00'
DROP VIEW v1;

View file

@ -484,8 +484,9 @@ BEGIN
WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END//
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @counter1 = @counter1 + 1;
END' at line 4
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END' at line 3
delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7;

View file

@ -448,7 +448,8 @@ SET @x=0;
CREATE or REPLACE VIEW v1 AS Select 1 INTO @x;
ERROR HY000: View's SELECT contains a 'INTO' clause
Select @x;
ERROR HY000: View's SELECT contains a variable or parameter
@x
0
CREATE or REPLACE VIEW v1 AS Select 1
FROM (SELECT 1 FROM t1) my_table;
ERROR HY000: View's SELECT contains a subquery in the FROM clause
@ -585,7 +586,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
CREATE or REPLACE view v1 as Select f59, f60
from tb2 by group f59 ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'by group f59' at line 2
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.5
--------------------------------------------------------------------------------
DROP VIEW IF EXISTS v1 ;
CREATE VIEW v1 SELECT * FROM tb2 limit 100 ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT * FROM tb2 limit 100' at line 1
@ -605,7 +608,9 @@ CREATE VIEW v1 SELECT 1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1' at line 1
CREATE VIEW v1 AS ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.6
--------------------------------------------------------------------------------
DROP VIEW IF EXISTS v1 ;
CREATE or REPLACE VIEW v1
as SELECT * from tb2 limit 100 ;
@ -1790,7 +1795,9 @@ ERROR HY000: View's SELECT contains a subquery in the FROM clause
SELECT * FROM test.v1 ;
ERROR 42S02: Table 'test.v1' doesn't exist
Drop view if exists test.v1 ;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.40
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
Set @var1 = 'ABC' ;
Set @var2 = 'XYZ' ;
@ -1799,7 +1806,9 @@ ERROR HY000: View's SELECT contains a variable or parameter
CREATE VIEW test.v1 AS SELECT @@global.sort_buffer_size;
ERROR HY000: View's SELECT contains a variable or parameter
Drop view if exists test.v1 ;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.41
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
Drop procedure if exists sp1 ;
Create procedure sp1() DETERMINISTIC
@ -1816,7 +1825,9 @@ Warnings:
Note 1051 Unknown table 'test.v1'
Drop procedure sp1 ;
ERROR 42000: PROCEDURE test.sp1 does not exist
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.42
--------------------------------------------------------------------------------
Drop VIEW if exists test.v1 ;
CREATE TEMPORARY VIEW test.v1 AS
SELECT * FROM test.tb2 limit 2 ;
@ -1828,7 +1839,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
SELECT * FROM test.tb2 limit 2' at line 1
Drop view if exists test.v1 ;
Use test;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.43
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
CREATE VIEW test.v1 AS SELECT f59,f60 FROM test.tb2;
INSERT INTO test.v1 values(122,432);

View file

@ -1,2 +0,0 @@
mysqltest: Warning detected in included file ./suite/funcs_1/views/views_master.inc at line 3039: Suspicious command '--eror 1116' detected, was this intentional? Use # instead of -- to avoid this warning
mysqltest: Warning detected in included file ./suite/funcs_1/views/views_master.inc at line 3050: Suspicious command '--eror 1116' detected, was this intentional? Use # instead of -- to avoid this warning

File diff suppressed because it is too large Load diff

View file

@ -3814,13 +3814,11 @@ CAST(my_time AS DATETIME) my_time id
NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2
0000-00-00 00:00:00 838:59:59 3
0000-00-00 00:00:00 13:00:00 4
0000-00-00 00:00:00 10:00:00 5
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 13:00:00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:00:00'
SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as datetime) AS `CAST(my_time AS DATETIME)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values`
@ -3831,13 +3829,11 @@ CAST(my_time AS DATETIME) my_time id
NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2
0000-00-00 00:00:00 838:59:59 3
0000-00-00 00:00:00 13:00:00 4
0000-00-00 00:00:00 10:00:00 5
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 13:00:00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:00:00'
DROP VIEW v1;

View file

@ -480,8 +480,9 @@ BEGIN
WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END//
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @counter1 = @counter1 + 1;
END' at line 4
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END' at line 3
delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7;

View file

@ -452,7 +452,8 @@ SET @x=0;
CREATE or REPLACE VIEW v1 AS Select 1 INTO @x;
ERROR HY000: View's SELECT contains a 'INTO' clause
Select @x;
ERROR HY000: View's SELECT contains a variable or parameter
@x
0
CREATE or REPLACE VIEW v1 AS Select 1
FROM (SELECT 1 FROM t1) my_table;
ERROR HY000: View's SELECT contains a subquery in the FROM clause
@ -589,7 +590,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
CREATE or REPLACE view v1 as Select f59, f60
from tb2 by group f59 ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'by group f59' at line 2
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.5
--------------------------------------------------------------------------------
DROP VIEW IF EXISTS v1 ;
CREATE VIEW v1 SELECT * FROM tb2 limit 100 ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT * FROM tb2 limit 100' at line 1
@ -609,7 +612,9 @@ CREATE VIEW v1 SELECT 1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1' at line 1
CREATE VIEW v1 AS ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.6
--------------------------------------------------------------------------------
DROP VIEW IF EXISTS v1 ;
CREATE or REPLACE VIEW v1
as SELECT * from tb2 limit 100 ;
@ -1794,7 +1799,9 @@ ERROR HY000: View's SELECT contains a subquery in the FROM clause
SELECT * FROM test.v1 ;
ERROR 42S02: Table 'test.v1' doesn't exist
Drop view if exists test.v1 ;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.40
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
Set @var1 = 'ABC' ;
Set @var2 = 'XYZ' ;
@ -1803,7 +1810,9 @@ ERROR HY000: View's SELECT contains a variable or parameter
CREATE VIEW test.v1 AS SELECT @@global.sort_buffer_size;
ERROR HY000: View's SELECT contains a variable or parameter
Drop view if exists test.v1 ;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.41
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
Drop procedure if exists sp1 ;
Create procedure sp1() DETERMINISTIC
@ -1820,7 +1829,9 @@ Warnings:
Note 1051 Unknown table 'test.v1'
Drop procedure sp1 ;
ERROR 42000: PROCEDURE test.sp1 does not exist
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.42
--------------------------------------------------------------------------------
Drop VIEW if exists test.v1 ;
CREATE TEMPORARY VIEW test.v1 AS
SELECT * FROM test.tb2 limit 2 ;
@ -1832,7 +1843,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
SELECT * FROM test.tb2 limit 2' at line 1
Drop view if exists test.v1 ;
Use test;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.43
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
CREATE VIEW test.v1 AS SELECT f59,f60 FROM test.tb2;
INSERT INTO test.v1 values(122,432);

View file

@ -1,2 +0,0 @@
mysqltest: Warning detected in included file ./suite/funcs_1/views/views_master.inc at line 3039: Suspicious command '--eror 1116' detected, was this intentional? Use # instead of -- to avoid this warning
mysqltest: Warning detected in included file ./suite/funcs_1/views/views_master.inc at line 3050: Suspicious command '--eror 1116' detected, was this intentional? Use # instead of -- to avoid this warning

File diff suppressed because it is too large Load diff

View file

@ -3814,13 +3814,11 @@ CAST(my_time AS DATETIME) my_time id
NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2
0000-00-00 00:00:00 838:59:59 3
0000-00-00 00:00:00 13:00:00 4
0000-00-00 00:00:00 10:00:00 5
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 13:00:00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:00:00'
SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as datetime) AS `CAST(my_time AS DATETIME)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values`
@ -3831,13 +3829,11 @@ CAST(my_time AS DATETIME) my_time id
NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2
0000-00-00 00:00:00 838:59:59 3
0000-00-00 00:00:00 13:00:00 4
0000-00-00 00:00:00 10:00:00 5
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 838:59:59'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 13:00:00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:00:00'
DROP VIEW v1;

View file

@ -484,8 +484,9 @@ BEGIN
WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END//
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @counter1 = @counter1 + 1;
END' at line 4
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END' at line 3
delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7;

View file

@ -470,7 +470,8 @@ SET @x=0;
CREATE or REPLACE VIEW v1 AS Select 1 INTO @x;
ERROR HY000: View's SELECT contains a 'INTO' clause
Select @x;
ERROR HY000: View's SELECT contains a variable or parameter
@x
0
CREATE or REPLACE VIEW v1 AS Select 1
FROM (SELECT 1 FROM t1) my_table;
ERROR HY000: View's SELECT contains a subquery in the FROM clause
@ -607,7 +608,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
CREATE or REPLACE view v1 as Select f59, f60
from tb2 by group f59 ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'by group f59' at line 2
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.5
--------------------------------------------------------------------------------
DROP VIEW IF EXISTS v1 ;
CREATE VIEW v1 SELECT * FROM tb2 limit 100 ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT * FROM tb2 limit 100' at line 1
@ -627,7 +630,9 @@ CREATE VIEW v1 SELECT 1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1' at line 1
CREATE VIEW v1 AS ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.6
--------------------------------------------------------------------------------
DROP VIEW IF EXISTS v1 ;
CREATE or REPLACE VIEW v1
as SELECT * from tb2 limit 100 ;
@ -1812,7 +1817,9 @@ ERROR HY000: View's SELECT contains a subquery in the FROM clause
SELECT * FROM test.v1 ;
ERROR 42S02: Table 'test.v1' doesn't exist
Drop view if exists test.v1 ;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.40
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
Set @var1 = 'ABC' ;
Set @var2 = 'XYZ' ;
@ -1821,7 +1828,9 @@ ERROR HY000: View's SELECT contains a variable or parameter
CREATE VIEW test.v1 AS SELECT @@global.sort_buffer_size;
ERROR HY000: View's SELECT contains a variable or parameter
Drop view if exists test.v1 ;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.41
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
Drop procedure if exists sp1 ;
Create procedure sp1() DETERMINISTIC
@ -1838,7 +1847,9 @@ Warnings:
Note 1051 Unknown table 'test.v1'
Drop procedure sp1 ;
ERROR 42000: PROCEDURE test.sp1 does not exist
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.42
--------------------------------------------------------------------------------
Drop VIEW if exists test.v1 ;
CREATE TEMPORARY VIEW test.v1 AS
SELECT * FROM test.tb2 limit 2 ;
@ -1850,7 +1861,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
SELECT * FROM test.tb2 limit 2' at line 1
Drop view if exists test.v1 ;
Use test;
ERROR HY000: View's SELECT contains a variable or parameter
Testcase 3.3.1.43
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
CREATE VIEW test.v1 AS SELECT f59,f60 FROM test.tb2;
INSERT INTO test.v1 values(122,432);

View file

@ -1,2 +0,0 @@
mysqltest: Warning detected in included file ./suite/funcs_1/views/views_master.inc at line 3039: Suspicious command '--eror 1116' detected, was this intentional? Use # instead of -- to avoid this warning
mysqltest: Warning detected in included file ./suite/funcs_1/views/views_master.inc at line 3050: Suspicious command '--eror 1116' detected, was this intentional? Use # instead of -- to avoid this warning

View file

@ -1,29 +0,0 @@
#### suite/funcs_1/t/a_version_check.test
#
# just a simple check of the version to be sure the correct server version is
# checked against the funcs_1 tests.
# just show machine and version to be sure we are testing the correct files
#
let $message= . Just show the version string for which the results in suite
. funcs_1 have been checked.
.
. I know that the .result file of this check needs to
. updated with each new version --- THIS IS INTENDED!;
--source include/show_msg.inc
--disable_query_log
SELECT CONCAT('funcs_1 checked with version: ', SUBSTR(version(), 1, 6 ) ) AS " ";
#SELECT CONCAT('aa = ', 'bb');
#SELECT CONCAT('aa = ', 'bb') AS " ";
if (0)
{
# these more detailed results create differences between the OS.
# mioght be used later when we enable OS dependent .result files
--vertical_results
SELECT @@version_compile_os AS 'vers_comp_os', current_date;
SHOW VARIABLES LIKE 'vers%';
--horizontal_results
}

View file

@ -10,6 +10,6 @@
#
##############################################################################
innodb_storedproc: switched off (too much changed output from WL#2984, needs to be checked)
memory_storedproc: switched off (too much changed output from WL#2984, needs to be checked)
myisam_storedproc: switched off (too much changed output from WL#2984, needs to be checked)
innodb_storedproc: (changes of WL#2984, using storeproc_nn instead)
memory_storedproc: (changes of WL#2984, using storeproc_nn instead)
myisam_storedproc: (changes of WL#2984, using storeproc_nn instead)

View file

@ -3036,7 +3036,9 @@ let $sublevel= `SELECT @max_level`;
eval CREATE VIEW test1.v$level AS SELECT f1, f2
FROM test3.t1 tab1 NATURAL JOIN test1.v$sublevel tab2;
eval SHOW CREATE VIEW test1.v$level;
--eror 1116
# the following line as written as '--eror 1116' and the command
# is successful so assuming no expected error was intended
# --error 1116
eval SELECT CAST(f1 AS SIGNED INTEGER) AS f1,
CAST(f2 AS CHAR) AS f2 FROM test1.v$level;
let $message= The output of following EXPLAIN is deactivated, because the result
@ -3047,7 +3049,9 @@ if (1)
{
--disable_result_log
}
--eror 1116
# the following line as written as '--eror 1116' and the command
# is successful so assuming no expected error was intended
# --error 1116
eval EXPLAIN SELECT CAST(f1 AS SIGNED INTEGER) AS f1,
CAST(f2 AS CHAR) AS f2 FROM test1.v$level;
if (1)

View file

@ -182,6 +182,12 @@ DROP TABLE t1;
select isnull(date(NULL)), isnull(cast(NULL as DATE));
#
# Bug#23656: Wrong result of CAST from DATE to int
#
SELECT CAST(cast('01-01-01' as date) AS UNSIGNED);
SELECT CAST(cast('01-01-01' as date) AS SIGNED);
--echo End of 4.1 tests

View file

@ -669,6 +669,117 @@ alter table t1 max_rows=100000000000;
show create table t1;
drop table t1;
#
# Tests for errors happening at various stages of CREATE TABLES ... SELECT
#
# (Also checks that it behaves atomically in the sense that in case
# of error it is automatically dropped if it has not existed before.)
#
# Error during open_and_lock_tables() of tables
--error ER_NO_SUCH_TABLE
create table t1 select * from t2;
# Rather special error which also caught during open tables pahse
--error ER_UPDATE_TABLE_USED
create table t1 select * from t1;
# Error which happens before select_create::prepare()
--error ER_CANT_AGGREGATE_2COLLATIONS
create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin);
# Error during table creation
--error ER_KEY_COLUMN_DOES_NOT_EXITS
create table t1 (primary key(a)) select "b" as b;
# Error in select_create::prepare() which is not related to table creation
create table t1 (a int);
--error ER_WRONG_VALUE_COUNT_ON_ROW
create table if not exists t1 select 1 as a, 2 as b;
drop table t1;
# Finally error which happens during insert
--error ER_DUP_ENTRY
create table t1 (primary key (a)) (select 1 as a) union all (select 1 as a);
# What happens if table already exists ?
create table t1 (i int);
--error ER_TABLE_EXISTS_ERROR
create table t1 select 1 as i;
create table if not exists t1 select 1 as i;
select * from t1;
# Error before select_create::prepare()
--error ER_CANT_AGGREGATE_2COLLATIONS
create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin);
select * from t1;
# Error which happens during insertion of rows
alter table t1 add primary key (i);
--error ER_DUP_ENTRY
create table if not exists t1 (select 2 as i) union all (select 2 as i);
select * from t1;
drop table t1;
# Base vs temporary tables dillema (a.k.a. bug#24508 "Inconsistent
# results of CREATE TABLE ... SELECT when temporary table exists").
# In this situation we either have to create non-temporary table and
# insert data in it or insert data in temporary table without creation
# of permanent table. Since currently temporary tables always shadow
# permanent tables we adopt second approach.
create temporary table t1 (j int);
create table if not exists t1 select 1;
select * from t1;
drop temporary table t1;
--error ER_NO_SUCH_TABLE
select * from t1;
--error ER_BAD_TABLE_ERROR
drop table t1;
#
# CREATE TABLE ... SELECT and LOCK TABLES
#
# There is little sense in using CREATE TABLE ... SELECT under
# LOCK TABLES as it mostly does not work. At least we check that
# the server doesn't crash, hang and produces sensible errors.
# Includes test for bug #20662 "Infinite loop in CREATE TABLE
# IF NOT EXISTS ... SELECT with locked tables".
create table t1 (i int);
insert into t1 values (1), (2);
lock tables t1 read;
--error ER_TABLE_NOT_LOCKED
create table t2 select * from t1;
--error ER_TABLE_NOT_LOCKED
create table if not exists t2 select * from t1;
unlock tables;
create table t2 (j int);
lock tables t1 read;
--error ER_TABLE_NOT_LOCKED
create table t2 select * from t1;
# This should not be ever allowed as it will undermine
# lock-all-at-once approach
--error ER_TABLE_NOT_LOCKED
create table if not exists t2 select * from t1;
unlock tables;
lock table t1 read, t2 read;
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
create table t2 select * from t1;
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
create table if not exists t2 select * from t1;
unlock tables;
lock table t1 read, t2 write;
--error ER_TABLE_EXISTS_ERROR
create table t2 select * from t1;
# This is the only case which really works.
create table if not exists t2 select * from t1;
select * from t1;
unlock tables;
drop table t2;
# OTOH CREATE TEMPORARY TABLE ... SELECT should work
# well under LOCK TABLES.
lock tables t1 read;
create temporary table t2 select * from t1;
create temporary table if not exists t2 select * from t1;
select * from t2;
unlock tables;
drop table t1, t2;
#
# Bug#21772: can not name a column 'upgrade' when create a table
#

View file

@ -12,3 +12,5 @@
ndb_load : Bug#17233
user_limits : Bug#23921 random failure of user_limits.test
im_life_cycle : Bug#27851: Instance manager test im_life_cycle fails randomly
im_daemon_life_cycle : Bug#20294: Instance manager tests fail randomly

View file

@ -413,6 +413,7 @@ connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
connection user1;
-- error 1142
alter table t1 rename t2;
disconnect user1;
connection root;
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
delete from mysql.user where user=_binary'mysqltest_1';
@ -1122,5 +1123,29 @@ DROP DATABASE mysqltest2;
DROP USER mysqltest_1@localhost;
#
# Bug#27878: Unchecked privileges on a view referring to a table from another
# database.
#
use test;
CREATE TABLE t1 (f1 int, f2 int);
INSERT INTO t1 VALUES(1,1), (2,2);
CREATE DATABASE db27878;
GRANT UPDATE(f1) ON t1 TO 'mysqltest_1'@'localhost';
GRANT SELECT ON `test`.* TO 'mysqltest_1'@'localhost';
GRANT ALL ON db27878.* TO 'mysqltest_1'@'localhost';
use db27878;
CREATE SQL SECURITY INVOKER VIEW db27878.v1 AS SELECT * FROM test.t1;
connect (user1,localhost,mysqltest_1,,test);
connection user1;
use db27878;
--error 1356
UPDATE v1 SET f2 = 4;
SELECT * FROM test.t1;
disconnect user1;
connection default;
DROP DATABASE db27878;
use test;
DROP TABLE t1;
--echo End of 5.0 tests

View file

@ -518,4 +518,58 @@ select * from t1;
drop table t1;
#
# Bug #28189: optimizer erroniously prefers ref access to range access
# for an InnoDB table
#
CREATE TABLE t1(
id int AUTO_INCREMENT PRIMARY KEY,
stat_id int NOT NULL,
acct_id int DEFAULT NULL,
INDEX idx1 (stat_id, acct_id),
INDEX idx2 (acct_id)
) ENGINE=MyISAM;
CREATE TABLE t2(
id int AUTO_INCREMENT PRIMARY KEY,
stat_id int NOT NULL,
acct_id int DEFAULT NULL,
INDEX idx1 (stat_id, acct_id),
INDEX idx2 (acct_id)
) ENGINE=InnoDB;
INSERT INTO t1(stat_id,acct_id) VALUES
(1,759), (2,831), (3,785), (4,854), (1,921),
(1,553), (2,589), (3,743), (2,827), (2,545),
(4,779), (4,783), (1,597), (1,785), (4,832),
(1,741), (1,833), (3,788), (2,973), (1,907);
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
UPDATE t1 SET acct_id=785
WHERE MOD(stat_id,2)=0 AND MOD(id,stat_id)=MOD(acct_id,stat_id);
OPTIMIZE TABLE t1;
SELECT COUNT(*) FROM t1;
SELECT COUNT(*) FROM t1 WHERE acct_id=785;
EXPLAIN SELECT COUNT(*) FROM t1 WHERE stat_id IN (1,3) AND acct_id=785;
INSERT INTO t2 SELECT * FROM t1;
OPTIMIZE TABLE t2;
EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785;
DROP TABLE t1,t2;
--echo End of 5.0 tests

View file

@ -216,3 +216,142 @@ select * from t1;
drop view v1;
drop table t1,t2;
#
# BUG#21483: Server abort or deadlock on INSERT DELAYED with another
# implicit insert
#
# The solution is to downgrade INSERT DELAYED to normal INSERT if the
# statement uses functions and access tables or triggers, or is called
# from a function or a trigger.
#
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS f1;
DROP FUNCTION IF EXISTS f2;
--enable_warnings
CREATE TABLE t1 (i INT);
delimiter |;
CREATE FUNCTION f1() RETURNS INT
BEGIN
INSERT INTO t1 VALUES (1);
RETURN 1;
END |
CREATE FUNCTION f2() RETURNS INT
BEGIN
INSERT DELAYED INTO t1 VALUES (2);
RETURN 1;
END |
delimiter ;|
SELECT f1();
SELECT f2();
INSERT INTO t1 VALUES (3);
INSERT DELAYED INTO t1 VALUES (4);
--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
INSERT INTO t1 VALUES (f1());
--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
INSERT DELAYED INTO t1 VALUES (f1());
--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
INSERT INTO t1 VALUES (f2());
--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
INSERT DELAYED INTO t1 VALUES (f2());
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
INSERT INTO t1 VALUES (NEW.i);
--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
INSERT INTO t1 VALUES (1);
--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
INSERT DELAYED INTO t1 VALUES (1);
SELECT * FROM t1;
DROP FUNCTION f2;
DROP FUNCTION f1;
DROP TABLE t1;
#
# BUG#20497: Trigger with INSERT DELAYED causes Error 1165
#
# Fixed by the patch for Bug#21483
#
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
CREATE TABLE t1 (i INT);
CREATE TABLE t2 (i INT);
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (NEW.i);
CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (NEW.i);
CREATE TRIGGER t1_bd BEFORE DELETE ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (OLD.i);
INSERT INTO t1 VALUES (1);
INSERT DELAYED INTO t1 VALUES (2);
SELECT * FROM t1;
UPDATE t1 SET i = 3 WHERE i = 1;
SELECT * FROM t1;
DELETE FROM t1 WHERE i = 3;
SELECT * FROM t1;
SELECT * FROM t2;
DROP TABLE t1, t2;
#
# BUG#21714: Wrong NEW.value and server abort on INSERT DELAYED to a
# table with a trigger
#
# Fixed by the patch for Bug#21483
#
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
CREATE TABLE t1 (i INT);
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
SET @a= NEW.i;
SET @a= 0;
INSERT DELAYED INTO t1 VALUES (1);
SELECT @a;
INSERT DELAYED INTO t1 VALUES (2);
SELECT @a;
DROP TABLE t1;
CREATE TABLE t1 (i INT);
CREATE TABLE t2 (i INT);
CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
INSERT INTO t2 VALUES (NEW.i);
CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (NEW.i);
CREATE TRIGGER t1_ad AFTER DELETE ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (OLD.i);
INSERT DELAYED INTO t1 VALUES (1);
SELECT * FROM t1;
UPDATE t1 SET i = 2 WHERE i = 1;
SELECT * FROM t1;
DELETE FROM t1 WHERE i = 2;
SELECT * FROM t1;
SELECT * FROM t2;
DROP TABLE t1, t2;
--echo End of 5.0 tests.

View file

@ -247,3 +247,46 @@ REPLACE INTO t1 VALUES (0,"test1",null);
SELECT id, f1 FROM t1;
DROP TABLE t1;
SET SQL_MODE='';
#
# Bug#27954: multi-row INSERT ... ON DUPLICATE with duplicated
# row at the first place into table with AUTO_INCREMENT and
# additional UNIQUE key.
#
CREATE TABLE t1 (
id INT AUTO_INCREMENT PRIMARY KEY,
c1 CHAR(1) UNIQUE KEY,
cnt INT DEFAULT 1
);
INSERT INTO t1 (c1) VALUES ('A'), ('B'), ('C');
SELECT * FROM t1;
INSERT INTO t1 (c1) VALUES ('A'), ('X'), ('Y'), ('Z')
ON DUPLICATE KEY UPDATE cnt=cnt+1;
SELECT * FROM t1;
DROP TABLE t1;
#
# Bug#28000: INSERT IGNORE ... SELECT ... ON DUPLICATE
# with erroneous UPDATE: NOT NULL field with NULL value.
#
CREATE TABLE t1 (
id INT AUTO_INCREMENT PRIMARY KEY,
c1 INT NOT NULL,
cnt INT DEFAULT 1
);
INSERT INTO t1 (id,c1) VALUES (1,10);
SELECT * FROM t1;
CREATE TABLE t2 (id INT, c1 INT);
INSERT INTO t2 VALUES (1,NULL), (2,2);
--error 1048
INSERT INTO t1 (id,c1) SELECT 1,NULL
ON DUPLICATE KEY UPDATE c1=NULL;
SELECT * FROM t1;
INSERT IGNORE INTO t1 (id,c1) SELECT 1,NULL
ON DUPLICATE KEY UPDATE c1=NULL, cnt=cnt+1;
SELECT * FROM t1;
INSERT IGNORE INTO t1 (id,c1) SELECT * FROM t2
ON DUPLICATE KEY UPDATE c1=NULL, cnt=cnt+1;
SELECT * FROM t1;
DROP TABLE t1;

View file

@ -333,6 +333,30 @@ select t1.i,t2.i,t3.i from t2 natural right join t3,t1 order by t1.i,t2.i,t3.i;
select t1.i,t2.i,t3.i from t2 right join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i,t3.i;
drop table t1,t2,t3;
#
# Bug #27531: Query performance degredation in 4.1.22 and greater
#
CREATE TABLE t1 (a int, b int default 0, c int default 1);
INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8);
INSERT INTO t1 (a) SELECT a + 8 FROM t1;
INSERT INTO t1 (a) SELECT a + 16 FROM t1;
CREATE TABLE t2 (a int, d int, e int default 0);
INSERT INTO t2 (a, d) VALUES (1,1),(2,2),(3,3),(4,4);
INSERT INTO t2 (a, d) SELECT a+4, a+4 FROM t2;
INSERT INTO t2 (a, d) SELECT a+8, a+8 FROM t2;
# should use join cache
EXPLAIN
SELECT STRAIGHT_JOIN t2.e FROM t1,t2 WHERE t2.d=1 AND t1.b=t2.e
ORDER BY t1.b, t1.c;
SELECT STRAIGHT_JOIN t2.e FROM t1,t2 WHERE t2.d=1 AND t1.b=t2.e
ORDER BY t1.b, t1.c;
DROP TABLE t1,t2;
# End of 4.1 tests
#

View file

@ -825,3 +825,23 @@ SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='bla';
SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='Bla';
DROP TABLE t1,t2;
#
# Bug 28188: 'not exists' optimization for outer joins
#
CREATE TABLE t1 (id int PRIMARY KEY, a varchar(8));
CREATE TABLE t2 (id int NOT NULL, b int NOT NULL, INDEX idx(id));
INSERT INTO t1 VALUES
(1,'aaaaaaa'), (5,'eeeeeee'), (4,'ddddddd'), (2,'bbbbbbb'), (3,'ccccccc');
INSERT INTO t2 VALUES
(3,10), (2,20), (5,30), (3,20), (5,10), (3,40), (3,30), (2,10), (2,40);
EXPLAIN
SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL;
flush status;
SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL;
show status like 'Handler_read%';
DROP TABLE t1,t2;

View file

@ -152,4 +152,30 @@ select * from t2;
--exec rm $MYSQLTEST_VARDIR/tmp/t1
SET @@SQL_MODE=@OLD_SQL_MODE;
drop table t1,t2;
#
# Bug#27670: LOAD DATA does not set CURRENT_TIMESTAMP default value for a
# TIMESTAMP field when no value has been provided.
#
create table t1(f1 int, f2 timestamp not null default current_timestamp);
create table t2(f1 int);
insert into t2 values(1),(2);
disable_query_log;
eval select * into outfile '$MYSQLTEST_VARDIR/tmp/t2' from t2;
eval load data infile '$MYSQLTEST_VARDIR/tmp/t2' into table t1;
enable_query_log;
select f1 from t1 where f2 <> '0000-00-00 00:00:00' order by f1;
--exec rm $MYSQLTEST_VARDIR/tmp/t2
delete from t1;
disable_query_log;
eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t2'
FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n'
FROM t2;
eval load data infile '$MYSQLTEST_VARDIR/tmp/t2' into table t1
FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n';
enable_query_log;
select f1 from t1 where f2 <> '0000-00-00 00:00:00' order by f1;
--exec rm $MYSQLTEST_VARDIR/tmp/t2
drop table t1,t2;
# End of 5.0 tests

View file

@ -606,6 +606,21 @@ select * from t1 order by counter;
drop table t1;
#
# bug#27437
connection con1;
create table t1 (a int primary key auto_increment) engine = ndb;
insert into t1() values (),(),(),(),(),(),(),(),(),(),(),();
connection con2;
insert into t1(a) values (20),(28);
connection con1;
insert into t1() values (),(),(),(),(),(),(),(),(),(),(),();
connection con2;
insert into t1() values (21), (22);
connection con1;
drop table t1;
#
# BUG#14514 Creating table with packed key fails silently
#

View file

@ -630,4 +630,13 @@ INSERT IGNORE INTO t1 VALUES (4,NULL),(5,NULL),(6,NULL),(7,4);
SELECT * FROM t1 ORDER BY pk;
DROP TABLE t1;
#
# Bug #27980 INSERT IGNORE wrongly ignores NULLs in unique index
#
create table t1(a int primary key, b int, unique key(b)) engine=ndb;
insert ignore into t1 values (1,0), (2,0), (2,null), (3,null);
select * from t1 order by a;
drop table t1;
# End of 4.1 tests

View file

@ -96,3 +96,38 @@ create table t1(a int);
eval select * into outfile "$MYSQL_TEST_DIR/outfile-test1" from t1;
drop table t1;
#
# Bug#28181 Access denied to 'information_schema when
# select into out file (regression)
#
create database mysqltest;
create user user_1@localhost;
grant all on mysqltest.* to user_1@localhost;
connect (con28181_1,localhost,user_1,,mysqltest);
--error 1044
eval select schema_name
into outfile "../tmp/outfile-test.4"
fields terminated by ',' optionally enclosed by '"'
lines terminated by '\n'
from information_schema.schemata
where schema_name like 'mysqltest';
connection default;
grant file on *.* to user_1@localhost;
connect (con28181_2,localhost,user_1,,mysqltest);
eval select schema_name
into outfile "../tmp/outfile-test.4"
fields terminated by ',' optionally enclosed by '"'
lines terminated by '\n'
from information_schema.schemata
where schema_name like 'mysqltest';
connection default;
--exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.4
use test;
revoke all privileges on *.* from user_1@localhost;
drop user user_1@localhost;
drop database mysqltest;

View file

@ -33,13 +33,13 @@ deallocate prepare no_such_statement;
execute stmt1;
# Nesting ps commands is not allowed:
--error 1064
--error ER_UNSUPPORTED_PS
prepare stmt2 from 'prepare nested_stmt from "select 1"';
--error 1064
--error ER_UNSUPPORTED_PS
prepare stmt2 from 'execute stmt1';
--error 1064
--error ER_UNSUPPORTED_PS
prepare stmt2 from 'deallocate prepare z';
# PS insert

View file

@ -416,11 +416,11 @@ deallocate prepare stmt_do ;
deallocate prepare stmt_set ;
## nonsense like prepare of prepare,execute or deallocate
--error 1064
--error ER_UNSUPPORTED_PS
prepare stmt1 from ' prepare stmt2 from '' select 1 '' ' ;
--error 1064
--error ER_UNSUPPORTED_PS
prepare stmt1 from ' execute stmt2 ' ;
--error 1064
--error ER_UNSUPPORTED_PS
prepare stmt1 from ' deallocate prepare never_prepared ' ;
## switch the database connection

View file

@ -899,3 +899,75 @@ insert into t1(c1) select c1 from v1;
drop table t1, t2, t3;
drop view v1;
set global query_cache_size=0;
#
# Query cache and changes to system variables
#
create table t1 (a int);
insert into t1 values (1),(2),(3);
set GLOBAL query_cache_type=1;
set GLOBAL query_cache_limit=10000;
set GLOBAL query_cache_min_res_unit=0;
set GLOBAL query_cache_size= 100000;
# default_week_format
reset query cache;
set LOCAL default_week_format = 0;
select week('2007-01-04');
select week('2007-01-04') from t1;
select extract(WEEK FROM '2007-01-04') from t1;
set LOCAL default_week_format = 2;
select week('2007-01-04');
select week('2007-01-04') from t1;
select extract(WEEK FROM '2007-01-04') from t1;
# div_precision_increment
reset query cache;
set LOCAL div_precision_increment=2;
select 1/7;
select 1/7 from t1;
set LOCAL div_precision_increment=4;
select 1/7;
select 1/7 from t1;
drop table t1;
CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
('Full-text indexes', 'are called collections'),
('Only MyISAM tables','support collections'),
('Function MATCH ... AGAINST()','is used to do a search'),
('Full-text search in MySQL', 'implements vector space model');
set GLOBAL ft_boolean_syntax='+ -><()~*:""&|';
select *, MATCH(a,b) AGAINST("+called +collections" IN BOOLEAN MODE) as x from t1;
# swap +/-
set GLOBAL ft_boolean_syntax='- +><()~*:""&|';
select *, MATCH(a,b) AGAINST("+called +collections" IN BOOLEAN MODE) as x from t1;
# If in the future we need to cache queries with functions
# be sure not to cause dead lock if the query cache is flushed
# while inserting a query in the query cache.
delimiter |;
create function change_global() returns integer
begin
set global ft_boolean_syntax='+ -><()~*:""&|';
return 1;
end|
delimiter ;|
select *, change_global() from t1;
drop function change_global;
set GLOBAL query_cache_type=default;
set GLOBAL query_cache_limit=default;
set GLOBAL query_cache_min_res_unit=default;
set GLOBAL query_cache_size= default;
# End of 5.0 tests

View file

@ -446,4 +446,79 @@ SHOW PROCEDURE CODE p1;
DROP PROCEDURE p1;
#
# Bug#26977 exception handlers never hreturn
#
--disable_warnings
drop table if exists t1;
drop procedure if exists proc_26977_broken;
drop procedure if exists proc_26977_works;
--enable_warnings
create table t1(a int unique);
delimiter //;
create procedure proc_26977_broken(v int)
begin
declare i int default 5;
declare continue handler for sqlexception
begin
select 'caught something';
retry:
while i > 0 do
begin
set i = i - 1;
select 'looping', i;
end;
end while retry;
end;
select 'do something';
insert into t1 values (v);
select 'do something again';
insert into t1 values (v);
end//
create procedure proc_26977_works(v int)
begin
declare i int default 5;
declare continue handler for sqlexception
begin
select 'caught something';
retry:
while i > 0 do
begin
set i = i - 1;
select 'looping', i;
end;
end while retry;
select 'optimizer: keep hreturn';
end;
select 'do something';
insert into t1 values (v);
select 'do something again';
insert into t1 values (v);
end//
delimiter ;//
show procedure code proc_26977_broken;
show procedure code proc_26977_works;
## This caust an error because of jump short cut
## optimization.
call proc_26977_broken(1);
## This works
call proc_26977_works(2);
drop table t1;
drop procedure proc_26977_broken;
drop procedure proc_26977_works;
--echo End of 5.0 tests.

View file

@ -7054,6 +7054,17 @@ SELECT bug5274_f2()|
DROP FUNCTION bug5274_f1|
DROP FUNCTION bug5274_f2|
#
# Bug#21513 (SP having body starting with quoted label rendered unusable)
#
--disable_warnings
drop procedure if exists proc_21513|
--enable_warnings
create procedure proc_21513()`my_label`:BEGIN END|
show create procedure proc_21513|
drop procedure proc_21513|
###
--echo End of 5.0 tests.

View file

@ -2874,4 +2874,12 @@ FROM t1;
DROP TABLE t1,t2;
#
# Bug #27807: Server crash when executing subquery with EXPLAIN
#
CREATE TABLE t1 (a int, b int, KEY (a));
INSERT INTO t1 VALUES (1,1),(2,1);
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
DROP TABLE t1;
--echo End of 5.0 tests.

View file

@ -546,3 +546,28 @@ SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1));
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4));
DROP TABLE t1,t2;
#
# Bug #28375: crash for NOT IN subquery predicate when left operand becomes NULL
#
CREATE TABLE t1 (id int);
CREATE TABLE t2 (id int PRIMARY KEY);
CREATE TABLE t3 (id int PRIMARY KEY, name varchar(10));
INSERT INTO t1 VALUES (2), (NULL), (3), (1);
INSERT INTO t2 VALUES (234), (345), (457);
INSERT INTO t3 VALUES (222,'bbb'), (333,'ccc'), (111,'aaa');
EXPLAIN
SELECT * FROM t1
WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3
WHERE t3.name='xxx' AND t2.id=t3.id);
SELECT * FROM t1
WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3
WHERE t3.name='xxx' AND t2.id=t3.id);
SELECT (t1.id IN (SELECT t2.id FROM t2,t3
WHERE t3.name='xxx' AND t2.id=t3.id)) AS x
FROM t1;
DROP TABLE t1,t2,t3;

View file

@ -1737,4 +1737,30 @@ DROP TRIGGER trg27006_a_insert;
DROP TRIGGER trg27006_a_update;
drop table t1,t2;
#
# Bug #20903 "Crash when using CREATE TABLE .. SELECT and triggers"
#
--disable_warnings
drop table if exists t1, t2, t3;
--enable_warnings
create table t1 (i int);
create trigger t1_bi before insert on t1 for each row set new.i = 7;
create trigger t1_ai after insert on t1 for each row set @a := 7;
create table t2 (j int);
insert into t2 values (1), (2);
set @a:="";
create table if not exists t1 select * from t2;
select * from t1;
select @a;
# Let us check that trigger that involves table also works ok.
drop trigger t1_bi;
drop trigger t1_ai;
create table t3 (isave int);
create trigger t1_bi before insert on t1 for each row insert into t3 values (new.i);
create table if not exists t1 select * from t2;
select * from t1;
select * from t3;
drop table t1, t2, t3;
--echo End of 5.0 tests

View file

@ -203,3 +203,50 @@ select f2, f3 from t1 where '01-03-10' between f2 and f3;
select f2 from t1 where DATE(f2) between "2001-4-15" AND "01-4-15";
SELECT 1 from dual where NOW() BETWEEN CURRENT_DATE() - INTERVAL 1 DAY AND CURRENT_DATE();
drop table t1;
#
# Bug#28133: Wrong DATE/DATETIME comparison in IN() function.
#
create table t1 (f1 date);
insert into t1 values('01-01-01'),('01-01-02'),('01-01-03');
select * from t1 where f1 in ('01-01-01','2001-01-02','2001-01-03 00:00:00');
create table t2(f2 datetime);
insert into t2 values('01-01-01 00:00:00'),('01-02-03 12:34:56'),('02-04-06 11:22:33');
select * from t2 where f2 in ('01-01-01','01-02-03 12:34:56','01-02-03');
select * from t1,t2 where '01-01-02' in (f1, cast(f2 as date));
select * from t1,t2 where '01-01-01' in (f1, '01-02-03');
select * from t1,t2 where if(1,'01-02-03 12:34:56','') in (f1, f2);
create table t3(f3 varchar(20));
insert into t3 select * from t2;
select * from t2,t3 where f2 in (f3,'03-04-05');
select f1,f2,f3 from t1,t2,t3 where (f1,'1') in ((f2,'1'),(f3,'1'));
select f1 from t1 where ('1',f1) in (('1','01-01-01'),('1','2001-1-1 0:0:0'),('1','02-02-02'));
drop table t1,t2,t3;
#
# Bug#27759: Wrong DATE/DATETIME comparison in LEAST()/GREATEST() functions.
#
select least(cast('01-01-01' as date), '01-01-02');
select greatest(cast('01-01-01' as date), '01-01-02');
select least(cast('01-01-01' as date), '01-01-02') + 0;
select greatest(cast('01-01-01' as date), '01-01-02') + 0;
select least(cast('01-01-01' as datetime), '01-01-02') + 0;
select cast(least(cast('01-01-01' as datetime), '01-01-02') as signed);
select cast(least(cast('01-01-01' as datetime), '01-01-02') as decimal(20,2));
--disable_warnings
DROP PROCEDURE IF EXISTS test27759 ;
--enable_warnings
DELIMITER |;
CREATE PROCEDURE test27759()
BEGIN
declare v_a date default '2007-4-10';
declare v_b date default '2007-4-11';
declare v_c datetime default '2004-4-9 0:0:0';
select v_a as a,v_b as b,
least( v_a, v_b ) as a_then_b,
least( v_b, v_a ) as b_then_a,
least( v_c, v_a ) as c_then_a;
END;|
DELIMITER ;|
call test27759();
drop procedure test27759;

View file

@ -1130,4 +1130,23 @@ alter table t1 modify column a decimal(19);
select * from t1;
drop table t1;
#
# Bug #27957 cast as decimal does not check overflow, also inconsistent with group, subselect
#
select cast(11.1234 as DECIMAL(3,2));
select * from (select cast(11.1234 as DECIMAL(3,2))) t;
select cast(a as DECIMAL(3,2))
from (select 11.1233 as a
UNION select 11.1234
UNION select 12.1234
) t;
select cast(a as DECIMAL(3,2)), count(*)
from (select 11.1233 as a
UNION select 11.1234
UNION select 12.1234
) t group by 1;
--echo End of 5.0 tests

View file

@ -3221,4 +3221,16 @@ EXPLAIN SELECT * FROM t1 UNION SELECT * FROM v1 ORDER BY a;
DROP VIEW v1;
DROP TABLE t1;
#
# Bug #27921 View ignores precision for CAST()
#
CREATE VIEW v1 AS SELECT CAST( 1.23456789 AS DECIMAL( 7,5 ) ) AS col;
SELECT * FROM v1;
DESCRIBE v1;
DROP VIEW v1;
CREATE VIEW v1 AS SELECT CAST(1.23456789 AS DECIMAL(8,0)) AS col;
SHOW CREATE VIEW v1;
DROP VIEW v1;
--echo End of 5.0 tests.

View file

@ -166,6 +166,13 @@ public:
*/
char char_value() const;
/**
* Get value stored in NdbRecAttr object.
*
* @return Int8 value.
*/
Int8 int8_value() const;
/**
* Get value stored in NdbRecAttr object.
*
@ -201,6 +208,13 @@ public:
*/
Uint8 u_char_value() const;
/**
* Get value stored in NdbRecAttr object.
*
* @return Uint8 value.
*/
Uint8 u_8_value() const;
/**
* Get value stored in NdbRecAttr object.
*
@ -346,6 +360,13 @@ NdbRecAttr::char_value() const
return *(char*)theRef;
}
inline
Int8
NdbRecAttr::int8_value() const
{
return *(Int8*)theRef;
}
inline
Uint32
NdbRecAttr::u_32_value() const
@ -367,6 +388,13 @@ NdbRecAttr::u_char_value() const
return *(Uint8*)theRef;
}
inline
Uint8
NdbRecAttr::u_8_value() const
{
return *(Uint8*)theRef;
}
inline
void
NdbRecAttr::release()

View file

@ -2059,6 +2059,9 @@ public:
Uint8 simpleRead;
Uint8 seqNoReplica;
Uint8 tcNodeFailrec;
#ifdef VM_TRACE
Uint8 tupkeyref;
#endif
}; /* p2c: size = 280 bytes */
typedef Ptr<TcConnectionrec> TcConnectionrecPtr;

View file

@ -2765,6 +2765,12 @@ void Dblqh::execTUPKEYREF(Signal* signal)
tcConnectptr.i = tupKeyRef->userRef;
terrorCode = tupKeyRef->errorCode;
ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec);
#ifdef VM_TRACE
ndbrequire(tcConnectptr.p->tupkeyref == 0);
tcConnectptr.p->tupkeyref = 1;
#endif
switch (tcConnectptr.p->transactionState) {
case TcConnectionrec::WAIT_TUP:
jam();
@ -3330,6 +3336,10 @@ void Dblqh::seizeTcrec()
locTcConnectptr.p->tcTimer = cLqhTimeOutCount;
locTcConnectptr.p->tableref = RNIL;
locTcConnectptr.p->savePointId = 0;
#ifdef VM_TRACE
locTcConnectptr.p->tupkeyref = 1;
#endif
cfirstfreeTcConrec = nextTc;
tcConnectptr = locTcConnectptr;
locTcConnectptr.p->connectState = TcConnectionrec::CONNECTED;
@ -4049,6 +4059,9 @@ void Dblqh::execACCKEYCONF(Signal* signal)
tupKeyReq->tcOpIndex = tcConnectptr.p->tcOprec;
tupKeyReq->savePointId = tcConnectptr.p->savePointId;
#ifdef VM_TRACE
tcConnectptr.p->tupkeyref = 0;
#endif
EXECUTE_DIRECT(tup, GSN_TUPKEYREQ, signal, TupKeyReq::SignalLength);
}//Dblqh::execACCKEYCONF()
@ -5860,6 +5873,10 @@ void Dblqh::completeUnusualLab(Signal* signal)
void Dblqh::releaseTcrec(Signal* signal, TcConnectionrecPtr locTcConnectptr)
{
jam();
#ifdef VM_TRACE
locTcConnectptr.p->tupkeyref = 1;
#endif
locTcConnectptr.p->tcTimer = 0;
locTcConnectptr.p->transactionState = TcConnectionrec::TC_NOT_CONNECTED;
locTcConnectptr.p->nextTcConnectrec = cfirstfreeTcConrec;
@ -5882,6 +5899,9 @@ void Dblqh::releaseTcrec(Signal* signal, TcConnectionrecPtr locTcConnectptr)
void Dblqh::releaseTcrecLog(Signal* signal, TcConnectionrecPtr locTcConnectptr)
{
jam();
#ifdef VM_TRACE
locTcConnectptr.p->tupkeyref = 1;
#endif
locTcConnectptr.p->tcTimer = 0;
locTcConnectptr.p->transactionState = TcConnectionrec::TC_NOT_CONNECTED;
locTcConnectptr.p->nextTcConnectrec = cfirstfreeTcConrec;
@ -8336,8 +8356,11 @@ void Dblqh::nextScanConfLoopLab(Signal* signal)
tupKeyReq->tcOpIndex = tcConnectptr.p->tcOprec;
tupKeyReq->savePointId = tcConnectptr.p->savePointId;
Uint32 blockNo = refToBlock(tcConnectptr.p->tcTupBlockref);
#ifdef VM_TRACE
tcConnectptr.p->tupkeyref = 0;
#endif
EXECUTE_DIRECT(blockNo, GSN_TUPKEYREQ, signal,
TupKeyReq::SignalLength);
TupKeyReq::SignalLength);
}
}
@ -9455,6 +9478,9 @@ void Dblqh::copySendTupkeyReqLab(Signal* signal)
tupKeyReq->tcOpIndex = tcConnectptr.p->tcOprec;
tupKeyReq->savePointId = tcConnectptr.p->savePointId;
Uint32 blockNo = refToBlock(tcConnectptr.p->tcTupBlockref);
#ifdef VM_TRACE
tcConnectptr.p->tupkeyref = 0;
#endif
EXECUTE_DIRECT(blockNo, GSN_TUPKEYREQ, signal,
TupKeyReq::SignalLength);
}

View file

@ -1138,7 +1138,11 @@ Dbtup::updateStartLab(Signal* signal,
regOperPtr->attrinbufLen);
} else {
jam();
retValue = interpreterStartLab(signal, pagePtr, regOperPtr->pageOffset);
if (interpreterStartLab(signal, pagePtr, regOperPtr->pageOffset) == -1)
{
jam();
return -1;
}
}//if
if (retValue == -1) {

View file

@ -18,7 +18,7 @@
#include <ndb_global.h>
#include "TimeModule.hpp"
static const char* cMonth[] = { "x", "January", "February", "Mars", "April", "May", "June",
static const char* cMonth[] = { "x", "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"};
static const char* cDay[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",

View file

@ -627,6 +627,16 @@ MgmtSrvr::start(BaseString &error_string)
ndbout_c("This is probably a bug.");
}
/*
set api reg req frequency quite high:
100 ms interval to make sure we have fairly up-to-date
info from the nodes. This to make sure that this info
is not dependent on heart beat settings in the
configuration
*/
theFacade->theClusterMgr->set_max_api_reg_req_interval(100);
TransporterRegistry *reg = theFacade->get_registry();
for(unsigned int i=0;i<reg->m_transporter_interface.size();i++) {
BaseString msg;

View file

@ -68,6 +68,7 @@ ClusterMgr::ClusterMgr(TransporterFacade & _facade):
clusterMgrThreadMutex = NdbMutex_Create();
waitForHBCond= NdbCondition_Create();
waitingForHB= false;
m_max_api_reg_req_interval= 0xFFFFFFFF; // MAX_INT
noOfAliveNodes= 0;
noOfConnectedNodes= 0;
theClusterMgrThread= 0;
@ -251,7 +252,7 @@ ClusterMgr::threadMain( ){
* Start of Secure area for use of Transporter
*/
theFacade.lock_mutex();
for (int i = 1; i < MAX_NODES; i++){
for (int i = 1; i < MAX_NDB_NODES; i++){
/**
* Send register request (heartbeat) to all available nodes
* at specified timing intervals
@ -272,7 +273,8 @@ ClusterMgr::threadMain( ){
}
theNode.hbCounter += timeSlept;
if (theNode.hbCounter >= theNode.hbFrequency) {
if (theNode.hbCounter >= m_max_api_reg_req_interval ||
theNode.hbCounter >= theNode.hbFrequency) {
/**
* It is now time to send a new Heartbeat
*/
@ -281,13 +283,6 @@ ClusterMgr::threadMain( ){
theNode.hbCounter = 0;
}
/**
* If the node is of type REP,
* then the receiver of the signal should be API_CLUSTERMGR
*/
if (theNode.m_info.m_type == NodeInfo::REP) {
signal.theReceiversBlockNumber = API_CLUSTERMGR;
}
#ifdef DEBUG_REG
ndbout_c("ClusterMgr: Sending API_REGREQ to node %d", (int)nodeId);
#endif

View file

@ -50,6 +50,7 @@ public:
void startThread();
void forceHB();
void set_max_api_reg_req_interval(unsigned int millisec) { m_max_api_reg_req_interval = millisec; }
private:
void threadMain();
@ -83,6 +84,7 @@ public:
Uint32 m_connect_count;
private:
Uint32 m_max_api_reg_req_interval;
Uint32 noOfAliveNodes;
Uint32 noOfConnectedNodes;
Node theNodes[MAX_NODES];

View file

@ -272,7 +272,7 @@ ndbrecattr_print_formatted(NdbOut& out, const NdbRecAttr &r,
out << r.u_short_value();
break;
case NdbDictionary::Column::Tinyunsigned:
out << (unsigned) r.u_char_value();
out << (unsigned) r.u_8_value();
break;
case NdbDictionary::Column::Bigint:
out << r.int64_value();
@ -287,7 +287,7 @@ ndbrecattr_print_formatted(NdbOut& out, const NdbRecAttr &r,
out << r.short_value();
break;
case NdbDictionary::Column::Tinyint:
out << (int) r.char_value();
out << (int) r.int8_value();
break;
case NdbDictionary::Column::Binary:
if (!f.hex_format)
@ -413,7 +413,7 @@ ndbrecattr_print_formatted(NdbOut& out, const NdbRecAttr &r,
break;
case NdbDictionary::Column::Year:
{
uint year = 1900 + r.u_char_value();
uint year = 1900 + r.u_8_value();
char buf[40];
sprintf(buf, "%04d", year);
out << buf;

View file

@ -90,20 +90,20 @@ EXTRA_DIST= $(BUILT_SOURCES) comp_err.def install_test_db.ncf \
# Build init_db.sql from the files that contain
# the system tables for this version of MySQL plus any commands
init_db.sql: $(top_srcdir)/scripts/mysql_system_tables.sql \
$(top_srcdir)/scripts/mysql_system_tables_data.sql
$(top_srcdir)/scripts/mysql_system_tables_data.sql
@echo "Building $@";
@echo "CREATE DATABASE mysql;" > $@;
@echo "CREATE DATABASE test;" >> $@;
@echo "use mysql;" >> $@;
@cat $(top_srcdir)/scripts/mysql_system_tables.sql \
$(top_srcdir)/scripts/mysql_system_tables_fix.sql >> $@;
$(top_srcdir)/scripts/mysql_system_tables_fix.sql >> $@;
# Build test_db.sql from init_db.sql plus
# some test data
test_db.sql: init_db.sql $(top_srcdir)/scripts/mysql_test_data_timezone.sql
@echo "Building $@";
@cat init_db.sql \
$(top_srcdir)/scripts/mysql_test_data_timezone.sql >> $@;
$(top_srcdir)/scripts/mysql_test_data_timezone.sql >> $@;
endif

View file

@ -16,9 +16,9 @@
## Process this file with automake to create Makefile.in
BUILT_SOURCES = mysql_fix_privilege_tables.sql \
mysql_fix_privilege_tables_sql.c
mysql_fix_privilege_tables_sql.c
noinst_PROGRAMS = comp_sql
EXTRA_PROGRAMS = comp_sql
bin_SCRIPTS = @server_scripts@ \
msql2mysql \
@ -70,6 +70,7 @@ EXTRA_DIST = $(EXTRA_SCRIPTS) \
mysqlaccess.conf \
mysqlbug \
make_win_bin_dist \
mysql_fix_privilege_tables_sql.c \
mysql_system_tables_fix.sql \
CMakeLists.txt
@ -98,13 +99,11 @@ CLEANFILES = @server_scripts@ \
mysql_tableinfo \
mysql_upgrade_shell \
mysqld_multi \
make_win_src_distribution \
mysql_fix_privilege_tables.sql \
mysql_fix_privilege_tables_sql.c
make_win_src_distribution
# mysqlbug should be distributed built so that people can report build
# failures with it.
DISTCLEANFILES = mysqlbug
DISTCLEANFILES = $(BUILT_SOURCES) mysqlbug
# We want the right version and configure comand line in mysqlbug
mysqlbug: ${top_builddir}/config.status mysqlbug.sh
@ -120,11 +119,14 @@ mysql_fix_privilege_tables.sql: mysql_system_tables.sql \
#
# Build mysql_fix_privilege_tables_sql.c from
# mysql_fix_privileges_tables.sql using comp_sql
# The "sleep" ensures the generated file has a younger timestamp than its source
# (which may have been generated in this very same "make" run).
#
mysql_fix_privilege_tables_sql.c: comp_sql.c mysql_fix_privilege_tables.sql
$(MAKE) $(AM_MAKEFLAGS) comp_sql$(EXEEXT)
sleep 2
$(top_builddir)/scripts/comp_sql$(EXEEXT) \
mysql_fix_privilege_tables \
mysql_fix_privilege_tables \
$(top_srcdir)/scripts/mysql_fix_privilege_tables.sql $@

View file

@ -8448,8 +8448,7 @@ bool create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
case FIELD_TYPE_NULL:
break;
case FIELD_TYPE_NEWDECIMAL:
if (!fld_length && !decimals)
length= 10;
my_decimal_trim(&length, &decimals);
if (length > DECIMAL_MAX_PRECISION)
{
my_error(ER_TOO_BIG_PRECISION, MYF(0), length, fld_name,

View file

@ -1630,6 +1630,34 @@ bool ha_ndbcluster::check_all_operations_for_error(NdbTransaction *trans,
DBUG_RETURN(true);
}
/**
* Check if record contains any null valued columns that are part of a key
*/
static
int
check_null_in_record(const KEY* key_info, const byte *record)
{
KEY_PART_INFO *curr_part, *end_part;
curr_part= key_info->key_part;
end_part= curr_part + key_info->key_parts;
while (curr_part != end_part)
{
if (curr_part->null_bit &&
(record[curr_part->null_offset] & curr_part->null_bit))
return 1;
curr_part++;
}
return 0;
/*
We could instead pre-compute a bitmask in table_share with one bit for
every null-bit in the key, and so check this just by OR'ing the bitmask
with the null bitmap in the record.
But not sure it's worth it.
*/
}
/*
* Peek to check if any rows already exist with conflicting
* primary key or unique index values
@ -1671,7 +1699,17 @@ int ha_ndbcluster::peek_indexed_rows(const byte *record, bool check_pk)
if (i != table->s->primary_key &&
key_info->flags & HA_NOSAME)
{
// A unique index is defined on table
/*
A unique index is defined on table.
We cannot look up a NULL field value in a unique index. But since
keys with NULLs are not indexed, such rows cannot conflict anyway, so
we just skip the index in this case.
*/
if (check_null_in_record(key_info, record))
{
DBUG_PRINT("info", ("skipping check for key with NULL"));
continue;
}
NdbIndexOperation *iop;
NDBINDEX *unique_index = (NDBINDEX *) m_index[i].unique_index;
key_part= key_info->key_part;
@ -2816,7 +2854,7 @@ int ha_ndbcluster::index_end()
}
/**
* Check if key contains null
* Check if key contains nullable columns
*/
static
int

View file

@ -40,6 +40,7 @@ class ha_ndbcluster_cond;
// connectstring to cluster if given by mysqld
extern const char *ndbcluster_connectstring;
extern ulong ndb_cache_check_time;
extern char opt_ndb_constrbuf[];
typedef enum ndb_index_type {
UNDEFINED_INDEX = 0,

View file

@ -1685,7 +1685,14 @@ void handler::restore_auto_increment()
{
THD *thd= table->in_use;
if (thd->next_insert_id)
{
thd->next_insert_id= thd->prev_insert_id;
if (thd->next_insert_id == 0)
{
/* we didn't generate a value, engine will be called again */
thd->clear_next_insert_id= 0;
}
}
}

View file

@ -1029,6 +1029,7 @@ Item_splocal::Item_splocal(const LEX_STRING &sp_var_name,
maybe_null= TRUE;
m_type= sp_map_item_type(sp_var_type);
m_field_type= sp_var_type;
m_result_type= sp_map_result_type(sp_var_type);
}
@ -4640,7 +4641,6 @@ inline uint char_val(char X)
Item_hex_string::Item_hex_string(const char *str, uint str_length)
{
name=(char*) str-2; // Lex makes this start with 0x
max_length=(str_length+1)/2;
char *ptr=(char*) sql_alloc(max_length+1);
if (!ptr)
@ -4751,7 +4751,6 @@ Item_bin_string::Item_bin_string(const char *str, uint str_length)
uchar bits= 0;
uint power= 1;
name= (char*) str - 2;
max_length= (str_length + 7) >> 3;
char *ptr= (char*) sql_alloc(max_length + 1);
if (!ptr)

View file

@ -946,7 +946,7 @@ class Item_splocal :public Item_sp_variable,
Type m_type;
Item_result m_result_type;
enum_field_types m_field_type;
public:
/*
Position of this reference to SP variable in the statement (the
@ -978,6 +978,7 @@ public:
inline enum Type type() const;
inline Item_result result_type() const;
inline enum_field_types field_type() const { return m_field_type; }
private:
bool set_value(THD *thd, sp_rcontext *ctx, Item **it);

View file

@ -749,7 +749,7 @@ void Arg_comparator::set_datetime_cmp_func(Item **a1, Item **b1)
obtained value
*/
static ulonglong
ulonglong
get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
Item *warn_item, bool *is_null)
{
@ -785,7 +785,7 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
MYSQL_TYPE_DATE ? MYSQL_TIMESTAMP_DATE : MYSQL_TIMESTAMP_DATETIME;
value= get_date_from_str(thd, str, t_type, warn_item->name, &error);
}
if (item->const_item())
if (item->const_item() && cache_arg)
{
Item_cache_int *cache= new Item_cache_int();
/* Mark the cache as non-const to prevent re-caching. */
@ -2790,7 +2790,6 @@ in_row::in_row(uint elements, Item * item)
base= (char*) new cmp_item_row[count= elements];
size= sizeof(cmp_item_row);
compare= (qsort2_cmp) cmp_row;
tmp.store_value(item);
/*
We need to reset these as otherwise we will call sort() with
uninitialized (even if not used) elements
@ -2842,6 +2841,27 @@ byte *in_longlong::get_value(Item *item)
return (byte*) &tmp;
}
void in_datetime::set(uint pos,Item *item)
{
Item **tmp= &item;
bool is_null;
struct packed_longlong *buff= &((packed_longlong*) base)[pos];
buff->val= get_datetime_value(thd, &tmp, 0, warn_item, &is_null);
buff->unsigned_flag= 1L;
}
byte *in_datetime::get_value(Item *item)
{
bool is_null;
Item **tmp_item= lval_cache ? &lval_cache : &item;
tmp.val= get_datetime_value(thd, &tmp_item, &lval_cache, warn_item, &is_null);
if (item->null_value)
return 0;
tmp.unsigned_flag= 1L;
return (byte*) &tmp;
}
in_double::in_double(uint elements)
:in_vector(elements,sizeof(double),(qsort2_cmp) cmp_double, 0)
{}
@ -2946,12 +2966,18 @@ cmp_item_row::~cmp_item_row()
}
void cmp_item_row::alloc_comparators()
{
if (!comparators)
comparators= (cmp_item **) current_thd->calloc(sizeof(cmp_item *)*n);
}
void cmp_item_row::store_value(Item *item)
{
DBUG_ENTER("cmp_item_row::store_value");
n= item->cols();
if (!comparators)
comparators= (cmp_item **) current_thd->calloc(sizeof(cmp_item *)*n);
alloc_comparators();
if (comparators)
{
item->bring_value();
@ -3063,6 +3089,36 @@ cmp_item* cmp_item_decimal::make_same()
}
void cmp_item_datetime::store_value(Item *item)
{
bool is_null;
Item **tmp_item= lval_cache ? &lval_cache : &item;
value= get_datetime_value(thd, &tmp_item, &lval_cache, warn_item, &is_null);
}
int cmp_item_datetime::cmp(Item *arg)
{
bool is_null;
Item **tmp_item= &arg;
return value !=
get_datetime_value(thd, &tmp_item, 0, warn_item, &is_null);
}
int cmp_item_datetime::compare(cmp_item *ci)
{
cmp_item_datetime *l_cmp= (cmp_item_datetime *)ci;
return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1);
}
cmp_item *cmp_item_datetime::make_same()
{
return new cmp_item_datetime(warn_item);
}
bool Item_func_in::nulls_in_row()
{
Item **arg,**arg_end;
@ -3138,7 +3194,11 @@ void Item_func_in::fix_length_and_dec()
Item **arg, **arg_end;
uint const_itm= 1;
THD *thd= current_thd;
bool datetime_found= FALSE;
/* TRUE <=> arguments values will be compared as DATETIMEs. */
bool compare_as_datetime= FALSE;
Item *date_arg= 0;
if (agg_cmp_type(thd, &cmp_type, args, arg_count))
return;
@ -3154,58 +3214,148 @@ void Item_func_in::fix_length_and_dec()
break;
}
}
/*
When comparing rows create the row comparator object beforehand to ease
the DATETIME comparison detection procedure.
*/
if (cmp_type == ROW_RESULT)
{
cmp_item_row *cmp= 0;
if (const_itm && !nulls_in_row())
{
array= new in_row(arg_count-1, 0);
cmp= &((in_row*)array)->tmp;
}
else
{
if (!(cmp= new cmp_item_row))
return;
in_item= cmp;
}
cmp->n= args[0]->cols();
cmp->alloc_comparators();
}
/* All DATE/DATETIME fields/functions has the STRING result type. */
if (cmp_type == STRING_RESULT || cmp_type == ROW_RESULT)
{
uint col, cols= args[0]->cols();
for (col= 0; col < cols; col++)
{
bool skip_column= FALSE;
/*
Check that all items to be compared has the STRING result type and at
least one of them is a DATE/DATETIME item.
*/
for (arg= args, arg_end= args + arg_count; arg != arg_end ; arg++)
{
Item *itm= ((cmp_type == STRING_RESULT) ? arg[0] :
arg[0]->element_index(col));
if (itm->result_type() != STRING_RESULT)
{
skip_column= TRUE;
break;
}
else if (itm->is_datetime())
{
datetime_found= TRUE;
/*
Internally all DATE/DATETIME values are converted to the DATETIME
type. So try to find a DATETIME item to issue correct warnings.
*/
if (!date_arg)
date_arg= itm;
else if (itm->field_type() == MYSQL_TYPE_DATETIME)
{
date_arg= itm;
/* All arguments are already checked to have the STRING result. */
if (cmp_type == STRING_RESULT)
break;
}
}
}
if (skip_column)
continue;
if (datetime_found)
{
if (cmp_type == ROW_RESULT)
{
cmp_item **cmp= 0;
if (array)
cmp= ((in_row*)array)->tmp.comparators + col;
else
cmp= ((cmp_item_row*)in_item)->comparators + col;
*cmp= new cmp_item_datetime(date_arg);
/* Reset variables for the next column. */
date_arg= 0;
datetime_found= FALSE;
}
else
compare_as_datetime= TRUE;
}
}
}
/*
Row item with NULLs inside can return NULL or FALSE =>
they can't be processed as static
*/
if (const_itm && !nulls_in_row())
{
/*
IN must compare INT/DATE/DATETIME/TIMESTAMP columns and constants
as int values (the same way as equality does).
So we must check here if the column on the left and all the constant
values on the right can be compared as integers and adjust the
comparison type accordingly.
*/
if (args[0]->real_item()->type() == FIELD_ITEM &&
thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
thd->lex->sql_command != SQLCOM_SHOW_CREATE &&
cmp_type != INT_RESULT)
if (compare_as_datetime)
array= new in_datetime(date_arg, arg_count - 1);
else
{
Field *field= ((Item_field*) (args[0]->real_item()))->field;
if (field->can_be_compared_as_longlong())
/*
IN must compare INT columns and constants as int values (the same
way as equality does).
So we must check here if the column on the left and all the constant
values on the right can be compared as integers and adjust the
comparison type accordingly.
*/
if (args[0]->real_item()->type() == FIELD_ITEM &&
thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
thd->lex->sql_command != SQLCOM_SHOW_CREATE &&
cmp_type != INT_RESULT)
{
bool all_converted= TRUE;
for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++)
Field *field= ((Item_field*) (args[0]->real_item()))->field;
if (field->can_be_compared_as_longlong())
{
if (!convert_constant_item (thd, field, &arg[0]))
all_converted= FALSE;
bool all_converted= TRUE;
for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++)
{
if (!convert_constant_item (thd, field, &arg[0]))
all_converted= FALSE;
}
if (all_converted)
cmp_type= INT_RESULT;
}
if (all_converted)
cmp_type= INT_RESULT;
}
}
switch (cmp_type) {
case STRING_RESULT:
array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in,
cmp_collation.collation);
break;
case INT_RESULT:
array= new in_longlong(arg_count-1);
break;
case REAL_RESULT:
array= new in_double(arg_count-1);
break;
case ROW_RESULT:
array= new in_row(arg_count-1, args[0]);
break;
case DECIMAL_RESULT:
array= new in_decimal(arg_count - 1);
break;
default:
DBUG_ASSERT(0);
return;
switch (cmp_type) {
case STRING_RESULT:
array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in,
cmp_collation.collation);
break;
case INT_RESULT:
array= new in_longlong(arg_count-1);
break;
case REAL_RESULT:
array= new in_double(arg_count-1);
break;
case ROW_RESULT:
/*
The row comparator was created at the beginning but only DATETIME
items comparators were initialized. Call store_value() to setup
others.
*/
((in_row*)array)->tmp.store_value(args[0]);
break;
case DECIMAL_RESULT:
array= new in_decimal(arg_count - 1);
break;
default:
DBUG_ASSERT(0);
return;
}
}
if (array && !(thd->is_fatal_error)) // If not EOM
{
@ -3224,7 +3374,19 @@ void Item_func_in::fix_length_and_dec()
}
else
{
in_item= cmp_item::get_comparator(cmp_type, cmp_collation.collation);
if (in_item)
{
/*
The row comparator was created at the beginning but only DATETIME
items comparators were initialized. Call store_value() to setup
others.
*/
in_item->store_value(args[0]);
}
else if (compare_as_datetime)
in_item= new cmp_item_datetime(date_arg);
else
in_item= cmp_item::get_comparator(cmp_type, cmp_collation.collation);
if (cmp_type == STRING_RESULT)
in_item->cmp_charset= cmp_collation.collation;
}

View file

@ -833,6 +833,7 @@ public:
class in_longlong :public in_vector
{
protected:
/*
Here we declare a temporary variable (tmp) of the same type as the
elements of this vector. tmp is used in finding if a given value is in
@ -866,6 +867,30 @@ public:
friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b);
};
/*
Class to represent a vector of constant DATE/DATETIME values.
Values are obtained with help of the get_datetime_value() function.
If the left item is a constant one then its value is cached in the
lval_cache variable.
*/
class in_datetime :public in_longlong
{
public:
THD *thd;
/* An item used to issue warnings. */
Item *warn_item;
/* Cache for the left item. */
Item *lval_cache;
in_datetime(Item *warn_item_arg, uint elements)
:in_longlong(elements), thd(current_thd), warn_item(warn_item_arg),
lval_cache(0) {};
void set(uint pos,Item *item);
byte *get_value(Item *item);
friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b);
};
class in_double :public in_vector
{
double tmp;
@ -986,6 +1011,30 @@ public:
cmp_item *make_same();
};
/*
Compare items in the DATETIME context.
Values are obtained with help of the get_datetime_value() function.
If the left item is a constant one then its value is cached in the
lval_cache variable.
*/
class cmp_item_datetime :public cmp_item
{
ulonglong value;
public:
THD *thd;
/* Item used for issuing warnings. */
Item *warn_item;
/* Cache for the left item. */
Item *lval_cache;
cmp_item_datetime(Item *warn_item_arg)
:thd(current_thd), warn_item(warn_item_arg), lval_cache(0) {}
void store_value(Item *item);
int cmp(Item *arg);
int compare(cmp_item *ci);
cmp_item *make_same();
};
class cmp_item_real :public cmp_item
{
double value;
@ -1020,31 +1069,6 @@ public:
};
class cmp_item_row :public cmp_item
{
cmp_item **comparators;
uint n;
public:
cmp_item_row(): comparators(0), n(0) {}
~cmp_item_row();
void store_value(Item *item);
int cmp(Item *arg);
int compare(cmp_item *arg);
cmp_item *make_same();
void store_value_by_template(cmp_item *tmpl, Item *);
};
class in_row :public in_vector
{
cmp_item_row tmp;
public:
in_row(uint elements, Item *);
~in_row();
void set(uint pos,Item *item);
byte *get_value(Item *item);
};
/*
cmp_item for optimized IN with row (right part string, which never
be changed)
@ -1120,6 +1144,34 @@ public:
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
};
class cmp_item_row :public cmp_item
{
cmp_item **comparators;
uint n;
public:
cmp_item_row(): comparators(0), n(0) {}
~cmp_item_row();
void store_value(Item *item);
inline void alloc_comparators();
int cmp(Item *arg);
int compare(cmp_item *arg);
cmp_item *make_same();
void store_value_by_template(cmp_item *tmpl, Item *);
friend void Item_func_in::fix_length_and_dec();
};
class in_row :public in_vector
{
cmp_item_row tmp;
public:
in_row(uint elements, Item *);
~in_row();
void set(uint pos,Item *item);
byte *get_value(Item *item);
friend void Item_func_in::fix_length_and_dec();
};
/* Functions used by where clause */
class Item_func_isnull :public Item_bool_func

View file

@ -445,11 +445,13 @@ Item *create_load_file(Item* a)
}
Item *create_func_cast(Item *a, Cast_target cast_type, int len, int dec,
Item *create_func_cast(Item *a, Cast_target cast_type,
const char *c_len, const char *c_dec,
CHARSET_INFO *cs)
{
Item *res;
int tmp_len;
ulong len;
uint dec;
LINT_INIT(res);
switch (cast_type) {
@ -460,15 +462,18 @@ Item *create_func_cast(Item *a, Cast_target cast_type, int len, int dec,
case ITEM_CAST_TIME: res= new Item_time_typecast(a); break;
case ITEM_CAST_DATETIME: res= new Item_datetime_typecast(a); break;
case ITEM_CAST_DECIMAL:
tmp_len= (len>0) ? len : 10;
if (tmp_len < dec)
len= c_len ? atoi(c_len) : 0;
dec= c_dec ? atoi(c_dec) : 0;
my_decimal_trim(&len, &dec);
if (len < dec)
{
my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
return 0;
}
res= new Item_decimal_typecast(a, tmp_len, dec ? dec : 2);
res= new Item_decimal_typecast(a, len, dec);
break;
case ITEM_CAST_CHAR:
len= c_len ? atoi(c_len) : -1;
res= new Item_char_typecast(a, len, cs ? cs :
current_thd->variables.collation_connection);
break;
@ -476,6 +481,7 @@ Item *create_func_cast(Item *a, Cast_target cast_type, int len, int dec,
return res;
}
Item *create_func_is_free_lock(Item* a)
{
current_thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);

View file

@ -27,7 +27,8 @@ Item *create_func_bit_length(Item* a);
Item *create_func_coercibility(Item* a);
Item *create_func_ceiling(Item* a);
Item *create_func_char_length(Item* a);
Item *create_func_cast(Item *a, Cast_target cast_type, int len, int dec,
Item *create_func_cast(Item *a, Cast_target cast_type,
const char *len, const char *dec,
CHARSET_INFO *cs);
Item *create_func_connection_id(void);
Item *create_func_conv(Item* a, Item *b, Item *c);

View file

@ -958,7 +958,8 @@ longlong Item_func_signed::val_int()
longlong value;
int error;
if (args[0]->cast_to_int_type() != STRING_RESULT)
if (args[0]->cast_to_int_type() != STRING_RESULT ||
args[0]->result_as_longlong())
{
value= args[0]->val_int();
null_value= args[0]->null_value;
@ -997,7 +998,8 @@ longlong Item_func_unsigned::val_int()
my_decimal2int(E_DEC_FATAL_ERROR, dec, 1, &value);
return value;
}
else if (args[0]->cast_to_int_type() != STRING_RESULT)
else if (args[0]->cast_to_int_type() != STRING_RESULT ||
args[0]->result_as_longlong())
{
value= args[0]->val_int();
null_value= args[0]->null_value;
@ -1048,18 +1050,61 @@ longlong Item_decimal_typecast::val_int()
my_decimal *Item_decimal_typecast::val_decimal(my_decimal *dec)
{
my_decimal tmp_buf, *tmp= args[0]->val_decimal(&tmp_buf);
bool sign;
uint precision;
if ((null_value= args[0]->null_value))
return NULL;
my_decimal_round(E_DEC_FATAL_ERROR, tmp, decimals, FALSE, dec);
sign= dec->sign();
if (unsigned_flag)
{
if (sign)
{
my_decimal_set_zero(dec);
goto err;
}
}
precision= my_decimal_length_to_precision(max_length,
decimals, unsigned_flag);
if (precision - decimals < (uint) my_decimal_intg(dec))
{
max_my_decimal(dec, precision, decimals);
dec->sign(sign);
goto err;
}
return dec;
err:
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_WARN_DATA_OUT_OF_RANGE,
ER(ER_WARN_DATA_OUT_OF_RANGE),
name, 1);
return dec;
}
void Item_decimal_typecast::print(String *str)
{
char len_buf[20*3 + 1];
char *end;
uint precision= my_decimal_length_to_precision(max_length, decimals,
unsigned_flag);
str->append(STRING_WITH_LEN("cast("));
args[0]->print(str);
str->append(STRING_WITH_LEN(" as decimal)"));
str->append(STRING_WITH_LEN(" as decimal("));
end=int10_to_str(precision, len_buf,10);
str->append(len_buf, (uint32) (end - len_buf));
str->append(',');
end=int10_to_str(decimals, len_buf,10);
str->append(len_buf, (uint32) (end - len_buf));
str->append(')');
str->append(')');
}
@ -2161,6 +2206,7 @@ double Item_func_units::val_real()
void Item_func_min_max::fix_length_and_dec()
{
int max_int_part=0;
bool datetime_found= FALSE;
decimals=0;
max_length=0;
maybe_null=0;
@ -2174,18 +2220,88 @@ void Item_func_min_max::fix_length_and_dec()
if (args[i]->maybe_null)
maybe_null=1;
cmp_type=item_cmp_type(cmp_type,args[i]->result_type());
if (args[i]->result_type() != ROW_RESULT && args[i]->is_datetime())
{
datetime_found= TRUE;
if (!datetime_item || args[i]->field_type() == MYSQL_TYPE_DATETIME)
datetime_item= args[i];
}
}
if (cmp_type == STRING_RESULT)
{
agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV, 1);
if (datetime_found)
{
thd= current_thd;
compare_as_dates= TRUE;
}
}
else if ((cmp_type == DECIMAL_RESULT) || (cmp_type == INT_RESULT))
max_length= my_decimal_precision_to_length(max_int_part+decimals, decimals,
unsigned_flag);
}
/*
Compare item arguments in the DATETIME context.
SYNOPSIS
cmp_datetimes()
value [out] found least/greatest DATE/DATETIME value
DESCRIPTION
Compare item arguments as DATETIME values and return the index of the
least/greatest argument in the arguments array.
The correct integer DATE/DATETIME value of the found argument is
stored to the value pointer, if latter is provided.
RETURN
0 If one of arguments is NULL
# index of the least/greatest argument
*/
uint Item_func_min_max::cmp_datetimes(ulonglong *value)
{
ulonglong min_max;
uint min_max_idx= 0;
LINT_INIT(min_max);
for (uint i=0; i < arg_count ; i++)
{
Item **arg= args + i;
bool is_null;
ulonglong res= get_datetime_value(thd, &arg, 0, datetime_item, &is_null);
if ((null_value= args[i]->null_value))
return 0;
if (i == 0 || (res < min_max ? cmp_sign : -cmp_sign) > 0)
{
min_max= res;
min_max_idx= i;
}
}
if (value)
{
*value= min_max;
if (datetime_item->field_type() == MYSQL_TYPE_DATE)
*value/= 1000000L;
}
return min_max_idx;
}
String *Item_func_min_max::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
if (compare_as_dates)
{
String *str_res;
uint min_max_idx= cmp_datetimes(NULL);
if (null_value)
return 0;
str_res= args[min_max_idx]->val_str(str);
str_res->set_charset(collation.collation);
return str_res;
}
switch (cmp_type) {
case INT_RESULT:
{
@ -2253,6 +2369,12 @@ double Item_func_min_max::val_real()
{
DBUG_ASSERT(fixed == 1);
double value=0.0;
if (compare_as_dates)
{
ulonglong result= 0;
(void)cmp_datetimes(&result);
return (double)result;
}
for (uint i=0; i < arg_count ; i++)
{
if (i == 0)
@ -2274,6 +2396,12 @@ longlong Item_func_min_max::val_int()
{
DBUG_ASSERT(fixed == 1);
longlong value=0;
if (compare_as_dates)
{
ulonglong result= 0;
(void)cmp_datetimes(&result);
return (longlong)result;
}
for (uint i=0; i < arg_count ; i++)
{
if (i == 0)
@ -2297,6 +2425,13 @@ my_decimal *Item_func_min_max::val_decimal(my_decimal *dec)
my_decimal tmp_buf, *tmp, *res;
LINT_INIT(res);
if (compare_as_dates)
{
ulonglong value= 0;
(void)cmp_datetimes(&value);
ulonglong2decimal(value, dec);
return dec;
}
for (uint i=0; i < arg_count ; i++)
{
if (i == 0)
@ -4315,7 +4450,7 @@ int get_var_with_binlog(THD *thd, enum_sql_command sql_command,
List<set_var_base> tmp_var_list;
LEX *sav_lex= thd->lex, lex_tmp;
thd->lex= &lex_tmp;
lex_start(thd, NULL, 0);
lex_start(thd);
tmp_var_list.push_back(new set_var_user(new Item_func_set_user_var(name,
new Item_null())));
/* Create the variable */

Some files were not shown because too many files have changed in this diff Show more