-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Is it a string that's sent, or the identifier?  For NULL, it is either an
> identifier (not quoted) or Perl undef that denotes NULL in the DBMS.  I'm
> not sure how you'd represent DEFAULT in Perl, or as a string rather than an
> identifier.

DBI (or DBD) currently maps undef to the literal string NULL before sending it
to the backend. To achieve other values, we have to use something besides a
simple scalar. In DBD::Pg's case, we're using a blessed ref, so the backend
does something like this:

if (! defined $value) {
        $value = "NULL";
}
elsif (ref $value eq 'DBD::Pg::DefaultValue') {
        $value = "DEFAULT";
}
else {
        $value = quote($value);
}

The user would do something like this:

$sth->execute(12,undef,'chocolate',$DBDPG_DEFAULT,99);

Ideally once it's added to DBI the code becomes a little more portable:

$sth->execute(12,undef,'chocolate',$DBI_DEFAULT,99);

I'm working on expanding this into a more general framework, as there are
some other "magic" variables that could also be usefully sent, such as
CURRENT_TIMESTAMP.

- --
Greg Sabino Mullane [EMAIL PROTECTED]
PGP Key: 0x14964AC8 200604271801
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iD8DBQFEUUAZvJuQZxSWSsgRAku7AJ4oios4B4DeHNFry+VwFnd5z6NGMgCfTPsS
NEqjDqwKEyyWubisf4PEwKQ=
=FLUs
-----END PGP SIGNATURE-----


Reply via email to