Skip to content

"SELECT 1;;" means (rc *SQLiteRows) Next() enters an infinite loop (SQLITE_MISUSE) #1161

Closed
@otoolep

Description

@otoolep

Spotted by rqlite/rqlite#1250

Apply the diff below, execute time go test -run TestQueryer and it will never return. Without the diff the test it runs fine, and exits normally. From instrumenting my own code (rqlite) it seems rows.Next() never returns an error. Should the code be more robust against this, or am I doing something wrong?

$ git diff
diff --git a/sqlite3_test.go b/sqlite3_test.go
index 326361e..df317f2 100644
--- a/sqlite3_test.go
+++ b/sqlite3_test.go
@@ -1114,9 +1114,7 @@ func TestQueryer(t *testing.T) {
        if err != nil {
                t.Error("Failed to call db.Exec:", err)
        }
-       rows, err := db.Query(`
-               select id from foo order by id;
-       `)
+       rows, err := db.Query(`SELECT 1;;`)
        if err != nil {
                t.Error("Failed to call db.Query:", err)
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions