Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YaBps-0004vj-Gq for pgsql-bugs@arkaria.postgresql.org; Mon, 23 Mar 2015 23:32:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YaBpr-0005nO-C6 for pgsql-bugs@arkaria.postgresql.org; Mon, 23 Mar 2015 23:32:43 +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 1YaBpp-0005nF-CF for pgsql-bugs@postgresql.org; Mon, 23 Mar 2015 23:32:41 +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 1YaBpk-0006E9-Tk for pgsql-bugs@postgresql.org; Mon, 23 Mar 2015 23:32:40 +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 t2NNWX2J019821; Mon, 23 Mar 2015 19:32:33 -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: References: Comments: In-reply-to Jeff Davis message dated "Mon, 23 Mar 2015 13:05:47 -0700" Date: Mon, 23 Mar 2015 19:32:33 -0400 Message-ID: <19820.1427153553@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: > create table pt(a int, b int, c float8 check (c < '10.1')); > create table ct(a int, b int, c float8); > select pg_get_constraintdef(oid) from pg_constraint where conname='pt_c_check'; > pg_get_constraintdef > -------------------------------------- > CHECK ((c < 10.1::double precision)) > (1 row) > -- copy constraint to "ct" using syntax given above > alter table ct add constraint pt_c_check CHECK ((c < 10.1::double precision)); > select pg_get_constraintdef(oid) from pg_constraint where conname='pt_c_check'; > pg_get_constraintdef > ---------------------------------------- > CHECK ((c < 10.1::double precision)) > CHECK ((c < (10.1)::double precision)) > (2 rows) What's evidently happening here is that ruleutils.c thinks it can dump a float8 constant using the syntax "10.1::double precision", but the parser will interpret that as a numeric constant with a separate cast step. I don't see any simple way around that except to dump using the syntax '10.1'::double precision which is ugly as sin, but perhaps we have no choice. A longer-term solution might be to get the parser to interpret 10.1::double precision as a float8 literal to start with, but that seems like it could have unexpected side-effects? Not sure. OTOH, you could argue that existing dump files already have the unquoted-literal syntax so it behooves us to try to get the parser to read them as they were meant. A larger issue is that I have a nasty feeling that this isn't the only place where ruleutils.c output might be read in a way that's functionally equivalent to the original, but not the exact same parsetree. 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