@@ -122,6 +122,66 @@ type ScriptTestAssertion struct {
122122// Unlike other engine tests, ScriptTests must be self-contained. No other tables are created outside the definition of
123123// the tests.
124124var ScriptTests = []ScriptTest {
125+ {
126+ // https://github.com/dolthub/go-mysql-server/issues/3259
127+ Name : "Missing column with same name as system variable" ,
128+ SetUpScript : []string {
129+ "CREATE DATABASE IF NOT EXISTS test_db" ,
130+ "USE test_db" ,
131+ "CREATE TABLE A (id INT)" ,
132+ "CREATE TABLE B (id INT)" ,
133+ "INSERT INTO A VALUES (1)" ,
134+ "INSERT INTO B VALUES (2)" ,
135+ },
136+ Assertions : []ScriptTestAssertion {
137+ {
138+ Query : "SELECT UNIX_TIMESTAMP(A.timestamp) FROM A LIMIT 1" ,
139+ ExpectedErr : sql .ErrTableColumnNotFound ,
140+ },
141+ {
142+ Query : "SELECT A.timestamp FROM A" ,
143+ ExpectedErr : sql .ErrTableColumnNotFound ,
144+ },
145+ {
146+ Query : "SELECT A.version FROM A" ,
147+ ExpectedErr : sql .ErrTableColumnNotFound ,
148+ },
149+ {
150+ Query : "SELECT A.max_connections FROM A" ,
151+ ExpectedErr : sql .ErrTableColumnNotFound ,
152+ },
153+ {
154+ Query : "SELECT UPPER(A.sql_mode) FROM A" ,
155+ ExpectedErr : sql .ErrTableColumnNotFound ,
156+ },
157+ {
158+ Query : "SELECT @@timestamp" ,
159+ Expected : []sql.Row {{float64 (0 )}},
160+ SkipResultsCheck : true , // dynamic var
161+ },
162+ {
163+ Query : "SELECT @@version" ,
164+ Expected : []sql.Row {{"" }},
165+ SkipResultsCheck : true , // dynamic var
166+ },
167+ {
168+ Query : "SELECT test_db.A.timestamp FROM A" ,
169+ ExpectedErr : sql .ErrTableColumnNotFound ,
170+ },
171+ {
172+ Query : "SELECT test_db.A.version FROM test_db.A" ,
173+ ExpectedErr : sql .ErrTableColumnNotFound ,
174+ },
175+ {
176+ Query : "SELECT a1.timestamp FROM A a1 JOIN B b1 ON a1.id = b1.id" ,
177+ ExpectedErr : sql .ErrTableColumnNotFound ,
178+ },
179+ {
180+ Query : "SELECT b1.max_connections FROM A a1 JOIN B b1 ON a1.id = b1.id" ,
181+ ExpectedErr : sql .ErrTableColumnNotFound ,
182+ },
183+ },
184+ },
125185 {
126186 // https://github.com/dolthub/dolt/issues/9927
127187 // https://github.com/dolthub/dolt/issues/9053
0 commit comments