Commit 44096f1c authored by Tom Lane's avatar Tom Lane

Fix portability breakage in pg_dump.

Commit 0eea8047 introduced some overly
optimistic assumptions about what could be in a local struct variable's
initializer.  (This might in fact be valid code according to C99, but I've
got at least one pre-C99 compiler that falls over on those nonconstant
address expressions.)  There is no reason whatsoever for main()'s workspace
to not be static, so revert long_options[] to a static and make the
DumpOptions struct static as well.
parent 8883bae3
......@@ -269,6 +269,7 @@ extern void PrintTOCSummary(Archive *AH, RestoreOptions *ropt);
extern RestoreOptions *NewRestoreOptions(void);
extern DumpOptions *NewDumpOptions(void);
extern void InitDumpOptions(DumpOptions *opts);
extern DumpOptions *dumpOptionsFromRestoreOptions(RestoreOptions *ropt);
/* Rearrange and filter TOC entries */
......
......@@ -109,23 +109,27 @@ static void mark_create_done(ArchiveHandle *AH, TocEntry *te);
static void inhibit_data_for_failed_table(ArchiveHandle *AH, TocEntry *te);
/*
* Allocate a new DumpOptions block.
* This is mainly so we can initialize it, but also for future expansion.
* We pg_malloc0 the structure, so we don't need to initialize whatever is
* 0, NULL or false anyway.
* Allocate a new DumpOptions block containing all default values.
*/
DumpOptions *
NewDumpOptions(void)
{
DumpOptions *opts;
DumpOptions *opts = (DumpOptions *) pg_malloc(sizeof(DumpOptions));
opts = (DumpOptions *) pg_malloc0(sizeof(DumpOptions));
InitDumpOptions(opts);
return opts;
}
/*
* Initialize a DumpOptions struct to all default values
*/
void
InitDumpOptions(DumpOptions *opts)
{
memset(opts, 0, sizeof(DumpOptions));
/* set any fields that shouldn't default to zeroes */
opts->include_everything = true;
opts->dumpSections = DUMP_UNSECTIONED;
return opts;
}
/*
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment