Re: psql shows line number

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Marko Tiikkaja <marko(at)joh(dot)to>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql shows line number
Date: 2013-11-26 15:37:14
Message-ID: CAHyXU0z53KivOSqmMozE=hz1grBCyAM9Pq1j+cEeFTcHJnXn2w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 26, 2013 at 9:22 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Marko Tiikkaja <marko(at)joh(dot)to> writes:
>> On 11/26/13 2:24 PM, Pavel Stehule wrote:
>>> yes, but we can define new statement like \sq+ (Show Query)
>
>> There's already \p; might not be too difficult to add a \p+ which would
>> also show the line numbers.
>
> I don't actually see the point of this. If you're working with queries
> that are long enough that counting lines is even slightly difficult,
> surely you're going to use \e to correct the problem? So it seems to
> me that the existing "\e nnn" facility pretty much does what's needed,
> and there's no great need to clutter your regular display with line
> numbers.

I agree in the sense line numbers don't help. But \e is not really a
solution to the problem. A pretty common thing for me to see (as an
artifact of my styling) in the log:

ERROR: syntax error at or near "from"
LINE 223: from
^

Not very helpful. Also good luck if your SQL is dynamically
generated. What I think would help *would* be able to optionally add
a some lines of context: then you'd at least have a shot at eyeballing
the error etc.

merlin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2013-11-26 15:46:48 Re: UNION ALL on partitioned tables won't use indices.
Previous Message Tom Lane 2013-11-26 15:22:50 Re: psql shows line number