[postgis-tickets] [SCM] PostGIS branch master updated. 3.3.0rc2-324-gf3dfb23ae
git at osgeo.org
git at osgeo.org
Tue Nov 8 01:30:12 PST 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".
The branch, master has been updated
via f3dfb23ae2815e7a709d4933303a234085ed55db (commit)
from bcca50bd5278ea3181df3f2114b2bfe4f94b64db (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit f3dfb23ae2815e7a709d4933303a234085ed55db
Author: Sandro Santilli <strk at kbt.io>
Date: Tue Nov 8 10:25:08 2022 +0100
RenameTopology function
Closes #5283
Includes documentation and regress test
diff --git a/NEWS b/NEWS
index 6dfb6e337..d03b84bfd 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ xxxx/xx/xx
- New install-extension-upgrades command in postgis script (Sandro Santilli)
- #5257, #5261, #5277, Support changes for PostgreSQL 16 (Regina Obe)
- #5006, GH705, ST_Transform: Support PROJ pipelines (Robert Coup, Koordinates)
+ - #5283, RenameTopology (Sandro Santilli)
* Enhancements *
- #5194, do not update system catalogs from postgis_extensions_upgrade (Sandro Santilli)
diff --git a/doc/extras_topology.xml b/doc/extras_topology.xml
index 55eb59eec..062bf9393 100644
--- a/doc/extras_topology.xml
+++ b/doc/extras_topology.xml
@@ -393,6 +393,54 @@ SELECT topology.AddTopoGeometryColumn('ri_topo', 'ri', 'roads', 'topo', 'LINE');
<para><xref linkend="DropTopoGeometryColumn"/></para>
</refsection>
</refentry>
+ <refentry id="RenameTopology">
+ <refnamediv>
+ <refname>RenameTopology</refname>
+ <refpurpose>Renames a topology</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>varchar <function>RenameTopology</function></funcdef>
+ <paramdef><type>varchar </type> <parameter>old_name</parameter></paramdef>
+ <paramdef><type>varchar </type> <parameter>new_name</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ </refsynopsisdiv>
+
+ <refsection>
+ <title>Description</title>
+
+ <para>
+Renames a topology schema updating its metadata record in
+topology.topology.
+ </para>
+
+ <!-- use this format if new function -->
+ <para>Availability: 3.4.0</para>
+ </refsection>
+
+
+ <refsection>
+ <title>Examples</title>
+ <para>
+This example renames a topology from <varname>topo_stage</varname> to
+<varname>topo_prod</varname>.
+ </para>
+ <programlisting>SELECT topology.RenameTopology('topo_stage', 'topo_prod');</programlisting>
+
+ </refsection>
+
+ <!-- Optionally add a "See Also" section -->
+ <refsection>
+ <title>See Also</title>
+
+ <para>>
+ <xref linkend="CopyTopology" />
+ </para>
+ </refsection>
+ </refentry>
<refentry id="DropTopoGeometryColumn">
<refnamediv>
<refname>DropTopoGeometryColumn</refname>
@@ -1156,7 +1204,11 @@ This example makes a backup of a topology called ma_topo
<refsection>
<title>See Also</title>
- <para><xref linkend="spatial_ref_sys"/>, <xref linkend="CreateTopology" /></para>
+ <para>
+ <xref linkend="spatial_ref_sys"/>,
+ <xref linkend="CreateTopology" />,
+ <xref linkend="RenameTopology" />
+ </para>
</refsection>
</refentry>
diff --git a/topology/Makefile.in b/topology/Makefile.in
index 6420be1e2..fc6ffefd4 100644
--- a/topology/Makefile.in
+++ b/topology/Makefile.in
@@ -139,6 +139,7 @@ topology.sql: \
sql/manage/FindLayer.sql.in \
sql/manage/FindTopology.sql.in \
sql/manage/ManageHelper.sql.in \
+ sql/manage/RenameTopology.sql.in \
sql/manage/ValidateTopology.sql.in \
sql/manage/ValidateTopologyRelation.sql.in \
sql/topoelement/topoelement_agg.sql.in \
diff --git a/topology/sql/manage/RenameTopology.sql.in b/topology/sql/manage/RenameTopology.sql.in
new file mode 100644
index 000000000..2364340e4
--- /dev/null
+++ b/topology/sql/manage/RenameTopology.sql.in
@@ -0,0 +1,43 @@
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+--
+-- PostGIS - Spatial Types for PostgreSQL
+-- http://postgis.net
+--
+-- Copyright (C) 2022 Sandro Santilli <strk at kbt.io>
+--
+-- This is free software; you can redistribute and/or modify it under
+-- the terms of the GNU General Public Licence. See the COPYING file.
+--
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+--{
+-- RenameTopology(old_name, new_name)
+--
+-- Renames a topology, returns new name.
+--
+CREATE OR REPLACE FUNCTION topology.RenameTopology(old_name varchar, new_name varchar)
+RETURNS varchar
+AS
+$BODY$
+DECLARE
+ sql text;
+BEGIN
+
+ sql := format(
+ 'ALTER SCHEMA %I RENAME TO %I',
+ old_name, new_name
+ );
+ EXECUTE sql;
+
+ sql := format(
+ 'UPDATE topology.topology SET name = %L WHERE name = %L',
+ new_name, old_name
+ );
+ EXECUTE sql;
+
+ RETURN new_name;
+END
+$BODY$
+LANGUAGE 'plpgsql' VOLATILE STRICT;
+--
+--} RenameTopology
diff --git a/topology/test/regress/renametopology.sql b/topology/test/regress/renametopology.sql
new file mode 100644
index 000000000..e19ff01b8
--- /dev/null
+++ b/topology/test/regress/renametopology.sql
@@ -0,0 +1,6 @@
+BEGIN;
+SELECT NULL FROM topology.CreateTopology('topo');
+SELECT 't1', topology.RenameTopology('topo', 'topo with space');
+SELECT 't2', topology.RenameTopology('topo with space', 'topo with MixedCase');
+SELECT 't2', topology.RenameTopology('topo with MixedCase', 'topo');
+ROLLBACK;
diff --git a/topology/test/regress/renametopology_expected b/topology/test/regress/renametopology_expected
new file mode 100644
index 000000000..bae8b6092
--- /dev/null
+++ b/topology/test/regress/renametopology_expected
@@ -0,0 +1,3 @@
+t1|topo with space
+t2|topo with MixedCase
+t2|topo
diff --git a/topology/topology.sql.in b/topology/topology.sql.in
index 27ae06595..197f72274 100644
--- a/topology/topology.sql.in
+++ b/topology/topology.sql.in
@@ -1415,6 +1415,7 @@ LANGUAGE 'plpgsql' VOLATILE STRICT;
#include "sql/manage/CopyTopology.sql.in"
#include "sql/manage/FindTopology.sql.in"
#include "sql/manage/FindLayer.sql.in"
+#include "sql/manage/RenameTopology.sql.in"
#include "sql/manage/ValidateTopology.sql.in"
#include "sql/manage/ValidateTopologyRelation.sql.in"
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
doc/extras_topology.xml | 54 ++++++++++++++++++++++++++-
topology/Makefile.in | 1 +
topology/sql/manage/RenameTopology.sql.in | 43 +++++++++++++++++++++
topology/test/regress/renametopology.sql | 6 +++
topology/test/regress/renametopology_expected | 3 ++
topology/topology.sql.in | 1 +
7 files changed, 108 insertions(+), 1 deletion(-)
create mode 100644 topology/sql/manage/RenameTopology.sql.in
create mode 100644 topology/test/regress/renametopology.sql
create mode 100644 topology/test/regress/renametopology_expected
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list