403Webshell
Server IP : 104.21.38.3  /  Your IP : 104.23.175.245
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/server/mysql/src/mysql-test/suite/rpl/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/server/mysql/src/mysql-test/suite/rpl/t/rpl_gcol_sec_index.test
#
# === Purpose ===
#
# This test verifies DMLs are applied on a table by the slave when
# 1. Table on slave has extra generated columns and containing a secondary
#    indexes defined on the generated columns.
# 2. Table on master has generated columns and slave modified the table by
#    changing the generated expressions and adding a secondary index on the
#    generated columns.
#
# === Implementation ===
# Note:
# Aliases used:
# Virtual Generated Column -> VGC
# Stored Generated Column -> SGC
#
# 1. a) Create a table without generated columns.
#    b) Create a table with a VGC and a SGC with secondary indexes defined on
#       them.
#
# 2. a) For 1.a), Add a VGC and SGC with secondary index on the Slave.
#    b) For 1.b), Modify the generated expression for the VGC and SGC on the
#                 Slave.
#
# 3. Perform INSERTs on the tables and validate table data.
#
# 4. Perform UPDATEs on the tables and validate table data.
#
# 5. Perform DELETEs on the tables and validate table data.
#
# === References ===
#
# BUG#30034874: INDEX CORRUPTION WHEN SLAVE HAS VIRTUAL COLUMNS/INDEXES
#               AND MASTER DOESN'T
#
#

--source include/have_binlog_format_row.inc
--source include/master-slave.inc

# ===========================================================================
--echo
--echo # Create a table without generated columns.
CREATE TABLE t1 (id INT) ENGINE=InnoDB;

--echo
--echo # Create a table with a VGC and a SGC with secondary indexes defined on
--echo # them.
CREATE TABLE t2(
id INT,
v_gcol INT GENERATED ALWAYS AS (id + 1) VIRTUAL NOT NULL,
s_gcol INT GENERATED ALWAYS AS (id + 1) STORED NOT NULL,
KEY v_idx (v_gcol), KEY s_idx (s_gcol)
) ENGINE=InnoDB;

# ===========================================================================
--source include/sync_slave_sql_with_master.inc
--echo
--echo # Add a VGC and also define secondary indexes on the VGC and SGC on the
--echo # Slave.
ALTER TABLE t1
ADD v_gcol INT GENERATED ALWAYS AS (id + 1) VIRTUAL NOT NULL,
ADD s_gcol INT GENERATED ALWAYS AS (id + 1) STORED NOT NULL,
ADD KEY v_idx (v_gcol), ADD KEY s_idx (s_gcol);

--echo
--echo # Modify the generated expression for the VGC and SGC on the Slave.
ALTER TABLE t2
MODIFY v_gcol INT GENERATED ALWAYS AS (id + 2) VIRTUAL NOT NULL,
MODIFY s_gcol INT GENERATED ALWAYS AS (id + 2) STORED NOT NULL;

# ===========================================================================
# Helper file for table data validation.
--write_file $MYSQLTEST_VARDIR/tmp/validate_table_data.inc
--let $i= 1
while ($i != 3)
{
  --let diff_tables= master:t$i, slave:t$i
  --let $mask_column_list= v_gcol, s_gcol
  --source include/diff_tables.inc

  --let $assert_text= Verified that table t$i has $expected_row_count rows
  --let $assert_cond= [SELECT count(*) as count from t$i where t$i.v_gcol= t$i.id+$i and t$i.s_gcol= t$i.id+$i ] = $expected_row_count
  --source include/assert.inc

  --inc $i
}
EOF

# ===========================================================================
--source include/rpl_connection_master.inc
--echo
--echo # INSERT values into the tables on the master.
INSERT INTO t1 VALUES (1);
INSERT INTO t2(id) VALUES (1);

--source include/sync_slave_sql_with_master.inc
--echo
--echo # Validate the table data.
--let $expected_row_count= 1
--source $MYSQLTEST_VARDIR/tmp/validate_table_data.inc

# ===========================================================================
--echo
--echo # UPDATE a record in the tables on the master.
--source include/rpl_connection_master.inc
UPDATE t1 SET id= 2 WHERE id= 1;
UPDATE t2 SET id= 2 WHERE id= 1;

--source include/sync_slave_sql_with_master.inc
--echo
--echo # Validate the table data.
--let $expected_row_count= 1
--source $MYSQLTEST_VARDIR/tmp/validate_table_data.inc

# ===========================================================================
--echo
--echo # DELETE a record in the tables on the master.
--source include/rpl_connection_master.inc
DELETE FROM t1 WHERE id= 2;
DELETE FROM t2 WHERE id= 2;

--source include/sync_slave_sql_with_master.inc
--echo
--echo # Validate the table data.
--let $expected_row_count= 0
--source $MYSQLTEST_VARDIR/tmp/validate_table_data.inc

# ===================================================================
--echo
--echo # Cleanup
--source include/rpl_connection_master.inc
DROP TABLE t1;
DROP TABLE t2;
--remove_file $MYSQLTEST_VARDIR/tmp/validate_table_data.inc
--source include/rpl_end.inc

Youez - 2016 - github.com/yon3zu
LinuXploit