Re: proposal: alternative psql commands quit and exit

2017-12-09 Thread Daniel Vérité
Everaldo Canuto wrote:

> >
> > postgres=> select 2+2
> >2-> help
> >3-> quit
> >4-> exit
> 
> 
> I like it! Maybe another proposal to change PROMPT2?

Thanks. Yes, I think it should be a different proposal.

On closer inspection, mysql doesn't make a real effort
to align prompts, the secondary prompt happens
to coincide with the default primary prompt, but
when it's non-default, the alignment is lost.
Their secondary prompt does not seem to be 
configurable.

By contrast PROMPT2 is fully configurable in psql.
The issue of alignment is non-trivial if we wish to retain the
nice-to-have property that if you copy-paste psql session
in an editor, the prompting can generally be filtered out
with a simple column-cut.

Best regards,
-- 
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite



Re: proposal: alternative psql commands quit and exit

2017-12-09 Thread Daniel Vérité
Tom Lane wrote:

>  The typical interaction I'd foresee is more like
> 
> postgres=> select 2+2  (user forgets semicolon)
> postgres-> help
> postgres-> quit
> postgres-> exit

A part of this is due to the default PROMPT2 being too similar to PROMPT1.
The significance of '=' turning to '-' is easily lost on newbies.

By comparison, the mysql client seems a bit more intuitive
for this, with this presentation:

mysql> select 2+2
-> help
-> quit
-> exit
The "mysql" part is replaced by spaces on secondary prompts, so
visually it's more obvious that it's a different state.
The space-padding is necessary to keep the user input left-aligned.

Maybe PROMPT2 could be improved in that direction in psql.
For instance, I wonder if it'd be doable to have PROMPT2 with the line
number and proper alignment, so the above session could end up displayed
like this:

postgres=> select 2+2
   2-> help
   3-> quit
   4-> exit

That way, the more lines are typed, the more it becomes obvious that
you're in a multi-line statement. Plus numbering lines might
be useful in general, anyway.


Best regards,
-- 
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite



Re: proposal: alternative psql commands quit and exit

2017-12-08 Thread Daniel Vérité
Everaldo Canuto wrote:

> Oracle's sqlplus uses "quit" or "exit" and MySQL client can be exited using
> "quit" and "exit" but for compatibility with psql, it also supports "\q"
> and "\quit".

When looking at the most popular postgres questions on stackoverflow:

https://stackoverflow.com/questions/tagged/postgresql?sort=votes

the first one (most up-voted) happens to be:

"How to exit from PostgreSQL command line utility: psql"

now at 430k views and 1368 upvotes.

Independently of the syntax-compatibility with other tools,
it can be a miserable experience for people who almost
never use psql to type "quit" or "exit" after they're done
with whatever they wanted to do, and nothing
happens except a tiny change in the prompt.

Implementing it is easy, but it might be a hard sell for the project
because it creates a precedent.
The next question in that list is "PostgreSQL DESCRIBE TABLE", so
why not implement "desc tablename;" as a synonym for
"\d tablename"?

The question after that is "Show tables in PostgreSQL", so
why not implement "show tablename;"? Well, this one is
impossible because SHOW is already a SQL command that does
something else, so that's already the end of that road to
compatibility.

Personally I'm +1 on accepting the additional "exit" and "quit"
as synonyms for \q, to comply with the "Do What I Mean" UX rule,
rather than just compatibility with other tools.
I guess this is why "help" is already a synonym of \h.


Best regards,
-- 
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite