How can I detect if a schema exists?

Started by Felix Morley Finchabout 13 years ago4 messagesgeneral
Jump to latest
#1Felix Morley Finch
felix@crowfix.com

I was reviving an old test program which hasn't been used since 9.1 and found that "SET search_path = xyzzy" no longer fails if the schema "xyzzy" doesn't exist.

Is there an approved or recommended way to tell if a schema exists? I can think of lots of ways, but none as easy as the 9.1 search_path. I suppose I shouldn't rely on undocumented features ...

--
... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
Felix Finch: scarecrow repairman & rocket surgeon / felix@crowfix.com
GPG = E987 4493 C860 246C 3B1E 6477 7838 76E9 182E 8151 ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o

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

#2Ian Lawrence Barwick
barwick@gmail.com
In reply to: Felix Morley Finch (#1)
Re: How can I detect if a schema exists?

2013/1/10 <felix@crowfix.com>

I was reviving an old test program which hasn't been used since 9.1 and
found that "SET search_path = xyzzy" no longer fails if the schema "xyzzy"
doesn't exist.

Is there an approved or recommended way to tell if a schema exists? I can
think of lots of ways, but none as easy as the 9.1 search_path. I suppose
I shouldn't rely on undocumented features ...

How about:

SELECT TRUE FROM information_schema.schemata WHERE schema_name = 'xyzzy'

? (Though I notice this table only seems to show the schemas owned by the
user if the user is not a superuser).

Ian Lawrence Barwick

#3Felix Morley Finch
felix@crowfix.com
In reply to: Ian Lawrence Barwick (#2)
Re: How can I detect if a schema exists?

On Thu, Jan 10, 2013 at 09:11:59AM +0900, Ian Lawrence Barwick wrote:

How about:

SELECT TRUE FROM information_schema.schemata WHERE schema_name = 'xyzzy'

? (Though I notice this table only seems to show the schemas owned by the
user if the user is not a superuser).

I'll have to play with the users and permissions, but that sounds like
it could be a feature; the code wants to know if the user can use the
schema.

--
... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
Felix Finch: scarecrow repairman & rocket surgeon / felix@crowfix.com
GPG = E987 4493 C860 246C 3B1E 6477 7838 76E9 182E 8151 ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o

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

#4Alexander Gataric
gataric@usa.net
In reply to: Felix Morley Finch (#3)
Custom JDBC wrapper for DB2 Fed Server

I was wondering if there is a Postgres JDBC Type 4 wrapper for DB2 Federated
Server. The default wrapper from IBM has a number of issues with Postgres
which a better wrapper could solve. I will attempt to modify the IBM wrapper
if I can get my hands on the source code.

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