@@ -56,7 +56,7 @@ static int bind_blob(sqlite3_stmt *s, int i, const void *p, int n, int copy) {
56
56
}
57
57
58
58
// Faster retrieval of column data types (1 cgo call instead of n).
59
- static void column_types(sqlite3_stmt *s, unsigned char *p , int n) {
59
+ static void column_types(sqlite3_stmt *s, unsigned char p[] , int n) {
60
60
int i = 0;
61
61
for (; i < n; ++i, ++p) {
62
62
*p = sqlite3_column_type(s, i);
@@ -541,7 +541,9 @@ func newStmt(c *Conn, sql string) (*Stmt, error) {
541
541
// be useful to the caller, so s is still returned without an error.
542
542
s := & Stmt {conn : c , stmt : stmt }
543
543
if stmt != nil {
544
- s .nVars = int (C .sqlite3_bind_parameter_count (stmt ))
544
+ if s .nVars = int (C .sqlite3_bind_parameter_count (stmt )); s .nVars == 0 {
545
+ s .varNames = unnamedVars
546
+ }
545
547
s .nCols = int (C .sqlite3_column_count (stmt ))
546
548
runtime .SetFinalizer (s , (* Stmt ).Close )
547
549
}
@@ -622,7 +624,7 @@ var unnamedVars = make([]string, 0, 1)
622
624
// is returned if the statement does not use named parameters.
623
625
// [http://www.sqlite.org/c3ref/bind_parameter_name.html]
624
626
func (s * Stmt ) Params () []string {
625
- if s .varNames == nil && s . nVars > 0 {
627
+ if s .varNames == nil {
626
628
var names []string
627
629
for i := 0 ; i < s .nVars ; i ++ {
628
630
name := C .sqlite3_bind_parameter_name (s .stmt , C .int (i + 1 ))
@@ -638,7 +640,7 @@ func (s *Stmt) Params() []string {
638
640
s .varNames = names
639
641
}
640
642
if len (s .varNames ) == 0 {
641
- return nil
643
+ return nil // unnamedVars -> nil
642
644
}
643
645
return s .varNames
644
646
}
@@ -687,7 +689,7 @@ func (s *Stmt) DeclTypes() []string {
687
689
// [http://www.sqlite.org/c3ref/column_blob.html]
688
690
func (s * Stmt ) DataTypes () []uint8 {
689
691
if len (s .colTypes ) == 0 {
690
- if ! s .haveRow || s . nCols == 0 {
692
+ if ! s .haveRow {
691
693
return nil
692
694
}
693
695
s .colType (0 )
0 commit comments