Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cOJTV-0005xS-Q9 for pgsql-bugs@arkaria.postgresql.org; Tue, 03 Jan 2017 07:25:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cOJTV-0004tj-3T for pgsql-bugs@arkaria.postgresql.org; Tue, 03 Jan 2017 07:25:37 +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 1cOJTT-0004tE-1m for pgsql-bugs@postgresql.org; Tue, 03 Jan 2017 07:25:35 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cOJTL-00069f-6S for pgsql-bugs@postgresql.org; Tue, 03 Jan 2017 07:25:33 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 4D11A20BCF for ; Tue, 3 Jan 2017 02:25:26 -0500 (EST) Received: from web2 ([10.202.2.212]) by compute2.internal (MEProxy); Tue, 03 Jan 2017 02:25:26 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.fm; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=IYbNLUcj2HtrZIMTCkOWHjxdGf w=; b=g8vuE1N/UIgLwaq6A1hearqLNncttDqVwThBRx9pOlOuTLYI6MrQ8hkIhC yN+he8CJjY0adxJXY+PUtPArOt3jDeiohKz772IU3+X2+Zgi94C4Xt838TJ15myv NX6KqOJcOyfYDHcEW+4xfWbH2TyUoFT2uJ2p2OWTnY+tYKgfw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=smtpout; bh=IY bNLUcj2HtrZIMTCkOWHjxdGfw=; b=Kwp/a0se/y45/3/s9QUsriIRF9haOCdVof Ndz69eGjtCxFexWoql0heDSLJKXLVVaxVcnWrohtZS2epGnujA5076N2k1fzWBZ1 jZR/MJymvp47pvtgNsIKq+RPCUZBENo4x27vdO+xjIhYrfWF9EZxRV+umfv/wTlq pGsk8JDpc= X-ME-Sender: Received: by mailuser.nyi.internal (Postfix, from userid 99) id 2BC5D626D0; Tue, 3 Jan 2017 02:25:26 -0500 (EST) Message-Id: <1483428326.1346104.835592537.16DDF6CD@webmail.messagingengine.com> From: CN To: pgsql-bugs@postgresql.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-9c115fcf Date: Tue, 03 Jan 2017 15:25:26 +0800 Subject: Re: BUG #14483: Prepared statement does not re-plan while it should References: <20170102154014.10135.49515@wrigleys.postgresql.org> <16871.1483373067@sss.pgh.pa.us> In-Reply-To: <16871.1483373067@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org > This behavior is intentional: it's to keep applications from having to > deal with the possibility that they prepare a statement, Describe it > to find out what columns it returns, and then when they actually execute > it, it returns some other column set. Many thanks for the clarification! I am not sure if it is appropriate to turn this bug report into feature request, again. We will get several results by searching key phrase "cached plan must not change result type". It will be much easier for me to use prepared statements if they are automatically re-parsed after any DDL that affects them or "SET SEARCH_PATH TO" is executed. I believe this is especially true where connection pool products are used. Even without using connections pooling, the following example shows that simple usage can also cause production applications to malfunction - they get the error when developers are also changing the database schema: ==== test=# CREATE TABLE t1 (c1 INTEGER); CREATE TABLE test=# PREPARE p1 AS SELECT c1 FROM t1; PREPARE test=# EXECUTE p1; c1 ---- (0 rows) test=# ALTER TABLE t1 ALTER c1 TYPE TEXT; ALTER TABLE test=# EXECUTE p1; ERROR: cached plan must not change result type ==== Once an application encounters this problem, disconnecting from the database and reconnecting back, which usually means restarting the application, seems to be the only way to "fix" it. Although deallocating prepared statements wherever necessary ultimately avoids this issue, it is complicated for me to correctly implement such applications. As a result, I currently avoid using prepared statements altogether and hence obviously greatly degrade the overall performance. Best Regards, CN -- http://www.fastmail.com - Choose from over 50 domains or use your own -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs