Merge pull request #8 from Quentin-M/psql-fix-npe

Fix NPEs in SQL Next and Contains
This commit is contained in:
Barak Michener 2015-08-26 16:19:08 -04:00
commit 6fcc8024f5
2 changed files with 11 additions and 1 deletions

View file

@ -131,6 +131,9 @@ func (it *AllIterator) Next() bool {
graph.NextLogIn(it)
if it.cursor == nil {
it.makeCursor()
if it.cursor == nil {
return false
}
}
if !it.cursor.Next() {
glog.V(4).Infoln("sql: No next")

View file

@ -151,6 +151,11 @@ func (it *SQLIterator) Next() bool {
graph.NextLogIn(it)
if it.cursor == nil {
err = it.makeCursor(true, nil)
if err != nil {
glog.Errorf("Couldn't make query: %v", err)
it.err = err
return false
}
it.cols, err = it.cursor.Columns()
if err != nil {
glog.Errorf("Couldn't get columns")
@ -226,7 +231,9 @@ func (it *SQLIterator) Contains(v graph.Value) bool {
if err != nil {
glog.Errorf("Couldn't make query: %v", err)
it.err = err
it.cursor.Close()
if it.cursor != nil {
it.cursor.Close()
}
return false
}
it.cols, err = it.cursor.Columns()