| 1 |
create table t1 (f1 int primary key, j json, vjhi int as (json_unquote(j->'$.Year')) virtual); |
| 2 |
show create table t1; |
| 3 |
Table Create Table |
| 4 |
t1 CREATE TABLE `t1` ( |
| 5 |
`f1` int NOT NULL, |
| 6 |
`j` json DEFAULT NULL, |
| 7 |
`vjhi` int GENERATED ALWAYS AS (json_unquote(json_extract(`j`,_utf8mb4'$.Year'))) VIRTUAL, |
| 8 |
PRIMARY KEY (`f1`) |
| 9 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
| 10 |
select f1, vjhi from t1 order by f1; |
| 11 |
f1 vjhi |
| 12 |
1 2009 |
| 13 |
# Connection default: |
| 14 |
start transaction with consistent snapshot; |
| 15 |
select f1, vjhi from t1 order by f1; |
| 16 |
f1 vjhi |
| 17 |
1 2009 |
| 18 |
# Connection con1: |
| 19 |
start transaction; |
| 20 |
UPDATE t1 SET j = JSON_SET(j, '$.Year', '2010'); |
| 21 |
select f1, vjhi from t1 order by f1; |
| 22 |
f1 vjhi |
| 23 |
1 2010 |
| 24 |
# Connection default: |
| 25 |
select f1, vjhi from t1 order by f1; |
| 26 |
f1 vjhi |
| 27 |
1 2009 |
| 28 |
# Connection con1: |
| 29 |
commit; |
| 30 |
# Connection default: |
| 31 |
select f1, vjhi from t1 order by f1; |
| 32 |
f1 vjhi |
| 33 |
1 2009 |
| 34 |
commit; |
| 35 |
select f1, vjhi from t1 order by f1; |
| 36 |
f1 vjhi |
| 37 |
1 2010 |
| 38 |
drop table t1; |