31 lines
919 B
PL/PgSQL
31 lines
919 B
PL/PgSQL
begin;
|
|
|
|
-- Business version conflicts are HTTP 409, not serialization failures.
|
|
-- PostgREST 14 retries SQLSTATE 40001 indefinitely, exhausting its pool.
|
|
-- Preserve the current function bodies, ownership, grants and all access checks.
|
|
do $migration$
|
|
declare
|
|
signature text;
|
|
definition text;
|
|
fixed text;
|
|
begin
|
|
foreach signature in array array[
|
|
'public.sun_save_app_state_v17(uuid,jsonb,text,bigint)',
|
|
'public.sun_v17_save_client_v1772(uuid,text,jsonb,bigint,text)'
|
|
] loop
|
|
definition := pg_get_functiondef(signature::regprocedure);
|
|
fixed := replace(definition, 'errcode=''40001''', 'errcode=''PT409''');
|
|
if fixed = definition then
|
|
if position('errcode=''PT409''' in definition) = 0 then
|
|
raise exception 'Unexpected conflict handler in %', signature;
|
|
end if;
|
|
else
|
|
execute fixed;
|
|
end if;
|
|
end loop;
|
|
end;
|
|
$migration$;
|
|
|
|
notify pgrst, 'reload schema';
|
|
commit;
|