pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #12465: Materialized view dump restoration issue
6+ messages / 4 participants
[nested] [flat]
* BUG #12465: Materialized view dump restoration issue
@ 2015-01-08 21:24 jeff.casavant@gmail.com
2015-01-09 20:42 ` Re: BUG #12465: Materialized view dump restoration issue Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: jeff.casavant@gmail.com @ 2015-01-08 21:24 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 12465
Logged by: Jeff Casavant
Email address: jeff.casavant@gmail.com
PostgreSQL version: 9.4.0
Operating system: Ubuntu 14.04.1
Description:
If
- two functions A and B exist in the public schema
- A calls B, and
- a materialized view calls A
then the dump produced by pg_dump or pg_dumpall will throw the following
error when passed to psql -f:
psql:dump.sql:7730: ERROR: function b() does not exist
LINE 1: SELECT B()
^
HINT: No function matches the given name and argument types. You might need
to add explicit type casts.
QUERY: SELECT B()
CONTEXT: SQL function "b" during inlining
Code to reproduce:
create function b() returns int as $$ select 1 $$ language sql;
create function a() returns int as $$ select b() $$ language sql;
create schema qwr;
create materialized view qwr.c as select a();
Then run pg_dump | psql .
Workaround:
Add public to all calls to 'SET search_path' in the dump.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #12465: Materialized view dump restoration issue
2015-01-08 21:24 BUG #12465: Materialized view dump restoration issue jeff.casavant@gmail.com
@ 2015-01-09 20:42 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-01-09 20:48 ` Re: BUG #12465: Materialized view dump restoration issue Jefferson Casavant <jeff.casavant@gmail.com>
2015-01-09 21:17 ` Re: BUG #12465: Materialized view dump restoration issue Marko Tiikkaja <marko@joh.to>
0 siblings, 2 replies; 6+ messages in thread
From: Tom Lane @ 2015-01-09 20:42 UTC (permalink / raw)
To: jeff.casavant@gmail.com; +Cc: pgsql-bugs
jeff.casavant@gmail.com writes:
> Code to reproduce:
> create function b() returns int as $$ select 1 $$ language sql;
> create function a() returns int as $$ select b() $$ language sql;
> create schema qwr;
> create materialized view qwr.c as select a();
This is not a pg_dump bug, this is a broken definition of function a().
That function will fail in any context where the caller changes
search_path, not only pg_dump. You can perhaps get away without that
in a single-schema database, but not with multiple schemas.
You could fix it by schema-qualifying b in the text of a,
or by adding a "SET schema_path" clause to a.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #12465: Materialized view dump restoration issue
2015-01-08 21:24 BUG #12465: Materialized view dump restoration issue jeff.casavant@gmail.com
2015-01-09 20:42 ` Re: BUG #12465: Materialized view dump restoration issue Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-01-09 20:48 ` Jefferson Casavant <jeff.casavant@gmail.com>
1 sibling, 0 replies; 6+ messages in thread
From: Jefferson Casavant @ 2015-01-09 20:48 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
I see what you mean. I ran across this issue with
ST_AsLatLonText(geometry) in PostGIS (which calls ST_AsLatLonText(geometry,
text)). I'll pass this bug on to them.
Jeff
On Fri, Jan 9, 2015 at 3:42 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> jeff.casavant@gmail.com writes:
> > Code to reproduce:
>
> > create function b() returns int as $$ select 1 $$ language sql;
> > create function a() returns int as $$ select b() $$ language sql;
> > create schema qwr;
> > create materialized view qwr.c as select a();
>
> This is not a pg_dump bug, this is a broken definition of function a().
> That function will fail in any context where the caller changes
> search_path, not only pg_dump. You can perhaps get away without that
> in a single-schema database, but not with multiple schemas.
>
> You could fix it by schema-qualifying b in the text of a,
> or by adding a "SET schema_path" clause to a.
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #12465: Materialized view dump restoration issue
2015-01-08 21:24 BUG #12465: Materialized view dump restoration issue jeff.casavant@gmail.com
2015-01-09 20:42 ` Re: BUG #12465: Materialized view dump restoration issue Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-01-09 21:17 ` Marko Tiikkaja <marko@joh.to>
2015-01-09 21:38 ` Re: BUG #12465: Materialized view dump restoration issue Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 6+ messages in thread
From: Marko Tiikkaja @ 2015-01-09 21:17 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; jeff.casavant@gmail.com; +Cc: pgsql-bugs
On 2015-01-09 21:42, Tom Lane wrote:
> jeff.casavant@gmail.com writes:
>> Code to reproduce:
>
>> create function b() returns int as $$ select 1 $$ language sql;
>> create function a() returns int as $$ select b() $$ language sql;
>> create schema qwr;
>> create materialized view qwr.c as select a();
>
> This is not a pg_dump bug, this is a broken definition of function a().
> That function will fail in any context where the caller changes
> search_path, not only pg_dump. You can perhaps get away without that
> in a single-schema database, but not with multiple schemas.
AFAIK there isn't a way to write inlineable SQL functions in relocatable
extensions in that way, since you don't know which schema they end up
installed in. The original test case comes from PostGIS.
But I think the bigger problem is that naively thinking it shouldn't be
this easy to create unrestorable databases. But perhaps I'm being
overly naive.
.marko
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #12465: Materialized view dump restoration issue
2015-01-08 21:24 BUG #12465: Materialized view dump restoration issue jeff.casavant@gmail.com
2015-01-09 20:42 ` Re: BUG #12465: Materialized view dump restoration issue Tom Lane <tgl@sss.pgh.pa.us>
2015-01-09 21:17 ` Re: BUG #12465: Materialized view dump restoration issue Marko Tiikkaja <marko@joh.to>
@ 2015-01-09 21:38 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-01-09 21:50 ` Re: BUG #12465: Materialized view dump restoration issue Marko Tiikkaja <marko@joh.to>
0 siblings, 1 reply; 6+ messages in thread
From: Tom Lane @ 2015-01-09 21:38 UTC (permalink / raw)
To: Marko Tiikkaja <marko@joh.to>; +Cc: jeff.casavant@gmail.com; pgsql-bugs
Marko Tiikkaja <marko@joh.to> writes:
> On 2015-01-09 21:42, Tom Lane wrote:
>> This is not a pg_dump bug, this is a broken definition of function a().
>> That function will fail in any context where the caller changes
>> search_path, not only pg_dump. You can perhaps get away without that
>> in a single-schema database, but not with multiple schemas.
> AFAIK there isn't a way to write inlineable SQL functions in relocatable
> extensions in that way, since you don't know which schema they end up
> installed in. The original test case comes from PostGIS.
You can do it for relocatable-at-install-time extensions, as suggested in
the manual:
CREATE FUNCTION ... SET search_path = @extschema@ ...
> But I think the bigger problem is that naively thinking it shouldn't be
> this easy to create unrestorable databases. But perhaps I'm being
> overly naive.
Well, if you know how to inform pg_dump what random assumptions about
search_path exist in the functions invoked by a matview (or expression
index, or some other cases), let me know.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #12465: Materialized view dump restoration issue
2015-01-08 21:24 BUG #12465: Materialized view dump restoration issue jeff.casavant@gmail.com
2015-01-09 20:42 ` Re: BUG #12465: Materialized view dump restoration issue Tom Lane <tgl@sss.pgh.pa.us>
2015-01-09 21:17 ` Re: BUG #12465: Materialized view dump restoration issue Marko Tiikkaja <marko@joh.to>
2015-01-09 21:38 ` Re: BUG #12465: Materialized view dump restoration issue Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-01-09 21:50 ` Marko Tiikkaja <marko@joh.to>
0 siblings, 0 replies; 6+ messages in thread
From: Marko Tiikkaja @ 2015-01-09 21:50 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: jeff.casavant@gmail.com; pgsql-bugs
On 2015-01-09 22:38, Tom Lane wrote:
> Marko Tiikkaja <marko@joh.to> writes:
>> On 2015-01-09 21:42, Tom Lane wrote:
>>> This is not a pg_dump bug, this is a broken definition of function a().
>>> That function will fail in any context where the caller changes
>>> search_path, not only pg_dump. You can perhaps get away without that
>>> in a single-schema database, but not with multiple schemas.
>
>> AFAIK there isn't a way to write inlineable SQL functions in relocatable
>> extensions in that way, since you don't know which schema they end up
>> installed in. The original test case comes from PostGIS.
>
> You can do it for relocatable-at-install-time extensions, as suggested in
> the manual:
>
> CREATE FUNCTION ... SET search_path = @extschema@ ...
Yup, and now it's not inlineable anymore.
>> But I think the bigger problem is that naively thinking it shouldn't be
>> this easy to create unrestorable databases. But perhaps I'm being
>> overly naive.
>
> Well, if you know how to inform pg_dump what random assumptions about
> search_path exist in the functions invoked by a matview (or expression
> index, or some other cases), let me know.
Hmm.. So I guess this is pretty much impossible as long as we insist on
the materialized views being initialized at restore time. (Though I
notice that even WITH NO DATA does not work.)
.marko
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2015-01-09 21:50 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-01-08 21:24 BUG #12465: Materialized view dump restoration issue jeff.casavant@gmail.com
2015-01-09 20:42 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-01-09 20:48 ` Jefferson Casavant <jeff.casavant@gmail.com>
2015-01-09 21:17 ` Marko Tiikkaja <marko@joh.to>
2015-01-09 21:38 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-01-09 21:50 ` Marko Tiikkaja <marko@joh.to>
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