Did it help? If yes - maybe you can help me?
On 2nd of September, Andres Freund committed patch:
Add psql PROMPT variable showing which line of a statement is being edited. The new %l substitution shows the line number inside a (potentially multi-line) statement starting from one. Author: Sawada Masahiko, heavily editorialized by me. Reviewed-By: Jeevan Chalke, Alvaro Herrera
This should help some people which get surprised when they type the query, press enter, and it's not executed due to missing ‘, " or ;.
With this patch in place, we can add %l in PROMPT variables in psql.
How does it look?
Without it, if you added new line in query, your psql could have looked like this:
depesz=# select depesz-# * depesz-# from depesz-# pg_class depesz-# limit 3 depesz-# ;
The difference between “=" and “-" was rather minuscule. Of course you could change your PROMPT* variables to better suit your needs, but now we can:
depesz=# \echo :PROMPT1 %/%R%# depesz=# \echo :PROMPT2 %/%R%# depesz=# \set PROMPT1 %/%R% (%l)# depesz=(1)#\set PROMPT2 %/%R% (%l)#
With these in place, previous query looks now:
depesz=(1)#select depesz-(2)#* depesz-(3)#from depesz-(4)#pg_class depesz-(5)#limit 3 depesz-(6)#;
Should be much simpler to spot when psql waits for next line, and when it ran something, just didn't output anything. Cool, thanks 🙂