vitess.io/vitess@v0.16.2/go/vt/vttablet/tabletserver/planbuilder/testdata/exec_cases.txt (about) 1 # union 2 "select * from a union select * from b" 3 { 4 "PlanID": "Select", 5 "TableName": "", 6 "Permissions": [ 7 { 8 "TableName": "a", 9 "Role": 0 10 }, 11 { 12 "TableName": "b", 13 "Role": 0 14 } 15 ], 16 "FullQuery": "select * from a union select * from b limit :#maxLimit" 17 } 18 19 # union with limit 20 "select * from a union select * from b limit 10" 21 { 22 "PlanID": "Select", 23 "TableName": "", 24 "Permissions": [ 25 { 26 "TableName": "a", 27 "Role": 0 28 }, 29 { 30 "TableName": "b", 31 "Role": 0 32 } 33 ], 34 "FullQuery": "select * from a union select * from b limit 10" 35 } 36 37 # with no where clause 38 "select * from a" 39 { 40 "PlanID": "Select", 41 "TableName": "a", 42 "Permissions": [ 43 { 44 "TableName": "a", 45 "Role": 0 46 } 47 ], 48 "FullQuery": "select * from a limit :#maxLimit" 49 } 50 51 # select with a regular where clause 52 "select * from a where id=1" 53 { 54 "PlanID": "Select", 55 "TableName": "a", 56 "Permissions": [ 57 { 58 "TableName": "a", 59 "Role": 0 60 } 61 ], 62 "FullQuery": "select * from a where id = 1 limit :#maxLimit" 63 } 64 65 # select with limit 66 "select * from a limit 5" 67 { 68 "PlanID": "Select", 69 "TableName": "a", 70 "Permissions": [ 71 { 72 "TableName": "a", 73 "Role": 0 74 } 75 ], 76 "FullQuery": "select * from a limit 5" 77 } 78 79 # limit with offset arg 80 "select * from a limit 10, 5" 81 { 82 "PlanID": "Select", 83 "TableName": "a", 84 "Permissions": [ 85 { 86 "TableName": "a", 87 "Role": 0 88 } 89 ], 90 "FullQuery": "select * from a limit 10, 5" 91 } 92 93 # select impossible 94 "select * from a where 1 != 1" 95 { 96 "PlanID": "SelectImpossible", 97 "TableName": "a", 98 "Permissions": [ 99 { 100 "TableName": "a", 101 "Role": 0 102 } 103 ], 104 "FullQuery": "select * from a where 1 != 1 limit :#maxLimit" 105 } 106 107 # bind in select list 108 "select :bv from a" 109 { 110 "PlanID": "Select", 111 "TableName": "a", 112 "Permissions": [ 113 { 114 "TableName": "a", 115 "Role": 0 116 } 117 ], 118 "FullQuery": "select :bv from a limit :#maxLimit" 119 } 120 121 # bind in select list and impossible 122 "select :bv from a where 1 != 1" 123 { 124 "PlanID": "SelectImpossible", 125 "TableName": "a", 126 "Permissions": [ 127 { 128 "TableName": "a", 129 "Role": 0 130 } 131 ], 132 "FullQuery": "select :bv from a where 1 != 1 limit :#maxLimit" 133 } 134 135 # single value sequence 136 "select next value from seq" 137 { 138 "PlanID": "Nextval", 139 "TableName": "seq", 140 "Permissions": [ 141 { 142 "TableName": "seq", 143 "Role": 0 144 } 145 ], 146 "NextCount": "INT64(1)" 147 } 148 149 # sequence with number 150 "select next 10 values from seq" 151 { 152 "PlanID": "Nextval", 153 "TableName": "seq", 154 "Permissions": [ 155 { 156 "TableName": "seq", 157 "Role": 0 158 } 159 ], 160 "NextCount": "INT64(10)" 161 } 162 163 164 # sequence with bindvar 165 "select next :a values from seq" 166 { 167 "PlanID": "Nextval", 168 "TableName": "seq", 169 "Permissions": [ 170 { 171 "TableName": "seq", 172 "Role": 0 173 } 174 ], 175 "NextCount": ":a" 176 } 177 178 # squence with bad value 179 "select next 12345667852342342342323423423 values from seq" 180 { 181 "PlanID": "Nextval", 182 "TableName": "seq", 183 "Permissions": [ 184 { 185 "TableName": "seq", 186 "Role": 0 187 } 188 ], 189 "NextCount": "DECIMAL(12345667852342342342323423423)" 190 } 191 192 # nextval on non-sequence table 193 "select next value from a" 194 "a is not a sequence" 195 196 # nextval on non-existent table 197 "select next value from id" 198 "id is not a sequence" 199 200 # for update 201 "select eid from a for update" 202 { 203 "PlanID": "Select", 204 "TableName": "a", 205 "Permissions": [ 206 { 207 "TableName": "a", 208 "Role": 0 209 } 210 ], 211 "FullQuery": "select eid from a limit :#maxLimit for update" 212 } 213 214 # lock in share mode 215 "select eid from a lock in share mode" 216 { 217 "PlanID": "Select", 218 "TableName": "a", 219 "Permissions": [ 220 { 221 "TableName": "a", 222 "Role": 0 223 } 224 ], 225 "FullQuery": "select eid from a limit :#maxLimit lock in share mode" 226 } 227 228 # normal insert 229 "insert into a(eid, id) values (1, 2)" 230 { 231 "PlanID": "Insert", 232 "TableName": "a", 233 "Permissions": [ 234 { 235 "TableName": "a", 236 "Role": 1 237 } 238 ], 239 "FullQuery": "insert into a(eid, id) values (1, 2)" 240 } 241 242 # insert cross-db 243 "insert into b.a (eid, id) values (1, 2)" 244 { 245 "PlanID": "Insert", 246 "TableName": "", 247 "Permissions": [ 248 { 249 "TableName": "a", 250 "Role": 1 251 } 252 ], 253 "FullQuery": "insert into b.a(eid, id) values (1, 2)" 254 } 255 256 # insert with bind value 257 "insert into a (eid, id) values (1, :a)" 258 { 259 "PlanID": "Insert", 260 "TableName": "a", 261 "Permissions": [ 262 { 263 "TableName": "a", 264 "Role": 1 265 } 266 ], 267 "FullQuery": "insert into a(eid, id) values (1, :a)" 268 } 269 270 # insert with subquery 271 "insert into b (eid, id) select * from a" 272 { 273 "PlanID": "Insert", 274 "TableName": "b", 275 "Permissions": [ 276 { 277 "TableName": "b", 278 "Role": 1 279 }, 280 { 281 "TableName": "a", 282 "Role": 0 283 } 284 ], 285 "FullQuery": "insert into b(eid, id) select * from a" 286 } 287 288 # upsert 289 "insert into a (eid, id) values (1, 2) on duplicate key update name = func(a)" 290 { 291 "PlanID": "Insert", 292 "TableName": "a", 293 "Permissions": [ 294 { 295 "TableName": "a", 296 "Role": 1 297 } 298 ], 299 "FullQuery": "insert into a(eid, id) values (1, 2) on duplicate key update `name` = func(a)" 300 } 301 302 # replace 303 "replace into b (eid, id) values (1, 2), (3, 4)" 304 { 305 "PlanID": "Insert", 306 "TableName": "b", 307 "Permissions": [ 308 { 309 "TableName": "b", 310 "Role": 1 311 } 312 ], 313 "FullQuery": "replace into b(eid, id) values (1, 2), (3, 4)" 314 } 315 316 # update with no where clause 317 "update d set foo='foo'" 318 { 319 "PlanID": "UpdateLimit", 320 "TableName": "d", 321 "Permissions": [ 322 { 323 "TableName": "d", 324 "Role": 1 325 } 326 ], 327 "FullQuery": "update d set foo = 'foo' limit :#maxLimit" 328 } 329 330 # normal update 331 "update d set foo='foo' where name in ('a', 'b')" 332 { 333 "PlanID": "UpdateLimit", 334 "TableName": "d", 335 "Permissions": [ 336 { 337 "TableName": "d", 338 "Role": 1 339 } 340 ], 341 "FullQuery": "update d set foo = 'foo' where `name` in ('a', 'b') limit :#maxLimit", 342 "WhereClause": "where `name` in ('a', 'b')" 343 } 344 345 # normal update 346 options:PassthroughDMLs 347 "update d set foo='foo' where name in ('a', 'b')" 348 { 349 "PlanID": "Update", 350 "TableName": "d", 351 "Permissions": [ 352 { 353 "TableName": "d", 354 "Role": 1 355 } 356 ], 357 "FullQuery": "update d set foo = 'foo' where `name` in ('a', 'b')", 358 "WhereClause": "where `name` in ('a', 'b')" 359 } 360 361 # cross-db update 362 "update a.b set foo='foo' where name in ('a', 'b')" 363 { 364 "PlanID": "Update", 365 "TableName": "", 366 "Permissions": [ 367 { 368 "TableName": "b", 369 "Role": 1 370 } 371 ], 372 "FullQuery": "update a.b set foo = 'foo' where `name` in ('a', 'b')", 373 "WhereClause": "where `name` in ('a', 'b')" 374 } 375 376 # update unknown table 377 "update bogus set name='foo' where id=1" 378 { 379 "PlanID": "Update", 380 "TableName": "", 381 "Permissions": [ 382 { 383 "TableName": "bogus", 384 "Role": 1 385 } 386 ], 387 "FullQuery": "update bogus set `name` = 'foo' where id = 1", 388 "WhereClause": "where id = 1" 389 } 390 391 # update unknown table 392 options:PassthroughDMLs 393 "update bogus set name='foo' where id=1" 394 { 395 "PlanID": "Update", 396 "TableName": "", 397 "Permissions": [ 398 { 399 "TableName": "bogus", 400 "Role": 1 401 } 402 ], 403 "FullQuery": "update bogus set `name` = 'foo' where id = 1", 404 "WhereClause": "where id = 1" 405 } 406 407 # multi-table update 408 "update a, b set a.name = 'foo' where a.id = b.id and b.var = 'test'" 409 { 410 "PlanID": "Update", 411 "TableName": "", 412 "Permissions": [ 413 { 414 "TableName": "a", 415 "Role": 1 416 }, 417 { 418 "TableName": "b", 419 "Role": 1 420 } 421 ], 422 "FullQuery": "update a, b set a.`name` = 'foo' where a.id = b.id and b.var = 'test'", 423 "WhereClause": "where a.id = b.id and b.var = 'test'" 424 } 425 426 # multi-table update 427 options:PassthroughDMLs 428 "update a join b on a.id = b.id set a.name = 'foo' where b.var = 'test'" 429 { 430 "PlanID": "Update", 431 "TableName": "", 432 "Permissions": [ 433 { 434 "TableName": "a", 435 "Role": 1 436 }, 437 { 438 "TableName": "b", 439 "Role": 1 440 } 441 ], 442 "FullQuery": "update a join b on a.id = b.id set a.`name` = 'foo' where b.var = 'test'", 443 "WhereClause": "where b.var = 'test'" 444 } 445 446 447 # update with limit 448 "update a set name='foo' limit 1" 449 { 450 "PlanID": "Update", 451 "TableName": "a", 452 "Permissions": [ 453 { 454 "TableName": "a", 455 "Role": 1 456 } 457 ], 458 "FullQuery": "update a set `name` = 'foo' limit 1" 459 } 460 461 # update with limit 462 options:PassthroughDMLs 463 "update a set name='foo' limit 1" 464 { 465 "PlanID": "Update", 466 "TableName": "a", 467 "Permissions": [ 468 { 469 "TableName": "a", 470 "Role": 1 471 } 472 ], 473 "FullQuery": "update a set `name` = 'foo' limit 1" 474 } 475 476 # delete with no where clause 477 "delete from a" 478 { 479 "PlanID": "DeleteLimit", 480 "TableName": "a", 481 "Permissions": [ 482 { 483 "TableName": "a", 484 "Role": 1 485 } 486 ], 487 "FullQuery": "delete from a limit :#maxLimit" 488 } 489 490 # normal delete 491 "delete from d where name in ('a', 'b')" 492 { 493 "PlanID": "DeleteLimit", 494 "TableName": "d", 495 "Permissions": [ 496 { 497 "TableName": "d", 498 "Role": 1 499 } 500 ], 501 "FullQuery": "delete from d where `name` in ('a', 'b') limit :#maxLimit", 502 "WhereClause": "where `name` in ('a', 'b')" 503 } 504 505 # normal delete 506 options:PassthroughDMLs 507 "delete from d where name in ('a', 'b')" 508 { 509 "PlanID": "Delete", 510 "TableName": "d", 511 "Permissions": [ 512 { 513 "TableName": "d", 514 "Role": 1 515 } 516 ], 517 "FullQuery": "delete from d where `name` in ('a', 'b')", 518 "WhereClause": "where `name` in ('a', 'b')" 519 } 520 521 # delete unknown table 522 "delete from bogus" 523 { 524 "PlanID": "Delete", 525 "TableName": "", 526 "Permissions": [ 527 { 528 "TableName": "bogus", 529 "Role": 1 530 } 531 ], 532 "FullQuery": "delete from bogus" 533 } 534 535 # delete unknown table 536 options:PassthroughDMLs 537 "delete from bogus" 538 { 539 "PlanID": "Delete", 540 "TableName": "", 541 "Permissions": [ 542 { 543 "TableName": "bogus", 544 "Role": 1 545 } 546 ], 547 "FullQuery": "delete from bogus" 548 } 549 550 # multi-table delete 551 "delete a, b from a, b where id = 1" 552 { 553 "PlanID": "Delete", 554 "TableName": "", 555 "Permissions": [ 556 { 557 "TableName": "a", 558 "Role": 1 559 }, 560 { 561 "TableName": "b", 562 "Role": 1 563 } 564 ], 565 "FullQuery": "delete a, b from a, b where id = 1", 566 "WhereClause": "where id = 1" 567 } 568 569 570 # delete with limit 571 "delete from a limit 10" 572 { 573 "PlanID": "Delete", 574 "TableName": "a", 575 "Permissions": [ 576 { 577 "TableName": "a", 578 "Role": 1 579 } 580 ], 581 "FullQuery": "delete from a limit 10" 582 } 583 584 # delete with limit 585 options:PassthroughDMLs 586 "delete from a limit 10" 587 { 588 "PlanID": "Delete", 589 "TableName": "a", 590 "Permissions": [ 591 { 592 "TableName": "a", 593 "Role": 1 594 } 595 ], 596 "FullQuery": "delete from a limit 10" 597 } 598 599 # create 600 "create table a(a int, b varchar(8))" 601 { 602 "PlanID": "DDL", 603 "TableName": "", 604 "Permissions": [ 605 { 606 "TableName": "a", 607 "Role": 2 608 } 609 ], 610 "FullQuery": "create table a (\n\ta int,\n\tb varchar(8)\n)" 611 } 612 613 # create index 614 "create index a on b(id)" 615 { 616 "PlanID": "DDL", 617 "TableName": "", 618 "Permissions": [ 619 { 620 "TableName": "b", 621 "Role": 2 622 } 623 ], 624 "FullQuery":"alter table b add index a (id)" 625 } 626 627 # create view 628 "create view a as select * from b" 629 { 630 "PlanID": "DDL", 631 "TableName": "", 632 "Permissions": [ 633 { 634 "TableName": "a", 635 "Role": 2 636 } 637 ], 638 "FullQuery":"create view a as select * from b" 639 } 640 641 # alter 642 "alter table a add column(a int)" 643 { 644 "PlanID": "DDL", 645 "TableName": "", 646 "Permissions": [ 647 { 648 "TableName": "a", 649 "Role": 2 650 } 651 ], 652 "FullQuery":"alter table a add column a int" 653 } 654 655 # alter rename 656 "alter table a rename b" 657 { 658 "PlanID": "DDL", 659 "TableName": "", 660 "Permissions": [ 661 { 662 "TableName": "a", 663 "Role": 2 664 }, 665 { 666 "TableName": "b", 667 "Role": 2 668 } 669 ], 670 "FullQuery":"alter table a rename b" 671 } 672 673 # rename 674 "rename table a to b" 675 { 676 "PlanID": "DDL", 677 "TableName": "", 678 "Permissions": [ 679 { 680 "TableName": "a", 681 "Role": 2 682 }, 683 { 684 "TableName": "b", 685 "Role": 2 686 } 687 ], 688 "FullQuery":"rename table a to b" 689 } 690 691 # multi-rename 692 "rename table a to b, b to a" 693 { 694 "PlanID": "DDL", 695 "TableName": "", 696 "Permissions": [ 697 { 698 "TableName": "a", 699 "Role": 2 700 }, 701 { 702 "TableName": "b", 703 "Role": 2 704 }, 705 { 706 "TableName": "b", 707 "Role": 2 708 }, 709 { 710 "TableName": "a", 711 "Role": 2 712 } 713 ], 714 "FullQuery":"rename table a to b, b to a" 715 } 716 717 # drop 718 "drop table a" 719 { 720 "PlanID": "DDL", 721 "TableName": "", 722 "Permissions": [ 723 { 724 "TableName": "a", 725 "Role": 2 726 } 727 ], 728 "FullQuery": "drop table a" 729 } 730 731 # drop 732 "truncate table a" 733 { 734 "PlanID": "DDL", 735 "TableName": "", 736 "Permissions": [ 737 { 738 "TableName": "a", 739 "Role": 2 740 } 741 ], 742 "FullQuery": "truncate table a" 743 } 744 745 # multi-drop 746 "drop table a, b" 747 { 748 "PlanID": "DDL", 749 "TableName": "", 750 "Permissions": [ 751 { 752 "TableName": "a", 753 "Role": 2 754 }, 755 { 756 "TableName": "b", 757 "Role": 2 758 } 759 ], 760 "FullQuery": "drop table a, b" 761 } 762 763 # analyze 764 "analyze table a" 765 { 766 "PlanID": "OtherRead", 767 "TableName": "" 768 } 769 770 # show 771 "show a" 772 { 773 "PlanID": "OtherRead", 774 "TableName": "" 775 } 776 777 # describe 778 "describe a" 779 { 780 "PlanID": "OtherRead", 781 "TableName": "" 782 } 783 784 # explain 785 "explain a" 786 { 787 "PlanID": "OtherRead", 788 "TableName": "" 789 } 790 791 # repair 792 "repair a" 793 { 794 "PlanID": "OtherAdmin", 795 "TableName": "" 796 } 797 798 # optimize 799 "optimize a" 800 { 801 "PlanID": "OtherAdmin", 802 "TableName": "" 803 } 804 805 # syntax error 806 "syntax error" 807 "syntax error at position 7 near 'syntax'" 808 809 # show tables #1 810 "show tables like 'key%'" 811 { 812 "PlanID": "Show", 813 "TableName":"", 814 "FullQuery": "show tables like 'key%'" 815 } 816 817 # show tables #2 818 "show tables where Tables_in_keyspace='apa'" 819 { 820 "PlanID": "Show", 821 "TableName":"", 822 "FullQuery": "show tables where Tables_in_dbName = 'apa'" 823 } 824 825 # show table status #1 826 "show table status like 'key%'" 827 { 828 "PlanID": "Show", 829 "TableName":"", 830 "FullQuery": "show table status like 'key%'" 831 } 832 833 # show table status #2 834 "show table status where Name='apa'" 835 { 836 "PlanID": "Show", 837 "TableName":"", 838 "FullQuery": "show table status where `Name` = 'apa'" 839 } 840 841 # show create table 842 "show create table t1" 843 { 844 "PlanID": "Show", 845 "TableName": "", 846 "FullQuery": "show create table t1" 847 } 848 849 # show create database system_schema 850 "show create database mysql" 851 { 852 "PlanID": "Show", 853 "TableName": "", 854 "FullQuery": "show create database mysql" 855 } 856 857 # show create database 858 "show create database anything" 859 { 860 "PlanID": "Show", 861 "TableName": "", 862 "FullQuery": "show create database dbName" 863 } 864 865 # load data 866 "load data infile 'x.txt' into table a" 867 { 868 "PlanID":"Load", 869 "TableName":"" 870 } 871 872 # alter view 873 "alter view a as select * from b" 874 { 875 "PlanID": "DDL", 876 "TableName": "", 877 "Permissions": [ 878 { 879 "TableName": "a", 880 "Role": 2 881 } 882 ], 883 "FullQuery":"alter view a as select * from b" 884 } 885 886 # drop view 887 "drop view a" 888 { 889 "PlanID": "DDL", 890 "TableName": "", 891 "Permissions": [ 892 { 893 "TableName": "a", 894 "Role": 2 895 } 896 ], 897 "FullQuery":"drop view a" 898 } 899 900 # multi-drop views 901 "drop view a, b" 902 { 903 "PlanID": "DDL", 904 "TableName": "", 905 "Permissions": [ 906 { 907 "TableName": "a", 908 "Role": 2 909 }, 910 { 911 "TableName": "b", 912 "Role": 2 913 } 914 ], 915 "FullQuery":"drop view a, b" 916 } 917 918 # flush statement 919 "flush tables a,b" 920 { 921 "PlanID": "Flush", 922 "TableName": "", 923 "Permissions": [ 924 { 925 "TableName": "a", 926 "Role": 2 927 }, 928 { 929 "TableName": "b", 930 "Role": 2 931 } 932 ], 933 "FullQuery": "flush tables a, b" 934 } 935 936 # call proc 937 "call getAllTheThings()" 938 { 939 "PlanID": "CallProcedure", 940 "TableName": "", 941 "FullQuery": "call getAllTheThings()" 942 } 943 944 # create table with function as a default value 945 "create table function_default (x varchar(25) DEFAULT (TRIM(' check ')))" 946 { 947 "PlanID": "DDL", 948 "TableName": "", 949 "Permissions": [ 950 { 951 "TableName": "function_default", 952 "Role": 2 953 } 954 ], 955 "FullQuery": "create table function_default (\n\tx varchar(25) default (trim(' check '))\n)" 956 } 957 958 # temporary table 959 "create temporary table temp(a int)" 960 { 961 "PlanID": "DDL", 962 "TableName": "", 963 "Permissions": [ 964 { 965 "TableName": "temp", 966 "Role": 2 967 } 968 ], 969 "FullQuery": "create temporary table temp (\n\ta int\n)", 970 "NeedsReservedConn": true 971 }