Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fxgQC-0006Ok-8b for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Sep 2018 22:37:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fxgQA-00013C-PD for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Sep 2018 22:37:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fxgQA-000135-IQ for pgsql-hackers@lists.postgresql.org; Wed, 05 Sep 2018 22:37:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fxgQ7-00018T-Nw for pgsql-hackers@lists.postgresql.org; Wed, 05 Sep 2018 22:37:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w85Mb0Id022724; Wed, 5 Sep 2018 18:37:01 -0400 From: Tom Lane To: Gunnlaugur Thor Briem cc: Adrian Klaver , Bruce Momjian , 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: <12109.1536174213@sss.pgh.pa.us> References: <20180829190635.GD25450@momjian.us> <6c73c320-95b7-c259-e309-c46300557852@aklaver.com> <6e023cde-943a-5cea-8626-f1e9b29695df@aklaver.com> <12109.1536174213@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Wed, 05 Sep 2018 15:03:33 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <22678.1536186959.0@sss.pgh.pa.us> Date: Wed, 05 Sep 2018 18:37:00 -0400 Message-ID: <22723.1536187020@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <22678.1536186959.1@sss.pgh.pa.us> [ redirecting to pgsql-hackers ] I wrote: > Gunnlaugur Thor Briem 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 ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="avoid-depending-on-search-path-in-unaccent-2.patch"; charset="us-ascii" Content-ID: <22678.1536186959.2@sss.pgh.pa.us> Content-Description: avoid-depending-on-search-path-in-unaccent-2.patch Content-Transfer-Encoding: quoted-printable diff --git a/contrib/unaccent/unaccent.c b/contrib/unaccent/unaccent.c index 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() =3D=3D 1) { ! dictOid =3D get_ts_dict_oid(stringToQualifiedNameList("unaccent"), fal= se); strArg =3D 0; } else --- 378,398 ---- = if (PG_NARGS() =3D=3D 1) { ! /* ! * Use the "unaccent" dictionary that is in the same schema that this ! * function is in. ! */ ! Oid procnspid =3D get_func_namespace(fcinfo->flinfo->fn_oid); ! const char *dictname =3D "unaccent"; ! = ! dictOid =3D 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 =3D 0; } else ------- =_aaaaaaaaaa0--