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 1qtI7W-00BnCK-1e for pgsql-bugs@arkaria.postgresql.org; Thu, 19 Oct 2023 01:46:42 +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 1qtI7S-00BKHa-Vz for pgsql-bugs@arkaria.postgresql.org; Thu, 19 Oct 2023 01:46:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qtI7S-00BKHS-NX for pgsql-bugs@lists.postgresql.org; Thu, 19 Oct 2023 01:46:39 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qtI7K-001SND-LY for pgsql-bugs@lists.postgresql.org; Thu, 19 Oct 2023 01:46:38 +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 39J1kTtQ3241896; Wed, 18 Oct 2023 21:46:29 -0400 From: Tom Lane To: Jeff Janes cc: Erwin Brandstetter , pgsql-bugs@lists.postgresql.org Subject: Re: Variable substitution in jsonb functions fails for jsonpath operator like_regex In-reply-to: References: <3157573.1697663770@sss.pgh.pa.us> Comments: In-reply-to Jeff Janes message dated "Wed, 18 Oct 2023 20:42:21 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3241894.1697679989.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Wed, 18 Oct 2023 21:46:29 -0400 Message-ID: <3241895.1697679989@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jeff Janes writes: > On Wed, Oct 18, 2023 at 5:20 PM Tom Lane wrote: >> Maybe it wouldn't take more than s/STRING_P/starts_with_initial/ >> here (though I'd then rename starts_with_initial to something >> more generic). > I tried it, and it didn't work. No error, it just doesn't match > anything--including literal values which do match things in HEAD. Oh, duh, makeItemLikeRegex() is expecting a plain JsonPathString, and JsonPathParseItem.value.like_regex is set up for just a constant pattern. We could no doubt fix that, but it's a bigger lift than I was hoping. > Maybe the problem is that the regex pattern is compiled at the same time > the jsonpath is compiled? Doesn't look that way to me: executeLikeRegex is just using RE_compile_and_execute every time. (It's "caching" a text datum representing the pattern string, which might be a good candidate for the silliest use of caching I've ever seen in PG; it's surely not buying any useful increment of performance.) regards, tom lane