GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — sqlparser/parse_test.go at master · smlxl/sqlparser
This repository was archived by the owner on Apr 24, 2025. It is now read-only.
Expand file tree/ Copy pathparse_test.goMore file actions 6516 lines (6441 loc) · 253 KB / Copy pathparse_test.goFile metadata and controls6516 lines (6441 loc) · 253 KB 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 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 /* Copyright 2019 The Vitess Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package sqlparser import ( "bufio" "compress/gzip" "fmt" "io" "math/rand/v2" "os" "path" "strings" "sync" "testing" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "vitess.io/vitess/go/test/utils" ) var ( validSQL = []struct { input string output string partialDDL bool ignoreNormalizerTest bool }{{ input: "select * from foo limit 5 + 5", }, { input: "create table x(location GEOMETRYCOLLECTION DEFAULT (POINT(7.0, 3.0)))", output: "create table x (\n\tlocation GEOMETRYCOLLECTION default (point(7.0, 3.0))\n)", }, { input: "create table t (id int primary key, dt datetime DEFAULT (CURRENT_TIMESTAMP))", output: "create table t (\n\tid int primary key,\n\tdt datetime default (current_timestamp())\n)", }, { input: "create table t (id int primary key, dt datetime DEFAULT now())", output: "create table t (\n\tid int primary key,\n\tdt datetime default now()\n)", }, { input: "create table t (id int primary key, dt datetime DEFAULT (now()))", output: "create table t (\n\tid int primary key,\n\tdt datetime default (now())\n)", }, { input: "create table t (id int primary key, dt datetime(6) DEFAULT (now()))", output: "create table t (\n\tid int primary key,\n\tdt datetime(6) default (now())\n)", }, { input: "create table t (id int primary key, dt datetime DEFAULT (now() + 1))", output: "create table t (\n\tid int primary key,\n\tdt datetime default (now() + 1)\n)", }, { input: "create table x (e enum('red','yellow') null collate 'utf8_bin')", output: "create table x (\n\te enum('red', 'yellow') collate 'utf8_bin' null\n)", }, { input: "create table 3t2 (c1 bigint not null, c2 text, primary key(c1))", output: "create table `3t2` (\n\tc1 bigint not null,\n\tc2 text,\n\tprimary key (c1)\n)", }, { input: "select 1 from t1 where exists (select 1) = TRUE", output: "select 1 from t1 where exists (select 1 from dual) = true", }, { input: "select 1 from t1 where exists (select 1) = FALSE", output: "select 1 from t1 where exists (select 1 from dual) = false", }, { input: "select 1 from t1 where exists (select 1) = 1", output: "select 1 from t1 where exists (select 1 from dual) = 1", }, { input: "create table x(location GEOMETRY DEFAULT (POINT(7.0, 3.0)))", output: "create table x (\n\tlocation GEOMETRY default (point(7.0, 3.0))\n)", }, { input: "select 1", output: "select 1 from dual", }, { input: "SELECT EXTRACT(YEAR FROM '2019-07-02')", output: "select extract(year from '2019-07-02') from dual", }, { input: "SELECT EXTRACT(YEAR_MONTH FROM '2019-07-02 01:02:03')", output: "select extract(year_month from '2019-07-02 01:02:03') from dual", }, { input: "select extract(year from \"21-10-22 12:00:00\")", output: "select extract(year from '21-10-22 12:00:00') from dual", }, { input: "SELECT EXTRACT(DAY_MINUTE FROM '2019-07-02 01:02:03')", output: "select extract(day_minute from '2019-07-02 01:02:03') from dual", }, { input: "SELECT EXTRACT(MICROSECOND FROM '2003-01-02 10:30:00.000123')", output: "select extract(microsecond from '2003-01-02 10:30:00.000123') from dual", }, { input: "CREATE TABLE t2 (b BLOB DEFAULT 'abc')", output: "create table t2 (\n\tb BLOB default 'abc'\n)", }, { input: "CREATE TABLE t2 (b blob DEFAULT 'abc')", output: "create table t2 (\n\tb blob default 'abc'\n)", }, { input: "CREATE TABLE t2 (b BLOB DEFAULT ('abc'))", output: "create table t2 (\n\tb BLOB default ('abc')\n)", }, { input: "CREATE TABLE t2 (b TINYBLOB DEFAULT 'abc')", output: "create table t2 (\n\tb TINYBLOB default 'abc'\n)", }, { input: "CREATE TABLE t2 (b TINYBLOB DEFAULT ('abc'))", output: "create table t2 (\n\tb TINYBLOB default ('abc')\n)", }, { input: "CREATE TABLE t2 (b MEDIUMBLOB DEFAULT 'abc')", output: "create table t2 (\n\tb MEDIUMBLOB default 'abc'\n)", }, { input: "CREATE TABLE t2 (b MEDIUMBLOB DEFAULT ('abc'))", output: "create table t2 (\n\tb MEDIUMBLOB default ('abc')\n)", }, { input: "CREATE TABLE t2 (b LONGBLOB DEFAULT 'abc')", output: "create table t2 (\n\tb LONGBLOB default 'abc'\n)", }, { input: "CREATE TABLE t2 (b LONGBLOB DEFAULT ('abc'))", output: "create table t2 (\n\tb LONGBLOB default ('abc')\n)", }, { input: "CREATE TABLE t2 (b TEXT DEFAULT 'abc')", output: "create table t2 (\n\tb TEXT default 'abc'\n)", }, { input: "CREATE TABLE t2 (b TEXT DEFAULT ('abc'))", output: "create table t2 (\n\tb TEXT default ('abc')\n)", }, { input: "CREATE TABLE t2 (b TINYTEXT DEFAULT 'abc')", output: "create table t2 (\n\tb TINYTEXT default 'abc'\n)", }, { input: "CREATE TABLE t2 (b TINYTEXT DEFAULT ('abc'))", output: "create table t2 (\n\tb TINYTEXT default ('abc')\n)", }, { input: "CREATE TABLE t2 (b MEDIUMTEXT DEFAULT 'abc')", output: "create table t2 (\n\tb MEDIUMTEXT default 'abc'\n)", }, { input: "CREATE TABLE t2 (b MEDIUMTEXT DEFAULT ('abc'))", output: "create table t2 (\n\tb MEDIUMTEXT default ('abc')\n)", }, { input: "CREATE TABLE t2 (b LONGTEXT DEFAULT 'abc')", output: "create table t2 (\n\tb LONGTEXT default 'abc'\n)", }, { input: "CREATE TABLE t2 (b LONGTEXT DEFAULT ('abc'))", output: "create table t2 (\n\tb LONGTEXT default ('abc')\n)", }, { input: "CREATE TABLE t2 (b JSON DEFAULT null)", output: "create table t2 (\n\tb JSON default null\n)", }, { input: "CREATE TABLE t2 (b JSON DEFAULT (null))", output: "create table t2 (\n\tb JSON default (null)\n)", }, { input: "CREATE TABLE t2 (b JSON DEFAULT '{name:abc}')", output: "create table t2 (\n\tb JSON default '{name:abc}'\n)", }, { input: "CREATE TABLE t2 (b JSON DEFAULT ('{name:abc}'))", output: "create table t2 (\n\tb JSON default ('{name:abc}')\n)", }, { input: "create table x(location POINT DEFAULT 7.0)", output: "create table x (\n\tlocation POINT default 7.0\n)", }, { input: "create table x(location POINT DEFAULT (7.0))", output: "create table x (\n\tlocation POINT default (7.0)\n)", }, { input: "create table x(location LINESTRING DEFAULT (POINT(7.0, 3.0)))", output: "create table x (\n\tlocation LINESTRING default (point(7.0, 3.0))\n)", }, { input: "select linestring(pt1, pt2) from geom", output: "select linestring(pt1, pt2) from geom", }, { input: "create table x(location POLYGON DEFAULT (POINT(7.0, 3.0)))", output: "create table x (\n\tlocation POLYGON default (point(7.0, 3.0))\n)", }, { input: "create table x(location MULTIPOINT DEFAULT (POINT(7.0, 3.0)))", output: "create table x (\n\tlocation MULTIPOINT default (point(7.0, 3.0))\n)", }, { input: "create table x(location MULTILINESTRING DEFAULT (POINT(7.0, 3.0)))", output: "create table x (\n\tlocation MULTILINESTRING default (point(7.0, 3.0))\n)", }, { input: "create table x(location MULTIPOLYGON DEFAULT (POINT(7.0, 3.0)))", output: "create table x (\n\tlocation MULTIPOLYGON default (point(7.0, 3.0))\n)", }, { input: "create table x(location GEOMETRYCOLLECTION DEFAULT (POINT(7.0, 3.0)))", output: "create table x (\n\tlocation GEOMETRYCOLLECTION default (point(7.0, 3.0))\n)", }, { input: "create table x(location GEOMETRYCOLLECTION DEFAULT (LINESTRING(POINT(4, 5), POINT(4.6, 7.9), POINT(4.6, 7.9))))", output: "create table x (\n\tlocation GEOMETRYCOLLECTION default (linestring(point(4, 5), point(4.6, 7.9), point(4.6, 7.9)))\n)", }, { input: "create table x(location GEOMETRYCOLLECTION DEFAULT (LINESTRING(POINT(7.0, 3.0))))", output: "create table x (\n\tlocation GEOMETRYCOLLECTION default (linestring(point(7.0, 3.0)))\n)", }, { input: "create table x(location GEOMETRYCOLLECTION DEFAULT (POLYGON(LINESTRING(POINT(4, 5), POINT(4.6, 7.9), POINT(4.6, 7.9)))))", output: "create table x (\n\tlocation GEOMETRYCOLLECTION default (polygon(linestring(point(4, 5), point(4.6, 7.9), point(4.6, 7.9))))\n)", }, { input: "select ST_ASTEXT(POLYGON(linestrings)) from linestringTable", output: "select st_astext(polygon(linestrings)) from linestringTable", }, { input: "create table x(location GEOMETRYCOLLECTION DEFAULT (MULTIPOINT(POINT(4, 5), POINT(4.6, 7.9), POINT(4.6, 7.9))))", output: "create table x (\n\tlocation GEOMETRYCOLLECTION default (multipoint(point(4, 5), point(4.6, 7.9), point(4.6, 7.9)))\n)", }, { input: "select ST_ASTEXT(MULTIPOINT(points)) from pointsTable", output: "select st_astext(multipoint(points)) from pointsTable", }, { input: "create table x(location GEOMETRYCOLLECTION DEFAULT (MULTILINESTRING(LINESTRING(POINT(8,9), POINT(8,9)))))", output: "create table x (\n\tlocation GEOMETRYCOLLECTION default (multilinestring(linestring(point(8, 9), point(8, 9))))\n)", }, { input: "select ST_ASTEXT(MULTILINESTRING(linestrings)) from linestringsTable", output: "select st_astext(multilinestring(linestrings)) from linestringsTable", }, { input: "create table x(location GEOMETRYCOLLECTION DEFAULT (MULTIPOLYGON(POINT(7.0, 3.0), POINT(7.0, 3.0))))", output: "create table x (\n\tlocation GEOMETRYCOLLECTION default (multipolygon(point(7.0, 3.0), point(7.0, 3.0)))\n)", }, { input: "select ST_ASTEXT(MULTIPOLYGON(polygons)) from polygonTable", output: "select st_astext(multipolygon(polygons)) from polygonTable", }, { input: "SELECT ST_AsText(ST_GeomCollFromText('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))'))", output: "select st_astext(st_geometrycollectionfromtext('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))')) from dual", }, { input: "SELECT ST_AsText(ST_GeomCollFromText('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))', 4326))", output: "select st_astext(st_geometrycollectionfromtext('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))', 4326)) from dual", }, { input: "SELECT ST_AsText(ST_GeomCollFromText('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))', 4326, 'axis-order=lat-long'))", output: "select st_astext(st_geometrycollectionfromtext('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))', 4326, 'axis-order=lat-long')) from dual", }, { input: "SELECT ST_AsText(ST_GeomFromText('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))'))", output: "select st_astext(st_geometryfromtext('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))')) from dual", }, { input: "SELECT ST_AsText(ST_GeomFromText('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))', 4326))", output: "select st_astext(st_geometryfromtext('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))', 4326)) from dual", }, { input: "SELECT ST_AsText(ST_GeomFromText('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))', 4326, 'axis-order=lat-long'))", output: "select st_astext(st_geometryfromtext('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))', 4326, 'axis-order=lat-long')) from dual", }, { input: "SELECT ST_AsText(ST_MultilinestringFromText('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))'))", output: "select st_astext(st_multilinestringfromtext('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))')) from dual", }, { input: "SELECT ST_AsText(ST_MultilinestringFromText('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))', 4326))", output: "select st_astext(st_multilinestringfromtext('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))', 4326)) from dual", }, { input: "SELECT ST_AsText(ST_MultilinestringFromText('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))', 4326, 'axis-order=lat-long'))", output: "select st_astext(st_multilinestringfromtext('MULTILINESTRING((10 10, 11 11), (9 9, 10 10))', 4326, 'axis-order=lat-long')) from dual", }, { input: "SELECT ST_AsText(ST_LinestringFromText('LINESTRING((10 10, 11 11))'))", output: "select st_astext(st_linestringfromtext('LINESTRING((10 10, 11 11))')) from dual", }, { input: "SELECT ST_AsText(ST_LinestringFromText('LINESTRING((10 10, 11 11))', 4326))", output: "select st_astext(st_linestringfromtext('LINESTRING((10 10, 11 11))', 4326)) from dual", }, { input: "SELECT ST_AsText(ST_LinestringFromText('LINESTRING((10 10, 11 11))', 4326, 'axis-order=lat-long'))", output: "select st_astext(st_linestringfromtext('LINESTRING((10 10, 11 11))', 4326, 'axis-order=lat-long')) from dual", }, { input: "SELECT ST_AsText(ST_PointFromText('POINT(10 10)'))", output: "select st_astext(st_pointfromtext('POINT(10 10)')) from dual", }, { input: "SELECT ST_AsText(ST_PointFromText('POINT(10 10)', 4326))", output: "select st_astext(st_pointfromtext('POINT(10 10)', 4326)) from dual", }, { input: "SELECT ST_AsText(ST_MultiPointFromText('MULTIPOINT((10 10, 11 11))'))", output: "select st_astext(st_multipointfromtext('MULTIPOINT((10 10, 11 11))')) from dual", }, { input: "SELECT ST_AsText(ST_MultiPointFromText('MULTIPOINT((10 10, 11 11))', 4326))", output: "select st_astext(st_multipointfromtext('MULTIPOINT((10 10, 11 11))', 4326)) from dual", }, { input: "SELECT ST_AsText(ST_MultiPointFromText('MULTIPOINT((10 10, 11 11))', 4326, 'axis-order=lat-long'))", output: "select st_astext(st_multipointfromtext('MULTIPOINT((10 10, 11 11))', 4326, 'axis-order=lat-long')) from dual", }, { input: "SELECT ST_AsText(ST_MultiPolygonFromText(@g))", output: "select st_astext(st_multipolygonfromtext(@g)) from dual", }, { input: "SELECT ST_AsText(ST_MultiPolygonFromText(@g, 4326))", output: "select st_astext(st_multipolygonfromtext(@g, 4326)) from dual", }, { input: "SELECT ST_AsText(ST_MultiPolygonFromText(@g, 4326, 'axis-order=lat-long'))", output: "select st_astext(st_multipolygonfromtext(@g, 4326, 'axis-order=lat-long')) from dual", }, { input: "SELECT ST_AsText(ST_PolygonFromText(@g))", output: "select st_astext(st_polygonfromtext(@g)) from dual", }, { input: "SELECT ST_AsText(ST_PolygonFromText(@g, 4326))", output: "select st_astext(st_polygonfromtext(@g, 4326)) from dual", }, { input: "SELECT ST_AsText(ST_PolygonFromText(@g, 4326, 'axis-order=long-lat'))", output: "select st_astext(st_polygonfromtext(@g, 4326, 'axis-order=long-lat')) from dual", }, { input: "SELECT ST_AsText(ST_GeomCollFromWKB(0x010100000000000000000022400000000000002240))", output: "select st_astext(st_geometrycollectionfromwkb(0x010100000000000000000022400000000000002240)) from dual", }, { input: "SELECT ST_AsText(ST_GeomCollFromWKB(g, 4326))", output: "select st_astext(st_geometrycollectionfromwkb(g, 4326)) from dual", }, { input: "SELECT ST_AsText(ST_GeomCollFromText(g, 4326, 'axis-order=lat-long'))", output: "select st_astext(st_geometrycollectionfromtext(g, 4326, 'axis-order=lat-long')) from dual", }, { input: "SELECT ST_AsText(ST_GeomFromWKB(g))", output: "select st_astext(st_geometryfromwkb(g)) from dual", }, { input: "SELECT ST_AsText(ST_GeomFromWKB(g, 4326))", output: "select st_astext(st_geometryfromwkb(g, 4326)) from dual", }, { input: "SELECT ST_AsText(ST_GeomFromWKB(g, 4326, 'axis-order=lat-long'))", output: "select st_astext(st_geometryfromwkb(g, 4326, 'axis-order=lat-long')) from dual", }, { input: "SELECT ST_AsText(ST_MultilinestringFromWKB(g))", output: "select st_astext(st_multilinestringfromwkb(g)) from dual", }, { input: "SELECT ST_AsText(ST_MultilinestringFromWKB(g, 4326))", output: "select st_astext(st_multilinestringfromwkb(g, 4326)) from dual", }, { input: "SELECT ST_AsText(ST_MultilinestringFromWKB(0x01050000000200000001020000000200000000000000000024400000000000002440000000000000264000000000000026400102000000020000000000000000002240000000000000224000000000000024400000000000002440, 4326, 'axis-order=lat-long'))", output: "select st_astext(st_multilinestringfromwkb(0x01050000000200000001020000000200000000000000000024400000000000002440000000000000264000000000000026400102000000020000000000000000002240000000000000224000000000000024400000000000002440, 4326, 'axis-order=lat-long')) from dual", }, { input: "SELECT ST_AsText(ST_LinestringFromWKB(g))", output: "select st_astext(st_linestringfromwkb(g)) from dual", }, { input: "SELECT ST_AsText(ST_LinestringFromWKB(g, 4326))", output: "select st_astext(st_linestringfromwkb(g, 4326)) from dual", }, { input: "SELECT ST_AsText(ST_LinestringFromWKB(g, 4326, 'axis-order=lat-long'))", output: "select st_astext(st_linestringfromwkb(g, 4326, 'axis-order=lat-long')) from dual", }, { input: "SELECT ST_AsText(ST_PointFromWKB(mp))", output: "select st_astext(st_pointfromwkb(mp)) from dual", }, { input: "SELECT ST_AsText(ST_PointFromWKB(mp, 4326))", output: "select st_astext(st_pointfromwkb(mp, 4326)) from dual", }, { input: "SELECT ST_AsText(ST_MultiPointFromWKB(mp))", output: "select st_astext(st_multipointfromwkb(mp)) from dual", }, { input: "SELECT ST_AsText(ST_MultiPointFromWKB(mp, 4326))", output: "select st_astext(st_multipointfromwkb(mp, 4326)) from dual", }, { input: "SELECT ST_AsText(ST_MultiPointFromWKB(mp, 4326, 'axis-order=lat-long'))", output: "select st_astext(st_multipointfromwkb(mp, 4326, 'axis-order=lat-long')) from dual", }, { input: "SELECT ST_AsText(ST_MultiPolygonFromText(g))", output: "select st_astext(st_multipolygonfromtext(g)) from dual", }, { input: "SELECT ST_AsText(ST_MultiPolygonFromText(g, 4326))", output: "select st_astext(st_multipolygonfromtext(g, 4326)) from dual", }, { input: "SELECT ST_AsText(ST_MultiPolygonFromText(g, 4326, 'axis-order=lat-long'))", output: "select st_astext(st_multipolygonfromtext(g, 4326, 'axis-order=lat-long')) from dual", }, { input: "SELECT ST_AsText(ST_PolygonFromText(g))", output: "select st_astext(st_polygonfromtext(g)) from dual", }, { input: "SELECT ST_AsText(ST_PolygonFromText(g, 4326))", output: "select st_astext(st_polygonfromtext(g, 4326)) from dual", }, { input: "SELECT ST_AsText(ST_PolygonFromText(g, 4326, 'axis-order=long-lat'), 'axis-order=long-lat')", output: "select st_astext(st_polygonfromtext(g, 4326, 'axis-order=long-lat'), 'axis-order=long-lat') from dual", }, { input: "SELECT ST_AsWKT(ST_GeomCollFromText(g, 4326, 'axis-order=lat-long'))", output: "select st_astext(st_geometrycollectionfromtext(g, 4326, 'axis-order=lat-long')) from dual", }, { input: "SELECT ST_AsBinary(ST_PolygonFromText(g, 4326, 'axis-order=long-lat'), 'axis-order=long-lat')", output: "select st_asbinary(st_polygonfromtext(g, 4326, 'axis-order=long-lat'), 'axis-order=long-lat') from dual", }, { input: "SELECT ST_AsWKB(ST_GeomCollFromText(g, 4326, 'axis-order=lat-long'))", output: "select st_asbinary(st_geometrycollectionfromtext(g, 4326, 'axis-order=lat-long')) from dual", }, { input: "SELECT ST_Dimension(ST_GeomFromText('LineString(1 1,2 2)'))", output: "select st_dimension(st_geometryfromtext('LineString(1 1,2 2)')) from dual", }, { input: "SELECT ST_AsText(ST_Envelope(ST_GeomFromText('LineString(1 1,2 2)')))", output: "select st_astext(st_envelope(st_geometryfromtext('LineString(1 1,2 2)'))) from dual", }, { input: "SELECT ST_IsSimple(ST_GeomFromText('POINT(1 1)'))", output: "select st_issimple(st_geometryfromtext('POINT(1 1)')) from dual", }, { input: "SELECT ST_GeometryType(ST_GeomFromText('POINT(1 1)'))", output: "select st_geometrytype(st_geometryfromtext('POINT(1 1)')) from dual", }, { input: "SELECT ST_IsEmpty(ST_GeomFromText('POINT(1 1)'))", output: "select st_isempty(st_geometryfromtext('POINT(1 1)')) from dual", }, { input: "SELECT ST_Latitude(@pt);", output: "select st_latitude(@pt) from dual", }, { input: "SELECT ST_AsText(ST_Latitude(@pt, 10));", output: "select st_astext(st_latitude(@pt, 10)) from dual", }, { input: "SELECT ST_Longitude(@pt);", output: "select st_longitude(@pt) from dual", }, { input: "SELECT ST_AsText(ST_Longitude(@pt, 10));", output: "select st_astext(st_longitude(@pt, 10)) from dual", }, { input: "SELECT ST_X(@pt);", output: "select st_x(@pt) from dual", }, { input: "SELECT ST_AsText(ST_X(@pt, 10));", output: "select st_astext(st_x(@pt, 10)) from dual", }, { input: "SELECT ST_Y(@pt);", output: "select st_y(@pt) from dual", }, { input: "SELECT ST_AsText(ST_Y(@pt, 10));", output: "select st_astext(st_y(@pt, 10)) from dual", }, { input: "SELECT ST_AsText(ST_EndPoint(ST_GeomFromText(@ls)));", output: "select st_astext(st_endpoint(st_geometryfromtext(@ls))) from dual", }, { input: "SELECT ST_IsClosed(ST_GeomFromText(@ls1));", output: "select st_isclosed(st_geometryfromtext(@ls1)) from dual", }, { input: "SELECT IsClosed(ST_GeomFromText(@ls1));", output: "select st_isclosed(st_geometryfromtext(@ls1)) from dual", }, { input: "SELECT ST_Length(@ls);", output: "select st_length(@ls) from dual", }, { input: "SELECT ST_Length(@ls, 'metre');", output: "select st_length(@ls, 'metre') from dual", }, { input: "SELECT GLength(@ls);", output: "select st_length(@ls) from dual", }, { input: "SELECT GLength(@ls, 'metre');", output: "select st_length(@ls, 'metre') from dual", }, { input: "SELECT ST_NumPoints(ST_GeomFromText(@ls));", output: "select st_numpoints(st_geometryfromtext(@ls)) from dual", }, { input: "SELECT Numpoints(ST_GeomFromText(@ls));", output: "select st_numpoints(st_geometryfromtext(@ls)) from dual", }, { input: "SELECT ST_AsText(ST_PointN(ST_GeomFromText(@ls),2));", output: "select st_astext(st_pointn(st_geometryfromtext(@ls), 2)) from dual", }, { input: "SELECT ST_AsText(PointN(ST_GeomFromText(@ls),2));", output: "select st_astext(st_pointn(st_geometryfromtext(@ls), 2)) from dual", }, { input: "SELECT ST_AsText(ST_StartPoint(ST_GeomFromText(@ls)));", output: "select st_astext(st_startpoint(st_geometryfromtext(@ls))) from dual", }, { input: "SELECT ST_AsText(StartPoint(ST_GeomFromText(@ls)));", output: "select st_astext(st_startpoint(st_geometryfromtext(@ls))) from dual", }, { input: "SELECT ST_Area(ST_GeomFromText(@mpoly));", output: "select st_area(st_geometryfromtext(@mpoly)) from dual", }, { input: "SELECT ST_AsText(ST_GeometryN(ST_GeomFromText(@gc),1));", output: "select st_astext(st_geometryn(st_geometryfromtext(@gc), 1)) from dual", }, { input: "SELECT ST_NumGeometries(ST_GeomFromText(@gc));", output: "select st_numgeometries(st_geometryfromtext(@gc)) from dual", }, { input: "SELECT ST_GeometryType(@poly),ST_AsText(ST_Centroid(@poly));", output: "select st_geometrytype(@poly), st_astext(st_centroid(@poly)) from dual", }, { input: "SELECT ST_AsText(ST_ExteriorRing(ST_GeomFromText(@poly)));", output: "select st_astext(st_exteriorring(st_geometryfromtext(@poly))) from dual", }, { input: "SELECT ST_AsText(ST_InteriorRingN(ST_GeomFromText(@poly),1));", output: "select st_astext(st_interiorringN(st_geometryfromtext(@poly), 1)) from dual", }, { input: "SELECT ST_NumInteriorRings(ST_GeomFromText(@poly));", output: "select st_numinteriorrings(st_geometryfromtext(@poly)) from dual", }, { input: "SELECT ST_NumInteriorRing(ST_GeomFromText(@poly));", output: "select st_numinteriorrings(st_geometryfromtext(@poly)) from dual", }, { input: "SELECT ST_GeoHash(180,0,10), ST_GeoHash(-180,-90,15);", output: "select st_geohash(180, 0, 10), st_geohash(-180, -90, 15) from dual", }, { input: "SELECT ST_GeoHash(@p,10);", output: "select st_geohash(@p, 10) from dual", }, { input: "SELECT ST_LatFromGeoHash(ST_GeoHash(45,-20,10));", output: "select st_latfromgeohash(st_geohash(45, -20, 10)) from dual", }, { input: "SELECT ST_LongFromGeoHash(ST_GeoHash(45,-20,10));", output: "select st_longfromgeohash(st_geohash(45, -20, 10)) from dual", }, { input: "SELECT ST_AsText(ST_PointFromGeoHash(@gh,0));", output: "select st_astext(st_pointfromgeohash(@gh, 0)) from dual", }, { input: "SELECT ST_AsGeoJSON(ST_GeomFromText('POINT(11.11111 12.22222)'));", output: "select st_asgeojson(st_geometryfromtext('POINT(11.11111 12.22222)')) from dual", }, { input: "SELECT ST_AsGeoJSON(ST_GeomFromText('POINT(11.11111 12.22222)'),2);", output: "select st_asgeojson(st_geometryfromtext('POINT(11.11111 12.22222)'), 2) from dual", }, { input: "SELECT ST_AsGeoJSON(ST_GeomFromText('POINT(11.11111 12.22222)'),2,0);", output: "select st_asgeojson(st_geometryfromtext('POINT(11.11111 12.22222)'), 2, 0) from dual", }, { input: "SELECT ST_AsText(ST_GeomFromGeoJSON(@json));", output: "select st_astext(st_geomfromgeojson(@`json`)) from dual", }, { input: "SELECT ST_AsText(ST_SRID(ST_GeomFromGeoJSON(@json, 0),0));", output: "select st_astext(ST_SRID(st_geomfromgeojson(@`json`, 0), 0)) from dual", }, { input: "SELECT ST_AsText(ST_SRID(ST_GeomFromGeoJSON(@json),1,4326));", output: "select st_astext(ST_SRID(st_geomfromgeojson(@`json`), 1, 4326)) from dual", }, { input: "WITH RECURSIVE odd_num_cte (id, n) AS (SELECT 1, 1 union all SELECT id+1, n+2 from odd_num_cte where id < 5) SELECT * FROM odd_num_cte", output: "with recursive odd_num_cte(id, n) as (select 1, 1 from dual union all select id + 1, n + 2 from odd_num_cte where id < 5) select * from odd_num_cte", }, { input: "WITH topsales2003 AS (SELECT salesRepEmployeeNumber employeeNumber, SUM(quantityOrdered * priceEach) sales FROM orders INNER JOIN orderdetails USING (orderNumber) INNER JOIN customers USING (customerNumber) WHERE YEAR(shippedDate) = 2003 AND status = 'Shipped' GROUP BY salesRepEmployeeNumber ORDER BY sales DESC LIMIT 5)SELECT employeeNumber, firstName, lastName, sales FROM employees JOIN topsales2003 USING (employeeNumber)", output: "with topsales2003 as (select salesRepEmployeeNumber as employeeNumber, sum(quantityOrdered * priceEach) as sales from orders join orderdetails using (orderNumber) join customers using (customerNumber) where YEAR(shippedDate) = 2003 and `status` = 'Shipped' group by salesRepEmployeeNumber order by sales desc limit 5) select employeeNumber, firstName, lastName, sales from employees join topsales2003 using (employeeNumber)", }, { input: "WITH count_a AS (SELECT COUNT(`id`) AS `num` FROM `tbl_a`), count_b AS (SELECT COUNT(`id`) AS `num` FROM tbl_b) SELECT 'a', `num` FROM `count_a` UNION SELECT 'b', `num` FROM `count_b`", output: "with count_a as (select count(id) as num from tbl_a) , count_b as (select count(id) as num from tbl_b) select 'a', num from count_a union select 'b', num from count_b", }, { input: "select 1 from t", }, { input: "select * from (select 1) as x(user)", output: "select * from (select 1 from dual) as x(`user`)", }, { input: "select user from (select id from users ) as x(user)", output: "select `user` from (select id from users) as x(`user`)", }, { input: "select n, d from something", }, { input: "insert into sys_message_assign(message_id, assign_user_id, read_state, id, is_delete, create_time, update_time, remark) values (N'3477028275831808', N'4104487936', N'1', N'0', N'0', '2021-09-22 14:24:17.922', '2021-09-22 14:24:17.922', null), (N'3477028275831808', N'3454139190608923', N'1', N'0', N'0', '2021-09-22 14:24:17.922', '2021-09-22 14:24:17.922', null)", /*We need to ignore this test because, after the normalizer, we change the produced NChar string into an introducer expression, so the vttablet will never see a NChar string */ ignoreNormalizerTest: true, }, { input: "select name, numbers from (select * from users) as x(name, numbers)", output: "select `name`, numbers from (select * from users) as x(`name`, numbers)", }, { input: "select 0b010, 0b0111, b'0111', b'011'", output: "select 0b010, 0b0111, 0b0111, 0b011 from dual", }, { input: "select 0x010, 0x0111, x'0111'", output: "select 0x010, 0x0111, X'0111' from dual", }, { input: "select date'2022-10-03'", output: "select date'2022-10-03' from dual", }, { input: "select date, time, timestamp from t", output: "select `date`, `time`, `timestamp` from t", }, { input: "select time'12:34:56'", output: "select time'12:34:56' from dual", }, { input: "select timestamp'2012-12-31 11:30:45'", output: "select timestamp'2012-12-31 11:30:45' from dual", }, { input: "select * from information_schema.columns", output: "select * from information_schema.`columns`", }, { input: "select * from information_schema.processlist", output: "select * from information_schema.`processlist`", }, { input: "select .1 from t", }, { input: "select 1.2e1 from t", }, { input: "select 1.2e+1 from t", }, { input: "select 1.2e-1 from t", }, { input: "select 08.3 from t", }, { input: "select -1 from t where b = -2", }, { input: "select - -1 from t", output: "select - -1 from t", }, { input: "select a from t", }, { input: "select $ from t", }, { // shift/reduce conflict on CHARSET, should throw an error on shifting which will be ignored as it is a DDL input: "alter database charset = 'utf16';", output: "alter database", partialDDL: true, }, { input: "alter database charset charset = 'utf16'", output: "alter database `charset` character set 'utf16'", }, { input: "create table t(id int unique)", output: "create table t (\n\tid int unique\n)", }, { input: "create table t(id int key)", output: "create table t (\n\tid int key\n)", }, { input: "create table t(id int unique key)", output: "create table t (\n\tid int unique key\n)", }, { input: "select a.b as a$b from $test$", }, { input: "select 1 from t // aa\n", output: "select 1 from t", }, { input: "select 1 from t -- aa\n", output: "select 1 from t", }, { input: "select 1 from t # aa\n", output: "select 1 from t", }, { input: "select 1 -- aa\nfrom t", output: "select 1 from t", }, { input: "select 1 #aa\nfrom t", output: "select 1 from t", }, { input: "select /* simplest */ 1 from t", }, { input: "select /* double star **/ 1 from t", }, { input: "select /* double */ /* comment */ 1 from t", }, { input: "select /* back-quote keyword */ `By` from t", }, { input: "select /* back-quote num */ `2a` from t", }, { input: "select /* back-quote . */ `a.b` from t", }, { input: "select /* back-quote back-quote */ `a``b` from t", }, { input: "select /* back-quote unnecessary */ 1 from `t`", output: "select /* back-quote unnecessary */ 1 from t", }, { input: "select /* back-quote idnum */ 1 from `a1`", output: "select /* back-quote idnum */ 1 from a1", }, { input: "select /* @ */ @@a from b", }, { input: "select /* \\0 */ '\\0' from a", }, { input: "select 1 /* drop this comment */ from t", output: "select 1 from t", }, { input: "select /* union */ 1 from t union select 1 from t", }, { input: "select /* double union */ 1 from t union select 1 from t union select 1 from t", }, { input: "select /* union all */ 1 from t union all select 1 from t", }, { input: "select /* union distinct */ 1 from t union distinct select 1 from t", output: "select /* union distinct */ 1 from t union select 1 from t", }, { input: "(select /* union parenthesized select */ 1 from t order by a) union select 1 from t", output: "(select /* union parenthesized select */ 1 from t order by a asc) union select 1 from t", }, { input: "select /* union parenthesized select 2 */ 1 from t union (select 1 from t)", output: "select /* union parenthesized select 2 */ 1 from t union select 1 from t", }, { input: "select /* union order by */ 1 from t union select 1 from t order by a", output: "select /* union order by */ 1 from t union select 1 from t order by a asc", }, { input: "select /* union order by limit lock */ 1 from t union select 1 from t order by a limit 1 for update", output: "select /* union order by limit lock */ 1 from t union select 1 from t order by a asc limit 1 for update", }, { input: "(select id, a from t order by id limit 1) union (select id, b as a from s order by id limit 1) order by a limit 1", output: "(select id, a from t order by id asc limit 1) union (select id, b as a from s order by id asc limit 1) order by a asc limit 1", }, { input: "select a from (select 1 as a from tbl1 union select 2 from tbl2) as t", output: "select a from (select 1 as a from tbl1 union select 2 from tbl2) as t", }, { input: "select * from t1 join (select * from t2 union select * from t3) as t", }, { // Ensure this doesn't generate: ""select * from t1 join t2 on a = b join t3 on a = b". input: "select * from t1 join t2 on a = b join t3", }, { input: "select * from t1 where col in (select 1 from dual union select 2 from dual)", output: "select * from t1 where col in (select 1 from dual union select 2 from dual)", }, { input: "select * from t1 where exists (select a from t2 union select b from t3)", }, { input: "select 1 from dual union select 2 from dual union all select 3 from dual union select 4 from dual union all select 5 from dual", output: "select 1 from dual union select 2 from dual union all select 3 from dual union select 4 from dual union all select 5 from dual", }, { input: "(select 1 from dual) order by 1 asc limit 2", output: "select 1 from dual order by 1 asc limit 2", }, { input: "(select 1 from dual order by 1 desc) order by 1 asc limit 2", output: "select 1 from dual order by 1 asc limit 2", }, { input: "(select 1 from dual)", output: "select 1 from dual", }, { input: "((select 1 from dual))", output: "select 1 from dual", }, { input: "select 1 from (select 1 from dual) as t", }, { input: "select 1 from (select 1 from dual union select 2 from dual) as t", output: "select 1 from (select 1 from dual union select 2 from dual) as t", }, { input: "select 1 from ((select 1 from dual) union select 2 from dual) as t", output: "select 1 from (select 1 from dual union select 2 from dual) as t", }, { input: "select /* distinct */ distinct 1 from t", }, { input: "select /* straight_join */ straight_join 1 from t", }, { input: "select /* for share */ 1 from t for share", }, { input: "select /* for share */ 1 from t for share nowait", }, { input: "select /* for share */ 1 from t for share skip locked", }, { input: "select /* for update */ 1 from t for update", }, { input: "select /* for update */ 1 from t for update nowait", }, { input: "select /* for update */ 1 from t for update skip locked", }, { input: "select /* lock in share mode */ 1 from t lock in share mode", }, { input: "select /* select list */ 1, 2 from t", }, { input: "select /* * */ * from t", }, { input: "select /* a.* */ a.* from t", }, { input: "select /* a.b.* */ a.b.* from t", }, { input: "select /* column alias */ a b from t", output: "select /* column alias */ a as b from t", }, { input: "select /* column alias with as */ a as b from t", }, { input: "select /* keyword column alias */ a as `By` from t", }, { input: "select /* column alias as string */ a as \"b\" from t", output: "select /* column alias as string */ a as b from t", }, { input: "select /* column alias as string without as */ a \"b\" from t", output: "select /* column alias as string without as */ a as b from t", }, { input: "select /* column alias with non_reserved keyword */ a as auto_increment from t", output: "select /* column alias with non_reserved keyword */ a as `auto_increment` from t", }, { input: "select /* a.* */ a.* from t", }, { input: "select next value for t", output: "select next 1 values from t", }, { input: "select next value from t", output: "select next 1 values from t", }, { input: "select next 10 values from t", }, { input: "select next :a values from t", }, { input: "select /* `By`.* */ `By`.* from t", }, { input: "select /* select with bool expr */ a = b from t", }, { input: "select /* case_when */ case when a = b then c end from t", }, { input: "select /* case_when_else */ case when a = b then c else d end from t", }, { input: "select /* case_when_when_else */ case when a = b then c when b = d then d else d end from t", }, { input: "select /* case */ case aa when a = b then c end from t", }, { input: "select /* parenthesis */ 1 from (t)", }, { input: "select /* parenthesis multi-table */ 1 from (t1, t2)", }, { input: "select /* table list */ 1 from t1, t2", }, { input: "select /* parenthessis in table list 1 */ 1 from (t1), t2", }, { input: "SELECT * FROM t1 USE INDEX (i1) IGNORE INDEX FOR ORDER BY (i2) ORDER BY a", output: "select * from t1 use index (i1) ignore index for order by (i2) order by a asc", }, { input: "SELECT * FROM t1 USE INDEX FOR JOIN (i1) FORCE INDEX FOR JOIN (i2)", output: "select * from t1 use index for join (i1) force index for join (i2)", }, { input: "SELECT * FROM t1 USE INDEX FOR JOIN (i1) FORCE INDEX FOR JOIN (i2) IGNORE KEY FOR GROUP BY (i1, i2)", output: "select * from t1 use index for join (i1) force index for join (i2) ignore index for group by (i1, i2)", }, { input: "SELECT * FROM t1 USE KEY (), t2 FORCE KEY (i2), t3 IGNORE INDEX FOR GROUP BY (i1, i2)", output: "select * from t1 use index (), t2 force index (i2), t3 ignore index for group by (i1, i2)", }, { input: "select /* parenthessis in table list 2 */ 1 from t1, (t2)", }, { input: "select /* use */ 1 from t1 use index (a) where b = 1", }, { input: "select /* use */ 1 from t1 use index () where b = 1", }, { input: "select /* keyword index */ 1 from t1 use index (`By`) where b = 1", }, { input: "select /* ignore */ 1 from t1 as t2 ignore index (a), t3 use index (b) where b = 1", }, { input: "select /* use */ 1 from t1 as t2 use index (a), t3 use index (b) where b = 1", }, { input: "select /* force */ 1 from t1 as t2 force index (a), t3 force index (b) where b = 1", }, { input: "select /* table alias */ 1 from t t1", output: "select /* table alias */ 1 from t as t1", }, { input: "select /* table alias with as */ 1 from t as t1", }, { input: "select /* string table alias */ 1 from t as 't1'", output: "select /* string table alias */ 1 from t as t1", }, { input: "select /* string table alias without as */ 1 from t 't1'", output: "select /* string table alias without as */ 1 from t as t1", }, { input: "select /* keyword table alias */ 1 from t as `By`", }, { input: "select /* join */ 1 from t1 join t2", }, { input: "select /* join on */ 1 from t1 join t2 on a = b", }, { input: "select /* join on */ 1 from t1 join t2 using (a)", }, { input: "select /* inner join */ 1 from t1 inner join t2", output: "select /* inner join */ 1 from t1 join t2", }, { input: "select /* cross join */ 1 from t1 cross join t2", output: "select /* cross join */ 1 from t1 join t2", }, { input: "select /* straight_join */ 1 from t1 straight_join t2", }, { input: "select /* straight_join on */ 1 from t1 straight_join t2 on a = b", }, { input: "select /* left join */ 1 from t1 left join t2 on a = b", }, { input: "select /* left join */ 1 from t1 left join t2 using (a)", }, { input: "select /* left outer join */ 1 from t1 left outer join t2 on a = b", output: "select /* left outer join */ 1 from t1 left join t2 on a = b", }, { input: "select /* left outer join */ 1 from t1 left outer join t2 using (a)", output: "select /* left outer join */ 1 from t1 left join t2 using (a)", }, { input: "select /* right join */ 1 from t1 right join t2 on a = b", }, { input: "select /* right join */ 1 from t1 right join t2 using (a)", }, { input: "select /* right outer join */ 1 from t1 right outer join t2 on a = b", output: "select /* right outer join */ 1 from t1 right join t2 on a = b", }, { input: "select /* right outer join */ 1 from t1 right outer join t2 using (a)", output: "select /* right outer join */ 1 from t1 right join t2 using (a)", }, { input: "select /* natural join */ 1 from t1 natural join t2", }, { input: "select /* natural left join */ 1 from t1 natural left join t2", }, { input: "select /* natural left outer join */ 1 from t1 natural left join t2", output: "select /* natural left outer join */ 1 from t1 natural left join t2", }, { input: "select /* natural right join */ 1 from t1 natural right join t2", }, { input: "select /* natural right outer join */ 1 from t1 natural right join t2", output: "select /* natural right outer join */ 1 from t1 natural right join t2", }, { input: "select /* join on */ 1 from t1 join t2 on a = b", }, { input: "select /* join using */ 1 from t1 join t2 using (a)", }, { input: "select /* join using (a, b, c) */ 1 from t1 join t2 using (a, b, c)", }, { input: "select /* s.t */ 1 from s.t", }, { input: "select /* keyword schema & table name */ 1 from `By`.`bY`", }, { input: "select /* select in from */ 1 from (select 1 from t) as a", }, { input: "select /* select in from with no as */ 1 from (select 1 from t) a", output: "select /* select in from with no as */ 1 from (select 1 from t) as a", }, { input: "select /* where */ 1 from t where a = b", }, { input: "select /* and */ 1 from t where a = b and a = c", }, { input: "select /* && */ 1 from t where a = b && a = c", output: "select /* && */ 1 from t where a = b and a = c", }, { input: "select /* or */ 1 from t where a = b or a = c", }, { input: "select /* || */ 1 from t where a = b || a = c", output: "select /* || */ 1 from t where a = b or a = c", }, { input: "select /* not */ 1 from t where not a = b", }, { input: "select /* ! */ 1 from t where a = !1", }, { input: "select /* bool is */ 1 from t where a = b is null", }, { input: "select /* bool is not */ 1 from t where a = b is not false", }, { input: "select /* true */ 1 from t where true", }, { input: "select /* false */ 1 from t where false", }, { input: "select /* false on left */ 1 from t where false = 0", }, { input: "select /* exists */ 1 from t where exists (select 1 from t)", }, { input: "select /* (boolean) */ 1 from t where not (a = b)", output: "select /* (boolean) */ 1 from t where not a = b", }, { input: "select /* in value list */ 1 from t where a in (b, c)", }, { input: "select /* in select */ 1 from t where a in (select 1 from t)", }, { input: "select /* not in */ 1 from t where a not in (b, c)", }, { input: "select /* like */ 1 from t where a like b", }, { input: "select /* like escape */ 1 from t where a like b escape '!'", }, { input: "select /* not like */ 1 from t where a not like b", }, { input: "select /* not like escape */ 1 from t where a not like b escape '$'", }, { input: "select /* regexp */ 1 from t where a regexp b", }, { input: "select /* not regexp */ 1 from t where a not regexp b", }, { input: "select /* rlike */ 1 from t where a rlike b", output: "select /* rlike */ 1 from t where a regexp b", }, { input: "select /* not rlike */ 1 from t where a not rlike b", output: "select /* not rlike */ 1 from t where a not regexp b", }, { input: "select /* between */ 1 from t where a between b and c", }, { input: "select /* not between */ 1 from t where a not between b and c", }, { input: "select /* is null */ 1 from t where a is null", }, { input: "select /* is not null */ 1 from t where a is not null", }, { input: "select /* is true */ 1 from t where a is true", }, { input: "select /* is not true */ 1 from t where a is not true", }, { input: "select /* is false */ 1 from t where a is false", }, { input: "select /* is not false */ 1 from t where a is not false", }, { input: "select /* < */ 1 from t where a < b", }, { input: "select /* <= */ 1 from t where a <= b", }, { input: "select /* >= */ 1 from t where a >= b", }, { input: "select /* > */ 1 from t where a > b", }, { input: "select /* != */ 1 from t where a != b", }, { input: "select /* <> */ 1 from t where a <> b", output: "select /* <> */ 1 from t where a != b", }, { input: "select /* <=> */ 1 from t where a <=> b", }, { input: "select /* != */ 1 from t where a != b", }, { input: "select /* single value expre list */ 1 from t where a in (b)", }, { input: "select /* select as a value expression */ 1 from t where a = (select a from t)", }, { input: "select /* parenthesised value */ 1 from t where a = (b)", output: "select /* parenthesised value */ 1 from t where a = b", }, { input: "select /* over-parenthesize */ ((1)) from t where ((a)) in (((1))) and ((a, b)) in ((((1, 1))), ((2, 2)))", output: "select /* over-parenthesize */ 1 from t where a in (1) and (a, b) in ((1, 1), (2, 2))", }, { input: "select /* dot-parenthesize */ (a.b) from t where (b.c) = 2", output: "select /* dot-parenthesize */ a.b from t where b.c = 2", }, { input: "select /* & */ 1 from t where a = b & c", }, { input: "select /* & */ 1 from t where a = b & c", }, { input: "select /* | */ 1 from t where a = b | c", }, { input: "select /* ^ */ 1 from t where a = b ^ c", }, { input: "select /* + */ 1 from t where a = b + c", }, { input: "select /* - */ 1 from t where a = b - c", }, { input: "select /* * */ 1 from t where a = b * c", }, { input: "select /* / */ 1 from t where a = b / c", }, { input: "select /* % */ 1 from t where a = b % c", }, { input: "select /* div */ 1 from t where a = b div c", }, { input: "select /* MOD */ 1 from t where a = b MOD c", output: "select /* MOD */ 1 from t where a = b % c", }, { input: "select /* << */ 1 from t where a = b << c", }, { input: "select /* >> */ 1 from t where a = b >> c", }, { input: "select /* % no space */ 1 from t where a = b%c", output: "select /* % no space */ 1 from t where a = b % c", }, { |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |