Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9GoR-0006aa-D4 for pgsql-bugs@arkaria.postgresql.org; Tue, 22 Nov 2016 19:33:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1c9GoQ-0001De-WC for pgsql-bugs@arkaria.postgresql.org; Tue, 22 Nov 2016 19:33:03 +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 1c9Gnl-0000Tc-PI for pgsql-bugs@postgresql.org; Tue, 22 Nov 2016 19:32:21 +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 1c9Gnh-00057v-Ua for pgsql-bugs@postgresql.org; Tue, 22 Nov 2016 19:32:21 +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 92E852C055C; Tue, 22 Nov 2016 20:32:15 +0100 (CET) Date: Tue, 22 Nov 2016 20:32:12 +0100 From: Julien Rouhaud To: Michael Paquier Cc: Tom Lane , sudalai , PostgreSQL mailing lists Subject: Re: Index file got removed Message-ID: <20161122193212.GD22157@nol.local> References: <1479294998857-5930602.post@n3.nabble.com> <23523.1479317197@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qFgkTsE6LiHkLPZw" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) 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 --qFgkTsE6LiHkLPZw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 22, 2016 at 09:57:29PM +0900, Michael Paquier wrote: >=20 > So I have explored in the code what would be the best way to fix the prob= lem: > 1) Append the correct tablespace to the SQL string of CREATE INDEX. > Those command strings are stored in changedIndexDefs in tablecmds.c, > and those get generated by pg_get_indexdef_string(), which can append > a tablespace if it is *not* a default. Appending *pg_default* to it > would be dangerous and it would have user-visible changes. OK _string > is not directly SQL callable but any caller of this function would be > impacted. > 2) Take advantage of is_alter_table in DefineIndex(), and do some > extra processing when assigning the tablespace of an index. In short, > if IndexStmt->tablespace is NULL and DefineIndex() is used for an > ALTER TABLE, ignore default_tablespace and assign pg_default. This > way, the current tablespace of an index is protected all the time, > even if the tablespace of an index is not the default. >=20 > 2) is more solid, and is far less invasive than 1), and has no impact > on existing routines of ruleutils.c, so I have implemented it with a > set of regression tests. I am adding that to the next CF so as we > don't forget about it. Thoughts are welcome. I agree that 2nd solution looks better. I reviewed your patch and everythi= ng works as intended, same for new regression tests which seem to cover all possible cases. I mark it as ready for committers. -- Julien Rouhaud http://dalibo.com - http://dalibo.org --qFgkTsE6LiHkLPZw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- iQEcBAEBCAAGBQJYNJ06AAoJELGaJ8vfEpOqdGkH/2dC0C0b/zPq5J5zQ2IWXCuR bGjElCxtu4qFp0k5fMLr5L+hAwNNulNOZzdtdpwxDkE32T2uTzu9ejGdJw+XJaGY 84MWKCDyGwShF4YyKdzVxXjFQa1gwe3aTy/fhbz6sR1i/bncHfmwc1Ouwb1KS+cN ASBK1AHZBSUDrrb6gj4pCX1CEKAw7xjIkFrOFmwxsrjdXXaeB+VYKCqkP/8zZEmo uH3Ppxvp6uR4A94krLGTwilnjusWqctSZRpcyigGBP0bubNg3Hev/piDNP9EZeeJ MjK8pkfKPiwDGYTMYfbgj6Wh7TAFkPOTof5SGx3Mm/L3X5lvtHVGM/GyY3BrCTs= =4sdB -----END PGP SIGNATURE----- --qFgkTsE6LiHkLPZw--