[plt-scheme] sqlite.plt seg faults with 370
Here's a self-contained test module which may help others re-create
the problem I'm seeing.
(module testing-sqlite mzscheme
(require (planet "sqli.scm " ("oesterholt" "sqlid.plt" 1 5))
(planet "sqld-sqlite.scm" ("oesterholt" "sqld-sqlite.plt" 1 0))
(lib "md5.ss"))
(provide insert-records test-retrieval)
(define *dbd* (sqld-sqlite-new "/tmp/test.sqd"))
(define *dbh* (sqli-connect *dbd*))
(define dbi (sqli-closure *dbh*))
(define (md5code n)
(bytes->string/latin-1 (md5 (string->bytes/latin-1 (number->string n)))))
(define (insert-records n)
(dbi 'query "create table if not exists notes (id INTEGER PRIMARY
KEY, note TEXT);")
(dbi 'begin)
(do ((i 1 (+ i 1)))
((> i n) (dbi 'commit))
(when (dbi 'query "insert or ignore into notes values ($1, $2);"
i (md5code i))
(error (format "Failed to insert record ~a" i))))
(printf "Successfully inserted ~a records...\n" n))
(define (test-retrieval n)
(dbi 'query "select * from notes where id <= $1;" n)
(do ((i 1 (+ 1 i))
(x #f)
(y #f))
((> i n) (printf "Successfully retrieved ~a records...\n" n))
(set! x (dbi 'fetchrow))
(set! y (list (number->string i) (md5code i)))
(unless (equal? x y)
(error (format "Got values ~a. Expected ~a." x y))))))
; And here is a sample transcript...
Welcome to MzScheme v371 [3m], Copyright (c) 2004-2007 PLT Scheme Inc.
> (require "testing-sqlite.scm")
> (insert-records 1000)
Successfully inserted 1000 records...
> (test-retrieval 1000)
Successfully retrieved 1000 records...
> (insert-records 10000)
Successfully inserted 10000 records...
> (test-retrieval 10000)
Successfully retrieved 10000 records...
> (insert-records 100000)
Successfully inserted 100000 records...
> (test-retrieval 100000)
procedure application: expected procedure, given: #<bad-value>;
arguments were: 2 ("13257" "f2843fe2048acb2e687eeebe826db352")
=== context ===
/home/keithf/.plt-scheme/planet/300/371/cache/oesterholt/sqld-sqlite.plt/1/7/sqld-i-sqlite.scm:101:8:
sqlite-i-callback
/home/keithf/.plt-scheme/planet/300/371/cache/oesterholt/sqld-sqlite.plt/1/7/sqld-i-sqlite.scm:64:42:
ffi-wrapper:sqlite3_exec
/home/keithf/.plt-scheme/planet/300/371/cache/oesterholt/sqld-sqlite.plt/1/7/sqld-i-sqlite.scm:136:8:
c-sqlite-query
/home/keithf/.plt-scheme/planet/300/371/cache/oesterholt/sqld-sqlite.plt/1/7/sqld-sqlite-internal.scm:199:4
/home/keithf/.plt-scheme/planet/300/371/cache/oesterholt/sqlid.plt/1/5/sqli.scm:926:4
/home/keithf/testing-sqlite.scm:23:2: test-retrieval