Re: BUG #14398: Order of Joins results in different results returned - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #14398: Order of Joins results in different results returned
Date
Msg-id 8758.1477518736@sss.pgh.pa.us
Whole thread Raw
In response to BUG #14398: Order of Joins results in different results returned  (vjchem@gmail.com)
List pgsql-bugs
vjchem@gmail.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

pgsql-bugs by date:

Previous
From: vjchem@gmail.com
Date:
Subject: BUG #14398: Order of Joins results in different results returned
Next
From: "Sengodan, Kesavan"
Date:
Subject: Not able to uninstall PostgreSQL 8.4.5-1 in Windows 10 OS and Windows Server 2012 OS