Re: add line number as prompt option to psql

From: Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com>
To: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: add line number as prompt option to psql
Date: 2014-07-09 17:32:35
Message-ID: CAD21AoBt6jb3pXAX1_Cf33FPHwX+a__-OpGndbTcb7QSKRLybQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 7, 2014 at 8:33 PM, Jeevan Chalke
<jeevan(dot)chalke(at)enterprisedb(dot)com> wrote:
> Hi,
>
> Found two (A and B) issues with latest patch:
>
> A:
> -- Set prompts
> postgres=# \set PROMPT1 '%/[%l]%R%# '
> postgres[1]=# \set PROMPT2 '%/[%l]%R%# '
>
> postgres[1]=#
> postgres[1]=# select
> postgres[2]-# *
> postgres[3]-# from
> postgres[4]-# abc;
> ERROR: relation "abc" does not exist
> LINE 4: abc;
> ^
>
> Now I used \e to edit the source. Deleted last line i.e. "abc;" and
> returned to prompt, landed at line 4, typed "abc;"
>
> postgres[1]=# \e
> postgres[4]-# abc;
> ERROR: relation "abc" does not exist
> LINE 5: abc;
> ^
>
> In above steps, error message says "LINE 5", where as on prompt "abc" is at
> line 4.
>
>
> postgres[1]=# select
> *
> from
> abc;
> ERROR: relation "abc" does not exist
> LINE 4: abc;
> ^
>
> Here I again see error at line 4. Something fishy. Please investigate.
> Looks like bug in LINE numbering in error message, not sure though.
> But with prompt line number feature, it should be sync to each other.
>
>
> B:
> However, I see that you have removed the code changes related to INT_MAX.
> Why?
> I have set cur_line to INT_MAX - 2 and then observed that after 2 lines I
> start getting negative numbers.
>

Thank you for reviewing the patch.
I have revised the patch, and attached.

> A:
> But with prompt line number feature, it should be sync to each other.

This patch can handle this case.

> B:
> However, I see that you have removed the code changes related to INT_MAX.
> Why?

I had mistake to remove them. I added them to latest patch.

Regards,

-------
Sawada Masahiko

Attachment Content-Type Size
psql-line-number_v3.patch application/octet-stream 4.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-07-09 17:33:02 Re: LEFT JOINs not optimized away when not needed
Previous Message Tom Lane 2014-07-09 17:30:40 Re: IMPORT FOREIGN SCHEMA statement