Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fga8y-0005Hk-Hu for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Jul 2018 18:28:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fga8w-0000QG-Jj for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Jul 2018 18:28:42 +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.89) (envelope-from ) id 1fga8w-0000Q8-9a for pgsql-bugs@lists.postgresql.org; Fri, 20 Jul 2018 18:28:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fga8s-0000nd-5y for pgsql-bugs@lists.postgresql.org; Fri, 20 Jul 2018 18:28:41 +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 w6KISWst028173; Fri, 20 Jul 2018 14:28:32 -0400 From: Tom Lane To: Andrew Gierth cc: Ireneusz Pluta , Andres Freund , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15287: postgres_fdw: the "WHERE date_trunc('day', dt) = 'YYYY-MM-DD' does not push to remote. In-reply-to: <87effxizux.fsf@news-spur.riddles.org.uk> References: <153210427860.1404.15984608571673921883@wrigleys.postgresql.org> <20180720163945.exro5xgl7skq3kzo@alap3.anarazel.de> <9d6b978a-1aff-4f9e-03c6-0489836570d8@wp.pl> <23967.1532106431@sss.pgh.pa.us> <87effxizux.fsf@news-spur.riddles.org.uk> Comments: In-reply-to Andrew Gierth message dated "Fri, 20 Jul 2018 18:31:13 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28171.1532111312.1@sss.pgh.pa.us> Date: Fri, 20 Jul 2018 14:28:32 -0400 Message-ID: <28172.1532111312@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andrew Gierth writes: > Wild idea: we have quite a few functions (e.g. date_trunc, date_part, > timezone, encode, decode, make_timestamptz, plus various extension > functions such as in pgcrypto) that take a "text" parameter which is > nothing more than a poor-man's enum, or otherwise represents something > which isn't actually free text. Perhaps these should use "name" instead, > or in some cases an enum type? Hm. It'd definitely be cool if constant text parameters could be const-folded to some enum-like representation, so that at runtime these functions would just do integer comparisons rather than string comparisons to decide what to do. Not sure about the backwards compatibility considerations though. However, that could only fix the OP's problem for these particular functions, which are a small fraction of the ones we have that take collatable types but don't really care about collation. I kinda feel like we should have invented an "ignores collation" function property, so that such functions could be identified --- that would not only let postgres_fdw handle this honestly, but we could refrain from throwing unmatched-collations errors for cases where it doesn't really matter. Maybe it's not too late to invent that in future. If the parser sets inputcollid = 0 for any function marked that way, then if the function is incorrectly marked as ignoring collation it would get an error at runtime, so it seems like we could add it safely. > (or in the case of date_trunc and extract, maybe they need to be split > up into separate functions so that we can properly distinguish the > immutable from the mutable cases) Different issue ... and not actually relevant to this case, since this form of date_trunc is immutable. regards, tom lane