[Commits] 015994f: MDEV-7515 GIS: No AddGeometryColumn or DropGeometryColumn in the tree.

holyfoot at askmonty.org holyfoot at askmonty.org
Tue Mar 17 12:46:24 EET 2015


revision-id: 015994f226cfa94e6d339fdc0de670a054f631b4
parent(s): ccc7297fe94af1129c717f91d31fa075d54a0371
committer: Alexey Botchkov
branch nick: 10.1
timestamp: 2015-03-17 14:44:59 +0400
message:

MDEV-7515 GIS: No AddGeometryColumn or DropGeometryColumn in the tree.

Installation scripts added to setup the required SP-s with the mysql_install_db.

---
 scripts/maria_add_gis_sp.sql           |  6 ++++--
 scripts/maria_add_gis_sp_bootstrap.sql | 34 ++++++++++++++++++++++++++++++++++
 scripts/mysql_install_db.pl.in         | 29 ++++++++++++++++++++++++++++-
 scripts/mysql_install_db.sh            | 14 +++++++++++++-
 4 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/scripts/maria_add_gis_sp.sql b/scripts/maria_add_gis_sp.sql
index fbaef70..8ddc7ab 100644
--- a/scripts/maria_add_gis_sp.sql
+++ b/scripts/maria_add_gis_sp.sql
@@ -13,9 +13,11 @@
 -- along with this program; if not, write to the Free Software
 -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
-# This part created stored procedures required by the OpenGIS standards.
 
-# Proc privilege is needed to run it.
+-- This part creates stored procedures required by the OpenGIS standards.
+-- Proc privilege is needed to run it.
+-- To use this file, load its contents into the mysql database like that:
+--     mysql -u root -p mysql < scripts/maria_add_gis_sp.sql
 
 SET sql_mode='';
 
diff --git a/scripts/maria_add_gis_sp_bootstrap.sql b/scripts/maria_add_gis_sp_bootstrap.sql
new file mode 100644
index 0000000..063b665
--- /dev/null
+++ b/scripts/maria_add_gis_sp_bootstrap.sql
@@ -0,0 +1,34 @@
+-- Copyright (C) 2014 MariaDB Ab.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; version 2 of the License.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program; if not, write to the Free Software
+-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
+# This part creates stored procedures required by the OpenGIS standards.
+# script is prepared to be run with the --bootstrap server option
+
+SET sql_mode='';
+
+DROP PROCEDURE IF EXISTS AddGeometryColumn;
+DROP PROCEDURE IF EXISTS DropGeometryColumn;
+
+CREATE PROCEDURE AddGeometryColumn(catalog varchar(64), t_schema varchar(64),
+   t_name varchar(64), geometry_column varchar(64), t_srid int)
+begin
+  set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' ADD ', geometry_column,' GEOMETRY REF_SYSTEM_ID=', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end;
+
+CREATE PROCEDURE DropGeometryColumn(catalog varchar(64), t_schema varchar(64),
+   t_name varchar(64), geometry_column varchar(64))
+begin
+  set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' DROP ', geometry_column); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end;
+
+
diff --git a/scripts/mysql_install_db.pl.in b/scripts/mysql_install_db.pl.in
index 4d36413..8a3492c 100644
--- a/scripts/mysql_install_db.pl.in
+++ b/scripts/mysql_install_db.pl.in
@@ -348,8 +348,9 @@ if ( $opt->{srcdir} )
 my $fill_help_tables     = "$pkgdatadir/fill_help_tables.sql";
 my $create_system_tables = "$pkgdatadir/mysql_system_tables.sql";
 my $fill_system_tables   = "$pkgdatadir/mysql_system_tables_data.sql";
+my $maria_add_gis_sp     = "$pkgdatadir/maria_add_gis_sp_bootstrap.sql";
 
-foreach my $f ( $fill_help_tables,$create_system_tables,$fill_system_tables )
+foreach my $f ( $fill_help_tables,$create_system_tables,$fill_system_tables,$maria_add_gis_sp )
 {
   -f $f or cannot_find_file($f);
 }
@@ -496,6 +497,32 @@ if ( open(PIPE, "| $mysqld_install_cmd_line") )
                  "The \"HELP\" command might not work properly");
   }
 
+  # ----------------------------------------------------------------------
+  # Pipe maria_add_gis_sp.sql to "mysqld --bootstrap"
+  # ----------------------------------------------------------------------
+
+  report_verbose_wait($opt,"Creating OpenGIS required SP-s...");
+  open(SQL, $maria_add_gis_sp)
+    or error($opt,"can't open $maria_add_gis_sp for reading: $!");
+  # FIXME  > /dev/null ?
+  if ( open(PIPE, "| $mysqld_install_cmd_line") )
+  {
+    print PIPE "use test;\n";
+    while ( <SQL> )
+    {
+      print PIPE $_;
+    }
+    close PIPE;
+    close SQL;
+
+    report_verbose($opt,"OK");
+  }
+  else
+  {
+    warning($opt,"OPENGIS REQUIRED SP-S WERE NOT COMPLETELY INSTALLED!",
+                 "GIS extentions might not work properly");
+  }
+
   report_verbose($opt,"To start mysqld at boot time you have to copy",
                       "support-files/mysql.server to the right place " .
                       "for your system");
diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh
index cce9623..15750ff 100644
--- a/scripts/mysql_install_db.sh
+++ b/scripts/mysql_install_db.sh
@@ -307,8 +307,9 @@ fill_help_tables="$pkgdatadir/fill_help_tables.sql"
 create_system_tables="$pkgdatadir/mysql_system_tables.sql"
 create_system_tables2="$pkgdatadir/mysql_performance_tables.sql"
 fill_system_tables="$pkgdatadir/mysql_system_tables_data.sql"
+maria_add_gis_sp="$pkgdatadir/maria_add_gis_sp_bootstrap.sql"
 
-for f in "$fill_help_tables" "$create_system_tables" "$create_system_tables2" "$fill_system_tables"
+for f in "$fill_help_tables" "$create_system_tables" "$create_system_tables2" "$fill_system_tables" "$maria_add_gis_sp"
 do
   if test ! -f "$f"
   then
@@ -469,6 +470,17 @@ else
   echo "The \"HELP\" command might not work properly."
 fi
 
+s_echo "Creating OpenGIS required SP-s..."
+if { echo "use test;"; cat "$maria_add_gis_sp"; } | mysqld_install_cmd_line > /dev/null
+then
+  s_echo "OK"
+else
+  echo
+  echo "WARNING: OPENGIS REQUIRED SP-S WERE NOT COMPLETELY INSTALLED!"
+  echo "GIS extentions might not work properly."
+fi
+
+
 # Don't output verbose information if running inside bootstrap or using
 # --srcdir for testing.  In such cases, there's no end user looking at
 # the screen.


More information about the commits mailing list