mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
Merge branch '2.2' into bug-1604834
This commit is contained in:
44
CONTRIBUTE.md
Normal file
44
CONTRIBUTE.md
Normal file
@@ -0,0 +1,44 @@
|
||||
#Contributing guide
|
||||
##How Can I Contribute?
|
||||
##Reporting Bugs
|
||||
Before creating bug reports, please check this list as you might find out that you don't need to create one. When you are creating a bug report, please include as many details as possible. You can use this template to structure the information.
|
||||
|
||||
###Before Submitting A Bug Report
|
||||
- Ensure you have carefully read the documentation. Percona Toolkit is a mature project with many settings that covers a wide range options.
|
||||
- Search for existing bugs in Launchpad to see if the problem has already been reported. If it has, add a comment to the existing issue instead of opening a new one.
|
||||
|
||||
###How Do I Submit A (Good) Bug Report?
|
||||
- Explain the problem and include additional details to help others reproduce the problem:
|
||||
- Use a clear and descriptive title for the issue to identify the problem.
|
||||
- Describe the exact steps which reproduce the problem, including as many details as possible. Provide examples of the command you used and include context information like language, OS and database versions.
|
||||
Describe the obtained results and the expected results and, if it is possible, provide examples.
|
||||
|
||||
##Submiting fixes
|
||||
###Create an Issue
|
||||
If you find a bug, the first step is to create an issue. Whatever the problem is, you’re likely not the only one experiencing it. Others will find your issue helpful, and other developers might help you find the cause and discuss the best solution for it.
|
||||
|
||||
####Tips for creating an issue
|
||||
- Check if there are any existing issues for your problem. By doing this, we can avoid duplicating efforts, since the issue might have been already reported and if not, you might find useful information on older issues related to the same problem.
|
||||
- Be clear about what your problem is: which program were you using, what was the expected result and what is the result you are getting. Detail how someone else can reproduce the problem, including examples.
|
||||
- Include system details like language version, OS, database details or special configurations, etc.
|
||||
- Paste the error output or logs in your issue or in a Gist.
|
||||
|
||||
###Pull Requests
|
||||
If you fixed a bug or added a new feature – awesome! Open a pull request with the code! Be sure you’ve read any documents on contributing, understand the license and have signed a Contributor Licence Agreement (CLA) if required. Once you’ve submitted a pull request, the maintainers can compare your branch to the existing one and decide whether or not to incorporate (merge) your changes.
|
||||
|
||||
###Tips for creating a pull request
|
||||
- Fork the repository and clone it locally. Connect your local to the original ‘upstream’ repository by adding it as a remote. Pull in changes from ‘upstream’ often so that you stay up to date so that when you submit your pull request, merge conflicts will be less likely.
|
||||
- Create a branch for your code. Usually it is a good practice to name the branch after the issue ID, like issue-12345.
|
||||
- Be clear about the problem you fixed or the feature you added. Include explanations and code references to help the maintainers understand what you did.
|
||||
- Add useful comments to the code to help others understand it.
|
||||
- Write tests. This is an important step. Run your changes against existing tests and create new ones when needed. Whether tests exist or not, make sure your changes don’t break the existing project.
|
||||
- Contribute in the style of the project to the best of your abilities. This may mean using indents, semicolons, or comments differently than you would in your own repository, but makes it easier for the maintainer to merge, others to understand and maintain in the future.
|
||||
- Keep your changes as small as possible and solve only what's reported in the issue. Mixing fixes might be confusing to others and makes testing harder.
|
||||
- Be as explicit as possible. Avoid using special/internal language variables like $_. Use a variable name that clearly represents the value it holds.
|
||||
- Write good commit messages. A comment like 'Misc bugfixes' or 'More code added' does not help to understand what's the change about.
|
||||
|
||||
###Open Pull Requests
|
||||
Once you’ve opened a pull request, a discussion will start around your proposed changes. Other contributors and users may chime in, but ultimately the decision is made by the maintainers. You may be asked to make some changes to your pull request, if so, add more commits to your branch and push them – they’ll automatically go into the existing pull request.
|
||||
|
||||
#Licensing
|
||||
Along with the pull request, include a message indicating that the submited code is your own creation and it can be distributed under the BSD licence.
|
@@ -1,8 +1,7 @@
|
||||
Percona Toolkit
|
||||
===============
|
||||
#Percona Toolkit
|
||||
|
||||
Percona Toolkit is a collection of advanced command-line tools used by
|
||||
Percona (http://www.percona.com/) support staff to perform a variety of
|
||||
*Percona Toolkit* is a collection of advanced command-line tools used by
|
||||
[Percona](http://www.percona.com/) support staff to perform a variety of
|
||||
MySQL and system tasks that are too difficult or complex to perform manually.
|
||||
|
||||
These tools are ideal alternatives to private or "one-off" scripts because
|
||||
@@ -12,26 +11,27 @@ no libraries are installed.
|
||||
|
||||
Percona Toolkit is developed and supported by Percona Inc. For more
|
||||
information and other free, open-source software developed by Percona,
|
||||
visit http://www.percona.com/software/.
|
||||
visit [http://www.percona.com/software/](http://www.percona.com/software/).
|
||||
|
||||
Installing
|
||||
----------
|
||||
##Installing
|
||||
|
||||
To install all tools, run:
|
||||
|
||||
perl Makefile.PL
|
||||
make
|
||||
make test
|
||||
make install
|
||||
```
|
||||
perl Makefile.PL
|
||||
make
|
||||
make test
|
||||
make install
|
||||
```
|
||||
|
||||
You probably need to be root to `make install'. On most systems, the tools
|
||||
You probably need to be root to `make install`. On most systems, the tools
|
||||
are installed in /usr/local/bin. See the INSTALL file for more information.
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
##Documentation
|
||||
|
||||
Run `man percona-toolkit' to see a list of installed tools, then `man tool'
|
||||
Run `man percona-toolkit` to see a list of installed tools, then `man tool`
|
||||
to read the embedded documentation for a specific tool. You can also read
|
||||
the documentation online at http://www.percona.com/software/percona-toolkit/.
|
||||
the documentation online at [http://www.percona.com/software/percona-toolkit/](http://www.percona.com/software/percona-toolkit/).
|
||||
|
||||
|
||||
|
@@ -10097,11 +10097,8 @@ sub create_new_table {
|
||||
# This is in contrast to previous behavior were we added underscores
|
||||
# indefinitely, sometimes exceeding the allowed name limit
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1215587
|
||||
if ( $sql =~ /CONSTRAINT `_/ ) {
|
||||
$sql =~ s/^ CONSTRAINT `_/ CONSTRAINT `/gm;
|
||||
} else {
|
||||
$sql =~ s/^ CONSTRAINT `/ CONSTRAINT `_/gm;
|
||||
}
|
||||
$sql =~ s/^ CONSTRAINT `(_?)/' CONSTRAINT `'.($1 eq '' ? '_' : '')/gme;
|
||||
|
||||
if ( $o->get('default-engine') ) {
|
||||
$sql =~ s/\s+ENGINE=\S+//;
|
||||
}
|
||||
|
@@ -1921,7 +1921,8 @@ sub main {
|
||||
|
||||
# If MySQL 5.7.6+ then we need to use SHOW CREATE USER
|
||||
my @create_user;
|
||||
if ( VersionCompare::cmp($version, '5.7.6') >= 0 ) {
|
||||
if (( VersionCompare::cmp($version, '5.7.6') >= 0 ) &&
|
||||
( VersionCompare::cmp($version, '10.0.0') <= 0 )) {
|
||||
eval {
|
||||
@create_user = @{ $dbh->selectcol_arrayref("SHOW CREATE USER $user_host") };
|
||||
};
|
||||
|
@@ -42,8 +42,7 @@ my $sample = "t/pt-online-schema-change/samples/";
|
||||
$sb->load_file('master', "$sample/bug-1215587.sql");
|
||||
|
||||
# run once: we expect constraint names to be prefixed with one underscore
|
||||
# note: We're running just a neutral no-op alter. We are only interested in constraint name
|
||||
# changes.
|
||||
# if they havre't one, and to remove one if they already do.
|
||||
($output, $exit_status) = full_output(
|
||||
sub { pt_online_schema_change::main(@args,
|
||||
"$master_dsn,D=bug1215587,t=Table1",
|
||||
@@ -52,24 +51,24 @@ $sb->load_file('master', "$sample/bug-1215587.sql");
|
||||
);
|
||||
|
||||
|
||||
my $constraints = $master_dbh->selectall_hashref("SELECT CONSTRAINT_NAME, TABLE_NAME FROM information_schema.KEY_COLUMN_USAGE WHERE table_schema='bug1215587' and (TABLE_NAME='Table1' OR TABLE_NAME='Table2') and CONSTRAINT_NAME LIKE '%fkey%'", 'table_name');
|
||||
my $constraints = $master_dbh->selectall_arrayref("SELECT TABLE_NAME, CONSTRAINT_NAME FROM information_schema.KEY_COLUMN_USAGE WHERE table_schema='bug1215587' and (TABLE_NAME='Table1' OR TABLE_NAME='Table2') and CONSTRAINT_NAME LIKE '%fkey%' ORDER BY TABLE_NAME, CONSTRAINT_NAME");
|
||||
|
||||
|
||||
is(
|
||||
$constraints->{Table1}->{constraint_name},
|
||||
'_fkey1',
|
||||
"Altered table: constraint name prefixed one underscore after 1st run"
|
||||
is_deeply(
|
||||
$constraints,
|
||||
[
|
||||
['Table1', 'fkey1a'],
|
||||
['Table1', '_fkey1b'],
|
||||
['Table2', 'fkey2b'],
|
||||
['Table2', '_fkey2a'],
|
||||
],
|
||||
"First run adds or removes underscore from constraint names, accordingly"
|
||||
);
|
||||
|
||||
is(
|
||||
$constraints->{Table2}->{constraint_name},
|
||||
'_fkey2',
|
||||
"Child table : constraint name prefixed one underscore after 1st run"
|
||||
);
|
||||
|
||||
|
||||
# run second time
|
||||
# we expect underscores to be removed
|
||||
# we expect constraints to be the same as we started (toggled back)
|
||||
($output, $exit_status) = full_output(
|
||||
sub { pt_online_schema_change::main(@args,
|
||||
"$master_dsn,D=bug1215587,t=Table1",
|
||||
@@ -77,19 +76,18 @@ is(
|
||||
qw(--execute)) },
|
||||
);
|
||||
|
||||
$constraints = $master_dbh->selectall_hashref("SELECT CONSTRAINT_NAME, TABLE_NAME FROM information_schema.KEY_COLUMN_USAGE WHERE table_schema='bug1215587' and (TABLE_NAME='Table1' OR TABLE_NAME='Table2') and CONSTRAINT_NAME LIKE '%fkey%'", 'table_name');
|
||||
$constraints = $master_dbh->selectall_arrayref("SELECT TABLE_NAME, CONSTRAINT_NAME FROM information_schema.KEY_COLUMN_USAGE WHERE table_schema='bug1215587' and (TABLE_NAME='Table1' OR TABLE_NAME='Table2') and CONSTRAINT_NAME LIKE '%fkey%' ORDER BY TABLE_NAME, CONSTRAINT_NAME");
|
||||
|
||||
|
||||
is(
|
||||
$constraints->{'Table1'}->{constraint_name},
|
||||
'fkey1',
|
||||
"Altered table: constraint name removed underscore after 2nd run"
|
||||
);
|
||||
|
||||
is(
|
||||
$constraints->{'Table2'}->{constraint_name},
|
||||
'fkey2',
|
||||
"Child table : constraint name removed underscore after 2nd run"
|
||||
is_deeply(
|
||||
$constraints,
|
||||
[
|
||||
['Table1', 'fkey1b'],
|
||||
['Table1', '_fkey1a'],
|
||||
['Table2', 'fkey2a'],
|
||||
['Table2', '_fkey2b'],
|
||||
],
|
||||
"Second run toggles constraint names back to how they were"
|
||||
);
|
||||
|
||||
|
||||
|
@@ -16,8 +16,13 @@ CREATE TABLE `Table2` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
ALTER TABLE `Table1`
|
||||
ADD CONSTRAINT `fkey1` FOREIGN KEY (`T2ID`) REFERENCES `Table2` (`ID`) ON DELETE NO ACTION;
|
||||
ADD CONSTRAINT `_fkey1a` FOREIGN KEY (`T2ID`) REFERENCES `Table2` (`ID`) ON DELETE NO ACTION;
|
||||
|
||||
ALTER TABLE `Table1`
|
||||
ADD CONSTRAINT `fkey1b` FOREIGN KEY (`T2ID`) REFERENCES `Table2` (`ID`) ON DELETE NO ACTION;
|
||||
|
||||
ALTER TABLE `Table2`
|
||||
ADD CONSTRAINT `fkey2` FOREIGN KEY (`ID`) REFERENCES `Table1` (`T2ID`) ON DELETE NO ACTION;
|
||||
ADD CONSTRAINT `fkey2a` FOREIGN KEY (`ID`) REFERENCES `Table1` (`T2ID`) ON DELETE NO ACTION;
|
||||
|
||||
ALTER TABLE `Table2`
|
||||
ADD CONSTRAINT `_fkey2b` FOREIGN KEY (`ID`) REFERENCES `Table1` (`T2ID`) ON DELETE NO ACTION;
|
||||
|
Reference in New Issue
Block a user