How can this be legal syntax - Mailing list pgsql-sql

From Asko Oja
Subject How can this be legal syntax
Date
Msg-id ecd779860812160900y3acfef7aj14de2d2f61af1d75@mail.gmail.com
Whole thread Raw
Responses Re: How can this be legal syntax  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-sql
I was quite amazed to find that this piece of code actually works while reviewing code.<br />I would prefer if it gave
anerror :)<br /><br />test=# create or replace function test(i_input text) returns text as <br />$$<br
/>declare                                         <br />     result text;<br />begin           <br />    SELECT<br
/>       CASE<br />        WHEN lower(i_input) ~ '^[a-z]' THEN 'S'<br />        WHEN i_input ~ '[0-9]' THEN 'N' <br
/>       ELSE 'ERROR'<br />         INTO result<br />        END;<br />    return result;<br />end;              <br
/>$$<br />language plpgsql security definer;<br />CREATE FUNCTION<br />test=# select * from test('aaaa' );<br /> test
<br/>------<br /> S<br />(1 row)<br /><br />test=# create or replace function test(i_input text) returns text as $$<br
/>declare<br/>    result text;<br />begin<br />    SELECT<br />        CASE<br />        WHEN lower(i_input) ~ '^[a-z]'
INTOresult THEN 'S'<br />         WHEN i_input ~ '[0-9]' THEN 'N' <br />        ELSE 'ERROR'<br />        END;<br />   
returnresult;<br />end;<br />$$ language plpgsql security definer;<br />CREATE FUNCTION<br />test=# select * from
test('aaaa');<br />  test <br />------<br /> S<br />(1 row)<br /> 

pgsql-sql by date:

Previous
From: "George Pavlov"
Date:
Subject: Re: create table with rownames as values in column of seciond table
Next
From: Alvaro Herrera
Date:
Subject: Re: How can this be legal syntax