Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qv5fa-0037W9-SG for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Oct 2023 00:53:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qv5fY-000j7s-Ge for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Oct 2023 00:53:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qv5fY-000j6Y-7r for pgsql-bugs@lists.postgresql.org; Tue, 24 Oct 2023 00:53:16 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qv5fW-001zT5-DN for pgsql-bugs@lists.postgresql.org; Tue, 24 Oct 2023 00:53:15 +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 39O0rC60460389; Mon, 23 Oct 2023 20:53:12 -0400 From: Tom Lane To: Erwin Brandstetter cc: "David G. Johnston" , Jeff Janes , PostgreSQL Bug List Subject: Re: Variable substitution in jsonb functions fails for jsonpath operator like_regex In-reply-to: References: <3157573.1697663770@sss.pgh.pa.us> <3241895.1697679989@sss.pgh.pa.us> <3378578.1697742079@sss.pgh.pa.us> Comments: In-reply-to Erwin Brandstetter message dated "Tue, 24 Oct 2023 00:59:26 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <460387.1698108792.1@sss.pgh.pa.us> Date: Mon, 23 Oct 2023 20:53:12 -0400 Message-ID: <460388.1698108792@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Erwin Brandstetter writes: > On Thu, 19 Oct 2023 at 21:01, Tom Lane wrote: >> Hmm ... looks like we *are* following the standard: >> ... >> The text mentions that "the second operand is permitted to be an SQL/JSON >> sequence and to support existential semantics", whereas they evidently >> don't want that for a regex pattern. > So input from "vars" cannot be substituted into the jsonpath expression > after "like_regex" (as opposed to all other jsonpath operators). Seems > pretty random from a user's perspective. I agree it looks pretty random if you haven't drilled down into the spec's fine print. Personally I wouldn't be opposed to extending the spec here (not that I'm volunteering to write the patch). Nosing around in jsonpath_gram.y, I see datetime_template as the only other place where there's a random-seeming choice to allow STRING_P but not VARIABLE_P. Should we tackle that too? regards, tom lane