internal quoting
authorMarko Kreen <markokr@gmail.com>
Mon, 17 Sep 2007 14:28:13 +0000 (14:28 +0000)
committerMarko Kreen <markokr@gmail.com>
Mon, 17 Sep 2007 14:28:13 +0000 (14:28 +0000)
sql/londiste/functions/londiste.quote_fqname.sql [new file with mode: 0644]

diff --git a/sql/londiste/functions/londiste.quote_fqname.sql b/sql/londiste/functions/londiste.quote_fqname.sql
new file mode 100644 (file)
index 0000000..e14168d
--- /dev/null
@@ -0,0 +1,21 @@
+
+create or replace function londiste.quote_fqname(i_name text)
+returns text as $$
+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;
+