interval behaviour

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема interval behaviour
Дата
Msg-id 1133459218.16010.56.camel@state.g2switchworks.com
обсуждение исходный текст
Ответы Re: interval behaviour  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
I seem to have found a rather odd interval bug.

Reading through the sql2003 spec, it would appear that the "proper" way
to represent an interval would be:

interval '10' day

(see pp 144-5, section 5.3 of ISO/IEC 9075-2:2003(E))

Excerpt:

<interval literal> ::= INTERVAL [ <sign> ] <interval string> <interval
qualifier>
<interval string> ::= <quote> <unquoted interval string> <quote>

Note that the qualifier is placed after the quote, and if you're not
sure, here's the excerpt from what an <interval qualifier> is:


<interval qualifier> ::=
    <start field> TO <end field>
  | <single datetime field>

<SNIP>

<single datetime field> ::=
    <non-second primary datetime field>
    [ <left paren> <interval leading field precision> <right paren> ]
  | SECOND [ <left paren> <interval leading field precision>
    [ <comma> <interval fractional seconds precision> ] <right paren> ]

<SNIP part deux>

<non-second primary datetime field> ::=
    YEAR
  | MONTH
  | DAY
  | HOUR
  | MINUTE

So, am I reading this right?

While PostgreSQL happily swallows

interval '10 day'

it is not, in fact, the way the spec says it should be.  That's ok,
since it seems to swallow the proper form just fine.

BUT IT DOESN'T!

Take these two examples: (both in 8.1.0)

test=# select now() + interval '6 month';
           ?column?
-------------------------------
 2006-06-01 11:41:32.017995-05
(1 row)

Looks good!

test=# select now() + interval '6' month;
           ?column?
------------------------------
 2005-12-01 11:41:27.17808-06
(1 row)

It took the arguments, but did not give the proper output.



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

Предыдущее
От: Terry Lee Tucker
Дата:
Сообщение: Re: Function returning SETOF
Следующее
От: Kelly Burkhart
Дата:
Сообщение: Re: default_index_tablespace?