From: | "James Harper" <james(dot)harper(at)bendigoit(dot)com(dot)au> |
---|---|
To: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: implicit cast of empty string to timestamp |
Date: | 2006-02-10 10:16:39 |
Message-ID: | AEC6C66638C05B468B556EA548C1A77DAF0812@trantor |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Ludek Finstrle | 2006-02-10 10:24:26 | Re: Problem using ODBC from .NET framework |
Previous Message | Tham Shiming | 2006-02-10 09:42:40 | Dropping a database that does not exist |