FS#70072 - [sqlite] compile with SQLITE_STMT

Attached to Project: Arch Linux
Opened by Sam Saffron (sam.saffron) - Friday, 19 March 2021, 00:31 GMT
Last edited by Andreas Radke (AndyRTR) - Saturday, 20 March 2021, 10:40 GMT
Task Type Feature Request
Category Packages: Core
Status Closed
Assigned To Andreas Radke (AndyRTR)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

I would like access to the SQLITE_STMT virtual view.

Per: https://www.sqlite.org/stmt.html

We need to compile with SQLITE_ENABLE_STMTVTAB to get access to it.

I don't know if it makes sense or not just to add it to the default flags, if it does not make sense to add to default flags can we make it somehow optional?

Looks like debian/gentoo compile with this so Arch is kind of different.

Clearly I can work around this, but I am concerned about maintaining a long term term replacement in AUR just for this little feature.
This task depends upon

Closed by  Andreas Radke (AndyRTR)
Saturday, 20 March 2021, 10:40 GMT
Reason for closing:  Implemented
Comment by Eli Schwartz (eschwartz) - Friday, 19 March 2021, 02:15 GMT
According to that page, it's only disabled by default in the amalgamation, which we don't use to build.

The /usr/bin/sqlite3 tool successfully runs the example stmt queries for me. Why do you think this is missing?
Comment by Sam Saffron (sam.saffron) - Friday, 19 March 2021, 04:12 GMT
I see, yes the binary works, the issue is that somehow Ruby is having trouble linking correctly as illustrated by this Dockerfile:

```
FROM archlinux

RUN pacman -Syu --noconfirm
RUN pacman -S --noconfirm ruby sqlite
RUN pacman -S --noconfirm base-devel
RUN gem install sqlite3
RUN sqlite3 test.db "SELECT * FROM SQLITE_STMT"
RUN ruby -e "require 'sqlite3'; db = SQLite3::Database.new 'test.db'; db.execute 'select * from SQLITE_STMT'"
```

Once I apply this the issue goes away:

```
--- a/sqlite/trunk/PKGBUILD
+++ b/sqlite/trunk/PKGBUILD
@@ -40,6 +40,7 @@ build() {
-DSQLITE_ENABLE_DBSTAT_VTAB=1 \
-DSQLITE_ENABLE_FTS3_TOKENIZER=1 \
-DSQLITE_SECURE_DELETE \
+ -DSQLITE_ENABLE_STMTVTAB \
-DSQLITE_MAX_VARIABLE_NUMBER=250000 \
-DSQLITE_MAX_EXPR_DEPTH=10000"
```

I guess the default amalgamation is the problem for rubygems
Comment by Sam Saffron (sam.saffron) - Friday, 19 March 2021, 04:20 GMT
Debian is good per:

```
FROM debian

RUN apt-get update
RUN apt-get install -y ruby build-essential
RUN apt-get install -y sqlite libsqlite3-dev
RUN apt-get install -y ruby-dev
RUN gem install sqlite3-ruby
RUN sqlite3 test.db "SELECT * FROM SQLITE_STMT"
RUN ruby -e "require 'sqlite3'; db = SQLite3::Database.new 'test.db'; db.execute 'select * from SQLITE_STMT'"
```
Comment by Eli Schwartz (eschwartz) - Friday, 19 March 2021, 04:26 GMT
"the amalgamation" is source code intended for including in a project as sqlite3.o rather than downloading the standard source code with the standard 'make install' infrastructure, compiling a system libsqlite3.so, and linking to it later on. It's not relevant here.

ruby-sqlite3 links to core/sqlite

$ pkg-list-linked-libraries ruby-sqlite3 libsql
==> checking linked libraries for ruby-sqlite3-1.4.2-2-x86_64.pkg.tar.xz ...
usr/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/sqlite3-1.4.2/sqlite3/sqlite3_native.so
NEEDED libsqlite3.so.0

$ sudo pacman -S ruby-sqlite3 && ruby -e "require 'sqlite3'; db = SQLite3::Database.new 'test.db'; db.execute 'select * from SQLITE_STMT'"
/usr/lib/ruby/gems/2.7.0/gems/sqlite3-1.4.2/lib/sqlite3/database.rb:147:in `initialize': no such table: SQLITE_STMT (SQLite3::SQLException)


So, the implication is that libsqlite3 does not enable SQLITE_STMT, only the CLI tool does... that's interesting.
Comment by Andreas Radke (AndyRTR) - Friday, 19 March 2021, 14:48 GMT
Please try 3.35.2-2 from testing repo.
Comment by Sam Saffron (sam.saffron) - Saturday, 20 March 2021, 00:36 GMT
Confirming `3.35.2-2` looks good to me! Thanks!

Loading...