Commit a37ff419 authored by Jon Olav Hauglid's avatar Jon Olav Hauglid

Bug #34197 CREATE PROCEDURE fails when COMMENT truncated in non

           strict SQL mode

The problem was that a COMMENT longer than 64 characters
caused CREATE PROCEDURE to fail.

This patch fixed the problem by changing the COMMENT field in 
mysql.proc from char(64) to text. The corresponding ROUTINE_COMMENT
field in INFORMATION_SCHEMA.ROUTINES is also changed from
varchar(64) to longtext.

mysql_system_tables.sql and mysql_system_tables_fix.sql updated.
Test case added to sp.test and affected result-files updated.
parent 8f39124a
......@@ -592,7 +592,7 @@ proc definer char(77)
proc created timestamp
proc modified timestamp
proc sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH')
proc comment char(64)
proc comment text
proc character_set_client char(32)
proc collation_connection char(32)
proc db_collation char(32)
......@@ -771,6 +771,7 @@ information_schema PARTITIONS PARTITION_DESCRIPTION
information_schema PLUGINS PLUGIN_DESCRIPTION
information_schema PROCESSLIST INFO
information_schema ROUTINES ROUTINE_DEFINITION
information_schema ROUTINES ROUTINE_COMMENT
information_schema TRIGGERS ACTION_CONDITION
information_schema TRIGGERS ACTION_STATEMENT
information_schema VIEWS VIEW_DEFINITION
......
......@@ -1127,7 +1127,7 @@ def ROUTINES SQL_DATA_ACCESS SQL_DATA_ACCESS 253 192 12 N 1 0 33
def ROUTINES SQL_PATH SQL_PATH 253 192 0 Y 0 0 33
def ROUTINES SECURITY_TYPE SECURITY_TYPE 253 21 7 N 1 0 33
def ROUTINES SQL_MODE SQL_MODE 253 24576 0 N 1 0 33
def ROUTINES ROUTINE_COMMENT ROUTINE_COMMENT 253 192 0 N 1 0 33
def ROUTINES ROUTINE_COMMENT ROUTINE_COMMENT 252 589815 0 N 17 0 33
def ROUTINES DEFINER DEFINER 253 231 14 N 1 0 33
SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE SQL_MODE ROUTINE_COMMENT DEFINER
p1 NULL test p1 PROCEDURE NULL SQL SELECT 1 NULL NULL SQL NO CONTAINS SQL NULL DEFINER root@localhost
......@@ -1182,7 +1182,7 @@ def ROUTINES SQL_DATA_ACCESS SQL_DATA_ACCESS 253 192 12 N 1 0 33
def ROUTINES SQL_PATH SQL_PATH 253 192 0 Y 0 0 33
def ROUTINES SECURITY_TYPE SECURITY_TYPE 253 21 7 N 1 0 33
def ROUTINES SQL_MODE SQL_MODE 253 24576 0 N 1 0 33
def ROUTINES ROUTINE_COMMENT ROUTINE_COMMENT 253 192 0 N 1 0 33
def ROUTINES ROUTINE_COMMENT ROUTINE_COMMENT 252 589815 0 N 17 0 33
def ROUTINES DEFINER DEFINER 253 231 14 N 1 0 33
SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE SQL_MODE ROUTINE_COMMENT DEFINER
f1 NULL test f1 FUNCTION int(11) SQL RETURN 1 NULL NULL SQL NO CONTAINS SQL NULL DEFINER root@localhost
......
......@@ -6933,3 +6933,20 @@ DROP TABLE t1, t2;
# ------------------------------------------------------------------
# -- End of 5.1 tests
# ------------------------------------------------------------------
#
# Bug#34197: CREATE PROCEDURE fails when COMMENT truncated in non
# strict SQL mode
#
DROP PROCEDURE IF EXISTS p1;
CREATE PROCEDURE p1 ()
COMMENT
'12345678901234567890123456789012345678901234567890123456789012345678901234567890'
BEGIN
END;
SELECT comment FROM mysql.proc WHERE name = "p1";
comment
12345678901234567890123456789012345678901234567890123456789012345678901234567890
SELECT routine_comment FROM information_schema.routines WHERE routine_name = "p1";
routine_comment
12345678901234567890123456789012345678901234567890123456789012345678901234567890
DROP PROCEDURE p1;
......@@ -201,7 +201,7 @@ proc CREATE TABLE `proc` (
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') NOT NULL DEFAULT '',
`comment` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
`comment` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`character_set_client` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
`collation_connection` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
`db_collation` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
......
......@@ -192,7 +192,7 @@ NULL information_schema ROUTINES LAST_ALTERED 17 0000-00-00 00:00:00 NO datetime
NULL information_schema ROUTINES PARAMETER_STYLE 11 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8) select
NULL information_schema ROUTINES ROUTINE_BODY 7 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8) select
NULL information_schema ROUTINES ROUTINE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
NULL information_schema ROUTINES ROUTINE_COMMENT 19 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
NULL information_schema ROUTINES ROUTINE_COMMENT 19 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
NULL information_schema ROUTINES ROUTINE_DEFINITION 8 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
NULL information_schema ROUTINES ROUTINE_NAME 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
NULL information_schema ROUTINES ROUTINE_SCHEMA 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
......@@ -552,7 +552,7 @@ NULL information_schema PROCESSLIST TIME int NULL NULL NULL NULL int(7)
NULL information_schema ROUTINES CREATED datetime NULL NULL NULL NULL datetime
NULL information_schema ROUTINES LAST_ALTERED datetime NULL NULL NULL NULL datetime
3.0000 information_schema ROUTINES SQL_MODE varchar 8192 24576 utf8 utf8_general_ci varchar(8192)
3.0000 information_schema ROUTINES ROUTINE_COMMENT varchar 64 192 utf8 utf8_general_ci varchar(64)
1.0000 information_schema ROUTINES ROUTINE_COMMENT longtext 4294967295 4294967295 utf8 utf8_general_ci longtext
3.0000 information_schema ROUTINES DEFINER varchar 77 231 utf8 utf8_general_ci varchar(77)
3.0000 information_schema ROUTINES CHARACTER_SET_CLIENT varchar 32 96 utf8 utf8_general_ci varchar(32)
3.0000 information_schema ROUTINES COLLATION_CONNECTION varchar 32 96 utf8 utf8_general_ci varchar(32)
......
......@@ -110,7 +110,7 @@ NULL mysql proc body 11 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NU
NULL mysql proc body_utf8 20 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references
NULL mysql proc character_set_client 17 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32) select,insert,update,references
NULL mysql proc collation_connection 18 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32) select,insert,update,references
NULL mysql proc comment 16 NO char 64 192 NULL NULL utf8 utf8_bin char(64) select,insert,update,references
NULL mysql proc comment 16 NULL NO text 65535 65535 NULL NULL utf8 utf8_bin text select,insert,update,references
NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
NULL mysql proc db 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
NULL mysql proc db_collation 19 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32) select,insert,update,references
......@@ -233,6 +233,7 @@ COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
1.0000 char latin1 latin1_bin
1.0000 char latin1 latin1_swedish_ci
1.0000 varchar latin1 latin1_swedish_ci
1.0000 text utf8 utf8_bin
1.0000 mediumtext utf8 utf8_general_ci
1.0000 text utf8 utf8_general_ci
SELECT DISTINCT
......@@ -403,7 +404,7 @@ NULL mysql ndb_binlog_index schemaops bigint NULL NULL NULL NULL bigint(20) unsi
NULL mysql proc created timestamp NULL NULL NULL NULL timestamp
NULL mysql proc modified timestamp NULL NULL NULL NULL timestamp
3.0000 mysql proc sql_mode set 478 1434 utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH')
3.0000 mysql proc comment char 64 192 utf8 utf8_bin char(64)
1.0000 mysql proc comment text 65535 65535 utf8 utf8_bin text
3.0000 mysql proc character_set_client char 32 96 utf8 utf8_bin char(32)
3.0000 mysql proc collation_connection char 32 96 utf8 utf8_bin char(32)
3.0000 mysql proc db_collation char 32 96 utf8 utf8_bin char(32)
......
......@@ -46,7 +46,7 @@ SECURITY_TYPE varchar(7) NO
CREATED datetime NO 0000-00-00 00:00:00
LAST_ALTERED datetime NO 0000-00-00 00:00:00
SQL_MODE varchar(8192) NO
ROUTINE_COMMENT varchar(64) NO
ROUTINE_COMMENT longtext NO NULL
DEFINER varchar(77) NO
CHARACTER_SET_CLIENT varchar(32) NO
COLLATION_CONNECTION varchar(32) NO
......@@ -72,7 +72,7 @@ ROUTINES CREATE TEMPORARY TABLE `ROUTINES` (
`CREATED` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`LAST_ALTERED` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`SQL_MODE` varchar(8192) NOT NULL DEFAULT '',
`ROUTINE_COMMENT` varchar(64) NOT NULL DEFAULT '',
`ROUTINE_COMMENT` longtext NOT NULL,
`DEFINER` varchar(77) NOT NULL DEFAULT '',
`CHARACTER_SET_CLIENT` varchar(32) NOT NULL DEFAULT '',
`COLLATION_CONNECTION` varchar(32) NOT NULL DEFAULT '',
......@@ -98,7 +98,7 @@ SECURITY_TYPE varchar(7) NO
CREATED datetime NO 0000-00-00 00:00:00
LAST_ALTERED datetime NO 0000-00-00 00:00:00
SQL_MODE varchar(8192) NO
ROUTINE_COMMENT varchar(64) NO
ROUTINE_COMMENT longtext NO NULL
DEFINER varchar(77) NO
CHARACTER_SET_CLIENT varchar(32) NO
COLLATION_CONNECTION varchar(32) NO
......
......@@ -8267,3 +8267,25 @@ DROP TABLE t1, t2;
--echo # ------------------------------------------------------------------
--echo # -- End of 5.1 tests
--echo # ------------------------------------------------------------------
--echo #
--echo # Bug#34197: CREATE PROCEDURE fails when COMMENT truncated in non
--echo # strict SQL mode
--echo #
--disable_warnings
DROP PROCEDURE IF EXISTS p1;
--enable_warnings
CREATE PROCEDURE p1 ()
COMMENT
'12345678901234567890123456789012345678901234567890123456789012345678901234567890'
BEGIN
END;
SELECT comment FROM mysql.proc WHERE name = "p1";
SELECT routine_comment FROM information_schema.routines WHERE routine_name = "p1";
DROP PROCEDURE p1;
......@@ -60,7 +60,7 @@ CREATE TABLE IF NOT EXISTS time_zone_transition_type ( Time_zone_id int unsign
CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint signed NOT NULL, Correction int signed NOT NULL, PRIMARY KEY TranTime (Transition_time) ) engine=MyISAM CHARACTER SET utf8 comment='Leap seconds information for time zones';
CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum( 'CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA') DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns longblob DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE', 'NO_ENGINE_SUBSTITUTION', 'PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db,name,type)) engine=MyISAM character set utf8 comment='Stored Procedures';
CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum( 'CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA') DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns longblob DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE', 'NO_ENGINE_SUBSTITUTION', 'PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment text collate utf8_bin NOT NULL, character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db,name,type)) engine=MyISAM character set utf8 comment='Stored Procedures';
CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
......
......@@ -427,6 +427,9 @@ ALTER TABLE proc ADD body_utf8 longblob DEFAULT NULL
AFTER db_collation;
ALTER TABLE proc MODIFY body_utf8 longblob DEFAULT NULL;
# Change comment from char(64) to text
ALTER TABLE proc MODIFY comment
text collate utf8_bin NOT NULL;
#
# EVENT privilege
......
......@@ -6290,7 +6290,7 @@ ST_FIELD_INFO proc_fields_info[]=
{"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 0, "Created", SKIP_OPEN_TABLE},
{"LAST_ALTERED", 0, MYSQL_TYPE_DATETIME, 0, 0, "Modified", SKIP_OPEN_TABLE},
{"SQL_MODE", 32*256, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
{"ROUTINE_COMMENT", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Comment",
{"ROUTINE_COMMENT", 65535, MYSQL_TYPE_STRING, 0, 0, "Comment",
SKIP_OPEN_TABLE},
{"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, "Definer", SKIP_OPEN_TABLE},
{"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment