diff --git a/CHANGELOG.md b/CHANGELOG.md index e57335c0..4a0f655c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 3.9.2 (unreleased) +- [PR #253](https://github.com/rqlite/rqlite/pull/254): Handle nil row returned by SQL execer. Fixes [issue #253](https://github.com/rqlite/rqlite/issues/253). + ## 3.9.1 (December 29th 2016) - [PR #247](https://github.com/rqlite/rqlite/pull/247): Simplify loading of SQLite dump files via single command execution. Fixes [issue #246](https://github.com/rqlite/rqlite/issues/246). - [PR #247](https://github.com/rqlite/rqlite/pull/247): Correct SQLite dump load authentication check. diff --git a/db/db.go b/db/db.go index af52bbe5..8beda22a 100644 --- a/db/db.go +++ b/db/db.go @@ -247,6 +247,9 @@ func (db *DB) Execute(queries []string, tx, xTime bool) ([]*Result, error) { } break } + if r == nil { + continue + } lid, err := r.LastInsertId() if err != nil { diff --git a/db/db_test.go b/db/db_test.go index 93fd4d08..7ec94291 100644 --- a/db/db_test.go +++ b/db/db_test.go @@ -82,6 +82,21 @@ func Test_LoadInMemory(t *testing.T) { } } +func Test_EmptyStatements(t *testing.T) { + db, path := mustCreateDatabase() + defer db.Close() + defer os.Remove(path) + + _, err := db.Execute([]string{""}, false, false) + if err != nil { + t.Fatalf("failed to execute empty statement: %s", err.Error()) + } + _, err = db.Execute([]string{";"}, false, false) + if err != nil { + t.Fatalf("failed to execute empty statement with semicolon: %s", err.Error()) + } +} + func Test_SimpleSingleStatements(t *testing.T) { db, path := mustCreateDatabase() defer db.Close()