@@ -24,6 +24,7 @@ type TableRowIter struct {
2424 partitions PartitionIter
2525 partition Partition
2626 rows RowIter
27+ valueRows ValueRowIter
2728}
2829
2930var _ RowIter = (* TableRowIter )(nil )
@@ -83,6 +84,7 @@ func (i *TableRowIter) NextValueRow(ctx *Context) (ValueRow, error) {
8384 return nil , ctx .Err ()
8485 default :
8586 }
87+
8688 if i .partition == nil {
8789 partition , err := i .partitions .Next (ctx )
8890 if err != nil {
@@ -96,27 +98,27 @@ func (i *TableRowIter) NextValueRow(ctx *Context) (ValueRow, error) {
9698 i .partition = partition
9799 }
98100
99- if i .rows == nil {
101+ if i .valueRows == nil {
100102 rows , err := i .table .PartitionRows (ctx , i .partition )
101103 if err != nil {
102104 return nil , err
103105 }
104- i .rows = rows
106+ i .valueRows = rows .( ValueRowIter )
105107 }
106108
107- row , err := i .rows .( ValueRowIter ) .NextValueRow (ctx )
109+ row , err := i .valueRows .NextValueRow (ctx )
108110 if err != nil && err == io .EOF {
109111 if err = i .rows .Close (ctx ); err != nil {
110112 return nil , err
111113 }
112114 i .partition = nil
113- i .rows = nil
115+ i .valueRows = nil
114116 row , err = i .NextValueRow (ctx )
115117 }
116118 return row , err
117119}
118120
119- // CanSupport implements the sql.ValueRowIter interface.
121+ // IsValueRowIter implements the sql.ValueRowIter interface.
120122func (i * TableRowIter ) IsValueRowIter (ctx * Context ) bool {
121123 if i .partition == nil {
122124 partition , err := i .partitions .Next (ctx )
@@ -125,7 +127,7 @@ func (i *TableRowIter) IsValueRowIter(ctx *Context) bool {
125127 }
126128 i .partition = partition
127129 }
128- if i .rows == nil {
130+ if i .valueRows == nil {
129131 rows , err := i .table .PartitionRows (ctx , i .partition )
130132 if err != nil {
131133 return false
@@ -134,9 +136,9 @@ func (i *TableRowIter) IsValueRowIter(ctx *Context) bool {
134136 if ! ok {
135137 return false
136138 }
137- i .rows = valRowIter
139+ i .valueRows = valRowIter
138140 }
139- return i .rows .( ValueRowIter ) .IsValueRowIter (ctx )
141+ return i .valueRows .IsValueRowIter (ctx )
140142}
141143
142144func (i * TableRowIter ) Close (ctx * Context ) error {
@@ -146,5 +148,11 @@ func (i *TableRowIter) Close(ctx *Context) error {
146148 return err
147149 }
148150 }
151+ if i .valueRows != nil {
152+ if err := i .valueRows .Close (ctx ); err != nil {
153+ _ = i .partitions .Close (ctx )
154+ return err
155+ }
156+ }
149157 return i .partitions .Close (ctx )
150158}
0 commit comments