Skip to content

Commit 8ff3a88

Browse files
Merge branch 'master' of https://github.com/github/vitess-gh into merge-upstream-v15.0.3
2 parents 5c37b15 + a5fb1dc commit 8ff3a88

File tree

11 files changed

+854
-112
lines changed

11 files changed

+854
-112
lines changed

go/test/endtoend/vtgate/vindex_bindvars/main_test.go

Lines changed: 162 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ var (
4141
id BIGINT NOT NULL,
4242
field BIGINT NOT NULL,
4343
field2 BIGINT,
44+
field3 BIGINT,
45+
field4 BIGINT,
46+
field5 BIGINT,
47+
field6 BIGINT,
4448
PRIMARY KEY (id)
4549
) ENGINE=Innodb;
4650
@@ -56,6 +60,30 @@ CREATE TABLE lookup2 (
5660
UNIQUE KEY (field2)
5761
) ENGINE=Innodb;
5862
63+
CREATE TABLE lookup3 (
64+
field3 BIGINT NOT NULL,
65+
keyspace_id binary(8),
66+
UNIQUE KEY (field3)
67+
) ENGINE=Innodb;
68+
69+
CREATE TABLE lookup4 (
70+
field4 BIGINT NOT NULL,
71+
keyspace_id binary(8),
72+
UNIQUE KEY (field4)
73+
) ENGINE=Innodb;
74+
75+
CREATE TABLE lookup5 (
76+
field5 BIGINT NOT NULL,
77+
keyspace_id binary(8),
78+
UNIQUE KEY (field5)
79+
) ENGINE=Innodb;
80+
81+
CREATE TABLE lookup6 (
82+
field6 BIGINT NOT NULL,
83+
keyspace_id binary(8),
84+
UNIQUE KEY (field6)
85+
) ENGINE=Innodb;
86+
5987
CREATE TABLE thex (
6088
id VARBINARY(64) NOT NULL,
6189
field BIGINT NOT NULL,
@@ -88,7 +116,7 @@ CREATE TABLE thex (
88116
"table": "lookup1",
89117
"from": "field",
90118
"to": "keyspace_id",
91-
"ignore_nulls": "true"
119+
"ignore_nulls": "true"
92120
},
93121
"owner": "t1"
94122
},
@@ -98,7 +126,47 @@ CREATE TABLE thex (
98126
"table": "lookup2",
99127
"from": "field2",
100128
"to": "keyspace_id",
101-
"ignore_nulls": "true"
129+
"ignore_nulls": "true"
130+
},
131+
"owner": "t1"
132+
},
133+
"lookup3": {
134+
"type": "lookup",
135+
"params": {
136+
"from": "field3",
137+
"no_verify": "true",
138+
"table": "lookup3",
139+
"to": "keyspace_id"
140+
},
141+
"owner": "t1"
142+
},
143+
"lookup4": {
144+
"type": "lookup",
145+
"params": {
146+
"from": "field4",
147+
"read_lock": "exclusive",
148+
"table": "lookup4",
149+
"to": "keyspace_id"
150+
},
151+
"owner": "t1"
152+
},
153+
"lookup5": {
154+
"type": "lookup",
155+
"params": {
156+
"from": "field5",
157+
"read_lock": "shared",
158+
"table": "lookup5",
159+
"to": "keyspace_id"
160+
},
161+
"owner": "t1"
162+
},
163+
"lookup6": {
164+
"type": "lookup",
165+
"params": {
166+
"from": "field6",
167+
"read_lock": "none",
168+
"table": "lookup6",
169+
"to": "keyspace_id"
102170
},
103171
"owner": "t1"
104172
}
@@ -117,6 +185,22 @@ CREATE TABLE thex (
117185
{
118186
"column": "field2",
119187
"name": "lookup2"
188+
},
189+
{
190+
"column": "field3",
191+
"name": "lookup3"
192+
},
193+
{
194+
"column": "field4",
195+
"name": "lookup4"
196+
},
197+
{
198+
"column": "field5",
199+
"name": "lookup5"
200+
},
201+
{
202+
"column": "field6",
203+
"name": "lookup6"
120204
}
121205
]
122206
},
@@ -136,6 +220,38 @@ CREATE TABLE thex (
136220
}
137221
]
138222
},
223+
"lookup3": {
224+
"column_vindexes": [
225+
{
226+
"column": "field3",
227+
"name": "binary_md5_vdx"
228+
}
229+
]
230+
},
231+
"lookup4": {
232+
"column_vindexes": [
233+
{
234+
"column": "field4",
235+
"name": "binary_md5_vdx"
236+
}
237+
]
238+
},
239+
"lookup5": {
240+
"column_vindexes": [
241+
{
242+
"column": "field5",
243+
"name": "binary_md5_vdx"
244+
}
245+
]
246+
},
247+
"lookup6": {
248+
"column_vindexes": [
249+
{
250+
"column": "field6",
251+
"name": "binary_md5_vdx"
252+
}
253+
]
254+
},
139255
"thex": {
140256
"column_vindexes": [
141257
{
@@ -216,51 +332,51 @@ func TestVindexBindVarOverlap(t *testing.T) {
216332
require.Nil(t, err)
217333
defer conn.Close()
218334

219-
utils.Exec(t, conn, "INSERT INTO t1 (id, field, field2) VALUES "+
220-
"(0,1,2), "+
221-
"(1,2,3), "+
222-
"(2,3,4), "+
223-
"(3,4,5), "+
224-
"(4,5,6), "+
225-
"(5,6,7), "+
226-
"(6,7,8), "+
227-
"(7,8,9), "+
228-
"(8,9,10), "+
229-
"(9,10,11), "+
230-
"(10,11,12), "+
231-
"(11,12,13), "+
232-
"(12,13,14), "+
233-
"(13,14,15), "+
234-
"(14,15,16), "+
235-
"(15,16,17), "+
236-
"(16,17,18), "+
237-
"(17,18,19), "+
238-
"(18,19,20), "+
239-
"(19,20,21), "+
240-
"(20,21,22)")
241-
result := utils.Exec(t, conn, "select id, field, field2 from t1 order by id")
335+
utils.Exec(t, conn, "INSERT INTO t1 (id, field, field2, field3, field4, field5, field6) VALUES "+
336+
"(0,1,2,3,4,5,6), "+
337+
"(1,2,3,4,5,6,7), "+
338+
"(2,3,4,5,6,7,8), "+
339+
"(3,4,5,6,7,8,9), "+
340+
"(4,5,6,7,8,9,10), "+
341+
"(5,6,7,8,9,10,11), "+
342+
"(6,7,8,9,10,11,12), "+
343+
"(7,8,9,10,11,12,13), "+
344+
"(8,9,10,11,12,13,14), "+
345+
"(9,10,11,12,13,14,15), "+
346+
"(10,11,12,13,14,15,16), "+
347+
"(11,12,13,14,15,16,17), "+
348+
"(12,13,14,15,16,17,18), "+
349+
"(13,14,15,16,17,18,19), "+
350+
"(14,15,16,17,18,19,20), "+
351+
"(15,16,17,18,19,20,21), "+
352+
"(16,17,18,19,20,21,22), "+
353+
"(17,18,19,20,21,22,23), "+
354+
"(18,19,20,21,22,23,24), "+
355+
"(19,20,21,22,23,24,25), "+
356+
"(20,21,22,23,24,25,26)")
357+
result := utils.Exec(t, conn, "select id, field, field2, field3, field4, field5, field6 from t1 order by id")
242358

243359
expected :=
244-
"[[INT64(0) INT64(1) INT64(2)] " +
245-
"[INT64(1) INT64(2) INT64(3)] " +
246-
"[INT64(2) INT64(3) INT64(4)] " +
247-
"[INT64(3) INT64(4) INT64(5)] " +
248-
"[INT64(4) INT64(5) INT64(6)] " +
249-
"[INT64(5) INT64(6) INT64(7)] " +
250-
"[INT64(6) INT64(7) INT64(8)] " +
251-
"[INT64(7) INT64(8) INT64(9)] " +
252-
"[INT64(8) INT64(9) INT64(10)] " +
253-
"[INT64(9) INT64(10) INT64(11)] " +
254-
"[INT64(10) INT64(11) INT64(12)] " +
255-
"[INT64(11) INT64(12) INT64(13)] " +
256-
"[INT64(12) INT64(13) INT64(14)] " +
257-
"[INT64(13) INT64(14) INT64(15)] " +
258-
"[INT64(14) INT64(15) INT64(16)] " +
259-
"[INT64(15) INT64(16) INT64(17)] " +
260-
"[INT64(16) INT64(17) INT64(18)] " +
261-
"[INT64(17) INT64(18) INT64(19)] " +
262-
"[INT64(18) INT64(19) INT64(20)] " +
263-
"[INT64(19) INT64(20) INT64(21)] " +
264-
"[INT64(20) INT64(21) INT64(22)]]"
360+
"[[INT64(0) INT64(1) INT64(2) INT64(3) INT64(4) INT64(5) INT64(6)] " +
361+
"[INT64(1) INT64(2) INT64(3) INT64(4) INT64(5) INT64(6) INT64(7)] " +
362+
"[INT64(2) INT64(3) INT64(4) INT64(5) INT64(6) INT64(7) INT64(8)] " +
363+
"[INT64(3) INT64(4) INT64(5) INT64(6) INT64(7) INT64(8) INT64(9)] " +
364+
"[INT64(4) INT64(5) INT64(6) INT64(7) INT64(8) INT64(9) INT64(10)] " +
365+
"[INT64(5) INT64(6) INT64(7) INT64(8) INT64(9) INT64(10) INT64(11)] " +
366+
"[INT64(6) INT64(7) INT64(8) INT64(9) INT64(10) INT64(11) INT64(12)] " +
367+
"[INT64(7) INT64(8) INT64(9) INT64(10) INT64(11) INT64(12) INT64(13)] " +
368+
"[INT64(8) INT64(9) INT64(10) INT64(11) INT64(12) INT64(13) INT64(14)] " +
369+
"[INT64(9) INT64(10) INT64(11) INT64(12) INT64(13) INT64(14) INT64(15)] " +
370+
"[INT64(10) INT64(11) INT64(12) INT64(13) INT64(14) INT64(15) INT64(16)] " +
371+
"[INT64(11) INT64(12) INT64(13) INT64(14) INT64(15) INT64(16) INT64(17)] " +
372+
"[INT64(12) INT64(13) INT64(14) INT64(15) INT64(16) INT64(17) INT64(18)] " +
373+
"[INT64(13) INT64(14) INT64(15) INT64(16) INT64(17) INT64(18) INT64(19)] " +
374+
"[INT64(14) INT64(15) INT64(16) INT64(17) INT64(18) INT64(19) INT64(20)] " +
375+
"[INT64(15) INT64(16) INT64(17) INT64(18) INT64(19) INT64(20) INT64(21)] " +
376+
"[INT64(16) INT64(17) INT64(18) INT64(19) INT64(20) INT64(21) INT64(22)] " +
377+
"[INT64(17) INT64(18) INT64(19) INT64(20) INT64(21) INT64(22) INT64(23)] " +
378+
"[INT64(18) INT64(19) INT64(20) INT64(21) INT64(22) INT64(23) INT64(24)] " +
379+
"[INT64(19) INT64(20) INT64(21) INT64(22) INT64(23) INT64(24) INT64(25)] " +
380+
"[INT64(20) INT64(21) INT64(22) INT64(23) INT64(24) INT64(25) INT64(26)]]"
265381
assert.Equal(t, expected, fmt.Sprintf("%v", result.Rows))
266382
}

go/vt/vtexplain/testdata/test-schema.sql

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,27 @@ CREATE TABLE orders_id_lookup (
111111
keyspace_id varbinary(128),
112112
primary key(id)
113113
);
114+
115+
CREATE TABLE orders_id_lookup_exclusive_read_lock (
116+
id int NOT NULL,
117+
keyspace_id varbinary(128),
118+
primary key(id)
119+
);
120+
121+
CREATE TABLE orders_id_lookup_shared_read_lock (
122+
id int NOT NULL,
123+
keyspace_id varbinary(128),
124+
primary key(id)
125+
);
126+
127+
CREATE TABLE orders_id_lookup_no_read_lock (
128+
id int NOT NULL,
129+
keyspace_id varbinary(128),
130+
primary key(id)
131+
);
132+
133+
CREATE TABLE orders_id_lookup_no_verify (
134+
id int NOT NULL,
135+
keyspace_id varbinary(128),
136+
primary key(id)
137+
);

go/vt/vtexplain/testdata/test-vschema.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,46 @@
1919
},
2020
"owner": "orders"
2121
},
22+
"orders_id_vdx_exclusive_read_lock": {
23+
"type": "lookup_unique",
24+
"params": {
25+
"table": "orders_id_lookup_exclusive_read_lock",
26+
"from": "id",
27+
"to": "keyspace_id",
28+
"read_lock": "exclusive"
29+
},
30+
"owner": "orders"
31+
},
32+
"orders_id_vdx_shared_read_lock": {
33+
"type": "lookup_unique",
34+
"params": {
35+
"table": "orders_id_lookup_shared_read_lock",
36+
"from": "id",
37+
"to": "keyspace_id",
38+
"read_lock": "shared"
39+
},
40+
"owner": "orders"
41+
},
42+
"orders_id_vdx_no_read_lock": {
43+
"type": "lookup_unique",
44+
"params": {
45+
"table": "orders_id_lookup_no_read_lock",
46+
"from": "id",
47+
"to": "keyspace_id",
48+
"read_lock": "none"
49+
},
50+
"owner": "orders"
51+
},
52+
"orders_id_vdx_no_verify": {
53+
"type": "lookup_unique",
54+
"params": {
55+
"table": "orders_id_lookup_no_verify",
56+
"from": "id",
57+
"to": "keyspace_id",
58+
"no_verify": "true"
59+
},
60+
"owner": "orders"
61+
},
2262
"music_user_map": {
2363
"type": "lookup_hash_unique",
2464
"owner": "music",
@@ -165,6 +205,22 @@
165205
}
166206
]
167207
},
208+
"orders_id_lookup_no_read_lock": {
209+
"column_vindexes": [
210+
{
211+
"column": "id",
212+
"name": "hash"
213+
}
214+
]
215+
},
216+
"orders_id_lookup_no_verify": {
217+
"column_vindexes": [
218+
{
219+
"column": "id",
220+
"name": "hash"
221+
}
222+
]
223+
},
168224
"email_customer_map": {
169225
"column_vindexes": [
170226
{

0 commit comments

Comments
 (0)