Overwrite pg_catalog?

Started by Julianoover 9 years ago8 messagesgeneral
Jump to latest
#1Juliano
jplinux@protonmail.com

Hi everyone,

I tried to restore pg_catalog to my new database, but the existing pg_catalog can't be overwritten or dropped, and postgres auto creates pg_catalog when I create a new DB.

So, there is a way to restore the pg_catalog to a new database?

Regards,
Juliano

#2Francisco Olarte
folarte@peoplecall.com
In reply to: Juliano (#1)
Re: Overwrite pg_catalog?

Juliano:

On Thu, Dec 1, 2016 at 12:16 PM, Juliano <jplinux@protonmail.com> wrote:

I tried to restore pg_catalog to my new database, but the existing
pg_catalog can't be overwritten or dropped, and postgres auto creates
pg_catalog when I create a new DB.

This is because, in general, pg_catalog is maintained by DML
statements, restoring it is not going to do what you think.

I.e., if you create a table, a row goes into pg_class, but if you
somehow manage to insert into pg_class a table is not properly created
( more things need to be done ).

Copying pg_catalog from one db to other is like trying to copy the
root dir and FAT from one floppy ( how old fashioned ) to other, it
cannot be done with normal tools and probably won't do what you think
it does.

So, there is a way to restore the pg_catalog to a new database?

Probably not, but this has the faint smell of http://xyproblem.info/ ,
what are you truing to achieve by doing that?

Francisco Olarte.

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

#3Melvin Davidson
melvin6925@gmail.com
In reply to: Francisco Olarte (#2)
Re: Overwrite pg_catalog?

On Thu, Dec 1, 2016 at 7:07 AM, Francisco Olarte <folarte@peoplecall.com>
wrote:

Juliano:

On Thu, Dec 1, 2016 at 12:16 PM, Juliano <jplinux@protonmail.com> wrote:

I tried to restore pg_catalog to my new database, but the existing
pg_catalog can't be overwritten or dropped, and postgres auto creates
pg_catalog when I create a new DB.

This is because, in general, pg_catalog is maintained by DML
statements, restoring it is not going to do what you think.

I.e., if you create a table, a row goes into pg_class, but if you
somehow manage to insert into pg_class a table is not properly created
( more things need to be done ).

Copying pg_catalog from one db to other is like trying to copy the
root dir and FAT from one floppy ( how old fashioned ) to other, it
cannot be done with normal tools and probably won't do what you think
it does.

So, there is a way to restore the pg_catalog to a new database?

Probably not, but this has the faint smell of http://xyproblem.info/ ,
what are you truing to achieve by doing that?

Francisco Olarte.

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

*Juliano,*

*The right way to do what you want is to:*

*A:*

*1. pg_dump from the database you want to copy
https://www.postgresql.org/docs/9.6/static/app-pgdump.html
<https://www.postgresql.org/docs/9.6/static/app-pgdump.html&gt;*

*2. pg_restore the dump file too the new database.
https://www.postgresql.org/docs/9.6/static/app-pgrestore.html
<https://www.postgresql.org/docs/9.6/static/app-pgrestore.html&gt;*

*OR*

*B:*

*1: pg_dumpall from the cluster you want to copy
https://www.postgresql.org/docs/9.6/static/app-pg-dumpall.html
<https://www.postgresql.org/docs/9.6/static/app-pg-dumpall.html&gt;*

*2: use psql to restore the dump file into the new cluster
https://www.postgresql.org/docs/9.6/static/app-psql.html
<https://www.postgresql.org/docs/9.6/static/app-psql.html&gt;*

--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.

#4David G. Johnston
david.g.johnston@gmail.com
In reply to: Juliano (#1)
Re: Overwrite pg_catalog?

On Thu, Dec 1, 2016 at 4:16 AM, Juliano <jplinux@protonmail.com> wrote:

Hi everyone,

I tried to restore pg_catalog to my new database, but the existing
pg_catalog can't be overwritten or dropped, and postgres auto creates
pg_catalog when I create a new DB.

So, there is a way to restore the pg_catalog to a new database?

​I suggest you explain the actual problem ​you are trying to solve - the
one for which you believe restoring pg_catalog is a solution.

David J.

#5Joshua D. Drake
jd@commandprompt.com
In reply to: Juliano (#1)
Re: Overwrite pg_catalog?

On 12/01/2016 03:16 AM, Juliano wrote:

Hi everyone,

I tried to restore pg_catalog to my new database, but the existing
pg_catalog can't be overwritten or dropped, and postgres auto creates
pg_catalog when I create a new DB.

So, there is a way to restore the pg_catalog to a new database?

Why would you do that? You should be restoring from a proper backup
which will already have everything it needs to populate the new
pg_catalog correctly.

JD

Regards,
Juliano

--
Command Prompt, Inc. http://the.postgres.company/
+1-503-667-4564
PostgreSQL Centered full stack support, consulting and development.
Everyone appreciates your honesty, until you are honest with them.
Unless otherwise stated, opinions are my own.

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

#6Michael Paquier
michael@paquier.xyz
In reply to: Francisco Olarte (#2)
Re: Overwrite pg_catalog?

On Thu, Dec 01, 2016 at 01:07:09PM +0100, Francisco Olarte wrote:

Juliano:

On Thu, Dec 1, 2016 at 12:16 PM, Juliano <jplinux@protonmail.com> wrote:

I tried to restore pg_catalog to my new database, but the existing
pg_catalog can't be overwritten or dropped, and postgres auto creates
pg_catalog when I create a new DB.

This is because, in general, pg_catalog is maintained by DML
statements, restoring it is not going to do what you think.

s/DML/DDL/
--
Michael

#7Juliano
jplinux@protonmail.com
In reply to: Michael Paquier (#6)
Re: Overwrite pg_catalog?

Hi everyone,

Ok, thanks.
Just to explain: I have some custom objects on my pg_catalog and I would like to restore it in a new test database and I think that this is the best way, isn't it?

Regards,
Juliano

-------- Original Message --------
Subject: Re: [GENERAL] Overwrite pg_catalog?
Local Time: December 2, 2016 2:18 AM
UTC Time: December 2, 2016 2:18 AM
From: michael.paquier@gmail.com
To: Francisco Olarte <folarte@peoplecall.com>
Juliano <jplinux@protonmail.com>, pgsql-general@postgresql.org <pgsql-general@postgresql.org>

On Thu, Dec 01, 2016 at 01:07:09PM +0100, Francisco Olarte wrote:

Juliano:

On Thu, Dec 1, 2016 at 12:16 PM, Juliano <jplinux@protonmail.com> wrote:

I tried to restore pg_catalog to my new database, but the existing
pg_catalog can't be overwritten or dropped, and postgres auto creates
pg_catalog when I create a new DB.

This is because, in general, pg_catalog is maintained by DML
statements, restoring it is not going to do what you think.

s/DML/DDL/
--
Michael

#8Michael Paquier
michael@paquier.xyz
In reply to: Juliano (#7)
Re: Overwrite pg_catalog?

On Tue, Dec 6, 2016 at 5:15 PM, Juliano <jplinux@protonmail.com> wrote:

Hi everyone,

Ok, thanks.
Just to explain: I have some custom objects on my pg_catalog and I would
like to restore it in a new test database and I think that this is the best
way, isn't it?

Yes, pg_dump and pg_dumpall are the tools to use to restore a database
or multiple databases from a past state, and provides options
regarding what you want to dump. So go for it.
--
Michael

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