简体   繁体   English

Perl DBI模块不会引发异常

[英]Perl DBI module do not raise exception

I try to run some statement, which will fail, in do() method with DBI RaiseError flag is ON, but it doesn`t raise an exception. 我尝试在do()方法中使用DBI RaiseError标志为ON的情况下运行某些语句,该语句将失败,但不会引发异常。

use strict;
use warnings;
use DBI;

my $dbh = DBI->connect("DBI:mysql:database=test;host=192.168.10.101",
                        "test", "123456", {'RaiseError' => 1});

eval { $dbh->do("DROP TABLE foo") }; # foo table not exist
if ($@) {
    print "Dropping foo failed: $@\n";
} else {
    print "ok\n";
}

This code return ok instead error. 此代码返回ok而不是错误。

I have this problem only on Windows 7 machine. 我仅在Windows 7计算机上有此问题。 (When I run this code on Linux exception is raised.) Is it a bug? (当我在Linux上运行此代码时,会引发异常。)这是一个错误吗?

Perl version: 5.16.3, DBI version: 1.623, DBD::mysql version: 4.022 Perl版本:5.16.3,DBI版本:1.623,DBD :: mysql版本:4.022

将DBD :: mysql更新到最新版本对我有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM