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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248
|
remote = require('net.box')
---
...
test_run = require('test_run').new()
---
...
engine = test_run:get_cfg('engine')
---
...
_ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}})
---
...
-- gh-3010: COLLATE after LIMIT should throw an error
-- All of these tests should throw error "near "COLLATE": syntax error"
box.execute("SELECT 1 LIMIT 1 COLLATE BINARY;")
---
- null
- Syntax error at line 1 near 'COLLATE'
...
box.execute("SELECT 1 LIMIT 1 COLLATE BINARY OFFSET 1;")
---
- null
- Syntax error at line 1 near 'COLLATE'
...
box.execute("SELECT 1 LIMIT 1 OFFSET 1 COLLATE BINARY;")
---
- null
- Syntax error at line 1 near 'COLLATE'
...
box.execute("SELECT 1 LIMIT 1, 1 COLLATE BINARY;")
---
- null
- Syntax error at line 1 near 'COLLATE'
...
box.execute("SELECT 1 LIMIT 1 COLLATE BINARY, 1;")
---
- null
- Syntax error at line 1 near 'COLLATE'
...
-- gh-3052: upper/lower support only default locale
-- For tr-TR result depends on collation
box.execute([[CREATE TABLE tu (descriptor VARCHAR(50) PRIMARY KEY, letter VARCHAR(50))]]);
---
- row_count: 1
...
box.internal.collation.create('TURKISH', 'ICU', 'tr-TR', {strength='primary'});
---
...
box.execute([[INSERT INTO tu VALUES ('Latin Capital Letter I U+0049','I');]])
---
- row_count: 1
...
box.execute([[INSERT INTO tu VALUES ('Latin Small Letter I U+0069','i');]])
---
- row_count: 1
...
box.execute([[INSERT INTO tu VALUES ('Latin Capital Letter I With Dot Above U+0130','İ');]])
---
- row_count: 1
...
box.execute([[INSERT INTO tu VALUES ('Latin Small Letter Dotless I U+0131','ı');]])
---
- row_count: 1
...
-- Without collation
box.execute([[SELECT descriptor, upper(letter) AS upper,lower(letter) AS lower FROM tu;]])
---
- metadata:
- name: DESCRIPTOR
type: string
- name: UPPER
type: string
- name: LOWER
type: string
rows:
- ['Latin Capital Letter I U+0049', 'I', 'i']
- ['Latin Capital Letter I With Dot Above U+0130', 'İ', 'i̇']
- ['Latin Small Letter Dotless I U+0131', 'I', 'ı']
- ['Latin Small Letter I U+0069', 'I', 'i']
...
-- With collation
box.execute([[SELECT descriptor, upper(letter COLLATE "TURKISH") AS upper,lower(letter COLLATE "TURKISH") AS lower FROM tu;]])
---
- metadata:
- name: DESCRIPTOR
type: string
- name: UPPER
type: string
- name: LOWER
type: string
rows:
- ['Latin Capital Letter I U+0049', 'I', 'ı']
- ['Latin Capital Letter I With Dot Above U+0130', 'İ', 'i']
- ['Latin Small Letter Dotless I U+0131', 'I', 'ı']
- ['Latin Small Letter I U+0069', 'İ', 'i']
...
box.internal.collation.drop('TURKISH')
---
...
-- For de-DE result is actually the same
box.internal.collation.create('GERMAN', 'ICU', 'de-DE', {strength='primary'});
---
...
box.execute([[INSERT INTO tu VALUES ('German Small Letter Sharp S U+00DF','ß');]])
---
- row_count: 1
...
-- Without collation
box.execute([[SELECT descriptor, upper(letter), letter FROM tu where UPPER(letter) = 'SS';]])
---
- metadata:
- name: DESCRIPTOR
type: string
- name: COLUMN_1
type: string
- name: LETTER
type: string
rows:
- ['German Small Letter Sharp S U+00DF', 'SS', 'ß']
...
-- With collation
box.execute([[SELECT descriptor, upper(letter COLLATE "GERMAN"), letter FROM tu where UPPER(letter COLLATE "GERMAN") = 'SS';]])
---
- metadata:
- name: DESCRIPTOR
type: string
- name: COLUMN_1
type: string
- name: LETTER
type: string
rows:
- ['German Small Letter Sharp S U+00DF', 'SS', 'ß']
...
box.internal.collation.drop('GERMAN')
---
...
box.execute(([[DROP TABLE tu]]))
---
- row_count: 1
...
box.schema.user.grant('guest','read,write,execute', 'universe')
---
...
cn = remote.connect(box.cfg.listen)
---
...
cn:execute('select 1 limit ? collate not_exist', {1})
---
- error: Syntax error at line 1 near 'COLLATE'
...
cn:close()
---
...
-- Explicitly set BINARY collation is predifined and has ID.
--
box.execute("CREATE TABLE t (id INT PRIMARY KEY, a TEXT, b TEXT COLLATE \"binary\");")
---
- row_count: 1
...
box.space.T:format()[2]['collation']
---
- null
...
box.space.T:format()[3]['collation']
---
- 3
...
box.execute("DROP TABLE t;")
---
- row_count: 1
...
-- BINARY collation works in the same way as there is no collation
-- at all.
--
t = box.schema.create_space('test', {format = {{'id', 'unsigned'}, {'a', 'string', collation = 'binary'}}})
---
...
t:format()[2]['collation']
---
- 3
...
pk = t:create_index('primary', {parts = {1}})
---
...
i = t:create_index('secondary', {parts = {2, 'str', collation='binary'}})
---
...
t:insert({1, 'AsD'})
---
- [1, 'AsD']
...
t:insert({2, 'ASD'})
---
- [2, 'ASD']
...
t:insert({3, 'asd'})
---
- [3, 'asd']
...
i:select('asd')
---
- - [3, 'asd']
...
i:select('ASD')
---
- - [2, 'ASD']
...
i:select('AsD')
---
- - [1, 'AsD']
...
t:drop()
---
...
-- Collation with id == 0 is "none". It used to unify interaction
-- with collation interface. It also can't be dropped.
--
box.space._collation:select{0}
---
- - [0, 'none', 1, 'BINARY', '', {}]
...
box.space._collation:delete{0}
---
- error: 'Can''t drop collation none : system collation'
...
-- gh-3185: collations of LHS and RHS must be compatible.
--
box.execute("CREATE TABLE t (id INT PRIMARY KEY, a TEXT, b TEXT COLLATE \"binary\", c TEXT COLLATE \"unicode_ci\");")
---
- row_count: 1
...
box.execute("SELECT * FROM t WHERE a = b;")
---
- metadata:
- name: ID
type: integer
- name: A
type: string
- name: B
type: string
- name: C
type: string
rows: []
...
box.execute("SELECT * FROM t WHERE a COLLATE \"binary\" = b;")
---
- metadata:
- name: ID
type: integer
- name: A
type: string
- name: B
type: string
- name: C
type: string
rows: []
...
box.execute("SELECT * FROM t WHERE b = c;")
---
- null
- Illegal mix of collations
...
box.execute("SELECT * FROM t WHERE b COLLATE \"binary\" = c;")
---
- metadata:
- name: ID
type: integer
- name: A
type: string
- name: B
type: string
- name: C
type: string
rows: []
...
box.execute("SELECT * FROM t WHERE a = c;")
---
- metadata:
- name: ID
type: integer
- name: A
type: string
- name: B
type: string
- name: C
type: string
rows: []
...
box.execute("SELECT * FROM t WHERE a COLLATE \"binary\" = c COLLATE \"unicode\";")
---
- null
- Illegal mix of collations
...
-- Make sure that using function featuring variable arguemnts
-- length and resulting collation which depends on arguments
-- is processed correctly.
--
box.execute("SELECT * FROM t WHERE a COLLATE \"binary\" = substr();")
---
- null
- 'Wrong number of arguments is passed to SUBSTR(): expected 1 or 2, got 0'
...
-- Compound queries perform implicit comparisons between values.
-- Hence, rules for collations compatibilities are the same.
--
box.execute("SELECT 'abc' COLLATE \"binary\" UNION SELECT 'ABC' COLLATE \"unicode_ci\"")
---
- null
- Illegal mix of collations
...
box.execute("SELECT 'abc' COLLATE \"unicode_ci\" UNION SELECT 'ABC' COLLATE binary")
---
- null
- Illegal mix of collations
...
box.execute("SELECT c FROM t UNION SELECT b FROM t;")
---
- null
- Illegal mix of collations
...
box.execute("SELECT b FROM t UNION SELECT a FROM t;")
---
- metadata:
- name: B
type: string
rows: []
...
box.execute("SELECT a FROM t UNION SELECT c FROM t;")
---
- metadata:
- name: A
type: string
rows: []
...
box.execute("SELECT c COLLATE \"binary\" FROM t UNION SELECT a FROM t;")
---
- metadata:
- name: COLUMN_1
type: string
rows: []
...
box.execute("SELECT b COLLATE \"unicode\" FROM t UNION SELECT a FROM t;")
---
- metadata:
- name: COLUMN_1
type: string
rows: []
...
box.execute("DROP TABLE t;")
---
- row_count: 1
...
box.schema.user.revoke('guest', 'read,write,execute', 'universe')
---
...
-- gh-3857 "PRAGMA collation_list" invokes segmentation fault.
box.schema.user.create('tmp')
---
...
box.session.su('tmp')
---
...
-- gh-4713 "PRAGMA collation_list" is not accessible to all users
_, err = box.execute('pragma collation_list')
---
...
assert(err == nil)
---
- true
...
box.session.su('admin')
---
...
box.schema.user.drop('tmp')
---
...
-- gh-3644 Foreign key update fails with "unicode_ci".
-- Check that foreign key update doesn't fail with "unicode_ci".
box.execute('CREATE TABLE t0 (s1 VARCHAR(5) COLLATE "unicode_ci" UNIQUE, id INT PRIMARY KEY AUTOINCREMENT);')
---
- row_count: 1
...
box.execute('CREATE TABLE t1 (s1 INT PRIMARY KEY, s0 VARCHAR(5) COLLATE "unicode_ci" REFERENCES t0(s1));')
---
- row_count: 1
...
box.execute("INSERT INTO t0(s1) VALUES ('a');")
---
- autoincrement_ids:
- 1
row_count: 1
...
box.execute("INSERT INTO t1 VALUES (1,'a');")
---
- row_count: 1
...
-- Should't fail.
box.execute("UPDATE t0 SET s1 = 'A';")
---
- row_count: 1
...
box.execute("SELECT s1 FROM t0;")
---
- metadata:
- name: S1
type: string
rows:
- ['A']
...
box.execute("SELECT * FROM t1;")
---
- metadata:
- name: S1
type: integer
- name: S0
type: string
rows:
- [1, 'a']
...
box.execute("DROP TABLE t1;")
---
- row_count: 1
...
box.execute("DROP TABLE t0;")
---
- row_count: 1
...
-- Check that foreign key update fails with default collation.
box.execute('CREATE TABLE t0 (s1 VARCHAR(5) UNIQUE, id INT PRIMARY KEY AUTOINCREMENT);')
---
- row_count: 1
...
box.execute('CREATE TABLE t1 (s1 INT PRIMARY KEY, s0 VARCHAR(5) REFERENCES t0(s1));')
---
- row_count: 1
...
box.execute("INSERT INTO t0(s1) VALUES ('a');")
---
- autoincrement_ids:
- 1
row_count: 1
...
box.execute("INSERT INTO t1 VALUES (1,'a');")
---
- row_count: 1
...
-- Should fail.
box.execute("UPDATE t0 SET s1 = 'A';")
---
- null
- 'Failed to execute SQL statement: FOREIGN KEY constraint failed'
...
box.execute("SELECT * FROM t1;")
---
- metadata:
- name: S1
type: integer
- name: S0
type: string
rows:
- [1, 'a']
...
box.execute("SELECT s1 FROM t0;")
---
- metadata:
- name: S1
type: string
rows:
- ['a']
...
box.execute("DROP TABLE t1;")
---
- row_count: 1
...
box.execute("DROP TABLE t0;")
---
- row_count: 1
...
-- gh-3937: result of concatination has derived collation.
--
box.execute("CREATE TABLE t4a(a TEXT COLLATE \"unicode\", b TEXT COLLATE \"unicode_ci\", c INT PRIMARY KEY);")
---
- row_count: 1
...
box.execute("INSERT INTO t4a VALUES('ABC','abc',1);")
---
- row_count: 1
...
box.execute("INSERT INTO t4a VALUES('ghi','ghi',3);")
---
- row_count: 1
...
-- Only LHS of concatenation has implicitly set collation.
-- Hence, no collation is used.
--
box.execute("SELECT c FROM t4a WHERE (a||'') = b;")
---
- metadata:
- name: C
type: integer
rows:
- [1]
- [3]
...
-- BINARY collation is forced for comparison operator as
-- a derivation from concatenation.
--
box.execute("SELECT c FROM t4a WHERE (a COLLATE \"binary\"||'') = b;")
---
- metadata:
- name: C
type: integer
rows:
- [3]
...
-- Both operands of concatenation have explicit but different
-- collations.
--
box.execute("SELECT c FROM t4a WHERE (a COLLATE \"binary\"||'' COLLATE \"unicode_ci\") = b;")
---
- null
- Illegal mix of collations
...
box.execute("SELECT c FROM t4a WHERE (a COLLATE \"binary\"||'') = b COLLATE \"unicode\";")
---
- null
- Illegal mix of collations
...
-- No collation is used since LHS and RHS of concatenation
-- operator have different implicit collations.
--
box.execute("SELECT c FROM t4a WHERE (a||'')=(b||'');")
---
- metadata:
- name: C
type: integer
rows:
- [3]
...
box.execute("SELECT c FROM t4a WHERE (a||b)=(b||a);")
---
- metadata:
- name: C
type: integer
rows:
- [3]
...
box.execute("CREATE TABLE t4b(a TEXT COLLATE \"unicode_ci\", b TEXT COLLATE \"unicode_ci\", c INT PRIMARY KEY);")
---
- row_count: 1
...
box.execute("INSERT INTO t4b VALUES('BCD','bcd',1);")
---
- row_count: 1
...
box.execute("INSERT INTO t4b VALUES('ghi','ghi',3);")
---
- row_count: 1
...
-- Operands have the same implicit collation, so it is derived.
--
box.execute("SELECT c FROM t4a WHERE (a||b)=(b||a);")
---
- metadata:
- name: C
type: integer
rows:
- [3]
...
-- Couple of other possible combinations.
--
box.execute("SELECT c FROM t4a WHERE (a||b COLLATE \"binary\")=(b||a);")
---
- metadata:
- name: C
type: integer
rows:
- [3]
...
box.execute("SELECT c FROM t4a WHERE (a||b COLLATE \"binary\")=(b COLLATE \"unicode_ci\"||a);")
---
- null
- Illegal mix of collations
...
box.execute("INSERT INTO t4b VALUES('abc', 'xxx', 2);")
---
- row_count: 1
...
box.execute("INSERT INTO t4b VALUES('gHz', 'xxx', 4);")
---
- row_count: 1
...
-- Results are sorted with case-insensitive order.
-- Otherwise capital latters come first.
--
box.execute("SELECT a FROM t4b ORDER BY a COLLATE \"unicode_ci\" || ''")
---
- metadata:
- name: A
type: string
rows:
- ['abc']
- ['BCD']
- ['ghi']
- ['gHz']
...
box.execute("SELECT a FROM t4b ORDER BY a || b")
---
- metadata:
- name: A
type: string
rows:
- ['abc']
- ['BCD']
- ['ghi']
- ['gHz']
...
box.space.T4A:drop()
---
...
box.space.T4B:drop()
---
...
-- gh-3537 Duplicate key error for an index that is not unique
-- pk - default, sc - unicode_ci
box.execute('CREATE TABLE t3 (s1 VARCHAR(5) PRIMARY KEY);')
---
- row_count: 1
...
box.execute('CREATE INDEX i3 ON t3 (s1 collate "unicode_ci");')
---
- row_count: 1
...
box.execute("INSERT INTO t3 VALUES ('a');")
---
- row_count: 1
...
box.execute("INSERT INTO t3 VALUES ('A');")
---
- row_count: 1
...
box.execute("SELECT * FROM t3;")
---
- metadata:
- name: S1
type: string
rows:
- ['A']
- ['a']
...
box.execute("DROP TABLE t3;")
---
- row_count: 1
...
-- pk - binary, sc - unicode
box.execute('CREATE TABLE t3b (s1 VARCHAR(5) collate "binary" PRIMARY KEY);')
---
- row_count: 1
...
box.execute('CREATE INDEX i3b ON t3b (s1 collate "unicode");')
---
- row_count: 1
...
box.execute("INSERT INTO t3b VALUES ('a');")
---
- row_count: 1
...
box.execute("INSERT INTO t3b VALUES ('A');")
---
- row_count: 1
...
box.execute("SELECT * FROM t3b;")
---
- metadata:
- name: S1
type: string
rows:
- ['A']
- ['a']
...
box.execute("DROP TABLE t3b;")
---
- row_count: 1
...
-- pk - binary, sc - unicode (make dup)
box.execute('CREATE TABLE t3b (s1 VARCHAR(5) collate "binary" PRIMARY KEY);')
---
- row_count: 1
...
box.execute('CREATE INDEX i3b ON t3b (s1 collate "unicode");')
---
- row_count: 1
...
box.execute("INSERT INTO t3b VALUES ('a');")
---
- row_count: 1
...
box.execute("INSERT INTO t3b VALUES ('A');")
---
- row_count: 1
...
box.execute("INSERT INTO t3b VALUES ('a');")
---
- null
- Duplicate key exists in unique index 'pk_unnamed_T3B_1' in space 'T3B'
...
box.execute("SELECT * FROM t3b;")
---
- metadata:
- name: S1
type: string
rows:
- ['A']
- ['a']
...
box.execute("DROP TABLE t3b;")
---
- row_count: 1
...
-- pk - unicode, sc - binary
box.execute('CREATE TABLE t3c (s1 VARCHAR(5) collate "unicode" PRIMARY KEY);')
---
- row_count: 1
...
box.execute('CREATE INDEX i3c ON t3c (s1 collate "binary");')
---
- row_count: 1
...
box.execute("INSERT INTO t3c VALUES ('a');")
---
- row_count: 1
...
box.execute("INSERT INTO t3c VALUES ('A');")
---
- row_count: 1
...
box.execute("SELECT * FROM t3c;")
---
- metadata:
- name: S1
type: string
rows:
- ['a']
- ['A']
...
box.execute("DROP TABLE t3c;")
---
- row_count: 1
...
-- pk - unicode, sc - binary (make dup)
box.execute('CREATE TABLE t3c (s1 VARCHAR(5) collate "unicode" PRIMARY KEY);')
---
- row_count: 1
...
box.execute('CREATE INDEX i3c ON t3c (s1 collate "binary");')
---
- row_count: 1
...
box.execute("INSERT INTO t3c VALUES ('a');")
---
- row_count: 1
...
box.execute("INSERT INTO t3c VALUES ('A');")
---
- row_count: 1
...
box.execute("INSERT INTO t3c VALUES ('a');")
---
- null
- Duplicate key exists in unique index 'pk_unnamed_T3C_1' in space 'T3C'
...
box.execute("SELECT * FROM t3c;")
---
- metadata:
- name: S1
type: string
rows:
- ['a']
- ['A']
...
box.execute("DROP TABLE t3c;")
---
- row_count: 1
...
-- pk - binary, sc - unicode_ci
box.execute('CREATE TABLE t3d (s1 VARCHAR(5) collate "binary" PRIMARY KEY);')
---
- row_count: 1
...
box.execute('CREATE INDEX i3d ON t3d (s1 collate "unicode_ci");')
---
- row_count: 1
...
box.execute("INSERT INTO t3d VALUES ('a');")
---
- row_count: 1
...
box.execute("INSERT INTO t3d VALUES ('A');")
---
- row_count: 1
...
box.execute("SELECT * FROM t3d;")
---
- metadata:
- name: S1
type: string
rows:
- ['A']
- ['a']
...
box.execute("DROP TABLE t3d;")
---
- row_count: 1
...
-- pk - binary, sc - unicode_ci (make dup)
box.execute('CREATE TABLE t3d (s1 VARCHAR(5) collate "binary" PRIMARY KEY);')
---
- row_count: 1
...
box.execute('CREATE INDEX i3d ON t3d (s1 collate "unicode_ci");')
---
- row_count: 1
...
box.execute("INSERT INTO t3d VALUES ('a');")
---
- row_count: 1
...
box.execute("INSERT INTO t3d VALUES ('A');")
---
- row_count: 1
...
box.execute("INSERT INTO t3d VALUES ('a');")
---
- null
- Duplicate key exists in unique index 'pk_unnamed_T3D_1' in space 'T3D'
...
box.execute("SELECT * FROM t3d;")
---
- metadata:
- name: S1
type: string
rows:
- ['A']
- ['a']
...
box.execute("DROP TABLE t3d;")
---
- row_count: 1
...
-- pk - unicode_ci, sc - binary (should fail)
box.execute('CREATE TABLE t3e (s1 VARCHAR(5) collate "unicode_ci" PRIMARY KEY);')
---
- row_count: 1
...
box.execute('CREATE INDEX i3e ON t3e (s1 collate "binary");')
---
- row_count: 1
...
box.execute("INSERT INTO t3e VALUES ('a');")
---
- row_count: 1
...
box.execute("INSERT INTO t3e VALUES ('A');")
---
- null
- Duplicate key exists in unique index 'pk_unnamed_T3E_1' in space 'T3E'
...
box.execute("SELECT * FROM t3e;")
---
- metadata:
- name: S1
type: string
rows:
- ['a']
...
box.execute("DROP TABLE t3e;")
---
- row_count: 1
...
-- pk - unicode, sc - unicode_ci
box.execute('CREATE TABLE t3f (s1 VARCHAR(5) collate "unicode" PRIMARY KEY);')
---
- row_count: 1
...
box.execute('CREATE INDEX i3f ON t3f (s1 collate "unicode_ci");')
---
- row_count: 1
...
box.execute("INSERT INTO t3f VALUES ('a');")
---
- row_count: 1
...
box.execute("INSERT INTO t3f VALUES ('A');")
---
- row_count: 1
...
box.execute("SELECT * FROM t3f;")
---
- metadata:
- name: S1
type: string
rows:
- ['a']
- ['A']
...
box.execute("DROP TABLE t3f;")
---
- row_count: 1
...
-- pk - unicode, sc - unicode_ci (make dup)
box.execute('CREATE TABLE t3f (s1 VARCHAR(5) collate "unicode" PRIMARY KEY);')
---
- row_count: 1
...
box.execute('CREATE INDEX i3f ON t3f (s1 collate "unicode_ci");')
---
- row_count: 1
...
box.execute("INSERT INTO t3f VALUES ('a');")
---
- row_count: 1
...
box.execute("INSERT INTO t3f VALUES ('A');")
---
- row_count: 1
...
box.execute("INSERT INTO t3f VALUES ('a');")
---
- null
- Duplicate key exists in unique index 'pk_unnamed_T3F_1' in space 'T3F'
...
box.execute("SELECT * FROM t3f;")
---
- metadata:
- name: S1
type: string
rows:
- ['a']
- ['A']
...
box.execute("DROP TABLE t3f;")
---
- row_count: 1
...
-- pk - unicode_ci, sc - unicode (should fail)
box.execute('CREATE TABLE t3g (s1 VARCHAR(5) collate "unicode_ci" PRIMARY KEY);')
---
- row_count: 1
...
box.execute('CREATE INDEX i3g ON t3g (s1 collate "unicode");')
---
- row_count: 1
...
box.execute("INSERT INTO t3g VALUES ('a');")
---
- row_count: 1
...
box.execute("INSERT INTO t3g VALUES ('A');")
---
- null
- Duplicate key exists in unique index 'pk_unnamed_T3G_1' in space 'T3G'
...
box.execute("SELECT * FROM t3g;")
---
- metadata:
- name: S1
type: string
rows:
- ['a']
...
box.execute("DROP TABLE t3g;")
---
- row_count: 1
...
-- pk - default, sc - multipart
box.execute('CREATE TABLE qms1 (w VARCHAR(5) PRIMARY KEY, n VARCHAR(5), q VARCHAR(5), s INTEGER);')
---
- row_count: 1
...
box.execute('CREATE INDEX iqms1 ON qms1 (w collate "unicode_ci", n);')
---
- row_count: 1
...
box.execute("INSERT INTO qms1 VALUES ('www', 'nnn', 'qqq', 1);")
---
- row_count: 1
...
box.execute("INSERT INTO qms1 VALUES ('WWW', 'nnn', 'qqq', 2);")
---
- row_count: 1
...
box.execute("SELECT * FROM qms1;")
---
- metadata:
- name: W
type: string
- name: N
type: string
- name: Q
type: string
- name: S
type: integer
rows:
- ['WWW', 'nnn', 'qqq', 2]
- ['www', 'nnn', 'qqq', 1]
...
box.execute("DROP TABLE qms1;")
---
- row_count: 1
...
box.execute('CREATE TABLE qms2 (w VARCHAR(5) PRIMARY KEY, n VARCHAR(5), q VARCHAR(5), s INTEGER);')
---
- row_count: 1
...
box.execute('CREATE INDEX iqms2 ON qms2 (w collate "unicode", n);')
---
- row_count: 1
...
box.execute("INSERT INTO qms2 VALUES ('www', 'nnn', 'qqq', 1);")
---
- row_count: 1
...
box.execute("INSERT INTO qms2 VALUES ('WWW', 'nnn', 'qqq', 2);")
---
- row_count: 1
...
box.execute("SELECT * FROM qms2;")
---
- metadata:
- name: W
type: string
- name: N
type: string
- name: Q
type: string
- name: S
type: integer
rows:
- ['WWW', 'nnn', 'qqq', 2]
- ['www', 'nnn', 'qqq', 1]
...
box.execute("DROP TABLE qms2;")
---
- row_count: 1
...
-- pk - multipart, sc overlaps with pk
box.execute('CREATE TABLE qms3 (w VARCHAR(5), n VARCHAR(5), q VARCHAR(5), s INTEGER, CONSTRAINT pk_qms3 PRIMARY KEY(w, n, q));')
---
- row_count: 1
...
box.execute('CREATE INDEX iqms3 ON qms3 (w collate "unicode_ci", s);')
---
- row_count: 1
...
box.execute("INSERT INTO qms3 VALUES ('www', 'nnn', 'qqq', 1);")
---
- row_count: 1
...
box.execute("INSERT INTO qms3 VALUES ('WWW', 'nnn', 'qqq', 2);")
---
- row_count: 1
...
box.execute("SELECT * FROM qms3;")
---
- metadata:
- name: W
type: string
- name: N
type: string
- name: Q
type: string
- name: S
type: integer
rows:
- ['WWW', 'nnn', 'qqq', 2]
- ['www', 'nnn', 'qqq', 1]
...
box.execute("DROP TABLE qms3;")
---
- row_count: 1
...
box.execute('CREATE TABLE qms4 (w VARCHAR(5), n VARCHAR(5), q VARCHAR(5), s INTEGER, CONSTRAINT pk_qms4 PRIMARY KEY(w, n, q));')
---
- row_count: 1
...
box.execute('CREATE INDEX iqms4 ON qms4 (w collate "unicode", s);')
---
- row_count: 1
...
box.execute("INSERT INTO qms4 VALUES ('www', 'nnn', 'qqq', 1);")
---
- row_count: 1
...
box.execute("INSERT INTO qms4 VALUES ('WWW', 'nnn', 'qqq', 2);")
---
- row_count: 1
...
box.execute("SELECT * FROM qms4;")
---
- metadata:
- name: W
type: string
- name: N
type: string
- name: Q
type: string
- name: S
type: integer
rows:
- ['WWW', 'nnn', 'qqq', 2]
- ['www', 'nnn', 'qqq', 1]
...
box.execute("DROP TABLE qms4;")
---
- row_count: 1
...
-- gh-3932: make sure set build-in functions derive collation
-- from their arguments.
--
box.execute("CREATE TABLE jj (s1 INT PRIMARY KEY, s2 VARCHAR(3) COLLATE \"unicode_ci\");")
---
- row_count: 1
...
box.execute("INSERT INTO jj VALUES (1,'A'), (2,'a')")
---
- row_count: 2
...
box.execute("SELECT DISTINCT trim(s2) FROM jj;")
---
- metadata:
- name: COLUMN_1
type: string
rows:
- ['A']
...
box.execute("INSERT INTO jj VALUES (3, 'aS'), (4, 'AS');")
---
- row_count: 2
...
box.execute("SELECT DISTINCT replace(s2, 'S', 's') FROM jj;")
---
- metadata:
- name: COLUMN_1
type: string
rows:
- ['A']
- ['as']
...
box.execute("SELECT DISTINCT substr(s2, 1, 1) FROM jj;")
---
- metadata:
- name: COLUMN_1
type: string
rows:
- ['A']
...
box.space.JJ:drop()
---
...
-- gh-3573: Strength in the _collation space
-- Collation without 'strength' option set now has explicit
-- 'strength' = 'tertiary'.
--
box.internal.collation.create('c', 'ICU', 'unicode')
---
...
box.space._collation.index.name:get({'c'})
---
- [277, 'c', 1, 'ICU', 'unicode', {'strength': 'tertiary'}]
...
box.internal.collation.drop('c')
---
...
--
-- gh-4007 Feature request for a new collation
--
-- Default unicode collation deals with russian letters
s = box.schema.space.create('t1')
---
...
s:format({{name='s1', type='string', collation = 'unicode'}})
---
...
idx = s:create_index('pk', {unique = true, type='tree', parts={{'s1', collation = 'unicode'}}})
---
...
s:insert{'Ё'}
---
- ['Ё']
...
s:insert{'Е'}
---
- ['Е']
...
s:insert{'ё'}
---
- ['ё']
...
s:insert{'е'}
---
- ['е']
...
-- all 4 letters are in the table
s:select{}
---
- - ['е']
- ['Е']
- ['ё']
- ['Ё']
...
s:drop()
---
...
-- unicode_ci collation doesn't distinguish russian letters 'Е' and 'Ё'
s = box.schema.space.create('t1')
---
...
s:format({{name='s1', type='string', collation = 'unicode_ci'}})
---
...
idx = s:create_index('pk', {unique = true, type='tree', parts={{'s1', collation = 'unicode_ci'}}})
---
...
s:insert{'Ё'}
---
- ['Ё']
...
-- the following calls should fail
s:insert{'е'}
---
- error: Duplicate key exists in unique index 'pk' in space 't1'
...
s:insert{'Е'}
---
- error: Duplicate key exists in unique index 'pk' in space 't1'
...
s:insert{'ё'}
---
- error: Duplicate key exists in unique index 'pk' in space 't1'
...
-- return single 'Ё'
s:select{}
---
- - ['Ё']
...
s:drop()
---
...
|