Read saves the query response to a Result.
()
| 1731 | |
| 1732 | // Read saves the query response to a Result. |
| 1733 | func (rr *ResultReader) Read() *Result { |
| 1734 | br := &Result{} |
| 1735 | |
| 1736 | for rr.NextRow() { |
| 1737 | if br.FieldDescriptions == nil { |
| 1738 | br.FieldDescriptions = make([]FieldDescription, len(rr.FieldDescriptions())) |
| 1739 | copy(br.FieldDescriptions, rr.FieldDescriptions()) |
| 1740 | } |
| 1741 | |
| 1742 | values := rr.Values() |
| 1743 | row := make([][]byte, len(values)) |
| 1744 | for i := range row { |
| 1745 | if values[i] != nil { |
| 1746 | row[i] = make([]byte, len(values[i])) |
| 1747 | copy(row[i], values[i]) |
| 1748 | } |
| 1749 | } |
| 1750 | br.Rows = append(br.Rows, row) |
| 1751 | } |
| 1752 | |
| 1753 | br.CommandTag, br.Err = rr.Close() |
| 1754 | |
| 1755 | return br |
| 1756 | } |
| 1757 | |
| 1758 | // NextRow advances the ResultReader to the next row and returns true if a row is available. |
| 1759 | func (rr *ResultReader) NextRow() bool { |