From: stan <stanb@panix.com>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general@postgresql.org
Cc: crodmail@gmail.com
Cc: docrtp@gmail.com
Cc: stanbrow@gmail.com
Subject: Re: A question about sequences and backup/restore cycles
Date: Tue, 22 Oct 2019 16:35:53 -0400
Message-ID: <20191022203553.GA6369@panix.com> (raw)
In-Reply-To: <a1048170-3b64-ddd1-9a00-0881a2cc0140@aklaver.com>
References: <20191022001331.GC10733@panix.com>
<c2a2c79f-b004-81b7-9a51-1fbc8bc341e2@aklaver.com>
<20191022113214.GA19088@panix.com>
<5805b200-6569-072c-f2c5-5462361e626c@aklaver.com>
<20191022174827.GB1406@panix.com>
<a1048170-3b64-ddd1-9a00-0881a2cc0140@aklaver.com>
On Tue, Oct 22, 2019 at 12:48:41PM -0700, Adrian Klaver wrote:
> On 10/22/19 10:48 AM, stan wrote:
> Please reply to list also:
> Ccing list.
>
>
> >
> > Sorry if my description was not clear.
> >
> > No, we do not mix test, and production data. Let me try to clarify the
> > question. Looking at a pg_dump, I see the following:
> >
> >
> > CREATE SEQUENCE public.customer_key_serial
> > START WITH 1
> > INCREMENT BY 1
> > NO MINVALUE
> > NO MAXVALUE
> > CACHE 1;
> >
> >
> > Yet, in the same pg_dump file I have:
> >
> >
> >
> >
> > COPY public.customer (customer_key, cust_no, name, c_type, location,
> > bill_address_1, bill_address_2, bill_city, bill_state, bill_zip,
> > bill_country, bill_attention, bill_addressee, ship_address_1,
> > ship_address_2, ship_addressee, ship_attention, ship_city, ship_state,
> > ship_zip, office_phone_area_code, office_phone_exchange,
> > office_phone_number, office_phone_extension, cell_phone_area_code,
> > cell_phone_exchange, cell_phone_number, ship_phone_area_code,
> > ship_phone_exchange, ship_phone_number, ship_phone_extension,
> > fax_phone_area_code, fax_phone_exchange, fax_phone_number, status, modtime)
> > FROM stdin;
> > 1 12 Made Up Inc. INDUSTRIAL_CONVEYOR \N 101 Nowhere
> > Ave. \N LaGrange GA 00000 \N \N \N
> > \N \N \N \N \N \N 00000 \N \N \N
> > \N \N \N \N \N \N \N \N \N
> > \N \N ACTIVE 2019-09-30 23:55:04.594203+00
> > 2 5 Jimmys Favorite Customer. PLASTICS \N
> > 56 Somewhere St. \N No Such City SC 00000 \N
> > \N \N \N \N \N \N \N \N 00000
> > \N \N \N \N \N \N \N \N \N
> > \N \N \N \N \N ACTIVE 2019-09-30
> > 23:55:04.636827+00
> >
> > So it appears to me the customer table is going to get (correctly) populated
> > with the originally generated keys, yet the sequence will want to return a 1
> > the next time it is called, when a new customer gets inserted.
> >
> > Am I missing something here?
> >
>
> Yes something like this, in dump file, for non-serial sequence:
>
> CREATE SEQUENCE public.plant1_p_item_no_seq
> START WITH 1
> INCREMENT BY 1
> NO MINVALUE
> NO MAXVALUE
> CACHE 1;
>
> SELECT pg_catalog.setval('public.plant1_p_item_no_seq', 5509, true);
>
> or for serial sequence:
>
> CREATE SEQUENCE public.avail_headers_line_id_seq
> AS integer
> START WITH 1
> INCREMENT BY 1
> NO MINVALUE
> NO MAXVALUE
> CACHE 1;
>
> ALTER TABLE ONLY public.avail_headers ALTER COLUMN line_id SET DEFAULT
> nextval('public.avail_headers_line_id_seq'::regclass);
>
>
> SELECT pg_catalog.setval('public.avail_headers_line_id_seq', 53, true);
>
> If you want to see how things are run on a higher level do something like:
>
> pg_dump -Fc -d some_db -f db.out
>
> pg_restore -l db_out > db_toc.txt
>
> -l on pg_restore creates a TOC(table of contents) showing the ordering of
> the schema recreation.
>
Oh, excellent.!!
Thanks for the patience to teach me about this.
Does make me wonder what the vendor did to create our issue on their
database.
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
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-general@postgresql.org
Cc: stanb@panix.com, adrian.klaver@aklaver.com, crodmail@gmail.com, docrtp@gmail.com, stanbrow@gmail.com
Subject: Re: A question about sequences and backup/restore cycles
In-Reply-To: <20191022203553.GA6369@panix.com>
References: <20191022001331.GC10733@panix.com> <c2a2c79f-b004-81b7-9a51-1fbc8bc341e2@aklaver.com> <20191022113214.GA19088@panix.com> <5805b200-6569-072c-f2c5-5462361e626c@aklaver.com> <20191022174827.GB1406@panix.com> <a1048170-3b64-ddd1-9a00-0881a2cc0140@aklaver.com> <20191022203553.GA6369@panix.com>
* 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