Skip to content

Instantly share code, notes, and snippets.

@felixbuenemann
Created February 12, 2015 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixbuenemann/056f157a200e334dc5b0 to your computer and use it in GitHub Desktop.
Save felixbuenemann/056f157a200e334dc5b0 to your computer and use it in GitHub Desktop.
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public, pg_catalog;
--
-- Name: foo_label(integer); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION foo_label(value integer) RETURNS text
LANGUAGE sql STABLE
AS $$ SELECT label FROM foo WHERE id = value; $$;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: baz; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE baz (
id integer
);
--
-- Name: bar; Type: MATERIALIZED VIEW; Schema: public; Owner: -; Tablespace:
--
CREATE MATERIALIZED VIEW bar AS
SELECT foo_label(baz.id) AS foo_label
FROM baz
WITH NO DATA;
--
-- Name: foo; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE foo (
id integer,
label text
);
--
-- PostgreSQL database dump complete
--
@felixbuenemann
Copy link
Author

Dump created on PostgreSQL 9.4.1 with pg_dump -x -s -O -f foo.sql foo and loaded with psql bar -f foo.sql gives error:

SET
SET
SET
SET
SET
SET
SET
CREATE FUNCTION
SET
SET
CREATE TABLE
psql:foo.sql:43: ERROR:  relation "foo" does not exist
LINE 1:  SELECT label FROM foo WHERE id = value;
                           ^
QUERY:   SELECT label FROM foo WHERE id = value;
CONTEXT:  SQL function "foo_label" during inlining
CREATE TABLE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment