|
66 | 66 | # Open temp files
|
67 | 67 | my $tmpext = ".tmp$$";
|
68 | 68 | my $bkifile = $output_path . 'postgres.bki';
|
69 |
| -open BKI, '>', $bkifile . $tmpext |
| 69 | +open my $bki, '>', $bkifile . $tmpext |
70 | 70 | or die "can't open $bkifile$tmpext: $!";
|
71 | 71 | my $schemafile = $output_path . 'schemapg.h';
|
72 |
| -open SCHEMAPG, '>', $schemafile . $tmpext |
| 72 | +open my $schemapg, '>', $schemafile . $tmpext |
73 | 73 | or die "can't open $schemafile$tmpext: $!";
|
74 | 74 | my $descrfile = $output_path . 'postgres.description';
|
75 |
| -open DESCR, '>', $descrfile . $tmpext |
| 75 | +open my $descr, '>', $descrfile . $tmpext |
76 | 76 | or die "can't open $descrfile$tmpext: $!";
|
77 | 77 | my $shdescrfile = $output_path . 'postgres.shdescription';
|
78 |
| -open SHDESCR, '>', $shdescrfile . $tmpext |
| 78 | +open my $shdescr, '>', $shdescrfile . $tmpext |
79 | 79 | or die "can't open $shdescrfile$tmpext: $!";
|
80 | 80 |
|
81 | 81 | # Fetch some special data that we will substitute into the output file.
|
|
97 | 97 | # Generate postgres.bki, postgres.description, and postgres.shdescription
|
98 | 98 |
|
99 | 99 | # version marker for .bki file
|
100 |
| -print BKI "# PostgreSQL $major_version\n"; |
| 100 | +print $bki "# PostgreSQL $major_version\n"; |
101 | 101 |
|
102 | 102 | # vars to hold data needed for schemapg.h
|
103 | 103 | my %schemapg_entries;
|
|
110 | 110 |
|
111 | 111 | # .bki CREATE command for this catalog
|
112 | 112 | my $catalog = $catalogs->{$catname};
|
113 |
| - print BKI "create $catname $catalog->{relation_oid}" |
| 113 | + print $bki "create $catname $catalog->{relation_oid}" |
114 | 114 | . $catalog->{shared_relation}
|
115 | 115 | . $catalog->{bootstrap}
|
116 | 116 | . $catalog->{without_oids}
|
|
120 | 120 | my @attnames;
|
121 | 121 | my $first = 1;
|
122 | 122 |
|
123 |
| - print BKI " (\n"; |
| 123 | + print $bki " (\n"; |
124 | 124 | foreach my $column (@{ $catalog->{columns} })
|
125 | 125 | {
|
126 | 126 | my $attname = $column->{name};
|
|
130 | 130 |
|
131 | 131 | if (!$first)
|
132 | 132 | {
|
133 |
| - print BKI " ,\n"; |
| 133 | + print $bki " ,\n"; |
134 | 134 | }
|
135 | 135 | $first = 0;
|
136 | 136 |
|
137 |
| - print BKI " $attname = $atttype"; |
| 137 | + print $bki " $attname = $atttype"; |
138 | 138 |
|
139 | 139 | if (defined $column->{forcenotnull})
|
140 | 140 | {
|
141 |
| - print BKI " FORCE NOT NULL"; |
| 141 | + print $bki " FORCE NOT NULL"; |
142 | 142 | }
|
143 | 143 | elsif (defined $column->{forcenull})
|
144 | 144 | {
|
145 |
| - print BKI " FORCE NULL"; |
| 145 | + print $bki " FORCE NULL"; |
146 | 146 | }
|
147 | 147 | }
|
148 |
| - print BKI "\n )\n"; |
| 148 | + print $bki "\n )\n"; |
149 | 149 |
|
150 | 150 | # open it, unless bootstrap case (create bootstrap does this automatically)
|
151 | 151 | if ($catalog->{bootstrap} eq '')
|
152 | 152 | {
|
153 |
| - print BKI "open $catname\n"; |
| 153 | + print $bki "open $catname\n"; |
154 | 154 | }
|
155 | 155 |
|
156 | 156 | if (defined $catalog->{data})
|
|
175 | 175 |
|
176 | 176 | # Write to postgres.bki
|
177 | 177 | my $oid = $row->{oid} ? "OID = $row->{oid} " : '';
|
178 |
| - printf BKI "insert %s( %s)\n", $oid, $row->{bki_values}; |
| 178 | + printf $bki "insert %s( %s)\n", $oid, $row->{bki_values}; |
179 | 179 |
|
180 | 180 | # Write comments to postgres.description and postgres.shdescription
|
181 | 181 | if (defined $row->{descr})
|
182 | 182 | {
|
183 |
| - printf DESCR "%s\t%s\t0\t%s\n", $row->{oid}, $catname, |
| 183 | + printf $descr "%s\t%s\t0\t%s\n", $row->{oid}, $catname, |
184 | 184 | $row->{descr};
|
185 | 185 | }
|
186 | 186 | if (defined $row->{shdescr})
|
187 | 187 | {
|
188 |
| - printf SHDESCR "%s\t%s\t%s\n", $row->{oid}, $catname, |
| 188 | + printf $shdescr "%s\t%s\t%s\n", $row->{oid}, $catname, |
189 | 189 | $row->{shdescr};
|
190 | 190 | }
|
191 | 191 | }
|
|
267 | 267 | }
|
268 | 268 | }
|
269 | 269 |
|
270 |
| - print BKI "close $catname\n"; |
| 270 | + print $bki "close $catname\n"; |
271 | 271 | }
|
272 | 272 |
|
273 | 273 | # Any information needed for the BKI that is not contained in a pg_*.h header
|
|
276 | 276 | # Write out declare toast/index statements
|
277 | 277 | foreach my $declaration (@{ $catalogs->{toasting}->{data} })
|
278 | 278 | {
|
279 |
| - print BKI $declaration; |
| 279 | + print $bki $declaration; |
280 | 280 | }
|
281 | 281 |
|
282 | 282 | foreach my $declaration (@{ $catalogs->{indexing}->{data} })
|
283 | 283 | {
|
284 |
| - print BKI $declaration; |
| 284 | + print $bki $declaration; |
285 | 285 | }
|
286 | 286 |
|
287 | 287 |
|
288 | 288 | # Now generate schemapg.h
|
289 | 289 |
|
290 | 290 | # Opening boilerplate for schemapg.h
|
291 |
| -print SCHEMAPG <<EOM; |
| 291 | +print $schemapg <<EOM; |
292 | 292 | /*-------------------------------------------------------------------------
|
293 | 293 | *
|
294 | 294 | * schemapg.h
|
|
313 | 313 | # Emit schemapg declarations
|
314 | 314 | foreach my $table_name (@tables_needing_macros)
|
315 | 315 | {
|
316 |
| - print SCHEMAPG "\n#define Schema_$table_name \\\n"; |
317 |
| - print SCHEMAPG join ", \\\n", @{ $schemapg_entries{$table_name} }; |
318 |
| - print SCHEMAPG "\n"; |
| 316 | + print $schemapg "\n#define Schema_$table_name \\\n"; |
| 317 | + print $schemapg join ", \\\n", @{ $schemapg_entries{$table_name} }; |
| 318 | + print $schemapg "\n"; |
319 | 319 | }
|
320 | 320 |
|
321 | 321 | # Closing boilerplate for schemapg.h
|
322 |
| -print SCHEMAPG "\n#endif /* SCHEMAPG_H */\n"; |
| 322 | +print $schemapg "\n#endif /* SCHEMAPG_H */\n"; |
323 | 323 |
|
324 | 324 | # We're done emitting data
|
325 |
| -close BKI; |
326 |
| -close SCHEMAPG; |
327 |
| -close DESCR; |
328 |
| -close SHDESCR; |
| 325 | +close $bki; |
| 326 | +close $schemapg; |
| 327 | +close $descr; |
| 328 | +close $shdescr; |
329 | 329 |
|
330 | 330 | # Finally, rename the completed files into place.
|
331 | 331 | Catalog::RenameTempFile($bkifile, $tmpext);
|
@@ -425,7 +425,7 @@ sub bki_insert
|
425 | 425 | my @attnames = @_;
|
426 | 426 | my $oid = $row->{oid} ? "OID = $row->{oid} " : '';
|
427 | 427 | my $bki_values = join ' ', map $row->{$_}, @attnames;
|
428 |
| - printf BKI "insert %s( %s)\n", $oid, $bki_values; |
| 428 | + printf $bki "insert %s( %s)\n", $oid, $bki_values; |
429 | 429 | }
|
430 | 430 |
|
431 | 431 | # The field values of a Schema_pg_xxx declaration are similar, but not
|
@@ -472,15 +472,15 @@ sub find_defined_symbol
|
472 | 472 | }
|
473 | 473 | my $file = $path . $catalog_header;
|
474 | 474 | next if !-f $file;
|
475 |
| - open(FIND_DEFINED_SYMBOL, '<', $file) || die "$file: $!"; |
476 |
| - while (<FIND_DEFINED_SYMBOL>) |
| 475 | + open(my $find_defined_symbol, '<', $file) || die "$file: $!"; |
| 476 | + while (<$find_defined_symbol>) |
477 | 477 | {
|
478 | 478 | if (/^#define\s+\Q$symbol\E\s+(\S+)/)
|
479 | 479 | {
|
480 | 480 | return $1;
|
481 | 481 | }
|
482 | 482 | }
|
483 |
| - close FIND_DEFINED_SYMBOL; |
| 483 | + close $find_defined_symbol; |
484 | 484 | die "$file: no definition found for $symbol\n";
|
485 | 485 | }
|
486 | 486 | die "$catalog_header: not found in any include directory\n";
|
|
0 commit comments