This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 101
Support backup & restore views and sequences #242
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
96645a1
tests: update the download URL of nightly TiDB
kennytm b500476
backup,restore: support adjusting sequence value
kennytm 4461019
tests: added test case for views and sequences
kennytm ff0e833
Merge branch 'master' into views-and-sequences
kennytm 40d5350
Merge branch 'master' into views-and-sequences
kennytm 57232f3
tests: fix and relax test
kennytm 8acfc96
Merge branch 'master' into views-and-sequences
kennytm b7efca4
backup: fix gofmt
kennytm e5fca6b
Merge branch 'master' into views-and-sequences
3pointer d7c1896
Merge branch 'master' into views-and-sequences
3pointer c75e712
Merge branch 'master' into views-and-sequences
3pointer fc27535
add backupsquence config && trigger sequence cycle round
3pointer 7146861
remove flag backupseqence
3pointer ca4b3ff
address comment
3pointer 07778c7
Merge pull request #1 from 3pointer/sequence_cycle
kennytm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright 2020 PingCAP, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -eu | ||
DB="$TEST_NAME" | ||
|
||
run_sql "create schema $DB;" | ||
run_sql "create view $DB.view_1 as select 331 as m;" | ||
run_sql "create view $DB.view_2 as select * from $DB.view_1;" | ||
run_sql "create sequence $DB.seq_1 nocache cycle maxvalue 40;" | ||
run_sql "create table $DB.table_1 (m int primary key default next value for $DB.seq_1, b int);" | ||
run_sql "insert into $DB.table_1 (b) values (8), (12), (16), (20);" | ||
run_sql "create sequence $DB.seq_2;" | ||
run_sql "create table $DB.table_2 (a int default next value for $DB.seq_1, b int default next value for $DB.seq_2, c int);" | ||
run_sql "insert into $DB.table_2 (c) values (24), (28), (32);" | ||
run_sql "create view $DB.view_3 as select m from $DB.table_1 union select a * b as m from $DB.table_2 union select m from $DB.view_2;" | ||
run_sql "drop view $DB.view_1;" | ||
run_sql "create view $DB.view_1 as select 133 as m;" | ||
3pointer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
echo "backup start..." | ||
run_br backup db --db "$DB" -s "local://$TEST_DIR/$DB" --pd $PD_ADDR | ||
|
||
run_sql "drop schema $DB;" | ||
|
||
echo "restore start..." | ||
run_br restore db --db $DB -s "local://$TEST_DIR/$DB" --pd $PD_ADDR | ||
|
||
set -x | ||
|
||
views_count=$(run_sql "select count(*) c, sum(m) s from $DB.view_3;" | tail -2 | paste -sd ';') | ||
[ "$views_count" = 'c: 8;s: 181' ] | ||
|
||
run_sql "insert into $DB.table_2 (c) values (33);" | ||
seq_val=$(run_sql "select a >= 8 and b >= 4 as g from $DB.table_2 where c = 33;" | tail -1) | ||
[ "$seq_val" = 'g: 1' ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM