How do I edit a function in PSQL

some1 picture some1 · May 22, 2016 · Viewed 9.6k times · Source

I created a default function in PGADMIN but the server doesn't have that software.

How can I edit the function using PSQL?

The closest I've seen is

\df+ function_name

but the output is garbled and not editable.


This will open the function using a default editor.

\ef function_name()

But then when I save it, it saves as this...

"/tmp/psql.edit.20631.sql" in the bin folder,

which doesn't seem correct.

Answer

Peter Eisentraut picture Peter Eisentraut · May 22, 2016

After you edit the function with \ef, you need to enter \g or ; to execute the statement that updates the function.

So it would be

\ef function_name()
[edit away]
\g