Add cdb_extension_reload() utility function

This commit is contained in:
Sandro Santilli 2014-06-04 10:28:48 +02:00
parent c286727181
commit a92d7d7d37
4 changed files with 24 additions and 0 deletions

View File

@ -9,6 +9,7 @@ CDBSCRIPTS = \
scripts-available/CDB_SearchPath.sql \
scripts-available/CDB_DDLTriggers.sql \
scripts-available/CDB_ExtensionPost.sql \
scripts-available/CDB_ExtensionUtils.sql \
$(END)
UPGRADABLE = \

4
NEWS
View File

@ -13,6 +13,10 @@ Enhancements:
- Include revision info in cdb_version() output (#34)
New features:
- Add a cdb_extension_reload() function
0.1.0 - 2014-05-23
------------------

View File

@ -95,3 +95,9 @@ to "V". Example to upgrade a 0.2.0dev version:
ALTER EXTENSION cartodb UPDATE TO '0.2.0devnext';
ALTER EXTENSION cartodb UPDATE TO '0.2.0dev';
```
Starting with 0.2.0, the in-place reload can be done with an ad-hoc function:
```sql
SELECT cartodb.cdb_extension_reload();
```

View File

@ -0,0 +1,13 @@
CREATE OR REPLACE FUNCTION cartodb.cdb_extension_reload() RETURNS void
AS $$
DECLARE
ver TEXT;
sql TEXT;
BEGIN
ver := split_part(cartodb.cdb_version(), ' ', 1);
sql := 'ALTER EXTENSION cartodb UPDATE TO ''' || ver || 'next''';
EXECUTE sql;
sql := 'ALTER EXTENSION cartodb UPDATE TO ''' || ver || '''';
EXECUTE sql;
END;
$$ language 'plpgsql' VOLATILE;