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 1gYlOF-0002Ra-K9 for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Dec 2018 05:24:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gYlOE-0006k5-0W for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Dec 2018 05:24:26 +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 1gYlOD-0006jc-MV for pgsql-hackers@lists.postgresql.org; Mon, 17 Dec 2018 05:24:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYlO6-0002uL-UM for pgsql-hackers@lists.postgresql.org; Mon, 17 Dec 2018 05:24:24 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wBH5OFao008777; Mon, 17 Dec 2018 00:24:15 -0500 From: Tom Lane To: Michael Paquier cc: Amul Sul , pgsql-hackers@lists.postgresql.org, a.korotkov@postgrespro.ru Subject: Re: ALTER INDEX ... ALTER COLUMN not present in dump In-reply-to: <20181217051439.GG31474@paquier.xyz> References: <20181122003147.GA3369@paquier.xyz> <154477492593.1386.13640101253353637283.pgcf@coridan.postgresql.org> <20181217051439.GG31474@paquier.xyz> Comments: In-reply-to Michael Paquier message dated "Mon, 17 Dec 2018 14:14:39 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8775.1545024255.1@sss.pgh.pa.us> Date: Mon, 17 Dec 2018 00:24:15 -0500 Message-ID: <8776.1545024255@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Michael Paquier writes: > As Alexander and others state on this thread, it looks a bit weird to > use internally-produced attribute names in those SQL queries, which is > why the new grammar has been added. At the same time, it looks more > solid to me to represent the dumps with those column names instead of > column numbers. Tom, Alexander, as you have commented on the original > thread, perhaps you have an opinion here to share? The problem is that there's no guarantee that the new server would generate the same column name for an index column --- and I don't want to try to lock things down so much that there would be such a guarantee. So I'd go with the column-number form. As an example: regression=# create table foo (expr int, f1 int, f2 int); CREATE TABLE regression=# create index on foo ((f1+f2)); CREATE INDEX regression=# create index on foo (expr, (f1+f2)); CREATE INDEX regression=# \d foo Table "public.foo" Column | Type | Collation | Nullable | Default --------+---------+-----------+----------+--------- expr | integer | | | f1 | integer | | | f2 | integer | | | Indexes: "foo_expr_expr1_idx" btree (expr, (f1 + f2)) "foo_expr_idx" btree ((f1 + f2)) regression=# \d foo_expr_idx Index "public.foo_expr_idx" Column | Type | Key? | Definition --------+---------+------+------------ expr | integer | yes | (f1 + f2) btree, for table "public.foo" regression=# \d foo_expr_expr1_idx Index "public.foo_expr_expr1_idx" Column | Type | Key? | Definition --------+---------+------+------------ expr | integer | yes | expr expr1 | integer | yes | (f1 + f2) btree, for table "public.foo" If we were to rename the "foo.expr" column at this point, and then dump and reload, the expression column in the second index would presumably acquire the name "expr" not "expr1", because "expr" would no longer be taken. So if pg_dump were to try to use that index column name in ALTER ... SET STATISTICS, it'd fail. regards, tom lane