I want to add a way for an application to find out what values are
bound to placeholders. This would be most useful in erro handlers.
Indeed, I want to extend the ShowErrorStatement mechanism to also
report the current placeholder values.

I'm currently thinking in terms of a $sth->{ParamValues} attribute
that would return a hash ref. The keys of the hash would naturally be
the parameter name ('1', '2', etc., or ":foo", ":bar" for drivers that
support named placeholders) and the values would be the, er, values.

That's all pretty straighforward but, as always, I have efficiency
high on my list of priorities and have some concerns here.

One simplistic approach to implementing this in the drivers is to
update the hash on every call to bind_param or execute. (The DBI
could possibly provide this as an optional service to drivers.)
But that would obviously have some impact on performance.

Another is to let the driver 'recover' the information from its
internal structures (or possibly the database API) when the ParamValues
attribute is required. That's generally better in that there would
be no performance cost if the driver already has sufficient information
available. I suspect most would - it's certainly essential for the
implementation of bind_param(). For execute(@values) a driver may
need to keep a copy of of the values, but a cheap array would suffice
for that and the ParamValues attribute FETCH code can translate the
array into a suitable hash.

A further option (for non-pure-perl) drivers is to use a boolean flag
(perhaps $h->{KeepParamValues}=1) to avoid the overheads unless the
application has asked for it. Setting ShowErrorStatement would probably
automatically set KeepParamValues.

Any thoughts on this rambling?

Tim.

Reply via email to