in reply to DBI execute is not failing when placeholder values are not supplied

(disclaimer : I don't use postgre. Your code fails appropriately when translated to sybase)
two things stand out from the DBD::PG changelog.
0.4   Jun 24, 1997
        - adapted to DBI-0.84:
          o new syntax for DBI->connect !
          o execute returns 0E0 -> n for     SELECT stmt
                                  -1 for non SELECT stmt
                                  -2 on error
0.81 June 13, 1998
	- bug-fix from Rolf Grossmann <grossman@securitas.net>:
	  undefined parameters in an execute statement will be 
	  translated from 'undef' to 'NULL'. Also every parameter 
	  for bind_param() will be quoted by default (escape quote 
	  and backslash). Appropriate tests have been added to test.pl.
The first seems to indicate that a failed exec will not die as may be expected with RaiseError, but rather return an error code, and the second may indicate a behavior where nonexistent params are automatically translated into null, although this might be a peculiar interpretation of this note.
Perhaps contacting the module maintainer is in order.
  • Comment on Re: DBI execute is not failing when placeholder values are not supplied (boo)

Replies are listed 'Best First'.
Re: Re: DBI execute is not failing when placeholder values are not supplied (boo)
by mpeppler (Vicar) on Oct 24, 2001 at 20:50 UTC
    Indeed DBD::Sybase fails on the execute with a somewhat appropriate error message, although the text of the message would seem to indicate that DBD::Sybase doesn't handle this situation as well as it could:
    DBD::Sybase::st execute failed: Server message number=201 severity=16 +state=2 line=0 procedure=*00001600000000_d028c5 text=Procedure *00001 +600000000_d028c5 expects parameter Invalid pointer param number 4, pointer value 0x0 , which was not supplied. Server message number=201 severity=16 state=2 line=0 procedure=*000016 +00000000_d028c5 text=Procedure *00001600000000_d028c5 expects paramet +er Invalid pointer param number 4, pointer value 0x0 , which was not supplied.
    I should probably see if the parameter binding code could be made somewhat more robust...

    Michael

Re: Re: DBI execute is not failing when placeholder values are not supplied (boo)
by runrig (Abbot) on Oct 24, 2001 at 20:45 UTC
    It may be interpretation, but I still think its a bug (missing != undefined). There's a difference between my @arr = (undef) and my @arr = (), because on the first, @arr == 1 and on the second, @arr == 0. And the DBD::Pg code DOES make an effort to check the number of parameters, so if it does find a mismatch, it reports the error rather than just binding NULL to the missing parameters. It shouldn't be any different when supplying no parameters.