pg_cron icon indicating copy to clipboard operation
pg_cron copied to clipboard

[BUG] setting search_path causes error

Open cwang9208 opened this issue 8 months ago • 1 comments

Hi,

We're using the latest pg_cron with the background worker mode in PostgreSQL-14. But the following simple code snippet would fail:


create table employees(emp_id int, increase_amount int, id int, salary int);

CREATE OR REPLACE PROCEDURE update_salary(employ_id INT, inc_amount INT)
LANGUAGE plpgsql
AS $$
BEGIN
   UPDATE employees
   SET salary = salary + inc_amount
   WHERE id = employ_id;
   
   COMMIT;
END;
$$;


-- Call a stored procedure every 5 seconds
SELECT cron.schedule('dummy', '5 seconds', 'set search_path to public; CALL update_salaryy(1, 500);');

The error message is ERROR: invalid transaction termination.

Can anyone help look into this problem?

cwang9208 avatar Jun 11 '24 05:06 cwang9208