Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit44096f1

Browse files
committed
Fix portability breakage in pg_dump.
Commit0eea804 introduced some overlyoptimistic assumptions about what could be in a local struct variable'sinitializer. (This might in fact be valid code according to C99, but I'vegot at least one pre-C99 compiler that falls over on those nonconstantaddress expressions.) There is no reason whatsoever for main()'s workspaceto not be static, so revert long_options[] to a static and make theDumpOptions struct static as well.
1 parent8883bae commit44096f1

File tree

3 files changed

+91
-84
lines changed

3 files changed

+91
-84
lines changed

‎src/bin/pg_dump/pg_backup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ extern void PrintTOCSummary(Archive *AH, RestoreOptions *ropt);
269269
externRestoreOptions*NewRestoreOptions(void);
270270

271271
externDumpOptions*NewDumpOptions(void);
272+
externvoidInitDumpOptions(DumpOptions*opts);
272273
externDumpOptions*dumpOptionsFromRestoreOptions(RestoreOptions*ropt);
273274

274275
/* Rearrange and filter TOC entries */

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,27 @@ static void mark_create_done(ArchiveHandle *AH, TocEntry *te);
109109
staticvoidinhibit_data_for_failed_table(ArchiveHandle*AH,TocEntry*te);
110110

111111
/*
112-
* Allocate a new DumpOptions block.
113-
* This is mainly so we can initialize it, but also for future expansion.
114-
* We pg_malloc0 the structure, so we don't need to initialize whatever is
115-
* 0, NULL or false anyway.
112+
* Allocate a new DumpOptions block containing all default values.
116113
*/
117114
DumpOptions*
118115
NewDumpOptions(void)
119116
{
120-
DumpOptions*opts;
117+
DumpOptions*opts= (DumpOptions*)pg_malloc(sizeof(DumpOptions));
121118

122-
opts= (DumpOptions*)pg_malloc0(sizeof(DumpOptions));
119+
InitDumpOptions(opts);
120+
returnopts;
121+
}
123122

123+
/*
124+
* Initialize a DumpOptions struct to all default values
125+
*/
126+
void
127+
InitDumpOptions(DumpOptions*opts)
128+
{
129+
memset(opts,0,sizeof(DumpOptions));
124130
/* set any fields that shouldn't default to zeroes */
125131
opts->include_everything= true;
126132
opts->dumpSections=DUMP_UNSECTIONED;
127-
128-
returnopts;
129133
}
130134

131135
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp