Re: psql history and "-- lines"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Дилян Палаузов <dpa-postgres(at)aegee(dot)org>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: psql history and "-- lines"
Date: 2017-05-06 01:25:23
Message-ID: 19006.1494033923@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Fri, May 5, 2017 at 1:52 PM, Дилян Палаузов <dpa-postgres(at)aegee(dot)org>
> wrote:
>> Could you plexe alter psql, so that it logs two lines in the history for
>> the mentioned case?

> It probably should only behave as you suggest in --single-line mode...

I'm not exactly convinced that the proposed change would be an
improvement. Consider code along the lines of (actual example
from system_views.sql):

--
-- Redeclare built-in functions that need default values attached to their
-- arguments. It's impractical to set those up directly in pg_proc.h because
-- of the complexity and platform-dependency of the expression tree
-- representation. (Note that internal functions still have to have entries
-- in pg_proc.h; we are merely causing their proargnames and proargdefaults
-- to get filled in.)
--

CREATE OR REPLACE FUNCTION
pg_start_backup(label text, fast boolean DEFAULT false, exclusive boolean DEFAULT true)
RETURNS pg_lsn STRICT VOLATILE LANGUAGE internal AS 'pg_start_backup'
PARALLEL RESTRICTED;

Would you really want each of those -- lines to be their own history
entry?

Another angle to think about is /* ... */ comments, which you really
can't break into separate lines without creating a syntactically-invalid
mess. That type of comment also creates the possibility of input like

/* foo
* bar */ select ...

There isn't any very nice way to separate this comment from the SQL query
for history purposes.

In my own usage, I think having leading comments being treated as
part of the SQL command is a good thing --- they're sort of a unit,
in most cases.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message rinto r john 2017-05-06 05:44:30 error- how to solve-reg
Previous Message Bill Parker 2017-05-05 21:41:00 Re: Postgresql and Clang Static Analyzer