summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/partition_column.result10
-rw-r--r--mysql-test/t/partition_column.test15
-rw-r--r--sql/partition_info.cc12
3 files changed, 36 insertions, 1 deletions
diff --git a/mysql-test/r/partition_column.result b/mysql-test/r/partition_column.result
index 79ab838f6cb..0ba56110116 100644
--- a/mysql-test/r/partition_column.result
+++ b/mysql-test/r/partition_column.result
@@ -1,4 +1,14 @@
drop table if exists t1;
+set @@sql_mode=allow_invalid_dates;
+create table t1 (a char, b char, c date)
+partition by range column_list (a,b,c)
+( partition p0 values less than (0,0,to_days('3000-11-31')));
+ERROR HY000: Partition column values of incorrect type
+create table t1 (a char, b char, c date)
+partition by range column_list (a,b,c)
+( partition p0 values less than (0,0,'3000-11-31'));
+ERROR HY000: Partition column values of incorrect type
+set @@sql_mode='';
create table t1 (a varchar(2) character set ucs2)
partition by list column_list (a)
(partition p0 values in (0x2020),
diff --git a/mysql-test/t/partition_column.test b/mysql-test/t/partition_column.test
index 6c39557f296..16f12bfad04 100644
--- a/mysql-test/t/partition_column.test
+++ b/mysql-test/t/partition_column.test
@@ -9,6 +9,21 @@ drop table if exists t1;
--enable_warnings
#
+# BUG#48165, sql_mode gives error
+#
+set @@sql_mode=allow_invalid_dates;
+--error ER_WRONG_TYPE_COLUMN_VALUE_ERROR
+create table t1 (a char, b char, c date)
+partition by range column_list (a,b,c)
+( partition p0 values less than (0,0,to_days('3000-11-31')));
+
+--error ER_WRONG_TYPE_COLUMN_VALUE_ERROR
+create table t1 (a char, b char, c date)
+partition by range column_list (a,b,c)
+( partition p0 values less than (0,0,'3000-11-31'));
+set @@sql_mode='';
+
+#
# BUG#48163, Dagger in UCS2 not working as partition value
#
create table t1 (a varchar(2) character set ucs2)
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 131e1dcf3a6..9d9aa5d4e95 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -1949,18 +1949,28 @@ bool partition_info::fix_column_value_functions(THD *thd,
{
uchar *val_ptr;
uint len= field->pack_length();
+ ulong save_sql_mode;
+ bool save_got_warning;
+
if (!(column_item= get_column_item(column_item,
field)))
{
result= TRUE;
goto end;
}
- if (column_item->save_in_field(field, TRUE))
+ save_sql_mode= thd->variables.sql_mode;
+ thd->variables.sql_mode= 0;
+ save_got_warning= thd->got_warning;
+ thd->got_warning= 0;
+ if (column_item->save_in_field(field, TRUE) ||
+ thd->got_warning)
{
my_error(ER_WRONG_TYPE_COLUMN_VALUE_ERROR, MYF(0));
result= TRUE;
goto end;
}
+ thd->got_warning= save_got_warning;
+ thd->variables.sql_mode= save_sql_mode;
if (!(val_ptr= (uchar*) sql_calloc(len)))
{
mem_alloc_error(len);