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
7e446b83
Commit
7e446b83
authored
Aug 27, 2004
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Item name for VIEW added to find_field_in_table (BUG#5147)
parent
b836d2dd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
14 deletions
+54
-14
mysql-test/r/view.result
mysql-test/r/view.result
+15
-0
mysql-test/t/view.test
mysql-test/t/view.test
+15
-0
sql/mysql_priv.h
sql/mysql_priv.h
+7
-5
sql/sql_acl.cc
sql/sql_acl.cc
+1
-0
sql/sql_base.cc
sql/sql_base.cc
+16
-9
No files found.
mysql-test/r/view.result
View file @
7e446b83
...
...
@@ -1151,3 +1151,18 @@ avg(vg_column)
0.0000
drop view v1;
drop table t1;
create table t1 (col1 bigint not null, primary key (col1));
create table t2 (col1 bigint not null, key (col1));
create view v1 as select * from t1;
create view v2 as select * from t2;
insert into v1 values (1);
insert into v2 values (1);
create view v3 (a,b) as select v1.col1 as a, v2.col1 as b from v1, v2 where v1.col1 = v2.col1;
select * from v3;
a b
1 1
show create view v3;
Table Create Table
v3 CREATE VIEW `test`.`v3` AS select `v1`.`col1` AS `a`,`v2`.`col1` AS `b` from `test`.`v1` join `test`.`v2` where (`v1`.`col1` = `v2`.`col1`)
drop view v3, v2, v1;
drop table t2, t1;
mysql-test/t/view.test
View file @
7e446b83
...
...
@@ -1091,3 +1091,18 @@ create view v1 as select count(tg_column) as vg_column from t1;
select
avg
(
vg_column
)
from
v1
;
drop
view
v1
;
drop
table
t1
;
#
# VIEW of VIEW with column renaming
#
create
table
t1
(
col1
bigint
not
null
,
primary
key
(
col1
));
create
table
t2
(
col1
bigint
not
null
,
key
(
col1
));
create
view
v1
as
select
*
from
t1
;
create
view
v2
as
select
*
from
t2
;
insert
into
v1
values
(
1
);
insert
into
v2
values
(
1
);
create
view
v3
(
a
,
b
)
as
select
v1
.
col1
as
a
,
v2
.
col1
as
b
from
v1
,
v2
where
v1
.
col1
=
v2
.
col1
;
select
*
from
v3
;
show
create
view
v3
;
drop
view
v3
,
v2
,
v1
;
drop
table
t2
,
t1
;
sql/mysql_priv.h
View file @
7e446b83
...
...
@@ -632,11 +632,13 @@ extern const Field *view_ref_found;
Field
*
find_field_in_tables
(
THD
*
thd
,
Item_ident
*
item
,
TABLE_LIST
*
tables
,
Item
**
ref
,
bool
report_error
,
bool
check_privileges
);
Field
*
find_field_in_table
(
THD
*
thd
,
TABLE_LIST
*
tables
,
const
char
*
name
,
uint
length
,
Item
**
ref
,
bool
check_grant_table
,
bool
check_grant_view
,
bool
allow_rowid
,
uint
*
cached_field_index_ptr
);
Field
*
find_field_in_table
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
const
char
*
name
,
const
char
*
item_name
,
uint
length
,
Item
**
ref
,
bool
check_grants_table
,
bool
check_grants_view
,
bool
allow_rowid
,
uint
*
cached_field_index_ptr
);
#ifdef HAVE_OPENSSL
#include <openssl/des.h>
struct
st_des_keyblock
...
...
sql/sql_acl.cc
View file @
7e446b83
...
...
@@ -2310,6 +2310,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
{
uint
unused_field_idx
=
NO_CACHED_FIELD_INDEX
;
if
(
!
find_field_in_table
(
thd
,
table_list
,
column
->
column
.
ptr
(),
column
->
column
.
ptr
(),
column
->
column
.
length
(),
0
,
0
,
0
,
0
,
&
unused_field_idx
))
{
...
...
sql/sql_base.cc
View file @
7e446b83
...
...
@@ -1924,6 +1924,7 @@ const Field *view_ref_found= (Field*) 0x2;
thd thread handler
table_list table where to find
name name of field
item_name name of item if it will be created (VIEW)
length length of name
ref expression substituted in VIEW should be
passed using this reference (return
...
...
@@ -1940,11 +1941,13 @@ const Field *view_ref_found= (Field*) 0x2;
# pointer to field
*/
Field
*
find_field_in_table
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
const
char
*
name
,
uint
length
,
Item
**
ref
,
bool
check_grants_table
,
bool
check_grants_view
,
bool
allow_rowid
,
uint
*
cached_field_index_ptr
)
Field
*
find_field_in_table
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
const
char
*
name
,
const
char
*
item_name
,
uint
length
,
Item
**
ref
,
bool
check_grants_table
,
bool
check_grants_view
,
bool
allow_rowid
,
uint
*
cached_field_index_ptr
)
{
Field
*
fld
;
if
(
table_list
->
field_translation
)
...
...
@@ -1972,7 +1975,7 @@ Field *find_field_in_table(THD *thd, TABLE_LIST *table_list,
if
(
arena
)
thd
->
set_n_backup_item_arena
(
arena
,
&
backup
);
*
ref
=
new
Item_ref
(
trans
+
i
,
0
,
table_list
->
view_name
.
str
,
name
);
item_
name
);
if
(
arena
)
thd
->
restore_backup_item_arena
(
arena
,
&
backup
);
/* as far as Item_ref have defined refernce it do not need tables */
...
...
@@ -2163,7 +2166,8 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
(
!
db
||
!
tables
->
db
||
!
tables
->
db
[
0
]
||
!
strcmp
(
db
,
tables
->
db
)))
{
found_table
=
1
;
Field
*
find
=
find_field_in_table
(
thd
,
tables
,
name
,
length
,
ref
,
Field
*
find
=
find_field_in_table
(
thd
,
tables
,
name
,
item
->
name
,
length
,
ref
,
(
test
(
tables
->
table
->
grant
.
want_privilege
)
&&
check_privileges
),
...
...
@@ -2226,7 +2230,8 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
return
(
Field
*
)
not_found_field
;
}
Field
*
field
=
find_field_in_table
(
thd
,
tables
,
name
,
length
,
ref
,
Field
*
field
=
find_field_in_table
(
thd
,
tables
,
name
,
item
->
name
,
length
,
ref
,
(
test
(
tables
->
table
->
grant
.
want_privilege
)
&&
check_privileges
),
...
...
@@ -2683,7 +2688,8 @@ insert_fields(THD *thd, TABLE_LIST *tables, const char *db_name,
const
char
*
field_name
=
iterator
->
name
();
/* Skip duplicate field names if NATURAL JOIN is used */
if
(
!
natural_join_table
||
!
find_field_in_table
(
thd
,
natural_join_table
,
field_name
,
!
find_field_in_table
(
thd
,
natural_join_table
,
field_name
,
field_name
,
strlen
(
field_name
),
&
not_used_item
,
0
,
0
,
0
,
&
not_used_field_index
))
{
...
...
@@ -2890,6 +2896,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
uint
not_used_field_index
=
NO_CACHED_FIELD_INDEX
;
if
((
t2_field
=
find_field_in_table
(
thd
,
tab2
,
t1_field_name
,
t1_field_name
,
strlen
(
t1_field_name
),
&
item_t2
,
0
,
0
,
0
,
&
not_used_field_index
)))
...
...
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