summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mysqld_error.h3
-rw-r--r--mysql-test/r/ctype_create.result8
-rw-r--r--mysql-test/t/ctype_create.test12
-rw-r--r--sql/share/czech/errmsg.txt1
-rw-r--r--sql/share/danish/errmsg.txt1
-rw-r--r--sql/share/dutch/errmsg.txt1
-rw-r--r--sql/share/english/errmsg.txt1
-rw-r--r--sql/share/estonian/errmsg.txt1
-rw-r--r--sql/share/french/errmsg.txt1
-rw-r--r--sql/share/german/errmsg.txt1
-rw-r--r--sql/share/greek/errmsg.txt1
-rw-r--r--sql/share/hungarian/errmsg.txt1
-rw-r--r--sql/share/italian/errmsg.txt1
-rw-r--r--sql/share/japanese/errmsg.txt1
-rw-r--r--sql/share/korean/errmsg.txt1
-rw-r--r--sql/share/norwegian-ny/errmsg.txt1
-rw-r--r--sql/share/norwegian/errmsg.txt1
-rw-r--r--sql/share/polish/errmsg.txt1
-rw-r--r--sql/share/portuguese/errmsg.txt1
-rw-r--r--sql/share/romanian/errmsg.txt1
-rw-r--r--sql/share/russian/errmsg.txt1
-rw-r--r--sql/share/serbian/errmsg.txt1
-rw-r--r--sql/share/slovak/errmsg.txt1
-rw-r--r--sql/share/spanish/errmsg.txt1
-rw-r--r--sql/share/swedish/errmsg.txt1
-rw-r--r--sql/share/ukrainian/errmsg.txt1
-rw-r--r--sql/sql_yacc.yy67
27 files changed, 95 insertions, 18 deletions
diff --git a/include/mysqld_error.h b/include/mysqld_error.h
index 4d65515d6ce..776869ff045 100644
--- a/include/mysqld_error.h
+++ b/include/mysqld_error.h
@@ -318,4 +318,5 @@
#define ER_WARN_INVALID_TIMESTAMP 1299
#define ER_INVALID_CHARACTER_STRING 1300
#define ER_WARN_ALLOWED_PACKET_OVERFLOWED 1301
-#define ER_ERROR_MESSAGES 302
+#define ER_CONFLICTING_DECLARATIONS 1302
+#define ER_ERROR_MESSAGES 303
diff --git a/mysql-test/r/ctype_create.result b/mysql-test/r/ctype_create.result
index 0da76c556e2..b35131f62a4 100644
--- a/mysql-test/r/ctype_create.result
+++ b/mysql-test/r/ctype_create.result
@@ -54,4 +54,12 @@ t1 CREATE TABLE `t1` (
`a` char(10) collate latin1_german1_ci default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci
DROP TABLE t1;
+create table t1 (a char) character set latin1 character set latin2;
+ERROR HY000: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET latin2'
+create table t1 (a char) character set latin1 collate latin2_bin;
+ERROR 42000: COLLATION 'latin2_bin' is not valid for CHARACTER SET 'latin1'
+create database d1 default character set latin1 character set latin2;
+ERROR HY000: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET latin2'
+create database d1 default character set latin1 collate latin2_bin;
+ERROR 42000: COLLATION 'latin2_bin' is not valid for CHARACTER SET 'latin1'
DROP DATABASE mysqltest1;
diff --git a/mysql-test/t/ctype_create.test b/mysql-test/t/ctype_create.test
index 6d7ed6fc205..9a5cb025474 100644
--- a/mysql-test/t/ctype_create.test
+++ b/mysql-test/t/ctype_create.test
@@ -71,6 +71,18 @@ SHOW CREATE TABLE t1;
DROP TABLE t1;
#
+# Bug#
+# CREATE TABLE and CREATE DATABASE didn't fail in some cases
+#
+--error 1302
+create table t1 (a char) character set latin1 character set latin2;
+--error 1253
+create table t1 (a char) character set latin1 collate latin2_bin;
+--error 1302
+create database d1 default character set latin1 character set latin2;
+--error 1253
+create database d1 default character set latin1 collate latin2_bin;
+
#
#
DROP DATABASE mysqltest1;
diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt
index ee75210d4fe..9769ec1a55d 100644
--- a/sql/share/czech/errmsg.txt
+++ b/sql/share/czech/errmsg.txt
@@ -314,3 +314,4 @@ character-set=latin2
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt
index 408f86b0445..31715354101 100644
--- a/sql/share/danish/errmsg.txt
+++ b/sql/share/danish/errmsg.txt
@@ -308,3 +308,4 @@ character-set=latin1
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt
index 95af6aaa01f..06e47e006f5 100644
--- a/sql/share/dutch/errmsg.txt
+++ b/sql/share/dutch/errmsg.txt
@@ -316,3 +316,4 @@ character-set=latin1
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt
index 5ad23b92a5a..a2e74460380 100644
--- a/sql/share/english/errmsg.txt
+++ b/sql/share/english/errmsg.txt
@@ -305,3 +305,4 @@ character-set=latin1
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt
index 36e0b8409e9..df29f08e752 100644
--- a/sql/share/estonian/errmsg.txt
+++ b/sql/share/estonian/errmsg.txt
@@ -310,3 +310,4 @@ character-set=latin7
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt
index 3bd6835908e..f0435278440 100644
--- a/sql/share/french/errmsg.txt
+++ b/sql/share/french/errmsg.txt
@@ -305,3 +305,4 @@ character-set=latin1
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt
index bf5a36a887a..af11e09f2f6 100644
--- a/sql/share/german/errmsg.txt
+++ b/sql/share/german/errmsg.txt
@@ -317,3 +317,4 @@ character-set=latin1
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt
index 9703bad11a1..7c921beba75 100644
--- a/sql/share/greek/errmsg.txt
+++ b/sql/share/greek/errmsg.txt
@@ -305,3 +305,4 @@ character-set=greek
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt
index 1f71086ff69..e961b72a38e 100644
--- a/sql/share/hungarian/errmsg.txt
+++ b/sql/share/hungarian/errmsg.txt
@@ -307,3 +307,4 @@ character-set=latin2
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt
index 21158fcb567..02c719fd7c0 100644
--- a/sql/share/italian/errmsg.txt
+++ b/sql/share/italian/errmsg.txt
@@ -305,3 +305,4 @@ character-set=latin1
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt
index 3a6dd644d8b..9674f690183 100644
--- a/sql/share/japanese/errmsg.txt
+++ b/sql/share/japanese/errmsg.txt
@@ -307,3 +307,4 @@ character-set=ujis
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt
index 356f0a63540..417d9976b7c 100644
--- a/sql/share/korean/errmsg.txt
+++ b/sql/share/korean/errmsg.txt
@@ -305,3 +305,4 @@ character-set=euckr
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt
index b5564cb264e..ae0b307439d 100644
--- a/sql/share/norwegian-ny/errmsg.txt
+++ b/sql/share/norwegian-ny/errmsg.txt
@@ -307,3 +307,4 @@ character-set=latin1
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt
index fcea45b06ac..246333af497 100644
--- a/sql/share/norwegian/errmsg.txt
+++ b/sql/share/norwegian/errmsg.txt
@@ -307,3 +307,4 @@ character-set=latin1
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt
index 2a18e4de020..417757b2aea 100644
--- a/sql/share/polish/errmsg.txt
+++ b/sql/share/polish/errmsg.txt
@@ -309,3 +309,4 @@ character-set=latin2
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt
index 6ba0fbca014..344860280cb 100644
--- a/sql/share/portuguese/errmsg.txt
+++ b/sql/share/portuguese/errmsg.txt
@@ -306,3 +306,4 @@ character-set=latin1
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt
index 50b2b36c959..6b64d103e61 100644
--- a/sql/share/romanian/errmsg.txt
+++ b/sql/share/romanian/errmsg.txt
@@ -309,3 +309,4 @@ character-set=latin2
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt
index d8641d1dd14..642b792a24f 100644
--- a/sql/share/russian/errmsg.txt
+++ b/sql/share/russian/errmsg.txt
@@ -307,3 +307,4 @@ character-set=koi8r
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt
index a8cde5a56b1..8c8bc6e9729 100644
--- a/sql/share/serbian/errmsg.txt
+++ b/sql/share/serbian/errmsg.txt
@@ -311,3 +311,4 @@ character-set=cp1250
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt
index 42ef7f62076..23814b2cbc2 100644
--- a/sql/share/slovak/errmsg.txt
+++ b/sql/share/slovak/errmsg.txt
@@ -313,3 +313,4 @@ character-set=latin2
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt
index b82712be350..113157858ad 100644
--- a/sql/share/spanish/errmsg.txt
+++ b/sql/share/spanish/errmsg.txt
@@ -307,3 +307,4 @@ character-set=latin1
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt
index 78620b28a2f..8b43ea8ed0e 100644
--- a/sql/share/swedish/errmsg.txt
+++ b/sql/share/swedish/errmsg.txt
@@ -305,3 +305,4 @@ character-set=latin1
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt
index 6d07eb1a656..4c762bf5313 100644
--- a/sql/share/ukrainian/errmsg.txt
+++ b/sql/share/ukrainian/errmsg.txt
@@ -310,3 +310,4 @@ character-set=koi8u
"Invalid TIMESTAMP value in column '%s' at row %ld",
"Invalid %s character string: '%.64s'",
"Result of %s() was larger than max_allowed_packet (%ld) - truncated"
+"Conflicting declarations: '%s' and '%s'"
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 4eca7359023..1c057e03a11 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1049,7 +1049,10 @@ create:
lex->col_list.empty();
}
| CREATE DATABASE opt_if_not_exists ident
- { Lex->create_info.default_table_charset=NULL; }
+ {
+ Lex->create_info.default_table_charset= NULL;
+ Lex->create_info.used_fields= 0;
+ }
opt_create_database_options
{
LEX *lex=Lex;
@@ -1136,11 +1139,8 @@ create_database_options:
| create_database_options create_database_option {};
create_database_option:
- opt_default COLLATE_SYM collation_name_or_default
- { Lex->create_info.default_table_charset=$3; }
- | opt_default charset charset_name_or_default
- { Lex->create_info.default_table_charset=$3; }
- ;
+ default_collation {}
+ | default_charset {};
opt_table_options:
/* empty */ { $$= 0; }
@@ -1200,21 +1200,49 @@ create_table_option:
table_list->next=0;
lex->create_info.used_fields|= HA_CREATE_USED_UNION;
}
- | opt_default charset opt_equal charset_name_or_default
- {
- Lex->create_info.default_table_charset= $4;
- Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
- }
- | opt_default COLLATE_SYM opt_equal collation_name_or_default
- {
- Lex->create_info.default_table_charset= $4;
- Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
- }
+ | default_charset
+ | default_collation
| INSERT_METHOD opt_equal merge_insert_types { Lex->create_info.merge_insert_method= $3; Lex->create_info.used_fields|= HA_CREATE_USED_INSERT_METHOD;}
| DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
{ Lex->create_info.data_file_name= $4.str; }
| INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.index_file_name= $4.str; };
+default_charset:
+ opt_default charset opt_equal charset_name_or_default
+ {
+ HA_CREATE_INFO *cinfo= &Lex->create_info;
+ if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
+ cinfo->default_table_charset && $4 &&
+ !my_charset_same(cinfo->default_table_charset,$4))
+ {
+ char cs1[32];
+ char cs2[32];
+ my_snprintf(cs1, sizeof(cs1), "CHARACTER SET %s",
+ cinfo->default_table_charset->csname);
+ my_snprintf(cs2, sizeof(cs2), "CHARACTER SET %s", $4->csname);
+ net_printf(YYTHD, ER_CONFLICTING_DECLARATIONS, cs1, cs2);
+ YYABORT;
+ }
+ Lex->create_info.default_table_charset= $4;
+ Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
+ };
+
+default_collation:
+ opt_default COLLATE_SYM opt_equal collation_name_or_default
+ {
+ HA_CREATE_INFO *cinfo= &Lex->create_info;
+ if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
+ cinfo->default_table_charset && $4 &&
+ !my_charset_same(cinfo->default_table_charset,$4))
+ {
+ net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH,
+ $4->name, cinfo->default_table_charset->csname);
+ YYABORT;
+ }
+ Lex->create_info.default_table_charset= $4;
+ Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
+ };
+
storage_engines:
ident_or_text
{
@@ -1824,7 +1852,12 @@ alter:
}
alter_list
{}
- | ALTER DATABASE ident opt_create_database_options
+ | ALTER DATABASE ident
+ {
+ Lex->create_info.default_table_charset= NULL;
+ Lex->create_info.used_fields= 0;
+ }
+ opt_create_database_options
{
LEX *lex=Lex;
lex->sql_command=SQLCOM_ALTER_DB;