← Back to team overview

maria-developers team mailing list archive

Re: FOR JSON

 

Hello Sergei,


On 05/25/2014 08:10 PM, Sergei Golubchik wrote:
Hi, Alexander!

On May 17, Alexander Barkov wrote:
Hello Monty,

We discussed extracting data in JSON format today,
to make it possible to return data as a single JSON value
(as a result set consisting of a single row and a single column):

SELECT id,name,address FROM users FOR JSON;

This can be built on the existing functionality.

"FOR JSON" is a result filter, something that gets the result of a query
and transforms it into something different, different set of columns
even.

Natirally, in MySQL language this should've been

   SELECT id,name,address FROM users PROCEDURE JSON;


We can make these two as synonyms:


SELECT id,name,address FROM users PROCEDURE JSON;

and

SELECT id,name,address FROM users FOR JSON;


so internally they map into the same thing.


And tada - it took only 15 years for a second useful procedure to appear :)


:)



Although, seriously, I don't expect PROCEDURE JSON to work out of the
box - procedure api is way too old and hardly ever used. I woldn't be
surprised if it's broken in many subtle ways.

At least this does not work:

select * from (select user from mysql.user procedure analyse())\G
ERROR 1221 (HY000): Incorrect usage of PROCEDURE and subquery

So it does need some hacking.
I think having JSON in subselects is important,
to be able to get one JSON value per record when needed
(instead of a single huge JSON value with one row and one column
bundling all records).



Regards,
Sergei



Follow ups

References