├── tools ├── sqlite_h.sh ├── Makefile ├── test.sh ├── README.org ├── gen-consts.py └── gen-consts.sh ├── .gitignore ├── Eldev ├── tests ├── Makefile ├── consts.el └── regression.el ├── Makefile ├── .github └── workflows │ └── test.yml ├── sqlite3.el ├── emacs-module.h ├── README.org ├── sqlite3-api.c ├── LICENSE └── consts.c /tools/sqlite_h.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo '#include ' | gcc $* -x c -H -fsyntax-only - 2>&1 | grep '^\. ' | cut -f2 -d' ' 3 | -------------------------------------------------------------------------------- /tools/Makefile: -------------------------------------------------------------------------------- 1 | # Grab SQLITE_* from sqlite.h 2 | # Requires pandoc and python3 3 | 4 | # generate consts.c based on the latest version of sqlite3 5 | homebrew: 6 | ./gen-consts.sh -I/usr/local/opt/sqlite3/include > ../consts.c 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.so 3 | *.dll 4 | **/.DS_Store 5 | sqlite3-napi-module-with-create-function.c 6 | xxx.el 7 | **/sqlite3-api-* 8 | 9 | *~ 10 | **/sqlite3-*# Added automatically by `eldev init'. 11 | /.eldev 12 | /Eldev-local 13 | -------------------------------------------------------------------------------- /Eldev: -------------------------------------------------------------------------------- 1 | ; -*- mode: emacs-lisp; lexical-binding: t -*- 2 | 3 | (setf eldev-project-source-dirs ".") 4 | (setf eldev-files-to-package 5 | `(:or ,eldev-files-to-package 6 | '("./Makefile" "./consts.c" "./emacs-module.h" "./sqlite3-api.c"))) 7 | -------------------------------------------------------------------------------- /tools/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # run tests with different versions of Emacs 4 | make EMACS="/Applications/Emacs\ 25-3.app/Contents/MacOS/Emacs" test 5 | make EMACS="/Applications/Emacs\ 26-3.app/Contents/MacOS/Emacs" test 6 | make EMACS=/usr/local/bin/emacs test # 27.1 7 | -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | EMACS282=$(HOME)/Emacs/dists/28.2/bin/emacs 2 | EMACS281=$(HOME)/Emacs/dists/28.1/bin/emacs 3 | EMACS272=$(HOME)/Emacs/dists/27.2/bin/emacs 4 | 5 | test: 6 | $(EMACS282) -batch -Q -L .. -l regression.el 7 | $(EMACS281) -batch -Q -L .. -l regression.el 8 | $(EMACS272) -batch -Q -L .. -l regression.el 9 | 10 | #test-consts: 11 | # $(EMACS) -l tests/consts.el 12 | -------------------------------------------------------------------------------- /tools/README.org: -------------------------------------------------------------------------------- 1 | #+OPTIONS: ^:nil 2 | * Notes to self 3 | 4 | Run ~make~ to generate ~consts.c~ with the Homebrew (latest) version of 5 | ~sqlite3.h~ on Mac. 6 | 7 | Requires ~curl~, Pandoc and Python 3. 8 | 9 | Not everything in ~sqlite3.h~ is required by the Emacs module. The codes listed 10 | below are filtered out. 11 | 12 | - ~SQLITE_TRANSIENT~ 13 | - ~SQLITE_STATIC~ 14 | - ~SQLITE_SCANSTAT_*~ 15 | - Anything not present on https://sqlite.org/c3ref/constlist.html 16 | 17 | Definitions in ~consts.c~ are guarded by ~#ifdef~ in case the local installation 18 | of (older) SQLite doesn't have them defined. E.g. 19 | 20 | #+BEGIN_SRC c :eval no :exports code 21 | #ifdef SQLITE_NOTADB 22 | defconst(env, "sqlite-notadb", env->make_integer(env, SQLITE_NOTADB)); 23 | #endif 24 | #+END_SRC 25 | 26 | Regenerate ~consts.c~ whenever a new version is SQLite is available. 27 | -------------------------------------------------------------------------------- /tools/gen-consts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | import os 5 | import re 6 | 7 | useful_codes = [] 8 | with open(sys.argv[1]) as f: 9 | for l in f.readlines(): 10 | useful_codes.append(l.rstrip()) 11 | 12 | # Read from sqlite3.h (from stdin) 13 | # only codes that exist in useful_codes are included in consts.c 14 | for line in sys.stdin.readlines(): 15 | # fields = [ "#define", "SQLITE_XXXX" "YYYY" ]; 16 | fields = re.split("\s+", line.rstrip(), 3) 17 | 18 | #print("{0}".format(fields[1])) 19 | if not fields[1] in useful_codes: 20 | #print("{0} excluded".format(fields[1])) 21 | continue 22 | 23 | sym = re.sub("_", "-", fields[1].lower()) 24 | if len(fields) > 2 and fields[2] != "": 25 | print("#ifdef {0}".format(fields[1])) 26 | if fields[2].startswith('"'): 27 | print('defconst(env, "{0}", env->make_string(env, {1}, strlen({1})));'.format(sym, fields[1])) 28 | else: 29 | print('defconst(env, "{0}", env->make_integer(env, {1}));'.format(sym, fields[1])) 30 | print("#endif") 31 | -------------------------------------------------------------------------------- /tests/consts.el: -------------------------------------------------------------------------------- 1 | ;; -*- lexical-binding: t -*- 2 | 3 | ;; This program is free software: you can redistribute it and/or modify 4 | ;; it under the terms of the GNU General Public License as published by 5 | ;; the Free Software Foundation, either version 3 of the License, or 6 | ;; (at your option) any later version. 7 | ;; 8 | ;; This program is distributed in the hope that it will be useful, 9 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | ;; GNU General Public License for more details. 12 | ;; 13 | ;; You should have received a copy of the GNU General Public License 14 | ;; along with this program. If not, see . 15 | ;; 16 | 17 | (require 'sqlite3) 18 | (require 'cl) 19 | 20 | 21 | (ert-deftest sqlite3-test-consts () 22 | (message "Tests:consts") 23 | (let ((vl (version-to-list sqlite-version))) 24 | ;; should pass the test 25 | (should (boundp 'sqlite-ok)) 26 | (if (version-list-<= vl '(3 28)) 27 | ;; older versions (3.28) doesn't have it defined 28 | (should-not (boundp 'sqlite-ioerr-data)) 29 | (should (boundp 'sqlite-ioerr-data))))) 30 | 31 | (sqlite3-set-log-level 3) 32 | (ert "^sqlite3-test") 33 | (garbage-collect) 34 | -------------------------------------------------------------------------------- /tools/gen-consts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR=$(dirname $0) 3 | NOW=$(date '+%Y-%m-%d %H:%M:%S') 4 | URL=https://sqlite.org/c3ref/constlist.html 5 | SQLITE3_H=$(echo '#include ' | gcc $* -x c -H -fsyntax-only - 2>&1 | grep '^\. ' | cut -f2 -d' ') 6 | MASTER=master.txt 7 | 8 | cat<. 22 | */ 23 | 24 | /* 25 | Auto-generated $NOW 26 | Based on $URL 27 | */ 28 | 29 | EOF 30 | 31 | curl -s $URL | pandoc -t html -t plain | grep "^SQLITE_" | grep -v SCANSTAT | grep -v SQLITE_STATIC | grep -v SQLITE_TRANSIENT > $DIR/$MASTER 32 | grep '^#define SQLITE_' $SQLITE3_H | $DIR/gen-consts.py $DIR/$MASTER 33 | rm -f $DIR/$MASTER 34 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | INC ?= -I. 3 | LIB ?= -lsqlite3 4 | 5 | ifeq ($(HOMEBREW), 1) 6 | PREFIX=$(shell brew --prefix sqlite) 7 | INC=-I$(PREFIX)/include 8 | LIB=-L$(PREFIX)/lib -lsqlite3 9 | endif 10 | 11 | CFLAGS ?= -g3 -Wall -std=c99 $(INC) 12 | 13 | EMACS ?= $(shell which emacs) 14 | 15 | UNAME_O=$(shell uname -o) 16 | ifeq ($(UNAME_O),Cygwin) 17 | SHLIB_EXTENSION=dll 18 | else ifeq ($(UNAME_O),Msys) 19 | SHLIB_EXTENSION=dll 20 | else 21 | SHLIB_EXTENSION=so 22 | endif 23 | 24 | # Melpa package 25 | PKG=sqlite3 26 | 27 | # dynamic module package 28 | MODULE=$(PKG) 29 | MODULE_VERSION=0.16 30 | MODULE_BASENAME=$(MODULE)-$(MODULE_VERSION) 31 | MODULE_PKG_EL=$(MODULE_BASENAME)/$(MODULE)-pkg.el 32 | MODULE_TAR=$(MODULE_BASENAME).tar 33 | 34 | all: $(MODULE)-api.$(SHLIB_EXTENSION) 35 | 36 | clean: 37 | rm -rf *.$(SHLIB_EXTENSION) *.o *.tar $(MODULE_BASENAME) 38 | 39 | # File "MODULE" is read by (sqlite3-api-install-dynamic-module) 40 | # during installation 41 | module: $(MODULE)-api.$(SHLIB_EXTENSION) 42 | mkdir -p $(MODULE_BASENAME) 43 | cp $(MODULE).el $(MODULE)-api.$(SHLIB_EXTENSION) $(MODULE_BASENAME) 44 | echo "(define-package \"$(MODULE)\" \"$(MODULE_VERSION)\" \"SQLite3 API dynamic module\")" > $(MODULE_PKG_EL) 45 | tar cvf $(MODULE_TAR) $(MODULE_BASENAME) 46 | 47 | install: module 48 | emacsclient -e '(package-install-file "$(MODULE_TAR)")' 49 | 50 | %.$(SHLIB_EXTENSION): %.o 51 | $(CC) -shared -o $@ $< $(LIB) 52 | 53 | %.o: %.c 54 | $(CC) $(CFLAGS) -fPIC -c $< 55 | 56 | # Regression test 57 | test: 58 | $(EMACS) -batch -Q -L . -l tests/regression.el 59 | 60 | test-consts: 61 | $(EMACS) -batch -Q -L . -l tests/consts.el 62 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | test: 14 | # Run the tests for all OSs and EMACS_VERSIONs. 15 | runs-on: ${{matrix.os}} 16 | 17 | strategy: 18 | matrix: 19 | os: [macos-latest, ubuntu-latest, windows-latest] 20 | emacs_version: ['28.2', '29.1'] 21 | 22 | steps: 23 | - name: Setup dev env (MS-Windows) 24 | uses: msys2/setup-msys2@v2 25 | if: startsWith (matrix.os, 'windows') 26 | with: 27 | msystem: MINGW64 28 | location: D:\ 29 | pacboy: >- 30 | gcc:p sqlite3:p 31 | 32 | - name: Set up Emacs 33 | if: "!startsWith (matrix.os, 'windows')" 34 | uses: purcell/setup-emacs@master 35 | with: 36 | version: ${{matrix.emacs_version}} 37 | 38 | - name: Set up Emacs (MS-Windows) 39 | if: startsWith (matrix.os, 'windows') 40 | uses: jcs090218/setup-emacs-windows@master 41 | with: 42 | version: ${{matrix.emacs_version}} 43 | 44 | - name: Install Eldev 45 | if: "!startsWith (matrix.os, 'windows')" 46 | run: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/github-eldev | sh 47 | 48 | - name: Install Eldev (MS-Windows) 49 | if: startsWith (matrix.os, 'windows') 50 | run: | 51 | # Remove expired DST Root CA X3 certificate. Workaround 52 | # for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=51038 53 | # bug on Emacs 27.2. 54 | gci cert:\LocalMachine\Root\DAC9024F54D8F6DF94935FB1732638CA6AD77C13 55 | gci cert:\LocalMachine\Root\DAC9024F54D8F6DF94935FB1732638CA6AD77C13 | Remove-Item 56 | 57 | curl.exe -fsSL https://raw.github.com/doublep/eldev/master/webinstall/github-eldev.bat | cmd /Q 58 | 59 | - name: Check out the source code 60 | uses: actions/checkout@v3 61 | 62 | - name: Test 63 | if: "!startsWith (matrix.os, 'windows')" 64 | env: 65 | # purcell/setup-emacs releases are built with nix and as such 66 | # we need to build the api with nix for binary compatibility. 67 | SQLITE3_API_BUILD_COMMAND: "nix-shell -p sqlite.dev --run \"make all\"" 68 | run: | 69 | eldev -p -dtTC test 70 | 71 | - name: Test (MS-Windows) 72 | if: startsWith (matrix.os, 'windows') 73 | run: | 74 | # Update PATH to include first to the new msys2 dev 75 | # environment. 76 | $env:Path = "D:\msys64\mingw64\bin;" + $env:Path 77 | # 78 | eldev -p -dtTC test 79 | -------------------------------------------------------------------------------- /sqlite3.el: -------------------------------------------------------------------------------- 1 | ;;; sqlite3.el --- Direct access to the core SQLite3 API -*- lexical-binding: t -*- 2 | 3 | ;; Copyright (C) 2018-2023 Y. N. Lo 4 | 5 | ;; Author: Y. N. Lo 6 | ;; Homepage: https://github.com/pekingduck/emacs-sqlite3-api 7 | ;; Keywords: comm, data, sql 8 | ;; Version: 0.17 9 | ;; Package-Requires: ((emacs "25.1")) 10 | 11 | ;; This file is not part of GNU Emacs. 12 | 13 | ;; This file is free software; you can redistribute it and/or modify 14 | ;; it under the terms of the GNU General Public License as published by 15 | ;; the Free Software Foundation; either version 3, or (at your option) 16 | ;; any later version. 17 | 18 | ;; This file is distributed in the hope that it will be useful, 19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | ;; GNU General Public License for more details. 22 | 23 | ;; For a full copy of the GNU General Public License 24 | ;; see . 25 | 26 | ;;; Commentary: 27 | 28 | ;; `sqlite3-api' is a dynamic module for GNU Emacs 25+ that provides 29 | ;; direct access to the core SQLite3 C API from Emacs Lisp. 30 | 31 | ;;; Code: 32 | 33 | (require 'cl-lib) 34 | 35 | (defvar sqlite3-api-build-command (or (getenv "SQLITE3_API_BUILD_COMMAND") 36 | "make all") 37 | "String containing the build command for the sqlite3-api module. 38 | 39 | It defaults to \"make all\". It can be overriden by 40 | setting the SQLITE3_API_BUILD_COMMAND environment variable.") 41 | 42 | (cl-eval-when (load eval) 43 | (unless (require 'sqlite3-api nil t) 44 | (if (or noninteractive 45 | (yes-or-no-p "sqlite3-api module must be built. Do so now? ")) 46 | (let ((default-directory (file-name-directory (or load-file-name 47 | buffer-file-name)))) 48 | (message "Building sqlite3-api module with %S" sqlite3-api-build-command) 49 | (with-temp-buffer 50 | (unless (zerop (call-process-shell-command 51 | sqlite3-api-build-command nil t t)) 52 | (error "Failed to compile module using: %s: %s" 53 | sqlite3-api-build-command 54 | (buffer-substring-no-properties 55 | (point-min) 56 | (point-max))))) 57 | (message "Loading sqlite3-api module...") 58 | (require 'sqlite3-api)) 59 | (user-error "Abort")))) 60 | 61 | (provide 'sqlite3) 62 | ;; Local Variables: 63 | ;; indent-tabs-mode: nil 64 | ;; End: 65 | ;;; sqlite3.el ends here 66 | -------------------------------------------------------------------------------- /emacs-module.h: -------------------------------------------------------------------------------- 1 | /* emacs-module.h - GNU Emacs module API. 2 | 3 | Copyright (C) 2015-2017 Free Software Foundation, Inc. 4 | 5 | This file is part of GNU Emacs. 6 | 7 | GNU Emacs is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or (at 10 | your option) any later version. 11 | 12 | GNU Emacs is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with GNU Emacs. If not, see . */ 19 | 20 | #ifndef EMACS_MODULE_H 21 | #define EMACS_MODULE_H 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #if defined __cplusplus && __cplusplus >= 201103L 28 | # define EMACS_NOEXCEPT noexcept 29 | #else 30 | # define EMACS_NOEXCEPT 31 | #endif 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Current environment. */ 38 | typedef struct emacs_env_25 emacs_env; 39 | 40 | /* Opaque pointer representing an Emacs Lisp value. 41 | BEWARE: Do not assume NULL is a valid value! */ 42 | typedef struct emacs_value_tag *emacs_value; 43 | 44 | enum emacs_arity { emacs_variadic_function = -2 }; 45 | 46 | /* Struct passed to a module init function (emacs_module_init). */ 47 | struct emacs_runtime 48 | { 49 | /* Structure size (for version checking). */ 50 | ptrdiff_t size; 51 | 52 | /* Private data; users should not touch this. */ 53 | struct emacs_runtime_private *private_members; 54 | 55 | /* Return an environment pointer. */ 56 | emacs_env *(*get_environment) (struct emacs_runtime *ert); 57 | }; 58 | 59 | 60 | /* Function prototype for the module init function. */ 61 | typedef int (*emacs_init_function) (struct emacs_runtime *ert); 62 | 63 | /* Function prototype for the module Lisp functions. */ 64 | typedef emacs_value (*emacs_subr) (emacs_env *env, ptrdiff_t nargs, 65 | emacs_value args[], void *data); 66 | 67 | /* Possible Emacs function call outcomes. */ 68 | enum emacs_funcall_exit 69 | { 70 | /* Function has returned normally. */ 71 | emacs_funcall_exit_return = 0, 72 | 73 | /* Function has signaled an error using `signal'. */ 74 | emacs_funcall_exit_signal = 1, 75 | 76 | /* Function has exit using `throw'. */ 77 | emacs_funcall_exit_throw = 2, 78 | }; 79 | 80 | struct emacs_env_25 81 | { 82 | /* Structure size (for version checking). */ 83 | ptrdiff_t size; 84 | 85 | /* Private data; users should not touch this. */ 86 | struct emacs_env_private *private_members; 87 | 88 | /* Memory management. */ 89 | 90 | emacs_value (*make_global_ref) (emacs_env *env, 91 | emacs_value any_reference); 92 | 93 | void (*free_global_ref) (emacs_env *env, 94 | emacs_value global_reference); 95 | 96 | /* Non-local exit handling. */ 97 | 98 | enum emacs_funcall_exit (*non_local_exit_check) (emacs_env *env); 99 | 100 | void (*non_local_exit_clear) (emacs_env *env); 101 | 102 | enum emacs_funcall_exit (*non_local_exit_get) 103 | (emacs_env *env, 104 | emacs_value *non_local_exit_symbol_out, 105 | emacs_value *non_local_exit_data_out); 106 | 107 | void (*non_local_exit_signal) (emacs_env *env, 108 | emacs_value non_local_exit_symbol, 109 | emacs_value non_local_exit_data); 110 | 111 | void (*non_local_exit_throw) (emacs_env *env, 112 | emacs_value tag, 113 | emacs_value value); 114 | 115 | /* Function registration. */ 116 | 117 | emacs_value (*make_function) (emacs_env *env, 118 | ptrdiff_t min_arity, 119 | ptrdiff_t max_arity, 120 | emacs_value (*function) (emacs_env *env, 121 | ptrdiff_t nargs, 122 | emacs_value args[], 123 | void *) 124 | EMACS_NOEXCEPT, 125 | const char *documentation, 126 | void *data); 127 | 128 | emacs_value (*funcall) (emacs_env *env, 129 | emacs_value function, 130 | ptrdiff_t nargs, 131 | emacs_value args[]); 132 | 133 | emacs_value (*intern) (emacs_env *env, 134 | const char *symbol_name); 135 | 136 | /* Type conversion. */ 137 | 138 | emacs_value (*type_of) (emacs_env *env, 139 | emacs_value value); 140 | 141 | bool (*is_not_nil) (emacs_env *env, emacs_value value); 142 | 143 | bool (*eq) (emacs_env *env, emacs_value a, emacs_value b); 144 | 145 | intmax_t (*extract_integer) (emacs_env *env, emacs_value value); 146 | 147 | emacs_value (*make_integer) (emacs_env *env, intmax_t value); 148 | 149 | double (*extract_float) (emacs_env *env, emacs_value value); 150 | 151 | emacs_value (*make_float) (emacs_env *env, double value); 152 | 153 | /* Copy the content of the Lisp string VALUE to BUFFER as an utf8 154 | null-terminated string. 155 | 156 | SIZE must point to the total size of the buffer. If BUFFER is 157 | NULL or if SIZE is not big enough, write the required buffer size 158 | to SIZE and return false. 159 | 160 | Note that SIZE must include the last null byte (e.g. "abc" needs 161 | a buffer of size 4). 162 | 163 | Return true if the string was successfully copied. */ 164 | 165 | bool (*copy_string_contents) (emacs_env *env, 166 | emacs_value value, 167 | char *buffer, 168 | ptrdiff_t *size_inout); 169 | 170 | /* Create a Lisp string from a utf8 encoded string. */ 171 | emacs_value (*make_string) (emacs_env *env, 172 | const char *contents, ptrdiff_t length); 173 | 174 | /* Embedded pointer type. */ 175 | emacs_value (*make_user_ptr) (emacs_env *env, 176 | void (*fin) (void *) EMACS_NOEXCEPT, 177 | void *ptr); 178 | 179 | void *(*get_user_ptr) (emacs_env *env, emacs_value uptr); 180 | void (*set_user_ptr) (emacs_env *env, emacs_value uptr, void *ptr); 181 | 182 | void (*(*get_user_finalizer) (emacs_env *env, emacs_value uptr)) 183 | (void *) EMACS_NOEXCEPT; 184 | void (*set_user_finalizer) (emacs_env *env, 185 | emacs_value uptr, 186 | void (*fin) (void *) EMACS_NOEXCEPT); 187 | 188 | /* Vector functions. */ 189 | emacs_value (*vec_get) (emacs_env *env, emacs_value vec, ptrdiff_t i); 190 | 191 | void (*vec_set) (emacs_env *env, emacs_value vec, ptrdiff_t i, 192 | emacs_value val); 193 | 194 | ptrdiff_t (*vec_size) (emacs_env *env, emacs_value vec); 195 | }; 196 | 197 | /* Every module should define a function as follows. */ 198 | extern int emacs_module_init (struct emacs_runtime *ert); 199 | 200 | #ifdef __cplusplus 201 | } 202 | #endif 203 | 204 | #endif /* EMACS_MODULE_H */ 205 | -------------------------------------------------------------------------------- /tests/regression.el: -------------------------------------------------------------------------------- 1 | ;; -*- lexical-binding: t -*- 2 | 3 | ;; This program is free software: you can redistribute it and/or modify 4 | ;; it under the terms of the GNU General Public License as published by 5 | ;; the Free Software Foundation, either version 3 of the License, or 6 | ;; (at your option) any later version. 7 | ;; 8 | ;; This program is distributed in the hope that it will be useful, 9 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | ;; GNU General Public License for more details. 12 | ;; 13 | ;; You should have received a copy of the GNU General Public License 14 | ;; along with this program. If not, see . 15 | ;; 16 | 17 | (require 'sqlite3) 18 | (require 'cl-lib) 19 | 20 | (ert-deftest sqlite3-test-create-db () 21 | (let ((db-file (make-temp-file "sqlite3")) 22 | dbh 23 | stmt) 24 | (message "Test:create-db") 25 | (unwind-protect 26 | (progn 27 | (setq dbh (sqlite3-open db-file 28 | sqlite-open-create 29 | sqlite-open-readwrite)) 30 | (should (= sqlite-ok 31 | (sqlite3-exec dbh "create table temp ( id integer primary key autoincrement )"))) 32 | (should (= sqlite-ok 33 | (sqlite3-exec dbh "insert into temp values (NULL)"))) 34 | (setq stmt (sqlite3-prepare dbh "select count(*) from temp")) 35 | (should (= sqlite-row (sqlite3-step stmt))) 36 | (should (= 1 (sqlite3-column-count stmt))) 37 | (should (= 1 (sqlite3-column-int64 stmt 0)))) 38 | (sqlite3-finalize stmt) 39 | (sqlite3-close dbh) 40 | (delete-file db-file)))) 41 | 42 | (ert-deftest sqlite3-test-memory-db () 43 | (let* ((dbh (sqlite3-open ":memory:" sqlite-open-create sqlite-open-readwrite)) 44 | stmt) 45 | (message "Test:memory-db") 46 | (unwind-protect 47 | (progn 48 | (should (= sqlite-ok 49 | (sqlite3-exec dbh "create table temp ( id integer primary key autoincrement )"))) 50 | (should (= sqlite-ok 51 | (sqlite3-exec dbh "insert into temp values (NULL)"))) 52 | (setq stmt (sqlite3-prepare dbh "select count(*) from temp")) 53 | (should (= sqlite-row (sqlite3-step stmt))) 54 | (should (= 1 (sqlite3-column-count stmt))) 55 | (should (= 1 (sqlite3-column-int64 stmt 0)))) 56 | (sqlite3-finalize stmt) 57 | (sqlite3-close dbh)))) 58 | 59 | 60 | (ert-deftest sqlite3-test-temp-db () 61 | (let (dbh stmt) 62 | (message "Test:temp-db") 63 | (unwind-protect 64 | (progn 65 | (setq dbh (sqlite3-open "" sqlite-open-create sqlite-open-readwrite)) 66 | (should (= sqlite-ok 67 | (sqlite3-exec dbh "create table test ( id integer primary key autoincrement )"))) 68 | (should (= sqlite-ok 69 | (sqlite3-exec dbh "insert into test values (NULL)"))) 70 | (setq stmt (sqlite3-prepare dbh "select count(*) from test")) 71 | (should (= sqlite-row (sqlite3-step stmt))) 72 | (should (= 1 (sqlite3-column-count stmt))) 73 | (should (= 1 (sqlite3-column-int64 stmt 0)))) 74 | (sqlite3-finalize stmt) 75 | (sqlite3-close dbh)))) 76 | 77 | (ert-deftest sqlite3-test-bulk-ops () 78 | (let (dbh stmt) 79 | (message "Test:bulk-ops") 80 | (unwind-protect 81 | (progn 82 | (setq dbh (sqlite3-open "" sqlite-open-readwrite sqlite-open-create)) 83 | (should (= sqlite-ok (sqlite3-exec dbh "create table test ( id integer primary key autoincrement, rand integer not null )"))) 84 | (should (setq stmt (sqlite3-prepare dbh "insert into test values (?, ?)"))) 85 | (should (= 2 (sqlite3-bind-parameter-count stmt))) 86 | (sqlite3-exec dbh "begin") 87 | (cl-loop for i from 1 to 100000 do 88 | (should (= sqlite-ok (sqlite3-bind-null stmt 1))) 89 | (should (= sqlite-ok (sqlite3-bind-int64 stmt 2 (random)))) 90 | (should (= sqlite-done (sqlite3-step stmt))) 91 | (should (= sqlite-ok (sqlite3-reset stmt)))) 92 | (should (= 100000 (sqlite3-last-insert-rowid dbh))) 93 | (should (= sqlite-ok (sqlite3-exec dbh "update test set rand = 0"))) 94 | (should (= 0 (sqlite3-get-autocommit dbh))) 95 | (should (= 100000 (sqlite3-changes dbh))) 96 | (should (= sqlite-ok (sqlite3-exec dbh "delete from test where id > 5000"))) 97 | (should (= 95000 (sqlite3-changes dbh))) 98 | (sqlite3-exec dbh "commit")) 99 | (sqlite3-finalize stmt)) 100 | (sqlite3-close dbh))) 101 | 102 | (ert-deftest sqlite3-test-datatypes () 103 | (let ((dbh) 104 | (stmt) 105 | (most-pos-double (ldexp 0.9999999999999999 1024)) 106 | (most-neg-double (ldexp 0.5 -1021)) 107 | (big-str (make-string 10000000 ?1)) 108 | (utf8-str "一二三四五六七")) 109 | (message "Test:datatypes") 110 | (unwind-protect 111 | (progn 112 | (setq dbh (sqlite3-open "" sqlite-open-readwrite sqlite-open-create)) 113 | (should (= sqlite-ok (sqlite3-exec dbh "create table temp (pos_int integer, neg_int integer, pos_flt real, neg_flt real, big_str text, utf8_str text, more_text text)"))) 114 | (should (setq stmt (sqlite3-prepare dbh "insert into temp values (?,?,?,?,?,?,?)"))) 115 | (should (= sqlite-ok (sqlite3-bind-int64 stmt 1 most-positive-fixnum))) 116 | (should (= sqlite-ok (sqlite3-bind-int64 stmt 2 most-negative-fixnum))) 117 | (should (= sqlite-ok (sqlite3-bind-double stmt 3 most-pos-double))) 118 | (should (= sqlite-ok (sqlite3-bind-double stmt 4 most-neg-double))) 119 | (should (= sqlite-ok (sqlite3-bind-text stmt 5 big-str))) 120 | (should (= sqlite-ok (sqlite3-bind-text stmt 6 utf8-str))) 121 | (should (= sqlite-ok (sqlite3-bind-null stmt 7))) 122 | (should (= sqlite-done (sqlite3-step stmt))) 123 | (sqlite3-finalize stmt) 124 | (should (setq stmt (sqlite3-prepare dbh "select * from temp"))) 125 | (should (= sqlite-row (sqlite3-step stmt))) 126 | (should (= most-positive-fixnum (sqlite3-column-int64 stmt 0))) 127 | (should (= most-negative-fixnum (sqlite3-column-int64 stmt 1))) 128 | (should (= most-pos-double (sqlite3-column-double stmt 2))) 129 | (should (= most-neg-double (sqlite3-column-double stmt 3))) 130 | (should (string= big-str (sqlite3-column-text stmt 4))) 131 | (should (string= utf8-str (sqlite3-column-text stmt 5))) 132 | (should (= sqlite-null (sqlite3-column-type stmt 6)))) 133 | (sqlite3-finalize stmt) 134 | (sqlite3-close dbh)))) 135 | 136 | (ert-deftest sqlite3-test-bind-multi () 137 | (let ((times 1000) 138 | (count 1) 139 | stmt dbh) 140 | (message "Test:bind-multi") 141 | (unwind-protect 142 | (progn 143 | (setq dbh (sqlite3-open ":memory:" 144 | sqlite-open-readwrite 145 | sqlite-open-create)) 146 | (sqlite3-exec dbh "create table temp (name text, age integer, iq real, ting text)") 147 | (setq stmt (sqlite3-prepare dbh "insert into temp values (?,?,?,?)")) 148 | (cl-loop for i from 1 to times do 149 | (should (= sqlite-ok 150 | (sqlite3-bind-multi stmt (format "name%d" i) i 123.4567 nil))) 151 | (sqlite3-step stmt) 152 | (sqlite3-reset stmt)) 153 | (sqlite3-finalize stmt) 154 | 155 | (setq stmt (sqlite3-prepare dbh "select * from temp")) 156 | (while (= sqlite-row (sqlite3-step stmt)) 157 | (cl-destructuring-bind (name age iq thing) (sqlite3-fetch stmt) 158 | (should (and (string= name (format "name%d" count)) 159 | (equal age count) 160 | (equal iq 123.4567) 161 | (null thing)))) 162 | (setq count (1+ count)))) 163 | (sqlite3-finalize stmt) 164 | (sqlite3-close dbh)))) 165 | 166 | (sqlite3-set-log-level 3) 167 | (message "************************* Emacs %s *************************" 168 | emacs-version) 169 | (ert "^sqlite3-test") 170 | (garbage-collect) 171 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | #+OPTIONS: ^:nil 2 | * SQLite3 API for Emacs 25+ 3 | ** Introduction 4 | ~sqlite3~ is a dynamic module for GNU Emacs 25+ that provides 5 | direct access to the core SQLite3 C API from Emacs Lisp. 6 | #+BEGIN_SRC emacs-lisp :eval no :exports code 7 | (require 'sqlite3) 8 | 9 | (setq dbh (sqlite3-open "person.sqlite3" sqlite-open-readwrite sqlite-open-create)) 10 | (sqlite3-exec dbh "create table temp (name text, age integer)") 11 | (setq stmt (sqlite3-prepare dbh "insert into temp values (?,?)")) 12 | (cl-loop for i from 1 to 10 do 13 | (sqlite3-bind-multi stmt (format "name%d" i) i) 14 | ;; execute the SQL 15 | (sqlite3-step stmt) 16 | ;; call reset if you want to bind the SQL to a new set of variables 17 | (sqlite3-reset stmt)) 18 | (sqlite3-finalize stmt) 19 | 20 | (setq stmt (sqlite3-prepare dbh "select * from temp")) 21 | (while (= sqlite-row (sqlite3-step stmt)) 22 | (cl-destructuring-bind (name age) (sqlite3-fetch stmt) 23 | (message "name: %s, age: %d" name age))) 24 | (sqlite3-finalize stmt) 25 | (sqlite3-close dbh) 26 | #+END_SRC 27 | 28 | While this module provides only 14 functions (vs [[https://sqlite.org/c3ref/funclist.html][200+ in the C API]]), it should satisfy most 29 | users' needs. 30 | 31 | The current version is v0.18. 32 | 33 | This is an alpha release so it might crash your Emacs. Save your work before you try it out! 34 | 35 | ** Table of Contents 36 | :PROPERTIES: 37 | :TOC: :include all :depth 4 :ignore (this) 38 | :END: 39 | 40 | # M-x org-make-toc to update the TOC 41 | # Requires https://github.com/alphapapa/org-make-toc 42 | :CONTENTS: 43 | - [[#sqlite3-api-for-emacs-25][SQLite3 API for Emacs 25+]] 44 | - [[#introduction][Introduction]] 45 | - [[#requirements][Requirements]] 46 | - [[#installation--removal][Installation & Removal]] 47 | - [[#melpa][Melpa]] 48 | - [[#elpa][Elpa]] 49 | - [[#straightel][Straight.el]] 50 | - [[#manual-installation][Manual Installation]] 51 | - [[#removal][Removal]] 52 | - [[#note-on-package-update][Note on Package Update]] 53 | - [[#testing][Testing]] 54 | - [[#api][API]] 55 | - [[#sqlite3-open][sqlite3-open]] 56 | - [[#sqlite3-close][sqlite3-close]] 57 | - [[#sqlite3-prepare][sqlite3-prepare]] 58 | - [[#sqlite3-finalize][sqlite3-finalize]] 59 | - [[#sqlite3-step][sqlite3-step]] 60 | - [[#sqlite3-changes][sqlite3-changes]] 61 | - [[#sqlite3-reset][sqlite3-reset]] 62 | - [[#sqlite3-last-insert-rowid][sqlite3-last-insert-rowid]] 63 | - [[#sqlite3-get-autocommit][sqlite3-get-autocommit]] 64 | - [[#sqlite3-exec][sqlite3-exec]] 65 | - [[#sqlite3-bind-][sqlite3-bind-*]] 66 | - [[#sqlite3-bind-multi][sqlite3-bind-multi]] 67 | - [[#sqlite3-column-][sqlite3-column-*]] 68 | - [[#sqlite3-fetch][sqlite3-fetch]] 69 | - [[#sqlite3-fetch-alist][sqlite3-fetch-alist]] 70 | - [[#transaction-support][Transaction Support]] 71 | - [[#error-handling][Error Handling]] 72 | - [[#note-on-garbage-collection][Note on Garbage Collection]] 73 | - [[#known-problems][Known Problems]] 74 | - [[#license][License]] 75 | - [[#contributors][Contributors]] 76 | - [[#changelog][Changelog]] 77 | - [[#useful-links-for-writing-dynamic-modules][Useful Links for Writing Dynamic Modules]] 78 | :END: 79 | 80 | ** Requirements 81 | - Emacs 25.1 or above, compiled with module support (~./configure 82 | --with-modules~). Emacs 27.1 supports dynamic modules by default unless you 83 | explicitly disable it. 84 | - SQLite3 v3.16.0 or above. Older versions might work but I have not personally tested those. 85 | - A C99 compiler 86 | 87 | It's been tested on macOS (Catalina), CentOS 7 and MS-Windows 11. 88 | 89 | ** Installation & Removal 90 | *** Melpa 91 | The package is available on [[https://melpa.org/#/sqlite3][Melpa]] (thanks to @tarsius). 92 | 93 | The first time you ~(require 'sqlite3)~, you will be asked to confirm the 94 | compilation of the dynamic module: 95 | 96 | #+BEGIN_SRC text :eval no :exports code 97 | sqlite3-api module must be built. Do so now? 98 | #+END_SRC 99 | 100 | The module is built using the ~make all~ command by default. To customize the build process, you can override this behavior by setting the =SQLITE3_API_BUILD_COMMAND= environment variable. 101 | 102 | *** Elpa 103 | #+BEGIN_SRC sh :eval no :exports code 104 | $ git clone https://github.com/pekingduck/emacs-sqlite3-api 105 | $ cd emacs-sqlite3-api 106 | $ make module 107 | #+END_SRC 108 | 109 | A tar archive called ~sqlite3-X.Y.tar~ will be created. Do a ~M-x package-install-file~ in Emacs to install that tar archive and 110 | you're all set. 111 | 112 | For Homebrew users on MacOS or Linux: 113 | #+BEGIN_SRC sh :eval no :exports code 114 | $ make HOMEBREW=1 115 | #+END_SRC 116 | to build the module against sqlite3 installed by Homebrew. 117 | 118 | If you have sqlite3 installed in a nonstandard location: 119 | #+BEGIN_SRC sh :eval no :exports code 120 | $ make INC=/path/to/sqlite3/include LIB="-L/path/to/sqlite3/lib -lsqlite3" 121 | #+END_SRC 122 | 123 | *** Straight.el 124 | If you would like to use this library with [[https://github.com/radian-software/straight.el][the straight emacs package manager]], you will need git pre-installed. 125 | The following are example snippets of elisp that can be included in your init file for using straight. 126 | **** Setting up the build environment 127 | For those where sqlite3 C library is installed to a non-standard directory, such as with an installation via homebrew, you may need to add the path to the =libsqlite3.so= to your =LD_LIBRARY_PATH= environment variable with ~setenv~. 128 | 129 | #+begin_src emacs-lisp :eval no :exports code 130 | (defconst sqlite-lib-dir 131 | ;; This example executes 'brew --prefix sqlite' to find the current installation path dynamically 132 | (concat 133 | (string-trim (shell-command-to-string "brew --prefix sqlite")) 134 | "/lib")) 135 | 136 | ;; Set LD_LIBRARY_PATH in Emacs' environment 137 | (setenv "LD_LIBRARY_PATH" 138 | (if-let (current-path (getenv "LD_LIBRARY_PATH")) 139 | (concat sqlite-lib-dir ":" current-path) 140 | sqlite-lib-dir)) 141 | #+end_src 142 | 143 | **** Installing via Straight without the use-package macro 144 | We need to modify =straight-default-files-directive= with an explicit list of =:files= or our shared object that we compile with ~make~ will not be linked into the emacs load path. 145 | Hence, we add to the =:defaults=, the shared library file extensions with a globbing pattern. 146 | 147 | Homebrew users will want to uncomment the =:pre-build= directive so that straight runs ~make~ in a way that finds brew's sqlite installation directory. 148 | 149 | #+begin_src emacs-lisp :eval no :exports code 150 | (straight-use-package 151 | '(sqlite3 152 | :host github 153 | :repo "pekingduck/emacs-sqlite3-api" 154 | :files (:defaults "*.dll" "*.dylib" "*.so") 155 | ;; :pre-build ("env" "HOMEBREW=1" "make" "all") 156 | )) 157 | (load-library "sqlite3") 158 | #+end_src 159 | 160 | **** Straight with the use-package macro 161 | One can optionally use straight with the use-package macro to get all of the configuration - including homebrew - handled in one block: 162 | 163 | #+begin_src emacs-lisp :eval no :exports code 164 | (use-package sqlite3 165 | :init 166 | (defconst sqlite-lib-dir 167 | ;; Execute 'brew --prefix sqlite' to find the current installation path 168 | (concat 169 | (string-trim (shell-command-to-string "brew --prefix sqlite")) 170 | "/lib")) 171 | (setenv "LD_LIBRARY_PATH" 172 | (if-let (current-path (getenv "LD_LIBRARY_PATH")) 173 | (concat sqlite-lib-dir ":" current-path) 174 | sqlite-lib-dir)) 175 | ;; Customize straight.el's build process for the sqlite3 module 176 | :straight 177 | (sqlite3 178 | :host github 179 | :repo "pekingduck/emacs-sqlite3-api" 180 | :files (:defaults "*.dll" "*.dylib" "*.so") 181 | :pre-build ("env" "HOMEBREW=1" "make" "all")) 182 | :config 183 | (load-library "sqlite3") 184 | ) 185 | #+end_src 186 | 187 | The =:init= section runs before the package is loaded into emacs, so it is great for handling things the OS dynamic loader might want defined. 188 | 189 | *** Manual Installation 190 | #+BEGIN_SRC sh :eval no :exports code 191 | $ git clone https://github.com/pekingduck/emacs-sqlite3-api 192 | $ cd emacs-sqlite3-api 193 | $ make 194 | $ cp sqlite3.el sqlite3-api.so /your/elisp/load-path/ 195 | #+END_SRC 196 | 197 | *** Removal 198 | If you installed manually, just remove ~sqlite3.el~ and ~sqlite3-api.so~ from 199 | your load path. Otherwise, do ~M-x package-delete~ to remove the sqlite3 200 | package. 201 | 202 | *** Note on Package Update 203 | Emacs 25 and 26: If you are updating from an older version, you'll need to 204 | restart Emacs for the new module to take effect. That's because ~unload-feature~ 205 | doesn't work for dynamic modules. 206 | 207 | Emacs 27.1: I can't find it in [[https://github.com/emacs-mirror/emacs/blob/emacs-27.1/etc/NEWS][~etc/NEWS~]], but it seems Emacs 27.1 208 | does support unloading of dynamic modules. To unload ~sqlite3~ properly: 209 | 210 | #+BEGIN_SRC emacs-lisp :eval no :exports code 211 | (unload-feature 'sqlite3) 212 | (unload-feature 'sqlite3-api) 213 | #+END_SRC 214 | 215 | ** Testing 216 | 217 | The tests can be run with the [[https://github.com/emacs-eldev/eldev][Eldev]] build tool 218 | 219 | #+BEGIN_SRC sh :eval no :exports code 220 | # from source 221 | eldev test 222 | # or as a compiled package 223 | eldev -p test 224 | #+END_SRC 225 | 226 | See [[https://emacs-eldev.github.io/eldev/][Eldev documentation]] for more information. 227 | 228 | ** API 229 | To load the package, put the following in your ~.emacs~: 230 | 231 | #+BEGIN_SRC emacs-lisp :eval no :exports code 232 | (require 'sqlite3) 233 | #+END_SRC 234 | 235 | An application will typically use sqlite3_open() to create a single database connection during initialization. 236 | 237 | To run an SQL statement, the application follows these steps: 238 | 239 | 1. Create a prepared statement using sqlite3_prepare(). 240 | 1. Evaluate the prepared statement by calling sqlite3_step() one or more times. 241 | 1. For queries, extract results by calling sqlite3_column() in between two calls to sqlite3_step(). 242 | 1. Destroy the prepared statement using sqlite3_finalize(). 243 | 1. Close the database using sqlite3_close(). 244 | 245 | [[https://www.sqlite.org/rescode.html][SQlite3 constants]], defined in sqlite3.h, are things such as numeric result codes 246 | from various interfaces (ex: ~SQLITE_OK~) or flags passed into functions to 247 | control behavior (ex: ~SQLITE_OPEN_READONLY~). 248 | 249 | In elisp they are in lowercase and words are separated by "-" instead of 250 | "_". For example, ~SQLITE_OK~ would be ~sqlite-ok~. 251 | 252 | [[https://www.sqlite.org][www.sqlite.org]] is always a good source of information, especially 253 | [[https://www.sqlite.org/cintro.html][An Introduction to the SQLite C/C++ Interface]] and [[https://www.sqlite.org/c3ref/intro.html][C/C++ API Reference]]. 254 | 255 | *** sqlite3-open 256 | #+BEGIN_SRC emacs-lisp :eval no :exports code 257 | (sqlite3-open "/path/to/data-file" flag1 flag2 ...) 258 | #+END_SRC 259 | Open the database file and return a database handle. 260 | 261 | This function calls [[https://www.sqlite.org/c3ref/open.html][sqlite3_open_v2()]] internally and raises ~db-error~ in case of error. 262 | 263 | *flag1*, *flag2*.... will be ORed together. 264 | *** sqlite3-close 265 | #+BEGIN_SRC emacs-lisp :eval no :exports code 266 | (sqlite3-close database-handle) 267 | #+END_SRC 268 | Close the database file. 269 | *** sqlite3-prepare 270 | #+BEGIN_SRC emacs-lisp :eval no :exports code 271 | (sqlite3-prepare database-handle sql-statement) 272 | #+END_SRC 273 | Compile the supplied SQL statement and return a statement handle. 274 | 275 | This function calls [[https://www.sqlite.org/c3ref/prepare.html][sqlite3_prepare_v2()]] internally and raises 'sql-error in case of error. 276 | *** sqlite3-finalize 277 | #+BEGIN_SRC emacs-lisp :eval no :exports code 278 | (sqlite3-finalize statement-handle1 statement-handle2 ...) 279 | #+END_SRC 280 | Destroy prepared statements. 281 | *** sqlite3-step 282 | #+BEGIN_SRC emacs-lisp :eval no :exports code 283 | (sqlite3-step statement-handle) 284 | #+END_SRC 285 | Execute a prepared SQL statement. Some of the return codes are: 286 | 287 | ~sqlite-done~ - the statement has finished executing successfully. 288 | 289 | ~sqlite-row~ - if the SQL statement being executed returns any data, then ~sqlite-row~ is returned each time a new row of data is ready for processing by the caller. 290 | 291 | *** sqlite3-changes 292 | #+BEGIN_SRC emacs-lisp :eval no :exports code 293 | (sqlite3-changes database-handle) 294 | #+END_SRC 295 | Return the number of rows modified (for update/delete/insert statements) 296 | 297 | *** sqlite3-reset 298 | #+BEGIN_SRC emacs-lisp :eval no :exports code 299 | (sqlite3-reset statement-handle) 300 | #+END_SRC 301 | Reset a prepared statement. Call this function if you want to re-bind 302 | the statement to new variables, or to re-execute the prepared statement 303 | from the start. 304 | *** sqlite3-last-insert-rowid 305 | #+BEGIN_SRC emacs-lisp :eval no :exports code 306 | (sqlite3-last-insert-rowid database-handle) 307 | #+END_SRC 308 | Retrieve the last inserted rowid (64 bit). 309 | 310 | Notes: Beware that Emacs only supports integers up to 61 bits. 311 | *** sqlite3-get-autocommit 312 | #+BEGIN_SRC emacs-lisp :eval no :exports code 313 | (sqlite3-get-autocommit database-handle) 314 | #+END_SRC 315 | Return 1 / 0 if auto-commit mode is ON / OFF. 316 | *** sqlite3-exec 317 | #+BEGIN_SRC emacs-lisp :eval no :exports code 318 | (sqlite3-exec database-handle sql-statements &optional callback) 319 | #+END_SRC 320 | The Swiss Army Knife of the API, you can execute multiple SQL statements 321 | (separated by ";") in a row with just one call. 322 | 323 | The callback function, if supplied, is invoked for *each row* and should accept 3 324 | parameters: 325 | 1. the first parameter is the number of columns in the current row; 326 | 2. the second parameter is the actual data (as a list strings or nil in case of NULL); 327 | 3. the third one is a list of column names. 328 | 329 | To signal an error condition inside the callback, return ~nil~. 330 | ~sqlite3_exec()~ will stop the execution and raise ~db-error~. 331 | 332 | Raises ~db-error~ in case of error. 333 | 334 | An example of a callback: 335 | #+BEGIN_SRC emacs-lisp :eval no :exports code 336 | (defun print-row (ncols data names) 337 | (cl-loop for i from 0 to (1- ncols) do 338 | (message "[Column %d/%d]%s=%s" (1+ i) ncols (elt names i) (elt data i))) 339 | (message "--------------------") 340 | t) 341 | 342 | (sqlite3-exec dbh "select * from table_a; select * from table b" 343 | #'print-row) 344 | #+END_SRC 345 | More examples: 346 | #+BEGIN_SRC emacs-lisp :eval no :exports code 347 | ;; Update/delete/insert 348 | (sqlite3-exec dbh "delete from table") ;; delete returns no rows 349 | 350 | ;; Retrieve the metadata of columns in a table 351 | (sqlite3-exec dbh "pragma table_info(table)" #'print-row) 352 | #+END_SRC 353 | *** sqlite3-bind-* 354 | #+BEGIN_SRC emacs-lisp :eval no :exports code 355 | (sqlite3-bind-text statement-handle column-no value) 356 | (sqlite3-bind-int64 statement-handle column-no value) 357 | (sqlite3-bind-double statement-handle column-no value) 358 | (sqlite3-bind-null statement-handle column-no) 359 | #+END_SRC 360 | The above four functions bind values to a compiled SQL statements. 361 | 362 | Please note that column number starts from 1, not 0! 363 | #+BEGIN_SRC emacs-lisp :eval no :exports code 364 | (sqlite3-bind-parameter-count statement-handle) 365 | #+END_SRC 366 | The above functions returns the number of SQL parameters of a prepared 367 | statement. 368 | *** sqlite3-bind-multi 369 | #+BEGIN_SRC emacs-lisp :eval no :exports code 370 | (sqlite3-bind-multi statement-handle &rest params) 371 | #+END_SRC 372 | ~sqlite3-bind-multi~ binds multiple parameters to a prepared SQL 373 | statement. It is not part of the official API but is provided for 374 | convenience. 375 | 376 | Example: 377 | #+BEGIN_SRC emacs-lisp :eval no :exports code 378 | (sqlite3-bind-multi stmt 1234 "a" 1.555 nil) ;; nil for NULL 379 | #+END_SRC 380 | *** sqlite3-column-* 381 | These column functions are used to retrieve the current row 382 | of the result set. 383 | 384 | #+BEGIN_SRC emacs-lisp :eval no :exports code 385 | (sqlite3-column-count statement-handle) 386 | #+END_SRC 387 | Return number of columns in a result set. 388 | #+END_SRCe1 389 | (sqlite3-column-type statement-handle column-no) 390 | #+END_SRC 391 | Return the type (~sqlite-integer~, ~sqlite-float~, ~sqlite3-text~ or 392 | ~sqlite-null~) of the specified column. 393 | 394 | Note: Column number starts from 0. 395 | #+BEGIN_SRC emacs-lisp :eval no :exports code 396 | (sqlite3-column-text statement-handle column-no) 397 | (sqlite3-column-int64 statement-handle column-no) 398 | (sqlite3-column-double statement-handle column-no) 399 | #+END_SRC 400 | The above functions retrieve data of the specified column. 401 | #+BEGIN_SRC emacs-lisp :eval no :exports code 402 | (sqlite3-column-name statement-handle column-no) 403 | #+END_SRC 404 | This function returns the column name of the specified column. 405 | 406 | Note: You can call ~sqlite3-column-xxx~ on a column even 407 | if ~sqlite3-column-type~ returns ~sqlite-yyy~: the SQLite3 engine will 408 | perform the necessary type conversion. 409 | 410 | Example: 411 | #+BEGIN_SRC emacs-lisp :eval no :exports code 412 | (setq stmt (sqlite3-prepare dbh "select * from temp")) 413 | (while (= sqlite-row (sqlite3-step stmt)) 414 | (let ((name (sqlite3-column-text stmt 0)) 415 | (age (sqlite3-column-int64 stmt 1))) 416 | (message "name: %s, age: %d" name age))) 417 | #+END_SRC 418 | *** sqlite3-fetch 419 | #+BEGIN_SRC emacs-lisp :eval no :exports code 420 | (sqlite3-fetch statement-handle) ;; returns a list such as (123 56 "Peter Smith" nil) 421 | #+END_SRC 422 | ~sqlite3-fetch~ is not part of the official API but provided for 423 | convenience. It retrieves the current row as a 424 | list without having to deal with sqlite3-column-* explicitly. 425 | 426 | *** sqlite3-fetch-alist 427 | #+BEGIN_SRC emacs-lisp :eval no :exports code 428 | (sqlite3-fetch-alist statement-handle) 429 | #+END_SRC 430 | ~sqlite3-fetch-alist~ is not part of the official API but provided for 431 | convenience. It retrieves the current row as an 432 | alist in the form of ~(("col_name1" . value1) ("col_name2" . value2) ..)~ 433 | 434 | ** Transaction Support 435 | Use ~sqlite3-exec~ to start, commit and rollback a transaction: 436 | #+BEGIN_SRC emacs-lisp :eval no :exports code 437 | (sqlite3-exec dbh "begin") 438 | (sqlite3-exec dbh "commit") 439 | (sqlite3-exec dbh "rollback") 440 | #+END_SRC 441 | See Error Handling below on how to use the [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Handling-Errors.html][condition-case]] form to handle rollback. 442 | ** Error Handling 443 | Currently two error symbols are defined in ~sqlite3.el~: 444 | 1. ~sql-error~ is raised by ~sqlite3-prepare~ 445 | 2. ~db-error~ is raised by ~sqlite3-open~ and ~sqlite3-exec~ 446 | 447 | #+BEGIN_SRC emacs-lisp :eval no :exports code 448 | (condition-case db-err 449 | (progn 450 | (sqlite3-exec dbh "begin") 451 | (sqlite3-exec dbh "update temp set a = 1 where b = 2") 452 | (sqlite3-exec dbh "commit")) 453 | (db-error 454 | (message "Symbol:%s, Message:%s, Error Code:%d" (elt db-err 0) (elt db-err 1) (elt db-err 2)) 455 | (sqlite3-exec dbh "rollback"))) 456 | #+END_SRC 457 | ~db-err~ is a list containing the error symbol (~db-error~ or ~sql-error~), an error message and finally an error code returned from the 458 | corresponding SQLite 459 | C API. 460 | 461 | ** Note on Garbage Collection 462 | Since Emacs's garbage collection is non-deterministic, it would be 463 | a good idea 464 | to manually free database/statement handles once they are not needed. 465 | 466 | ** Known Problems 467 | - SQLite3 supports 64 bit integers but Emacs integers are only 61 bits. 468 | For integers > 61 bits you can retrieve them as text as a workaround. 469 | - BLOB and TEXT columns with embedded NULLs are not supported. 470 | 471 | ** License 472 | The code is licensed under the [[https://www.gnu.org/licenses/gpl-3.0.html][GNU GPL v3]]. 473 | 474 | ** Contributors 475 | - [[https://github.com/tarsius][Jonas Bernoulli]] - Melpa package 476 | - @reflektoin 477 | - @yasuhirokimura 478 | - @ikappaki - added GitHub CI Actions (0aa2b03) 479 | 480 | ** Changelog 481 | *v0.18 - 2023-11-24* 482 | - Module is now loaded after compilation. 483 | - GitHub CI Actions added 484 | 485 | *v0.17 - 2023-03-15* 486 | - Added 28.2 to regression tests 487 | 488 | *v0.16 - 2022-05-01* 489 | - Fixed a bug in ~sqlite3-bind-multi~ 490 | 491 | *v0.15 - 2020-09-16* 492 | - Fixed a bug in ~sqlite3-bind-multi~ under Emacs 27.1 493 | 494 | *v0.14 - 2020-07-08* 495 | - Added sqlite3.el (melpa) 496 | 497 | *v0.13 - 2020-04-20* 498 | - Rewrote README in .org format 499 | 500 | *v0.12 - 2019-05-12* 501 | - ~sqlite3-fetch-alist~ added 502 | - Fixed a compilation problem on macOS Mojave 503 | 504 | *v0.11 - 2017-09-14* 505 | - ~sqlite3-finalize~ now accepts multiple handles. 506 | 507 | *v0.1 - 2017-09-04* 508 | - Emacs Lisp code removed. The package is now pure C. 509 | 510 | *v0.0 - 2017-08-29* 511 | - Fixed a memory leak in ~sql_api_exec()~ 512 | - Changed ~sqlite3_close()~ to ~sqlite3_close_v2()~ in ~sqlite_api_close()~ 513 | - Better error handling: Error code is returned along with error message 514 | ** Useful Links for Writing Dynamic Modules 515 | - https://phst.github.io/emacs-modules 516 | - http://nullprogram.com/blog/2016/11/05/ 517 | -------------------------------------------------------------------------------- /sqlite3-api.c: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License as published by 4 | the Free Software Foundation, either version 3 of the License, or 5 | (at your option) any later version. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program. If not, see . 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "emacs-module.h" 22 | 23 | int plugin_is_GPL_compatible; 24 | 25 | #define NON_LOCAL_EXIT_CHECK(env) \ 26 | if ((env)->non_local_exit_check(env) != emacs_funcall_exit_return) { \ 27 | return (env)->intern((env), "nil"); \ 28 | } 29 | #define SYM(env, sym) (env)->intern((env), sym) 30 | #define IS_INTEGER(env, val) \ 31 | (env)->eq((env), (env)->type_of((env), (val)), (env)->intern((env), "integer")) 32 | #define IS_FLOAT(env, val) \ 33 | (env)->eq((env), (env)->type_of((env), (val)), (env)->intern((env), "float")) 34 | #define IS_STRING(env, val) \ 35 | (env)->eq((env), (env)->type_of((env), (val)), (env)->intern((env), "string")) 36 | #define IS_NIL(env, val) \ 37 | (env)->eq((env), (val), (env)->intern((env), "nil")) 38 | #define NIL(env) (env)->intern((env), "nil") 39 | 40 | #define RETURN_NIL_ON_NIL(env, stmt) \ 41 | if (!(env)->is_not_nil((env), (stmt))) { \ 42 | WARN(env, "%s: handle is nil", __func__); \ 43 | return SYM((env), "nil"); \ 44 | } 45 | 46 | #define MAKE_INT(env, i) \ 47 | (env)->make_integer((env), (i)) 48 | 49 | #define MAKE_FLOAT(env, fl) \ 50 | (env)->make_float((env), (fl)) 51 | 52 | #define MAKE_STR(env, s) \ 53 | (env)->make_string((env), (s), strlen(s)) 54 | 55 | /* Equivalent to (list a b c) in elisp 56 | len is the length of the list 57 | elts, an array of emacs_value, are the elements 58 | */ 59 | 60 | #define MAKE_LIST(env, len, elts) \ 61 | (env)->funcall((env), SYM((env), "list"), (len), (elts)) 62 | 63 | /* (cons a b) */ 64 | #define MAKE_CONS(env, elts) \ 65 | (env)->funcall((env), SYM((env), "cons"), 2, (elts)) 66 | 67 | #define WARN(env, ...) message(env, SQLITE3_LOG_LEVEL_WARN, __VA_ARGS__) 68 | #define DEBUG(env, ...) message(env, SQLITE3_LOG_LEVEL_DEBUG, __VA_ARGS__) 69 | #define ERROR(env, ...) message(env, SQLITE3_LOG_LEVEL_ERROR, __VA_ARGS__) 70 | #define INFO(env, ...) message(env, SQLITE3_LOG_LEVEL_INFO, __VA_ARGS__) 71 | 72 | #define FREE(p) if ((p) != 0) free(p); 73 | 74 | #define SQLITE3_MAX_LOG_BUF 1000 75 | 76 | static int SQLITE3_LOG_LEVEL_DEBUG = 0; 77 | static int SQLITE3_LOG_LEVEL_INFO = 1; 78 | static int SQLITE3_LOG_LEVEL_WARN = 2; 79 | static int SQLITE3_LOG_LEVEL_ERROR = 3; 80 | static int sqlite3_api_log_level; 81 | 82 | /* Logging function */ 83 | static void message(emacs_env *env, int log_level, const char *fmt, ...) { 84 | (void)env; 85 | 86 | if (log_level < sqlite3_api_log_level) 87 | return; 88 | 89 | static const char *LOG_LEVEL_DESC[] = { 90 | "DEBUG", 91 | "INFO", 92 | "WARN", 93 | "ERROR" 94 | }; 95 | fprintf(stderr, "[%s] ", LOG_LEVEL_DESC[log_level]); 96 | 97 | va_list args; 98 | va_start(args, fmt); 99 | vfprintf(stderr, fmt, args); 100 | va_end(args); 101 | 102 | fprintf(stderr, "\n"); 103 | } 104 | 105 | /* Signal an error condition. 106 | Equivalent to (signal symbol '(msg code)) in elisp */ 107 | void signal_error( 108 | emacs_env *env, 109 | const char *symbol, 110 | const char *msg, 111 | int code) { 112 | emacs_value signal = SYM(env, symbol); 113 | emacs_value argv[2] = { 114 | MAKE_STR(env, msg), 115 | MAKE_INT(env, code) 116 | }; 117 | 118 | env->non_local_exit_signal( 119 | env, 120 | signal, 121 | MAKE_LIST(env, 2, argv)); 122 | } 123 | 124 | /* Extract and copy string contents from function parameters */ 125 | int extract_string_arg(emacs_env *env, emacs_value arg, char **str) { 126 | ptrdiff_t size = 0; 127 | if (!env->copy_string_contents(env, arg, NULL, &size)) 128 | return 1; 129 | 130 | *str = malloc(size); 131 | if (!env->copy_string_contents(env, arg, *str, &size)) { 132 | FREE(*str); 133 | *str = 0; 134 | return 1; 135 | } 136 | return 0; 137 | } 138 | 139 | /* Bind the supplied function to a symbol by calling (fset ....) */ 140 | void bind_func(emacs_env *env, const char *name, ptrdiff_t min, 141 | ptrdiff_t max, 142 | emacs_value (*function) (emacs_env *env, 143 | ptrdiff_t nargs, 144 | emacs_value args[], 145 | void *) EMACS_NOEXCEPT, 146 | const char *doc) { 147 | emacs_value fset = SYM(env, "fset"); 148 | emacs_value args[2]; 149 | 150 | args[0] = SYM(env, name); 151 | args[1] = env->make_function(env, min, max, function, doc, 0); 152 | env->funcall(env, fset, 2, args); 153 | } 154 | 155 | /* finalizer for database handle (sqlite3 *) */ 156 | static void sqlite3_dbh_gc(void *ptr) { 157 | INFO(0, "%s: entered", __func__); 158 | 159 | if (ptr) { 160 | INFO(0, "%s: non-null dbh", __func__); 161 | sqlite3_close_v2((sqlite3 *)ptr); 162 | } 163 | } 164 | 165 | /* finalizer for statement handle (sqlite3_stmt *) */ 166 | static void sqlite3_stmt_gc(void *ptr) { 167 | INFO(0, "%s: entered", __func__); 168 | 169 | if (ptr) { 170 | INFO(0, "%s: non-null stmt", __func__); 171 | sqlite3_finalize((sqlite3_stmt *)ptr); 172 | } 173 | } 174 | 175 | /* bind_*() functions: 176 | Bind SQL parameters after the SQL is prepared (compiled). 177 | */ 178 | static emacs_value sqlite3_api_bind_null( 179 | emacs_env *env, 180 | ptrdiff_t n, 181 | emacs_value *args, 182 | void *ptr) { 183 | (void)ptr; 184 | (void)n; 185 | 186 | RETURN_NIL_ON_NIL(env, args[0]); 187 | 188 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 189 | NON_LOCAL_EXIT_CHECK(env); 190 | 191 | // The column no. 192 | int col = env->extract_integer(env, args[1]); 193 | NON_LOCAL_EXIT_CHECK(env); 194 | 195 | return MAKE_INT(env, sqlite3_bind_null(stmt, col)); 196 | } 197 | 198 | static emacs_value sqlite3_api_bind_double( 199 | emacs_env *env, 200 | ptrdiff_t n, 201 | emacs_value *args, 202 | void *ptr) { 203 | (void)ptr; 204 | (void)n; 205 | 206 | RETURN_NIL_ON_NIL(env, args[0]); 207 | 208 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 209 | NON_LOCAL_EXIT_CHECK(env); 210 | 211 | // The column no. 212 | int col = env->extract_integer(env, args[1]); 213 | NON_LOCAL_EXIT_CHECK(env); 214 | 215 | double val = env->extract_float(env, args[2]); 216 | NON_LOCAL_EXIT_CHECK(env); 217 | 218 | return MAKE_INT(env, sqlite3_bind_double(stmt, col, val)); 219 | } 220 | 221 | static emacs_value sqlite3_api_bind_parameter_count( 222 | emacs_env *env, 223 | ptrdiff_t n, 224 | emacs_value *args, 225 | void *ptr) { 226 | (void)ptr; 227 | (void)n; 228 | 229 | RETURN_NIL_ON_NIL(env, args[0]); 230 | 231 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 232 | NON_LOCAL_EXIT_CHECK(env); 233 | 234 | return MAKE_INT(env, sqlite3_bind_parameter_count(stmt)); 235 | } 236 | 237 | static emacs_value sqlite3_api_bind_int64( 238 | emacs_env *env, 239 | ptrdiff_t n, 240 | emacs_value *args, 241 | void *ptr) { 242 | (void)ptr; 243 | (void)n; 244 | 245 | RETURN_NIL_ON_NIL(env, args[0]); 246 | 247 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 248 | NON_LOCAL_EXIT_CHECK(env); 249 | 250 | // The column no. 251 | int col = env->extract_integer(env, args[1]); 252 | NON_LOCAL_EXIT_CHECK(env); 253 | 254 | 255 | intmax_t val = env->extract_integer(env, args[2]); 256 | NON_LOCAL_EXIT_CHECK(env); 257 | 258 | return MAKE_INT(env, sqlite3_bind_int64(stmt, col, val)); 259 | } 260 | 261 | static emacs_value sqlite3_api_bind_text( 262 | emacs_env *env, 263 | ptrdiff_t n, 264 | emacs_value *args, 265 | void *ptr) { 266 | (void)ptr; 267 | (void)n; 268 | 269 | RETURN_NIL_ON_NIL(env, args[0]); 270 | 271 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 272 | NON_LOCAL_EXIT_CHECK(env); 273 | 274 | // The column no. 275 | int col = env->extract_integer(env, args[1]); 276 | NON_LOCAL_EXIT_CHECK(env); 277 | 278 | char *txt; 279 | if (extract_string_arg(env, args[2], &txt)) { 280 | return NIL(env); 281 | } 282 | 283 | DEBUG(env, "%s: [%s] to col %d", __func__, txt, col); 284 | int rv = sqlite3_bind_text(stmt, col, txt, -1, SQLITE_TRANSIENT); 285 | FREE(txt); 286 | return MAKE_INT(env, rv); 287 | } 288 | 289 | static emacs_value sqlite3_api_bind_multi( 290 | emacs_env *env, 291 | ptrdiff_t n, 292 | emacs_value *args, 293 | void *ptr) { 294 | (void)ptr; 295 | (void)n; 296 | 297 | RETURN_NIL_ON_NIL(env, args[0]); 298 | 299 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 300 | NON_LOCAL_EXIT_CHECK(env); 301 | 302 | int rv; 303 | for (int i = 1; i < n; i++) { 304 | char *txt = 0; 305 | 306 | //emacs_value type = env->type_of(env, args[i]); 307 | if (IS_INTEGER(env, args[i])) { 308 | rv = sqlite3_bind_int64(stmt, i, env->extract_integer(env, args[i])); 309 | NON_LOCAL_EXIT_CHECK(env); 310 | } else if (IS_FLOAT(env, args[i])) { 311 | rv = sqlite3_bind_double(stmt, i, env->extract_float(env, args[i])); 312 | NON_LOCAL_EXIT_CHECK(env); 313 | } else if (IS_STRING(env, args[i])) { 314 | extract_string_arg(env, args[i], &txt); 315 | rv = sqlite3_bind_text(stmt, i, txt, -1, SQLITE_TRANSIENT); 316 | FREE(txt); 317 | NON_LOCAL_EXIT_CHECK(env); 318 | } else if (IS_NIL(env, args[i])) { 319 | rv = sqlite3_bind_null(stmt, i); 320 | NON_LOCAL_EXIT_CHECK(env); 321 | } else { 322 | WARN(env, "%s: arg %d is of unknown type", __func__, i); 323 | rv = SQLITE_MISUSE; 324 | } 325 | if (rv != SQLITE_OK) { 326 | WARN(env, "%s: ERROR CODE = %d", __func__, rv); 327 | sqlite3_reset(stmt); 328 | break; 329 | } 330 | } 331 | 332 | return MAKE_INT(env, rv); 333 | } 334 | 335 | static emacs_value sqlite3_api_column_name( 336 | emacs_env *env, 337 | ptrdiff_t n, 338 | emacs_value *args, 339 | void *ptr) { 340 | (void)ptr; 341 | (void)n; 342 | 343 | RETURN_NIL_ON_NIL(env, args[0]); 344 | 345 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 346 | NON_LOCAL_EXIT_CHECK(env); 347 | 348 | // The column no. 349 | int col = env->extract_integer(env, args[1]); 350 | NON_LOCAL_EXIT_CHECK(env); 351 | 352 | const char *name = sqlite3_column_name(stmt, col); 353 | return MAKE_STR(env, name); 354 | } 355 | 356 | static emacs_value sqlite3_api_column_text( 357 | emacs_env *env, 358 | ptrdiff_t n, 359 | emacs_value *args, 360 | void *ptr) { 361 | (void)ptr; 362 | (void)n; 363 | 364 | RETURN_NIL_ON_NIL(env, args[0]); 365 | 366 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 367 | NON_LOCAL_EXIT_CHECK(env); 368 | 369 | // The column no. 370 | int col = env->extract_integer(env, args[1]); 371 | NON_LOCAL_EXIT_CHECK(env); 372 | 373 | return env->make_string(env, 374 | (const char *)sqlite3_column_text(stmt, col), 375 | sqlite3_column_bytes(stmt, col)); 376 | 377 | } 378 | 379 | static emacs_value sqlite3_api_column_int64( 380 | emacs_env *env, 381 | ptrdiff_t n, 382 | emacs_value *args, 383 | void *ptr) { 384 | (void)ptr; 385 | (void)n; 386 | 387 | RETURN_NIL_ON_NIL(env, args[0]); 388 | 389 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 390 | NON_LOCAL_EXIT_CHECK(env); 391 | 392 | // The column no. 393 | int col = env->extract_integer(env, args[1]); 394 | NON_LOCAL_EXIT_CHECK(env); 395 | 396 | return MAKE_INT(env, (intmax_t)sqlite3_column_int64(stmt, col)); 397 | } 398 | 399 | static emacs_value sqlite3_api_column_double( 400 | emacs_env *env, 401 | ptrdiff_t n, 402 | emacs_value *args, 403 | void *ptr) { 404 | (void)ptr; 405 | (void)n; 406 | 407 | RETURN_NIL_ON_NIL(env, args[0]); 408 | 409 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 410 | NON_LOCAL_EXIT_CHECK(env); 411 | 412 | // The column no. 413 | int col = env->extract_integer(env, args[1]); 414 | NON_LOCAL_EXIT_CHECK(env); 415 | 416 | return MAKE_FLOAT(env, sqlite3_column_double(stmt, col)); 417 | } 418 | 419 | static emacs_value sqlite3_api_column_type( 420 | emacs_env *env, 421 | ptrdiff_t n, 422 | emacs_value *args, 423 | void *ptr) { 424 | (void)ptr; 425 | (void)n; 426 | 427 | RETURN_NIL_ON_NIL(env, args[0]); 428 | 429 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 430 | NON_LOCAL_EXIT_CHECK(env); 431 | 432 | // The column no. 433 | int col = env->extract_integer(env, args[1]); 434 | NON_LOCAL_EXIT_CHECK(env); 435 | 436 | return MAKE_INT(env, sqlite3_column_type(stmt, col)); 437 | } 438 | 439 | static emacs_value sqlite3_api_changes( 440 | emacs_env *env, 441 | ptrdiff_t n, 442 | emacs_value *args, 443 | void *ptr) { 444 | (void)ptr; 445 | (void)n; 446 | 447 | RETURN_NIL_ON_NIL(env, args[0]); 448 | 449 | sqlite3 *dbh = (sqlite3 *)env->get_user_ptr(env, args[0]); 450 | NON_LOCAL_EXIT_CHECK(env); 451 | 452 | return MAKE_INT(env, sqlite3_changes(dbh)); 453 | } 454 | 455 | static emacs_value sqlite3_api_step( 456 | emacs_env *env, 457 | ptrdiff_t n, 458 | emacs_value *args, 459 | void *ptr) { 460 | (void)ptr; 461 | (void)n; 462 | 463 | RETURN_NIL_ON_NIL(env, args[0]); 464 | 465 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 466 | NON_LOCAL_EXIT_CHECK(env) 467 | 468 | return MAKE_INT(env, sqlite3_step(stmt)); 469 | } 470 | 471 | static emacs_value sqlite3_api_reset( 472 | emacs_env *env, 473 | ptrdiff_t n, 474 | emacs_value *args, 475 | void *ptr) { 476 | (void)ptr; 477 | (void)n; 478 | 479 | RETURN_NIL_ON_NIL(env, args[0]); 480 | 481 | // Exrtract sqlite3 db struct 482 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 483 | NON_LOCAL_EXIT_CHECK(env); 484 | 485 | return MAKE_INT(env, sqlite3_reset(stmt)); 486 | } 487 | 488 | static emacs_value sqlite3_api_column_count( 489 | emacs_env *env, 490 | ptrdiff_t n, 491 | emacs_value *args, 492 | void *ptr) { 493 | (void)ptr; 494 | (void)n; 495 | 496 | RETURN_NIL_ON_NIL(env, args[0]); 497 | 498 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 499 | NON_LOCAL_EXIT_CHECK(env); 500 | 501 | return MAKE_INT(env, sqlite3_column_count(stmt)); 502 | } 503 | 504 | static emacs_value sqlite3_api_fetch_alist( 505 | emacs_env *env, 506 | ptrdiff_t n, 507 | emacs_value *args, 508 | void *ptr) { 509 | (void)ptr; 510 | (void)n; 511 | 512 | RETURN_NIL_ON_NIL(env, args[0]); 513 | 514 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 515 | NON_LOCAL_EXIT_CHECK(env); 516 | 517 | /* Create a list to store the results */ 518 | int ncols = sqlite3_column_count(stmt); 519 | emacs_value *elts = malloc(sizeof(emacs_value)*ncols); 520 | for (int i = 0; i < ncols; i++) { 521 | /* Create a pair for each column */ 522 | emacs_value cons[2]; 523 | const char *col_name = sqlite3_column_name(stmt, i); 524 | 525 | cons[0] = MAKE_STR(env, col_name); 526 | 527 | switch(sqlite3_column_type(stmt, i)) { 528 | case SQLITE_INTEGER: 529 | cons[1] = MAKE_INT(env, sqlite3_column_int64(stmt, i)); 530 | break; 531 | case SQLITE_FLOAT: 532 | cons[1] = MAKE_FLOAT(env, sqlite3_column_double(stmt, i)); 533 | break; 534 | case SQLITE_TEXT: 535 | cons[1] = env->make_string( 536 | env, 537 | (const char *)sqlite3_column_text(stmt, i), 538 | sqlite3_column_bytes(stmt, i)); 539 | break; 540 | default: 541 | cons[1] = NIL(env); 542 | } 543 | elts[i] = MAKE_CONS(env, cons); 544 | } 545 | 546 | emacs_value res = MAKE_LIST(env, ncols, elts); 547 | FREE(elts); 548 | return res; 549 | } 550 | 551 | static emacs_value sqlite3_api_fetch( 552 | emacs_env *env, 553 | ptrdiff_t n, 554 | emacs_value *args, 555 | void *ptr) { 556 | (void)ptr; 557 | (void)n; 558 | 559 | RETURN_NIL_ON_NIL(env, args[0]); 560 | 561 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[0]); 562 | NON_LOCAL_EXIT_CHECK(env); 563 | 564 | /* Create a list to store the results */ 565 | int ncols = sqlite3_column_count(stmt); 566 | emacs_value *elts = malloc(sizeof(emacs_value)*ncols); 567 | for (int i = 0; i < ncols; i++) { 568 | switch(sqlite3_column_type(stmt, i)) { 569 | case SQLITE_INTEGER: 570 | elts[i] = MAKE_INT(env, sqlite3_column_int64(stmt, i)); 571 | break; 572 | case SQLITE_FLOAT: 573 | elts[i] = MAKE_FLOAT(env, sqlite3_column_double(stmt, i)); 574 | break; 575 | case SQLITE_TEXT: 576 | elts[i] = env->make_string( 577 | env, 578 | (const char *)sqlite3_column_text(stmt, i), 579 | sqlite3_column_bytes(stmt, i)); 580 | break; 581 | default: 582 | elts[i] = NIL(env); 583 | } 584 | } 585 | 586 | emacs_value res = MAKE_LIST(env, ncols, elts); 587 | FREE(elts); 588 | return res; 589 | } 590 | 591 | static emacs_value sqlite3_api_prepare( 592 | emacs_env *env, 593 | ptrdiff_t n, 594 | emacs_value *args, 595 | void *ptr) { 596 | (void)ptr; 597 | (void)n; 598 | 599 | RETURN_NIL_ON_NIL(env, args[0]); 600 | 601 | sqlite3 *dbh = (sqlite3 *)env->get_user_ptr(env, args[0]); 602 | NON_LOCAL_EXIT_CHECK(env); 603 | 604 | // SQL statement to be prepared 605 | char *sql_txt; 606 | if (extract_string_arg(env, args[1], &sql_txt)) { 607 | return NIL(env); 608 | } 609 | 610 | // Prepare 611 | sqlite3_stmt *stmt; 612 | const char *tail; 613 | int rv = sqlite3_prepare_v2(dbh, sql_txt, -1, &stmt, &tail); 614 | INFO(env, "%s: statement prepared (rv=%d)", __func__, rv); 615 | 616 | FREE(sql_txt); 617 | if (rv != SQLITE_OK) { 618 | signal_error(env, "sql-error", "sqlite3_prepare_v2() failed", rv); 619 | return NIL(env); 620 | } 621 | return env->make_user_ptr(env, sqlite3_stmt_gc, stmt); 622 | } 623 | 624 | static emacs_value sqlite3_api_get_autocommit( 625 | emacs_env *env, 626 | ptrdiff_t n, 627 | emacs_value *args, 628 | void *ptr) { 629 | (void)ptr; 630 | (void)n; 631 | 632 | /* User passed a nil stmt */ 633 | RETURN_NIL_ON_NIL(env, args[0]); 634 | 635 | sqlite3 *dbh = (sqlite3 *)env->get_user_ptr(env, args[0]); 636 | NON_LOCAL_EXIT_CHECK(env); 637 | 638 | INFO(env, "%s: entered", __func__); 639 | return MAKE_INT(env, sqlite3_get_autocommit(dbh)); 640 | } 641 | 642 | /* Small struct for passing data from sqlite3_exec() to exec_callback() */ 643 | struct func_env { 644 | emacs_env *env; 645 | emacs_value callback; 646 | }; 647 | 648 | /* this #define is only used in exec_callback() */ 649 | #define NON_LOCAL_EXIT_CHECK_AND_CLEANUP \ 650 | if (env->non_local_exit_check(env) != emacs_funcall_exit_return) { \ 651 | FREE(data_args); \ 652 | FREE(col_args); \ 653 | return 1; \ 654 | } 655 | 656 | static int exec_callback(void *data, int ncols, 657 | char **col_data, char **col_names) { 658 | struct func_env *fe = (struct func_env *)data; 659 | 660 | emacs_env *env = fe->env; 661 | 662 | /* Build up two lists and pass them to the LISP callback */ 663 | emacs_value *data_args = malloc(sizeof(emacs_value)*ncols); 664 | emacs_value *col_args = malloc(sizeof(emacs_value)*ncols); 665 | 666 | for (int i = 0; i < ncols; i++) { 667 | if (col_data[i]) 668 | data_args[i] = MAKE_STR(env, col_data[i]); 669 | else 670 | data_args[i] = NIL(env); 671 | NON_LOCAL_EXIT_CHECK_AND_CLEANUP; 672 | 673 | col_args[i] = MAKE_STR(env, col_names[i]); 674 | NON_LOCAL_EXIT_CHECK_AND_CLEANUP; 675 | } 676 | 677 | /* equivalent to (list "a" "b" "c" ....) */ 678 | emacs_value args[3]; 679 | args[0] = MAKE_INT(env, ncols); 680 | NON_LOCAL_EXIT_CHECK_AND_CLEANUP; 681 | args[1] = MAKE_LIST(env, ncols, data_args); 682 | NON_LOCAL_EXIT_CHECK_AND_CLEANUP; 683 | args[2] = MAKE_LIST(env, ncols, col_args); 684 | NON_LOCAL_EXIT_CHECK_AND_CLEANUP; 685 | 686 | emacs_value v = env->funcall(env, fe->callback, 3, args); 687 | FREE(data_args); 688 | FREE(col_args); 689 | 690 | if (env->is_not_nil(env, v)) 691 | return 0; 692 | return 1; 693 | } 694 | 695 | static emacs_value sqlite3_api_exec( 696 | emacs_env *env, 697 | ptrdiff_t n, 698 | emacs_value *args, 699 | void *ptr) { 700 | (void)ptr; 701 | 702 | /* User passed a nil dbh */ 703 | RETURN_NIL_ON_NIL(env, args[0]); 704 | 705 | sqlite3 *dbh = (sqlite3 *)env->get_user_ptr(env, args[0]); 706 | NON_LOCAL_EXIT_CHECK(env); 707 | 708 | char *sql_txt; 709 | if (extract_string_arg(env, args[1], &sql_txt)) { 710 | FREE(sql_txt); 711 | return NIL(env); 712 | } 713 | 714 | char *errmsg = 0; 715 | int rv; 716 | if (n == 3) { 717 | struct func_env fe = { env, args[2] }; 718 | rv = sqlite3_exec(dbh, sql_txt, exec_callback, (void *)&fe, &errmsg); 719 | } else { 720 | rv = sqlite3_exec(dbh, sql_txt, 0, 0, &errmsg); 721 | } 722 | FREE(sql_txt); 723 | 724 | if (rv != SQLITE_OK) { 725 | signal_error(env, "db-error", errmsg, rv); 726 | if (errmsg) 727 | sqlite3_free(errmsg); 728 | return NIL(env); 729 | } 730 | 731 | return MAKE_INT(env, rv); 732 | } 733 | 734 | 735 | static emacs_value sqlite3_api_finalize( 736 | emacs_env *env, 737 | ptrdiff_t n, 738 | emacs_value *args, 739 | void *ptr) { 740 | (void)ptr; 741 | 742 | INFO(env, "%s: entered", __func__); 743 | 744 | for (int i = 0; i < n; i++) { 745 | /* User passed a nil stmt */ 746 | if (!env->is_not_nil(env, args[i])) 747 | continue; 748 | 749 | sqlite3_stmt *stmt = (sqlite3_stmt *)env->get_user_ptr(env, args[i]); 750 | NON_LOCAL_EXIT_CHECK(env); 751 | 752 | sqlite3_finalize(stmt); 753 | env->set_user_ptr(env, args[i], 0); 754 | DEBUG(env, "%s: #%d finalized", __func__, i); 755 | } 756 | 757 | return NIL(env); 758 | } 759 | 760 | 761 | static emacs_value sqlite3_api_close( 762 | emacs_env *env, 763 | ptrdiff_t n, 764 | emacs_value *args, 765 | void *ptr) { 766 | (void)ptr; 767 | (void)n; 768 | 769 | /* nil database handle */ 770 | RETURN_NIL_ON_NIL(env, args[0]); 771 | 772 | sqlite3 *dbh = (sqlite3 *)env->get_user_ptr(env, args[0]); 773 | NON_LOCAL_EXIT_CHECK(env); 774 | 775 | INFO(env, "%s: entered", __func__); 776 | sqlite3_close_v2(dbh); 777 | env->set_user_ptr(env, args[0], 0); 778 | return NIL(env); 779 | } 780 | 781 | static emacs_value sqlite3_api_last_insert_rowid( 782 | emacs_env *env, 783 | ptrdiff_t n, 784 | emacs_value *args, 785 | void *ptr) { 786 | (void)ptr; 787 | (void)n; 788 | 789 | RETURN_NIL_ON_NIL(env, args[0]); 790 | 791 | sqlite3 *dbh = (sqlite3 *)env->get_user_ptr(env, args[0]); 792 | NON_LOCAL_EXIT_CHECK(env); 793 | 794 | return MAKE_INT(env, (intmax_t)sqlite3_last_insert_rowid(dbh)); 795 | } 796 | 797 | 798 | static emacs_value sqlite3_api_set_log_level( 799 | emacs_env *env, 800 | ptrdiff_t n, 801 | emacs_value *args, 802 | void *ptr) { 803 | (void)ptr; 804 | (void)n; 805 | 806 | int log_level = env->extract_integer(env, args[0]); 807 | NON_LOCAL_EXIT_CHECK(env); 808 | sqlite3_api_log_level = log_level; 809 | return NIL(env); 810 | } 811 | 812 | static emacs_value sqlite3_api_open( 813 | emacs_env *env, 814 | ptrdiff_t n, 815 | emacs_value *args, 816 | void *ptr) { 817 | (void)ptr; 818 | (void)n; 819 | 820 | // Filename 821 | char *db_file = 0; 822 | if (extract_string_arg(env, args[0], &db_file)) { 823 | return NIL(env); 824 | } 825 | 826 | // FLAGS 827 | int flags = 0; 828 | for (int i = 1; i < n; i++) { 829 | flags |= env->extract_integer(env, args[i]); 830 | NON_LOCAL_EXIT_CHECK(env); 831 | } 832 | 833 | sqlite3 *dbh = 0; 834 | int rv = sqlite3_open_v2(db_file, &dbh, flags, 0); 835 | INFO(env, "%s: file=%s, flags=%d, rv=%d", __func__, db_file, flags, rv); 836 | FREE(db_file); 837 | 838 | if (rv != SQLITE_OK) { 839 | if (dbh) 840 | sqlite3_free(dbh); 841 | signal_error(env, "db-error", "sqlite_open_v2() failed", rv); 842 | return NIL(env); 843 | } 844 | 845 | return env->make_user_ptr(env, sqlite3_dbh_gc, dbh); 846 | } 847 | 848 | /* (define-error err_sym err_desc) */ 849 | static void define_error( 850 | emacs_env *env, 851 | const char *err_sym, 852 | const char *err_desc) { 853 | emacs_value argv[] = { 854 | SYM(env, err_sym), 855 | MAKE_STR(env, err_desc) 856 | }; 857 | env->funcall(env, SYM(env, "define-error"), 2, argv); 858 | } 859 | 860 | /* Since defconst is a special form, args are NOT evaluated. Hence 861 | eval is needed: 862 | 863 | (eval (list '(defconst sym val)) t) 864 | 865 | Reference: https://phst.github.io/emacs-modules#funcall 866 | */ 867 | static void defconst(emacs_env *env, const char *sym, emacs_value val) { 868 | emacs_value list_argv[] = { 869 | SYM(env, "defconst"), 870 | SYM(env, sym), 871 | val 872 | }; 873 | emacs_value form = MAKE_LIST(env, 3, list_argv); 874 | emacs_value eval_argv[] = { form, SYM(env, "t") }; 875 | env->funcall(env, SYM(env, "eval"), 2, eval_argv); 876 | } 877 | 878 | int emacs_module_init(struct emacs_runtime *ert) { 879 | emacs_env *env = ert->get_environment(ert); 880 | 881 | struct lisp_func { 882 | const char *lisp_func_name; 883 | ptrdiff_t min_arity; 884 | ptrdiff_t max_arity; 885 | emacs_value (*function) (emacs_env *env, 886 | ptrdiff_t nargs, 887 | emacs_value args[], 888 | void *) EMACS_NOEXCEPT; 889 | const char *documentation; 890 | }; 891 | 892 | struct lisp_func all_funcs[] = { 893 | { "sqlite3-open", 1, 10, sqlite3_api_open, 894 | "Open a SQLite3 database." }, 895 | { "sqlite3-close", 1, 1, sqlite3_api_close, 896 | "Close a SQLite3 database." }, 897 | { "sqlite3-prepare", 2, 2, sqlite3_api_prepare, 898 | "Prepare (compile) a SQL statement." }, 899 | { "sqlite3-finalize", 1, 127, sqlite3_api_finalize, 900 | "Destroy a prepared statement." }, 901 | { "sqlite3-changes", 1, 1, sqlite3_api_changes, 902 | "Count the number of rows modified." }, 903 | { "sqlite3-step", 1, 1, sqlite3_api_step, 904 | "Evaluate a SQL statement." }, 905 | { "sqlite3-reset", 1, 1, sqlite3_api_reset, 906 | "Reset a prepared SQL statement." }, 907 | { "sqlite3-last-insert-rowid", 1, 1, sqlite3_api_last_insert_rowid, 908 | "Return last insert rowid." }, 909 | { "sqlite3-get-autocommit", 1, 1, sqlite3_api_get_autocommit, 910 | "Test for auto-commit mode." }, 911 | { "sqlite3-exec", 2, 3, sqlite3_api_exec, 912 | "One-step query execution interface." }, 913 | { "sqlite3-set-log-level", 1, 1, sqlite3_api_set_log_level, 914 | "Set log level (DEBUG 0, INFO 1, WARN 2, ERROR 3, NOLOG 100)." }, 915 | 916 | /* bind interface */ 917 | { "sqlite3-bind-text", 3, 3, sqlite3_api_bind_text, 918 | "Bind text to a prepared SQL statement." }, 919 | { "sqlite3-bind-int64", 3, 3, sqlite3_api_bind_int64, 920 | "Bind int64 to a prepared SQL statement." }, 921 | { "sqlite3-bind-double", 3, 3, sqlite3_api_bind_double, 922 | "Bind double to a prepared SQL statement." }, 923 | { "sqlite3-bind-null", 2, 2, sqlite3_api_bind_null, 924 | "Bind NULL to a prepared SQL statement." }, 925 | { "sqlite3-bind-parameter-count", 1, 1, 926 | sqlite3_api_bind_parameter_count, 927 | "Return the number of SQL parameters." }, 928 | { "sqlite3-bind-multi", 1, 127, sqlite3_api_bind_multi, 929 | "Bind multiple parameters to a prepared SQL statement." }, 930 | 931 | /* Result */ 932 | { "sqlite3-column-count", 1, 1, sqlite3_api_column_count, 933 | "Return the number of rows in a result set." }, 934 | { "sqlite3-column-name", 2, 2, sqlite3_api_column_name, 935 | "Return the name of a column." }, 936 | { "sqlite3-column-type", 2, 2, sqlite3_api_column_type, 937 | "Return the datatype of a column." }, 938 | { "sqlite3-column-text", 2, 2, sqlite3_api_column_text, 939 | "Return text data of a column." }, 940 | { "sqlite3-column-int64", 2, 2, sqlite3_api_column_int64, 941 | "Return int64 data of a column." }, 942 | { "sqlite3-column-double", 2, 2, sqlite3_api_column_double, 943 | "Return double data of a column." }, 944 | { "sqlite3-fetch", 1, 1, sqlite3_api_fetch, 945 | "Return row as a list." }, 946 | { "sqlite3-fetch-alist", 1, 1, sqlite3_api_fetch_alist, 947 | "Return row as an alist." }, 948 | { NULL, 0, 0, NULL, NULL } 949 | }; 950 | 951 | for (int i = 0; all_funcs[i].lisp_func_name != NULL; i++) { 952 | bind_func(env, 953 | all_funcs[i].lisp_func_name, 954 | all_funcs[i].min_arity, 955 | all_funcs[i].max_arity, 956 | all_funcs[i].function, 957 | all_funcs[i].documentation); 958 | } 959 | sqlite3_api_log_level = SQLITE3_LOG_LEVEL_ERROR; 960 | 961 | /* consts.c includes all the (defconst sqlite-xxx ....) function 962 | calls which is generated by tools/gen-consts.sh */ 963 | #include "consts.c" 964 | 965 | define_error(env, "db-error", "Database Error"); 966 | define_error(env, "sql-error", "SQL Error"); 967 | 968 | /* (provide 'sqlite3-module ) */ 969 | emacs_value provide = SYM(env, "provide"); 970 | emacs_value mod = SYM(env, "sqlite3-api"); 971 | env->funcall(env, provide, 1, &mod); 972 | return 0; 973 | } 974 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /consts.c: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License as published by 4 | the Free Software Foundation, either version 3 of the License, or 5 | (at your option) any later version. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | Auto-generated 2020-07-10 12:21:25 18 | Based on https://sqlite.org/c3ref/constlist.html 19 | */ 20 | 21 | #ifdef SQLITE_VERSION 22 | defconst(env, "sqlite-version", env->make_string(env, SQLITE_VERSION, strlen(SQLITE_VERSION))); 23 | #endif 24 | #ifdef SQLITE_VERSION_NUMBER 25 | defconst(env, "sqlite-version-number", env->make_integer(env, SQLITE_VERSION_NUMBER)); 26 | #endif 27 | #ifdef SQLITE_SOURCE_ID 28 | defconst(env, "sqlite-source-id", env->make_string(env, SQLITE_SOURCE_ID, strlen(SQLITE_SOURCE_ID))); 29 | #endif 30 | #ifdef SQLITE_OK 31 | defconst(env, "sqlite-ok", env->make_integer(env, SQLITE_OK)); 32 | #endif 33 | #ifdef SQLITE_ERROR 34 | defconst(env, "sqlite-error", env->make_integer(env, SQLITE_ERROR)); 35 | #endif 36 | #ifdef SQLITE_INTERNAL 37 | defconst(env, "sqlite-internal", env->make_integer(env, SQLITE_INTERNAL)); 38 | #endif 39 | #ifdef SQLITE_PERM 40 | defconst(env, "sqlite-perm", env->make_integer(env, SQLITE_PERM)); 41 | #endif 42 | #ifdef SQLITE_ABORT 43 | defconst(env, "sqlite-abort", env->make_integer(env, SQLITE_ABORT)); 44 | #endif 45 | #ifdef SQLITE_BUSY 46 | defconst(env, "sqlite-busy", env->make_integer(env, SQLITE_BUSY)); 47 | #endif 48 | #ifdef SQLITE_LOCKED 49 | defconst(env, "sqlite-locked", env->make_integer(env, SQLITE_LOCKED)); 50 | #endif 51 | #ifdef SQLITE_NOMEM 52 | defconst(env, "sqlite-nomem", env->make_integer(env, SQLITE_NOMEM)); 53 | #endif 54 | #ifdef SQLITE_READONLY 55 | defconst(env, "sqlite-readonly", env->make_integer(env, SQLITE_READONLY)); 56 | #endif 57 | #ifdef SQLITE_INTERRUPT 58 | defconst(env, "sqlite-interrupt", env->make_integer(env, SQLITE_INTERRUPT)); 59 | #endif 60 | #ifdef SQLITE_IOERR 61 | defconst(env, "sqlite-ioerr", env->make_integer(env, SQLITE_IOERR)); 62 | #endif 63 | #ifdef SQLITE_CORRUPT 64 | defconst(env, "sqlite-corrupt", env->make_integer(env, SQLITE_CORRUPT)); 65 | #endif 66 | #ifdef SQLITE_NOTFOUND 67 | defconst(env, "sqlite-notfound", env->make_integer(env, SQLITE_NOTFOUND)); 68 | #endif 69 | #ifdef SQLITE_FULL 70 | defconst(env, "sqlite-full", env->make_integer(env, SQLITE_FULL)); 71 | #endif 72 | #ifdef SQLITE_CANTOPEN 73 | defconst(env, "sqlite-cantopen", env->make_integer(env, SQLITE_CANTOPEN)); 74 | #endif 75 | #ifdef SQLITE_PROTOCOL 76 | defconst(env, "sqlite-protocol", env->make_integer(env, SQLITE_PROTOCOL)); 77 | #endif 78 | #ifdef SQLITE_EMPTY 79 | defconst(env, "sqlite-empty", env->make_integer(env, SQLITE_EMPTY)); 80 | #endif 81 | #ifdef SQLITE_SCHEMA 82 | defconst(env, "sqlite-schema", env->make_integer(env, SQLITE_SCHEMA)); 83 | #endif 84 | #ifdef SQLITE_TOOBIG 85 | defconst(env, "sqlite-toobig", env->make_integer(env, SQLITE_TOOBIG)); 86 | #endif 87 | #ifdef SQLITE_CONSTRAINT 88 | defconst(env, "sqlite-constraint", env->make_integer(env, SQLITE_CONSTRAINT)); 89 | #endif 90 | #ifdef SQLITE_MISMATCH 91 | defconst(env, "sqlite-mismatch", env->make_integer(env, SQLITE_MISMATCH)); 92 | #endif 93 | #ifdef SQLITE_MISUSE 94 | defconst(env, "sqlite-misuse", env->make_integer(env, SQLITE_MISUSE)); 95 | #endif 96 | #ifdef SQLITE_NOLFS 97 | defconst(env, "sqlite-nolfs", env->make_integer(env, SQLITE_NOLFS)); 98 | #endif 99 | #ifdef SQLITE_AUTH 100 | defconst(env, "sqlite-auth", env->make_integer(env, SQLITE_AUTH)); 101 | #endif 102 | #ifdef SQLITE_FORMAT 103 | defconst(env, "sqlite-format", env->make_integer(env, SQLITE_FORMAT)); 104 | #endif 105 | #ifdef SQLITE_RANGE 106 | defconst(env, "sqlite-range", env->make_integer(env, SQLITE_RANGE)); 107 | #endif 108 | #ifdef SQLITE_NOTADB 109 | defconst(env, "sqlite-notadb", env->make_integer(env, SQLITE_NOTADB)); 110 | #endif 111 | #ifdef SQLITE_NOTICE 112 | defconst(env, "sqlite-notice", env->make_integer(env, SQLITE_NOTICE)); 113 | #endif 114 | #ifdef SQLITE_WARNING 115 | defconst(env, "sqlite-warning", env->make_integer(env, SQLITE_WARNING)); 116 | #endif 117 | #ifdef SQLITE_ROW 118 | defconst(env, "sqlite-row", env->make_integer(env, SQLITE_ROW)); 119 | #endif 120 | #ifdef SQLITE_DONE 121 | defconst(env, "sqlite-done", env->make_integer(env, SQLITE_DONE)); 122 | #endif 123 | #ifdef SQLITE_ERROR_MISSING_COLLSEQ 124 | defconst(env, "sqlite-error-missing-collseq", env->make_integer(env, SQLITE_ERROR_MISSING_COLLSEQ)); 125 | #endif 126 | #ifdef SQLITE_ERROR_RETRY 127 | defconst(env, "sqlite-error-retry", env->make_integer(env, SQLITE_ERROR_RETRY)); 128 | #endif 129 | #ifdef SQLITE_ERROR_SNAPSHOT 130 | defconst(env, "sqlite-error-snapshot", env->make_integer(env, SQLITE_ERROR_SNAPSHOT)); 131 | #endif 132 | #ifdef SQLITE_IOERR_READ 133 | defconst(env, "sqlite-ioerr-read", env->make_integer(env, SQLITE_IOERR_READ)); 134 | #endif 135 | #ifdef SQLITE_IOERR_SHORT_READ 136 | defconst(env, "sqlite-ioerr-short-read", env->make_integer(env, SQLITE_IOERR_SHORT_READ)); 137 | #endif 138 | #ifdef SQLITE_IOERR_WRITE 139 | defconst(env, "sqlite-ioerr-write", env->make_integer(env, SQLITE_IOERR_WRITE)); 140 | #endif 141 | #ifdef SQLITE_IOERR_FSYNC 142 | defconst(env, "sqlite-ioerr-fsync", env->make_integer(env, SQLITE_IOERR_FSYNC)); 143 | #endif 144 | #ifdef SQLITE_IOERR_DIR_FSYNC 145 | defconst(env, "sqlite-ioerr-dir-fsync", env->make_integer(env, SQLITE_IOERR_DIR_FSYNC)); 146 | #endif 147 | #ifdef SQLITE_IOERR_TRUNCATE 148 | defconst(env, "sqlite-ioerr-truncate", env->make_integer(env, SQLITE_IOERR_TRUNCATE)); 149 | #endif 150 | #ifdef SQLITE_IOERR_FSTAT 151 | defconst(env, "sqlite-ioerr-fstat", env->make_integer(env, SQLITE_IOERR_FSTAT)); 152 | #endif 153 | #ifdef SQLITE_IOERR_UNLOCK 154 | defconst(env, "sqlite-ioerr-unlock", env->make_integer(env, SQLITE_IOERR_UNLOCK)); 155 | #endif 156 | #ifdef SQLITE_IOERR_RDLOCK 157 | defconst(env, "sqlite-ioerr-rdlock", env->make_integer(env, SQLITE_IOERR_RDLOCK)); 158 | #endif 159 | #ifdef SQLITE_IOERR_DELETE 160 | defconst(env, "sqlite-ioerr-delete", env->make_integer(env, SQLITE_IOERR_DELETE)); 161 | #endif 162 | #ifdef SQLITE_IOERR_BLOCKED 163 | defconst(env, "sqlite-ioerr-blocked", env->make_integer(env, SQLITE_IOERR_BLOCKED)); 164 | #endif 165 | #ifdef SQLITE_IOERR_NOMEM 166 | defconst(env, "sqlite-ioerr-nomem", env->make_integer(env, SQLITE_IOERR_NOMEM)); 167 | #endif 168 | #ifdef SQLITE_IOERR_ACCESS 169 | defconst(env, "sqlite-ioerr-access", env->make_integer(env, SQLITE_IOERR_ACCESS)); 170 | #endif 171 | #ifdef SQLITE_IOERR_CHECKRESERVEDLOCK 172 | defconst(env, "sqlite-ioerr-checkreservedlock", env->make_integer(env, SQLITE_IOERR_CHECKRESERVEDLOCK)); 173 | #endif 174 | #ifdef SQLITE_IOERR_LOCK 175 | defconst(env, "sqlite-ioerr-lock", env->make_integer(env, SQLITE_IOERR_LOCK)); 176 | #endif 177 | #ifdef SQLITE_IOERR_CLOSE 178 | defconst(env, "sqlite-ioerr-close", env->make_integer(env, SQLITE_IOERR_CLOSE)); 179 | #endif 180 | #ifdef SQLITE_IOERR_DIR_CLOSE 181 | defconst(env, "sqlite-ioerr-dir-close", env->make_integer(env, SQLITE_IOERR_DIR_CLOSE)); 182 | #endif 183 | #ifdef SQLITE_IOERR_SHMOPEN 184 | defconst(env, "sqlite-ioerr-shmopen", env->make_integer(env, SQLITE_IOERR_SHMOPEN)); 185 | #endif 186 | #ifdef SQLITE_IOERR_SHMSIZE 187 | defconst(env, "sqlite-ioerr-shmsize", env->make_integer(env, SQLITE_IOERR_SHMSIZE)); 188 | #endif 189 | #ifdef SQLITE_IOERR_SHMLOCK 190 | defconst(env, "sqlite-ioerr-shmlock", env->make_integer(env, SQLITE_IOERR_SHMLOCK)); 191 | #endif 192 | #ifdef SQLITE_IOERR_SHMMAP 193 | defconst(env, "sqlite-ioerr-shmmap", env->make_integer(env, SQLITE_IOERR_SHMMAP)); 194 | #endif 195 | #ifdef SQLITE_IOERR_SEEK 196 | defconst(env, "sqlite-ioerr-seek", env->make_integer(env, SQLITE_IOERR_SEEK)); 197 | #endif 198 | #ifdef SQLITE_IOERR_DELETE_NOENT 199 | defconst(env, "sqlite-ioerr-delete-noent", env->make_integer(env, SQLITE_IOERR_DELETE_NOENT)); 200 | #endif 201 | #ifdef SQLITE_IOERR_MMAP 202 | defconst(env, "sqlite-ioerr-mmap", env->make_integer(env, SQLITE_IOERR_MMAP)); 203 | #endif 204 | #ifdef SQLITE_IOERR_GETTEMPPATH 205 | defconst(env, "sqlite-ioerr-gettemppath", env->make_integer(env, SQLITE_IOERR_GETTEMPPATH)); 206 | #endif 207 | #ifdef SQLITE_IOERR_CONVPATH 208 | defconst(env, "sqlite-ioerr-convpath", env->make_integer(env, SQLITE_IOERR_CONVPATH)); 209 | #endif 210 | #ifdef SQLITE_IOERR_VNODE 211 | defconst(env, "sqlite-ioerr-vnode", env->make_integer(env, SQLITE_IOERR_VNODE)); 212 | #endif 213 | #ifdef SQLITE_IOERR_AUTH 214 | defconst(env, "sqlite-ioerr-auth", env->make_integer(env, SQLITE_IOERR_AUTH)); 215 | #endif 216 | #ifdef SQLITE_IOERR_BEGIN_ATOMIC 217 | defconst(env, "sqlite-ioerr-begin-atomic", env->make_integer(env, SQLITE_IOERR_BEGIN_ATOMIC)); 218 | #endif 219 | #ifdef SQLITE_IOERR_COMMIT_ATOMIC 220 | defconst(env, "sqlite-ioerr-commit-atomic", env->make_integer(env, SQLITE_IOERR_COMMIT_ATOMIC)); 221 | #endif 222 | #ifdef SQLITE_IOERR_ROLLBACK_ATOMIC 223 | defconst(env, "sqlite-ioerr-rollback-atomic", env->make_integer(env, SQLITE_IOERR_ROLLBACK_ATOMIC)); 224 | #endif 225 | #ifdef SQLITE_IOERR_DATA 226 | defconst(env, "sqlite-ioerr-data", env->make_integer(env, SQLITE_IOERR_DATA)); 227 | #endif 228 | #ifdef SQLITE_LOCKED_SHAREDCACHE 229 | defconst(env, "sqlite-locked-sharedcache", env->make_integer(env, SQLITE_LOCKED_SHAREDCACHE)); 230 | #endif 231 | #ifdef SQLITE_LOCKED_VTAB 232 | defconst(env, "sqlite-locked-vtab", env->make_integer(env, SQLITE_LOCKED_VTAB)); 233 | #endif 234 | #ifdef SQLITE_BUSY_RECOVERY 235 | defconst(env, "sqlite-busy-recovery", env->make_integer(env, SQLITE_BUSY_RECOVERY)); 236 | #endif 237 | #ifdef SQLITE_BUSY_SNAPSHOT 238 | defconst(env, "sqlite-busy-snapshot", env->make_integer(env, SQLITE_BUSY_SNAPSHOT)); 239 | #endif 240 | #ifdef SQLITE_BUSY_TIMEOUT 241 | defconst(env, "sqlite-busy-timeout", env->make_integer(env, SQLITE_BUSY_TIMEOUT)); 242 | #endif 243 | #ifdef SQLITE_CANTOPEN_NOTEMPDIR 244 | defconst(env, "sqlite-cantopen-notempdir", env->make_integer(env, SQLITE_CANTOPEN_NOTEMPDIR)); 245 | #endif 246 | #ifdef SQLITE_CANTOPEN_ISDIR 247 | defconst(env, "sqlite-cantopen-isdir", env->make_integer(env, SQLITE_CANTOPEN_ISDIR)); 248 | #endif 249 | #ifdef SQLITE_CANTOPEN_FULLPATH 250 | defconst(env, "sqlite-cantopen-fullpath", env->make_integer(env, SQLITE_CANTOPEN_FULLPATH)); 251 | #endif 252 | #ifdef SQLITE_CANTOPEN_CONVPATH 253 | defconst(env, "sqlite-cantopen-convpath", env->make_integer(env, SQLITE_CANTOPEN_CONVPATH)); 254 | #endif 255 | #ifdef SQLITE_CANTOPEN_DIRTYWAL 256 | defconst(env, "sqlite-cantopen-dirtywal", env->make_integer(env, SQLITE_CANTOPEN_DIRTYWAL)); 257 | #endif 258 | #ifdef SQLITE_CANTOPEN_SYMLINK 259 | defconst(env, "sqlite-cantopen-symlink", env->make_integer(env, SQLITE_CANTOPEN_SYMLINK)); 260 | #endif 261 | #ifdef SQLITE_CORRUPT_VTAB 262 | defconst(env, "sqlite-corrupt-vtab", env->make_integer(env, SQLITE_CORRUPT_VTAB)); 263 | #endif 264 | #ifdef SQLITE_CORRUPT_SEQUENCE 265 | defconst(env, "sqlite-corrupt-sequence", env->make_integer(env, SQLITE_CORRUPT_SEQUENCE)); 266 | #endif 267 | #ifdef SQLITE_CORRUPT_INDEX 268 | defconst(env, "sqlite-corrupt-index", env->make_integer(env, SQLITE_CORRUPT_INDEX)); 269 | #endif 270 | #ifdef SQLITE_READONLY_RECOVERY 271 | defconst(env, "sqlite-readonly-recovery", env->make_integer(env, SQLITE_READONLY_RECOVERY)); 272 | #endif 273 | #ifdef SQLITE_READONLY_CANTLOCK 274 | defconst(env, "sqlite-readonly-cantlock", env->make_integer(env, SQLITE_READONLY_CANTLOCK)); 275 | #endif 276 | #ifdef SQLITE_READONLY_ROLLBACK 277 | defconst(env, "sqlite-readonly-rollback", env->make_integer(env, SQLITE_READONLY_ROLLBACK)); 278 | #endif 279 | #ifdef SQLITE_READONLY_DBMOVED 280 | defconst(env, "sqlite-readonly-dbmoved", env->make_integer(env, SQLITE_READONLY_DBMOVED)); 281 | #endif 282 | #ifdef SQLITE_READONLY_CANTINIT 283 | defconst(env, "sqlite-readonly-cantinit", env->make_integer(env, SQLITE_READONLY_CANTINIT)); 284 | #endif 285 | #ifdef SQLITE_READONLY_DIRECTORY 286 | defconst(env, "sqlite-readonly-directory", env->make_integer(env, SQLITE_READONLY_DIRECTORY)); 287 | #endif 288 | #ifdef SQLITE_ABORT_ROLLBACK 289 | defconst(env, "sqlite-abort-rollback", env->make_integer(env, SQLITE_ABORT_ROLLBACK)); 290 | #endif 291 | #ifdef SQLITE_CONSTRAINT_CHECK 292 | defconst(env, "sqlite-constraint-check", env->make_integer(env, SQLITE_CONSTRAINT_CHECK)); 293 | #endif 294 | #ifdef SQLITE_CONSTRAINT_COMMITHOOK 295 | defconst(env, "sqlite-constraint-commithook", env->make_integer(env, SQLITE_CONSTRAINT_COMMITHOOK)); 296 | #endif 297 | #ifdef SQLITE_CONSTRAINT_FOREIGNKEY 298 | defconst(env, "sqlite-constraint-foreignkey", env->make_integer(env, SQLITE_CONSTRAINT_FOREIGNKEY)); 299 | #endif 300 | #ifdef SQLITE_CONSTRAINT_FUNCTION 301 | defconst(env, "sqlite-constraint-function", env->make_integer(env, SQLITE_CONSTRAINT_FUNCTION)); 302 | #endif 303 | #ifdef SQLITE_CONSTRAINT_NOTNULL 304 | defconst(env, "sqlite-constraint-notnull", env->make_integer(env, SQLITE_CONSTRAINT_NOTNULL)); 305 | #endif 306 | #ifdef SQLITE_CONSTRAINT_PRIMARYKEY 307 | defconst(env, "sqlite-constraint-primarykey", env->make_integer(env, SQLITE_CONSTRAINT_PRIMARYKEY)); 308 | #endif 309 | #ifdef SQLITE_CONSTRAINT_TRIGGER 310 | defconst(env, "sqlite-constraint-trigger", env->make_integer(env, SQLITE_CONSTRAINT_TRIGGER)); 311 | #endif 312 | #ifdef SQLITE_CONSTRAINT_UNIQUE 313 | defconst(env, "sqlite-constraint-unique", env->make_integer(env, SQLITE_CONSTRAINT_UNIQUE)); 314 | #endif 315 | #ifdef SQLITE_CONSTRAINT_VTAB 316 | defconst(env, "sqlite-constraint-vtab", env->make_integer(env, SQLITE_CONSTRAINT_VTAB)); 317 | #endif 318 | #ifdef SQLITE_CONSTRAINT_ROWID 319 | defconst(env, "sqlite-constraint-rowid", env->make_integer(env, SQLITE_CONSTRAINT_ROWID)); 320 | #endif 321 | #ifdef SQLITE_CONSTRAINT_PINNED 322 | defconst(env, "sqlite-constraint-pinned", env->make_integer(env, SQLITE_CONSTRAINT_PINNED)); 323 | #endif 324 | #ifdef SQLITE_NOTICE_RECOVER_WAL 325 | defconst(env, "sqlite-notice-recover-wal", env->make_integer(env, SQLITE_NOTICE_RECOVER_WAL)); 326 | #endif 327 | #ifdef SQLITE_NOTICE_RECOVER_ROLLBACK 328 | defconst(env, "sqlite-notice-recover-rollback", env->make_integer(env, SQLITE_NOTICE_RECOVER_ROLLBACK)); 329 | #endif 330 | #ifdef SQLITE_WARNING_AUTOINDEX 331 | defconst(env, "sqlite-warning-autoindex", env->make_integer(env, SQLITE_WARNING_AUTOINDEX)); 332 | #endif 333 | #ifdef SQLITE_AUTH_USER 334 | defconst(env, "sqlite-auth-user", env->make_integer(env, SQLITE_AUTH_USER)); 335 | #endif 336 | #ifdef SQLITE_OK_LOAD_PERMANENTLY 337 | defconst(env, "sqlite-ok-load-permanently", env->make_integer(env, SQLITE_OK_LOAD_PERMANENTLY)); 338 | #endif 339 | #ifdef SQLITE_OK_SYMLINK 340 | defconst(env, "sqlite-ok-symlink", env->make_integer(env, SQLITE_OK_SYMLINK)); 341 | #endif 342 | #ifdef SQLITE_OPEN_READONLY 343 | defconst(env, "sqlite-open-readonly", env->make_integer(env, SQLITE_OPEN_READONLY)); 344 | #endif 345 | #ifdef SQLITE_OPEN_READWRITE 346 | defconst(env, "sqlite-open-readwrite", env->make_integer(env, SQLITE_OPEN_READWRITE)); 347 | #endif 348 | #ifdef SQLITE_OPEN_CREATE 349 | defconst(env, "sqlite-open-create", env->make_integer(env, SQLITE_OPEN_CREATE)); 350 | #endif 351 | #ifdef SQLITE_OPEN_DELETEONCLOSE 352 | defconst(env, "sqlite-open-deleteonclose", env->make_integer(env, SQLITE_OPEN_DELETEONCLOSE)); 353 | #endif 354 | #ifdef SQLITE_OPEN_EXCLUSIVE 355 | defconst(env, "sqlite-open-exclusive", env->make_integer(env, SQLITE_OPEN_EXCLUSIVE)); 356 | #endif 357 | #ifdef SQLITE_OPEN_AUTOPROXY 358 | defconst(env, "sqlite-open-autoproxy", env->make_integer(env, SQLITE_OPEN_AUTOPROXY)); 359 | #endif 360 | #ifdef SQLITE_OPEN_URI 361 | defconst(env, "sqlite-open-uri", env->make_integer(env, SQLITE_OPEN_URI)); 362 | #endif 363 | #ifdef SQLITE_OPEN_MEMORY 364 | defconst(env, "sqlite-open-memory", env->make_integer(env, SQLITE_OPEN_MEMORY)); 365 | #endif 366 | #ifdef SQLITE_OPEN_MAIN_DB 367 | defconst(env, "sqlite-open-main-db", env->make_integer(env, SQLITE_OPEN_MAIN_DB)); 368 | #endif 369 | #ifdef SQLITE_OPEN_TEMP_DB 370 | defconst(env, "sqlite-open-temp-db", env->make_integer(env, SQLITE_OPEN_TEMP_DB)); 371 | #endif 372 | #ifdef SQLITE_OPEN_TRANSIENT_DB 373 | defconst(env, "sqlite-open-transient-db", env->make_integer(env, SQLITE_OPEN_TRANSIENT_DB)); 374 | #endif 375 | #ifdef SQLITE_OPEN_MAIN_JOURNAL 376 | defconst(env, "sqlite-open-main-journal", env->make_integer(env, SQLITE_OPEN_MAIN_JOURNAL)); 377 | #endif 378 | #ifdef SQLITE_OPEN_TEMP_JOURNAL 379 | defconst(env, "sqlite-open-temp-journal", env->make_integer(env, SQLITE_OPEN_TEMP_JOURNAL)); 380 | #endif 381 | #ifdef SQLITE_OPEN_SUBJOURNAL 382 | defconst(env, "sqlite-open-subjournal", env->make_integer(env, SQLITE_OPEN_SUBJOURNAL)); 383 | #endif 384 | #ifdef SQLITE_OPEN_MASTER_JOURNAL 385 | defconst(env, "sqlite-open-master-journal", env->make_integer(env, SQLITE_OPEN_MASTER_JOURNAL)); 386 | #endif 387 | #ifdef SQLITE_OPEN_NOMUTEX 388 | defconst(env, "sqlite-open-nomutex", env->make_integer(env, SQLITE_OPEN_NOMUTEX)); 389 | #endif 390 | #ifdef SQLITE_OPEN_FULLMUTEX 391 | defconst(env, "sqlite-open-fullmutex", env->make_integer(env, SQLITE_OPEN_FULLMUTEX)); 392 | #endif 393 | #ifdef SQLITE_OPEN_SHAREDCACHE 394 | defconst(env, "sqlite-open-sharedcache", env->make_integer(env, SQLITE_OPEN_SHAREDCACHE)); 395 | #endif 396 | #ifdef SQLITE_OPEN_PRIVATECACHE 397 | defconst(env, "sqlite-open-privatecache", env->make_integer(env, SQLITE_OPEN_PRIVATECACHE)); 398 | #endif 399 | #ifdef SQLITE_OPEN_WAL 400 | defconst(env, "sqlite-open-wal", env->make_integer(env, SQLITE_OPEN_WAL)); 401 | #endif 402 | #ifdef SQLITE_OPEN_NOFOLLOW 403 | defconst(env, "sqlite-open-nofollow", env->make_integer(env, SQLITE_OPEN_NOFOLLOW)); 404 | #endif 405 | #ifdef SQLITE_IOCAP_ATOMIC 406 | defconst(env, "sqlite-iocap-atomic", env->make_integer(env, SQLITE_IOCAP_ATOMIC)); 407 | #endif 408 | #ifdef SQLITE_IOCAP_ATOMIC512 409 | defconst(env, "sqlite-iocap-atomic512", env->make_integer(env, SQLITE_IOCAP_ATOMIC512)); 410 | #endif 411 | #ifdef SQLITE_IOCAP_ATOMIC1K 412 | defconst(env, "sqlite-iocap-atomic1k", env->make_integer(env, SQLITE_IOCAP_ATOMIC1K)); 413 | #endif 414 | #ifdef SQLITE_IOCAP_ATOMIC2K 415 | defconst(env, "sqlite-iocap-atomic2k", env->make_integer(env, SQLITE_IOCAP_ATOMIC2K)); 416 | #endif 417 | #ifdef SQLITE_IOCAP_ATOMIC4K 418 | defconst(env, "sqlite-iocap-atomic4k", env->make_integer(env, SQLITE_IOCAP_ATOMIC4K)); 419 | #endif 420 | #ifdef SQLITE_IOCAP_ATOMIC8K 421 | defconst(env, "sqlite-iocap-atomic8k", env->make_integer(env, SQLITE_IOCAP_ATOMIC8K)); 422 | #endif 423 | #ifdef SQLITE_IOCAP_ATOMIC16K 424 | defconst(env, "sqlite-iocap-atomic16k", env->make_integer(env, SQLITE_IOCAP_ATOMIC16K)); 425 | #endif 426 | #ifdef SQLITE_IOCAP_ATOMIC32K 427 | defconst(env, "sqlite-iocap-atomic32k", env->make_integer(env, SQLITE_IOCAP_ATOMIC32K)); 428 | #endif 429 | #ifdef SQLITE_IOCAP_ATOMIC64K 430 | defconst(env, "sqlite-iocap-atomic64k", env->make_integer(env, SQLITE_IOCAP_ATOMIC64K)); 431 | #endif 432 | #ifdef SQLITE_IOCAP_SAFE_APPEND 433 | defconst(env, "sqlite-iocap-safe-append", env->make_integer(env, SQLITE_IOCAP_SAFE_APPEND)); 434 | #endif 435 | #ifdef SQLITE_IOCAP_SEQUENTIAL 436 | defconst(env, "sqlite-iocap-sequential", env->make_integer(env, SQLITE_IOCAP_SEQUENTIAL)); 437 | #endif 438 | #ifdef SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 439 | defconst(env, "sqlite-iocap-undeletable-when-open", env->make_integer(env, SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN)); 440 | #endif 441 | #ifdef SQLITE_IOCAP_POWERSAFE_OVERWRITE 442 | defconst(env, "sqlite-iocap-powersafe-overwrite", env->make_integer(env, SQLITE_IOCAP_POWERSAFE_OVERWRITE)); 443 | #endif 444 | #ifdef SQLITE_IOCAP_IMMUTABLE 445 | defconst(env, "sqlite-iocap-immutable", env->make_integer(env, SQLITE_IOCAP_IMMUTABLE)); 446 | #endif 447 | #ifdef SQLITE_IOCAP_BATCH_ATOMIC 448 | defconst(env, "sqlite-iocap-batch-atomic", env->make_integer(env, SQLITE_IOCAP_BATCH_ATOMIC)); 449 | #endif 450 | #ifdef SQLITE_LOCK_NONE 451 | defconst(env, "sqlite-lock-none", env->make_integer(env, SQLITE_LOCK_NONE)); 452 | #endif 453 | #ifdef SQLITE_LOCK_SHARED 454 | defconst(env, "sqlite-lock-shared", env->make_integer(env, SQLITE_LOCK_SHARED)); 455 | #endif 456 | #ifdef SQLITE_LOCK_RESERVED 457 | defconst(env, "sqlite-lock-reserved", env->make_integer(env, SQLITE_LOCK_RESERVED)); 458 | #endif 459 | #ifdef SQLITE_LOCK_PENDING 460 | defconst(env, "sqlite-lock-pending", env->make_integer(env, SQLITE_LOCK_PENDING)); 461 | #endif 462 | #ifdef SQLITE_LOCK_EXCLUSIVE 463 | defconst(env, "sqlite-lock-exclusive", env->make_integer(env, SQLITE_LOCK_EXCLUSIVE)); 464 | #endif 465 | #ifdef SQLITE_SYNC_NORMAL 466 | defconst(env, "sqlite-sync-normal", env->make_integer(env, SQLITE_SYNC_NORMAL)); 467 | #endif 468 | #ifdef SQLITE_SYNC_FULL 469 | defconst(env, "sqlite-sync-full", env->make_integer(env, SQLITE_SYNC_FULL)); 470 | #endif 471 | #ifdef SQLITE_SYNC_DATAONLY 472 | defconst(env, "sqlite-sync-dataonly", env->make_integer(env, SQLITE_SYNC_DATAONLY)); 473 | #endif 474 | #ifdef SQLITE_FCNTL_LOCKSTATE 475 | defconst(env, "sqlite-fcntl-lockstate", env->make_integer(env, SQLITE_FCNTL_LOCKSTATE)); 476 | #endif 477 | #ifdef SQLITE_FCNTL_GET_LOCKPROXYFILE 478 | defconst(env, "sqlite-fcntl-get-lockproxyfile", env->make_integer(env, SQLITE_FCNTL_GET_LOCKPROXYFILE)); 479 | #endif 480 | #ifdef SQLITE_FCNTL_SET_LOCKPROXYFILE 481 | defconst(env, "sqlite-fcntl-set-lockproxyfile", env->make_integer(env, SQLITE_FCNTL_SET_LOCKPROXYFILE)); 482 | #endif 483 | #ifdef SQLITE_FCNTL_LAST_ERRNO 484 | defconst(env, "sqlite-fcntl-last-errno", env->make_integer(env, SQLITE_FCNTL_LAST_ERRNO)); 485 | #endif 486 | #ifdef SQLITE_FCNTL_SIZE_HINT 487 | defconst(env, "sqlite-fcntl-size-hint", env->make_integer(env, SQLITE_FCNTL_SIZE_HINT)); 488 | #endif 489 | #ifdef SQLITE_FCNTL_CHUNK_SIZE 490 | defconst(env, "sqlite-fcntl-chunk-size", env->make_integer(env, SQLITE_FCNTL_CHUNK_SIZE)); 491 | #endif 492 | #ifdef SQLITE_FCNTL_FILE_POINTER 493 | defconst(env, "sqlite-fcntl-file-pointer", env->make_integer(env, SQLITE_FCNTL_FILE_POINTER)); 494 | #endif 495 | #ifdef SQLITE_FCNTL_SYNC_OMITTED 496 | defconst(env, "sqlite-fcntl-sync-omitted", env->make_integer(env, SQLITE_FCNTL_SYNC_OMITTED)); 497 | #endif 498 | #ifdef SQLITE_FCNTL_WIN32_AV_RETRY 499 | defconst(env, "sqlite-fcntl-win32-av-retry", env->make_integer(env, SQLITE_FCNTL_WIN32_AV_RETRY)); 500 | #endif 501 | #ifdef SQLITE_FCNTL_PERSIST_WAL 502 | defconst(env, "sqlite-fcntl-persist-wal", env->make_integer(env, SQLITE_FCNTL_PERSIST_WAL)); 503 | #endif 504 | #ifdef SQLITE_FCNTL_OVERWRITE 505 | defconst(env, "sqlite-fcntl-overwrite", env->make_integer(env, SQLITE_FCNTL_OVERWRITE)); 506 | #endif 507 | #ifdef SQLITE_FCNTL_VFSNAME 508 | defconst(env, "sqlite-fcntl-vfsname", env->make_integer(env, SQLITE_FCNTL_VFSNAME)); 509 | #endif 510 | #ifdef SQLITE_FCNTL_POWERSAFE_OVERWRITE 511 | defconst(env, "sqlite-fcntl-powersafe-overwrite", env->make_integer(env, SQLITE_FCNTL_POWERSAFE_OVERWRITE)); 512 | #endif 513 | #ifdef SQLITE_FCNTL_PRAGMA 514 | defconst(env, "sqlite-fcntl-pragma", env->make_integer(env, SQLITE_FCNTL_PRAGMA)); 515 | #endif 516 | #ifdef SQLITE_FCNTL_BUSYHANDLER 517 | defconst(env, "sqlite-fcntl-busyhandler", env->make_integer(env, SQLITE_FCNTL_BUSYHANDLER)); 518 | #endif 519 | #ifdef SQLITE_FCNTL_TEMPFILENAME 520 | defconst(env, "sqlite-fcntl-tempfilename", env->make_integer(env, SQLITE_FCNTL_TEMPFILENAME)); 521 | #endif 522 | #ifdef SQLITE_FCNTL_MMAP_SIZE 523 | defconst(env, "sqlite-fcntl-mmap-size", env->make_integer(env, SQLITE_FCNTL_MMAP_SIZE)); 524 | #endif 525 | #ifdef SQLITE_FCNTL_TRACE 526 | defconst(env, "sqlite-fcntl-trace", env->make_integer(env, SQLITE_FCNTL_TRACE)); 527 | #endif 528 | #ifdef SQLITE_FCNTL_HAS_MOVED 529 | defconst(env, "sqlite-fcntl-has-moved", env->make_integer(env, SQLITE_FCNTL_HAS_MOVED)); 530 | #endif 531 | #ifdef SQLITE_FCNTL_SYNC 532 | defconst(env, "sqlite-fcntl-sync", env->make_integer(env, SQLITE_FCNTL_SYNC)); 533 | #endif 534 | #ifdef SQLITE_FCNTL_COMMIT_PHASETWO 535 | defconst(env, "sqlite-fcntl-commit-phasetwo", env->make_integer(env, SQLITE_FCNTL_COMMIT_PHASETWO)); 536 | #endif 537 | #ifdef SQLITE_FCNTL_WIN32_SET_HANDLE 538 | defconst(env, "sqlite-fcntl-win32-set-handle", env->make_integer(env, SQLITE_FCNTL_WIN32_SET_HANDLE)); 539 | #endif 540 | #ifdef SQLITE_FCNTL_WAL_BLOCK 541 | defconst(env, "sqlite-fcntl-wal-block", env->make_integer(env, SQLITE_FCNTL_WAL_BLOCK)); 542 | #endif 543 | #ifdef SQLITE_FCNTL_ZIPVFS 544 | defconst(env, "sqlite-fcntl-zipvfs", env->make_integer(env, SQLITE_FCNTL_ZIPVFS)); 545 | #endif 546 | #ifdef SQLITE_FCNTL_RBU 547 | defconst(env, "sqlite-fcntl-rbu", env->make_integer(env, SQLITE_FCNTL_RBU)); 548 | #endif 549 | #ifdef SQLITE_FCNTL_VFS_POINTER 550 | defconst(env, "sqlite-fcntl-vfs-pointer", env->make_integer(env, SQLITE_FCNTL_VFS_POINTER)); 551 | #endif 552 | #ifdef SQLITE_FCNTL_JOURNAL_POINTER 553 | defconst(env, "sqlite-fcntl-journal-pointer", env->make_integer(env, SQLITE_FCNTL_JOURNAL_POINTER)); 554 | #endif 555 | #ifdef SQLITE_FCNTL_WIN32_GET_HANDLE 556 | defconst(env, "sqlite-fcntl-win32-get-handle", env->make_integer(env, SQLITE_FCNTL_WIN32_GET_HANDLE)); 557 | #endif 558 | #ifdef SQLITE_FCNTL_PDB 559 | defconst(env, "sqlite-fcntl-pdb", env->make_integer(env, SQLITE_FCNTL_PDB)); 560 | #endif 561 | #ifdef SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 562 | defconst(env, "sqlite-fcntl-begin-atomic-write", env->make_integer(env, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE)); 563 | #endif 564 | #ifdef SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 565 | defconst(env, "sqlite-fcntl-commit-atomic-write", env->make_integer(env, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE)); 566 | #endif 567 | #ifdef SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 568 | defconst(env, "sqlite-fcntl-rollback-atomic-write", env->make_integer(env, SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE)); 569 | #endif 570 | #ifdef SQLITE_FCNTL_LOCK_TIMEOUT 571 | defconst(env, "sqlite-fcntl-lock-timeout", env->make_integer(env, SQLITE_FCNTL_LOCK_TIMEOUT)); 572 | #endif 573 | #ifdef SQLITE_FCNTL_DATA_VERSION 574 | defconst(env, "sqlite-fcntl-data-version", env->make_integer(env, SQLITE_FCNTL_DATA_VERSION)); 575 | #endif 576 | #ifdef SQLITE_FCNTL_SIZE_LIMIT 577 | defconst(env, "sqlite-fcntl-size-limit", env->make_integer(env, SQLITE_FCNTL_SIZE_LIMIT)); 578 | #endif 579 | #ifdef SQLITE_FCNTL_CKPT_DONE 580 | defconst(env, "sqlite-fcntl-ckpt-done", env->make_integer(env, SQLITE_FCNTL_CKPT_DONE)); 581 | #endif 582 | #ifdef SQLITE_FCNTL_RESERVE_BYTES 583 | defconst(env, "sqlite-fcntl-reserve-bytes", env->make_integer(env, SQLITE_FCNTL_RESERVE_BYTES)); 584 | #endif 585 | #ifdef SQLITE_FCNTL_CKPT_START 586 | defconst(env, "sqlite-fcntl-ckpt-start", env->make_integer(env, SQLITE_FCNTL_CKPT_START)); 587 | #endif 588 | #ifdef SQLITE_ACCESS_EXISTS 589 | defconst(env, "sqlite-access-exists", env->make_integer(env, SQLITE_ACCESS_EXISTS)); 590 | #endif 591 | #ifdef SQLITE_ACCESS_READWRITE 592 | defconst(env, "sqlite-access-readwrite", env->make_integer(env, SQLITE_ACCESS_READWRITE)); 593 | #endif 594 | #ifdef SQLITE_ACCESS_READ 595 | defconst(env, "sqlite-access-read", env->make_integer(env, SQLITE_ACCESS_READ)); 596 | #endif 597 | #ifdef SQLITE_SHM_UNLOCK 598 | defconst(env, "sqlite-shm-unlock", env->make_integer(env, SQLITE_SHM_UNLOCK)); 599 | #endif 600 | #ifdef SQLITE_SHM_LOCK 601 | defconst(env, "sqlite-shm-lock", env->make_integer(env, SQLITE_SHM_LOCK)); 602 | #endif 603 | #ifdef SQLITE_SHM_SHARED 604 | defconst(env, "sqlite-shm-shared", env->make_integer(env, SQLITE_SHM_SHARED)); 605 | #endif 606 | #ifdef SQLITE_SHM_EXCLUSIVE 607 | defconst(env, "sqlite-shm-exclusive", env->make_integer(env, SQLITE_SHM_EXCLUSIVE)); 608 | #endif 609 | #ifdef SQLITE_SHM_NLOCK 610 | defconst(env, "sqlite-shm-nlock", env->make_integer(env, SQLITE_SHM_NLOCK)); 611 | #endif 612 | #ifdef SQLITE_CONFIG_SINGLETHREAD 613 | defconst(env, "sqlite-config-singlethread", env->make_integer(env, SQLITE_CONFIG_SINGLETHREAD)); 614 | #endif 615 | #ifdef SQLITE_CONFIG_MULTITHREAD 616 | defconst(env, "sqlite-config-multithread", env->make_integer(env, SQLITE_CONFIG_MULTITHREAD)); 617 | #endif 618 | #ifdef SQLITE_CONFIG_SERIALIZED 619 | defconst(env, "sqlite-config-serialized", env->make_integer(env, SQLITE_CONFIG_SERIALIZED)); 620 | #endif 621 | #ifdef SQLITE_CONFIG_MALLOC 622 | defconst(env, "sqlite-config-malloc", env->make_integer(env, SQLITE_CONFIG_MALLOC)); 623 | #endif 624 | #ifdef SQLITE_CONFIG_GETMALLOC 625 | defconst(env, "sqlite-config-getmalloc", env->make_integer(env, SQLITE_CONFIG_GETMALLOC)); 626 | #endif 627 | #ifdef SQLITE_CONFIG_SCRATCH 628 | defconst(env, "sqlite-config-scratch", env->make_integer(env, SQLITE_CONFIG_SCRATCH)); 629 | #endif 630 | #ifdef SQLITE_CONFIG_PAGECACHE 631 | defconst(env, "sqlite-config-pagecache", env->make_integer(env, SQLITE_CONFIG_PAGECACHE)); 632 | #endif 633 | #ifdef SQLITE_CONFIG_HEAP 634 | defconst(env, "sqlite-config-heap", env->make_integer(env, SQLITE_CONFIG_HEAP)); 635 | #endif 636 | #ifdef SQLITE_CONFIG_MEMSTATUS 637 | defconst(env, "sqlite-config-memstatus", env->make_integer(env, SQLITE_CONFIG_MEMSTATUS)); 638 | #endif 639 | #ifdef SQLITE_CONFIG_MUTEX 640 | defconst(env, "sqlite-config-mutex", env->make_integer(env, SQLITE_CONFIG_MUTEX)); 641 | #endif 642 | #ifdef SQLITE_CONFIG_GETMUTEX 643 | defconst(env, "sqlite-config-getmutex", env->make_integer(env, SQLITE_CONFIG_GETMUTEX)); 644 | #endif 645 | #ifdef SQLITE_CONFIG_LOOKASIDE 646 | defconst(env, "sqlite-config-lookaside", env->make_integer(env, SQLITE_CONFIG_LOOKASIDE)); 647 | #endif 648 | #ifdef SQLITE_CONFIG_PCACHE 649 | defconst(env, "sqlite-config-pcache", env->make_integer(env, SQLITE_CONFIG_PCACHE)); 650 | #endif 651 | #ifdef SQLITE_CONFIG_GETPCACHE 652 | defconst(env, "sqlite-config-getpcache", env->make_integer(env, SQLITE_CONFIG_GETPCACHE)); 653 | #endif 654 | #ifdef SQLITE_CONFIG_LOG 655 | defconst(env, "sqlite-config-log", env->make_integer(env, SQLITE_CONFIG_LOG)); 656 | #endif 657 | #ifdef SQLITE_CONFIG_URI 658 | defconst(env, "sqlite-config-uri", env->make_integer(env, SQLITE_CONFIG_URI)); 659 | #endif 660 | #ifdef SQLITE_CONFIG_PCACHE2 661 | defconst(env, "sqlite-config-pcache2", env->make_integer(env, SQLITE_CONFIG_PCACHE2)); 662 | #endif 663 | #ifdef SQLITE_CONFIG_GETPCACHE2 664 | defconst(env, "sqlite-config-getpcache2", env->make_integer(env, SQLITE_CONFIG_GETPCACHE2)); 665 | #endif 666 | #ifdef SQLITE_CONFIG_COVERING_INDEX_SCAN 667 | defconst(env, "sqlite-config-covering-index-scan", env->make_integer(env, SQLITE_CONFIG_COVERING_INDEX_SCAN)); 668 | #endif 669 | #ifdef SQLITE_CONFIG_SQLLOG 670 | defconst(env, "sqlite-config-sqllog", env->make_integer(env, SQLITE_CONFIG_SQLLOG)); 671 | #endif 672 | #ifdef SQLITE_CONFIG_MMAP_SIZE 673 | defconst(env, "sqlite-config-mmap-size", env->make_integer(env, SQLITE_CONFIG_MMAP_SIZE)); 674 | #endif 675 | #ifdef SQLITE_CONFIG_WIN32_HEAPSIZE 676 | defconst(env, "sqlite-config-win32-heapsize", env->make_integer(env, SQLITE_CONFIG_WIN32_HEAPSIZE)); 677 | #endif 678 | #ifdef SQLITE_CONFIG_PCACHE_HDRSZ 679 | defconst(env, "sqlite-config-pcache-hdrsz", env->make_integer(env, SQLITE_CONFIG_PCACHE_HDRSZ)); 680 | #endif 681 | #ifdef SQLITE_CONFIG_PMASZ 682 | defconst(env, "sqlite-config-pmasz", env->make_integer(env, SQLITE_CONFIG_PMASZ)); 683 | #endif 684 | #ifdef SQLITE_CONFIG_STMTJRNL_SPILL 685 | defconst(env, "sqlite-config-stmtjrnl-spill", env->make_integer(env, SQLITE_CONFIG_STMTJRNL_SPILL)); 686 | #endif 687 | #ifdef SQLITE_CONFIG_SMALL_MALLOC 688 | defconst(env, "sqlite-config-small-malloc", env->make_integer(env, SQLITE_CONFIG_SMALL_MALLOC)); 689 | #endif 690 | #ifdef SQLITE_CONFIG_SORTERREF_SIZE 691 | defconst(env, "sqlite-config-sorterref-size", env->make_integer(env, SQLITE_CONFIG_SORTERREF_SIZE)); 692 | #endif 693 | #ifdef SQLITE_CONFIG_MEMDB_MAXSIZE 694 | defconst(env, "sqlite-config-memdb-maxsize", env->make_integer(env, SQLITE_CONFIG_MEMDB_MAXSIZE)); 695 | #endif 696 | #ifdef SQLITE_DBCONFIG_MAINDBNAME 697 | defconst(env, "sqlite-dbconfig-maindbname", env->make_integer(env, SQLITE_DBCONFIG_MAINDBNAME)); 698 | #endif 699 | #ifdef SQLITE_DBCONFIG_LOOKASIDE 700 | defconst(env, "sqlite-dbconfig-lookaside", env->make_integer(env, SQLITE_DBCONFIG_LOOKASIDE)); 701 | #endif 702 | #ifdef SQLITE_DBCONFIG_ENABLE_FKEY 703 | defconst(env, "sqlite-dbconfig-enable-fkey", env->make_integer(env, SQLITE_DBCONFIG_ENABLE_FKEY)); 704 | #endif 705 | #ifdef SQLITE_DBCONFIG_ENABLE_TRIGGER 706 | defconst(env, "sqlite-dbconfig-enable-trigger", env->make_integer(env, SQLITE_DBCONFIG_ENABLE_TRIGGER)); 707 | #endif 708 | #ifdef SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 709 | defconst(env, "sqlite-dbconfig-enable-fts3-tokenizer", env->make_integer(env, SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER)); 710 | #endif 711 | #ifdef SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 712 | defconst(env, "sqlite-dbconfig-enable-load-extension", env->make_integer(env, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION)); 713 | #endif 714 | #ifdef SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 715 | defconst(env, "sqlite-dbconfig-no-ckpt-on-close", env->make_integer(env, SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE)); 716 | #endif 717 | #ifdef SQLITE_DBCONFIG_ENABLE_QPSG 718 | defconst(env, "sqlite-dbconfig-enable-qpsg", env->make_integer(env, SQLITE_DBCONFIG_ENABLE_QPSG)); 719 | #endif 720 | #ifdef SQLITE_DBCONFIG_TRIGGER_EQP 721 | defconst(env, "sqlite-dbconfig-trigger-eqp", env->make_integer(env, SQLITE_DBCONFIG_TRIGGER_EQP)); 722 | #endif 723 | #ifdef SQLITE_DBCONFIG_RESET_DATABASE 724 | defconst(env, "sqlite-dbconfig-reset-database", env->make_integer(env, SQLITE_DBCONFIG_RESET_DATABASE)); 725 | #endif 726 | #ifdef SQLITE_DBCONFIG_DEFENSIVE 727 | defconst(env, "sqlite-dbconfig-defensive", env->make_integer(env, SQLITE_DBCONFIG_DEFENSIVE)); 728 | #endif 729 | #ifdef SQLITE_DBCONFIG_WRITABLE_SCHEMA 730 | defconst(env, "sqlite-dbconfig-writable-schema", env->make_integer(env, SQLITE_DBCONFIG_WRITABLE_SCHEMA)); 731 | #endif 732 | #ifdef SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 733 | defconst(env, "sqlite-dbconfig-legacy-alter-table", env->make_integer(env, SQLITE_DBCONFIG_LEGACY_ALTER_TABLE)); 734 | #endif 735 | #ifdef SQLITE_DBCONFIG_DQS_DML 736 | defconst(env, "sqlite-dbconfig-dqs-dml", env->make_integer(env, SQLITE_DBCONFIG_DQS_DML)); 737 | #endif 738 | #ifdef SQLITE_DBCONFIG_DQS_DDL 739 | defconst(env, "sqlite-dbconfig-dqs-ddl", env->make_integer(env, SQLITE_DBCONFIG_DQS_DDL)); 740 | #endif 741 | #ifdef SQLITE_DBCONFIG_ENABLE_VIEW 742 | defconst(env, "sqlite-dbconfig-enable-view", env->make_integer(env, SQLITE_DBCONFIG_ENABLE_VIEW)); 743 | #endif 744 | #ifdef SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 745 | defconst(env, "sqlite-dbconfig-legacy-file-format", env->make_integer(env, SQLITE_DBCONFIG_LEGACY_FILE_FORMAT)); 746 | #endif 747 | #ifdef SQLITE_DBCONFIG_TRUSTED_SCHEMA 748 | defconst(env, "sqlite-dbconfig-trusted-schema", env->make_integer(env, SQLITE_DBCONFIG_TRUSTED_SCHEMA)); 749 | #endif 750 | #ifdef SQLITE_DBCONFIG_MAX 751 | defconst(env, "sqlite-dbconfig-max", env->make_integer(env, SQLITE_DBCONFIG_MAX)); 752 | #endif 753 | #ifdef SQLITE_DENY 754 | defconst(env, "sqlite-deny", env->make_integer(env, SQLITE_DENY)); 755 | #endif 756 | #ifdef SQLITE_IGNORE 757 | defconst(env, "sqlite-ignore", env->make_integer(env, SQLITE_IGNORE)); 758 | #endif 759 | #ifdef SQLITE_CREATE_INDEX 760 | defconst(env, "sqlite-create-index", env->make_integer(env, SQLITE_CREATE_INDEX)); 761 | #endif 762 | #ifdef SQLITE_CREATE_TABLE 763 | defconst(env, "sqlite-create-table", env->make_integer(env, SQLITE_CREATE_TABLE)); 764 | #endif 765 | #ifdef SQLITE_CREATE_TEMP_INDEX 766 | defconst(env, "sqlite-create-temp-index", env->make_integer(env, SQLITE_CREATE_TEMP_INDEX)); 767 | #endif 768 | #ifdef SQLITE_CREATE_TEMP_TABLE 769 | defconst(env, "sqlite-create-temp-table", env->make_integer(env, SQLITE_CREATE_TEMP_TABLE)); 770 | #endif 771 | #ifdef SQLITE_CREATE_TEMP_TRIGGER 772 | defconst(env, "sqlite-create-temp-trigger", env->make_integer(env, SQLITE_CREATE_TEMP_TRIGGER)); 773 | #endif 774 | #ifdef SQLITE_CREATE_TEMP_VIEW 775 | defconst(env, "sqlite-create-temp-view", env->make_integer(env, SQLITE_CREATE_TEMP_VIEW)); 776 | #endif 777 | #ifdef SQLITE_CREATE_TRIGGER 778 | defconst(env, "sqlite-create-trigger", env->make_integer(env, SQLITE_CREATE_TRIGGER)); 779 | #endif 780 | #ifdef SQLITE_CREATE_VIEW 781 | defconst(env, "sqlite-create-view", env->make_integer(env, SQLITE_CREATE_VIEW)); 782 | #endif 783 | #ifdef SQLITE_DELETE 784 | defconst(env, "sqlite-delete", env->make_integer(env, SQLITE_DELETE)); 785 | #endif 786 | #ifdef SQLITE_DROP_INDEX 787 | defconst(env, "sqlite-drop-index", env->make_integer(env, SQLITE_DROP_INDEX)); 788 | #endif 789 | #ifdef SQLITE_DROP_TABLE 790 | defconst(env, "sqlite-drop-table", env->make_integer(env, SQLITE_DROP_TABLE)); 791 | #endif 792 | #ifdef SQLITE_DROP_TEMP_INDEX 793 | defconst(env, "sqlite-drop-temp-index", env->make_integer(env, SQLITE_DROP_TEMP_INDEX)); 794 | #endif 795 | #ifdef SQLITE_DROP_TEMP_TABLE 796 | defconst(env, "sqlite-drop-temp-table", env->make_integer(env, SQLITE_DROP_TEMP_TABLE)); 797 | #endif 798 | #ifdef SQLITE_DROP_TEMP_TRIGGER 799 | defconst(env, "sqlite-drop-temp-trigger", env->make_integer(env, SQLITE_DROP_TEMP_TRIGGER)); 800 | #endif 801 | #ifdef SQLITE_DROP_TEMP_VIEW 802 | defconst(env, "sqlite-drop-temp-view", env->make_integer(env, SQLITE_DROP_TEMP_VIEW)); 803 | #endif 804 | #ifdef SQLITE_DROP_TRIGGER 805 | defconst(env, "sqlite-drop-trigger", env->make_integer(env, SQLITE_DROP_TRIGGER)); 806 | #endif 807 | #ifdef SQLITE_DROP_VIEW 808 | defconst(env, "sqlite-drop-view", env->make_integer(env, SQLITE_DROP_VIEW)); 809 | #endif 810 | #ifdef SQLITE_INSERT 811 | defconst(env, "sqlite-insert", env->make_integer(env, SQLITE_INSERT)); 812 | #endif 813 | #ifdef SQLITE_PRAGMA 814 | defconst(env, "sqlite-pragma", env->make_integer(env, SQLITE_PRAGMA)); 815 | #endif 816 | #ifdef SQLITE_READ 817 | defconst(env, "sqlite-read", env->make_integer(env, SQLITE_READ)); 818 | #endif 819 | #ifdef SQLITE_SELECT 820 | defconst(env, "sqlite-select", env->make_integer(env, SQLITE_SELECT)); 821 | #endif 822 | #ifdef SQLITE_TRANSACTION 823 | defconst(env, "sqlite-transaction", env->make_integer(env, SQLITE_TRANSACTION)); 824 | #endif 825 | #ifdef SQLITE_UPDATE 826 | defconst(env, "sqlite-update", env->make_integer(env, SQLITE_UPDATE)); 827 | #endif 828 | #ifdef SQLITE_ATTACH 829 | defconst(env, "sqlite-attach", env->make_integer(env, SQLITE_ATTACH)); 830 | #endif 831 | #ifdef SQLITE_DETACH 832 | defconst(env, "sqlite-detach", env->make_integer(env, SQLITE_DETACH)); 833 | #endif 834 | #ifdef SQLITE_ALTER_TABLE 835 | defconst(env, "sqlite-alter-table", env->make_integer(env, SQLITE_ALTER_TABLE)); 836 | #endif 837 | #ifdef SQLITE_REINDEX 838 | defconst(env, "sqlite-reindex", env->make_integer(env, SQLITE_REINDEX)); 839 | #endif 840 | #ifdef SQLITE_ANALYZE 841 | defconst(env, "sqlite-analyze", env->make_integer(env, SQLITE_ANALYZE)); 842 | #endif 843 | #ifdef SQLITE_CREATE_VTABLE 844 | defconst(env, "sqlite-create-vtable", env->make_integer(env, SQLITE_CREATE_VTABLE)); 845 | #endif 846 | #ifdef SQLITE_DROP_VTABLE 847 | defconst(env, "sqlite-drop-vtable", env->make_integer(env, SQLITE_DROP_VTABLE)); 848 | #endif 849 | #ifdef SQLITE_FUNCTION 850 | defconst(env, "sqlite-function", env->make_integer(env, SQLITE_FUNCTION)); 851 | #endif 852 | #ifdef SQLITE_SAVEPOINT 853 | defconst(env, "sqlite-savepoint", env->make_integer(env, SQLITE_SAVEPOINT)); 854 | #endif 855 | #ifdef SQLITE_COPY 856 | defconst(env, "sqlite-copy", env->make_integer(env, SQLITE_COPY)); 857 | #endif 858 | #ifdef SQLITE_RECURSIVE 859 | defconst(env, "sqlite-recursive", env->make_integer(env, SQLITE_RECURSIVE)); 860 | #endif 861 | #ifdef SQLITE_TRACE_STMT 862 | defconst(env, "sqlite-trace-stmt", env->make_integer(env, SQLITE_TRACE_STMT)); 863 | #endif 864 | #ifdef SQLITE_TRACE_PROFILE 865 | defconst(env, "sqlite-trace-profile", env->make_integer(env, SQLITE_TRACE_PROFILE)); 866 | #endif 867 | #ifdef SQLITE_TRACE_ROW 868 | defconst(env, "sqlite-trace-row", env->make_integer(env, SQLITE_TRACE_ROW)); 869 | #endif 870 | #ifdef SQLITE_TRACE_CLOSE 871 | defconst(env, "sqlite-trace-close", env->make_integer(env, SQLITE_TRACE_CLOSE)); 872 | #endif 873 | #ifdef SQLITE_LIMIT_LENGTH 874 | defconst(env, "sqlite-limit-length", env->make_integer(env, SQLITE_LIMIT_LENGTH)); 875 | #endif 876 | #ifdef SQLITE_LIMIT_SQL_LENGTH 877 | defconst(env, "sqlite-limit-sql-length", env->make_integer(env, SQLITE_LIMIT_SQL_LENGTH)); 878 | #endif 879 | #ifdef SQLITE_LIMIT_COLUMN 880 | defconst(env, "sqlite-limit-column", env->make_integer(env, SQLITE_LIMIT_COLUMN)); 881 | #endif 882 | #ifdef SQLITE_LIMIT_EXPR_DEPTH 883 | defconst(env, "sqlite-limit-expr-depth", env->make_integer(env, SQLITE_LIMIT_EXPR_DEPTH)); 884 | #endif 885 | #ifdef SQLITE_LIMIT_COMPOUND_SELECT 886 | defconst(env, "sqlite-limit-compound-select", env->make_integer(env, SQLITE_LIMIT_COMPOUND_SELECT)); 887 | #endif 888 | #ifdef SQLITE_LIMIT_VDBE_OP 889 | defconst(env, "sqlite-limit-vdbe-op", env->make_integer(env, SQLITE_LIMIT_VDBE_OP)); 890 | #endif 891 | #ifdef SQLITE_LIMIT_FUNCTION_ARG 892 | defconst(env, "sqlite-limit-function-arg", env->make_integer(env, SQLITE_LIMIT_FUNCTION_ARG)); 893 | #endif 894 | #ifdef SQLITE_LIMIT_ATTACHED 895 | defconst(env, "sqlite-limit-attached", env->make_integer(env, SQLITE_LIMIT_ATTACHED)); 896 | #endif 897 | #ifdef SQLITE_LIMIT_LIKE_PATTERN_LENGTH 898 | defconst(env, "sqlite-limit-like-pattern-length", env->make_integer(env, SQLITE_LIMIT_LIKE_PATTERN_LENGTH)); 899 | #endif 900 | #ifdef SQLITE_LIMIT_VARIABLE_NUMBER 901 | defconst(env, "sqlite-limit-variable-number", env->make_integer(env, SQLITE_LIMIT_VARIABLE_NUMBER)); 902 | #endif 903 | #ifdef SQLITE_LIMIT_TRIGGER_DEPTH 904 | defconst(env, "sqlite-limit-trigger-depth", env->make_integer(env, SQLITE_LIMIT_TRIGGER_DEPTH)); 905 | #endif 906 | #ifdef SQLITE_LIMIT_WORKER_THREADS 907 | defconst(env, "sqlite-limit-worker-threads", env->make_integer(env, SQLITE_LIMIT_WORKER_THREADS)); 908 | #endif 909 | #ifdef SQLITE_PREPARE_PERSISTENT 910 | defconst(env, "sqlite-prepare-persistent", env->make_integer(env, SQLITE_PREPARE_PERSISTENT)); 911 | #endif 912 | #ifdef SQLITE_PREPARE_NORMALIZE 913 | defconst(env, "sqlite-prepare-normalize", env->make_integer(env, SQLITE_PREPARE_NORMALIZE)); 914 | #endif 915 | #ifdef SQLITE_PREPARE_NO_VTAB 916 | defconst(env, "sqlite-prepare-no-vtab", env->make_integer(env, SQLITE_PREPARE_NO_VTAB)); 917 | #endif 918 | #ifdef SQLITE_INTEGER 919 | defconst(env, "sqlite-integer", env->make_integer(env, SQLITE_INTEGER)); 920 | #endif 921 | #ifdef SQLITE_FLOAT 922 | defconst(env, "sqlite-float", env->make_integer(env, SQLITE_FLOAT)); 923 | #endif 924 | #ifdef SQLITE_BLOB 925 | defconst(env, "sqlite-blob", env->make_integer(env, SQLITE_BLOB)); 926 | #endif 927 | #ifdef SQLITE_NULL 928 | defconst(env, "sqlite-null", env->make_integer(env, SQLITE_NULL)); 929 | #endif 930 | #ifdef SQLITE_UTF8 931 | defconst(env, "sqlite-utf8", env->make_integer(env, SQLITE_UTF8)); 932 | #endif 933 | #ifdef SQLITE_UTF16LE 934 | defconst(env, "sqlite-utf16le", env->make_integer(env, SQLITE_UTF16LE)); 935 | #endif 936 | #ifdef SQLITE_UTF16BE 937 | defconst(env, "sqlite-utf16be", env->make_integer(env, SQLITE_UTF16BE)); 938 | #endif 939 | #ifdef SQLITE_UTF16 940 | defconst(env, "sqlite-utf16", env->make_integer(env, SQLITE_UTF16)); 941 | #endif 942 | #ifdef SQLITE_ANY 943 | defconst(env, "sqlite-any", env->make_integer(env, SQLITE_ANY)); 944 | #endif 945 | #ifdef SQLITE_UTF16_ALIGNED 946 | defconst(env, "sqlite-utf16-aligned", env->make_integer(env, SQLITE_UTF16_ALIGNED)); 947 | #endif 948 | #ifdef SQLITE_DETERMINISTIC 949 | defconst(env, "sqlite-deterministic", env->make_integer(env, SQLITE_DETERMINISTIC)); 950 | #endif 951 | #ifdef SQLITE_DIRECTONLY 952 | defconst(env, "sqlite-directonly", env->make_integer(env, SQLITE_DIRECTONLY)); 953 | #endif 954 | #ifdef SQLITE_SUBTYPE 955 | defconst(env, "sqlite-subtype", env->make_integer(env, SQLITE_SUBTYPE)); 956 | #endif 957 | #ifdef SQLITE_INNOCUOUS 958 | defconst(env, "sqlite-innocuous", env->make_integer(env, SQLITE_INNOCUOUS)); 959 | #endif 960 | #ifdef SQLITE_WIN32_DATA_DIRECTORY_TYPE 961 | defconst(env, "sqlite-win32-data-directory-type", env->make_integer(env, SQLITE_WIN32_DATA_DIRECTORY_TYPE)); 962 | #endif 963 | #ifdef SQLITE_WIN32_TEMP_DIRECTORY_TYPE 964 | defconst(env, "sqlite-win32-temp-directory-type", env->make_integer(env, SQLITE_WIN32_TEMP_DIRECTORY_TYPE)); 965 | #endif 966 | #ifdef SQLITE_INDEX_SCAN_UNIQUE 967 | defconst(env, "sqlite-index-scan-unique", env->make_integer(env, SQLITE_INDEX_SCAN_UNIQUE)); 968 | #endif 969 | #ifdef SQLITE_INDEX_CONSTRAINT_EQ 970 | defconst(env, "sqlite-index-constraint-eq", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_EQ)); 971 | #endif 972 | #ifdef SQLITE_INDEX_CONSTRAINT_GT 973 | defconst(env, "sqlite-index-constraint-gt", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_GT)); 974 | #endif 975 | #ifdef SQLITE_INDEX_CONSTRAINT_LE 976 | defconst(env, "sqlite-index-constraint-le", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_LE)); 977 | #endif 978 | #ifdef SQLITE_INDEX_CONSTRAINT_LT 979 | defconst(env, "sqlite-index-constraint-lt", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_LT)); 980 | #endif 981 | #ifdef SQLITE_INDEX_CONSTRAINT_GE 982 | defconst(env, "sqlite-index-constraint-ge", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_GE)); 983 | #endif 984 | #ifdef SQLITE_INDEX_CONSTRAINT_MATCH 985 | defconst(env, "sqlite-index-constraint-match", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_MATCH)); 986 | #endif 987 | #ifdef SQLITE_INDEX_CONSTRAINT_LIKE 988 | defconst(env, "sqlite-index-constraint-like", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_LIKE)); 989 | #endif 990 | #ifdef SQLITE_INDEX_CONSTRAINT_GLOB 991 | defconst(env, "sqlite-index-constraint-glob", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_GLOB)); 992 | #endif 993 | #ifdef SQLITE_INDEX_CONSTRAINT_REGEXP 994 | defconst(env, "sqlite-index-constraint-regexp", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_REGEXP)); 995 | #endif 996 | #ifdef SQLITE_INDEX_CONSTRAINT_NE 997 | defconst(env, "sqlite-index-constraint-ne", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_NE)); 998 | #endif 999 | #ifdef SQLITE_INDEX_CONSTRAINT_ISNOT 1000 | defconst(env, "sqlite-index-constraint-isnot", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_ISNOT)); 1001 | #endif 1002 | #ifdef SQLITE_INDEX_CONSTRAINT_ISNOTNULL 1003 | defconst(env, "sqlite-index-constraint-isnotnull", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_ISNOTNULL)); 1004 | #endif 1005 | #ifdef SQLITE_INDEX_CONSTRAINT_ISNULL 1006 | defconst(env, "sqlite-index-constraint-isnull", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_ISNULL)); 1007 | #endif 1008 | #ifdef SQLITE_INDEX_CONSTRAINT_IS 1009 | defconst(env, "sqlite-index-constraint-is", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_IS)); 1010 | #endif 1011 | #ifdef SQLITE_INDEX_CONSTRAINT_FUNCTION 1012 | defconst(env, "sqlite-index-constraint-function", env->make_integer(env, SQLITE_INDEX_CONSTRAINT_FUNCTION)); 1013 | #endif 1014 | #ifdef SQLITE_MUTEX_FAST 1015 | defconst(env, "sqlite-mutex-fast", env->make_integer(env, SQLITE_MUTEX_FAST)); 1016 | #endif 1017 | #ifdef SQLITE_MUTEX_RECURSIVE 1018 | defconst(env, "sqlite-mutex-recursive", env->make_integer(env, SQLITE_MUTEX_RECURSIVE)); 1019 | #endif 1020 | #ifdef SQLITE_MUTEX_STATIC_MASTER 1021 | defconst(env, "sqlite-mutex-static-master", env->make_integer(env, SQLITE_MUTEX_STATIC_MASTER)); 1022 | #endif 1023 | #ifdef SQLITE_MUTEX_STATIC_MEM 1024 | defconst(env, "sqlite-mutex-static-mem", env->make_integer(env, SQLITE_MUTEX_STATIC_MEM)); 1025 | #endif 1026 | #ifdef SQLITE_MUTEX_STATIC_MEM2 1027 | defconst(env, "sqlite-mutex-static-mem2", env->make_integer(env, SQLITE_MUTEX_STATIC_MEM2)); 1028 | #endif 1029 | #ifdef SQLITE_MUTEX_STATIC_OPEN 1030 | defconst(env, "sqlite-mutex-static-open", env->make_integer(env, SQLITE_MUTEX_STATIC_OPEN)); 1031 | #endif 1032 | #ifdef SQLITE_MUTEX_STATIC_PRNG 1033 | defconst(env, "sqlite-mutex-static-prng", env->make_integer(env, SQLITE_MUTEX_STATIC_PRNG)); 1034 | #endif 1035 | #ifdef SQLITE_MUTEX_STATIC_LRU 1036 | defconst(env, "sqlite-mutex-static-lru", env->make_integer(env, SQLITE_MUTEX_STATIC_LRU)); 1037 | #endif 1038 | #ifdef SQLITE_MUTEX_STATIC_LRU2 1039 | defconst(env, "sqlite-mutex-static-lru2", env->make_integer(env, SQLITE_MUTEX_STATIC_LRU2)); 1040 | #endif 1041 | #ifdef SQLITE_MUTEX_STATIC_PMEM 1042 | defconst(env, "sqlite-mutex-static-pmem", env->make_integer(env, SQLITE_MUTEX_STATIC_PMEM)); 1043 | #endif 1044 | #ifdef SQLITE_MUTEX_STATIC_APP1 1045 | defconst(env, "sqlite-mutex-static-app1", env->make_integer(env, SQLITE_MUTEX_STATIC_APP1)); 1046 | #endif 1047 | #ifdef SQLITE_MUTEX_STATIC_APP2 1048 | defconst(env, "sqlite-mutex-static-app2", env->make_integer(env, SQLITE_MUTEX_STATIC_APP2)); 1049 | #endif 1050 | #ifdef SQLITE_MUTEX_STATIC_APP3 1051 | defconst(env, "sqlite-mutex-static-app3", env->make_integer(env, SQLITE_MUTEX_STATIC_APP3)); 1052 | #endif 1053 | #ifdef SQLITE_MUTEX_STATIC_VFS1 1054 | defconst(env, "sqlite-mutex-static-vfs1", env->make_integer(env, SQLITE_MUTEX_STATIC_VFS1)); 1055 | #endif 1056 | #ifdef SQLITE_MUTEX_STATIC_VFS2 1057 | defconst(env, "sqlite-mutex-static-vfs2", env->make_integer(env, SQLITE_MUTEX_STATIC_VFS2)); 1058 | #endif 1059 | #ifdef SQLITE_MUTEX_STATIC_VFS3 1060 | defconst(env, "sqlite-mutex-static-vfs3", env->make_integer(env, SQLITE_MUTEX_STATIC_VFS3)); 1061 | #endif 1062 | #ifdef SQLITE_TESTCTRL_FIRST 1063 | defconst(env, "sqlite-testctrl-first", env->make_integer(env, SQLITE_TESTCTRL_FIRST)); 1064 | #endif 1065 | #ifdef SQLITE_TESTCTRL_PRNG_SAVE 1066 | defconst(env, "sqlite-testctrl-prng-save", env->make_integer(env, SQLITE_TESTCTRL_PRNG_SAVE)); 1067 | #endif 1068 | #ifdef SQLITE_TESTCTRL_PRNG_RESTORE 1069 | defconst(env, "sqlite-testctrl-prng-restore", env->make_integer(env, SQLITE_TESTCTRL_PRNG_RESTORE)); 1070 | #endif 1071 | #ifdef SQLITE_TESTCTRL_PRNG_RESET 1072 | defconst(env, "sqlite-testctrl-prng-reset", env->make_integer(env, SQLITE_TESTCTRL_PRNG_RESET)); 1073 | #endif 1074 | #ifdef SQLITE_TESTCTRL_BITVEC_TEST 1075 | defconst(env, "sqlite-testctrl-bitvec-test", env->make_integer(env, SQLITE_TESTCTRL_BITVEC_TEST)); 1076 | #endif 1077 | #ifdef SQLITE_TESTCTRL_FAULT_INSTALL 1078 | defconst(env, "sqlite-testctrl-fault-install", env->make_integer(env, SQLITE_TESTCTRL_FAULT_INSTALL)); 1079 | #endif 1080 | #ifdef SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 1081 | defconst(env, "sqlite-testctrl-benign-malloc-hooks", env->make_integer(env, SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS)); 1082 | #endif 1083 | #ifdef SQLITE_TESTCTRL_PENDING_BYTE 1084 | defconst(env, "sqlite-testctrl-pending-byte", env->make_integer(env, SQLITE_TESTCTRL_PENDING_BYTE)); 1085 | #endif 1086 | #ifdef SQLITE_TESTCTRL_ASSERT 1087 | defconst(env, "sqlite-testctrl-assert", env->make_integer(env, SQLITE_TESTCTRL_ASSERT)); 1088 | #endif 1089 | #ifdef SQLITE_TESTCTRL_ALWAYS 1090 | defconst(env, "sqlite-testctrl-always", env->make_integer(env, SQLITE_TESTCTRL_ALWAYS)); 1091 | #endif 1092 | #ifdef SQLITE_TESTCTRL_RESERVE 1093 | defconst(env, "sqlite-testctrl-reserve", env->make_integer(env, SQLITE_TESTCTRL_RESERVE)); 1094 | #endif 1095 | #ifdef SQLITE_TESTCTRL_OPTIMIZATIONS 1096 | defconst(env, "sqlite-testctrl-optimizations", env->make_integer(env, SQLITE_TESTCTRL_OPTIMIZATIONS)); 1097 | #endif 1098 | #ifdef SQLITE_TESTCTRL_ISKEYWORD 1099 | defconst(env, "sqlite-testctrl-iskeyword", env->make_integer(env, SQLITE_TESTCTRL_ISKEYWORD)); 1100 | #endif 1101 | #ifdef SQLITE_TESTCTRL_SCRATCHMALLOC 1102 | defconst(env, "sqlite-testctrl-scratchmalloc", env->make_integer(env, SQLITE_TESTCTRL_SCRATCHMALLOC)); 1103 | #endif 1104 | #ifdef SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 1105 | defconst(env, "sqlite-testctrl-internal-functions", env->make_integer(env, SQLITE_TESTCTRL_INTERNAL_FUNCTIONS)); 1106 | #endif 1107 | #ifdef SQLITE_TESTCTRL_LOCALTIME_FAULT 1108 | defconst(env, "sqlite-testctrl-localtime-fault", env->make_integer(env, SQLITE_TESTCTRL_LOCALTIME_FAULT)); 1109 | #endif 1110 | #ifdef SQLITE_TESTCTRL_EXPLAIN_STMT 1111 | defconst(env, "sqlite-testctrl-explain-stmt", env->make_integer(env, SQLITE_TESTCTRL_EXPLAIN_STMT)); 1112 | #endif 1113 | #ifdef SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD 1114 | defconst(env, "sqlite-testctrl-once-reset-threshold", env->make_integer(env, SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD)); 1115 | #endif 1116 | #ifdef SQLITE_TESTCTRL_NEVER_CORRUPT 1117 | defconst(env, "sqlite-testctrl-never-corrupt", env->make_integer(env, SQLITE_TESTCTRL_NEVER_CORRUPT)); 1118 | #endif 1119 | #ifdef SQLITE_TESTCTRL_VDBE_COVERAGE 1120 | defconst(env, "sqlite-testctrl-vdbe-coverage", env->make_integer(env, SQLITE_TESTCTRL_VDBE_COVERAGE)); 1121 | #endif 1122 | #ifdef SQLITE_TESTCTRL_BYTEORDER 1123 | defconst(env, "sqlite-testctrl-byteorder", env->make_integer(env, SQLITE_TESTCTRL_BYTEORDER)); 1124 | #endif 1125 | #ifdef SQLITE_TESTCTRL_ISINIT 1126 | defconst(env, "sqlite-testctrl-isinit", env->make_integer(env, SQLITE_TESTCTRL_ISINIT)); 1127 | #endif 1128 | #ifdef SQLITE_TESTCTRL_SORTER_MMAP 1129 | defconst(env, "sqlite-testctrl-sorter-mmap", env->make_integer(env, SQLITE_TESTCTRL_SORTER_MMAP)); 1130 | #endif 1131 | #ifdef SQLITE_TESTCTRL_IMPOSTER 1132 | defconst(env, "sqlite-testctrl-imposter", env->make_integer(env, SQLITE_TESTCTRL_IMPOSTER)); 1133 | #endif 1134 | #ifdef SQLITE_TESTCTRL_PARSER_COVERAGE 1135 | defconst(env, "sqlite-testctrl-parser-coverage", env->make_integer(env, SQLITE_TESTCTRL_PARSER_COVERAGE)); 1136 | #endif 1137 | #ifdef SQLITE_TESTCTRL_RESULT_INTREAL 1138 | defconst(env, "sqlite-testctrl-result-intreal", env->make_integer(env, SQLITE_TESTCTRL_RESULT_INTREAL)); 1139 | #endif 1140 | #ifdef SQLITE_TESTCTRL_PRNG_SEED 1141 | defconst(env, "sqlite-testctrl-prng-seed", env->make_integer(env, SQLITE_TESTCTRL_PRNG_SEED)); 1142 | #endif 1143 | #ifdef SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 1144 | defconst(env, "sqlite-testctrl-extra-schema-checks", env->make_integer(env, SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS)); 1145 | #endif 1146 | #ifdef SQLITE_TESTCTRL_LAST 1147 | defconst(env, "sqlite-testctrl-last", env->make_integer(env, SQLITE_TESTCTRL_LAST)); 1148 | #endif 1149 | #ifdef SQLITE_STATUS_MEMORY_USED 1150 | defconst(env, "sqlite-status-memory-used", env->make_integer(env, SQLITE_STATUS_MEMORY_USED)); 1151 | #endif 1152 | #ifdef SQLITE_STATUS_PAGECACHE_USED 1153 | defconst(env, "sqlite-status-pagecache-used", env->make_integer(env, SQLITE_STATUS_PAGECACHE_USED)); 1154 | #endif 1155 | #ifdef SQLITE_STATUS_PAGECACHE_OVERFLOW 1156 | defconst(env, "sqlite-status-pagecache-overflow", env->make_integer(env, SQLITE_STATUS_PAGECACHE_OVERFLOW)); 1157 | #endif 1158 | #ifdef SQLITE_STATUS_SCRATCH_USED 1159 | defconst(env, "sqlite-status-scratch-used", env->make_integer(env, SQLITE_STATUS_SCRATCH_USED)); 1160 | #endif 1161 | #ifdef SQLITE_STATUS_SCRATCH_OVERFLOW 1162 | defconst(env, "sqlite-status-scratch-overflow", env->make_integer(env, SQLITE_STATUS_SCRATCH_OVERFLOW)); 1163 | #endif 1164 | #ifdef SQLITE_STATUS_MALLOC_SIZE 1165 | defconst(env, "sqlite-status-malloc-size", env->make_integer(env, SQLITE_STATUS_MALLOC_SIZE)); 1166 | #endif 1167 | #ifdef SQLITE_STATUS_PARSER_STACK 1168 | defconst(env, "sqlite-status-parser-stack", env->make_integer(env, SQLITE_STATUS_PARSER_STACK)); 1169 | #endif 1170 | #ifdef SQLITE_STATUS_PAGECACHE_SIZE 1171 | defconst(env, "sqlite-status-pagecache-size", env->make_integer(env, SQLITE_STATUS_PAGECACHE_SIZE)); 1172 | #endif 1173 | #ifdef SQLITE_STATUS_SCRATCH_SIZE 1174 | defconst(env, "sqlite-status-scratch-size", env->make_integer(env, SQLITE_STATUS_SCRATCH_SIZE)); 1175 | #endif 1176 | #ifdef SQLITE_STATUS_MALLOC_COUNT 1177 | defconst(env, "sqlite-status-malloc-count", env->make_integer(env, SQLITE_STATUS_MALLOC_COUNT)); 1178 | #endif 1179 | #ifdef SQLITE_DBSTATUS_LOOKASIDE_USED 1180 | defconst(env, "sqlite-dbstatus-lookaside-used", env->make_integer(env, SQLITE_DBSTATUS_LOOKASIDE_USED)); 1181 | #endif 1182 | #ifdef SQLITE_DBSTATUS_CACHE_USED 1183 | defconst(env, "sqlite-dbstatus-cache-used", env->make_integer(env, SQLITE_DBSTATUS_CACHE_USED)); 1184 | #endif 1185 | #ifdef SQLITE_DBSTATUS_SCHEMA_USED 1186 | defconst(env, "sqlite-dbstatus-schema-used", env->make_integer(env, SQLITE_DBSTATUS_SCHEMA_USED)); 1187 | #endif 1188 | #ifdef SQLITE_DBSTATUS_STMT_USED 1189 | defconst(env, "sqlite-dbstatus-stmt-used", env->make_integer(env, SQLITE_DBSTATUS_STMT_USED)); 1190 | #endif 1191 | #ifdef SQLITE_DBSTATUS_LOOKASIDE_HIT 1192 | defconst(env, "sqlite-dbstatus-lookaside-hit", env->make_integer(env, SQLITE_DBSTATUS_LOOKASIDE_HIT)); 1193 | #endif 1194 | #ifdef SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 1195 | defconst(env, "sqlite-dbstatus-lookaside-miss-size", env->make_integer(env, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE)); 1196 | #endif 1197 | #ifdef SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 1198 | defconst(env, "sqlite-dbstatus-lookaside-miss-full", env->make_integer(env, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL)); 1199 | #endif 1200 | #ifdef SQLITE_DBSTATUS_CACHE_HIT 1201 | defconst(env, "sqlite-dbstatus-cache-hit", env->make_integer(env, SQLITE_DBSTATUS_CACHE_HIT)); 1202 | #endif 1203 | #ifdef SQLITE_DBSTATUS_CACHE_MISS 1204 | defconst(env, "sqlite-dbstatus-cache-miss", env->make_integer(env, SQLITE_DBSTATUS_CACHE_MISS)); 1205 | #endif 1206 | #ifdef SQLITE_DBSTATUS_CACHE_WRITE 1207 | defconst(env, "sqlite-dbstatus-cache-write", env->make_integer(env, SQLITE_DBSTATUS_CACHE_WRITE)); 1208 | #endif 1209 | #ifdef SQLITE_DBSTATUS_DEFERRED_FKS 1210 | defconst(env, "sqlite-dbstatus-deferred-fks", env->make_integer(env, SQLITE_DBSTATUS_DEFERRED_FKS)); 1211 | #endif 1212 | #ifdef SQLITE_DBSTATUS_CACHE_USED_SHARED 1213 | defconst(env, "sqlite-dbstatus-cache-used-shared", env->make_integer(env, SQLITE_DBSTATUS_CACHE_USED_SHARED)); 1214 | #endif 1215 | #ifdef SQLITE_DBSTATUS_CACHE_SPILL 1216 | defconst(env, "sqlite-dbstatus-cache-spill", env->make_integer(env, SQLITE_DBSTATUS_CACHE_SPILL)); 1217 | #endif 1218 | #ifdef SQLITE_DBSTATUS_MAX 1219 | defconst(env, "sqlite-dbstatus-max", env->make_integer(env, SQLITE_DBSTATUS_MAX)); 1220 | #endif 1221 | #ifdef SQLITE_STMTSTATUS_FULLSCAN_STEP 1222 | defconst(env, "sqlite-stmtstatus-fullscan-step", env->make_integer(env, SQLITE_STMTSTATUS_FULLSCAN_STEP)); 1223 | #endif 1224 | #ifdef SQLITE_STMTSTATUS_SORT 1225 | defconst(env, "sqlite-stmtstatus-sort", env->make_integer(env, SQLITE_STMTSTATUS_SORT)); 1226 | #endif 1227 | #ifdef SQLITE_STMTSTATUS_AUTOINDEX 1228 | defconst(env, "sqlite-stmtstatus-autoindex", env->make_integer(env, SQLITE_STMTSTATUS_AUTOINDEX)); 1229 | #endif 1230 | #ifdef SQLITE_STMTSTATUS_VM_STEP 1231 | defconst(env, "sqlite-stmtstatus-vm-step", env->make_integer(env, SQLITE_STMTSTATUS_VM_STEP)); 1232 | #endif 1233 | #ifdef SQLITE_STMTSTATUS_REPREPARE 1234 | defconst(env, "sqlite-stmtstatus-reprepare", env->make_integer(env, SQLITE_STMTSTATUS_REPREPARE)); 1235 | #endif 1236 | #ifdef SQLITE_STMTSTATUS_RUN 1237 | defconst(env, "sqlite-stmtstatus-run", env->make_integer(env, SQLITE_STMTSTATUS_RUN)); 1238 | #endif 1239 | #ifdef SQLITE_STMTSTATUS_MEMUSED 1240 | defconst(env, "sqlite-stmtstatus-memused", env->make_integer(env, SQLITE_STMTSTATUS_MEMUSED)); 1241 | #endif 1242 | #ifdef SQLITE_CHECKPOINT_PASSIVE 1243 | defconst(env, "sqlite-checkpoint-passive", env->make_integer(env, SQLITE_CHECKPOINT_PASSIVE)); 1244 | #endif 1245 | #ifdef SQLITE_CHECKPOINT_FULL 1246 | defconst(env, "sqlite-checkpoint-full", env->make_integer(env, SQLITE_CHECKPOINT_FULL)); 1247 | #endif 1248 | #ifdef SQLITE_CHECKPOINT_RESTART 1249 | defconst(env, "sqlite-checkpoint-restart", env->make_integer(env, SQLITE_CHECKPOINT_RESTART)); 1250 | #endif 1251 | #ifdef SQLITE_CHECKPOINT_TRUNCATE 1252 | defconst(env, "sqlite-checkpoint-truncate", env->make_integer(env, SQLITE_CHECKPOINT_TRUNCATE)); 1253 | #endif 1254 | #ifdef SQLITE_VTAB_CONSTRAINT_SUPPORT 1255 | defconst(env, "sqlite-vtab-constraint-support", env->make_integer(env, SQLITE_VTAB_CONSTRAINT_SUPPORT)); 1256 | #endif 1257 | #ifdef SQLITE_VTAB_INNOCUOUS 1258 | defconst(env, "sqlite-vtab-innocuous", env->make_integer(env, SQLITE_VTAB_INNOCUOUS)); 1259 | #endif 1260 | #ifdef SQLITE_VTAB_DIRECTONLY 1261 | defconst(env, "sqlite-vtab-directonly", env->make_integer(env, SQLITE_VTAB_DIRECTONLY)); 1262 | #endif 1263 | #ifdef SQLITE_ROLLBACK 1264 | defconst(env, "sqlite-rollback", env->make_integer(env, SQLITE_ROLLBACK)); 1265 | #endif 1266 | #ifdef SQLITE_FAIL 1267 | defconst(env, "sqlite-fail", env->make_integer(env, SQLITE_FAIL)); 1268 | #endif 1269 | #ifdef SQLITE_REPLACE 1270 | defconst(env, "sqlite-replace", env->make_integer(env, SQLITE_REPLACE)); 1271 | #endif 1272 | #ifdef SQLITE_SERIALIZE_NOCOPY 1273 | defconst(env, "sqlite-serialize-nocopy", env->make_integer(env, SQLITE_SERIALIZE_NOCOPY)); 1274 | #endif 1275 | #ifdef SQLITE_DESERIALIZE_FREEONCLOSE 1276 | defconst(env, "sqlite-deserialize-freeonclose", env->make_integer(env, SQLITE_DESERIALIZE_FREEONCLOSE)); 1277 | #endif 1278 | #ifdef SQLITE_DESERIALIZE_RESIZEABLE 1279 | defconst(env, "sqlite-deserialize-resizeable", env->make_integer(env, SQLITE_DESERIALIZE_RESIZEABLE)); 1280 | #endif 1281 | #ifdef SQLITE_DESERIALIZE_READONLY 1282 | defconst(env, "sqlite-deserialize-readonly", env->make_integer(env, SQLITE_DESERIALIZE_READONLY)); 1283 | #endif 1284 | --------------------------------------------------------------------------------