Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bVP5F-0000Fp-ID for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Aug 2016 20:17:37 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bVP5F-0004GP-51 for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Aug 2016 20:17: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 1bVP5E-0004EN-2O for pgsql-hackers@postgreSQL.org; Thu, 04 Aug 2016 20:17:36 +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 1bVP5B-0001aN-G3 for pgsql-hackers@postgreSQL.org; Thu, 04 Aug 2016 20:17:34 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id B5C1F2023E; Thu, 4 Aug 2016 16:17:32 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Thu, 04 Aug 2016 16:17:32 -0400 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-sasl-enc:x-sasl-enc; s=smtpout; bh=CV/3hP395+G6TlD KGfw3pi6rWFk=; b=QfCH1Z6mutwEMWbT6mrpCLmWIKs2sQl4hkzgC/EZdmUP9uK v2/AK8LXFvfWO9b9O1qr9AtppWZ8M3ElJZRJsDtqm4BaaJwDf8l5E7EEuMWZNqGG wJmaKFXG+u2LTrB9uDQPF6xptdxaqoRzOHD52kHHDuzPvDNdNXJmuItecsBA= X-Sasl-enc: APrZAusaazZdCxlp9CeZ3kErpRQHc7+0pQICVozuk76D 1470341852 Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id 6E6B1CCDA7; Thu, 4 Aug 2016 16:17:32 -0400 (EDT) Subject: Re: Keeping CURRENT_DATE and similar constructs in original format To: Tom Lane , pgsql-hackers@postgreSQL.org References: <30058.1463091294@sss.pgh.pa.us> From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: <3ceb9e06-bed7-6847-5bd8-c78bd7ed618e@2ndquadrant.com> Date: Thu, 4 Aug 2016 16:17:31 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <30058.1463091294@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit 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 On 5/12/16 6:14 PM, Tom Lane wrote: > So what I've wanted to do for some time is invent a new expression node > type that represents any one of these functions and can be reverse-listed > in the same format that the input had. The attached proposed patch does > that. I was experimenting with this as well when I found your patch, and I think this is the right solution. Your patch works fine for me. Because of the refactoring in 2f153ddfdd318b211590dd5585f65f357d85c2de, you will need to update your patch a bit. > (I'm not particularly in love with the node type name > ValueFunction; anybody got a better idea?) I think this is fine. The only other idea I have would be SQLValueFunction, to emphasize that this is about SQL-mandated special cases. > By the by, a scan through gram.y reveals other stuff we aren't trying > to reverse-list in original form: > > a_expr AT TIME ZONE a_expr > LIKE, ILIKE, SIMILAR TO > OVERLAPS > BETWEEN > COLLATION FOR '(' a_expr ')' > EXTRACT '(' extract_list ')' > OVERLAY '(' overlay_list ')' > POSITION '(' position_list ')' > SUBSTRING '(' substr_list ')' > TREAT '(' a_expr AS Typename ')' > TRIM '(' BOTH trim_list ')' > TRIM '(' LEADING trim_list ')' > TRIM '(' TRAILING trim_list ')' > TRIM '(' trim_list ')' > > Each of these gets converted to some PG-specific function or operator > name, and then will get reverse-listed using that name and ordinary > function or operator syntax, rather than using the SQL-approved special > syntax. I think those could be addressed by having ruleutils.c *always* convert matching function calls back to the special syntax. Alternatively, tag the function call node in the grammar with "this is special syntax" and then look for that in ruleutils.c. This is sort of what I was playing with, except that the several levels of casting for the datetime functions make that a mess. If it's only one function call, it should be easier. -- Peter Eisentraut http://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