Re: Schema version management - Mailing list pgsql-hackers

From Joel Jacobson
Subject Re: Schema version management
Date
Msg-id CAASwCXfPcGs9n3tiEuqgAkKkvKzwTDwkNbJ0bJsw5ZPc6-J1Ow@mail.gmail.com
Whole thread Raw
In response to Re: Schema version management  (Daniel Farina <daniel@heroku.com>)
Responses Re: Schema version management
List pgsql-hackers
On Mon, May 21, 2012 at 8:08 AM, Daniel Farina <daniel@heroku.com> wrote:
> I think you are absolutely right, but I'm not sure if teaching pg_dump
> a new option is the best idea.  It's a pretty complex program as-is.
> I've also heard some people who really wish pg knew how to self-dump
> for valid reasons.

Complex program? Yes, pg_dump it is extremely complex, I wouldn't want
to touch any of the code. A rewrite is probably close to impossible.

Complex patch? No. It's 102 lines of code and doesn't change any of
the existing code in pg_dump, it simply adds some lines writing out
the objects to separate files. Have a look at the patch, it's super
simple.

> It sounds like some of the catalog wrangling and cycle-breaking
> properties of pg_dump could benefit from being exposed stand-alone,
> but unfortunately that's not a simple task, especially if you want to
> do The Right Thing and have pg_dump link that code, given pg_dump's
> criticality.

I agree it's not a simple task, and it's probably not something anyone
will fix in the near future.
The --split option doesn't aim to solve this problem either. That's a
different problem, and it's not a problem I have.

> pg_extractor is a new/alternative take on the database copying
> problem, maybe you could have a look at that?

It's just sad realizing people need to some up with hacks and
work-arounds to solve a obvious real-life problem, easily fixed inside
pg_dump with 102 lines of drop-dead simple code, not touching any of
the logics or flows in pg_dump.

I can't even image how many hours coders have wasted hacking together
tools like pg_extractor just to circumvent the stupid fact pg_dump
can't do this natively.

The pg_extractor is way more complex than my suggested patch, it's 974
lines of perl codes, as opposed to 102 lines of simple code in the
patch.
The pg_extractor also does a lot more than simply splitting objects
into separate files, like executing svn commands.

The splitting of objects into separate files should clearly be the
responsibility of pg_dump.
It would allow you to easily version control the schema files your
self with any version control software system, such as svn, git, etc.

I'm sure pg_extractor does it best to achieve the objective, but even
if it does, I would never trust it for production usage, version
controlling your production schema is far too important to trust any
tool not part of the mainline distribution of postgres. And personally
I don't have any problem, I've been using the --split option for two
years, I just feel sorry for the rest of the postgres community,
unaware of how to solve this problem, having to hack together their
own little tools, or be "lucky" finding some existing hack.


pgsql-hackers by date:

Previous
From: Daniel Farina
Date:
Subject: Re: Schema version management
Next
From: Alvaro Herrera
Date:
Subject: Re: Remove readline notice from psql --version?