Thread: pgsql: pg_upgrade: preserve database and relation minmxid values

pgsql: pg_upgrade: preserve database and relation minmxid values

From
Bruce Momjian
Date:
pg_upgrade:  preserve database and relation minmxid values

Also set these values for pre-9.3 old clusters that don't have values to
preserve.

Analysis by Alvaro

Backpatch through 9.3

Branch
------
REL9_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/b446a384b7c231e3fa10dfb0fbc9247a6b329348

Modified Files
--------------
contrib/pg_upgrade/pg_upgrade.c |   68 +++++++++++++-------
contrib/pg_upgrade/server.c     |   13 ++--
src/bin/pg_dump/pg_dump.c       |  132 ++++++++++++++++++++++++++-------------
src/bin/pg_dump/pg_dump.h       |    2 +
src/bin/pg_dump/pg_dumpall.c    |   39 +++++++-----
5 files changed, 171 insertions(+), 83 deletions(-)


Re: pgsql: pg_upgrade: preserve database and relation minmxid values

From
Andres Freund
Date:
Hi,

On 2014-07-02 19:29:43 +0000, Bruce Momjian wrote:
> pg_upgrade:  preserve database and relation minmxid values
>
> Also set these values for pre-9.3 old clusters that don't have values to
> preserve.
>
> Analysis by Alvaro
>
> Backpatch through 9.3

My compiler quite correctly complains about misleading indentation
introduced by this commit:

/home/andres/src/postgresql-9.3/src/bin/pg_dump/pg_dump.c:2475:4: warning: statement is indented as if it were guarded
by...[-Wmisleading-indentation] 
    lo_res = ExecuteSqlQueryForSingleRow(fout, loFrozenQry->data);
    ^~~~~~
/home/andres/src/postgresql-9.3/src/bin/pg_dump/pg_dump.c:2469:3: note: ...this 'else' clause, but it is not
   else
   ^~~~

The code in question is:
                /*
                 * pg_largeobject_metadata
                 */
                if (fout->remoteVersion >= 90000)
                {
                        resetPQExpBuffer(loFrozenQry);
                        resetPQExpBuffer(loOutQry);

                if (fout->remoteVersion >= 90300)
                        appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid\n"
                                                          "FROM pg_catalog.pg_class\n"
                                                          "WHERE oid = %u;\n",
                                                          LargeObjectMetadataRelationId);
                else
                        appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid\n"
                                                          "FROM pg_catalog.pg_class\n"
                                                          "WHERE oid = %u;\n",
                                                          LargeObjectMetadataRelationId);

                        lo_res = ExecuteSqlQueryForSingleRow(fout, loFrozenQry->data);

This appears to have been the result of a somewhat incorrectly resolved
conflict in 9.3/9.4 (master/9.5 don't show the problem).

Regards,

Andres


Re: pgsql: pg_upgrade: preserve database and relation minmxid values

From
Bruce Momjian
Date:
On Sun, Mar 27, 2016 at 05:44:51PM +0200, Andres Freund wrote:
> Hi,
>
> On 2014-07-02 19:29:43 +0000, Bruce Momjian wrote:
> > pg_upgrade:  preserve database and relation minmxid values
> >
> > Also set these values for pre-9.3 old clusters that don't have values to
> > preserve.
> >
> > Analysis by Alvaro
> >
> > Backpatch through 9.3
>
> My compiler quite correctly complains about misleading indentation
> introduced by this commit:
>
> /home/andres/src/postgresql-9.3/src/bin/pg_dump/pg_dump.c:2475:4: warning: statement is indented as if it were
guardedby... [-Wmisleading-indentation] 
>     lo_res = ExecuteSqlQueryForSingleRow(fout, loFrozenQry->data);
>     ^~~~~~
> /home/andres/src/postgresql-9.3/src/bin/pg_dump/pg_dump.c:2469:3: note: ...this 'else' clause, but it is not
>    else
>    ^~~~
>
> The code in question is:
>                 /*
>                  * pg_largeobject_metadata
>                  */
>                 if (fout->remoteVersion >= 90000)
>                 {
>                         resetPQExpBuffer(loFrozenQry);
>                         resetPQExpBuffer(loOutQry);
>
>                 if (fout->remoteVersion >= 90300)
>                         appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid\n"
>                                                           "FROM pg_catalog.pg_class\n"
>                                                           "WHERE oid = %u;\n",
>                                                           LargeObjectMetadataRelationId);
>                 else
>                         appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid\n"
>                                                           "FROM pg_catalog.pg_class\n"
>                                                           "WHERE oid = %u;\n",
>                                                           LargeObjectMetadataRelationId);
>
>                         lo_res = ExecuteSqlQueryForSingleRow(fout, loFrozenQry->data);
>
> This appears to have been the result of a somewhat incorrectly resolved
> conflict in 9.3/9.4 (master/9.5 don't show the problem).

Thanks, indentation fixed.

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

+ As you are, so once was I. As I am, so you will be. +
+                     Ancient Roman grave inscription +