You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The "constraint" field is empty in the below test case:
NOTICE: function f(text) does not exist, skipping
drop table if exists t cascade;
NOTICE: table "t" does not exist, skipping
create table t(k serial primary key, v varchar(5) not null);
create unique index t_v_unq on t(v);
insert into t(v) values ('dog'), ('cat'), ('frog');
create function f(new_v in text)
returns table(z text)
security definer
language plpgsql
as $body$
declare
sqlstate_ text not null := '';
constraint_ text not null := '';
msg text not null := '';
begin
z := 'Inserting "'||new_v||'"'; return next;
begin
insert into t(v) values (new_v);
z := 'No exception'; return next;
exception
when others then
get stacked diagnostics
sqlstate_ = returned_sqlstate,
constraint_ = constraint_name,
msg = message_text;
if sqlstate_ = '23505' then
z := 'unique_violation'; return next;
z := 'constraint: '||constraint_; return next;
z := 'message: '||msg; return next;
else
z := 'others'; return next;
z := 'sqlstate: '||sqlstate_; return next;
z := 'message: '||msg; return next;
end if;
end;
end;
$body$;
select z from f('dog');
z
----------------------------------------------------------------------
Inserting "dog"
unique_violation
constraint:
message: duplicate key value violates unique constraint "t_v_unq"
(4 rows)```
The text was updated successfully, but these errors were encountered:
Jira Link: DB-3097
Description
The "constraint" field is empty in the below test case:
The text was updated successfully, but these errors were encountered: