From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Amul Sul <sulamul@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Cc: a.korotkov@postgrespro.ru
Subject: Re: ALTER INDEX ... ALTER COLUMN not present in dump
Date: Mon, 17 Dec 2018 00:24:15 -0500
Message-ID: <8776.1545024255@sss.pgh.pa.us> (raw)
In-Reply-To: <20181217051439.GG31474@paquier.xyz>
References: <CAARsnT3UQ4V=yDNW468w8RqHfYiY9mpn2r_c5UkBJ97NAApUEw@mail.gmail.com>
<20181122003147.GA3369@paquier.xyz>
<154477492593.1386.13640101253353637283.pgcf@coridan.postgresql.org>
<20181217051439.GG31474@paquier.xyz>
Michael Paquier <michael@paquier.xyz> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, michael@paquier.xyz, sulamul@gmail.com, pgsql-hackers@lists.postgresql.org, a.korotkov@postgrespro.ru
Subject: Re: ALTER INDEX ... ALTER COLUMN not present in dump
In-Reply-To: <8776.1545024255@sss.pgh.pa.us>
References: <CAARsnT3UQ4V=yDNW468w8RqHfYiY9mpn2r_c5UkBJ97NAApUEw@mail.gmail.com> <20181122003147.GA3369@paquier.xyz> <154477492593.1386.13640101253353637283.pgcf@coridan.postgresql.org> <20181217051439.GG31474@paquier.xyz> <8776.1545024255@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox