Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#45240
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
lance6716 authored and ti-chi-bot committed Jul 10, 2023
1 parent 613ecc5 commit aab07d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions dumpling/export/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,11 @@ func getListTableTypeByConf(conf *Config) listTableType {
}

func prepareTableListToDump(tctx *tcontext.Context, conf *Config, db *sql.Conn) error {
<<<<<<< HEAD
if conf.specifiedTables {
=======
if conf.SpecifiedTables || conf.SQL != "" {
>>>>>>> cb3fc6a63b3 (dumpling: skip query tables when use `--sql` (#45240))
return nil
}
databases, err := prepareDumpingDatabases(tctx, conf, db)
Expand Down
8 changes: 7 additions & 1 deletion dumpling/tests/no_table_and_db_name/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ assert() {
}

TEST_NAME=no_table_and_db_name
export DUMPLING_TEST_PORT=4000
run_sql "drop database if exists $TEST_NAME"
run_sql "create database $TEST_NAME DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"
export DUMPLING_TEST_DATABASE=no_table_and_db_name
Expand All @@ -22,8 +23,13 @@ chars_20="1111_0000_1111_0000_"
# insert 100 records, each occupies 20 bytes
run_sql "insert into t values $(seq -s, 100 | sed 's/,*$//g' | sed "s/[0-9]*/('$chars_20')/g");"

run_sql "set global tidb_general_log=1;"
# dumping with file size = 233 bytes, actually 10 rows
run_dumpling -F 233B --filetype csv --sql "select * from $TEST_NAME.t"
run_sql "set global tidb_general_log=0;"
assert [ $( grep "GENERAL_LOG" $DUMPLING_TEST_DIR/tidb.log | grep --ignore-case "INFORMATION_SCHEMA.TABLES" | wc -l ) -eq 0 ]
assert [ $( grep "GENERAL_LOG" $DUMPLING_TEST_DIR/tidb.log | grep --ignore-case "SHOW FULL TABLES" | wc -l ) -eq 0 ]
assert [ $( grep "GENERAL_LOG" $DUMPLING_TEST_DIR/tidb.log | grep --ignore-case "SHOW TABLE STATUS" | wc -l ) -eq 0 ]

assert [ $( ls -lh $DUMPLING_OUTPUT_DIR | grep -e ".csv$" | wc -l ) -eq 10 ]

Expand All @@ -39,4 +45,4 @@ assert [ $( cat $DUMPLING_OUTPUT_DIR/*.csv | wc -l ) -eq $(( 100 + 10 )) ]
# 10 files with header.
# assert [ $( cat $DUMPLING_OUTPUT_DIR/*.sql | wc -l ) -eq $(( 100 + 10 * 2 )) ]

echo "TEST: [$TEST_NAME] passed."
echo "TEST: [$TEST_NAME] passed."

0 comments on commit aab07d2

Please sign in to comment.