Re: Open 7.3 items

From: Sean Chittenden <sean(at)chittenden(dot)org>
To: Hannu Krosing <hannu(at)tm(dot)ee>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Open 7.3 items
Date: 2002-08-14 09:03:42
Message-ID: 20020814090342.GG61893@ninja1.internal
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > > > > > 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(at)domain(dot)com','@'), split_after('user(at)domain(dot)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(at)somewhere','@'),
> split_after('me(at)somewhere','@');
> split_before | split_after
> --------------+-------------
> me | somewhere
> (1 row)

Oh that was handy and fast! I didn't know of strpos(). Cool, who
says 'ya can't learn something every day? :~) Now with an alias or
subselect, it should be very easy to order users in a domain in any
way that SQL allows. :~) Thanks Hannu. -sc

--
Sean Chittenden

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Rod Taylor 2002-08-14 11:55:52 Re: Domains and Indexes
Previous Message Oliver Elphick 2002-08-14 09:03:11 Re: anoncvs - here we go again!