From: stephan Date: Fri, 1 Sep 2023 16:28:46 +0000 (+0000) Subject: Correct a Tester1.java test which inadvertently created a spurious db file in the... X-Git-Tag: version-3.44.0~216^2~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a5f425cc6ea78aed239573fe7af1e30c9b844390;p=thirdparty%2Fsqlite.git Correct a Tester1.java test which inadvertently created a spurious db file in the current dir. Unrelated minor cleanups. FossilOrigin-Name: 016bbdadbf9f95cef185d2606c23e3b3c724586fcca470e11e6fbdbaefd75c79 --- diff --git a/ext/jni/src/c/sqlite3-jni.c b/ext/jni/src/c/sqlite3-jni.c index 0744b99d0a..906bca2a24 100644 --- a/ext/jni/src/c/sqlite3-jni.c +++ b/ext/jni/src/c/sqlite3-jni.c @@ -2303,7 +2303,7 @@ S3JniApi(sqlite3_bind_text(),jint,1bind_1text)( return (jint)rc; } -S3JniApi(sqlite3_text16(),jint,1bind_1text16)( +S3JniApi(sqlite3_bind_text16(),jint,1bind_1text16)( JniArgsEnvClass, jobject jpStmt, jint ndx, jbyteArray baData, jint nMax ){ jbyte * const pBuf = baData ? s3jni_jbytearray_bytes(baData) : 0; @@ -2412,7 +2412,7 @@ S3JniApi(sqlite3_cancel_auto_extension(),jboolean,1cancel_1auto_1extension)( jboolean rc = JNI_FALSE; int i; S3JniAutoExt_mutex_enter; - /* This algo mirrors the one in the core. */ + /* This algo corresponds to the one in the core. */ for( i = SJG.autoExt.nExt-1; i >= 0; --i ){ ax = &SJG.autoExt.aExt[i]; if( ax->jObj && (*env)->IsSameObject(env, ax->jObj, jAutoExt) ){ @@ -2430,7 +2430,6 @@ S3JniApi(sqlite3_cancel_auto_extension(),jboolean,1cancel_1auto_1extension)( return rc; } - /* Wrapper for sqlite3_close(_v2)(). */ static jint s3jni_close_db(JNIEnv * const env, jobject jDb, int version){ int rc = 0; @@ -2586,8 +2585,7 @@ S3JniApi(sqlite3_column_text(),jbyteArray,1column_1text)( } #if 0 -// this impl might prove useful, but we'd need to publish the -// bytearray-returning impl with a different name. +// this impl might prove useful. S3JniApi(sqlite3_column_text(),jstring,1column_1text)( JniArgsEnvClass, jobject jpStmt, jint ndx ){ @@ -2648,11 +2646,15 @@ static void s3jni_rollback_hook_impl(void *pP){ (void)s3jni_commit_rollback_hook_impl(0, pP); } +/* +** Proxy for sqlite3_commit_hook() (if isCommit is true) or +** sqlite3_rollback_hook(). +*/ static jobject s3jni_commit_rollback_hook(int isCommit, JNIEnv * const env, jobject jDb, jobject jHook){ S3JniDb * ps; - jobject pOld = 0; - S3JniHook * pHook; + jobject pOld = 0; /* previous hoook */ + S3JniHook * pHook; /* ps->hooks.commit|rollback */ S3JniDb_mutex_enter; ps = S3JniDb_from_java(jDb); @@ -2684,7 +2686,7 @@ static jobject s3jni_commit_rollback_hook(int isCommit, JNIEnv * const env, S3JniExceptionReport; S3JniExceptionClear; s3jni_db_error(ps->pDb, SQLITE_ERROR, - "Cannot not find matching call() in" + "Cannot not find matching call() method in" "hook object."); }else{ pHook->midCallback = xCallback; @@ -2711,9 +2713,10 @@ S3JniApi(sqlite3_commit_hook(),jobject,1commit_1hook)( S3JniApi(sqlite3_compileoption_get(),jstring,1compileoption_1get)( JniArgsEnvClass, jint n ){ - jstring const rv = (*env)->NewStringUTF( env, sqlite3_compileoption_get(n) ) + const char * z = sqlite3_compileoption_get(n); + jstring const rv = z ? (*env)->NewStringUTF( env, z ) : 0; /* We know these to be ASCII, so MUTF-8 is fine. */; - s3jni_oom_check(rv); + s3jni_oom_check(z ? !!rv : 1); return rv; } @@ -4382,8 +4385,7 @@ S3JniApi(sqlite3_value_text(),jbyteArray,1value_1text)( } #if 0 -// this impl might prove useful, but we'd need to publish the -// bytearray-returning impl with a different name. +// this impl might prove useful. S3JniApi(sqlite3_value_text(),jstring,1value_1text)( JniArgsEnvClass, jobject jpSVal ){ diff --git a/ext/jni/src/org/sqlite/jni/Tester1.java b/ext/jni/src/org/sqlite/jni/Tester1.java index ce8eb6bd23..b4ba626222 100644 --- a/ext/jni/src/org/sqlite/jni/Tester1.java +++ b/ext/jni/src/org/sqlite/jni/Tester1.java @@ -220,7 +220,15 @@ public class Tester1 implements Runnable { outln("\t"+optName+"\t (used="+ sqlite3_compileoption_used(optName)+")"); } + } + private void testCompileOption(){ + int i = 0; + String optName; + for( ; null != (optName = sqlite3_compileoption_get(i)); ++i){ + } + affirm( i > 10 ); + affirm( null==sqlite3_compileoption_get(-1) ); } private void testOpenDb1(){ @@ -1330,7 +1338,7 @@ public class Tester1 implements Runnable { sqlite3 db = createNewDb(); affirm( 4==val.value ); - execSql(db, "ATTACH ':memory' as foo"); + execSql(db, "ATTACH ':memory:' as foo"); affirm( 4==val.value, "ATTACH uses the same connection, not sub-connections." ); sqlite3_close(db); db = null; @@ -1450,19 +1458,17 @@ public class Tester1 implements Runnable { rc = sqlite3_stmt_explain(stmt, 2); affirm( 2 == sqlite3_stmt_isexplain(stmt) ); sqlite3_finalize(stmt); - - sqlite3_close_v2(db); } private void testLimit(){ final sqlite3 db = createNewDb(); + int v; - int v1, v2; - v1 = sqlite3_limit(db, SQLITE_LIMIT_LENGTH, -1); - affirm( v1 > 0 ); - affirm( v1 == sqlite3_limit(db, SQLITE_LIMIT_LENGTH, v1-1) ); - affirm( v1-1 == sqlite3_limit(db, SQLITE_LIMIT_LENGTH, -1) ); + v = sqlite3_limit(db, SQLITE_LIMIT_LENGTH, -1); + affirm( v > 0 ); + affirm( v == sqlite3_limit(db, SQLITE_LIMIT_LENGTH, v-1) ); + affirm( v-1 == sqlite3_limit(db, SQLITE_LIMIT_LENGTH, -1) ); sqlite3_close_v2(db); } diff --git a/ext/jni/src/org/sqlite/jni/tester/SQLTester.java b/ext/jni/src/org/sqlite/jni/tester/SQLTester.java index 47d6b6f3ef..517d8c30a5 100644 --- a/ext/jni/src/org/sqlite/jni/tester/SQLTester.java +++ b/ext/jni/src/org/sqlite/jni/tester/SQLTester.java @@ -475,12 +475,12 @@ public class SQLTester { the db's result code. appendMode specifies how/whether to append results to the result - buffer. lineMode specifies whether to output all results in a + buffer. rowMode specifies whether to output all results in a single line or one line per row. If appendMode is - ResultBufferMode.NONE then lineMode is ignored and may be null. + ResultBufferMode.NONE then rowMode is ignored and may be null. */ public int execSql(sqlite3 db, boolean throwOnError, - ResultBufferMode appendMode, ResultRowMode lineMode, + ResultBufferMode appendMode, ResultRowMode rowMode, String sql) throws SQLTesterException { if( null==db && null==aDb[0] ){ // Delay opening of the initial db to enable tests to change its @@ -562,7 +562,7 @@ public class SQLTester { throw new SQLTesterException("Unhandled ResultBufferMode: "+appendMode); } } - if( ResultRowMode.NEWLINE == lineMode ){ + if( ResultRowMode.NEWLINE == rowMode ){ spacing = 0; sb.append('\n'); } @@ -1128,8 +1128,9 @@ class TestScript { } public String getOutputPrefix(){ - String rc = "["+(moduleName==null ? filename : moduleName)+"]"; + String rc = "["+(moduleName==null ? "" : moduleName)+"]"; if( null!=testCaseName ) rc += "["+testCaseName+"]"; + if( null!=filename ) rc += "["+filename+"]"; return rc + " line "+ cur.lineNo; } @@ -1273,6 +1274,7 @@ class TestScript { } private boolean checkRequiredProperties(SQLTester t, String[] props) throws SQLTesterException{ + if( true ) return false; int nOk = 0; for(String rp : props){ verbose1("REQUIRED_PROPERTIES: ",rp); @@ -1293,6 +1295,12 @@ class TestScript { t.appendDbInitSql("pragma temp_store=0;"); ++nOk; break; + case "AUTOVACUUM": + t.appendDbInitSql("pragma auto_vacuum=full;"); + ++nOk; + case "INCRVACUUM": + t.appendDbInitSql("pragma auto_vacuum=incremental;"); + ++nOk; default: break; } @@ -1331,9 +1339,9 @@ class TestScript { m = patternRequiredProperties.matcher(line); if( m.find() ){ final String rp = m.group(1); - //if( ! checkRequiredProperties( tester, rp.split("\\s+") ) ){ - throw new IncompatibleDirective(this, "REQUIRED_PROPERTIES: "+rp); - //} + if( ! checkRequiredProperties( tester, rp.split("\\s+") ) ){ + throw new IncompatibleDirective(this, "REQUIRED_PROPERTIES: "+rp); + } } m = patternMixedModuleName.matcher(line); if( m.find() ){ diff --git a/ext/jni/src/tests/000-000-sanity.test b/ext/jni/src/tests/000-000-sanity.test index 2bfacb1cec..4ccbece31c 100644 --- a/ext/jni/src/tests/000-000-sanity.test +++ b/ext/jni/src/tests/000-000-sanity.test @@ -6,7 +6,8 @@ ** xMODULE_NAME: module-name ** xREQUIRED_PROPERTIES: small fast reliable ** xREQUIRED_PROPERTIES: RECURSIVE_TRIGGERS -** xREQUIRED_PROPERTIES: TEMPSTORE_MEM TEMPSTORE_FILE +** xREQUIRED_PROPERTIES: TEMPSTORE_FILE TEMPSTORE_MEM +** xREQUIRED_PROPERTIES: AUTOVACUUM INCRVACUUM ** */ --print starting up 😃 diff --git a/ext/wasm/SQLTester/SQLTester.mjs b/ext/wasm/SQLTester/SQLTester.mjs index 8741b81524..a72399aefc 100644 --- a/ext/wasm/SQLTester/SQLTester.mjs +++ b/ext/wasm/SQLTester/SQLTester.mjs @@ -112,12 +112,6 @@ class SQLTesterException extends globalThis.Error { } this.name = 'SQLTesterException'; } - /** - If this overrideable method returns false (the default) then - exceptions of that type are fatal to a whole test run, instead of - just the test which triggered it. If the the "keep going" flag - is set, this preference is ignored. - */ isFatal() { return false; } } @@ -169,6 +163,7 @@ const __SAB = ('undefined'===typeof globalThis.SharedArrayBuffer) ? function(){} : globalThis.SharedArrayBuffer; +/* Frequently-reused regexes. */ const Rx = newObj({ requiredProperties: / REQUIRED_PROPERTIES:[ \t]*(\S.*)\s*$/, scriptModuleName: / SCRIPT_MODULE_NAME:[ \t]*(\S+)\s*$/, @@ -176,7 +171,6 @@ const Rx = newObj({ command: /^--(([a-z-]+)( .*)?)$/, //! "Special" characters - we have to escape output if it contains any. special: /[\x00-\x20\x22\x5c\x7b\x7d]/, - //! Either of '{' or '}'. squiggly: /[{}]/ }); @@ -189,7 +183,7 @@ const Util = newObj({ argvToString: (list)=>{ const m = [...list]; - m.shift(); + m.shift() /* strip command name */; return m.join(" ") }, @@ -257,9 +251,10 @@ class Outer { } } + static #verboseLabel = ["🔈",/*"🔉",*/"🔊","📢"]; verboseN(lvl, args){ if( this.#verbosity>=lvl ){ - this.#outlnImpl(lvl,'VERBOSE ',lvl,': ',...args); + this.#outlnImpl(lvl, Outer.#verboseLabel[lvl-1],': ',...args); } } verbose1(...args){ return this.verboseN(1,args); } @@ -364,8 +359,24 @@ class SQLTester { this.#resultBuffer.push(line); if( addNL ) this.#resultBuffer.push('\n'); } + appendDbInitSql(sql){ + this.#db.initSql.push(sql); + if( this.currentDb() ){ + this.execSql(null, true, ResultBufferMode.NONE, null, sql); + } + } + + #runInitSql(pDb){ + let rc = 0; + for(const sql of this.#db.initSql){ + this.#outer.verbose2("RUNNING DB INIT CODE: ",sql); + rc = this.execSql(pDb, false, ResultBufferMode.NONE, null, sql); + if( rc ) break; + } + return rc; + } - #clearBuffer(buffer){ +#clearBuffer(buffer){ buffer.length = 0; return buffer; } @@ -390,27 +401,21 @@ class SQLTester { } nullValue(){ - if( 0==arguments.length ){ - return this.#nullView; - }else{ - this.#nullView = ''+arguments[0]; - } + return (0==arguments.length) + ? this.#nullView + : (this.#nullView = ''+arguments[0]); } outputColumnNames(){ - if( 0==arguments.length ){ - return this.#emitColNames; - }else{ - this.#emitColNames = !!arguments[0]; - } + return (0==arguments.length) + ? this.#emitColNames + : (this.#emitColNames = !!arguments[0]); } currentDbId(){ - if( 0==arguments.length ){ - return this.#db.iCurrentDb; - }else{ - this.#affirmDbId(arguments[0]).#db.iCurrentDb = arguments[0]; - } + return (0==arguments.length) + ? this.#db.iCurrentDb + : (this.#affirmDbId(arguments[0]).#db.iCurrentDb = arguments[0]); } #affirmDbId(id){ @@ -438,9 +443,9 @@ class SQLTester { if( 0==arguments.length ){ id = this.#db.iCurrentDb; } - const db = this.#affirmDbId(id).#db.list[id]; - if( db ){ - sqlite3.capi.sqlite3_close_v2(db); + const pDb = this.#affirmDbId(id).#db.list[id]; + if( pDb ){ + sqlite3.capi.sqlite3_close_v2(pDb); this.#db.list[id] = null; } } @@ -474,10 +479,9 @@ class SQLTester { rc = sqlite3.capi.sqlite3_open_v2(name, ppOut, flags, null); pDb = wasm.peekPtr(ppOut); }); + let sql; if( 0==rc && this.#db.initSql.length > 0){ - this.#outer.verbose2("RUNNING DB INIT CODE: ",this.#db.initSql.toString()); - rc = this.execSql(pDb, false, ResultBufferMode.NONE, - null, this.#db.initSql.join('')); + rc = this.#runInitSql(pDb); } if( 0!=rc ){ sqlite3.SQLite3Error.toss( @@ -613,7 +617,7 @@ class SQLTester { sqlite3.oo1.DB.checkRc(pDb, rc); } - execSql(pDb, throwOnError, appendMode, lineMode, sql){ + execSql(pDb, throwOnError, appendMode, rowMode, sql){ if( !pDb && !this.#db.list[0] ){ this.#setupInitialDb(); } @@ -685,7 +689,7 @@ class SQLTester { } }/* column loop */ }/* row loop */ - if( ResultRowMode.NEWLINE === lineMode ){ + if( ResultRowMode.NEWLINE === rowMode ){ spacing = 0; sb.push('\n'); } @@ -806,8 +810,9 @@ class TestScript { } getOutputPrefix() { - let rc = "["+(this.#moduleName || this.#filename)+"]"; + let rc = "["+(this.#moduleName || '')+"]"; if( this.#testCaseName ) rc += "["+this.#testCaseName+"]"; + if( this.#filename ) rc += '['+this.#filename+']'; return rc + " line "+ this.#cursor.lineNo; } @@ -829,6 +834,42 @@ class TestScript { return args.length ? this : rc; } + #checkRequiredProperties(tester, props){ + if(true) return false; + let nOk = 0; + for(const rp of props){ + this.verbose2("REQUIRED_PROPERTIES: ",rp); + switch(rp){ + case "RECURSIVE_TRIGGERS": + tester.appendDbInitSql("pragma recursive_triggers=on;"); + ++nOk; + break; + case "TEMPSTORE_FILE": + /* This _assumes_ that the lib is built with SQLITE_TEMP_STORE=1 or 2, + which we just happen to know is the case */ + tester.appendDbInitSql("pragma temp_store=1;"); + ++nOk; + break; + case "TEMPSTORE_MEM": + /* This _assumes_ that the lib is built with SQLITE_TEMP_STORE=1 or 2, + which we just happen to know is the case */ + tester.appendDbInitSql("pragma temp_store=0;"); + ++nOk; + break; + case "AUTOVACUUM": + tester.appendDbInitSql("pragma auto_vacuum=full;"); + ++nOk; + break; + case "INCRVACUUM": + tester.appendDbInitSql("pragma auto_vacuum=incremental;"); + ++nOk; + default: + break; + } + } + return props.length == nOk; + } + #checkForDirective(tester,line){ if(line.startsWith("#")){ throw new IncompatibleDirective(this, "C-preprocessor input: "+line); @@ -843,9 +884,9 @@ class TestScript { m = Rx.requiredProperties.exec(line); if( m ){ const rp = m[1]; - //if( ! checkRequiredProperties( tester, rp.split("\\s+") ) ){ - throw new IncompatibleDirective(this, "REQUIRED_PROPERTIES: "+rp); - //} + if( !this.#checkRequiredProperties( tester, rp.split(/\s+/).filter(v=>!!v) ) ){ + throw new IncompatibleDirective(this, "REQUIRED_PROPERTIES: "+rp); + } } m = Rx.mixedModuleName.exec(line); diff --git a/ext/wasm/SQLTester/SQLTester.run.mjs b/ext/wasm/SQLTester/SQLTester.run.mjs index 0f91230fd0..735fe4dcd8 100644 --- a/ext/wasm/SQLTester/SQLTester.run.mjs +++ b/ext/wasm/SQLTester/SQLTester.run.mjs @@ -42,7 +42,8 @@ let ts = new ns.TestScript('/foo.test',` ** xMODULE_NAME: module-name ** xREQUIRED_PROPERTIES: small fast reliable ** xREQUIRED_PROPERTIES: RECURSIVE_TRIGGERS -** xREQUIRED_PROPERTIES: TEMPSTORE_MEM TEMPSTORE_FILE +** xREQUIRED_PROPERTIES: TEMPSTORE_FILE TEMPSTORE_MEM +** xREQUIRED_PROPERTIES: AUTOVACUUM INCRVACUUM ** */ /* --verbosity 3 */ diff --git a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js index 8e874f7282..327b6a95ad 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js @@ -895,7 +895,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ sah.read( header, {at: 0} ); util.affirmDbHeader( header ); } - sah.write(new Uint8Array(2), { + sah.write(new Uint8Array([1,1]), { at: HEADER_OFFSET_DATA + 18 }/*force db out of WAL mode*/); }catch(e){ @@ -927,7 +927,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ this.setAssociatedPath(sah, '', 0); toss("Expected to write "+n+" bytes but wrote "+nWrote+"."); }else{ - sah.write(new Uint8Array([0,0]), {at: HEADER_OFFSET_DATA+18} + sah.write(new Uint8Array([1,1]), {at: HEADER_OFFSET_DATA+18} /* force db out of WAL mode */); this.setAssociatedPath(sah, name, capi.SQLITE_OPEN_MAIN_DB); } diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index ca2fde985e..af89f216f7 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -1197,7 +1197,7 @@ const installOpfsVfs = function callee(options){ sah.read( header, {at: 0} ); util.affirmDbHeader( header ); } - sah.write(new Uint8Array(2), {at: 18}/*force db out of WAL mode*/); + sah.write(new Uint8Array([1,1]), {at: 18}/*force db out of WAL mode*/); return nWrote; }catch(e){ await sah.close(); @@ -1255,7 +1255,7 @@ const installOpfsVfs = function callee(options){ if(nWrote != n){ toss("Expected to write "+n+" bytes but wrote "+nWrote+"."); } - sah.write(new Uint8Array(2), {at: 18}) /* force db out of WAL mode */; + sah.write(new Uint8Array([1,1]), {at: 18}) /* force db out of WAL mode */; return nWrote; }catch(e){ if( sah ){ await sah.close(); sah = undefined; } diff --git a/manifest b/manifest index d03e82d999..23e22a86e7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sthe\sJNI-internal\smetrics\sopt-in\srather\sthan\sopt-out\sso\sclient\sbuilds\swon't\shave\sthem\sby\sdefault.\sUnrelated\sdoc\stweaks. -D 2023-09-01T14:20:39.576 +C Correct\sa\sTester1.java\stest\swhich\sinadvertently\screated\sa\sspurious\sdb\sfile\sin\sthe\scurrent\sdir.\sUnrelated\sminor\scleanups. +D 2023-09-01T16:28:46.444 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -237,7 +237,7 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3 F ext/jni/GNUmakefile 3e0e28c1c451eab31dd4fa9d262951ef67ed3ece3270a2efc8ec66ec57068547 F ext/jni/README.md 1332b1fa27918bd5d9ca2d0d4f3ac3a6ab86b9e3699dc5bfe32904a027f3d2a9 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa -F ext/jni/src/c/sqlite3-jni.c 0a814e8dbc333ff8a1a8a74aebaece435d2982ed6d4d8e8bf9b7082688b20221 +F ext/jni/src/c/sqlite3-jni.c 00469db3f64a7f53bc1ecb60749260b937f8892ddc56d4c61d5f427f6e6758a7 F ext/jni/src/c/sqlite3-jni.h c22f0189254abe26fad3ba132b484785b19a1aa96d34d30d7d8c5ffe6a9b25d1 F ext/jni/src/org/sqlite/jni/AbstractCollationCallback.java 95e88ba04f4aac51ffec65693e878e234088b2f21b387f4e4285c8b72b33e436 F ext/jni/src/org/sqlite/jni/AggregateFunction.java 7312486bc65fecdb91753c0a4515799194e031f45edbe16a6373cea18f404dc4 @@ -265,7 +265,7 @@ F ext/jni/src/org/sqlite/jni/SQLFunction.java 544a875d33fd160467d82e2397ac33157b F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 98f8d62492e2d6693336dd42c12267ea7f21eefe219aa85b8dd399bd6b0732bd F ext/jni/src/org/sqlite/jni/ScalarFunction.java 6d387bb499fbe3bc13c53315335233dbf6a0c711e8fa7c521683219b041c614c F ext/jni/src/org/sqlite/jni/TableColumnMetadata.java 54511b4297fa28dcb3f49b24035e34ced10e3fd44fd0e458e784f4d6b0096dab -F ext/jni/src/org/sqlite/jni/Tester1.java d4ab6f3f83cbb96e763dd4feb6e5527864d9957eb5e79259bfbe57dcf6d0103e +F ext/jni/src/org/sqlite/jni/Tester1.java 2a6ef03fca523280731a88f697cdc8ece9548cd4cbe7e1cc90823e5bb5998e27 F ext/jni/src/org/sqlite/jni/TesterFts5.java 02b59ea7d75666fd565d90bb8dc7b0c09441bb9d1af091fad9f6d7377297a474 F ext/jni/src/org/sqlite/jni/TraceV2Callback.java beb0b064c1a5f8bfe585a324ed39a4e33edbe379a3fc60f1401661620d3ca7c0 F ext/jni/src/org/sqlite/jni/UpdateHookCallback.java 8376f4a931f2d5612b295c003c9515ba933ee76d8f95610e89c339727376e36c @@ -284,9 +284,9 @@ F ext/jni/src/org/sqlite/jni/sqlite3.java 62b1b81935ccf3393472d17cb883dc5ff39c38 F ext/jni/src/org/sqlite/jni/sqlite3_context.java 66ca95ce904044263a4aff684abe262d56f73e6b06bca6cf650761d79d7779ad F ext/jni/src/org/sqlite/jni/sqlite3_stmt.java 78e6d1b95ac600a9475e9db4623f69449322b0c93d1bd4e1616e76ed547ed9fc F ext/jni/src/org/sqlite/jni/sqlite3_value.java 3d1d4903e267bc0bc81d57d21f5e85978eff389a1a6ed46726dbe75f85e6914a -F ext/jni/src/org/sqlite/jni/tester/SQLTester.java e5a1a4b55ed940e61558be1292aa66563219f360c7c1f9d40d770307e6da3c07 +F ext/jni/src/org/sqlite/jni/tester/SQLTester.java a6863d0284c8ec8ca5abd3d40e1fb297e7ae57fb97282ba335cd896a770e3918 F ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md f9f25126127045d051e918fe59004a1485311c50a13edbf18c79a6ff9160030e -F ext/jni/src/tests/000-000-sanity.test cfe6dc1b950751d6096e3f5695becaadcdaa048bfe9567209d6eb676e693366d +F ext/jni/src/tests/000-000-sanity.test c3427a0e0ac84d7cbe4c95fdc1cd4b61f9ddcf43443408f3000139478c4dc745 F ext/jni/src/tests/000-001-ignored.test e17e874c6ab3c437f1293d88093cf06286083b65bf162317f91bbfd92f961b70 F ext/jni/src/tests/900-001-fts.test bf0ce17a8d082773450e91f2388f5bbb2dfa316d0b676c313c637a91198090f0 F ext/lsm1/Makefile a553b728bba6c11201b795188c5708915cc4290f02b7df6ba7e8c4c943fd5cd9 @@ -550,8 +550,8 @@ F ext/wasm/GNUmakefile 0e362f3fc04eab6628cbe4f1e35f4ab4a200881f6b5f753b27fb45eab F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff -F ext/wasm/SQLTester/SQLTester.mjs 20309ff838209601711087932b008734bab00176e6a47e41d95e11f6d363bae0 -F ext/wasm/SQLTester/SQLTester.run.mjs addeb962f33fb6bca723ab12f0b018303ff962dfc57ee969d051fcbf4f191569 +F ext/wasm/SQLTester/SQLTester.mjs ec2f6ba63a0f2f0562941a0fb8e46b7dc55589711513f1952349785966edfe50 +F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ceabe40849784e24e41c84638 F ext/wasm/SQLTester/index.html 3a12895015c165281307eb47786ce3c46b3c3f06383ad6a9fe3a8526105632f1 F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api d6a5078f48a5301ed17b9a30331075d9b2506e1360c1f0dee0c7816c10acd9ab @@ -571,8 +571,8 @@ F ext/wasm/api/sqlite3-api-worker1.js 9f32af64df1a031071912eea7a201557fe39b17386 F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379 F ext/wasm/api/sqlite3-v-helper.js 7daa0eab0a513a25b05e9abae7b5beaaa39209b3ed12f86aeae9ef8d2719ed25 -F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 561463ac5380e4ccf1839a1922e6d7a5585660f32e3b9701a270b78cd35566cf -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js d9e62d42b86f7bb3143eb071628b24e2ba7dcc749e41a0e9d3e2451bfea1a6b6 +F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 327a8c363a8c84c61770dc3c46cc83d7cc0eb6b59a3b29728bddf087651d3b77 +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 46c4afa6c50d7369252c104f274ad977a97e91ccfafc38b400fe36e90bdda88e F ext/wasm/api/sqlite3-wasm.c 65d60439671e24d50d9119ca805ac1c68fb36129e164377eb46f8d037bd88b07 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bc06df0d599e625bde6a10a394e326dc68da9ff07fa5404354580f81566e591f F ext/wasm/api/sqlite3-worker1.c-pp.js da509469755035e919c015deea41b4514b5e84c12a1332e6cc8d42cb2cc1fb75 @@ -659,14 +659,14 @@ F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 F src/expr.c 1affe0cc049683ef0ef3545d9b6901508556b0ef7e2892a344c3df6d7288d79d F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a7fcbf7e66d14dbb73cf49f31489ebf66d0e6006c62b95246924a3bae9f37b36 -F src/func.c c96c7f55b97493ce278937e6ab6578a866b7e5d6dd486d58b220e9d17e88a750 +F src/func.c 154f08966f8a3a7cad6c438205df1abf58fb2826961a0683e82e120fa647e84c F src/global.c 29f56a330ed9d1b5cd9b79ac0ca36f97ac3afc730ff8bfa987b0db9e559d684d F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 -F src/json.c ae840f87b418f039f5d336b488933d09396bd31e6b31e855b93055ccaee4e255 +F src/json.c 51141f1c09ccb177057e5813e6302a5e32e5ba88cc4a756318a35081010fc6df F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 98cfba10989b3da6f1807ad42444017742db7f100a54f1032af7a8b1295912c0 F src/main.c 2adfb1973ee495977f8c75d6590aae9882161d5f8749b46621299656a2df0cc6 @@ -706,7 +706,7 @@ F src/printf.c e3ba080e2f409f9bfcc8d34724e6fc160e9c718dc92d0548f6b71b8b6f860ce2 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 37953a5f36c60bea413c3c04efcd433b6177009f508ef2ace0494728912fe2e9 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 5f545a2c8702d4d3430bbb188cfec47d6c122d899061ef00cbe56af14591c574 +F src/select.c e9fb48546ab1882639a3a960383f6342dddb776c0227615f8e19de51f0102f68 F src/shell.c.in 2f9be25294b68b07e7e81f0adcec4475aba6011b64f160e414efe226910c4d7b F src/sqlite.h.in 7dbea32976fb18740214edc314253c902e127dac7645a705e566644ed4aa5ef5 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1179,7 +1179,7 @@ F test/fts4umlaut.test fcaca4471de7e78c9d1f7e8976e3e8704d7d8ad979d57a739d00f3f75 F test/fts4unicode.test 82a9c16b68ba2f358a856226bb2ee02f81583797bc4744061c54401bf1a0f4c9 F test/fts4upfrom.test f25835162c989dffd5e2ef91ec24c4848cc9973093e2d492d1c7b32afac1b49d F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d -F test/func.test 719076723b13a6bfcff7b00b7987b1d7b06876ceb71e868b3d13d571d9b42cae +F test/func.test cbcf086273529d4a99b7199086da637a99039d2cad81dd7d7c4c9e25258ae164 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab6a F test/func4.test 2285fb5792d593fef442358763f0fd9de806eda47dbc7a5934df57ffdc484c31 @@ -1298,7 +1298,7 @@ F test/json/json-generator.tcl dc0dd0f393800c98658fc4c47eaa6af29d4e17527380cd286 F test/json/json-q1.txt 65f9d1cdcc4cffa9823fb73ed936aae5658700cd001fde448f68bfb91c807307 F test/json/json-speed-check.sh 8b7babf530faa58bd59d6d362cec8e9036a68c5457ff46f3b1f1511d21af6737 x F test/json101.test dc9d5a2a5b1fd1b54dbd71c538b17933cc98d84b4c1f821ead754933663dca55 -F test/json102.test 24f6f204f9cde45b971016691d0b92a9b4c58040d699e36d6b12cb165f9083ff +F test/json102.test 4c69694773a470f1fda34e5f4ba24920b35184fb66050b450fc2ef9ab5ad310b F test/json103.test 53df87f83a4e5fa0c0a56eb29ff6c94055c6eb919f33316d62161a8880112dbe F test/json104.test 1b844a70cddcfa2e4cd81a5db0657b2e61e7f00868310f24f56a9ba0114348c1 F test/json105.test 11670a4387f4308ae0318cadcbd6a918ea7edcd19fbafde020720a073952675d @@ -1525,7 +1525,7 @@ F test/selectD.test 6d1909b49970bf92f45ce657505befcef5fc7cbc13544e18103a316d3218 F test/selectE.test a8730ca330fcf40ace158f134f4fe0eb00c7edbf F test/selectF.test 21c94e6438f76537b72532fa9fd4710cdd455fc3 F test/selectG.test 089f7d3d7e6db91566f00b036cb353107a2cca6220eb1cb264085a836dae8840 -F test/selectH.test 88237ded5925adfb3f27fdafb5428c2ffc4d61e313bceb854e225ffc3ef0d206 +F test/selectH.test 0b54599f1917d99568c9b929df22ec6261ed7b6d2f02a46b5945ef81b7871aac F test/session.test 78fa2365e93d3663a6e933f86e7afc395adf18be F test/sessionfuzz-data1.db 1f8d5def831f19b1c74571037f0d53a588ea49a6c4ca2a028fc0c27ef896dbcb F test/sessionfuzz.c 5eef09af01eeff6f20250ae4c0112c2e576e4d2f2026cc9a49dc5be6886fa6ee @@ -2116,8 +2116,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P eb24f97253d9c8e7c728c2ac67a0824b10ca67362ac4f8abb94d5d3c54c58c5b -R b5c8106325c21efbc360de8a5178bfb9 +P aa72d25a22c80a7a376127266b8923f0661147c8bc483baa327230364851a255 +R 42c737a27d848aaab44302c5d742eacf U stephan -Z a20aea990735784858db150336da744c +Z 76973b081c5a9e008b03ef52a45413be # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 84b6d6a05d..7b3492731b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aa72d25a22c80a7a376127266b8923f0661147c8bc483baa327230364851a255 \ No newline at end of file +016bbdadbf9f95cef185d2606c23e3b3c724586fcca470e11e6fbdbaefd75c79 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 3332523486..8739035b5b 100644 --- a/src/func.c +++ b/src/func.c @@ -1907,7 +1907,8 @@ static void avgFinalize(sqlite3_context *context){ if( p && p->cnt>0 ){ double r; if( p->approx ){ - r = p->rSum+p->rErr; + r = p->rSum; + if( !sqlite3IsNaN(p->rErr) ) r += p->rErr; }else{ r = (double)(p->iSum); } @@ -1920,7 +1921,8 @@ static void totalFinalize(sqlite3_context *context){ p = sqlite3_aggregate_context(context, 0); if( p ){ if( p->approx ){ - r = p->rSum+p->rErr; + r = p->rSum; + if( !sqlite3IsNaN(p->rErr) ) r += p->rErr; }else{ r = (double)(p->iSum); } diff --git a/src/json.c b/src/json.c index f8d4aa2a77..253fce9f49 100644 --- a/src/json.c +++ b/src/json.c @@ -2484,7 +2484,9 @@ static void jsonArrayLengthFunc( } if( pNode->eType==JSON_ARRAY ){ while( 1 /*exit-by-break*/ ){ - for(i=1; i<=pNode->n; n++){ + i = 1; + while( i<=pNode->n ){ + if( (pNode[i].jnFlags & JNODE_REMOVE)==0 ) n++; i += jsonNodeSize(&pNode[i]); } if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; diff --git a/src/select.c b/src/select.c index 321badd07f..90b284036c 100644 --- a/src/select.c +++ b/src/select.c @@ -5301,12 +5301,12 @@ static int disableUnusedSubqueryResultColumns(SrcItem *pItem){ assert( pItem->pSelect!=0 ); pSub = pItem->pSelect; assert( pSub->pEList->nExpr==pTab->nCol ); - if( (pSub->selFlags & (SF_Distinct|SF_Aggregate))!=0 ){ - testcase( pSub->selFlags & SF_Distinct ); - testcase( pSub->selFlags & SF_Aggregate ); - return 0; - } for(pX=pSub; pX; pX=pX->pPrior){ + if( (pX->selFlags & (SF_Distinct|SF_Aggregate))!=0 ){ + testcase( pX->selFlags & SF_Distinct ); + testcase( pX->selFlags & SF_Aggregate ); + return 0; + } if( pX->pPrior && pX->op!=TK_ALL ){ /* This optimization does not work for compound subqueries that ** use UNION, INTERSECT, or EXCEPT. Only UNION ALL is allowed. */ diff --git a/test/func.test b/test/func.test index 4743e109bd..aea372e08e 100644 --- a/test/func.test +++ b/test/func.test @@ -1549,8 +1549,8 @@ do_catchsql_test func-37.120 { # Incorrect handling of infinity by SUM(). # do_execsql_test func-38.100 { - WITH t1(x) AS (VALUES(9e+999)) SELECT sum(x) FROM t1; - WITH t1(x) AS (VALUES(-9e+999)) SELECT sum(x) FROM t1; -} {Inf -Inf} + WITH t1(x) AS (VALUES(9e+999)) SELECT sum(x), avg(x), total(x) FROM t1; + WITH t1(x) AS (VALUES(-9e+999)) SELECT sum(x), avg(x), total(x) FROM t1; +} {Inf Inf Inf -Inf -Inf -Inf} finish_test diff --git a/test/json102.test b/test/json102.test index 276c1816a7..ce901efeb1 100644 --- a/test/json102.test +++ b/test/json102.test @@ -48,6 +48,9 @@ do_execsql_test json102-180 { do_execsql_test json102-190 { SELECT json_array_length('[1,2,3,4]'); } {{4}} +do_execsql_test json102-191 { + SELECT json_array_length( json_remove('[1,2,3,4]','$[2]') ); +} {{3}} do_execsql_test json102-200 { SELECT json_array_length('[1,2,3,4]', '$'); } {{4}} diff --git a/test/selectH.test b/test/selectH.test index a97679bda2..41f0999fe3 100644 --- a/test/selectH.test +++ b/test/selectH.test @@ -113,6 +113,33 @@ do_execsql_test 4.1 { CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT); SELECT 1 FROM (SELECT DISTINCT name COLLATE rtrim FROM sqlite_schema UNION ALL SELECT a FROM t1); -} 1 +} {1 1} + +do_execsql_test 4.2 { + SELECT DISTINCT name COLLATE rtrim FROM sqlite_schema + UNION ALL + SELECT a FROM t1 +} {v1 t1} + +#------------------------------------------------------------------------- +# forum post https://sqlite.org/forum/forumpost/b83c7b2168 +# +reset_db +do_execsql_test 5.0 { + CREATE TABLE t1 (val1); + INSERT INTO t1 VALUES(4); + INSERT INTO t1 VALUES(5); + CREATE TABLE t2 (val2); +} +do_execsql_test 5.1 { + SELECT DISTINCT val1 FROM t1 UNION ALL SELECT val2 FROM t2; +} { + 4 5 +} +do_execsql_test 5.2 { + SELECT count(1234) FROM ( + SELECT DISTINCT val1 FROM t1 UNION ALL SELECT val2 FROM t2 + ) +} {2} finish_test