proposal: prefix function - Mailing list pgsql-hackers

From Pavel Stehule
Subject proposal: prefix function
Date
Msg-id CAFj8pRDj04axPu2GgR8fDouDHLfxzyzcdqS0c+NOSfxJkYbRFQ@mail.gmail.com
Whole thread Raw
Responses Re: proposal: prefix function  (Chris Travers <chris.travers@adjust.com>)
List pgsql-hackers
Hi

can we implement prefix function for fast test if substr is prefix of some string?

create or replace function prefix(str text, substr text)
returns boolean as $$
  select substr(str, 1, length(substr)) = substr
$$ language sql;

This function can be very effective in C language. Now it should be implemented with like or regexp, what is significantly more expensive.

Regards

Pavel

pgsql-hackers by date:

Previous
From: Haribabu Kommi
Date:
Subject: Re: Pluggable Storage - Andres's take
Next
From: Thomas Munro
Date:
Subject: Re: [PATCH] Tab completion for ALTER DATABASE … SET TABLESPACE