Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
94d51833
Commit
94d51833
authored
Oct 13, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-4.1
into deer.(none):/home/hf/work/mysql-4.1.clean
parents
0d897747
3d332ea7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
1 deletion
+75
-1
mysql-test/r/select.result
mysql-test/r/select.result
+45
-0
mysql-test/t/select.test
mysql-test/t/select.test
+29
-0
sql/sql_select.cc
sql/sql_select.cc
+1
-1
No files found.
mysql-test/r/select.result
View file @
94d51833
...
...
@@ -2653,3 +2653,48 @@ 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;
a
drop table t1,t11;
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;
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;
mysql-test/t/select.test
View file @
94d51833
...
...
@@ -2199,4 +2199,33 @@ insert into t1 values(1,""),(2,"");
show
table
status
like
't1%'
;
select
123
as
a
from
t1
where
f1
is
null
;
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)
#
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
sql/sql_select.cc
View file @
94d51833
...
...
@@ -4135,7 +4135,7 @@ eq_ref_table(JOIN *join, ORDER *start_order, JOIN_TAB *tab)
tab
->
cached_eq_ref_table
=
1
;
if
(
tab
->
type
==
JT_CONST
)
// We can skip const tables
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
Item
**
ref_item
=
tab
->
ref
.
items
;
Item
**
end
=
ref_item
+
tab
->
ref
.
key_parts
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment