1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

fixed bug #1427 "enum allows duplicate values in the list"

include/mysqld_error.h:
  added ER_DUPLICATED_VALUE_IN_TYPE
mysql-test/r/create.result:
  added test for bug #1427 "enum allows duplicate values in the list"
mysql-test/t/create.test:
  added test for bug #1427 "enum allows duplicate values in the list"
sql/share/czech/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/danish/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/dutch/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/english/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/estonian/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/french/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/german/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/greek/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/hungarian/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/italian/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/japanese/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/korean/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/norwegian-ny/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/norwegian/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/polish/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/portuguese/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/romanian/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/russian/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/serbian/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/slovak/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/spanish/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/swedish/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/share/ukrainian/errmsg.txt:
  added message for ER_DUPLICATED_VALUE_IN_TYPE
sql/sql_table.cc:
  added function check_duplicates_in_interval and 
  calling it from mysql_create_table for enum and set
This commit is contained in:
unknown
2004-03-13 23:13:31 +04:00
parent 8b11f1c106
commit 5a67c11c18
27 changed files with 96 additions and 1 deletions

View File

@ -307,4 +307,5 @@
#define ER_NON_UPDATABLE_TABLE 1288 #define ER_NON_UPDATABLE_TABLE 1288
#define ER_FEATURE_DISABLED 1289 #define ER_FEATURE_DISABLED 1289
#define ER_OPTION_PREVENTS_STATEMENT 1290 #define ER_OPTION_PREVENTS_STATEMENT 1290
#define ER_ERROR_MESSAGES 291 #define ER_DUPLICATED_VALUE_IN_TYPE 1291
#define ER_ERROR_MESSAGES 292

View File

@ -456,6 +456,20 @@ Field Type Null Key Default Extra
name varchar(10) YES NULL name varchar(10) YES NULL
age smallint(6) YES -1 age smallint(6) YES -1
drop table t1, t2; drop table t1, t2;
create table t1(cenum enum('a'), cset set('b'));
create table t2(cenum enum('a','a'), cset set('b','b'));
Warnings:
Error 1291 Column 'cenum' has duplicated value 'a' in ENUM
Error 1291 Column 'cset' has duplicated value 'b' in SET
create table t3(cenum enum('a','A','a','c','c'), cset set('b','B','b','d','d'));
Warnings:
Error 1291 Column 'cenum' has duplicated value 'a' in ENUM
Error 1291 Column 'cenum' has duplicated value 'A' in ENUM
Error 1291 Column 'cenum' has duplicated value 'c' in ENUM
Error 1291 Column 'cset' has duplicated value 'b' in SET
Error 1291 Column 'cset' has duplicated value 'B' in SET
Error 1291 Column 'cset' has duplicated value 'd' in SET
drop table t1, t2, t3;
create database test_$1; create database test_$1;
use test_$1; use test_$1;
select database(); select database();

View File

@ -346,6 +346,15 @@ create table t2(name varchar(10), age smallint default - 1);
describe t2; describe t2;
drop table t1, t2; drop table t1, t2;
#
# test for bug #1427 "enum allows duplicate values in the list"
#
create table t1(cenum enum('a'), cset set('b'));
create table t2(cenum enum('a','a'), cset set('b','b'));
create table t3(cenum enum('a','A','a','c','c'), cset set('b','B','b','d','d'));
drop table t1, t2, t3;
# #
# Bug #1209 # Bug #1209
# #

View File

