← Back to team overview

maria-discuss team mailing list archive

Re: JSON and binary strings

 

Hi Peter,

Yes, that is the actual returned value. But

> {"name":"ÁÂÃÄÅÆ"}

is not valid JSON (see 2.5 in rfc4627). And I don't think invalid JSON
*should* be expected from a function called COLUMN_JSON.

But I don't know what Maria should do when it is asked to return a value in
a format that cannot express that value.

Tom

From:  Peter Laursen <peter_laursen@xxxxxxxxxx>
Date:  Saturday, January 31, 2015 at 3:39 PM
To:  Tom Worster <fsb@xxxxxxxxxx>
Cc:  maria-discuss email list <maria-discuss@xxxxxxxxxxxxxxxxxxx>
Subject:  Re: [Maria-discuss] JSON and binary strings

I get the result (what I think is expected) from the query "SELECT
COLUMN_JSON(COLUMN_CREATE('name', UNHEX('C1C2C3C4C5C6'))):"

{"name":"ÁÂÃÄÅÆ"} 

.. in SQLyog (GUI client always using UTF8 as client character set)  on
Windows. In command line client shipped with MariaDB 10.0 for Windows, I get
garbage (both after SET NAMES latin1 and SET NAMES utf8 - but MariaDB does
not (yet) have a fully unicode-enabled commandline client for Windows like
MySQL 5.6 and 5.7 have).

Are you sure that your client environment will handle all those
special/accented characters at the same time? I think you bumped into an
encoding issue in the client of some kind. What is your client environment
and OS, and what does the query return here?



-- Peter
-- Webyog

On Sat, Jan 31, 2015 at 3:59 PM, Tom Worster <fsb@xxxxxxxxxx> wrote:
> I could have been more direct. What should be the expected behavior in the
> following?
> 
> SELECT COLUMN_JSON(COLUMN_CREATE('name', UNHEX('C1C2C3C4C5C6')));
> 
> 
> From:  Tom Worster <fsb@xxxxxxxxxx>
> Date:  Friday, January 30, 2015 at 9:05 PM
> To:  maria-discuss email list <maria-discuss@xxxxxxxxxxxxxxxxxxx>
> Subject:  [Maria-discuss] JSON and binary strings
> 
> BINARY is one of the datatypes you can use with dynamic columns. If you try
> saving binary string and then retrieve it with COLUMN_JSON() then you get an
> invalid JSON document back. All the JSON decoders I tested reject such
> documents.
> 
> It doesn't make sense to me that COLUMN_JSON() would return a document that's
> invalid according to the JSON spec and can't be decoded. But I don't know what
> it should do. It seems that BINARY in dynamic columns means that COLUMN_JSON()
> is in an impossible position.
> 
> [On a related note, if you save a valid utf8 string that includes control
> characters (e.g. "I went down to the river,\nI set down on the bank.") then
> COLUMN_JSON() fails to escape them. While similar, this I think is a bug.]
> 
> Tom
> _______________________________________________ Mailing list:
> https://launchpad.net/~maria-discuss Post to     :
> maria-discuss@xxxxxxxxxxxxxxxxxxx Unsubscribe :
> https://launchpad.net/~maria-discuss More help   :
> https://help.launchpad.net/ListHelp
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~maria-discuss
> Post to     : maria-discuss@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~maria-discuss
> More help   : https://help.launchpad.net/ListHelp
> 




Follow ups

References