Sqlite-open Symbol’s function definition is void

GNU Emacs 29.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.16.0) of 2024-01-23

Trying to use the sqlite-builtin as the org-roam-database-connector

Installed the emacsql-sqlite-builtin from Melpa
20240119.2314

Then tried to set the variable as described in the manual – but i cant make emacs find the function definition sqlite-open :sob:

supposedly org-roam also has a check to see whether the function exists before setting the variable –

any idea what i am doing wrong ?

What did you do exactly?

I installed emacsql-sqlite-builtin from Melpa the version I mentioned

then simply used (setq org-roam-database-connector 'sqlite-builtin)

Just trying to see if the new db connector would speed anything up or not – but it says cannot find the function definition for sqlite-open

eieio-oset: Symbol’s function definition is void: sqlite-open

the default sqlite works – was just interested to check out the new one.

I can see that in the emacsql-sqlite-builtin.el file it says to look for sqlite-open in sqlite library

;;; Code:

(require 'emacsql)
(require 'emacsql-sqlite-common)

(require 'sqlite nil t)
(declare-function sqlite-open "sqlite")
(declare-function sqlite-select "sqlite")
(declare-function sqlite-close "sqlite")

I used '#locate-library to go to the file location …/lisp/sqlite.el

There is nothing that describes the function

;;; sqlite.el --- Functions for interacting with sqlite3 databases  -*- lexical-binding: t; -*-

;; Copyright (C) 2021-2024 Free Software Foundation, Inc.

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;;

;;; Code:

(declare-function sqlite-transaction "sqlite.c")
(declare-function sqlite-commit "sqlite.c")
(declare-function sqlite-rollback "sqlite.c")

(defmacro with-sqlite-transaction (db &rest body)
  "Execute BODY while holding a transaction for DB.
If BODY completes normally, commit the changes and return
the value of BODY.
If BODY signals an error, or transaction commit fails, roll
back the transaction changes."
  (declare (indent 1) (debug (form body)))
  (let ((db-var (gensym))
        (func-var (gensym))
        (res-var (gensym))
        (commit-var (gensym)))
    `(let ((,db-var ,db)
           (,func-var (lambda () ,@body))
           ,res-var ,commit-var)
       (if (sqlite-available-p)
           (unwind-protect
               (progn
                 (sqlite-transaction ,db-var)
                 (setq ,res-var (funcall ,func-var))
                 (setq ,commit-var (sqlite-commit ,db-var))
                 ,res-var)
             (or ,commit-var (sqlite-rollback ,db-var))))
         (funcall ,func-var))))

(provide 'sqlite)

;;; sqlite.el ends here

Strange …

What’s the value after you evaluate this function?

It’s a function in C. I have the same sqlite.el and I can find sqlite-open function.

Did you build your Emacs from source?

When you did, did you have sqlite dev package in your Linux distro (Debian? something like libsqlite3-dev?) – the flag is automatically on. When you do ./configure, the log output would have noted something about sqlite3, like this:

... [my omission]
  Does Emacs use -lwebp?                                  yes
  Does Emacs use -lsqlite3?                               yes
  Does Emacs use cairo?                                   yes
  Does Emacs use -llcms2?                                 yes
  Does Emacs use imagemagick?                             no
... [my omission]
1 Like

Yes, I did compile it from source – thanks for the pointers – I will try and recompile emacs and see if it solves it and collect more data as to what is going wrong, thanks.

(sqlite-available-p)

Return t if sqlite3 support is available in this instance of Emacs.

Oh and this results in nil

I think something did go wrong during compile time – I have been lazy and copy pasting my entire emacs folder across computers

1. Install the build dependencies for Emacs:

$ sudo apt build-dep emacs
$ sudo apt install libtree-sitter-dev

2. Download and unpack the Emacs archive:

$ wget http://mirrors.nav.ro/gnu/emacs/emacs-29.1.tar.xz
$ tar xvf emacs-29.1.tar.xz

3. Install Emacs in HOME/.local/emacs/:

$ ./autogen.sh
$ ./configure --prefix="$HOME/.local/emacs/" --without-compress-install --with-native-compilation --with-json --with-mailutils --with-tree-sitter CC=gcc-12
$ make -j 4   # Replace the number 4 with the number of cores that your CPU has.
$ make install

These are the install instructions i found somewhere and used…

Thank you so much - recompiling Emacs with the libsqlite3-dev installed from the repo - compiled with sqlite3 enabled and org-roam now defaults to sqlite-builtin.

I needed to install the library in Debian Stable.

You’re the best ))

1 Like