From 14418eda615fd09ef77c605356d2e63cebe9274e Mon Sep 17 00:00:00 2001 From: psc Date: Fri, 20 May 2011 12:49:36 +0000 Subject: [PATCH] Add error handling to the create_table function of the DBsqlite module, and abort recreate_fai_release_db and recreate_fai_server_db events if create_table fails git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@20891 594d385d-05f5-0310-b6e9-bd551577e9d8 --- trunk/gosa-si/modules/DBsqlite.pm | 8 ++++++++ trunk/gosa-si/server/events/gosaTriggered.pm | 18 +++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/trunk/gosa-si/modules/DBsqlite.pm b/trunk/gosa-si/modules/DBsqlite.pm index e6ec1048c..4b8f60a66 100644 --- a/trunk/gosa-si/modules/DBsqlite.pm +++ b/trunk/gosa-si/modules/DBsqlite.pm @@ -133,11 +133,19 @@ sub create_table { my $col_names_string = join(", ", @col_names); my $sql_statement = "CREATE TABLE IF NOT EXISTS $table_name ( $col_names_string )"; my $res = $self->exec_statement($sql_statement); + if ($@) { + &main::daemon_log("0 ERROR: CREATE TABLE IF NOT EXISTS $table_name failed", 1); + return 1; + } # Add indices if(defined($index_names_ref) and ref($index_names_ref) eq 'ARRAY') { foreach my $index_name (@$index_names_ref) { $self->exec_statement("CREATE ".(($index_name eq 'id')?'UNIQUE':'')." INDEX IF NOT EXISTS $index_name on $table_name ($index_name);"); + if ($@) { + &main::daemon_log("0 ERROR: CREATE $index_name on $table_name failed", 1); + return 1; + } } } diff --git a/trunk/gosa-si/server/events/gosaTriggered.pm b/trunk/gosa-si/server/events/gosaTriggered.pm index 42f2189fc..d7ef85131 100644 --- a/trunk/gosa-si/server/events/gosaTriggered.pm +++ b/trunk/gosa-si/server/events/gosaTriggered.pm @@ -162,12 +162,14 @@ sub recreate_fai_server_db { my $res = $main::job_db->exec_statement($sql_statement); } - $main::fai_server_db->create_table("new_fai_server", \@main::fai_server_col_names); + my $res = $main::fai_server_db->create_table("new_fai_server", \@main::fai_server_col_names); + if ($res) { + return ( $out_msg ); + } &main::create_fai_server_db("new_fai_server",undef,"dont", $session_id); $main::fai_server_db->move_table("new_fai_server", $main::fai_server_tn); - - my @out_msg_l = ( $out_msg ); - return @out_msg_l; + + return ( $out_msg ); } @@ -182,12 +184,14 @@ sub recreate_fai_release_db { my $res = $main::job_db->exec_statement($sql_statement); } - $main::fai_release_db->create_table("new_fai_release", \@main::fai_release_col_names); + my $res = $main::fai_release_db->create_table("new_fai_release", \@main::fai_release_col_names); + if ($res) { + return ( $out_msg ); + } &main::create_fai_release_db("new_fai_release", $session_id); $main::fai_release_db->move_table("new_fai_release", $main::fai_release_tn); - my @out_msg_l = ( $out_msg ); - return @out_msg_l; + return ( $out_msg ); } -- 2.30.2