pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
dropping a schema and cross-schema dependencies
3+ messages / 2 participants
[nested] [flat]

* dropping a schema and cross-schema dependencies
@ 2007-04-06 22:09 George Pavlov <gpavlov@mynewplace.com>
  2007-04-06 23:39 ` Re: dropping a schema and cross-schema dependencies Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: George Pavlov @ 2007-04-06 22:09 UTC (permalink / raw)
  To: pgsql-sql

I would like to be able to drop a schema with all of its objects, but
don't want to accidentally drop objects that are in other schemas. If
there are such objects I'd prefer the drop to fail. If I use DROP SCHEMA
FOO CASCADE I run the risk of dropping objects from other schemas that
depend on objects in FOO (e.g. a table that uses a domain/user defined
datatype from FOO). I don't particularly like such cross-schema
dependencies but they are easy to create acidentally and I don't want to
blow out a big table. 

Any thoughts on this? "Talk to the people who wrote the SQL standard" is
one response, of course, but what do you all think is a reasonable
behavior here? Anyone else see this as an issue? Does this warrant an PG
extension to SQL? How do other DBMSs do it?

As an immediate solution can anyone share a comprehensive query to
INFORMATION_SCHEMA/PG_CATALOG that can be used to check for any
cross-schema dependencies and halt before issuing a DROP with a CASCADE?

TIA,

George



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: dropping a schema and cross-schema dependencies
  2007-04-06 22:09 dropping a schema and cross-schema dependencies George Pavlov <gpavlov@mynewplace.com>
@ 2007-04-06 23:39 ` Tom Lane <tgl@sss.pgh.pa.us>
  2007-04-07 00:05   ` Re: dropping a schema and cross-schema dependencies George Pavlov <gpavlov@mynewplace.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2007-04-06 23:39 UTC (permalink / raw)
  To: George Pavlov <gpavlov@mynewplace.com>; +Cc: pgsql-sql

"George Pavlov" <gpavlov@mynewplace.com> writes:
> As an immediate solution can anyone share a comprehensive query to
> INFORMATION_SCHEMA/PG_CATALOG that can be used to check for any
> cross-schema dependencies and halt before issuing a DROP with a CASCADE?

Issue the DROP without CASCADE and read the error message.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: dropping a schema and cross-schema dependencies
  2007-04-06 22:09 dropping a schema and cross-schema dependencies George Pavlov <gpavlov@mynewplace.com>
  2007-04-06 23:39 ` Re: dropping a schema and cross-schema dependencies Tom Lane <tgl@sss.pgh.pa.us>
@ 2007-04-07 00:05   ` George Pavlov <gpavlov@mynewplace.com>
  0 siblings, 0 replies; 3+ messages in thread

From: George Pavlov @ 2007-04-07 00:05 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql

> > As an immediate solution can anyone share a comprehensive query to
> > INFORMATION_SCHEMA/PG_CATALOG that can be used to check for any
> > cross-schema dependencies and halt before issuing a DROP 
> with a CASCADE?
> 
> Issue the DROP without CASCADE and read the error message.

Well, to be precise I should read the notices preceding the error
message (the error message is the same whether there are within- or
cross-schema dependencies). But, yes, that's what I have been doing, I
was hoping for something a little more graceful. Ideally I want a DROP
SCHEMA in a script to succeed without bothering me if there are no
cross-schema dependencies and only to fail if there are cross-schema
dependencies. So I was hoping I could check ahead of time and in a
definitive way that there are no cross schema dependencies and then
issue a DROP CASCADE. What you are suggesting is to issue a DROP without
CASCADE and grep through the error message before issuing a second DROP
CASCADE, but what am I grepping for? What are all the possible notices
that pertain to cross-schema dependencies? I want to make sure I am not
missing something that I have not seen before. So, for example we might
have a notice like this:

  NOTICE:  table test.employee column first_name depends on type name_ud

So, if the word "table" is followed by a word that contains a period I
have a cross-schema dependency. This could work. I just want to be
comprehensive.

George



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2007-04-07 00:05 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-04-06 22:09 dropping a schema and cross-schema dependencies George Pavlov <gpavlov@mynewplace.com>
2007-04-06 23:39 ` Tom Lane <tgl@sss.pgh.pa.us>
2007-04-07 00:05   ` George Pavlov <gpavlov@mynewplace.com>

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