Re: Passing initially_valid values instead of !skip_validation to StoreRelCheck() in AddRelationNewConstraints()
От | Amit Langote |
---|---|
Тема | Re: Passing initially_valid values instead of !skip_validation to StoreRelCheck() in AddRelationNewConstraints() |
Дата | |
Msg-id | 5667D783.5030303@lab.ntt.co.jp обсуждение исходный текст |
Ответ на | Re: Passing initially_valid values instead of !skip_validation to StoreRelCheck() in AddRelationNewConstraints() (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>) |
Ответы |
Re: Passing initially_valid values instead of
!skip_validation to StoreRelCheck() in AddRelationNewConstraints()
|
Список | pgsql-hackers |
On 2015/12/09 11:19, Amit Langote wrote: > On 2015/12/09 5:50, Robert Haas wrote: >> I suspect this is an oversight. We allowed FOREIGN KEY constraints to >> be not valid in 722bf7017bbe796decc79c1fde03e7a83dae9ada by Simon >> Riggs, but didn't add allow it for CHECK constraints until Alvaro's >> commit of 897795240cfaaed724af2f53ed2c50c9862f951f a few months later. >> My guess is that there's no reason for these not to behave in the same >> way, but they don't. Amul's proposed one-liner might be one part of >> actually fixing that, but it wouldn't be enough by itself: you'd also >> need to teach transformCreateStmt to set the initially_valid flag to >> true, maybe by adding a new function transformCheckConstraints or so. > > So, any NOT VALID specification for a FK constraint is effectively > overridden in transformFKConstraints() at table creation time but the same > doesn't happen for CHECK constraints. I agree that that could be fixed, > then as you say, Amul's one-liner would make sense. So, how about attached? I think it may be enough to flip initially_valid to true in transformTableConstraint() when in a CREATE TABLE context. Regarding Amul's proposed change, there arises one minor inconsistency. StoreRelCheck() is called in two places - AddRelationNewConstraints(), where we can safely change from passing the value of !skip_validation to that of initially_valid and StoreConstraints(), where we cannot because CookedConstraint is used which doesn't have the initially_valid field. Nevertheless, attached patch includes the former. Thoughts? Thanks, Amit
Вложения
В списке pgsql-hackers по дате отправления: