Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cPcm3-0000VT-Ua for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Jan 2017 22:14:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cPcm3-0002d8-Cr for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Jan 2017 22:14:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cPckd-0000uh-7i for pgsql-hackers@postgresql.org; Fri, 06 Jan 2017 22:12:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cPcka-0002Hu-40 for pgsql-hackers@postgresql.org; Fri, 06 Jan 2017 22:12:42 +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 v06MCYJK027954; Fri, 6 Jan 2017 17:12:34 -0500 From: Tom Lane To: Alvaro Herrera cc: Justin Pryzby , Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: ALTER TABLE .. ALTER COLUMN .. ERROR: attribute .. has wrong type In-reply-to: <20170106213346.vro3rrghuzabnxmv@alvherre.pgsql> References: <20170106213346.vro3rrghuzabnxmv@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Fri, 06 Jan 2017 18:33:46 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27952.1483740754.1@sss.pgh.pa.us> Date: Fri, 06 Jan 2017 17:12:34 -0500 Message-ID: <27953.1483740754@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 Alvaro Herrera writes: > Tom Lane wrote: >> Hmm. The bespoke code for constructing the attno map bothers me; >> surely there is existing code that does that? If not, it'd still >> make more sense to factor it out, I think, because there will be >> other needs for it in future. > There isn't any that I could find -- all the existing callers of > map_variable_attnos build their map in other ways (while walking an > attribute array at construction time). [ pokes around... ] The code I was thinking of is convert_tuples_by_name in access/common/tupconvert.c. There's a bit of an API mismatch in that it wants to wrap the mapping array in a TupleConversionMap struct; but maybe we could refactor tupconvert.c to offer a way to get just the map array. > I also modified the algorithm to use the relcache instead of walking the > child's attribute list for each parent attribute (that was silly). Hmm. That might be better in a big-O sense but I doubt it's faster for reasonable numbers of columns. > My rationale when writing the event trigger code was that each command > would only be published once, for the parent table, not recursively for > each child. So only the original expression should be seen. Oh good; then we're just talking about a localized bug fix and not a protocol break for event triggers. 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