Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQia4-0008Mr-7G for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Jan 2017 22:38:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cQia3-0004iZ-QQ for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Jan 2017 22:38:19 +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 1cQia1-0004dz-Rg for pgsql-hackers@postgresql.org; Mon, 09 Jan 2017 22:38:17 +0000 Received: from mail-qt0-x235.google.com ([2607:f8b0:400d:c0d::235]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cQiZy-0001xl-3R for pgsql-hackers@postgresql.org; Mon, 09 Jan 2017 22:38:16 +0000 Received: by mail-qt0-x235.google.com with SMTP id k15so379673502qtg.3 for ; Mon, 09 Jan 2017 14:38:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=NdLQAM0e5H9d3bxCpMWtudLJAzxBVzkpmYsNH/fYV5A=; b=fBQkmVuJrkEnCVA3LAmvHPOvDb+tENzWL+PBe6YU7OW3E9hii5sm+UxRgSweb9sFQ+ IoAGVpvhnB4ppMY33Zh8xSHbGWt5Uu/9EYQ4WUM7CyXxVKFrgKmaIFDCW7vFAZeVoqEZ xkqIBD0bs0cQCoCdNKt4NaRDvf2raxdIMEHhtSwIu8aBZEvJsEVsAE3FJKnY1QjkhvrE Do2dI6kt0Ys/tl11rozvaq6+8MY69MOg/qIPAu97ekXqua/Uk09Ow4/bPxxjFw72YT+3 8jriDHSIk8cTnm5c2pWYYAy+XUJRv9Ls8LPiH8bu2k0RNPvVtgdzI55M+gYdWGhyarRn JK/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=NdLQAM0e5H9d3bxCpMWtudLJAzxBVzkpmYsNH/fYV5A=; b=pV/I2x54MjBMFi3u6+BnZrCeyaMBH5/cizqGlRCMCMd9gszKc2SZYcUWOcCeKxPGGB Mju7QZF/BMQ3nZrija8EXZbuSsgz+tIW1OP4CM+atdu4sqYY0SJO/MB4lXDp7tZGgJUz bKcLAnbOtrG3Fk7emne0l2pcTzBhIYDxavA78g6A4lUfqN1PB0FkmmjjDcPX7lljpj7h dN7iSLprUc6ZfuI+AMDrn/Eizmfv6juYUwwgqD57AVqiHabRQ/mR924PiygiZuSrmFJD NtJx85v4zKF0tZPQVxwsd2F/c5NNyZibMkET21GTeei0/g7X+PvSCVsvtwQ30cmr21FY SyAA== X-Gm-Message-State: AIkVDXJ84Msvdq404UF1zYBoWz7fHCDWge4jLWltyt4UJiqMazUdNcw/Ne0a0ifETSsL7vmJ X-Received: by 10.237.43.167 with SMTP id e36mr3546187qtd.245.1484001493051; Mon, 09 Jan 2017 14:38:13 -0800 (PST) Received: from alvin.alvh.no-ip.org ([181.42.144.42]) by smtp.gmail.com with ESMTPSA id h46sm58484065qta.35.2017.01.09.14.38.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jan 2017 14:38:12 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 8617C1590; Mon, 9 Jan 2017 19:38:07 -0300 (CLST) Date: Mon, 9 Jan 2017 19:38:07 -0300 From: Alvaro Herrera To: Tom Lane Cc: Justin Pryzby , Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: ALTER TABLE .. ALTER COLUMN .. ERROR: attribute .. has wrong type Message-ID: <20170109223807.qxuckfwaihh72x2w@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <26761.1483989025@sss.pgh.pa.us> User-Agent: NeoMutt/20161104 (1.7.1) X-Pg-Spam-Score: -2.6 (--) 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 Tom Lane wrote: > Alvaro Herrera writes: > > Tom Lane wrote: > >> [ 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. > > > Ah, nice gadget. I think the attached patch should do. > > Looks reasonable to me. Thanks for looking! Pushed. > > Hm, I was thinking in unreasonable numbers of columns, keeping in mind > > that they can appear in arbitrary order in child tables. Then again, > > that probably seldom occurs in real databases. I suppose this could > > become an issue with table partitioning becoming more common, but I'm > > okay with deferring the optimization work. > > It occurred to me that it'd be really easy to improve > convert_tuples_by_name so that, rather than having the inner loop > start from j = 0 every time, it starts from the attribute after the > last match (and loops around if needed, so that it still examines > every child attribute). I think this would keep it at more-or-less > linear time for all but very contrived child tables. > > Since your patch is touching that code I won't do anything about it > right now, but maybe later. Yeah, I had the same idea. Looks fiddly but not terribly difficult, and well localized. Didn't we have a list of tasks for eager contributors? -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers