MCPcopy
hub / github.com/go-sql-driver/mysql / TestCloseStmtBeforeRows

Function TestCloseStmtBeforeRows

driver_test.go:1749–1786  ·  view source on GitHub ↗

dangling statements http://code.google.com/p/go/issues/detail?id=3865

(t *testing.T)

Source from the content-addressed store, hash-verified

1747// dangling statements
1748// http://code.google.com/p/go/issues/detail?id=3865
1749func TestCloseStmtBeforeRows(t *testing.T) {
1750 runTestsParallel(t, dsn, func(dbt *DBTest, _ string) {
1751 stmt, err := dbt.db.Prepare("SELECT 1")
1752 if err != nil {
1753 dbt.Fatal(err)
1754 }
1755
1756 rows, err := stmt.Query()
1757 if err != nil {
1758 stmt.Close()
1759 dbt.Fatal(err)
1760 }
1761 defer rows.Close()
1762
1763 err = stmt.Close()
1764 if err != nil {
1765 dbt.Fatal(err)
1766 }
1767
1768 if !rows.Next() {
1769 dbt.Fatal("getting row failed")
1770 } else {
1771 err = rows.Err()
1772 if err != nil {
1773 dbt.Fatal(err)
1774 }
1775
1776 var out bool
1777 err = rows.Scan(&out)
1778 if err != nil {
1779 dbt.Fatalf("error on rows.Scan(): %s", err.Error())
1780 }
1781 if out != true {
1782 dbt.Errorf("true != %t", out)
1783 }
1784 }
1785 })
1786}
1787
1788// It is valid to have multiple Rows for the same Stmt
1789// http://code.google.com/p/go/issues/detail?id=3734

Callers

nothing calls this directly

Calls 7

runTestsParallelFunction · 0.85
PrepareMethod · 0.80
ScanMethod · 0.80
QueryMethod · 0.45
CloseMethod · 0.45
NextMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected