Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin_debugger and view record type #78

Closed
cvas71 opened this issue Sep 27, 2022 · 6 comments
Closed

plugin_debugger and view record type #78

cvas71 opened this issue Sep 27, 2022 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@cvas71
Copy link
Contributor

cvas71 commented Sep 27, 2022

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
$$;

@cvas71
Copy link
Contributor Author

cvas71 commented Sep 28, 2022

I made some changes to plpgsql_debugger.c in extension pldbgapi,
PIExecute.kt in plugin. Now, when debugging, you can see variable values with the RECORD type.

@ng-galien
Copy link
Owner

Hello @cvas71,

The best to integrate your modification is you make a pull request for both projects.

Thank you for these modifications!

@ng-galien ng-galien added the bug Something isn't working label Sep 28, 2022
@cvas71
Copy link
Contributor Author

cvas71 commented Sep 29, 2022

I couldn't make a pull request.
I forked two projects and made changes there.

@ng-galien
Copy link
Owner

ng-galien commented Sep 29, 2022

Yes that's the flow for project contribution

  • Fork the project
  • Create a branch with your fix, for example "record support"
  • Commit your changes here
  • Create a pull request to the upstream project

@ng-galien ng-galien pinned this issue Sep 29, 2022
@ng-galien ng-galien added enhancement New feature or request and removed bug Something isn't working labels Sep 29, 2022
@ng-galien
Copy link
Owner

ng-galien commented Sep 29, 2022

@cvas71 Your changes are committed and I've created a branch print-vars-dev to integrate it. I make few changes for supporting every versions in one branch.
Remaining

  • Test pg14
  • Test pg13
  • Test pg12 (not supported)
  • Test pg11 (not supported)
  • Update docker file
  • Deploy on DockerHub
  • Update & deploy plugin

@ng-galien ng-galien self-assigned this Sep 29, 2022
@cvas71
Copy link
Contributor Author

cvas71 commented Sep 30, 2022

Yes, I did not take into account that it is necessary to make sure that the changes will also be compatible with other versions of PostgreSQL.

@ng-galien ng-galien unpinned this issue Oct 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants