Re: Issue in Behavior of Interval Datatype

From: Amit Kapila <amit(dot)kapila(at)huawei(dot)com>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "'PG Hackers'" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Issue in Behavior of Interval Datatype
Date: 2012-08-04 06:18:33
Message-ID: 001f01cd7208$fa440900$eecc1b00$@kapila@huawei.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Saturday, August 04, 2012 1:48 AM
Amit Kapila <amit(dot)kapila(at)huawei(dot)com> writes:
> select (interval '56:48' minute to second);
> result$B!'(B00:56:48
> select (interval '-56:48' minute to second);
> result$B!'(B-56:48:00
> select (interval '+56:48' minute to second);
> result$B!'(B56:48:00

> I have checked the code and found that in function DecodeInterval(), for
> timezone case (DTK_TZ) it uses INTERVAL_FULL_RANGE irrespective of range
> passed by user.

> However if use the range passed as argument in function DecodeInterval(),
> the result of using $B!F(B+$B!G(B or $B!F(B-$B!F(B is same as
without using it.

> Is there any particular reason for ignoring the range for DTK_TZ case in
> DecodeInterval() function?

> I think you are right; this if-block should be exactly like the DTK_TIME
> case except for handling the prepended sign. That also raises the
> question why it is changing the tmask value returned by DecodeTime.
> It seems to be doing exactly the wrong thing there. Test case:

> regression=# select (interval '56:48 56:48' );
> ERROR: invalid input syntax for type interval: "56:48 56:48"
> LINE 1: select (interval '56:48 56:48' );
^
> regression=# select (interval '56:48 +56:48' );
> interval
> ----------
> 56:48:00
> (1 row)

> The second one fails to fail because an inappropriate tmask value got
>included into fmask.

Yes, this is right that tmask need not be changed, also one more thing I
have noticed that
in file Interval.c also there is a function DecodeInterval() which is
currently little different
from DecodeInterval() in datetime.c for DTK_TZ case.
For example Assert check is commented.
Why the Assert check is commented out there?
May be due to some defect, but I am not able to think the reason for same.

Shouldn't we make this change (don't change tmask in case of DTK_TZ) in
Interval.c?

>Will fix.

Thank you very much.

With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2012-08-04 06:41:44 Re: [WIP] Performance Improvement by reducing WAL for Update Operation
Previous Message Craig Ringer 2012-08-04 04:56:28 Re: [PATCH] Docs: Make notes on sequences and rollback more obvious