mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#41465: confusing error message when comment is too long
The problem was that the server was trying to use the unknown error format string (ER_UNKNOWN_ERROR) to print messages about comments being too long, but the said format string does not accept arguments and will always default to "Unknown error". The solution is to introduce new error messages which are specific to the error conditions so that server wants to signal -- this also means that it's possible to translate those messages. mysql-test/r/strict.result: Update test case result. mysql-test/t/strict.test: Update test case with new errors. sql/share/errmsg.txt: Introduce new errors for long comments. sql/unireg.cc: Use new errors.
This commit is contained in:
@ -1305,7 +1305,7 @@ set @@sql_mode='traditional';
|
|||||||
create table t1 (i int)
|
create table t1 (i int)
|
||||||
comment '123456789*123456789*123456789*123456789*123456789*
|
comment '123456789*123456789*123456789*123456789*123456789*
|
||||||
123456789*123456789*123456789*123456789*123456789*';
|
123456789*123456789*123456789*123456789*123456789*';
|
||||||
ERROR HY000: Too long comment for table 't1'
|
ERROR HY000: Comment for table 't1' is too long (max = 60)
|
||||||
create table t1 (
|
create table t1 (
|
||||||
i int comment
|
i int comment
|
||||||
'123456789*123456789*123456789*123456789*
|
'123456789*123456789*123456789*123456789*
|
||||||
@ -1315,7 +1315,7 @@ i int comment
|
|||||||
123456789*123456789*123456789*123456789*
|
123456789*123456789*123456789*123456789*
|
||||||
123456789*123456789*123456789*123456789*
|
123456789*123456789*123456789*123456789*
|
||||||
123456789*123456789*123456789*123456789*');
|
123456789*123456789*123456789*123456789*');
|
||||||
ERROR HY000: Too long comment for field 'i'
|
ERROR HY000: Comment for field 'i' is too long (max = 255)
|
||||||
set @@sql_mode= @org_mode;
|
set @@sql_mode= @org_mode;
|
||||||
create table t1
|
create table t1
|
||||||
(i int comment
|
(i int comment
|
||||||
@ -1327,7 +1327,7 @@ create table t1
|
|||||||
123456789*123456789*123456789*123456789*
|
123456789*123456789*123456789*123456789*
|
||||||
123456789*123456789*123456789*123456789*');
|
123456789*123456789*123456789*123456789*');
|
||||||
Warnings:
|
Warnings:
|
||||||
Warning 1105 Unknown error
|
Warning 1629 Comment for field 'i' is too long (max = 255)
|
||||||
select column_name, column_comment from information_schema.columns where
|
select column_name, column_comment from information_schema.columns where
|
||||||
table_schema = 'test' and table_name = 't1';
|
table_schema = 'test' and table_name = 't1';
|
||||||
column_name column_comment
|
column_name column_comment
|
||||||
|
@ -1163,11 +1163,11 @@ set @@sql_mode= @org_mode;
|
|||||||
# Bug #13934 Silent truncation of table comments
|
# Bug #13934 Silent truncation of table comments
|
||||||
#
|
#
|
||||||
set @@sql_mode='traditional';
|
set @@sql_mode='traditional';
|
||||||
--error 1105
|
--error ER_TOO_LONG_TABLE_COMMENT
|
||||||
create table t1 (i int)
|
create table t1 (i int)
|
||||||
comment '123456789*123456789*123456789*123456789*123456789*
|
comment '123456789*123456789*123456789*123456789*123456789*
|
||||||
123456789*123456789*123456789*123456789*123456789*';
|
123456789*123456789*123456789*123456789*123456789*';
|
||||||
--error 1105
|
--error ER_TOO_LONG_FIELD_COMMENT
|
||||||
create table t1 (
|
create table t1 (
|
||||||
i int comment
|
i int comment
|
||||||
'123456789*123456789*123456789*123456789*
|
'123456789*123456789*123456789*123456789*
|
||||||
|
@ -6169,3 +6169,11 @@ ER_CONFLICT_FN_PARSE_ERROR
|
|||||||
eng "Error in parsing conflict function. Message: %-.64s"
|
eng "Error in parsing conflict function. Message: %-.64s"
|
||||||
ER_EXCEPTIONS_WRITE_ERROR
|
ER_EXCEPTIONS_WRITE_ERROR
|
||||||
eng "Write to exceptions table failed. Message: %-.128s""
|
eng "Write to exceptions table failed. Message: %-.128s""
|
||||||
|
|
||||||
|
ER_TOO_LONG_TABLE_COMMENT
|
||||||
|
eng "Comment for table '%-.64s' is too long (max = %lu)"
|
||||||
|
por "Coment<6E>rio para a tabela '%-.64s' <20> longo demais (max = %lu)"
|
||||||
|
|
||||||
|
ER_TOO_LONG_FIELD_COMMENT
|
||||||
|
eng "Comment for field '%-.64s' is too long (max = %lu)"
|
||||||
|
por "Coment<6E>rio para o campo '%-.64s' <20> longo demais (max = %lu)"
|
||||||
|
@ -229,16 +229,16 @@ bool mysql_create_frm(THD *thd, const char *file_name,
|
|||||||
create_info->comment.length, 60);
|
create_info->comment.length, 60);
|
||||||
if (tmp_len < create_info->comment.length)
|
if (tmp_len < create_info->comment.length)
|
||||||
{
|
{
|
||||||
(void) my_snprintf(buff, sizeof(buff), "Too long comment for table '%s'",
|
|
||||||
table);
|
|
||||||
if ((thd->variables.sql_mode &
|
if ((thd->variables.sql_mode &
|
||||||
(MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
|
(MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
|
||||||
{
|
{
|
||||||
my_message(ER_UNKNOWN_ERROR, buff, MYF(0));
|
my_error(ER_TOO_LONG_TABLE_COMMENT, MYF(0), table, tmp_len);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||||
ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
|
ER_TOO_LONG_TABLE_COMMENT,
|
||||||
|
ER(ER_TOO_LONG_TABLE_COMMENT),
|
||||||
|
table, tmp_len);
|
||||||
create_info->comment.length= tmp_len;
|
create_info->comment.length= tmp_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,17 +613,16 @@ static bool pack_header(uchar *forminfo, enum legacy_db_type table_type,
|
|||||||
255);
|
255);
|
||||||
if (tmp_len < field->comment.length)
|
if (tmp_len < field->comment.length)
|
||||||
{
|
{
|
||||||
char buff[128];
|
|
||||||
(void) my_snprintf(buff,sizeof(buff), "Too long comment for field '%s'",
|
|
||||||
field->field_name);
|
|
||||||
if ((current_thd->variables.sql_mode &
|
if ((current_thd->variables.sql_mode &
|
||||||
(MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
|
(MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
|
||||||
{
|
{
|
||||||
my_message(ER_UNKNOWN_ERROR, buff, MYF(0));
|
my_error(ER_TOO_LONG_FIELD_COMMENT, MYF(0), field->field_name, tmp_len);
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||||
ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
|
ER_TOO_LONG_FIELD_COMMENT,
|
||||||
|
ER(ER_TOO_LONG_FIELD_COMMENT),
|
||||||
|
field->field_name, tmp_len);
|
||||||
field->comment.length= tmp_len;
|
field->comment.length= tmp_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user