|From:||Andres Freund <andres(at)2ndquadrant(dot)com>|
|To:||Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com>|
|Cc:||Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>|
|Subject:||Re: add line number as prompt option to psql|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
On 2014-08-21 11:43:48 +0900, Sawada Masahiko wrote:
> On Wed, Aug 20, 2014 at 9:00 PM, Jeevan Chalke
> <jeevan(dot)chalke(at)enterprisedb(dot)com> wrote:
> > Hi,
> > I have reviewed this:
> > I have initialize cur_lineno to UINTMAX - 2. And then observed following
> > behaviour to check wrap-around.
> > postgres=# \set PROMPT1 '%/[%l]%R%# '
> > postgres=# \set PROMPT2 '%/[%l]%R%# '
> > postgres=# select
> > postgres-# a
> > postgres-# ,
> > postgres-# b
> > postgres-# from
> > postgres-# dual;
> > It is wrapping to 0, where as line number always start with 1. Any issues?
> > I would like to ignore this as UINTMAX lines are too much for a input
> > buffer to hold. It is almost NIL chances to hit this.
> > However, I think you need to use UINT64_FORMAT while printing uint64
> > number. Currently it is %u which wrap-around at UINT_MAX.
> > See how pset.lineno is displayed.
> > Apart from this, I didn't see any issues in my testing.
> > Patch applies cleanly. make/make install/initdb/make check all are well.
> Thank you for reviewing the patch!
> Attached patch is latest version patch.
> I modified the output format of cur_lineno.
I like the feature - and I wanted to commit it, but enough stuff turned
up that I needed to fix that it warrants some new testing.
Stuff I've changed:
* removed include of limits.h - that probably was a rememnant from a
* removed a trailing whitespace
* expanded the documentation about %l. "The current line number" isn't
very clear. Of a file? Of all lines ever entered in psql? It's now
"The line number inside the current statement, starting from
* Correspondingly I've changed the variable's name to stmt_lineno.
* COPY FROM ... STDIN/PROMPT3 was broken because a) the promp was only generated
once b) the lineno wasn't incremented.
* CTRL-C didn't reset the line number.
* Unfortunately I've notice here that the prompting is broken in some
postgres=# SELECT 1,
│ ?column? │ ?column? │ ?column? │
│ 1 │ 2 ↵│ 3 │
│ │ 2b ↵│ │
│ │ 2c ↵│ │
│ │ 2d │ │
postgres=# SELECT 1,
That's rather inconsistent...
I've attached my version of the patch. Note that I've got rid of all the
PSCAN_INCOMPLETE checks... Please test!
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
|Next Message||Fabrízio de Royes Mello||2014-08-26 13:25:50||Re: Patch to add support of "IF NOT EXISTS" to others "CREATE" statements|
|Previous Message||Heikki Linnakangas||2014-08-26 13:20:41||Re: Patch to add support of "IF NOT EXISTS" to others "CREATE" statements|