Commit 2a0183b5 authored by unknown's avatar unknown

merging


sql/sql_select.cc:
  Auto merged
parents 8b6ba46c 2e887f79
...@@ -2653,3 +2653,103 @@ t11 MyISAM 9 Dynamic 0 0 X X X X X X X X latin1_swedish_ci NULL ...@@ -2653,3 +2653,103 @@ t11 MyISAM 9 Dynamic 0 0 X X X X X X X X latin1_swedish_ci NULL
select 123 as a from t1 where f1 is null; select 123 as a from t1 where f1 is null;
a a
drop table t1,t11; drop table t1,t11;
CREATE TABLE t1 (
kunde_intern_id int(10) unsigned NOT NULL default '0',
kunde_id int(10) unsigned NOT NULL default '0',
FK_firma_id int(10) unsigned NOT NULL default '0',
aktuell enum('Ja','Nein') NOT NULL default 'Ja',
vorname varchar(128) NOT NULL default '',
nachname varchar(128) NOT NULL default '',
geloescht enum('Ja','Nein') NOT NULL default 'Nein',
firma varchar(128) NOT NULL default ''
);
INSERT INTO t1 VALUES
(3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'),
(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX');
SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1
WHERE
(
(
( '' != '' AND firma LIKE CONCAT('%', '', '%'))
OR
(vorname LIKE CONCAT('%', 'Vorname1', '%') AND
nachname LIKE CONCAT('%', '1Nachname', '%') AND
'Vorname1' != '' AND 'xxxx' != '')
)
AND
(
aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2
)
)
;
kunde_id FK_firma_id aktuell vorname nachname geloescht
SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname,
geloescht FROM t1
WHERE
(
(
aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2
)
AND
(
( '' != '' AND firma LIKE CONCAT('%', '', '%') )
OR
( vorname LIKE CONCAT('%', 'Vorname1', '%') AND
nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND
'xxxx' != '')
)
)
;
kunde_id FK_firma_id aktuell vorname nachname geloescht
SELECT COUNT(*) FROM t1 WHERE
( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1))
AND FK_firma_id = 2;
COUNT(*)
0
drop table t1;
CREATE TABLE t1 (a INT, b INT);
(SELECT a, b AS c FROM t1) ORDER BY c+1;
a c
(SELECT a, b AS c FROM t1) ORDER BY b+1;
a c
SELECT a, b AS c FROM t1 ORDER BY c+1;
a c
SELECT a, b AS c FROM t1 ORDER BY b+1;
a c
drop table t1;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) );
INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4);
CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, c INT );
INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),
(1,2,3);
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c;
a b c d
1 2 1 1
1 2 2 1
1 2 3 1
1 10 2
1 11 2
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c;
a b c d
1 10 4
1 2 1 1
1 2 2 1
1 2 3 1
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c;
a b c d
1 2 1 1
1 2 2 1
1 2 3 1
1 10 2
1 11 2
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2,t1
WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c;
a b c d
1 2 1 1
1 2 2 1
1 2 3 1
DROP TABLE IF EXISTS t1, t2;
...@@ -2199,4 +2199,34 @@ insert into t1 values(1,""),(2,""); ...@@ -2199,4 +2199,34 @@ insert into t1 values(1,""),(2,"");
show table status like 't1%'; show table status like 't1%';
select 123 as a from t1 where f1 is null; select 123 as a from t1 where f1 is null;
drop table t1,t11; drop table t1,t11;
# Bug 7672 Unknown column error in order clause
#
CREATE TABLE t1 (a INT, b INT);
(SELECT a, b AS c FROM t1) ORDER BY c+1;
(SELECT a, b AS c FROM t1) ORDER BY b+1;
SELECT a, b AS c FROM t1 ORDER BY c+1;
SELECT a, b AS c FROM t1 ORDER BY b+1;
drop table t1;
#
# Bug #3874 (function in GROUP and LEFT JOIN)
#
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) );
INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4);
CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, c INT );
INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),
(1,2,3);
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c;
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c;
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c;
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2,t1
WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c;
DROP TABLE IF EXISTS t1, t2;
# End of 4.1 tests # End of 4.1 tests
...@@ -4135,7 +4135,7 @@ eq_ref_table(JOIN *join, ORDER *start_order, JOIN_TAB *tab) ...@@ -4135,7 +4135,7 @@ eq_ref_table(JOIN *join, ORDER *start_order, JOIN_TAB *tab)
tab->cached_eq_ref_table=1; tab->cached_eq_ref_table=1;
if (tab->type == JT_CONST) // We can skip const tables if (tab->type == JT_CONST) // We can skip const tables
return (tab->eq_ref_table=1); /* purecov: inspected */ return (tab->eq_ref_table=1); /* purecov: inspected */
if (tab->type != JT_EQ_REF) if (tab->type != JT_EQ_REF || tab->table->maybe_null)
return (tab->eq_ref_table=0); // We must use this return (tab->eq_ref_table=0); // We must use this
Item **ref_item=tab->ref.items; Item **ref_item=tab->ref.items;
Item **end=ref_item+tab->ref.key_parts; Item **end=ref_item+tab->ref.key_parts;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment