http://autogol.ath.cx/dbd-sqlite3/Gauche-dbd-sqlite3-0.1.3.tgz
変更点
http://autogol.ath.cx/dbd-sqlite3/Gauche-dbd-sqlite3-0.1.2.tgz
変更点
(use dbi) (use util.relation) (define conn (dbi-connect "dbi:sqlite3:db=:memory:")) (dbi-func conn 'sqlite3-create-function* "my_func" -1 5 +) (print (relation-rows (dbi-do conn "select my_func(1, 2, 3)")))
あと今更ですが、cise使っているので、新しめのGaucheでないと動きません。
http://autogol.ath.cx/dbd-sqlite3/Gauche-dbd-sqlite3-0.1.1.tgz
変更点は以下です。
$ tar zxvf Gauche-dbd-sqlite3-0.1.1.tgz $ cd Gauche-dbd-sqlite3-0.1.1 $ cp shared/* . $ aclocal $ autoconf $ ./configure $ make $ make check $ sudo make install
(use dbi) (use dbd.sqlite3) ; dbi-func (define conn (dbi-connect "dbi:sqlite3:db=:memory:")) (define db (slot-ref conn 'db)) (define (my-func context . args) (dbi-func conn 'sqlite3-result-int context (apply + (map (cut dbi-func conn 'sqlite3-value-int <>) args)))) (dbi-func conn 'sqlite3-create-function db "my_func" -1 5 my-func)
http://autogol.ath.cx/Gauche-dbd-sqlite3-0.1.tgz
一応特徴としては、
(use dbi) (use dbd.sqlite3.base) (use util.relation) (use srfi-1) (define conn (dbi-connect "dbi:sqlite3:db=:memory:")) (define db (slot-ref conn 'db)) (define (my-func context . args) (sqlite3-result-int context (apply + (map sqlite3-value-int args)))) (sqlite3-create-function db "my_func" -1 SQLITE_ANY my-func) (let1 res (dbi-do conn "select my_func(1, 2, 3, 4)") (print (relation-rows res))) (define (my-step context x) (sqlite3-set-aggregate-context context (+ (sqlite3-value-int x) (sqlite3-get-aggregate-context context 0)))) (define (my-final context) (sqlite3-result-int context (sqlite3-get-aggregate-context context 0))) (sqlite3-create-aggregate db "my_agg" 1 SQLITE_ANY my-step my-final) (dbi-do conn "create table test (a integer)") (let loop ([lst (iota 10)]) (unless (null? lst) (dbi-do conn "insert into test values (?)" '() (car lst)) (loop (cdr lst)))) (let1 res (dbi-do conn "select my_agg(a) from test") (print (relation-rows res))) (dbi-close conn) 0
yuumi3(http://d.hatena.ne.jp/yuum3/ )です、変更ありがとうございます。Mac OS/X はOKでした。 しかし cygwinでは以下のようなエラーになりました。
bash-3.2$ ./configure checking build system type... i686-pc-cygwin checking host system type... i686-pc-cygwin checking target system type... i686-pc-cygwin checking for gosh... /usr/local/bin/gosh checking for gauche-config... /usr/local/bin/gauche-config checking for gauche-package... /usr/local/bin/gauche-package checking for gauche-install... /usr/local/bin/gauche-install checking for gauche-cesconv... /usr/local/bin/gauche-cesconv checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for SQLITE3... yes checking for gcc... gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for sqlite3_table_column_metadata... no checking for sqlite3_load_extension... no checking for sqlite3_set_authorizer... yes checking for sqlite3_complete... yes checking for sqlite3_progress_handler... yes checking for sqlite3_enable_shared_cache... yes checking for sqlite3_trace... yes checking for sqlite3_blob_open... yes checking for sqlite3_column_decltype... yes configure: creating Gauche-dbd-sqlite3.gpd configure: creating ./config.status config.status: creating Makefile bash-3.2$ make /usr/local/bin/gauche-package compile --verbose --cflags="" --cppflags="-DSQLITE _OMIT_LOAD_EXTENSION=1 -DGAUCHE_API_0_9" --ldflags="" --libs="-lsqlite3 /usr/l ocal/lib/gauche/0.8.13/i686-pc-cygwin/libgauche-uvector.dll" sqlite3 ./sqlite3.c ./sqlite3lib.stub '/usr/local/lib/gauche/0.8.13/i686-pc-cygwin/gauche-config' --fixup-extension 's qlite3' gcc -std=gnu99 -c -DSQLITE_OMIT_LOAD_EXTENSION=1 -DGAUCHE_API_0_9 -I/usr/local/l ib/gauche/0.8.13/include -o 'sqlite3_head.o' 'sqlite3_head.c' gcc -std=gnu99 -c -DSQLITE_OMIT_LOAD_EXTENSION=1 -DGAUCHE_API_0_9 -I/usr/local/l ib/gauche/0.8.13/include -o 'sqlite3.o' './sqlite3.c' '/usr/local/lib/gauche/0.8.13/i686-pc-cygwin/gosh' genstub ./sqlite3lib.stub gcc -std=gnu99 -c -DSQLITE_OMIT_LOAD_EXTENSION=1 -DGAUCHE_API_0_9 -I/usr/local/l ib/gauche/0.8.13/include -o 'sqlite3lib.o' './sqlite3lib.c' gcc -std=gnu99 -c -DSQLITE_OMIT_LOAD_EXTENSION=1 -DGAUCHE_API_0_9 -I/usr/local/l ib/gauche/0.8.13/include -o 'sqlite3_tail.o' 'sqlite3_tail.c' gcc -std=gnu99 -L/usr/local/lib/gauche/0.8.13/i686-pc-cygwin -Wl,--export-all- symbols -Wl,--enable-auto-import -shared -o sqlite3.dll 'sqlite3_head.o' 'sqlite 3.o' 'sqlite3lib.o' 'sqlite3_tail.o' -lgauche -lm -lpthread -lsqlite3 /usr/lo cal/lib/gauche/0.8.13/i686-pc-cygwin/libgauche-uvector.dll sqlite3lib.o:sqlite3lib.c:(.text+0x49a5): undefined reference to `_sqlite3_limit ' sqlite3lib.o:sqlite3lib.c:(.text+0x5415): undefined reference to `_sqlite3_rando mness' sqlite3lib.o:sqlite3lib.c:(.text+0x58a5): undefined reference to `_sqlite3_resul t_error_code' sqlite3lib.o:sqlite3lib.c:(.text+0x6636): undefined reference to `_sqlite3_sql' collect2: ld returned 1 exit status *** ERROR: command execution failed: gcc -std=gnu99 -L/usr/local/lib/gauche/0.8 .13/i686-pc-cygwin -Wl,--export-all-symbols -Wl,--enable-auto-import -shared -o sqlite3.dll 'sqlite3_head.o' 'sqlite3.o' 'sqlite3lib.o' 'sqlite3_tail.o' -lgauc he -lm -lpthread -lsqlite3 /usr/local/lib/gauche/0.8.13/i686-pc-cygwin/libgau che-uvector.dll Stack Trace: _______________________________________ 0 args 1 (usage) At line 99 of "(input string port)" make: *** [sqlite3.dll] Error 70