mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Add tests which demonstrate the difference in behavior for zero-length results in sqlite3_value_text_v2() (empty string) vs sqlite3_value_blob_v2() (NULL).
FossilOrigin-Name: 2e7cf00d161e151d49113928fd3ef05069ecbe0635eddd844e9220bd015fe6f9
This commit is contained in:
@ -3345,7 +3345,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
|||||||
.t("value_text_v2() and friends...", function(sqlite3){
|
.t("value_text_v2() and friends...", function(sqlite3){
|
||||||
const db = new sqlite3.oo1.DB();
|
const db = new sqlite3.oo1.DB();
|
||||||
db.exec(["create table t(a,b); insert into t(a,b) ",
|
db.exec(["create table t(a,b); insert into t(a,b) ",
|
||||||
"values(1,123),(2,null),(3,'hi world'),(4,X'232A')"]);
|
"values(1,123),(2,null),(3,'hi world'),(4,X'232A'),(5,'')"]);
|
||||||
const P = wasm.pstack;
|
const P = wasm.pstack;
|
||||||
const stack = P.pointer;
|
const stack = P.pointer;
|
||||||
let q;
|
let q;
|
||||||
@ -3384,6 +3384,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
|||||||
next(); cmp(null);
|
next(); cmp(null);
|
||||||
next(); cmp('hi world');
|
next(); cmp('hi world');
|
||||||
next(); cmp( '#*' );
|
next(); cmp( '#*' );
|
||||||
|
next(); cmp( '' ); // empty strings are not null
|
||||||
/* The following only applies when built with
|
/* The following only applies when built with
|
||||||
SQLITE_ENABLE_API_ARMOR: */
|
SQLITE_ENABLE_API_ARMOR: */
|
||||||
T.assert( capi.SQLITE_MISUSE ==
|
T.assert( capi.SQLITE_MISUSE ==
|
||||||
@ -3406,7 +3407,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
|||||||
.t("value_blob_v2() and friends...", function(sqlite3){
|
.t("value_blob_v2() and friends...", function(sqlite3){
|
||||||
const db = new sqlite3.oo1.DB();
|
const db = new sqlite3.oo1.DB();
|
||||||
db.exec(["create table t(a,b); insert into t(a,b) ",
|
db.exec(["create table t(a,b); insert into t(a,b) ",
|
||||||
"values(1,123),(2,null),(3,'hi'),(4,X'23002A')"]);
|
"values(1,123),(2,null),(3,'hi'),(4,X'23002A'),(5,'')"]);
|
||||||
const P = wasm.pstack;
|
const P = wasm.pstack;
|
||||||
const stack = P.pointer;
|
const stack = P.pointer;
|
||||||
let q;
|
let q;
|
||||||
@ -3428,7 +3429,10 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
|||||||
const blob = wasm.peekPtr(ppOut);
|
const blob = wasm.peekPtr(ppOut);
|
||||||
const len = wasm.peek32(pnOut);
|
const len = wasm.peek32(pnOut);
|
||||||
//log("blob=",wasm.cstrToJs(blob));
|
//log("blob=",wasm.cstrToJs(blob));
|
||||||
T.assert(len === byteList.length, "Lengths don't match");
|
T.assert(len === byteList.length, "Lengths don't match")
|
||||||
|
T.assert( len ? !!blob : !blob,
|
||||||
|
"Expecting len=non-0/blob=non-null or len=0/blob=null. "+
|
||||||
|
"Got len="+len+" blob=@"+blob );
|
||||||
for( let i = 0; i < len; ++i ){
|
for( let i = 0; i < len; ++i ){
|
||||||
T.assert( byteList[i] === wasm.peek8(blob+i),
|
T.assert( byteList[i] === wasm.peek8(blob+i),
|
||||||
"mismatch at offset "+i+": "+byteList[i]
|
"mismatch at offset "+i+": "+byteList[i]
|
||||||
@ -3439,6 +3443,8 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
|||||||
next(); cmp([]); // null
|
next(); cmp([]); // null
|
||||||
next(); cmp([104,105]); // "hi"
|
next(); cmp([104,105]); // "hi"
|
||||||
next(); cmp([0x23, 0, 0x2a]); // X'23002A'
|
next(); cmp([0x23, 0, 0x2a]); // X'23002A'
|
||||||
|
next(); cmp([]); // empty blobs are null
|
||||||
|
|
||||||
/* The following only applies when built with
|
/* The following only applies when built with
|
||||||
SQLITE_ENABLE_API_ARMOR: */
|
SQLITE_ENABLE_API_ARMOR: */
|
||||||
T.assert( capi.SQLITE_MISUSE ==
|
T.assert( capi.SQLITE_MISUSE ==
|
||||||
@ -3448,6 +3454,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
|||||||
/* But a 0 pnOut is always okay. */
|
/* But a 0 pnOut is always okay. */
|
||||||
T.assert( capi.SQLITE_OK ==
|
T.assert( capi.SQLITE_OK ==
|
||||||
capi.sqlite3_value_blob_v2(sv, ppOut, 0) );
|
capi.sqlite3_value_blob_v2(sv, ppOut, 0) );
|
||||||
|
|
||||||
}finally{
|
}finally{
|
||||||
if( q ) q.finalize();
|
if( q ) q.finalize();
|
||||||
db.close();
|
db.close();
|
||||||
|
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
|||||||
C Add\sJS\stests\sfor\sSQLITE_ENABLE_API_ARMOR-shielded\ssqlite3_value_blob/text_v2()\smisuse.
|
C Add\stests\swhich\sdemonstrate\sthe\sdifference\sin\sbehavior\sfor\szero-length\sresults\sin\ssqlite3_value_text_v2()\s(empty\sstring)\svs\ssqlite3_value_blob_v2()\s(NULL).
|
||||||
D 2025-07-01T00:34:15.974
|
D 2025-07-01T09:02:27.937
|
||||||
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
|
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
@ -698,7 +698,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555
|
|||||||
F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c
|
F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c
|
||||||
F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c
|
F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c
|
||||||
F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2
|
F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2
|
||||||
F ext/wasm/tester1.c-pp.js b3c49abab7b650f9c0fcfc2a8ce77258ec69d8fae3b51d54f2f7a219ac0d61c2
|
F ext/wasm/tester1.c-pp.js 2c84df3ad6d6ae0d6fe47c24e50cbd587e7274a440aa97a528819e69c869466c
|
||||||
F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e
|
F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e
|
||||||
F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88
|
F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88
|
||||||
F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
|
F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
|
||||||
@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
|
|||||||
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
|
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
|
||||||
F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
|
F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P c371f92d5b42f2436d2dc92f244e11748fa8cf00e3818b613cce7ea0cfe09c87
|
P 3c0de5b33ce5c41363d004f8359ba41486d014bb04ec7806ba8eb8636fbbdd4c
|
||||||
R 9fa80d600744868f0ca50b681ffc55cb
|
R d985b519d05c6acd122710dfe9810682
|
||||||
U stephan
|
U stephan
|
||||||
Z 3a38662a4da6c675804d7ca2bcbbd57b
|
Z 9a6dc35879d96b1b4f3e2225467554bb
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
@ -1 +1 @@
|
|||||||
3c0de5b33ce5c41363d004f8359ba41486d014bb04ec7806ba8eb8636fbbdd4c
|
2e7cf00d161e151d49113928fd3ef05069ecbe0635eddd844e9220bd015fe6f9
|
||||||
|
Reference in New Issue
Block a user