Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cOVhK-0003Rq-Uw for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Jan 2017 20:28:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cOVhK-0002GP-I3 for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Jan 2017 20:28:42 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cOVhJ-0002Fa-CU for pgsql-hackers@postgresql.org; Tue, 03 Jan 2017 20:28:41 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cOVhG-0004w7-JA for pgsql-hackers@postgresql.org; Tue, 03 Jan 2017 20:28:40 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v03KSXG8030894; Tue, 3 Jan 2017 15:28:33 -0500 From: Tom Lane To: Justin Pryzby cc: Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: ALTER TABLE .. ALTER COLUMN .. ERROR: attribute .. has wrong type In-reply-to: <30539.1483474695@sss.pgh.pa.us> References: <20161012152505.GD12747@telsasoft.com> <20170102225618.GA10071@telsasoft.com> <20170103003240.GM32031@telsasoft.com> <20170103165903.GP32031@telsasoft.com> <20170103185742.GQ32031@telsasoft.com> <28476.1483471956@sss.pgh.pa.us> <20170103194604.GR32031@telsasoft.com> <29101.1483473021@sss.pgh.pa.us> <20170103195709.GT32031@telsasoft.com> <30539.1483474695@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 03 Jan 2017 15:18:15 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30892.1483475313.1@sss.pgh.pa.us> Date: Tue, 03 Jan 2017 15:28:33 -0500 Message-ID: <30893.1483475313@sss.pgh.pa.us> X-Pg-Spam-Score: -5.1 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org I wrote: > I'm wondering if this represents some sort of out-of-sync condition > between the table and its child tables. Hah: regression=# create table p(f1 int); CREATE TABLE regression=# create table c1(extra smallint) inherits(p); CREATE TABLE regression=# alter table p add column f2 int; ALTER TABLE regression=# insert into c1 values(1,2,3); INSERT 0 1 regression=# alter table p alter column f2 type bigint using f2::bigint; ERROR: attribute 2 has wrong type DETAIL: Table has type smallint, but query expects integer. Of course, in c1 the target column is #3 not #2. The USING expression isn't being adjusted for the discrepancy between parent and child column numbers. This test case works before 9.5; somebody must have broke it while refactoring. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers