From: | Gabriel Furstenheim Milerud <furstenheim(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Executing regex in C code |
Date: | 2017-07-30 16:47:00 |
Message-ID: | CAJN3DWo=BOO+s8rgYiMhFiPnzPrO3VrvnpqOm6zPKGZO+xXkXg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thanks a lot,
That did the trick
Best regards
On 30 July 2017 at 18:26, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Gabriel Furstenheim Milerud <furstenheim(at)gmail(dot)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
>
From | Date | Subject | |
---|---|---|---|
Next Message | Vincenzo Romano | 2017-07-30 16:53:25 | Re: RETURNS SETOF RECORD with 1 column |
Previous Message | marcelo | 2017-07-30 16:36:11 | Re: Schemas and serials |