diff options
-rw-r--r-- | contrib/unaccent/unaccent.c | 18 | ||||
-rw-r--r-- | doc/src/sgml/unaccent.sgml | 9 |
2 files changed, 25 insertions, 2 deletions
diff --git a/contrib/unaccent/unaccent.c b/contrib/unaccent/unaccent.c index f2dc76bf169..3017d833b37 100644 --- a/contrib/unaccent/unaccent.c +++ b/contrib/unaccent/unaccent.c @@ -20,6 +20,8 @@ #include "tsearch/ts_locale.h" #include "tsearch/ts_public.h" #include "utils/builtins.h" +#include "utils/lsyscache.h" +#include "utils/syscache.h" PG_MODULE_MAGIC; @@ -325,7 +327,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 af9cad5d8c7..867b4c439dc 100644 --- a/doc/src/sgml/unaccent.sgml +++ b/doc/src/sgml/unaccent.sgml @@ -142,10 +142,17 @@ mydb=# select ts_headline('fr','Hôtel de la Mer',to_tsquery('fr','Hotels') </indexterm> <synopsis> -unaccent(<optional><replaceable class="PARAMETER">dictionary</replaceable>, </optional> <replaceable class="PARAMETER">string</replaceable>) returns <type>text</type> +unaccent(<optional><replaceable class="parameter">dictionary</replaceable> <type>regdictionary</type>, </optional> <replaceable class="parameter">string</replaceable> <type>text</type>) returns <type>text</type> </synopsis> <para> + If the <replaceable class="parameter">dictionary</replaceable> argument is + omitted, the text search dictionary named <literal>unaccent</literal> and + appearing in the same schema as the <function>unaccent()</function> + function itself is used. + </para> + + <para> For example: <programlisting> SELECT unaccent('unaccent', 'Hôtel'); |