Commit 93c633c3 authored by gwenn's avatar gwenn

Fix Complete method.

parent d0334ea5
......@@ -224,7 +224,9 @@ func TestReadonlyMisuse(t *testing.T) {
}
func TestComplete(t *testing.T) {
assert.T(t, Complete("SELECT 1;"), "expected complete statement")
c, err := Complete("SELECT 1;")
checkNoError(t, err, "error: %s")
assert.T(t, c, "expected complete statement")
}
func TestExecMisuse(t *testing.T) {
......
......@@ -342,10 +342,14 @@ func SetSoftHeapLimit(n int64) int64 {
// Complete determines if an SQL statement is complete.
// (See http://sqlite.org/c3ref/complete.html)
func Complete(sql string) bool {
func Complete(sql string) (bool, error) {
cs := C.CString(sql)
defer C.free(unsafe.Pointer(cs))
return C.sqlite3_complete(cs) != 0
rv := C.sqlite3_complete(cs)
if rv == C.SQLITE_NOMEM {
return false, ErrNoMem
}
return rv != 0, nil
}
// Log writes a message into the error log established by ConfigLog method.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment