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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
b8c065c5
Commit
b8c065c5
authored
Mar 16, 2004
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Plain Diff
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/bk/work-select_list-4.1
parents
a99baaba
c9938b9d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
+20
-2
mysql-test/r/derived.result
mysql-test/r/derived.result
+6
-0
mysql-test/t/derived.test
mysql-test/t/derived.test
+8
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+6
-1
No files found.
mysql-test/r/derived.result
View file @
b8c065c5
...
@@ -320,3 +320,9 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -320,3 +320,9 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
2 DERIVED t2 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
2 DERIVED t2 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
drop table t2;
drop table t2;
CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`));
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;
min max avg
10.00 10.00 10
DROP TABLE t1;
mysql-test/t/derived.test
View file @
b8c065c5
...
@@ -188,7 +188,6 @@ INSERT INTO t3 VALUES (1000,0.00),(1001,0.25),(1002,0.50),(1003,0.75),(1008,1.00
...
@@ -188,7 +188,6 @@ INSERT INTO t3 VALUES (1000,0.00),(1001,0.25),(1002,0.50),(1003,0.75),(1008,1.00
select
497
,
TMP
.
ID
,
NULL
from
(
select
497
as
ID
,
MAX
(
t3
.
DATA
)
as
DATA
from
t1
join
t2
on
(
t1
.
ObjectID
=
t2
.
ID
)
join
t3
on
(
t1
.
ObjectID
=
t3
.
ID
)
group
by
t2
.
ParID
order
by
DATA
DESC
)
as
TMP
;
select
497
,
TMP
.
ID
,
NULL
from
(
select
497
as
ID
,
MAX
(
t3
.
DATA
)
as
DATA
from
t1
join
t2
on
(
t1
.
ObjectID
=
t2
.
ID
)
join
t3
on
(
t1
.
ObjectID
=
t3
.
ID
)
group
by
t2
.
ParID
order
by
DATA
DESC
)
as
TMP
;
drop
table
t1
,
t2
,
t3
;
drop
table
t1
,
t2
,
t3
;
#
#
# explain derived
# explain derived
#
#
...
@@ -206,3 +205,11 @@ insert into t2 values (1,7),(2,7);
...
@@ -206,3 +205,11 @@ insert into t2 values (1,7),(2,7);
explain
select
a
from
t2
where
a
>
1
;
explain
select
a
from
t2
where
a
>
1
;
explain
select
a
from
(
select
a
from
t2
where
a
>
1
)
tt
;
explain
select
a
from
(
select
a
from
t2
where
a
>
1
)
tt
;
drop
table
t2
;
drop
table
t2
;
#
# select list counter
#
CREATE
TABLE
`t1`
(
`itemid`
int
(
11
)
NOT
NULL
default
'0'
,
`grpid`
varchar
(
15
)
NOT
NULL
default
''
,
`vendor`
int
(
11
)
NOT
NULL
default
'0'
,
`date_`
date
NOT
NULL
default
'0000-00-00'
,
`price`
decimal
(
12
,
2
)
NOT
NULL
default
'0.00'
,
PRIMARY
KEY
(
`itemid`
,
`grpid`
,
`vendor`
,
`date_`
),
KEY
`itemid`
(
`itemid`
,
`vendor`
),
KEY
`itemid_2`
(
`itemid`
,
`date_`
));
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
;
sql/sql_yacc.yy
View file @
b8c065c5
...
@@ -3249,8 +3249,13 @@ select_derived:
...
@@ -3249,8 +3249,13 @@ select_derived:
YYABORT;
YYABORT;
mysql_init_select(lex);
mysql_init_select(lex);
lex->current_select->linkage= DERIVED_TABLE_TYPE;
lex->current_select->linkage= DERIVED_TABLE_TYPE;
lex->current_select->parsing_place= SELECT_LEX_NODE::SELECT_LIST;
}
select_options select_item_list
{
Select->parsing_place= SELECT_LEX_NODE::NO_MATTER;
}
}
select_options select_item_list
opt_select_from union_opt
opt_select_from union_opt
;
;
opt_outer:
opt_outer:
...
...
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