This commit is contained in:
root
2024-04-24 10:25:44 +08:00
parent 627bf43ee3
commit 248388a322
5271 changed files with 3753425 additions and 803 deletions

View File

@@ -0,0 +1,107 @@
# suite/funcs_1/t/charset_collation.test
#
# Tests checking the content of the information_schema tables
# character_sets
# collations
# collation_character_set_applicability
#
# Created:
# 2009-04-28 mleich Replace the charset_collation_* test which failed too often
# because of changes
# - in general available character sets and collations
# - in build types
# (Bug#40545, Bug#40209, Bug#40618, Bug#38346)
#
# Create a low privileged user.
--error 0, ER_CANNOT_USER
DROP USER dbdict_test@localhost;
CREATE USER dbdict_test@localhost;
--echo # Establish connection con (user=dbdict_test)
connect (con,localhost,dbdict_test,,);
################################################################################
#
# The original requirements for the following tests were:
#
# 3.2.2.2: Ensure that the table (information_schema.character_sets) shows the
# relevant information on every character set for which the current
# user or PUBLIC have the USAGE privilege.
#
# 3.2.2.3: Ensure that the table (information_schema.character_sets) does not
# show any information on any character set for which the current user
# or PUBLIC have no USAGE privilege.
#
#
# 3.2.3.2: Ensure that the table (information_schema.collations) shows the
# relevant information on every collation for which the current user
# or PUBLIC have the USAGE privilege.
#
# 3.2.3.3: Ensure that the table (information_schema.collations) does not show
# any information on any collations for which the current user and
# PUBLIC have no USAGE privilege.
#
#
# 3.2.4.2: Ensure that the table
# information_schema.collation_character_set_applicability
# shows the relevant information on every collation/character set
# combination for which the current user or PUBLIC have the USAGE
# privilege.
#
# 3.2.4.3: Ensure that the table
# information_schema.collation_character_set_applicability
# does not show any information on any collation/character set
# combinations for which the current user and PUBLIC have no
# USAGE privilege.
#
# Notes (2009-04-28 mleich):
# - The requirements are outdated because grant/revoke privilege for using a
# characterset/collation were never implemented.
# Therefore the tests focus on the completeness and correctness of the
# content (rows and columns) of these tables.
# - The amount of collations/character sets grows with new MySQL releases.
# Even within the same release the amount of records within these tables
# can differ between different build types (community, enterprise, source,...)
# Therefore we limit the queries to character sets and collations which
# - exist in all build types
# - have in all build types the same "state".
# The character set
# - utf8 is used for Metadata
# - ascii is a quite usual
# The collations <character set>_general_ci and <character set>_bin seem
# to be available all time.
#
################################################################################
let $char_set_condition= character_set_name IN ('utf8','latin1','binary');
let $collation_condition=
(collation_name LIKE CONCAT(character_set_name,'_general_ci')
OR
collation_name LIKE CONCAT(character_set_name,'_bin'));
--echo
eval SELECT *
FROM information_schema.character_sets
WHERE $char_set_condition
ORDER BY character_set_name;
--echo
eval SELECT *
FROM information_schema.collations
WHERE $char_set_condition
AND $collation_condition
ORDER BY collation_name;
--echo
eval SELECT *
FROM information_schema.collation_character_set_applicability
WHERE $char_set_condition
AND $collation_condition
ORDER BY collation_name, character_set_name;
# Cleanup
--echo # Switch to connection default + disconnect con
connection default;
disconnect con;
DROP USER dbdict_test@localhost;

View File

@@ -0,0 +1,13 @@
##############################################################################
#
# List the test cases that are to be disabled temporarely.
#
# Separate the test case name and the comment with ':'.
#
# <testcasename> : Comment test
#
# Don't use any TAB characters for whitespace.
#
##############################################################################
ndb_trig_1011ext: Bug#11747493 NDB: Duplicate key error aborts transaction in handler. Doesn't talk back to SQL

View File

@@ -0,0 +1,17 @@
#### suite/funcs_1/t/innodb_bitdata.test
# InnoDB tables should be used
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
let $message= NOT YET IMPLEMENTED: bitdata tests;
--source include/show_msg80.inc
exit;
# Create some objects needed in many testcases
USE test;
--source suite/funcs_1/include/innodb_tb4.inc
--source suite/funcs_1/bitdata/bitdata_master.test

View File

@@ -0,0 +1,19 @@
#### suite/funcs_1/t/innodb_cursors.test
# Innodb tables should be used
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
let $message= NOT YET IMPLEMENTED: cursor tests;
--source include/show_msg80.inc
exit;
# Create some objects needed in many testcases
USE test;
--source suite/funcs_1/include/innodb_tb1.inc
--source suite/funcs_1/cursors/cursors_master.test

View File

@@ -0,0 +1,16 @@
###################################################
# #
# Functions within VIEWs based on InnoDB tables #
# #
###################################################
#
# NOTE: PLEASE SEE THE DETAILED DESCRIPTION IN
# suite/funcs_1/views/func_view.inc
# BEFORE ADDING NEW TEST CASES HERE !!!
let $type= 'InnoDB' ;
--source include/have_innodb.inc
--source suite/funcs_1/views/func_view.inc

View File

@@ -0,0 +1,9 @@
#### suite/funcs_1/t/innodb_storedproc_02.test
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
--source suite/funcs_1/storedproc/storedproc_02.inc

View File

@@ -0,0 +1,9 @@
#### suite/funcs_1/t/innodb_storedproc_03.test
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
--source suite/funcs_1/storedproc/storedproc_03.inc

View File

@@ -0,0 +1,9 @@
#### suite/funcs_1/t/innodb_storedproc_06.test
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
--source suite/funcs_1/storedproc/storedproc_06.inc

View File

@@ -0,0 +1,9 @@
#### suite/funcs_1/t/innodb_storedproc_07.test
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
--source suite/funcs_1/storedproc/storedproc_07.inc

View File

@@ -0,0 +1,9 @@
#### suite/funcs_1/t/innodb_storedproc_08.test
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
--source suite/funcs_1/storedproc/storedproc_08.inc

View File

@@ -0,0 +1,9 @@
#### suite/funcs_1/t/innodb_storedproc_10.test
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
--source suite/funcs_1/storedproc/storedproc_10.inc

View File

@@ -0,0 +1,10 @@
#### suite/funcs_1/t/innodb_trig_0102.test
# InnoDB tables should be used
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
--source suite/funcs_1/triggers/triggers_0102.inc

View File

@@ -0,0 +1,10 @@
#### suite/funcs_1/t/innodb_trig_03.test
# InnoDB tables should be used
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
--source suite/funcs_1/triggers/triggers_03.inc

View File

@@ -0,0 +1,25 @@
#### suite/funcs_1/t/innodb_trig_03e.test
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
# InnoDB tables should be used
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
# Create some objects needed in many testcases
USE test;
--source suite/funcs_1/triggers/triggers_03e_db_level.inc
--source suite/funcs_1/triggers/triggers_03e_table_level.inc
--source suite/funcs_1/triggers/triggers_03e_global_db_mix.inc
--source suite/funcs_1/triggers/triggers_03e_db_table_mix.inc
--source suite/funcs_1/triggers/triggers_03e_prepare.inc
--source suite/funcs_1/triggers/triggers_03e_definer.inc
--source suite/funcs_1/triggers/triggers_03e_transaction.inc
--source suite/funcs_1/triggers/triggers_03e_columns.inc

View File

@@ -0,0 +1,10 @@
#### suite/funcs_1/t/innodb_trig_0407.test
# InnoDB tables should be used
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
--source suite/funcs_1/triggers/triggers_0407.inc

View File

@@ -0,0 +1,10 @@
#### suite/funcs_1/t/innodb_trig_08.test
# InnoDB tables should be used
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
--source suite/funcs_1/triggers/triggers_08.inc

View File

@@ -0,0 +1,10 @@
#### suite/funcs_1/t/innodb_trig_09.test
# InnoDB tables should be used
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
--source suite/funcs_1/triggers/triggers_09.inc

View File

@@ -0,0 +1,10 @@
#### suite/funcs_1/t/innodb_trig_1011ext.test
# InnoDB tables should be used
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
--source suite/funcs_1/triggers/triggers_1011ext.inc

View File

@@ -0,0 +1,10 @@
#### suite/funcs_1/t/innodb_triggers.test
# InnoDB tables should be used
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
--source suite/funcs_1/triggers/trig_frkey.inc

View File

@@ -0,0 +1,24 @@
#### suite/funcs_1/t/innodb_views.test
# InnoDB tables should be used
#
# 1. Check if InnoDB is available
--source include/have_innodb.inc
# 2. Set $engine_type
let $engine_type= innodb;
# Create some objects needed in many testcases
USE test;
--source suite/funcs_1/include/innodb_tb2.inc
--disable_warnings
DROP DATABASE IF EXISTS test1;
--enable_warnings
CREATE DATABASE test1;
USE test1;
--source suite/funcs_1/include/innodb_tb2.inc
USE test;
--source suite/funcs_1/views/views_master.inc
DROP DATABASE test1;
DROP TABLE test.tb2;

View File

@@ -0,0 +1,516 @@
# suite/funcs_1/t/is_basics_mixed.test
#
# Checks of some basic properties of the INFORMATION_SCHEMA which are not
# related to a certain INFORMATION_SCHEMA table.
#
# This test should not check properties related to storage engines.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test is strict adjusted to the behaviour of the non embedded server.
# Example of common differences between both servers:
# USE information_schema; CREATE VIEW tables AS SELECT 'garbage';
# non embedded server:
# - errname ER_DBACCESS_DENIED_ERROR
# - ERROR 42000: Access denied for user 'root'@'localhost' to
# database 'information_schema'
# embedded server:
# - errno 1
# - Can't create/write to file
# '.../var/master-data/information_schema/tables.frm~
--source include/not_embedded.inc
--source suite/funcs_1/datadict/datadict.pre
# $engine_type must point to storage engine which is all time available.
# The fastest engine should be preferred.
let $engine_type = MEMORY;
# The INFORMATION_SCHEMA database must exist.
SHOW DATABASES LIKE 'information_schema';
--echo #######################################################################
--echo # Testcase 3.2.1.20: USE INFORMATION_SCHEMA is supported
--echo #######################################################################
# Ensure that USE INFORMATION_SCHEMA allows the user to switch to the
# INFORMATION_SCHEMA database, for query purposes only.
#
# Note: The "for query purposes only" is checked in other tests.
# High privileged user (root)
--echo # Switch to connection default
connection default;
USE test;
SELECT DATABASE();
USE information_schema;
SELECT DATABASE();
#
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
# Low privileged user
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , test);
SELECT DATABASE();
USE information_schema;
SELECT DATABASE();
#
--echo # Switch to connection default and close connection testuser1
connection default;
disconnect testuser1;
DROP USER 'testuser1'@'localhost';
--echo #######################################################################
--echo # Testcase TBD1: The INFORMATION_SCHEMA cannot be dropped.
--echo #######################################################################
--error ER_DBACCESS_DENIED_ERROR
DROP DATABASE information_schema;
--echo #######################################################################
--echo # Testcase TBD2: There cannot be a second database INFORMATION_SCHEMA.
--echo #######################################################################
--error ER_DBACCESS_DENIED_ERROR
CREATE DATABASE information_schema;
--echo ##################################################################################
--echo # Testcase 3.2.1.6+3.2.1.7: No user may create an INFORMATION_SCHEMA table or view
--echo ##################################################################################
# 3.2.1.6 Ensure that no user may create an INFORMATION_SCHEMA base table.
# 3.2.1.7 Ensure that no user may create an INFORMATION_SCHEMA view
#
# 1. High privileged user (root)
--echo # Switch to connection default (user=root)
connection default;
--source suite/funcs_1/datadict/basics_mixed1.inc
# 2. High privileged user (testuser1)
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
GRANT ALL ON *.* TO testuser1@localhost;
SHOW GRANTS FOR testuser1@localhost;
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , test);
--source suite/funcs_1/datadict/basics_mixed1.inc
--echo # Switch to connection default (user=root) and close connection testuser1
connection default;
disconnect testuser1;
DROP USER 'testuser1'@'localhost';
--echo ###############################################################################
--echo # Testcase 3.2.1.1+3.2.1.2: INFORMATION_SCHEMA tables can be queried via SELECT
--echo ###############################################################################
# 3.2.1.1 Ensure that every INFORMATION_SCHEMA table can be queried with
# a SELECT statement, just as if it were an ordinary user-defined table.
# 3.2.1.2 Ensure that queries on an INFORMATION_SCHEMA table can accept all
# SELECT statement options and are always correctly evaluated.
#
# Some notes(mleich):
# - Currently here only a subset of select statement options is checked, it's
# still not possible to check here all possible options
# - The content of many INFORMATION_SCHEMA tables is checked in other tests.
# - We work here only with a subset of the columns of information_schema.tables
# because we want have a stable base (all time existing table, stable layout).
--disable_warnings
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
--replace_result $engine_type <some_engine>
eval
CREATE TABLE db_datadict.t1_first (f1 BIGINT UNIQUE, f2 BIGINT)
ENGINE = $engine_type;
--replace_result $engine_type <some_engine>
eval
CREATE TABLE db_datadict.t1_second (f1 BIGINT UNIQUE, f2 BIGINT)
ENGINE = $engine_type;
# SELECT *
--echo # Attention: The protocolling of the next result set is disabled.
--disable_result_log
SELECT * FROM information_schema.tables;
--enable_result_log
#
# SELECT <some columns> + WHERE
--sorted_result
SELECT table_name FROM information_schema.tables
WHERE table_schema = 'db_datadict';
#
# SELECT string_function(<some column>) + ORDER BY
SELECT LENGTH(table_name) FROM information_schema.tables
WHERE table_schema = 'db_datadict' ORDER BY table_name;
#
# SELECT aggregate_function(<some column>) + WHERE with LIKE
SELECT count(table_name) FROM information_schema.tables
WHERE table_schema LIKE 'db_datadic%';
#
# SELECT with addition in column list
--sorted_result
SELECT CAST((LENGTH(table_schema) + LENGTH(table_name)) AS DECIMAL(15,1))
FROM information_schema.tables
WHERE table_schema = 'db_datadict';
#
# WHERE with IN + LIMIT
SELECT table_name FROM information_schema.tables
WHERE table_name IN ('t1_first','t1_second') ORDER BY table_name LIMIT 1;
SELECT table_name FROM information_schema.tables
WHERE table_name IN ('t1_first','t1_second') ORDER BY table_name LIMIT 1,1;
#
# WHERE with AND
SELECT table_name,table_schema AS my_col FROM information_schema.tables
WHERE table_name = 't1_first' AND table_schema = 'db_datadict';
#
# SELECT HIGH_PRIORITY + WHERE with OR
--sorted_result
SELECT HIGH_PRIORITY table_name AS my_col FROM information_schema.tables
WHERE table_name = 't1_first' OR table_name = 't1_second';
#
# Empty result set
SELECT 1 AS my_col FROM information_schema.tables
WHERE table_name = 't1_third';
#
# SELECT INTO USER VARIABLE
SELECT table_name,table_schema INTO @table_name,@table_schema
FROM information_schema.tables
WHERE table_schema = 'db_datadict' ORDER BY table_name LIMIT 1;
SELECT @table_name,@table_schema;
#
# SELECT INTO OUTFILE
let $OUTFILE = $MYSQLTEST_VARDIR/tmp/datadict.out;
--error 0,1
remove_file $OUTFILE;
--replace_result $OUTFILE <OUTFILE>
eval SELECT table_name,table_schema
INTO OUTFILE '$OUTFILE'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM information_schema.tables
WHERE table_schema = 'db_datadict' ORDER BY table_name;
cat_file $OUTFILE;
remove_file $OUTFILE;
#
# UNION
--sorted_result
SELECT table_name FROM information_schema.tables
WHERE table_name = 't1_first'
UNION ALL
SELECT table_name FROM information_schema.tables
WHERE table_name = 't1_second';
#
# DISTINCT + SUBQUERY
SELECT DISTINCT table_schema FROM information_schema.tables
WHERE table_name IN (SELECT table_name FROM information_schema.tables
WHERE table_schema = 'db_datadict')
ORDER BY table_name;
#
# JOIN
SELECT table_name FROM information_schema.tables t1
LEFT JOIN information_schema.tables t2 USING(table_name,table_schema)
WHERE t2.table_schema = 'db_datadict'
ORDER BY table_name;
#
# No schema assigned in SELECT + we are in SCHEMA test
# --> The table tables does not exist
USE test;
--error ER_NO_SUCH_TABLE
SELECT * FROM tables;
--echo #########################################################################
--echo # Testcase 3.2.1.17+3.2.1.18
--echo #########################################################################
# 3.2.1.17: Ensure that the SELECT privilege is granted TO PUBLIC WITH GRANT
# OPTION on every INFORMATION_SCHEMA table.
#
# 3.2.1.18: Ensure that the CREATE VIEW privilege on an INFORMATION_SCHEMA table
# may be granted to any user.
#
# Note (mleich): The requirements are to some extend outdated.
# Every user is allowed to SELECT on the INFORMATION_SCHEMA.
# But the result sets depend on the privileges of the user.
#
--disable_warnings
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
--replace_result $engine_type <some_engine>
eval
CREATE TABLE db_datadict.t1 (f1 BIGINT UNIQUE, f2 BIGINT)
ENGINE = $engine_type;
SELECT * FROM db_datadict.t1;
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
--error 0,ER_CANNOT_USER
DROP USER 'testuser2'@'localhost';
CREATE USER 'testuser2'@'localhost';
GRANT CREATE VIEW,SELECT ON db_datadict.* TO testuser1@localhost
WITH GRANT OPTION;
GRANT USAGE ON db_datadict.* TO testuser2@localhost;
FLUSH PRIVILEGES;
# Check 0: Reveal that GRANT <some privilege> ON INFORMATION_SCHEMA is no
# longer allowed.
--error ER_DBACCESS_DENIED_ERROR
GRANT SELECT on information_schema.* TO testuser1@localhost;
--error ER_DBACCESS_DENIED_ERROR
GRANT CREATE VIEW ON information_schema.* TO 'u_6_401018'@'localhost';
# Check 1: Show that a "simple" user (<> root) has the permission to SELECT
# on some INFORMATION_SCHEMA table.
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , db_datadict);
SELECT table_schema,table_name FROM information_schema.tables
WHERE table_schema = 'information_schema' AND table_name = 'tables';
# Check 2: Show the privileges of the user on some INFORMATION_SCHEMA tables.
SELECT * FROM information_schema.table_privileges
WHERE table_schema = 'information_schema';
SELECT * FROM information_schema.schema_privileges
WHERE table_schema = 'information_schema';
# Check 3: Show the following
# 1. If a simple user (testuser1) has the privilege to create a VIEW
# than this VIEW could use a SELECT on an INFORMATION_SCHEMA table.
# 2. This user (testuser1) is also able to GRANT the SELECT privilege
# on this VIEW to another user (testuser2).
# 3. The other user (testuser2) must be able to SELECT on this VIEW
# but gets a different result set than testuser1.
CREATE VIEW db_datadict.v2 AS
SELECT TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE
FROM information_schema.tables WHERE table_schema = 'db_datadict';
SELECT TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE
FROM db_datadict.v2;
SELECT TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE
FROM information_schema.tables WHERE table_schema = 'db_datadict';
GRANT SELECT ON db_datadict.v2 to testuser2@localhost;
#
--echo # Establish connection testuser2 (user=testuser2)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser2, localhost, testuser2, , db_datadict);
SELECT TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE
FROM db_datadict.v2;
SELECT TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE
FROM information_schema.tables WHERE table_schema = 'db_datadict';
# Cleanup
--echo # Switch to connection default and close connections testuser1 and testuser2
connection default;
disconnect testuser1;
disconnect testuser2;
DROP USER 'testuser1'@'localhost';
DROP USER 'testuser2'@'localhost';
DROP DATABASE db_datadict;
--echo #########################################################################
--echo # Testcase 3.2.1.19
--echo #########################################################################
# Ensure that no other privilege on an INFORMATION_SCHEMA table is granted, or
# may be granted, to any user.
#
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
# Initial privileges on the INFORMATION_SCHEMA tables (empty result sets)
let $my_select1 = SELECT 'empty result set was expected' AS my_col
FROM information_schema.schema_privileges
WHERE table_schema = 'information_schema';
let $my_select2 = SELECT 'empty result set was expected' AS my_col
FROM information_schema.table_privileges
WHERE table_schema = 'information_schema';
let $my_select3 = SELECT 'empty result set was expected' AS my_col
FROM information_schema.column_privileges
WHERE table_schema = 'information_schema';
eval $my_select1;
eval $my_select2;
eval $my_select3;
#FIXME: check GRANT on IS
--error ER_DBACCESS_DENIED_ERROR
GRANT ALTER ON information_schema.*
TO 'testuser1'@'localhost';
#FIXME: check GRANT on IS
--error ER_DBACCESS_DENIED_ERROR
GRANT ALTER ROUTINE ON information_schema.*
TO 'testuser1'@'localhost';
#FIXME: check GRANT on IS
--error ER_DBACCESS_DENIED_ERROR
GRANT CREATE ON information_schema.*
TO 'testuser1'@'localhost';
#FIXME: check GRANT on IS
--error ER_DBACCESS_DENIED_ERROR
GRANT CREATE ROUTINE ON information_schema.*
TO 'testuser1'@'localhost';
#FIXME: check GRANT on IS
--error ER_DBACCESS_DENIED_ERROR
GRANT CREATE TEMPORARY TABLES ON information_schema.*
TO 'testuser1'@'localhost';
#FIXME: check GRANT on IS
--error ER_DBACCESS_DENIED_ERROR
GRANT DELETE ON information_schema.*
TO 'testuser1'@'localhost';
#FIXME: check GRANT on IS
--error ER_DBACCESS_DENIED_ERROR
GRANT DROP ON information_schema.*
TO 'testuser1'@'localhost';
#FIXME: check GRANT on IS
--error ER_DBACCESS_DENIED_ERROR
GRANT EXECUTE ON information_schema.*
TO 'testuser1'@'localhost';
#FIXME: check GRANT on IS
--error ER_DBACCESS_DENIED_ERROR
GRANT INDEX ON information_schema.*
TO 'testuser1'@'localhost';
#FIXME: check GRANT on IS
--error ER_DBACCESS_DENIED_ERROR
GRANT INSERT ON information_schema.*
TO 'testuser1'@'localhost';
#FIXME: check GRANT on IS
--error ER_DBACCESS_DENIED_ERROR
GRANT LOCK TABLES ON information_schema.*
TO 'testuser1'@'localhost';
#FIXME: check GRANT on IS
--error ER_DBACCESS_DENIED_ERROR
GRANT UPDATE ON information_schema.*
TO 'testuser1'@'localhost';
# Has something accidently changed?
eval $my_select1;
eval $my_select2;
eval $my_select3;
# Cleanup
DROP USER 'testuser1'@'localhost';
--echo #########################################################################
--echo # Testcase 3.2.1.16
--echo #########################################################################
# Ensure that no user may use any INFORMATION_SCHEMA table to determine any
# information on a database and/or its structure unless authorized to get that
# information.
# Note: The plan is to create a new database and objects within it so that
# any INFORMATION_SCHEMA table gets additional rows if possible.
# A user having no rights on the new database and no rights on objects
# must nowhere see tha name of the new database.
--source suite/funcs_1/datadict/basics_mixed3.inc
--disable_warnings
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
--replace_result $engine_type <some_engine>
eval
CREATE TABLE db_datadict.t1 (f1 BIGINT, f2 BIGINT NOT NULL, f3 BIGINT,
PRIMARY KEY(f1))
ENGINE = $engine_type;
CREATE UNIQUE INDEX UIDX ON db_datadict.t1(f3);
CREATE PROCEDURE db_datadict.sproc1() SELECT 'db_datadict';
CREATE FUNCTION db_datadict.func1() RETURNS INT RETURN 0;
CREATE TRIGGER db_datadict.trig1 BEFORE INSERT ON db_datadict.t1
FOR EACH ROW SET @aux = 1;
CREATE VIEW db_datadict.v1 AS SELECT * FROM db_datadict.t1;
CREATE VIEW db_datadict.v2 AS SELECT * FROM information_schema.tables;
--source suite/funcs_1/datadict/basics_mixed3.inc
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
GRANT ALL ON test.* TO 'testuser1'@'localhost';
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , test);
--source suite/funcs_1/datadict/basics_mixed3.inc
# Cleanup
--echo # Switch to connection default and close connections testuser1 and testuser2
connection default;
disconnect testuser1;
DROP USER 'testuser1'@'localhost';
DROP DATABASE db_datadict;
--echo ########################################################################
--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
--echo # DDL on INFORMATION_SCHEMA tables are not supported
--echo ########################################################################
# Thorough tests checking the requirements above per every INFORMATION_SCHEMA
# table are within other scripts.
# We check here only that the requirement is fulfilled even when using a
# STORED PROCEDURE.
--disable_warnings
DROP PROCEDURE IF EXISTS test.p1;
--enable_warnings
CREATE PROCEDURE test.p1()
INSERT INTO information_schema.tables
SELECT * FROM information_schema.tables LIMIT 1;
--error ER_DBACCESS_DENIED_ERROR
CALL test.p1();
DROP PROCEDURE test.p1;
CREATE PROCEDURE test.p1()
UPDATE information_schema.columns SET table_schema = 'garbage';
--error ER_DBACCESS_DENIED_ERROR
CALL test.p1();
DROP PROCEDURE test.p1;
CREATE PROCEDURE test.p1()
DELETE FROM information_schema.schemata;
--error ER_DBACCESS_DENIED_ERROR
CALL test.p1();
DROP PROCEDURE test.p1;
--echo #########################################################################
--echo # Testcase 3.2.17.1+3.2.17.2: To be implemented outside of this script
--echo #########################################################################
# 3.2.17.1 Ensure that every INFORMATION_SCHEMA table shows all the correct
# information, and no incorrect information, for a database to which
# 100 different users, each of which has a randomly issued set of
# privileges and access to a randomly chosen set of database objects,
# have access.
# The database should contain a mixture of all types of database
# objects (i.e. tables, views, stored procedures, triggers).
# 3.2.17.2 Ensure that every INFORMATION_SCHEMA table shows all the correct
# information, and no incorrect information, for 10 different
# databases to which 50 different users, each of which has a randomly
# issued set of privileges and access to a randomly chosen set of
# database objects in two or more of the databases, have access.
# The databases should each contain a mixture of all types of database
# objects (i.e. tables, views, stored procedures, triggers).
#
# Note(mleich): These requirements are kept here so that they do not get lost.
# The tests are not yet implemented.
# If they are ever developed than they should be stored in other
# scripts. They will have most probably a long runtime because
# the current INFORMATION_SCHEMA implementation has some performance
# issues if a lot of users, privileges and objects are involved.
#

