We are way off the original topic now... I did look at the DBI source code as chromatic suggested... I guess this is the sort of thing where everybody can claim "victory" depending upon their point of view!

The code in DBI's connect() related to RaiseError:

unless ( $attr->{HandleError} && $attr->{HandleError}->($msg, $drh, $dbh)) { Carp::croak($msg) if $attr->{RaiseError}; Carp::carp ($msg) if $attr->{PrintError}; }
Ok, fair enough. If RaiseError is true, then the DBI croaks on an error.

I was pondering a different question. I was wondering what happens if connect() fails because the arguments supplied are are of wrong number or type - in a more general case, what happens if the arg list is such that the DBI connect cannot recognize that RaiseError is intended to be 'on'? That case is handled by this DBI code:

Carp::croak('Usage: $class->connect([$dsn [,$user [,$passwd [,\%attr]] +]])') if (ref $old_driver or ($attr and not ref $attr) or ref $pass);
So I guess a more accurate description of what the DBI does: The DBI will croak no matter what the state of RaiseError if it detects an invalid argument list to connect(). I also found out through testing that if you misspell "Raiseerror", the DBI also croaks - it will croak for any syntax error that is detected (the spec doesn't say this, but the code does it).

I'm testing right now with SQLite which doesn't have users or passwords so there are scenarios with MySQL that I am unable to test.

At the end of the day, if I omit the "or die" clause to a connect (which also specifies the RaiseError attribute), then I would have to be 100% sure that the "or die" code can never be executed under any circumstance. I can't prove that and that is certainly not part of the public specification.

Now I know that the "hey Mom, Jimmy's mom let's him to X" (the other guys do it defense) is pretty weak, but I learned my "bad" habit about this from Programming the Perl DBI" by Alligator Descartes and Tim Bunce.

I think that I am on very solid ground with my current practice and recommendations.

Back to original question in the original post!!!
I still have not found any way at all for a prepare of the INSERT statement to succeed where one of the columns does not exist in the table.


In reply to Re^3: DBI not erroring out on Insert by Marshall
in thread DBI not erroring out on Insert by rethaew

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.