Commit bd2cebb8 authored by Monty's avatar Monty Committed by Sergei Petrunia

Fixed check_costs.pl to always create table if table does not exists

This allows one to always use --skip-create-table for repeated runs.
parent 587646a4
......@@ -234,7 +234,7 @@ sub test_engine()
setup_engine($engine);
setup($opt_init_query);
$table= $base_table . "_$engine";
if (!defined($opt_skip_create))
if (!defined($opt_skip_create) || !check_if_table_exist($table))
{
my $index_type="";
......@@ -270,7 +270,7 @@ sub test_engine()
ENGINE= $engine")
or die "Got error on CREATE TABLE: $DBI::errstr";
}
$cur_rows= get_row_count();
$cur_rows= get_row_count($table);
if ($cur_rows == 0 || !defined($opt_skip_create))
{
$dbh->do("insert into $table select
......@@ -976,6 +976,8 @@ $sth->execute || die "Got error on '$query': " . $dbh->errstr . "\n";;
sub get_row_count()
{
my ($table)= @_;
my ($query, $sth, $row);
$query= "select count(*) from $table";
$sth= $dbh->prepare($query) || die "Got error on '$query': " . $dbh->errstr . "\n";
if (!$sth->execute)
......@@ -994,6 +996,7 @@ sub get_row_count()
sub get_variable()
{
my ($name)= @_;
my ($query, $sth, $row);
$query= "select @@" . $name;
if (!($sth= $dbh->prepare($query)))
{
......@@ -1003,3 +1006,18 @@ sub get_variable()
$row= $sth->fetchrow_arrayref();
return $row->[0];
}
sub check_if_table_exist()
{
my ($name)= @_;
my ($query,$sth);
$query= "select 1 from $name limit 1";
$sth= $dbh->prepare($query) || die "Got error on '$query': " . $dbh->errstr . "\n";
print $sth->fetchrow_arrayref();
if (!$sth->execute || !defined($sth->fetchrow_arrayref()))
{
return 0; # Table does not exists
}
return 1;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment