1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
create or replace function londiste.quote_fqname(i_name text)
returns text as $$
-- ----------------------------------------------------------------------
-- Function: londiste.quote_fqname(1)
--
-- Quete fully-qualified object name for SQL.
--
-- First dot is taken as schema separator.
--
-- If schema is missing, 'public' is assumed.
--
-- Parameters:
-- i_name - fully qualified object name.
--
-- Returns:
-- Quoted name.
-- ----------------------------------------------------------------------
declare
res text;
pos integer;
s text;
n text;
begin
pos := position('.' in i_name);
if pos > 0 then
s := substring(i_name for pos - 1);
n := substring(i_name from pos + 1);
else
s := 'public';
n := i_name;
end if;
return quote_ident(s) || '.' || quote_ident(n);
end;
$$ language plpgsql strict immutable;
|