pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15445: Difference between two dates is not an integer
7+ messages / 5 participants
[nested] [flat]

* BUG #15445: Difference between two dates is not an integer
@ 2018-10-19 13:14  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 7+ messages in thread

From: PG Bug reporting form @ 2018-10-19 13:14 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: martin.varady@gmail.com

The following bug has been logged on the website:

Bug reference:      15445
Logged by:          Martin Varady
Email address:      martin.varady@gmail.com
PostgreSQL version: 10.4
Operating system:   Windows Server 2012
Description:        

I've been using Postgres 9.3 and am recently testing moving to Postgres 10.
Testing Postgres 10 I've noticed that the difference between two dates gives
me an interval when it is documented as giving a integer. This is how it
worked in Postgres 9.3.

From Documentation of Postgres 10:
https://www.postgresql.org/docs/10/static/functions-datetime.html
date '2001-10-01' - date '2001-09-28' 	integer '3' (days)

Test Case:
I'm casting the result to an int to prove my point.
select (date '2001-10-01' - date '2001-09-28')::int
In Postgres 9.3 provides a result of 3 Integer type
In Postgres 10 gives error:

ERROR:  cannot cast type interval to integer
LINE 1: select (date '2001-10-01' - date '2001-09-28')::int
                                                      ^
SQL state: 42846
Character: 47



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #15445: Difference between two dates is not an integer
@ 2018-10-19 13:26  Sergei Kornilov <sk@zsrv.org>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 7+ messages in thread

From: Sergei Kornilov @ 2018-10-19 13:26 UTC (permalink / raw)
  To: martin.varady@gmail.com <martin.varady@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Hello

Works for me in pg 10.5, 11.0, and 9.6

Try this query:
SELECT n.nspname as "Schema",
  o.oprname AS "Name",
  CASE WHEN o.oprkind='l' THEN NULL ELSE pg_catalog.format_type(o.oprleft, NULL) END AS "Left arg type",
  CASE WHEN o.oprkind='r' THEN NULL ELSE pg_catalog.format_type(o.oprright, NULL) END AS "Right arg type",
  pg_catalog.format_type(o.oprresult, NULL) AS "Result type",
  coalesce(pg_catalog.obj_description(o.oid, 'pg_operator'),
           pg_catalog.obj_description(o.oprcode, 'pg_proc')) AS "Description"
FROM pg_catalog.pg_operator o
     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace
WHERE o.oprname OPERATOR(pg_catalog.=) '-'
  AND o.oprleft OPERATOR(pg_catalog.=) (select oid from pg_type where typname OPERATOR(pg_catalog.=) 'date')
  AND o.oprleft OPERATOR(pg_catalog.=) o.oprright
  AND pg_catalog.pg_operator_is_visible(o.oid)
ORDER BY 1, 2, 3, 4;

Maybe you have custom operators?

regards, Sergei




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #15445: Difference between two dates is not an integer
@ 2018-10-19 14:05  Martin Varady <martin.varady@gmail.com>
  parent: Sergei Kornilov <sk@zsrv.org>
  0 siblings, 1 reply; 7+ messages in thread

From: Martin Varady @ 2018-10-19 14:05 UTC (permalink / raw)
  To: sk@zsrv.org; +Cc: pgsql-bugs@lists.postgresql.org

I got what you would expect but still doesn't work. It is the enterpriseDB
version we bought for Oracle to Postgres conversions.
"EnterpriseDB 10.4.9, compiled by Visual C++ build 1800, 64-bit"

I'll keep looking at it to see if I can figure it out. Thanks.

[image: image.png]

On Fri, Oct 19, 2018 at 9:26 AM Sergei Kornilov <sk@zsrv.org> wrote:

> Hello
>
> Works for me in pg 10.5, 11.0, and 9.6
>
> Try this query:
> SELECT n.nspname as "Schema",
>   o.oprname AS "Name",
>   CASE WHEN o.oprkind='l' THEN NULL ELSE pg_catalog.format_type(o.oprleft,
> NULL) END AS "Left arg type",
>   CASE WHEN o.oprkind='r' THEN NULL ELSE
> pg_catalog.format_type(o.oprright, NULL) END AS "Right arg type",
>   pg_catalog.format_type(o.oprresult, NULL) AS "Result type",
>   coalesce(pg_catalog.obj_description(o.oid, 'pg_operator'),
>            pg_catalog.obj_description(o.oprcode, 'pg_proc')) AS
> "Description"
> FROM pg_catalog.pg_operator o
>      LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace
> WHERE o.oprname OPERATOR(pg_catalog.=) '-'
>   AND o.oprleft OPERATOR(pg_catalog.=) (select oid from pg_type where
> typname OPERATOR(pg_catalog.=) 'date')
>   AND o.oprleft OPERATOR(pg_catalog.=) o.oprright
>   AND pg_catalog.pg_operator_is_visible(o.oid)
> ORDER BY 1, 2, 3, 4;
>
> Maybe you have custom operators?
>
> regards, Sergei
>

Attachments:

image.png (image/png, 75.6K) download view image
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: BUG #15445: Difference between two dates is not an integer
@ 2018-10-19 14:26  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Martin Varady <martin.varady@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Tom Lane @ 2018-10-19 14:26 UTC (permalink / raw)
  To: Martin Varady <martin.varady@gmail.com>; +Cc: sk@zsrv.org; pgsql-bugs@lists.postgresql.org

Martin Varady <martin.varady@gmail.com> writes:
> I got what you would expect but still doesn't work. It is the enterpriseDB
> version we bought for Oracle to Postgres conversions.
> "EnterpriseDB 10.4.9, compiled by Visual C++ build 1800, 64-bit"

Well, you should have a word with EDB then, but what it sounds like
is they install a nondefault date - date operator, or possibly remove
PG's standard one so that timestamp - timestamp gets chosen instead.
Which is probably reasonable if your goal is compatibility with
Oracle.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #15445: Difference between two dates is not an integer
@ 2018-10-19 14:37  Martin Varady <martin.varady@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 7+ messages in thread

From: Martin Varady @ 2018-10-19 14:37 UTC (permalink / raw)
  To: tgl@sss.pgh.pa.us; +Cc: sk@zsrv.org; pgsql-bugs@lists.postgresql.org

Not sure how to close my logged bug. But its safe to say its not a defect.
Thank You for your help.

On Fri, Oct 19, 2018 at 10:26 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Martin Varady <martin.varady@gmail.com> writes:
> > I got what you would expect but still doesn't work. It is the
> enterpriseDB
> > version we bought for Oracle to Postgres conversions.
> > "EnterpriseDB 10.4.9, compiled by Visual C++ build 1800, 64-bit"
>
> Well, you should have a word with EDB then, but what it sounds like
> is they install a nondefault date - date operator, or possibly remove
> PG's standard one so that timestamp - timestamp gets chosen instead.
> Which is probably reasonable if your goal is compatibility with
> Oracle.
>
>                         regards, tom lane
>

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #15445: Difference between two dates is not an integer
@ 2018-10-19 15:02  Anthony Sotolongo <asotolongo@gmail.com>
  parent: Martin Varady <martin.varady@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Anthony Sotolongo @ 2018-10-19 15:02 UTC (permalink / raw)
  To: Martin Varady <martin.varady@gmail.com>; +Cc: tgl@sss.pgh.pa.us; sk@zsrv.org; pgsql-bugs@lists.postgresql.org

Hi Martin if you are using EDB Postgres this operation require set
edb_redwood_date = false

And then the operator - with date Will be like PostgreSQL native


Regards


El vie., 19 de oct. de 2018 11:56 a.m., Martin Varady <
martin.varady@gmail.com> escribió:

> Not sure how to close my logged bug. But its safe to say its not a defect.
> Thank You for your help.
>
> On Fri, Oct 19, 2018 at 10:26 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
>> Martin Varady <martin.varady@gmail.com> writes:
>> > I got what you would expect but still doesn't work. It is the
>> enterpriseDB
>> > version we bought for Oracle to Postgres conversions.
>> > "EnterpriseDB 10.4.9, compiled by Visual C++ build 1800, 64-bit"
>>
>> Well, you should have a word with EDB then, but what it sounds like
>> is they install a nondefault date - date operator, or possibly remove
>> PG's standard one so that timestamp - timestamp gets chosen instead.
>> Which is probably reasonable if your goal is compatibility with
>> Oracle.
>>
>>                         regards, tom lane
>>
>

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #15445: Difference between two dates is not an integer
@ 2018-10-19 15:52  Martin Varady <martin.varady@gmail.com>
  parent: Anthony Sotolongo <asotolongo@gmail.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Martin Varady @ 2018-10-19 15:52 UTC (permalink / raw)
  To: asotolongo@gmail.com; +Cc: tgl@sss.pgh.pa.us; sk@zsrv.org; pgsql-bugs@lists.postgresql.org

That was it, thank you so much. I'll check out what the impact of that is
during the migration process. Worse case I set it after the fact.

Thank You,
Martin

On Fri, Oct 19, 2018 at 11:03 AM Anthony Sotolongo <asotolongo@gmail.com>
wrote:

> Hi Martin if you are using EDB Postgres this operation require set
> edb_redwood_date = false
>
> And then the operator - with date Will be like PostgreSQL native
>
>
> Regards
>
>
> El vie., 19 de oct. de 2018 11:56 a.m., Martin Varady <
> martin.varady@gmail.com> escribió:
>
>> Not sure how to close my logged bug. But its safe to say its not a
>> defect. Thank You for your help.
>>
>> On Fri, Oct 19, 2018 at 10:26 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>
>>> Martin Varady <martin.varady@gmail.com> writes:
>>> > I got what you would expect but still doesn't work. It is the
>>> enterpriseDB
>>> > version we bought for Oracle to Postgres conversions.
>>> > "EnterpriseDB 10.4.9, compiled by Visual C++ build 1800, 64-bit"
>>>
>>> Well, you should have a word with EDB then, but what it sounds like
>>> is they install a nondefault date - date operator, or possibly remove
>>> PG's standard one so that timestamp - timestamp gets chosen instead.
>>> Which is probably reasonable if your goal is compatibility with
>>> Oracle.
>>>
>>>                         regards, tom lane
>>>
>>

^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2018-10-19 15:52 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-10-19 13:14 BUG #15445: Difference between two dates is not an integer PG Bug reporting form <noreply@postgresql.org>
2018-10-19 13:26 ` Sergei Kornilov <sk@zsrv.org>
2018-10-19 14:05   ` Martin Varady <martin.varady@gmail.com>
2018-10-19 14:26     ` Tom Lane <tgl@sss.pgh.pa.us>
2018-10-19 14:37       ` Martin Varady <martin.varady@gmail.com>
2018-10-19 15:02         ` Anthony Sotolongo <asotolongo@gmail.com>
2018-10-19 15:52           ` Martin Varady <martin.varady@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox