@@ -122,6 +122,98 @@ 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/dolt/issues/9927
127+ // https://github.com/dolthub/dolt/issues/9053
128+ Name : "double negation of integer minimum values" ,
129+ SetUpScript : []string {
130+ "CREATE TABLE t0(c0 BIGINT);" ,
131+ "INSERT INTO t0(c0) VALUES (-9223372036854775808);" ,
132+ "CREATE TABLE t1(c0 INT);" ,
133+ "INSERT INTO t1(c0) VALUES (-2147483648);" ,
134+ "CREATE TABLE t2(c0 SMALLINT);" ,
135+ "INSERT INTO t2(c0) VALUES (-32768);" ,
136+ "CREATE TABLE t3(c0 TINYINT);" ,
137+ "INSERT INTO t3(c0) VALUES (-128);" ,
138+ },
139+ Assertions : []ScriptTestAssertion {
140+ {
141+ Query : "SELECT 128;" ,
142+ Expected : []sql.Row {{uint64 (128 )}},
143+ ExpectedColumns : sql.Schema {{Name : "128" , Type : types .Uint8 }},
144+ },
145+ {
146+ Query : "SELECT -128;" ,
147+ Expected : []sql.Row {{int8 (- 128 )}},
148+ ExpectedColumns : sql.Schema {{Name : "-128" , Type : types .Int8 }},
149+ },
150+ {
151+ Query : "SELECT -(-128);" ,
152+ Expected : []sql.Row {{int16 (128 )}},
153+ ExpectedColumns : sql.Schema {{Name : "-(-128)" , Type : types .Int16 }},
154+ },
155+ {
156+ Query : "SELECT -(-32768);" ,
157+ Expected : []sql.Row {{int32 (32768 )}},
158+ ExpectedColumns : sql.Schema {{Name : "-(-32768)" , Type : types .Int32 }},
159+ },
160+ {
161+ Query : "SELECT -(-2147483648);" ,
162+ Expected : []sql.Row {{int64 (2147483648 )}},
163+ ExpectedColumns : sql.Schema {{Name : "-(-2147483648)" , Type : types .Int64 }},
164+ },
165+ {
166+ Query : "SELECT -(-9223372036854775808)" ,
167+ Expected : []sql.Row {{"9223372036854775808" }},
168+ ExpectedColumns : sql.Schema {{Name : "-(-9223372036854775808)" , Type : types .InternalDecimalType }},
169+ },
170+ {
171+ Query : "SELECT -t0.c0 FROM t0;" ,
172+ ExpectedErr : sql .ErrValueOutOfRange ,
173+ },
174+ {
175+ Query : "SELECT -t1.c0 FROM t1;" ,
176+ Expected : []sql.Row {{2147483648 }},
177+ },
178+ {
179+ Query : "SELECT -t2.c0 FROM t2;" ,
180+ Expected : []sql.Row {{32768 }},
181+ },
182+ {
183+ Query : "SELECT -t3.c0 FROM t3;" ,
184+ Expected : []sql.Row {{128 }},
185+ },
186+ {
187+ Query : "SELECT -(-t1.c0 + 1) FROM t1;" ,
188+ Expected : []sql.Row {{- 2147483649 }},
189+ },
190+ {
191+ Query : "SELECT -(-(t2.c0 - 1)) FROM t2;" ,
192+ Expected : []sql.Row {{- 32769 }},
193+ },
194+ {
195+ Query : "SELECT -(-t3.c0 * 2) FROM t3;" ,
196+ Expected : []sql.Row {{- 256 }},
197+ },
198+ {
199+ Query : "SELECT -(-(-128));" ,
200+ Expected : []sql.Row {{int8 (- 128 )}},
201+ },
202+ {
203+ Query : "SELECT -(-(-(-128)));" ,
204+ Expected : []sql.Row {{int16 (128 )}},
205+ },
206+ {
207+ Query : "SELECT -(-NULL);" ,
208+ Expected : []sql.Row {{nil }},
209+ },
210+ {
211+ Query : "SELECT -(-CAST(-128 AS SIGNED));" ,
212+ Expected : []sql.Row {{int64 (- 128 )}},
213+ ExpectedColumns : sql.Schema {{Name : "-(-CAST(-128 AS SIGNED))" , Type : types .Int64 }},
214+ },
215+ },
216+ },
125217 {
126218 // https://github.com/dolthub/dolt/issues/9865
127219 Name : "Stored procedure containing a transaction does not return EOF" ,
0 commit comments