SQLite

View Ticket
Login
Ticket Hash: f45ac567eaa9f93c55eef59b33fb90f0146adf85
Title: Invalid JSON generated by json_group_array()
Status: Fixed Type: Code_Defect
Severity: Severe Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2016-01-30 14:54:49
9.39 years ago
Created: 2016-01-30 13:56:13
9.39 years ago
Version Found In: 3.10.2
User Comments:
drh added on 2016-01-30 13:56:13: (text/x-fossil-wiki)
The first column in the output of the following query contains invalid
JSON.  The "abc" string value is not quoted.  The output is
<nowiki><b>[1,abc]</b> instead of <b>[1,"abc"]</b></nowiki>

<blockquote><verbatim>
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(1),('abc');
SELECT
   json_group_array(x),
   json_group_array(json_object('x',x))
  FROM t1;
</verbatim></blockquote>

This problem was reported by Marien Zwart on the SQLite Users
mailing list.

drh added on 2016-01-30 14:54:49: (text/x-fossil-wiki)
The underlying problem was that the subtype information for a VDBE register
was not being cleared when that register was overwritten and reused, which
cause cause the subtype from a prior json_object() call to leak into the
parameter of the json_group_array() call.  Upgraded the severity to Severe
since this problem affects all users of sqlite3_value_subtype() and
sqlite3_result_subtype().