[Sqlparser] VALUES(...) should take a fully-qualified column name

A values expression is allowed to take a fully qualified (table.col),
but the current parser only allows unqualified columns. I have modified
the grammar, plan builder, and AST accordingly.

Signed-off-by: Daniel Tahara <tahara@dropbox.com>
This commit is contained in:
Daniel Tahara 2018-05-01 11:01:00 -07:00
Родитель 6147e6e470
Коммит 98e162a6a2
7 изменённых файлов: 202 добавлений и 153 удалений

Просмотреть файл

@ -621,6 +621,42 @@ options:PassthroughDMLs
"PKValues": [[1], [2]]
}
# upsert with values() func and qualified column
"insert into a (eid, id, name) values (1, 2, 'foo') on duplicate key update name = values(a.name)"
{
"PlanID": "UPSERT_PK",
"TableName": "a",
"Permissions": [
{
"TableName": "a",
"Role": 1
}
],
"FullQuery": "insert into a(eid, id, name) values (1, 2, 'foo') on duplicate key update name = values(a.name)",
"OuterQuery": "insert into a(eid, id, name) values (1, 2, 'foo')",
"UpsertQuery": "update a set name = ('foo') where :#pk",
"PKValues": [[1], [2]]
}
# upsert with values() func and qualified column with improper table
"insert into a (eid, id, name) values (1, 2, 'foo') on duplicate key update name = values(c.name)"
"could not find qualified column c.name in table a"
# upsert with values() func and qualified column and qualified table
"insert into b.a (eid, id, name) values (1, 2, 'foo') on duplicate key update name = values(b.a.name)"
{
"PlanID": "PASS_DML",
"Reason": "TABLE",
"TableName": "",
"Permissions": [
{
"TableName": "a",
"Role": 1
}
],
"FullQuery": "insert into b.a(eid, id, name) values (1, 2, 'foo') on duplicate key update name = values(b.a.name)"
}
# upsert with values() inside another func
"insert into a (eid, id, name) values (1, 2, 'foo') on duplicate key update name = concat(values(name), 'foo')"
{
@ -722,7 +758,7 @@ options:PassthroughDMLs
# upsert with mismatch values()
"insert into a (eid, id) values (1, 2) on duplicate key update eid = values(eid), name = values(name)"
"could not find column name"
"could not find column &{<nil> name { }}"
# upsert pk change, with values() func
"insert into a (eid, id) values (1, 2) on duplicate key update eid = values(eid), id = values(id)"

Просмотреть файл

@ -2701,12 +2701,12 @@ func (node *GroupConcatExpr) replace(from, to Expr) bool {
// ValuesFuncExpr represents a function call.
type ValuesFuncExpr struct {
Name ColIdent
Name *ColName
}
// Format formats the node.
func (node *ValuesFuncExpr) Format(buf *TrackedBuffer) {
buf.Myprintf("values(%s)", node.Name.String())
buf.Myprintf("values(%v)", node.Name)
}
func (node *ValuesFuncExpr) walkSubtree(visit Visit) error {

Просмотреть файл

@ -613,6 +613,10 @@ var (
input: "insert /* bool in insert value */ into a values (1, true, false)",
}, {
input: "insert /* bool in on duplicate */ into a values (1, 2) on duplicate key update b = false, c = d",
}, {
input: "insert /* bool in on duplicate */ into a values (1, 2, 3) on duplicate key update b = values(b), c = d",
}, {
input: "insert /* bool in on duplicate */ into a values (1, 2, 3) on duplicate key update b = values(a.b), c = d",
}, {
input: "insert /* bool expression on duplicate */ into a values (1, 2) on duplicate key update b = func(a), c = a > d",
}, {

Просмотреть файл

@ -672,61 +672,61 @@ var yyAct = [...]int{
1026, 669, 631, 512, 461, 460, 626, 684, 881, 442,
462, 541, 442, 725, 442, 1067, 686, 421, 301, 578,
577, 462, 414, 400, 404, 732, 735, 727, 211, 567,
912, 23, 289, 289, 289, 289, 289, 540, 501, 502,
994, 741, 289, 289, 289, 289, 289, 540, 501, 502,
503, 504, 505, 506, 507, 728, 729, 556, 752, 772,
775, 736, 566, 717, 718, 906, 289, 725, 907, 1028,
668, 541, 912, 744, 1115, 743, 737, 745, 746, 76,
568, 727, 566, 913, 541, 177, 177, 76, 50, 177,
23, 54, 177, 776, 754, 755, 177, 757, 76, 76,
76, 76, 76, 76, 76, 76, 765, 1079, 810, 811,
812, 913, 76, 76, 774, 773, 177, 1160, 1075, 778,
753, 933, 881, 756, 569, 541, 788, 724, 726, 663,
881, 76, 430, 50, 430, 177, 1145, 50, 803, 823,
1043, 76, 430, 742, 936, 819, 824, 994, 814, 301,
301, 301, 301, 912, 301, 301, 813, 23, 893, 213,
912, 736, 1028, 717, 718, 912, 289, 725, 54, 913,
668, 541, 775, 744, 566, 743, 737, 745, 746, 76,
568, 727, 566, 881, 1115, 177, 177, 76, 913, 177,
23, 23, 177, 776, 754, 755, 177, 757, 76, 76,
76, 76, 76, 76, 76, 76, 765, 881, 810, 811,
812, 541, 76, 76, 774, 773, 177, 1160, 541, 778,
753, 1079, 1075, 756, 933, 881, 788, 724, 726, 569,
912, 76, 430, 663, 430, 177, 50, 50, 50, 1145,
803, 76, 430, 742, 823, 1043, 824, 893, 936, 301,
301, 301, 301, 630, 301, 301, 819, 917, 918, 213,
431, 301, 248, 247, 250, 251, 252, 253, 222, 820,
821, 249, 254, 767, 485, 486, 478, 479, 480, 481,
482, 483, 484, 477, 76, 890, 487, 465, 870, 630,
881, 688, 478, 479, 480, 481, 482, 483, 484, 477,
76, 892, 487, 691, 50, 65, 50, 917, 918, 858,
482, 483, 484, 477, 76, 814, 487, 465, 870, 890,
892, 688, 475, 485, 486, 478, 479, 480, 481, 482,
483, 484, 477, 691, 23, 487, 50, 813, 65, 858,
826, 1060, 859, 1028, 960, 177, 865, 920, 177, 177,
177, 177, 177, 640, 299, 675, 439, 762, 889, 760,
177, 923, 763, 177, 761, 871, 764, 177, 550, 551,
922, 759, 177, 177, 758, 1237, 76, 1231, 909, 910,
217, 218, 456, 990, 76, 546, 549, 550, 551, 547,
301, 548, 552, 880, 854, 573, 454, 546, 549, 550,
551, 547, 908, 548, 552, 1236, 289, 917, 918, 895,
864, 689, 897, 863, 698, 699, 700, 701, 702, 703,
177, 177, 177, 640, 299, 439, 675, 923, 906, 762,
177, 907, 889, 177, 763, 871, 760, 177, 922, 1237,
759, 761, 177, 177, 758, 1231, 76, 854, 909, 910,
764, 50, 550, 551, 76, 546, 549, 550, 551, 547,
301, 548, 552, 880, 1236, 573, 990, 546, 549, 550,
551, 547, 908, 548, 552, 864, 289, 917, 918, 895,
863, 689, 897, 951, 698, 699, 700, 701, 702, 703,
704, 705, 706, 707, 708, 709, 710, 711, 712, 921,
444, 951, 934, 930, 576, 177, 422, 929, 76, 931,
76, 943, 445, 1211, 177, 1210, 1158, 177, 76, 937,
1113, 948, 949, 1146, 833, 639, 554, 456, 430, 862,
938, 939, 214, 215, 878, 54, 208, 861, 879, 1190,
804, 805, 806, 807, 975, 883, 884, 885, 209, 1189,
1148, 957, 913, 430, 894, 458, 815, 816, 817, 900,
1198, 901, 902, 903, 904, 966, 1136, 301, 658, 56,
58, 565, 973, 980, 51, 301, 1, 446, 450, 950,
830, 952, 953, 954, 963, 839, 301, 301, 301, 301,
301, 301, 301, 301, 468, 1213, 1171, 1054, 790, 782,
301, 301, 398, 64, 1205, 789, 1177, 998, 1033, 997,
47, 1134, 797, 1003, 1029, 945, 1032, 800, 1015, 671,
688, 1059, 1016, 1208, 752, 1045, 1046, 1047, 511, 465,
752, 235, 301, 1037, 1034, 1023, 974, 522, 942, 1039,
583, 979, 976, 969, 970, 977, 972, 971, 581, 76,
582, 1038, 177, 580, 1053, 585, 299, 1052, 978, 584,
76, 579, 188, 1051, 968, 295, 553, 572, 825, 1050,
459, 66, 719, 983, 982, 835, 495, 860, 300, 1035,
664, 448, 733, 733, 1188, 1147, 896, 521, 741, 738,
234, 679, 246, 288, 243, 289, 245, 1081, 1002, 244,
670, 905, 469, 76, 76, 733, 76, 872, 873, 874,
1083, 232, 224, 1086, 287, 537, 545, 543, 542, 1068,
1069, 919, 1089, 1109, 915, 286, 1088, 993, 1110, 76,
1096, 1195, 674, 25, 301, 55, 219, 177, 19, 18,
17, 20, 301, 16, 15, 1048, 76, 14, 29, 1114,
13, 12, 11, 10, 9, 8, 1125, 1126, 1127, 7,
1122, 6, 5, 1128, 4, 210, 22, 2, 0, 0,
0, 934, 1130, 0, 0, 0, 0, 0, 0, 430,
0, 0, 0, 0, 0, 0, 76, 76, 0, 1137,
217, 218, 934, 930, 576, 177, 456, 929, 76, 931,
76, 444, 422, 943, 177, 1211, 1210, 177, 76, 1158,
454, 948, 949, 445, 937, 1113, 1146, 833, 430, 639,
938, 939, 554, 456, 878, 214, 215, 208, 879, 1190,
804, 805, 806, 807, 975, 883, 884, 885, 209, 54,
1189, 957, 862, 430, 894, 1148, 815, 816, 817, 900,
861, 901, 902, 903, 904, 966, 913, 301, 458, 1198,
1136, 658, 973, 980, 56, 301, 58, 446, 450, 950,
565, 952, 953, 954, 51, 1, 301, 301, 301, 301,
301, 301, 301, 301, 468, 830, 963, 839, 1213, 1171,
301, 301, 1054, 790, 782, 398, 64, 998, 1033, 997,
47, 1205, 789, 1003, 1029, 1177, 1032, 1134, 1015, 671,
688, 797, 1016, 945, 752, 1045, 1046, 1047, 511, 465,
752, 235, 301, 1037, 1034, 1023, 974, 522, 800, 1039,
1059, 979, 976, 969, 970, 977, 972, 971, 1208, 76,
942, 1038, 177, 583, 1053, 581, 299, 1052, 978, 582,
76, 580, 585, 1051, 968, 584, 579, 188, 295, 1050,
553, 572, 719, 825, 478, 479, 480, 481, 482, 483,
484, 477, 733, 733, 487, 459, 66, 983, 733, 982,
835, 495, 860, 288, 300, 289, 1035, 1081, 1002, 664,
448, 1188, 1147, 76, 76, 733, 76, 872, 873, 874,
1083, 896, 521, 1086, 738, 234, 679, 246, 243, 1068,
1069, 245, 1089, 1109, 244, 670, 1088, 905, 469, 76,
1096, 232, 224, 287, 301, 537, 545, 177, 543, 542,
919, 915, 301, 286, 993, 1048, 76, 1110, 1195, 1114,
674, 25, 55, 219, 19, 18, 1125, 1126, 1127, 17,
1122, 20, 16, 1128, 15, 14, 29, 13, 12, 11,
10, 934, 1130, 9, 8, 7, 6, 5, 4, 430,
210, 22, 2, 0, 0, 0, 76, 76, 0, 1137,
0, 1139, 0, 1143, 0, 0, 301, 0, 301, 1144,
0, 0, 0, 0, 0, 0, 301, 0, 0, 0,
76, 1149, 76, 76, 0, 1090, 1033, 0, 0, 1162,
@ -791,7 +791,7 @@ var yyAct = [...]int{
655, 656, 511, 181, 0, 0, 0, 288, 0, 183,
0, 0, 0, 785, 0, 0, 189, 185, 0, 0,
0, 0, 0, 0, 223, 0, 0, 0, 0, 223,
223, 0, 0, 734, 734, 223, 0, 0, 0, 0,
223, 0, 0, 734, 734, 223, 0, 0, 0, 734,
965, 785, 0, 187, 0, 0, 191, 0, 0, 223,
223, 223, 223, 0, 175, 0, 734, 175, 175, 175,
175, 175, 0, 999, 634, 635, 0, 0, 638, 766,
@ -821,9 +821,9 @@ var yyAct = [...]int{
617, 618, 619, 620, 0, 621, 622, 623, 624, 625,
602, 603, 604, 605, 586, 587, 0, 0, 589, 0,
590, 591, 592, 593, 594, 595, 596, 597, 598, 599,
606, 607, 608, 609, 610, 611, 612, 613, 475, 485,
486, 478, 479, 480, 481, 482, 483, 484, 477, 0,
0, 487, 0, 0, 0, 0, 0, 0, 0, 0,
606, 607, 608, 609, 610, 611, 612, 613, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 175, 0, 0, 0,
0, 0, 0, 0, 0, 0, 223, 0, 0, 0,
@ -1581,10 +1581,10 @@ var yyPact = [...]int{
279, -1000, -174, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, 820, 864, -1000, -1000, -1000, -1000, -1000, -1000, 652,
-1000, 834, 869, -1000, -1000, -1000, -1000, -1000, -1000, 655,
2100, 23, 55, -10, 8777, 50, 1597, 9338, -1000, -31,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, 651, -1000, -1000,
-1000, -1000, -1000, 819, 832, 653, 812, 711, -1000, 5098,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, 585, -1000, -1000,
-1000, -1000, -1000, 820, 832, 653, 815, 761, -1000, 5098,
20, 7817, 8590, 4438, -1000, 477, 46, 9338, -142, 8964,
16, 16, 16, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
@ -1597,18 +1597,18 @@ var yyPact = [...]int{
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, 48, 9338, -1000, 9338, 15, 476,
15, 15, 15, 9338, -1000, 85, -1000, -1000, -1000, -1000,
9338, 471, 776, 26, 2807, 2807, 2807, 2807, -26, 2807,
2807, 675, -1000, -1000, -1000, -1000, 2807, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, 396, 781, 5541, 5541,
820, -1000, 651, -1000, -1000, -1000, 731, -1000, -1000, 233,
844, -1000, 6394, 84, -1000, 5541, 1741, 580, -1000, -1000,
580, -1000, -1000, 67, -1000, -1000, 5963, 5963, 5963, 5963,
9338, 471, 782, 26, 2807, 2807, 2807, 2807, -26, 2807,
2807, 674, -1000, -1000, -1000, -1000, 2807, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, 396, 792, 5541, 5541,
834, -1000, 585, -1000, -1000, -1000, 785, -1000, -1000, 233,
857, -1000, 6394, 84, -1000, 5541, 1741, 583, -1000, -1000,
583, -1000, -1000, 67, -1000, -1000, 5963, 5963, 5963, 5963,
5963, 5963, 5963, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, 580, -1000, 5321,
580, 580, 580, 580, 580, 580, 580, 580, 5541, 580,
580, 580, 580, 580, 580, 580, 580, 580, 580, 580,
580, 580, 8403, 517, 714, -1000, -1000, -1000, 804, 7036,
7630, 9338, 528, -1000, 570, 3972, -1000, -1000, -1000, 147,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, 583, -1000, 5321,
583, 583, 583, 583, 583, 583, 583, 583, 5541, 583,
583, 583, 583, 583, 583, 583, 583, 583, 583, 583,
583, 583, 8403, 517, 714, -1000, -1000, -1000, 810, 7036,
7630, 9338, 528, -1000, 575, 3972, -1000, -1000, -1000, 147,
7410, -1000, -1000, -1000, 774, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
@ -1619,112 +1619,112 @@ var yyPact = [...]int{
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 475, -1000,
1840, 460, 2807, 42, 637, 456, 170, 420, 9338, 9338,
2807, 27, 9338, 802, 672, 9338, 409, 407, -1000, 4205,
1840, 460, 2807, 42, 601, 456, 170, 420, 9338, 9338,
2807, 27, 9338, 806, 672, 9338, 409, 407, -1000, 4205,
-1000, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, -1000,
-1000, -1000, -1000, -1000, -1000, 2807, 2807, -1000, -1000, 9338,
-1000, -1000, -1000, -1000, 859, 114, 444, 83, 575, -1000,
382, 819, 396, 711, 7223, 683, -1000, -1000, 9338, -1000,
-1000, -1000, -1000, -1000, 862, 114, 444, 83, 579, -1000,
382, 820, 396, 761, 7223, 684, -1000, -1000, 9338, -1000,
5541, 5541, 329, -1000, 8191, -1000, -1000, 3273, 109, 5963,
347, 257, 5963, 5963, 5963, 5963, 5963, 5963, 5963, 5963,
5963, 5963, 5963, 5963, 5963, 5963, 5963, 269, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, 404, -1000, 651, 605,
-1000, -1000, -1000, -1000, -1000, -1000, 404, -1000, 585, 605,
605, 90, 90, 90, 90, 90, 90, 6174, 4658, 396,
469, 164, 5321, 5098, 5098, 5541, 5541, 9151, 9151, 5098,
806, 149, 164, 8964, -1000, 396, -1000, -1000, -1000, -1000,
812, 149, 164, 9151, -1000, 396, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, 5098, 5098, 5098, 5098, -8, 9338, -1000,
9151, 7817, 7817, 7817, 7817, 7817, -1000, 703, 700, -1000,
688, 686, 695, 9338, -1000, 467, 7036, 92, 580, -1000,
8004, -1000, -1000, -8, 508, 7817, 9338, -1000, -1000, 3972,
570, 5541, 74, -1000, -1000, -1000, -1000, 2574, 104, 231,
-116, -1000, -1000, -1000, 585, -1000, 585, 585, 585, 585,
-71, -71, -71, -71, -1000, -1000, -1000, -1000, -1000, 603,
595, -1000, 585, 585, 585, -1000, -1000, -1000, -1000, -1000,
9151, 7817, 7817, 7817, 7817, 7817, -1000, 703, 699, -1000,
695, 688, 709, 9338, -1000, 467, 7036, 92, 583, -1000,
8004, -1000, -1000, -8, 520, 7817, 9338, -1000, -1000, 3972,
575, 5541, 74, -1000, -1000, -1000, -1000, 2574, 104, 231,
-116, -1000, -1000, -1000, 587, -1000, 587, 587, 587, 587,
-71, -71, -71, -71, -1000, -1000, -1000, -1000, -1000, 654,
632, -1000, 587, 587, 587, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, 592, 592, 592, 586, 586, 658, -1000, 9338, -163,
398, 2807, 801, 2807, -1000, 106, -1000, 9338, -1000, -1000,
-1000, 603, 603, 603, 591, 591, 658, -1000, 9338, -163,
398, 2807, 804, 2807, -1000, 106, -1000, 9338, -1000, -1000,
9338, 2807, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 727,
5541, 5541, 3739, 5541, -1000, -1000, -1000, 781, -1000, 806,
818, -1000, 750, 747, 5098, -1000, -1000, 109, 145, -1000,
-1000, 239, -1000, -1000, -1000, -1000, 80, 580, -1000, 1863,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 710,
5541, 5541, 3739, 5541, -1000, -1000, -1000, 792, -1000, 812,
841, -1000, 747, 742, 5098, -1000, -1000, 109, 145, -1000,
-1000, 239, -1000, -1000, -1000, -1000, 80, 583, -1000, 1863,
-1000, -1000, -1000, -1000, 347, 5963, 5963, 5963, 221, 1863,
1816, 581, 1946, 90, 101, 101, 107, 107, 107, 107,
107, 597, 597, -1000, -1000, -1000, 396, -1000, -1000, -1000,
396, 5098, 568, -1000, -1000, 5541, -1000, 396, 464, 464,
318, 278, 674, -1000, 73, 647, 464, 5098, 218, -1000,
5541, 396, -1000, 464, 396, 464, 464, 535, 580, -1000,
599, -1000, 142, 714, 656, 666, 726, -1000, -1000, -1000,
-1000, 699, -1000, 690, -1000, -1000, -1000, -1000, -1000, 44,
38, 28, 8964, -1000, 840, 7817, 571, -1000, -1000, 164,
-1000, 389, 567, 2341, -1000, -1000, -1000, -1000, -1000, -1000,
591, 791, 127, 125, 374, -1000, -1000, 782, -1000, 176,
-119, -1000, -1000, 294, -71, -71, -1000, -1000, 74, 771,
1816, 581, 600, 90, 101, 101, 107, 107, 107, 107,
107, 879, 879, -1000, -1000, -1000, 396, -1000, -1000, -1000,
396, 5098, 571, -1000, -1000, 5541, -1000, 396, 464, 464,
318, 278, 678, -1000, 73, 636, 464, 5098, 218, -1000,
5541, 396, -1000, 464, 396, 464, 464, 698, 583, -1000,
576, -1000, 142, 714, 606, 666, 726, -1000, -1000, -1000,
-1000, 697, -1000, 686, -1000, -1000, -1000, -1000, -1000, 44,
38, 28, 8964, -1000, 854, 7817, 557, -1000, -1000, 164,
-1000, 389, 570, 2341, -1000, -1000, -1000, -1000, -1000, -1000,
595, 796, 127, 125, 374, -1000, -1000, 784, -1000, 176,
-119, -1000, -1000, 294, -71, -71, -1000, -1000, 74, 753,
74, 74, 74, 316, 316, -1000, -1000, -1000, -1000, 292,
-1000, -1000, -1000, 270, -1000, 663, 8964, 2807, -1000, 3506,
-1000, -1000, -1000, -1000, -1000, -1000, 816, 313, 137, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-9, -1000, 2807, -1000, 715, 164, 164, 71, -1000, -1000,
9338, -1000, -1000, -1000, -1000, 636, -1000, -1000, -1000, 3040,
-9, -1000, 2807, -1000, 728, 164, 164, 71, -1000, -1000,
9338, -1000, -1000, -1000, -1000, 529, -1000, -1000, -1000, 3040,
5098, -1000, 221, 1863, 1692, -1000, 5963, 5963, -1000, -1000,
464, 5098, 164, -1000, -1000, -1000, -18, 269, -18, 5963,
5963, 3739, 5963, 5963, -152, 576, 138, -1000, 5541, 433,
-1000, -1000, -1000, -1000, -1000, 662, 9151, 580, -1000, 6825,
8964, 820, 9151, 5541, 5541, -1000, -1000, 5541, 587, -1000,
5541, -1000, -1000, -1000, 580, 580, 580, 416, -1000, 820,
571, -1000, -1000, 2574, -1000, 2574, 8964, -1000, 348, 319,
5963, 3739, 5963, 5963, -152, 553, 138, -1000, 5541, 433,
-1000, -1000, -1000, -1000, -1000, 662, 9151, 583, -1000, 6825,
8964, 834, 9151, 5541, 5541, -1000, -1000, 5541, 592, -1000,
5541, -1000, -1000, -1000, 583, 583, 583, 416, -1000, 834,
557, -1000, -1000, 2574, -1000, 2574, 8964, -1000, 348, 319,
-1000, -1000, 660, 70, -1000, -1000, -1000, 470, 74, 74,
-1000, 196, -1000, -1000, -1000, 453, -1000, 451, 564, 446,
9338, -1000, -1000, 553, -1000, 130, -1000, -1000, 8964, -1000,
-1000, 196, -1000, -1000, -1000, 453, -1000, 451, 568, 446,
9338, -1000, -1000, 567, -1000, 130, -1000, -1000, 8964, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, 8964, 9338, -1000, -1000, -1000, -1000, -1000, 8964, -1000,
-1000, 3506, -1000, 840, 7817, -1000, -1000, 396, -1000, 5963,
1863, 1863, -1000, -1000, 396, 585, 585, -1000, 585, 586,
-1000, 585, -40, 585, -43, 396, 396, 1252, 1507, -1000,
392, 1464, 580, -149, -1000, 164, 5541, -1000, 793, 518,
520, -1000, -1000, 4878, 396, 426, 66, 416, 819, -1000,
-1000, 3506, -1000, 854, 7817, -1000, -1000, 396, -1000, 5963,
1863, 1863, -1000, -1000, 396, 587, 587, -1000, 587, 591,
-1000, 587, -40, 587, -43, 396, 396, 1252, 1507, -1000,
392, 1464, 583, -149, -1000, 164, 5541, -1000, 798, 511,
530, -1000, -1000, 4878, 396, 426, 66, 416, 820, -1000,
164, 164, 164, 8964, 164, 8964, 8964, 8964, 6614, 8964,
819, -1000, 2341, -1000, 402, -1000, 585, -1000, -1000, -109,
857, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
820, -1000, 2341, -1000, 402, -1000, 587, -1000, -1000, -109,
861, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -71, 310, -71, 265, -1000, 251, 2807, 3506,
2574, -1000, 583, -1000, -1000, -1000, -1000, 797, 837, 530,
2574, -1000, 586, -1000, -1000, -1000, -1000, 800, 842, 564,
-1000, 1863, -1000, -1000, 49, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, 5963, 5963, -1000, 5963, 5963, 5963,
396, 302, 164, 788, -1000, 580, -1000, -1000, 584, 8964,
396, 302, 164, 791, -1000, 583, -1000, -1000, 584, 8964,
8964, -1000, -1000, 395, -1000, 366, 366, 366, 92, -1000,
-1000, 86, 8964, -1000, 129, -1000, -131, 74, -1000, 74,
454, 403, -1000, -1000, -1000, 8964, 580, 835, 823, -1000,
-1000, 285, 285, 285, 285, 2, -1000, -1000, 851, -1000,
580, -1000, 651, 59, -1000, 8964, -1000, -1000, -1000, -1000,
-1000, 86, -1000, 315, 128, 301, -1000, 191, 787, -1000,
785, -1000, -1000, -1000, -1000, -1000, 361, -11, -1000, 5541,
5541, -1000, -1000, -1000, -1000, 396, 37, -167, 9151, 520,
454, 403, -1000, -1000, -1000, 8964, 583, 836, 823, -1000,
-1000, 285, 285, 285, 285, 2, -1000, -1000, 860, -1000,
583, -1000, 585, 59, -1000, 8964, -1000, -1000, -1000, -1000,
-1000, 86, -1000, 315, 128, 301, -1000, 191, 788, -1000,
787, -1000, -1000, -1000, -1000, -1000, 361, -11, -1000, 5541,
5541, -1000, -1000, -1000, -1000, 396, 37, -167, 9151, 530,
396, 8964, -1000, -1000, -1000, 240, -1000, -1000, -1000, 296,
-1000, -1000, 637, 354, -1000, 8964, 164, 513, -1000, 709,
-156, -170, 486, -1000, -1000, -1000, -1000, -163, -1000, -11,
742, -1000, 707, -1000, -1000, -1000, -17, -165, -19, -168,
580, -171, 5752, -1000, 285, 396, -1000, -1000,
-1000, -1000, 601, 354, -1000, 8964, 164, 513, -1000, 707,
-156, -170, 506, -1000, -1000, -1000, -1000, -163, -1000, -11,
731, -1000, 701, -1000, -1000, -1000, -17, -165, -19, -168,
583, -171, 5752, -1000, 285, 396, -1000, -1000,
}
var yyPgo = [...]int{
0, 1067, 24, 482, 1066, 1065, 1064, 1062, 1061, 1059,
1055, 1054, 1053, 1052, 1051, 1050, 1048, 1047, 1044, 1043,
1041, 1040, 1039, 1038, 87, 1036, 1035, 1033, 55, 1032,
57, 1031, 1028, 34, 41, 38, 31, 668, 1027, 27,
78, 51, 1025, 42, 1024, 1021, 60, 1018, 53, 1017,
1016, 1355, 1015, 1014, 12, 32, 1012, 1011, 1002, 1001,
63, 311, 1000, 999, 996, 994, 992, 991, 40, 5,
9, 8, 15, 990, 931, 17, 989, 43, 987, 986,
985, 984, 39, 981, 45, 980, 21, 44, 979, 10,
50, 22, 19, 7, 59, 978, 26, 49, 977, 295,
976, 120, 402, 975, 974, 973, 971, 28, 176, 464,
660, 52, 970, 968, 967, 1215, 58, 54, 14, 966,
29, 1264, 30, 965, 962, 33, 961, 959, 955, 953,
950, 948, 940, 253, 938, 923, 921, 16, 70, 917,
915, 46, 20, 912, 911, 906, 36, 47, 905, 37,
904, 903, 902, 899, 23, 18, 898, 11, 897, 6,
896, 895, 2, 885, 13, 884, 3, 880, 4, 35,
876, 874, 0, 117, 871, 870, 61,
0, 1082, 24, 482, 1081, 1080, 1078, 1077, 1076, 1075,
1074, 1073, 1070, 1069, 1068, 1067, 1066, 1065, 1064, 1062,
1061, 1059, 1055, 1054, 87, 1053, 1052, 1051, 55, 1050,
57, 1048, 1047, 34, 41, 38, 31, 668, 1044, 27,
78, 51, 1043, 42, 1041, 1040, 60, 1039, 53, 1038,
1036, 1355, 1035, 1033, 12, 32, 1032, 1031, 1028, 1027,
63, 311, 1025, 1024, 1021, 1018, 1017, 1016, 40, 5,
9, 8, 15, 1015, 931, 17, 1014, 43, 1012, 1011,
1002, 1001, 39, 1000, 45, 999, 21, 44, 996, 10,
50, 22, 19, 7, 59, 994, 26, 49, 992, 295,
991, 120, 402, 990, 989, 987, 986, 28, 176, 464,
660, 52, 985, 973, 971, 1215, 58, 54, 14, 970,
29, 1264, 30, 968, 967, 33, 966, 965, 962, 961,
959, 955, 953, 253, 950, 948, 940, 16, 70, 938,
923, 46, 20, 921, 917, 915, 36, 47, 912, 37,
911, 906, 905, 904, 23, 18, 903, 11, 902, 6,
899, 898, 2, 897, 13, 896, 3, 895, 4, 35,
885, 884, 0, 117, 880, 876, 61,
}
var yyR1 = [...]int{
@ -1960,7 +1960,7 @@ var yyChk = [...]int{
-61, -61, -61, -122, 56, 58, 56, -60, -60, -109,
-35, 21, -34, -36, -173, 54, -173, -2, -34, -34,
-37, -37, -75, -109, -115, -75, -34, -28, -76, -77,
76, -109, -173, -34, -35, -34, -34, -90, 142, -51,
76, -75, -173, -34, -35, -34, -34, -90, 142, -51,
-93, -96, -75, -40, -41, -41, -40, -41, 41, 41,
41, 46, 41, 46, 41, -48, -115, -173, -54, 49,
123, 50, -172, -117, -90, 52, -39, -51, -97, -37,
@ -4927,7 +4927,7 @@ yydefault:
yyDollar = yyS[yypt-4 : yypt+1]
//line sql.y:2185
{
yyVAL.expr = &ValuesFuncExpr{Name: yyDollar[3].colIdent}
yyVAL.expr = &ValuesFuncExpr{Name: yyDollar[3].colName}
}
case 424:
yyDollar = yyS[yypt-2 : yypt+1]

Просмотреть файл

@ -2181,7 +2181,7 @@ function_call_keyword:
{
$$ = &CaseExpr{Expr: $2, Whens: $3, Else: $4}
}
| VALUES openb sql_id closeb
| VALUES openb column_name closeb
{
$$ = &ValuesFuncExpr{Name: $3}
}

Просмотреть файл

@ -240,7 +240,7 @@ func isVindexChanging(setClauses sqlparser.UpdateExprs, colVindexes []*vindexes.
return true
}
// update on duplicate key is changing the vindex column, not supported.
if !valueExpr.Name.Equal(assignment.Name.Name) {
if !valueExpr.Name.Name.Equal(assignment.Name.Name) {
return true
}
}

Просмотреть файл

@ -432,7 +432,13 @@ func analyzeInsertNoType(ins *sqlparser.Insert, plan *Plan, table *schema.Table)
var formatErr error
plan.UpsertQuery = GenerateUpdateOuterQuery(upd, tableAlias, func(buf *sqlparser.TrackedBuffer, node sqlparser.SQLNode) {
if node, ok := node.(*sqlparser.ValuesFuncExpr); ok {
colnum := ins.Columns.FindColumn(node.Name)
if !node.Name.Qualifier.IsEmpty() && node.Name.Qualifier != ins.Table {
formatErr = vterrors.Errorf(vtrpcpb.Code_NOT_FOUND,
"could not find qualified column %v in table %v",
sqlparser.String(node.Name), sqlparser.String(ins.Table))
return
}
colnum := ins.Columns.FindColumn(node.Name.Name)
if colnum == -1 {
formatErr = vterrors.Errorf(vtrpcpb.Code_NOT_FOUND, "could not find column %v", node.Name)
return
@ -588,7 +594,10 @@ func analyzeOnDupExpressions(ins *sqlparser.Insert, pkIndex *schema.Index) (pkVa
pkValues = make([]sqltypes.PlanValue, len(pkIndex.Columns))
}
if vf, ok := expr.Expr.(*sqlparser.ValuesFuncExpr); ok {
insertCol := ins.Columns.FindColumn(vf.Name)
if !vf.Name.Qualifier.IsEmpty() && vf.Name.Qualifier != ins.Table {
return nil, false
}
insertCol := ins.Columns.FindColumn(vf.Name.Name)
if insertCol == -1 {
return nil, false
}