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

Function TestChunkReuseCorruptSysVarString

pkg/server/tests/commontest/tidb_test.go:2697–2732  ·  view source on GitHub ↗

See: https://github.com/pingcap/tidb/issues/40979 Reusing memory of `chunk.Chunk` may cause some systems variable's memory value to be modified unexpectedly.

(t *testing.T)

Source from the content-addressed store, hash-verified

2695// See: https://github.com/pingcap/tidb/issues/40979
2696// Reusing memory of `chunk.Chunk` may cause some systems variable's memory value to be modified unexpectedly.
2697func TestChunkReuseCorruptSysVarString(t *testing.T) {
2698 ts := servertestkit.CreateTidbTestSuite(t)
2699
2700 db, err := sql.Open("mysql", ts.GetDSN())
2701 require.NoError(t, err)
2702 defer func() {
2703 require.NoError(t, db.Close())
2704 }()
2705
2706 conn, err := db.Conn(context.Background())
2707 require.NoError(t, err)
2708 defer func() {
2709 require.NoError(t, conn.Close())
2710 }()
2711
2712 rs, err := conn.QueryContext(context.Background(), "show tables in test")
2713 ts.Rows(t, rs)
2714 require.NoError(t, err)
2715
2716 _, err = conn.ExecContext(context.Background(), "set @@time_zone=(select 'Asia/Shanghai')")
2717 require.NoError(t, err)
2718
2719 rs, err = conn.QueryContext(context.Background(), "select TIDB_TABLE_ID from information_schema.tables where TABLE_SCHEMA='aaaa'")
2720 ts.Rows(t, rs)
2721 require.NoError(t, err)
2722
2723 rs, err = conn.QueryContext(context.Background(), "select @@time_zone")
2724 require.NoError(t, err)
2725 defer func() {
2726 require.NoError(t, rs.Close())
2727 }()
2728
2729 rows := ts.Rows(t, rs)
2730 require.Equal(t, 1, len(rows))
2731 require.Equal(t, "Asia/Shanghai", rows[0])
2732}
2733
2734func TestTiDBIdleTransactionTimeout(t *testing.T) {
2735 ts := servertestkit.CreateTidbTestTopSQLSuite(t)

Callers

nothing calls this directly

Calls 8

CreateTidbTestSuiteFunction · 0.92
GetDSNMethod · 0.80
OpenMethod · 0.65
CloseMethod · 0.65
QueryContextMethod · 0.65
RowsMethod · 0.65
ExecContextMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected