[PATCH] Add planner support function to two-argument regexp_like()

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: [PATCH] Add planner support function to two-argument regexp_like()
Date: 2026-07-29 04:11:37
Message-ID: CAGRkXqQZA-LX2UGewj9jHEmUE94U49i8XJjauDiUxZ34Tv1S-g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

The ~ operator gets index conditions from a fixed pattern prefix, via
textregexeq_support(). regexp_like(), which is the same test, has no
support function and so misses out.

With no flags the two are identical, and like_regex_support() already
handles a FuncExpr, so the patch is just a prosupport entry plus a test.

1M rows, text column, btree index, C locale:
before: Seq Scan 255.094 ms
after: Index Only Scan, Index Cond on prefix 0.010 ms

I left the three-argument form alone: with 'n', '^' matches after a
newline, so a prefix range would miss rows. Handling flags needs its
own support function.

make check passes. Needs a catversion bump.

Regards,
Shihao

Attachment Content-Type Size
0001-Add-planner-support-function-to-two-argument-regexp_.patch application/octet-stream 7.2 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-07-29 04:14:38 Re: Build warning with meson and dtrace on Fedora 43
Previous Message shveta malik 2026-07-29 04:10:11 Re: Race between pg_dump and ALTER SEQUENCE can cause read failure