1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643
|
DROP TABLE IF EXISTS t1, t2;
SET NAMES latin1;
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
#
# Testing DATE literals
#
SELECT DATE'xxxx';
ERROR HY000: Incorrect DATE value: 'xxxx'
SELECT DATE'01';
ERROR HY000: Incorrect DATE value: '01'
SELECT DATE'01-01';
ERROR HY000: Incorrect DATE value: '01-01'
SELECT DATE'2001';
ERROR HY000: Incorrect DATE value: '2001'
SELECT DATE'2001-01';
ERROR HY000: Incorrect DATE value: '2001-01'
SELECT DATE'2001-00-00';
DATE'2001-00-00'
2001-00-00
SELECT DATE'2001-01-00';
DATE'2001-01-00'
2001-01-00
SELECT DATE'0000-00-00';
DATE'0000-00-00'
0000-00-00
SELECT DATE'2001-01-01 00:00:00';
ERROR HY000: Incorrect DATE value: '2001-01-01 00:00:00'
SELECT DATE'01:01:01';
DATE'01:01:01'
2001-01-01
Warnings:
Warning 4095 Delimiter ':' in position 2 in datetime value '01:01:01' at row 1 is deprecated. Prefer the standard '-'.
SELECT DATE'01-01-01';
DATE'01-01-01'
2001-01-01
SELECT DATE'2010-01-01';
DATE'2010-01-01'
2010-01-01
SELECT DATE '2010-01-01';
DATE '2010-01-01'
2010-01-01
CREATE TABLE t1 AS SELECT DATE'2010-01-01';
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`DATE'2010-01-01'` date NOT NULL DEFAULT '0000-00-00'
) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
{d'2001-01-01'},
{d'2001-01-01 10:10:10'};
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`{d'2001-01-01'}` date NOT NULL DEFAULT '0000-00-00',
`2001-01-01 10:10:10` varchar(19) CHARACTER SET latin1 NOT NULL DEFAULT ''
) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
EXPLAIN SELECT {d'2010-01-01'};
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 /* select#1 */ select DATE'2010-01-01' AS `{d'2010-01-01'}`
EXPLAIN SELECT DATE'2010-01-01';
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 /* select#1 */ select DATE'2010-01-01' AS `DATE'2010-01-01'`
#
# Testing DATE literals in non-default sql_mode
#
SET sql_mode='NO_ZERO_IN_DATE';
Warnings:
Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
SELECT DATE'2001-00-00';
ERROR HY000: Incorrect DATE value: '2001-00-00'
SELECT DATE'2001-01-00';
ERROR HY000: Incorrect DATE value: '2001-01-00'
SET sql_mode = '';
SELECT DATE'0000-00-00';
DATE'0000-00-00'
0000-00-00
SET sql_mode=default;
#
# Testing TIME literals
#
SELECT TIME'xxxx';
ERROR HY000: Incorrect TIME value: 'xxxx'
SELECT TIME'900:00:00';
ERROR HY000: Incorrect TIME value: '900:00:00'
SELECT TIME'-900:00:00';
ERROR HY000: Incorrect TIME value: '-900:00:00'
SELECT TIME'1 24:00:00';
TIME'1 24:00:00'
48:00:00
SELECT TIME'30 24:00:00';
TIME'30 24:00:00'
744:00:00
SELECT TIME'0000-00-00 00:00:00';
ERROR HY000: Incorrect TIME value: '0000-00-00 00:00:00'
SELECT TIME'40 24:00:00';
ERROR HY000: Incorrect TIME value: '40 24:00:00'
SELECT TIME'10';
TIME'10'
00:00:10
SELECT TIME'10:10';
TIME'10:10'
10:10:00
SELECT TIME'10:11.12';
TIME'10:11.12'
10:11:00.12
SELECT TIME'10:10:10';
TIME'10:10:10'
10:10:10
SELECT TIME'10:10:10.';
TIME'10:10:10.'
10:10:10
SELECT TIME'10:10:10.1';
TIME'10:10:10.1'
10:10:10.1
SELECT TIME'10:10:10.12';
TIME'10:10:10.12'
10:10:10.12
SELECT TIME'10:10:10.123';
TIME'10:10:10.123'
10:10:10.123
SELECT TIME'10:10:10.1234';
TIME'10:10:10.1234'
10:10:10.1234
SELECT TIME'10:10:10.12345';
TIME'10:10:10.12345'
10:10:10.12345
SELECT TIME'10:10:10.123456';
TIME'10:10:10.123456'
10:10:10.123456
SELECT TIME'-10:00:00';
TIME'-10:00:00'
-10:00:00
SELECT TIME '10:11:12';
TIME '10:11:12'
10:11:12
CREATE TABLE t1 AS SELECT
TIME'10:10:10',
TIME'10:10:10.',
TIME'10:10:10.1',
TIME'10:10:10.12',
TIME'10:10:10.123',
TIME'10:10:10.1234',
TIME'10:10:10.12345',
TIME'10:10:10.123456';
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`TIME'10:10:10'` time NOT NULL DEFAULT '00:00:00',
`TIME'10:10:10.'` time NOT NULL DEFAULT '00:00:00',
`TIME'10:10:10.1'` time(1) NOT NULL DEFAULT '00:00:00.0',
`TIME'10:10:10.12'` time(2) NOT NULL DEFAULT '00:00:00.00',
`TIME'10:10:10.123'` time(3) NOT NULL DEFAULT '00:00:00.000',
`TIME'10:10:10.1234'` time(4) NOT NULL DEFAULT '00:00:00.0000',
`TIME'10:10:10.12345'` time(5) NOT NULL DEFAULT '00:00:00.00000',
`TIME'10:10:10.123456'` time(6) NOT NULL DEFAULT '00:00:00.000000'
) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
{t'10:10:10'},
{t'10:10:10.'},
{t'10:10:10.123456'},
{t'2001-01-01'};
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`{t'10:10:10'}` time NOT NULL DEFAULT '00:00:00',
`{t'10:10:10.'}` time NOT NULL DEFAULT '00:00:00',
`{t'10:10:10.123456'}` time(6) NOT NULL DEFAULT '00:00:00.000000',
`2001-01-01` varchar(10) CHARACTER SET latin1 NOT NULL DEFAULT ''
) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
EXPLAIN SELECT {t'10:01:01'};
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 /* select#1 */ select TIME'10:01:01' AS `{t'10:01:01'}`
EXPLAIN SELECT TIME'10:01:01';
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 /* select#1 */ select TIME'10:01:01' AS `TIME'10:01:01'`
#
# Testing TIMESTAMP literals
#
SELECT TIMESTAMP'xxxx';
ERROR HY000: Incorrect DATETIME value: 'xxxx'
SELECT TIMESTAMP'2010';
ERROR HY000: Incorrect DATETIME value: '2010'
SELECT TIMESTAMP'2010-01';
ERROR HY000: Incorrect DATETIME value: '2010-01'
SELECT TIMESTAMP'2010-01-01';
ERROR HY000: Incorrect DATETIME value: '2010-01-01'
SELECT TIMESTAMP'2010-01-01 00';
TIMESTAMP'2010-01-01 00'
2010-01-01 00:00:00
SELECT TIMESTAMP'2010-01-01 00:01';
TIMESTAMP'2010-01-01 00:01'
2010-01-01 00:01:00
SELECT TIMESTAMP'2010-01-01 10:10:10';
TIMESTAMP'2010-01-01 10:10:10'
2010-01-01 10:10:10
SELECT TIMESTAMP'2010-01-01 10:10:10.';
TIMESTAMP'2010-01-01 10:10:10.'
2010-01-01 10:10:10
SELECT TIMESTAMP'2010-01-01 10:10:10.1';
TIMESTAMP'2010-01-01 10:10:10.1'
2010-01-01 10:10:10.1
SELECT TIMESTAMP'2010-01-01 10:10:10.12';
TIMESTAMP'2010-01-01 10:10:10.12'
2010-01-01 10:10:10.12
SELECT TIMESTAMP'2010-01-01 10:10:10.123';
TIMESTAMP'2010-01-01 10:10:10.123'
2010-01-01 10:10:10.123
SELECT TIMESTAMP'2010-01-01 10:10:10.1234';
TIMESTAMP'2010-01-01 10:10:10.1234'
2010-01-01 10:10:10.1234
SELECT TIMESTAMP'2010-01-01 10:10:10.12345';
TIMESTAMP'2010-01-01 10:10:10.12345'
2010-01-01 10:10:10.12345
SELECT TIMESTAMP'2010-01-01 10:10:10.123456';
TIMESTAMP'2010-01-01 10:10:10.123456'
2010-01-01 10:10:10.123456
SELECT TIMESTAMP '2010-01-01 10:20:30';
TIMESTAMP '2010-01-01 10:20:30'
2010-01-01 10:20:30
CREATE TABLE t1 AS SELECT
TIMESTAMP'2010-01-01 10:10:10',
TIMESTAMP'2010-01-01 10:10:10.',
TIMESTAMP'2010-01-01 10:10:10.1',
TIMESTAMP'2010-01-01 10:10:10.12',
TIMESTAMP'2010-01-01 10:10:10.123',
TIMESTAMP'2010-01-01 10:10:10.1234',
TIMESTAMP'2010-01-01 10:10:10.12345',
TIMESTAMP'2010-01-01 10:10:10.123456';
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`TIMESTAMP'2010-01-01 10:10:10'` datetime NOT NULL,
`TIMESTAMP'2010-01-01 10:10:10.'` datetime NOT NULL,
`TIMESTAMP'2010-01-01 10:10:10.1'` datetime(1) NOT NULL,
`TIMESTAMP'2010-01-01 10:10:10.12'` datetime(2) NOT NULL,
`TIMESTAMP'2010-01-01 10:10:10.123'` datetime(3) NOT NULL,
`TIMESTAMP'2010-01-01 10:10:10.1234'` datetime(4) NOT NULL,
`TIMESTAMP'2010-01-01 10:10:10.12345'` datetime(5) NOT NULL,
`TIMESTAMP'2010-01-01 10:10:10.123456'` datetime(6) NOT NULL
) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
{ts'2001-01-01 10:10:10'},
{ts'2001-01-01 10:10:10.'},
{ts'2001-01-01 10:10:10.123456'},
{ts'2001-01-01'};
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`{ts'2001-01-01 10:10:10'}` datetime NOT NULL,
`{ts'2001-01-01 10:10:10.'}` datetime NOT NULL,
`{ts'2001-01-01 10:10:10.123456'}` datetime(6) NOT NULL,
`2001-01-01` varchar(10) CHARACTER SET latin1 NOT NULL DEFAULT ''
) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
EXPLAIN SELECT {ts'2010-01-01 10:10:10'};
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 /* select#1 */ select TIMESTAMP'2010-01-01 10:10:10' AS `{ts'2010-01-01 10:10:10'}`
EXPLAIN SELECT TIMESTAMP'2010-01-01 10:10:10';
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 /* select#1 */ select TIMESTAMP'2010-01-01 10:10:10' AS `TIMESTAMP'2010-01-01 10:10:10'`
#
# Testing nanosecond rounding for TIMESTAMP literals with bad dates
#
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
SELECT TIMESTAMP'2001-00-00 00:00:00.999999';
TIMESTAMP'2001-00-00 00:00:00.999999'
2001-00-00 00:00:00.999999
SELECT TIMESTAMP'2001-00-01 00:00:00.999999';
TIMESTAMP'2001-00-01 00:00:00.999999'
2001-00-01 00:00:00.999999
SELECT TIMESTAMP'2001-01-00 00:00:00.999999';
TIMESTAMP'2001-01-00 00:00:00.999999'
2001-01-00 00:00:00.999999
SELECT TIMESTAMP'2001-00-00 00:00:00.9999999';
ERROR HY000: Incorrect DATETIME value: '2001-00-00 00:00:00.9999999'
SELECT TIMESTAMP'2001-00-01 00:00:00.9999999';
ERROR HY000: Incorrect DATETIME value: '2001-00-01 00:00:00.9999999'
SELECT TIMESTAMP'2001-01-00 00:00:00.9999999';
ERROR HY000: Incorrect DATETIME value: '2001-01-00 00:00:00.9999999'
#
# String literal with bad dates and nanoseconds to DATETIME(N)
#
CREATE TABLE t1 (a DATETIME(6));
INSERT INTO t1 VALUES ('2001-00-00 00:00:00.9999999');
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
INSERT INTO t1 VALUES ('2001-00-01 00:00:00.9999999');
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
INSERT INTO t1 VALUES ('2001-01-00 00:00:00.9999999');
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
SELECT * FROM t1;
a
0000-00-00 00:00:00.000000
0000-00-00 00:00:00.000000
0000-00-00 00:00:00.000000
DROP TABLE t1;
CREATE TABLE t1 (a DATETIME(5));
INSERT INTO t1 VALUES ('2001-00-00 00:00:00.9999999');
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
INSERT INTO t1 VALUES ('2001-00-01 00:00:00.9999999');
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
INSERT INTO t1 VALUES ('2001-01-00 00:00:00.9999999');
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
SELECT * FROM t1;
a
0000-00-00 00:00:00.00000
0000-00-00 00:00:00.00000
0000-00-00 00:00:00.00000
DROP TABLE t1;
CREATE TABLE t1 (a DATETIME);
INSERT INTO t1 VALUES ('2001-00-00 00:00:00.9999999');
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
INSERT INTO t1 VALUES ('2001-00-01 00:00:00.9999999');
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
INSERT INTO t1 VALUES ('2001-01-00 00:00:00.9999999');
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
SELECT * FROM t1;
a
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
DROP TABLE t1;
#
# Testing Item_date_literal::eq
#
CREATE TABLE t1 (a DATE);
INSERT INTO t1 VALUES ('2001-01-01'),('2003-01-01');
SELECT * FROM t1 WHERE a BETWEEN DATE'2001-01-01' AND DATE'2002-01-01';
a
2001-01-01
SELECT DATE'2001-01-01' FROM t1 GROUP BY DATE'2001-01-01';
DATE'2001-01-01'
2001-01-01
DROP TABLE t1;
SET sql_mode = default;
#
# BUG #16812821: INCONSISTANT RESULTS WHEN ODBC DATE FORMAT IS USED
#
CREATE TABLE t1(c1 INT, c2 DATE, c3 TIME, c4 TIMESTAMP);
CREATE TABLE t2(c11 INT, C12 INT);
INSERT INTO t1 VALUES (1, '2014-01-02', '01:01:01', '2014-01-02 01:01:01'),
(2, '2014-01-04', '01:01:01', '2014-01-02 01:01:01');
INSERT INTO t2 VALUES (3, 4), (5, 6);
SELECT * FROM t1 LEFT JOIN t2 ON c1 = c11
WHERE c2 BETWEEN {d'2014-01-01'} AND {d'2014-01-05'};
c1 c2 c3 c4 c11 C12
1 2014-01-02 01:01:01 2014-01-02 01:01:01 NULL NULL
2 2014-01-04 01:01:01 2014-01-02 01:01:01 NULL NULL
SELECT * FROM t1 LEFT JOIN t2 ON c1 = c11
WHERE c3 BETWEEN {t'01:01:01'} AND {t'01:01:05'};
c1 c2 c3 c4 c11 C12
1 2014-01-02 01:01:01 2014-01-02 01:01:01 NULL NULL
2 2014-01-04 01:01:01 2014-01-02 01:01:01 NULL NULL
SELECT * FROM t1 LEFT JOIN t2 ON c1 = c11
WHERE c4 BETWEEN {ts'2014-01-01 01:01:01'} AND {ts'2014-01-05 01:01:01'};
c1 c2 c3 c4 c11 C12
1 2014-01-02 01:01:01 2014-01-02 01:01:01 NULL NULL
2 2014-01-04 01:01:01 2014-01-02 01:01:01 NULL NULL
SELECT * FROM t1 LEFT JOIN t2 ON c1 = c11
WHERE c2 BETWEEN DATE'2014-01-01' AND DATE'2014-01-05';
c1 c2 c3 c4 c11 C12
1 2014-01-02 01:01:01 2014-01-02 01:01:01 NULL NULL
2 2014-01-04 01:01:01 2014-01-02 01:01:01 NULL NULL
SELECT * FROM t1 LEFT JOIN t2 ON c1 = c11
WHERE c3 BETWEEN TIME'01:01:01' AND TIME'01:01:05';
c1 c2 c3 c4 c11 C12
1 2014-01-02 01:01:01 2014-01-02 01:01:01 NULL NULL
2 2014-01-04 01:01:01 2014-01-02 01:01:01 NULL NULL
SELECT * FROM t1 LEFT JOIN t2 ON c1 = c11
WHERE c4 BETWEEN TIMESTAMP'2014-01-01 01:01:01'
AND TIMESTAMP'2014-01-05 01:01:01';
c1 c2 c3 c4 c11 C12
1 2014-01-02 01:01:01 2014-01-02 01:01:01 NULL NULL
2 2014-01-04 01:01:01 2014-01-02 01:01:01 NULL NULL
DROP TABLE t1, t2;
#
# WL#13601 Deprecate arbitrary delimiters and whitespaces in
# time / date / datetime / timestamp literals
#
------------------ DATETIME literals
superfluous blanks
SELECT TIMESTAMP ' 2021-07-15 23:01:02';
TIMESTAMP ' 2021-07-15 23:01:02'
2021-07-15 23:01:02
Warnings:
Warning 4096 Delimiter ' ' in position 0 in datetime value ' 2021-07-15 23:01:02' at row 1 is superfluous and is deprecated. Please remove.
SELECT TIMESTAMP '2021-07-15 23:01:02 ';
TIMESTAMP '2021-07-15 23:01:02 '
2021-07-15 23:01:02
Warnings:
Warning 4096 Delimiter ' ' in position 19 in datetime value '2021-07-15 23:01:02 ' at row 1 is superfluous and is deprecated. Please remove.
SELECT TIMESTAMP '2021-07-15 23:01:02';
TIMESTAMP '2021-07-15 23:01:02'
2021-07-15 23:01:02
Warnings:
Warning 4096 Delimiter ' ' in position 11 in datetime value '2021-07-15 23:01:02' at row 1 is superfluous and is deprecated. Please remove.
wrong type delimiter
SELECT TIMESTAMP '2021/07-15 23:01:02';
TIMESTAMP '2021/07-15 23:01:02'
2021-07-15 23:01:02
Warnings:
Warning 4095 Delimiter '/' in position 4 in datetime value '2021/07-15 23:01:02' at row 1 is deprecated. Prefer the standard '-'.
SELECT TIMESTAMP '2021-07/15 23:01:02';
TIMESTAMP '2021-07/15 23:01:02'
2021-07-15 23:01:02
Warnings:
Warning 4095 Delimiter '/' in position 7 in datetime value '2021-07/15 23:01:02' at row 1 is deprecated. Prefer the standard '-'.
SELECT TIMESTAMP '2021-07-15 23.01:02';
TIMESTAMP '2021-07-15 23.01:02'
2021-07-15 23:01:02
Warnings:
Warning 4095 Delimiter '.' in position 13 in datetime value '2021-07-15 23.01:02' at row 1 is deprecated. Prefer the standard ':'.
SELECT TIMESTAMP '2021-07-15 23:01.02';
TIMESTAMP '2021-07-15 23:01.02'
2021-07-15 23:01:02
Warnings:
Warning 4095 Delimiter '.' in position 16 in datetime value '2021-07-15 23:01.02' at row 1 is deprecated. Prefer the standard ':'.
wrong &redundant
SELECT TIMESTAMP '2021//07/15 23:01:02';
TIMESTAMP '2021//07/15 23:01:02'
2021-07-15 23:01:02
Warnings:
Warning 4095 Delimiter '/' in position 4 in datetime value '2021//07/15 23:01:02' at row 1 is deprecated. Prefer the standard '-'.
SELECT TIMESTAMP '2021/07//15 23:01:02';
TIMESTAMP '2021/07//15 23:01:02'
2021-07-15 23:01:02
Warnings:
Warning 4095 Delimiter '/' in position 4 in datetime value '2021/07//15 23:01:02' at row 1 is deprecated. Prefer the standard '-'.
SELECT TIMESTAMP '2021-07-15 23..01:02';
TIMESTAMP '2021-07-15 23..01:02'
2021-07-15 23:01:02
Warnings:
Warning 4095 Delimiter '.' in position 13 in datetime value '2021-07-15 23..01:02' at row 1 is deprecated. Prefer the standard ':'.
SELECT TIMESTAMP '2021-07-15 23:01..02';
TIMESTAMP '2021-07-15 23:01..02'
2021-07-15 23:01:02
Warnings:
Warning 4095 Delimiter '.' in position 16 in datetime value '2021-07-15 23:01..02' at row 1 is deprecated. Prefer the standard ':'.
correct type delimiter but redundant
SELECT TIMESTAMP '2021--07-15 23:01:02';
TIMESTAMP '2021--07-15 23:01:02'
2021-07-15 23:01:02
Warnings:
Warning 4096 Delimiter '-' in position 5 in datetime value '2021--07-15 23:01:02' at row 1 is superfluous and is deprecated. Please remove.
SELECT TIMESTAMP '2021-07--15 23:01:02';
TIMESTAMP '2021-07--15 23:01:02'
2021-07-15 23:01:02
Warnings:
Warning 4096 Delimiter '-' in position 8 in datetime value '2021-07--15 23:01:02' at row 1 is superfluous and is deprecated. Please remove.
SELECT TIMESTAMP '2021-07-15 23::01:02';
TIMESTAMP '2021-07-15 23::01:02'
2021-07-15 23:01:02
Warnings:
Warning 4096 Delimiter ':' in position 14 in datetime value '2021-07-15 23::01:02' at row 1 is superfluous and is deprecated. Please remove.
SELECT TIMESTAMP '2021-07-15 23:01::02';
TIMESTAMP '2021-07-15 23:01::02'
2021-07-15 23:01:02
Warnings:
Warning 4096 Delimiter ':' in position 17 in datetime value '2021-07-15 23:01::02' at row 1 is superfluous and is deprecated. Please remove.
all wrong
SELECT TIMESTAMP ' 2021??07//15 23:+*&01.,"02 ';
TIMESTAMP ' 2021??07//15 23:+*&01.,"02 '
2021-07-15 23:01:02
Warnings:
Warning 4096 Delimiter ' ' in position 0 in datetime value ' 2021??07//15 23:+*&01.,"02 ' at row 1 is superfluous and is deprecated. Please remove.
in CAST
SELECT CAST('2015-01-15 23-24:25' AS DATETIME);
CAST('2015-01-15 23-24:25' AS DATETIME)
2015-01-15 23:24:25
Warnings:
Warning 4095 Delimiter '-' in position 13 in datetime value '2015-01-15 23-24:25' at row 1 is deprecated. Prefer the standard ':'.
in JSON_VALUE
SELECT JSON_VALUE('{"data": "2019-01-01 11:11::11"}', '$.data' RETURNING DATETIME) AS v;
v
2019-01-01 11:11:11
Warnings:
Warning 4096 Delimiter ':' in position 17 in datetime value '2019-01-01 11:11::11' at row 1 is superfluous and is deprecated. Please remove.
SELECT LEAST(CAST('01-01-01' AS DATETIME), '01-01:02');
LEAST(CAST('01-01-01' AS DATETIME), '01-01:02')
2001-01-01 00:00:00
Warnings:
Warning 4095 Delimiter ':' in position 5 in datetime value '01-01:02' at row 1 is deprecated. Prefer the standard '-'.
in get_mysql_time_from_str
CREATE TABLE t1(f1 DATE);
INSERT INTO t1 VALUES ('2001-01-01');
SELECT f1 FROM t1 WHERE f1 < "01-4:15";
f1
2001-01-01
Warnings:
Warning 4095 Delimiter ':' in position 4 in datetime value '01-4:15' at row 1 is deprecated. Prefer the standard '-'.
DROP TABLE t1;
CREATE TABLE t1(f1 DATETIME, c VARCHAR(20));
INSERT INTO t1 VALUES (NULL, '2001-01-01 19.55.00');
UPDATE t1 SET f1=c;
Warnings:
Warning 4095 Delimiter '.' in position 13 in datetime value '2001-01-01 19.55.00' at row 1 is deprecated. Prefer the standard ':'.
DROP TABLE t1;
------------------ DATE literals
SELECT DATE'2021/09-20';
DATE'2021/09-20'
2021-09-20
Warnings:
Warning 4095 Delimiter '/' in position 4 in datetime value '2021/09-20' at row 1 is deprecated. Prefer the standard '-'.
SELECT DATE' 2021-09-20';
DATE' 2021-09-20'
2021-09-20
Warnings:
Warning 4096 Delimiter ' ' in position 0 in datetime value ' 2021-09-20' at row 1 is superfluous and is deprecated. Please remove.
SELECT DATE'2021-09-20 ';
DATE'2021-09-20 '
2021-09-20
Warnings:
Warning 4096 Delimiter ' ' in position 10 in datetime value '2021-09-20 ' at row 1 is superfluous and is deprecated. Please remove.
in CAST
SELECT CAST('2015-01-15 23-24:25' AS DATE);
CAST('2015-01-15 23-24:25' AS DATE)
2015-01-15
Warnings:
Warning 4095 Delimiter '-' in position 13 in datetime value '2015-01-15 23-24:25' at row 1 is deprecated. Prefer the standard ':'.
in JSON_VALUE
SELECT JSON_VALUE('{"data": "2019-01/01"}', '$.data' RETURNING DATE) AS v;
v
2019-01-01
Warnings:
Warning 4095 Delimiter '/' in position 7 in datetime value '2019-01/01' at row 1 is deprecated. Prefer the standard '-'.
SELECT LEAST(CAST('2001-12-10' AS DATE), '2001-12/11');
LEAST(CAST('2001-12-10' AS DATE), '2001-12/11')
2001-12-10
Warnings:
Warning 4095 Delimiter '/' in position 7 in datetime value '2001-12/11' at row 1 is deprecated. Prefer the standard '-'.
CREATE TABLE t1(f1 DATE);
INSERT INTO t1 VALUES ('2001-01-01');
SELECT f1 FROM t1 WHERE f1 < "2001-01/01";
f1
Warnings:
Warning 4095 Delimiter '/' in position 7 in datetime value '2001-01/01' at row 1 is deprecated. Prefer the standard '-'.
DROP TABLE t1;
CREATE TABLE t1(f1 DATE, c VARCHAR(20));
INSERT INTO t1 VALUES (NULL, '2001-01/01');
UPDATE t1 SET f1=c;
Warnings:
Warning 4095 Delimiter '/' in position 7 in datetime value '2001-01/01' at row 1 is deprecated. Prefer the standard '-'.
DROP TABLE t1;
------------------ TIME literals
These were much stricter before the WL, we only add checks for
leading and trailing blanks
SELECT TIME' 10:11:12.098700';
TIME' 10:11:12.098700'
10:11:12.098700
Warnings:
Warning 4096 Delimiter ' ' in position 0 in datetime value ' 10:11:12.098700' at row 1 is superfluous and is deprecated. Please remove.
SELECT TIME'10:11:12.098700 ';
TIME'10:11:12.098700 '
10:11:12.098700
Warnings:
Warning 4096 Delimiter ' ' in position 15 in datetime value '10:11:12.098700 ' at row 1 is superfluous and is deprecated. Please remove.
SELECT TIME'10-11:12.098700 ';
ERROR HY000: Incorrect TIME value: '10-11:12.098700 '
Superfluous blanks in the 'D hh:mm:ss' format
SELECT TIME'1 01:01:01',
TIME'1 01:01',
TIME'1 01',
TIME'1 ',
TIME'1', # OK
TIME' 1';
TIME'1 01:01:01' TIME'1 01:01' TIME'1 01' TIME'1 ' TIME'1' TIME' 1'
25:01:01 25:01:00 25:00:00 00:00:01 00:00:01 00:00:01
Warnings:
Warning 4096 Delimiter ' ' in position 1 in datetime value '1 01:01:01' at row 1 is superfluous and is deprecated. Please remove.
Warning 4096 Delimiter ' ' in position 1 in datetime value '1 01:01' at row 1 is superfluous and is deprecated. Please remove.
Warning 4096 Delimiter ' ' in position 1 in datetime value '1 01' at row 1 is superfluous and is deprecated. Please remove.
Warning 4096 Delimiter ' ' in position 1 in datetime value '1 ' at row 1 is superfluous and is deprecated. Please remove.
Warning 4096 Delimiter ' ' in position 0 in datetime value ' 1' at row 1 is superfluous and is deprecated. Please remove.
in CAST
select CAST('10:11:12.098700 ' AS TIME);
CAST('10:11:12.098700 ' AS TIME)
10:11:12
Warnings:
Warning 4096 Delimiter ' ' in position 15 in datetime value '10:11:12.098700 ' at row 1 is superfluous and is deprecated. Please remove.
in JSON_VALUE
SELECT JSON_VALUE('{"data": "10:11:12.098700 "}', '$.data' RETURNING TIME) AS v;
v
10:11:12
Warnings:
Warning 4096 Delimiter ' ' in position 15 in datetime value '10:11:12.098700 ' at row 1 is superfluous and is deprecated. Please remove.
# For some reason, the second argument below doesn't get
# attempted converted to TIME, so we do not see any warning.
# The comparison is done on strings instead.
# This is in contrast to DATE and DATETIME. Bug? FIXME
SELECT LEAST(CAST('10:11:12' AS TIME), '10:11:13 ');
LEAST(CAST('10:11:12' AS TIME), '10:11:13 ')
10:11:12
CREATE TABLE t1(f1 TIME, c VARCHAR(20));
INSERT INTO t1 VALUES (NULL, ' 19:55:00');
UPDATE t1 SET f1=c;
Warnings:
Warning 4096 Delimiter ' ' in position 0 in datetime value ' 19:55:00' at row 1 is superfluous and is deprecated. Please remove.
DROP TABLE t1;
Test weird delimiters between date and time parts
# Delimiter instead of space
SELECT TIMESTAMP'2021-07-17.18:45:00';
TIMESTAMP'2021-07-17.18:45:00'
2021-07-17 18:45:00
Warnings:
Warning 4095 Delimiter '.' in position 10 in datetime value '2021-07-17.18:45:00' at row 1 is deprecated. Prefer the standard ' '.
SELECT TIMESTAMP'2021-07-17-18:45:00';
TIMESTAMP'2021-07-17-18:45:00'
2021-07-17 18:45:00
Warnings:
Warning 4095 Delimiter '-' in position 10 in datetime value '2021-07-17-18:45:00' at row 1 is deprecated. Prefer the standard ' '.
# No warning given here, since we cannot replace the period with a space
SELECT TIMESTAMP'20211018.121000';
TIMESTAMP'20211018.121000'
2021-10-18 12:10:00
|