Skip to content

Commit

Permalink
Removed temp directory, it's not needed because any temp files can go…
Browse files Browse the repository at this point in the history
… into the replication directory.
  • Loading branch information
Elliot Chance committed Jun 19, 2010
1 parent b5a52f6 commit c357f34
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
9 changes: 7 additions & 2 deletions backend/mysql.pl
Expand Up @@ -194,7 +194,12 @@ sub backend_mysql_table_exists {
# be left intact. # be left intact.
# @return Always 1. # @return Always 1.
sub backend_mysql_update_index { sub backend_mysql_update_index {
open(SQL, "temp/CreateIndexes.sql"); # 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>); chomp(my @lines = <SQL>);


foreach my $line (@lines) { foreach my $line (@lines) {
Expand Down Expand Up @@ -268,7 +273,7 @@ sub backend_mysql_update_schema {


# this is where it has to translate PostgreSQL to MySQL as well as making any modifications # this is where it has to translate PostgreSQL to MySQL as well as making any modifications
# needed. # needed.
open(SQL, "temp/CreateTables.sql"); open(SQL, "replication/CreateTables.sql");
chomp(my @lines = <SQL>); chomp(my @lines = <SQL>);
my $table = ""; my $table = "";
foreach my $line (@lines) { foreach my $line (@lines) {
Expand Down
8 changes: 4 additions & 4 deletions backend/postgresql.pl
Expand Up @@ -24,7 +24,7 @@ sub backend_postgresql_update_index {
mbz_do_sql("CREATE LANGUAGE plpgsql"); mbz_do_sql("CREATE LANGUAGE plpgsql");
} }


open(SQL, "temp/CreateFunctions.sql"); open(SQL, "replication/CreateFunctions.sql");
chomp(my @lines = <SQL>); chomp(my @lines = <SQL>);
my $full = ""; my $full = "";
foreach my $line (@lines) { foreach my $line (@lines) {
Expand All @@ -40,7 +40,7 @@ sub backend_postgresql_update_index {
} }
close(SQL); close(SQL);


open(SQL, "temp/CreateIndexes.sql"); open(SQL, "replication/CreateIndexes.sql");
chomp(my @lines = <SQL>); chomp(my @lines = <SQL>);
foreach my $line (@lines) { foreach my $line (@lines) {
# skip blank lines and single bracket lines # skip blank lines and single bracket lines
Expand All @@ -52,7 +52,7 @@ sub backend_postgresql_update_index {
} }
close(SQL); close(SQL);


open(SQL, "temp/CreatePrimaryKeys.sql"); open(SQL, "replication/CreatePrimaryKeys.sql");
chomp(my @lines = <SQL>); chomp(my @lines = <SQL>);
foreach my $line (@lines) { foreach my $line (@lines) {
# skip blank lines and single bracket lines # skip blank lines and single bracket lines
Expand Down Expand Up @@ -80,7 +80,7 @@ sub backend_postgresql_update_index {
# to create (and replace) them. This is just so all the error messages and so nasty. # to create (and replace) them. This is just so all the error messages and so nasty.
# @return Always 1. # @return Always 1.
sub backend_postgresql_update_schema { sub backend_postgresql_update_schema {
open(SQL, "temp/CreateTables.sql"); open(SQL, "replication/CreateTables.sql");
chomp(my @lines = <SQL>); chomp(my @lines = <SQL>);
my $table = ""; my $table = "";
foreach my $line (@lines) { foreach my $line (@lines) {
Expand Down
29 changes: 17 additions & 12 deletions src/functions.pl
Expand Up @@ -137,14 +137,14 @@ sub mbz_download_replication {
# indexes and PL/pgSQL. It will later be converted for the RDBMS we are using. # indexes and PL/pgSQL. It will later be converted for the RDBMS we are using.
# @return Always 1. # @return Always 1.
sub mbz_download_schema { sub mbz_download_schema {
unlink("temp/CreateTables.sql"); unlink("replication/CreateTables.sql");
mbz_download_file($g_schema_url, "temp/CreateTables.sql"); mbz_download_file($g_schema_url, "replication/CreateTables.sql");
unlink("temp/CreateIndexes.sql"); unlink("replication/CreateIndexes.sql");
mbz_download_file($g_index_url, "temp/CreateIndexes.sql"); mbz_download_file($g_index_url, "replication/CreateIndexes.sql");
unlink("temp/CreatePrimaryKeys.sql"); unlink("replication/CreatePrimaryKeys.sql");
mbz_download_file($g_pk_url, "temp/CreatePrimaryKeys.sql"); mbz_download_file($g_pk_url, "replication/CreatePrimaryKeys.sql");
unlink("temp/CreateFunctions.sql"); unlink("replication/CreateFunctions.sql");
mbz_download_file($g_func_url, "temp/CreateFunctions.sql"); mbz_download_file($g_func_url, "replication/CreateFunctions.sql");
return 1; return 1;
} }


Expand Down Expand Up @@ -754,11 +754,12 @@ sub mbz_unzip_mbdump {
my $file = $_[0]; my $file = $_[0];
print localtime() . ": Uncompressing $file... "; print localtime() . ": Uncompressing $file... ";
mkdir("mbdump"); mkdir("mbdump");
system("bunzip2 -f replication/$file");
system("tar -xf replication/" . substr($file, 0, length($file) - 4) . " -C replication");
if($^O eq "MSWin32") { if($^O eq "MSWin32") {
system("$g_mv replication\\mbdump\\* mbdump >nul"); system("$g_mv replication\\mbdump\\* mbdump >nul");
system("bunzip2 -f replication/$file");
system("tar -xf replication/" . substr($file, 0, length($file) - 4) . " -C replication");
} else { } else {
system("tar -xjf replication/$file -C replication");
system("$g_mv replication/mbdump/* mbdump"); system("$g_mv replication/mbdump/* mbdump");
} }
print "Done\n"; print "Done\n";
Expand Down Expand Up @@ -792,8 +793,12 @@ sub mbz_unzip_replication {
my $id = $_[0]; my $id = $_[0];
print localtime() . ": Uncompressing... "; print localtime() . ": Uncompressing... ";
mkdir("replication/$id"); mkdir("replication/$id");
system("bunzip2 -f replication/replication-$id.tar.bz2"); if($^O eq "MSWin32") {
system("tar -xf replication/replication-$id.tar -C replication/$id"); system("bunzip2 -f replication/replication-$id.tar.bz2");
system("tar -xf replication/replication-$id.tar -C replication/$id");
} else {
system("tar -xjf replication/replication-$id.tar.bz2 -C replication/$id");
}
print "Done\n"; print "Done\n";
return 1; return 1;
} }
Expand Down
3 changes: 0 additions & 3 deletions temp/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion temp/blank.file

This file was deleted.

0 comments on commit c357f34

Please sign in to comment.