View File

@@ -0,0 +1,112 @@
# suite/funcs_1/t/is_character_sets.test
#
# Check the layout of information_schema.character_sets and run some
# functionality related tests.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
if (`SELECT VERSION() LIKE '%embedded%'`)
{
--skip Bug#37456 funcs_1: Several tests crash when used with embedded server
}
let $is_table = CHARACTER_SETS;
# The table INFORMATION_SCHEMA.CHARACTER_SETS must exist
eval SHOW TABLES FROM information_schema LIKE '$is_table';
--echo #######################################################################
--echo # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
--echo #######################################################################
# Ensure that every INFORMATION_SCHEMA table can be queried with a SELECT
# statement, just as if it were an ordinary user-defined table.
#
--source suite/funcs_1/datadict/is_table_query.inc
--echo #########################################################################
--echo # Testcase 3.2.2.1: INFORMATION_SCHEMA.CHARACTER_SETS layout
--echo #########################################################################
# Ensure that the INFORMATION_SCHEMA.CHARACTER_SETS table has the following
# columns, in the following order:
#
# CHARACTER_SET_NAME (shows a character set name),
# DEFAULT_COLLATE_NAME (shows the name of the default collation for that
# character set),
# DESCRIPTION (shows a descriptive name for that character set),
# MAXLEN (shows the number of bytes used to store each character supported by
# that character set).
#
eval DESCRIBE information_schema.$is_table;
eval SHOW CREATE TABLE information_schema.$is_table;
eval SHOW COLUMNS FROM information_schema.$is_table;
# Note: Retrieval of information within information_schema.columns about
# information_schema.character_sets is in is_columns_is.test.
# Retrieval of information_schema.character_sets content is in
# charset_collation.inc (sourced by charset_collation_*.test).
echo # Testcases 3.2.2.2 and 3.2.2.3 are checked in suite/funcs_1/t/charset_collation*.test;
--echo ########################################################################
--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
--echo # DDL on INFORMATION_SCHEMA tables are not supported
--echo ########################################################################
# 3.2.1.3: Ensure that no user may execute an INSERT statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.4: Ensure that no user may execute an UPDATE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.5: Ensure that no user may execute a DELETE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.8: Ensure that no user may create an index on an
# INFORMATION_SCHEMA table.
# 3.2.1.9: Ensure that no user may alter the definition of an
# INFORMATION_SCHEMA table.
# 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
# 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table to any
# other database.
# 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;
--enable_warnings
CREATE DATABASE db_datadict;
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.character_sets
SELECT * FROM information_schema.character_sets;
--error ER_DBACCESS_DENIED_ERROR
UPDATE information_schema.character_sets SET description = 'just updated';
--error ER_DBACCESS_DENIED_ERROR
DELETE FROM information_schema.character_sets WHERE table_name = 't1';
--error ER_DBACCESS_DENIED_ERROR
TRUNCATE information_schema.character_sets;
--error ER_DBACCESS_DENIED_ERROR
CREATE INDEX my_idx ON information_schema.character_sets(character_set_name);
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.character_sets DROP PRIMARY KEY;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.character_sets ADD f1 INT;
--error ER_DBACCESS_DENIED_ERROR
DROP TABLE information_schema.character_sets;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.character_sets RENAME db_datadict.character_sets;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.character_sets
RENAME information_schema.xcharacter_sets;
# Cleanup
DROP DATABASE db_datadict;

View File

@@ -0,0 +1,41 @@
# suite/funcs_1/t/is_cml_innodb.test
#
# Check the content of information_schema.columns about tables using
# UNICODE columns.
# Variant for storage engine InnoDB
#
# Author:
# 2008-06-04 mleich Create this script based on older scripts and new code.
#
--source include/have_ucs2.inc
# This test cannot be used for the embedded server because privileges
# are expected within result sets.
--source include/not_embedded.inc
--source include/have_innodb.inc
let $engine_type= InnoDB;
USE test;
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
eval CREATE TABLE t1
(
f1 CHAR UNICODE,
f2 CHAR(0) UNICODE,
f3 CHAR(10) UNICODE,
f5 VARCHAR(0) UNICODE,
f6 VARCHAR(255) UNICODE,
f7 VARCHAR(260) UNICODE,
f8 TEXT UNICODE,
f9 TINYTEXT UNICODE,
f10 MEDIUMTEXT UNICODE,
f11 LONGTEXT UNICODE
) ENGINE = $engine_type;
# We look only for the tables created here.
let $my_where = WHERE table_schema LIKE 'test%';
--source suite/funcs_1/datadict/columns.inc
DROP TABLE t1;

View File

@@ -0,0 +1,37 @@
# suite/funcs_1/t/is_cml_memory.test
#
# Check the content of information_schema.columns about tables using
# UNICODE columns.
# Variant for storage engine MEMORY
#
# Author:
# 2008-06-04 mleich Create this script based on older scripts and new code.
#
--source include/have_ucs2.inc
# This test cannot be used for the embedded server because privileges
# are expected within result sets.
--source include/not_embedded.inc
let $engine_type= MEMORY;
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
USE test;
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
eval CREATE TABLE t1
(
f1 CHAR UNICODE,
f2 CHAR(0) UNICODE,
f3 CHAR(10) UNICODE,
f5 VARCHAR(0) UNICODE,
f6 VARCHAR(255) UNICODE,
f7 VARCHAR(260) UNICODE
) ENGINE = $engine_type;
# We look only for the tables created here.
let $my_where = WHERE table_schema LIKE 'test%';
--source suite/funcs_1/datadict/columns.inc
DROP TABLE t1;

View File

@@ -0,0 +1,41 @@
# suite/funcs_1/t/is_cml_myisam.test
#
# Check the content of information_schema.columns about tables using
# UNICODE columns.
# Variant for storage engine MyISAM
#
# Author:
# 2008-06-04 mleich Create this script based on older scripts and new code.
#
--source include/have_ucs2.inc
# This test cannot be used for the embedded server because privileges
# are expected within result sets.
--source include/not_embedded.inc
let $engine_type= MyISAM;
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
USE test;
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
eval CREATE TABLE t1
(
f1 CHAR UNICODE,
f2 CHAR(0) UNICODE,
f3 CHAR(10) UNICODE,
f5 VARCHAR(0) UNICODE,
f6 VARCHAR(255) UNICODE,
f7 VARCHAR(260) UNICODE,
f8 TEXT UNICODE,
f9 TINYTEXT UNICODE,
f10 MEDIUMTEXT UNICODE,
f11 LONGTEXT UNICODE
) ENGINE = $engine_type;
# We look only for the tables created here.
let $my_where = WHERE table_schema LIKE 'test%';
--source suite/funcs_1/datadict/columns.inc
DROP TABLE t1;

View File

@@ -0,0 +1,42 @@
# suite/funcs_1/t/is_cml_ndb.test
#
# Check the content of information_schema.columns about tables using
# UNICODE columns.
# Variant for storage engine NDB
#
# Author:
# 2008-06-04 mleich Create this script based on older scripts and new code.
#
--source include/have_ucs2.inc
# This test cannot be used for the embedded server because privileges
# are expected within result sets.
--source include/not_embedded.inc
--source include/have_ndb.inc
let $engine_type= NDB;
USE test;
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
eval CREATE TABLE t1
(
f1 CHAR UNICODE,
f2 CHAR(0) UNICODE,
f3 CHAR(10) UNICODE,
f5 VARCHAR(0) UNICODE,
f6 VARCHAR(255) UNICODE,
f7 VARCHAR(260) UNICODE,
f8 TEXT UNICODE,
f9 TINYTEXT UNICODE,
f10 MEDIUMTEXT UNICODE,
f11 LONGTEXT UNICODE,
PRIMARY KEY(f1)
) ENGINE = $engine_type;
# We look only for the tables created here.
let $my_where = WHERE table_schema LIKE 'test%';
--source suite/funcs_1/datadict/columns.inc
DROP TABLE t1;

View File

@@ -0,0 +1,113 @@
# suite/funcs_1/t/is_coll_char_set_appl.test
#
# Check the layout of information_schema.collation_character_set_applicability
# and some functionality related tests.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
if (`SELECT VERSION() LIKE '%embedded%'`)
{
--skip Bug#37456 funcs_1: Several tests crash when used with embedded server
}
let $is_table = COLLATION_CHARACTER_SET_APPLICABILITY;
# The table INFORMATION_SCHEMA.CHARACTER_SET_APPLICABILITY must exist
eval SHOW TABLES FROM information_schema LIKE '$is_table';
--echo #######################################################################
--echo # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
--echo #######################################################################
# Ensure that every INFORMATION_SCHEMA table can be queried with a SELECT
# statement, just as if it were an ordinary user-defined table.
#
--source suite/funcs_1/datadict/is_table_query.inc
--echo #########################################################################
--echo # Testcase 3.2.4.1: INFORMATION_SCHEMA.CHARACTER_SET_APPLICABILITY layout
--echo #########################################################################
# Ensure that the INFORMATION_SCHEMA.CHARACTER_SET_APPLICABILITY table has the
# following columns, in the following order:
#
# COLLATION_NAME (shows the name of a collation),
# CHARACTER_SET_NAME (shows the name of a character set to which that
# collation applies).
#
eval DESCRIBE information_schema.$is_table;
eval SHOW CREATE TABLE information_schema.$is_table;
eval SHOW COLUMNS FROM information_schema.$is_table;
# Note: Retrieval of information within information_schema.columns about
# information_schema.collation_character_set_applicability is in
# is_columns_is.test.
# Retrieval of information_schema.collation_character_set_applicability
# content is in charset_collation.inc (sourced by charset_collation_*.test).
echo # Testcases 3.2.4.2 and 3.2.4.3 are checked in suite/funcs_1/t/charset_collation*.test;
--echo ########################################################################
--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
--echo # DDL on INFORMATION_SCHEMA tables are not supported
--echo ########################################################################
# 3.2.1.3: Ensure that no user may execute an INSERT statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.4: Ensure that no user may execute an UPDATE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.5: Ensure that no user may execute a DELETE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.8: Ensure that no user may create an index on an
# INFORMATION_SCHEMA table.
# 3.2.1.9: Ensure that no user may alter the definition of an
# INFORMATION_SCHEMA table.
# 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
# 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table to any
# other database.
# 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;
--enable_warnings
CREATE DATABASE db_datadict;
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.collation_character_set_applicability
SELECT * FROM information_schema.collation_character_set_applicability;
--error ER_DBACCESS_DENIED_ERROR
UPDATE information_schema.collation_character_set_applicability
SET collation_name = 'big6_chinese_ci' WHERE character_set_name = 'big6';
--error ER_DBACCESS_DENIED_ERROR
UPDATE information_schema.collation_character_set_applicability
SET character_set_name = 't_4711';
--error ER_DBACCESS_DENIED_ERROR
DELETE FROM information_schema.collation_character_set_applicability;
--error ER_DBACCESS_DENIED_ERROR
TRUNCATE information_schema.collation_character_set_applicability;
--error ER_DBACCESS_DENIED_ERROR
CREATE INDEX my_idx
ON information_schema.collation_character_set_applicability(collation_name);
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.collation_character_set_applicability ADD f1 INT;
--error ER_DBACCESS_DENIED_ERROR
DROP TABLE information_schema.collation_character_set_applicability;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.collation_character_set_applicability
RENAME db_datadict.collation_character_set_applicability;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.collation_character_set_applicability
RENAME information_schema.xcollation_character_set_applicability;
# Cleanup
DROP DATABASE db_datadict;

View File

@@ -0,0 +1,118 @@
# suite/funcs_1/t/is_collations.test
#
# Check the layout of information_schema.collations and some
# functionality related tests.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
if (`SELECT VERSION() LIKE '%embedded%'`)
{
--skip Bug#37456 funcs_1: Several tests crash when used with embedded server
}
let $is_table = COLLATIONS;
# The table INFORMATION_SCHEMA.COLLATIONS must exist
eval SHOW TABLES FROM information_schema LIKE '$is_table';
--echo #######################################################################
--echo # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
--echo #######################################################################
# Ensure that every INFORMATION_SCHEMA table can be queried with a SELECT
# statement, just as if it were an ordinary user-defined table.
#
--source suite/funcs_1/datadict/is_table_query.inc
--echo #########################################################################
--echo # Testcase 3.2.3.1: INFORMATION_SCHEMA.COLLATIONS layout
--echo #########################################################################
# Ensure that the INFORMATION_SCHEMA.COLLATIONS table has the following
# columns, in the following order:
#
# COLLATION_NAME (shows a collation name),
# CHARACTER_SET_NAME (shows the name of the character set to which the
# collation applies),
# ID (shows a numeric identifier for that collation/character set combination),
# IS_DEFAULT (shows whether the collation is the default collation for the
# character set shown),
# IS_COMPILED (indicates whether the collation is compiled into the MySQL server),
# SORTLEN (shows a value related to the amount of memory required to sort
# strings using this collation/character set combination).
#
eval DESCRIBE information_schema.$is_table;
eval SHOW CREATE TABLE information_schema.$is_table;
eval SHOW COLUMNS FROM information_schema.$is_table;
# Note: Retrieval of information within information_schema.columns about
# information_schema.collations is in is_columns_is.test.
# Retrieval of information_schema.collations content is in
# charset_collation.inc (sourced by charset_collation_*.test).
echo # Testcases 3.2.3.2 and 3.2.3.3 are checked in suite/funcs_1/t/charset_collation*.test;
--echo ########################################################################
--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
--echo # DDL on INFORMATION_SCHEMA tables are not supported
--echo ########################################################################
# 3.2.1.3: Ensure that no user may execute an INSERT statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.4: Ensure that no user may execute an UPDATE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.5: Ensure that no user may execute a DELETE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.8: Ensure that no user may create an index on an INFORMATION_SCHEMA table.
# 3.2.1.9: Ensure that no user may alter the definition of an
# INFORMATION_SCHEMA table.
# 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
# 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table to any
# other database.
# 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;
--enable_warnings
CREATE DATABASE db_datadict;
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.collations
SELECT * FROM information_schema.collations;
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.collations
(collation_name,character_set_name,id,is_default,is_compiled,sortlen)
VALUES ( 'cp1251_bin', 'cp1251',50, '', '',0);
--error ER_DBACCESS_DENIED_ERROR
UPDATE information_schema.collations SET description = 'just updated';
--error ER_DBACCESS_DENIED_ERROR
DELETE FROM information_schema.collations WHERE table_name = 't1';
--error ER_DBACCESS_DENIED_ERROR
TRUNCATE information_schema.collations;
--error ER_DBACCESS_DENIED_ERROR
CREATE INDEX my_idx ON information_schema.collations(character_set_name);
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.collations DROP PRIMARY KEY;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.collations ADD f1 INT;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.collations ENABLE KEYS;
--error ER_DBACCESS_DENIED_ERROR
DROP TABLE information_schema.collations;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.collations RENAME db_datadict.collations;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.collations
RENAME information_schema.xcollations;
# Cleanup
DROP DATABASE db_datadict;

View File

