[PD] [psql] object hand-holding
matju at artengine.ca
Mon Dec 10 20:55:22 CET 2007
On Mon, 10 Dec 2007, Jamie Bullock wrote:
> On Mon, 2007-12-10 at 12:18 -0500, Mathieu Bouchard wrote:
>> This almost *never* happens.
> I take your point, but I think you are exaggerating slightly.
Not in this context. We're only looking at the average query; I don't even
mean an actual query, but statistics about queries. If only 10% of them
don't have arguments, then unless there's a huge difference in object
count (which there is not), it doesn't make much of a difference on the
total object count. And that is only supposing that you need something
like an extra [bang] before your sql query to prevent [psql] from getting
> I just looked at the code for a database driven web app I worked on
> recently. It uses 30 queries, 3 of which have no variables. Out of these
> three only one doesn't 'overlap' with other queries and therefore can't
> be refactored. Maybe 1 in 30 is almost never?
Yes. to contrast this, 3% wouldn't be "almost never" if, for example, the
issue was whether to support something at all, or not. In that case, if
the cost of a workaround is 50x the wanted feature, or if a workaround is
impossible, it can weigh a lot in the design priorities.
> Good point! I think Hans' recent suggestion addresses the problem. It
> also occurs to me that for Postgres at least, we have the PREPARE
> statement, which addresses the optimisation and injection issues you
> have raised. Technically [psql] already supports PREPARE except that
> PREPARE uses the '$' character as its placeholder identifier, and '$1'
> can't be passed around as a symbol in Pd. I think it might be
> interesting to use the '?' notation currently under discussion as an
> interface to PREPARE though.
The '?' notation is either MySQL-specific or PerlDBI-specific or both. By
PerlDBI I mean any database interface (in any language) following's Perl
DBI package closely enough. I guess that if you use DBI-over-Postgres,
then it replaces all ? by $ automatically.
$ alone can be used in pd as long as it is not followed by a digit, but I
wouldn't encourage that, if it's not used in a [expr] way, because the use
of '$' alone would prevent you from later supporting an [expr] syntax in a
way compatible with yourself.
Using $f1 or $s1 in [expr] style, or perhaps $e1 to mean "any atom" (e
stands for "element"), would be useful, though less required than the
placeholder feature itself.
_ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada
More information about the Pd-list