ericsink / SQLitePCL.raw

A Portable Class Library (PCL) for low-level (raw) access to SQLite
Apache License 2.0
512 stars 106 forks source link

JSON1 not included starting with version 2.1.0 #535

Closed michaelstonis closed 1 year ago

michaelstonis commented 1 year ago

What version of SQLitePCLRaw are you using? 2.1.0+

If you are using one of the SQLitePCLRaw bundle packages, which one? SQLitePCLRaw.bundle_e_sqlite3

What platform are you running on? What operating system? Which version? What CPU? macOS. Ventura 13.1

What target framework are you building for? Not using framework

Are you on .NET Framework or the newer stuff (.NET Core, .NET 5+, etc)? .NET 6+

Are you using the command line, or an IDE? Which IDE? Which version of that IDE? Executing from unit test in visual studio mac

Is this problem something that just started happening? For example, were things working well for you and then you updated something and then the problem showed up? What changed? Issue started happening when updating from 2.0.7 to 2.1.0+

What is the exact error message you are seeing when the problem happens? Checking loaded compilation options, ENABLE_JSON1 is no longer listed

Are you using PackageReference or packages.config? PackageReference

If you are using mobile platforms, are you on classic/legacy Xamarin or on .NET 6 and higher? .NET 6+

Sometimes other packages using SQLitePCLRaw cause problems when they are mixed together. What other packages are you including in your project? Microsoft.Data.Sqlite

How can we reproduce the problem you are seeing? Your issue will get attention much faster if you attach a minimal reproduction sample project.

If I roll back to Microsoft.Data.Sqlite 5.0.13 and SQLitePCLRaw.bundle_e_sqlite3 2.0.7

Compile Options
    COMPILER=clang-12.0.0
    DEFAULT_FOREIGN_KEYS
    ENABLE_COLUMN_METADATA
    ENABLE_FTS3_PARENTHESIS
    ENABLE_FTS4
    ENABLE_FTS5
    ENABLE_JSON1
    ENABLE_RTREE
    ENABLE_SNAPSHOT
    THREADSAFE=1

Microsoft.Data.Sqlite 7.0.2 and SQLitePCLRaw.bundle_e_sqlite3 2.1.0-2.1.4

Compile Options
    ATOMIC_INTRINSICS=1
    COMPILER=clang-13.0.0
    DEFAULT_AUTOVACUUM
    DEFAULT_CACHE_SIZE=-2000
    DEFAULT_FILE_FORMAT=4
    DEFAULT_FOREIGN_KEYS
    DEFAULT_JOURNAL_SIZE_LIMIT=-1
    DEFAULT_MMAP_SIZE=0
    DEFAULT_PAGE_SIZE=4096
    DEFAULT_PCACHE_INITSZ=20
    DEFAULT_RECURSIVE_TRIGGERS
    DEFAULT_SYNCHRONOUS=2
    DEFAULT_SECTOR_SIZE=4096
    DEFAULT_WAL_AUTOCHECKPOINT=1000
    DEFAULT_WAL_SYNCHRONOUS=2
    DEFAULT_WORKER_THREADS=0
    ENABLE_COLUMN_METADATA
    ENABLE_FTS3
    ENABLE_FTS3_PARENTHESIS
    ENABLE_FTS5
    ENABLE_RTREE
    ENABLE_SNAPSHOT
    MALLOC_SOFT_LIMIT=1024
    ENABLE_FTS4
    MAX_ATTACHED=10
    MAX_COLUMN=2000
    MAX_COMPOUND_SELECT=500
    MAX_DEFAULT_PAGE_SIZE=8192
    MAX_EXPR_DEPTH=1000
    MAX_FUNCTION_ARG=127
    MAX_LENGTH=1000000000
    MAX_LIKE_PATTERN_LENGTH=50000
    MAX_MMAP_SIZE=0x7fff0000
    MAX_PAGE_COUNT=1073741823
    MAX_PAGE_SIZE=65536
    MAX_SQL_LENGTH=1000000000
    MAX_TRIGGER_DEPTH=1000
    MAX_VARIABLE_NUMBER=32766
    MAX_VDBE_OP=250000000
    MAX_WORKER_THREADS=8
    MUTEX_PTHREADS
    SYSTEM_MALLOC
    TEMP_STORE=1
    THREADSAFE=1
ericsink commented 1 year ago

Interesting. I didn't change anything JSON-related in the build options.

I just found this:

https://www.sqlite.org/json1.html

which says:

The JSON functions and operators are built into SQLite by default, as of SQLite version 3.38.0 (2022-02-22). They can be omitted by adding the -DSQLITE_OMIT_JSON compile-time option. Prior to version 3.38.0, the JSON functions were an extension that would only be included in builds if the -DSQLITE_ENABLE_JSON1 compile-time option was included. In other words, the JSON functions went from being opt-in with SQLite version 3.37.2 and earlier to opt-out with SQLite version 3.38.0 and later.

which seems relevant.

michaelstonis commented 1 year ago

Awesome. Yea, all of my unit tests started failing because I had a check for ENABLE_JSON1 at launch. I am just going to add a call to select sqlite_version() and evaluate the version. I wonder if there is a way to guarantee that it is available, but probably unnecessary for now.

Great find and thanks for the reply!

michaelstonis commented 1 year ago

Just for reference, pragma_function_list can provide the list of functions and can be used to make a determination from there.

Example select exists(select 1 from pragma_function_list where name='json');