Re: ALTER TABLE .. ALTER COLUMN .. ERROR: attribute .. has wrong type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER TABLE .. ALTER COLUMN .. ERROR: attribute .. has wrong type
Date: 2017-01-03 21:26:42
Message-ID: 24903.1483478802@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Justin Pryzby <pryzby(at)telsasoft(dot)com> writes:
> On Tue, Jan 03, 2017 at 03:35:34PM -0500, Tom Lane wrote:
>> Right. So I bet that if you check the attnum of pmsumpacketlatency_000 in
>> eric_umts_rnc_utrancell_metrics, you'll find it's different from that in
>> eric_umts_rnc_utrancell_201701, and that the attribute having that attnum
>> in eric_umts_rnc_utrancell_201701 has type smallint not int.

> I think that's consistent with what your understanding:

> ts=# SELECT attrelid::regclass, attname, attnum, atttypid FROM pg_attribute WHERE attrelid::regclass::text~'eric_umts_rnc_utrancell_(metrics|201701)$' AND (attname='pmsumpacketlatency_000' OR attnum IN (367,424) ) ORDER BY 1,2;
> eric_umts_rnc_utrancell_metrics | pmsamplespshsadchrabestablish | 367 | 21
> eric_umts_rnc_utrancell_metrics | pmsumpacketlatency_000 | 424 | 23
> eric_umts_rnc_utrancell_201701 | pmsumpacketlatency_000 | 367 | 23
> eric_umts_rnc_utrancell_201701 | pmulupswitchsuccessmedium | 424 | 21

Yup. So if you can't wait for a fix, your best bet would be to dump and
reload these tables, which should bring their attnums back in sync.
(Of course, they might not stay that way for long, if you're also
in the habit of adding columns often.)

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-01-03 21:30:27 Re: Broken atomics code on PPC with FreeBSD 10.3
Previous Message Tom Lane 2017-01-03 21:13:10 Re: Shrink volume of default make output