agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Tim Landscheidt <tim@tim-landscheidt.de>
To: pgsql-sql@postgresql.org
Subject: Re: find all views depend on a schema/table
Date: Mon, 27 Jan 2014 04:42:06 +0000
Message-ID: <87k3dmrq75.fsf@passepartout.tim-landscheidt.de> (raw)
References: <52E28D0D.3080908@encs.concordia.ca>
	<13660.1390580600@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

Tom Lane <tgl@sss.pgh.pa.us> wrote:

>> Is there a simple way to query all views depend on a schema or table?

> Well, you could build something that examines pg_depend, or you could
> try this:

> begin;
> drop table some_table restrict;
> ... note what it complains about ...
> rollback;

Note that neither show dependencies that are "hidden" in
functions, i. e.:

| tim=# CREATE TABLE T (ID INT PRIMARY KEY);
| NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "t_pkey" for table "t"
| CREATE TABLE
| tim=# CREATE FUNCTION F() RETURNS INT AS 'SELECT MIN(ID) FROM T;' LANGUAGE SQL;
| CREATE FUNCTION
| tim=# CREATE VIEW V AS SELECT F();
| CREATE VIEW
| tim=# DROP TABLE T;
| DROP TABLE
| tim=# SELECT * FROM V;
| ERROR:  relation "t" does not exist
| LINE 1: SELECT MIN(ID) FROM T;
|                             ^
| QUERY:  SELECT MIN(ID) FROM T;
| CONTEXT:  SQL function "f" during inlining
| tim=#

Tim



-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (4+ messages)

Message-ID: <87k3dmrq75.fsf@passepartout.tim-landscheidt.de>
Permalink:  ../87k3dmrq75.fsf@passepartout.tim-landscheidt.de/
Also on:    postgresql.org/message-id/87k3dmrq75.fsf@passepartout.tim-landscheidt.de

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tim@tim-landscheidt.de
  Subject: Re: find all views depend on a schema/table
  In-Reply-To: <87k3dmrq75.fsf@passepartout.tim-landscheidt.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox