Skip to content

Commit aeb7d3c

Browse files
authored
remove columns definition cache. (go-sql-driver#592)
fixes go-sql-driver#587
1 parent 3361273 commit aeb7d3c

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

rows.go

+3-20
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ type mysqlRows struct {
3333

3434
type binaryRows struct {
3535
mysqlRows
36-
// stmtCols is a pointer to the statement's cached columns for different
37-
// result sets.
38-
stmtCols *[][]mysqlField
39-
// i is a number of the current result set. It is used to fetch proper
40-
// columns from stmtCols.
41-
i int
4236
}
4337

4438
type textRows struct {
@@ -132,25 +126,14 @@ func (rows *mysqlRows) nextNotEmptyResultSet() (int, error) {
132126
}
133127
}
134128

135-
func (rows *binaryRows) NextResultSet() (err error) {
129+
func (rows *binaryRows) NextResultSet() error {
136130
resLen, err := rows.nextNotEmptyResultSet()
137131
if err != nil {
138132
return err
139133
}
140134

141-
// get columns, if not cached, read them and cache them.
142-
if rows.i >= len(*rows.stmtCols) {
143-
rows.rs.columns, err = rows.mc.readColumns(resLen)
144-
*rows.stmtCols = append(*rows.stmtCols, rows.rs.columns)
145-
} else {
146-
rows.rs.columns = (*rows.stmtCols)[rows.i]
147-
if err := rows.mc.readUntilEOF(); err != nil {
148-
return err
149-
}
150-
}
151-
152-
rows.i++
153-
return nil
135+
rows.rs.columns, err = rows.mc.readColumns(resLen)
136+
return err
154137
}
155138

156139
func (rows *binaryRows) Next(dest []driver.Value) error {

statement.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ type mysqlStmt struct {
2020
mc *mysqlConn
2121
id uint32
2222
paramCount int
23-
columns [][]mysqlField // cached from the first query
2423
}
2524

2625
func (stmt *mysqlStmt) Close() error {
@@ -109,20 +108,10 @@ func (stmt *mysqlStmt) Query(args []driver.Value) (driver.Rows, error) {
109108
}
110109

111110
rows := new(binaryRows)
112-
rows.stmtCols = &stmt.columns
113111

114112
if resLen > 0 {
115113
rows.mc = mc
116-
rows.i++
117-
// Columns
118-
// If not cached, read them and cache them
119-
if len(stmt.columns) == 0 {
120-
rows.rs.columns, err = mc.readColumns(resLen)
121-
stmt.columns = append(stmt.columns, rows.rs.columns)
122-
} else {
123-
rows.rs.columns = stmt.columns[0]
124-
err = mc.readUntilEOF()
125-
}
114+
rows.rs.columns, err = mc.readColumns(resLen)
126115
} else {
127116
rows.rs.done = true
128117

0 commit comments

Comments
 (0)