| 1 |
################################################################################ |
| 2 |
# t/gcol_rpl.test # |
| 3 |
# # |
| 4 |
# Purpose: # |
| 5 |
# Test replication of tables with generated columns. # |
| 6 |
# # |
| 7 |
#------------------------------------------------------------------------------# |
| 8 |
# Original Author: Andrey Zhakov # |
| 9 |
# Original Date: 2008-09-04 # |
| 10 |
# Change Author: # |
| 11 |
# Change Date: # |
| 12 |
# Change: # |
| 13 |
################################################################################ |
| 14 |
|
| 15 |
# |
| 16 |
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! |
| 17 |
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN |
| 18 |
# THE SOURCED FILES ONLY. |
| 19 |
# |
| 20 |
|
| 21 |
#------------------------------------------------------------------------------# |
| 22 |
# General not engine specific settings and requirements |
| 23 |
--source suite/gcol/inc/gcol_init_vars.pre |
| 24 |
|
| 25 |
#------------------------------------------------------------------------------# |
| 26 |
# Engine specific settings and requirements |
| 27 |
|
| 28 |
##### Storage engine to be tested |
| 29 |
# Set the session storage engine |
| 30 |
SET @@session.default_storage_engine = 'InnoDB'; |
| 31 |
|
| 32 |
##### Workarounds for known open engine specific bugs |
| 33 |
# none |
| 34 |
|
| 35 |
#------------------------------------------------------------------------------# |
| 36 |
# Execute the tests to be applied to all storage engines |
| 37 |
--source include/master-slave.inc |
| 38 |
|
| 39 |
connection master; |
| 40 |
create table t1 (a int, b int generated always as (a+1) virtual); |
| 41 |
show create table t1; |
| 42 |
insert into t1 values (1,default); |
| 43 |
insert into t1 values (2,default); |
| 44 |
select * from t1; |
| 45 |
save_master_pos; |
| 46 |
|
| 47 |
connection slave; |
| 48 |
sync_with_master; |
| 49 |
select * from t1; |
| 50 |
|
| 51 |
connection master; |
| 52 |
drop table t1; |
| 53 |
save_master_pos; |
| 54 |
|
| 55 |
connection slave; |
| 56 |
sync_with_master; |
| 57 |
|
| 58 |
--echo # |
| 59 |
--echo # Bug#22241015: REPLICATION SERVERS CRASHES WHILE CHANGING A |
| 60 |
--echo # VALUE OF INDEXED JSON FIELD |
| 61 |
--echo # |
| 62 |
# Use master connection |
| 63 |
--connection master |
| 64 |
CREATE TABLE gtable (doc JSON); |
| 65 |
INSERT INTO gtable (doc) VALUES |
| 66 |
('{"id": 1, "name": "Omar Bras"}'), |
| 67 |
('{"id": 2, "name": "Omar Mex"}'); |
| 68 |
ALTER TABLE gtable ADD COLUMN gtext TEXT GENERATED ALWAYS AS |
| 69 |
(JSON_UNQUOTE(JSON_EXTRACT(doc, '$.name'))) VIRTUAL, |
| 70 |
ADD UNIQUE INDEX name_index (gtext(50)); |
| 71 |
UPDATE gtable SET doc=JSON_SET(doc,'$.name',"Omar Argentina") WHERE JSON_EXTRACT(doc, "$.id") = 2; |
| 72 |
INSERT INTO gtable(doc) VALUES (NULL); |
| 73 |
SELECT * FROM gtable; |
| 74 |
UPDATE gtable SET doc= '{ "id": 4, "name": "Omar Ara" }' where doc IS NULL; |
| 75 |
SELECT * FROM gtable ORDER BY gtext; |
| 76 |
UPDATE gtable SET doc= NULL WHERE JSON_EXTRACT(doc, "$.id") = 4; |
| 77 |
SELECT * FROM gtable ORDER BY gtext; |
| 78 |
|
| 79 |
--source include/sync_slave_sql_with_master.inc |
| 80 |
SHOW CREATE TABLE gtable; |
| 81 |
--echo # Connection:slave - Row with value 3 is expected on slave. |
| 82 |
SELECT * FROM gtable ORDER BY gtext; |
| 83 |
|
| 84 |
--let $diff_tables= master:gtable, slave:gtable |
| 85 |
--source include/diff_tables.inc |
| 86 |
|
| 87 |
#cleanup |
| 88 |
--connection master |
| 89 |
DROP TABLE gtable; |
| 90 |
## Postamble |
| 91 |
--source include/sync_slave_sql_with_master.inc |
| 92 |
|
| 93 |
#------------------------------------------------------------------------------# |
| 94 |
# Execute storage engine specific tests |
| 95 |
|
| 96 |
|
| 97 |
#------------------------------------------------------------------------------# |
| 98 |
# Cleanup |
| 99 |
--source suite/gcol/inc/gcol_cleanup.inc |
| 100 |
--source include/rpl_end.inc |