Permalink
Browse files

Split creation of foreign keys from creation of indexes and primary k…

…eys.

They're not always needed/wanted.
  • Loading branch information...
1 parent 27bf3a2 commit d68bba7260725916ec3c157873457c45e8f798ad @murdos murdos committed Aug 26, 2011
Showing with 31 additions and 1 deletion.
  1. +9 −0 backend/mysql.pl
  2. +2 −0 backend/postgresql.pl
  3. +4 −0 init.pl
  4. +7 −1 languages/English.pl
  5. +9 −0 src/functions.pl
View
@@ -300,9 +300,18 @@ sub backend_mysql_update_index {
}
close(SQL);
+ print "Done\n";
+ return 1;
+}
+
+# backend_mysql_update_foreignkey()
+# Attemp to pull as much relevant information from CreateFKConstraints.sql as we can.
+# @return Always 1.
+sub backend_mysql_update_foreignkey {
open(SQL, "replication/CreateFKConstraints.sql");
chomp(my @lines = <SQL>);
my $index_name = "", $table_name = "", $columns = [], $foreign_table_name = "", $foreign_columns = [];
+
foreach my $line (@lines) {
# skip blank lines and single bracket lines
next if($line eq "" || substr($line, 0, 2) eq "--" || substr($line, 0, 1) eq "\\" ||
View
@@ -76,7 +76,9 @@ sub backend_postgresql_update_index {
mbz_do_sql($line, 'nodie');
}
close(SQL);
+}
+sub backend_postgresql_update_foreignkey {
open(SQL, "replication/CreateFKConstraints.sql");
chomp(my @lines = <SQL>);
my $sql = "";
View
@@ -35,6 +35,8 @@
} elsif($action == 5) {
print $L{'init_actionindex'};
} elsif($action == 6) {
+ print $L{'init_actionfk'};
+} elsif($action == 7) {
print $L{'init_actionplugininit'};
}
chomp(my $input = <STDIN>);
@@ -62,5 +64,7 @@
} elsif($action == 5) {
mbz_update_index();
} elsif($action == 6) {
+ mbz_update_foreignkey();
+} elsif($action == 7) {
mbz_init_plugins();
}
View
@@ -43,7 +43,8 @@
"[3] Load raw tables (requires big download ~1GB)\n".
"[4] Load raw tables (don't download, load from 'mbdump/')\n".
"[5] Apply table indexing\n".
-"[6] Initialise plugins\n\n".
+"[6] Apply table foreign keys\n".
+"[7] Initialise plugins\n\n".
"Option: ";
# action descriptions
@@ -74,6 +75,11 @@
"it is faster.... if you cancel, you can safely return by running this again.\n".
"Ready to proceed? (y/n): ";
+$L{'init_actionfk'} =
+"One of the most time consuming option. This will apply foreign keys to your already loaded\n".
+"database. If you cancel, you can safely return by running this again.\n".
+"Ready to proceed? (y/n): ";
+
$L{'init_actionplugininit'} =
"Run this last but before you start the replications. Make sure you edit settings.pl\n".
"with the active plugins you wish to initialise in \@g_active_plugins.\n\n".
View
@@ -820,6 +820,15 @@ sub mbz_update_index {
return (\&$function_name)->();
}
+# mbz_update_foreignkey()
+# This subroutine is just a controller that redirects to the update index for the RDBMS we are
+# using.
+# @return Passthru from backend_DB_update_index().
+sub mbz_update_foreignkey {
+ # use the subroutine appropriate for the RDBMS
+ my $function_name = "backend_${g_db_rdbms}_update_foreignkey";
+ return (\&$function_name)->();
+}
# mbz_update_schema()
# This subroutine is just a controller that redirects to the update schema for the RDBMS we are

0 comments on commit d68bba7

Please sign in to comment.