@ -303,3 +303,4 @@ character-set=latin2
"The target table %-.100s of the %s is not updatable", "The target table %-.100s of the %s is not updatable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -297,3 +297,4 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -305,3 +305,4 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -294,3 +294,4 @@ character-set=latin1
"The target table %-.100s of the %s is not updatable", "The target table %-.100s of the %s is not updatable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -299,3 +299,4 @@ character-set=latin7
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -294,3 +294,4 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -306,3 +306,4 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -294,3 +294,4 @@ character-set=greek
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -296,3 +296,4 @@ character-set=latin2
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -294,3 +294,4 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -296,3 +296,4 @@ character-set=ujis
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -294,3 +294,4 @@ character-set=euckr
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -296,3 +296,4 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -296,3 +296,4 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -298,3 +298,4 @@ character-set=latin2
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -295,3 +295,4 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -298,3 +298,4 @@ character-set=latin2
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -296,3 +296,4 @@ character-set=koi8r
"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %-.100s <20> %s <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %-.100s <20> %s <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -288,3 +288,4 @@ character-set=cp1250
"The target table %-.100s of the %s is not updatable", "The target table %-.100s of the %s is not updatable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working" "The '%s' feature was disabled; you need MySQL built with '%s' to have it working"
"The MySQL server is running with the %s option so it cannot execute this statement" "The MySQL server is running with the %s option so it cannot execute this statement"
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -302,3 +302,4 @@ character-set=latin2
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -296,3 +296,4 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable", "The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -294,3 +294,4 @@ character-set=latin1
"'%s' <20>r inte aktiverad; F<>r att aktivera detta m<>ste du bygga om MySQL med '%s' definerad", "'%s' <20>r inte aktiverad; F<>r att aktivera detta m<>ste du bygga om MySQL med '%s' definerad",
"MySQL <20>r started i --skip-grant-tables mod. Pga av detta kan du inte anv<6E>nda detta program", "MySQL <20>r started i --skip-grant-tables mod. Pga av detta kan du inte anv<6E>nda detta program",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -299,3 +299,4 @@ character-set=koi8u
"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %-.100s <20> %s <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %-.100s <20> %s <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", "The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement", "The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"

View File

@ -342,6 +342,50 @@ static int sort_keys(KEY *a, KEY *b)
0); 0);
} }
/*
Check TYPELIB (set or enum) for duplicates
SYNOPSIS
check_duplicates_in_interval()
set_or_name "SET" or "ENUM" string for warning message
name name of the checked column
typelib list of values for the column
DESCRIPTION
This function prints an warning for each value in list
which has some duplicates on its right
RETURN VALUES
void
*/
void check_duplicates_in_interval(const char *set_or_name,
const char *name, TYPELIB *typelib)
{
unsigned int old_count= typelib->count;
const char **old_type_names= typelib->type_names;
if (typelib->count <= 1)
return;
old_count= typelib->count;
old_type_names= typelib->type_names;
const char **cur_value= typelib->type_names;
for ( ; typelib->count > 1; cur_value++)
{
typelib->type_names++;
typelib->count--;
if (find_type((char*)*cur_value,typelib,1))
{
push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_DUPLICATED_VALUE_IN_TYPE,
ER(ER_DUPLICATED_VALUE_IN_TYPE),
name,*cur_value,set_or_name);
}
}
typelib->count= old_count;
typelib->type_names= old_type_names;
}
/* /*
Create a table Create a table
@ -546,6 +590,8 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
if (sql_field->charset->state & MY_CS_BINSORT) if (sql_field->charset->state & MY_CS_BINSORT)
sql_field->pack_flag|=FIELDFLAG_BINARY; sql_field->pack_flag|=FIELDFLAG_BINARY;
sql_field->unireg_check=Field::INTERVAL_FIELD; sql_field->unireg_check=Field::INTERVAL_FIELD;
check_duplicates_in_interval("ENUM",sql_field->field_name,
sql_field->interval);
break; break;
case FIELD_TYPE_SET: case FIELD_TYPE_SET:
sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) | sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) |
@ -553,6 +599,8 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
if (sql_field->charset->state & MY_CS_BINSORT) if (sql_field->charset->state & MY_CS_BINSORT)
sql_field->pack_flag|=FIELDFLAG_BINARY; sql_field->pack_flag|=FIELDFLAG_BINARY;
sql_field->unireg_check=Field::BIT_FIELD; sql_field->unireg_check=Field::BIT_FIELD;
check_duplicates_in_interval("SET",sql_field->field_name,
sql_field->interval);
break; break;
case FIELD_TYPE_DATE: // Rest of string types case FIELD_TYPE_DATE: // Rest of string types
case FIELD_TYPE_NEWDATE: case FIELD_TYPE_NEWDATE: