Преглед на файлове

remove columns definition cache. (#592)

fixes #587
INADA Naoki преди 8 години
родител
ревизия
aeb7d3c9ee
променени са 2 файла, в които са добавени 4 реда и са изтрити 32 реда
  1. 3 20
      rows.go
  2. 1 12
      statement.go

+ 3 - 20
rows.go

@@ -33,12 +33,6 @@ type mysqlRows struct {
 
 type binaryRows struct {
 	mysqlRows
-	// stmtCols is a pointer to the statement's cached columns for different
-	// result sets.
-	stmtCols *[][]mysqlField
-	// i is a number of the current result set. It is used to fetch proper
-	// columns from stmtCols.
-	i int
 }
 
 type textRows struct {
@@ -132,25 +126,14 @@ func (rows *mysqlRows) nextNotEmptyResultSet() (int, error) {
 	}
 }
 
-func (rows *binaryRows) NextResultSet() (err error) {
+func (rows *binaryRows) NextResultSet() error {
 	resLen, err := rows.nextNotEmptyResultSet()
 	if err != nil {
 		return err
 	}
 
-	// get columns, if not cached, read them and cache them.
-	if rows.i >= len(*rows.stmtCols) {
-		rows.rs.columns, err = rows.mc.readColumns(resLen)
-		*rows.stmtCols = append(*rows.stmtCols, rows.rs.columns)
-	} else {
-		rows.rs.columns = (*rows.stmtCols)[rows.i]
-		if err := rows.mc.readUntilEOF(); err != nil {
-			return err
-		}
-	}
-
-	rows.i++
-	return nil
+	rows.rs.columns, err = rows.mc.readColumns(resLen)
+	return err
 }
 
 func (rows *binaryRows) Next(dest []driver.Value) error {

+ 1 - 12
statement.go

@@ -20,7 +20,6 @@ type mysqlStmt struct {
 	mc         *mysqlConn
 	id         uint32
 	paramCount int
-	columns    [][]mysqlField // cached from the first query
 }
 
 func (stmt *mysqlStmt) Close() error {
@@ -109,20 +108,10 @@ func (stmt *mysqlStmt) Query(args []driver.Value) (driver.Rows, error) {
 	}
 
 	rows := new(binaryRows)
-	rows.stmtCols = &stmt.columns
 
 	if resLen > 0 {
 		rows.mc = mc
-		rows.i++
-		// Columns
-		// If not cached, read them and cache them
-		if len(stmt.columns) == 0 {
-			rows.rs.columns, err = mc.readColumns(resLen)
-			stmt.columns = append(stmt.columns, rows.rs.columns)
-		} else {
-			rows.rs.columns = stmt.columns[0]
-			err = mc.readUntilEOF()
-		}
+		rows.rs.columns, err = mc.readColumns(resLen)
 	} else {
 		rows.rs.done = true