@@ -0,0 +1,353 @@
# suite/funcs_1/t/is_column_privileges.test
#
# Check the layout of information_schema.column_privileges and the impact of
# CREATE/ALTER/DROP TABLE/VIEW/SCHEMA ... on it.
#
# Note:
# This test is not intended
# - to show information about the all time existing tables
# within the databases information_schema and mysql
# - for checking storage engine properties
# Therefore please do not alter $engine_type and $other_engine_type.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
let $engine_type = MEMORY;
let $other_engine_type = MyISAM;
let $is_table = COLUMN_PRIVILEGES;
# The table INFORMATION_SCHEMA.COLUMN_PRIVILEGES must exist
eval SHOW TABLES FROM information_schema LIKE '$is_table';
--echo #######################################################################
--echo # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
--echo #######################################################################
# Ensure that every INFORMATION_SCHEMA table can be queried with a SELECT
# statement, just as if it were an ordinary user-defined table.
#
--source suite/funcs_1/datadict/is_table_query.inc
--echo #########################################################################
--echo # Testcase 3.2.5.1: INFORMATION_SCHEMA.COLUMN_PRIVILEGES layout
--echo #########################################################################
# Ensure that the INFORMATION_SCHEMA.COLUMN_PRIVILEGES table has the following
# columns, in the following order:
#
# GRANTEE (shows the name of a user who has either granted,
# or been granted a column privilege),
# TABLE_CATALOG (always shows NULL),
# TABLE_SCHEMA (shows the name of the schema, or database, in which the table
# for which a column privilege has been granted resides),
# TABLE_NAME (shows the name of the table),
# COLUMN_NAME (shows the name of the column on which a column privilege has
# been granted),
# PRIVILEGE_TYPE (shows the type of privilege that was granted; must be either
# SELECT, INSERT, UPDATE, or REFERENCES),
# IS_GRANTABLE (shows whether that privilege was granted WITH GRANT OPTION).
#
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval DESCRIBE information_schema.$is_table;
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval SHOW CREATE TABLE information_schema.$is_table;
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval SHOW COLUMNS FROM information_schema.$is_table;
# Note: Retrieval of information within information_schema.columns
# about information_schema.column_privileges is in is_columns_is.test.
# Show that TABLE_CATALOG is always NULL.
SELECT table_catalog, table_schema, table_name, column_name, privilege_type
FROM information_schema.column_privileges WHERE table_catalog IS NOT NULL;
--echo ######################################################################
--echo # Testcase 3.2.5.2+3.2.5.3+3.2.5.4:
--echo # INFORMATION_SCHEMA.COLUMN_PRIVILEGES accessible information
--echo ######################################################################
# 3.2.5.2: Ensure that the table shows the relevant information on every
# column privilege which has been granted to the current user or
# PUBLIC, or which was granted by the current user.
# 3.2.5.3: Ensure that the table does not show any information on any column
# privilege which was granted to any user other than the current user
# or PUBLIC, or which was granted by any user other than
# the current user.
# 3.2.5.4: Ensure that the table does not show any information on any
# privileges that are not column privileges for the current user.
#
# Note: Check of content within information_schema.column_privileges about the
# databases information_schema, mysql and test is in
# is_column_privileges_is_mysql_test.test
#
--disable_warnings
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
--replace_result $other_engine_type <other_engine_type>
eval
CREATE TABLE db_datadict.t1 (f1 INT, f2 DECIMAL, f3 TEXT)
ENGINE = $other_engine_type;
USE db_datadict;
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
--error 0,ER_CANNOT_USER
DROP USER 'testuser2'@'localhost';
CREATE USER 'testuser2'@'localhost';
--error 0,ER_CANNOT_USER
DROP USER 'testuser3'@'localhost';
CREATE USER 'testuser3'@'localhost';
GRANT SELECT(f1, f3) ON db_datadict.t1 TO 'testuser1'@'localhost';
GRANT INSERT(f1) ON db_datadict.t1 TO 'testuser1'@'localhost';
GRANT UPDATE(f2) ON db_datadict.t1 TO 'testuser1'@'localhost';
GRANT SELECT(f2) ON db_datadict.t1 TO 'testuser2'@'localhost';
GRANT INSERT, SELECT ON db_datadict.t1 TO 'testuser3'@'localhost';
GRANT SELECT(f3) ON db_datadict.t1 TO 'testuser3'@'localhost';
GRANT INSERT, SELECT ON db_datadict.t1 TO 'testuser3'@'localhost'
WITH GRANT OPTION;
GRANT ALL ON db_datadict.* TO 'testuser3'@'localhost';
let $select= SELECT * FROM information_schema.column_privileges
WHERE grantee LIKE '''testuser%'''
ORDER BY grantee, table_schema,table_name,column_name,privilege_type;
eval $select;
# Note: WITH GRANT OPTION applies to all privileges on this table
# and not to the columns mentioned only.
GRANT UPDATE(f3) ON db_datadict.t1 TO 'testuser1'@'localhost'
WITH GRANT OPTION;
eval $select;
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , db_datadict);
eval $select;
--echo # Establish connection testuser2 (user=testuser2)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser2, localhost, testuser2, , db_datadict);
eval $select;
--echo # Establish connection testuser3 (user=testuser3)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser3, localhost, testuser3, , db_datadict);
--echo # FIXME: Is it correct that granted TABLES do not occur in COLUMN_PRIVILEGES?
SELECT * FROM information_schema.table_privileges
WHERE grantee LIKE '''testuser%'''
ORDER BY grantee,table_schema,table_name,privilege_type;
SELECT * FROM information_schema.schema_privileges
WHERE grantee LIKE '''testuser%'''
ORDER BY grantee,table_schema,privilege_type;
eval $select;
GRANT SELECT(f1, f3) ON db_datadict.t1 TO 'testuser2'@'localhost';
--echo # FIXME: Is it intended that *my* grants to others are *NOT* shown here?
eval $select;
--echo # Switch to connection testuser2 (user=testuser2)
connection testuser2;
eval $select;
# Cleanup
--echo # Switch to connection default and close connections testuser1,testuser2,testuser3
connection default;
disconnect testuser1;
disconnect testuser2;
disconnect testuser3;
DROP DATABASE db_datadict;
DROP USER 'testuser1'@'localhost';
DROP USER 'testuser2'@'localhost';
DROP USER 'testuser3'@'localhost';
--echo ################################################################################
--echo # 3.2.1.13+3.2.1.14+3.2.1.15: INFORMATION_SCHEMA.COLUMN_PRIVILEGES modifications
--echo ################################################################################
# 3.2.1.13: Ensure that the creation of any new database object (e.g. table or
# column) automatically inserts all relevant information on that
# object into every appropriate INFORMATION_SCHEMA table.
# 3.2.1.14: Ensure that the alteration of any existing database object
# automatically updates all relevant information on that object in
# every appropriate INFORMATION_SCHEMA table.
# 3.2.1.15: Ensure that the dropping of any existing database object
# automatically deletes all relevant information on that object from
# every appropriate INFORMATION_SCHEMA table.
#
# Note (mleich):
# The MySQL privilege system allows to GRANT objects before they exist.
# (Exception: Grant privileges for columns of not existing tables/views.)
# There is also no migration of privileges if objects (tables, views, columns)
# are moved to other databases (tables only), renamed or dropped.
#
--disable_warnings
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
--replace_result $engine_type <engine_type>
eval
CREATE TABLE db_datadict.my_table (f1 BIGINT, f2 CHAR(10), f3 DATE)
ENGINE = $engine_type;
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
GRANT ALL ON test.* TO 'testuser1'@'localhost';
let $my_select = SELECT * FROM information_schema.column_privileges
WHERE table_name = 'my_table'
ORDER BY grantee, table_schema,table_name,column_name,privilege_type;
let $my_show = SHOW GRANTS FOR 'testuser1'@'localhost';
eval $my_select;
eval $my_show;
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , test);
eval $my_select;
eval $my_show;
--echo # Switch to connection default
connection default;
GRANT SELECT (f1,f3) ON db_datadict.my_table TO 'testuser1'@'localhost';
eval $my_select;
eval $my_show;
--echo # Switch to connection testuser1
connection testuser1;
eval $my_select;
eval $my_show;
--echo # Switch to connection default
connection default;
ALTER TABLE db_datadict.my_table DROP COLUMN f3;
GRANT UPDATE (f1) ON db_datadict.my_table TO 'testuser1'@'localhost';
eval $my_select;
eval $my_show;
--echo # Switch to connection testuser1
connection testuser1;
eval $my_select;
eval $my_show;
--error ER_BAD_FIELD_ERROR
SELECT f1, f3 FROM db_datadict.my_table;
--echo # Switch to connection default
connection default;
ALTER TABLE db_datadict.my_table CHANGE COLUMN f1 my_col BIGINT;
eval $my_select;
eval $my_show;
--echo # Switch to connection testuser1
connection testuser1;
eval $my_select;
eval $my_show;
--echo # Switch to connection default
connection default;
DROP TABLE db_datadict.my_table;
eval $my_select;
eval $my_show;
--echo # Switch to connection testuser1
connection testuser1;
eval $my_select;
eval $my_show;
--echo # Switch to connection default
connection default;
REVOKE ALL ON db_datadict.my_table FROM 'testuser1'@'localhost';
eval $my_select;
eval $my_show;
--echo # Switch to connection testuser1
connection testuser1;
eval $my_select;
eval $my_show;
--echo # Switch to connection default and close connection testuser1
connection default;
disconnect testuser1;
DROP USER 'testuser1'@'localhost';
DROP DATABASE db_datadict;
--echo ########################################################################
--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
--echo # DDL on INFORMATION_SCHEMA table are not supported
--echo ########################################################################
# 3.2.1.3: Ensure that no user may execute an INSERT statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.4: Ensure that no user may execute an UPDATE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.5: Ensure that no user may execute a DELETE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.8: Ensure that no user may create an index on an
# INFORMATION_SCHEMA table.
# 3.2.1.9: Ensure that no user may alter the definition of an
# INFORMATION_SCHEMA table.
# 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
# 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table to any
# other database.
# 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;
--enable_warnings
CREATE DATABASE db_datadict;
--replace_result $engine_type <engine_type>
eval
CREATE TABLE db_datadict.t1 (f1 BIGINT, f2 BIGINT)
ENGINE = $engine_type;
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
GRANT SELECT (f1) ON db_datadict.t1 TO 'testuser1'@'localhost';
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.column_privileges
SELECT * FROM information_schema.column_privileges;
--error ER_DBACCESS_DENIED_ERROR
UPDATE information_schema.column_privileges SET table_schema = 'test'
WHERE table_name = 't1';
--error ER_DBACCESS_DENIED_ERROR
DELETE FROM information_schema.column_privileges WHERE table_name = 't1';
--error ER_DBACCESS_DENIED_ERROR
TRUNCATE information_schema.column_privileges;
--error ER_DBACCESS_DENIED_ERROR
CREATE INDEX my_idx_on_tables
ON information_schema.column_privileges(table_schema);
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.column_privileges ADD f1 INT;
--error ER_DBACCESS_DENIED_ERROR
DROP TABLE information_schema.column_privileges;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.column_privileges
RENAME db_datadict.column_privileges;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.column_privileges
RENAME information_schema.xcolumn_privileges;
# Cleanup
DROP DATABASE db_datadict;
DROP USER 'testuser1'@'localhost';

View File

@@ -0,0 +1,61 @@
# suite/funcs_1/t/is_column_privileges_is_mysql_test.test
#
# Check the content of information_schema.column_privileges about the databases
# information_schema and mysql visible to high and low privileged users.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
--echo ##############################################################################
--echo # Testcases 3.2.9.2+3.2.9.3 INFORMATION_SCHEMA.SCHEMATA accessible information
--echo ##############################################################################
# 3.2.9.2 Ensure that the table shows the relevant information for every
# database on which the current user or PUBLIC have privileges.
# 3.2.9.3 Ensure that the table does not show any information on any databases
# on which the current user and PUBLIC have no privileges.
#
--disable_warnings
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
# Create a low privileged user.
# Note: The database db_datadict is just a "home" for the low privileged user
# and not in the focus of testing.
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
GRANT SELECT ON db_datadict.* TO 'testuser1'@'localhost';
let $my_select = SELECT * FROM information_schema.column_privileges
WHERE table_schema IN ('information_schema','mysql','test')
ORDER BY table_schema, table_name, column_name;
let $my_show1 = SHOW DATABASES LIKE 'information_schema';
let $my_show2 = SHOW DATABASES LIKE 'mysql';
let $my_show3 = SHOW DATABASES LIKE 'test';
eval $my_select;
eval $my_show1;
eval $my_show2;
eval $my_show3;
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , db_datadict);
eval $my_select;
eval $my_show1;
eval $my_show2;
eval $my_show3;
# Cleanup
--echo # Switch to connection default and close connection testuser1
connection default;
DROP USER 'testuser1'@'localhost';
DROP DATABASE db_datadict;

View File

@@ -0,0 +1,446 @@
# suite/funcs_1/t/is_columns.test
#
# Check the layout of information_schema.columns and the impact of
# CREATE/ALTER/DROP TABLE/VIEW/SCHEMA/COLUMN ... on its content.
#
# Note:
# This test is not intended
# - to show information about the all time existing tables
# within the databases information_schema and mysql
# - for checking storage engine properties
# Therefore please do not alter $engine_type and $other_engine_type.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
let $engine_type = MEMORY;
let $other_engine_type = MyISAM;
let $is_table = COLUMNS;
# The table INFORMATION_SCHEMA.COLUMNS must exist
eval SHOW TABLES FROM information_schema LIKE '$is_table';
--echo #######################################################################
--echo # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
--echo #######################################################################
# Ensure that every INFORMATION_SCHEMA table can be queried with a SELECT
# statement, just as if it were an ordinary user-defined table.
#
--source suite/funcs_1/datadict/is_table_query.inc
--echo #########################################################################
--echo # Testcase 3.2.6.1: INFORMATION_SCHEMA.COLUMNS layout
--echo #########################################################################
# Ensure that the INFORMATION_SCHEMA.COLUMNS table has the following columns,
# in the following order:
#
# TABLE_CATALOG (always shows NULL),
# TABLE_SCHEMA (shows the name of the database, or schema, in which an
# accessible table resides),
# TABLE_NAME (shows the name of an accessible table),
# COLUMN_NAME (shows the name of a column within that table),
# ORDINAL_POSITION (shows the ordinal position of that column in that table),
# COLUMN_DEFAULT (shows the column's default value),
# IS_NULLABLE (shows whether the column may accept NULL values),
# DATA_TYPE (shows the column's defined data type; keyword only),
# CHARACTER_MAXIMUM_LENGTH (shows, for a string column, the column's defined
# maximum length in characters; otherwise NULL),
# CHARACTER_OCTET_LENGTH (shows, for a string column, the column's defined
# maximum length in octets; otherwise NULL),
# NUMERIC_PRECISION (shows, for a numeric column, the column's or data type's
# defined precision; otherwise NULL),
# NUMERIC_SCALE (shows, for a numeric column, the column's or data type's
# defined scale; otherwise NULL),
# CHARACTER_SET_NAME (shows, for a character string column, the column's default
# character set; otherwise NULL),
# COLLATION_NAME (shows, for a character string column, the column's default
# collation; otherwise NULL),
# COLUMN_TYPE (shows the column's complete, defined data type),
# COLUMN_KEY (shows whether the column is indexed; possible values are PRI if
# the column is part of a PRIMARY KEY, UNI if the column is part of a
# UNIQUE key, MUL if the column is part of an index key that allows
# duplicates),
# EXTRA (shows any additional column definition information, e.g. whether the
# column was defined with the AUTO_INCREMENT attribute),
# PRIVILEGES (shows the privileges available to the user on the column),
# COLUMN_COMMENT (shows the comment, if any, defined for the comment;
# otherwise NULL).
#
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval DESCRIBE information_schema.$is_table;
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval SHOW CREATE TABLE information_schema.$is_table;
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval SHOW COLUMNS FROM information_schema.$is_table;
# Note: Retrieval of information within information_schema.columns about
# information_schema.columns is in is_columns_is.test.
# Show that TABLE_CATALOG is always NULL.
SELECT table_catalog, table_schema, table_name, column_name
FROM information_schema.columns WHERE table_catalog IS NOT NULL;
--echo ###############################################################################
--echo # Testcase 3.2.6.2 + 3.2.6.3: INFORMATION_SCHEMA.COLUMNS accessible information
--echo ###############################################################################
# 3.2.6.2: Ensure that the table shows the relevant information on the columns
# of every table that is accessible to the current user or to PUBLIC.
# 3.2.6.3: Ensure that the table does not show any information on the columns
# of any table which is not accessible to the current user or PUBLIC.
#
# Note: Check of content within information_schema.columns about
# databases is in
# mysql is_columns_mysql.test
# information_schema is_columns_is.test
# test% is_columns_<engine>.test
#
--disable_warnings
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
--error 0,ER_CANNOT_USER
DROP USER 'testuser2'@'localhost';
CREATE USER 'testuser2'@'localhost';
--replace_result $other_engine_type <other_engine_type>
eval
CREATE TABLE db_datadict.t1
(f1 CHAR(10), f2 TEXT, f3 DATE, f4 INT AUTO_INCREMENT,
UNIQUE INDEX MUL_IDX(f1,f3), PRIMARY KEY (f4))
ENGINE = $other_engine_type;
CREATE VIEW db_datadict.v1 AS SELECT 1 AS f1, 1 AS f2;
GRANT SELECT(f1, f2) ON db_datadict.t1 TO 'testuser1'@'localhost';
GRANT SELECT(f2) ON db_datadict.v1 TO 'testuser1'@'localhost';
--replace_result $other_engine_type <other_engine_type>
eval
CREATE TABLE db_datadict.t2
(f1 CHAR(10), f2 TEXT, f3 DATE, f4 INT, PRIMARY KEY (f1,f4))
ENGINE = $other_engine_type;
GRANT INSERT(f1, f2) ON db_datadict.t2 TO 'testuser2'@'localhost';
let $my_select= SELECT * FROM information_schema.columns
WHERE table_schema = 'db_datadict'
ORDER BY table_schema, table_name, ordinal_position;
let $my_show1 = SHOW COLUMNS FROM db_datadict.t1;
let $my_show2 = SHOW COLUMNS FROM db_datadict.t2;
let $my_show3 = SHOW COLUMNS FROM db_datadict.v1;
# Point of view of user root.
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval $my_select;
eval $my_show1;
eval $my_show2;
eval $my_show3;
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , db_datadict);
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval $my_select;
eval $my_show1;
--error ER_TABLEACCESS_DENIED_ERROR
eval $my_show2;
eval $my_show3;
--echo # Establish connection testuser2 (user=testuser2)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser2, localhost, testuser2, , db_datadict);
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval $my_select;
--error ER_TABLEACCESS_DENIED_ERROR
eval $my_show1;
eval $my_show2;
--error ER_TABLEACCESS_DENIED_ERROR
eval $my_show3;
--echo # Switch to connection default and close connections testuser1, testuser2
connection default;
disconnect testuser1;
disconnect testuser2;
# Cleanup
DROP USER 'testuser1'@'localhost';
DROP USER 'testuser2'@'localhost';
DROP DATABASE IF EXISTS db_datadict;
--echo ###############################################################################
--echo # Testcase 3.2.1.13+3.2.1.14+3.2.1.15: INFORMATION_SCHEMA.COLUMNS modifications
--echo ###############################################################################
# 3.2.1.13: Ensure that the creation of any new database object (e.g. table or
# column) automatically inserts all relevant information on that
# object into every appropriate INFORMATION_SCHEMA table.
# 3.2.1.14: Ensure that the alteration of any existing database object
# automatically updates all relevant information on that object in
# every appropriate INFORMATION_SCHEMA table.
# 3.2.1.15: Ensure that the dropping of any existing database object
# automatically deletes all relevant information on that object from
# every appropriate INFORMATION_SCHEMA table.
#
--disable_warnings
DROP TABLE IF EXISTS test.t1_my_table;
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
SELECT table_name FROM information_schema.columns
WHERE table_name LIKE 't1_my_table%';
--replace_result $engine_type <engine_type>
eval
CREATE TABLE test.t1_my_table (f1 CHAR(12))
DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci
ENGINE = $engine_type;
# Settings used in CREATE TABLE must be visible in information_schema.columns.
--vertical_results
SELECT * FROM information_schema.columns
WHERE table_name = 't1_my_table';
--horizontal_results
#
# Check modification of TABLE_NAME
SELECT table_name FROM information_schema.columns
WHERE table_name LIKE 't1_my_table%';
RENAME TABLE test.t1_my_table TO test.t1_my_tablex;
SELECT table_name FROM information_schema.columns
WHERE table_name LIKE 't1_my_table%';
#
# Check modification of TABLE_SCHEMA
SELECT table_schema,table_name FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
RENAME TABLE test.t1_my_tablex TO db_datadict.t1_my_tablex;
SELECT table_schema,table_name FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
#
# Check modification of COLUMN_NAME
SELECT table_name, column_name FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
ALTER TABLE db_datadict.t1_my_tablex CHANGE COLUMN f1 first_col CHAR(12);
SELECT table_name, column_name FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
#
# Check modification of COLUMN size
SELECT table_name, column_name, character_maximum_length,
character_octet_length, column_type
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
ALTER TABLE db_datadict.t1_my_tablex
MODIFY COLUMN first_col CHAR(20);
SELECT table_name, column_name, character_maximum_length,
character_octet_length, column_type
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
#
# Check modification of COLUMN type
SELECT table_name, column_name, character_maximum_length,
character_octet_length, column_type
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
ALTER TABLE db_datadict.t1_my_tablex
MODIFY COLUMN first_col VARCHAR(20);
SELECT table_name, column_name, character_maximum_length,
character_octet_length, column_type
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
#
# Check modify COLUMN DEFAULT
SELECT table_name, column_name, column_default
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
ALTER TABLE db_datadict.t1_my_tablex
MODIFY COLUMN first_col CHAR(10) DEFAULT 'hello';
SELECT table_name, column_name, column_default
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
#
# Check modify IS_NULLABLE
SELECT table_name, column_name, is_nullable
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
ALTER TABLE db_datadict.t1_my_tablex
MODIFY COLUMN first_col CHAR(10) NOT NULL;
SELECT table_name, column_name, is_nullable
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
#
# Check modify COLLATION
SELECT table_name, column_name, collation_name
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
ALTER TABLE db_datadict.t1_my_tablex
MODIFY COLUMN first_col CHAR(10) COLLATE 'latin1_general_cs';
SELECT table_name, column_name, collation_name
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
#
# Check modify CHARACTER SET
SELECT table_name, column_name, character_maximum_length,
character_octet_length, character_set_name
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
ALTER TABLE db_datadict.t1_my_tablex
MODIFY COLUMN first_col CHAR(10) CHARACTER SET utf8;
SELECT table_name, column_name, character_maximum_length,
character_octet_length, character_set_name
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
#
# Check modify COLUMN_COMMENT
SELECT table_name, column_name, column_comment
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
ALTER TABLE db_datadict.t1_my_tablex
MODIFY COLUMN first_col CHAR(10) COMMENT 'Hello';
SELECT table_name, column_name, column_comment
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
#
# Check ADD COLUMN
SELECT table_name, column_name
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
ALTER TABLE db_datadict.t1_my_tablex
ADD COLUMN second_col CHAR(10);
SELECT table_name, column_name
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
#
# Check switch ordinal position of column
SELECT table_name, column_name, ordinal_position
FROM information_schema.columns
WHERE table_name = 't1_my_tablex'
ORDER BY table_name, column_name;
ALTER TABLE db_datadict.t1_my_tablex
MODIFY COLUMN second_col CHAR(10) FIRST;
SELECT table_name, column_name, ordinal_position
FROM information_schema.columns
WHERE table_name = 't1_my_tablex'
ORDER BY table_name, column_name;
#
# Check DROP COLUMN
SELECT table_name, column_name
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
ALTER TABLE db_datadict.t1_my_tablex
DROP COLUMN first_col;
SELECT table_name, column_name
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
#
# Check set COLUMN UNIQUE
SELECT table_name, column_name, column_key
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
ALTER TABLE db_datadict.t1_my_tablex
ADD UNIQUE INDEX IDX(second_col);
SELECT table_name, column_name, column_key
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
#
# Check impact of DROP TABLE
SELECT table_name, column_name
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
DROP TABLE db_datadict.t1_my_tablex;
SELECT table_name, column_name
FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
#
# Check a VIEW
CREATE VIEW test.t1_my_tablex
AS SELECT 1 AS "col1", 'A' collate latin1_german1_ci AS "col2";
--vertical_results
SELECT * FROM information_schema.columns
WHERE table_name = 't1_my_tablex'
ORDER BY table_name, column_name;
--horizontal_results
DROP VIEW test.t1_my_tablex;
SELECT table_name FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
#
# Check impact of DROP SCHEMA
--replace_result $engine_type <engine_type>
eval
CREATE TABLE db_datadict.t1_my_tablex
ENGINE = $engine_type AS
SELECT 1;
SELECT table_name FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
DROP DATABASE db_datadict;
SELECT table_name FROM information_schema.columns
WHERE table_name = 't1_my_tablex';
--echo ########################################################################
--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
--echo # DDL on INFORMATION_SCHEMA table are not supported
--echo ########################################################################
# 3.2.1.3: Ensure that no user may execute an INSERT statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.4: Ensure that no user may execute an UPDATE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.5: Ensure that no user may execute a DELETE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.8: Ensure that no user may create an index on an
# INFORMATION_SCHEMA table.
# 3.2.1.9: Ensure that no user may alter the definition of an
# INFORMATION_SCHEMA table.
# 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
# 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table to any
# other database.
# 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 test.t1;
--enable_warnings
CREATE DATABASE db_datadict;
CREATE TABLE test.t1 (f1 BIGINT);
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.columns (table_schema,table_name,column_name)
VALUES('test','t1', 'f2');
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.columns (table_schema,table_name,column_name)
VALUES('test','t2', 'f1');
--error ER_DBACCESS_DENIED_ERROR
UPDATE information_schema.columns SET table_name = 't4' WHERE table_name = 't1';
--error ER_DBACCESS_DENIED_ERROR
DELETE FROM information_schema.columns WHERE table_name = 't1';
--error ER_DBACCESS_DENIED_ERROR
TRUNCATE information_schema.columns;
--error ER_DBACCESS_DENIED_ERROR
CREATE INDEX i3 ON information_schema.columns(table_name);
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.columns ADD f1 INT;
--error ER_DBACCESS_DENIED_ERROR
DROP TABLE information_schema.columns;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.columns RENAME db_datadict.columns;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.columns RENAME information_schema.xcolumns;
# Cleanup
DROP TABLE test.t1;
DROP DATABASE db_datadict;

