Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
От | jian he |
---|---|
Тема | Re: Add SPLIT PARTITION/MERGE PARTITIONS commands |
Дата | |
Msg-id | CACJufxHo0u=PzgCn88VZEW0mtB=JopchqBTESudUMH+HCyiTpg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Add SPLIT PARTITION/MERGE PARTITIONS commands (jian he <jian.universality@gmail.com>) |
Список | pgsql-hackers |
for v45. + foreach_ptr(CookedConstraint, ccon, cookedConstraints) + { + if (!ccon->skip_validation && ccon->contype == CONSTR_CHECK) + { + Bitmapset *attnums = NULL; + + pull_varattnos((Node *) ccon->expr, 1, &attnums); + + /* + * Add check only if it contains tableoid + * (TableOidAttributeNumber). + */ + if (bms_is_member(TableOidAttributeNumber - FirstLowInvalidHeapAttributeNumber, + attnums)) + { + NewConstraint *newcon; + + newcon = (NewConstraint *) palloc0(sizeof(NewConstraint)); + newcon->name = ccon->name; + newcon->contype = ccon->contype; + newcon->qual = ccon->expr; + + tab->constraints = lappend(tab->constraints, newcon); + } + } + } we need to expand the virtual generated column here, otherwise, bms_is_member would be not correct. consider case like: CREATE TABLE pp (f1 INT, f2 INT generated always as (f1 + tableoid::int)) PARTITION BY RANGE (f1); CREATE TABLE pp_1 (f2 INT generated always as (f1 + tableoid::int), f1 int); ALTER TABLE pp ATTACH PARTITION pp_1 FOR VALUES FROM (-1) TO (10); CREATE TABLE pp_2 (f2 INT generated always as (f1 + tableoid::int), f1 int); ALTER TABLE pp ATTACH PARTITION pp_2 FOR VALUES FROM (10) TO (20); ALTER TABLE PP add check (f2 > 0); ALTER TABLE pp MERGE PARTITIONS (pp_1, pp_2) INTO pp_12; In this context, the merge partition command needs to evaluate the constraint "pp_f2_check" again on pp_12. attach minor diff fix this problem.
Вложения
В списке pgsql-hackers по дате отправления: