Re: unaccent module - two params function should be immutable

Lists: pgsql-hackers
From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>
Subject: unaccent module - two params function should be immutable
Date: 2013-02-19 07:30:29
Message-ID: CAFj8pRDi0LRcmgyvd0ttC9J=VwOxe094fVRG2KTR_AQC86y-wg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

There was a proposal to change flag of function to immutable - should
be used in indexes

CREATE FUNCTION unaccent(regdictionary, text)
RETURNS text
AS 'MODULE_PATHNAME', 'unaccent_dict'
LANGUAGE C STABLE STRICT;

is there any progress?

Regards

Pavel Stehule


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-09-11 00:14:10
Message-ID: 20130911001410.GK16378@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Feb 19, 2013 at 08:30:29AM +0100, Pavel Stehule wrote:
> Hello
>
> There was a proposal to change flag of function to immutable - should
> be used in indexes
>
> CREATE FUNCTION unaccent(regdictionary, text)
> RETURNS text
> AS 'MODULE_PATHNAME', 'unaccent_dict'
> LANGUAGE C STABLE STRICT;
>
>
> is there any progress?

I have developed the attached patch based on your suggestion. I did not
see anything in the code that would make it STABLE, except a lookup of a
dictionary library:

dictOid = get_ts_dict_oid(stringToQualifiedNameList("unaccent"), false);

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
unaccent.diff text/x-diff 1.8 KB

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-09-14 13:42:32
Message-ID: CAFj8pRAXf0UteRd8xLY8PRHuCUKkYttUEKkJ7rbgGLR72ntFBw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2013/9/11 Bruce Momjian <bruce(at)momjian(dot)us>

> On Tue, Feb 19, 2013 at 08:30:29AM +0100, Pavel Stehule wrote:
> > Hello
> >
> > There was a proposal to change flag of function to immutable - should
> > be used in indexes
> >
> > CREATE FUNCTION unaccent(regdictionary, text)
> > RETURNS text
> > AS 'MODULE_PATHNAME', 'unaccent_dict'
> > LANGUAGE C STABLE STRICT;
> >
> >
> > is there any progress?
>
> I have developed the attached patch based on your suggestion. I did not
> see anything in the code that would make it STABLE, except a lookup of a
> dictionary library:
>
> dictOid = get_ts_dict_oid(stringToQualifiedNameList("unaccent"),
> false);
>

yes, it risk, but similar is with timezones, and other external data.

Regards

Pavel

>
> --
> Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
> EnterpriseDB http://enterprisedb.com
>
> + It's impossible for everything to be true. +
>


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-09-17 14:15:47
Message-ID: CA+TgmoasAyS3bQw4VHZ+H_dUHqbbN2NcvKdAKZTZFSmjGNTj3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Sep 14, 2013 at 9:42 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
>> I have developed the attached patch based on your suggestion. I did not
>> see anything in the code that would make it STABLE, except a lookup of a
>> dictionary library:
>>
>> dictOid = get_ts_dict_oid(stringToQualifiedNameList("unaccent"),
>> false);
>
> yes, it risk, but similar is with timezones, and other external data.

That's a catalog lookup - not a reliance on external data.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-09-24 21:36:58
Message-ID: 20130924213658.GB21534@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Sep 17, 2013 at 10:15:47AM -0400, Robert Haas wrote:
> On Sat, Sep 14, 2013 at 9:42 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> >> I have developed the attached patch based on your suggestion. I did not
> >> see anything in the code that would make it STABLE, except a lookup of a
> >> dictionary library:
> >>
> >> dictOid = get_ts_dict_oid(stringToQualifiedNameList("unaccent"),
> >> false);
> >
> > yes, it risk, but similar is with timezones, and other external data.
>
> That's a catalog lookup - not a reliance on external data.

Sorry, I was wrong. Only unaccent_dict() calls get_ts_dict_oid(), and
we aren't changing the signature of that function.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-10-08 16:20:55
Message-ID: 20131008162055.GL22450@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Sep 24, 2013 at 05:36:58PM -0400, Bruce Momjian wrote:
> On Tue, Sep 17, 2013 at 10:15:47AM -0400, Robert Haas wrote:
> > On Sat, Sep 14, 2013 at 9:42 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> > >> I have developed the attached patch based on your suggestion. I did not
> > >> see anything in the code that would make it STABLE, except a lookup of a
> > >> dictionary library:
> > >>
> > >> dictOid = get_ts_dict_oid(stringToQualifiedNameList("unaccent"),
> > >> false);
> > >
> > > yes, it risk, but similar is with timezones, and other external data.
> >
> > That's a catalog lookup - not a reliance on external data.
>
> Sorry, I was wrong. Only unaccent_dict() calls get_ts_dict_oid(), and
> we aren't changing the signature of that function.

Applied.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-10-08 16:31:03
Message-ID: CAFj8pRDqa8T2VD-HVgCcSS_KpfBdj+SjbE_o74c_rdDMJTtXrg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2013/10/8 Bruce Momjian <bruce(at)momjian(dot)us>

> On Tue, Sep 24, 2013 at 05:36:58PM -0400, Bruce Momjian wrote:
> > On Tue, Sep 17, 2013 at 10:15:47AM -0400, Robert Haas wrote:
> > > On Sat, Sep 14, 2013 at 9:42 AM, Pavel Stehule <
> pavel(dot)stehule(at)gmail(dot)com> wrote:
> > > >> I have developed the attached patch based on your suggestion. I
> did not
> > > >> see anything in the code that would make it STABLE, except a lookup
> of a
> > > >> dictionary library:
> > > >>
> > > >> dictOid =
> get_ts_dict_oid(stringToQualifiedNameList("unaccent"),
> > > >> false);
> > > >
> > > > yes, it risk, but similar is with timezones, and other external data.
> > >
> > > That's a catalog lookup - not a reliance on external data.
> >
> > Sorry, I was wrong. Only unaccent_dict() calls get_ts_dict_oid(), and
> > we aren't changing the signature of that function.
>
> Applied.
>

nice

thank you

Regards

Pavel Stehule

>
> --
> Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
> EnterpriseDB http://enterprisedb.com
>
> + It's impossible for everything to be true. +
>


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-10-08 16:35:35
Message-ID: 20131008163535.GN22450@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Oct 8, 2013 at 06:31:03PM +0200, Pavel Stehule wrote:
>
>
>
> 2013/10/8 Bruce Momjian <bruce(at)momjian(dot)us>
>
> On Tue, Sep 24, 2013 at 05:36:58PM -0400, Bruce Momjian wrote:
> > On Tue, Sep 17, 2013 at 10:15:47AM -0400, Robert Haas wrote:
> > > On Sat, Sep 14, 2013 at 9:42 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com
> > wrote:
> > > >> I have developed the attached patch based on your suggestion.  I did
> not
> > > >> see anything in the code that would make it STABLE, except a lookup
> of a
> > > >> dictionary library:
> > > >>
> > > >>         dictOid = get_ts_dict_oid(stringToQualifiedNameList
> ("unaccent"),
> > > >> false);
> > > >
> > > > yes, it risk, but similar is with timezones, and other external data.
> > >
> > > That's a catalog lookup - not a reliance on external data.
> >
> > Sorry, I was wrong.  Only unaccent_dict() calls get_ts_dict_oid(), and
> > we aren't changing the signature of that function.
>
> Applied.
>
>
> nice
>
> thank you

Do we need to update any version or anything? I didn't think so.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-10-08 16:38:30
Message-ID: CAFj8pRDz6cgkPYiHf8kvWvM1hG+KPtoJMg4=0ppu9mBnqGSNOg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2013/10/8 Bruce Momjian <bruce(at)momjian(dot)us>

> On Tue, Oct 8, 2013 at 06:31:03PM +0200, Pavel Stehule wrote:
> >
> >
> >
> > 2013/10/8 Bruce Momjian <bruce(at)momjian(dot)us>
> >
> > On Tue, Sep 24, 2013 at 05:36:58PM -0400, Bruce Momjian wrote:
> > > On Tue, Sep 17, 2013 at 10:15:47AM -0400, Robert Haas wrote:
> > > > On Sat, Sep 14, 2013 at 9:42 AM, Pavel Stehule <
> pavel(dot)stehule(at)gmail(dot)com
> > > wrote:
> > > > >> I have developed the attached patch based on your suggestion.
> I did
> > not
> > > > >> see anything in the code that would make it STABLE, except a
> lookup
> > of a
> > > > >> dictionary library:
> > > > >>
> > > > >> dictOid = get_ts_dict_oid(stringToQualifiedNameList
> > ("unaccent"),
> > > > >> false);
> > > > >
> > > > > yes, it risk, but similar is with timezones, and other
> external data.
> > > >
> > > > That's a catalog lookup - not a reliance on external data.
> > >
> > > Sorry, I was wrong. Only unaccent_dict() calls get_ts_dict_oid(),
> and
> > > we aren't changing the signature of that function.
> >
> > Applied.
> >
> >
> > nice
> >
> > thank you
>
> Do we need to update any version or anything? I didn't think so.
>

I am not sure - does pg_upgrade change of flag after upgrade without
increasing version number?

Regards

Pavel

>
> --
> Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
> EnterpriseDB http://enterprisedb.com
>
> + Everyone has their own god. +
>


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-10-08 16:46:48
Message-ID: 20131008164648.GO22450@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Oct 8, 2013 at 06:38:30PM +0200, Pavel Stehule wrote:
> I am not sure - does pg_upgrade change of flag after upgrade without increasing
> version number?

What happens in pg_upgrade is that the CREATE EXTENSION command is
pg_dump'ed, and run by pg_uprade, and it then pulls from the SQL file to
create the new function signature.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-10-08 16:52:47
Message-ID: CAFj8pRCbjeKXBSCGf08ztzTSbM63tq0c-yyyVt3umsntT3VK8Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2013/10/8 Bruce Momjian <bruce(at)momjian(dot)us>

> On Tue, Oct 8, 2013 at 06:38:30PM +0200, Pavel Stehule wrote:
> > I am not sure - does pg_upgrade change of flag after upgrade without
> increasing
> > version number?
>
> What happens in pg_upgrade is that the CREATE EXTENSION command is
> pg_dump'ed, and run by pg_uprade, and it then pulls from the SQL file to
> create the new function signature.
>

ok, then it is ok

>
> --
> Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
> EnterpriseDB http://enterprisedb.com
>
> + Everyone has their own god. +
>


From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-10-08 17:25:25
Message-ID: 20131008172525.GF27001@eldon.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian escribió:

> Do we need to update any version or anything? I didn't think so.

I think there should be an 1.1 version here. That way, if somebody is
using the existing definition from the 1.0 module, they can get the new
definition by doing an extension upgrade.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-10-08 17:30:13
Message-ID: 20131008173013.GP22450@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Oct 8, 2013 at 02:25:25PM -0300, Alvaro Herrera wrote:
> Bruce Momjian escribió:
>
> > Do we need to update any version or anything? I didn't think so.
>
> I think there should be an 1.1 version here. That way, if somebody is
> using the existing definition from the 1.0 module, they can get the new
> definition by doing an extension upgrade.

Uh, how would they get this new version? By compiling 9.4 and
installing it in 9.3?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +


From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-10-08 17:43:25
Message-ID: 20131008174325.GG27001@eldon.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian escribió:
> On Tue, Oct 8, 2013 at 02:25:25PM -0300, Alvaro Herrera wrote:
> > Bruce Momjian escribió:
> >
> > > Do we need to update any version or anything? I didn't think so.
> >
> > I think there should be an 1.1 version here. That way, if somebody is
> > using the existing definition from the 1.0 module, they can get the new
> > definition by doing an extension upgrade.
>
> Uh, how would they get this new version? By compiling 9.4 and
> installing it in 9.3?

Oh, is this only in 9.4? Then there's no point.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-11-08 23:00:53
Message-ID: 31281.1383951653@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> [ mark unaccent functions immutable ]

> Applied.

This patch is flat out wrong and needs to be reverted.

The functions were correctly marked (by you!) in commit
c0577c92a84cc477a88fe6868c16c4a7e3348b11 on the basis of the discussion of
bug #5781,
http://www.postgresql.org/message-id/201012021544.oB2FiTn1041521@wwwmaster.postgresql.org
which was a request exactly like this one and was denied for good and
sufficient reasons. There was absolutely no reasoning given in this
thread that explained why we should ignore the previous objections.

In particular, marking the single-argument version of unaccent() as
immutable is the height of folly because its behavior depends on the
setting of search_path. Changing the two-argument function is maybe
a bit more debatable, but that's not what you did.

If we were going to change the behavior, this patch would still be wrong
because it fails to provide an upgrade path. The objections saying you
needed a 1.1 migration script were completely correct.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: unaccent module - two params function should be immutable
Date: 2013-11-18 20:55:07
Message-ID: 20131118205507.GE28149@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Nov 8, 2013 at 06:00:53PM -0500, Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > [ mark unaccent functions immutable ]
>
> > Applied.
>
> This patch is flat out wrong and needs to be reverted.
>
> The functions were correctly marked (by you!) in commit
> c0577c92a84cc477a88fe6868c16c4a7e3348b11 on the basis of the discussion of
> bug #5781,
> http://www.postgresql.org/message-id/201012021544.oB2FiTn1041521@wwwmaster.postgresql.org
> which was a request exactly like this one and was denied for good and
> sufficient reasons. There was absolutely no reasoning given in this
> thread that explained why we should ignore the previous objections.
>
> In particular, marking the single-argument version of unaccent() as
> immutable is the height of folly because its behavior depends on the
> setting of search_path. Changing the two-argument function is maybe
> a bit more debatable, but that's not what you did.
>
> If we were going to change the behavior, this patch would still be wrong
> because it fails to provide an upgrade path. The objections saying you
> needed a 1.1 migration script were completely correct.

Thanks, patch reverted. If people still want this, it needs to be
resbumitted with this feedback in mind.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +