Re: clone_schema function

Поиск
Список
Период
Сортировка
От Igor Neyman
Тема Re: clone_schema function
Дата
Msg-id A76B25F2823E954C9E45E32FA49D70ECCD5158B2@mail.corp.perceptron.com
обсуждение исходный текст
Ответ на Re: clone_schema function  (Melvin Davidson <melvin6925@gmail.com>)
Список pgsql-general

 

 

From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Melvin Davidson
Sent: Friday, September 11, 2015 4:24 PM
To: Daniel Verite <daniel@manitou-mail.org>
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] clone_schema function

 

"seriously flawed" is a bit of a stretch. Most sane developers would not have schema names of one letter.

They usually name a schema something practical, which totally avoids your nit picky exception.

However, if you are that concerned about the "serious flaw", you have the option of using the method

of dumping the schema, editing the dump and reloading. Or, I invite you to use your great skills and

write a better method.

 

On Fri, Sep 11, 2015 at 4:06 PM, Daniel Verite <daniel@manitou-mail.org> wrote:

        Melvin Davidson wrote:

> I've added error checking and verified that it now copies the
> current sequnce values, table data, views and functions.

The code dealing with functions is seriously flawed.

Consider that part:
     SELECT pg_get_functiondef(func_oid) INTO qry;
     SELECT replace(qry, source_schema, dest_schema) INTO dest_qry;
     EXECUTE dest_qry;

It suggests that to duplicate a function in schema A to B,
every letter A in the entire function definition should be replaced
by B, garbling everything along the way.
For example CREATE FUNCTION would become CREBTE FUNCTION,
DECLARE would become DECLBRE and so on.

Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite


____________________________________________________

 

It does not have to be one-letter schema name.

Consider the following:

 

Schema called “vector” has a table called “vector_config” referenced in some function.

Now, what happens if schema “vector” is copied into some destination schema using your script?

 

Melvin, you needn’t consider every critique of your script to be a personal attack on you.

 

Regards,

Igor Neyman

 

 

В списке pgsql-general по дате отправления:

Предыдущее
От: Charles Lynch
Дата:
Сообщение: BDR problem
Следующее
От: "Daniel Verite"
Дата:
Сообщение: Re: clone_schema function