Re: :PgSQL: More Queestions

From: Tim Bunce <Tim(dot)Bunce(at)pobox(dot)com>
To: Rudy Lippan <rlippan(at)remotelinux(dot)com>
Cc: Tim Bunce <Tim(dot)Bunce(at)pobox(dot)com>, Adam Witney <awitney(at)sghms(dot)ac(dot)uk>, David Wheeler <david(at)wheeler(dot)net>, dbi-dev(at)perl(dot)org, pgsql-interfaces <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: :PgSQL: More Queestions
Date: 2002-11-22 09:31:26
Message-ID: 20021122093126.GC24516@dansat.data-plan.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Thu, Nov 21, 2002 at 03:54:56PM -0500, Rudy Lippan wrote:
> On Thu, 21 Nov 2002, Tim Bunce wrote:
>
> > Or ignore colons that have a digit as the previous character
> > as that would never be a placeholder.
>
> Since DBD::Pg emulates place holders, it is possible to have them after a
> digit.

Possible sure, but place holder values should always be viewed and used
as complete lexical tokens. Being over-clever with 'token concatenation'
by doing things like "SELECT * FROM log_:1" and binding a date like
20021122 as a number to select from table log_20021122 is a bad idea.

(FYI I'm not familiar with PostgresSQL's dialect of SQL.)

> I thought that using the [ as a literal marker might break less existing
> code, for example $d->prepare->("insert into foo (int_date)
> VALUES(200301:1"); Or any such other silly uses.

Such silly uses deserve to be broken and replaced with
$d->prepare->("insert into foo (int_date) VALUES(:1)")
or
$d->prepare->("insert into foo (int_date) VALUES(200301$foo)")

> And besides the array
> data type will probably be used less than other types.
>
> The best solution might be to treat [] as a literal wrt placeholders, but
> allow [:1 for the [:1] case, which is the only case that would work with
> the existing code. Currently, For [:1:2] preparse would see 2 place holders

Viewing place holder values as complete lexical tokens make that
not a sensible thing to do. And, for the only valid uses of
concatenated placeholders, the same effect could be achieved with
one placeholder and concatenating the values bound to it.

> and for [:1::2] preparse would see a place holder and a cast.

Is "::2" a valid cast that people would actually use in real code?

So far I think I'd just extend my original proposal to say
"Ignore colons that have a digit or colon as the previous character".

Tim.

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Bruce Momjian 2002-11-22 15:46:11 Re: Frontend/Backend protocol changes?
Previous Message Bruce Badger 2002-11-22 06:38:42 Re: Frontend/Backend protocol changes?