Assume I created a function that I execute in REPEATABLE_READ
isolation level in PostgresSQL, e.g.
CREATE FUNCTION some_stuff() RETURNS void AS $$
BEGIN
-- do stuff that could throw an error
END;
$$ LANGUAGE plpgsql;
It's possible for this function internally to throw the following error:
ERROR: could not serialize access due to concurrent update
. Is there a way to catch this error and repeat the function/transaction internally?
So have something like this:
CREATE FUNCTION some_stuff() RETURNS void AS $$
BEGIN
try {
-- do stuff that could throw an error
} catch (error) { call some_stuff(); }
END;
$$ LANGUAGE plpgsql;
Or has this error catching to be done in the application level, i.e. in Java that is calling this function?