Re: [GENERAL] Executing regex in C code

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [GENERAL] Executing regex in C code
Дата
Msg-id 24047.1501431979@sss.pgh.pa.us
обсуждение исходный текст
Ответ на [GENERAL] Executing regex in C code  (Gabriel Furstenheim Milerud <furstenheim@gmail.com>)
Ответы Re: [GENERAL] Executing regex in C code
Список pgsql-general
Gabriel Furstenheim Milerud <furstenheim@gmail.com> 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


В списке pgsql-general по дате отправления:

Предыдущее
От: Gabriel Furstenheim Milerud
Дата:
Сообщение: [GENERAL] Executing regex in C code
Следующее
От: marcelo
Дата:
Сообщение: Re: [GENERAL] Schemas and serials