View File

@@ -0,0 +1,25 @@
# suite/funcs_1/t/is_columns_innodb.test
#
# Check the content of information_schema.columns about tables within
# the databases created by the user.
# Variant for storage engine InnoDB
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
--source include/have_innodb.inc
let $engine_type= InnoDB;
--source suite/funcs_1/datadict/datadict_load.inc
# We look only for the tables created by datadict_load.inc.
let $my_where = WHERE table_schema LIKE 'test%';
--source suite/funcs_1/datadict/columns.inc
--source suite/funcs_1/include/cleanup.inc

View File

@@ -0,0 +1,22 @@
# suite/funcs_1/t/is_columns_is.test
#
# Check the content of information_schema.columns about tables within
# the database information_schema.
# Variant for the non embedded server
# The expected results must equal is_columns_is_embedded except that
# columns.privileges are not empty.
#
# Note: The INFORMATION_SCHEMA table PROFILING is optional (exists in MySQL
# Community version only) and therefore we exclude it from retrieval.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
--source include/not_embedded.inc
let $my_where = WHERE table_schema = 'information_schema'
AND table_name <> 'profiling';
--source suite/funcs_1/datadict/columns.inc

View File

@@ -0,0 +1,23 @@
# suite/funcs_1/t/is_columns_is_embedded.test
#
# Check the content of information_schema.columns about tables within
# the database information_schema.
# Variant for the embedded server
# The expected results must equal is_columns_is except that
# columns.privileges is empty.
#
# Note: The INFORMATION_SCHEMA table PROFILING is optional (exists in MySQL
# Community version only) and therefore we exclude it from retrieval.
#
# Author:
# 2008-06-06 mleich Create this variant for the embedded server
#
if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{
--skip Test requires: embedded server
}
let $my_where = WHERE table_schema = 'information_schema'
AND table_name <> 'profiling';
--source suite/funcs_1/datadict/columns.inc

View File

@@ -0,0 +1,25 @@
# suite/funcs_1/t/is_columns_memory.test
#
# Check the content of information_schema.columns about tables within
# the databases created by the user.
# Variant for storage engine MEMORY
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
let $engine_type= MEMORY;
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
--source suite/funcs_1/datadict/datadict_load.inc
# We look only for the tables created by datadict_load.inc.
let $my_where = WHERE table_schema LIKE 'test%';
--source suite/funcs_1/datadict/columns.inc
--source suite/funcs_1/include/cleanup.inc

View File

@@ -0,0 +1,24 @@
# suite/funcs_1/t/is_columns_myisam.test
#
# Check the content of information_schema.columns about tables within
# the databases created by the user.
# Variant for storage engine MyISAM and the non embedded server
# The expected results must equal is_columns_myisam_embedded except that
# that the privilege system works (affects some result sets).
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
--source include/not_embedded.inc
let $engine_type= MyISAM;
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
--source suite/funcs_1/datadict/datadict_load.inc
# We look only for the tables created by datadict_load.inc.
let $my_where = WHERE table_schema LIKE 'test%';
--source suite/funcs_1/datadict/columns.inc
--source suite/funcs_1/include/cleanup.inc

View File

@@ -0,0 +1,25 @@
# suite/funcs_1/t/is_columns_myisam_embedded.test
#
# Check the content of information_schema.columns about tables within
# the databases created by the user.
# Variant for storage engine MyISAM and the embedded server
# The expected results must equal is_columns_myisam except that all users
# have all privileges (affects some result sets).
#
# Author:
# 2008-06-06 mleich Create this this variant for the embedded server.
#
if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{
--skip Test requires: embedded server
}
let $engine_type= MyISAM;
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
--source suite/funcs_1/datadict/datadict_load.inc
# We look only for the tables created by datadict_load.inc.
let $my_where = WHERE table_schema LIKE 'test%';
--source suite/funcs_1/datadict/columns.inc
--source suite/funcs_1/include/cleanup.inc

View File

@@ -0,0 +1,18 @@
# suite/funcs_1/t/is_columns_mysql.test
#
# Check the content of information_schema.columns about tables within
# the database mysql.
# Variant for the non embedded server
# The expected results must equal is_columns_mysql_embedded except that
# columns.privileges are not empty.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
--source include/not_embedded.inc
let $my_where = WHERE table_schema = 'mysql';
--source suite/funcs_1/datadict/columns.inc

View File

@@ -0,0 +1,19 @@
# suite/funcs_1/t/is_columns_mysql_embedded.test
#
# Check the content of information_schema.columns about tables within
# the database mysql.
# Variant for the embedded server
# The expected results must equal is_columns_mysql except that
# columns.privileges is empty.
#
# Author:
# 2008-06-06 mleich Create this variant for the embedded server
#
if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{
--skip Test requires: embedded server
}
let $my_where = WHERE table_schema = 'mysql';
--source suite/funcs_1/datadict/columns.inc

View File

@@ -0,0 +1,37 @@
# suite/funcs_1/t/is_columns_ndb.test
#
# Check the content of information_schema.columns about tables within
# the databases created by the user.
# Variant for storage engine ndb
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
--source include/have_ndb.inc
let $engine_type= ndb;
--source suite/funcs_1/datadict/datadict_load.inc
# We look only for the tables created by datadict_load.inc.
let $my_where = WHERE table_schema LIKE 'test%';
--source suite/funcs_1/datadict/columns.inc
# This test runs with a different set of tables.
# --source suite/funcs_1/include/cleanup.inc
DROP DATABASE test1;
DROP DATABASE test4;
DROP TABLE test.t1;
DROP TABLE test.t2;
DROP TABLE test.t3;
DROP TABLE test.t4;
DROP TABLE test.t7;
DROP TABLE test.t8;
DROP TABLE test.t9;
DROP TABLE test.t10;
DROP TABLE test.t11;

View File

@@ -0,0 +1,129 @@
# suite/funcs_1/t/is_engines.test
#
# Check the layout of information_schema.engines
#
# Note:
# This test is not intended
# - to show information about the all time existing tables
# within the databases information_schema and mysql
# - for checking storage engine properties
# Therefore please do not alter $engine_type and $other_engine_type.
# Some results of the subtests depend on the storage engines assigned.
#
# Author:
# 2008-02-29 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
#
if (`SELECT VERSION() LIKE '%embedded%'`)
{
--skip Bug#37456 funcs_1: Several tests crash when used with embedded server
}
let $engine_type = MEMORY;
let $other_engine_type = MyISAM;
let $is_table = ENGINES;
# The table INFORMATION_SCHEMA.ENGINES must exist
eval SHOW TABLES FROM information_schema LIKE '$is_table';
--echo #######################################################################
--echo # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
--echo #######################################################################
# Ensure that every INFORMATION_SCHEMA table can be queried with a SELECT
# statement, just as if it were an ordinary user-defined table.
#
--source suite/funcs_1/datadict/is_table_query.inc
--echo #########################################################################
--echo # Testcase 3.2.12.1: INFORMATION_SCHEMA.ENGINES layout
--echo #########################################################################
# Ensure that the INFORMATION_SCHEMA.ENGINES table has the following columns,
# in the following order:
#
# ENGINE
# SUPPORT
# COMMENT
# TRANSACTIONS
# XA
# SAVEPOINTS
#
# Value Meaning
# YES The feature is supported and is active.
# NO The feature is not supported = The server was compiled without
# support for the feature.
# DISABLED The feature is supported but has been disabled.
#
eval DESCRIBE information_schema.$is_table;
eval SHOW CREATE TABLE information_schema.$is_table;
eval SHOW COLUMNS FROM information_schema.$is_table;
# Note: Retrieval of information within information_schema.columns about
# information_schema.engines is in is_columns_is.test.
# FIXME: Check the regression tests and implement tests checking the
# functionality if missing.
--echo ########################################################################
--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
--echo # DDL on INFORMATION_SCHEMA tables are not supported
--echo ########################################################################
# 3.2.1.3: Ensure that no user may execute an INSERT statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.4: Ensure that no user may execute an UPDATE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.5: Ensure that no user may execute a DELETE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.8: Ensure that no user may create an index on an
# INFORMATION_SCHEMA table.
# 3.2.1.9: Ensure that no user may alter the definition of an
# INFORMATION_SCHEMA table.
# 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
# 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table to any
# other database.
# 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;
--enable_warnings
CREATE DATABASE db_datadict;
--replace_result $engine_type <engine_type>
eval
CREATE TABLE db_datadict.t1 (f1 BIGINT)
ENGINE = $engine_type;
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.engines
SELECT * FROM information_schema.engines;
--error ER_DBACCESS_DENIED_ERROR
UPDATE information_schema.engines SET engine = '1234567';
--error ER_DBACCESS_DENIED_ERROR
DELETE FROM information_schema.engines WHERE support IN ('DEFAULT','YES');
--error ER_DBACCESS_DENIED_ERROR
TRUNCATE information_schema.engines;
--error ER_DBACCESS_DENIED_ERROR
CREATE INDEX my_idx_on_engines ON information_schema.engines(engine);
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.engines DROP PRIMARY KEY;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.engines ADD f1 INT;
--error ER_DBACCESS_DENIED_ERROR
DROP TABLE information_schema.engines;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.engines RENAME db_datadict.engines;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.engines RENAME information_schema.xengines;
# Cleanup
DROP DATABASE db_datadict;

View File

@@ -0,0 +1,15 @@
# suite/funcs_1/t/is_engines_archive.test
#
# Check the content of information_schema.engines
# Variant for storage engine ARCHIVE
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
#
let $engine_type= ARCHIVE;
--source include/have_archive.inc
--vertical_results
eval SELECT * FROM information_schema.engines
WHERE ENGINE = '$engine_type';

View File

@@ -0,0 +1,15 @@
# suite/funcs_1/t/is_engines_blackhole.test
#
# Check the content of information_schema.engines
# Variant for storage engine BLACKHOLE
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
#
let $engine_type= BLACKHOLE;
--source include/have_blackhole.inc
--vertical_results
eval SELECT * FROM information_schema.engines
WHERE ENGINE = '$engine_type';

View File

@@ -0,0 +1,15 @@
# suite/funcs_1/t/is_engines_csv.test
#
# Check the content of information_schema.engines
# Variant for storage engine CSV
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
#
let $engine_type= CSV;
--source include/have_csv.inc
--vertical_results
eval SELECT * FROM information_schema.engines
WHERE ENGINE = '$engine_type';

View File

@@ -0,0 +1,15 @@
# suite/funcs_1/t/is_engines_federated.test
#
# Check the content of information_schema.engines
# Variant for storage engine FEDERATED
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
#
let $engine_type= FEDERATED;
--source suite/federated/include/have_federated_db.inc
--vertical_results
eval SELECT * FROM information_schema.engines
WHERE ENGINE = '$engine_type';

View File

@@ -0,0 +1,15 @@
# suite/funcs_1/t/is_engines_innodb.test
#
# Check the content of information_schema.engines
# Variant for storage engine InnoDB
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
#
let $engine_type= InnoDB;
--source include/have_innodb.inc
--vertical_results
eval SELECT * FROM information_schema.engines
WHERE ENGINE = '$engine_type';

View File

@@ -0,0 +1,14 @@
# suite/funcs_1/t/is_engines_memory.test
#
# Check the content of information_schema.engines
# Variant for storage engine MEMORY
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
#
let $engine_type= MEMORY;
--vertical_results
eval SELECT * FROM information_schema.engines
WHERE ENGINE = '$engine_type';

View File

@@ -0,0 +1,14 @@
# suite/funcs_1/t/is_engines_innodb.test
#
# Check the content of information_schema.engines
# Variant for storage engine InnoDB
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
#
let $engine_type= MRG_MYISAM;
--vertical_results
eval SELECT * FROM information_schema.engines
WHERE ENGINE = '$engine_type';

View File

@@ -0,0 +1,14 @@
# suite/funcs_1/t/is_tables_myisam.test
#
# Check the content of information_schema.engines
# Variant for storage engine MyISAM
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
#
let $engine_type= MyISAM;
--vertical_results
eval SELECT * FROM information_schema.engines
WHERE ENGINE = '$engine_type';

View File

@@ -0,0 +1,15 @@
# suite/funcs_1/t/is_engines_ndb.test
#
# Check the content of information_schema.engines
# Variant for storage engine NDB
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
#
let $engine_type= ndbcluster;
--source include/have_ndb.inc
--vertical_results
eval SELECT * FROM information_schema.engines
WHERE ENGINE = '$engine_type';

View File

@@ -0,0 +1,172 @@
# suite/funcs_1/t/is_events.test
#
# Check the layout of information_schema.events and some functionality of it.
#
# This test is not intended for checking storage engine properties
# Therefore please do not alter $engine_type and $other_engine_type.
#
# Author:
# 2008-02-29 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
#
if (`SELECT VERSION() LIKE '%embedded%'`)
{
--skip Bug#37456 funcs_1: Several tests crash when used with embedded server
}
let $engine_type = MEMORY;
let $other_engine_type = MyISAM;
let $is_table = EVENTS;
# The table INFORMATION_SCHEMA.EVENTS must exist
eval SHOW TABLES FROM information_schema LIKE '$is_table';
--echo #######################################################################
--echo # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
--echo #######################################################################
# Ensure that every INFORMATION_SCHEMA table can be queried with a SELECT
# statement, just as if it were an ordinary user-defined table.
#
--source suite/funcs_1/datadict/is_table_query.inc
--echo #########################################################################
--echo # Testcase 3.2.12.1: INFORMATION_SCHEMA.EVENTS layout
--echo #########################################################################
# Ensure that the INFORMATION_SCHEMA.EVENTS table has the following columns,
# in the following order:
#
# EVENT_CATALOG always NULL
# EVENT_SCHEMA The name of the schema (database) to which this
# event belongs.
# EVENT_NAME The name of the event.
# DEFINER The user who created the event.
# 'user_name'@'host_name' format!
# TIME_ZONE The time zone in effect when schedule for the event was
# last modified
# EVENT_BODY The language used for the statements in the event's
# DO clause. (always SQL)
# EVENT_DEFINITION The text of the SQL statement making up the event's
# DO clause.
# EVENT_TYPE One of the two values ONE TIME or RECURRING.
# EXECUTE_AT one-time event: DATETIME value specified in the AT clause
# of the CREATE EVENT statement used to
# create the event
# or of the last ALTER EVENT statement that modified
# the event.
# INTERVAL_VALUE recurring events; numeric portion of the event's
# EVERY clause.
# INTERVAL_FIELD recurring events: units portion of the EVERY clause
# governing the timing of the event, prefixed with
# 'INTERVAL_'. Example: 'INTERVAL_DAY'
# SQL_MODE The SQL mode in effect at the time the event was created
# or altered.
# STARTS For recurring event whose definition includes a STARTS
# clause, this column contains the corresponding
# DATETIME value. If there is no STARTS clause affecting
# the timing of the event, this column is empty.
# ENDS For a recurring event whose definition includes a ENDS
# clause, this column contains the corresponding DATETIME
# value. If there is no ENDS clause affecting the timing
# of the event, this column contains NULL.
# STATUS ENABLED, DISABLED or SLAVESIDE_DISABLED
# ON_COMPLETION PRESERVE or NOT PRESERVE.
# CREATED Date and time of event creation
# LAST_ALTERED Date and time of the last event modification
# never modified -> value = CREATED
# LAST_EXECUTED Date and time of start of last event execution
# never executed -> value IS NULL.
# EVENT_COMMENT The text of a comment. Default: empty string.
# ORIGINATOR The server ID of the MySQL server on which the event was
# created; used in replication. Default: 0
# CHARACTER_SET_CLIENT Session value of the character_set_client system variable
# when the event was created.
# COLLATION_CONNECTION Session value of the collation_connection system
# variable when the event was created.
# DATABASE_COLLATION Collation of the database with which the event
# is associated.
#
eval DESCRIBE information_schema.$is_table;
eval SHOW CREATE TABLE information_schema.$is_table;
eval SHOW COLUMNS FROM information_schema.$is_table;
# Note: Retrieval of information within information_schema.columns about
# information_schema.events is in is_columns_is.test.
# Check event_catalog event_body, event_type, event_type, status, on_completion
SELECT event_catalog, event_name, event_body, event_type, event_type,
status, on_completion
FROM information_schema.events
WHERE event_catalog IS NOT NULL or
event_body NOT IN ('SQL') or
event_type NOT IN ('ONE TIME','RECURRING') or
status NOT IN ('ENABLED','DISABLED','SLAVESIDE_DISABLED') or
on_completion NOT IN ('PRESERVE','NOT PRESERVE');
# FIXME: Check the regression tests and implement tests checking the
# functionality if missing.
--echo ########################################################################
--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
--echo # DDL on INFORMATION_SCHEMA tables are not supported
--echo ########################################################################
# 3.2.1.3: Ensure that no user may execute an INSERT statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.4: Ensure that no user may execute an UPDATE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.5: Ensure that no user may execute a DELETE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.8: Ensure that no user may create an index on an
# INFORMATION_SCHEMA table.
# 3.2.1.9: Ensure that no user may alter the definition of an
# INFORMATION_SCHEMA table.
# 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
# 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table to any
# other database.
# 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;
--enable_warnings
CREATE DATABASE db_datadict;
--replace_result $engine_type <engine_type>
eval
CREATE TABLE db_datadict.t1 (f1 BIGINT)
ENGINE = $engine_type;
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.events
SELECT * FROM information_schema.events;
--error ER_DBACCESS_DENIED_ERROR
UPDATE information_schema.events SET event_name = '1234567'
WHERE table_name = 't1';
--error ER_DBACCESS_DENIED_ERROR
DELETE FROM information_schema.events WHERE event_catalog IS NULL;
--error ER_DBACCESS_DENIED_ERROR
TRUNCATE information_schema.events;
--error ER_DBACCESS_DENIED_ERROR
CREATE INDEX my_idx_on_events ON information_schema.events(event_name);
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.events DROP PRIMARY KEY;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.events ADD f1 INT;
--error ER_DBACCESS_DENIED_ERROR
DROP TABLE information_schema.events;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.events RENAME db_datadict.events;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.events RENAME information_schema.xevents;
# Cleanup
DROP DATABASE db_datadict;

