Re: to_char incompatibility - Mailing list pgsql-hackers

From Roberts, Jon
Subject Re: to_char incompatibility
Date
Msg-id 1A6E6D554222284AB25ABE3229A927627153EB@nrtexcus702.int.asurion.com
Whole thread Raw
In response to to_char incompatibility  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: to_char incompatibility  (Josh Berkus <josh@agliodbs.com>)
List 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.stehule@gmail.com]
> Sent: Thursday, January 10, 2008 8:47 AM
> To: Roberts, Jon
> Cc: Peter Eisentraut; pgsql-hackers@postgresql.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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: tag REL8_2_6 not present in file xyz
Next
From: Gregory Stark
Date:
Subject: Re: flex/bison output wrongly created in the source directory