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
481bcd57
Commit
481bcd57
authored
Nov 29, 2002
by
Sinisa@sinisa.nasamreza.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
many bug fixes
parent
8a53d1ca
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
14 deletions
+24
-14
mysql-test/r/derived.result
mysql-test/r/derived.result
+6
-0
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+7
-7
mysql-test/t/derived.test
mysql-test/t/derived.test
+2
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+3
-3
sql/sql_base.cc
sql/sql_base.cc
+2
-2
sql/sql_derived.cc
sql/sql_derived.cc
+2
-2
sql/sql_lex.cc
sql/sql_lex.cc
+2
-0
No files found.
mysql-test/r/derived.result
View file @
481bcd57
...
...
@@ -64,7 +64,13 @@ a t
18 18
19 19
20 20
explain select count(*) from t1 as tt1, (select * from t1) as tt2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Select tables optimized away
drop table if exists t1;
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
(SELECT * FROM (SELECT 1 as a) as a )
1
select * from (select 1 as a) b left join (select 2 as a) c using(a);
a a
1 NULL
mysql-test/r/subselect.result
View file @
481bcd57
...
...
@@ -17,14 +17,14 @@ SELECT (SELECT 1),MAX(1) FROM (SELECT 1) as a;
1 1
SELECT (SELECT a) as a;
Reference 'a' not supported (forward reference in item list)
EXPLAIN SELECT 1
,a
FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
EXPLAIN SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
3 DEPENDENT SUBSELECT No tables used
2 DERIVED No tables used
SELECT 1
,a
FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
1
a
1
1
SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
1
1
SELECT (SELECT 1), a;
Unknown column 'a' in 'field list'
SELECT 1 as a FROM (SELECT 1) as b HAVING (SELECT a)=1;
...
...
@@ -387,9 +387,9 @@ id select_type table type possible_keys key key_len ref rows Extra
drop table t1;
CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1);
SELECT 1
,a
FROM (SELECT a FROM t1) b HAVING (SELECT b.a)=1;
1
a
1
1
SELECT 1 FROM (SELECT a FROM t1) b HAVING (SELECT b.a)=1;
1
1
drop table t1;
create table t1 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a));
...
...
mysql-test/t/derived.test
View file @
481bcd57
...
...
@@ -33,5 +33,7 @@ while ($1)
}
enable_query_log
;
SELECT
*
FROM
(
SELECT
*
FROM
t1
)
as
b
ORDER
BY
a
ASC
LIMIT
0
,
20
;
explain
select
count
(
*
)
from
t1
as
tt1
,
(
select
*
from
t1
)
as
tt2
;
drop
table
if
exists
t1
;
SELECT
*
FROM
(
SELECT
(
SELECT
*
FROM
(
SELECT
1
as
a
)
as
a
))
as
b
;
select
*
from
(
select
1
as
a
)
b
left
join
(
select
2
as
a
)
c
using
(
a
);
mysql-test/t/subselect.test
View file @
481bcd57
...
...
@@ -8,8 +8,8 @@ SELECT (SELECT 1 FROM (SELECT 1) as b HAVING b=1) as a,(SELECT 1 FROM (SELECT 1)
SELECT
(
SELECT
1
),
MAX
(
1
)
FROM
(
SELECT
1
)
as
a
;
--
error
1245
SELECT
(
SELECT
a
)
as
a
;
EXPLAIN
SELECT
1
,
a
FROM
(
SELECT
1
as
a
)
as
b
HAVING
(
SELECT
a
)
=
1
;
SELECT
1
,
a
FROM
(
SELECT
1
as
a
)
as
b
HAVING
(
SELECT
a
)
=
1
;
EXPLAIN
SELECT
1
FROM
(
SELECT
1
as
a
)
as
b
HAVING
(
SELECT
a
)
=
1
;
SELECT
1
FROM
(
SELECT
1
as
a
)
as
b
HAVING
(
SELECT
a
)
=
1
;
--
error
1054
SELECT
(
SELECT
1
),
a
;
SELECT
1
as
a
FROM
(
SELECT
1
)
as
b
HAVING
(
SELECT
a
)
=
1
;
...
...
@@ -230,7 +230,7 @@ drop table t1;
CREATE
TABLE
t1
(
a
int
(
1
));
INSERT
INTO
t1
VALUES
(
1
);
SELECT
1
,
a
FROM
(
SELECT
a
FROM
t1
)
b
HAVING
(
SELECT
b
.
a
)
=
1
;
SELECT
1
FROM
(
SELECT
a
FROM
t1
)
b
HAVING
(
SELECT
b
.
a
)
=
1
;
drop
table
t1
;
#update with subselects
...
...
sql/sql_base.cc
View file @
481bcd57
...
...
@@ -1894,13 +1894,13 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
const
char
*
name
=
item
->
field_name
;
uint
length
=
(
uint
)
strlen
(
name
);
if
(
table_name
)
if
(
table_name
&&
table_name
[
0
]
)
{
/* Qualified field */
bool
found_table
=
0
;
for
(;
tables
;
tables
=
tables
->
next
)
{
if
(
!
strcmp
(
tables
->
alias
,
table_name
)
&&
(
!
db
||
!
strcmp
(
db
,
tables
->
db
)))
(
!
db
||
!
tables
->
db
||
!
tables
->
db
[
0
]
||
!
strcmp
(
db
,
tables
->
db
)))
{
found_table
=
1
;
Field
*
find
=
find_field_in_table
(
thd
,
tables
->
table
,
name
,
length
,
...
...
sql/sql_derived.cc
View file @
481bcd57
...
...
@@ -106,9 +106,9 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
t
->
table
=
table
;
table
->
derived_select_number
=
sl
->
select_number
;
table
->
tmp_table
=
TMP_TABLE
;
if
(
!
lex
->
describe
)
if
(
lex
->
describe
)
sl
->
exclude
();
t
->
db
=
(
tables
&&
tables
->
db
)
?
tables
->
db
:
(
char
*
)
""
;
t
->
db
=
(
char
*
)
""
;
t
->
derived
=
(
SELECT_LEX
*
)
0
;
// just in case ...
}
}
...
...
sql/sql_lex.cc
View file @
481bcd57
...
...
@@ -1173,6 +1173,8 @@ bool st_select_lex_unit::create_total_list_n_last_return(THD *thd, st_lex *lex,
net_printf
(
thd
,
ER_WRONG_USAGE
,
"UNION"
,
"ORDER BY"
);
return
1
;
}
if
(
sl
->
linkage
==
DERIVED_TABLE_TYPE
)
continue
;
for
(
SELECT_LEX_UNIT
*
inner
=
sl
->
first_inner_unit
();
inner
;
inner
=
inner
->
next_unit
())
...
...
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