On Tue, Apr 20, 2021 at 1:48 PM Julien Rouhaud <rjuju...@gmail.com> wrote: > On Tue, Apr 20, 2021 at 12:05:27PM +1200, Thomas Munro wrote: > > Yeah, that runs directly into non-trivial locking problems. I felt > > like some of the other complaints could conceivably be addressed in > > time, including dumb stuff like Windows default locale string format > > and hopefully some expression analysis problems, but not this. I'll > > hold off reverting for a few more days to see if anyone has any other > > thoughts on that, because there doesn't seem to be any advantage in > > being too hasty about it. > > I also feel that the ALTER TYPE example Tom showed earlier isn't something > trivial to fix and cannot be done in pg14 :(
Just an idea: It might be possible to come up with a scheme where ALTER TYPE ADD ATTRIBUTE records versions somewhere at column add time, and index_check_collation_versions() finds and checks those when they aren't superseded by index->collation versions created by REINDEX, or already present due to other dependencies on the same collation. Of course, the opposite problem applies when you ALTER TYPE DROP ATTRIBUTE: you might have some zombie refobjversions you don't need anymore, but that would seem to be the least of your worries if you drop attributes from composite types used in indexes: create type myrow as (f1 int, f2 int); create table mytable (r1 myrow primary key); insert into mytable select row(generate_series(1, 10), generate_series(10, 1, -1))::myrow; select * from mytable; alter type myrow drop attribute f1; select * from mytable; select * from mytable where r1 = row(6); -- !!! reindex table mytable; select * from mytable where r1 = row(6);