github.com/dolthub/go-mysql-server@v0.18.0/enginetest/queries/type_wire_queries.go (about) 1 // Copyright 2022 Dolthub, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package queries 16 17 import "github.com/dolthub/go-mysql-server/sql" 18 19 // TypeWireTest is used to ensure that types are properly represented over the wire (vs being directly returned from the 20 // engine). 21 type TypeWireTest struct { 22 Name string 23 SetUpScript []string 24 Queries []string 25 Results [][]sql.Row 26 } 27 28 // TypeWireTests are used to ensure that types are properly represented over the wire (vs being directly returned from 29 // the engine). 30 var TypeWireTests = []TypeWireTest{ 31 { 32 Name: "TINYINT", 33 SetUpScript: []string{ 34 `CREATE TABLE test (pk TINYINT PRIMARY KEY, v1 TINYINT);`, 35 `INSERT INTO test VALUES (-75, "-25"), (0, 0), (107.2, 0025), (107.5, 0025), (120, -120);`, 36 `UPDATE test SET v1 = v1 - 1 WHERE pk < 0;`, 37 `DELETE FROM test WHERE pk > "119";`, 38 }, 39 Queries: []string{ 40 `SELECT * FROM test ORDER BY pk;`, 41 `SELECT v1, pk FROM test ORDER BY pk;`, 42 `SELECT v1*2, pk+1 FROM test ORDER BY pk;`, 43 }, 44 Results: [][]sql.Row{ 45 {{"-75", "-26"}, {"0", "0"}, {"107", "25"}, {"108", "25"}}, 46 {{"-26", "-75"}, {"0", "0"}, {"25", "107"}, {"25", "108"}}, 47 {{"-52", "-74"}, {"0", "1"}, {"50", "108"}, {"50", "109"}}, 48 }, 49 }, 50 { 51 Name: "SMALLINT", 52 SetUpScript: []string{ 53 `CREATE TABLE test (pk SMALLINT PRIMARY KEY, v1 SMALLINT);`, 54 `INSERT INTO test VALUES (-75.7, "-2531"), (-75, "-2531"), (0, 0), (2547.2, 03325), (2547.6, 03325), (9999, 9999);`, 55 `UPDATE test SET v1 = v1 - 1 WHERE pk < 0;`, 56 `DELETE FROM test WHERE pk >= "9999";`, 57 }, 58 Queries: []string{ 59 `SELECT * FROM test ORDER BY pk;`, 60 `SELECT v1, pk FROM test ORDER BY pk;`, 61 `SELECT v1*2, pk+1 FROM test ORDER BY pk;`, 62 }, 63 Results: [][]sql.Row{ 64 {{"-76", "-2532"}, {"-75", "-2532"}, {"0", "0"}, {"2547", "3325"}, {"2548", "3325"}}, 65 {{"-2532", "-76"}, {"-2532", "-75"}, {"0", "0"}, {"3325", "2547"}, {"3325", "2548"}}, 66 {{"-5064", "-75"}, {"-5064", "-74"}, {"0", "1"}, {"6650", "2548"}, {"6650", "2549"}}, 67 }, 68 }, 69 { 70 Name: "MEDIUMINT", 71 SetUpScript: []string{ 72 `CREATE TABLE test (pk MEDIUMINT PRIMARY KEY, v1 MEDIUMINT);`, 73 `INSERT INTO test VALUES (-75, "-2531"), (0, 0), (2547.2, 03325), (2547.7, 03325), (999999, 999999);`, 74 `UPDATE test SET v1 = v1 - 1 WHERE pk < 0;`, 75 `DELETE FROM test WHERE pk > "99999";`, 76 }, 77 Queries: []string{ 78 `SELECT * FROM test ORDER BY pk;`, 79 `SELECT v1, pk FROM test ORDER BY pk;`, 80 `SELECT v1*2, pk+1 FROM test ORDER BY pk;`, 81 }, 82 Results: [][]sql.Row{ 83 {{"-75", "-2532"}, {"0", "0"}, {"2547", "3325"}, {"2548", "3325"}}, 84 {{"-2532", "-75"}, {"0", "0"}, {"3325", "2547"}, {"3325", "2548"}}, 85 {{"-5064", "-74"}, {"0", "1"}, {"6650", "2548"}, {"6650", "2549"}}, 86 }, 87 }, 88 { 89 Name: "INT", 90 SetUpScript: []string{ 91 `CREATE TABLE test (pk INT PRIMARY KEY, v1 INT);`, 92 `INSERT INTO test VALUES (-75, "-2531"), (0, 0), (2547.2, 03325), (2547.8, 03325), (999999, 999999);`, 93 `UPDATE test SET v1 = v1 - 1 WHERE pk < 0;`, 94 `DELETE FROM test WHERE pk > "99999";`, 95 }, 96 Queries: []string{ 97 `SELECT * FROM test ORDER BY pk;`, 98 `SELECT v1, pk FROM test ORDER BY pk;`, 99 `SELECT v1*2, pk+1 FROM test ORDER BY pk;`, 100 }, 101 Results: [][]sql.Row{ 102 {{"-75", "-2532"}, {"0", "0"}, {"2547", "3325"}, {"2548", "3325"}}, 103 {{"-2532", "-75"}, {"0", "0"}, {"3325", "2547"}, {"3325", "2548"}}, 104 {{"-5064", "-74"}, {"0", "1"}, {"6650", "2548"}, {"6650", "2549"}}, 105 }, 106 }, 107 { 108 Name: "BIGINT", 109 SetUpScript: []string{ 110 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 BIGINT);`, 111 `INSERT INTO test VALUES (-75, "-2531"), (0, 0), (2547.2, 03325), (2547.9, 03325), (999999, 999999);`, 112 `UPDATE test SET v1 = v1 - 1 WHERE pk < 0;`, 113 `DELETE FROM test WHERE pk > "99999";`, 114 }, 115 Queries: []string{ 116 `SELECT * FROM test ORDER BY pk;`, 117 `SELECT v1, pk FROM test ORDER BY pk;`, 118 `SELECT v1*2, pk+1 FROM test ORDER BY pk;`, 119 }, 120 Results: [][]sql.Row{ 121 {{"-75", "-2532"}, {"0", "0"}, {"2547", "3325"}, {"2548", "3325"}}, 122 {{"-2532", "-75"}, {"0", "0"}, {"3325", "2547"}, {"3325", "2548"}}, 123 {{"-5064", "-74"}, {"0", "1"}, {"6650", "2548"}, {"6650", "2549"}}, 124 }, 125 }, 126 { 127 Name: "TINYINT UNSIGNED", 128 SetUpScript: []string{ 129 `CREATE TABLE test (pk TINYINT UNSIGNED PRIMARY KEY, v1 TINYINT UNSIGNED);`, 130 `INSERT INTO test VALUES (0, 0), (25, "26"), (32.1, 0126), (42.8, 0126), (255, 255);`, 131 `UPDATE test SET v1 = v1 - 1 WHERE pk > 0 AND pk < 30;`, 132 `DELETE FROM test WHERE pk >= "255";`, 133 }, 134 Queries: []string{ 135 `SELECT * FROM test ORDER BY pk;`, 136 `SELECT v1, pk FROM test ORDER BY pk;`, 137 `SELECT v1*2, pk+1 FROM test ORDER BY pk;`, 138 }, 139 Results: [][]sql.Row{ 140 {{"0", "0"}, {"25", "25"}, {"32", "126"}, {"43", "126"}}, 141 {{"0", "0"}, {"25", "25"}, {"126", "32"}, {"126", "43"}}, 142 {{"0", "1"}, {"50", "26"}, {"252", "33"}, {"252", "44"}}, 143 }, 144 }, 145 { 146 Name: "SMALLINT UNSIGNED", 147 SetUpScript: []string{ 148 `CREATE TABLE test (pk SMALLINT UNSIGNED PRIMARY KEY, v1 SMALLINT UNSIGNED);`, 149 `INSERT INTO test VALUES (0, 0), (25, "2531"), (2547.2, 03325), (2547.5, 03325), (9999, 9999);`, 150 `UPDATE test SET v1 = v1 - 1 WHERE pk > 0 AND pk < 100;`, 151 `DELETE FROM test WHERE pk >= "9999";`, 152 }, 153 Queries: []string{ 154 `SELECT * FROM test ORDER BY pk;`, 155 `SELECT v1, pk FROM test ORDER BY pk;`, 156 `SELECT v1*2, pk+1 FROM test ORDER BY pk;`, 157 }, 158 Results: [][]sql.Row{ 159 {{"0", "0"}, {"25", "2530"}, {"2547", "3325"}, {"2548", "3325"}}, 160 {{"0", "0"}, {"2530", "25"}, {"3325", "2547"}, {"3325", "2548"}}, 161 {{"0", "1"}, {"5060", "26"}, {"6650", "2548"}, {"6650", "2549"}}, 162 }, 163 }, 164 { 165 Name: "MEDIUMINT UNSIGNED", 166 SetUpScript: []string{ 167 `CREATE TABLE test (pk MEDIUMINT UNSIGNED PRIMARY KEY, v1 MEDIUMINT UNSIGNED);`, 168 `INSERT INTO test VALUES (75, "2531"), (0, 0), (2547.2, 03325), (2547.6, 03325), (999999, 999999);`, 169 `UPDATE test SET v1 = v1 + 1 WHERE pk < 100;`, 170 `DELETE FROM test WHERE pk > "99999";`, 171 }, 172 Queries: []string{ 173 `SELECT * FROM test ORDER BY pk;`, 174 `SELECT v1, pk FROM test ORDER BY pk;`, 175 `SELECT v1*2, pk+1 FROM test ORDER BY pk;`, 176 }, 177 Results: [][]sql.Row{ 178 {{"0", "1"}, {"75", "2532"}, {"2547", "3325"}, {"2548", "3325"}}, 179 {{"1", "0"}, {"2532", "75"}, {"3325", "2547"}, {"3325", "2548"}}, 180 {{"2", "1"}, {"5064", "76"}, {"6650", "2548"}, {"6650", "2549"}}, 181 }, 182 }, 183 { 184 Name: "INT UNSIGNED", 185 SetUpScript: []string{ 186 `CREATE TABLE test (pk INT UNSIGNED PRIMARY KEY, v1 INT UNSIGNED);`, 187 `INSERT INTO test VALUES (75, "2531"), (0, 0), (2547.2, 03325), (2547.7, 03325), (999999, 999999);`, 188 `UPDATE test SET v1 = v1 + 1 WHERE pk < 100;`, 189 `DELETE FROM test WHERE pk > "99999";`, 190 }, 191 Queries: []string{ 192 `SELECT * FROM test ORDER BY pk;`, 193 `SELECT v1, pk FROM test ORDER BY pk;`, 194 `SELECT v1*2, pk+1 FROM test ORDER BY pk;`, 195 }, 196 Results: [][]sql.Row{ 197 {{"0", "1"}, {"75", "2532"}, {"2547", "3325"}, {"2548", "3325"}}, 198 {{"1", "0"}, {"2532", "75"}, {"3325", "2547"}, {"3325", "2548"}}, 199 {{"2", "1"}, {"5064", "76"}, {"6650", "2548"}, {"6650", "2549"}}, 200 }, 201 }, 202 { 203 Name: "BIGINT UNSIGNED", 204 SetUpScript: []string{ 205 `CREATE TABLE test (pk BIGINT UNSIGNED PRIMARY KEY, v1 BIGINT UNSIGNED);`, 206 `INSERT INTO test VALUES (75, "2531"), (0, 0), (2547.2, 03325), (2547.8, 03325), (999999, 999999);`, 207 `UPDATE test SET v1 = v1 + 1 WHERE pk < 100;`, 208 `DELETE FROM test WHERE pk > "99999";`, 209 }, 210 Queries: []string{ 211 `SELECT * FROM test ORDER BY pk;`, 212 `SELECT v1, pk FROM test ORDER BY pk;`, 213 `SELECT v1*2, pk+1 FROM test ORDER BY pk;`, 214 }, 215 Results: [][]sql.Row{ 216 {{"0", "1"}, {"75", "2532"}, {"2547", "3325"}, {"2548", "3325"}}, 217 {{"1", "0"}, {"2532", "75"}, {"3325", "2547"}, {"3325", "2548"}}, 218 {{"2", "1"}, {"5064", "76"}, {"6650", "2548"}, {"6650", "2549"}}, 219 }, 220 }, 221 { 222 Name: "FLOAT", 223 SetUpScript: []string{ 224 `CREATE TABLE test (pk FLOAT PRIMARY KEY, v1 FLOAT);`, 225 `INSERT INTO test VALUES (-75.11, "-2531"), (0, 0), ("2547.2", 03325), (999999, 999999);`, 226 `UPDATE test SET v1 = v1 - 1 WHERE pk < 0;`, 227 `DELETE FROM test WHERE pk > "99999";`, 228 }, 229 Queries: []string{ 230 `SELECT * FROM test ORDER BY pk;`, 231 `SELECT v1, pk FROM test ORDER BY pk;`, 232 `SELECT v1*2, pk+1 FROM test ORDER BY pk;`, 233 }, 234 Results: [][]sql.Row{ 235 {{"-75.11", "-2532"}, {"0", "0"}, {"2547.2", "3325"}}, 236 {{"-2532", "-75.11"}, {"0", "0"}, {"3325", "2547.2"}}, 237 {{"-5064", "-74.11000061035156"}, {"0", "1"}, {"6650", "2548.199951171875"}}, 238 }, 239 }, 240 { 241 Name: "DOUBLE", 242 SetUpScript: []string{ 243 `CREATE TABLE test (pk DOUBLE PRIMARY KEY, v1 DOUBLE);`, 244 `INSERT INTO test VALUES (-75.11, "-2531"), (0, 0), ("2547.2", 03325), (999999, 999999);`, 245 `UPDATE test SET v1 = v1 - 1 WHERE pk < 0;`, 246 `DELETE FROM test WHERE pk > "99999";`, 247 }, 248 Queries: []string{ 249 `SELECT * FROM test ORDER BY pk;`, 250 `SELECT v1, pk FROM test ORDER BY pk;`, 251 `SELECT v1*2, pk+1 FROM test ORDER BY pk;`, 252 }, 253 Results: [][]sql.Row{ 254 {{"-75.11", "-2532"}, {"0", "0"}, {"2547.2", "3325"}}, 255 {{"-2532", "-75.11"}, {"0", "0"}, {"3325", "2547.2"}}, 256 {{"-5064", "-74.11"}, {"0", "1"}, {"6650", "2548.2"}}, 257 }, 258 }, 259 { 260 Name: "DECIMAL", 261 SetUpScript: []string{ 262 `CREATE TABLE test (pk DECIMAL(5,0) PRIMARY KEY, v1 DECIMAL(25,5));`, 263 `INSERT INTO test VALUES (-75, "-2531.356"), (0, 0), (2547.2, 03325), (99999, 999999);`, 264 `UPDATE test SET v1 = v1 - 1 WHERE pk < 0;`, 265 `DELETE FROM test WHERE pk >= "99999";`, 266 }, 267 Queries: []string{ 268 `SELECT * FROM test ORDER BY pk;`, 269 `SELECT v1, pk FROM test ORDER BY pk;`, 270 `SELECT v1*2, pk+1 FROM test ORDER BY pk;`, 271 }, 272 Results: [][]sql.Row{ 273 {{"-75", "-2532.35600"}, {"0", "0.00000"}, {"2547", "3325.00000"}}, 274 {{"-2532.35600", "-75"}, {"0.00000", "0"}, {"3325.00000", "2547"}}, 275 {{"-5064.71200", "-74"}, {"0.00000", "1"}, {"6650.00000", "2548"}}, 276 }, 277 }, 278 { 279 Name: "BIT", 280 SetUpScript: []string{ 281 `CREATE TABLE test (pk BIT(55) PRIMARY KEY, v1 BIT(1), v2 BIT(24));`, 282 `INSERT INTO test VALUES (75, 0, "21"), (0, 0, 0), (2547.2, 1, 03325), (999999, 1, 999999);`, 283 `UPDATE test SET v2 = v2 - 1 WHERE pk > 0 AND pk < 100;`, 284 `DELETE FROM test WHERE pk > 99999;`, 285 }, 286 Queries: []string{ 287 `SELECT * FROM test ORDER BY pk;`, 288 `SELECT v2, v1, pk FROM test ORDER BY pk;`, 289 `SELECT v1*1, pk/10, v2+1 FROM test ORDER BY pk;`, 290 }, 291 Results: [][]sql.Row{ 292 {{"\x00\x00\x00\x00\x00\x00\x00", "\x00", "\x00\x00\x00"}, {"\x00\x00\x00\x00\x00\x00K", "\x00", "\x0020"}, {"\x00\x00\x00\x00\x00\t\xf3", "", "\x00\xfd"}}, 293 {{"\x00\x00\x00", "\x00", "\x00\x00\x00\x00\x00\x00\x00"}, {"\x0020", "\x00", "\x00\x00\x00\x00\x00\x00K"}, {"\x00\xfd", "", "\x00\x00\x00\x00\x00\t\xf3"}}, 294 {{"0", "0.0000", "1"}, {"0", "7.5000", "12849"}, {"1", "254.7000", "3326"}}, 295 }, 296 }, 297 { 298 Name: "YEAR", 299 SetUpScript: []string{ 300 `CREATE TABLE test (pk YEAR PRIMARY KEY, v1 YEAR);`, 301 `INSERT INTO test VALUES (1901, 1901), (1950, "1950"), (1979.2, 01986), (2122, 2122);`, 302 `UPDATE test SET v1 = v1 + 1 WHERE pk < 1975;`, 303 `DELETE FROM test WHERE pk > "2100";`, 304 }, 305 Queries: []string{ 306 `SELECT * FROM test ORDER BY pk;`, 307 `SELECT v1, pk FROM test ORDER BY pk;`, 308 `SELECT v1+3, pk+2 FROM test ORDER BY pk;`, 309 }, 310 Results: [][]sql.Row{ 311 {{"1901", "1902"}, {"1950", "1951"}, {"1979", "1986"}}, 312 {{"1902", "1901"}, {"1951", "1950"}, {"1986", "1979"}}, 313 {{"1905", "1903"}, {"1954", "1952"}, {"1989", "1981"}}, 314 }, 315 }, 316 { 317 Name: "TIMESTAMP", 318 SetUpScript: []string{ 319 `CREATE TABLE test (pk TIMESTAMP PRIMARY KEY, v1 TIMESTAMP);`, 320 `INSERT INTO test VALUES ("1980-04-12 12:02:11", "1986-08-02 17:04:22"), ("1999-11-28 13:06:33", "2022-01-14 15:08:44"), ("2020-05-06 18:10:55", "1975-09-15 11:12:16");`, 321 `UPDATE test SET v1 = "2000-01-01 00:00:00" WHERE pk < "1990-01-01 00:00:00";`, 322 `DELETE FROM test WHERE pk > "2015-01-01 00:00:00";`, 323 }, 324 Queries: []string{ 325 `SELECT * FROM test ORDER BY pk;`, 326 `SELECT pk, v1 FROM test ORDER BY pk;`, 327 `SELECT v1, pk FROM test ORDER BY pk;`, 328 `SELECT DATE_ADD(TIMESTAMP('2022-10-26 13:14:15'), INTERVAL 1 DAY);`, 329 `SELECT DATE_ADD('2022-10-26 13:14:15', INTERVAL 1 DAY);`, 330 `SELECT DATE_ADD('2022-10-26', INTERVAL 1 SECOND);`, 331 `SELECT DATE_ADD('2022-10-26', INTERVAL 1 MINUTE);`, 332 `SELECT DATE_ADD('2022-10-26', INTERVAL 1 HOUR);`, 333 }, 334 Results: [][]sql.Row{ 335 {{"1980-04-12 12:02:11", "2000-01-01 00:00:00"}, {"1999-11-28 13:06:33", "2022-01-14 15:08:44"}}, 336 {{"1980-04-12 12:02:11", "2000-01-01 00:00:00"}, {"1999-11-28 13:06:33", "2022-01-14 15:08:44"}}, 337 {{"2000-01-01 00:00:00", "1980-04-12 12:02:11"}, {"2022-01-14 15:08:44", "1999-11-28 13:06:33"}}, 338 {{"2022-10-27 13:14:15"}}, 339 {{"2022-10-27 13:14:15"}}, 340 {{"2022-10-26 00:00:01"}}, 341 {{"2022-10-26 00:01:00"}}, 342 {{"2022-10-26 01:00:00"}}, 343 }, 344 }, 345 { 346 Name: "DATETIME", 347 SetUpScript: []string{ 348 `CREATE TABLE test (pk DATETIME PRIMARY KEY, v1 DATETIME);`, 349 `INSERT INTO test VALUES ("1000-04-12 12:02:11", "1986-08-02 17:04:22"), ("1999-11-28 13:06:33", "2022-01-14 15:08:44"), ("5020-05-06 18:10:55", "1975-09-15 11:12:16");`, 350 `UPDATE test SET v1 = "2000-01-01 00:00:00" WHERE pk < "1990-01-01 00:00:00";`, 351 `DELETE FROM test WHERE pk > "5000-01-01 00:00:00";`, 352 }, 353 Queries: []string{ 354 `SELECT * FROM test ORDER BY pk;`, 355 `SELECT pk, v1 FROM test ORDER BY pk;`, 356 `SELECT v1, pk FROM test ORDER BY pk;`, 357 `SELECT DATE_ADD('2022-10-26 13:14:15', INTERVAL 1 DAY);`, 358 `SELECT DATE_ADD('2022-10-26', INTERVAL 1 SECOND);`, 359 `SELECT DATE_ADD('2022-10-26', INTERVAL 1 MINUTE);`, 360 `SELECT DATE_ADD('2022-10-26', INTERVAL 1 HOUR);`, 361 }, 362 Results: [][]sql.Row{ 363 {{"1000-04-12 12:02:11", "2000-01-01 00:00:00"}, {"1999-11-28 13:06:33", "2022-01-14 15:08:44"}}, 364 {{"1000-04-12 12:02:11", "2000-01-01 00:00:00"}, {"1999-11-28 13:06:33", "2022-01-14 15:08:44"}}, 365 {{"2000-01-01 00:00:00", "1000-04-12 12:02:11"}, {"2022-01-14 15:08:44", "1999-11-28 13:06:33"}}, 366 {{"2022-10-27 13:14:15"}}, 367 {{"2022-10-26 00:00:01"}}, 368 {{"2022-10-26 00:01:00"}}, 369 {{"2022-10-26 01:00:00"}}, 370 }, 371 }, 372 { 373 Name: "DATE", 374 SetUpScript: []string{ 375 `CREATE TABLE test (pk DATE PRIMARY KEY, v1 DATE);`, 376 `INSERT INTO test VALUES ("1000-04-12", "1986-08-02"), ("1999-11-28", "2022-01-14"), ("5020-05-06", "1975-09-15");`, 377 `UPDATE test SET v1 = "2000-01-01" WHERE pk < "1990-01-01";`, 378 `DELETE FROM test WHERE pk > "5000-01-01";`, 379 }, 380 Queries: []string{ 381 `SELECT * FROM test ORDER BY pk;`, 382 `SELECT pk, v1 FROM test ORDER BY pk;`, 383 `SELECT v1, pk FROM test ORDER BY pk;`, 384 `SELECT DATE_ADD(DATE('2022-10-26'), INTERVAL 1 DAY);`, 385 `SELECT DATE_ADD(DATE('2022-10-26'), INTERVAL 1 WEEK);`, 386 `SELECT DATE_ADD(DATE('2022-10-26'), INTERVAL 1 MONTH);`, 387 `SELECT DATE_ADD(DATE('2022-10-26'), INTERVAL 1 QUARTER);`, 388 `SELECT DATE_ADD(DATE('2022-10-26'), INTERVAL 1 YEAR);`, 389 }, 390 Results: [][]sql.Row{ 391 {{"1000-04-12", "2000-01-01"}, {"1999-11-28", "2022-01-14"}}, 392 {{"1000-04-12", "2000-01-01"}, {"1999-11-28", "2022-01-14"}}, 393 {{"2000-01-01", "1000-04-12"}, {"2022-01-14", "1999-11-28"}}, 394 {{"2022-10-27"}}, 395 {{"2022-11-02"}}, 396 {{"2022-11-26"}}, 397 {{"2023-01-26"}}, 398 {{"2023-10-26"}}, 399 }, 400 }, 401 { 402 Name: "TIME", 403 SetUpScript: []string{ 404 `CREATE TABLE test (pk TIME PRIMARY KEY, v1 TIME);`, 405 `INSERT INTO test VALUES ("-800:00:00", "-20:21:22"), ("00:00:00", "00:00:00"), ("10:26:57", "30:53:14"), ("700:23:51", "300:25:52");`, 406 `UPDATE test SET v1 = "-120:12:20" WHERE pk < "00:00:00";`, 407 `DELETE FROM test WHERE pk > "600:00:00";`, 408 }, 409 Queries: []string{ 410 `SELECT * FROM test ORDER BY pk;`, 411 `SELECT pk, v1 FROM test ORDER BY pk;`, 412 `SELECT v1, pk FROM test ORDER BY pk;`, 413 // Known bug - https://github.com/dolthub/dolt/issues/4643 414 //`SELECT DATE_ADD(TIMEDIFF('12:13:14', '0:0:0'), INTERVAL 1 SECOND);`, 415 //`SELECT DATE_ADD(TIMEDIFF('12:13:14', '0:0:0'), INTERVAL 1 MINUTE);`, 416 //`SELECT DATE_ADD(TIMEDIFF('12:13:14', '0:0:0'), INTERVAL 1 HOUR);`, 417 }, 418 Results: [][]sql.Row{ 419 {{"-800:00:00", "-120:12:20"}, {"00:00:00", "00:00:00"}, {"10:26:57", "30:53:14"}}, 420 {{"-800:00:00", "-120:12:20"}, {"00:00:00", "00:00:00"}, {"10:26:57", "30:53:14"}}, 421 {{"-120:12:20", "-800:00:00"}, {"00:00:00", "00:00:00"}, {"30:53:14", "10:26:57"}}, 422 }, 423 }, 424 { 425 Name: "CHAR", 426 SetUpScript: []string{ 427 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 CHAR(5), v2 CHAR(10));`, 428 `INSERT INTO test VALUES (1, "abc", "def"), (2, "c-a", "123"), (3, "__2", 456), (4, "?hi?", "\\n");`, 429 `UPDATE test SET v1 = "a-c" WHERE pk = 2;`, 430 `DELETE FROM test WHERE pk = 4;`, 431 }, 432 Queries: []string{ 433 `SELECT * FROM test ORDER BY pk;`, 434 `SELECT pk, v2, v1 FROM test ORDER BY pk;`, 435 `SELECT CONCAT(v1, "r"), pk, v2 FROM test ORDER BY pk;`, 436 }, 437 Results: [][]sql.Row{ 438 {{"1", "abc", "def"}, {"2", "a-c", "123"}, {"3", "__2", "456"}}, 439 {{"1", "def", "abc"}, {"2", "123", "a-c"}, {"3", "456", "__2"}}, 440 {{"abcr", "1", "def"}, {"a-cr", "2", "123"}, {"__2r", "3", "456"}}, 441 }, 442 }, 443 { 444 Name: "VARCHAR", 445 SetUpScript: []string{ 446 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 VARCHAR(5), v2 VARCHAR(10));`, 447 `INSERT INTO test VALUES (1, "abc", "def"), (2, "c-a", "123"), (3, "__2", 456), (4, "?hi?", "\\n");`, 448 `UPDATE test SET v1 = CONCAT(v1, "x") WHERE pk = 2;`, 449 `DELETE FROM test WHERE pk = 4;`, 450 }, 451 Queries: []string{ 452 `SELECT * FROM test ORDER BY pk;`, 453 `SELECT pk, v2, v1 FROM test ORDER BY pk;`, 454 `SELECT CONCAT(v1, "r"), pk, v2 FROM test ORDER BY pk;`, 455 `SELECT DATE_ADD('2022-10-26 13:14:15', INTERVAL 1 DAY);`, 456 }, 457 Results: [][]sql.Row{ 458 {{"1", "abc", "def"}, {"2", "c-ax", "123"}, {"3", "__2", "456"}}, 459 {{"1", "def", "abc"}, {"2", "123", "c-ax"}, {"3", "456", "__2"}}, 460 {{"abcr", "1", "def"}, {"c-axr", "2", "123"}, {"__2r", "3", "456"}}, 461 {{"2022-10-27 13:14:15"}}, 462 }, 463 }, 464 { 465 Name: "BINARY", 466 SetUpScript: []string{ 467 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 BINARY(5), v2 BINARY(10));`, 468 `INSERT INTO test VALUES (1, "abc", "def"), (2, "c-a", "123"), (3, "__2", 456), (4, "?hi?", "\\n");`, 469 `UPDATE test SET v1 = "a-c" WHERE pk = 2;`, 470 `DELETE FROM test WHERE pk = 4;`, 471 }, 472 Queries: []string{ 473 `SELECT * FROM test ORDER BY pk;`, 474 `SELECT pk, v2, v1 FROM test ORDER BY pk;`, 475 `SELECT CONCAT(v1, "r"), pk, v2 FROM test ORDER BY pk;`, 476 }, 477 Results: [][]sql.Row{ 478 {{"1", "abc\x00\x00", "def\x00\x00\x00\x00\x00\x00\x00"}, {"2", "a-c\x00\x00", "123\x00\x00\x00\x00\x00\x00\x00"}, {"3", "__2\x00\x00", "456\x00\x00\x00\x00\x00\x00\x00"}}, 479 {{"1", "def\x00\x00\x00\x00\x00\x00\x00", "abc\x00\x00"}, {"2", "123\x00\x00\x00\x00\x00\x00\x00", "a-c\x00\x00"}, {"3", "456\x00\x00\x00\x00\x00\x00\x00", "__2\x00\x00"}}, 480 {{"abc\x00\x00r", "1", "def\x00\x00\x00\x00\x00\x00\x00"}, {"a-c\x00\x00r", "2", "123\x00\x00\x00\x00\x00\x00\x00"}, {"__2\x00\x00r", "3", "456\x00\x00\x00\x00\x00\x00\x00"}}, 481 }, 482 }, 483 { 484 Name: "VARBINARY", 485 SetUpScript: []string{ 486 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 VARBINARY(5), v2 VARBINARY(10));`, 487 `INSERT INTO test VALUES (1, "abc", "def"), (2, "c-a", "123"), (3, "__2", 456), (4, "?hi?", "\\n");`, 488 `UPDATE test SET v1 = CONCAT(v1, "x") WHERE pk = 2;`, 489 `DELETE FROM test WHERE pk = 4;`, 490 }, 491 Queries: []string{ 492 `SELECT * FROM test ORDER BY pk;`, 493 `SELECT pk, v2, v1 FROM test ORDER BY pk;`, 494 `SELECT CONCAT(v1, "r"), pk, v2 FROM test ORDER BY pk;`, 495 }, 496 Results: [][]sql.Row{ 497 {{"1", "abc", "def"}, {"2", "c-ax", "123"}, {"3", "__2", "456"}}, 498 {{"1", "def", "abc"}, {"2", "123", "c-ax"}, {"3", "456", "__2"}}, 499 {{"abcr", "1", "def"}, {"c-axr", "2", "123"}, {"__2r", "3", "456"}}, 500 }, 501 }, 502 { 503 Name: "TINYTEXT", 504 SetUpScript: []string{ 505 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 TINYTEXT, v2 TINYTEXT);`, 506 `INSERT INTO test VALUES (1, "abc", "def"), (2, "c-a", "123"), (3, "__2", 456), (4, "?hi?", "\\n");`, 507 `UPDATE test SET v1 = CONCAT(v1, "x") WHERE pk = 2;`, 508 `DELETE FROM test WHERE pk = 4;`, 509 }, 510 Queries: []string{ 511 `SELECT * FROM test ORDER BY pk;`, 512 `SELECT pk, v2, v1 FROM test ORDER BY pk;`, 513 `SELECT CONCAT(v1, "r"), pk, v2 FROM test ORDER BY pk;`, 514 }, 515 Results: [][]sql.Row{ 516 {{"1", "abc", "def"}, {"2", "c-ax", "123"}, {"3", "__2", "456"}}, 517 {{"1", "def", "abc"}, {"2", "123", "c-ax"}, {"3", "456", "__2"}}, 518 {{"abcr", "1", "def"}, {"c-axr", "2", "123"}, {"__2r", "3", "456"}}, 519 }, 520 }, 521 { 522 Name: "TEXT", 523 SetUpScript: []string{ 524 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 TEXT, v2 TEXT);`, 525 `INSERT INTO test VALUES (1, "abc", "def"), (2, "c-a", "123"), (3, "__2", 456), (4, "?hi?", "\\n");`, 526 `UPDATE test SET v1 = CONCAT(v1, "x") WHERE pk = 2;`, 527 `DELETE FROM test WHERE pk = 4;`, 528 }, 529 Queries: []string{ 530 `SELECT * FROM test ORDER BY pk;`, 531 `SELECT pk, v2, v1 FROM test ORDER BY pk;`, 532 `SELECT CONCAT(v1, "r"), pk, v2 FROM test ORDER BY pk;`, 533 }, 534 Results: [][]sql.Row{ 535 {{"1", "abc", "def"}, {"2", "c-ax", "123"}, {"3", "__2", "456"}}, 536 {{"1", "def", "abc"}, {"2", "123", "c-ax"}, {"3", "456", "__2"}}, 537 {{"abcr", "1", "def"}, {"c-axr", "2", "123"}, {"__2r", "3", "456"}}, 538 }, 539 }, 540 { 541 Name: "MEDIUMTEXT", 542 SetUpScript: []string{ 543 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 MEDIUMTEXT, v2 MEDIUMTEXT);`, 544 `INSERT INTO test VALUES (1, "abc", "def"), (2, "c-a", "123"), (3, "__2", 456), (4, "?hi?", "\\n");`, 545 `UPDATE test SET v1 = CONCAT(v1, "x") WHERE pk = 2;`, 546 `DELETE FROM test WHERE pk = 4;`, 547 }, 548 Queries: []string{ 549 `SELECT * FROM test ORDER BY pk;`, 550 `SELECT pk, v2, v1 FROM test ORDER BY pk;`, 551 `SELECT CONCAT(v1, "r"), pk, v2 FROM test ORDER BY pk;`, 552 }, 553 Results: [][]sql.Row{ 554 {{"1", "abc", "def"}, {"2", "c-ax", "123"}, {"3", "__2", "456"}}, 555 {{"1", "def", "abc"}, {"2", "123", "c-ax"}, {"3", "456", "__2"}}, 556 {{"abcr", "1", "def"}, {"c-axr", "2", "123"}, {"__2r", "3", "456"}}, 557 }, 558 }, 559 { 560 Name: "LONGTEXT", 561 SetUpScript: []string{ 562 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 LONGTEXT, v2 LONGTEXT);`, 563 `INSERT INTO test VALUES (1, "abc", "def"), (2, "c-a", "123"), (3, "__2", 456), (4, "?hi?", "\\n");`, 564 `UPDATE test SET v1 = CONCAT(v1, "x") WHERE pk = 2;`, 565 `DELETE FROM test WHERE pk = 4;`, 566 }, 567 Queries: []string{ 568 `SELECT * FROM test ORDER BY pk;`, 569 `SELECT pk, v2, v1 FROM test ORDER BY pk;`, 570 `SELECT CONCAT(v1, "r"), pk, v2 FROM test ORDER BY pk;`, 571 }, 572 Results: [][]sql.Row{ 573 {{"1", "abc", "def"}, {"2", "c-ax", "123"}, {"3", "__2", "456"}}, 574 {{"1", "def", "abc"}, {"2", "123", "c-ax"}, {"3", "456", "__2"}}, 575 {{"abcr", "1", "def"}, {"c-axr", "2", "123"}, {"__2r", "3", "456"}}, 576 }, 577 }, 578 { 579 Name: "TINYBLOB", 580 SetUpScript: []string{ 581 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 TINYBLOB, v2 TINYBLOB);`, 582 `INSERT INTO test VALUES (1, "abc", "def"), (2, "c-a", "123"), (3, "__2", 456), (4, "?hi?", "\\n");`, 583 `UPDATE test SET v1 = CONCAT(v1, "x") WHERE pk = 2;`, 584 `DELETE FROM test WHERE pk = 4;`, 585 }, 586 Queries: []string{ 587 `SELECT * FROM test ORDER BY pk;`, 588 `SELECT pk, v2, v1 FROM test ORDER BY pk;`, 589 `SELECT CONCAT(v1, "r"), pk, v2 FROM test ORDER BY pk;`, 590 }, 591 Results: [][]sql.Row{ 592 {{"1", "abc", "def"}, {"2", "c-ax", "123"}, {"3", "__2", "456"}}, 593 {{"1", "def", "abc"}, {"2", "123", "c-ax"}, {"3", "456", "__2"}}, 594 {{"abcr", "1", "def"}, {"c-axr", "2", "123"}, {"__2r", "3", "456"}}, 595 }, 596 }, 597 { 598 Name: "BLOB", 599 SetUpScript: []string{ 600 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 BLOB, v2 BLOB);`, 601 `INSERT INTO test VALUES (1, "abc", "def"), (2, "c-a", "123"), (3, "__2", 456), (4, "?hi?", "\\n");`, 602 `UPDATE test SET v1 = CONCAT(v1, "x") WHERE pk = 2;`, 603 `DELETE FROM test WHERE pk = 4;`, 604 }, 605 Queries: []string{ 606 `SELECT * FROM test ORDER BY pk;`, 607 `SELECT pk, v2, v1 FROM test ORDER BY pk;`, 608 `SELECT CONCAT(v1, "r"), pk, v2 FROM test ORDER BY pk;`, 609 }, 610 Results: [][]sql.Row{ 611 {{"1", "abc", "def"}, {"2", "c-ax", "123"}, {"3", "__2", "456"}}, 612 {{"1", "def", "abc"}, {"2", "123", "c-ax"}, {"3", "456", "__2"}}, 613 {{"abcr", "1", "def"}, {"c-axr", "2", "123"}, {"__2r", "3", "456"}}, 614 }, 615 }, 616 { 617 Name: "MEDIUMBLOB", 618 SetUpScript: []string{ 619 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 MEDIUMBLOB, v2 MEDIUMBLOB);`, 620 `INSERT INTO test VALUES (1, "abc", "def"), (2, "c-a", "123"), (3, "__2", 456), (4, "?hi?", "\\n");`, 621 `UPDATE test SET v1 = CONCAT(v1, "x") WHERE pk = 2;`, 622 `DELETE FROM test WHERE pk = 4;`, 623 }, 624 Queries: []string{ 625 `SELECT * FROM test ORDER BY pk;`, 626 `SELECT pk, v2, v1 FROM test ORDER BY pk;`, 627 `SELECT CONCAT(v1, "r"), pk, v2 FROM test ORDER BY pk;`, 628 }, 629 Results: [][]sql.Row{ 630 {{"1", "abc", "def"}, {"2", "c-ax", "123"}, {"3", "__2", "456"}}, 631 {{"1", "def", "abc"}, {"2", "123", "c-ax"}, {"3", "456", "__2"}}, 632 {{"abcr", "1", "def"}, {"c-axr", "2", "123"}, {"__2r", "3", "456"}}, 633 }, 634 }, 635 { 636 Name: "LONGBLOB", 637 SetUpScript: []string{ 638 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 LONGBLOB, v2 LONGBLOB);`, 639 `INSERT INTO test VALUES (1, "abc", "def"), (2, "c-a", "123"), (3, "__2", 456), (4, "?hi?", "\\n");`, 640 `UPDATE test SET v1 = CONCAT(v1, "x") WHERE pk = 2;`, 641 `DELETE FROM test WHERE pk = 4;`, 642 }, 643 Queries: []string{ 644 `SELECT * FROM test ORDER BY pk;`, 645 `SELECT pk, v2, v1 FROM test ORDER BY pk;`, 646 `SELECT CONCAT(v1, "r"), pk, v2 FROM test ORDER BY pk;`, 647 }, 648 Results: [][]sql.Row{ 649 {{"1", "abc", "def"}, {"2", "c-ax", "123"}, {"3", "__2", "456"}}, 650 {{"1", "def", "abc"}, {"2", "123", "c-ax"}, {"3", "456", "__2"}}, 651 {{"abcr", "1", "def"}, {"c-axr", "2", "123"}, {"__2r", "3", "456"}}, 652 }, 653 }, 654 { 655 Name: "ENUM", 656 SetUpScript: []string{ 657 `CREATE TABLE test (pk ENUM("a","b","c") PRIMARY KEY, v1 ENUM("x","y","z"));`, 658 `INSERT INTO test VALUES (1, 1), ("b", "y"), (3, "z");`, 659 `UPDATE test SET v1 = "x" WHERE pk = 2;`, 660 `DELETE FROM test WHERE pk > 2;`, 661 }, 662 Queries: []string{ 663 `SELECT * FROM test ORDER BY pk;`, 664 `SELECT pk, v1 FROM test ORDER BY pk;`, 665 `SELECT v1, pk FROM test ORDER BY pk;`, 666 }, 667 Results: [][]sql.Row{ 668 {{"a", "x"}, {"b", "x"}}, 669 {{"a", "x"}, {"b", "x"}}, 670 {{"x", "a"}, {"x", "b"}}, 671 }, 672 }, 673 { 674 Name: "SET", 675 SetUpScript: []string{ 676 `CREATE TABLE test (pk SET("a","b","c") PRIMARY KEY, v1 SET("w","x","y","z"));`, 677 `INSERT INTO test VALUES (0, 1), ("b", "y"), ("b,c", "z,z"), ("a,c,b", 10);`, 678 `UPDATE test SET v1 = "y,x,w" WHERE pk >= 4`, 679 `DELETE FROM test WHERE pk > "b,c";`, 680 }, 681 Queries: []string{ 682 `SELECT * FROM test ORDER BY pk;`, 683 `SELECT pk, v1 FROM test ORDER BY pk;`, 684 `SELECT v1, pk FROM test ORDER BY pk;`, 685 }, 686 Results: [][]sql.Row{ 687 {{"", "w"}, {"b", "y"}, {"b,c", "w,x,y"}}, 688 {{"", "w"}, {"b", "y"}, {"b,c", "w,x,y"}}, 689 {{"w", ""}, {"y", "b"}, {"w,x,y", "b,c"}}, 690 }, 691 }, 692 { 693 Name: "GEOMETRY", 694 SetUpScript: []string{ 695 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 GEOMETRY);`, 696 `INSERT INTO test VALUES (1, POINT(1, 2)), (2, LINESTRING(POINT(1, 2), POINT(3, 4))), (3, ST_GeomFromText('POLYGON((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))'));`, 697 }, 698 Queries: []string{ 699 `SELECT * FROM test ORDER BY pk;`, 700 `SELECT pk, v1 FROM test ORDER BY pk;`, 701 `SELECT pk, ST_ASWKT(v1) FROM test ORDER BY pk;`, 702 }, 703 Results: [][]sql.Row{ 704 { 705 {"1", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40})}, 706 {"2", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40})}, 707 {"3", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F})}, 708 }, 709 { 710 {"1", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40})}, 711 {"2", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40})}, 712 {"3", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F})}, 713 }, 714 { 715 {"1", "POINT(1 2)"}, 716 {"2", "LINESTRING(1 2,3 4)"}, 717 {"3", "POLYGON((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))"}, 718 }, 719 }, 720 }, 721 { 722 Name: "POINT", 723 SetUpScript: []string{ 724 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 POINT);`, 725 `INSERT INTO test VALUES (1, POINT(1, 2)), (2, POINT(3.4, 5.6)), (3, POINT(10, -20)), (4, POINT(1000, -1000));`, 726 `DELETE FROM test WHERE pk = 4;`, 727 }, 728 Queries: []string{ 729 `SELECT * FROM test ORDER BY pk;`, 730 `SELECT pk, v1 FROM test ORDER BY pk;`, 731 `SELECT pk, ST_ASWKT(v1) FROM test ORDER BY pk;`, 732 }, 733 Results: [][]sql.Row{ 734 { 735 {"1", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40})}, 736 {"2", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x0B, 0x40, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x16, 0x40})}, 737 {"3", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0xC0})}, 738 }, 739 { 740 {"1", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40})}, 741 {"2", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x0B, 0x40, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x16, 0x40})}, 742 {"3", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0xC0})}, 743 }, 744 { 745 {"1", "POINT(1 2)"}, 746 {"2", "POINT(3.4 5.6)"}, 747 {"3", "POINT(10 -20)"}, 748 }, 749 }, 750 }, 751 { 752 Name: "LINESTRING", 753 SetUpScript: []string{ 754 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 LINESTRING);`, 755 `INSERT INTO test VALUES (1, LINESTRING(POINT(1, 2), POINT(3, 4))), (2, LINESTRING(POINT(5, 6), POINT(7, 8)));`, 756 }, 757 Queries: []string{ 758 `SELECT * FROM test ORDER BY pk;`, 759 `SELECT pk, v1 FROM test ORDER BY pk;`, 760 `SELECT pk, ST_ASWKT(v1) FROM test ORDER BY pk;`, 761 }, 762 Results: [][]sql.Row{ 763 { 764 {"1", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40})}, 765 {"2", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40})}, 766 }, 767 { 768 {"1", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40})}, 769 {"2", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40})}, 770 }, 771 { 772 {"1", "LINESTRING(1 2,3 4)"}, 773 {"2", "LINESTRING(5 6,7 8)"}, 774 }, 775 }, 776 }, 777 { 778 Name: "POLYGON", 779 SetUpScript: []string{ 780 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 POLYGON);`, 781 `INSERT INTO test VALUES (1, ST_GeomFromText('POLYGON((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))'));`, 782 }, 783 Queries: []string{ 784 `SELECT * FROM test ORDER BY pk;`, 785 `SELECT pk, v1 FROM test ORDER BY pk;`, 786 `SELECT pk, ST_ASWKT(v1) FROM test ORDER BY pk;`, 787 }, 788 Results: [][]sql.Row{ 789 { 790 {"1", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F})}, 791 }, 792 { 793 {"1", string([]byte{0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F})}, 794 }, 795 { 796 {"1", "POLYGON((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))"}, 797 }, 798 }, 799 }, 800 { 801 Name: "JSON", 802 SetUpScript: []string{ 803 `CREATE TABLE test (pk BIGINT PRIMARY KEY, v1 JSON);`, 804 `INSERT INTO test VALUES (1, '{"key1": {"key": "value"}}'), (2, '{"key1": "value1", "key2": "value2"}'), (3, '{"key1": {"key": [2,3]}}');`, 805 `UPDATE test SET v1 = '["a", 1]' WHERE pk = 1;`, 806 `DELETE FROM test WHERE pk = 3;`, 807 }, 808 Queries: []string{ 809 `SELECT * FROM test ORDER BY pk;`, 810 `SELECT v1, pk FROM test ORDER BY pk;`, 811 `SELECT pk, JSON_ARRAYAGG(v1) FROM (SELECT * FROM test ORDER BY pk) as sub GROUP BY v1 ORDER BY pk;`, 812 }, 813 Results: [][]sql.Row{ 814 {{"1", "[\"a\",1]"}, {"2", "{\"key1\":\"value1\",\"key2\":\"value2\"}"}}, 815 {{"[\"a\",1]", "1"}, {"{\"key1\":\"value1\",\"key2\":\"value2\"}", "2"}}, 816 {{"1", "[[\"a\",1]]"}, {"2", "[{\"key1\":\"value1\",\"key2\":\"value2\"}]"}}, 817 }, 818 }, 819 }