summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2009-03-05 08:20:01 -0300
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2009-03-05 08:20:01 -0300
commit53802ae6ca0ea2d95c9d24b8c07a27213406131e (patch)
treefbac8fc482a3b56406f23f85c87c4d38e83e8115 /sql
parentf44b2650fb7002a0e6452198a72e799d04f034cf (diff)
downloadmariadb-git-53802ae6ca0ea2d95c9d24b8c07a27213406131e.tar.gz
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.
Diffstat (limited to 'sql')
-rw-r--r--sql/share/errmsg.txt8
-rw-r--r--sql/unireg.cc17
2 files changed, 16 insertions, 9 deletions
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index 23231eefcc2..aa1521acab6 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -6169,3 +6169,11 @@ ER_CONFLICT_FN_PARSE_ERROR
eng "Error in parsing conflict function. Message: %-.64s"
ER_EXCEPTIONS_WRITE_ERROR
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ário para a tabela '%-.64s' é longo demais (max = %lu)"
+
+ER_TOO_LONG_FIELD_COMMENT
+ eng "Comment for field '%-.64s' is too long (max = %lu)"
+ por "Comentário para o campo '%-.64s' é longo demais (max = %lu)"
diff --git a/sql/unireg.cc b/sql/unireg.cc
index da018ebec3d..51293184ad8 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -229,16 +229,16 @@ bool mysql_create_frm(THD *thd, const char *file_name,
create_info->comment.length, 60);
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 &
(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;
}
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;
}
@@ -613,17 +613,16 @@ static bool pack_header(uchar *forminfo, enum legacy_db_type table_type,
255);
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 &
(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);
}
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;
}