MCPcopy
hub / github.com/pingcap/tidb / TestCursorFetchExecuteCheck

Function TestCursorFetchExecuteCheck

pkg/server/tests/cursor/cursor_test.go:138–167  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

136}
137
138func TestCursorFetchExecuteCheck(t *testing.T) {
139 store, dom := testkit.CreateMockStoreAndDomain(t)
140 srv := server2.CreateMockServer(t, store)
141 srv.SetDomain(dom)
142 defer srv.Close()
143
144 appendUint32 := binary.LittleEndian.AppendUint32
145 ctx := context.Background()
146 c := server2.CreateMockConn(t, srv)
147
148 stmt, _, _, err := c.Context().Prepare("select 1")
149 require.NoError(t, err)
150
151 // execute with wrong ID
152 require.Error(t, c.Dispatch(ctx, append(
153 appendUint32([]byte{tmysql.ComStmtExecute}, uint32(stmt.ID()+1)),
154 tmysql.CursorTypeReadOnly, 0x1, 0x0, 0x0, 0x0,
155 )))
156
157 // execute with wrong flag
158 require.Error(t, c.Dispatch(ctx, append(
159 appendUint32([]byte{tmysql.ComStmtExecute}, uint32(stmt.ID())),
160 tmysql.CursorTypeReadOnly|tmysql.CursorTypeForUpdate, 0x1, 0x0, 0x0, 0x0,
161 )))
162
163 require.Error(t, c.Dispatch(ctx, append(
164 appendUint32([]byte{tmysql.ComStmtExecute}, uint32(stmt.ID())),
165 tmysql.CursorTypeReadOnly|tmysql.CursorTypeScrollable, 0x1, 0x0, 0x0, 0x0,
166 )))
167}
168
169func TestConcurrentExecuteAndFetch(t *testing.T) {
170 runTestConcurrentExecuteAndFetch(t, false)

Callers

nothing calls this directly

Calls 9

CreateMockStoreAndDomainFunction · 0.92
appendUint32Function · 0.85
PrepareMethod · 0.80
CloseMethod · 0.65
ContextMethod · 0.65
ErrorMethod · 0.65
DispatchMethod · 0.65
IDMethod · 0.65
SetDomainMethod · 0.45

Tested by

no test coverage detected