summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/mysqld.cc24
-rw-r--r--sql/sql_class.h15
-rw-r--r--sql/table.cc25
-rw-r--r--sql/table.h2
4 files changed, 57 insertions, 9 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 4444e02d983..2cc9e878f74 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3708,14 +3708,24 @@ static int init_common_variables()
if (ignore_db_dirs_init())
exit(1);
-#ifdef _WIN32
- get_win_tzname(system_time_zone, sizeof(system_time_zone));
-#elif defined(HAVE_TZNAME)
struct tm tm_tmp;
- localtime_r(&server_start_time,&tm_tmp);
- const char *tz_name= tzname[tm_tmp.tm_isdst != 0 ? 1 : 0];
- strmake_buf(system_time_zone, tz_name);
-#endif /* HAVE_TZNAME */
+ localtime_r(&server_start_time, &tm_tmp);
+
+#ifdef HAVE_TZNAME
+#ifdef _WIN32
+ /*
+ If env.variable TZ is set, derive timezone name from it.
+ Otherwise, use IANA tz name from get_win_tzname.
+ */
+ if (!getenv("TZ"))
+ get_win_tzname(system_time_zone, sizeof(system_time_zone));
+ else
+#endif
+ {
+ const char *tz_name= tzname[tm_tmp.tm_isdst != 0 ? 1 : 0];
+ strmake_buf(system_time_zone, tz_name);
+ }
+#endif
/*
We set SYSTEM time zone as reasonable default and
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 51c1bc984da..273b53e4227 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1970,6 +1970,21 @@ private:
};
+struct Suppress_warnings_error_handler : public Internal_error_handler
+{
+ bool handle_condition(THD *thd,
+ uint sql_errno,
+ const char *sqlstate,
+ Sql_condition::enum_warning_level *level,
+ const char *msg,
+ Sql_condition **cond_hdl)
+ {
+ return *level == Sql_condition::WARN_LEVEL_WARN;
+ }
+};
+
+
+
/**
Tables that were locked with LOCK TABLES statement.
diff --git a/sql/table.cc b/sql/table.cc
index 7c3bc88de2c..299bafcd0db 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -8794,12 +8794,28 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode)
DBUG_RETURN(in_use->is_error());
}
-int TABLE::update_virtual_field(Field *vf)
+/*
+ Calculate the virtual field value for a specified field.
+ @param vf A field to calculate
+ @param ignore_warnings Ignore the warnings and also make the
+ calculations permissive. This usually means
+ that a calculation is internal and is not
+ expected to fail.
+*/
+int TABLE::update_virtual_field(Field *vf, bool ignore_warnings)
{
DBUG_ENTER("TABLE::update_virtual_field");
Query_arena backup_arena;
Counting_error_handler count_errors;
+ Suppress_warnings_error_handler warning_handler;
in_use->push_internal_handler(&count_errors);
+ bool abort_on_warning;
+ if (ignore_warnings)
+ {
+ abort_on_warning= in_use->abort_on_warning;
+ in_use->abort_on_warning= false;
+ in_use->push_internal_handler(&warning_handler);
+ }
/*
TODO: this may impose memory leak until table flush.
See comment in
@@ -8813,6 +8829,13 @@ int TABLE::update_virtual_field(Field *vf)
DBUG_RESTORE_WRITE_SET(vf);
in_use->restore_active_arena(expr_arena, &backup_arena);
in_use->pop_internal_handler();
+ if (ignore_warnings)
+ {
+ in_use->abort_on_warning= abort_on_warning;
+ in_use->pop_internal_handler();
+ // This is an internal calculation, we expect it to always succeed
+ DBUG_ASSERT(count_errors.errors == 0);
+ }
DBUG_RETURN(count_errors.errors);
}
diff --git a/sql/table.h b/sql/table.h
index f394f549ff7..70198ed5fdc 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1678,7 +1678,7 @@ public:
uint actual_n_key_parts(KEY *keyinfo);
ulong actual_key_flags(KEY *keyinfo);
- int update_virtual_field(Field *vf);
+ int update_virtual_field(Field *vf, bool ignore_warnings);
int update_virtual_fields(handler *h, enum_vcol_update_mode update_mode);
int update_default_fields(bool ignore_errors);
void evaluate_update_default_function();