Re: ALTER tbl rewrite loses CLUSTER ON index
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Michael Paquier <michael@paquier.xyz>,
Alvaro Herrera <alvherre@2ndquadrant.com>,
Amit Langote <amitlangote09@gmail.com>, pgsql-hackers@postgresql.org
Date: 2020-03-12T17:19:56Z
Lists: pgsql-hackers
Justin Pryzby <pryzby@telsasoft.com> writes: > @cfbot: resending with only Amit's 0001, since Michael pushed a variation on > 0002. Boy, I really dislike this patch. ATPostAlterTypeParse is documented as using the supplied definition string, and nothing else, to reconstruct the index. This breaks that without even the courtesy of documenting the breakage. Moreover, the reason why it's designed like that is to avoid requiring the old index objects to still be accessible. So I'm surprised that this hack works at all. I don't think it would have worked at the time the code was first written, and I think it's imposing a constraint we'll have problems with (again?) in future. The right way to fix this is to note the presence of the indisclustered flag when we're examining the index earlier, and include a suitable command in the definition string. So probably pg_get_indexdef_string() is what needs to change. It doesn't look like that's used anywhere else, so we can just redefine its behavior as needed. regards, tom lane
Commits
-
Refactor cluster.c to use new routine get_index_isclustered()
- 8ef9451f58ee 13.0 landed
-
Preserve clustered index after rewrites with ALTER TABLE
- 3f77a670241d 9.5.22 landed
- 61a161fe4421 9.6.18 landed
- cef2b8d52c59 10.13 landed
- 41faafbd75a5 11.8 landed
- 3e62dd3a937b 12.3 landed
- a40caf5f862c 13.0 landed
-
Preserve replica identity index across ALTER TABLE rewrite
- 1cc9c2412cc9 13.0 cited
-
Remove RangeIOData->typiofunc
- a77315fdf2a1 13.0 cited
-
Preserve pg_index.indisclustered across REINDEX CONCURRENTLY
- f087d63a45b5 12.3 landed
- d79fb88ac738 13.0 landed