Debug PostgreSQL function using pgAdmin

后端 未结 3 1365
不思量自难忘°
不思量自难忘° 2021-01-31 01:07

I refer this to enable the debugger in the PostgreSQL server in order to debugging the plpgsql function by stepping through the codes using the pgadmin.

I have already

相关标签:
3条回答
  • 2021-01-31 01:57

    Ken,

    Have you tried pgAdmin 1.8 to rule out issue with PgAdmin 1.14/ PostgreSQL 8.3 interaction. It's been a while since I've used 8.3 and for the article I wrote -- which you are referring to, I was testing with 1.14/ PostgreSQL 9.1 so it could very well be an issue with the interaction with older version. Unfortunately I don't have a 8.3 anymore to test with.

    I vaguely remember having the issue you had once, but it was when I had another shared library in my postgresql.conf in addition to the pldebugger. Can't remember which one that was, but removing the other shared library fixed my issue.

    Hope some of these suggestions help, Regina

    0 讨论(0)
  • 2021-01-31 02:07

    I had the same problem. Make sure the only shared lib you´re loading in the postgres.conf is the debugger. Nothing else. Not even the profiler. If you get a SSL error when trying to debug a function, reconnect to the server.

    0 讨论(0)
  • 2021-01-31 02:14

    You have to enable debugging in two places. On PGAdmin and on the database itself. That article you referenced does a wonderful job explaining it but there were some nuances.

    PGAdmin

    When updating your postgresql.conf file to load the debugging library, I was running PGAdmin on Windows so the file was here:

    C:\Program Files\PostgreSQL\9.4\data\postgresql.conf
    

    And the path to the plugin_debugger.dll was actually

    $libdir/plugin_debugger.dll
    

    not

    $libdir/plugins/plugin_debugger.dll
    

    as specified in the article. So your postgresql.conf would need a line like this

    shared_preload_libraries = '$libdir/plugin_debugger.dll'
    

    Search for the actual .dll if you're in doubt. If you're on Linux the file you'll be looking for is plugin_debugger.so. Don't forget that changing the postgresql.conf file will require a restart for the change to take effect.

    PostgreSQL Database

    Assuming you're running your PostgreSQL database on a Linux server this gist does an excellent job at explaining how to download the dependencies for enabling debugging. Make sure you're running as root when you install.

    The part that's easy to miss is issuing the command against the actual database you want to debug. For newer versions on PostgreSQL all you'll need to do is this:

    CREATE EXTENSION IF NOT EXISTS pldbgapi;
    

    If that doesn't return an error, you should be good to go.

    Some additional things of note:

    • As mentioned above, you can only debug when running as a super user account
    • From their docs you can only debug pl/pgsql functions. So if your function says something like LANGUAGE c PGAdmin won't even show a right-click Debug menu option when you select the function. Look for something that has LANGUAGE plpgsql and the Debug menu should show.
    0 讨论(0)
提交回复
热议问题