Re: ignore tablespace in schema definition queries

From: Allan Kamau <kamauallan(at)gmail(dot)com>
To: Joao Miguel Ferreira <joao(dot)miguel(dot)c(dot)ferreira(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: ignore tablespace in schema definition queries
Date: 2021-04-03 13:13:00
Message-ID: CAF3N6oRgAyS8wR92BGBrH0t+zknmVLHLZDg+A2w2sB6c6GGaJg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Apr 3, 2021 at 1:59 PM Joao Miguel Ferreira <
joao(dot)miguel(dot)c(dot)ferreira(at)gmail(dot)com> wrote:

> Hello all,
>
> I have a big set of migration queries (that I do not control) that I must
> run on my automatic test database, in order to set ip up and run tests.
> These queries create all sorts of things like indexes, tables, and so. But
> they also include the specification of the tablespace they expect to use
> (tablespace_000, tablespace_001, up to tablespace_999). This would require
> me to setup hundreds of tablespaces before I can start the migration
> process, and run the tests.
>
> Is there a way to tell the postgres server to ignore that part and just
> use some default tablespace? My present situation is that I can not bring
> the test database to a usable point because many migration queries fail due
> to the tablespace they need has not been created. My problem is that I
> would like to avoid creating them.
>
> Thanks
> João
>
>
Hi João,

Below are some thoughts, not a solution.

Since the migration queries seem to be part of a procedural process of your
activities, it may seem advisable to run them as they are so as to avoid
probable complications later on.
There may be some good reason the migration queries are constructing
tablespaces and also provides the opportunity to specify the directory file
where the data would be stored.

The construction of the 1000 tablespaces (tablespace_000 till
tablespace_999) could be done using a procedural language such as plpgsql
and generate_series or "common" programming languages such as python via
psycopg2.
Here you could construct the tablespaces before you run the migration
queries.

Allan.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Luca Ferrari 2021-04-03 13:22:38 Re: questions about wraparound
Previous Message Joao Miguel Ferreira 2021-04-03 10:59:18 ignore tablespace in schema definition queries