SQLite

Check-in [1c33c5db]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the subtype on the value column from json_each/json_tree for cases when the value is an array or object. Fix for the bug reported by forum post ecb94cd210.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1c33c5db2e05019d1a375109f79ad8588a3c17f81e4f4b8d66c880c3c860e87e
User & Date: drh 2024-02-16 21:30:08
Context
2024-02-17
03:32
Fix rounding in zero-precision %f and %g printf conversions. Forum post 393708f4a8. This bug was introduced by check-in [32befb224b254639] and first appeared in version 3.43.0. (check-in: 7fca1bc4 user: drh tags: trunk)
01:12
The PRAGMA optimize command invokes ANALYZE if a table shrinks by 25 times in addition to if it grows by 25 times. (check-in: 40532ffb user: drh tags: better-pragma-optimize)
2024-02-16
21:34
Fix the subtype on the value column from json_each/json_tree for cases when the value is an array or object. (check-in: b278ae39 user: drh tags: branch-3.45)
21:30
Fix the subtype on the value column from json_each/json_tree for cases when the value is an array or object. Fix for the bug reported by forum post ecb94cd210. (check-in: 1c33c5db user: drh tags: trunk)
18:34
Retweak last check-in to retain compile-time checking of xprintf() arguments. (check-in: 67017491 user: larrybr tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/json.c.

4940
4941
4942
4943
4944
4945
4946



4947
4948
4949
4950
4951
4952
4953
        sqlite3_result_int64(ctx, p->aParent[p->nParent-1].iKey);
      }
      break;
    }
    case JEACH_VALUE: {
      u32 i = jsonSkipLabel(p);
      jsonReturnFromBlob(&p->sParse, i, ctx, 1);



      break;
    }
    case JEACH_TYPE: {
      u32 i = jsonSkipLabel(p);
      u8 eType = p->sParse.aBlob[i] & 0x0f;
      sqlite3_result_text(ctx, jsonbType[eType], -1, SQLITE_STATIC);
      break;







>
>
>







4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
        sqlite3_result_int64(ctx, p->aParent[p->nParent-1].iKey);
      }
      break;
    }
    case JEACH_VALUE: {
      u32 i = jsonSkipLabel(p);
      jsonReturnFromBlob(&p->sParse, i, ctx, 1);
      if( (p->sParse.aBlob[i] & 0x0f)>=JSONB_ARRAY ){
        sqlite3_result_subtype(ctx, JSON_SUBTYPE);
      }
      break;
    }
    case JEACH_TYPE: {
      u32 i = jsonSkipLabel(p);
      u8 eType = p->sParse.aBlob[i] & 0x0f;
      sqlite3_result_text(ctx, jsonbType[eType], -1, SQLITE_STATIC);
      break;

Changes to test/json101.test.

373
374
375
376
377
378
379














380
381
382
383
384
385
386
   WHERE jx.value<>jx.atom AND type NOT IN ('array','object');
} {}
do_execsql_test json101-5.8 {
  SELECT j2.rowid, jx.rowid, fullkey, path, key
    FROM j2, json_tree(j2.json) AS jx
   WHERE jx.value<>jx.atom AND type NOT IN ('array','object');
} {}















do_execsql_test json101-6.1 {
  SELECT json_valid('{"a":55,"b":72,}');
} {0}
do_execsql_test json101-6.2 {
  SELECT json_error_position('{"a":55,"b":72,}');
} {0}







>
>
>
>
>
>
>
>
>
>
>
>
>
>







373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
   WHERE jx.value<>jx.atom AND type NOT IN ('array','object');
} {}
do_execsql_test json101-5.8 {
  SELECT j2.rowid, jx.rowid, fullkey, path, key
    FROM j2, json_tree(j2.json) AS jx
   WHERE jx.value<>jx.atom AND type NOT IN ('array','object');
} {}

# 2024-02-16 https://sqlite.org/forum/forumpost/ecb94cd210
# Regression in json_tree()/json_each().  The value column
# should have the "J" subtype if the value is an array or
# object.
#
do_execsql_test json101-5.10 {
  SELECT json_insert('{}','$.a',value) FROM json_tree('[1,2,3]') WHERE atom IS NULL;
} {{{"a":[1,2,3]}}}
#        ^^^^^^^--- In double-quotes, a string literal, prior to bug fix

do_execsql_test json101-5.11 {
  SELECT json_insert('{}','$.a',value) FROM json_tree('"[1,2,3]"');
} {{{"a":"[1,2,3]"}}}

do_execsql_test json101-6.1 {
  SELECT json_valid('{"a":55,"b":72,}');
} {0}
do_execsql_test json101-6.2 {
  SELECT json_error_position('{"a":55,"b":72,}');
} {0}