ng-galien / idea-plpgdebugger Goto Github PK
View Code? Open in Web Editor NEWA plugin to debug PL/pg in Intellij
License: MIT License
A plugin to debug PL/pg in Intellij
License: MIT License
Describe the bug
When I try to debug my routine I would like to see results of every RAISE NOTICE call but there are nothing happens. I try to do the same but in the pgAdmin and then I can see all messages.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Message should appear with data I put there as It does in pgAdmin
Desktop (please complete the following information):
Started a debugging session from the Database Explorer.
This worked once. The next time I invoked the same function, it just ran, no debugger.
M1 Mac, Postgres 14, IntelliJ
Describe the bug
Information is missing when debug extension is not available
Please support latest version ( 2022.1 ) of intelij
Ability to edit source code, reload function and restart debugger
Describe the bug
I see Routine not found
error.
To Reproduce
Steps to reproduce the behavior:
create schema s_test;
create or replace function s_test.test_debug(p_text text, p_int integer DEFAULT 0) returns text
language plpgsql
as
$$
BEGIN
return 'DEBUG END';
end
$$;
SELECT s_test.test_debug('TEST', 0);
Try debug last row.
Expected behavior
Should debug routines in schemas
Debugging an anonymous plpg function can be a great feature.
JSON and JSONB variables outputs are just inlined and not exploded in the variable view.
For RECORD type, as it's returned as a ROW without type we can outputs it as JSONB.
@cvas71 what's your feelings about it?
This is a maintenance with quick fixes
After debugging on a session, the debugger remains activated.
I keep trying to debug the SELECT test_debug('TEST', 1224312); function. Sometimes debugging works on version 1.0.3, and sometimes it doesn't. There is a normal execution of the function with the return of the result and there is no switch to debug mode. I also noticed that after the debugging process, if you simply execute the SELECT test_debug('TEST', 1224312); then its execution time is delayed by tens of seconds.
Also, after some attempts on the server side, there is a process that can only be killed.
thanks for your efforts!!
Describe the bug
Once I was able to start debugging.
After few IDE restarts I can not do that anymore -- my Debug button is disabled (grayed out).
Screenshots
Additional context
IDEA Plugin version 222.3.2
IntelliJ IDEA 2022.3.3 (Ultimate Edition) Build #IU-223.8836.41, built on March 10, 2023
PostgreSQL 13.9 (Debian 13.9-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Run failed to start
java.util.NoSuchElementException: List is empty.
at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:214)
at net.plpgsql.ideadebugger.command.PlExecutor.createListener(PlExecutor.kt:111)
at net.plpgsql.ideadebugger.run.PlProcess$InnerThread.run(PlProcess.kt:347)
Expected behavior
Debuggers starts as described.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
Is your feature request related to a problem? Please describe.
I use PGTT https://github.com/darold/pgtt extension, and it require load it's module after new session started:
LOAD '$libdir/plugins/pgtt';
https://github.com/darold/pgtt#use-of-the-extension
When I start debugging, I should load this module before debugging.
I try use "Evaluate expression" window, but it, seems, not worked (PostgreSQL 14.1), show nothing.
Describe the solution you'd like
Allow execute LOAD 'module'
in the variables
Describe alternatives you've considered
Make separate function for initialize and load module. Execute function once in Variables
block.
Additional context
Good afternoon, Sir.
I am using your plugin_debugger (https://github.com/ng-galien/pldebugger) library built according to your instructions. I noticed that if in the declared variables there is a variable with the RECORD type, the debugging process ends with an error.
[55000] ERROR: record "v_record" is not assigned yet
The tuple structure of a not-yet-assigned record is indeterminate.
It's easy to check.
In your function, which goes for an example, added in the declaration
v_record RECORD;
and before RETURN
pasted the code
FOR v_record IN SELECT * FROM public.debug
LOOP
RAISE NOTICE '%', v_record.id;
END LOOP;
CREATE FUNCTION test_debug(p_text text, p_int integer DEFAULT 0) RETURNS text
LANGUAGE plpgsql
AS
$$
DECLARE
v_int_array INT[] = ARRAY [6, 7, 8];
v_custom public.custom_type = (434, 'Custom')::public.custom_type;
v_debug_array debug[];
v_debug debug;
v_text TEXT = '';
v_int INT = 0;
v_date DATE = NULL;
v_record RECORD;
BEGIN
v_text = p_text;
v_int_array = ARRAY_APPEND(v_int_array, p_int);
SELECT * FROM public.debug LIMIT 1 INTO v_debug;
v_int_array = ARRAY_APPEND(v_int_array, 3);
SELECT ARRAY_AGG(d) FROM public.debug d INTO v_debug_array;
v_int_array = ARRAY_APPEND(v_int_array, 5);
v_int_array = ARRAY_APPEND(v_int_array, 7);
v_text = 'TEST';
v_int = v_int + 1;
v_date = CURRENT_DATE;
SELECT ARRAY_AGG(id) FROM public.debug INTO v_int_array;
FOR v_record IN SELECT *
FROM public.debug
LOOP
RAISE NOTICE '%', v_record.id;
END LOOP;
RETURN 'DEBUG END';
END
$$;
Describe the bug
Debugger execute function without stopping on it.
To Reproduce
create schema if not exists test_schema;
create or replace function test_schema.debug_test() returns text as $$
begin
return 'A';
end;
$$ language plpgsql;
select test_schema.debug_test(); -- Try debug this
In Debug/Console window it show single line:
[NOTICE] PLDBGBREAK:27
In Service windows it show execution result:
Expected behavior
Should stop on function body.
Additional context
PostgreSQL 14.1 (Docker-edition)
Plsql Debugger 1.1.0
When the call stack have at least 2 frames the inline values are not displayed on the last stack
Build docker images for Apple Silicon devices.
Describe the bug
Can't debug stored procedures.
To Reproduce
Steps to reproduce the behavior:
create or replace procedure debug_proc_test() as $$
begin
null;
end;
$$ language plpgsql;
-- Select here and click "Debug" button:
call debug_proc_test();
Expected behavior
Should debug procedures (not functions only),
Is your feature request related to a problem? Please describe.
The IDE gives the following error message:
Plugin 'PostgreSQL Debugger' (version '232.0.3') is not compatible with the current version of the IDE, because it requires build 232.* or older but the current build is IU-233.11799.241
Describe the solution you'd like
A new version of Intellij IDEA is out and the plugin cannot be loaded.
Build #IU-233.11799.241, built on December 2, 2023
Please remove the version restriction or similar to make it possible to load the plugin assuming that is all that is really required.
Describe alternatives you've considered
The alternative is to downgrade used version of Intellij IDEA.
Additional context
N/A
The legacy PostgreSQL debugger has some limitations as it only outputs a subset of variable.
It only outputs basic variables and arrays. Rows, records and structured type are discarded.
Compile the modified debugger is not technically difficult but requires a Linux platform as it's too complicated on Windows.
We can provide a Docker image of the PostgreSQL with the enhanced debugger:
Clean dependencies
In PostgreSQL 14.1 This query can't executed.
Raise error "ERROR: column reference "oid" is ambiguous".
SELECT oid,
pronargs,
idx,
proargname,
concat(t_type_ns.nspname, '.', t_type.typname),
idx > (pronargs-pronargdefaults)
FROM (SELECT idx ,
pronargs,
pronargdefaults,
t_proc1.oid,
t_proc1.proargtypes[idx - 1] as proargtype,
t_proc1.proargnames[idx] as proargname
FROM (SELECT t_proc.oid,
case when t_proc.pronargs = 0 then '{0}'::oid[] else t_proc.proargtypes::oid[] end as proargtypes,
case when t_proc.pronargs = 0 then '{""}'::text[] else t_proc.proargnames end as proargnames,
t_proc.pronargs,
t_proc.pronargdefaults,
case when t_proc.pronargs = 0 then 1 else t_proc.pronargs end as serial
FROM pg_proc t_proc
JOIN pg_namespace t_namespace
ON t_proc.pronamespace = t_namespace.oid
WHERE lower(t_namespace.nspname) = lower('%s')
AND lower(t_proc.proname) = lower('%s')
ORDER BY t_proc.oid) t_proc1,
generate_series(1, t_proc1.serial) idx) t_proc2
LEFT JOIN pg_type t_type
ON t_proc2.proargtype = t_type.oid
left join pg_namespace t_type_ns ON t_type.typnamespace = t_type_ns.oid
Because lacking of unit tests or integration test we need a manual test suite.
Describe the bug
When a function code is updated, the debugger does not load the new version unless one quits DataGrip and starts it agian.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
When a function code changes, the debugger should load the new version on every debug run.
Desktop (please complete the following information):
Support for indirect debugging, wait for target procedure
A function like myfunc(arg enum, arg jsonb) fails
Probably related to the query construction for argument validation
Namespace have to be considered too
Identify the target procedure
Describe the bug
If I select code from keyboard, the button Debug
leaves disabled.
To Reproduce
Steps to reproduce the behavior:
Shift
and select some textExpected behavior
Should be enabled button.
(RubyMine 2021.3.1)
How do I attach to the db session and query tables? I can watch content of the variables fine, but how do I query tables tho?
Describe the bug
Sometimes I've got this error after debug session terminated:
java.sql.SQLException: Ошибка ввода/вывода при отправке бэкенду (I/O error when send to backend)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:349)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:481)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:401)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:322)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:308)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:284)
at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:236)
at com.intellij.database.remote.jdbc.impl.RemoteStatementImpl.executeQuery(RemoteStatementImpl.java:179)
at jdk.internal.reflect.GeneratedMethodAccessor45.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
at java.rmi/sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:303)
at java.rmi/sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:279)
at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:164)
at java.rmi/java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:217)
at java.rmi/java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:162)
at com.sun.proxy.$Proxy201.executeQuery(Unknown Source)
at net.plpgsql.ideadebugger.DBRowSet.open(RowSet.kt:77)
at net.plpgsql.ideadebugger.AbstractRowSet.execute(RowSet.kt:40)
at net.plpgsql.ideadebugger.DBRowSet.run(RowSet.kt:88)
at net.plpgsql.ideadebugger.PlCommandKt.plRunStep(PlCommand.kt:155)
at net.plpgsql.ideadebugger.PlProcess$fetchStep$$inlined$runAsync$1.run(promise.kt:402)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.net.SocketException: Socket closed
at java.base/java.net.SocketInputStream.socketRead0(Native Method)
at java.base/java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:161)
at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:128)
at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:113)
at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73)
at org.postgresql.core.PGStream.receiveChar(PGStream.java:443)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2056)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:322)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:481)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:401)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:322)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:308)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:284)
at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:236)
at com.intellij.database.remote.jdbc.impl.RemoteStatementImpl.executeQuery(RemoteStatementImpl.java:179)
at jdk.internal.reflect.GeneratedMethodAccessor45.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
... 1 more
Result of the function was showed in the result grid.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Error message should not appear.
CHAR(X) is not properly casted when the tuple is converted to Json, see getVariables
All about parameters in the plugin
If in a function, add a comment before DECLARE or, for example, a special command such as #variable_conflict use_variable.
When debugging, the cursor is set to a line lower than it should be.
All about debug process control
Describe the bug
Installed extension pldbgapi, debug works under user superuser. Under other (non-superuser) user -- does not.
Additional context
Complaint on shared libraries obviously an error, libraries totally work when I attempt to debug under superuser.
And shared libraries are either loaded or not loaded, that is not user-dependent, right?
IDEA Plugin version 222.3.2
IntelliJ IDEA 2022.3.3 (Ultimate Edition) Build #IU-223.8836.41, built on March 10, 2023
PostgreSQL 13.9 (Debian 13.9-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
To follow internal changes it's better to stick to intellij version
Describe the bug
When I try to debug a function by right clicking and selecting "Debug Routine" in the explorer I receive the following error:
To Reproduce
Steps to reproduce the behavior:
create schema if not exists test_schema;
create or replace function test_schema.debug_test() returns text as $$
begin
return 'Test';
end;
$$ language plpgsql;
Expected behavior
Function is debugged
Desktop (please complete the following information):
Additional context
Debugging the following from a console window works as expected:
select test_schema.debug_test();
Describe the bug
If you spin up the Docker database and try to right click on the Debug procedure/function and run Debug, you will get a dialogue saying that you are missing the plpgsql extension. Installing it will do nothing, but installing the pldbgapi extension mentioned in the README will fix the issue. This sent me off in the wrong direction for two days.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
An error saying I have not installed pldbgapi
Screenshots
Desktop (please complete the following information):
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.