> 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