From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: proposal: using PQexecParams in psql (using variables as real params) |
Date: | 2009-11-16 08:14:29 |
Message-ID: | 162867790911160014j2e5a2959w274670ddeb9f6191@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2009/11/16 Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>:
>
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
>
>> I propose to add possibility to use psql variables as real query
>> parameters. The goal of this proposal is simplification of creating
>> psql based commands.
>
>> postgres=# \pexec
>> Separately passing parameters is on.
>> postgres=# select upper(:message);
>
> There might be good if we can use both old and new behaviors at once
> instead of \pexec switch. Something like:
>
> SELECT * FROM :tablename WHERE id = $value
>
> BTW, this proposal is a partial solution for scripting in psql.
> But we will want other goodies soon - assignment, if, loop...
> If there is a total solution, it would be better than a partial one.
> I've heard pgAdmin uses pgScript as a client-side language.
> Should we also take the language (or client-side plpgsql) in psql?
I don't would to reimplement pgScript. Personally I prefer some
scripting possibilities in psql too, but when pgScript exists, then we
could to use it. What more - we have a DO statement. So there are
tools. DO is great, now I missing some like USING clause:
DO (tablename varchar, value varchar)
$$
EXECUTE 'SELECT * FROM '|| tablename || 'WHERE id = $1' USING value;
$$ USING :tablename, :value;
I don't would to create new syntax for identifiers - see parallel
thread. Proposed feature is maximally simple and transparent.
>
> Regards,
> ---
> ITAGAKI Takahiro
> NTT Open Source Software Center
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Boszormenyi Zoltan | 2009-11-16 08:14:57 | What is the correct way to extract values from an int8 array in SPI? |
Previous Message | Heikki Linnakangas | 2009-11-16 08:05:58 | Re: [HACKERS] pgsql: /home/peter/commit-msg |