Re: Open 7.3 items - Mailing list pgsql-hackers

From Hannu Krosing
Subject Re: Open 7.3 items
Date
Msg-id 1029305519.3100.82.camel@rh72.home.ee
Whole thread Raw
In response to Re: Open 7.3 items  (Sean Chittenden <sean@chittenden.org>)
Responses Re: Open 7.3 items
List pgsql-hackers
On Wed, 2002-08-14 at 12:45, Sean Chittenden wrote:
> > > > > Well, they aren't separate fields so you can't ORDER BY domain.  The dot
> > > > > was used so it looks like a schema based on dbname.
> > 
> > IMHO it should look like an user in domain ;)
> 
> Agreed, but there is something to be said for doing a sort of users
> per domain.  This wouldn't be an issue, I don't think, if there was a
> split_before() and split_after() like functions.
> 
> # SELECT split_before('user@domain.com','@'), split_after('user@domain.com', '@');
>  ?column? |  ?column?
> ----------+------------
>  user     | domain.com
> 
> What would you guys say to submissions for a patch that would add the
> function listed above? 

create function split_before(text,text) returns text as 'select case when (strpos($1,$2) > 0)            then
substr($1,1,strpos($1,$2)-1)           else $1             end as usename
 
' language 'SQL';

create function split_after(text,text) returns text as 'select case when (strpos($1,$2) > 0)            then
substr($1,strpos($1,$2)+1)           else ''''             end as usedomain
 
' language 'SQL' ;

hannu=# select split_before('me@somewhere','@'),
split_after('me@somewhere','@');split_before | split_after 
--------------+-------------me           | somewhere
(1 row)

-------------
Hannu



pgsql-hackers by date:

Previous
From: Sean Chittenden
Date:
Subject: Re: Open 7.3 items
Next
From: "Christopher Kings-Lynne"
Date:
Subject: contrib Makefiles