3768 brajmohan saxena 2012-03-14 [merge]
BUG#11748924 PARTITIONS: TOO-LONG COMMENT CAUSES NO WARNING
Problem:
There is no validation of comment length for
partition comments and some redundancy of code
for table,column and index comments.
Solution:
Replaced the existing redundant code of comment
length for table, column and index objects with
a generic function validate_comment_length.this
function will validate partition comments as well.
modified:
include/mysql_com.h
mysql-test/r/partition_error.result
mysql-test/t/partition_error.test
sql/share/errmsg-utf8.txt
sql/sql_table.cc
sql/sql_table.h
sql/unireg.cc
3767 Tor Didriksen 2012-03-14 [merge]
merge 5.5 => trunk
modified:
mysql-test/r/filesort_debug.result
mysql-test/t/filesort_debug.test
sql/filesort.cc
=== modified file 'include/mysql_com.h'
--- a/include/mysql_com.h 2012-03-06 14:29:42 +0000
+++ b/include/mysql_com.h 2012-03-14 11:56:51 +0000
@@ -39,6 +39,7 @@
#define TABLE_COMMENT_MAXLEN 2048
#define COLUMN_COMMENT_MAXLEN 1024
#define INDEX_COMMENT_MAXLEN 1024
+#define TABLE_PARTITION_COMMENT_MAXLEN 1024
/*
USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
=== modified file 'mysql-test/r/partition_error.result'
--- a/mysql-test/r/partition_error.result 2011-11-01 11:52:24 +0000
+++ b/mysql-test/r/partition_error.result 2012-03-14 11:56:51 +0000
@@ -1751,3 +1751,99 @@ PARTITION pmax VALUES LESS THAN MAXVALUE
ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
DROP TABLE t1;
End of 5.1 tests
+CREATE TABLE t1 (a INT)
+PARTITION BY LIST (a)
+SUBPARTITION BY HASH (a) SUBPARTITIONS 2
+(PARTITION p1 VALUES IN (1) COMMENT "Comment in p1"
+ (SUBPARTITION p1spFirst COMMENT "SubPartition comment in p1spFirst",
+SUBPARTITION p1spSecond COMMENT "SubPartition comment in p1spSecond"),
+PARTITION p2 VALUES IN (2) COMMENT "Comment in p2"
+ (SUBPARTITION p2spFirst COMMENT "SubPartition comment in p2spFirst",
+SUBPARTITION p2spSecond COMMENT "SubPartition comment in p2spSecond"));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY LIST (a)
+SUBPARTITION BY HASH (a)
+(PARTITION p1 VALUES IN (1)
+ (SUBPARTITION p1spFirst COMMENT = 'SubPartition comment in p1spFirst' ENGINE = MyISAM,
+ SUBPARTITION p1spSecond COMMENT = 'SubPartition comment in p1spSecond' ENGINE = MyISAM),
+ PARTITION p2 VALUES IN (2)
+ (SUBPARTITION p2spFirst COMMENT = 'SubPartition comment in p2spFirst' ENGINE = MyISAM,
+ SUBPARTITION p2spSecond COMMENT = 'SubPartition comment in p2spSecond' ENGINE = MyISAM)) */
+SELECT PARTITION_NAME, SUBPARTITION_NAME, PARTITION_COMMENT FROM INFORMATION_SCHEMA.PARTITIONS
+WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test';
+PARTITION_NAME SUBPARTITION_NAME PARTITION_COMMENT
+p1 p1spFirst SubPartition comment in p1spFirst
+p1 p1spSecond SubPartition comment in p1spSecond
+p2 p2spFirst SubPartition comment in p2spFirst
+p2 p2spSecond SubPartition comment in p2spSecond
+DROP TABLE t1;
+CREATE TABLE t1 (a INT)
+PARTITION BY LIST (a)
+SUBPARTITION BY HASH (a) SUBPARTITIONS 2
+(PARTITION p1 VALUES IN (1)
+(SUBPARTITION p1spFirst COMMENT "SubPartition comment in p1spFirst",
+SUBPARTITION p1spSecond),
+PARTITION p2 VALUES IN (2) COMMENT "Comment in p2"
+ (SUBPARTITION p2spFirst,
+SUBPARTITION p2spSecond COMMENT "SubPartition comment in p2spSecond"));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY LIST (a)
+SUBPARTITION BY HASH (a)
+(PARTITION p1 VALUES IN (1)
+ (SUBPARTITION p1spFirst COMMENT = 'SubPartition comment in p1spFirst' ENGINE = MyISAM,
+ SUBPARTITION p1spSecond ENGINE = MyISAM),
+ PARTITION p2 VALUES IN (2)
+ (SUBPARTITION p2spFirst COMMENT = 'Comment in p2' ENGINE = MyISAM,
+ SUBPARTITION p2spSecond COMMENT = 'SubPartition comment in p2spSecond' ENGINE = MyISAM)) */
+SELECT PARTITION_NAME, SUBPARTITION_NAME, PARTITION_COMMENT FROM INFORMATION_SCHEMA.PARTITIONS
+WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test';
+PARTITION_NAME SUBPARTITION_NAME PARTITION_COMMENT
+p1 p1spFirst SubPartition comment in p1spFirst
+p1 p1spSecond
+p2 p2spFirst Comment in p2
+p2 p2spSecond SubPartition comment in p2spSecond
+DROP TABLE t1;
+CREATE TABLE t1
+(a INT ,
+KEY inx_a (a) )
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH (a) SUBPARTITIONS 2
+(PARTITION pUpTo10 VALUES LESS THAN (10) COMMENT
+"This is a long comment (2050 ascii characters) 50 pUpTo10 partition ......80-!.................. 100 ................................................................................................ 200....................................................................................................................................................................................................................................................................................................... 500 ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
........... 1000 ..............1024-|.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1500 .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
....................... 2000 ......................................204
8-|++"
+ (SUBPARTITION `p-10sp0` ,SUBPARTITION `p-10sp1` ),
+PARTITION pMax VALUES LESS THAN MAXVALUE COMMENT
+"This is a long comment (2050 ascii characters) 50 pMax partition comment .80-!.................. 100 ................................................................................................ 200....................................................................................................................................................................................................................................................................................................... 500 ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
........... 1000 ..............1024-|.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1500 .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
....................... 2000 ......................................204
8-|++"
+ (SUBPARTITION `pMaxsp0` ,SUBPARTITION `pMaxsp1` ));
+Warnings:
+Warning 1792 Comment for table partition 'pUpTo10' is too long (max = 1024)
+Warning 1792 Comment for table partition 'pMax' is too long (max = 1024)
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ KEY `inx_a` (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+SUBPARTITION BY HASH (a)
+(PARTITION pUpTo10 VALUES LESS THAN (10)
+ (SUBPARTITION `p-10sp0` COMMENT = 'This is a long comment (2050 ascii characters) 50 pUpTo10 partition ......80-!.................. 100 ................................................................................................ 200....................................................................................................................................................................................................................................................................................................... 500 .................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
.............................................. 1000 ..............1024-|' ENGINE = MyISAM,
+ SUBPARTITION `p-10sp1` COMMENT = 'This is a long comment (2050 ascii characters) 50 pUpTo10 partition ......80-!.................. 100 ................................................................................................ 200....................................................................................................................................................................................................................................................................................................... 500 .................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
.............................................. 1000 ..............1024-|' ENGINE = MyISAM),
+ PARTITION pMax VALUES LESS THAN MAXVALUE
+ (SUBPARTITION pMaxsp0 COMMENT = 'This is a long comment (2050 ascii characters) 50 pMax partition comment .80-!.................. 100 ................................................................................................ 200....................................................................................................................................................................................................................................................................................................... 500 ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
............................................ 1000 ..............1024-|' ENGINE = MyISAM,
+ SUBPARTITION pMaxsp1 COMMENT = 'This is a long comment (2050 ascii characters) 50 pMax partition comment .80-!.................. 100 ................................................................................................ 200....................................................................................................................................................................................................................................................................................................... 500 ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
............................................ 1000 ..............1024-|' ENGINE = MyISAM)) */
+SELECT PARTITION_NAME, SUBPARTITION_NAME, PARTITION_COMMENT FROM INFORMATION_SCHEMA.PARTITIONS
+WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test';
+PARTITION_NAME SUBPARTITION_NAME PARTITION_COMMENT
+pUpTo10 p-10sp0 This is a long comment (2050 ascii characters) 50 pUpTo10 partition ......80-!
+pUpTo10 p-10sp1 This is a long comment (2050 ascii characters) 50 pUpTo10 partition ......80-!
+pMax pMaxsp0 This is a long comment (2050 ascii characters) 50 pMax partition comment .80-!
+pMax pMaxsp1 This is a long comment (2050 ascii characters) 50 pMax partition comment .80-!
+DROP TABLE t1;
=== modified file 'mysql-test/t/partition_error.test'
--- a/mysql-test/t/partition_error.test 2011-03-31 14:35:51 +0000
+++ b/mysql-test/t/partition_error.test 2012-02-06 15:09:32 +0000
@@ -2004,3 +2004,49 @@ PARTITION pmax VALUES LESS THAN MAXVALUE
DROP TABLE t1;
--echo End of 5.1 tests
+
+CREATE TABLE t1 (a INT)
+PARTITION BY LIST (a)
+SUBPARTITION BY HASH (a) SUBPARTITIONS 2
+(PARTITION p1 VALUES IN (1) COMMENT "Comment in p1"
+ (SUBPARTITION p1spFirst COMMENT "SubPartition comment in p1spFirst",
+ SUBPARTITION p1spSecond COMMENT "SubPartition comment in p1spSecond"),
+ PARTITION p2 VALUES IN (2) COMMENT "Comment in p2"
+ (SUBPARTITION p2spFirst COMMENT "SubPartition comment in p2spFirst",
+ SUBPARTITION p2spSecond COMMENT "SubPartition comment in p2spSecond"));
+SHOW CREATE TABLE t1;
+SELECT PARTITION_NAME, SUBPARTITION_NAME, PARTITION_COMMENT FROM INFORMATION_SCHEMA.PARTITIONS
+WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test';
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT)
+PARTITION BY LIST (a)
+SUBPARTITION BY HASH (a) SUBPARTITIONS 2
+(PARTITION p1 VALUES IN (1)
+ (SUBPARTITION p1spFirst COMMENT "SubPartition comment in p1spFirst",
+ SUBPARTITION p1spSecond),
+ PARTITION p2 VALUES IN (2) COMMENT "Comment in p2"
+ (SUBPARTITION p2spFirst,
+ SUBPARTITION p2spSecond COMMENT "SubPartition comment in p2spSecond"));
+SHOW CREATE TABLE t1;
+SELECT PARTITION_NAME, SUBPARTITION_NAME, PARTITION_COMMENT FROM INFORMATION_SCHEMA.PARTITIONS
+WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test';
+DROP TABLE t1;
+
+CREATE TABLE t1
+(a INT ,
+ KEY inx_a (a) )
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH (a) SUBPARTITIONS 2
+(PARTITION pUpTo10 VALUES LESS THAN (10) COMMENT
+"This is a long comment (2050 ascii characters) 50 pUpTo10 partition ......80-!.................. 100 ................................................................................................ 200....................................................................................................................................................................................................................................................................................................... 500 ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
........... 1000 ..............1024-|.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1500 .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
....................... 2000 ......................................204
8-|++"
+ (SUBPARTITION `p-10sp0` ,SUBPARTITION `p-10sp1` ),
+ PARTITION pMax VALUES LESS THAN MAXVALUE COMMENT
+"This is a long comment (2050 ascii characters) 50 pMax partition comment .80-!.................. 100 ................................................................................................ 200....................................................................................................................................................................................................................................................................................................... 500 ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
........... 1000 ..............1024-|.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1500 .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
....................... 2000 ......................................204
8-|++"
+ (SUBPARTITION `pMaxsp0` ,SUBPARTITION `pMaxsp1` ));
+
+SHOW CREATE TABLE t1;
+SELECT PARTITION_NAME, SUBPARTITION_NAME, PARTITION_COMMENT FROM INFORMATION_SCHEMA.PARTITIONS
+WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test';
+
+DROP TABLE t1;
=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt 2012-03-14 09:52:49 +0000
+++ b/sql/share/errmsg-utf8.txt 2012-03-14 11:56:51 +0000
@@ -6715,5 +6715,8 @@ ER_UNKNOWN_EXPLAIN_FORMAT
ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION 25006
eng "Cannot execute statement in a READ ONLY transaction."
+ER_TOO_LONG_TABLE_PARTITION_COMMENT
+ eng "Comment for table partition '%-.64s' is too long (max = %lu)"
+
ER_SLAVE_CONFIGURATION
eng "Slave is not configured or failed to initialize properly. You must at least set --server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log."
=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc 2012-03-06 14:29:42 +0000
+++ b/sql/sql_table.cc 2012-03-14 11:56:51 +0000
@@ -3837,33 +3837,12 @@ mysql_prepare_create_table(THD *thd, HA_
my_error(ER_TOO_LONG_KEY,MYF(0),max_key_length);
DBUG_RETURN(TRUE);
}
-
- uint tmp_len= system_charset_info->cset->charpos(system_charset_info,
- key->key_create_info.comment.str,
- key->key_create_info.comment.str +
- key->key_create_info.comment.length,
- INDEX_COMMENT_MAXLEN);
-
- if (tmp_len < key->key_create_info.comment.length)
- {
- if ((thd->variables.sql_mode &
- (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
- {
- my_error(ER_TOO_LONG_INDEX_COMMENT, MYF(0),
- key_info->name, static_cast<ulong>(INDEX_COMMENT_MAXLEN));
- DBUG_RETURN(-1);
- }
- char warn_buff[MYSQL_ERRMSG_SIZE];
- my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_TOO_LONG_INDEX_COMMENT),
- key_info->name, static_cast<ulong>(INDEX_COMMENT_MAXLEN));
- /* do not push duplicate warnings */
- if (!thd->get_stmt_da()->has_sql_condition(warn_buff, strlen(warn_buff)))
- push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
- ER_TOO_LONG_INDEX_COMMENT, warn_buff);
-
- key->key_create_info.comment.length= tmp_len;
- }
-
+ if (validate_comment_length(thd, key->key_create_info.comment.str,
+ &key->key_create_info.comment.length,
+ INDEX_COMMENT_MAXLEN,
+ ER_TOO_LONG_INDEX_COMMENT,
+ key_info->name))
+ DBUG_RETURN(-1);
key_info->comment.length= key->key_create_info.comment.length;
if (key_info->comment.length > 0)
{
@@ -3923,6 +3902,57 @@ mysql_prepare_create_table(THD *thd, HA_
DBUG_RETURN(FALSE);
}
+/**
+ @brief check comment length of table, column, index and partition
+
+ @details If comment length is more than the standard length
+ truncate it and store the comment length upto the standard
+ comment length size
+
+ @param thd Thread handle
+ @param comment_str Comment string
+ @param[in,out] comment_len Comment length
+ @param max_len Maximum allowed comment length
+ @param err_code Error message
+ @param comment_name Type of comment
+
+ @return Operation status
+ @retval true Error found
+ @retval false On success
+*/
+
+bool validate_comment_length(THD *thd, const char *comment_str,
+ uint *comment_len, uint max_len,
+ uint err_code, const char *comment_name)
+{
+ int length= 0;
+ DBUG_ENTER("validate_comment_length");
+ uint tmp_len= system_charset_info->cset->charpos(system_charset_info,
+ comment_str,
+ comment_str +
+ *comment_len,
+ max_len);
+ if (tmp_len < *comment_len)
+ {
+ if ((thd->variables.sql_mode &
+ (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
+ {
+ my_error(err_code, MYF(0),
+ comment_name, static_cast<ulong>(max_len));
+ DBUG_RETURN(true);
+ }
+ char warn_buff[MYSQL_ERRMSG_SIZE];
+ length= my_snprintf(warn_buff, sizeof(warn_buff), ER(err_code),
+ comment_name, static_cast<ulong>(max_len));
+ /* do not push duplicate warnings */
+ if (!thd->get_stmt_da()->has_sql_condition(warn_buff, length))
+ push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
+ err_code, warn_buff);
+ *comment_len= tmp_len;
+ }
+ DBUG_RETURN(false);
+}
+
/*
Set table default charset, if not set
@@ -4221,6 +4251,42 @@ bool mysql_create_table_no_lock(THD *thd
char *part_syntax_buf;
uint syntax_len;
handlerton *engine_type;
+ List_iterator<partition_element> part_it(part_info->partitions);
+ partition_element *part_elem;
+
+ while ((part_elem= part_it++))
+ {
+ if (part_elem->part_comment)
+ {
+ uint comment_len= strlen(part_elem->part_comment);
+ if (validate_comment_length(thd, part_elem->part_comment,
+ &comment_len,
+ TABLE_PARTITION_COMMENT_MAXLEN,
+ ER_TOO_LONG_TABLE_PARTITION_COMMENT,
+ part_elem->partition_name))
+ DBUG_RETURN(true);
+ part_elem->part_comment[comment_len]= '\0';
+ }
+ if (part_elem->subpartitions.elements)
+ {
+ List_iterator<partition_element> sub_it(part_elem->subpartitions);
+ partition_element *subpart_elem;
+ while ((subpart_elem= sub_it++))
+ {
+ if (subpart_elem->part_comment)
+ {
+ uint comment_len= strlen(subpart_elem->part_comment);
+ if (validate_comment_length(thd, subpart_elem->part_comment,
+ &comment_len,
+ TABLE_PARTITION_COMMENT_MAXLEN,
+ ER_TOO_LONG_TABLE_PARTITION_COMMENT,
+ subpart_elem->partition_name))
+ DBUG_RETURN(true);
+ subpart_elem->part_comment[comment_len]= '\0';
+ }
+ }
+ }
+ }
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
{
my_error(ER_PARTITION_NO_TEMPORARY, MYF(0));
=== modified file 'sql/sql_table.h'
--- a/sql/sql_table.h 2012-01-31 15:16:16 +0000
+++ b/sql/sql_table.h 2012-02-06 15:09:32 +0000
@@ -216,6 +216,9 @@ bool sync_ddl_log();
void release_ddl_log();
void execute_ddl_log_recovery();
bool execute_ddl_log_entry(THD *thd, uint first_entry);
+bool validate_comment_length(THD *thd, const char *comment_str,
+ uint *comment_len, uint max_len,
+ uint err_code, const char *comment_name);
template<typename T> class List;
void promote_first_timestamp_column(List<Create_field> *column_definitions);
=== modified file 'sql/unireg.cc'
--- a/sql/unireg.cc 2012-03-06 14:29:42 +0000
+++ b/sql/unireg.cc 2012-03-14 11:56:51 +0000
@@ -26,7 +26,8 @@
#include "sql_priv.h"
#include "unireg.h"
-#include "sql_partition.h" // struct partition_info
+#include "sql_partition.h" // struct partition_info
+#include "sql_table.h" // validate_comment_length
#include "sql_class.h" // THD, Internal_error_handler
#include <m_ctype.h>
#include <assert.h>
@@ -54,7 +55,6 @@ static bool make_empty_rec(THD *thd, int
List<Create_field> &create_fields,
uint reclength, ulong data_offset,
handler *handler);
-
/**
An interceptor to hijack ER_TOO_MANY_FIELDS error from
pack_screens and retry again without UNIREG screens.
@@ -117,7 +117,7 @@ bool mysql_create_frm(THD *thd, const ch
handler *db_file)
{
LEX_STRING str_db_type;
- uint reclength, info_length, screens, key_info_length, maxlength, tmp_len, i;
+ uint reclength, info_length, screens, key_info_length, maxlength, i;
ulong key_buff_length;
File file;
ulong filepos, data_offset;
@@ -214,40 +214,24 @@ bool mysql_create_frm(THD *thd, const ch
For additional credit, realise that UTF-8 has 1-3 bytes before 6.0,
and 1-4 bytes in 6.0 (6.0 also has UTF-32).
*/
- tmp_len= system_charset_info->cset->charpos(system_charset_info,
- create_info->comment.str,
- create_info->comment.str +
- create_info->comment.length,
- TABLE_COMMENT_MAXLEN);
-
- if (tmp_len < create_info->comment.length)
+ if (create_info->comment.length > TABLE_COMMENT_MAXLEN)
{
- char *real_table_name= (char*) table;
+ const char *real_table_name= table;
List_iterator<Create_field> it(create_fields);
Create_field *field;
while ((field=it++))
{
if (field->field && field->field->table &&
- (real_table_name= field->field->table->s->table_name.str))
- break;
- }
- if ((thd->variables.sql_mode &
- (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
- {
- my_error(ER_TOO_LONG_TABLE_COMMENT, MYF(0),
- real_table_name, static_cast<ulong>(TABLE_COMMENT_MAXLEN));
- my_free(screen_buff);
- DBUG_RETURN(1);
+ (real_table_name= field->field->table->s->table_name.str))
+ break;
}
- THD *thd= current_thd;
- char warn_buff[MYSQL_ERRMSG_SIZE];
- my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_TOO_LONG_TABLE_COMMENT),
- real_table_name, static_cast<ulong>(TABLE_COMMENT_MAXLEN));
- /* do not push duplicate warnings */
- if (!thd->get_stmt_da()->has_sql_condition(warn_buff, strlen(warn_buff)))
- push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
- ER_TOO_LONG_TABLE_COMMENT, warn_buff);
- create_info->comment.length= tmp_len;
+ if (validate_comment_length(thd,
+ create_info->comment.str,
+ &create_info->comment.length,
+ TABLE_COMMENT_MAXLEN,
+ ER_TOO_LONG_TABLE_COMMENT,
+ real_table_name))
+ DBUG_RETURN(true);
}
/*
If table comment is longer than TABLE_COMMENT_INLINE_MAXLEN bytes,
@@ -733,33 +717,13 @@ static bool pack_header(uchar *forminfo,
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,
- COLUMN_COMMENT_MAXLEN);
- if (tmp_len < field->comment.length)
- {
- THD *thd= current_thd;
-
- if ((thd->variables.sql_mode &
- (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
- {
- my_error(ER_TOO_LONG_FIELD_COMMENT, MYF(0), field->field_name,
- static_cast<ulong>(COLUMN_COMMENT_MAXLEN));
- DBUG_RETURN(1);
- }
- char warn_buff[MYSQL_ERRMSG_SIZE];
- my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_TOO_LONG_FIELD_COMMENT),
- field->field_name,
- static_cast<ulong>(COLUMN_COMMENT_MAXLEN));
- /* do not push duplicate warnings */
- if (!thd->get_stmt_da()->has_sql_condition(warn_buff, strlen(warn_buff)))
- push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
- ER_TOO_LONG_FIELD_COMMENT, warn_buff);
- field->comment.length= tmp_len;
- }
-
+ if (validate_comment_length(current_thd,
+ field->comment.str,
+ &field->comment.length,
+ COLUMN_COMMENT_MAXLEN,
+ ER_TOO_LONG_FIELD_COMMENT,
+ (char *) field->field_name))
+ DBUG_RETURN(true);
totlength+= field->length;
com_length+= field->comment.length;
if (MTYP_TYPENR(field->unireg_check) == Field::NOEMPTY ||
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (brajmohan.saxena:3767 to 3768) Bug#11748924 | brajmohan saxena | 14 Mar |