larrybr [Mon, 27 Nov 2023 15:08:50 +0000 (15:08 +0000)]
Pickup stray oput?() calls that should have gone to stdout. Simplify console line reading, sacrificing speed (which does not matter then) for code size.
drh [Mon, 20 Nov 2023 15:54:00 +0000 (15:54 +0000)]
Back out an incorrect change to the sqlite3ExprCompareSkip() function that
was added way back on 2019-08-22 for [44578865fa7baf97|check-in 44578865fa7ba]
and which was only today discovered to be incorrect by
[forum:/forumpost/45ec3d9788|forum post 45ec3d9788].
drh [Mon, 20 Nov 2023 13:06:59 +0000 (13:06 +0000)]
Convert an assert in OP_VCheck into a branch that aborts the opcode, as this
can happen on some very obscure conditions, as discovered by dbsqlfuzz.
Test case in TH3.
drh [Fri, 17 Nov 2023 17:25:30 +0000 (17:25 +0000)]
Add an assert() to prove the sqlite3_prepare() always either returns
SQLITE_OK or else leaves *ppStmt set to NULL. See
[forum:/forumpost/70bb8576c6c084c2|forum post 70bb8576c6c084c2].
drh [Fri, 17 Nov 2023 11:58:26 +0000 (11:58 +0000)]
Fix an incorrect assert() associated with ALTER TABLE where an unknown
aggregate function contains an ORDER BY clause.
dbsqlfuzz e0900262dadd5c78c2226ad6a435c7f0255be2cd.
larrybr [Thu, 16 Nov 2023 18:31:05 +0000 (18:31 +0000)]
Simplify and make more rational how console I/O package features are selected. (Motivated by Fiddle and other command-line utilities to soon use the package.) No substantive code-execution changes.
dan [Wed, 15 Nov 2023 19:19:04 +0000 (19:19 +0000)]
Changes so that if SQLITE_ENABLE_SETLK_TIMEOUT is defined as 2 instead of 1, all blocking locks are taken for a single millisecond and the default busy-handler invoked as normal.
stephan [Wed, 15 Nov 2023 08:29:42 +0000 (08:29 +0000)]
JNI: clear out the sqlite3_context native pointer after calling UDF callbacks which do not have an argv (as was already done for those which have an argv). Add related tests and code commentary.
stephan [Tue, 14 Nov 2023 14:38:11 +0000 (14:38 +0000)]
JNI: add Sqlite.Stmt.step(boolean) overload which returns the result code of sqlite3_step() unless passed true, in which case it throws for any result other than ROW or DONE. The intent is to simplify handling of LOCKED and BUSY errors.
stephan [Tue, 14 Nov 2023 05:33:44 +0000 (05:33 +0000)]
JNI: use ByteBuffer.limit() instead of ByteBuffer.capacity() when figuring out where the logical end of a ByteBuffer is, for reasons explained at length in new code comments. This is unfortunately slower but is the correct way to do it.
stephan [Tue, 14 Nov 2023 02:43:30 +0000 (02:43 +0000)]
JNI: change sqlite3_prepare_multi()'s exception-handling semantics to be more C-like and, to support that, add the package-private sqlite3_jni_db_error() method to set the db error state from package-level Java code.
stephan [Mon, 13 Nov 2023 23:11:10 +0000 (23:11 +0000)]
JNI: add sqlite3_column_nio_buffer() and sqlite3_value_nio_buffer() using an only-slightly roundabout approach to creating properly-sized ByteBuffer objects.
stephan [Mon, 13 Nov 2023 18:35:37 +0000 (18:35 +0000)]
JNI: add sqlite3_result_nio_buffer() and tests. Discover that we cannot create sensible sqlite3_column_nio_buffer() or sqlite3_value_nio_buffer() counterparts because of ByteBuffer interface limitations.
larrybr [Mon, 13 Nov 2023 05:24:00 +0000 (05:24 +0000)]
Enhance console_io to permit emits limited in various ways, such as valid UTF-8, upto control chars, or with counted limits, all getting away from 0-termination as the sole limit. In CLI, use this capability to avoid certain emit-chars-singly procedures that were breaking up UTF-8 characters. This fixes broken json mode output (on Windows) and (maybe) C-literal-like emits.
stephan [Sat, 11 Nov 2023 14:50:01 +0000 (14:50 +0000)]
JNI wrapper1: when checking for an out-of-bounds statement column index, perform the is-statement-finalized check before the range check so that the former exception trumps the latter.
stephan [Sat, 11 Nov 2023 14:43:50 +0000 (14:43 +0000)]
Do not cache a statement's column count in the JNI wrapper1 API because an ALTER TABLE via another statement may invalidate it, as reported in [forum:6d80efd58d4591c7|forum post 6d80efd58d4591c7].
larrybr [Sat, 11 Nov 2023 06:20:38 +0000 (06:20 +0000)]
Pervasive changes to console_io.{c,h} in support of simplifying ubiquitous emit ops in shell, and to get better control of console streams that might be opened only via .read or .output commands. Changes to shell to use {s,o,e}put{f,z}(...) calls for initial testing, but this check-in has few such conversions so that most will be in a separate check-in. Many renames to better follow recent coding convention. This code seems to be working, but has not been tested on difficult platforms or with multiple console hosts yet. So it is a WIP.
drh [Fri, 10 Nov 2023 17:49:26 +0000 (17:49 +0000)]
Ensure 8-byte alignment of data structues in sqlite3_database_file_object().
This should have appeared on trunk originally and then be cherry-picked onto
the branch. Oh well....
dan [Fri, 10 Nov 2023 15:03:18 +0000 (15:03 +0000)]
Fix an obscure problem with the join-strength-reduction optimization that could occur when mixing LEFT and RIGHT joins in the same query. [forum:/forumpost/7f74ce0bee|Forum post 7f74ce0bee].
drh [Thu, 9 Nov 2023 17:36:37 +0000 (17:36 +0000)]
Add the SQLITE_RESULT_SUBTYPE flag for application-defined functions. Add
the -DSQLITE_STRICT_SUBTYPE=1 compile-time option that raises an error if
any function invokes sqlite3_result_subtype() without the SQLITE_RESULT_SUBTYPE
flag. SQLITE_RESULT_SUBTYPE prevents an indexed value of that function from
being used to replace an equivalent expression, since the indexed expression
does not carry the subtype. Fix for the problem described at
[forum:/forumpost/68d284c86b082c3e|forum post 68d284c86b082c3e].
drh [Thu, 9 Nov 2023 15:01:56 +0000 (15:01 +0000)]
Fixes: (1) In the ->> function, instead of setting a subtype and clearing it,
do not set it in the first place, as doing the set would trigger an error
under SQLITE_STRICT_SUBTYPE. (2) Allow the SQLITE_STRICT_SUBTYPE through
the property filter on sqlite3_create_function().
drh [Thu, 9 Nov 2023 12:58:03 +0000 (12:58 +0000)]
Add the SQLITE_STRICT_SUBTYPE compile-time option. This change reveals that
the current SQLITE_RESULT_SUBTYPE design does not work unless we tag the ->>
operator with SQLITE_RESULT_SUBTYPE. But that will disable an important
optimization.
stephan [Thu, 9 Nov 2023 12:48:54 +0000 (12:48 +0000)]
Add some notes about the JNI pointer-passing approach and convert a couple of potential NullPointerExceptions into appropriate C result codes. Clarify that invocation of undefined behaviour from the Java API does not (due to the addition of defensive code) mean the same thing as it does in C (e.g. no NULL pointer dereferences).
drh [Thu, 9 Nov 2023 12:08:16 +0000 (12:08 +0000)]
Omit the new SQLITE_VALUE_SUBTYPE name. Stay with legacy SQLTIE_SUBTYPE.
Add extra documentation to sqlite3_value_subtype() and sqlite3_result_subtype()
indicating that the SQLITE_SUBTYPE and SQLITE_RESULT_SUBTYPE properties are
required on functions that use those interfaces.
drh [Wed, 8 Nov 2023 16:37:12 +0000 (16:37 +0000)]
More precise characterization of JSON functions. Indicate when functions might
return JSON (subtype 'J') and when they make use of the function argument cache.
larrybr [Tue, 7 Nov 2023 19:30:14 +0000 (19:30 +0000)]
Refactor MBCS/UTF-8 translation to avoid extra allocations, supporting non-formatted (faster) output. Some code cleanup. Wrap .system/.shell command exection with restoration of startup console mode and renewing mode setup. Changes to make legacy MBCS build work better (than legacy did, even with --no-utf8.)
drh [Tue, 7 Nov 2023 19:03:13 +0000 (19:03 +0000)]
Update the documentation to the sqlite3_set_auxdata() and sqlite3_get_auxdata()
routines to make it clear that they do not work as one might expect when they
are called during query planning, instead of during query execution. The JSON
routines misuse those interfaces, so add a special flag to JSON routines that
prevents them from being invoked during query planning. Fix for the problem
in [forum:/forumpost/a655ee159eca1ea5|forum post a655ee159eca1ea5].
stephan [Tue, 7 Nov 2023 17:15:55 +0000 (17:15 +0000)]
JNI: during static init record whether the current JVM supports JNI-level access to java.nio.ByteBuffer raw memory, and add sqlite3_jni_supports_nio() to query that.