"Function unaccent(text) does not exist" in update trigger

All we need is an easy explanation of the problem, so here it is.

I’ve created a trigger for table x1 to update a column y with the expression to_tsvector(unaccent(x1.col1 || ' ' || x2.col1)). This trigger function throws:

function unaccent(text) does not exist

Why would this function not exist when a trigger is called, but exist when executed manually? I’m using Supabase to manage this database.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

The function unaccent() is typically the one installed by the additional module unaccent. See:

Additional modules can be installed to any schema. (I like to use a dedicated schema.) See:

If so, then the schema must be added to the search_path to allow function calls without schema-qualification like you demonstrate.

The obvious explanation for your observation would be that you call the function in one session with an appropriate search_path, and execute the trigger in another session with a different search_path.

To diagnose, add this line to your PL/pgSQL trigger function just before the command calling unaccent() temporarily (and make sure notices are logged or reported to the client, depending on where you look):

RAISE NOTICE 'Current search_path: %', current_setting('search_path');

The simple & safe fix is to schema-qualify the function name. Like:


But investigate whether schemas and the search_path are handled properly across your DB cluster …

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply