Fix NPE in SQL Quadstore
When `tx.Exec` fails and an error is returned, result is nil. Thus, `result.RowsAffected()` panics. * Add a missing return statement in the error test. * Add a second missing return statement just below to return the proper error message if we can't execute `RowsAffected` instead of saying that the triple doesn't exist.
This commit is contained in:
parent
6c5ac2abaf
commit
3f5a4a7827
1 changed files with 2 additions and 0 deletions
|
|
@ -216,10 +216,12 @@ func (qs *QuadStore) runTxPostgres(tx *sql.Tx, in []graph.Delta, opts graph.Igno
|
|||
d.Quad.Subject, d.Quad.Predicate, d.Quad.Object, d.Quad.Label)
|
||||
if err != nil {
|
||||
glog.Errorf("couldn't exec DELETE statement: %v", err)
|
||||
return err
|
||||
}
|
||||
affected, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
glog.Errorf("couldn't get DELETE RowsAffected: %v", err)
|
||||
return err
|
||||
}
|
||||
if affected != 1 && !opts.IgnoreMissing {
|
||||
return errors.New("deleting non-existent triple; rolling back")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue