Re: [PATCHES] Proposed patch for sequence-renaming problems

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] Proposed patch for sequence-renaming problems
Date: 2005-10-01 19:28:58
Message-ID: 200510011928.j91JSwQ15723@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Bruce Momjian wrote:
> Tom Lane wrote:
> > Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > > Tom Lane wrote:
> > >> Does that sound like a workable compromise?
> >
> > > Personally, I _love_ it. I hope others do as well. :-)
> >
> > OK, I'll work up a patch.
>
> Here is a query that shows nextval(::text) usage as defaults:
>
> SELECT n.nspname, c.relname, a.attname, d.adsrc
> FROM pg_namespace n, pg_class c, pg_attribute a, pg_attrdef d
> WHERE n.oid = c.relnamespace AND
> c.oid = a.attrelid AND
> a.attrelid = d.adrelid AND
> a.attnum = d.adnum AND
> d.adsrc ~ '.*nextval\\(''[^'']*''::TEXT\\)';

Sorry, this is the right one:

SELECT n.nspname, c.relname, a.attname, d.adsrc
FROM pg_namespace n, pg_class c, pg_attribute a, pg_attrdef d
WHERE n.oid = c.relnamespace AND
c.oid = a.attrelid AND
a.attrelid = d.adrelid AND
a.attnum = d.adnum AND
d.adsrc ~ '.*nextval\\(''[^'']*''::text\\)';

Followed by the appropriate:

ALTER TABLE sp.test2 ALTER COLUMN x DROP DEFAULT;

ALTER TABLE sp.test2 ALTER COLUMN x SET DEFAULT nextval('sp.aa');

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2005-10-01 19:32:52 Re: effective SELECT from child tables
Previous Message Bruce Momjian 2005-10-01 19:09:19 Re: [PATCHES] Proposed patch for sequence-renaming problems

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-10-01 21:01:51 Re: Proposed patch for sequence-renaming problems
Previous Message Bruce Momjian 2005-10-01 19:09:19 Re: [PATCHES] Proposed patch for sequence-renaming problems