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
44beb247
Commit
44beb247
authored
Nov 28, 2008
by
Gleb Shchepa
Browse files
Options
Browse Files
Download
Plain Diff
manual merge 5.0-bugteam --> 5.1-bugteam (bug 33461)
parents
c762d934
228c913e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
10 deletions
+62
-10
mysql-test/r/view.result
mysql-test/r/view.result
+29
-4
mysql-test/t/view.test
mysql-test/t/view.test
+30
-4
sql/sql_view.cc
sql/sql_view.cc
+3
-2
No files found.
mysql-test/r/view.result
View file @
44beb247
...
@@ -625,7 +625,7 @@ drop table t1;
...
@@ -625,7 +625,7 @@ drop table t1;
create table t1 (a int, b int);
create table t1 (a int, b int);
create view v1 as select a, sum(b) from t1 group by a;
create view v1 as select a, sum(b) from t1 group by a;
select b from v1 use index (some_index) where b=1;
select b from v1 use index (some_index) where b=1;
ERROR
HY000: Incorrect usage of index hints and VIEW
ERROR
42000: Key 'some_index' doesn't exist in table 'v1'
drop view v1;
drop view v1;
drop table t1;
drop table t1;
create table t1 (col1 char(5),col2 char(5));
create table t1 (col1 char(5),col2 char(5));
...
@@ -3562,11 +3562,11 @@ CREATE TABLE t1 (a INT);
...
@@ -3562,11 +3562,11 @@ CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
INSERT INTO t1 VALUES (1),(2);
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT * FROM v1 USE KEY(non_existant);
SELECT * FROM v1 USE KEY(non_existant);
ERROR
HY000: Incorrect usage of index hints and VIEW
ERROR
42000: Key 'non_existant' doesn't exist in table 'v1'
SELECT * FROM v1 FORCE KEY(non_existant);
SELECT * FROM v1 FORCE KEY(non_existant);
ERROR
HY000: Incorrect usage of index hints and VIEW
ERROR
42000: Key 'non_existant' doesn't exist in table 'v1'
SELECT * FROM v1 IGNORE KEY(non_existant);
SELECT * FROM v1 IGNORE KEY(non_existant);
ERROR
HY000: Incorrect usage of index hints and VIEW
ERROR
42000: Key 'non_existant' doesn't exist in table 'v1'
DROP VIEW v1;
DROP VIEW v1;
DROP TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL DEFAULT 0,
CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL DEFAULT 0,
...
@@ -3674,6 +3674,31 @@ DROP VIEW v1;
...
@@ -3674,6 +3674,31 @@ DROP VIEW v1;
CREATE VIEW v1 AS SELECT 1;
CREATE VIEW v1 AS SELECT 1;
DROP VIEW v1;
DROP VIEW v1;
CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, INDEX (c2));
INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
SELECT * FROM t1 USE INDEX (PRIMARY) WHERE c1=2;
c1 c2
2 2
SELECT * FROM t1 USE INDEX (c2) WHERE c2=2;
c1 c2
2 2
CREATE VIEW v1 AS SELECT c1, c2 FROM t1;
SHOW INDEX FROM v1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
SELECT * FROM v1 USE INDEX (PRIMARY) WHERE c1=2;
ERROR 42000: Key 'PRIMARY' doesn't exist in table 'v1'
SELECT * FROM v1 FORCE INDEX (PRIMARY) WHERE c1=2;
ERROR 42000: Key 'PRIMARY' doesn't exist in table 'v1'
SELECT * FROM v1 IGNORE INDEX (PRIMARY) WHERE c1=2;
ERROR 42000: Key 'PRIMARY' doesn't exist in table 'v1'
SELECT * FROM v1 USE INDEX (c2) WHERE c2=2;
ERROR 42000: Key 'c2' doesn't exist in table 'v1'
SELECT * FROM v1 FORCE INDEX (c2) WHERE c2=2;
ERROR 42000: Key 'c2' doesn't exist in table 'v1'
SELECT * FROM v1 IGNORE INDEX (c2) WHERE c2=2;
ERROR 42000: Key 'c2' doesn't exist in table 'v1'
DROP VIEW v1;
DROP TABLE t1;
# -----------------------------------------------------------------
# -----------------------------------------------------------------
# -- End of 5.0 tests.
# -- End of 5.0 tests.
# -----------------------------------------------------------------
# -----------------------------------------------------------------
...
...
mysql-test/t/view.test
View file @
44beb247
...
@@ -510,7 +510,7 @@ drop table t1;
...
@@ -510,7 +510,7 @@ drop table t1;
#
#
create
table
t1
(
a
int
,
b
int
);
create
table
t1
(
a
int
,
b
int
);
create
view
v1
as
select
a
,
sum
(
b
)
from
t1
group
by
a
;
create
view
v1
as
select
a
,
sum
(
b
)
from
t1
group
by
a
;
--
error
ER_
WRONG_USAGE
--
error
ER_
KEY_DOES_NOT_EXITS
select
b
from
v1
use
index
(some_index) where b=1
;
select
b
from
v1
use
index
(some_index) where b=1
;
drop
view
v1
;
drop
view
v1
;
drop
table
t1
;
drop
table
t1
;
...
@@ -3421,11 +3421,11 @@ drop table t1;
...
@@ -3421,11 +3421,11 @@ drop table t1;
CREATE
TABLE
t1
(
a
INT
);
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
1
),(
2
);
INSERT
INTO
t1
VALUES
(
1
),(
2
);
CREATE
VIEW
v1
AS
SELECT
*
FROM
t1
;
CREATE
VIEW
v1
AS
SELECT
*
FROM
t1
;
--
error
ER_
WRONG_USAGE
--
error
ER_
KEY_DOES_NOT_EXITS
SELECT
*
FROM
v1
USE
KEY
(non_existant)
;
SELECT
*
FROM
v1
USE
KEY
(non_existant)
;
--
error
ER_
WRONG_USAGE
--
error
ER_
KEY_DOES_NOT_EXITS
SELECT
*
FROM
v1
FORCE
KEY
(
non_existant
);
SELECT
*
FROM
v1
FORCE
KEY
(
non_existant
);
--
error
ER_
WRONG_USAGE
--
error
ER_
KEY_DOES_NOT_EXITS
SELECT
*
FROM
v1
IGNORE
KEY
(
non_existant
);
SELECT
*
FROM
v1
IGNORE
KEY
(
non_existant
);
DROP
VIEW
v1
;
DROP
VIEW
v1
;
...
@@ -3564,6 +3564,32 @@ DROP VIEW v1;
...
@@ -3564,6 +3564,32 @@ DROP VIEW v1;
CREATE
VIEW
v1
AS
SELECT
1
;
CREATE
VIEW
v1
AS
SELECT
1
;
DROP
VIEW
v1
;
DROP
VIEW
v1
;
#
# Bug #33461: SELECT ... FROM <view> USE INDEX (...) throws an error
#
CREATE
TABLE
t1
(
c1
INT
PRIMARY
KEY
,
c2
INT
,
INDEX
(
c2
));
INSERT
INTO
t1
VALUES
(
1
,
1
),
(
2
,
2
),
(
3
,
3
);
SELECT
*
FROM
t1
USE
INDEX
(PRIMARY) WHERE c1=2
;
SELECT
*
FROM
t1
USE
INDEX
(c2) WHERE c2=2
;
CREATE
VIEW
v1
AS
SELECT
c1
,
c2
FROM
t1
;
SHOW
INDEX
FROM
v1
;
--
error
ER_KEY_DOES_NOT_EXITS
SELECT
*
FROM
v1
USE
INDEX
(PRIMARY) WHERE c1=2
;
--
error
ER_KEY_DOES_NOT_EXITS
SELECT
*
FROM
v1
FORCE
INDEX
(
PRIMARY
)
WHERE
c1
=
2
;
--
error
ER_KEY_DOES_NOT_EXITS
SELECT
*
FROM
v1
IGNORE
INDEX
(
PRIMARY
)
WHERE
c1
=
2
;
--
error
ER_KEY_DOES_NOT_EXITS
SELECT
*
FROM
v1
USE
INDEX
(c2) WHERE c2=2
;
--
error
ER_KEY_DOES_NOT_EXITS
SELECT
*
FROM
v1
FORCE
INDEX
(
c2
)
WHERE
c2
=
2
;
--
error
ER_KEY_DOES_NOT_EXITS
SELECT
*
FROM
v1
IGNORE
INDEX
(
c2
)
WHERE
c2
=
2
;
DROP
VIEW
v1
;
DROP
TABLE
t1
;
--
echo
# -----------------------------------------------------------------
--
echo
# -----------------------------------------------------------------
--
echo
# -- End of 5.0 tests.
--
echo
# -- End of 5.0 tests.
...
...
sql/sql_view.cc
View file @
44beb247
...
@@ -1049,7 +1049,8 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
...
@@ -1049,7 +1049,8 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
if
(
table
->
index_hints
&&
table
->
index_hints
->
elements
)
if
(
table
->
index_hints
&&
table
->
index_hints
->
elements
)
{
{
my_error
(
ER_WRONG_USAGE
,
MYF
(
0
),
"index hints"
,
"VIEW"
);
my_error
(
ER_KEY_DOES_NOT_EXITS
,
MYF
(
0
),
table
->
index_hints
->
head
()
->
key_name
.
str
,
table
->
table_name
);
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
}
}
...
...
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