CREATE TABLESPACE dynamically - Mailing list pgsql-general

From William Garrison
Subject CREATE TABLESPACE dynamically
Date
Msg-id 45F86632.6000607@mobydisk.com
Whole thread Raw
Responses Re: CREATE TABLESPACE dynamically  (Richard Huxton <dev@archonet.com>)
List 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?


pgsql-general by date:

Previous
From: Tony Caduto
Date:
Subject: Re: How to write a function that manipulates a set of results
Next
From: "Dave Page"
Date:
Subject: Re: Debugging Server Code