Commit 62e8c6e4 authored by gwenn's avatar gwenn

Misc.

parent 8da40ff0
...@@ -6,7 +6,7 @@ package sqlite_test ...@@ -6,7 +6,7 @@ package sqlite_test
import ( import (
"fmt" "fmt"
sqlite "github.com/gwenn/gosqlite" "github.com/gwenn/gosqlite"
) )
func check(err error) { func check(err error) {
......
...@@ -149,9 +149,8 @@ func (c *Context) ResultDouble(d float64) { ...@@ -149,9 +149,8 @@ func (c *Context) ResultDouble(d float64) {
// ResultError sets the result of an SQL function. // ResultError sets the result of an SQL function.
// (See sqlite3_result_error, http://sqlite.org/c3ref/result_blob.html) // (See sqlite3_result_error, http://sqlite.org/c3ref/result_blob.html)
func (c *FunctionContext) ResultError(msg string) { func (c *FunctionContext) ResultError(msg string) {
cs := C.CString(msg) cs, l := cstring(msg)
defer C.free(unsafe.Pointer(cs)) C.sqlite3_result_error(c.sc, cs, l)
C.sqlite3_result_error(c.sc, cs, -1)
} }
// ResultErrorTooBig sets the result of an SQL function. // ResultErrorTooBig sets the result of an SQL function.
......
...@@ -68,9 +68,9 @@ func (c *Conn) Databases() (map[string]string, error) { ...@@ -68,9 +68,9 @@ func (c *Conn) Databases() (map[string]string, error) {
func (c *Conn) Tables(dbName string) ([]string, error) { func (c *Conn) Tables(dbName string) ([]string, error) {
var sql string var sql string
if len(dbName) == 0 { if len(dbName) == 0 {
sql = "SELECT name FROM sqlite_master WHERE type IN ('table') AND name NOT LIKE 'sqlite_%'" sql = "SELECT name FROM sqlite_master WHERE type IN ('table') AND name NOT LIKE 'sqlite_%' ORDER BY 1"
} else { } else {
sql = Mprintf("SELECT name FROM %Q.sqlite_master WHERE type IN ('table') AND name NOT LIKE 'sqlite_%%'", dbName) sql = Mprintf("SELECT name FROM %Q.sqlite_master WHERE type IN ('table') AND name NOT LIKE 'sqlite_%%' ORDER BY 1", dbName)
} }
s, err := c.prepare(sql) s, err := c.prepare(sql)
if err != nil { if err != nil {
...@@ -151,6 +151,7 @@ func (c *Conn) Column(dbName, tableName, columnName string) (*Column, error) { ...@@ -151,6 +151,7 @@ func (c *Conn) Column(dbName, tableName, columnName string) (*Column, error) {
if rv != C.SQLITE_OK { if rv != C.SQLITE_OK {
return nil, c.error(rv, fmt.Sprintf("Conn.Column(db: %q, tbl: %q, col: %q)", dbName, tableName, columnName)) return nil, c.error(rv, fmt.Sprintf("Conn.Column(db: %q, tbl: %q, col: %q)", dbName, tableName, columnName))
} }
// TODO How to avoid copy?
return &Column{-1, columnName, C.GoString(zDataType), notNull == 1, "", primaryKey == 1, return &Column{-1, columnName, C.GoString(zDataType), notNull == 1, "", primaryKey == 1,
autoinc == 1, C.GoString(zCollSeq)}, nil autoinc == 1, C.GoString(zCollSeq)}, nil
} }
......
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