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
9e8c3a6f
Commit
9e8c3a6f
authored
May 19, 2003
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bugs 442/443 (reduced subselect in ORDER/GROUP clauses)
parent
524878e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
+38
-2
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+17
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+17
-0
sql/sql_select.cc
sql/sql_select.cc
+4
-2
No files found.
mysql-test/r/subselect.result
View file @
9e8c3a6f
...
...
@@ -1126,3 +1126,20 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ref salary salary 5 const 1 Using where
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1;
(SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0);
a
1
CREATE TABLE `t1` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`pseudo` varchar(35) NOT NULL default '',
`email` varchar(60) NOT NULL default '',
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`),
UNIQUE KEY `pseudo` (`pseudo`),
) TYPE=MyISAM CHARSET=latin1 PACK_KEYS=1 ROW_FORMAT=DYNAMIC;
INSERT INTO t1 (id,pseudo,email) VALUES (1,'test','test'),(2,'test1','test1');
SELECT pseudo as a, pseudo as b FROM t1 GROUP BY (SELECT a) ORDER BY (SELECT id*1);
a b
test test
test1 test1
drop table if exists t1;
mysql-test/t/subselect.test
View file @
9e8c3a6f
...
...
@@ -714,3 +714,20 @@ create table t1 (id int not null auto_increment primary key, salary int, key(sal
insert
into
t1
(
salary
)
values
(
100
),(
1000
),(
10000
),(
10
),(
500
),(
5000
),(
50000
);
explain
SELECT
id
FROM
t1
where
salary
=
(
SELECT
MAX
(
salary
)
FROM
t1
);
drop
table
t1
;
#
# reduced subselect in ORDER BY & GROUP BY clauses
#
(
SELECT
1
as
a
)
UNION
(
SELECT
1
)
ORDER
BY
(
SELECT
a
+
0
);
CREATE
TABLE
`t1`
(
`id`
mediumint
(
8
)
unsigned
NOT
NULL
auto_increment
,
`pseudo`
varchar
(
35
)
NOT
NULL
default
''
,
`email`
varchar
(
60
)
NOT
NULL
default
''
,
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`email`
(
`email`
),
UNIQUE
KEY
`pseudo`
(
`pseudo`
),
)
TYPE
=
MyISAM
CHARSET
=
latin1
PACK_KEYS
=
1
ROW_FORMAT
=
DYNAMIC
;
INSERT
INTO
t1
(
id
,
pseudo
,
email
)
VALUES
(
1
,
'test'
,
'test'
),(
2
,
'test1'
,
'test1'
);
SELECT
pseudo
as
a
,
pseudo
as
b
FROM
t1
GROUP
BY
(
SELECT
a
)
ORDER
BY
(
SELECT
id
*
1
);
drop
table
if
exists
t1
;
sql/sql_select.cc
View file @
9e8c3a6f
...
...
@@ -7167,9 +7167,11 @@ find_order_in_list(THD *thd, Item **ref_pointer_array,
}
order
->
in_field_list
=
0
;
Item
*
it
=
*
order
->
item
;
if
(
it
->
fix_fields
(
thd
,
tables
,
order
->
item
)
||
it
->
check_cols
(
1
)
||
if
(
it
->
fix_fields
(
thd
,
tables
,
order
->
item
)
||
//'it' ressigned because fix_field can change it
(
it
=
*
order
->
item
),
it
->
check_cols
(
1
)
||
thd
->
is_fatal_error
)
return
1
;
// Wrong field
return
1
;
// Wrong field
uint
el
=
all_fields
.
elements
;
all_fields
.
push_front
(
it
);
// Add new field to field list
ref_pointer_array
[
el
]
=
it
;
...
...
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