如何让PL / Python回溯更加冗长?

时间:2015-08-11 18:09:59

标签: python postgresql plpython

目前在出现错误的情况下,我在psql中为PL / Python程序提供了这样的回溯,它导入了Python模块并从中调用了一些函数:

ERROR:  AssertionError: 
CONTEXT:  Traceback (most recent call last):
  PL/Python function "tempo_timeintervalset_contains", line 6, in <module>
    TimeIntervalSet.from_json(timeintervalset))
  PL/Python function "tempo_timeintervalset_contains", line 209, in __contains__
  PL/Python function "tempo_timeintervalset_contains", line 106, in _walk
  PL/Python function "tempo_timeintervalset_contains", line 41, in _evaluate
  PL/Python function "tempo_timeintervalset_contains", line 200, in callback
  PL/Python function "tempo_timeintervalset_contains", line 91, in __contains__
PL/Python function "tempo_timeintervalset_contains"

我尝试在log_error_verbosity = verbose中设置postgresql.conf并设置此环境变量PYTHONVERBOSE=1 PYTHONDEBUG=1。什么都没有帮助。

谁知道,如果可能的话,如何将它设置得更加详细?

1 个答案:

答案 0 :(得分:0)

我知道这已经过时了,但我觉得这很有效。

create function python_version()
returns text
language plpythonu
as $$

import sys
import traceback

try:
    return sys.version
except:
    error = sys.exc_info()[0]
    details = traceback.format_exc()
    plpy.error('%s: %s' % ( error, details ) )
$$;
相关问题