diff --git a/contrib/unaccent/unaccent.c b/contrib/unaccent/unaccent.c index 247c202755..dbf2bb9602 100644 --- a/contrib/unaccent/unaccent.c +++ b/contrib/unaccent/unaccent.c @@ -20,7 +20,9 @@ #include "tsearch/ts_locale.h" #include "tsearch/ts_public.h" #include "utils/builtins.h" +#include "utils/lsyscache.h" #include "utils/regproc.h" +#include "utils/syscache.h" PG_MODULE_MAGIC; @@ -376,7 +378,21 @@ unaccent_dict(PG_FUNCTION_ARGS) if (PG_NARGS() == 1) { - dictOid = get_ts_dict_oid(stringToQualifiedNameList("unaccent"), false); + /* + * Use the "unaccent" dictionary that is in the same schema that this + * function is in. + */ + Oid procnspid = get_func_namespace(fcinfo->flinfo->fn_oid); + const char *dictname = "unaccent"; + + dictOid = GetSysCacheOid2(TSDICTNAMENSP, + PointerGetDatum(dictname), + ObjectIdGetDatum(procnspid)); + if (!OidIsValid(dictOid)) + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("text search dictionary \"%s.%s\" does not exist", + get_namespace_name(procnspid), dictname))); strArg = 0; } else diff --git a/doc/src/sgml/unaccent.sgml b/doc/src/sgml/unaccent.sgml index a7f5f53041..547ac54a71 100644 --- a/doc/src/sgml/unaccent.sgml +++ b/doc/src/sgml/unaccent.sgml @@ -174,12 +174,14 @@ mydb=# select ts_headline('fr','Hôtel de la Mer',to_tsquery('fr','Hotels') -unaccent(dictionary, string) returns text +unaccent(dictionary regdictionary, string text) returns text If the dictionary argument is - omitted, unaccent is assumed. + omitted, the text search dictionary named unaccent and + appearing in the same schema as the unaccent() + function itself is used.