View File

@@ -0,0 +1,19 @@
# suite/funcs_1/t/is_key_column_usage.test
#
# Check the layout of information_schema.key_column_usage and the impact of
# CREATE/ALTER/DROP TABLE/VIEW/SCHEMA/COLUMN ... on it.
# Variant for the non embedded server
# The expected results must equal is_key_column_usage_embedded except that
# that the privilege system works (affects some result sets).
#
# There is detailed information about this test within
# suite/funcs_1/datadict/is_key_column_usage.inc
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
--source include/not_embedded.inc
--source suite/funcs_1/datadict/is_key_column_usage.inc

View File

@@ -0,0 +1,24 @@
# suite/funcs_1/t/is_key_column_usage_embedded.test
#
# Check the layout of information_schema.key_column_usage and the impact of
# CREATE/ALTER/DROP TABLE/VIEW/SCHEMA/COLUMN ... on it.
# Variant for the embedded server
# The expected results must equal is_key_column_usage except that all users
# have all privileges (affects some result sets).
#
# There is detailed information about this test within
# suite/funcs_1/datadict/is_key_column_usage.inc
#
# Author:
# 2008-06-06 mleich Create this this variant for the embedded server.
#
if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{
--skip Test requires: embedded server
}
if (`SELECT VERSION() LIKE '%embedded%'`)
{
--skip Bug#37456 funcs_1: Several tests crash when used with embedded server
}
--source suite/funcs_1/datadict/is_key_column_usage.inc

View File

@@ -0,0 +1,19 @@
# suite/funcs_1/t/is_routines.test
#
# Check the layout of information_schema.routines and the impact of
# CREATE/ALTER/DROP PROCEDURE/FUNCTION ... on it.
# Variant for the non embedded server
# The expected results must equal is_routines_embedded except that
# that the privilege system works (affects some result sets).
#
# There is detailed information about this test within
# suite/funcs_1/datadict/is_routines.inc
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
--source include/not_embedded.inc
--source suite/funcs_1/datadict/is_routines.inc

View File

@@ -0,0 +1,24 @@
# suite/funcs_1/t/is_routines_embedded.test
#
# Check the layout of information_schema.routines and the impact of
# CREATE/ALTER/DROP PROCEDURE/FUNCTION ... on it.
# Variant for the embedded server
# The expected results must equal is_routines except that all users
# have all privileges (affects some result sets).
#
# There is detailed information about this test within
# suite/funcs_1/datadict/is_routines.inc
#
# Author:
# 2008-06-06 mleich Create this this variant for the embedded server.
#
if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{
--skip Test requires: embedded server
}
if (`SELECT VERSION() LIKE '%embedded%'`)
{
--skip Bug#37456 funcs_1: Several tests crash when used with embedded server
}
--source suite/funcs_1/datadict/is_routines.inc

View File

@@ -0,0 +1,338 @@
# suite/funcs_1/t/is_schema_privileges.test
#
# Check the layout of information_schema.schema_privileges and the impact of
# CREATE/ALTER/DROP TABLE/VIEW/SCHEMA ... on it.
#
# Note:
# This test is not intended
# - to show information about the all time existing schemas
# information_schema and mysql
# - for checking storage engine properties
# Therefore please do not alter $engine_type and $other_engine_type.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
let $engine_type = MEMORY;
let $other_engine_type = MyISAM;
let $is_table = SCHEMA_PRIVILEGES;
# The table INFORMATION_SCHEMA.SCHEMA_PRIVILEGES must exist
eval SHOW TABLES FROM information_schema LIKE '$is_table';
--echo #######################################################################
--echo # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
--echo #######################################################################
# Ensure that every INFORMATION_SCHEMA table can be queried with a SELECT
# statement, just as if it were an ordinary user-defined table.
#
--source suite/funcs_1/datadict/is_table_query.inc
--echo #########################################################################
--echo # Testcase 3.2.15.1: INFORMATION_SCHEMA.SCHEMA_PRIVILEGES layout
--echo #########################################################################
# Ensure that the INFORMATION_SCHEMA.SCHEMA_PRIVILEGES table has the following
# columns, in the following order:
#
# GRANTEE (shows a user to whom a schema privilege has been granted),
# TABLE_CATALOG (always shows NULL),
# TABLE_SCHEMA (shows the name of the database, or schema, on which the
# privilege has been granted),
# PRIVILEGE_TYPE (shows the granted privilege),
# IS_GRANTABLE (shows whether the privilege was granted WITH GRANT OPTION)
#
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval DESCRIBE information_schema.$is_table;
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval SHOW CREATE TABLE information_schema.$is_table;
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval SHOW COLUMNS FROM information_schema.$is_table;
# Note: Retrieval of information within information_schema.columns
# about information_schema.schema_privileges is in is_columns_is.test.
# Show that TABLE_CATALOG is always NULL.
SELECT GRANTEE, TABLE_CATALOG, TABLE_SCHEMA, PRIVILEGE_TYPE
FROM information_schema.schema_privileges WHERE table_catalog IS NOT NULL;
--echo ###############################################################################
--echo # Testcase 3.2.15.2-3.2.15.4 INFORMATION_SCHEMA.SCHEMA_PRIVILEGES accessibility
--echo ###############################################################################
# 3.2.15.2 Ensure that the table shows the relevant information on every
# schema-level privilege which has been granted to the current user
# or to PUBLIC, or has been granted by the current user.
# FIXME: Why is "or has been granted by the current user" invisible?
# 3.2.15.3 Ensure that the table does not show any information on any
# schema-level privileges which have been granted to users
# other than the current user or to PUBLIC, or that have been
# granted by any user other than the current user.
# 3.2.15.4 Ensure that the table does not show any information on any
# privileges that are not schema-level privileges for the
# current user.
#
# Note: Check of content within information_schema.schema_privileges about the
# databases information_schema, mysql and test is in
# is_schema_privileges_is_mysql_test.
#
--disable_warnings
DROP DATABASE IF EXISTS db_datadict_1;
DROP DATABASE IF EXISTS db_datadict_2;
DROP DATABASE IF EXISTS db_datadict_3;
--enable_warnings
CREATE DATABASE db_datadict_1;
CREATE DATABASE db_datadict_2;
CREATE DATABASE db_datadict_3;
eval
CREATE TABLE db_datadict_2.t1(f1 INT, f2 INT, f3 INT)
ENGINE = $engine_type;
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
--error 0,ER_CANNOT_USER
DROP USER 'testuser2'@'localhost';
CREATE USER 'testuser2'@'localhost';
GRANT INSERT ON db_datadict_1.* TO 'testuser1'@'localhost';
GRANT INSERT ON db_datadict_2.t1 TO 'testuser1'@'localhost';
GRANT SELECT ON db_datadict_4.* TO 'testuser1'@'localhost' WITH GRANT OPTION;
GRANT SELECT ON db_datadict_3.* TO 'testuser2'@'localhost';
GRANT SELECT ON db_datadict_1.* TO 'testuser2'@'localhost';
let $my_select = SELECT * FROM information_schema.schema_privileges
WHERE table_schema LIKE 'db_datadict%'
ORDER BY grantee,table_schema,privilege_type;
let $show_testuser1 = SHOW GRANTS FOR 'testuser1'@'localhost';
let $show_testuser2 = SHOW GRANTS FOR 'testuser2'@'localhost';
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , test);
GRANT SELECT ON db_datadict_4.* TO 'testuser2'@'localhost';
--echo # Root granted INSERT db_datadict_1 to me -> visible
--echo # Root granted SELECT db_datadict_1 to testuser2 -> invisible
--echo # Root granted INSERT db_datadict_2.t1 (no schema-level priv!)
--echo # but not db_datadict_2 to me -> invisible
--echo # Root granted SELECT db_datadict_3. to testuser2 but not to me -> invisible
--echo # Root granted SELECT db_datadict_4. to me -> visible
--echo # I granted SELECT db_datadict_4. to testuser2 -> invisible (reality), visible(requirement)
--echo # FIXME
eval $my_select;
eval $show_testuser1;
--error ER_DBACCESS_DENIED_ERROR
eval $show_testuser2;
--echo # Establish connection testuser2 (user=testuser2)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser2, localhost, testuser2, , test);
--echo # Root granted SELECT db_datadict_1 to me -> visible
--echo # Root granted INSERT db_datadict_1 to testuser1 -> invisible
--echo # Root granted INSERT db_datadict_2.t1 but not db_datadict_1 to testuser1 -> invisible
--echo # Root granted SELECT db_datadict_3. to me -> visible
--echo # testuser1 granted SELECT db_datadict_4. to me -> visible
eval $my_select;
--error ER_DBACCESS_DENIED_ERROR
eval $show_testuser1;
eval $show_testuser2;
--echo # Switch to connection default and close connections testuser1 and testuser2
connection default;
disconnect testuser1;
disconnect testuser2;
eval $my_select;
eval $show_testuser1;
eval $show_testuser2;
# Cleanup
DROP USER 'testuser1'@'localhost';
DROP USER 'testuser2'@'localhost';
DROP DATABASE db_datadict_1;
DROP DATABASE db_datadict_2;
DROP DATABASE db_datadict_3;
--echo ################################################################################
--echo # 3.2.1.13+3.2.1.14+3.2.1.15: INFORMATION_SCHEMA.SCHEMA_PRIVILEGES modifications
--echo ################################################################################
# 3.2.1.13: Ensure that the creation of any new database object (e.g. table or
# column) automatically inserts all relevant information on that
# object into every appropriate INFORMATION_SCHEMA table.
# 3.2.1.14: Ensure that the alteration of any existing database object
# automatically updates all relevant information on that object in
# every appropriate INFORMATION_SCHEMA table.
# 3.2.1.15: Ensure that the dropping of any existing database object
# automatically deletes all relevant information on that object from
# every appropriate INFORMATION_SCHEMA table.
#
# Note (mleich):
# The MySQL privilege system allows to GRANT objects before they exist.
# (Exception: Grant privileges for columns of not existing tables/views.)
# There is also no migration of privileges if objects (tables, views, columns)
# are moved to other databases (tables only), renamed or dropped.
#
--disable_warnings
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
--error 0,ER_CANNOT_USER
DROP USER 'the_user'@'localhost';
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
GRANT SELECT ON test.* TO 'testuser1'@'localhost';
let $my_select = SELECT * FROM information_schema.schema_privileges
WHERE table_schema = 'db_datadict'
ORDER BY grantee,table_schema,privilege_type;
############ Check grant SCHEMA
eval $my_select;
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , test);
eval $my_select;
--echo # Switch to connection default
connection default;
GRANT UPDATE ON db_datadict.* TO 'testuser1'@'localhost';
eval $my_select;
--echo # Switch to connection testuser1
eval $my_select;
############ Check RENAME SCHEMA
# Implement this if RENAME SCHEMA is again available.
# Note(mleich): I expect that RENAME has no impact on the result sets, because
# the schema_name is not migrated.
# --echo # Switch to connection default
# connection default;
# RENAME SCHEMA db_datadict TO db_datadictx;
# eval $my_select;
# --echo # Switch to connection testuser1
# eval $my_select;
# RENAME SCHEMA db_datadictx TO db_datadict;
############ Check extend PRIVILEGES (affects PRIVILEGE_TYPE) on SCHEMA
--echo # Switch to connection default
connection default;
GRANT SELECT ON db_datadict.* TO 'testuser1'@'localhost';
eval $my_select;
--echo # Switch to connection testuser1
eval $my_select;
############ Check extend PRIVILEGES (affects IS_GRANTABLE) on SCHEMA
--echo # Switch to connection default
connection default;
GRANT SELECT ON db_datadict.* TO 'testuser1'@'localhost' WITH GRANT OPTION;
eval $my_select;
--echo # Switch to connection testuser1
eval $my_select;
############ Check DROP SCHEMA
# No impact, because there is no "maintenance" of privileges.
--echo # Switch to connection default
connection default;
DROP SCHEMA db_datadict;
eval $my_select;
--echo # Switch to connection testuser1
eval $my_select;
############ Check REVOKE PRIVILEGE
--echo # Switch to connection default
connection default;
REVOKE UPDATE ON db_datadict.* FROM 'testuser1'@'localhost';
eval $my_select;
--echo # Switch to connection testuser1
eval $my_select;
############ Check RENAME USER
--echo # Switch to connection default
connection default;
RENAME USER 'testuser1'@'localhost' TO 'the_user'@'localhost';
eval $my_select;
--echo # Switch to connection testuser1
eval $my_select;
--echo # Close connection testuser1
disconnect testuser1;
--echo # Establish connection the_user (user=the_user)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (the_user, localhost, the_user, , test);
eval $my_select;
--echo # Close connection the_user
disconnect the_user;
############ Check DROP USER
--echo # Switch to connection default
connection default;
eval $my_select;
DROP USER 'the_user'@'localhost';
eval $my_select;
--echo ########################################################################
--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
--echo # DDL on INFORMATION_SCHEMA table are not supported
--echo ########################################################################
# 3.2.1.3: Ensure that no user may execute an INSERT statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.4: Ensure that no user may execute an UPDATE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.5: Ensure that no user may execute a DELETE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.8: Ensure that no user may create an index on an INFORMATION_SCHEMA table.
# 3.2.1.9: Ensure that no user may alter the definition of an
# INFORMATION_SCHEMA table.
# 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
# 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table to any
# other database.
# 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;
--enable_warnings
CREATE DATABASE db_datadict;
--replace_result $engine_type <engine_type>
eval
CREATE TABLE db_datadict.t1 (f1 BIGINT, f2 BIGINT)
ENGINE = $engine_type;
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
GRANT SELECT ON db_datadict.* TO 'testuser1'@'localhost';
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.schema_privileges
SELECT * FROM information_schema.schema_privileges;
--error ER_DBACCESS_DENIED_ERROR
UPDATE information_schema.schema_privileges SET table_schema = 'test'
WHERE table_name = 't1';
--error ER_DBACCESS_DENIED_ERROR
DELETE FROM information_schema.schema_privileges
WHERE table_schema = 'db_datadict';
--error ER_DBACCESS_DENIED_ERROR
TRUNCATE information_schema.schema_privileges;
--error ER_DBACCESS_DENIED_ERROR
CREATE INDEX my_idx_on_tables
ON information_schema.schema_privileges(table_schema);
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.schema_privileges ADD f1 INT;
--error ER_DBACCESS_DENIED_ERROR
DROP TABLE information_schema.schema_privileges;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.schema_privileges
RENAME db_datadict.schema_privileges;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.schema_privileges
RENAME information_schema.xschema_privileges;
# Cleanup
DROP DATABASE db_datadict;
DROP USER 'testuser1'@'localhost';

View File

@@ -0,0 +1,61 @@
# suite/funcs_1/t/is_schema_privileges_is_mysql_test.test
#
# Check the content of information_schema.schema_privileges about the databases
# information_schema, mysql and test visible to high and low privileged users.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
--echo ##############################################################################
--echo # Testcases 3.2.9.2+3.2.9.3 INFORMATION_SCHEMA.SCHEMATA accessible information
--echo ##############################################################################
# 3.2.9.2 Ensure that the table shows the relevant information for every
# database on which the current user or PUBLIC have privileges.
# 3.2.9.3 Ensure that the table does not show any information on any databases
# on which the current user and PUBLIC have no privileges.
#
--disable_warnings
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
# Create a low privileged user.
# Note: The database db_datadict is just a "home" for the low privileged user
# and not in the focus of testing.
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
GRANT SELECT ON db_datadict.* TO 'testuser1'@'localhost';
let $my_select = SELECT * FROM information_schema.schema_privileges
WHERE table_schema IN ('information_schema','mysql','test')
ORDER BY grantee, table_schema, privilege_type;
let $my_show1 = SHOW DATABASES LIKE 'information_schema';
let $my_show2 = SHOW DATABASES LIKE 'mysql';
let $my_show3 = SHOW DATABASES LIKE 'test';
eval $my_select;
eval $my_show1;
eval $my_show2;
eval $my_show3;
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , db_datadict);
eval $my_select;
eval $my_show1;
eval $my_show2;
eval $my_show3;
# Cleanup
--echo # Switch to connection default and close connection testuser1
connection default;
DROP USER 'testuser1'@'localhost';
DROP DATABASE db_datadict;

View File

@@ -0,0 +1,19 @@
# suite/funcs_1/t/is_schemata.test
#
# Check the layout of information_schema.schemata, permissions and the impact of
# CREATE/ALTER/DROP SCHEMA on it.
# Variant for the non embedded server
# The expected results must equal is_schemata_embedded except that
# that the privilege system works (affects some result sets).
#
# There is detailed information about this test within
# suite/funcs_1/datadict/is_schemata.inc
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
--source include/not_embedded.inc
--source suite/funcs_1/datadict/is_schemata.inc

View File

@@ -0,0 +1,24 @@
# suite/funcs_1/t/is_schemata_embedded.test
#
# Check the layout of information_schema.schemata, permissions and the impact of
# CREATE/ALTER/DROP SCHEMA on it.
# Variant for the embedded server
# The expected results must equal is_schemata except that all users
# have all privileges (affects some result sets).
#
# There is detailed information about this test within
# suite/funcs_1/datadict/is_schemata.inc
#
# Author:
# 2008-06-06 mleich Create this this variant for the embedded server.
#
if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{
--skip Test requires: embedded server
}
if (`SELECT VERSION() LIKE '%embedded%'`)
{
--skip Bug#37456 funcs_1: Several tests crash when used with embedded server
}
--source suite/funcs_1/datadict/is_schemata.inc

View File

@@ -0,0 +1,61 @@
# suite/funcs_1/t/is_schemata_is_mysql_test.test
#
# Check the content of information_schema.schemata about the databases
# information_schema and mysql visible to high and low privileged users.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
--echo #################################################################################
--echo # Testcases 3.2.9.2 + 3.2.9.3: INFORMATION_SCHEMA.SCHEMATA accessible information
--echo #################################################################################
# 3.2.9.2 Ensure that the table shows the relevant information for every
# database on which the current user or PUBLIC have privileges.
# 3.2.9.3 Ensure that the table does not show any information on any databases
# on which the current user and PUBLIC have no privileges.
#
--disable_warnings
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
# Create a low privileged user.
# Note: The database db_datadict is just a "home" for the low privileged user
# and not in the focus of testing.
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
GRANT SELECT ON db_datadict.* TO 'testuser1'@'localhost';
let $my_select = SELECT * FROM information_schema.schemata
WHERE schema_name IN ('information_schema','mysql','test')
ORDER BY schema_name;
let $my_show1 = SHOW DATABASES LIKE 'information_schema';
let $my_show2 = SHOW DATABASES LIKE 'mysql';
let $my_show3 = SHOW DATABASES LIKE 'test';
eval $my_select;
eval $my_show1;
eval $my_show2;
eval $my_show3;
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , db_datadict);
eval $my_select;
eval $my_show1;
eval $my_show2;
eval $my_show3;
# Cleanup
--echo # Switch to connection default and close connection testuser1
connection default;
DROP USER 'testuser1'@'localhost';
DROP DATABASE db_datadict;

View File

