summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-10-11 23:16:01 +0400
committerAlexander Barkov <bar@mariadb.com>2019-10-12 07:25:53 +0400
commit530f3f7cfc912ce9ff8282c520aa055b768cbe2a (patch)
tree62a578b80fa42079d1a362475210c5aecbd51e88 /sql
parenta0d3a351b8c5c2eb757270f31f9741b94f88ff1d (diff)
downloadmariadb-git-530f3f7cfc912ce9ff8282c520aa055b768cbe2a.tar.gz
MDEV-20806 Federated does not work with INET6, returns NULL with warning ER_TRUNCATED_WRONG_VALUE
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc17
-rw-r--r--sql/field.h19
-rw-r--r--sql/sql_class.h17
3 files changed, 46 insertions, 7 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 01220d7205a..b74c95909e8 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1887,13 +1887,16 @@ bool Field::compatible_field_size(uint field_metadata,
int Field::store(const char *to, size_t length, CHARSET_INFO *cs,
enum_check_fields check_level)
{
- int res;
- THD *thd= get_thd();
- enum_check_fields old_check_level= thd->count_cuted_fields;
- thd->count_cuted_fields= check_level;
- res= store(to, length, cs);
- thd->count_cuted_fields= old_check_level;
- return res;
+ Check_level_instant_set tmp_level(get_thd(), check_level);
+ return store(to, length, cs);
+}
+
+
+int Field::store_text(const char *to, size_t length, CHARSET_INFO *cs,
+ enum_check_fields check_level)
+{
+ Check_level_instant_set tmp_level(get_thd(), check_level);
+ return store_text(to, length, cs);
}
diff --git a/sql/field.h b/sql/field.h
index 3d9cfe92346..1af55487704 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -916,6 +916,23 @@ public:
reset();
}
virtual int store(const char *to, size_t length,CHARSET_INFO *cs)=0;
+ /*
+ This is used by engines like CSV and Federated to signal the field
+ that the data is going to be in text (rather than binary) representation,
+ even if cs points to &my_charset_bin.
+
+ If a Field distinguishes between text and binary formats (e.g. INET6),
+ we cannot call store(str,length,&my_charset_bin),
+ to avoid "field" mis-interpreting the data format as binary.
+ */
+ virtual int store_text(const char *to, size_t length, CHARSET_INFO *cs)
+ {
+ return store(to, length, cs);
+ }
+ virtual int store_binary(const char *to, size_t length)
+ {
+ return store(to, length, &my_charset_bin);
+ }
virtual int store_hex_hybrid(const char *str, size_t length);
virtual int store(double nr)=0;
virtual int store(longlong nr, bool unsigned_val)=0;
@@ -940,6 +957,8 @@ public:
{ return store_time_dec(ltime, TIME_SECOND_PART_DIGITS); }
int store(const char *to, size_t length, CHARSET_INFO *cs,
enum_check_fields check_level);
+ int store_text(const char *to, size_t length, CHARSET_INFO *cs,
+ enum_check_fields check_level);
int store(const LEX_STRING *ls, CHARSET_INFO *cs)
{
DBUG_ASSERT(ls->length < UINT_MAX32);
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 77059e7aab0..8ca74457273 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -6884,6 +6884,23 @@ public:
};
+class Check_level_instant_set
+{
+ THD *m_thd;
+ enum_check_fields m_check_level;
+public:
+ Check_level_instant_set(THD *thd, enum_check_fields temporary_value)
+ :m_thd(thd), m_check_level(thd->count_cuted_fields)
+ {
+ thd->count_cuted_fields= temporary_value;
+ }
+ ~Check_level_instant_set()
+ {
+ m_thd->count_cuted_fields= m_check_level;
+ }
+};
+
+
/**
This class resembles the SQL Standard schema qualified object name:
<schema qualified name> ::= [ <schema name> <period> ] <qualified identifier>