You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by fr...@apache.org on 2022/03/31 05:32:11 UTC

[calcite-avatica-go] branch master updated: [CALCITE-5072] Index out of range when calling rows.Next()

This is an automated email from the ASF dual-hosted git repository.

francischuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite-avatica-go.git


The following commit(s) were added to refs/heads/master by this push:
     new 945cf88  [CALCITE-5072] Index out of range when calling rows.Next()
945cf88 is described below

commit 945cf887766c83b1af8e9aa2f80c2803e6c65626
Author: fuling <fu...@alibaba-inc.com>
AuthorDate: Wed Mar 30 21:24:17 2022 +0800

    [CALCITE-5072] Index out of range when calling rows.Next()
---
 rows.go | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/rows.go b/rows.go
index 0d4c4cc..b886b66 100644
--- a/rows.go
+++ b/rows.go
@@ -40,6 +40,7 @@ type rows struct {
 	statementID      uint32
 	resultSets       []*resultSet
 	currentResultSet int
+	columnNames      []string
 }
 
 // Columns returns the names of the columns. The number of
@@ -47,13 +48,17 @@ type rows struct {
 // slice.  If a particular column name isn't known, an empty
 // string should be returned for that entry.
 func (r *rows) Columns() []string {
-
+	if r.columnNames != nil {
+		return r.columnNames
+	}
 	var cols []string
-
+	if len(r.resultSets) == 0 {
+		return cols
+	}
 	for _, column := range r.resultSets[r.currentResultSet].columns {
 		cols = append(cols, column.Name)
 	}
-
+	r.columnNames = cols
 	return cols
 }
 
@@ -74,7 +79,9 @@ func (r *rows) Close() error {
 //
 // Next should return io.EOF when there are no more rows.
 func (r *rows) Next(dest []driver.Value) error {
-
+	if len(r.resultSets) == 0 {
+		return io.EOF
+	}
 	resultSet := r.resultSets[r.currentResultSet]
 
 	if resultSet.currentRow >= len(resultSet.data) {