From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: proposal: function parse_ident |
Date: | 2015-09-16 04:49:33 |
Message-ID: | CAFj8pRBfXOvCUQiLRzQyrH_khv2zbX1ic-6Y32Qr+Unmhpx8aA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2015-09-16 2:41 GMT+02:00 Peter Eisentraut <peter_e(at)gmx(dot)net>:
> On 9/11/15 6:25 AM, Pavel Stehule wrote:
> > new update of parse_ident function patch
>
> How would you actually use this?
>
> I know several people have spoken up that they could use this, but could
> you provide a few actual practical examples?
>
>
I see two basic use cases
1. processing user input with little bit more comfort - the user doesn't
need to separate schema and table
CREATE OR REPLACE FUNCTION createtable(tablename text)
RETURNS void AS $$
DECLARE names text[];
BEGIN
names := parse_ident(tablename);
IF array_length(names) > 2 || array_length(names) = 0 THEN
RAISE EXCEPTION 'wrong identifier';
END IF;
IF names[2] IS NOT NULL THEN
CREATE SCHEMA IF NOT EXISTS names[2];
END IF;
CREATE TABLE tablename;
END;
$$ LANGUAGE plpgsql;
2. parsing error messages or some automatic variables
Regards
Pavel
From | Date | Subject | |
---|---|---|---|
Next Message | Yugo Nagata | 2015-09-16 05:02:30 | T_PrivGrantee is left in NodeTag |
Previous Message | Jeff Janes | 2015-09-16 04:30:11 | Re: [PATCH] Microvacuum for gist. |