From: | Gabriel Furstenheim Milerud <furstenheim(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Executing regex in C code |
Date: | 2017-07-30 15:46:53 |
Message-ID: | CAJN3DWrSZw=tHNGY6O0mxKBOd2nQLGKoUfR6pwUFXoJNkUB8Cw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I'm trying to execute the equivalent to '~' with regexp from within C code.
According to pg_operator
<https://github.com/postgres/postgres/blob/c7b8998ebbf310a156aa38022555a24d98fdbfb4/src/include/catalog/pg_operator.h>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.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-07-30 16:26:19 | Re: Executing regex in C code |
Previous Message | Melvin Davidson | 2017-07-29 20:17:52 | Re: Schemas and serials |