- if ($param{DBType} =~ /^mysql$/i) {
- my $sql = "SHOW DATABASES";
- foreach ( &sqlRawReturn($sql) ) {
- $database_exists++ if ($_ eq $param{'DBName'});
- }
-
- unless ($database_exists) {
- &status("Creating database $param{DBName}...");
- my $query = "CREATE DATABASE $param{DBName}";
- &sqlRaw("create(db $param{DBName})", $query);
- }
-
- # retrieve a list of db's from the server.
- my @tables = map {s/^\`//; s/\`$//; $_;} $dbh->func('_ListTables');
- if ($#tables == -1){
- @tables = $dbh->tables;
- }
- &status("Tables: ".join(',',@tables));
- @db{@tables} = (1) x @tables;
-
- } elsif ($param{DBType} =~ /^SQLite(2)?$/i) {
-
- # retrieve a list of db's from the server.
- foreach ( &sqlRawReturn("SELECT name FROM sqlite_master WHERE type='table'") ) {
- $db{$_} = 1;
- }
-
- # create database not needed for SQLite
-
- } elsif ($param{DBType} =~ /^pgsql$/i) {
- # $sql_showDB = SQL to select the DB list
- # $sql_showTBL = SQL to select all tables for the current connection
-
- my $sql_showDB = "SELECT datname FROM pg_database";
- my $sql_showTBL = "SELECT c.relname FROM pg_catalog.pg_class c \
- LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace \
- WHERE c.relkind IN ('r','') AND n.nspname NOT IN ('pg_catalog','pg_toast') and
- pg_catalog.pg_table_is_visible(c.oid)";
-
- foreach ( &sqlRawReturn($sql_showDB) ) {
- $database_exists++ if ($_ eq $param{'DBName'});
- }
-
- unless ($database_exists) {
- &status("Creating PostgreSQL database $param{'DBName'}");
- &status("(actually, not really, please read the INSTALL file)");
- }
-
- # retrieve a list of db's from the server. This code is from mysql above, please check -- troubled
- my @tables = map {s/^\`//; s/\`$//; $_;} &sqlRawReturn($sql_showTBL);
- if ($#tables == -1){
+ if ( $param{DBType} =~ /^mysql$/i ) {
+ my $sql = 'SHOW DATABASES';
+ foreach ( &sqlRawReturn($sql) ) {
+ $database_exists++ if ( $_ eq $param{'DBName'} );
+ }
+
+ unless ($database_exists) {
+ &status("Creating database $param{DBName}...");
+ my $query = "CREATE DATABASE $param{DBName}";
+ &sqlRaw( "create(db $param{DBName})", $query );
+ }
+
+ # retrieve a list of db's from the server.
+ my @tables = map { s/^\`//; s/\`$//; $_; } $dbh->func('_ListTables');
+ if ( $#tables == -1 ) {