Commit 30091e23 authored by mleich@five.local.lan's avatar mleich@five.local.lan
Browse files

WL#4203 Reorganize and fix the data dictionary tests of

        testsuite funcs_1
1. Fix the following bugs
   Bug#30440 "datadict" tests (all engines) fail: Character sets depend on configuration
      Solution: Test variants charset_collation_* adjusted to different builds
   Bug#32603 "datadict" tests (all engines) fail in "community" tree: "PROFILING" table
      Solution: Excluding "PROFILING" table from queries
   Bug#33654 "slow log" is missing a line
      Solution: Unify the content of the fields TABLES.TABLE_ROWS and
                STATISTICS.CARDINALITY within result sets
   Bug#34532 Some funcs_1 tests do not clean up at end of testing
      Solution: DROP objects/reset global server variables modified during testing
                + let tests missing implementation end before loading of tables
   Bug#31421 funcs_1: ndb__datadict fails, discrepancy between scripts and expected results
      Solution: Cut <engine>__datadict tests into smaller tests + generate new results.
   Bug#33599 INFORMATION_SCHEMA.STATISTICS got a new column INDEX_COMMENT: tests fail (2)
      Generation of new results during post merge fix
   Bug#33600 CHARACTER_OCTET_LENGTH is now CHARACTER_MAXIMUM_LENGTH * 4
      Generation of new results during post merge fix
   Bug#33631 Platform-specific replace of CHARACTER_MAXIMUM_LENGTH broken by 4-byte encoding
      Generation of new results during post merge fix
      + removal of platform-specific replace routine (no more needed)
2. Restructure the tests
   - Test not more than one INFORMATION_SCHEMA view per testscript
   - Separate tests of I_S view layout+functionality from content related to the
     all time existing databases "information_schema", "mysql" and "test"
   - Avoid storage engine related variants of tests which are not sensible to
     storage engines at all.
3. Reimplement or add some subtests + cleanup
   There is a some probability that even the reviewed changeset
   - does not fix all bugs from above   or
   - contains new bugs which show up on some platforms <> Linux or on one of
     the various build types
4. The changeset contains fixes according to
   - one code review
   - minor bugs within testing code found after code review (accepted by reviewer)
   - problems found during tests with 5.0.56 in build environment
parent 9ea63c27
Loading
Loading
Loading
Loading
+45 −133
Original line number Diff line number Diff line
Matthias 17.06.2005
-------------------
1. I changed the database test1 (dropped + created in SP test)
   to test4.
   Please adjust the SP test cases.
2. There is a difference between my definition of
       innodb_tb4 + memory_tb4
   to the latest table definition used by disha.
   Please adjust the table definition if needed.
3. The data load files are product of the Disha data generation script
   (downloaded ~20 May ?) + modified by Omer
   These load data fit fairly to the table definitions.
2008-02-29 Matthias Leich
=========================

1. The testsuite "funcs_1" is mostly intended for additional (compared
   to the common regression tests stored in mysql-test/t) checks
   of features (VIEWS, INFORMATION_SCHEMA, STORED PROCEDURES,...)
   introduced with MySQL 5.0.

2. There were some extensions of this suite when new information_schema
   views were introduced. But in most cases the tests for these views
   were stored within the regression testsuite (mysql-test/t).

   INFORMATION_SCHEMA views introduced with MySQL 5.1
   ==================================================
   ENGINES       (partially tested here)
   EVENTS        (partially tested here)
   FILES
   GLOBAL_STATUS
   GLOBAL_VARIABLES
   PARTITIONS
   PLUGINS
   PROCESSLIST   (full tested here)
   PROFILING
   REFERENTIAL_CONSTRAINTS
   SESSION_STATUS
   SESSION_VARIABLES

3. Some hints:
   - SHOW TABLES ... LIKE '<pattern>'
     does a case sensitive comparison between the tablename and
     the pattern.
     The names of the tables within the informationschema are in uppercase.
     So please use something like
        SHOW TABLES FOR information_schema LIKE 'TABLES'
     when you intend to get the same non empty result set on OS with and
     without case sensitive filesystems and default configuration.
   - The name of the data dictionary is 'information_schema' (lowercase).
   - Server on OS with filesystem with case sensitive filenames
     (= The files 'abc' and 'Abc' can coexist.)
     + default configuration
     Example of behaviour:
     DROP DATABASE information_schema;
     ERROR 42000: Access denied for user ... to database 'information_schema'
     DROP DATABASE INFORMATION_SCHEMA;
     ERROR 42000: Access denied for user ... to database 'INFORMATION_SCHEMA'
