File: json_gcol_innodb.result

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (448 lines) | stat: -rw-r--r-- 17,389 bytes parent folder | download
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
set default_storage_engine=innodb;
CREATE TABLE t(
j JSON,
stored_gc JSON GENERATED ALWAYS AS (JSON_EXTRACT(j, '$[0]')) STORED,
virtual_gc JSON GENERATED ALWAYS AS (JSON_EXTRACT(j, '$[1]')) VIRTUAL);
INSERT INTO t(j) VALUES
(JSON_ARRAY(1, 2)), (JSON_ARRAY(2, 1)), (JSON_ARRAY(10, 10)), (JSON_ARRAY(5));
SELECT * FROM t ORDER BY stored_gc;
j	stored_gc	virtual_gc
[1, 2]	1	2
[2, 1]	2	1
[5]	5	NULL
[10, 10]	10	10
SELECT * FROM t ORDER BY virtual_gc;
j	stored_gc	virtual_gc
[5]	5	NULL
[2, 1]	2	1
[1, 2]	1	2
[10, 10]	10	10
DROP TABLE t;
# ----------------------------------------------------------------------
# Test of generated columns that call JSON functions
# ----------------------------------------------------------------------
CREATE TABLE t(id INT, j JSON,
gc INT GENERATED ALWAYS AS (JSON_EXTRACT(j, '$[0]')));
INSERT INTO t(id, j) VALUES (0, '"5"'), (1, '[]'), (2, '[1,2]'), (3, '5');
INSERT INTO t(j) VALUES ('{}');
ERROR 22018: Invalid JSON value for CAST to INTEGER from column json_extract at row 1
INSERT INTO t(j) VALUES ('{"a":1}');
ERROR 22018: Invalid JSON value for CAST to INTEGER from column json_extract at row 1
INSERT INTO t(j) VALUES ('"abc"');
ERROR 22018: Invalid JSON value for CAST to INTEGER from column json_extract at row 1
INSERT INTO t(j) VALUES ('');
ERROR 22032: Invalid JSON text: "The document is empty." at position 0 in value for column 't.j'.
INSERT INTO t(j) VALUES ('[');
ERROR 22032: Invalid JSON text: "Invalid value." at position 1 in value for column 't.j'.
SELECT * FROM t ORDER BY id;
id	j	gc
0	"5"	5
1	[]	NULL
2	[1, 2]	1
3	5	5
UPDATE t SET j = '[123]';
SELECT * FROM t ORDER BY id;
id	j	gc
0	[123]	123
1	[123]	123
2	[123]	123
3	[123]	123
UPDATE t SET j = '[';
ERROR 22032: Invalid JSON text: "Invalid value." at position 1 in value for column 't.j'.
DROP TABLE t;
CREATE TABLE t(id INT, j JSON,
gc JSON GENERATED ALWAYS AS (JSON_ARRAY(j)));
INSERT INTO t(id, j)
VALUES (1, '1'), (2, '[true, false]'), (3, '{"a":1,"b":2}');
INSERT INTO t(j) VALUES ('');
ERROR 22032: Invalid JSON text: "The document is empty." at position 0 in value for column 't.j'.
INSERT INTO t(j) VALUES ('[');
ERROR 22032: Invalid JSON text: "Invalid value." at position 1 in value for column 't.j'.
SELECT * FROM t ORDER BY id;
id	j	gc
1	1	[1]
2	[true, false]	[[true, false]]
3	{"a": 1, "b": 2}	[{"a": 1, "b": 2}]
UPDATE t SET j = '"abc"';
SELECT * FROM t ORDER BY id;
id	j	gc
1	"abc"	["abc"]
2	"abc"	["abc"]
3	"abc"	["abc"]
UPDATE t SET j = '[';
ERROR 22032: Invalid JSON text: "Invalid value." at position 1 in value for column 't.j'.
DROP TABLE t;
CREATE TABLE t(ts TIMESTAMP, j JSON AS (CAST(ts AS JSON)));
INSERT INTO t(ts) VALUES ('2000-01-01 00:00:00');
SELECT CAST(JSON_ARRAY(ts, j) AS CHAR) FROM t;
CAST(JSON_ARRAY(ts, j) AS CHAR)
["2000-01-01 00:00:00.000000", "2000-01-01 00:00:00.000000"]
DROP TABLE t;
#
# Bug#21491442 VARIANT::FORCED_RETURN() [WITH T = JSON_SCALAR*]:
#              ASSERTION `FALSE' FAILED.
#
create table t (a json, b blob,
c int generated always as (1!=a) virtual not null) engine=innodb;
insert into t(a) values('[1]');
insert into t(a) values('[1]');
select a,c from t;
a	c
[1]	1
[1]	1
prepare ps1 from 'insert into t(a) values(?)';
set @a='[1]';
execute ps1 using @a;
execute ps1 using @a;
select a,c from t;
a	c
[1]	1
[1]	1
[1]	1
[1]	1
drop table t;
create temporary table t (a json, b blob,
c int generated always as (1!=a) virtual not null) engine=innodb;
insert into t(a) values('[1]');
insert into t(a) values('[1]');
select a,c from t;
a	c
[1]	1
[1]	1
prepare ps1 from 'insert into t(a) values(?)';
set @a='[1]';
execute ps1 using @a;
execute ps1 using @a;
select a,c from t;
a	c
[1]	1
[1]	1
[1]	1
[1]	1
drop table t;
#
# WL#8170: Expression analyzer for GC.
# Queries with GC and JSON_EXTRACT  compared to strings should use index
#
create table t1(
f1 json,
gc varchar(20) character set utf8mb4 as
(json_unquote(json_extract(f1,"$"))) stored,
key gc_idx(gc));
insert into t1(f1) values ('"qwe"'),('"rty"'),('"uiop"');
insert into t1(f1) values ('"zxc"'),('"vbn"'),('"mnb"');
insert into t1(f1) select f1 from t1;
insert into t1(f1) select f1 from t1;
insert into t1(f1) values ('"asd"'),('"asdf"'),('"asasas"');
set @save_opt_sw= @@optimizer_switch;
set @@optimizer_switch="index_condition_pushdown=off";
set @string_literal='asd';
select f1 from t1 where gc = "asd";
f1
"asd"
explain select f1 from t1 where gc = "asd";
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ref	gc_idx	gc_idx	83	const	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` = 'asd')
select f1 from t1 where gc = @string_literal;
f1
"asd"
explain select f1 from t1 where gc = @string_literal;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ref	gc_idx	gc_idx	83	const	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` = (@`string_literal`))
select f1 from t1 where json_extract(f1,"$") = "asd";
f1
"asd"
explain select f1 from t1 where json_extract(f1,"$") = "asd";
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ref	gc_idx	gc_idx	83	const	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` = 'asd')
select f1 from t1 where json_extract(f1,"$") = @string_literal;
f1
"asd"
explain select f1 from t1 where json_extract(f1,"$") = @string_literal;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ref	gc_idx	gc_idx	83	const	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` = (@`string_literal`))
select f1 from t1 where "asd" = json_extract(f1,"$");
f1
"asd"
explain select f1 from t1 where "asd" = json_extract(f1,"$");
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ref	gc_idx	gc_idx	83	const	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ('asd' = `test`.`t1`.`gc`)
select f1 from t1 where @string_literal = json_extract(f1,"$");
f1
"asd"
explain select f1 from t1 where @string_literal = json_extract(f1,"$");
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ref	gc_idx	gc_idx	83	const	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((@`string_literal`) = `test`.`t1`.`gc`)
set @string_literal = 'z';
select f1 from t1 where gc > "z";
f1
"zxc"
"zxc"
"zxc"
"zxc"
explain select f1 from t1 where gc > "z";
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` > 'z')
select f1 from t1 where gc > @string_literal;
f1
"zxc"
"zxc"
"zxc"
"zxc"
explain select f1 from t1 where gc > @string_literal;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` > <cache>((@`string_literal`)))
select f1 from t1 where json_extract(f1,"$") > "z";
f1
"zxc"
"zxc"
"zxc"
"zxc"
explain select f1 from t1 where json_extract(f1,"$") > "z";
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` > 'z')
select f1 from t1 where json_extract(f1,"$") > @string_literal;
f1
"zxc"
"zxc"
"zxc"
"zxc"
explain select f1 from t1 where json_extract(f1,"$") > @string_literal;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` > <cache>((@`string_literal`)))
set @string_lo = 'v';
set @string_hi = 'z';
select f1 from t1 where gc > "v" and gc < "z";
f1
"vbn"
"vbn"
"vbn"
"vbn"
explain select f1 from t1 where gc > "v" and gc < "z";
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`gc` > 'v') and (`test`.`t1`.`gc` < 'z'))
select f1 from t1 where gc > @string_lo and gc < @string_hi;
f1
"vbn"
"vbn"
"vbn"
"vbn"
explain select f1 from t1 where gc > @string_lo and gc < @string_hi;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`gc` > <cache>((@`string_lo`))) and (`test`.`t1`.`gc` < <cache>((@`string_hi`))))
select f1 from t1
where json_extract(f1,"$") > "v" and json_extract(f1,"$") < "z";
f1
"vbn"
"vbn"
"vbn"
"vbn"
select f1 from t1
where json_extract(f1,"$") > @string_lo and json_extract(f1,"$") < @string_hi;
f1
"vbn"
"vbn"
"vbn"
"vbn"
explain
select f1 from t1
where json_extract(f1,"$") > @string_lo and json_extract(f1,"$") < @string_hi;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`gc` > <cache>((@`string_lo`))) and (`test`.`t1`.`gc` < <cache>((@`string_hi`))))
select f1 from t1 where gc between "v" and "z";
f1
"vbn"
"vbn"
"vbn"
"vbn"
explain select f1 from t1 where gc between "v" and "z";
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` between 'v' and 'z')
select f1 from t1 where gc between @string_lo and @string_hi;
f1
"vbn"
"vbn"
"vbn"
"vbn"
explain select f1 from t1 where gc between @string_lo and @string_hi;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` between <cache>((@`string_lo`)) and <cache>((@`string_hi`)))
select f1 from t1 where json_extract(f1,"$") between "v" and "z";
f1
"vbn"
"vbn"
"vbn"
"vbn"
Warning	1235	This version of MySQL doesn't yet support 'comparison of JSON in the BETWEEN operator'
Warnings:
explain select f1 from t1 where json_extract(f1,"$") between "v" and "z";
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	4	100.00	Using where
Warnings:
Warning	1235	This version of MySQL doesn't yet support 'comparison of JSON in the BETWEEN operator'
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` between 'v' and 'z')
select f1 from t1 where json_extract(f1,"$") between @string_lo and @string_hi;
f1
"vbn"
"vbn"
"vbn"
"vbn"
Warning	1235	This version of MySQL doesn't yet support 'comparison of JSON in the BETWEEN operator'
Warnings:
explain
select f1 from t1 where json_extract(f1,"$") between @string_lo and @string_hi;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	4	100.00	Using where
Warnings:
Warning	1235	This version of MySQL doesn't yet support 'comparison of JSON in the BETWEEN operator'
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` between <cache>((@`string_lo`)) and <cache>((@`string_hi`)))
set @string_1 = 'asd';
set @string_2 = 'asasas';
set @string_3 = 'asdf';
select f1 from t1 where gc in ("asd","asasas","asdf");
f1
"asasas"
"asd"
"asdf"
explain select f1 from t1 where gc in ("asd","asasas","asdf");
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	3	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` in ('asd','asasas','asdf'))
select f1 from t1 where gc in (@string_1, @string_2, @string_3);
f1
"asasas"
"asd"
"asdf"
explain select f1 from t1 where gc in (@string_1, @string_2, @string_3);
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	3	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` in (<cache>((@`string_1`)),<cache>((@`string_2`)),<cache>((@`string_3`))))
select f1 from t1 where json_extract(f1,"$") in ("asd","asasas","asdf");
f1
"asasas"
"asd"
"asdf"
explain select f1 from t1 where json_extract(f1,"$") in ("asd","asasas","asdf");
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	3	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` in ('asd','asasas','asdf'))
select f1 from t1
where json_extract(f1,"$") in (@string_1, @string_2, @string_3);
f1
"asasas"
"asd"
"asdf"
explain
select f1 from t1
where json_extract(f1,"$") in (@string_1, @string_2, @string_3);
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	gc_idx	gc_idx	83	NULL	3	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` in (<cache>((@`string_1`)),<cache>((@`string_2`)),<cache>((@`string_3`))))
select f1 from t1 where json_unquote(json_extract(f1,"$")) = "asd";
f1
"asd"
explain select f1 from t1 where json_unquote(json_extract(f1,"$")) = "asd";
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ref	gc_idx	gc_idx	83	const	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` = 'asd')
select f1 from t1 where json_unquote(json_extract(f1,"$")) = @string_literal;
f1
explain
select f1 from t1 where json_unquote(json_extract(f1,"$")) = @string_literal;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ref	gc_idx	gc_idx	83	const	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`gc` = (@`string_literal`))
set @@optimizer_switch= @save_opt_sw;
drop table t1;
create table t1(f1 varchar(10), gc varchar(10) as (json_unquote(f1)) stored,
key gc_idx(gc));
insert into t1(f1) values ('"qwe"'),('"rty"'),('"uiop"');
select f1 from t1 where lower(f1)="qwe";
f1
drop table t1;
#
#
# Bug#21054516:QUERY HAVING SQL_BIG_RESULT ON JSON DATA GIVES EXTRA
#              ROWS IN OUTPUT
#
CREATE TABLE t1 (
pk integer auto_increment key,
col_varchar_255_utf8_key varchar(255)  CHARACTER SET utf8
);
Warnings:
Warning	3719	'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
INSERT INTO t1 VALUES (NULL, 'q') , (NULL, 'tgzvsj') ,
(NULL, 'b') , (NULL, 'q') , (NULL, 'up') , (NULL, 'up') ;
ALTER TABLE t1 ADD COLUMN json_varchar255_utf8_key json;
UPDATE t1 SET json_varchar255_utf8_key =
JSON_OBJECT('col_varchar_255_utf8_key', col_varchar_255_utf8_key);
ALTER TABLE t1 MODIFY col_varchar_255_utf8_key VARCHAR(255)
GENERATED ALWAYS AS
(JSON_EXTRACT(json_varchar255_utf8_key,'$.col_varchar_255_utf8_key[0]'))
STORED;
SELECT SQL_BIG_RESULT table1.json_varchar255_utf8_key AS field1, count(*)
FROM t1 AS table1 LEFT JOIN t1 AS table2 ON table1.pk <= table2.pk
GROUP  BY field1;
field1	count(*)
{"col_varchar_255_utf8_key": "up"}	3
{"col_varchar_255_utf8_key": "q"}	9
{"col_varchar_255_utf8_key": "b"}	4
{"col_varchar_255_utf8_key": "tgzvsj"}	5
Warnings:
Warning	1235	This version of MySQL doesn't yet support 'sorting of non-scalar JSON values'
DROP TABLE t1;
#
# Bug#26352119: WHERE JSON_EXTRACT() ON GEN KEY
#
SET NAMES utf8mb4 COLLATE utf8mb4_ja_0900_as_cs;
CREATE TABLE t1 (j JSON, pk VARCHAR(10) AS (j->>'$.id') STORED PRIMARY KEY);
INSERT INTO t1 (j) VALUES ('{"id":"a"}'), ('{"id":"b"}'), ('{"id":"c"}');
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
EXPLAIN SELECT * FROM t1 WHERE j->>'$.id'='b';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	const	PRIMARY	PRIMARY	42	const	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select '{"id": "b"}' AS `j`,'b' AS `pk` from `test`.`t1` where true
SELECT * FROM t1 WHERE j->>'$.id'='b';
j	pk
{"id": "b"}	b
DROP TABLE t1;
SET NAMES DEFAULT;