Re: psql tab completion for DO blocks

David Fetter <david@fetter.org>

From: David Fetter <david@fetter.org>
To: Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>
Cc: Bruce Momjian <bruce@momjian.us>, Robert Haas <robertmhaas@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Peter Eisentraut <peter_e@gmx.net>, PG Hackers <pgsql-hackers@postgresql.org>
Date: 2010-02-11T20:27:41Z
Lists: pgsql-hackers
On Wed, Feb 10, 2010 at 11:00:00AM +0900, Takahiro Itagaki wrote:
> Bruce Momjian <bruce@momjian.us> wrote:
> 
> > Where are we on this patch?  We should at least implement the completion
> > for 'LANGUAGE' in 'DO', and use the existing pg_language query for
> > completion.  I am attaching a patch that does exactly this.
> 
> I don't think we need the patch except adding DO to the top-level sql_commands.
> 
> Syntax of DO command is:
>     DO code [ LANGUAGE lang_name ]

That's not the only syntax.

    DO [LANGUAGE lang_name] code

also works, e.g.:

CREATE LANGUAGE plperl;
CREATE TABLE foo(id SERIAL PRIMARY KEY, t TEXT);
DO LANGUAGE plperl $$spi_exec_query(q[INSERT INTO foo(t) VALUES('aaa')]);$$;
SELECT * FROM foo;

The DO LANGUAGE lang_name code syntax is much clearer, as far as I'm
concerned, than putting the code block before the language anyhow. :)

Cheers,
David.
-- 
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate