Rename relname to colname in _CDB_Unique_Column_Identifier

This commit is contained in:
Guido Fioravantti 2015-10-26 18:35:12 +01:00
parent 8734608792
commit 58b2705383

View File

@ -60,8 +60,8 @@ $$ LANGUAGE 'plpgsql';
-- UTF8 safe and lenght aware. Find a unique identifier for a column with a given prefix -- UTF8 safe and lenght aware. Find a unique identifier for a column with a given prefix
-- and/or suffix and withing a realtion. -- and/or suffix based on colname and within a relation specified via reloid.
CREATE OR REPLACE FUNCTION cartodb._CDB_Unique_Column_Identifier(prefix TEXT, relname TEXT, suffix TEXT, reloid REGCLASS) CREATE OR REPLACE FUNCTION cartodb._CDB_Unique_Column_Identifier(prefix TEXT, colname TEXT, suffix TEXT, reloid REGCLASS)
RETURNS TEXT RETURNS TEXT
AS $$ AS $$
DECLARE DECLARE
@ -79,13 +79,13 @@ BEGIN
usedspace := usedspace + coalesce(octet_length(prefix), 0); usedspace := usedspace + coalesce(octet_length(prefix), 0);
usedspace := usedspace + coalesce(octet_length(suffix), 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'); PERFORM _CDB_Error('prefixes are to long to generate a valid identifier', '_CDB_Unique_Column_Identifier');
END IF; END IF;
ident := coalesce(prefix, '') || relname || coalesce(suffix, ''); ident := coalesce(prefix, '') || colname || coalesce(suffix, '');
i := 0; i := 0;
origident := ident; origident := ident;