4. How to execute the "small" test with 10 rows per table.
   Do NOT set the environment variable NO_REFRESH to a
   value <> ''.
   Start the test for example by
   ./mysql-test-run.pl --vardir=/dev/shm/var \
              --force --suite=funcs_1 --do-test=myisam
   The "result" files fit mostly to this variant.

   Any database not in ('mysql','test') and any tables
   needed within a testcase ( t/<storage engine>_<test filed>.test )
   will be (re)created at the beginning of the test.

5. How to execute the "big" test with many rows per table.
   Replace the directories
     suite/funcs_1/data   and
     suite/funcs_1/r
   with the appropriate ones for the "big" test.
   Set the environment variable NO_REFRESH to a value <> ''.
   Start the test for example by
   ./mysql-test-run.pl --vardir=/dev/shm/var \
              --force --suite=funcs_1 --do-test=myisam

   All databases and tables will be (re)created by the script
   <storage engine>__load.test  .

6. I am not sure of the files
   ./funcs_1/include/create_<whatever>.inc
   are in the moment needed. I included them, because I
   guess my VIEW testcase example needs them.

I guess the pushed files are far away from being perfect.
It is a 8 hours hack.
Please try them, create missing files and come up with improvements.

Good luck !

Matthias 17.06.2005
===================================================================
Omer 19.06.2005
---------------
1. Changed the structure of the memory_tb3 table to include two
   additional column f121, f122. These columns exist for the table in
   the other storage engines as TEXT. Since memory does not support
   TEXT, Disha did not include them. How ever I am using them in the
   Trigger tests so added them to the memory definition as CHAR(50);.
   Also modifyed the DataGen_modiy.pl file to account for these two
   column when generating the data.
   - checked in a new DataGen_modify.pl (create a 'lib' directory
     under 'funcs_1').
   - checked in a new memory_tb3.txt
2. Added three <storage>_triggers.test files based on Matthias's
   structure above.
3. Added three <storage>__triggers.result files
4. Added the Trigger_master.test file in the trigger dierctory
   Note: This is not complete and is still under work
5. Created a 'lib' directory and added the DataGen*.pl scripts to it
   (exists under the disha suite) but should be here as well).
Omer 19.06.2005
===================================================================
Matthias 12.09.2005
-------------------
   Replace the geometry data types by VARBINARY
   The removal of the geometry data types was necessary, because the
   execution of the funcs_1 testsuite should not depend on the
   availability of the geometry feature.
   Note: There are servers compiled without the geometry feature.

   The columns are not removed, but their data type was changed
   VARBINARY. This allows us to omit any changes within the loader
   input files or data generation scripts.
   The replacement of geometry by VARCHAR allows us to use our

Matthias 12.09.2005
===================================================================
Matthias 14.09.2005
-------------------
   The results of the <storage_engine>_views testcases suffer when
   executed in "--ps-protocol" mode from the open
   Bug#11589: mysqltest, --ps-protocol, strange output,
              float/double/real with zerofill  .
   Implementation of a workaround:
     At the beginning of views_master.inc is a variable $have_bug_11589 .
     If this varable is set to 1, the ps-protocol will be switched
     of for the critical statements.
Matthias 14.09.2005
===================================================================
Carsten 16.09.2005
------------------
1. The results of the datadict_<engine> testcases have been changed in nearly 
   all occurrencies of --error <n> because now for the INFORMATION_SCHEMA only 
   the --error 1044 (ERROR 42000: Access denied for user '..' to database 
   'information_schema') seems to be used.
2. To get identical results when using "--ps-protocol" some SELECTs FROM 
   information_schema has been wrapped to suppress using ps-protocol because 
   there are differences.
3. The test using SELECT .. OUTFILE has been disabled due to bug #13202.
4. Fixed datadict_<engine>.result files after the change that added 2 columns to 
   the VIEWS table (DEFINER varchar(77), SECURITY_TYPE varchar(7)).
===================================================================
Matthias 25.08.2007
-------------------
Fixes for Bugs 30418,30420,30438,30440 
1. Replace error numbers with error names
2. Replace static "InnoDB" (not all time available) used within an
   "alter table" by $OTHER_ENGINE_TYPE (set to MEMORY or MyISAM).
   Minor adjustment of column data type.
