Re: Index file got removed

From: Julien Rouhaud <julien(dot)rouhaud(at)dalibo(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, sudalai <sudalait2(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Index file got removed
Date: 2016-11-22 19:32:12
Message-ID: 20161122193212.GD22157@nol.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Nov 22, 2016 at 09:57:29PM +0900, Michael Paquier wrote:
>
> So I have explored in the code what would be the best way to fix the problem:
> 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.
>
> 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 everything
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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2016-11-22 19:33:24 Re: Index file got removed
Previous Message Michael Paquier 2016-11-22 12:57:29 Re: Index file got removed