From 1354684d2bb4d8f09365fa5f9b4e3df8c83f9bd1 Mon Sep 17 00:00:00 2001 From: mattn Date: Sun, 22 Mar 2015 03:37:43 +0900 Subject: [PATCH] Fix hang in test --- sqlite3.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/sqlite3.go b/sqlite3.go index 758cfdf..fc53297 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -382,17 +382,18 @@ func (c *SQLiteConn) Prepare(query string) (driver.Stmt, error) { t = strings.TrimSpace(C.GoString(tail)) } nv := int(C.sqlite3_bind_parameter_count(s)) - if nv > 0 { - pn := C.GoString(C.sqlite3_bind_parameter_name(s, 1)) - /* TODO: map argument for named parameters - if len(pn) > 0 && pn[0] == '$' && pn[1] != '1' { - nv = -1 + /* + if nv > 0 { + pn := C.GoString(C.sqlite3_bind_parameter_name(s, 1)) + // TODO: map argument for named parameters + if len(pn) > 0 && pn[0] == '$' && pn[1] != '1' { + nv = -1 + } + if len(pn) > 0 && pn[0] != '?' { + nv = -1 + } } - */ - if len(pn) > 0 && pn[0] != '?' { - nv = -1 - } - } + */ ss := &SQLiteStmt{c: c, s: s, nv: nv, t: t} runtime.SetFinalizer(ss, (*SQLiteStmt).Close) return ss, nil @@ -440,7 +441,6 @@ func (s *SQLiteStmt) bind(args []driver.Value) error { for k, v := range m { pn := C.CString(k) if pi := int(C.sqlite3_bind_parameter_index(s.s, pn)); pi > 0 { - println(pi) vargs = append(vargs, bindArg{pi, v}) } C.free(unsafe.Pointer(pn)) @@ -503,6 +503,7 @@ func (s *SQLiteStmt) bind(args []driver.Value) error { return s.c.lastError() } } + println(4) return nil }