patternsqlMinor
SQL Comments disappear with psql and `\e`
Viewed 0 times
sqlwithpsqldisappearandcomments
Problem
Is there anyway at all, ever to change the behavior of comments in
Run that in psql. Then run
psql. Take the query below. Execute it.CREATE TABLE foo
AS
SELECT x AS id,
-- x AS id2,
x AS id3
FROM generate_series(1,50) AS x;Run that in psql. Then run
\e. Now at least, for me what I see in my editor is the line absent. This is driving me crazy. Is there a way around this.. The comment is just absent from the buffer that gets passed to the editor. Often, it's commented and not deleted because I want to uncomment it at a later point.Solution
Workaround with C-style comments
For whatever reason.. this seems to work when you use C-style comments instead of standard SQL comments,
Now you can do
For whatever reason.. this seems to work when you use C-style comments instead of standard SQL comments,
CREATE TABLE foo
AS
SELECT x AS id,
/* x AS id2, */
x AS id3
FROM generate_series(1,50) AS x;Now you can do
\e and edit it.Code Snippets
CREATE TABLE foo
AS
SELECT x AS id,
/* x AS id2, */
x AS id3
FROM generate_series(1,50) AS x;Context
StackExchange Database Administrators Q#166630, answer score: 6
Revisions (0)
No revisions yet.