Thread: tsearch2 upgrade problem and mediawiki

tsearch2 upgrade problem and mediawiki

From
Jon Lapham
Date:
After upgrading from Postgres 8.1 to 8.2 (via pg_dumpall) I had problems
with mediawiki (v1.9.2) that utilized tsearch2.  I thought I had fixed
the problem by removing tsearch2 in my v8.1 databases, pg_dumpall-ing
and reloading to v8.2, and re-installing tsearch2 from scratch.

When updating a page in mediawiki, I get an error.  This is what I am
seeing in my pg_log:

STATEMENT:  SELECT nextval('rev_rev_id_val')
ERROR:  record "new" has no field "textvector"
CONTEXT:  PL/pgSQL function "ts2_page_text" line 3 at assignment
STATEMENT:  INSERT /* Revision::insertOn */  INTO pagecontent
(old_id,old_text,old_flags) VALUES ('2128','{| class="wikitable [snip]

The table "pagecontent" has a trigger:
wikidb=> \d pagecontent
                         Table "mediawiki.pagecontent"
   Column   |  Type   |                       Modifiers

-----------+---------+-------------------------------------------------------
  old_id    | integer | not null default
nextval('text_old_id_val'::regclass)
  old_text  | text    |
  old_flags | text    |
Indexes:
     "pagecontent_pkey" PRIMARY KEY, btree (old_id)
Triggers:
     ts2_page_text BEFORE INSERT OR UPDATE ON pagecontent FOR EACH ROW
EXECUTE PROCEDURE ts2_page_text()

with this code:

BEGIN
   IF TG_OP = 'INSERT' THEN
   NEW.textvector = to_tsvector('default',NEW.old_text);
   ELSIF NEW.old_text != OLD.old_text THEN
   NEW.textvector := to_tsvector('default',NEW.old_text);
   END IF;
   RETURN NEW;
   END;

This looks like a problem with tsearch2 to me... can anyone give me a
pointer on where to go from here to debug this?  Thanks!

-Jon

--
-**-*-*---*-*---*-*---*-----*-*-----*---*-*---*-----*-----*-*-----*---
  Jon Lapham  <lapham@jandr.org>                Rio de Janeiro, Brasil
  Personal: http://www.jandr.org/
***-*--*----*-------*------------*--------------------*---------------


Re: tsearch2 upgrade problem and mediawiki

From
Richard Huxton
Date:
Jon Lapham wrote:
> After upgrading from Postgres 8.1 to 8.2 (via pg_dumpall) I had problems
> with mediawiki (v1.9.2) that utilized tsearch2.  I thought I had fixed
> the problem by removing tsearch2 in my v8.1 databases, pg_dumpall-ing
> and reloading to v8.2, and re-installing tsearch2 from scratch.
>
> When updating a page in mediawiki, I get an error.  This is what I am
> seeing in my pg_log:
>
> STATEMENT:  SELECT nextval('rev_rev_id_val')
> ERROR:  record "new" has no field "textvector"

> BEGIN
>   IF TG_OP = 'INSERT' THEN
>   NEW.textvector = to_tsvector('default',NEW.old_text);
>   ELSIF NEW.old_text != OLD.old_text THEN
>   NEW.textvector := to_tsvector('default',NEW.old_text);
>   END IF;
>   RETURN NEW;
>   END;
>
> This looks like a problem with tsearch2 to me... can anyone give me a
> pointer on where to go from here to debug this?  Thanks!

Well, that's a trigger that's updating a column called "textvector" of
type tsvector (a tsearch2 type). It's not a tsearch2 trigger function
though, so presumably it comes with mediawiki.

Try just adding the column, I'm guessing it was dropped while you were
taking out the old tsearch2 installation.
   ALTER TABLE pagecontent ADD COLUMN textvector tsvector;

Incidentally, I tend to install tsearch2 in its own schema now, makes it
simpler to check what's installed. It does mean you need to do alter
your search_path though.

Oh, and 8.3 will have tsearch as a built-in.

--
   Richard Huxton
   Archonet Ltd

Re: tsearch2 upgrade problem and mediawiki

From
Jon Lapham
Date:
Richard Huxton wrote:
> Try just adding the column, I'm guessing it was dropped while you were
> taking out the old tsearch2 installation.
>   ALTER TABLE pagecontent ADD COLUMN textvector tsvector;

Thanks, that fixed the problem.

--
-**-*-*---*-*---*-*---*-----*-*-----*---*-*---*-----*-----*-*-----*---
  Jon Lapham  <lapham@jandr.org>                Rio de Janeiro, Brasil
  Personal: http://www.jandr.org/
***-*--*----*-------*------------*--------------------*---------------