|
I can reproduce it with utf8 names (not with latin1).
I am not sure it is a bug though, as in this query you are trying to convert a blob to char:
column_get(column_create('test1', column_create('key1','value1','key2','value2','key3','value3')) , 'test1' as char)
|
If you execute just it
set names utf8;
|
select column_get(column_create('test1', column_create('key1','value1','key2','value2','key3','value3')) , 'test1' as char);
|
you'll get
+----------------------------------------------------------------------------------------------------------------------+
|
| column_get(column_create('test1', column_create('key1','value1','key2','value2','key3','value3')) , 'test1' as char) |
|
+----------------------------------------------------------------------------------------------------------------------+
|
|
|
s ? key1key2key3!value1!value2!value3 |
|
+----------------------------------------------------------------------------------------------------------------------+
|
1 row in set, 1 warning (0.00 sec)
|
|
MariaDB [test]> show warnings;
|
+---------+------+----------------------------------------------------------------------------+
|
| Level | Code | Message |
|
+---------+------+----------------------------------------------------------------------------+
|
| Warning | 1300 | Invalid utf8 character string: '\xE3\x00key1key2key3!value1!value2!value3' |
|
+---------+------+----------------------------------------------------------------------------+
|
1 row in set (0.00 sec)
|
So, further attempt to read an already invalid value does not go to well.
I suppose column_create has the right to return non-utf8 symbols. Shouldn't there be as binary instead?
ATTN bar and sanja as experts on character sets and dynamic columns, correspondingly.
|
|
AFAIK column_create/column_add return result in binary charset (at least it should). But probably it goes wrong somewhere.
|
|
Assigning to sanja for further analysis (please reassign to or consult with bar if necessary).
|
|
In second test suite we trying to send back to the client binary string (packed Dynamic Column) via charset which do not support all possible characters combination (utf8). So it is normal (I checked in debugger that the problem is in attempt to check binary data as utf8).
|
|
For original test suite we have the same problem. Correct query is:
select column_json(column_get(column_create('test1', column_create('key1','value1','key2','value2','key3','value3')) , 'test1' as BINARY));
(Notice BINARY).
|
|
I'll add note to the documentation about safe charset.
|
1. Before
In good-old 10.0, char was understood as binary
MariaDB [(none)]> show variables like 'version';
|
+---------------+--------------------------------+
|
| Variable_name | Value |
|
+---------------+--------------------------------+
|
| version | 10.0.27-MariaDB-1~trusty-wsrep |
|
+---------------+--------------------------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [(none)]> SELECT (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS char), 'int' AS char) * 2);
|
+-----------------------------------------------------------------------------------------------------------------+
|
| (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS char), 'int' AS char) * 2) |
|
+-----------------------------------------------------------------------------------------------------------------+
|
| 246 |
|
+-----------------------------------------------------------------------------------------------------------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [(none)]> SELECT (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS binary), 'int' AS char) * 2);
|
+-------------------------------------------------------------------------------------------------------------------+
|
| (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS binary), 'int' AS char) * 2) |
|
+-------------------------------------------------------------------------------------------------------------------+
|
| 246 |
|
+-------------------------------------------------------------------------------------------------------------------+
|
1 row in set (0.00 sec)
|
2. After
Now we need to do more work in our ORM
MariaDB [(none)]> show variables like 'version';
|
+---------------+-----------------+
|
| Variable_name | Value |
|
+---------------+-----------------+
|
| version | 10.1.20-MariaDB |
|
+---------------+-----------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [(none)]> SELECT (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS char), 'int' AS char) * 2);
|
+-----------------------------------------------------------------------------------------------------------------+
|
| (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS char), 'int' AS char) * 2) |
|
+-----------------------------------------------------------------------------------------------------------------+
|
| -64 |
|
+-----------------------------------------------------------------------------------------------------------------+
|
1 row in set, 1 warning (0.00 sec)
|
|
MariaDB [(none)]> SHOW WARNINGS;
|
+---------+------+---------------------------------------+
|
| Level | Code | Message |
|
+---------+------+---------------------------------------+
|
| Warning | 1300 | Invalid utf8 character string: '\xF6' |
|
+---------+------+---------------------------------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [(none)]> SELECT (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS binary), 'int' AS char) * 2);
|
+-------------------------------------------------------------------------------------------------------------------+
|
| (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS binary), 'int' AS char) * 2) |
|
+-------------------------------------------------------------------------------------------------------------------+
|
| 246 |
|
+-------------------------------------------------------------------------------------------------------------------+
|
1 row in set (0.00 sec)
|
|
|
I like the 10.0 behavior better because Maria is more friendly if she understands from the outer COLUMN_GET context that, well, obviously this 'child' as char needs to be taken as binary.
Is there any value to the improvement in 10.1?
|