@@ -0,0 +1,381 @@
# suite/funcs_1/t/is_statistics.test
#
# Check the layout of information_schema.statistics and the impact of
# CREATE/ALTER/DROP TABLE/VIEW/SCHEMA ... on its content.
#
# Note:
# This test is not intended
# - to show information about the all time existing tables
# within the databases information_schema and mysql
# - for checking storage engine properties
# Therefore please do not alter $engine_type and $other_engine_type.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
let $engine_type = MEMORY;
let $other_engine_type = MyISAM;
let $is_table = STATISTICS;
# The table INFORMATION_SCHEMA.STATISTICS must exist
eval SHOW TABLES FROM information_schema LIKE '$is_table';
--echo #######################################################################
--echo # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
--echo #######################################################################
# Ensure that every INFORMATION_SCHEMA table can be queried with a SELECT
# statement, just as if it were an ordinary user-defined table.
#
--source suite/funcs_1/datadict/is_table_query.inc
--echo #########################################################################
--echo # Testcase 3.2.14.1: INFORMATION_SCHEMA.STATISTICS layout
--echo #########################################################################
# Ensure that the INFORMATION_SCHEMA.STATISTICS table has the following columns,
# in the following order:
#
# TABLE_CATALOG (always shows NULL),
# TABLE_SCHEMA (shows the database, or schema, in which a table indexed by
# an accessible index resides),
# TABLE_NAME (shows the name of the indexed table),
# NON_UNIQUE (shows whether the index may contain duplicate values;
# 0 if it cannot, 1 if it can),
# INDEX_SCHEMA (shows the database, or schema, in which an accessible
# index resides),
# INDEX_NAME (shows the name of an index which the current user may access),
# SEQ_IN_INDEX (shows the ordinal position of an indexed column within
# the index),
# COLUMN_NAME (shows the name of a column that comprises some, or all, of an
# index key),
# COLLATION (shows how the column is sorted in the index; either A for ascending
# or NULL for unsorted columns),
# CARDINALITY (shows the number of unique values in the index),
# SUB_PART (shows the number of indexed characters if the index is
# a prefix index),
# PACKED (shows how the index key is packed),
# NULLABLE (shows whether the index column may contain NULL values),
# INDEX_TYPE (shows the index type; either BTREE, FULLTEXT, HASH or RTREE),
# COMMENT (shows a comment on the index, if any).
#
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval DESCRIBE information_schema.$is_table;
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval SHOW CREATE TABLE information_schema.$is_table;
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval SHOW COLUMNS FROM information_schema.$is_table;
# Note: Retrieval of information within information_schema.columns about
# information_schema.statistics is in is_columns_is.test.
# Show that TABLE_CATALOG is always NULL.
SELECT table_catalog, table_schema, table_name, index_schema, index_name
FROM information_schema.statistics WHERE table_catalog IS NOT NULL;
--echo ####################################################################################
--echo # Testcase 3.2.14.2 + 3.2.14.3: INFORMATION_SCHEMA.STATISTICS accessible information
--echo ####################################################################################
# 3.2.14.2 Ensure that the table shows the relevant information on every index
# which the current user or PUBLIC may access (usually because
# privileges on the indexed table have been granted).
# 3.2.14.3 Ensure that the table does not show any information on any indexes
# which the current user and PUBLIC may not access.
#
# Note: Check of content within information_schema.statistics about
# database is in
# mysql is_statistics_mysql.test
# information_schema is_statistics_is.test
#
--disable_warnings
DROP DATABASE IF EXISTS db_datadict;
DROP DATABASE IF EXISTS db_datadict_2;
--enable_warnings
CREATE DATABASE db_datadict;
CREATE DATABASE db_datadict_2;
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
--error 0,ER_CANNOT_USER
DROP USER 'testuser2'@'localhost';
CREATE USER 'testuser2'@'localhost';
--replace_result $engine_type <engine_type>
eval
CREATE TABLE db_datadict.t1
(f1 INT NOT NULL, PRIMARY KEY(f1), f2 INT, INDEX f2_ind(f2))
ENGINE = $engine_type;
--replace_result $engine_type <engine_type>
eval
CREATE TABLE db_datadict.t2
(f1 INT NOT NULL, PRIMARY KEY(f1), f2 INT, INDEX f2_ind(f2))
ENGINE = $engine_type;
eval
CREATE TABLE db_datadict_2.t3
(f1 INT NOT NULL, f2 INT, f5 DATE,
PRIMARY KEY(f1), INDEX f2f1_ind(f2,f1), UNIQUE(f5))
ENGINE = $engine_type;
eval
CREATE TABLE db_datadict_2.t4
(f1 INT NOT NULL, PRIMARY KEY(f1), f2 INT, INDEX f2_ind(f2))
ENGINE = $engine_type;
let $my_select = SELECT * FROM information_schema.statistics
WHERE table_schema LIKE 'db_datadict%'
ORDER BY table_schema,table_name,index_name,seq_in_index,column_name;
let $my_show1 = SHOW GRANTS FOR 'testuser1'@'localhost';
let $my_show2 = SHOW GRANTS FOR 'testuser2'@'localhost';
eval $my_select;
eval $my_show1;
eval $my_show2;
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , test);
# nothing visible for testuser1
eval $my_select;
eval $my_show1;
--error ER_DBACCESS_DENIED_ERROR
eval $my_show2;
--echo # Establish connection testuser2 (user=testuser2)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser2, localhost, testuser2, , test);
# nothing visible for testuser2
eval $my_select;
--error ER_DBACCESS_DENIED_ERROR
eval $my_show1;
eval $my_show2;
--echo # Switch to connection default
connection default;
GRANT SELECT ON db_datadict.t1 TO 'testuser1'@'localhost' WITH GRANT OPTION;
GRANT SELECT(f1,f5) ON db_datadict_2.t3 TO 'testuser1'@'localhost';
eval $my_select;
eval $my_show1;
eval $my_show2;
--echo # Switch to connection testuser1
connection testuser1;
eval $my_select;
eval $my_show1;
--error ER_DBACCESS_DENIED_ERROR
eval $my_show2;
--echo # Switch to connection testuser2
connection testuser2;
eval $my_select;
--error ER_DBACCESS_DENIED_ERROR
eval $my_show1;
eval $my_show2;
--echo # Switch to connection default
connection default;
REVOKE SELECT,GRANT OPTION ON db_datadict.t1 FROM 'testuser1'@'localhost';
eval $my_show1;
--echo # Switch to connection testuser1
# nothing visible for testuser1
connection testuser1;
eval $my_select;
eval $my_show1;
# Cleanup
--echo # Switch to connection default and close connections testuser1, testuser2
connection default;
disconnect testuser1;
disconnect testuser2;
DROP USER 'testuser1'@'localhost';
DROP USER 'testuser2'@'localhost';
DROP DATABASE db_datadict;
DROP DATABASE db_datadict_2;
--echo #########################################################################
--echo # 3.2.1.13+3.2.1.14+3.2.1.15: INFORMATION_SCHEMA.STATISTICS modifications
--echo #########################################################################
# 3.2.1.13: Ensure that the creation of any new database object (e.g. table or
# column) automatically inserts all relevant information on that
# object into every appropriate INFORMATION_SCHEMA table.
# 3.2.1.14: Ensure that the alteration of any existing database object
# automatically updates all relevant information on that object in
# every appropriate INFORMATION_SCHEMA table.
# 3.2.1.15: Ensure that the dropping of any existing database object
# automatically deletes all relevant information on that object from
# every appropriate INFORMATION_SCHEMA table.
#
--disable_warnings
DROP TABLE IF EXISTS test.t1_my_table;
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
--replace_result $other_engine_type <other_engine_type>
eval
CREATE TABLE test.t1_1 (f1 BIGINT,
f2 TEXT, f2x TEXT, f3 CHAR(10), f3x CHAR(10), f4 BIGINT, f4x BIGINT,
f5 POINT, f5x POINT NOT NULL)
DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci
ENGINE = $other_engine_type;
--replace_result $engine_type <engine_type>
eval
CREATE TABLE test.t1_2 (f1 BIGINT, f2 BIGINT)
ENGINE = $engine_type;
# Tables without primary key or index do not show up
# in information_schema.statistics.
SELECT table_name FROM information_schema.statistics
WHERE table_name LIKE 't1_%';
# Check ADD PRIMARY KEY (two columns)
ALTER TABLE test.t1_1 ADD PRIMARY KEY (f1,f3);
SELECT * FROM information_schema.statistics
WHERE table_name LIKE 't1_%'
ORDER BY table_schema,table_name,index_name,seq_in_index,column_name;
# Check DROP PRIMARY KEY
ALTER TABLE test.t1_1 DROP PRIMARY KEY;
SELECT table_name FROM information_schema.statistics
WHERE table_name LIKE 't1_%';
# Check ADD PRIMARY KEY (one column)
ALTER TABLE test.t1_1 ADD PRIMARY KEY (f1);
SELECT * FROM information_schema.statistics
WHERE table_name LIKE 't1_%';
# Some variations on index definitions
# 1. No name assigned, one column
ALTER TABLE test.t1_1 ADD INDEX (f4);
# 2. Name assigned, two columns
CREATE INDEX f3_f1 ON test.t1_1 (f3,f1);
# 3. Unique index
CREATE UNIQUE INDEX f4x_uni ON test.t1_1 (f4x);
# 4. Index using HASH
CREATE INDEX f2_hash USING HASH ON test.t1_2 (f2);
# 5. Index with comment (feature introduced in 5.2)
--error ER_PARSE_ERROR
CREATE INDEX f1_idx ON test.t1_2 (f1) COMMENT = 'COMMENT';
# 6. NOT NULL
CREATE INDEX not_null ON test.t1_1 (f3x);
# 7. Prefix index
CREATE INDEX f2_prefix ON test.t1_1 (f2(20));
#
SELECT * FROM information_schema.statistics
WHERE table_name LIKE 't1_%' AND index_name <> 'PRIMARY'
ORDER BY table_schema,table_name,index_name,seq_in_index,column_name;
--horizontal_results
DROP TABLE test.t1_2;
#
# Check modification of TABLE_NAME
SELECT DISTINCT table_name FROM information_schema.statistics
WHERE table_name = 't1_1';
RENAME TABLE test.t1_1 TO test.t1_1x;
SELECT DISTINCT table_name FROM information_schema.statistics
WHERE table_name = 't1_1x';
#
# Check modification of TABLE_SCHEMA
SELECT DISTINCT table_schema,table_name FROM information_schema.statistics
WHERE table_name LIKE 't1_1%';
RENAME TABLE test.t1_1x TO db_datadict.t1_1x;
SELECT DISTINCT table_schema,table_name FROM information_schema.statistics
WHERE table_name LIKE 't1_1%';
#
# Check impact of DROP TABLE
SELECT DISTINCT table_name FROM information_schema.statistics
WHERE table_name = 't1_1x';
DROP TABLE db_datadict.t1_1x;
SELECT DISTINCT table_name FROM information_schema.statistics
WHERE table_name = 't1_1x';
#
# Check a temporary table (not visible)
--replace_result $engine_type <engine_type>
eval
CREATE TEMPORARY TABLE test.t1_1x (PRIMARY KEY(f1,f2))
ENGINE = $engine_type
AS SELECT 1 AS f1, 2 AS f2;
--vertical_results
SELECT * FROM information_schema.statistics
WHERE table_name = 't1_1x';
--horizontal_results
DROP TEMPORARY TABLE test.t1_1x;
#
# Check impact of DROP SCHEMA
--replace_result $engine_type <engine_type>
eval
CREATE TABLE db_datadict.t1_1x (PRIMARY KEY(f1))
ENGINE = $engine_type
AS SELECT 1 AS f1, 2 AS f2;
SELECT table_name FROM information_schema.statistics
WHERE table_name = 't1_1x';
DROP DATABASE db_datadict;
SELECT table_name FROM information_schema.statistics
WHERE table_name = 't1_1x';
--echo ########################################################################
--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
--echo # DDL on INFORMATION_SCHEMA tables are not supported
--echo ########################################################################
# 3.2.1.3: Ensure that no user may execute an INSERT statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.4: Ensure that no user may execute an UPDATE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.5: Ensure that no user may execute a DELETE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.8: Ensure that no user may create an index on an
# INFORMATION_SCHEMA table.
# 3.2.1.9: Ensure that no user may alter the definition of an
# INFORMATION_SCHEMA table.
# 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
# 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table to any
# other database.
# 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;
--enable_warnings
CREATE DATABASE db_datadict;
--replace_result $engine_type <engine_type>
eval
CREATE TABLE db_datadict.t1 (f1 BIGINT)
ENGINE = $engine_type;
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.statistics
SELECT * FROM information_schema.statistics;
--error ER_DBACCESS_DENIED_ERROR
UPDATE information_schema.statistics SET table_schema = 'test'
WHERE table_name = 't1';
--error ER_DBACCESS_DENIED_ERROR
DELETE FROM information_schema.statistics WHERE table_name = 't1';
--error ER_DBACCESS_DENIED_ERROR
TRUNCATE information_schema.statistics;
--error ER_DBACCESS_DENIED_ERROR
CREATE INDEX my_idx_on_statistics
ON information_schema.statistics(table_schema);
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.statistics DROP PRIMARY KEY;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.statistics ADD f1 INT;
--error ER_DBACCESS_DENIED_ERROR
DROP TABLE information_schema.statistics;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.statistics RENAME db_datadict.statistics;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.statistics RENAME information_schema.xstatistics;
# Cleanup
DROP DATABASE db_datadict;

View File

@@ -0,0 +1,14 @@
# suite/funcs_1/t/is_statistics_is.test
#
# Check the content of information_schema.statistics about tables within
# the database information_schema for a high and a low privileged user.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
let $my_where = WHERE table_schema = 'information_schema';
--source suite/funcs_1/datadict/statistics.inc

View File

@@ -0,0 +1,18 @@
# suite/funcs_1/t/is_statistics_mysql.test
#
# Check the content of information_schema.statistics about tables within
# the database mysql for a high and a low privileged user.
# Variant for the non embedded server
# The expected results must equal is_statistics_mysql_embedded except that
# that the privilege system works (affects some result sets).
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
--source include/not_embedded.inc
let $database = mysql;
let $my_where = WHERE table_schema = 'mysql';
--source suite/funcs_1/datadict/statistics.inc

View File

@@ -0,0 +1,19 @@
# suite/funcs_1/t/is_statistics_mysql_embedded.test
#
# Check the content of information_schema.statistics about tables within
# the database mysql for a high and a low privileged user.
# Variant for the embedded server
# The expected results must equal is_statistics_mysql except that all users
# have all privileges (affects some result sets).
#
# Author:
# 2008-06-06 mleich Create this this variant for the embedded server.
#
if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{
--skip Test requires: embedded server
}
let $database = mysql;
let $my_where = WHERE table_schema = 'mysql';
--source suite/funcs_1/datadict/statistics.inc

View File

@@ -0,0 +1,333 @@
# suite/funcs_1/t/is_table_constraints.test
#
# Check the layout of information_schema.table_constraints and the impact of
# CREATE/ALTER/DROP TABLE/VIEW/SCHEMA/COLUMN ... on it.
#
# Note:
# This test is not intended
# - to show information about the all time existing tables
# within the databases information_schema and mysql
# - for checking storage engine properties
# Therefore please do not alter $engine_typee.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
let $engine_type = MyISAM;
let $is_table = TABLE_CONSTRAINTS;
# The table INFORMATION_SCHEMA.TABLE_CONSTRAINTS must exist
eval SHOW TABLES FROM information_schema LIKE '$is_table';
--echo #######################################################################
--echo # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
--echo #######################################################################
# Ensure that every INFORMATION_SCHEMA table can be queried with a SELECT
# statement, just as if it were an ordinary user-defined table.
#
--source suite/funcs_1/datadict/is_table_query.inc
--echo #########################################################################
--echo # Testcase 3.2.10.1: INFORMATION_SCHEMA.TABLE_CONSTRAINTS layout
--echo #########################################################################
# Ensure that the INFORMATION_SCHEMA.TABLE_CONSTRAINTS table has the following
# columns, in the following order:
#
# CONSTRAINT_CATALOG (always shows NULL),
# CONSTRAINT_SCHEMA (shows the database, or schema, in which
# a constraint an accessible table resides),
# CONSTRAINT_NAME (shows the name of a constraint defined on
# an accessible table),
# TABLE_SCHEMA (shows the database, or schema, in which the
# table resides),
# TABLE_NAME (shows the name of the table),
# CONSTRAINT_TYPE (shows the type of the constraint; either
# 'primary key', 'foreign key', 'unique', 'check').
#
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval DESCRIBE information_schema.$is_table;
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval SHOW CREATE TABLE information_schema.$is_table;
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval SHOW COLUMNS FROM information_schema.$is_table;
# Note: Retrieval of information within information_schema.columns about
# information_schema.table_constraints is in is_columns_is.test.
# Show that CONSTRAINT_CATALOG IS NULL
SELECT constraint_catalog, constraint_schema, constraint_name,
table_schema, table_name
FROM information_schema.table_constraints
WHERE constraint_catalog IS NOT NULL;
--echo #########################################################################################
--echo # Testcase 3.2.7.2 + 3.2.7.3: INFORMATION_SCHEMA.TABLE_CONSTRAINTS accessible information
--echo #########################################################################################
# 3.2.7.2: Ensure that the table shows the relevant information on every
# column, defined to be part of an index key, which is accessible to
# the current user or to PUBLIC.
# 3.2.7.3: Ensure that the table does not show any information on any indexed
# column that is not accessible to the current user or PUBLIC.
#
# Note: Check of content within table_constraints about tables within
# database is checked in
# 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
CREATE TABLE db_datadict.t1 (f1 BIGINT, f2 BIGINT, f3 BIGINT, f4 BIGINT,
f5 BIGINT, f6 BIGINT, PRIMARY KEY (f1,f2))
ENGINE = $engine_type;
CREATE UNIQUE INDEX my_idx1 ON db_datadict.t1(f6,f1);
CREATE UNIQUE INDEX my_idx2 ON db_datadict.t1(f3);
--replace_result $engine_type <some_engine_type>
eval
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';
let $my_select = SELECT * FROM information_schema.table_constraints
WHERE table_schema = 'db_datadict'
ORDER BY table_schema,table_name, constraint_name;
let $my_show1 = SHOW INDEXES FROM db_datadict.t1;
let $my_show2 = SHOW INDEXES FROM db_datadict.t2;
eval $my_select;
# 1 Table Note: We intentinally suppress the protocolling of all
# 2 Non_unique output being not of interest or depending on
# 3 Key_name storage engine used for the table.
# 4 Seq_in_index
# 5 Column_name
# 6 Collation
# 7 Cardinality
# 8 Sub_part
# 9 Packed
# 10 Null
# 11 Index_type
# 12 Comment
--replace_column 6 ### 7 ### 8 ### 9 ### 10 ### 11 ### 12 ###
eval $my_show1;
--replace_column 6 ### 7 ### 8 ### 9 ### 10 ### 11 ### 12 ###
eval $my_show2;
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , db_datadict);
SHOW GRANTS FOR 'testuser1'@'localhost';
eval $my_select;
--replace_column 6 ### 7 ### 8 ### 9 ### 10 ### 11 ### 12 ###
eval $my_show1;
--error ER_TABLEACCESS_DENIED_ERROR
eval $my_show2;
# Cleanup
--echo # Switch to connection default and close connection testuser1
connection default;
disconnect testuser1;
DROP USER 'testuser1'@'localhost';
DROP DATABASE db_datadict;
--echo #########################################################################################
--echo # Testcase 3.2.1.13+3.2.1.14+3.2.1.15: INFORMATION_SCHEMA.TABLE_CONSTRAINTS modifications
--echo #########################################################################################
# 3.2.1.13: Ensure that the creation of any new database object (e.g. table or
# column) automatically inserts all relevant information on that
# object into every appropriate INFORMATION_SCHEMA table.
# 3.2.1.14: Ensure that the alteration of any existing database object
# automatically updates all relevant information on that object in
# every appropriate INFORMATION_SCHEMA table.
# 3.2.1.15: Ensure that the dropping of any existing database object
# 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
WHERE table_name LIKE 't1_my_table%';
--replace_result $engine_type <engine_type>
eval
CREATE TABLE test.t1_my_table
(f1 CHAR(12), f2 TIMESTAMP, f4 BIGINT, PRIMARY KEY(f1,f2))
DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci
ENGINE = $engine_type;
# Settings used in CREATE TABLE must be visible
# in information_schema.table_constraints.
SELECT constraint_name, table_schema, table_name, constraint_type
FROM information_schema.table_constraints
WHERE table_name = 't1_my_table';
#
# Check modification of TABLE_NAME
SELECT table_name FROM information_schema.table_constraints
WHERE table_name LIKE 't1_my_table%';
RENAME TABLE test.t1_my_table TO test.t1_my_tablex;
SELECT table_name FROM information_schema.table_constraints
WHERE table_name LIKE 't1_my_table%';
#
# Check modification of TABLE_SCHEMA
SELECT table_schema,table_name FROM information_schema.table_constraints
WHERE table_name = 't1_my_tablex';
RENAME TABLE test.t1_my_tablex TO db_datadict.t1_my_tablex;
SELECT table_schema,table_name FROM information_schema.table_constraints
WHERE table_name = 't1_my_tablex';
#
let $my_select = SELECT constraint_schema, constraint_name, table_schema,
table_name, constraint_type
FROM information_schema.table_constraints
WHERE table_name = 't1_my_tablex'
ORDER BY table_schema,table_name, constraint_name;
#
# Check ADD INDEX being not UNIQUE (does not show up in table_constraints)
eval $my_select;
CREATE INDEX f2 ON db_datadict.t1_my_tablex(f2);
eval $my_select;
DROP INDEX f2 ON db_datadict.t1_my_tablex;
#
# Check ADD UNIQUE INDEX without name explicit assigned
eval $my_select;
ALTER TABLE db_datadict.t1_my_tablex ADD UNIQUE (f2);
eval $my_select;
DROP INDEX f2 ON db_datadict.t1_my_tablex;
#
# Check ADD UNIQUE INDEX with name explicit assigned
eval $my_select;
ALTER TABLE db_datadict.t1_my_tablex ADD UNIQUE my_idx (f4,f1);
eval $my_select;
DROP INDEX my_idx ON db_datadict.t1_my_tablex;
eval $my_select;
ALTER TABLE db_datadict.t1_my_tablex ADD UNIQUE my_idx (f2);
eval $my_select;
#
# Check DROP COLUMN (removing an UNIQUE INDEX)
eval $my_select;
ALTER TABLE db_datadict.t1_my_tablex
DROP COLUMN f2;
eval $my_select;
#
# Check impact of DROP TABLE
SELECT table_name
FROM information_schema.table_constraints
WHERE table_name = 't1_my_tablex';
DROP TABLE db_datadict.t1_my_tablex;
SELECT table_name
FROM information_schema.table_constraints
WHERE table_name = 't1_my_tablex';
#
# No UNIQUE CONSTRAINT -> no entry in key_column_usage
SELECT table_name FROM information_schema.table_constraints
WHERE table_name = 't1_my_tablex';
--replace_result $engine_type <engine_type>
eval
CREATE TABLE db_datadict.t1_my_tablex
ENGINE = $engine_type AS
SELECT 1 AS f1;
SELECT table_name FROM information_schema.table_constraints
WHERE table_name = 't1_my_tablex';
# UNIQUE CONSTRAINT -> entry in key_column_usage
ALTER TABLE db_datadict.t1_my_tablex ADD PRIMARY KEY(f1);
SELECT table_name FROM information_schema.table_constraints
WHERE table_name = 't1_my_tablex';
#
# Check impact of DROP SCHEMA
SELECT table_name FROM information_schema.table_constraints
WHERE table_name = 't1_my_tablex';
DROP DATABASE db_datadict;
SELECT table_name FROM information_schema.table_constraints
WHERE table_name = 't1_my_tablex';
#
--echo ########################################################################
--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
--echo # DDL on INFORMATION_SCHEMA tables are not supported
--echo ########################################################################
# 3.2.1.3: Ensure that no user may execute an INSERT statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.4: Ensure that no user may execute an UPDATE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.5: Ensure that no user may execute a DELETE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.8: Ensure that no user may create an index on an
# INFORMATION_SCHEMA table.
# 3.2.1.9: Ensure that no user may alter the definition of an
# INFORMATION_SCHEMA table.
# 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
# 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table to any
# other database.
# 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
CREATE TABLE db_datadict.t1 (f1 BIGINT, UNIQUE(f1))
ENGINE = $engine_type;
--error ER_DBACCESS_DENIED_ERROR
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.table_constraints
(constraint_schema, constraint_name, table_name)
VALUES ( 'mysql', 'primary', 'db');
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.table_constraints
SELECT * FROM information_schema.table_constraints;
--error ER_DBACCESS_DENIED_ERROR
UPDATE information_schema.table_constraints
SET table_name = 'db1' WHERE constraint_name = 'primary';
--error ER_DBACCESS_DENIED_ERROR
DELETE FROM information_schema.table_constraints WHERE table_name = 't1';
--error ER_DBACCESS_DENIED_ERROR
TRUNCATE information_schema.table_constraints;
--error ER_DBACCESS_DENIED_ERROR
CREATE INDEX i3 ON information_schema.table_constraints(table_name);
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.table_constraints ADD f1 INT;
--error ER_DBACCESS_DENIED_ERROR
DROP TABLE information_schema.table_constraints;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.table_constraints
RENAME db_datadict.table_constraints;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.table_constraints
RENAME information_schema.xtable_constraints;
# Cleanup
DROP TABLE db_datadict.t1;
DROP DATABASE db_datadict;

