Re: implicit cast of empty string to timestamp

Поиск
Список
Период
Сортировка
От James Harper
Тема Re: implicit cast of empty string to timestamp
Дата
Msg-id AEC6C66638C05B468B556EA548C1A77DAF0812@trantor
обсуждение исходный текст
Ответ на implicit cast of empty string to timestamp  ("James Harper" <james.harper@bendigoit.com.au>)
Список 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


В списке pgsql-general по дате отправления:

Предыдущее
От: "A. Kretschmer"
Дата:
Сообщение: Re: implicit cast of empty string to timestamp
Следующее
От: "James Harper"
Дата:
Сообщение: Re: implicit cast of empty string to timestamp