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
5b1e1eea
Commit
5b1e1eea
authored
Jul 05, 2007
by
igor@olga.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug29392
parents
0b00ebbb
4c02004d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
0 deletions
+108
-0
mysql-test/r/view.result
mysql-test/r/view.result
+47
-0
mysql-test/t/view.test
mysql-test/t/view.test
+55
-0
sql/item.h
sql/item.h
+6
-0
No files found.
mysql-test/r/view.result
View file @
5b1e1eea
...
...
@@ -3500,4 +3500,51 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (
person_id int NOT NULL PRIMARY KEY,
username varchar(40) default NULL,
status_flg char(1) NOT NULL default 'A'
);
CREATE TABLE t2 (
person_role_id int NOT NULL auto_increment PRIMARY KEY,
role_id int NOT NULL,
person_id int NOT NULL,
INDEX idx_person_id (person_id),
INDEX idx_role_id (role_id)
);
CREATE TABLE t3 (
role_id int NOT NULL auto_increment PRIMARY KEY,
role_name varchar(100) default NULL,
app_name varchar(40) NOT NULL,
INDEX idx_app_name(app_name)
);
CREATE VIEW v1 AS
SELECT profile.person_id AS person_id
FROM t1 profile, t2 userrole, t3 role
WHERE userrole.person_id = profile.person_id AND
role.role_id = userrole.role_id AND
profile.status_flg = 'A'
ORDER BY profile.person_id,role.app_name,role.role_name;
INSERT INTO t1 VALUES
(6,'Sw','A'), (-1136332546,'ols','e'), (0,' *\n','0'),
(-717462680,'ENTS Ta','0'), (-904346964,'ndard SQL\n','0');
INSERT INTO t2 VALUES
(1,3,6),(2,4,7),(3,5,8),(4,6,9),(5,1,6),(6,1,7),(7,1,8),(8,1,9),(9,1,10);
INSERT INTO t3 VALUES
(1,'NUCANS_APP_USER','NUCANSAPP'),(2,'NUCANS_TRGAPP_USER','NUCANSAPP'),
(3,'IA_INTAKE_COORDINATOR','IACANS'),(4,'IA_SCREENER','IACANS'),
(5,'IA_SUPERVISOR','IACANS'),(6,'IA_READONLY','IACANS'),
(7,'SOC_USER','SOCCANS'),(8,'CAYIT_USER','CAYITCANS'),
(9,'RTOS_DCFSPOS_SUPERVISOR','RTOS');
EXPLAIN SELECT t.person_id AS a, t.person_id AS b FROM v1 t WHERE t.person_id=6;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE profile const PRIMARY PRIMARY 4 const 1 Using temporary; Using filesort
1 SIMPLE userrole ref idx_person_id,idx_role_id idx_person_id 4 const 2
1 SIMPLE role eq_ref PRIMARY PRIMARY 4 test.userrole.role_id 1
SELECT t.person_id AS a, t.person_id AS b FROM v1 t WHERE t.person_id=6;
a b
6 6
6 6
DROP VIEW v1;
DROP TABLE t1,t2,t3;
End of 5.0 tests.
mysql-test/t/view.test
View file @
5b1e1eea
...
...
@@ -3348,4 +3348,59 @@ EXPLAIN SELECT a, SUM(b) FROM v1 WHERE a=1 GROUP BY a;
DROP
VIEW
v1
;
DROP
TABLE
t1
;
#
# Bug #29392: SELECT over a multi-table view with ORDER BY
# selecting the same view column with two different aliases
#
CREATE
TABLE
t1
(
person_id
int
NOT
NULL
PRIMARY
KEY
,
username
varchar
(
40
)
default
NULL
,
status_flg
char
(
1
)
NOT
NULL
default
'A'
);
CREATE
TABLE
t2
(
person_role_id
int
NOT
NULL
auto_increment
PRIMARY
KEY
,
role_id
int
NOT
NULL
,
person_id
int
NOT
NULL
,
INDEX
idx_person_id
(
person_id
),
INDEX
idx_role_id
(
role_id
)
);
CREATE
TABLE
t3
(
role_id
int
NOT
NULL
auto_increment
PRIMARY
KEY
,
role_name
varchar
(
100
)
default
NULL
,
app_name
varchar
(
40
)
NOT
NULL
,
INDEX
idx_app_name
(
app_name
)
);
CREATE
VIEW
v1
AS
SELECT
profile
.
person_id
AS
person_id
FROM
t1
profile
,
t2
userrole
,
t3
role
WHERE
userrole
.
person_id
=
profile
.
person_id
AND
role
.
role_id
=
userrole
.
role_id
AND
profile
.
status_flg
=
'A'
ORDER
BY
profile
.
person_id
,
role
.
app_name
,
role
.
role_name
;
INSERT
INTO
t1
VALUES
(
6
,
'Sw'
,
'A'
),
(
-
1136332546
,
'ols'
,
'e'
),
(
0
,
' *\n'
,
'0'
),
(
-
717462680
,
'ENTS Ta'
,
'0'
),
(
-
904346964
,
'ndard SQL\n'
,
'0'
);
INSERT
INTO
t2
VALUES
(
1
,
3
,
6
),(
2
,
4
,
7
),(
3
,
5
,
8
),(
4
,
6
,
9
),(
5
,
1
,
6
),(
6
,
1
,
7
),(
7
,
1
,
8
),(
8
,
1
,
9
),(
9
,
1
,
10
);
INSERT
INTO
t3
VALUES
(
1
,
'NUCANS_APP_USER'
,
'NUCANSAPP'
),(
2
,
'NUCANS_TRGAPP_USER'
,
'NUCANSAPP'
),
(
3
,
'IA_INTAKE_COORDINATOR'
,
'IACANS'
),(
4
,
'IA_SCREENER'
,
'IACANS'
),
(
5
,
'IA_SUPERVISOR'
,
'IACANS'
),(
6
,
'IA_READONLY'
,
'IACANS'
),
(
7
,
'SOC_USER'
,
'SOCCANS'
),(
8
,
'CAYIT_USER'
,
'CAYITCANS'
),
(
9
,
'RTOS_DCFSPOS_SUPERVISOR'
,
'RTOS'
);
EXPLAIN
SELECT
t
.
person_id
AS
a
,
t
.
person_id
AS
b
FROM
v1
t
WHERE
t
.
person_id
=
6
;
SELECT
t
.
person_id
AS
a
,
t
.
person_id
AS
b
FROM
v1
t
WHERE
t
.
person_id
=
6
;
DROP
VIEW
v1
;
DROP
TABLE
t1
,
t2
,
t3
;
--
echo
End
of
5.0
tests
.
sql/item.h
View file @
5b1e1eea
...
...
@@ -1989,6 +1989,12 @@ class Item_direct_view_ref :public Item_direct_ref
bool
fix_fields
(
THD
*
,
Item
**
);
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
;
Item
*
get_tmp_table_item
(
THD
*
thd
)
{
Item
*
item
=
Item_ref
::
get_tmp_table_item
(
thd
);
item
->
name
=
name
;
return
item
;
}
virtual
Ref_Type
ref_type
()
{
return
VIEW_REF
;
}
};
...
...
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