PSql: how not to delete comments for an external editor?

I like to use psql and sometimes I comment out part of the request (usually a single line) - something like "quick fix and see what you get."

The internal psql editor is not suitable for large queries, so I often use the external editor through \e (currently it is vim ).

The problem is that some part of the request is currently commented out in psql , then it appears as an empty line in an external editor.

How can I configure psql not to delete comments when calling an external editor?

+5
source share
1 answer

I always used /* COMMENT */ to temporarily comment out part of the code, because I thought it would lose the rest in the request (after -- ), because it converts the code into one line

The new request buffer is then reprocessed according to the usual psql rules, where the entire buffer is processed as a single line

(((I had the same error in Oracle 8.smth something - in the dumping package, it ignored all the characters after the comment -- in the package code)))

Surprisingly, \e editor loses only one line (commented with the help -- one).

Answer : use /**/ comment and it will continue to comment through the runs

Tip : if you use vim , you can skip to the end of the line using the ESC + $ sequence, so this doesn't really matter much in the effort involved with comments --

+2
source

Source: https://habr.com/ru/post/1209567/


All Articles