Re: [HACKERS] psql and comments - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: [HACKERS] psql and comments
Date
Msg-id Pine.LNX.4.10.9910071638570.848-100000@peter-e.yi.org
Whole thread Raw
In response to Re: [HACKERS] psql and comments  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
On Oct 6, Bruce Momjian mentioned:

> > postgres=> select 'hi'; -- comment

> But aren't they _in_ a new statement, that begins with '--'?

Good point. But it's still kind of counterintuitive, isn't it? Especially
since something that begins with a '--' can't ever become a useful
statement. The problem seems to be in the parsing stages: the query is
send off before the comment is encountered.

The alternative solution of putting query and comment on the same line
would be
=> select 'hi' -- comment ;
but that doesn't work at all obviously.

Meanwhile it might be worth pondering if
=> select 'hi' -- comment \g
should be allowed, since
=> select 'hi' \g -- comment
does something different. (And try removing that file if you're an
unexperienced user.)

Regarding that last line, I just discovered a possible incompatibility
between the official and my current version. The official version creates
a file "-- comment" whereas mine makes a file "--" because I now have word
splitting and quoting rules and the like (so \g '-- comment' would
work). Something to else ponder.

-- 
Peter Eisentraut - peter_e@gmx.net
http://yi.org/peter-e/



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] union and LIMIT problem
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Re: psql and comments