Repository: calcite-avatica-go Updated Branches: refs/heads/master 4d019103b -> e3c045c78
Check size of ExecuteResponse.Results before using it because under some conditions, the result set can be empty Project: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/repo Commit: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/commit/ff983fb3 Tree: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/tree/ff983fb3 Diff: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/diff/ff983fb3 Branch: refs/heads/master Commit: ff983fb33b148c14d96d8e330e542cb63120c8d4 Parents: 4d01910 Author: Francis Chuang <francis.chu...@boostport.com> Authored: Thu Dec 14 21:10:41 2017 +1100 Committer: Francis Chuang <francis.chu...@boostport.com> Committed: Thu Dec 14 21:28:51 2017 +1100 ---------------------------------------------------------------------- statement.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/blob/ff983fb3/statement.go ---------------------------------------------------------------------- diff --git a/statement.go b/statement.go index ba231e3..ff30fad 100644 --- a/statement.go +++ b/statement.go @@ -24,6 +24,7 @@ import ( "github.com/apache/calcite-avatica-go/message" "golang.org/x/net/context" + "errors" ) type stmt struct { @@ -93,8 +94,14 @@ func (s *stmt) exec(ctx context.Context, args []namedValue) (driver.Result, erro return nil, err } + results := res.(*message.ExecuteResponse).Results + + if len(results) <= 0{ + return nil, errors.New("empty ResultSet in ExecuteResponse") + } + // Currently there is only 1 ResultSet per response - changed := int64(res.(*message.ExecuteResponse).Results[0].UpdateCount) + changed := int64(results[0].UpdateCount) return &result{ affectedRows: changed,