Thread: prepareable statements

prepareable statements

From
nconway@klamath.dyndns.org (Neil Conway)
Date:
I've attached an updated version of the prepareable statements patch. It
is very similar to the latest patch I posted on -hackers -- the only new
changes are a few comment fixes, an unrelated typo fix, and re-sync
with latest CVS. I'm not aware of any outstanding issues with the patch,
so if you'd like me to change something, let me know.

The current syntax is:

    PREPARE q1(a,b,c) AS ...;

    EXECUTE q1(1,2,3);

    DEALLOCATE q1;

Peter objected to the EXECUTE syntax, whereas Rod Taylor said it was
good. Not really sure which way to go...

Cheers,

Neil

--
Neil Conway <neilconway@rogers.com>
PGP Key ID: DB3C29FC

Attachment

Re: prepareable statements

From
Rod Taylor
Date:
> Peter objected to the EXECUTE syntax, whereas Rod Taylor said it was
> good. Not really sure which way to go...

Why I like Execute:

CALL is for use with functions, so they're different (non-conflicting)
commands.

Works like a function call -- but it's not a function.  It implies your
running something that has been prepared or compiled.  You compile the
source (etc.), then execute the binary.

You prepare the statement, then execute the result.

Lastly, Perl (DBI) uses execute(args) for a prepared statement so it's
somewhat familiar for a large group.


Re: prepareable statements

From
Karel Zak
Date:
On Wed, Jul 31, 2002 at 05:18:16PM -0400, Neil Conway wrote:
> I've attached an updated version of the prepareable statements patch. It
> is very similar to the latest patch I posted on -hackers -- the only new
> changes are a few comment fixes, an unrelated typo fix, and re-sync
> with latest CVS. I'm not aware of any outstanding issues with the patch,
> so if you'd like me to change something, let me know.
>
> The current syntax is:
>
>     PREPARE q1(a,b,c) AS ...;
>
>     EXECUTE q1(1,2,3);
>
>     DEALLOCATE q1;
>
> Peter objected to the EXECUTE syntax, whereas Rod Taylor said it was
> good. Not really sure which way to go...

 I agree with Peter. SQL is not language like C (or others). SQL
 queries seem like English sentence and rather then braces use
 standard words. The construction q1(1,2,3) seems like table 'q1'
 and fields a, b, c or it seems line function call.

 IMHO this your syntax is not consisten with other SQL syntax, it's
 SQL by C/C++ programmer's glasses :-)

 BTW -- Neil, I must thank to you. I'm very glad you finish my old
 ideas and work/experiments and put it official tree. Thanks!

    Karel

--
 Karel Zak  <zakkr@zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/

 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

Re: prepareable statements

From
Neil Conway
Date:
nconway@klamath.dyndns.org (Neil Conway) writes:
> I've attached an updated version of the prepareable statements patch. It
> is very similar to the latest patch I posted on -hackers -- the only new
> changes are a few comment fixes, an unrelated typo fix, and re-sync
> with latest CVS. I'm not aware of any outstanding issues with the patch,
> so if you'd like me to change something, let me know.

Here's the patch, re-synced with latest CVS -- no other changes.

Regarding the syntax debate, my personal preference is to stick with
the current (function-like) syntax, but I'm not too worried about this
point. I'd prefer that the patch be committed in one form or another
reasonably quickly, so that I have enough time to write the
documentation and do some general "polish" work before the beta.

Let me know what changes, if any, still need to be made.

Cheers,

Neil

--
Neil Conway <neilconway@rogers.com>
PGP Key ID: DB3C29FC

Attachment