Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d5dm4-00039F-Gp for pgsql-hackers@arkaria.postgresql.org; Tue, 02 May 2017 19:47:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d5dm4-0008Ui-3T for pgsql-hackers@arkaria.postgresql.org; Tue, 02 May 2017 19:47:52 +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 1d5dkV-0002kq-Fh for pgsql-hackers@postgresql.org; Tue, 02 May 2017 19:46:15 +0000 Received: from mimolette.dalibo.net ([212.85.157.144] helo=mail.dalibo.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d5dkS-0004sq-1x for pgsql-hackers@postgresql.org; Tue, 02 May 2017 19:46:14 +0000 Received: from nol.local (130.120.138.88.rev.sfr.net [88.138.120.130]) by mail.dalibo.com (Postfix) with ESMTPSA id 91D7C2C08D3; Tue, 2 May 2017 21:46:10 +0200 (CEST) Subject: Re: [GENERAL] Column rename in an extension update script To: Philippe BEAUDOIN , pgsql-hackers References: <2cf7941e-4e41-7714-3de8-37b1a8f74dff@free.fr> From: Julien Rouhaud Message-ID: <24fbcf75-04d2-9d10-ac12-c99fe4ca96a4@dalibo.com> Date: Tue, 2 May 2017 21:45:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <2cf7941e-4e41-7714-3de8-37b1a8f74dff@free.fr> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -1.9 (-) 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 moving this thread to -hackers, since this looks like a bug. On 01/05/2017 08:54, Philippe BEAUDOIN wrote: > Hi all, > > I am coding an update script for an extension. And I am in trouble when > trying to rename a column of an existing table. > > Just after the ALTER TABLE statement, I want to access this table. But > at this time, the altered column is not visible with its new name. > I can reproduce this issue. It looks like this is due to missing cache invalidation between the ALTER TABLE execution and next query planning (failure happens during pg_analyze_and_rewrite()). AFAICT, CommandCounterIncrement() is responsible for handling invalidation messages, but in execute_sql_string() this function is called before executing a Stmt instead of after. Moving the CommandCounterIncrement() just before the PopActiveSnapshot() call (and removing the final one) fixes this issue for me, but I have no idea if this is the right fix. -- Julien Rouhaud http://dalibo.com - http://dalibo.org -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers