Search Postgresql Archives

Executing regex in C code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux