[Rt-commit] rt branch, 4.4/mysql8-quoted-tables, repushed
Aaron Trevena
ast at bestpractical.com
Wed Sep 9 13:34:52 EDT 2020
The branch 4.4/mysql8-quoted-tables was deleted and repushed:
was fa9ab931860c85664e3f518d2adaeabc5db5938b
now 3cb39ef7b62683ae2d4b8626495733e3a3fe85bd
1: 7b048865db = 1: 7b048865db Allow to squelch recipients that also exist in one time inputs
2: 6cf274f5bc = 2: 6cf274f5bc Check txn's fields for its relationship with ticket
3: 9d05b93c13 = 3: 9d05b93c13 Fix "Case sensitive search by Queues.Name" warnings in GetReferencedQueues
4: 406252f311 = 4: 406252f311 Support to copy saved charts like searches
5: de3e4f5000 = 5: de3e4f5000 Refactor saved chart tests a bit to reduce code duplication by using a loop
6: feec798d3d = 6: feec798d3d Test the copy feature of saved charts
7: 5dc91ca147 = 7: 5dc91ca147 Exclude MIME attachments when questing a transaction's content
8: 2505933f07 = 8: 2505933f07 Add tests for transaction content
9: 31ca5c2ab2 = 9: 31ca5c2ab2 Fix wrongly duplicated one-time addresses on ticket update page
10: 43061702cb = 10: 43061702cb Update mysql schema for mysql 8 making Groups reserved word
11: e3ba6e1ab5 ! 11: a26e687b37 Update queries and user creation for Mysql 8
@@ -219,23 +219,28 @@
foreach my $use ( @URI_USES ) {
my $stable = m2t( $use->{'model'} );
-+ $stable = "`$stable`" if ($db_type eq 'mysql');
++ my $stablename = ($db_type eq 'mysql') ? "`$stable`" : $stable;
my $scolumn = $use->{'column'};
foreach my $tmodel ( @models ) {
my $tclass = 'RT::'. $tmodel;
my $ttable = m2t($tmodel);
-
-+ $ttable = "`$ttable`" if ($db_type eq 'mysql');
++ my $ttablename = ($db_type eq 'mysql') ? "`$ttable`" : $ttable;
my $tprefix = $prefix .'/'. ($tclass eq 'RT::Ticket'? 'ticket' : $tclass) .'/';
$tprefix = $prefix . '/article/' if $tclass eq 'RT::Article';
+
+- my $query = "SELECT s.id FROM $stable s LEFT JOIN $ttable t "
++ my $query = "SELECT s.id FROM $stablename s LEFT JOIN $ttablename t "
+ ." ON t.id = ". sql_str2int("SUBSTR(s.$scolumn, ?)")
+ ." WHERE s.$scolumn LIKE ? AND t.id IS NULL";
+ my @binds = (length($tprefix) + 1, sql_escape_like($tprefix).'%');
@@
." errors with links.\n",
'Link to a missing object in $ttable'
);
-
-+ $stable =~ s/`//g;
delete_record($stable, $sid);
}
}
@@ -243,19 +248,26 @@
my ($ttable, @tcols) = (shift, shift);
my %args = @_;
-+ $ttable = "`$ttable`" if ($db_type eq 'mysql');
-+ $stable = "`$stable`" if ($db_type eq 'mysql');
++ my $stablename = ($db_type eq 'mysql') ? "`$stable`" : $stable;
++ my $ttablename = ($db_type eq 'mysql') ? "`$ttable`" : $ttable;
+
@scols = @{ $scols[0] } if ref $scols[0];
@tcols = @{ $tcols[0] } if ref $tcols[0];
+@@
+ if $opt{'verbose'};
+
+ my $query = "SELECT s.id, ". join(', ', map "s.$_", @scols)
+- ." FROM $stable s LEFT JOIN $ttable t"
++ ." FROM $stablename s LEFT JOIN $ttablename t"
+ ." ON (". join(
+ ' AND ', map columns_eq_cond('s', $stable, $scols[$_] => 't', $ttable, $tcols[$_]), (0..(@scols-1))
+ ) .")"
@@
my $sth = execute_query( $query, @binds );
while ( my ($sid, @set) = $sth->fetchrow_array ) {
$res = 0;
-
-+ $stable =~ s/`//g;
-+ $ttable =~ s/`//g;
print STDERR "Record #$sid in $stable references a nonexistent record in $ttable\n";
for ( my $i = 0; $i < @scols; $i++ ) {
print STDERR "\t$scols[$i] => '$set[$i]' => $tcols[$i]\n";
@@ -271,18 +283,21 @@
sub load_record {
my ($table, $id) = @_;
-+ $table = "`$table`" if ($db_type eq 'mysql');
- my $sth = execute_query( "SELECT * FROM $table WHERE id = ?", $id );
+- my $sth = execute_query( "SELECT * FROM $table WHERE id = ?", $id );
++ my $tablename = ($db_type eq 'mysql') ? "`$table`" : $table;
++ my $sth = execute_query( "SELECT * FROM $tablename WHERE id = ?", $id );
return $sth->fetchrow_hashref('NAME_lc');
}
-@@
+
sub delete_record {
my ($table, $id) = (@_);
print "Deleting record #$id in $table\n" if $opt{'verbose'};
-+ $table = "`$table`" if ($db_type eq 'mysql');
- my $query = "DELETE FROM $table WHERE id = ?";
+- my $query = "DELETE FROM $table WHERE id = ?";
++ my $tablename = ($db_type eq 'mysql') ? "`$table`" : $table;
++ my $query = "DELETE FROM $tablename WHERE id = ?";
$redo_check{ $_ } = 1 foreach @{ $redo_on{'Delete'}{ $table } || [] };
return execute_query( $query, $id );
+ }
@@
my $where = shift;
my $what = shift;
12: fa9ab93186 ! 12: 3cb39ef7b6 Update tests for mysql 8
@@ -3,10 +3,7 @@
Update tests for mysql 8
Tests fail due to new Groups reserved word and other changes in mysql 8, requiring
- Groups table to be escaped and the rt-validator to be run with resolve a second time
- for some tests.
-
- Add debug and workaround for rt-validator not fully resolving integrity failures
+ Groups table to be escaped, add debug output for any failing validator results.
diff --git a/t/validator/transaction.t b/t/validator/transaction.t
--- a/t/validator/transaction.t
@@ -21,44 +18,14 @@
$res,
qr/Transactions references a nonexistent record in CustomFields/,
@@
- $RT::Handle->dbh->do( "DELETE FROM Users where id=" . $user->id );
$RT::Handle->dbh->do( "DELETE FROM Principals where id=" . $user->PrincipalId );
-- my ( $ecode, $res ) = RT::Test->run_validator( resolve => 1 );
+ my ( $ecode, $res ) = RT::Test->run_validator( resolve => 1 );
- isnt( $ecode, 0, 'non-zero exit code' );
-+ my ( $ecode, $res ) = RT::Test->run_validator( resolve => 1, );
+ isnt( $ecode, 0, 'non-zero exit code' ) or diag ($res);
like(
$res,
qr/Transactions references a nonexistent record in Users/,
-@@
- 'Found/Fixed error of Transactions <-> Principals'
- );
-
-+ # TODO: validator requiring second run on mysql, possible race condition or query ordering
-+ ( $ecode, $res ) = RT::Test->run_validator( resolve => 1 );
-+
- RT::Test->db_is_valid;
- }
-
-@@
- qr/Transactions references a nonexistent record in Queues/,
- 'Found/Fixed error of Transactions <-> Queues'
- );
-+ # TODO: validator requiring second run on mysql, possible race condition or query ordering
-+ ( $ecode, $res ) = RT::Test->run_validator( resolve => 1 );
- RT::Test->db_is_valid;
- }
-
-@@
- qr/Transactions references a nonexistent record in Tickets/,
- 'Found/Fixed error of Transactions <-> Tickets'
- );
-+ # TODO: validator requiring second run on mysql, possible race condition or query ordering
-+ ( $ecode, $res ) = RT::Test->run_validator( resolve => 1, verbose => 1 );
- RT::Test->db_is_valid;
- }
-
diff --git a/t/web/query_log.t b/t/web/query_log.t
--- a/t/web/query_log.t
More information about the rt-commit
mailing list