Updates to the sqlite3_value_subtype() and sqlite3_result_subtype()

documentation and to test cases for json1 dealing with those interfaces.

FossilOrigin-Name: d6cadbe9fefce9a7af6b2d0cb83362f967d7d89a
This commit is contained in:
drh 2015-09-11 01:22:41 +00:00
parent 46f76d6c3c
commit 12b3b89542
4 changed files with 86 additions and 64 deletions

View File

@ -1,5 +1,5 @@
C Add\snew\sinterfaces\ssqlite3_value_subtype()\sand\ssqlite3_result_subtype().\nUpdate\sthe\sjson1.c\sextension\sto\stake\sadvantages\sof\sthose\sinterfaces\sto\savoid\nthe\sgoofy\s'$$'\spath\ssyntax\sand\sto\sallow\snested\scalls\sto\sjson_array()\sand\njson_object()\sthat\swork\sas\sexpected.
D 2015-09-11T00:26:04.863
C Updates\sto\sthe\ssqlite3_value_subtype()\sand\ssqlite3_result_subtype()\ndocumentation\sand\sto\stest\scases\sfor\sjson1\sdealing\swith\sthose\sinterfaces.
D 2015-09-11T01:22:41.498
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in f85066ce844a28b671aaeeff320921cd0ce36239
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -342,7 +342,7 @@ F src/resolve.c 3126f7694b8ce0f97282d7dd3a5198b8fa18dce9
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
F src/select.c c17613385bc6b095c421b1f30548814f5fd8a9b2
F src/shell.c 6332ef06db1390ef812cfdff1fc97b4fd76cdd42
F src/sqlite.h.in 65ff1449e8c181da9ec752e8304e0a1efffaf47f
F src/sqlite.h.in dbaf8c3796e80221de4395b5f4f872abddb5f89f
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
F src/sqlite3ext.h 64350bf36833a56ad675e27392a913f417c5c308
F src/sqliteInt.h 788dc0ea7ba32ec9fec06c628c1792d7b4753d86
@ -815,7 +815,7 @@ F test/jrnlmode.test 7864d59cf7f6e552b9b99ba0f38acd167edc10fa
F test/jrnlmode2.test 81610545a4e6ed239ea8fa661891893385e23a1d
F test/jrnlmode3.test 556b447a05be0e0963f4311e95ab1632b11c9eaa
F test/json101.test e20d2421c531db32fad59c5e06e80af0b1b002c8
F test/json102.test 12ef6d7d7c02c526fa3c2be1e933e7eb2a497cea
F test/json102.test b5da30aef253102ad63f2186c9319e4b5d505a1b
F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff
F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63
F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200
@ -1386,8 +1386,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P f5580f08538636ffb1367e717a33756288ccddde 8a80d6459e246ec1b38325e1cbd1e862157138b3
R 6298ef57aadddbd507dac61cb4572ea0
T +closed 8a80d6459e246ec1b38325e1cbd1e862157138b3
P db4152aef2253ed2a33e3cad01e0c6758e03f900
R 1bba7f6a951d63c0429f61e7df8f5c7d
U drh
Z 2fd3a23a70bcc4f4e537cdb3e485fd63
Z 186760bb5fa5f9976b74dfde02dde033

View File

@ -1 +1 @@
db4152aef2253ed2a33e3cad01e0c6758e03f900
d6cadbe9fefce9a7af6b2d0cb83362f967d7d89a

View File

@ -4362,14 +4362,14 @@ int sqlite3_value_numeric_type(sqlite3_value*);
** METHOD: sqlite3_value
**
** The sqlite3_value_subtype(V) function returns the subtype for
** an application-defined SQL function argument V. The subtype
** an [application-defined SQL function] argument V. The subtype
** information can be used to pass a limited amount of context from
** one SQL function to another. Use the [sqlite3_result_subtype()]
** routine to set the subtype for the return value of an SQL function.
**
** SQLite makes no use of subtype itself. It merely passes the subtype
** from the result of one application-defined function to the input of
** another.
** from the result of one [application-defined SQL function] into the
** input of another.
*/
unsigned int sqlite3_value_subtype(sqlite3_value*);
@ -4678,9 +4678,10 @@ int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
** METHOD: sqlite3_context
**
** The sqlite3_result_subtype(C,T) function causes the subtype of
** the result from the application-defined function with context C
** to be T. Only the lower 8 bits of the subtype T are preserved
** in current versions of SQLite; higher order bits are discarded.
** the result from the [application-defined SQL function] with
** [sqlite3_context] C to be the value T. Only the lower 8 bits
** of the subtype T are preserved in current versions of SQLite;
** higher order bits are discarded.
** The number of subtype bytes preserved by SQLite might increase
** in future releases of SQLite.
*/

View File