3. Use mysqltest result set sorting in several cases.
4. Avoid any statistics about help tables, because their content
   depends on configuration:
   developer release - help tables are empty
   build release     - help tables have content + growing with version
5. Add two help table related tests (one for build, one for developer)
   to ensure that informations about help tables within
   INFORMATION_SCHEMA.TABLES/STATISTICS are checked.
General note:
   Most INFORMATION_SCHEMA properties (table layout, permissions etc.)
   are not affected by our variation of the storage engines except
   that some properties of our tables using a specific storage
   engine become visible. So it makes sense to decompose
   this test into a storage engine specific part and a non
   storage engine specific part in future.
+53 −0
Original line number Diff line number Diff line
# suite/funcs_1/datadict/basics_mixed1.inc
#
# Auxiliary script to be sourced by suite/funcs_1/t/is_basics_mixed.test
#
# 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.
#

# 1 Attempt to create tables and views when residing in information_schema
# 1.1 CREATE TABLE
USE information_schema;
let $message= root: create a table with a name of an IS table directly in IS;
let $dd_part1= CREATE TABLE;
let $dd_part2= ( c1 INT );
--source suite/funcs_1/datadict/basics_mixed2.inc
# FIXME 3.2.1.6: error message ER_UNKNOWN_TABLE is misleading
--error ER_UNKNOWN_TABLE
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
#
# 1.2 CREATE VIEW
# 1.2.1 Hit on existing INFORMATION_SCHEMA table
--error ER_DBACCESS_DENIED_ERROR
CREATE VIEW tables AS SELECT 'garbage';
--error ER_DBACCESS_DENIED_ERROR
CREATE VIEW tables AS SELECT * FROM information_schema.tables;
# 1.2.2 New view
# ER_DBACCESS_DENIED_ERROR would be better.
--error ER_UNKNOWN_TABLE
CREATE VIEW v1 AS SELECT 'garbage';

# 2 Attempt to create tables and views when residing in information_schema
# 1.1 CREATE TABLE
USE test;
let $message= root: create a table with a name of an IS table from other db;
let $dd_part1= CREATE TABLE information_schema.;
let $dd_part2= ( c1 INT );
--source suite/funcs_1/datadict/basics_mixed2.inc
# FIXME 3.2.1.6: error message ER_UNKNOWN_TABLE is misleading
--error ER_UNKNOWN_TABLE
CREATE TABLE information_schema.t1 (f1 INT, f2 INT, f3 INT);
#
# Hit on existing INFORMATION_SCHEMA table
--error ER_DBACCESS_DENIED_ERROR
CREATE VIEW information_schema.tables AS SELECT 'garbage';
--error ER_DBACCESS_DENIED_ERROR
CREATE VIEW information_schema.tables AS
SELECT * FROM information_schema.tables;
# New table
# ER_DBACCESS_DENIED_ERROR would be better.
--error ER_UNKNOWN_TABLE
CREATE VIEW information_schema.v1 AS SELECT 'garbage';
+55 −0
Original line number Diff line number Diff line
#### suite/funcs_1/datadict/datadict_tables.inc

#### suite/funcs_1/datadict/basics_mixed2.inc
#
# Auxiliary script to be sourced by suite/funcs_1/datadict/is_basics_mixed1.inc
#
# contains all tables from INFORMATION_SCHEMA

# usage:

# --source suite/funcs_1/datadict/datadict_tables_err_<no>.inc
#
# up to a change of "mysqltest", which makes lines like "eval --error $err_no"
# possible we will have some different files with the same content except the
# error numbers.

--source include/show_msg.inc

let $message= known error 1051:;
--source include/show_msg.inc
# Usage example(snip of script):
#    let $dd_part1= CREATE TABLE information_schema.;
#    let $dd_part2= ( c1 INT );
#    --source suite/funcs_1/datadict/basics_mixed2.inc
#
# We expect to get
# ERROR 42000: Access denied for user 'root'@'localhost'
#              to database 'information_schema'
# for every statement.
#
# 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.
#

--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 schemata                              $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 tables                                $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 columns                               $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 character_sets                        $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 collations                            $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 collation_character_set_applicability $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 routines                              $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 statistics                            $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 views                                 $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 user_privileges                       $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 schema_privileges                     $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 table_privileges                      $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 column_privileges                     $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 table_constraints                     $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 key_column_usage                      $dd_part2;
--error 1051
--error ER_DBACCESS_DENIED_ERROR
eval $dd_part1 triggers                              $dd_part2;
+42 −0
Original line number Diff line number Diff line
#### suite/funcs_1/datadict/basics_mixed3.inc
#
# Auxiliary routine to be sourced by suite/funcs_1/t/is_basics_mixed.test
#
# Check if INFORMATION_SCHEMA tables contain a schema_name like 'db_data%'.
#
# 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.
#

