From 58b2705383197951d1c41ee82a904cbda80780be Mon Sep 17 00:00:00 2001 From: Guido Fioravantti Date: Mon, 26 Oct 2015 18:35:12 +0100 Subject: [PATCH] Rename relname to colname in _CDB_Unique_Column_Identifier --- scripts-available/CDB_Helper.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts-available/CDB_Helper.sql b/scripts-available/CDB_Helper.sql index 6338b67..3cf97ff 100644 --- a/scripts-available/CDB_Helper.sql +++ b/scripts-available/CDB_Helper.sql @@ -60,8 +60,8 @@ $$ LANGUAGE 'plpgsql'; -- UTF8 safe and lenght aware. Find a unique identifier for a column with a given prefix --- and/or suffix and withing a realtion. -CREATE OR REPLACE FUNCTION cartodb._CDB_Unique_Column_Identifier(prefix TEXT, relname TEXT, suffix TEXT, reloid REGCLASS) +-- and/or suffix based on colname and within a relation specified via reloid. +CREATE OR REPLACE FUNCTION cartodb._CDB_Unique_Column_Identifier(prefix TEXT, colname TEXT, suffix TEXT, reloid REGCLASS) RETURNS TEXT AS $$ DECLARE @@ -79,13 +79,13 @@ BEGIN usedspace := usedspace + coalesce(octet_length(prefix), 0); usedspace := usedspace + coalesce(octet_length(suffix), 0); - relname := _CDB_Octet_Truncate(relname, maxlen - usedspace); + colname := _CDB_Octet_Truncate(colname, maxlen - usedspace); - IF relname = '' THEN + IF colname = '' THEN PERFORM _CDB_Error('prefixes are to long to generate a valid identifier', '_CDB_Unique_Column_Identifier'); END IF; - ident := coalesce(prefix, '') || relname || coalesce(suffix, ''); + ident := coalesce(prefix, '') || colname || coalesce(suffix, ''); i := 0; origident := ident;