Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dumpling: skip query tables when use --sql (#45240) #45261

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dumpling/export/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ func getListTableTypeByConf(conf *Config) listTableType {
}

func prepareTableListToDump(tctx *tcontext.Context, conf *Config, db *sql.Conn) error {
if conf.specifiedTables {
if conf.specifiedTables || conf.SQL != "" {
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."
Loading