Commit f27d2825 authored by Matthieu Muffato's avatar Matthieu Muffato
Browse files

Fixed the CREATE/DROP database statements for missing / extra arguments

parent b259a1bb
......@@ -216,8 +216,11 @@ sub to_cmd {
if($driver eq 'sqlite') {
return ['rm', '-f', $dbname];
} elsif(!$2) {
$sqlcmd = "$1 $dbname";
} else {
if (not $dbname) {
die "'DROP DATABASE' needs a database name\n";
}
$sqlcmd = "$1 $dbname" unless $2;
$dbname = '';
}
} elsif($sqlcmd =~ /(CREATE\s+DATABASE\s*?)(?:\s+(\w+))?/i ) {
......@@ -225,12 +228,15 @@ sub to_cmd {
if($driver eq 'sqlite') {
return ['touch', $dbname];
} elsif(!$2) {
} else {
if (not $dbname) {
die "'CREATE DATABASE' needs a database name\n";
}
my %limits = ( 'mysql' => 64, 'pgsql' => 63 );
if (length($dbname) > $limits{$driver}) {
die "Database name '$dbname' is too long (> $limits{$driver}). Cannot create the database\n";
}
$sqlcmd = "$1 $dbname";
$sqlcmd = "$1 $dbname" unless $2;
$dbname = '';
}
}
......
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