summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorAnel Husakovic <anel@mariadb.org>2019-07-10 02:27:35 -0700
committerAnel Husakovic <anel@mariadb.org>2019-07-11 00:52:27 -0700
commit81ad7b12d09f5c4b50fdfa5d7105fed82f9a463c (patch)
tree9d732508b86d8c24fbca5dc4efdfe63275c268c4 /sql/field.cc
parent0a3aec0a75cfd929c3383d034270c15166db83ee (diff)
downloadmariadb-git-bb-anel-json-v2-10.3-recursion.tar.gz
- Indentation fixed - Logic of empty string fixed - Added read_variable_length() to opaque data type - Added logic and test case for MYSQL_TYPE_NEWDECIMAL - Added new utf8 test - Added support encoding for other opaque data types (MYSQL_TYPE_{LONG/MEDIUM/TINY}BLOB, MYSQL_TYPE_VARCHAR, MYSQL_TYPE_YEAR) found in json suite of mysql and test cases - Added big array test (--do-test=anel/mysql_j) - alter force @todo
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc40
1 files changed, 12 insertions, 28 deletions
diff --git a/sql/field.cc b/sql/field.cc
index d5ab3153910..d79e9622d1e 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -11188,18 +11188,6 @@ uint32 Field_blob::max_display_length() const
bool Field_mysql_json::parse_mysql(String *s, bool json_quoted,
const char *func_name) const
{
- // This code is part of mysql code val_json(wrapper)
- /*
- The empty string is not a valid JSON binary representation, so we
- should have returned an error. However, sometimes an empty
- Field_json object is created in order to retrieve meta-data.
- Return a dummy value instead of raising an error. Bug#21104470.
- The field could also contain an empty string after forcing NULL or
- DEFAULT into a not nullable JSON column using lax error checking
- (such as INSERT IGNORE or non-strict SQL mode). The JSON null
- literal is used to represent the empty value in this case.
- Bug#21437989.
- */
const char *data= s->ptr();
size_t length= s->length();
@@ -11207,27 +11195,25 @@ bool Field_mysql_json::parse_mysql(String *s, bool json_quoted,
s->length(0);
if (length == 0)
{
- //@todo anel will need to see how to handle this
- //Json_wrapper w(new (std::nothrow) Json_null());
- //wr->steal(&w);
+ // There are no data.
return false;
}
// Each document should start with a one-byte type specifier.
if (length < 1)
- return 1; //err(); /* purecov: inspected */
-
- // anel Parse JSON value => part of parse_value()
-
+ return true;
+
+ // First byte is type, starting from second byte, raw data are considered for
+ // obtaining the header and key/value vectors.
size_t type= data[0];
+ const char* data1= data + 1;
+ size_t len= length - 1;
- const char* data1=data+1;
- size_t len=length-1;
-
+ // The fifth argument represents `large` parameter and since it is validated
+ // according to the `type` in parse_value() false value is not important here.
if(parse_value(s, type, data1, len, false, 0))
- {
return true;
- }
+
return false;
}
@@ -11235,10 +11221,8 @@ bool Field_mysql_json::parse_mysql(String *s, bool json_quoted,
{
ASSERT_COLUMN_MARKED_FOR_READ;
String *buf1= Field_blob::val_str(buf1_tmp, buf2);
- bool parsed= this->parse_mysql(buf1, true, field_name.str);
- if(!parsed)
- buf1->append("\nFinshed");
- else
+
+ if (this->parse_mysql(buf1, true, field_name.str))
buf1->length(0);
return buf1;
}