Re: BUG #14398: Order of Joins results in different results returned

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: vjchem(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14398: Order of Joins results in different results returned
Date: 2016-10-26 21:52:16
Message-ID: 8758.1477518736@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

vjchem(at)gmail(dot)com writes:
> This appears to ultimately be a casting issue, but it was surprising to us
> and thus I thought I'd file a bug report. I have a query that has two JOINs,
> where each JOIN uses parameters $1 and $2. The order of the JOIN changes the
> results returned. I can get the results I expect by explicitly casting $1
> and $2 or by changing the order of the JOINs. Is this expected behavior? It
> feels like I should get an error if the casting is ambiguous or that the
> order of the JOINs should not change the results.

I think the point is that you've got two separate uses of $1 and $2
in contexts that will lead to different conclusions about what their
types are (date or timestamptz, respectively). Whichever one the
parser comes to first will determine its choice, and the other context
is not so incompatible as to result in an error; nor is the provided
input string. But you'll get different results depending on that
choice.

Yes, it's ambiguous, but throwing an error would probably not make
more people happy than it makes unhappy.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Sengodan, Kesavan 2016-10-27 07:41:26 Not able to uninstall PostgreSQL 8.4.5-1 in Windows 10 OS and Windows Server 2012 OS
Previous Message vjchem 2016-10-26 20:49:25 BUG #14398: Order of Joins results in different results returned