BUG #2307: Buckup and sequences in DEFAULT part

Started by Kamil Gizaabout 20 years ago5 messagesbugs
Jump to latest
#1Kamil Giza
kamilg@zeto.olsztyn.pl

The following bug has been logged online:

Bug reference: 2307
Logged by: Giza Kamil
Email address: kamilg@zeto.olsztyn.pl
PostgreSQL version: 8.1.3
Operating system: Windows,Linux
Description: Buckup and sequences in DEFAULT part
Details:

Hi!
My script is:
CREATE SEQUENCE schema.seq_taid;
CREATE TABLE schema.tab1(ID integer DEFAULT nextval('schema.seq_taid'));

After runing on server I have:

CREATE TABLE schema.tab1(ID integer DEFAULT
nextval('schema.seq_taid'::regclass));

but on 8.0 version was

CREATE TABLE schema.tab1(ID integer DEFAULT
nextval(('schema.seq_taid'::text)::regclass));

Buckups on 8.0 were OK, but on 8.1 I'm getting samething like that:
CREATE TABLE schema.tab1(ID integer DEFAULT nextval('seq_taid'::regclass));
Buckup cat schema name from sequence name in function nextval in DEFAULT
part.

Problem exists in buckups in PgAdmin and pg_buckup from command line on
server.

Is there any kind of solution for that or I have to wait for next version.
It's a very important for me to resolve this problem as quickly as
possible.

Best regards,
Kamil Giza

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Kamil Giza (#1)
Re: BUG #2307: Buckup and sequences in DEFAULT part

"Giza Kamil" <kamilg@zeto.olsztyn.pl> writes:

Buckups on 8.0 were OK, but on 8.1 I'm getting samething like that:
CREATE TABLE schema.tab1(ID integer DEFAULT nextval('seq_taid'::regclass));

You haven't said why you think this is a problem. The dump is perfectly
valid AFAICS.

regards, tom lane

#3Kamil Giza
kamilg@zeto.olsztyn.pl
In reply to: Tom Lane (#2)
Re: BUG #2307: Buckup and sequences in DEFAULT part

It's a problem because after restore, server is looking for sequence in
schema "public" but sequence was created in schema "schema".
When I'm inserting new row to the table I have an error because server
can't find the sequence.
I know I can set proper searchpath, but now I can't because I have
sequences with the same names in different schemas.

regards,
Kamil Giza

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Kamil Giza (#3)
Re: BUG #2307: Buckup and sequences in DEFAULT part

Kamil Giza <kamilg@zeto.olsztyn.pl> writes:

It's a problem because after restore, server is looking for sequence in
schema "public" but sequence was created in schema "schema".

No, it doesn't. regclass constants don't work that way; the sequence is
identified by OID, and isn't subject to search path issues at all. You
are assuming a problem that does not exist anymore.

regards, tom lane

#5Kamil Giza
kamilg@zeto.olsztyn.pl
In reply to: Tom Lane (#4)
Re: BUG #2307: Buckup and sequences in DEFAULT part

OK. You are right. Everything is OK with PostgreSQL. The problem is with
ZEOS components for Delphi. Sorry for trouble.

regards,
Kamil Giza