1call mtr.add_suppression("Column count of mysql.proc is wrong. Expected 20, found 19. The table is probably corrupted");
2call mtr.add_suppression("Stored routine .test...bug14233_[123].: invalid value in column mysql.proc");
3use test;
4SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
5Warnings:
6Warning	3090	Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
7drop procedure if exists bug14233;
8drop function if exists bug14233;
9drop table if exists t1;
10drop view if exists v1;
11create procedure bug14233()
12set @x = 42;
13create function bug14233_f() returns int
14return 42;
15create table t1 (id int);
16create trigger t1_ai after insert on t1 for each row call bug14233();
17alter table mysql.proc drop type;
18call bug14233();
19ERROR HY000: Column count of mysql.proc is wrong. Expected 20, found 19. The table is probably corrupted
20create view v1 as select bug14233_f();
21ERROR HY000: Column count of mysql.proc is wrong. Expected 20, found 19. The table is probably corrupted
22insert into t1 values (0);
23ERROR HY000: Column count of mysql.proc is wrong. Expected 20, found 19. The table is probably corrupted
24show procedure status;
25ERROR HY000: Column count of mysql.proc is wrong. Expected 20, found 19. The table is probably corrupted
26flush table mysql.proc;
27call bug14233();
28ERROR HY000: Incorrect information in file: './mysql/proc.frm'
29create view v1 as select bug14233_f();
30ERROR HY000: Incorrect information in file: './mysql/proc.frm'
31insert into t1 values (0);
32ERROR HY000: Incorrect information in file: './mysql/proc.frm'
33flush table mysql.proc;
34call bug14233();
35ERROR 42S02: Table 'mysql.proc' doesn't exist
36create view v1 as select bug14233_f();
37ERROR 42S02: Table 'mysql.proc' doesn't exist
38insert into t1 values (0);
39ERROR 42S02: Table 'mysql.proc' doesn't exist
40flush table mysql.proc;
41flush privileges;
42delete from mysql.proc where name like 'bug14233%';
43insert into mysql.proc
44(
45db, name, type, specific_name, language, sql_data_access, is_deterministic,
46security_type, param_list, returns, body, definer, created, modified,
47sql_mode, comment, character_set_client, collation_connection, db_collation,
48body_utf8
49)
50values
51(
52'test', 'bug14233_1', 'FUNCTION', 'bug14233_1', 'SQL', 'READS_SQL_DATA', 'NO',
53'DEFINER', '', 'int(10)',
54'select count(*) from mysql.user',
55'root@localhost', NOW() , '0000-00-00 00:00:00', '', '',
56'', '', '',
57'select count(*) from mysql.user'
58),
59(
60'test', 'bug14233_2', 'FUNCTION', 'bug14233_2', 'SQL', 'READS_SQL_DATA', 'NO',
61'DEFINER', '', 'int(10)',
62'begin declare x int; select count(*) into x from mysql.user; end',
63'root@localhost', NOW() , '0000-00-00 00:00:00', '', '',
64'', '', '',
65'begin declare x int; select count(*) into x from mysql.user; end'
66),
67(
68'test', 'bug14233_3', 'PROCEDURE', 'bug14233_3', 'SQL', 'READS_SQL_DATA','NO',
69'DEFINER', '', '',
70'alksj wpsj sa ^#!@ ',
71'root@localhost', NOW() , '0000-00-00 00:00:00', '', '',
72'', '', '',
73'alksj wpsj sa ^#!@ '
74);
75select bug14233_1();
76ERROR HY000: Failed to load routine test.bug14233_1. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
77create view v1 as select bug14233_1();
78ERROR HY000: Failed to load routine test.bug14233_1. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
79select bug14233_2();
80ERROR HY000: Failed to load routine test.bug14233_2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
81create view v1 as select bug14233_2();
82ERROR HY000: Failed to load routine test.bug14233_2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
83call bug14233_3();
84ERROR HY000: Failed to load routine test.bug14233_3. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
85drop trigger t1_ai;
86create trigger t1_ai after insert on t1 for each row call bug14233_3();
87insert into t1 values (0);
88ERROR HY000: Failed to load routine test.bug14233_3. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
89drop trigger t1_ai;
90drop table t1;
91drop function bug14233_1;
92drop function bug14233_2;
93drop procedure bug14233_3;
94show procedure status where db=DATABASE();
95Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
96show function status where db=DATABASE();
97Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
98DROP TABLE IF EXISTS proc_backup;
99DROP PROCEDURE IF EXISTS p1;
100# Backup the proc table
101RENAME TABLE mysql.proc TO proc_backup;
102CREATE TABLE mysql.proc LIKE proc_backup;
103FLUSH TABLE mysql.proc;
104# Test with a valid table.
105CREATE PROCEDURE p1()
106SET @foo = 10;
107CALL p1();
108SHOW PROCEDURE STATUS;
109Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
110test	p1	PROCEDURE	root@localhost	0000-00-00 00:00:00	0000-00-00 00:00:00	DEFINER		latin1	latin1_swedish_ci	latin1_swedish_ci
111# Modify a field of the table.
112ALTER TABLE mysql.proc MODIFY comment CHAR (32);
113CREATE PROCEDURE p2()
114SET @foo = 10;
115ERROR HY000: Cannot load from mysql.proc. The table is probably corrupted
116# Procedure loaded from the cache
117CALL p1();
118SHOW PROCEDURE STATUS;
119ERROR HY000: Cannot load from mysql.proc. The table is probably corrupted
120DROP TABLE mysql.proc;
121RENAME TABLE proc_backup TO mysql.proc;
122FLUSH TABLE mysql.proc;
123#
124# Bug#51376 Assert `! is_set()' failed in
125#           Diagnostics_area::set_ok_status on DROP FUNCTION
126#
127DROP FUNCTION IF EXISTS f1;
128CREATE FUNCTION f1() RETURNS INT RETURN 1;
129# Backup the procs_priv table
130RENAME TABLE mysql.procs_priv TO procs_priv_backup;
131FLUSH TABLE mysql.procs_priv;
132DROP FUNCTION f1;
133ERROR 42S02: Table 'mysql.procs_priv' doesn't exist
134SHOW WARNINGS;
135Level	Code	Message
136Error	1146	Table 'mysql.procs_priv' doesn't exist
137Warning	1405	Failed to revoke all privileges to dropped routine
138# Restore the procs_priv table
139RENAME TABLE procs_priv_backup TO mysql.procs_priv;
140FLUSH TABLE mysql.procs_priv;
141#
142# Bug #56137 "Assertion `thd->lock == 0' failed on upgrading from
143#             5.1.50 to 5.5.6".
144#
145drop database if exists mysqltest;
146# Backup mysql.proc.
147flush table mysql.proc;
148create database mysqltest;
149# Corrupt mysql.proc to make it unusable by current version of server.
150alter table mysql.proc drop column type;
151# The below statement should not cause assertion failure.
152drop database mysqltest;
153Warnings:
154Error	1805	Column count of mysql.proc is wrong. Expected 20, found 19. The table is probably corrupted
155# Restore mysql.proc.
156drop table mysql.proc;
157#
158# Bug#58414 mysql_upgrade fails on dump upgrade between 5.1.53 -> 5.5.8
159#
160DROP TABLE IF EXISTS proc_backup;
161DROP DATABASE IF EXISTS db1;
162# Backup the proc table
163RENAME TABLE mysql.proc TO proc_backup;
164CREATE TABLE mysql.proc LIKE proc_backup;
165CREATE DATABASE db1;
166CREATE PROCEDURE db1.p1() SET @foo = 10;
167# Modify a field of the table.
168ALTER TABLE mysql.proc MODIFY comment CHAR (32);
169DROP DATABASE db1;
170Warnings:
171Error	1728	Cannot load from mysql.proc. The table is probably corrupted
172# Restore mysql.proc
173DROP TABLE mysql.proc;
174RENAME TABLE proc_backup TO mysql.proc;
175SET sql_mode = default;
176