summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2022-11-17 17:30:59 +0100
committerSergei Golubchik <serg@mariadb.org>2023-01-09 18:06:06 +0100
commit610cea3ddae5aa7756a3ec1409466c9e0c5fd5b3 (patch)
tree4446f506220dd9474db5602d9afc033dcbd6da15
parentad27e95d542dfb2ad3a31e4fdf1063cc0685d1f2 (diff)
downloadmariadb-git-610cea3ddae5aa7756a3ec1409466c9e0c5fd5b3.tar.gz
cleanup
Helper class to swicth to relaxed checks during field copy. Temporarily.
-rw-r--r--mysql-test/main/olap.result1
-rw-r--r--mysql-test/main/olap.test4
-rw-r--r--mysql-test/main/type_date.result1
-rw-r--r--mysql-test/main/type_date.test4
-rw-r--r--sql/item.cc6
-rw-r--r--sql/sql_class.h13
-rw-r--r--sql/sql_select.h6
7 files changed, 15 insertions, 20 deletions
diff --git a/mysql-test/main/olap.result b/mysql-test/main/olap.result
index 93eda747d83..cc261c92603 100644
--- a/mysql-test/main/olap.result
+++ b/mysql-test/main/olap.result
@@ -1,4 +1,3 @@
-drop table if exists t1,t2;
set @sav_dpi= @@div_precision_increment;
set div_precision_increment= 5;
show variables like 'div_precision_increment';
diff --git a/mysql-test/main/olap.test b/mysql-test/main/olap.test
index 0c990300b68..6f4048bf120 100644
--- a/mysql-test/main/olap.test
+++ b/mysql-test/main/olap.test
@@ -1,7 +1,3 @@
---disable_warnings
-drop table if exists t1,t2;
---enable_warnings
-
set @sav_dpi= @@div_precision_increment;
set div_precision_increment= 5;
show variables like 'div_precision_increment';
diff --git a/mysql-test/main/type_date.result b/mysql-test/main/type_date.result
index e22b15c88cf..0cf78458817 100644
--- a/mysql-test/main/type_date.result
+++ b/mysql-test/main/type_date.result
@@ -1,4 +1,3 @@
-drop table if exists t1,t2;
create table t1 (a char(16), b date, c datetime);
insert into t1 SET a='test 2000-01-01', b='2000-01-01', c='2000-01-01';
select * from t1 where c = '2000-01-01';
diff --git a/mysql-test/main/type_date.test b/mysql-test/main/type_date.test
index 27d03bd888c..74997aa0ef7 100644
--- a/mysql-test/main/type_date.test
+++ b/mysql-test/main/type_date.test
@@ -1,10 +1,6 @@
#
# test of problem with date fields
#
---disable_warnings
-drop table if exists t1,t2;
---enable_warnings
-
create table t1 (a char(16), b date, c datetime);
insert into t1 SET a='test 2000-01-01', b='2000-01-01', c='2000-01-01';
select * from t1 where c = '2000-01-01';
diff --git a/sql/item.cc b/sql/item.cc
index 630a408b13f..8af83f3a7f1 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1472,12 +1472,8 @@ int Item::save_in_field_no_warnings(Field *field, bool no_conversions)
{
int res;
TABLE *table= field->table;
- THD *thd= table->in_use;
- Check_level_instant_set check_level_save(thd, CHECK_FIELD_IGNORE);
- Sql_mode_save sql_mode(thd);
- thd->variables.sql_mode&= ~(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
- thd->variables.sql_mode|= MODE_INVALID_DATES;
MY_BITMAP *old_map= dbug_tmp_use_all_columns(table, &table->write_set);
+ Use_relaxed_field_copy urfc(table->in_use);
res= save_in_field(field, no_conversions);
dbug_tmp_restore_column_map(&table->write_set, old_map);
return res;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index e82c786c96f..3abd9b9308d 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -6881,6 +6881,19 @@ public:
};
+class Use_relaxed_field_copy: public Sql_mode_save,
+ public Check_level_instant_set
+{
+public:
+ Use_relaxed_field_copy(THD *thd) :
+ Sql_mode_save(thd), Check_level_instant_set(thd, CHECK_FIELD_IGNORE)
+ {
+ thd->variables.sql_mode&= ~(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
+ thd->variables.sql_mode|= MODE_INVALID_DATES;
+ }
+};
+
+
/**
This class resembles the SQL Standard schema qualified object name:
<schema qualified name> ::= [ <schema name> <period> ] <qualified identifier>
diff --git a/sql/sql_select.h b/sql/sql_select.h
index b3945c499f8..d71fc034a9d 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -1914,11 +1914,7 @@ public:
enum store_key_result copy()
{
enum store_key_result result;
- THD *thd= to_field->table->in_use;
- Check_level_instant_set check_level_save(thd, CHECK_FIELD_IGNORE);
- Sql_mode_save sql_mode(thd);
- thd->variables.sql_mode&= ~(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
- thd->variables.sql_mode|= MODE_INVALID_DATES;
+ Use_relaxed_field_copy urfc(to_field->table->in_use);
result= copy_inner();
return result;
}