View File

@@ -0,0 +1,14 @@
# suite/funcs_1/t/is_table_constraints_is.test
#
# Check the content of information_schema.table_constraints about tables within
# the database information_schema with different privileged users.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
let $table_schema = information_schema;
--source suite/funcs_1/datadict/table_constraints.inc

View File

@@ -0,0 +1,17 @@
# suite/funcs_1/t/is_table_constraints_mysql.test
#
# Check the content of information_schema.table_constraints about tables within
# the database mysql (= the system tables) with different privileged users.
# Variant for the non embedded server
# The expected results must equal is_table_constraints_mysql_embedded
# except that the privilege system works (affects some result sets).
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
--source include/not_embedded.inc
let $table_schema = mysql;
--source suite/funcs_1/datadict/table_constraints.inc

View File

@@ -0,0 +1,18 @@
# suite/funcs_1/t/is_table_constraints_mysql_embedded.test
#
# Check the content of information_schema.table_constraints about tables within
# the database mysql (= the system tables) with different privileged users.
# Variant for the embedded server
# The expected results must equal is_table_constraints_mysql
# except that all users have all privileges (affects some result sets).
#
# Author:
# 2008-06-06 mleich Create this this variant for the embedded server.
#
if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{
--skip Test requires: embedded server
}
let $table_schema = mysql;
--source suite/funcs_1/datadict/table_constraints.inc

View File

@@ -0,0 +1,351 @@
# suite/funcs_1/t/is_table_privileges.test
#
# Check the layout of information_schema.table_privileges and the impact of
# CREATE/ALTER/DROP TABLE/VIEW/SCHEMA ... on it.
#
# Note:
# This test is not intended
# - to show information about the all time existing tables
# within the databases information_schema and mysql
# - for checking storage engine properties
# Therefore please do not alter $engine_type and $other_engine_type.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
let $engine_type = MEMORY;
let $other_engine_type = MyISAM;
let $is_table = TABLE_PRIVILEGES;
# The table INFORMATION_SCHEMA.TABLE_PRIVILEGES must exist
eval SHOW TABLES FROM information_schema LIKE '$is_table';
--echo #######################################################################
--echo # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
--echo #######################################################################
# Ensure that every INFORMATION_SCHEMA table can be queried with a SELECT
# statement, just as if it were an ordinary user-defined table.
#
--source suite/funcs_1/datadict/is_table_query.inc
--echo #########################################################################
--echo # Testcase 3.2.11.1: INFORMATION_SCHEMA.TABLE_PRIVILEGES layout
--echo #########################################################################
# Ensure that the INFORMATION_SCHEMA.TABLE_PRIVILEGES table has the following
# columns, in the following order:
#
# GRANTEE (shows the name of a user who has either granted, or been granted a
# table privilege),
# TABLE_CATALOG (always shows NULL),
# TABLE_SCHEMA (shows the name of the schema, or database, in which the table
# for which a privilege has been granted resides),
# TABLE_NAME (shows the name of the table),
# PRIVILEGE_TYPE (shows the type of privilege that was granted; must be either
# SELECT, INSERT, UPDATE, DELETE, REFERENCES, ALTER, INDEX, DROP or
# CREATE VIEW),
# IS_GRANTABLE (shows whether that privilege was granted WITH GRANT OPTION).
#
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval DESCRIBE information_schema.$is_table;
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval SHOW CREATE TABLE information_schema.$is_table;
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval SHOW COLUMNS FROM information_schema.$is_table;
# Note: Retrieval of information within information_schema.columns
# about information_schema.table_privileges is in is_columns_is.test.
# Show that TABLE_CATALOG is always NULL.
SELECT table_catalog, table_schema, table_name, privilege_type
FROM information_schema.table_privileges WHERE table_catalog IS NOT NULL;
--echo ######################################################################
--echo # Testcase 3.2.11.2+3.2.11.3+3.2.11.4:
--echo # INFORMATION_SCHEMA.TABLE_PRIVILEGES accessible information
--echo ######################################################################
# 3.2.11.2: Ensure that the table shows the relevant information on every
# table privilege which has been granted to the current user or
# PUBLIC, or which was granted by the current user.
# 3.2.11.3: Ensure that the table does not show any information on any table
# privilege which was granted to any user other than the current
# user or PUBLIC, or which was granted by any user other than the
# current user.
# 3.2.11.4: Ensure that the table does not show any information on any
# privileges that are not table privileges for the current user.
#
# To be implemented:
# Check of content within information_schema.table_privileges about
# databases like 'information_schema' or 'mysql'.
# 2008-02-15 Neither root nor a just created low privileged user has table
# privileges within these schemas.
#
--disable_warnings
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
--replace_result $engine_type <engine_type>
eval
CREATE TABLE db_datadict.tb1(f1 INT, f2 INT, f3 INT)
ENGINE = $engine_type;
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
GRANT CREATE, SELECT ON db_datadict.*
TO 'testuser1'@'localhost' WITH GRANT OPTION;
GRANT SELECT ON db_datadict.tb1 TO 'testuser1'@'localhost';
--error 0,ER_CANNOT_USER
DROP USER 'testuser2'@'localhost';
CREATE USER 'testuser2'@'localhost';
GRANT ALL ON db_datadict.tb1 TO 'testuser2'@'localhost' WITH GRANT OPTION;
--error 0,ER_CANNOT_USER
DROP USER 'testuser3'@'localhost';
CREATE USER 'testuser3'@'localhost';
let $my_select = SELECT * FROM information_schema.table_privileges
WHERE table_name LIKE 'tb%'
ORDER BY grantee,table_schema,table_name,privilege_type;
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , db_datadict);
--replace_result $other_engine_type <other_engine_type>
eval
CREATE TABLE tb3 (f1 TEXT)
ENGINE = $other_engine_type;
GRANT SELECT ON db_datadict.tb3 TO 'testuser3'@'localhost';
eval $my_select;
SHOW GRANTS FOR 'testuser1'@'localhost';
--echo # Establish connection testuser2 (user=testuser3)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser2, localhost, testuser2, , db_datadict);
# we see only table privileges for this user, and not any other privileges
eval $my_select;
SHOW GRANTS FOR 'testuser2'@'localhost';
--echo # Establish connection testuser3 (user=testuser3)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser3, localhost, testuser3, , db_datadict);
# we see only table privileges for this user, and not any other privileges
eval $my_select;
SHOW GRANTS FOR 'testuser3'@'localhost';
--echo # Switch to connection default and close the other connections
connection default;
disconnect testuser1;
disconnect testuser2;
disconnect testuser3;
# we see only 'public' table privileges
eval $my_select;
SHOW GRANTS FOR 'testuser1'@'localhost';
SHOW GRANTS FOR 'testuser2'@'localhost';
SHOW GRANTS FOR 'testuser3'@'localhost';
# Cleanup
DROP USER 'testuser1'@'localhost';
DROP USER 'testuser2'@'localhost';
DROP USER 'testuser3'@'localhost';
DROP DATABASE db_datadict;
--echo ################################################################################
--echo # 3.2.1.13+3.2.1.14+3.2.1.15: INFORMATION_SCHEMA.TABLE_PRIVILEGES modifications
--echo ################################################################################
# 3.2.1.13: Ensure that the creation of any new database object (e.g. table or
# column) automatically inserts all relevant information on that
# object into every appropriate INFORMATION_SCHEMA table.
# 3.2.1.14: Ensure that the alteration of any existing database object
# automatically updates all relevant information on that object in
# every appropriate INFORMATION_SCHEMA table.
# 3.2.1.15: Ensure that the dropping of any existing database object
# automatically deletes all relevant information on that object from
# every appropriate INFORMATION_SCHEMA table.
#
# Note (mleich):
# The MySQL privilege system allows to GRANT objects before they exist.
# (Exception: Grant privileges for columns of not existing tables/views.)
# There is also no migration of privileges if objects (tables,views,columns)
# are moved to other databases (tables only), renamed or dropped.
#
--disable_warnings
DROP TABLE IF EXISTS test.t1_table;
DROP VIEW IF EXISTS test.t1_view;
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
--replace_result $engine_type <engine_type>
eval
CREATE TABLE test.t1_table (f1 BIGINT)
DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci
COMMENT = 'Initial Comment' ENGINE = $engine_type;
CREATE VIEW test.t1_view AS SELECT 1;
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
--error 0,ER_CANNOT_USER
DROP USER 'the_user'@'localhost';
#
# Check granted TABLE and VIEW
SELECT table_name FROM information_schema.table_privileges
WHERE table_name LIKE 't1_%';
GRANT ALL ON test.t1_table TO 'testuser1'@'localhost';
GRANT ALL ON test.t1_view TO 'testuser1'@'localhost';
SELECT * FROM information_schema.table_privileges
WHERE table_name LIKE 't1_%'
ORDER BY grantee, table_schema, table_name, privilege_type;
#
# Check modification of GRANTEE (migration of permissions)
SELECT DISTINCT grantee, table_name FROM information_schema.table_privileges
WHERE table_name LIKE 't1_%'
ORDER BY grantee, table_name;
RENAME USER 'testuser1'@'localhost' TO 'the_user'@'localhost';
# FIXME: mleich Workaround for bug to be reported
# It looks like an immediate reloading of the system tables is missing in case
# of RENAME USER.
FLUSH PRIVILEGES;
SELECT DISTINCT grantee, table_name FROM information_schema.table_privileges
WHERE table_name LIKE 't1_%'
ORDER BY grantee, table_name;
--error ER_NONEXISTING_GRANT
SHOW GRANTS FOR 'testuser1'@'localhost';
SHOW GRANTS FOR 'the_user'@'localhost';
#
# Check modification of TABLE_SCHEMA (no migration of permissions)
SELECT DISTINCT table_schema,table_name FROM information_schema.table_privileges
WHERE table_name LIKE 't1_%'
ORDER BY table_schema,table_name;
RENAME TABLE test.t1_table TO db_datadict.t1_table;
--error ER_FORBID_SCHEMA_CHANGE
RENAME TABLE test.t1_view TO db_datadict.t1_view;
SELECT DISTINCT table_schema,table_name FROM information_schema.table_privileges
WHERE table_name LIKE 't1_%'
ORDER BY table_schema,table_name;
SHOW GRANTS FOR 'the_user'@'localhost';
REVOKE ALL PRIVILEGES ON test.t1_table FROM 'the_user'@'localhost';
REVOKE ALL PRIVILEGES ON test.t1_view FROM 'the_user'@'localhost';
DROP VIEW test.t1_view;
CREATE VIEW db_datadict.t1_view AS SELECT 1;
GRANT ALL ON db_datadict.t1_table TO 'the_user'@'localhost';
GRANT ALL ON db_datadict.t1_view TO 'the_user'@'localhost';
#
# Check modification of TABLE_NAME (no migration of permissions)
SELECT DISTINCT table_name FROM information_schema.table_privileges
WHERE table_name LIKE 't1_%'
ORDER BY table_name;
RENAME TABLE db_datadict.t1_table TO db_datadict.t1_tablex;
RENAME TABLE db_datadict.t1_view TO db_datadict.t1_viewx;
SELECT DISTINCT table_name FROM information_schema.table_privileges
WHERE table_name LIKE 't1_%'
ORDER BY table_name;
RENAME TABLE db_datadict.t1_tablex TO db_datadict.t1_table;
RENAME TABLE db_datadict.t1_viewx TO db_datadict.t1_view;
#
# Check impact of DROP TABLE/VIEW (no removal of permissions)
SELECT DISTINCT table_name FROM information_schema.table_privileges
WHERE table_name LIKE 't1_%'
ORDER BY table_name;
DROP TABLE db_datadict.t1_table;
DROP VIEW db_datadict.t1_view;
SELECT DISTINCT table_name FROM information_schema.table_privileges
WHERE table_name LIKE 't1_%'
ORDER BY table_name;
#
# Check impact of DROP SCHEMA (no removal of permissions)
--replace_result $engine_type <engine_type>
eval
CREATE TABLE db_datadict.t1_table
ENGINE = $engine_type AS
SELECT 1;
CREATE VIEW db_datadict.t1_view AS SELECT 1;
GRANT ALL ON db_datadict.t1_table TO 'the_user'@'localhost';
GRANT ALL ON db_datadict.t1_view TO 'the_user'@'localhost';
SELECT DISTINCT table_name FROM information_schema.table_privileges
WHERE table_name LIKE 't1_%'
ORDER BY table_name;
DROP DATABASE db_datadict;
SELECT DISTINCT table_name FROM information_schema.table_privileges
WHERE table_name LIKE 't1_%'
ORDER BY table_name;
# Cleanup
DROP USER 'the_user'@'localhost';
--echo ########################################################################
--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
--echo # DDL on INFORMATION_SCHEMA table are not supported
--echo ########################################################################
# 3.2.1.3: Ensure that no user may execute an INSERT statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.4: Ensure that no user may execute an UPDATE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.5: Ensure that no user may execute a DELETE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.8: Ensure that no user may create an index on an
# INFORMATION_SCHEMA table.
# 3.2.1.9: Ensure that no user may alter the definition of an
# INFORMATION_SCHEMA table.
# 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
# 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table to any
# other database.
# 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;
--enable_warnings
CREATE DATABASE db_datadict;
--replace_result $engine_type <engine_type>
eval
CREATE TABLE db_datadict.t1 (f1 BIGINT, f2 BIGINT)
ENGINE = $engine_type;
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
GRANT SELECT (f1) ON db_datadict.t1 TO 'testuser1'@'localhost';
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.table_privileges
SELECT * FROM information_schema.table_privileges;
--error ER_DBACCESS_DENIED_ERROR
UPDATE information_schema.table_privileges SET table_schema = 'test'
WHERE table_name = 't1';
--error ER_DBACCESS_DENIED_ERROR
DELETE FROM information_schema.table_privileges WHERE table_name = 't1';
--error ER_DBACCESS_DENIED_ERROR
TRUNCATE information_schema.table_privileges;
--error ER_DBACCESS_DENIED_ERROR
CREATE INDEX my_idx_on_tables
ON information_schema.table_privileges(table_schema);
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.table_privileges ADD f1 INT;
--error ER_DBACCESS_DENIED_ERROR
DROP TABLE information_schema.table_privileges;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.table_privileges
RENAME db_datadict.table_privileges;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.table_privileges
RENAME information_schema.xtable_privileges;
# Cleanup
DROP DATABASE db_datadict;
DROP USER 'testuser1'@'localhost';

View File

@@ -0,0 +1,19 @@
# suite/funcs_1/t/tables.test
#
# Check the layout of information_schema.tables and the impact of
# CREATE/ALTER/DROP TABLE/VIEW/SCHEMA ... on it.
# Variant for the non embedded server
# The expected results must equal is_tables_embedded except that
# that the privilege system works (affects some result sets).
#
# There is detailed information about this test within
# suite/funcs_1/datadict/is_tables.inc
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
--source include/not_embedded.inc
--source suite/funcs_1/datadict/is_tables.inc

View File

@@ -0,0 +1,24 @@
# suite/funcs_1/t/is_tables_embedded.test
#
# Check the layout of information_schema.tables and the impact of
# CREATE/ALTER/DROP TABLE/VIEW/SCHEMA ... on it.
# Variant for the embedded server
# The expected results must equal is_tables except that all users
# have all privileges (affects some result sets).
#
# There is detailed information about this test within
# suite/funcs_1/datadict/is_tables.inc
#
# Author:
# 2008-06-06 mleich Create this this variant for the embedded server.
#
if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{
--skip Test requires: embedded server
}
if (`SELECT VERSION() LIKE '%embedded%'`)
{
--skip Bug#37456 funcs_1: Several tests crash when used with embedded server
}
--source suite/funcs_1/datadict/is_tables.inc

View File

@@ -0,0 +1,22 @@
# suite/funcs_1/t/is_tables_innodb.test
#
# Check the content of information_schema.tables about tables within
# the databases created by the user.
# Variant for storage engine InnoDB
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
--source include/have_innodb.inc
let $engine_type= InnoDB;
# We look only for the tables created by suite/funcs_1/datadict/tables.inc
let $my_where = WHERE table_schema LIKE 'test%' AND table_type = 'BASE TABLE';
--source suite/funcs_1/datadict/tables.inc

View File

@@ -0,0 +1,18 @@
# suite/funcs_1/t/is_tables_is.test
#
# Check the content of information_schema.tables about tables within
# the database information_schema.
#
# Note: The INFORMATION_SCHEMA table PROFILING is optional (exists in MySQL
# Community version only) and therefore we exclude it from retrieval.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
let $my_where = WHERE table_schema = 'information_schema'
AND table_name <> 'profiling';
--source suite/funcs_1/datadict/tables1.inc

View File

@@ -0,0 +1,22 @@
# suite/funcs_1/t/is_tables_memory.test
#
# Check the content of information_schema.tables about tables within
# the databases created by the user.
# Variant for storage engine MEMORY
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
let $engine_type= MEMORY;
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
# We look only for the tables created by suite/funcs_1/datadict/tables.inc
let $my_where = WHERE table_schema LIKE 'test%' AND table_type = 'BASE TABLE';
--source suite/funcs_1/datadict/tables.inc

View File

@@ -0,0 +1,21 @@
# suite/funcs_1/t/is_tables_myisam.test
#
# Check the content of information_schema.tables about tables within
# the databases created by the user.
# Variant for storage engine MyISAM and the non embedded server
# The expected results must equal is_columns_myisam_embedded except that
# that the privilege system works (affects some result sets).
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
--source include/not_embedded.inc
let $engine_type= MyISAM;
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
# We look only for the tables created by suite/funcs_1/datadict/tables.inc
let $my_where = WHERE table_schema LIKE 'test%' AND table_type = 'BASE TABLE';
--source suite/funcs_1/datadict/tables.inc

