plpgsql plan caching allowing invalid data to enter table?
От | Joe Van Dyk |
---|---|
Тема | plpgsql plan caching allowing invalid data to enter table? |
Дата | |
Msg-id | CACfv+pJUbc5Kg7HQ-xSpw_HDhExZWOWhff0pVyADb24bkokaaQ@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: plpgsql plan caching allowing invalid data to enter table?
Re: plpgsql plan caching allowing invalid data to enter table? Re: plpgsql plan caching allowing invalid data to enter table? |
Список | pgsql-general |
It's looking like I can use a plpgsql function to insert data into a table that violates a domain constraint. Is this a known problem?
create domain my_domain text check (length(value) > 2);
create table my_table (name my_domain);
create function f(text) returns void as $$
declare my_var my_domain := $1;
begin
insert into my_table values (my_var);
end $$ language plpgsql;
Session 2:
select f('test');
delete from my_table;
-- Keep session open!
Session 1:
alter domain my_domain drop constraint my_domain_check;
alter domain my_domain add constraint my_domain_check check (length(value) > 5);
Session 2:
select f('test');
-- This works, but it should fail.
-- I have a constraint of more than 5 characters on the domain.
-- But I can insert a row with 4 characters.
В списке pgsql-general по дате отправления: