EnterpriseDB / pldebugger

Procedural Language Debugger Plugin for PostgreSQL and EDB Postgres Advanced Server
70 stars 19 forks source link

Plugin_debugger not work when has pg_hint_plan on shared_preload_libraries #14

Open phlaluna opened 1 year ago

phlaluna commented 1 year ago

Hi,

I did several tests and the Debbuger Plugin does not work when the shared_preload_libraries has "plugin_debugger,pg_hint_plan". When shared_preload_libraries has only "plugin_debugger" or with other libraries like "auto_explain,plugin_debugger,pg_stat_statements,pg_repack", it's work.

I can create function and create extension without any error. But when I use Debug from PGAdmin or Dbeaver it doesn't return the debug result.

Works: shared_preload_libraries="auto_explain,plugin_debugger,pg_stat_statements,pg_repack" return-debug-without-pg-hint

Problem: shared_preload_libraries="plugin_debugger,pg_hint_plan" pgadmin-with-pg-hint-no-parameters pgadmin-with-pg-hint-no-result pgadmin-with-pg-hint-no-stack

Script to create test function:

CREATE SCHEMA test;
DROP function if exists test.somefunc(var integer);
CREATE FUNCTION test.somefunc(var integer) RETURNS integer AS $$
DECLARE
   quantity integer := 30+var;
BEGIN
   RAISE NOTICE 'Quantity here is %', quantity;      --30
   quantity := 50;
   --
   --
   DECLARE
      quantity integer := 80;
   BEGIN
      RAISE NOTICE 'Quantity here is %', quantity;   --80
   END;
   RAISE NOTICE 'Quantity here is %', quantity;      --50
   RETURN quantity;
END;
$$ LANGUAGE plpgsql;
CREATE EXTENSION pldbgapi;
phlaluna commented 1 year ago

I opened an issue on postgresql and they replied the following:

_The plugin debugger uses dbg API, pg_hintplan uses dbg API too. Unfortunately this API is not designed to be used by two active extensions in one time.

_I found a workaround in plpgsqlcheck, but it requires modification in extensions. You should report this issue to their authors.

https://github.com/ossc-db/pg_hint_plan/issues https://github.com/EnterpriseDB/pldebugger/issues

The fix is not on the PostgreSQL side.

jasonchenTJ commented 7 months ago

@phlaluna
Hi Bro, I met the same issue. My PG version is 16.1.
The conflict plugins are auto_explain and plugin_debugger.

The problem probably due to internal hook programming.

Thanks Jason