CREATE TABLESPACE dynamically

From: William Garrison <postgres(at)mobydisk(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: CREATE TABLESPACE dynamically
Date: 2007-03-14 21:16:34
Message-ID: 45F86632.6000607@mobydisk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am writing scripts to create a database that I want to run in my
development, testing, and production environments. That means I need to
be able to do something like

IF <condition>
CREATE TABLESPACE foo LOCATION E'C:\database';
ELSE
CREATE TABLESPACE foo LOCATION E'Z:\database';

I can't seem to find a way to do this, for two reasons:
1) I can't do IF statements unless I create a PL/PGSQL function. And a
PL/PGSQL function cannot issue a CREATE TABLESPACE command.
2) The CREATE TABLESPACE command does not allow expressions.
CREATE TABLESPACE foo LOCATION 'FOO' | 'BAR'
is not valid. I'm not sure I understand why since that is an expression
that yields a string. Parenthesis don't help either.

Is there any way I can do this?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tony Caduto 2007-03-14 21:33:47 Re: How to write a function that manipulates a set of results
Previous Message Ted Byers 2007-03-14 21:03:31 Re: [Bulk] Re: quoted identifier behaviour