Re: Procedure for feature requests?

From: Martin Gainty <mgainty(at)hotmail(dot)com>
To: Sam Mason <sam(at)samason(dot)me(dot)uk>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Procedure for feature requests?
Date: 2009-10-03 16:14:19
Message-ID: BLU142-W108163601A9B7C24761566AED10@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


is there a way to create a cast with assignment e.g.?
CREATE CAST ((date,date) AS int4) WITH FUNCTION generate_series(date,date) AS ASSIGNMENT;http://www.postgresql.org/docs/8.4/static/sql-createcast.html
?
Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.

> Date: Sat, 3 Oct 2009 16:23:36 +0100
> From: sam(at)samason(dot)me(dot)uk
> To: pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] Procedure for feature requests?
>
> On Fri, Oct 02, 2009 at 09:48:14PM +0000, Tim Landscheidt wrote:
> > Sam Mason <sam(at)samason(dot)me(dot)uk> wrote:
> > > 8.4 has a generate_series(timestamp,timestamp,interval) which would seem
> > > to be a bit more flexible than you want.
> >
> > Yes, I know :-). But as "generate_series(A, B, C)" can also
> > be written as "A + generate_series(0, (C - B) / C) * C" (or
> > something "flexible" like that :-)), a
>
> For things as complicated as timestamps I'm not sure if this is such a
> trivial transform. If you can figure out the limit then it seems easy,
> though I'm not sure how you'd do that.
>
> > "generate_series(DATE, DATE)" would inter alia get rid off
> > the need to cast the result from TIMESTAMP to DATE and to
> > explicitly specify "'1 day'". Just a small, trivial enhance-
> > ment for a popular use case :-).
>
> Interesting, I tend to aim for maximum expressiveness not ease of
> expressiveness. It would be somewhat easy to add the above if you want
> though:
>
> CREATE FUNCTION generate_series(date,date)
> RETURNS SETOF date
> IMMUTABLE LANGUAGE sql AS $$
> SELECT generate_series($1::timestamp,$2::timestamp,interval '1 day')::date;
> $$;
>
> or I suppose you could use the integer series generation:
>
> SELECT $1 + generate_series(0,$2 - $1);
>
> Hum, now I'll have to see which is "better".
>
> That second version seems to be slightly quicker (20 to 30%, for ranges
> from a year up to a century respectively) so you may prefer it, but the
> difference is going to be in the noise for any query I've ever used
> generate_series for.
>
> --
> Sam http://samason.me.uk/
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/171222986/direct/01/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2009-10-03 16:19:09 Re: PostgreSQL reads each 8k block - no larger blocks are used - even on sequential scans
Previous Message Greg Stark 2009-10-03 16:05:39 Re: How useful is the money datatype?