From 5ea1b7d4d7967de910f70703cf1b2af372e40429 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Mon, 21 Sep 2015 14:13:50 +0200 Subject: [PATCH] Fix creation of type _cdb_has_usable_geom_record Fix the ERROR: type "_cdb_has_usable_geom_record" already exists by checking for existence before. Duly noted for upgrades. --- scripts-available/CDB_CartodbfyTable.sql | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts-available/CDB_CartodbfyTable.sql b/scripts-available/CDB_CartodbfyTable.sql index 158dd04..2e44e9a 100644 --- a/scripts-available/CDB_CartodbfyTable.sql +++ b/scripts-available/CDB_CartodbfyTable.sql @@ -688,16 +688,20 @@ BEGIN END; $$ LANGUAGE 'plpgsql'; - -CREATE TYPE _cdb_has_usable_geom_record - AS (has_usable_geoms boolean, - text_geom_column boolean, - text_geom_column_name text, - text_geom_column_srid boolean, - has_geom boolean, - has_geom_name text, - has_mercgeom boolean, - has_mercgeom_name text); +DO $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = '_cdb_has_usable_geom_record') THEN + CREATE TYPE _cdb_has_usable_geom_record + AS (has_usable_geoms boolean, + text_geom_column boolean, + text_geom_column_name text, + text_geom_column_srid boolean, + has_geom boolean, + has_geom_name text, + has_mercgeom boolean, + has_mercgeom_name text); + END IF; +END$$; DROP FUNCTION IF EXISTS _CDB_Has_Usable_Geom(REGCLASS); CREATE OR REPLACE FUNCTION _CDB_Has_Usable_Geom(reloid REGCLASS)