Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7UkG-0003sI-0i for pgsql-bugs@arkaria.postgresql.org; Thu, 17 Nov 2016 22:01:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1c7UkF-0007Xi-EN for pgsql-bugs@arkaria.postgresql.org; Thu, 17 Nov 2016 22:01:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1c7UkE-0007XC-R2 for pgsql-bugs@postgresql.org; Thu, 17 Nov 2016 22:01:22 +0000 Received: from mimolette.dalibo.net ([212.85.157.144] helo=mail.dalibo.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1c7UkB-0003S6-Gf for pgsql-bugs@postgresql.org; Thu, 17 Nov 2016 22:01:22 +0000 Received: from nol.local (aur75-1-78-192-238-147.fbxo.proxad.net [78.192.238.147]) by mail.dalibo.com (Postfix) with ESMTPSA id 088912C06A1; Thu, 17 Nov 2016 23:01:17 +0100 (CET) Subject: Re: Index file got removed To: Tom Lane , Michael Paquier References: <1479294998857-5930602.post@n3.nabble.com> <23523.1479317197@sss.pgh.pa.us> Cc: sudalai , PostgreSQL mailing lists From: Julien Rouhaud Message-ID: Date: Thu, 17 Nov 2016 23:01:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 17/11/2016 22:31, Julien Rouhaud wrote: > On 16/11/2016 18:26, Tom Lane wrote: >> Michael Paquier writes: >>> On Wed, Nov 16, 2016 at 3:16 AM, sudalai wrote: >>>> I am creating a table test and index for that table on default tablespace. >>>> Then i'm changing default_tablespace to some other tablespace. >>>> After that altering one of the index column. >>>> This alter operation moves the index to new default_tablespace, but index >>>> file is missing in new tablespace. >> >>> I am just digging into it, instinctively that would be something in >>> tablecmds.c.. >> >> I'm betting that where it reconstructs textual commands to create the new >> indexes, it's forgotten to do anything about tablespaces. > > I looked at it, and IIUC the issue is that during AT_PASS_OLD_INDEX > pass, ATExecAddIndex defines a new index using the old heap in original > tablespace (stmt->oldNode is valid), and DefineIndex will create a new > cat entry using the current default tablespace instead of the existing > index one. > > The only way I found to fix this is to save the original tablespace in > ATExecAddIndex() if the old heap is reused, see attached patch. I'm not > at all familiar with this part of code, but at least initdb and > regression tests don't fail. After some more thoughts, this is probably broken if a single command recreates a mix of indexes that should be and should not be rebuilt. The original tablespace information could be saved and restored around DefineIndex(), but since it looks like an ugly hack I prefer to wait if there's a better fix for this. -- Julien Rouhaud http://dalibo.com - http://dalibo.org -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs