Search Postgresql Archives

Re: Executing regex in C code

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

 



Thanks a lot,
That did the trick

Best regards

On 30 July 2017 at 18:26, Tom Lane <tgl@xxxxxxxxxxxxx> wrote:
Gabriel Furstenheim Milerud <furstenheim@xxxxxxxxx> writes:
> I'm trying to execute the equivalent to '~' with regexp from within 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.

Yes, you need to use DirectFunctionCall2Coll() if you're trying to invoke
a collation-aware function.  It's probably good enough to pass
DEFAULT_COLLATION_OID, although if you're inside a SQL function of
your own, passing down whatever collation was passed to you would
be a better plan.

                        regards, tom lane


[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