mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge joreland@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/jonas/src/mysql-5.0 sql/sql_insert.cc: Auto merged
This commit is contained in:
@ -39,3 +39,6 @@ DROP TABLE t1;
|
||||
SELECT CHAR(31) = '', '' = CHAR(31);
|
||||
CHAR(31) = '' '' = CHAR(31)
|
||||
0 0
|
||||
SELECT CHAR(30) = '', '' = CHAR(30);
|
||||
CHAR(30) = '' '' = CHAR(30)
|
||||
0 0
|
||||
|
@ -330,6 +330,15 @@ SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MA
|
||||
min max avg
|
||||
10.00 10.00 10
|
||||
DROP TABLE t1;
|
||||
create table t1 (a integer, b integer);
|
||||
insert into t1 values (1,4), (2,2),(2,2), (4,1),(4,1),(4,1),(4,1);
|
||||
select distinct sum(b) from t1 group by a;
|
||||
sum(b)
|
||||
4
|
||||
select distinct sum(b) from (select a,b from t1) y group by a;
|
||||
sum(b)
|
||||
4
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a char(10), b char(10));
|
||||
INSERT INTO t1 VALUES ('root','localhost'), ('root','%');
|
||||
SELECT * FROM (SELECT (SELECT a.a FROM t1 AS a WHERE a.a = b.a) FROM t1 AS b) AS c;
|
||||
|
@ -328,6 +328,19 @@ trim(trailing 'foo' from 'foo')
|
||||
select trim(leading 'foo' from 'foo');
|
||||
trim(leading 'foo' from 'foo')
|
||||
|
||||
select quote(ltrim(concat(' ', 'a')));
|
||||
quote(ltrim(concat(' ', 'a')))
|
||||
'a'
|
||||
select quote(trim(concat(' ', 'a')));
|
||||
quote(trim(concat(' ', 'a')))
|
||||
'a'
|
||||
CREATE TABLE t1 SELECT 1 UNION SELECT 2 UNION SELECT 3;
|
||||
SELECT QUOTE('A') FROM t1;
|
||||
QUOTE('A')
|
||||
'A'
|
||||
'A'
|
||||
'A'
|
||||
DROP TABLE t1;
|
||||
select 1=_latin1'1';
|
||||
1=_latin1'1'
|
||||
1
|
||||
@ -694,12 +707,6 @@ select count(*) as total, left(c,10) as reg from t1 group by reg order by reg de
|
||||
total reg
|
||||
10 2004-12-10
|
||||
drop table t1;
|
||||
select quote(ltrim(concat(' ', 'a')));
|
||||
quote(ltrim(concat(' ', 'a')))
|
||||
'a'
|
||||
select quote(trim(concat(' ', 'a')));
|
||||
quote(trim(concat(' ', 'a')))
|
||||
'a'
|
||||
select trim(null from 'kate') as "must_be_null";
|
||||
must_be_null
|
||||
NULL
|
||||
@ -712,3 +719,26 @@ NULL
|
||||
select trim(trailing NULL from 'xyz') as "must_be_null";
|
||||
must_be_null
|
||||
NULL
|
||||
CREATE TABLE t1 (
|
||||
id int(11) NOT NULL auto_increment,
|
||||
a bigint(20) unsigned default NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES
|
||||
('0','16307858876001849059');
|
||||
SELECT CONV('e251273eb74a8ee3', 16, 10);
|
||||
CONV('e251273eb74a8ee3', 16, 10)
|
||||
16307858876001849059
|
||||
EXPLAIN
|
||||
SELECT id
|
||||
FROM t1
|
||||
WHERE a = 16307858876001849059;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
||||
EXPLAIN
|
||||
SELECT id
|
||||
FROM t1
|
||||
WHERE a = CONV('e251273eb74a8ee3', 16, 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
||||
DROP TABLE t1;
|
||||
|
@ -2168,3 +2168,51 @@ ERROR 42S22: Unknown column 'a2' in 'scalar IN/ALL/ANY subquery'
|
||||
select * from t1 where a1 > any(select b1 from t2);
|
||||
a1
|
||||
drop table t1,t2;
|
||||
create table t1 (a integer, b integer);
|
||||
select (select * from t1) = (select 1,2);
|
||||
(select * from t1) = (select 1,2)
|
||||
NULL
|
||||
select (select 1,2) = (select * from t1);
|
||||
(select 1,2) = (select * from t1)
|
||||
NULL
|
||||
select row(1,2) = ANY (select * from t1);
|
||||
row(1,2) = ANY (select * from t1)
|
||||
0
|
||||
select row(1,2) != ALL (select * from t1);
|
||||
row(1,2) != ALL (select * from t1)
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 (a integer, b integer);
|
||||
select row(1,(2,2)) in (select * from t1 );
|
||||
ERROR 21000: Operand should contain 2 column(s)
|
||||
select row(1,(2,2)) = (select * from t1 );
|
||||
ERROR 21000: Operand should contain 2 column(s)
|
||||
select (select * from t1) = row(1,(2,2));
|
||||
ERROR 21000: Operand should contain 1 column(s)
|
||||
drop table t1;
|
||||
create table t1 (a integer);
|
||||
insert into t1 values (1);
|
||||
select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx ;
|
||||
ERROR 42S22: Reference 'xx' not supported (forward reference in item list)
|
||||
select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx;
|
||||
ERROR 42S22: Reference 'xx' not supported (forward reference in item list)
|
||||
select 1 as xx, 1 = ALL ( select 1 from t1 where 1 = xx );
|
||||
xx 1 = ALL ( select 1 from t1 where 1 = xx )
|
||||
1 1
|
||||
select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx;
|
||||
ERROR 42S22: Reference 'xx' not supported (forward reference in item list)
|
||||
select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx from DUAL;
|
||||
ERROR 42S22: Reference 'xx' not supported (forward reference in item list)
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` ( `a` char(3) NOT NULL default '', `b` char(3) NOT NULL default '', `c` char(3) NOT NULL default '', PRIMARY KEY (`a`,`b`,`c`)) ENGINE=InnoDB;
|
||||
CREATE TABLE t2 LIKE t1;
|
||||
INSERT INTO t1 VALUES (1,1,1);
|
||||
INSERT INTO t2 VALUES (1,1,1);
|
||||
PREPARE my_stmt FROM "SELECT t1.b, count(*) FROM t1 group by t1.b having
|
||||
count(*) > ALL (SELECT COUNT(*) FROM t2 WHERE t2.a=1 GROUP By t2.b)";
|
||||
EXECUTE my_stmt;
|
||||
b count(*)
|
||||
EXECUTE my_stmt;
|
||||
b count(*)
|
||||
deallocate prepare my_stmt;
|
||||
drop table t1,t2;
|
||||
|
@ -33,3 +33,5 @@ DROP TABLE t1;
|
||||
|
||||
# Bug #8134: Comparison against CHAR(31) at end of string
|
||||
SELECT CHAR(31) = '', '' = CHAR(31);
|
||||
# Extra test
|
||||
SELECT CHAR(30) = '', '' = CHAR(30);
|
||||
|
@ -214,6 +214,16 @@ insert into t1 values (128, 'rozn', 2, now(), 10),(128, 'rozn', 1, now(), 10);
|
||||
SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# DISTINCT over grouped select on subquery in the FROM clause
|
||||
#
|
||||
create table t1 (a integer, b integer);
|
||||
insert into t1 values (1,4), (2,2),(2,2), (4,1),(4,1),(4,1),(4,1);
|
||||
select distinct sum(b) from t1 group by a;
|
||||
select distinct sum(b) from (select a,b from t1) y group by a;
|
||||
drop table t1;
|
||||
|
||||
|
||||
#
|
||||
# Test for bug #7413 "Subquery with non-scalar results participating in
|
||||
# select list of derived table crashes server" aka "VIEW with sub query can
|
||||
|
@ -196,6 +196,18 @@ select trim(trailing 'foo' from 'foo');
|
||||
select trim(leading 'foo' from 'foo');
|
||||
|
||||
#
|
||||
# crashing bug with QUOTE() and LTRIM() or TRIM() fixed
|
||||
# Bug #7495
|
||||
#
|
||||
|
||||
select quote(ltrim(concat(' ', 'a')));
|
||||
select quote(trim(concat(' ', 'a')));
|
||||
|
||||
# Bad results from QUOTE(). Bug #8248
|
||||
CREATE TABLE t1 SELECT 1 UNION SELECT 2 UNION SELECT 3;
|
||||
SELECT QUOTE('A') FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
# Test collation and coercibility
|
||||
#
|
||||
|
||||
@ -430,12 +442,6 @@ create table t1 (a int not null primary key, b varchar(40), c datetime);
|
||||
insert into t1 (a,b,c) values (1,'Tom','2004-12-10 12:13:14'),(2,'ball games','2004-12-10 12:13:14'), (3,'Basil','2004-12-10 12:13:14'), (4,'Dean','2004-12-10 12:13:14'),(5,'Ellis','2004-12-10 12:13:14'), (6,'Serg','2004-12-10 12:13:14'), (7,'Sergei','2004-12-10 12:13:14'),(8,'Georg','2004-12-10 12:13:14'),(9,'Salle','2004-12-10 12:13:14'),(10,'Sinisa','2004-12-10 12:13:14');
|
||||
select count(*) as total, left(c,10) as reg from t1 group by reg order by reg desc limit 0,12;
|
||||
drop table t1;
|
||||
# crashing bug with QUOTE() and LTRIM() or TRIM() fixed
|
||||
# Bug #7495
|
||||
#
|
||||
|
||||
select quote(ltrim(concat(' ', 'a')));
|
||||
select quote(trim(concat(' ', 'a')));
|
||||
|
||||
#
|
||||
# Bug#7455 unexpected result: TRIM(<NULL> FROM <whatever>) gives NOT NULL
|
||||
@ -446,3 +452,30 @@ select trim(null from 'kate') as "must_be_null";
|
||||
select trim('xyz' from null) as "must_be_null";
|
||||
select trim(leading NULL from 'kate') as "must_be_null";
|
||||
select trim(trailing NULL from 'xyz') as "must_be_null";
|
||||
|
||||
#
|
||||
# Bug #7751 - conversion for a bigint unsigned constant
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (
|
||||
id int(11) NOT NULL auto_increment,
|
||||
a bigint(20) unsigned default NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=MyISAM;
|
||||
|
||||
INSERT INTO t1 VALUES
|
||||
('0','16307858876001849059');
|
||||
|
||||
SELECT CONV('e251273eb74a8ee3', 16, 10);
|
||||
|
||||
EXPLAIN
|
||||
SELECT id
|
||||
FROM t1
|
||||
WHERE a = 16307858876001849059;
|
||||
|
||||
EXPLAIN
|
||||
SELECT id
|
||||
FROM t1
|
||||
WHERE a = CONV('e251273eb74a8ee3', 16, 10);
|
||||
|
||||
DROP TABLE t1;
|
||||
|
@ -1419,8 +1419,11 @@ SELECT f1 FROM t1
|
||||
WHERE f1 <> ALL ( SELECT SUM(f1) AS sf1 FROM t2 HAVING sf1 > 10000);
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
#
|
||||
# Test for BUG#7885: Server crash when 'any' subselect compared to
|
||||
# non-existant field.
|
||||
#
|
||||
create table t1 (a1 int);
|
||||
create table t2 (b1 int);
|
||||
--error 1054
|
||||
@ -1428,3 +1431,56 @@ select * from t1 where a2 > any(select b1 from t2);
|
||||
select * from t1 where a1 > any(select b1 from t2);
|
||||
drop table t1,t2;
|
||||
|
||||
|
||||
#
|
||||
# Comparison subquery with * and row
|
||||
#
|
||||
create table t1 (a integer, b integer);
|
||||
select (select * from t1) = (select 1,2);
|
||||
select (select 1,2) = (select * from t1);
|
||||
# queries whih can be converted to IN
|
||||
select row(1,2) = ANY (select * from t1);
|
||||
select row(1,2) != ALL (select * from t1);
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Comparison subquery and row with nested rows
|
||||
#
|
||||
create table t1 (a integer, b integer);
|
||||
-- error 1241
|
||||
select row(1,(2,2)) in (select * from t1 );
|
||||
-- error 1241
|
||||
select row(1,(2,2)) = (select * from t1 );
|
||||
-- error 1241
|
||||
select (select * from t1) = row(1,(2,2));
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Forward reference detection
|
||||
#
|
||||
create table t1 (a integer);
|
||||
insert into t1 values (1);
|
||||
-- error 1247
|
||||
select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx ;
|
||||
-- error 1247
|
||||
select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx;
|
||||
select 1 as xx, 1 = ALL ( select 1 from t1 where 1 = xx );
|
||||
-- error 1247
|
||||
select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx;
|
||||
-- error 1247
|
||||
select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx from DUAL;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# cleaning up of results of subselects (BUG#8125)
|
||||
#
|
||||
CREATE TABLE `t1` ( `a` char(3) NOT NULL default '', `b` char(3) NOT NULL default '', `c` char(3) NOT NULL default '', PRIMARY KEY (`a`,`b`,`c`)) ENGINE=InnoDB;
|
||||
CREATE TABLE t2 LIKE t1;
|
||||
INSERT INTO t1 VALUES (1,1,1);
|
||||
INSERT INTO t2 VALUES (1,1,1);
|
||||
PREPARE my_stmt FROM "SELECT t1.b, count(*) FROM t1 group by t1.b having
|
||||
count(*) > ALL (SELECT COUNT(*) FROM t2 WHERE t2.a=1 GROUP By t2.b)";
|
||||
EXECUTE my_stmt;
|
||||
EXECUTE my_stmt;
|
||||
deallocate prepare my_stmt;
|
||||
drop table t1,t2;
|
||||
|
Reference in New Issue
Block a user