前段时间我问了disadvantages of using PLV8在 PostgreSQL 函数和触发器中。与此同时,我将混合场景与 plpgSQL 结合使用并且非常喜欢它。但是 - 如前所述 - 调试 PLV8 的选项较少。到目前为止,我了解到 plugin_debugger 仅适用于 plpgSQL。外面有没有人找到了一种很好的方法来以另一种方式进行 PLV8 调试,然后使用大量烦人的 plv8.elog(注意,'这发生在我的变量上')
?也许任何第三方工具或 secret 插件?
最佳答案
pl/v8 不再支持远程调试。
它在 1.4.x 版之前的 pl/v8 中可用(参见 #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 GUCplv8.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),那么处理起来可能有点困难。
如果您对调试协议(protocol)的底层特性感兴趣,check this out .
单步执行代码可能需要一些腿部工作,但是 here is a starting point了解如何做到这一点。
如果您正在寻找完整的现成解决方案或分步教程,我不确定是否有特定于 PL/v8 的解决方案。
我还没有亲自尝试过其中任何一种来调试 PL/v8,但是,有可能有人可以连接并且或多或少地按预期工作:https://developer.chrome.com/devtools/docs/debugging-clients
关于postgresql - 在 PostgreSQL 中调试 PLV8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38179342/