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

Function TestForeignKey

pkg/planner/core/preprocess_test.go:295–309  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

293}
294
295func TestForeignKey(t *testing.T) {
296 store, dom := testkit.CreateMockStoreAndDomain(t)
297 tk := testkit.NewTestKit(t, store)
298 tk.MustExec("create table test.t1(a int, b int, c int)")
299 tk.MustExec("create table test.t2(d int)")
300 tk.MustExec("create database test2")
301 tk.MustExec("create table test2.t(e int)")
302
303 is := dom.InfoSchema()
304 runSQL(t, tk.Session(), is, "ALTER TABLE test.t1 ADD CONSTRAINT fk FOREIGN KEY (a) REFERENCES t2 (d)", false, nil)
305
306 tk.MustExec("use test")
307 runSQL(t, tk.Session(), is, "ALTER TABLE test.t1 ADD CONSTRAINT fk FOREIGN KEY (b) REFERENCES t2 (d)", false, nil)
308 runSQL(t, tk.Session(), is, "ALTER TABLE test.t1 ADD CONSTRAINT fk FOREIGN KEY (c) REFERENCES test2.t (e)", false, nil)
309}
310
311func TestDropGlobalTempTable(t *testing.T) {
312 store := testkit.CreateMockStore(t)

Callers

nothing calls this directly

Calls 6

MustExecMethod · 0.95
SessionMethod · 0.95
CreateMockStoreAndDomainFunction · 0.92
NewTestKitFunction · 0.92
runSQLFunction · 0.85
InfoSchemaMethod · 0.80

Tested by

no test coverage detected