Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c98c35c

Browse files
committed
Avoid putting build-location-dependent strings into generated files.
Various Perl scripts we use to generate files were in the habit of printing things like "generated by $0" into their output files. That looks like a fine idea at first glance, but it results in non-reproducible output, because in VPATH builds $0 won't be just the name of the script file, but a full path for it. We'd prefer that you get identical results whether using VPATH or not, so this is a bad thing. Some of these places also printed their input file name(s), causing an additional hazard of the same type. Hence, establish a policy that thou shalt not print $0, nor input file pathnames, into output files (they're still allowed in error messages, though). Instead just write the script name verbatim. While we are at it, we can make these annotations more useful by giving the script's full relative path name within the PG source tree, eg instead of Gen_fmgrtab.pl let's print src/backend/utils/Gen_fmgrtab.pl. Not all of the changes made here actually affect any files shipped in finished tarballs today, but it seems best to apply the policy everyplace so that nobody copies unsafe code into places where it could matter. Christoph Berg and Tom Lane Discussion: https://postgr.es/m/20171215102223.GB31812@msg.df7cb.de
1 parent 59d1e2b commit c98c35c

17 files changed

+21
-26
lines changed

src/backend/catalog/genbki.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@
340340
* *** DO NOT EDIT THIS FILE! ***
341341
* ******************************
342342
*
343-
* It has been GENERATED by $0
343+
* It has been GENERATED by src/backend/catalog/genbki.pl
344344
*
345345
*-------------------------------------------------------------------------
346346
*/

src/backend/utils/Gen_fmgrtab.pl

+3-6
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@
118118
* *** DO NOT EDIT THIS FILE! ***
119119
* ******************************
120120
*
121-
* It has been GENERATED by $0
122-
* from $infile
121+
* It has been GENERATED by src/backend/utils/Gen_fmgrtab.pl
123122
*
124123
*-------------------------------------------------------------------------
125124
*/
@@ -153,8 +152,7 @@
153152
* *** DO NOT EDIT THIS FILE! ***
154153
* ******************************
155154
*
156-
* It has been GENERATED by $0
157-
* from $infile
155+
* It has been GENERATED by src/backend/utils/Gen_fmgrtab.pl
158156
*
159157
*-------------------------------------------------------------------------
160158
*/
@@ -181,8 +179,7 @@
181179
* *** DO NOT EDIT THIS FILE! ***
182180
* ******************************
183181
*
184-
* It has been GENERATED by $0
185-
* from $infile
182+
* It has been GENERATED by src/backend/utils/Gen_fmgrtab.pl
186183
*
187184
*-------------------------------------------------------------------------
188185
*/

src/backend/utils/mb/Unicode/UCS_to_BIG5.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
use strict;
2828
use convutils;
2929

30-
my $this_script = $0;
30+
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_BIG5.pl';
3131

3232
# Load BIG5.TXT
3333
my $all = &read_source("BIG5.TXT");

src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use strict;
1717
use convutils;
1818

19-
my $this_script = $0;
19+
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl';
2020

2121
# Read the input
2222

src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use strict;
1111
use convutils;
1212

13-
my $this_script = $0;
13+
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl';
1414

1515
# first generate UTF-8 --> EUC_JIS_2004 table
1616

src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use strict;
1515
use convutils;
1616

17-
my $this_script = $0;
17+
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl';
1818

1919
# Load JIS0212.TXT
2020
my $jis0212 = &read_source("JIS0212.TXT");

src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use strict;
2020
use convutils;
2121

22-
my $this_script = $0;
22+
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl';
2323

2424
# Load the source file.
2525

src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use strict;
2121
use convutils;
2222

23-
my $this_script = $0;
23+
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl';
2424

2525
my $mapping = &read_source("CNS11643.TXT");
2626

src/backend/utils/mb/Unicode/UCS_to_GB18030.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use strict;
1717
use convutils;
1818

19-
my $this_script = $0;
19+
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_GB18030.pl';
2020

2121
# Read the input
2222

src/backend/utils/mb/Unicode/UCS_to_JOHAB.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use strict;
1919
use convutils;
2020

21-
my $this_script = $0;
21+
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_JOHAB.pl';
2222

2323
# Load the source file.
2424

src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# first generate UTF-8 --> SHIFT_JIS_2004 table
1414

15-
my $this_script = $0;
15+
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl';
1616

1717
my $in_file = "sjis-0213-2004-std.txt";
1818

src/backend/utils/mb/Unicode/UCS_to_SJIS.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use strict;
1414
use convutils;
1515

16-
my $this_script = $0;
16+
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_SJIS.pl';
1717

1818
my $mapping = read_source("CP932.TXT");
1919

src/backend/utils/mb/Unicode/UCS_to_UHC.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use strict;
1717
use convutils;
1818

19-
my $this_script = $0;
19+
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_UHC.pl';
2020

2121
# Read the input
2222

src/backend/utils/mb/Unicode/UCS_to_most.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use strict;
1919
use convutils;
2020

21-
my $this_script = $0;
21+
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_most.pl';
2222

2323
my %filename = (
2424
'WIN866' => 'CP866.TXT',

src/bin/psql/create_help.pl

+3-5
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@
5151
* *** Do not change this file by hand. It is automatically
5252
* *** generated from the DocBook documentation.
5353
*
54-
* generated by
55-
* $^X $0 @ARGV
54+
* generated by src/bin/psql/create_help.pl
5655
*
5756
*/
5857
@@ -76,8 +75,7 @@
7675
* *** Do not change this file by hand. It is automatically
7776
* *** generated from the DocBook documentation.
7877
*
79-
* generated by
80-
* $^X $0 @ARGV
78+
* generated by src/bin/psql/create_help.pl
8179
*
8280
*/
8381
@@ -131,7 +129,7 @@
131129
my $nl_count = () = $cmdsynopsis =~ /\n/g;
132130

133131
$cmdsynopsis =~ m!</>!
134-
and die "$0:$file: null end tag not supported in synopsis\n";
132+
and die "$0: $file: null end tag not supported in synopsis\n";
135133
$cmdsynopsis =~ s/%/%%/g;
136134

137135
while ($cmdsynopsis =~ m!<(\w+)[^>]*>(.+?)</\1[^>]*>!)

src/pl/plperl/text2macro.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ =head1 DESCRIPTION
4040
print qq{
4141
/*
4242
* DO NOT EDIT - THIS FILE IS AUTOGENERATED - CHANGES WILL BE LOST
43-
* Written by $0 from @ARGV
43+
* Generated by src/pl/plperl/text2macro.pl
4444
*/
4545
};
4646

src/test/perl/TestLib.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ BEGIN
6666
delete $ENV{PGPORT};
6767
delete $ENV{PGHOST};
6868

69-
$ENV{PGAPPNAME} = $0;
69+
$ENV{PGAPPNAME} = basename($0);
7070

7171
# Must be set early
7272
$windows_os = $Config{osname} eq 'MSWin32' || $Config{osname} eq 'msys';

0 commit comments

Comments
 (0)