Re: [PATCH] pg_upgrade fails when postgres/template1 isn't in default tablespace - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [PATCH] pg_upgrade fails when postgres/template1 isn't in default tablespace
Date
Msg-id 20150904001009.GA17454@momjian.us
Whole thread Raw
In response to Re: [PATCH] pg_upgrade fails when postgres/template1 isn't in default tablespace  (Andres Freund <andres@anarazel.de>)
Responses Re: [PATCH] pg_upgrade fails when postgres/template1 isn't in default tablespace  (Hyongtae Lim <htlim@bitnine.co.kr>)
List pgsql-hackers
On Thu, Sep  3, 2015 at 01:03:30PM +0200, Andres Freund wrote:
> Hi Bruce,
>
> Are you actually waiting for review in this thread? Or is the CF entry
> more of a reminder?

Oh, I have a commit-fest entry for this?  Well, whoever did that was
doing the right thing so things are not forgotten.  Yeah!  :-)

Anyway, I was going to work on this once I had read my email backlog,
but because of the commit-fest entry, I worked on it today instead.

I have developed the attached patch which fixes the pg_upgrade problem,
and the pg_dumpall problem with postgres and template1 in non-default
tablespaces.  I modified the pg_dumpall patch with the following changes:

*  It is a general pg_dumpall bug, not specific to binary upgrade mode,
so the new code will be used in non-binary upgrade mode too.

* I hard-coded the "connect template1" string, as it is a constant (no
need for %s and fmtId()).

*  You can't mix fprintf() and appendPQExpBuffer() and get the output in
the specified order, i.e. fprintf will come out first.  Now, in your
case, it didn't matter, but it isn't clean either.

*  I wanted the original database connection to be restored right after
the switch.

The new output looks like this:

    \connect postgres
    ALTER DATABASE template1 SET TABLESPACE tt;
    \connect template1

Based on our previous policy, these are both bugs and cause either
errors or inaccurate restores, so I plan to apply the attached patch to
all back branches.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +

Attachment

pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: BRIN INDEX value
Next
From: Bruce Momjian
Date:
Subject: Re: Freeze avoidance of very large table.