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
b8624674
Commit
b8624674
authored
Sep 18, 2004
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/dlenev/src/mysql-5.0-amf
parents
cee3d5c4
e95a75e5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
43 deletions
+80
-43
mysql-test/r/view.result
mysql-test/r/view.result
+23
-4
mysql-test/t/view.test
mysql-test/t/view.test
+28
-6
sql/item.h
sql/item.h
+3
-0
sql/item_strfunc.h
sql/item_strfunc.h
+5
-0
sql/sql_insert.cc
sql/sql_insert.cc
+2
-2
sql/sql_update.cc
sql/sql_update.cc
+3
-2
sql/sql_view.cc
sql/sql_view.cc
+16
-29
No files found.
mysql-test/r/view.result
View file @
b8624674
...
@@ -922,14 +922,17 @@ create table mysqltest.v3 (b int);
...
@@ -922,14 +922,17 @@ create table mysqltest.v3 (b int);
grant create view on mysqltest.v3 to mysqltest_1@localhost;
grant create view on mysqltest.v3 to mysqltest_1@localhost;
drop table mysqltest.v3;
drop table mysqltest.v3;
create view mysqltest.v3 as select b from mysqltest.t2;
create view mysqltest.v3 as select b from mysqltest.t2;
ERROR 42000: create view command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 'v3'
create table mysqltest.v3 (b int);
grant create view, update on mysqltest.v3 to mysqltest_1@localhost;
grant create view, update on mysqltest.v3 to mysqltest_1@localhost;
drop
table
mysqltest.v3;
drop
view
mysqltest.v3;
create view mysqltest.v3 as select b from mysqltest.t2;
create view mysqltest.v3 as select b from mysqltest.t2;
grant
select(b)
on mysqltest.v3 to mysqltest_1@localhost;
grant
create view, update, insert
on mysqltest.v3 to mysqltest_1@localhost;
drop view mysqltest.v3;
drop view mysqltest.v3;
create view mysqltest.v3 as select b from mysqltest.t2;
create view mysqltest.v3 as select b from mysqltest.t2;
ERROR 42000: create view command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 'v3'
create table mysqltest.v3 (b int);
grant select(b) on mysqltest.v3 to mysqltest_1@localhost;
drop table mysqltest.v3;
create view mysqltest.v3 as select b from mysqltest.t2;
ERROR 42000: create view command denied to user 'mysqltest_1'@'localhost' for table 'v3'
ERROR 42000: create view command denied to user 'mysqltest_1'@'localhost' for table 'v3'
create view v4 as select b+1 from mysqltest.t2;
create view v4 as select b+1 from mysqltest.t2;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2'
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2'
...
@@ -1311,3 +1314,19 @@ a a a
...
@@ -1311,3 +1314,19 @@ a a a
3 3 3
3 3 3
drop view v1;
drop view v1;
drop table t1;
drop table t1;
create table t1 (s1 char);
create view v1 as select s1 collate latin1_german1_ci as s1 from t1;
insert into v1 values ('a');
select * from v1;
s1
a
update v1 set s1='b';
select * from v1;
s1
b
update v1,t1 set v1.s1='c' where t1.s1=v1.s1;
select * from v1;
s1
c
drop view v1;
drop table t1;
mysql-test/t/view.test
View file @
b8624674
...
@@ -804,29 +804,37 @@ create view mysqltest.v1 as select * from mysqltest.t1;
...
@@ -804,29 +804,37 @@ create view mysqltest.v1 as select * from mysqltest.t1;
--
error
1143
--
error
1143
create
view
v3
as
select
a
from
mysqltest
.
t2
;
create
view
v3
as
select
a
from
mysqltest
.
t2
;
# give CRETEA VIEW privileges
but without any privileges for result colemn
# give CRETEA VIEW privileges
(without any privileges for result colemn)
connection
root
;
connection
root
;
create
table
mysqltest
.
v3
(
b
int
);
create
table
mysqltest
.
v3
(
b
int
);
grant
create
view
on
mysqltest
.
v3
to
mysqltest_1
@
localhost
;
grant
create
view
on
mysqltest
.
v3
to
mysqltest_1
@
localhost
;
drop
table
mysqltest
.
v3
;
drop
table
mysqltest
.
v3
;
connection
user1
;
connection
user1
;
--
error
1143
create
view
mysqltest
.
v3
as
select
b
from
mysqltest
.
t2
;
create
view
mysqltest
.
v3
as
select
b
from
mysqltest
.
t2
;
# give UPDATE privileges
-> create works
# give UPDATE privileges
connection
root
;
connection
root
;
create
table
mysqltest
.
v3
(
b
int
);
grant
create
view
,
update
on
mysqltest
.
v3
to
mysqltest_1
@
localhost
;
grant
create
view
,
update
on
mysqltest
.
v3
to
mysqltest_1
@
localhost
;
drop
table
mysqltest
.
v3
;
drop
view
mysqltest
.
v3
;
connection
user1
;
connection
user1
;
create
view
mysqltest
.
v3
as
select
b
from
mysqltest
.
t2
;
create
view
mysqltest
.
v3
as
select
b
from
mysqltest
.
t2
;
# give UPDATE and INSERT privilege (to get more privileges then anderlying
# table)
connection
root
;
grant
create
view
,
update
,
insert
on
mysqltest
.
v3
to
mysqltest_1
@
localhost
;
drop
view
mysqltest
.
v3
;
connection
user1
;
--
error
1143
create
view
mysqltest
.
v3
as
select
b
from
mysqltest
.
t2
;
# If give other privileges for VIEW then underlaying table have =>
# If give other privileges for VIEW then underlaying table have =>
# creation prohibited
# creation prohibited
connection
root
;
connection
root
;
create
table
mysqltest
.
v3
(
b
int
);
grant
select
(
b
)
on
mysqltest
.
v3
to
mysqltest_1
@
localhost
;
grant
select
(
b
)
on
mysqltest
.
v3
to
mysqltest_1
@
localhost
;
drop
view
mysqltest
.
v3
;
drop
table
mysqltest
.
v3
;
connection
user1
;
connection
user1
;
--
error
1142
--
error
1142
create
view
mysqltest
.
v3
as
select
b
from
mysqltest
.
t2
;
create
view
mysqltest
.
v3
as
select
b
from
mysqltest
.
t2
;
...
@@ -1271,3 +1279,17 @@ select * from t1 left join (t2 as t, v1) on v1.a=t1.a;
...
@@ -1271,3 +1279,17 @@ select * from t1 left join (t2 as t, v1) on v1.a=t1.a;
select
*
from
t1
left
join
(
t2
as
t
,
t2
)
on
t2
.
a
=
t1
.
a
;
select
*
from
t1
left
join
(
t2
as
t
,
t2
)
on
t2
.
a
=
t1
.
a
;
drop
view
v1
;
drop
view
v1
;
drop
table
t1
;
drop
table
t1
;
#
# Collation with view update
#
create
table
t1
(
s1
char
);
create
view
v1
as
select
s1
collate
latin1_german1_ci
as
s1
from
t1
;
insert
into
v1
values
(
'a'
);
select
*
from
v1
;
update
v1
set
s1
=
'b'
;
select
*
from
v1
;
update
v1
,
t1
set
v1
.
s1
=
'c'
where
t1
.
s1
=
v1
.
s1
;
select
*
from
v1
;
drop
view
v1
;
drop
table
t1
;
sql/item.h
View file @
b8624674
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
class
Protocol
;
class
Protocol
;
struct
st_table_list
;
struct
st_table_list
;
void
item_init
(
void
);
/* Init item functions */
void
item_init
(
void
);
/* Init item functions */
class
Item_field
;
/*
/*
...
@@ -277,6 +278,7 @@ class Item {
...
@@ -277,6 +278,7 @@ class Item {
virtual
void
bring_value
()
{}
virtual
void
bring_value
()
{}
Field
*
tmp_table_field_from_field_type
(
TABLE
*
table
);
Field
*
tmp_table_field_from_field_type
(
TABLE
*
table
);
virtual
Item_field
*
filed_for_view_update
()
{
return
0
;
}
virtual
Item
*
neg_transformer
(
THD
*
thd
)
{
return
NULL
;
}
virtual
Item
*
neg_transformer
(
THD
*
thd
)
{
return
NULL
;
}
void
delete_self
()
void
delete_self
()
...
@@ -497,6 +499,7 @@ class Item_field :public Item_ident
...
@@ -497,6 +499,7 @@ class Item_field :public Item_ident
Item
*
get_tmp_table_item
(
THD
*
thd
);
Item
*
get_tmp_table_item
(
THD
*
thd
);
void
cleanup
();
void
cleanup
();
inline
uint32
max_disp_length
()
{
return
field
->
max_length
();
}
inline
uint32
max_disp_length
()
{
return
field
->
max_length
();
}
Item_field
*
filed_for_view_update
()
{
return
this
;
}
friend
class
Item_default_value
;
friend
class
Item_default_value
;
friend
class
Item_insert_value
;
friend
class
Item_insert_value
;
friend
class
st_select_lex_unit
;
friend
class
st_select_lex_unit
;
...
...
sql/item_strfunc.h
View file @
b8624674
...
@@ -636,6 +636,11 @@ class Item_func_set_collation :public Item_str_func
...
@@ -636,6 +636,11 @@ class Item_func_set_collation :public Item_str_func
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
;
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
;
const
char
*
func_name
()
const
{
return
"collate"
;
}
const
char
*
func_name
()
const
{
return
"collate"
;
}
void
print
(
String
*
str
);
void
print
(
String
*
str
);
Item_field
*
filed_for_view_update
()
{
/* this function is transparent for view updating */
return
args
[
0
]
->
filed_for_view_update
();
}
};
};
class
Item_func_charset
:
public
Item_str_func
class
Item_func_charset
:
public
Item_str_func
...
...
sql/sql_insert.cc
View file @
b8624674
...
@@ -490,13 +490,13 @@ static bool check_view_insertability(TABLE_LIST *view, ulong query_id)
...
@@ -490,13 +490,13 @@ static bool check_view_insertability(TABLE_LIST *view, ulong query_id)
{
{
Item_field
*
field
;
Item_field
*
field
;
/* simple SELECT list entry (field without expression) */
/* simple SELECT list entry (field without expression) */
if
(
(
*
trans
)
->
type
()
!=
Item
::
FIELD_ITEM
)
if
(
!
(
field
=
(
*
trans
)
->
filed_for_view_update
())
)
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
field
=
(
Item_field
*
)(
*
trans
);
if
(
field
->
field
->
unireg_check
==
Field
::
NEXT_NUMBER
)
if
(
field
->
field
->
unireg_check
==
Field
::
NEXT_NUMBER
)
view
->
contain_auto_increment
=
1
;
view
->
contain_auto_increment
=
1
;
/* prepare unique test */
/* prepare unique test */
field
->
field
->
query_id
=
other_query_id
;
field
->
field
->
query_id
=
other_query_id
;
*
trans
=
field
;
// remove collation if we have it
}
}
/* unique test */
/* unique test */
for
(
trans
=
trans_start
;
trans
!=
trans_end
;
trans
++
)
for
(
trans
=
trans_start
;
trans
!=
trans_end
;
trans
++
)
...
...
sql/sql_update.cc
View file @
b8624674
...
@@ -67,9 +67,10 @@ static bool check_fields(THD *thd, List<Item> &items)
...
@@ -67,9 +67,10 @@ static bool check_fields(THD *thd, List<Item> &items)
{
{
List_iterator
<
Item
>
it
(
items
);
List_iterator
<
Item
>
it
(
items
);
Item
*
item
;
Item
*
item
;
Item_field
*
field
;
while
((
item
=
it
++
))
while
((
item
=
it
++
))
{
{
if
(
item
->
type
()
!=
Item
::
FIELD_ITEM
)
if
(
!
(
field
=
item
->
filed_for_view_update
())
)
{
{
/* as far as item comes from VIEW select list it has name */
/* as far as item comes from VIEW select list it has name */
my_error
(
ER_NONUPDATEABLE_COLUMN
,
MYF
(
0
),
item
->
name
);
my_error
(
ER_NONUPDATEABLE_COLUMN
,
MYF
(
0
),
item
->
name
);
...
@@ -79,7 +80,7 @@ static bool check_fields(THD *thd, List<Item> &items)
...
@@ -79,7 +80,7 @@ static bool check_fields(THD *thd, List<Item> &items)
we make temporary copy of Item_field, to avoid influence of changing
we make temporary copy of Item_field, to avoid influence of changing
result_field on Item_ref which refer on this field
result_field on Item_ref which refer on this field
*/
*/
Item_field
*
field
=
new
Item_field
(
thd
,
(
Item_field
*
)
item
);
field
=
new
Item_field
(
thd
,
field
);
it
.
replace
(
field
);
it
.
replace
(
field
);
((
Item_field
*
)
item
)
->
register_item_tree_changing
(
it
.
ref
());
((
Item_field
*
)
item
)
->
register_item_tree_changing
(
it
.
ref
());
}
}
...
...
sql/sql_view.cc
View file @
b8624674
...
@@ -148,8 +148,9 @@ int mysql_create_view(THD *thd,
...
@@ -148,8 +148,9 @@ int mysql_create_view(THD *thd,
Item
*
item
;
Item
*
item
;
while
((
item
=
it
++
))
while
((
item
=
it
++
))
{
{
if
(
item
->
type
()
==
Item
::
FIELD_ITEM
)
Item_field
*
field
;
((
Item_field
*
)
item
)
->
any_privileges
=
1
;
if
((
field
=
item
->
filed_for_view_update
()))
field
->
any_privileges
=
1
;
}
}
}
}
#endif
#endif
...
@@ -237,17 +238,16 @@ int mysql_create_view(THD *thd,
...
@@ -237,17 +238,16 @@ int mysql_create_view(THD *thd,
view
->
real_name
);
view
->
real_name
);
while
((
item
=
it
++
))
while
((
item
=
it
++
))
{
{
Item_field
*
fld
;
uint
priv
=
(
get_column_grant
(
thd
,
&
view
->
grant
,
db
,
uint
priv
=
(
get_column_grant
(
thd
,
&
view
->
grant
,
db
,
view
->
real_name
,
item
->
name
)
&
view
->
real_name
,
item
->
name
)
&
VIEW_ANY_ACL
);
VIEW_ANY_ACL
);
if
(
item
->
type
()
==
Item
::
FIELD_ITEM
)
if
(
(
fld
=
item
->
filed_for_view_update
())
)
{
{
Item_field
*
fld
=
(
Item_field
*
)
item
;
/*
/*
There are no any privileges on VIEW column or there are
Do we have more privilegeson view field then underlying table field
some other privileges then we have for underlaying table
*/
*/
if
(
priv
==
0
||
(
~
fld
->
have_privileges
&
priv
))
if
((
~
fld
->
have_privileges
&
priv
))
{
{
/* VIEW column has more privileges */
/* VIEW column has more privileges */
my_printf_error
(
ER_COLUMNACCESS_DENIED_ERROR
,
my_printf_error
(
ER_COLUMNACCESS_DENIED_ERROR
,
...
@@ -261,22 +261,6 @@ int mysql_create_view(THD *thd,
...
@@ -261,22 +261,6 @@ int mysql_create_view(THD *thd,
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
}
}
}
}
else
{
if
(
!
(
priv
&
SELECT_ACL
))
{
/* user have not privilege to SELECT expression */
my_printf_error
(
ER_COLUMNACCESS_DENIED_ERROR
,
ER
(
ER_COLUMNACCESS_DENIED_ERROR
),
MYF
(
0
),
"select"
,
thd
->
priv_user
,
thd
->
host_or_ip
,
item
->
name
,
view
->
real_name
);
DBUG_RETURN
(
-
1
);
}
}
}
}
}
}
#endif
#endif
...
@@ -903,8 +887,9 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view)
...
@@ -903,8 +887,9 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view)
uint
k
;
uint
k
;
for
(
k
=
0
;
k
<
elements_in_view
;
k
++
)
for
(
k
=
0
;
k
<
elements_in_view
;
k
++
)
{
{
if
(
trans
[
k
]
->
type
()
==
Item
::
FIELD_ITEM
&&
Item_field
*
field
;
((
Item_field
*
)
trans
[
k
])
->
field
==
key_part
->
field
)
if
((
field
=
trans
[
k
]
->
filed_for_view_update
())
&&
field
->
field
==
key_part
->
field
)
break
;
break
;
}
}
if
(
k
==
elements_in_view
)
if
(
k
==
elements_in_view
)
...
@@ -923,8 +908,9 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view)
...
@@ -923,8 +908,9 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view)
{
{
for
(
i
=
0
;
i
<
elements_in_view
;
i
++
)
for
(
i
=
0
;
i
<
elements_in_view
;
i
++
)
{
{
if
(
trans
[
i
]
->
type
()
==
Item
::
FIELD_ITEM
&&
Item_field
*
field
;
((
Item_field
*
)
trans
[
i
])
->
field
==
*
field_ptr
)
if
((
field
=
trans
[
i
]
->
filed_for_view_update
())
&&
field
->
field
==
*
field_ptr
)
break
;
break
;
}
}
if
(
i
==
elements_in_view
)
// If field didn't exists
if
(
i
==
elements_in_view
)
// If field didn't exists
...
@@ -976,8 +962,9 @@ void insert_view_fields(List<Item> *list, TABLE_LIST *view)
...
@@ -976,8 +962,9 @@ void insert_view_fields(List<Item> *list, TABLE_LIST *view)
for
(
uint
i
=
0
;
i
<
elements_in_view
;
i
++
)
for
(
uint
i
=
0
;
i
<
elements_in_view
;
i
++
)
{
{
if
(
trans
[
i
]
->
type
()
==
Item
::
FIELD_ITEM
)
Item_field
*
fld
;
list
->
push_back
(
trans
[
i
]);
if
((
fld
=
trans
[
i
]
->
filed_for_view_update
()))
list
->
push_back
(
fld
);
}
}
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
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