1

I was editing a Postgres function using \ef and changed the RETURN type. Didn't realize this was a no-go for saving it.

mattswheels=# \ef fib
mattswheels-# \g
ERROR:  cannot change return type of existing function
HINT:  Use DROP FUNCTION fib(numeric) first.

I wrote a fair amount of code -- is there a way to recover it? I know vim said it saved to a /tmp folder somewhere but I'm not sure of the path.

some1
  • 1,547
  • 8
  • 26
  • 45

1 Answers1

2

You may be able to recover the failed function text from the PostgreSQL logs, since it logs by default all syntax errors (including errors compiling functions). The logs are in $PGDATA/pg_log. Try:

less `ls -t /var/lib/pgsql/*/data/pg_log/postgresql-*.log | head -n 1`
Ezequiel Tolnay
  • 4,302
  • 1
  • 19
  • 28