Re: PLPerl Trigger to update text search

From: Alex Hunsaker <badalex(at)gmail(dot)com>
To: Alex Magnum <magnum11200(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: PLPerl Trigger to update text search
Date: 2015-08-01 01:15:11
Message-ID: CAFaPBrQA5T717aMm5UPK3C2KhzCWAUtMTQKHDU=-z_xXXjejgQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jul 31, 2015 at 6:07 AM, Alex Magnum <magnum11200(at)gmail(dot)com> wrote:

> Hi,
>
> I am trying to update a tsvector field through a plperl trigger.
>
> $_TD->{new}{text_search} = to_tsvector('pg_catalog.english', 'text1
> text2');
>
>
You need to wrap that into an actual SPI call at the very least. Database
procedures are not available natively for PL languages in general (minus
perhaps pl/pgsql).

Something like:

$_TD->{new}{text_search} =
spi_exec_query("to_tsvector('pg_catalog.english', ". quote_literal('text1
text2') .";")->{rows}[0]{to_tsvector};

If performance is any consideration, I suspect pl/pgsql would be the clear
winner.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alex Hunsaker 2015-08-01 01:16:32 Re: PLPerl Trigger to update text search
Previous Message Ramesh T 2015-07-31 16:39:24 postgres 9.3