Re: psql :: support for \ev viewname and \sv viewname - Mailing list pgsql-hackers

From Tom Lane
Subject Re: psql :: support for \ev viewname and \sv viewname
Date
Msg-id 9640.1435941052@sss.pgh.pa.us
Whole thread Raw
In response to Re: psql :: support for \ev viewname and \sv viewname  (Jeevan Chalke <jeevan.chalke@enterprisedb.com>)
Responses Re: psql :: support for \ev viewname and \sv viewname
List pgsql-hackers
Jeevan Chalke <jeevan.chalke@enterprisedb.com> writes:
> Patch looks excellent now. No issues.
> Found a typo which I have fixed in the attached patch.

Starting to look at this ...

The business with numbering lines from SELECT seems to me to be completely
nonsensical.  In the first place, it fails to allow for views containing
WITH clauses.  But really it looks like it was cargo-culted over from
\ef/\sf without understanding why those commands number lines the way
they do.  The reason they do that is that for errors occurring inside a
function definition, the PL will typically report a line number relative
to the function body text, and so we're trying to be helpful about
interpreting line numbers of that kind.  But there's no comparable
behavior in the case of a view.  If you fat-finger a view, you'll get
a line number relative to the text of the whole CREATE command, eg

regression=# create or replace view z as
regression-# select 1/col
regression-# from bar;
ERROR:  relation "bar" does not exist
LINE 3: from bar;            ^

So AFAICS, \ev and \sv should just number lines straightforwardly, with
"1" being the first line of the CREATE command text.  Am I missing
something?
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pgbench - allow backslash-continuations in custom scripts
Next
From: Fujii Masao
Date:
Subject: Re: WAL logging problem in 9.4.3?