Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jv3il-0005rv-N0 for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Jul 2020 19:02:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jv3iD-0004Kw-4L for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Jul 2020 19:02:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jv3iC-0004Kk-U5 for pgsql-hackers@lists.postgresql.org; Mon, 13 Jul 2020 19:02:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jv3i5-0006Zv-W3 for pgsql-hackers@lists.postgresql.org; Mon, 13 Jul 2020 19:02:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 06DJ1ob52688629; Mon, 13 Jul 2020 15:01:51 -0400 From: Tom Lane To: Anastasia Lubennikova cc: Robert Haas , PostgreSQL Hackers Subject: Re: Proposal: Automatic partition creation In-reply-to: References: <7fec3abb-c663-c0d2-8452-a46141be6d4a@postgrespro.ru> <1378901.1594051837@sss.pgh.pa.us> Comments: In-reply-to Anastasia Lubennikova message dated "Mon, 13 Jul 2020 21:01:28 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2688627.1594666910.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 13 Jul 2020 15:01:50 -0400 Message-ID: <2688628.1594666910@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Anastasia Lubennikova writes: > On 06.07.2020 19:10, Tom Lane wrote: >> Robert Haas writes: >>> I think the big problem here is identifying the operator to use. We >>> have no way of identifying the "plus" or "minus" operator associated >>> with a datatype; indeed, that constant doesn't exist. >> We did indeed solve this in connection with window functions, cf >> 0a459cec9. I may be misunderstanding what the problem is here, >> but I think trying to reuse that infrastructure might help. > Do we need to introduce a new support function? Is there a reason why we= = > can not rely on '+' operator? (1) the appropriate operator might not be named '+' (2) even if it is, it might not be in your search_path (3) you're vulnerable to security problems from someone capturing the '+' operator with a better match; since you aren't writing the operator explicitly, you can't fix that by qualifying it (4) if the interval constant is written as an undecorated string literal, the parser may have trouble resolving a match at all > I understand that the addition operator may lack or be overloaded for > some complex datatypes, but I haven't found any examples that are useful > for range partitioning. "It works for all the built-in data types" isn't really a satisfactory answer. But even just in the built-in types, consider "date": # select oid::regoperator from pg_operator where oprname =3D'+' and oprlef= t =3D 'date'::regtype; oid = -------------------------------- +(date,interval) +(date,integer) +(date,time without time zone) +(date,time with time zone) (4 rows) It's not that immediately obvious which of these would make sense to use. But the short answer here is that we did not accept relying on '+' being the right thing for window function ranges, and I don't see why it is more acceptable for partitioning ranges. The existing places where our parser relies on implicit operator names are, without exception, problematic [1]. regards, tom lane [1] https://www.postgresql.org/message-id/flat/ffefc172-a487-aa87-a0e7-472= bf29735c8%40gmail.com