@@ -, +, @@ not exist --- C4/Installer.pm | 16 +++++++++++++++- installer/data/mysql/updatedatabase.pl | 15 --------------- 2 files changed, 15 insertions(+), 16 deletions(-) --- a/C4/Installer.pm +++ a/C4/Installer.pm @@ -30,7 +30,7 @@ use vars qw(@ISA @EXPORT); BEGIN { require Exporter; @ISA = qw( Exporter ); - push @EXPORT, qw( foreign_key_exists index_exists column_exists ); + push @EXPORT, qw( foreign_key_exists index_exists column_exists TableExists); }; =head1 NAME @@ -527,6 +527,7 @@ sub index_exists { sub column_exists { my ( $table_name, $column_name ) = @_; + return unless TableExists($table_name); my $dbh = C4::Context->dbh; my ($exists) = $dbh->selectrow_array( qq| @@ -537,6 +538,19 @@ sub column_exists { return $exists; } +sub TableExists { # Could be renamed table_exists for consistency + my $table = shift; + eval { + my $dbh = C4::Context->dbh; + local $dbh->{PrintError} = 0; + local $dbh->{RaiseError} = 1; + $dbh->do(qq{SELECT * FROM $table WHERE 1 = 0 }); + }; + return 1 unless $@; + return 0; +} + + =head1 AUTHOR C4::Installer is a refactoring of logic originally from installer/installer.pl, which was --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -17572,21 +17572,6 @@ foreach my $file ( sort readdir $dirh ) { =head1 FUNCTIONS -=head2 TableExists($table) - -=cut - -sub TableExists { - my $table = shift; - eval { - local $dbh->{PrintError} = 0; - local $dbh->{RaiseError} = 1; - $dbh->do(qq{SELECT * FROM $table WHERE 1 = 0 }); - }; - return 1 unless $@; - return 0; -} - =head2 DropAllForeignKeys($table) Drop all foreign keys of the table $table --