github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/tests/_utils/run_sql_online_ddl (about) 1 #!/bin/bash 2 # parameter 1: an ALTER SQL to be executed 3 # parameter 2: host 4 # parameter 3: port 5 # parameter 4: password 6 # parameter 5: db 7 # parameter 6: online ddl tool, pt or gh-ost 8 9 set -eu 10 11 line=$1 12 host=$2 13 port=$3 14 password=$4 15 schema=$5 16 ghost_bin=${GHOST_BINARY:-gh-ost} 17 ptosc_bin=${PTOSC_BINARY:-pt-online-schema-change} 18 19 table=$(echo $line | cut -d " " -f3) 20 alter=$(echo "$line" | cut -d " " -f4-) 21 echo "alter: $alter" 22 # gh-ost check connection port whether equals to `select @@global.port`. 23 # if we have test MySQL in container and port mapping, these two ports 24 # may different. So we cheat gh-ost that we are running on aliyun rds, 25 # on which will disable the port check. 26 if [ "$6" == "gh-ost" ]; then 27 $ghost_bin -version 28 $ghost_bin --user=root --host=$host --port=$port --password=$password \ 29 --database=$schema --table=$table --alter="$alter" \ 30 --serve-socket-file="$TEST_DIR/gh-ost.$schema.$table.$port.sock" \ 31 --allow-on-master --allow-master-master --initially-drop-ghost-table \ 32 --initially-drop-old-table -ok-to-drop-table -aliyun-rds -execute \ 33 >>$TEST_DIR/gh-ost.log 34 elif [ "$6" == "pt" ]; then 35 $ptosc_bin --version 36 $ptosc_bin --user=root --host=$host --port=$port --password=$password \ 37 --alter="$alter" D=$schema,t=$table \ 38 --recursion-method=none --print --execute \ 39 >>$TEST_DIR/pt-osc.log 40 $ptosc_bin --user=root --host=$host --port=$port --password=$password \ 41 --alter "COMMENT='string' CHARACTER SET='utf8mb4'" D=$schema,t=$table \ 42 --recursion-method=none --print --execute \ 43 >>$TEST_DIR/pt-osc.log 44 else 45 mysql -uroot -h$host -P$port -p$password --default-character-set utf8 -E -e "use $schema; $line" >>"$TEST_DIR/sql_res.$TEST_NAME.txt" 46 fi