r53592 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53591‎ | r53592 | r53593 >
Date:13:04, 21 July 2009
Author:avar
Status:deferred
Tags:
Comment:
support for deleting created views
Modified paths:
  • /trunk/tools/osm-tools/osm2pgsql-style/create-language-views.pl (modified) (history)

Diff [purge]

Index: trunk/tools/osm-tools/osm2pgsql-style/create-language-views.pl
@@ -8,6 +8,7 @@
99
1010 perl wikipedia-language-codes.pl > wikipedia-languages.yml
1111 perl create-language-views.pl --languages wikipedia-languages.yml --psql-user gis > create_views.sql
 12+ perl create-language-views.pl --languages wikipedia-languages.yml --psql-user gis --delete > delete_views.sql
1213 psql -U gis gis < create_views.sql
1314
1415 =head1 OPTIONS
@@ -26,6 +27,10 @@
2728
2829 The PostgreSQL user to use.
2930
 31+=item --delete
 32+
 33+Create SQL to delete the views and associated data.
 34+
3035 =head1 LINKS
3136
3237 L<http://wiki.openstreetmap.org/wiki/Regionalisedmap>
@@ -55,6 +60,7 @@
5661 'h|help' => \my $help,
5762 'languages=s' => \my $languages,
5863 'psql-user=s' => \my $psql_user,
 64+ 'delete' => \my $delete,
5965 'style=s' => \my $style,
6066 ) or help();
6167
@@ -120,12 +126,17 @@
121127 my @munged_columns = munged_columns($code, @{ $columns{$table} });
122128
123129 my $view_name = "view_${table}_lang_${code}";
124 - say "CREATE VIEW \"$view_name\" as";
125 - say " SELECT";
126 - say join ",\n", map { " $_" } @munged_columns;
127 - say "FROM $table;";
128 - say "";
129130
 131+ if ($delete) {
 132+ say "DROP VIEW \"$view_name\";";
 133+ } else {
 134+ say "CREATE VIEW \"$view_name\" as";
 135+ say " SELECT";
 136+ say join ",\n", map { " $_" } @munged_columns;
 137+ say "FROM $table;";
 138+ say "";
 139+ }
 140+
130141 push @{ $created_views{ $table} } => $view_name;
131142 }
132143
@@ -154,7 +165,11 @@
155166 say "";
156167
157168 for my $view (@views) {
158 - say qq[INSERT INTO geometry_columns VALUES ('', 'public', '$view', 'way', 2, 900913, '$type');];
 169+ if ($delete) {
 170+ say qq[DELETE FROM geometry_columns WHERE f_table_catalog = '' AND f_table_schema = 'public' AND f_table_name = '$view' AND f_geometry_column = 'way' AND coord_dimension = 2 AND srid = 900913 AND type = '$type';];
 171+ } else {
 172+ say qq[INSERT INTO geometry_columns VALUES ('', 'public', '$view', 'way', 2, 900913, '$type');];
 173+ }
159174 }
160175 }
161176

Status & tagging log