Search code examples
sqlpostgresqlfull-text-searchtx-indexed-search

Postgres full text search error when using setweight()


I have PostgreSQL 9.6.8 running on Fedora 27 64bit. When i execute this query:

UPDATE tbl SET textsearchable_index_col = 
setweight(to_tsvector('french', coalesce("col1",'')), 'D') || 
setweight(to_tsvector('french', coalesce("col2",'')), 'D');

I get this error:

ERROR:  cache lookup failed for function 3625

********** Error **********

ERROR: cache lookup failed for function 3625
SQL state: XX000

but when I execute either:

UPDATE tbl SET textsearchable_index_col = 
setweight(to_tsvector('french', coalesce("col1",'')), 'D');

or

UPDATE tbl SET textsearchable_index_col = 
setweight(to_tsvector('french', coalesce("col2",'')), 'D');

I get:

Query returned successfully: 0 rows affected, 11 msec execution time.

My question is why does it work for either column individually but it does not work when together? This link shows that it should be possible to use both columns in the same query (at the end of section 12.3.1).

Edit: here is what the system returns for Laurenz's queries. The first query returns

 oprname | oprleft  | oprright | oprcode     
---------+----------+----------+----------
 ||      | tsvector | tsvector | 3625

The second query returns an empty result set.


Solution

  • Your database is corrupted, and you are lacking the function tsvector_concat which is the function behind the || operator.

    This is how it should look on a healthy system:

    SELECT oprname, oprleft::regtype, oprright::regtype, oprcode
    FROM pg_operator
    WHERE oid = 3633;
    
     oprname | oprleft  | oprright |     oprcode     
    ---------+----------+----------+-----------------
     ||      | tsvector | tsvector | tsvector_concat
    (1 row)
    
    SELECT proname, proargtypes::regtype[], prosrc
    FROM pg_proc
    WHERE oid = 3625;
    
         proname     |        proargtypes        |     prosrc      
    -----------------+---------------------------+-----------------
     tsvector_concat | [0:1]={tsvector,tsvector} | tsvector_concat
    (1 row)
    

    The second part is missing in your case.

    You should restore from a backup.

    Try to figure out how you got into this mess so that you can avoid it in the future.