Re: psql shows line number - Mailing list pgsql-hackers

From Merlin Moncure
Subject Re: psql shows line number
Date
Msg-id CAHyXU0z53KivOSqmMozE=hz1grBCyAM9Pq1j+cEeFTcHJnXn2w@mail.gmail.com
Whole thread Raw
In response to Re: psql shows line number  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Tue, Nov 26, 2013 at 9:22 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Marko Tiikkaja <marko@joh.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



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: psql shows line number
Next
From: Tom Lane
Date:
Subject: Re: UNION ALL on partitioned tables won't use indices.