pgsql: Move pg_dump memory routines into pg_dumpmem.c/h and restore com

Started by Bruce Momjianabout 14 years ago4 messages
#1Bruce Momjian
bruce@momjian.us

Move pg_dump memory routines into pg_dumpmem.c/h and restore common.c
with its original functions. The previous function migration would
cause too many difficulties in back-patching.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/9a7d49d1fba666c8bfb9df0065545e85d54dbc41

Modified Files
--------------
src/bin/pg_dump/Makefile | 6 +-
src/bin/pg_dump/common.c | 982 +++++++++++++++++++++++++++++++--
src/bin/pg_dump/common.h | 24 -
src/bin/pg_dump/compress_io.c | 2 +-
src/bin/pg_dump/dumpcatalog.c | 978 --------------------------------
src/bin/pg_dump/dumpmem.c | 73 +++
src/bin/pg_dump/dumpmem.h | 24 +
src/bin/pg_dump/dumputils.c | 2 +-
src/bin/pg_dump/pg_backup_archiver.c | 2 +-
src/bin/pg_dump/pg_backup_custom.c | 2 +-
src/bin/pg_dump/pg_backup_db.c | 2 +-
src/bin/pg_dump/pg_backup_directory.c | 2 +-
src/bin/pg_dump/pg_backup_files.c | 2 +-
src/bin/pg_dump/pg_backup_null.c | 2 +-
src/bin/pg_dump/pg_backup_tar.c | 2 +-
src/bin/pg_dump/pg_dump.c | 2 +-
src/bin/pg_dump/pg_dump_sort.c | 2 +-
src/bin/pg_dump/pg_restore.c | 2 +-
18 files changed, 1056 insertions(+), 1055 deletions(-)

#2Andrew Dunstan
andrew@dunslane.net
In reply to: Bruce Momjian (#1)
Re: pgsql: Move pg_dump memory routines into pg_dumpmem.c/h and restore com

On 11/26/2011 10:36 PM, Bruce Momjian wrote:

Move pg_dump memory routines into pg_dumpmem.c/h and restore common.c
with its original functions. The previous function migration would
cause too many difficulties in back-patching.

MSVC is still broken with this change, but now I think we've exposed a
long-standing error in the MSVC build system.

Mkvcbuild.pm has:

my $pgdumpall = AddSimpleFrontend('pg_dump', 1);
$pgdumpall->{name} = 'pg_dumpall';
$pgdumpall->AddIncludeDir('src\backend');
$pgdumpall->AddFile('src\bin\pg_dump\pg_dumpall.c');
$pgdumpall->AddFile('src\bin\pg_dump\keywords.c');
$pgdumpall->AddFile('src\backend\parser\kwlookup.c')

AddSimpleFrontend() calls AddDir() which harvests the contents of
$(OBJS) from the Makefile for the target. But pg_dumpall doesn't want
$(OBJS). We've been benignly but mistakenly building it with them for a
quite a few years, but now we can't do that any more, given Bruce's
changes. It looks like the fix is to call AddProject() for pg_dumpall
instead of AddSimpleFrontend() and then do a little more work ourselves
to select exactly what we need.

I don't have time to do that and test it immediately, as I'll be away
most of the day, so if anyone else can please go for it.

cheers

andrew

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#2)
Re: pgsql: Move pg_dump memory routines into pg_dumpmem.c/h and restore com

Andrew Dunstan <andrew@dunslane.net> writes:

MSVC is still broken with this change, but now I think we've exposed a
long-standing error in the MSVC build system. ...
AddSimpleFrontend() calls AddDir() which harvests the contents of
$(OBJS) from the Makefile for the target. But pg_dumpall doesn't want
$(OBJS). We've been benignly but mistakenly building it with them for a
quite a few years, but now we can't do that any more, given Bruce's
changes. It looks like the fix is to call AddProject() for pg_dumpall
instead of AddSimpleFrontend() and then do a little more work ourselves
to select exactly what we need.

Maybe it would be better to refactor the makefile so that $(OBJS) is
still sensible to use this way?

regards, tom lane

#4Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#3)
1 attachment(s)
Re: pgsql: Move pg_dump memory routines into pg_dumpmem.c/h and restore com

On 11/27/2011 12:42 PM, Tom Lane wrote:

Andrew Dunstan<andrew@dunslane.net> writes:

MSVC is still broken with this change, but now I think we've exposed a
long-standing error in the MSVC build system. ...
AddSimpleFrontend() calls AddDir() which harvests the contents of
$(OBJS) from the Makefile for the target. But pg_dumpall doesn't want
$(OBJS). We've been benignly but mistakenly building it with them for a
quite a few years, but now we can't do that any more, given Bruce's
changes. It looks like the fix is to call AddProject() for pg_dumpall
instead of AddSimpleFrontend() and then do a little more work ourselves
to select exactly what we need.

Maybe it would be better to refactor the makefile so that $(OBJS) is
still sensible to use this way?

I don't think so. That would make things worse for the pg_dump and
pg_restore targets which do use $(OBJS) as it is now.

Attached is a slightly hackish but very small patch that I have tested
that resolves the problem. Unless there's an objection I'll apply it
shortly (with an explanatory comment). Essentially it still uses
AddSimpleFrontend, so we still get the useful things it does, like
linking in libpq and setting up Windows resources, but the removes the
unwanted sources for $(OBJS) files from the object. Then we add in just
the files we do want.

cheers

andrew

Attachments:

dumpall.patchtext/x-patch; name=dumpall.patchDownload
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 482f100..59a7624 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -344,9 +344,13 @@ sub mkvcbuild
     $pgdump->AddFile('src\backend\parser\kwlookup.c');
 
     my $pgdumpall = AddSimpleFrontend('pg_dump', 1);
+    my @nodumpall = grep  {m /src\\bin\\pg_dump\\.*\.c$/ } 
+	keys %{$pgdumpall->{files}};
+    delete @{$pgdumpall->{files}}{@nodumpall};
     $pgdumpall->{name} = 'pg_dumpall';
     $pgdumpall->AddIncludeDir('src\backend');
     $pgdumpall->AddFile('src\bin\pg_dump\pg_dumpall.c');
+    $pgdumpall->AddFile('src\bin\pg_dump\dumputils.c');
     $pgdumpall->AddFile('src\bin\pg_dump\keywords.c');
     $pgdumpall->AddFile('src\backend\parser\kwlookup.c');