Am Freitag, dem 27.05.2022 um 19:08 +0000 schrieb Cary Huang:
[...] > The patch applies and tests fine and I think this patch has good > intentions to prevent the default behavior of REINDEX DATABASE to > cause a deadlock. However, I am not in favor of simply omitting the > database name after DATABASE clause because of consistency. Almost > all other queries involving the DATABASE clause require database name > to be given following after. For example, ALTER DATABASE [dbname]. > > Being able to omit database name for REINDEX DATABASE seems > inconsistent to me. > > The documentation states that REINDEX DATABASE only works on the > current database, but it still requires the user to provide a > database name and require that it must match the current database. > Not very useful option, isn’t it? But it is still required from the > user to stay consistent with other DATABASE clauses. > Hmm, right, but you can see this from another perspective, too: For example, ALTER DATABASE works by adjusting properties of other databases very well, SET TABLESPACE can be used when not connected to the target database only, so you are required to specify its name in that case. REINDEX DATABASE cannot reindex other databases than the one we're connected to. Seen from that point, i currently can't see the logical justification to have the database name there, besides of "yes, i really meant that database i am connected to" or consistency. > Maybe the best way is to keep the query clause as is (with the > database name still required) and simply don’t let it reindex system > catalog to prevent deadlock. At the end, give user a notification > that system catalogs have not been reindexed, and tell them to use > REINDEX SYSTEM instead. +1