Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1izG7K-0007MM-Ro for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Feb 2020 08:33:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1izG7J-0007At-OZ for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Feb 2020 08:33:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1izG7J-00078n-9X for pgsql-hackers@lists.postgresql.org; Wed, 05 Feb 2020 08:33:01 +0000 Received: from mail-yw1-xc32.google.com ([2607:f8b0:4864:20::c32]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1izG7G-0001Jn-MT for pgsql-hackers@postgresql.org; Wed, 05 Feb 2020 08:32:59 +0000 Received: by mail-yw1-xc32.google.com with SMTP id b186so1737742ywc.1 for ; Wed, 05 Feb 2020 00:32:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=HuuQIairAv2yRwqNP82BHXL/ToW+NyU4+fY4LHvUEXI=; b=JkMpEEeKuXX3KdXz5uN/9Qqrm7cH8qQuO0JJUSpRQ/ghv28S8W4X/ZA7VmYI2OH7mP a3ByTsICmtjCJRHthnx0DX9iTBksS+z5s6ZxFUmzZ3iyXlfsYwz0KyEYft1w2waJrLqB pucI9LcpAFC4S0JtlCUmaVNoxzKIdLphdhdiQVx7L0WASuoZW4/WUuyUh7/+hX0STZL0 47CLqZ8Sj6eg/hmHklEzVJ/bSP8Y/CY4yHv/UpVSDMzliXAS8wSA5NXNf+8DnEJP2xBq sgIjJ3wJW0k9/PyHCISecm32296NVh2dF/IQNMmX5vlAcBzqziw/ldYXEh5b/ZBqoJDF wHsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=HuuQIairAv2yRwqNP82BHXL/ToW+NyU4+fY4LHvUEXI=; b=eS4Ubs48okO99NnC9qfLZ0lqsXqBinCuwXRzKZWrB/T//SQJlm9Uk7bWFhEnObhaff sDuGeCuZUvri9d6KXzP/xLL+ywu5qpfke0ssdjHraaqX73aQdVt7EAxQ93/J1JsejeD3 nrnjI1pll5mL6Pgt8Lxw83ltAAiGEY0D7BIjRuaznMsg0NHJiZNrGUNiB7pQOVUw0qBg K6TTLaAR8pzkSRmsMGXC1zuPXrgeH4f82SQqS1qukRezzGGxHsopoT8ZoYdt6SRbHrNh tBl0zn6+6u+A9zNRNEAy1ClzQj6fdjdfb2Q1lYdeLmijIQEuiD/dJXLtNjxf9oYBtcb/ wipg== X-Gm-Message-State: APjAAAWyOXKks1cNwv4t49MF4jzvdtPeYzgd3qBnGnbPyuxXh8fplOQc XtCeg9vOjaI3sKyi4i0+cu9isLMjOgA= X-Google-Smtp-Source: APXvYqzohmxjfoU2rvTpz+8ktUriiU/bOWlLiYNe1IDdP21poxhnDdgv+5Z5xxg5WP1jX24gLvN8hQ== X-Received: by 2002:a81:f208:: with SMTP id i8mr9010226ywm.101.1580891578021; Wed, 05 Feb 2020 00:32:58 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id 124sm11036031ywm.25.2020.02.05.00.32.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Feb 2020 00:32:57 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id 78FB6800925; Wed, 5 Feb 2020 02:32:55 -0600 (CST) Date: Wed, 5 Feb 2020 02:32:55 -0600 From: Justin Pryzby To: Amit Langote Cc: pgsql-hackers@postgresql.org Subject: Re: ALTER tbl rewrite loses CLUSTER ON index Message-ID: <20200205083255.GE13621@telsasoft.com> References: <20200202161718.GI13621@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Feb 05, 2020 at 03:53:45PM +0900, Amit Langote wrote: > Hi Justin, > > On Mon, Feb 3, 2020 at 1:17 AM Justin Pryzby wrote: > > Other options are preserved by ALTER (and CLUSTER ON is and most obviously > > should be preserved by CLUSTER's rewrite), so I think (SET) CLUSTER should be > > preserved by ALTER, too. > > Yes. > > create table foo (a int primary key); > cluster foo; > ERROR: there is no previously clustered index for table "foo" > cluster foo using foo_pkey; > alter table foo alter a type bigint; > cluster foo; > ERROR: there is no previously clustered index for table "foo" > > With your patch, this last error doesn't occur. > > Like you, I too suspect that losing indisclustered like this is > unintentional, so should be fixed. Thanks for checking. It doesn't need to be said, but your patch is obviously superior. I ran into this while looking into a suggestion from Alvaro that ALTER should rewrite in order of a clustered index (if any) rather than in pre-existing heap order (more on that another day). So while this looks like a bug, and I can't think how a backpatch would break something, my suggestion is that backpatching a fix is of low value, so it's only worth +0. Thanks Justin