View File

@@ -0,0 +1,22 @@
# suite/funcs_1/t/is_tables_myisam_embedded.test
#
# Check the content of information_schema.tables about tables within
# the databases created by the user.
# Variant for storage engine MyISAM and the embedded server
# The expected results must equal is_tabless_myisam except that
# that the privilege system works (affects some result sets).
#
# Author:
# 2008-06-06 mleich Create this this variant for the embedded server.
#
if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{
--skip Test requires: embedded server
}
let $engine_type= MyISAM;
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
# We look only for the tables created by suite/funcs_1/datadict/tables.inc
let $my_where = WHERE table_schema LIKE 'test%' AND table_type = 'BASE TABLE';
--source suite/funcs_1/datadict/tables.inc

View File

@@ -0,0 +1,17 @@
# suite/funcs_1/t/is_tables_mysql.test
#
# Check the content of information_schema.tables about tables within
# the database mysql (= the system tables).
# Variant for the non embedded server
# The expected results must equal is_tables_mysql_embedded except that
# that the privilege system works (affects some result sets).
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
--source include/not_embedded.inc
let $my_where = WHERE table_schema = 'mysql';
--source suite/funcs_1/datadict/tables1.inc

View File

@@ -0,0 +1,18 @@
# suite/funcs_1/t/is_tables_mysql_embedded.test
#
# Check the content of information_schema.tables about tables within
# the database mysql (= the system tables).
# Variant for the embedded server
# The expected results must equal is_tables_mysql except that all users
# have all privileges (affects some result sets).
#
# Author:
# 2008-06-06 mleich Create this this variant for the embedded server.
#
if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{
--skip Test requires: embedded server
}
let $my_where = WHERE table_schema = 'mysql';
--source suite/funcs_1/datadict/tables1.inc

View File

@@ -0,0 +1,22 @@
# suite/funcs_1/t/is_tables_ndb.test
#
# Check the content of information_schema.tables about tables within
# the databases created by the user.
# Variant for storage engine NDB
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
--source include/have_ndb.inc
let $engine_type= NDB;
# We look only for the tables created by suite/funcs_1/datadict/tables.inc
let $my_where = WHERE table_schema LIKE 'test%' AND table_type = 'BASE TABLE';
--source suite/funcs_1/datadict/tables.inc

View File

@@ -0,0 +1,19 @@
# suite/funcs_1/t/is_triggers.test
#
# Check the layout of information_schema.triggers and the impact of
# CREATE/ALTER/DROP TABLE/VIEW/SCHEMA ... on it.
# Variant for the non embedded server
# The expected results must equal is_triggers_embedded except that
# that the privilege system works (affects some result sets).
#
# There is detailed information about this test within
# suite/funcs_1/datadict/is_triggers.inc
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
--source include/not_embedded.inc
--source suite/funcs_1/datadict/is_triggers.inc

View File

@@ -0,0 +1,24 @@
# suite/funcs_1/t/is_triggers_embedded.test
#
# Check the layout of information_schema.triggers and the impact of
# CREATE/ALTER/DROP TABLE/VIEW/SCHEMA ... on it.
# Variant for the embedded server
# The expected results must equal is_triggers except that all users
# have all privileges (affects some result sets).
#
# There is detailed information about this test within
# suite/funcs_1/datadict/is_triggers.inc
#
# Author:
# 2008-06-06 mleich Create this this variant for the embedded server.
#
if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{
--skip Test requires: embedded server
}
if (`SELECT VERSION() LIKE '%embedded%'`)
{
--skip Bug#37456 funcs_1: Several tests crash when used with embedded server
}
--source suite/funcs_1/datadict/is_triggers.inc

View File

@@ -0,0 +1,349 @@
# suite/funcs_1/t/is_user_privileges.test
#
# Check the layout of information_schema.user_privileges, permissions and
# the impact of CREATE/ALTER/DROP SCHEMA on it.
#
# Note:
# This test is not intended
# - to show information about the all time existing tables
# within the databases information_schema and mysql
# - for checking storage engine properties
# Therefore please do not alter $engine_type and $other_engine_type.
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
let $engine_type = MEMORY;
let $other_engine_type = MyISAM;
let $is_table = USER_PRIVILEGES;
# The table INFORMATION_SCHEMA.USER_PRIVILEGES must exist
eval SHOW TABLES FROM information_schema LIKE '$is_table';
--echo #######################################################################
--echo # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
--echo #######################################################################
# Ensure that every INFORMATION_SCHEMA table can be queried with a SELECT
# statement, just as if it were an ordinary user-defined table.
#
--source suite/funcs_1/datadict/is_table_query.inc
--echo #########################################################################
--echo # Testcase 3.2.16.1: INFORMATION_SCHEMA.USER_PRIVILEGES layout
--echo #########################################################################
# Ensure that the INFORMATION_SCHEMA.USER_PRIVILEGES table has the following columns,
# in the following order:
#
# GRANTEE (shows a user to whom a user privilege has been granted),
# TABLE_CATALOG (always shows NULL),
# PRIVILEGE_TYPE (shows the granted privilege),
# IS_GRANTABLE (shows whether the privilege was granted WITH GRANT OPTION).
#
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval DESCRIBE information_schema.$is_table;
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval SHOW CREATE TABLE information_schema.$is_table;
--source suite/funcs_1/datadict/datadict_bug_12777.inc
eval SHOW COLUMNS FROM information_schema.$is_table;
# Note: Retrieval of information within information_schema.columns about
# information_schema.user_privileges is in is_columns_is.test.
# Show that TABLE_CATALOG is always NULL.
SELECT grantee, table_catalog, privilege_type
FROM information_schema.user_privileges
WHERE table_catalog IS NOT NULL;
--echo ##########################################################################
--echo # Testcases 3.2.16.2+3.2.16.3+3.2.16.4: INFORMATION_SCHEMA.USER_PRIVILEGES
--echo # accessible information
--echo ##########################################################################
# 3.2.16.2: Ensure that the table shows the relevant information on every user
# privilege which has been granted to the current user or to PUBLIC,
# or has been granted by the current user.
# 3.2.16.3: Ensure that the table does not show any information on any user
# privileges which have been granted to users other than the current
# user or have been granted by any user other than the current user.
# 3.2.16.4: Ensure that the table does not show any information on any
# privileges that are not user privileges for the current user.
#
--disable_warnings
DROP DATABASE IF EXISTS db_datadict;
--enable_warnings
CREATE DATABASE db_datadict;
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
--error 0,ER_CANNOT_USER
DROP USER 'testuser2'@'localhost';
CREATE USER 'testuser2'@'localhost';
--error 0,ER_CANNOT_USER
DROP USER 'testuser3'@'localhost';
CREATE USER 'testuser3'@'localhost';
GRANT SELECT ON db_datadict.* TO 'testuser1'@'localhost';
GRANT SELECT ON mysql.user TO 'testuser1'@'localhost';
GRANT INSERT ON *.* TO 'testuser2'@'localhost';
GRANT UPDATE ON *.* TO 'testuser2'@'localhost';
let $my_select1= SELECT * FROM information_schema.user_privileges
WHERE grantee LIKE '''testuser%'''
ORDER BY grantee, table_catalog, privilege_type;
let $my_select2= SELECT * FROM mysql.user
WHERE user LIKE 'testuser%' ORDER BY host, user;
let $my_show= SHOW GRANTS;
eval $my_select1;
eval $my_select2;
--echo #
--echo # Add GRANT OPTION db_datadict.* to testuser1;
GRANT UPDATE ON db_datadict.* TO 'testuser1'@'localhost' WITH GRANT OPTION;
eval $my_select1;
eval $my_select2;
--echo # Establish connection testuser1 (user=testuser1)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser1, localhost, testuser1, , db_datadict);
eval $my_select1;
eval $my_select2;
eval $my_show;
--echo
--echo # Now add SELECT on *.* to testuser1;
--echo # Switch to connection default
connection default;
GRANT SELECT ON *.* TO 'testuser1'@'localhost';
--echo #
--echo # Here <SELECT NO> is shown correctly for testuser1;
eval $my_select1;
eval $my_select2;
GRANT SELECT ON *.* TO 'testuser1'@'localhost' WITH GRANT OPTION;
--echo #
--echo # Here <SELECT YES> is shown correctly for testuser1;
eval $my_select1;
eval $my_select2;
--echo # Switch to connection testuser1
# check that this appears
connection testuser1;
eval $my_select1;
eval $my_select2;
eval $my_show;
--echo # Establish connection testuser2 (user=testuser2)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser2, localhost, testuser2, , db_datadict);
eval $my_select1;
--error ER_TABLEACCESS_DENIED_ERROR
eval $my_select2;
eval $my_show;
--echo # Establish connection testuser3 (user=testuser3)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (testuser3, localhost, testuser3, , test);
eval $my_select1;
--error ER_TABLEACCESS_DENIED_ERROR
eval $my_select2;
eval $my_show;
--echo
--echo # Revoke privileges from testuser1;
--echo # Switch to connection default
connection default;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'testuser1'@'localhost';
eval $my_select1;
eval $my_select2;
--echo # Switch to connection testuser1
# check for changes
connection testuser1;
eval $my_select1;
--error ER_TABLEACCESS_DENIED_ERROR
eval $my_select2;
eval $my_show;
# OK, testuser1 has no privs here
--error ER_TABLEACCESS_DENIED_ERROR
CREATE TABLE db_datadict.tb_55 ( c1 TEXT );
eval $my_select1;
--error ER_TABLEACCESS_DENIED_ERROR
eval $my_select2;
eval $my_show;
# OK, testuser1 has no privs here
--error ER_TABLEACCESS_DENIED_ERROR
CREATE TABLE db_datadict.tb_66 ( c1 TEXT );
--echo
--echo # Add ALL on db_datadict.* (and select on mysql.user) to testuser1;
--echo # Switch to connection default
connection default;
GRANT ALL ON db_datadict.* TO 'testuser1'@'localhost' WITH GRANT OPTION;
GRANT SELECT ON mysql.user TO 'testuser1'@'localhost';
eval $my_select1;
eval $my_select2;
--echo # Switch to connection testuser1
connection testuser1;
eval $my_select1;
eval $my_select2;
eval $my_show;
# OK, testuser1 has no privs here
--error ER_TABLEACCESS_DENIED_ERROR
CREATE TABLE db_datadict.tb_56 ( c1 TEXT );
# using 'USE' lets the server read the privileges new, so now the CREATE works
USE db_datadict;
eval $my_select1;
eval $my_select2;
eval $my_show;
--replace_result $other_engine_type <other_engine_type>
eval
CREATE TABLE tb_57 ( c1 TEXT )
ENGINE = $other_engine_type;
--echo
--echo # Revoke privileges from testuser1;
--echo # Switch to connection default
connection default;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'testuser1'@'localhost';
eval $my_select1;
eval $my_select2;
--echo # Switch to connection testuser1
# check for changes
connection testuser1;
eval $my_select1;
--error ER_TABLEACCESS_DENIED_ERROR
eval $my_select2;
eval $my_show;
# WORKS, as the existing old privileges are used!
--replace_result $other_engine_type <other_engine_type>
eval
CREATE TABLE db_datadict.tb_58 ( c1 TEXT )
ENGINE = $other_engine_type;
# existing privileges are "read" new when USE is called, user has no privileges
--error ER_DBACCESS_DENIED_ERROR
USE db_datadict;
#FIXME 3.2.16: check that it is correct that this now 'works': --error ER_TABLEACCESS_DENIED_ERROR
--replace_result $other_engine_type <other_engine_type>
eval
CREATE TABLE db_datadict.tb_59 ( c1 TEXT )
ENGINE = $other_engine_type;
# Cleanup
--echo # Switch to connection default and close connections testuser1,testuser2,testuser3
connection default;
disconnect testuser1;
disconnect testuser2;
disconnect testuser3;
DROP USER 'testuser1'@'localhost';
DROP USER 'testuser2'@'localhost';
DROP USER 'testuser3'@'localhost';
DROP DATABASE IF EXISTS db_datadict;
--echo ########################################################################################
--echo # Testcases 3.2.1.13+3.2.1.14+3.2.1.15: INFORMATION_SCHEMA.USER_PRIVILEGES modifications
--echo ########################################################################################
# 3.2.1.13: Ensure that the creation of any new database object (e.g. table or
# column) automatically inserts all relevant information on that
# object into every appropriate INFORMATION_SCHEMA table.
# 3.2.1.14: Ensure that the alteration of any existing database object
# automatically updates all relevant information on that object in
# every appropriate INFORMATION_SCHEMA table.
# 3.2.1.15: Ensure that the dropping of any existing database object
# automatically deletes all relevant information on that object from
# every appropriate INFORMATION_SCHEMA table.
#
let $my_select = SELECT * FROM information_schema.user_privileges
WHERE grantee = '''testuser1''@''localhost''';
let $my_show = SHOW GRANTS FOR 'testuser1'@'localhost';
eval $my_select;
--error ER_NONEXISTING_GRANT
eval $my_show;
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
eval $my_select;
eval $my_show;
GRANT SELECT, FILE ON *.* TO 'testuser1'@'localhost';
eval $my_select;
eval $my_show;
DROP USER 'testuser1'@'localhost';
eval $my_select;
--error ER_NONEXISTING_GRANT
eval $my_show;
--echo ########################################################################
--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
--echo # DDL on INFORMATION_SCHEMA tables are not supported
--echo ########################################################################
# 3.2.1.3: Ensure that no user may execute an INSERT statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.4: Ensure that no user may execute an UPDATE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.5: Ensure that no user may execute a DELETE statement on any
# INFORMATION_SCHEMA table.
# 3.2.1.8: Ensure that no user may create an index on an
# INFORMATION_SCHEMA table.
# 3.2.1.9: Ensure that no user may alter the definition of an
# INFORMATION_SCHEMA table.
# 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
# 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table to any
# other database.
# 3.2.1.12: Ensure that no user may directly add to, alter, or delete any data
# in an INFORMATION_SCHEMA table.
#
--error 0,ER_CANNOT_USER
DROP USER 'testuser1'@'localhost';
CREATE USER 'testuser1'@'localhost';
--error ER_DBACCESS_DENIED_ERROR
INSERT INTO information_schema.user_privileges
SELECT * FROM information_schema.user_privileges;
--error ER_DBACCESS_DENIED_ERROR
UPDATE information_schema.user_privileges
SET PRIVILEGE_TYPE = 'gaming';
--error ER_DBACCESS_DENIED_ERROR
DELETE FROM information_schema.user_privileges
WHERE grantee = '''testuser1''@''localhost''';
--error ER_DBACCESS_DENIED_ERROR
TRUNCATE information_schema.user_privileges;
--error ER_DBACCESS_DENIED_ERROR
CREATE INDEX i1 ON information_schema.user_privileges(grantee);
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.user_privileges ADD f1 INT;
--error ER_DBACCESS_DENIED_ERROR
DROP TABLE information_schema.user_privileges;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.user_privileges
RENAME db_datadict.user_privileges;
--error ER_DBACCESS_DENIED_ERROR
ALTER TABLE information_schema.user_privileges
RENAME information_schema.xuser_privileges;
# Cleanup
DROP USER 'testuser1'@'localhost';

View File

@@ -0,0 +1,19 @@
# suite/funcs_1/t/is_views.test
#
# Check the layout of information_schema.views and the impact of
# CREATE/ALTER/DROP TABLE/VIEW/SCHEMA ... on it.
# Variant for the non embedded server
# The expected results must equal is_views_embedded except that
# that the privilege system works (affects some result sets).
#
# There is detailed information about this test within
# suite/funcs_1/datadict/is_views.inc
#
# Author:
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
# testsuite funcs_1
# Create this script based on older scripts and new code.
#
--source include/not_embedded.inc
--source suite/funcs_1/datadict/is_views.inc

View File

@@ -0,0 +1,24 @@
# suite/funcs_1/t/is_views_embedded.test
#
# Check the layout of information_schema.views and the impact of
# CREATE/ALTER/DROP TABLE/VIEW/SCHEMA ... on it.
# Variant for the embedded server
# The expected results must equal is_views except that all users
# have all privileges (affects some result sets).
#
# There is detailed information about this test within
# suite/funcs_1/datadict/is_views.inc
#
# Author:
# 2008-06-06 mleich Create this this variant for the embedded server.
#
if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{
--skip Test requires: embedded server
}
if (`SELECT VERSION() LIKE '%embedded%'`)
{
--skip Bug#37456 funcs_1: Several tests crash when used with embedded server
}
--source suite/funcs_1/datadict/is_views.inc

View File

@@ -0,0 +1,17 @@
#### suite/funcs_1/t/memory_bitdata
# Memory tables should be used
#
# Set $engine_type
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
let $message= NOT YET IMPLEMENTED: bitdata tests;
--source include/show_msg80.inc
exit;
# Create some objects needed in many testcases
USE test;
--source suite/funcs_1/include/memory_tb4.inc
--source suite/funcs_1/bitdata/bitdata_master.test

View File

@@ -0,0 +1,18 @@
#### suite/funcs_1/t/memory_cursors.test
# Memory tables should be used
#
# Set $engine_type
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
let $message= NOT YET IMPLEMENTED: cursor tests;
--source include/show_msg80.inc
exit;
# Create some objects needed in many testcases
USE test;
--source suite/funcs_1/include/memory_tb1.inc
--source suite/funcs_1/cursors/cursors_master.test

View File

@@ -0,0 +1,16 @@
###################################################
# #
# Functions within VIEWs based on Memory tables #
# #
###################################################
#
# NOTE: PLEASE SEE THE DETAILED DESCRIPTION IN
# suite/funcs_1/views/func_view.inc
# BEFORE ADDING NEW TEST CASES HERE !!!
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $type= 'MEMORY' ;
--source suite/funcs_1/views/func_view.inc

View File

@@ -0,0 +1,7 @@
#### suite/funcs_1/t/memory_storedproc_02.test
#
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
--source suite/funcs_1/storedproc/storedproc_02.inc

View File

@@ -0,0 +1,7 @@
#### suite/funcs_1/t/memory_storedproc_03.test
#
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
--source suite/funcs_1/storedproc/storedproc_03.inc

View File

@@ -0,0 +1,7 @@
#### suite/funcs_1/t/memory_storedproc_06.test
#
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
--source suite/funcs_1/storedproc/storedproc_06.inc

View File

@@ -0,0 +1,7 @@
#### suite/funcs_1/t/memory_storedproc_07.test
#
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
--source suite/funcs_1/storedproc/storedproc_07.inc

View File

@@ -0,0 +1,7 @@
#### suite/funcs_1/t/memory_storedproc_08.test
#
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
--source suite/funcs_1/storedproc/storedproc_08.inc

View File

@@ -0,0 +1,7 @@
#### suite/funcs_1/t/memory_storedproc_10.test
#
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
--source suite/funcs_1/storedproc/storedproc_10.inc

View File

@@ -0,0 +1,10 @@
#### suite/funcs_1/t/memory_trig_0102.test
# Memory tables should be used
#
# Set $engine_type
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
--source suite/funcs_1/include/bug28309_skip.inc
--source suite/funcs_1/triggers/triggers_0102.inc

View File

@@ -0,0 +1,9 @@
#### suite/funcs_1/t/memory_trig_03.test
# Memory tables should be used
#
# Set $engine_type
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
--source suite/funcs_1/triggers/triggers_03.inc

View File

@@ -0,0 +1,23 @@
#### suite/funcs_1/t/memory_triggers.test
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
# Memory tables should be used
#
# Set $engine_type
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
# Create some objects needed in many testcases
USE test;
--source suite/funcs_1/triggers/triggers_03e_db_level.inc
--source suite/funcs_1/triggers/triggers_03e_table_level.inc
--source suite/funcs_1/triggers/triggers_03e_global_db_mix.inc
--source suite/funcs_1/triggers/triggers_03e_db_table_mix.inc
--source suite/funcs_1/triggers/triggers_03e_prepare.inc
--source suite/funcs_1/triggers/triggers_03e_definer.inc
--source suite/funcs_1/triggers/triggers_03e_columns.inc

View File

@@ -0,0 +1,10 @@
#### suite/funcs_1/t/memory_trig_0407.test
# Memory tables should be used
#
# Set $engine_type
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
--source suite/funcs_1/include/bug28309_skip.inc
--source suite/funcs_1/triggers/triggers_0407.inc

View File

@@ -0,0 +1,9 @@
#### suite/funcs_1/t/memory_trig_08.test
# Memory tables should be used
#
# Set $engine_type
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
--source suite/funcs_1/triggers/triggers_08.inc

View File

@@ -0,0 +1,9 @@
#### suite/funcs_1/t/memory_trig_09.test
# Memory tables should be used
#
# Set $engine_type
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
--source suite/funcs_1/triggers/triggers_09.inc

View File

@@ -0,0 +1,10 @@
#### suite/funcs_1/t/memory_trig_1011ext.test
# Memory tables should be used
#
# Set $engine_type
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
let $engine_type= memory;
--source suite/funcs_1/include/bug28309_skip.inc
--source suite/funcs_1/triggers/triggers_1011ext.inc

Some files were not shown because too many files have changed in this diff Show More