** Setup ** SET @old_big_tables = @@SESSION.sql_big_tables; CREATE TABLE t1(a varchar(20), b varchar(20)); INSERT INTO t1 VALUES('aa','bb'); INSERT INTO t1 VALUES('aa','bb'); INSERT INTO t1 VALUES('aa','bb'); INSERT INTO t1 VALUES('aa','bb'); INSERT INTO t1 VALUES('aa','bb'); '#--------------------FN_DYNVARS_155_01-------------------------#' SET SESSION sql_big_tables = 1; SET @diskTableCount = 0; SET @tempTableCount = 0; SELECT * FROM (SELECT ta.a as a, tb.b as b FROM t1 as ta INNER JOIN t1 as tb ON ta.a = tb.a) sub; a b aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb SET @diskTableCount = 1 - @diskTableCount; SET @tempTableCount = 1 - @tempTableCount; SELECT @diskTableCount; @diskTableCount 1 1 Expected SELECT @tempTableCount; @tempTableCount 1 1 Expected '#--------------------FN_DYNVARS_155_02-------------------------#' SET SESSION sql_big_tables = 0; SET @diskTableCount = 1; SET @tempTableCount = 1; SELECT * FROM (SELECT ta.b as a, tb.a as b FROM t1 as ta INNER JOIN t1 as tb ON ta.a = tb.a) sub; a b bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa bb aa SET @diskTableCount = 1 - @diskTableCount; SET @tempTableCount = 2 - @tempTableCount; SELECT @diskTableCount; @diskTableCount 0 0 Expected SELECT @tempTableCount; @tempTableCount 1 1 Expected '#--------------------FN_DYNVARS_155_03-------------------------#' ** Connecting con_int1 using root ** ** Connection con_int1 ** SELECT @@SESSION.sql_big_tables; @@SESSION.sql_big_tables 0 0 / FALSE Expected; SET SESSION sql_big_tables = FALSE; ** Connecting con_int2 using root ** ** Connection con_int2 ** SELECT @@SESSION.sql_big_tables; @@SESSION.sql_big_tables 0 0 / FALSE Expected; SET SESSION sql_big_tables = TRUE; ** Connection con_int1 ** SELECT @@SESSION.sql_big_tables; @@SESSION.sql_big_tables 0 0 / FALSE Expected; ** Connection con_int2 ** SELECT @@SESSION.sql_big_tables; @@SESSION.sql_big_tables 1 1 / TRUE Expected; ** Connection default ** Disconnecting Connections con_int1, con_int2 SET SESSION sql_big_tables = @old_big_tables; DROP TABLE t1;