I'm ran my .pgsql script using /i blah.pgsql script and then using my .java function to call that pgsql to test it.
However, after I ran it. I realized it corrupted my data, and I am not sure how to debug and what's causing the corrupt data. I can't DROP SCHEMA because it hangs, so I have to create a new SHOW SEARCH_PATH Schema to test it again. I did it three times already, and I want to avoid the problem. Can someone please help me identify why it caused the corrupt data? Thank you! Honestly, this is the only problem I have, and I cannot figure out why this cause a really bad corrupt database. If you need more information / database let me know so I can edit and provide more.
The point in creating this file is to get the count of every update is made. but it seems like updating is corrupting the whole database file
Here's my code
CREATE OR REPLACE function assignDelinquents (theAgent char(6), theCount integer)
RETURNS integer
LANGUAGE plpgsql
AS $$
DECLARE
max_update integer := 0;
counter integer := 0;
BEGIN
LOOP
UPDATE Delinquents d
-- code here
counter := counter + 1;
END LOOP;
RETURN counter;
END $$;
Edit: pg_stat_activity result: https://pastebin.com/46hN1uj9 I'm fairly new to pgsql, so it's really weird why i can't really do anything.