Thread: non intuitive behaviour of DROP TABLE IF EXISTS
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi. I think the following behaviour is not intuitive: manlio=> DROP TABLE IF EXISTS foo.bar; ERROR: schema "foo" does not exist The statement should not fail if the schema does not exist Thanks Manlio -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkuP4UEACgkQscQJ24LbaURLWQCfVoKqOdnIzX0asSTbDnMJXV8M WzoAniLEibeav+KLm6LbhWhxIiJWSGMG =X1nb -----END PGP SIGNATURE-----
Manlio Perillo wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi. > > I think the following behaviour is not intuitive: > > manlio=> DROP TABLE IF EXISTS foo.bar; > ERROR: schema "foo" does not exist > > The statement should not fail if the schema does not exist Hmm. Well, it says TABLE IF EXISTS, not TABLE AND SCHEMA IF EXISTS. ;-) Not sure if it makes sense to change it. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com PG East: http://www.enterprisedb.com/community/nav-pg-east-2010.do
On Sunday 07 March 2010 02.49:29 Bruce Momjian wrote: > Manlio Perillo wrote: > > I think the following behaviour is not intuitive: > > > > manlio=> DROP TABLE IF EXISTS foo.bar; > > ERROR: schema "foo" does not exist > > > > The statement should not fail if the schema does not exist > > Hmm. Well, it says TABLE IF EXISTS, not TABLE AND SCHEMA IF EXISTS. > ;-) > > Not sure if it makes sense to change it. I tend to agree with Manlio from an end user perspective. It's a case of "do not feed the elephant". Seeing this sign, what do you do if there is no elephant around? "Do not feed the elephant in the cage" doesn't change the situation if there is neither elephant nor cage... :-) (Obviously from a developer perspective, I appreciate you might need extra code to not fail on resolving non-existing schemas. And I guess this is not a very high priority issue...) cheers -- vbi (Trivia quiz: name the book) -- this email is protected by a digital signature: http://fortytwo.ch/gpg