[GENERAL] Executing regex in C code - Mailing list pgsql-general

From Gabriel Furstenheim Milerud
Subject [GENERAL] Executing regex in C code
Date
Msg-id CAJN3DWrSZw=tHNGY6O0mxKBOd2nQLGKoUfR6pwUFXoJNkUB8Cw@mail.gmail.com
Whole thread Raw
Responses Re: [GENERAL] Executing regex in C code  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi,
I'm trying to execute the equivalent to '~' with regexp from within C code. According to pg_operator this operator for type text corresponds to textregexeq:

  DATA(insert OID = 641 ( "~" PGNSP PGUID b f f 25 25 16 0 642 textregexeq regexeqsel regexeqjoinsel ));
  DESCR("matches regular expression, case-sensitive");

I've tried to execute it from the C code:

  text * s = cstring_to_text("aa");
  text * p = cstring_to_text("a");
  return DatumGetBool(DirectFunctionCall2(textregexeq, PointerGetDatum(s), PointerGetDatum(p)));

But I'm getting an error with collate:

ERROR:  could not determine which collation to use for regular expression
HINT: Use the COLLATE clause to set the collation explicitly.
Any hints on how to proceed? Of course if I do select 'aa'~'a'; from psql it works like a charm.

Thanks in advance.

pgsql-general by date:

Previous
From: Melvin Davidson
Date:
Subject: Re: [GENERAL] Schemas and serials
Next
From: Tom Lane
Date:
Subject: Re: [GENERAL] Executing regex in C code