Re: to_char incompatibility

From: "Roberts, Jon" <Jon(dot)Roberts(at)asurion(dot)com>
To: 'Pavel Stehule' <pavel(dot)stehule(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: to_char incompatibility
Date: 2008-01-10 15:38:42
Message-ID: 1A6E6D554222284AB25ABE3229A927627153EB@nrtexcus702.int.asurion.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I always put security definer as I really think that should be the default
behavior. Anyway, your function should run faster.

Jon

> -----Original Message-----
> From: Pavel Stehule [mailto:pavel(dot)stehule(at)gmail(dot)com]
> Sent: Thursday, January 10, 2008 8:47 AM
> To: Roberts, Jon
> Cc: Peter Eisentraut; pgsql-hackers(at)postgresql(dot)org
> Subject: Re: [HACKERS] to_char incompatibility
>
> small non important note: your function is very expensive
>
> exactly same but faster is:
>
> CREATE OR REPLACE FUNCTION fn_to_date(p_date varchar, p_format varchar)
> RETURNS timestamp AS $$
> SELECT to_timestamp(replace($1, ' ', ''), replace($2, ' ', ''));
> $$ LANGUAGE SQL STRICT IMMUTABLE;
>
> or
>
> CREATE OR REPLACE FUNCTION fn_to_date(p_date varchar, p_format varchar)
> RETURNS timestamp AS $$
> BEGIN
> RETURN to_timestamp(replace(p_date, ' ', ''), replace(p_format, ' ',
> ''));
> END$$ LANGUAGE SQL STRICT IMMUTABLE;
>
> there isn't any reason for using security definer and you forgot
> IMMUTABLE,
>
> Regards
> Pavel Stehule

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Stark 2008-01-10 15:45:30 Re: flex/bison output wrongly created in the source directory
Previous Message Tom Lane 2008-01-10 15:36:24 Re: tag REL8_2_6 not present in file xyz