Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YccRx-0000tD-Ab for pgsql-bugs@arkaria.postgresql.org; Mon, 30 Mar 2015 16:22:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YccRw-000518-Oa for pgsql-bugs@arkaria.postgresql.org; Mon, 30 Mar 2015 16:22:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YccRv-0004zD-F1 for pgsql-bugs@postgresql.org; Mon, 30 Mar 2015 16:22:03 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YccRr-00082z-VQ for pgsql-bugs@postgresql.org; Mon, 30 Mar 2015 16:22:02 +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 t2UGLvZB017190; Mon, 30 Mar 2015 12:21:57 -0400 From: Tom Lane To: Jeff Davis cc: pgsql-bugs@postgresql.org Subject: Re: pg_get_constraintdef() doesn't always give an equal constraint In-reply-to: <1427694213.2845.20.camel@jeff-desktop> References: <19820.1427153553@sss.pgh.pa.us> <14244.1427569696@sss.pgh.pa.us> <1427694213.2845.20.camel@jeff-desktop> Comments: In-reply-to Jeff Davis message dated "Sun, 29 Mar 2015 22:43:33 -0700" Date: Mon, 30 Mar 2015 12:21:57 -0400 Message-ID: <17189.1427732517@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) 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 Jeff Davis writes: > On Sat, 2015-03-28 at 15:08 -0400, Tom Lane wrote: >> Basically, I think we have to change ruleutils so that it quotes anything >> that wouldn't be seen as a simple integer or numeric constant by the >> lexer+grammar. >> >> The attached patch does this; the regression test changes illustrate >> what's going to happen to the output if we do this. > This fixes my problem, thank you. OK. Given the lack of other suggestions, let's press forward with fixing it this way. > There are two switch statements in that function, and they have > overlapping purposes. Can't we just always set needlabel in the first > switch statement, and remove the second switch statement? Meh. The two switches are considering different things and don't have exactly the same set of switch labels, so I don't really see that as an improvement ... > When I refactored it to do that (attached), I noticed that if showtype > == -1, it returns before appending the collation. I don't see any reason > those should be related, so I removed the early return (I don't think > there's an actual bug there, though). ... especially since this change is outright wrong. showtype == -1 implies that the caller is going to print a cast; we cannot insert a COLLATE clause in the middle of that without breaking things. (It may be that this case is unreachable because a vanilla Const would never have nondefault collation, but that doesn't make it a good change.) >> Looking at the changes, I'm not 100% convinced we want to back-patch. >> As you say, nobody's complained of this problem before, and I'm worried >> that people will see the output changes as a bigger deal than the issue >> we're trying to fix. > Fine with me. Agreed, we'll fix HEAD only. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs