Re: [COMMITTERS] pgsql: Correct some errors and do some SGML

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Neil Conway <neilc(at)samurai(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Correct some errors and do some SGML
Date: 2006-04-02 09:16:55
Message-ID: 20060402091654.GA12964@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Alvaro Herrera wrote:
> Neil Conway wrote:
> > On Sun, 2006-04-02 at 00:02 -0400, Neil Conway wrote:
> > > Correct some errors and do some SGML police work on the reference pages
> > > for REASSIGN OWNED and DROP OWNED.
> >
> > BTW, I notice that the patch adding these commands also neglected to
> > update psql's tab completion. I'm fairly busy ATM -- would anyone like
> > to take a look at fixing this?
>
> Will do.

Ok, I just applied a simple hack by separating the generators for CREATE
and DROP.

DROP OWNED is a bit kludgy -- I added a constant "element" to the list
of completions to be returned for DROP, which is still
words_after_create. It seems better to do it this way rather than
duplicating the entire list. However, the current implementation for
both is a bit bogus: if you type CREATE FOO <tab> it will list the
existing FOOs, which is nonsensical -- why would you want to create a
FOO using an already existing name? Because of this, I think CREATE
should just emit the list of possible objects to create; only DROP would
complete using the queries.

Also, DROP is wrong when you do something like

ALTER TABLE foo ALTER bar DROP <tab>

If you stop before that last DROP is complete, it shows "DROP DEFAULT"
and "DROP NOT NULL", but as soon as the DROP is complete it shows
instead the list of things to drop:

alvherre=# alter TABLE foo ALTER a D
DROP DEFAULT DROP NOT NULL
alvherre=# alter TABLE foo ALTER a DROP
AGGREGATE DOMAIN LANGUAGE RULE TABLESPACE UNIQUE
CAST FUNCTION OPERATOR SCHEMA TEMP USER
CONVERSION GROUP OWNED SEQUENCE TRIGGER VIEW
DATABASE INDEX ROLE TABLE TYPE

I tried to "fix" it by having the completion for DROP only work when
it's the first word of the buffer, by checking that prev2_wd is NULL.
This doesn't work however, because at this point

alvherre=# DROP<tab>

prev_wd, prev2_wd, prev3_wd and prev4_wd are all "DROP"! This disagrees
with what the comment for previous_word says; this should probably be
fixed, but I wouldn't want to do it this late.

I wonder how far we are from needing a true parser here, if we want to
improve much more.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2006-04-02 17:38:13 pgsql: Update information schema for SQL:2003 and new PostgreSQL
Previous Message Alvaro Herrera 2006-04-02 09:02:42 pgsql: Add tab-completion for REASSIGN OWNED BY and DROP OWNED BY.

Browse pgsql-hackers by date

  From Date Subject
Next Message Qingqing Zhou 2006-04-02 14:20:59 Re: Problem compiling with mingw
Previous Message Alvaro Herrera 2006-04-02 04:29:57 Re: pgsql: Correct some errors and do some SGML