|
20 | 20 | use warnings; |
21 | 21 |
|
22 | 22 | my@input_files; |
23 | | -our@include_path; |
| 23 | +my@include_path; |
24 | 24 | my$output_path =''; |
25 | 25 | my$major_version; |
26 | 26 |
|
|
105 | 105 | my%schemapg_entries; |
106 | 106 | my@tables_needing_macros; |
107 | 107 | my%regprocoids; |
108 | | -our@types; |
| 108 | +my@types; |
109 | 109 |
|
110 | 110 | # produce output, one catalog at a time |
111 | 111 | foreachmy$catname (@{$catalogs->{names} }) |
|
124 | 124 | my$first = 1; |
125 | 125 |
|
126 | 126 | print$bki" (\n"; |
127 | | -foreachmy$column (@{$catalog->{columns} }) |
| 127 | +my$schema =$catalog->{columns}; |
| 128 | +foreachmy$column (@$schema) |
128 | 129 | { |
129 | 130 | my$attname =$column->{name}; |
130 | 131 | my$atttype =$column->{type}; |
|
150 | 151 | } |
151 | 152 | print$bki"\n )\n"; |
152 | 153 |
|
153 | | -# open it, unless bootstrap case (create bootstrap does this automatically) |
154 | | -if ($catalog->{bootstrap}eq'') |
| 154 | +# Open it, unless bootstrap case (create bootstrap does this |
| 155 | +# automatically) |
| 156 | +if (!$catalog->{bootstrap}) |
155 | 157 | { |
156 | 158 | print$bki"open$catname\n"; |
157 | 159 | } |
|
169 | 171 | Catalog::SplitDataLine($row->{bki_values}); |
170 | 172 |
|
171 | 173 | # Perform required substitutions on fields |
172 | | -foreachmy$att (keys%bki_values) |
| 174 | +foreachmy$column (@$schema) |
173 | 175 | { |
| 176 | +my$attname =$column->{name}; |
| 177 | +my$atttype =$column->{type}; |
174 | 178 |
|
175 | 179 | # Substitute constant values we acquired above. |
176 | 180 | # (It's intentional that this can apply to parts of a field). |
177 | | -$bki_values{$att} =~s/\bPGUID\b/$BOOTSTRAP_SUPERUSERID/g; |
178 | | -$bki_values{$att} =~s/\bPGNSP\b/$PG_CATALOG_NAMESPACE/g; |
| 181 | +$bki_values{$attname} =~s/\bPGUID\b/$BOOTSTRAP_SUPERUSERID/g; |
| 182 | +$bki_values{$attname} =~s/\bPGNSP\b/$PG_CATALOG_NAMESPACE/g; |
179 | 183 |
|
180 | 184 | # Replace regproc columns' values with OIDs. |
181 | 185 | # If we don't have a unique value to substitute, |
182 | 186 | # just do nothing (regprocin will complain). |
183 | | -if ($bki_attr{$att}->{type}eq'regproc') |
| 187 | +if ($atttypeeq'regproc') |
184 | 188 | { |
185 | | -my$procoid =$regprocoids{$bki_values{$att} }; |
186 | | -$bki_values{$att} =$procoid |
| 189 | +my$procoid =$regprocoids{$bki_values{$attname} }; |
| 190 | +$bki_values{$attname} =$procoid |
187 | 191 | ifdefined($procoid) &&$procoidne'MULTIPLE'; |
188 | 192 | } |
189 | 193 | } |
|
215 | 219 | printf$bki"insert%s(%s )\n",$oid, |
216 | 220 | join('',@bki_values{@attnames}); |
217 | 221 |
|
218 | | -# Write comments to postgres.description and postgres.shdescription |
| 222 | +# Write comments to postgres.description and |
| 223 | +# postgres.shdescription |
219 | 224 | if (defined$row->{descr}) |
220 | 225 | { |
221 | | -printf$descr"%s\t%s\t0\t%s\n",$row->{oid},$catname, |
222 | | -$row->{descr}; |
| 226 | +printf$descr"%s\t%s\t0\t%s\n", |
| 227 | +$row->{oid},$catname,$row->{descr}; |
223 | 228 | } |
224 | 229 | if (defined$row->{shdescr}) |
225 | 230 | { |
226 | | -printf$shdescr"%s\t%s\t%s\n",$row->{oid},$catname, |
227 | | -$row->{shdescr}; |
| 231 | +printf$shdescr"%s\t%s\t%s\n", |
| 232 | +$row->{oid},$catname,$row->{shdescr}; |
228 | 233 | } |
229 | 234 | } |
230 | 235 | } |
|
240 | 245 |
|
241 | 246 | # Currently, all bootstrapped relations also need schemapg.h |
242 | 247 | # entries, so skip if the relation isn't to be in schemapg.h. |
243 | | -nextif$table->{schema_macro}ne'True'; |
| 248 | +nextif!$table->{schema_macro}; |
244 | 249 |
|
245 | 250 | $schemapg_entries{$table_name} = []; |
246 | 251 | push@tables_needing_macros,$table_name; |
247 | | -my$is_bootstrap =$table->{bootstrap}; |
248 | 252 |
|
249 | 253 | # Generate entries for user attributes. |
250 | 254 | my$attnum = 0; |
|
259 | 263 | $priornotnull &= ($row->{attnotnull}eq't'); |
260 | 264 |
|
261 | 265 | # If it's bootstrapped, put an entry in postgres.bki. |
262 | | -if ($is_bootstrapeq'bootstrap') |
| 266 | +if ($table->{bootstrap}) |
263 | 267 | { |
264 | 268 | bki_insert($row,@attnames); |
265 | 269 | } |
|
268 | 272 | $row = |
269 | 273 | emit_schemapg_row($row, |
270 | 274 | grep {$bki_attr{$_}{type}eq'bool' }@attnames); |
271 | | -push @{$schemapg_entries{$table_name} },'{' |
272 | | - .join( |
273 | | -',',grep {defined$_ } |
274 | | -map$row->{$_},@attnames) .' }'; |
| 275 | +push @{$schemapg_entries{$table_name} }, |
| 276 | +sprintf"{%s }", |
| 277 | +join(',',grep {defined$_ } @{$row}{@attnames}); |
275 | 278 | } |
276 | 279 |
|
277 | 280 | # Generate entries for system attributes. |
278 | 281 | # We only need postgres.bki entries, not schemapg.h entries. |
279 | | -if ($is_bootstrapeq'bootstrap') |
| 282 | +if ($table->{bootstrap}) |
280 | 283 | { |
281 | 284 | $attnum = 0; |
282 | 285 | my@SYS_ATTRS = ( |
|
294 | 297 | $row->{attnum} =$attnum; |
295 | 298 | $row->{attstattarget} ='0'; |
296 | 299 |
|
297 | | -#some catalogs don't haveoids |
| 300 | +#Omit the oid column if the catalog doesn't havethem |
298 | 301 | next |
299 | | -if$table->{without_oids}eq' without_oids' |
| 302 | +if$table->{without_oids} |
300 | 303 | &&$row->{attname}eq'oid'; |
301 | 304 |
|
302 | 305 | bki_insert($row,@attnames); |
|