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
2eee0e9b
Commit
2eee0e9b
authored
Oct 19, 2023
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: mainly formatting, plus one helper
parent
1fe4a71b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
74 additions
and
90 deletions
+74
-90
mysql-test/main/information_schema_db.result
mysql-test/main/information_schema_db.result
+20
-4
mysql-test/main/information_schema_db.test
mysql-test/main/information_schema_db.test
+21
-27
mysql-test/suite/funcs_1/r/is_table_constraints.result
mysql-test/suite/funcs_1/r/is_table_constraints.result
+0
-6
mysql-test/suite/funcs_1/t/is_table_constraints.test
mysql-test/suite/funcs_1/t/is_table_constraints.test
+0
-14
sql/sql_acl.cc
sql/sql_acl.cc
+8
-3
sql/sql_show.cc
sql/sql_show.cc
+22
-36
sql/table.h
sql/table.h
+3
-0
No files found.
mysql-test/main/information_schema_db.result
View file @
2eee0e9b
set local sql_mode="";
set global sql_mode="";
drop table if exists t1,t2;
drop view if exists v1,v2;
drop function if exists f1;
drop function if exists f2;
show tables from INFORMATION_SCHEMA like 'T%';
Tables_in_information_schema (T%)
TABLES
...
...
@@ -17,6 +13,10 @@ create database mbase;
use `inf%`;
show tables;
Tables_in_inf%
#
# Bug#18113 SELECT * FROM information_schema.xxx crashes server
# Bug#17204 second CALL to procedure crashes Server
#
grant all privileges on `inf%`.* to 'mysqltest_1'@'localhost';
grant all privileges on `mbase`.* to 'mysqltest_1'@'localhost';
create table t1 (f1 int);
...
...
@@ -65,6 +65,9 @@ drop database `inf%`;
drop procedure mbase.p1;
drop database mbase;
disconnect user1;
#
# Bug#18282 INFORMATION_SCHEMA.TABLES provides inconsistent info about invalid views
#
use test;
create table t1 (i int);
create function f1 () returns int return (select max(i) from t1);
...
...
@@ -88,6 +91,10 @@ v2 VIEW VIEW
drop function f1;
drop function f2;
drop view v1, v2;
#
# Bug#20543 select on information_schema strange warnings, view, different
# schemas/users
#
create database testdb_1;
create user testdb_1@localhost;
grant all on testdb_1.* to testdb_1@localhost with grant option;
...
...
@@ -216,6 +223,9 @@ disconnect testdb_2;
connection default;
drop user testdb_1@localhost;
drop user testdb_2@localhost;
#
# Bug#22763 Disrepancy between SHOW CREATE VIEW and I_S.VIEWS
#
create database testdb_1;
create table testdb_1.t1 (a int);
create view testdb_1.v1 as select * from testdb_1.t1;
...
...
@@ -246,6 +256,9 @@ connection user1;
disconnect user1;
connection default;
set global sql_mode=default;
#
# MDEV-20549 SQL SECURITY DEFINER does not work for INFORMATION_SCHEMA tables
#
create user foo@localhost;
grant select on test.* to foo@localhost;
create procedure rootonly() select 1;
...
...
@@ -325,3 +338,6 @@ disconnect foo;
drop view v1d, v1i, v2d, v2i, v3d, v3i, v4d, v4i, v5d, v5i;
drop user foo@localhost;
drop procedure rootonly;
#
# End of 10.2 tests
#
mysql-test/main/information_schema_db.test
View file @
2eee0e9b
...
...
@@ -2,21 +2,11 @@
# in the embedded server by default). So skip the test in embedded-server mode.
--
source
include
/
not_embedded
.
inc
#Don't run this test when thread_pool active
--
source
include
/
not_threadpool
.
inc
--
source
include
/
testdb_only
.
inc
set
local
sql_mode
=
""
;
set
global
sql_mode
=
""
;
--
disable_warnings
drop
table
if
exists
t1
,
t2
;
drop
view
if
exists
v1
,
v2
;
drop
function
if
exists
f1
;
drop
function
if
exists
f2
;
--
enable_warnings
--
replace_result
'Tables_in_INFORMATION_SCHEMA (T%)'
'Tables_in_information_schema (T%)'
--
sorted_result
show
tables
from
INFORMATION_SCHEMA
like
'T%'
;
...
...
@@ -25,9 +15,10 @@ create database mbase;
use
`inf%`
;
show
tables
;
#
# Bug#18113 SELECT * FROM information_schema.xxx crashes server
# Bug#17204 second CALL to procedure crashes Server
--
echo
#
--
echo
# Bug#18113 SELECT * FROM information_schema.xxx crashes server
--
echo
# Bug#17204 second CALL to procedure crashes Server
--
echo
#
# Crash happened when one selected data from one of INFORMATION_SCHEMA
# tables and in order to build its contents server had to open view which
# used stored function and table or view on which one had not global or
...
...
@@ -89,9 +80,9 @@ drop procedure mbase.p1;
drop
database
mbase
;
disconnect
user1
;
#
# Bug#18282 INFORMATION_SCHEMA.TABLES provides inconsistent info about invalid views
#
--
echo
#
--
echo
# Bug#18282 INFORMATION_SCHEMA.TABLES provides inconsistent info about invalid views
--
echo
#
use
test
;
create
table
t1
(
i
int
);
create
function
f1
()
returns
int
return
(
select
max
(
i
)
from
t1
);
...
...
@@ -110,11 +101,10 @@ drop function f2;
drop
view
v1
,
v2
;
--
enable_view_protocol
#
# Bug#20543 select on information_schema strange warnings, view, different
# schemas/users
#
#
--
echo
#
--
echo
# Bug#20543 select on information_schema strange warnings, view, different
--
echo
# schemas/users
--
echo
#
--
disable_service_connection
create
database
testdb_1
;
create
user
testdb_1
@
localhost
;
...
...
@@ -225,9 +215,9 @@ connection default;
drop
user
testdb_1
@
localhost
;
drop
user
testdb_2
@
localhost
;
#
# Bug#22763 Disrepancy between SHOW CREATE VIEW and I_S.VIEWS
#
--
echo
#
--
echo
# Bug#22763 Disrepancy between SHOW CREATE VIEW and I_S.VIEWS
--
echo
#
create
database
testdb_1
;
create
table
testdb_1
.
t1
(
a
int
);
create
view
testdb_1
.
v1
as
select
*
from
testdb_1
.
t1
;
...
...
@@ -259,9 +249,9 @@ connection default;
set
global
sql_mode
=
default
;
#
# MDEV-20549 SQL SECURITY DEFINER does not work for INFORMATION_SCHEMA tables
#
--
echo
#
--
echo
# MDEV-20549 SQL SECURITY DEFINER does not work for INFORMATION_SCHEMA tables
--
echo
#
create
user
foo
@
localhost
;
grant
select
on
test
.*
to
foo
@
localhost
;
...
...
@@ -303,3 +293,7 @@ drop view v1d, v1i, v2d, v2i, v3d, v3i, v4d, v4i, v5d, v5i;
drop
user
foo
@
localhost
;
drop
procedure
rootonly
;
--
enable_service_connection
--
echo
#
--
echo
# End of 10.2 tests
--
echo
#
mysql-test/suite/funcs_1/r/is_table_constraints.result
View file @
2eee0e9b
...
...
@@ -94,7 +94,6 @@ def mysql PRIMARY mysql transaction_registry
#########################################################################################
# Testcase 3.2.7.2 + 3.2.7.3: INFORMATION_SCHEMA.TABLE_CONSTRAINTS accessible information
#########################################################################################
DROP DATABASE IF EXISTS db_datadict;
CREATE DATABASE db_datadict;
CREATE TABLE db_datadict.t1 (f1 BIGINT, f2 BIGINT, f3 BIGINT, f4 BIGINT,
f5 BIGINT, f6 BIGINT, PRIMARY KEY (f1,f2))
...
...
@@ -104,7 +103,6 @@ CREATE UNIQUE INDEX my_idx2 ON db_datadict.t1(f3);
CREATE TABLE db_datadict.t2 (f1 BIGINT, f2 BIGINT, f3 BIGINT, f4 BIGINT,
f5 BIGINT, f6 BIGINT, PRIMARY KEY (f1,f2))
ENGINE = <some_engine_type>;
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
GRANT SELECT(f5) ON db_datadict.t1 TO 'testuser1'@'localhost';
SHOW GRANTS FOR 'testuser1'@'localhost';
...
...
@@ -158,8 +156,6 @@ DROP DATABASE db_datadict;
#########################################################################################
# Testcase 3.2.1.13+3.2.1.14+3.2.1.15: INFORMATION_SCHEMA.TABLE_CONSTRAINTS modifications
#########################################################################################
DROP DATABASE IF EXISTS db_datadict;
DROP TABLE IF EXISTS test.t1_my_table;
CREATE DATABASE db_datadict;
SELECT table_name FROM information_schema.table_constraints
WHERE table_name LIKE 't1_my_table%';
...
...
@@ -310,8 +306,6 @@ table_name
# Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
# DDL on INFORMATION_SCHEMA tables are not supported
########################################################################
DROP DATABASE IF EXISTS db_datadict;
DROP TABLE IF EXISTS db_datadict.t1;
CREATE DATABASE db_datadict;
CREATE TABLE db_datadict.t1 (f1 BIGINT, UNIQUE(f1))
ENGINE = <engine_type>;
...
...
mysql-test/suite/funcs_1/t/is_table_constraints.test
View file @
2eee0e9b
...
...
@@ -36,7 +36,6 @@ eval SHOW TABLES FROM information_schema LIKE '$is_table';
#
--
source
suite
/
funcs_1
/
datadict
/
is_table_query
.
inc
--
echo
#########################################################################
--
echo
# Testcase 3.2.10.1: INFORMATION_SCHEMA.TABLE_CONSTRAINTS layout
--
echo
#########################################################################
...
...
@@ -85,9 +84,6 @@ ORDER BY constraint_schema, table_name, constraint_name;
# mysql is_table_constraints_mysql
# information_schema is_table_constraints_is
#
--
disable_warnings
DROP
DATABASE
IF
EXISTS
db_datadict
;
--
enable_warnings
CREATE
DATABASE
db_datadict
;
--
replace_result
$engine_type
<
some_engine_type
>
eval
...
...
@@ -102,8 +98,6 @@ CREATE TABLE db_datadict.t2 (f1 BIGINT, f2 BIGINT, f3 BIGINT, f4 BIGINT,
f5
BIGINT
,
f6
BIGINT
,
PRIMARY
KEY
(
f1
,
f2
))
ENGINE
=
$engine_type
;
--
error
0
,
ER_CANNOT_USER
DROP
USER
'testuser1'
@
'localhost'
;
CREATE
USER
'testuser1'
@
'localhost'
;
GRANT
SELECT
(
f5
)
ON
db_datadict
.
t1
TO
'testuser1'
@
'localhost'
;
SHOW
GRANTS
FOR
'testuser1'
@
'localhost'
;
...
...
@@ -161,10 +155,6 @@ DROP DATABASE db_datadict;
# automatically deletes all relevant information on that object from
# every appropriate INFORMATION_SCHEMA table.
#
--
disable_warnings
DROP
DATABASE
IF
EXISTS
db_datadict
;
DROP
TABLE
IF
EXISTS
test
.
t1_my_table
;
--
enable_warnings
CREATE
DATABASE
db_datadict
;
SELECT
table_name
FROM
information_schema
.
table_constraints
...
...
@@ -281,10 +271,6 @@ WHERE table_name = 't1_my_tablex';
# 3.2.1.12: Ensure that no user may directly add to, alter, or delete any data
# in an INFORMATION_SCHEMA table.
#
--
disable_warnings
DROP
DATABASE
IF
EXISTS
db_datadict
;
DROP
TABLE
IF
EXISTS
db_datadict
.
t1
;
--
enable_warnings
CREATE
DATABASE
db_datadict
;
--
replace_result
$engine_type
<
engine_type
>
eval
...
...
sql/sql_acl.cc
View file @
2eee0e9b
...
...
@@ -5210,6 +5210,13 @@ class GRANT_TABLE :public GRANT_NAME
};
ulong
GRANT_INFO
::
all_privilege
()
{
return
(
grant_table_user
?
grant_table_user
->
cols
:
0
)
|
(
grant_table_role
?
grant_table_role
->
cols
:
0
)
|
privilege
;
}
void
GRANT_NAME
::
set_user_details
(
const
char
*
h
,
const
char
*
d
,
const
char
*
u
,
const
char
*
t
,
bool
is_routine
)
...
...
@@ -8227,9 +8234,7 @@ bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables,
if
(
!
(
~
t_ref
->
grant
.
privilege
&
want_access
))
continue
;
if
((
want_access
&=
~
((
grant_table
?
grant_table
->
cols
:
0
)
|
(
grant_table_role
?
grant_table_role
->
cols
:
0
)
|
t_ref
->
grant
.
privilege
)))
if
((
want_access
&=
~
t_ref
->
grant
.
all_privilege
()))
{
goto
err
;
// impossible
}
...
...
sql/sql_show.cc
View file @
2eee0e9b
...
...
@@ -6778,10 +6778,8 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
if
(
show_table
->
file
)
{
(
void
)
read_statistics_for_tables
(
thd
,
tables
);
show_table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_NO_LOCK
|
HA_STATUS_CONST
|
HA_STATUS_TIME
);
show_table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_NO_LOCK
|
HA_STATUS_CONST
|
HA_STATUS_TIME
);
set_statistics_for_table
(
thd
,
show_table
);
}
for
(
uint
i
=
0
;
i
<
show_table
->
s
->
keys
;
i
++
,
key_info
++
)
...
...
@@ -7108,14 +7106,10 @@ static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables,
TABLE
*
show_table
=
tables
->
table
;
KEY
*
key_info
=
show_table
->
s
->
key_info
;
uint
primary_key
=
show_table
->
s
->
primary_key
;
show_table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_NO_LOCK
|
show_table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_NO_LOCK
|
HA_STATUS_TIME
);
for
(
uint
i
=
0
;
i
<
show_table
->
s
->
keys
;
i
++
,
key_info
++
)
{
if
(
i
!=
primary_key
&&
!
(
key_info
->
flags
&
HA_NOSAME
))
continue
;
if
(
i
==
primary_key
&&
!
strcmp
(
key_info
->
name
.
str
,
primary_key_name
))
{
if
(
store_constraints
(
thd
,
table
,
db_name
,
table_name
,
...
...
@@ -7133,16 +7127,14 @@ static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables,
}
// Table check constraints
for
(
uint
i
=
0
;
i
<
show_table
->
s
->
table_check_constraints
;
i
++
)
for
(
uint
i
=
0
;
i
<
show_table
->
s
->
table_check_constraints
;
i
++
)
{
Virtual_column_info
*
check
=
show_table
->
check_constraints
[
i
];
Virtual_column_info
*
check
=
show_table
->
check_constraints
[
i
];
if
(
store_constraints
(
thd
,
table
,
db_name
,
table_name
,
check
->
name
.
str
,
check
->
name
.
length
,
STRING_WITH_LEN
(
"CHECK"
)
)
)
{
DBUG_RETURN
(
1
);
}
if
(
store_constraints
(
thd
,
table
,
db_name
,
table_name
,
check
->
name
.
str
,
check
->
name
.
length
,
STRING_WITH_LEN
(
"CHECK"
)))
DBUG_RETURN
(
1
);
}
show_table
->
file
->
get_foreign_key_list
(
thd
,
&
f_key_list
);
...
...
@@ -7153,7 +7145,7 @@ static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables,
if
(
store_constraints
(
thd
,
table
,
db_name
,
table_name
,
f_key_info
->
foreign_id
->
str
,
strlen
(
f_key_info
->
foreign_id
->
str
),
"FOREIGN KEY"
,
11
))
STRING_WITH_LEN
(
"FOREIGN KEY"
)
))
DBUG_RETURN
(
1
);
}
}
...
...
@@ -7284,8 +7276,7 @@ store_key_column_usage(TABLE *table, const LEX_CSTRING *db_name,
}
static
int
get_schema_key_column_usage_record
(
THD
*
thd
,
TABLE_LIST
*
tables
,
static
int
get_schema_key_column_usage_record
(
THD
*
thd
,
TABLE_LIST
*
tables
,
TABLE
*
table
,
bool
res
,
const
LEX_CSTRING
*
db_name
,
const
LEX_CSTRING
*
table_name
)
...
...
@@ -7306,8 +7297,7 @@ static int get_schema_key_column_usage_record(THD *thd,
TABLE
*
show_table
=
tables
->
table
;
KEY
*
key_info
=
show_table
->
s
->
key_info
;
uint
primary_key
=
show_table
->
s
->
primary_key
;
show_table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_NO_LOCK
|
show_table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_NO_LOCK
|
HA_STATUS_TIME
);
for
(
uint
i
=
0
;
i
<
show_table
->
s
->
keys
;
i
++
,
key_info
++
)
{
...
...
@@ -7317,18 +7307,15 @@ static int get_schema_key_column_usage_record(THD *thd,
KEY_PART_INFO
*
key_part
=
key_info
->
key_part
;
for
(
uint
j
=
0
;
j
<
key_info
->
user_defined_key_parts
;
j
++
,
key_part
++
)
{
if
(
key_part
->
field
)
{
f_idx
++
;
restore_record
(
table
,
s
->
default_values
);
store_key_column_usage
(
table
,
db_name
,
table_name
,
key_info
->
name
.
str
,
key_info
->
name
.
length
,
key_part
->
field
->
field_name
.
str
,
key_part
->
field
->
field_name
.
length
,
(
longlong
)
f_idx
);
if
(
schema_table_store_record
(
thd
,
table
))
DBUG_RETURN
(
1
);
}
f_idx
++
;
restore_record
(
table
,
s
->
default_values
);
store_key_column_usage
(
table
,
db_name
,
table_name
,
key_info
->
name
.
str
,
key_info
->
name
.
length
,
key_part
->
field
->
field_name
.
str
,
key_part
->
field
->
field_name
.
length
,
(
longlong
)
f_idx
);
if
(
schema_table_store_record
(
thd
,
table
))
DBUG_RETURN
(
1
);
}
}
...
...
@@ -8189,8 +8176,7 @@ get_referential_constraints_record(THD *thd, TABLE_LIST *tables,
{
List
<
FOREIGN_KEY_INFO
>
f_key_list
;
TABLE
*
show_table
=
tables
->
table
;
show_table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_NO_LOCK
|
show_table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_NO_LOCK
|
HA_STATUS_TIME
);
show_table
->
file
->
get_foreign_key_list
(
thd
,
&
f_key_list
);
...
...
sql/table.h
View file @
2eee0e9b
...
...
@@ -336,6 +336,9 @@ typedef struct st_grant_info
ulong
orig_want_privilege
;
/** The grant state for internal tables. */
GRANT_INTERNAL_INFO
m_internal
;
/* OR table and all column privileges */
ulong
all_privilege
();
}
GRANT_INFO
;
enum
tmp_table_type
...
...
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