# No column with the name of a database contained in:
#    character_sets collations collation_character_set_applicability
#    user_privileges
SELECT DISTINCT table_schema FROM information_schema.columns
WHERE table_schema LIKE 'db_data%';
SELECT DISTINCT table_schema FROM information_schema.column_privileges
WHERE table_schema LIKE 'db_data%';
SELECT DISTINCT constraint_schema,table_schema
FROM information_schema.key_column_usage
WHERE constraint_schema LIKE 'db_data%' OR table_schema LIKE 'db_data%';
SELECT DISTINCT routine_schema FROM information_schema.routines
WHERE routine_schema LIKE 'db_data%';
SELECT DISTINCT schema_name FROM information_schema.schemata
WHERE schema_name LIKE 'db_data%';
SELECT DISTINCT table_schema FROM information_schema.schema_privileges
WHERE table_schema LIKE 'db_data%';
SELECT DISTINCT table_schema,index_schema FROM information_schema.statistics
WHERE table_schema LIKE 'db_data%' OR index_schema LIKE 'db_data%';
SELECT DISTINCT table_schema FROM information_schema.tables
WHERE table_schema LIKE 'db_data%';
SELECT DISTINCT constraint_schema,table_schema
FROM information_schema.table_constraints
WHERE constraint_schema LIKE 'db_data%' OR table_schema LIKE 'db_data%';
SELECT DISTINCT table_schema FROM information_schema.table_privileges
WHERE table_schema LIKE 'db_data%';
SELECT DISTINCT trigger_schema,event_object_schema
FROM information_schema.triggers
WHERE trigger_schema LIKE 'db_data%' OR event_object_schema LIKE 'db_data%';
SELECT DISTINCT table_schema FROM information_schema.views
WHERE table_schema LIKE 'db_data%';
+122 −0
Original line number Diff line number Diff line
# suite/funcs_1/datadict/charset_collation.inc
#
# Tests checking the content of the information_schema tables
#      character_sets
#      collations
#      collation_character_set_applicability
#
#
# The amount and properties of character_sets/collations depend on the
# build type
# 2007-12 MySQL 5.0
# ---------------------------------------------------------------------
#
# Variant 1 fits to
#    version_comment       MySQL Enterprise Server (Commercial)
#    version_comment       MySQL Enterprise Server (GPL)
#    version_comment       MySQL Classic Server (Commercial)
#    version_comment       MySQL Pushbuild Edition, build <number>
#   (version_comment       Source distribution
#    and
#    compile was without "max" - > no collation 'utf8_general_ci')
#
# Variant 2 fits to
#    version_comment       MySQL Enterprise Server (GPL)
#    version_comment       MySQL Classic Server (Commercial)
#    version_comment       MySQL Pushbuild Edition, build <number>
#   (version_comment       Source distribution
#    and
#    compile was without "max" - > collation 'utf8_general_ci' exists)
#
# Difference between variant 1 and 2 is the collation 'utf8_general_ci'.
#
# Variant 3 fits to
#    version_comment       MySQL Community Server (GPL)
#    version_comment       MySQL Cluster Server (Commercial)
#
# Difference between variant 3 and 2 is within the collation properties
# IS_COMPILED and SORTLEN.
#
# Created:
# 2007-12-18 mleich - remove the unstable character_set/collation subtests
#                     from include/datadict-master.inc
#                   - create this new test
#

# 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)
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
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 (2007-12-19 mleich):
# - The requirements are outdated because grant/revoke privilege for using a
#   characterset/collation were never implemented.
#   Therefore the tests should simply check the content 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,...)
#
#
################################################################################
--echo
SELECT *
FROM information_schema.character_sets
ORDER BY character_set_name;

--echo
SELECT *
FROM information_schema.collations
ORDER BY collation_name;

echo;
--echo
SELECT *
FROM information_schema.collation_character_set_applicability
ORDER BY collation_name, character_set_name;


# Cleanup
--echo # Switch to connection default + disconnect con
connection default;
disconnect con;
DROP USER dbdict_test@localhost;
Loading