Re: proposal: function parse_ident - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: proposal: function parse_ident
Date
Msg-id CAFj8pRBfXOvCUQiLRzQyrH_khv2zbX1ic-6Y32Qr+Unmhpx8aA@mail.gmail.com
Whole thread Raw
In response to Re: proposal: function parse_ident  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: proposal: function parse_ident
List pgsql-hackers
<div dir="ltr"><br /><div class="gmail_extra"><br /><div class="gmail_quote">2015-09-16 2:41 GMT+02:00 Peter Eisentraut
<spandir="ltr"><<a href="mailto:peter_e@gmx.net" target="_blank">peter_e@gmx.net</a>></span>:<br /><blockquote
class="gmail_quote"style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 9/11/15 6:25
AM,Pavel Stehule wrote:<br /> > new update of parse_ident function patch<br /><br /></span>How would you actually
usethis?<br /><br /> I know several people have spoken up that they could use this, but could<br /> you provide a few
actualpractical examples?<br /><br /></blockquote></div><br /></div><div class="gmail_extra">I see two basic use
cases<br/><br /></div><div class="gmail_extra">1. processing user input with little bit more comfort - the user doesn't
needto separate schema and table<br /></div><div class="gmail_extra"><br /></div><div class="gmail_extra">CREATE OR
REPLACEFUNCTION createtable(tablename text)<br /></div><div class="gmail_extra">RETURNS void AS $$<br /></div><div
class="gmail_extra">DECLAREnames text[];<br />BEGIN<br /></div><div class="gmail_extra">  names :=
parse_ident(tablename);<br/></div><div class="gmail_extra">  IF array_length(names) > 2 || array_length(names) = 0
THEN<br/></div><div class="gmail_extra">    RAISE EXCEPTION 'wrong identifier';<br /></div><div class="gmail_extra"> 
ENDIF;<br /></div><div class="gmail_extra">  IF names[2] IS NOT NULL THEN<br /></div><div class="gmail_extra">    
CREATESCHEMA IF NOT EXISTS names[2];<br /></div><div class="gmail_extra">  END IF;<br /></div><div
class="gmail_extra"> CREATE TABLE tablename;<br /></div><div class="gmail_extra">END;<br /></div><div
class="gmail_extra">$$LANGUAGE plpgsql;<br /></div><div class="gmail_extra"><br /></div><div class="gmail_extra">2.
parsingerror messages or some automatic variables<br /><br /></div><div class="gmail_extra">Regards<br /><br
/></div><divclass="gmail_extra">Pavel<br /></div></div> 

pgsql-hackers by date:

Previous
From: Jeff Janes
Date:
Subject: Re: [PATCH] Microvacuum for gist.
Next
From: Yugo Nagata
Date:
Subject: T_PrivGrantee is left in NodeTag