A few days ago I started writing apps using Mason. For some reason the following code;

my $sql = "this is not sql" ; my $sth = $dbh->prepare($sql) or $m->abort(500) ;
does not trigger the abort, finding this a bit strange, I then ran the following under mod_perl
use DBI ; my $r = Apache->request; $r->content_type("text/html"); $r->send_http_header(); $dbh = DBI->connect('dbi:mysql:test:localhost', 'user', 'pass' ); my $sql = "blah blah blah" ; my $sth = $dbh->prepare($sql) or die('sql prepare error'); $sth->execute() ; my ($name) = $sth->fetchrow_array; $r->print( ".$name.\n") ;

In both cases the DBD::mysql::st error is written to the error log, but not the die error from my program. To try and prevent myself from going mad, I did the exact same thing using traditional cgi and still no die() error. Even if the script is executed from the command line it still doesn't die!!

Shouldn't prepare return a undefined reference on error, forcing the die to be executed?

If it helps, I'm running Debian Woody, with Perl 5.6.1 and DBI 1.31


In reply to $dbh->prepare not triggering die by Nomis52

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.