Search Postgresql Archives

Re: implicit cast of empty string to timestamp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> am  10.02.2006, um 20:22:57 +1100 mailte James Harper folgendes:
> > Is there anything I can do to make postgres allow an implicit cast
of an
> > empty string to a timestamp, so that a badly behaved application can
do:
> 
> > INSERT INTO SomeTable (timestampfield) VALUES ('')
> 
> You can't insert a empty string into a timestamp, IIRC.

No, and if someone tries I want to put a NULL in there.

I had hoped the following might work (syntax is from memory):

CREATE SCHEMA fnord;
SET search_path TO fnord;
CREATE FUNCTION fnord.timestamp (text) RETURNS timestamp LANGUAGE SQL AS
$$
SELECT pg_catalog.timestamp('20010101') $$;

SELECT CAST(text '20060101' AS timestamp);
SELECT CAST(text '' AS timestamp);

I had hoped that my 'timestamp' function would have overridden the
unqualified function call in the cast, but it was not to be :(

Curiously tho, \df didn't even acknowledge the 'timestamp' function in
the database, even though it was in the pg_proc's table.

Oh well.

James



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux