Re: Request for Implementation of Custom Error Messages for CHECK Constraints

Поиск
Список
Период
Сортировка
От Marcos Pegoraro
Тема Re: Request for Implementation of Custom Error Messages for CHECK Constraints
Дата
Msg-id CAB-JLwbM6FPanbpjynt5VLPbgD3+5fxKcLZOnvFSe5yrHHQmig@mail.gmail.com
обсуждение исходный текст
Ответ на Request for Implementation of Custom Error Messages for CHECK Constraints  ("Miguel Ferreira" <miguelmbferreira@gmail.com>)
Список pgsql-hackers
Em sáb., 10 de mai. de 2025 às 21:57, David G. Johnston <david.g.johnston@gmail.com> escreveu:
Constraints can be targeted by “comment on”.

So, why not using that COMMENT ON message to raise when that constraint gets violated ?
A GUC like Constraint_Exception_Returns_MessageOn = {Never | Always | If_Exists}
with its default value set to Never, so it runs like today, but if changed to If_Exists it will try to 
get that message or always, to show that COMMENT ON, even empty.

alter table b add constraint fk_b_a foreign key(ID) references a(ID);
comment on constraint fk_b_a on b is 'There is a problem on Foreign Key on Table B related to Table A';

regards
Marcos
 

В списке pgsql-hackers по дате отправления: