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 1mQcdu-0000Qq-W3 for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Sep 2021 21:40: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 1mQcds-0002HU-Pp for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Sep 2021 21:40:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mQcdr-0002FJ-FV for pgsql-hackers@lists.postgresql.org; Wed, 15 Sep 2021 21:40:32 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mQcdk-0004xz-PC for pgsql-hackers@lists.postgresql.org; Wed, 15 Sep 2021 21:40:30 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 9BEC25C00E2; Wed, 15 Sep 2021 17:40:22 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 15 Sep 2021 17:40:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=l49tlSXZ0zYODgpyGd9/1LA7+ym qbsWO1kyDlwADLY4=; b=A3wWcy3mygTE9TRzvWL0lK9DBm2/gGntDokhTxILSSY iAAhq5TClpbHZ1xlnZx4Oa3nm2FEbbjSBECI27eNME8WiZxbqh66mvfAU88eh5QO nOpcGi82SFRDSwX3TwQb96qDWpBepPu63cx9Q6K2iHq6zhW5CO0O+X6TcAT+CrlV Ma1Rboh32/CImBgE2ZP1BDqg0urp/Eb9h9CU+3xJVnHBtAEm3SLmAr5yeqAKFcCD voL7tTfpxoWT0do9cxiXs0eQJX79oiMSdPFGN9nDeYh8gIQKU+PhL6ipSOsyKctm hIc69hu+zDbD26Qp+/jJU/MTQ1b/sBiHouXdMJtuhPg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=l49tlS XZ0zYODgpyGd9/1LA7+ymqbsWO1kyDlwADLY4=; b=k0U92Yu/2grs5jQ/Fip/cm q7LPBjHgSrpgxpS9xn1tv+5S26OYgBLKn8YybH1rcjJdLy0IFj0IxjsNJj8Gt4W8 AApatgVL+HY210iRf+Kji9ys3unLSCbLeeF6D+QcaBMEhGO7GbBDGcFV0B47+Hr1 C+z0jP/ArDsZLdcFMcs7CkW9J7tRoeqEqjF1Z2T++B6i3StzB7dJGXKLjXmkXvhQ mU2qqHRXn1VtvyFcZLd8IfiYyDe1S35829mvtopL82n3jzXTMbnji2j+MTCg3fHU BCP8NwCakd8oBetpOcbYKKAN1VD1S/K7j/2VoEtmfs/WcMGdEPyGcH2f5UVRvCTA == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudehfecutefuodetggdotefrodftvfcurf hrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghsucfh rhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrthhtvg hrnhepudekhfekleeugeevteehleffffejgeelueduleeffeeutdelffeujeffhfeuffdu necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghnug hrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 15 Sep 2021 17:40:21 -0400 (EDT) Date: Wed, 15 Sep 2021 14:40:19 -0700 From: Andres Freund To: Tom Lane Cc: Julien Rouhaud , Jim Mlodgenski , Simon Riggs , PostgreSQL Developers Subject: Re: Hook for extensible parsing. Message-ID: <20210915214019.xtphp3vd2345dir4@alap3.anarazel.de> References: <20210501072458.adqjoaqnmhg4l34l@nol> <984300.1631719616@sss.pgh.pa.us> <1023941.1631725020@sss.pgh.pa.us> <20210915195506.bse4pzi2x5atxzzw@alap3.anarazel.de> <1091268.1631739097@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1091268.1631739097@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2021-09-15 16:51:37 -0400, Tom Lane wrote: > The other problem here is that a simple call-this-instead-of-that > top-level hook doesn't seem all that useful anyway, because it leaves > you with the task of duplicating a huge amount of functionality that > you're then going to make some tweaks within. That's already an issue > when you're just thinking about the grammar, and if you have to buy > into it for parse analysis too, I doubt that it's going to be very > practical. If, say, you'd like to support some weird function that > requires special parsing and analysis rules, I don't see how you get > that out of this without first duplicating a very large fraction of > src/backend/parser/. We do have a small amount of infrastructure around this - the hackery that plpgsql uses. That's not going to help you with everything, but I think it should be be enough to recognize e.g. additional top-level statements. Obviously not enough to intercept parsing deeper into a statement, but at least something. And parse-analysis for some types of things will be doable with the current infrastructure, by e.g. handling the new top-level statement in the hook, and then passing the buck to the normal parse analysis for e.g. expressions in that. Obviously not going to get you that far... > (As a comparison point, we do have a top-level hook for replacing > the planner; but I have never heard of anyone actually doing so. > There are people using that hook to *wrap* the planner with some > before-and-after processing, which is quite a different thing.) Citus IIRC has some paths that do not end up calling into the standard planner, but only for a few simplistic cases. > I don't have any better ideas to offer :-( ... but I very much fear > that the approach proposed here is a dead end. I unfortunately don't see a good way forward without changing the way we do parsing on a more fundamental level :(. Greetings, Andres Freund