On 1/16/2013 4:40 PM, Tom Lane wrote:
> HideMe <r36@tara-lu.com> writes:
>> Postgres 9.1
>> Ubuntu something.
>> We have a stored procedure that performs the following evaluations:
>> IF ST_Intersects(line1, line2) OR ST_Intersects(line3, line4) THEN
>> do stuff
>> ELSIF ST_Intersects(line5, line6) OR ST_Intersects(line7, line8) THEN
>> do stuffB
>> END IF;
> In principle the order of ORs is not guaranteed, but that mainly has
> to do with execution of query WHERE clauses, wherein the optimizer
> will feel free to move sub-clauses to different relations, join
> levels, etc. I think you're reasonably safe to assume that OR is
> left-to-right in this simple context.
Thanks Tom... I knew the WHERE clause scenario was not guaranteed. I
just didn't know if the psql stored procedure conditional tests behaved
like C or ... not.
> IF ST_Intersects(line1, line2) THEN
> do stuff
> ELSIF ST_Intersects(line5, line6) THEN
> do stuffB
> ELSIF ST_Intersects(line3, line4) THEN
> do stuff
> ELSIF ST_Intersects(line7, line8) THEN
> do stuffB
> END IF;
> That doesn't look like it produces quite the same results ...
>
That would be true if you absolutely need the order initially given -
but in this case each ST_Intersects is a test for invalid data. This is
a collegue's sample, I asked hm ahead of time - order doesn't matter.
if any of the 4 conditions results, then invalid data exists in the
scenario and we have to do something about it... but only 1 condition
should ever be true.
again, thanks Tom.
Roxanne