From: Tom Lane <tgl@sss.pgh.pa.us>
To: Gunnlaugur Thor Briem <gunnlaugur@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Bruce Momjian <bruce@momjian.us>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: unaccent(text) fails depending on search_path (WAS: pg_upgrade fails saying function unaccent(text) doesn't exist)
Date: Wed, 05 Sep 2018 18:37:00 -0400
Message-ID: <22723.1536187020@sss.pgh.pa.us> (raw)
In-Reply-To: <12109.1536174213@sss.pgh.pa.us>
References: <CAPs+M8LCex6d=DeneofdsoJVijaG59m9V0ggbb3pOH7hZO4+cQ@mail.gmail.com>
<20180829190635.GD25450@momjian.us>
<CAPs+M8KRP3McWzVwU1hs9QZXsUHXbb7RSgtshqcy4NwDgW0VHg@mail.gmail.com>
<6c73c320-95b7-c259-e309-c46300557852@aklaver.com>
<CAPs+M8KpVH0mm5N1T7Qf5TiwkSF8se3Aadu3RwDbJZwAexC5zw@mail.gmail.com>
<6e023cde-943a-5cea-8626-f1e9b29695df@aklaver.com>
<CAPs+M8LYh1fmuU8=yG21nyAuZOOY22EGZsMCwWPH8TLhOqK9tg@mail.gmail.com>
<12109.1536174213@sss.pgh.pa.us>
[ redirecting to pgsql-hackers ]
I wrote:
> Gunnlaugur Thor Briem <gunnlaugur@gmail.com> writes:
>> SET search_path = "$user"; SELECT public.unaccent('foo');
>> SET
>> ERROR: text search dictionary "unaccent" does not exist
> Meh. I think we need the attached, or something just about like it.
>
> It's barely possible that there's somebody out there who's relying on
> setting the search path to allow choosing among multiple "unaccent"
> dictionaries. But there are way more people whose functions are
> broken due to the recent search-path-tightening changes.
Here's a slightly more efficient version.
regards, tom lane
Attachments:avoid-depending-on-search-path-in-unaccent-2.patch (text/x-diff, 1.2K) downloaddiff --git a/contrib/unaccent/unaccent.c b/contrib/unaccent/unaccent.cindex 247c202..dbf2bb9 100644
*** a/contrib/unaccent/unaccent.c
--- b/contrib/unaccent/unaccent.c
***************
*** 20,26 ****
--- 20,28 ----
#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;
*************** unaccent_dict(PG_FUNCTION_ARGS)
*** 376,382 ****
if (PG_NARGS() == 1)
{
! dictOid = get_ts_dict_oid(stringToQualifiedNameList("unaccent"), false);
strArg = 0;
}
else
--- 378,398 ----
if (PG_NARGS() == 1)
{
! /*
! * 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, gunnlaugur@gmail.com, adrian.klaver@aklaver.com, bruce@momjian.us, pgsql-hackers@lists.postgresql.org
Subject: Re: unaccent(text) fails depending on search_path (WAS: pg_upgrade fails saying function unaccent(text) doesn't exist)
In-Reply-To: <22723.1536187020@sss.pgh.pa.us>
References: <CAPs+M8LCex6d=DeneofdsoJVijaG59m9V0ggbb3pOH7hZO4+cQ@mail.gmail.com> <20180829190635.GD25450@momjian.us> <CAPs+M8KRP3McWzVwU1hs9QZXsUHXbb7RSgtshqcy4NwDgW0VHg@mail.gmail.com> <6c73c320-95b7-c259-e309-c46300557852@aklaver.com> <CAPs+M8KpVH0mm5N1T7Qf5TiwkSF8se3Aadu3RwDbJZwAexC5zw@mail.gmail.com> <6e023cde-943a-5cea-8626-f1e9b29695df@aklaver.com> <CAPs+M8LYh1fmuU8=yG21nyAuZOOY22EGZsMCwWPH8TLhOqK9tg@mail.gmail.com> <12109.1536174213@sss.pgh.pa.us> <22723.1536187020@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox