Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PSql: how to not remove comments for external editor?

I like to use psql, and sometimes I commenting part of query (usually one line) - something like "quick fix and see what you get".

Internal psql editor is not suitable for big queries, and so often I'm using external editor via \e (currently it's vim).

The problem is when some part of query is currently commented in psql, then it appearing as empty line in external editor.

How I can configure psql to not remove comments when external editor is called?

like image 662
cub-uanic Avatar asked Oct 20 '22 20:10

cub-uanic


1 Answers

I always used /* COMMENT */ for temporarily commenting part of code, because I thought it would loose the rest on a query (after --) cos it converts code to one line

The new query buffer is then re-parsed according to the normal rules of psql, where the whole buffer is treated as a single line

(((I had same bug in Oracle 8.smth something - dumping package it was ignoring all characters after -- comment in package code)))

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

Answer: use /**/ commenting and it will keep comment through runs

Hint: if you use vim you can jump to the end of line by ESC + $ sequence, so it is not big difference in efforts from -- commenting

like image 86
Vao Tsun Avatar answered Oct 22 '22 22:10

Vao Tsun