在 PostgreSQL 中调试 PLV8

Debugging PLV8 in PostgreSQL

前段时间我在 PostgreSQL 函数和触发器中请求 。与此同时,我将混合场景与 plpgSQL 结合使用并且非常喜欢它。但是 - 如前所述 - 调试 PLV8 的选项较少。到目前为止,我了解到 plugin_debugger 仅适用于 plpgSQL。外面有没有人找到了一种很好的方法来以另一种方式进行 PLV8 调试,然后使用大量烦人的 plv8.elog(NOTICE, 'this happens with my variable')?也许任何第三方工具或秘密插件?

pl/v8不再支持远程调试。

它在 pl/v8 版本 1 之前可用。4.x(参见 #131)。旧版本中值得注意的缺失功能包括 ES6。

解决方法

如果您需要使用 pl/v8 1.4.x 调试 ES6/7 代码,您可以使用 Traceur 转译它。


来自documentation 1.4.x:

PL/v8 supports v8 remote debugger. You need to enable it at the compile time to pass ENABLE_DEBUGGER_SUPPORT to make. make static will automatically turns it on. If enabled, and once PL/v8 module is loaded (and the execution engine is initialized, PL/v8 accepts a remote debugger connection. If you have d8 from v8 package, run with --remote-debug --debug-port=35432 to attach the functions. If you want to change the remote debugger port, there is a GUC plv8.debugger_port to set the port number. You can also try debugger statement inside functions to set a breakpoint. For more details of v8 remote debugger, see v8 documentation.

如果您不熟悉调试 JavaScript(或 v8),那可能有点难处理。

如果您对调试协议的底层功能感兴趣,check this out

单步执行代码可能需要一些腿部工作,但 here is a starting point 如何完成。

如果您正在寻找完整的现成解决方案或分步教程,我不确定是否有特定于 PL/v8。

我还没有亲自尝试过其中任何一种来调试 PL/v8,但是,有可能可以连接并且或多或少按预期工作:https://developer.chrome.com/devtools/docs/debugging-clients