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

Commit72559b4

Browse files
committed
Fix genbki.pl and Gen_fmgrtab.pl to use PID-specific temp file names,
so that it's safe if a parallel make chooses to run two concurrent copies.Also, work around a memory leak in some versions of Perl.
1 parent1658f6b commit72559b4

File tree

3 files changed

+39
-24
lines changed

3 files changed

+39
-24
lines changed

‎src/backend/catalog/Catalog.pm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
# Portions Copyright (c) 1994, Regents of the University of California
99
#
10-
# $PostgreSQL: pgsql/src/backend/catalog/Catalog.pm,v 1.2 2010/01/0502:34:03 tgl Exp $
10+
# $PostgreSQL: pgsql/src/backend/catalog/Catalog.pm,v 1.3 2010/01/0520:23:32 tgl Exp $
1111
#
1212
#----------------------------------------------------------------------
1313

@@ -170,11 +170,14 @@ sub Catalogs
170170
}
171171

172172
# Rename temporary files to final names.
173-
# Call this function with the final file name --- we append .tmp automatically
173+
# Call this function with the final file name and the .tmp extension
174+
# Note: recommended extension is ".tmp$$", so that parallel make steps
175+
# can't use the same temp files
174176
subRenameTempFile
175177
{
176178
my$final_name =shift;
177-
my$temp_name =$final_name .'.tmp';
179+
my$extension =shift;
180+
my$temp_name =$final_name .$extension;
178181
print"Writing$final_name\n";
179182
rename($temp_name,$final_name) ||die"rename:$temp_name:$!";
180183
}

‎src/backend/catalog/genbki.pl

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
1111
# Portions Copyright (c) 1994, Regents of the University of California
1212
#
13-
# $PostgreSQL: pgsql/src/backend/catalog/genbki.pl,v 1.3 2010/01/0506:41:44 tgl Exp $
13+
# $PostgreSQL: pgsql/src/backend/catalog/genbki.pl,v 1.4 2010/01/0520:23:32 tgl Exp $
1414
#
1515
#----------------------------------------------------------------------
1616

@@ -62,14 +62,19 @@
6262
}
6363

6464
# Open temp files
65-
open BKI,'>',$output_path .'postgres.bki.tmp'
66-
||die"can't open postgres.bki.tmp:$!";
67-
open SCHEMAPG,'>',$output_path .'schemapg.h.tmp'
68-
||die"can't open 'schemapg.h.tmp:$!";
69-
open DESCR,'>',$output_path .'postgres.description.tmp'
70-
||die"can't open postgres.description.tmp:$!";
71-
open SHDESCR,'>',$output_path .'postgres.shdescription.tmp'
72-
||die"can't open postgres.shdescription.tmp:$!";
65+
my$tmpext =".tmp$$";
66+
my$bkifile =$output_path .'postgres.bki';
67+
open BKI,'>',$bkifile .$tmpext
68+
ordie"can't open$bkifile$tmpext:$!";
69+
my$schemafile =$output_path .'schemapg.h';
70+
open SCHEMAPG,'>',$schemafile .$tmpext
71+
ordie"can't open$schemafile$tmpext:$!";
72+
my$descrfile =$output_path .'postgres.description';
73+
open DESCR,'>',$descrfile .$tmpext
74+
ordie"can't open$descrfile$tmpext:$!";
75+
my$shdescrfile =$output_path .'postgres.shdescription';
76+
open SHDESCR,'>',$shdescrfile .$tmpext
77+
ordie"can't open$shdescrfile$tmpext:$!";
7378

7479
# Fetch some special data that we will substitute into the output file.
7580
# CAUTION: be wary about what symbols you substitute into the .bki file here!
@@ -283,15 +288,15 @@
283288

284289
# We're done emitting data
285290
close BKI;
291+
close SCHEMAPG;
286292
close DESCR;
287293
close SHDESCR;
288-
close SCHEMAPG;
289294

290295
# Finally, rename the completed files into place.
291-
Catalog::RenameTempFile($output_path .'postgres.bki');
292-
Catalog::RenameTempFile($output_path .'postgres.description');
293-
Catalog::RenameTempFile($output_path .'postgres.shdescription');
294-
Catalog::RenameTempFile($output_path .'schemapg.h');
296+
Catalog::RenameTempFile($bkifile,$tmpext);
297+
Catalog::RenameTempFile($schemafile,$tmpext);
298+
Catalog::RenameTempFile($descrfile,$tmpext);
299+
Catalog::RenameTempFile($shdescrfile,$tmpext);
295300

296301
exit 0;
297302

‎src/backend/utils/Gen_fmgrtab.pl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
#
1111
# IDENTIFICATION
12-
# $PostgreSQL: pgsql/src/backend/utils/Gen_fmgrtab.pl,v 1.4 2010/01/0501:06:56 tgl Exp $
12+
# $PostgreSQL: pgsql/src/backend/utils/Gen_fmgrtab.pl,v 1.5 2010/01/0520:23:32 tgl Exp $
1313
#
1414
#-------------------------------------------------------------------------
1515

@@ -58,7 +58,6 @@
5858
my$data =$catalogs->{pg_proc}->{data};
5959
foreachmy$row (@$data)
6060
{
61-
6261
# To construct fmgroids.h and fmgrtab.c, we need to inspect some
6362
# of the individual data fields. Just splitting on whitespace
6463
# won't work, because some quoted fields might contain internal
@@ -81,10 +80,19 @@
8180
nargs=>$row->{pronargs},
8281
prosrc=>$row->{prosrc},
8382
};
83+
84+
# Hack to work around memory leak in some versions of Perl
85+
$row =undef;
8486
}
8587

8688
# Emit headers for both files
87-
open H,'>',$output_path .'fmgroids.h.tmp' ||die"Could not open fmgroids.h.tmp:$!";
89+
my$tmpext =".tmp$$";
90+
my$oidsfile =$output_path .'fmgroids.h';
91+
my$tabfile =$output_path .'fmgrtab.c';
92+
93+
open H,'>',$oidsfile .$tmpextordie"Could not open$oidsfile$tmpext:$!";
94+
open T,'>',$tabfile .$tmpextordie"Could not open$tabfile$tmpext:$!";
95+
8896
print H
8997
qq|/*-------------------------------------------------------------------------
9098
*
@@ -123,7 +131,6 @@
123131
*/
124132
|;
125133

126-
open T,'>',$output_path .'fmgrtab.c.tmp' ||die"Could not open fmgrtab.c.tmp:$!";
127134
print T
128135
qq|/*-------------------------------------------------------------------------
129136
*
@@ -174,7 +181,6 @@
174181

175182
# And add the file footers.
176183
print H"\n#endif /* FMGROIDS_H */\n";
177-
close(H);
178184

179185
print T
180186
qq| /* dummy entry is easier than getting rid of comma after last real one */
@@ -187,11 +193,12 @@
187193
const int fmgr_nbuiltins = (sizeof(fmgr_builtins) / sizeof(FmgrBuiltin)) - 1;
188194
|;
189195

196+
close(H);
190197
close(T);
191198

192199
# Finally, rename the completed files into place.
193-
Catalog::RenameTempFile($output_path .'fmgroids.h');
194-
Catalog::RenameTempFile($output_path .'fmgrtab.c');
200+
Catalog::RenameTempFile($oidsfile,$tmpext);
201+
Catalog::RenameTempFile($tabfile,$tmpext);
195202

196203
subusage
197204
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp