On 2014-08-21 11:43:48 +0900, Sawada Masahiko wrote:
> On Wed, Aug 20, 2014 at 9:00 PM, Jeevan Chalke
> <jeevan.chalke@enterprisedb.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[18446744073709551613]=# \set PROMPT2 '%/[%l]%R%# '
> > postgres[18446744073709551613]=# select
> > postgres[18446744073709551614]-# a
> > postgres[18446744073709551615]-# ,
> > postgres[0]-# b
> > postgres[1]-# from
> > postgres[2]-# 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
previous version
* 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
<literal>1</>."
* 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
common cases:
postgres[1]=# SELECT 1,
postgres[2]-# '2
postgres[2]'# 2b
postgres[2]'# 2c
postgres[2]'# 2d',
postgres[3]-# 3;
┌──────────┬──────────┬──────────┐
│ ?column? │ ?column? │ ?column? │
├──────────┼──────────┼──────────┤
│ 1 │ 2 ↵│ 3 │
│ │ 2b ↵│ │
│ │ 2c ↵│ │
│ │ 2d │ │
└──────────┴──────────┴──────────┘
(1 row)
postgres[1]=# SELECT 1,
'2
2b
2c
2d',
3
postgres[7]-#
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!
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services