Bug #761: Date format ambiguity while insertion!!!!

Поиск
Список
Период
Сортировка
От pgsql-bugs@postgresql.org
Тема Bug #761: Date format ambiguity while insertion!!!!
Дата
Msg-id 20020909084829.83B06475BD7@postgresql.org
обсуждение исходный текст
Ответы Re: Bug #761: Date format ambiguity while insertion!!!!  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-bugs
Shubhankar Dasgupta (dasgupta@intelesoftech.com) reports a bug with a severity of 1
The lower the number the more severe it is.

Short Description
Date format ambiguity while insertion!!!!

Long Description
I am using Postgres 7.2.2 on Redhat Linux 7.2

My datestyle settings have been set as "ISO US(non european)"
This would mean that my date values should get inserted in the mm-dd-yyyy format. "09-01-2002" is interpreted as
Sepetember1st, 2002 while "01-09-2002" is interpreted as January 9th, 2002. 
This works perfectly most of the time except during certain cases where my month field exceeds 12.
As an example--consider "13-01-2002". As per my datesyle settings, postgres should have tried to interpret this as the
1stday of some "UNKNOWN" month of 2002 and should have thrown an error. However this date gets inserted and gets stored
as13th January, 2002 (interperted in the dd-mm-yyyy format). 
Its only when both the first two fields exceed 12(something like 13-13-2002), that I am given an error "Bad date
externalrepresentation '13-13-2002'. If either of the first two fields is less than or equal to 12, postgres accepts
thatas the month field irrespective of my datestyle settings. 
This may be a flexibility feature but then this I believe is extremely dangerous as it would accept user-errors without
theuser knowing it. 

Sample Code
ims=> insert into testdate values('1','09-01-2002');
INSERT 1590456 1
ims=> insert into testdate values('2','01-09-2002');
INSERT 1590457 1
ims=> insert into testdate values('3','13-09-2002');
INSERT 1590458 1
ims=> insert into testdate values('4','09-13-2002');
INSERT 1590459 1
ims=> insert into testdate values('5','13-13-2002');
ERROR:  Bad date external representation '13-13-2002'
ims=> select * from testdate ;
 dateid |   mydate
--------+------------
 1      | 2002-09-01
 2      | 2002-01-09
 3      | 2002-09-13
 4      | 2002-09-13
(4 rows)


No file was uploaded with this report

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

Предыдущее
От: Tatsuo Ishii
Дата:
Сообщение: Re: crash in apache
Следующее
От: "Ronald Kuczek"
Дата:
Сообщение: Unable to compile 7.3beta1 on cygwin