@ -20,125 +20,147 @@ source $testdir/tester.tcl
load_static_extension db json
do_execsql_test json102-100 {
SELECT json(' { "this" : "is", "a": [ "test" ] } ');
} {{{"this":"is","a":["test"]}}}
do_execsql_test json102-110 {
SELECT json_array(1,2,'3',4);
} {{[1,2,"3",4]}}
do_execsql_test json102-110 {
do_execsql_test json102-120 {
SELECT json_array('[1,2]');
} {{["[1,2]"]}}
do_execsql_test json102-120 {
do_execsql_test json102-130 {
SELECT json_array(json_array(1,2));
} {{[[1,2]]}}
do_execsql_test json102-140 {
SELECT json_array(1,null,'3','[4,5]','{"six":7.7}');
} {{[1,null,"3","[4,5]","{\"six\":7.7}"]}}
do_execsql_test json102-130 {
do_execsql_test json102-150 {
SELECT json_array(1,null,'3',json('[4,5]'),json('{"six":7.7}'));
} {{[1,null,"3",[4,5],{"six":7.7}]}}
do_execsql_test json102-160 {
SELECT json_array_length('[1,2,3,4]');
} {{4}}
do_execsql_test json102-140 {
do_execsql_test json102-170 {
SELECT json_array_length('{"one":[1,2,3]}');
} {{0}}
do_execsql_test json102-150 {
do_execsql_test json102-180 {
SELECT json_array_length('{"one":[1,2,3]}', '$.one');
} {{3}}
do_execsql_test json102-160 {
do_execsql_test json102-190 {
SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$');
} {{{"a":2,"c":[4,5,{"f":7}]}}}
do_execsql_test json102-170 {
do_execsql_test json102-200 {
SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c');
} {{[4,5,{"f":7}]}}
do_execsql_test json102-180 {
do_execsql_test json102-210 {
SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c[2]');
} {{{"f":7}}}
do_execsql_test json102-190 {
do_execsql_test json102-220 {
SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c[2].f');
} {{7}}
do_execsql_test json102-200 {
do_execsql_test json102-230 {
SELECT json_extract('{"a":2,"c":[4,5],"f":7}','$.c','$.a');
} {{[[4,5],2]}}
do_execsql_test json102-210 {
do_execsql_test json102-240 {
SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.x');
} {{}}
do_execsql_test json102-220 {
do_execsql_test json102-250 {
SELECT json_insert('{"a":2,"c":4}', '$.a', 99);
} {{{"a":2,"c":4}}}
do_execsql_test json102-230 {
do_execsql_test json102-260 {
SELECT json_insert('{"a":2,"c":4}', '$.e', 99);
} {{{"a":2,"c":4,"e":99}}}
do_execsql_test json102-240 {
do_execsql_test json102-270 {
SELECT json_replace('{"a":2,"c":4}', '$.a', 99);
} {{{"a":99,"c":4}}}
do_execsql_test json102-250 {
do_execsql_test json102-280 {
SELECT json_replace('{"a":2,"c":4}', '$.e', 99);
} {{{"a":2,"c":4}}}
do_execsql_test json102-260 {
do_execsql_test json102-290 {
SELECT json_set('{"a":2,"c":4}', '$.a', 99);
} {{{"a":99,"c":4}}}
do_execsql_test json102-270 {
do_execsql_test json102-300 {
SELECT json_set('{"a":2,"c":4}', '$.e', 99);
} {{{"a":2,"c":4,"e":99}}}
do_execsql_test json102-280 {
do_execsql_test json102-310 {
SELECT json_set('{"a":2,"c":4}', '$.c', '[97,96]');
} {{{"a":2,"c":"[97,96]"}}}
do_execsql_test json102-320 {
SELECT json_set('{"a":2,"c":4}', '$.c', json('[97,96]'));
} {{{"a":2,"c":[97,96]}}}
do_execsql_test json102-330 {
SELECT json_set('{"a":2,"c":4}', '$.c', json_array(97,96));
} {{{"a":2,"c":[97,96]}}}
do_execsql_test json102-340 {
SELECT json_object('a',2,'c',4);
} {{{"a":2,"c":4}}}
do_execsql_test json102-290 {
do_execsql_test json102-350 {
SELECT json_object('a',2,'c','{e:5}');
} {{{"a":2,"c":"{e:5}"}}}
do_execsql_test json102-300 {
do_execsql_test json102-360 {
SELECT json_object('a',2,'c',json_object('e',5));
} {{{"a":2,"c":{"e":5}}}}
do_execsql_test json102-370 {
SELECT json_remove('[0,1,2,3,4]','$[2]');
} {{[0,1,3,4]}}
do_execsql_test json102-310 {
do_execsql_test json102-380 {
SELECT json_remove('[0,1,2,3,4]','$[2]','$[0]');
} {{[1,3,4]}}
do_execsql_test json102-320 {
do_execsql_test json102-390 {
SELECT json_remove('[0,1,2,3,4]','$[0]','$[2]');
} {{[1,2,4]}}
do_execsql_test json102-330 {
do_execsql_test json102-400 {
SELECT json_remove('{"x":25,"y":42}');
} {{{"x":25,"y":42}}}
do_execsql_test json102-340 {
do_execsql_test json102-410 {
SELECT json_remove('{"x":25,"y":42}','$.z');
} {{{"x":25,"y":42}}}
do_execsql_test json102-350 {
do_execsql_test json102-420 {
SELECT json_remove('{"x":25,"y":42}','$.y');
} {{{"x":25}}}
do_execsql_test json102-360 {
do_execsql_test json102-430 {
SELECT json_remove('{"x":25,"y":42}','$');
} {{}}
do_execsql_test json102-370 {
do_execsql_test json102-440 {
SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}');
} {{object}}
do_execsql_test json102-380 {
do_execsql_test json102-450 {
SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$');
} {{object}}
do_execsql_test json102-390 {
do_execsql_test json102-460 {
SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a');
} {{array}}
do_execsql_test json102-400 {
do_execsql_test json102-470 {
SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[0]');
} {{integer}}
do_execsql_test json102-410 {
do_execsql_test json102-480 {
SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[1]');
} {{real}}
do_execsql_test json102-420 {
do_execsql_test json102-490 {
SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[2]');
} {{true}}
do_execsql_test json102-430 {
do_execsql_test json102-500 {
SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[3]');
} {{false}}
do_execsql_test json102-440 {
do_execsql_test json102-510 {
SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[4]');
} {{null}}
do_execsql_test json102-450 {
do_execsql_test json102-520 {
SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[5]');
} {{text}}
do_execsql_test json102-460 {
do_execsql_test json102-530 {
SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[6]');
} {{}}
do_execsql_test json102-470 {
SELECT json_valid('{"x":35}');
do_execsql_test json102-540 {
SELECT json_valid(char(123)||'"x":35'||char(125));
} {{1}}
do_execsql_test json102-480 {
SELECT json_valid('{"x":35'); -- }
do_execsql_test json102-550 {
SELECT json_valid(char(123)||'"x":35');
} {{0}}
ifcapable vtab {
do_execsql_test json102-500 {
do_execsql_test json102-1000 {
CREATE TABLE user(name,phone);
INSERT INTO user(name,phone) VALUES
('Alice','["919-555-2345","804-555-3621"]'),
@ -151,13 +173,13 @@ do_execsql_test json102-500 {
ORDER BY 1;
} {Cindy Dave}
do_execsql_test json102-510 {
do_execsql_test json102-1010 {
UPDATE user
SET phone=json_extract(phone,'$[0]')
WHERE json_array_length(phone)<2;
SELECT name, substr(phone,1,5) FROM user ORDER BY name;
} {Alice {["919} Bob 201-5 Cindy 704-5 Dave {["336}}
do_execsql_test json102-511 {
do_execsql_test json102-1011 {
SELECT name FROM user WHERE phone LIKE '704-%'
UNION
SELECT user.name
@ -166,7 +188,7 @@ do_execsql_test json102-511 {
AND json_each.value LIKE '704-%';
} {Cindy Dave}
do_execsql_test json102-600 {
do_execsql_test json102-1100 {
CREATE TABLE big(json JSON);
INSERT INTO big(json) VALUES('{
"id":123,
@ -203,32 +225,32 @@ set correct_answer [list \
2 {$.stuff[2]} xyzzy \
2 {$.partlist[0].uuid} 0 \
2 {$.partlist[1].uuid} c690dc14-572e-11e5-95f9-dfc8861fd535]
do_execsql_test json102-610 {
do_execsql_test json102-1110 {
SELECT big.rowid, fullkey, value
FROM big, json_tree(big.json)
WHERE json_tree.type NOT IN ('object','array')
ORDER BY +big.rowid, +json_tree.id
} $correct_answer
do_execsql_test json102-620 {
do_execsql_test json102-1120 {
SELECT big.rowid, fullkey, atom
FROM big, json_tree(big.json)
WHERE atom IS NOT NULL
ORDER BY +big.rowid, +json_tree.id
} $correct_answer
do_execsql_test json102-630 {
do_execsql_test json102-1130 {
SELECT DISTINCT json_extract(big.json,'$.id')
FROM big, json_tree(big.json,'$.partlist')
WHERE json_tree.key='uuid'
AND json_tree.value='6fa5181e-5721-11e5-a04e-57f3d7b32808';
} {123}
do_execsql_test json102-631 {
do_execsql_test json102-1131 {
SELECT DISTINCT json_extract(big.json,'$.id')
FROM big, json_tree(big.json,'$')
WHERE json_tree.key='uuid'
AND json_tree.value='6fa5181e-5721-11e5-a04e-57f3d7b32808';
} {123}
do_execsql_test json102-632 {
do_execsql_test json102-1132 {
SELECT DISTINCT json_extract(big.json,'$.id')
FROM big, json_tree(big.json)
WHERE json_tree.key='uuid'