pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jeff Janes <jeff.janes@gmail.com>
Cc: Erwin Brandstetter <brsaweda@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Variable substitution in jsonb functions fails for jsonpath operator like_regex
Date: Wed, 18 Oct 2023 21:46:29 -0400
Message-ID: <3241895.1697679989@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMkU=1x1bkHBczE4XZ1w=pyE75EGbkxGMUOYLwHMkp4t74vUwg@mail.gmail.com>
References: <CAGHENJ4A8awD2uXHkf50eV+9wyiDm3eP+G10J09+0VRmXBQAdw@mail.gmail.com>
	<3157573.1697663770@sss.pgh.pa.us>
	<CAMkU=1x1bkHBczE4XZ1w=pyE75EGbkxGMUOYLwHMkp4t74vUwg@mail.gmail.com>

Jeff Janes <jeff.janes@gmail.com> writes:
> On Wed, Oct 18, 2023 at 5:20 PM Tom Lane <tgl@sss.pgh.pa.us> 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





view thread (8+ messages)  latest in thread

Message-ID: <3241895.1697679989@sss.pgh.pa.us>
Permalink:  ../3241895.1697679989@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3241895.1697679989@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jeff.janes@gmail.com, brsaweda@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: Variable substitution in jsonb functions fails for jsonpath operator like_regex
  In-Reply-To: <3241895.1697679989@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox