pgsql: Fix pg_dump's logic for eliding sequence limits that match the d

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix pg_dump's logic for eliding sequence limits that match the d
Date: 2018-02-20 16:23:52
Message-ID: E1eoAhs-0007ZO-8C@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix pg_dump's logic for eliding sequence limits that match the defaults.

The previous coding here applied atoi() to strings that could represent
values too large to fit in an int. If the overflowed value happened to
match one of the cases it was looking for, it would drop that limit
value from the output, leading to incorrect restoration of the sequence.

Avoid the unsafe behavior, and also make the logic cleaner by explicitly
calculating the default min/max values for the appropriate kind of
sequence.

Reported and patched by Alexey Bashtanov, though I whacked his patch
around a bit. Back-patch to v10 where the faulty logic was added.

Discussion: https://postgr.es/m/cb85a9a5-946b-c7c4-9cf2-6cd6e25d7a33@imap.cc

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3486bcf9e89d87b59d0e370af098fda38be97209

Modified Files
--------------
src/bin/pg_dump/pg_dump.c | 53 ++++++++++++++++++++++++++---------------------
1 file changed, 29 insertions(+), 24 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message David G. Johnston 2018-02-20 20:49:42 Re: pgsql: Allow UNIQUE indexes on partitioned tables
Previous Message Alvaro Herrera 2018-02-20 15:36:47 Re: pgsql: Allow UNIQUE indexes on partitioned tables