2015-09-16 2:41 GMT+02:00 Peter Eisentraut <pete...@gmx.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