summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <vva@eagle.mysql.r18.ru>2004-03-10 22:54:07 +0400
committerunknown <vva@eagle.mysql.r18.ru>2004-03-10 22:54:07 +0400
commit2053f8f850f2b078dc947fa38d23339b8b24fed9 (patch)
tree9477ae54316c6e9890d227309fae165d98b377c9 /mysql-test
parentc0422729cf5b271d703564ff42afc621b069dfe5 (diff)
downloadmariadb-git-2053f8f850f2b078dc947fa38d23339b8b24fed9.tar.gz
fixed BUG #2874 "Grant table bug" and
added tests for testing structure of mysql db client/mysqltest.c: extend "replace" to column names extend "disable_result_log" to output of --exec commad mysql-test/install_test_db.sh: corrected wrong column definitions (as a result of tests) mysql-test/mysql-test-run.sh: export MYSQL and MYSQL_FIX_SYSTEM_TABLES + added option --result-file for *.opt files scripts/mysql_fix_privilege_tables.sh: added new options to using in tests + added new alters (as a result of new tests) scripts/mysql_fix_privilege_tables.sql: added new alters (as a result of new tests) scripts/mysql_install_db.sh: corrected definition of tables_priv.Table_name
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/include/system_db_struct.inc12
-rw-r--r--mysql-test/install_test_db.sh28
-rw-r--r--mysql-test/mysql-test-run.sh16
-rw-r--r--mysql-test/r/system_mysql_db.result119
-rw-r--r--mysql-test/r/system_mysql_db_refs.result67
-rw-r--r--mysql-test/t/reserv/system_mysql_db.test8
-rw-r--r--mysql-test/t/reserv/system_mysql_db_fix-master.opt1
-rw-r--r--mysql-test/t/reserv/system_mysql_db_fix.test14
-rw-r--r--mysql-test/t/reserv/system_mysql_db_refs.test89
9 files changed, 338 insertions, 16 deletions
diff --git a/mysql-test/include/system_db_struct.inc b/mysql-test/include/system_db_struct.inc
new file mode 100644
index 00000000000..5a7aa26c65a
--- /dev/null
+++ b/mysql-test/include/system_db_struct.inc
@@ -0,0 +1,12 @@
+#
+# This test must examine structure of current system database
+#
+
+-- replace_result Tables_in_mysql Tables_in_db Tables_in_test Tables_in_db
+show tables;
+show create table db;
+show create table host;
+show create table user;
+show create table func;
+show create table tables_priv;
+show create table columns_priv;
diff --git a/mysql-test/install_test_db.sh b/mysql-test/install_test_db.sh
index 8f90301d2d8..2eb19e88764 100644
--- a/mysql-test/install_test_db.sh
+++ b/mysql-test/install_test_db.sh
@@ -72,9 +72,9 @@ if test ! -f $mdata/db.frm
then
# mysqld --bootstrap wants one command/line
c_d="$c_d CREATE TABLE db ("
- c_d="$c_d Host char(60) DEFAULT '' NOT NULL,"
- c_d="$c_d Db char(64) DEFAULT '' NOT NULL,"
- c_d="$c_d User char(16) DEFAULT '' NOT NULL,"
+ c_d="$c_d Host char(60) binary DEFAULT '' NOT NULL,"
+ c_d="$c_d Db char(64) binary DEFAULT '' NOT NULL,"
+ c_d="$c_d User char(16) binary DEFAULT '' NOT NULL,"
c_d="$c_d Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
@@ -99,8 +99,8 @@ fi
if test ! -f $mdata/host.frm
then
c_h="$c_h CREATE TABLE host ("
- c_h="$c_h Host char(60) DEFAULT '' NOT NULL,"
- c_h="$c_h Db char(64) DEFAULT '' NOT NULL,"
+ c_h="$c_h Host char(60) binary DEFAULT '' NOT NULL,"
+ c_h="$c_h Db char(64) binary DEFAULT '' NOT NULL,"
c_h="$c_h Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
@@ -178,10 +178,10 @@ fi
if test ! -f $mdata/tables_priv.frm
then
c_t="$c_t CREATE TABLE tables_priv ("
- c_t="$c_t Host char(60) DEFAULT '' NOT NULL,"
- c_t="$c_t Db char(64) DEFAULT '' NOT NULL,"
- c_t="$c_t User char(16) DEFAULT '' NOT NULL,"
- c_t="$c_t Table_name char(60) DEFAULT '' NOT NULL,"
+ c_t="$c_t Host char(60) binary DEFAULT '' NOT NULL,"
+ c_t="$c_t Db char(64) binary DEFAULT '' NOT NULL,"
+ c_t="$c_t User char(16) binary DEFAULT '' NOT NULL,"
+ c_t="$c_t Table_name char(64) binary DEFAULT '' NOT NULL,"
c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL,"
c_t="$c_t Timestamp timestamp(14),"
c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL,"
@@ -195,11 +195,11 @@ fi
if test ! -f $mdata/columns_priv.frm
then
c_c="$c_c CREATE TABLE columns_priv ("
- c_c="$c_c Host char(60) DEFAULT '' NOT NULL,"
- c_c="$c_c Db char(64) DEFAULT '' NOT NULL,"
- c_c="$c_c User char(16) DEFAULT '' NOT NULL,"
- c_c="$c_c Table_name char(64) DEFAULT '' NOT NULL,"
- c_c="$c_c Column_name char(64) DEFAULT '' NOT NULL,"
+ c_c="$c_c Host char(60) binary DEFAULT '' NOT NULL,"
+ c_c="$c_c Db char(64) binary DEFAULT '' NOT NULL,"
+ c_c="$c_c User char(16) binary DEFAULT '' NOT NULL,"
+ c_c="$c_c Table_name char(64) binary DEFAULT '' NOT NULL,"
+ c_c="$c_c Column_name char(64) binary DEFAULT '' NOT NULL,"
c_c="$c_c Timestamp timestamp(14),"
c_c="$c_c Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,"
c_c="$c_c PRIMARY KEY (Host,Db,User,Table_name,Column_name)"
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index 5b39b167d7d..6fc699da9dd 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -461,6 +461,7 @@ if [ x$SOURCE_DIST = x1 ] ; then
LANGUAGE="$BASEDIR/sql/share/english/"
CHARSETSDIR="$BASEDIR/sql/share/charsets"
INSTALL_DB="./install_test_db"
+ MYSQL_FIX_SYSTEM_TABLES="$BASEDIR/scripts/mysql_fix_privilege_tables"
else
if test -x "$BASEDIR/libexec/mysqld"
then
@@ -478,6 +479,7 @@ else
MYSQL_MANAGER_PWGEN="$BASEDIR/bin/mysqlmanager-pwgen"
MYSQL="$BASEDIR/bin/mysql"
INSTALL_DB="./install_test_db -bin"
+ MYSQL_FIX_SYSTEM_TABLES="$BASEDIR/bin/mysql_fix_privilege_tables"
if test -d "$BASEDIR/share/mysql/english"
then
LANGUAGE="$BASEDIR/share/mysql/english/"
@@ -490,8 +492,12 @@ fi
MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK"
MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR"
+MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password="
+MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password="
+export MYSQL
export MYSQL_DUMP
export MYSQL_BINLOG
+export MYSQL_FIX_SYSTEM_TABLES
if [ -z "$MASTER_MYSQLD" ]
then
@@ -1168,6 +1174,7 @@ run_testcase ()
master_init_script=$TESTDIR/$tname-master.sh
slave_init_script=$TESTDIR/$tname-slave.sh
slave_master_info_file=$TESTDIR/$tname.slave-mi
+ result_file=$tname
echo $tname > $CURRENT_TEST
SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
if [ $USE_MANAGER = 1 ] ; then
@@ -1217,6 +1224,11 @@ run_testcase ()
# Note that this must be set to space, not "" for test-reset to work
EXTRA_MASTER_OPT=" "
;;
+ --result-file=*)
+ result_file=`$ECHO "$EXTRA_MASTER_OPT" | $SED -e "s;--result-file=;;"`
+ # Note that this must be set to space, not "" for test-reset to work
+ EXTRA_MASTER_OPT=" "
+ ;;
esac
stop_master
echo "CURRENT_TEST: $tname" >> $MASTER_MYERR
@@ -1274,7 +1286,7 @@ run_testcase ()
if [ -f $tf ] ; then
$RM -f r/$tname.*reject
- mysql_test_args="-R r/$tname.result $EXTRA_MYSQL_TEST_OPT"
+ mysql_test_args="-R r/$result_file.result $EXTRA_MYSQL_TEST_OPT"
if [ -z "$DO_CLIENT_GDB" ] ; then
`$MYSQL_TEST $mysql_test_args < $tf 2> $TIMEFILE`;
else
@@ -1306,7 +1318,7 @@ run_testcase ()
$ECHO "$RES$RES_SPACE [ fail ]"
$ECHO
error_is
- show_failed_diff $tname
+ show_failed_diff $result_file
$ECHO
if [ x$FORCE != x1 ] ; then
$ECHO "Aborting. To continue, re-run with '--force'."
diff --git a/mysql-test/r/system_mysql_db.result b/mysql-test/r/system_mysql_db.result
new file mode 100644
index 00000000000..257b3b13f08
--- /dev/null
+++ b/mysql-test/r/system_mysql_db.result
@@ -0,0 +1,119 @@
+show tables;
+Tables_in_db
+columns_priv
+db
+func
+host
+tables_priv
+user
+show create table db;
+Table Create Table
+db CREATE TABLE `db` (
+ `Host` char(60) binary NOT NULL default '',
+ `Db` char(64) binary NOT NULL default '',
+ `User` char(16) binary NOT NULL default '',
+ `Select_priv` enum('N','Y') NOT NULL default 'N',
+ `Insert_priv` enum('N','Y') NOT NULL default 'N',
+ `Update_priv` enum('N','Y') NOT NULL default 'N',
+ `Delete_priv` enum('N','Y') NOT NULL default 'N',
+ `Create_priv` enum('N','Y') NOT NULL default 'N',
+ `Drop_priv` enum('N','Y') NOT NULL default 'N',
+ `Grant_priv` enum('N','Y') NOT NULL default 'N',
+ `References_priv` enum('N','Y') NOT NULL default 'N',
+ `Index_priv` enum('N','Y') NOT NULL default 'N',
+ `Alter_priv` enum('N','Y') NOT NULL default 'N',
+ `Create_tmp_table_priv` enum('N','Y') NOT NULL default 'N',
+ `Lock_tables_priv` enum('N','Y') NOT NULL default 'N',
+ PRIMARY KEY (`Host`,`Db`,`User`),
+ KEY `User` (`User`)
+) TYPE=MyISAM COMMENT='Database privileges'
+show create table host;
+Table Create Table
+host CREATE TABLE `host` (
+ `Host` char(60) binary NOT NULL default '',
+ `Db` char(64) binary NOT NULL default '',
+ `Select_priv` enum('N','Y') NOT NULL default 'N',
+ `Insert_priv` enum('N','Y') NOT NULL default 'N',
+ `Update_priv` enum('N','Y') NOT NULL default 'N',
+ `Delete_priv` enum('N','Y') NOT NULL default 'N',
+ `Create_priv` enum('N','Y') NOT NULL default 'N',
+ `Drop_priv` enum('N','Y') NOT NULL default 'N',
+ `Grant_priv` enum('N','Y') NOT NULL default 'N',
+ `References_priv` enum('N','Y') NOT NULL default 'N',
+ `Index_priv` enum('N','Y') NOT NULL default 'N',
+ `Alter_priv` enum('N','Y') NOT NULL default 'N',
+ `Create_tmp_table_priv` enum('N','Y') NOT NULL default 'N',
+ `Lock_tables_priv` enum('N','Y') NOT NULL default 'N',
+ PRIMARY KEY (`Host`,`Db`)
+) TYPE=MyISAM COMMENT='Host privileges; Merged with database privileges'
+show create table user;
+Table Create Table
+user CREATE TABLE `user` (
+ `Host` varchar(60) binary NOT NULL default '',
+ `User` varchar(16) binary NOT NULL default '',
+ `Password` varchar(16) binary NOT NULL default '',
+ `Select_priv` enum('N','Y') NOT NULL default 'N',
+ `Insert_priv` enum('N','Y') NOT NULL default 'N',
+ `Update_priv` enum('N','Y') NOT NULL default 'N',
+ `Delete_priv` enum('N','Y') NOT NULL default 'N',
+ `Create_priv` enum('N','Y') NOT NULL default 'N',
+ `Drop_priv` enum('N','Y') NOT NULL default 'N',
+ `Reload_priv` enum('N','Y') NOT NULL default 'N',
+ `Shutdown_priv` enum('N','Y') NOT NULL default 'N',
+ `Process_priv` enum('N','Y') NOT NULL default 'N',
+ `File_priv` enum('N','Y') NOT NULL default 'N',
+ `Grant_priv` enum('N','Y') NOT NULL default 'N',
+ `References_priv` enum('N','Y') NOT NULL default 'N',
+ `Index_priv` enum('N','Y') NOT NULL default 'N',
+ `Alter_priv` enum('N','Y') NOT NULL default 'N',
+ `Show_db_priv` enum('N','Y') NOT NULL default 'N',
+ `Super_priv` enum('N','Y') NOT NULL default 'N',
+ `Create_tmp_table_priv` enum('N','Y') NOT NULL default 'N',
+ `Lock_tables_priv` enum('N','Y') NOT NULL default 'N',
+ `Execute_priv` enum('N','Y') NOT NULL default 'N',
+ `Repl_slave_priv` enum('N','Y') NOT NULL default 'N',
+ `Repl_client_priv` enum('N','Y') NOT NULL default 'N',
+ `ssl_type` enum('','ANY','X509','SPECIFIED') NOT NULL default '',
+ `ssl_cipher` blob NOT NULL,
+ `x509_issuer` blob NOT NULL,
+ `x509_subject` blob NOT NULL,
+ `max_questions` int(11) unsigned NOT NULL default '0',
+ `max_updates` int(11) unsigned NOT NULL default '0',
+ `max_connections` int(11) unsigned NOT NULL default '0',
+ PRIMARY KEY (`Host`,`User`)
+) TYPE=MyISAM COMMENT='Users and global privileges'
+show create table func;
+Table Create Table
+func CREATE TABLE `func` (
+ `name` char(64) NOT NULL default '',
+ `ret` tinyint(1) NOT NULL default '0',
+ `dl` char(128) NOT NULL default '',
+ `type` enum('function','aggregate') NOT NULL default 'function',
+ PRIMARY KEY (`name`)
+) TYPE=MyISAM COMMENT='User defined functions'
+show create table tables_priv;
+Table Create Table
+tables_priv CREATE TABLE `tables_priv` (
+ `Host` char(60) binary NOT NULL default '',
+ `Db` char(64) binary NOT NULL default '',
+ `User` char(16) binary NOT NULL default '',
+ `Table_name` char(64) binary NOT NULL default '',
+ `Grantor` char(77) NOT NULL default '',
+ `Timestamp` timestamp(14) NOT NULL,
+ `Table_priv` set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') NOT NULL default '',
+ `Column_priv` set('Select','Insert','Update','References') NOT NULL default '',
+ PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`),
+ KEY `Grantor` (`Grantor`)
+) TYPE=MyISAM COMMENT='Table privileges'
+show create table columns_priv;
+Table Create Table
+columns_priv CREATE TABLE `columns_priv` (
+ `Host` char(60) binary NOT NULL default '',
+ `Db` char(64) binary NOT NULL default '',
+ `User` char(16) binary NOT NULL default '',
+ `Table_name` char(64) binary NOT NULL default '',
+ `Column_name` char(64) binary NOT NULL default '',
+ `Timestamp` timestamp(14) NOT NULL,
+ `Column_priv` set('Select','Insert','Update','References') NOT NULL default '',
+ PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`,`Column_name`)
+) TYPE=MyISAM COMMENT='Column privileges'
diff --git a/mysql-test/r/system_mysql_db_refs.result b/mysql-test/r/system_mysql_db_refs.result
new file mode 100644
index 00000000000..a08b46ffbbb
--- /dev/null
+++ b/mysql-test/r/system_mysql_db_refs.result
@@ -0,0 +1,67 @@
+set @name="This is a very long string, that mustn't find room in a system field like Table_name. Thus it should be cut by the actual size of the field. So we can use this string to find out the actual length of the field and to use it in any compare queries";
+create table test_db select * from mysql.db;
+delete from test_db;
+insert into test_db (Host,Db,User) values (@name,@name,@name);
+create table test_host select * from mysql.host;
+delete from test_host;
+insert into test_host (Host,Db) values (@name,@name);
+create table test_user select * from mysql.user;
+delete from test_user;
+insert into test_user (Host,User) values (@name,@name);
+create table test_func select * from mysql.func;
+delete from test_func;
+insert into test_func (name) values (@name);
+create table test_tables_priv select * from mysql.tables_priv;
+delete from test_tables_priv;
+insert into test_tables_priv (Host,Db,User,Table_name) values (@name,@name,@name,@name);
+create table test_columns_priv select * from mysql.columns_priv;
+delete from test_columns_priv;
+insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name);
+select
+if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_Host,
+if(isnull(test_host.Host),'WRONG!!!','ok') as test_host_Host,
+if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_Host,
+if(isnull(test_tables_priv.Host),'WRONG!!!','ok') as test_tables_priv_Host,
+if(isnull(test_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host
+from test_db
+left join test_host on test_db.Host=test_host.Host
+left join test_user on test_db.Host=test_user.Host
+left join test_tables_priv on test_db.Host=test_tables_priv.Host
+left join test_columns_priv on test_db.Host=test_columns_priv.Host;
+test_db_Host test_host_Host test_user_Host test_tables_priv_Host test_columns_priv_Host
+ok ok ok ok ok
+select
+if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db,
+if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db,
+if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db,
+if(isnull(test_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db
+from test_db
+left join test_host on test_db.Db=test_host.Db
+left join test_tables_priv on test_db.Db=test_tables_priv.Db
+left join test_columns_priv on test_db.Db=test_columns_priv.Db;
+test_db_Db test_host_Db test_tables_priv_Db est_columns_priv_Db
+ok ok ok ok
+select
+if(isnull(test_db.User),'WRONG!!!','ok') as test_db_User,
+if(isnull(test_user.User),'WRONG!!!','ok') as test_user_User,
+if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User,
+if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User
+from test_db
+left join test_user on test_db.User=test_user.User
+left join test_tables_priv on test_db.User=test_tables_priv.User
+left join test_columns_priv on test_db.User=test_columns_priv.User;
+test_db_User test_user_User test_tables_priv_User test_columns_priv_User
+ok ok ok ok
+select
+if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User,
+if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User
+from test_tables_priv
+left join test_columns_priv on test_tables_priv.Table_name=test_columns_priv.Table_name;
+test_tables_priv_User test_columns_priv_User
+ok ok
+drop table test_columns_priv;
+drop table test_tables_priv;
+drop table test_func;
+drop table test_host;
+drop table test_user;
+drop table test_db;
diff --git a/mysql-test/t/reserv/system_mysql_db.test b/mysql-test/t/reserv/system_mysql_db.test
new file mode 100644
index 00000000000..85a2f7f9bae
--- /dev/null
+++ b/mysql-test/t/reserv/system_mysql_db.test
@@ -0,0 +1,8 @@
+#
+# This test must examine integrity of system database "mysql"
+#
+
+-- disable_query_log
+use mysql;
+-- enable_query_log
+-- source include/system_db_struct.inc
diff --git a/mysql-test/t/reserv/system_mysql_db_fix-master.opt b/mysql-test/t/reserv/system_mysql_db_fix-master.opt
new file mode 100644
index 00000000000..69eb9d2cbf0
--- /dev/null
+++ b/mysql-test/t/reserv/system_mysql_db_fix-master.opt
@@ -0,0 +1 @@
+--result-file=system_mysql_db \ No newline at end of file
diff --git a/mysql-test/t/reserv/system_mysql_db_fix.test b/mysql-test/t/reserv/system_mysql_db_fix.test
new file mode 100644
index 00000000000..bb2d37ee215
--- /dev/null
+++ b/mysql-test/t/reserv/system_mysql_db_fix.test
@@ -0,0 +1,14 @@
+#
+# This is the test for mysql_fix_privilege_tables
+#
+
+-- disable_query_log
+-- source include/create_old_system_tables.inc
+-- exec $MYSQL_FIX_SYSTEM_TABLES --database=test > nil 2>nil
+-- enable_query_log
+
+-- source include/system_db_struct.inc
+
+-- disable_query_log
+-- source include/drop_system_tables.inc
+-- enable_query_log
diff --git a/mysql-test/t/reserv/system_mysql_db_refs.test b/mysql-test/t/reserv/system_mysql_db_refs.test
new file mode 100644
index 00000000000..d15141fdaa5
--- /dev/null
+++ b/mysql-test/t/reserv/system_mysql_db_refs.test
@@ -0,0 +1,89 @@
+#
+# This test must examine integrity of current system database
+#
+
+set @name="This is a very long string, that mustn't find room in a system field like Table_name. Thus it should be cut by the actual size of the field. So we can use this string to find out the actual length of the field and to use it in any compare queries";
+
+#
+# If this part is wrong, most likely you've done wrong modification of system database "mysql"
+#
+
+create table test_db select * from mysql.db;
+delete from test_db;
+insert into test_db (Host,Db,User) values (@name,@name,@name);
+
+create table test_host select * from mysql.host;
+delete from test_host;
+insert into test_host (Host,Db) values (@name,@name);
+
+create table test_user select * from mysql.user;
+delete from test_user;
+insert into test_user (Host,User) values (@name,@name);
+
+create table test_func select * from mysql.func;
+delete from test_func;
+insert into test_func (name) values (@name);
+
+create table test_tables_priv select * from mysql.tables_priv;
+delete from test_tables_priv;
+insert into test_tables_priv (Host,Db,User,Table_name) values (@name,@name,@name,@name);
+
+create table test_columns_priv select * from mysql.columns_priv;
+delete from test_columns_priv;
+insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name);
+
+# 'Host' field must be the same for all the tables:
+
+select
+ if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_Host,
+ if(isnull(test_host.Host),'WRONG!!!','ok') as test_host_Host,
+ if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_Host,
+ if(isnull(test_tables_priv.Host),'WRONG!!!','ok') as test_tables_priv_Host,
+ if(isnull(test_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host
+
+from test_db
+left join test_host on test_db.Host=test_host.Host
+left join test_user on test_db.Host=test_user.Host
+left join test_tables_priv on test_db.Host=test_tables_priv.Host
+left join test_columns_priv on test_db.Host=test_columns_priv.Host;
+
+# 'Db' field must be the same for all the tables:
+
+select
+ if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db,
+ if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db,
+ if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db,
+ if(isnull(test_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db
+
+from test_db
+left join test_host on test_db.Db=test_host.Db
+left join test_tables_priv on test_db.Db=test_tables_priv.Db
+left join test_columns_priv on test_db.Db=test_columns_priv.Db;
+
+# 'User' field must be the same for all the tables:
+
+select
+ if(isnull(test_db.User),'WRONG!!!','ok') as test_db_User,
+ if(isnull(test_user.User),'WRONG!!!','ok') as test_user_User,
+ if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User,
+ if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User
+
+from test_db
+left join test_user on test_db.User=test_user.User
+left join test_tables_priv on test_db.User=test_tables_priv.User
+left join test_columns_priv on test_db.User=test_columns_priv.User;
+
+# 'Table_name' field must be the same for all the tables:
+
+select
+ if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User,
+ if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User
+from test_tables_priv
+left join test_columns_priv on test_tables_priv.Table_name=test_columns_priv.Table_name;
+
+drop table test_columns_priv;
+drop table test_tables_priv;
+drop table test_func;
+drop table test_host;
+drop table test_user;
+drop table test_db;