Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Found some issues with CREATE UNIQUE on non-NGS while building the en…

…tire database. Some minor bugs fixes the replications to ignore some tables and columns for non-NGS.
  • Loading branch information...
commit 332da7db1ad1012fd905777bc1262baf0642287c 1 parent c357f34
Elliot Chance authored
View
24 backend/mysql.pl
@@ -194,11 +194,6 @@ sub backend_mysql_table_exists {
# be left intact.
# @return Always 1.
sub backend_mysql_update_index {
- # TODO: It is not indexing 'id' columns of the tables, this might be because the CREATE TABLEs
- # contains SERIAL type, this will need to be fixed. One method is to search for SERIAL
- # columns in CreateTables.sql or simply look for all the 'id' columns and create indexes
- # on them.
-
open(SQL, "replication/CreateIndexes.sql");
chomp(my @lines = <SQL>);
@@ -247,8 +242,25 @@ sub backend_mysql_update_index {
print "$new_line\n";
mbz_do_sql($new_line);
}
-
close(SQL);
+
+ # the second phase is to add indexing for what PostgreSQL would of originally defined as SERIAL
+ # columns. We can't guarantee that given any column called 'id' will be unique (even through
+ # that's likely) so we create normal indexes on them
+ my $q = $dbh->prepare("show tables");
+ $q->execute();
+ while(@r = $q->fetchrow_array()) {
+ my $q2 = $dbh->prepare("describe `$r[0]`");
+ $q2->execute();
+ while(@r2 = $q2->fetchrow_array()) {
+ if($r2[0] eq 'id' && !mbz_index_exists("$r[0]_$r2[0]_idx")) {
+ $sql = "CREATE INDEX `$r[0]_$r2[0]_idx` ON `$r[0]` (`$r2[0]`)";
+ print "$sql\n";
+ mbz_do_sql($sql);
+ }
+ }
+ }
+
print "Done\n";
return 1;
}
View
10 init.pl
@@ -5,6 +5,16 @@
require "backend/$g_db_rdbms.pl";
require "src/functions.pl";
+# TODO: There is an issue with some of the CREATE UNIQUE INDEXs on table columns that are not unique
+# name (select count(1) - count(distinct ?) from ?)
+# artistalias_nameindex 20 duplicates
+# url_idx_url 75 duplicates
+# wordlist_wordindex 30 duplicates
+#
+# This has only been tested against non-NGS. The non-NGS schema comes from an old version from
+# the git repository which means this can't be fixed. However everyone that can should move to
+# using the NGS schema where any unique issues can be fixed by updating the git repository.
+
# first boot
mbz_choose_language() if(!$g_chosenlanguage);
mbz_first_boot() if($g_firstboot);
View
1  plugins/pendinglog.pl
@@ -38,6 +38,7 @@ sub pendinglog_init {
sub pendinglog_beforereplication {
my ($repID) = @_;
+
mbz_do_sql(qq|
INSERT INTO pendinglog
SELECT $g_pending.SeqId, '$repID',
View
11 settings.pl
@@ -51,6 +51,17 @@
# eg. 'trmids'
);
+# there are some SQL inconsistencies when using non-NGS
+if(!$g_use_ngs) {
+ push(@g_ignore_tables, 'release_group');
+ push(@g_ignore_tables, 'release_group_meta');
+ push(@g_ignore_tables, 'release_groupwords');
+ push(@g_ignore_tables, 'isrc');
+
+ push(@g_ignore_fields, 'release_group');
+ push(@g_ignore_fields, 'release_groupusecount');
+}
+
# Schema. This is where the SQL scripts to create the schema come from, only edit this if you know
# what you're doing.
$schema_base = 'http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=blob_plain';
View
15 src/functions.pl
@@ -410,11 +410,10 @@ sub mbz_raw_download {
}
@files = (
- # TODO: turn this back on when finished testing.
- #'mbdump-artistrelation.tar.bz2',
- #'mbdump-derived.tar.bz2',
+ 'mbdump-artistrelation.tar.bz2',
+ 'mbdump-derived.tar.bz2',
'mbdump-stats.tar.bz2',
- #'mbdump.tar.bz2'
+ 'mbdump.tar.bz2'
);
}
@@ -530,7 +529,7 @@ sub mbz_run_transactions {
# next if we are ignoring this table
my $tableName = substr($rep_row[1], 10, length($rep_row[1]) - 11);
if(mbz_in_array(\@g_ignore_tables, $tableName)) {
- ++$rows if($rep_row[5] eq '0' || $rep_row[2] eq 'd');
+ ++$rows if(($rep_row[5] eq '0' || $rep_row[5] eq 'f') || $rep_row[2] eq 'd');
mbz_do_sql("DELETE FROM $pending WHERE SeqId='$rep_row[0]'");
mbz_do_sql("DELETE FROM $pendingdata WHERE SeqId='$rep_row[0]'");
next;
@@ -544,9 +543,9 @@ sub mbz_run_transactions {
$data = mbz_unpack_data($rep_row[6]);
# build replicated SQL
- my $sql = "insert into ";
- $sql = "update " if($rep_row[2] eq 'u');
- $sql = "delete from " if($rep_row[2] eq 'd');
+ my $sql = "INSERT INTO ";
+ $sql = "UPDATE " if($rep_row[2] eq 'u');
+ $sql = "DELETE FROM " if($rep_row[2] eq 'd');
$sql .= mbz_escape_entity($tableName) . " ";
if($rep_row[2] eq 'i') {
$sql .= mbz_map_values($data, ',');
Please sign in to comment.
Something went wrong with that request. Please try again.