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

Function TestInterruptBySignal

driver_test.go:2208–2254  ·  view source on GitHub ↗

See Issue #422

(t *testing.T)

Source from the content-addressed store, hash-verified

2206
2207// See Issue #422
2208func TestInterruptBySignal(t *testing.T) {
2209 runTestsWithMultiStatement(t, dsn, func(dbt *DBTest) {
2210 dbt.mustExec(`
2211 DROP PROCEDURE IF EXISTS test_signal;
2212 CREATE PROCEDURE test_signal(ret INT)
2213 BEGIN
2214 SELECT ret;
2215 SIGNAL SQLSTATE
2216 '45001'
2217 SET
2218 MESSAGE_TEXT = "an error",
2219 MYSQL_ERRNO = 45001;
2220 END
2221 `)
2222 defer dbt.mustExec("DROP PROCEDURE test_signal")
2223
2224 var val int
2225
2226 // text protocol
2227 rows, err := dbt.db.Query("CALL test_signal(42)")
2228 if err != nil {
2229 dbt.Fatalf("error on text query: %s", err.Error())
2230 }
2231 for rows.Next() {
2232 if err := rows.Scan(&val); err != nil {
2233 dbt.Error(err)
2234 } else if val != 42 {
2235 dbt.Errorf("expected val to be 42")
2236 }
2237 }
2238 rows.Close()
2239
2240 // binary protocol
2241 rows, err = dbt.db.Query("CALL test_signal(?)", 42)
2242 if err != nil {
2243 dbt.Fatalf("error on binary query: %s", err.Error())
2244 }
2245 for rows.Next() {
2246 if err := rows.Scan(&val); err != nil {
2247 dbt.Error(err)
2248 } else if val != 42 {
2249 dbt.Errorf("expected val to be 42")
2250 }
2251 }
2252 rows.Close()
2253 })
2254}
2255
2256func TestColumnsReusesSlice(t *testing.T) {
2257 rows := mysqlRows{

Callers

nothing calls this directly

Calls 7

mustExecMethod · 0.80
ScanMethod · 0.80
QueryMethod · 0.45
ErrorMethod · 0.45
NextMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected