Today, Tom Lane committed patch, written by Abhijit Menon-Sen, which adds interesting feature to psql. Namely – it simplifies changing definition of functions.
Commit message pretty much explains everything:
Implement a psql command "\ef" to edit the definition of a function. In support of that, create a backend function pg_get_functiondef(). The psql command is functional but maybe a bit rough around the edges... Abhijit Menon-Sen
To elaborate a bit.
To change function definition before, you had to basically pg_dump -s the database, find the function, change it, and load to psql.
Other option was simply to keep creation.sql file, and modify it when you had to modify the function.
But now, it's simpler. It is enough to call \ef function_name, and your favorite $EDITOR will be launched, with full “CREATE OR REPLACE FUNCTION…" conveniently put in the edited buffer.
In case there is more than 1 function with given name, you will get nice error message:
# \ef texticlike ERROR: more than one function named "texticlike" LINE 1: SELECT 'texticlike'::pg_catalog.regproc::pg_catalog.oid ^
And, then you can use \ef with function params, like:
# \ef texticlike(citext, text)
Great addition. psql gets better and better.