Re: altering a column's collation leaves an invalid foreign key
От
jian he
Тема
Re: altering a column's collation leaves an invalid foreign key
Дата
Msg-id
CACJufxE3U650j=acBuksB+D9GoGVwU0Q2q+7b-BiF6muyp8_qA@mail.gmail.com
Ответ на
Список
Дерево обсуждения
altering a column's collation leaves an invalid foreign key Paul Jungwirth <pj@illuminatedcomputing.com>
Re: altering a column's collation leaves an invalid foreign key Paul Jungwirth <pj@illuminatedcomputing.com>
Re: altering a column's collation leaves an invalid foreign key jian he <jian.universality@gmail.com>
Re: altering a column's collation leaves an invalid foreign key jian he <jian.universality@gmail.com>
Re: altering a column's collation leaves an invalid foreign key jian he <jian.universality@gmail.com>
Re: altering a column's collation leaves an invalid foreign key jian he <jian.universality@gmail.com>
Re: altering a column's collation leaves an invalid foreign key Tom Lane <tgl@sss.pgh.pa.us>
Re: altering a column's collation leaves an invalid foreign key jian he <jian.universality@gmail.com>
Re: altering a column's collation leaves an invalid foreign key Peter Eisentraut <peter@eisentraut.org>
Re: altering a column's collation leaves an invalid foreign key jian he <jian.universality@gmail.com>
Re: altering a column's collation leaves an invalid foreign key Peter Eisentraut <peter@eisentraut.org>
On Sat, Apr 13, 2024 at 9:13 PM jian he wrote: > > > > > Here is a patch implementing this. It was a bit more fuss than I expected, so maybe someone has a > > > > better way. > I think I found a simple way. > > the logic is: > * ATExecAlterColumnType changes one column once at a time. > * one column can only have one collation. so we don't need to store a > list of collation oid. > * ATExecAlterColumnType we can get the new collation (targetcollid) > and original collation info. > * RememberAllDependentForRebuilding will check the column dependent, > whether this column is referenced by a foreign key or not information > is recorded. > so AlteredTableInfo->changedConstraintOids have the primary key and > foreign key oids. > * ATRewriteCatalogs will call ATPostAlterTypeCleanup (see the comments > in ATRewriteCatalogs) > * for tab->changedConstraintOids (foreign key, primary key) will call > ATPostAlterTypeParse, so > for foreign key (con->contype == CONSTR_FOREIGN) will call TryReuseForeignKey. > * in TryReuseForeignKey, we can pass the information that our primary > key old collation is nondeterministic > and old collation != new collation to the foreign key constraint. > so foreign key can act accordingly at ATAddForeignKeyConstraint (old_check_ok). > > > based on the above logic, I add one bool in struct AlteredTableInfo, > one bool in struct Constraint. > bool in AlteredTableInfo is for storing it, later passing it to struct > Constraint. > we need bool in Constraint because ATAddForeignKeyConstraint needs it. I refactored the comments. also added some extra tests hoping to make it more bullet proof, maybe it's redundant.
В списке pgsql-hackers по дате отправления
От: Matthias van de Meent
Дата:
От: Dilip Kumar
Дата: