Re: Dump/restore indexes and functions in public schema - Mailing list pgsql-general

From Tom Lane
Subject Re: Dump/restore indexes and functions in public schema
Date
Msg-id 11802.1349794273@sss.pgh.pa.us
Whole thread Raw
In response to Re: Dump/restore indexes and functions in public schema  (marian krucina <marian.krucina@gmail.com>)
List pgsql-general
marian krucina <marian.krucina@gmail.com> writes:
> Example:
> in PG91:
> CREATE FUNCTION function_y(x INT) RETURNS INT AS $$ SELECT $1*$1 $$
> LANGUAGE SQL;
> CREATE FUNCTION function_x(x INT) RETURNS INT AS $$ SELECT
> function_y($1) $$ LANGUAGE SQL;
> CREATE SCHEMA schema_a;
> CREATE TABLE schema_a.table_a(i INT);
> CREATE INDEX ON schema_a.table_a(function_x(i));
> INSERT INTO schema_a.table_a VALUES(1),(9),(2);

Mph.  Well, actually what you've got there is a function that will break
anytime somebody looks at it sideways, anyhow.  You need to
schema-qualify the reference to function_y, or if you don't want to do
that for some reason, you could attach a "SET search_path" clause to the
definition of function_x.

I don't regard this as a Postgres bug, because index functions are
required to be immutable, and function_x fails that test because its
results vary depending on search_path.

            regards, tom lane


pgsql-general by date:

Previous
From: Willy-Bas Loos
Date:
Subject: Re: something better than pgtrgm?
Next
From: Andrew Sullivan
Date:
Subject: Re: something better than pgtrgm?