postgresql - 恢复对 Postgres 功能的更改

标签 postgresql psql

我正在使用\ef 编辑一个 Postgres 函数并更改了 RETURN 类型。没有意识到这是无法挽救的。

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

我写了相当多的代码——有办法恢复吗?我知道 vim 说它保存在某处的/tmp 文件夹中,但我不确定路径。

最佳答案

您可以从 PostgreSQL 日志中恢复失败的函数文本,因为它默认记录所有语法错误(包括错误编译函数)。日志位于 $PGDATA/pg_log 中。尝试:

less `ls -t /var/lib/pgsql/*/data/pg_log/postgresql-*.log | head -n 1`

关于postgresql - 恢复对 Postgres 功能的更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37635878/

相关文章:

sql - 在 PostgreSQL 中使用 json 数组中的索引

php - 未捕获的异常 'PDOException',消息为“SQLSTATE[08P01]”

postgresql - 带时区的 Postgres 查询

python - PostgreSQL 错误 : insert operation returns id exists in Python

postgresql - 错误 : column "exists" does not exist in SQL insert command

php - 包含或要求的 undefined variable

sql - 我们如何将所有 PostgreSQL 输出(包括错误)写入日志文件?

mysql - SQL:最大聚合和按查询分组

postgresql - 对许多 PostgreSQL 查询进行基准测试

postgresql - 如何按标识符分组并在 postgreSQL 中创建一个 JSON 对象数组?