summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorgluh@mysql.com/eagle.(none) <>2007-04-10 15:01:04 +0500
committergluh@mysql.com/eagle.(none) <>2007-04-10 15:01:04 +0500
commitb80d373b6a1af56daf6f44d0455b5e5ab2ee4544 (patch)
tree4d0de5e0bcac77725813d192e578289a08a70b97 /sql/sql_table.cc
parentd8e6b38ec1c07b034f8738ad64c6cbd1e23461bd (diff)
downloadmariadb-git-b80d373b6a1af56daf6f44d0455b5e5ab2ee4544.tar.gz
Bug#27069 set with identical elements are created(additional fix)
issue an error in strict mode if enum|set column has duplicates members in 'create table'
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc27
1 files changed, 19 insertions, 8 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 607fc4c5040..f498d33191b 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -414,10 +414,11 @@ static int sort_keys(KEY *a, KEY *b)
which has some duplicates on its right
RETURN VALUES
- void
+ 0 ok
+ 1 Error
*/
-void check_duplicates_in_interval(const char *set_or_name,
+bool check_duplicates_in_interval(const char *set_or_name,
const char *name, TYPELIB *typelib,
CHARSET_INFO *cs, unsigned int *dup_val_count)
{
@@ -433,6 +434,13 @@ void check_duplicates_in_interval(const char *set_or_name,
tmp.count--;
if (find_type2(&tmp, (const char*)*cur_value, *cur_length, cs))
{
+ if ((current_thd->variables.sql_mode &
+ (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
+ {
+ my_error(ER_DUPLICATED_VALUE_IN_TYPE, MYF(0),
+ name,*cur_value,set_or_name);
+ return 1;
+ }
push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_DUPLICATED_VALUE_IN_TYPE,
ER(ER_DUPLICATED_VALUE_IN_TYPE),
@@ -440,6 +448,7 @@ void check_duplicates_in_interval(const char *set_or_name,
(*dup_val_count)++;
}
}
+ return 0;
}
@@ -575,9 +584,10 @@ int prepare_create_field(create_field *sql_field,
if (sql_field->charset->state & MY_CS_BINSORT)
sql_field->pack_flag|=FIELDFLAG_BINARY;
sql_field->unireg_check=Field::INTERVAL_FIELD;
- check_duplicates_in_interval("ENUM",sql_field->field_name,
- sql_field->interval,
- sql_field->charset, &dup_val_count);
+ if (check_duplicates_in_interval("ENUM",sql_field->field_name,
+ sql_field->interval,
+ sql_field->charset, &dup_val_count))
+ DBUG_RETURN(1);
break;
case FIELD_TYPE_SET:
sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) |
@@ -585,9 +595,10 @@ int prepare_create_field(create_field *sql_field,
if (sql_field->charset->state & MY_CS_BINSORT)
sql_field->pack_flag|=FIELDFLAG_BINARY;
sql_field->unireg_check=Field::BIT_FIELD;
- check_duplicates_in_interval("SET",sql_field->field_name,
- sql_field->interval,
- sql_field->charset, &dup_val_count);
+ if (check_duplicates_in_interval("SET",sql_field->field_name,
+ sql_field->interval,
+ sql_field->charset, &dup_val_count))
+ DBUG_RETURN(1);
/* Check that count of unique members is not more then 64 */
if (sql_field->interval->count - dup_val_count > sizeof(longlong)*8)
{