summaryrefslogtreecommitdiff
path: root/sql/unireg.cc
diff options
context:
space:
mode:
authorunknown <gluh@eagle.intranet.mysql.r18.ru>2006-06-29 18:39:34 +0500
committerunknown <gluh@eagle.intranet.mysql.r18.ru>2006-06-29 18:39:34 +0500
commit8703b22e167c706d5a8c77a1e24948b4db3fafb3 (patch)
treee1df56628e6e5f088a1482f6457da748a9c1c141 /sql/unireg.cc
parenta7f9f7ae743efca9b1f405773416d19f9ebaf3c2 (diff)
downloadmariadb-git-8703b22e167c706d5a8c77a1e24948b4db3fafb3.tar.gz
Fix for bug#13934 Silent truncation of table comments
Table comment: issue a warning(error in traditional mode) if length of comment > 60 symbols Column comment: issue a warning(error in traditional mode) if length of comment > 255 symbols Table 'comment' is changed from char* to LEX_STRING mysql-test/r/strict.result: test case mysql-test/t/strict.test: test case sql/handler.h: Table 'comment' is changed from char* to LEX_STRING sql/sql_show.cc: Table 'comment' is changed from char* to LEX_STRING sql/sql_table.cc: Table 'comment' is changed from char* to LEX_STRING sql/sql_yacc.yy: Table 'comment' is changed from char* to LEX_STRING sql/table.cc: Table 'comment' is changed from char* to LEX_STRING sql/table.h: Table 'comment' is changed from char* to LEX_STRING sql/unireg.cc: Fix for bug#13934 Silent truncation of table comments Table comment: issue a warning(error in traditional mode) if length of comment > 60 symbols Column comment: issue a warning(error in traditional mode) if length of comment > 255 symbols
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r--sql/unireg.cc49
1 files changed, 45 insertions, 4 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 0ab77462f61..3a139aea4c7 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -76,7 +76,7 @@ bool mysql_create_frm(THD *thd, my_string file_name,
handler *db_file)
{
LEX_STRING str_db_type;
- uint reclength,info_length,screens,key_info_length,maxlength;
+ uint reclength, info_length, screens, key_info_length, maxlength, tmp_len;
ulong key_buff_length;
File file;
ulong filepos, data_offset;
@@ -143,10 +143,30 @@ bool mysql_create_frm(THD *thd, my_string file_name,
fileinfo[26]= (uchar) test((create_info->max_rows == 1) &&
(create_info->min_rows == 1) && (keys == 0));
int2store(fileinfo+28,key_info_length);
- strmake((char*) forminfo+47,create_info->comment ? create_info->comment : "",
- 60);
- forminfo[46]=(uchar) strlen((char*)forminfo+47); // Length of comment
+ tmp_len= system_charset_info->cset->charpos(system_charset_info,
+ create_info->comment.str,
+ create_info->comment.str +
+ create_info->comment.length, 60);
+ if (tmp_len < create_info->comment.length)
+ {
+ char buff[128];
+ (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));
+ goto err;
+ }
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
+ create_info->comment.length= tmp_len;
+ }
+
+ strmake((char*) forminfo+47, create_info->comment.str ?
+ create_info->comment.str : "", create_info->comment.length);
+ forminfo[46]=(uchar) create_info->comment.length;
if (my_pwrite(file,(byte*) fileinfo,64,0L,MYF_RW) ||
my_pwrite(file,(byte*) keybuff,key_info_length,
(ulong) uint2korr(fileinfo+6),MYF_RW))
@@ -449,6 +469,27 @@ static bool pack_header(uchar *forminfo, enum db_type table_type,
create_field *field;
while ((field=it++))
{
+
+ uint tmp_len= system_charset_info->cset->charpos(system_charset_info,
+ field->comment.str,
+ field->comment.str +
+ field->comment.length, 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));
+ DBUG_RETURN(1);
+ }
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
+ field->comment.length= tmp_len;
+ }
+
totlength+= field->length;
com_length+= field->comment.length;
if (MTYP_TYPENR(field->unireg_check) == Field::NOEMPTY ||