· 9 years ago · May 31, 2017, 08:36 AM
1# share/sql/000_info.sql: <feff>DROP TABLE IF EXISTS `info`;
2# CREATE TABLE `info` (
3# `name` varchar(50) NOT NULL default '',
4# `type` varchar(20) default NULL,
5# `opus_lib` varchar(50) NOT NULL default '',
6# PRIMARY KEY (`name`)
7# ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
8
9
10The code:
11
12
13my @files = sort glob( File::Spec->catfile('share', 'sql', '*.sql') );
14foreach my $file (@files) {
15 local $/;
16 open(my $fh, '<', $file) or die "$file: $!";
17 my $file_text = <$fh>;
18 push @sql, $file_text;
19 Test::More::diag("$file: $file_text");
20}
21
22my $dbh = DBI->connect($mysqld->dsn(dbname => 'test'), undef, undef);
23$dbh->{RaiseError} = 1;
24$dbh->do(q{set storage_engine=INNODB});
25$dbh->do($_) for @sql;
26
27
28The error:
29
30
31DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ?DROP TABLE IF EXISTS `info`;
32CREATE TABLE `info` (
33 `name` va' at line 1 at t/collateral/lib/mysql/Indicator/ConfigData.pm line 112.
34DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ?DROP TABLE IF EXISTS `info`;
35CREATE TABLE `info` (
36 `name` va' at line 1 at t/collateral/lib/mysql/Indicator/ConfigData.pm line 112.
37Compilation failed in require at t/collateral/lib/CommonSetup.pm line 11.
38BEGIN failed--compilation aborted at t/200-mysql.t line 5.
39t/200-mysql.t ..