Re: [sqlite] unexpected behavior with CROSS and LEFT JOIN together

2010-02-24 Thread Igor Tandetnik
D. Richard Hipp wrote: > On Feb 24, 2010, at 5:45 PM, Igor Tandetnik wrote: > >> D. Richard Hipp wrote: >>> This problem has existed in SQLite forever and has never been seen >>> before. So it is obscure. The simple fix is to put the ON clause >>> on the CROSS JOIN where it belongs. >> >> Doe

Re: [sqlite] unexpected behavior with CROSS and LEFT JOIN together

2010-02-24 Thread D. Richard Hipp
On Feb 24, 2010, at 5:45 PM, Igor Tandetnik wrote: > D. Richard Hipp wrote: >> This problem has existed in SQLite forever and has never been seen >> before. So it is obscure. The simple fix is to put the ON clause on >> the CROSS JOIN where it belongs. > > Does CROSS JOIN allow an ON clause? T

Re: [sqlite] unexpected behavior with CROSS and LEFT JOIN together

2010-02-24 Thread ve3meo
I posted the following and it didn't appear - I probably hit Reply to Sender instead of Reply Group: > Does INDEX sqlite_autoindex_currency_1 contain only pointers to the > identical currencies? > > Tom This little change also works: ON +c1.cur=c2.cur; or ON c1.cur=+c2.cur; Along with LIKE, th

Re: [sqlite] unexpected behavior with CROSS and LEFT JOIN together

2010-02-24 Thread Igor Tandetnik
D. Richard Hipp wrote: > This problem has existed in SQLite forever and has never been seen > before. So it is obscure. The simple fix is to put the ON clause on > the CROSS JOIN where it belongs. Does CROSS JOIN allow an ON clause? That doesn't make much sense. I guess I'm missing something o

Re: [sqlite] unexpected behavior with CROSS and LEFT JOIN together

2010-02-24 Thread D. Richard Hipp
On Feb 24, 2010, at 5:20 PM, Pavel Ivanov wrote: >> Does INDEX sqlite_autoindex_currency_1 contain only pointers to the >> identical currencies? > > First of all AFAIK 'PRIMARY KEY' implies uniqueness of the column. And > second: I bet if you execute 'PRAGMA case_sensitive_like = true' then > pla

Re: [sqlite] unexpected behavior with CROSS and LEFT JOIN together

2010-02-24 Thread Pavel Ivanov
> Does INDEX sqlite_autoindex_currency_1 contain only pointers to the > identical currencies? First of all AFAIK 'PRIMARY KEY' implies uniqueness of the column. And second: I bet if you execute 'PRAGMA case_sensitive_like = true' then plans will be the same. See http://www.sqlite.org/optoverview.h

Re: [sqlite] unexpected behavior with CROSS and LEFT JOIN together

2010-02-24 Thread ve3meo
"ve3meo" wrote in message news:hm47t5$5l...@dough.gmane.org... > > "Igor Tandetnik" wrote in > message news:hm45gu$s5...@dough.gmane.org... >> Mark Brand wrote: >>> --Gives unexpected results >>> SELECT c1.cur cur1, c2.cur cur2, COALESCE(self.rate, x.rate) rate >>> FROM currency c1 >>> CROSS

Re: [sqlite] unexpected behavior with CROSS and LEFT JOIN together

2010-02-24 Thread ve3meo
"Igor Tandetnik" wrote in message news:hm45gu$s5...@dough.gmane.org... > Mark Brand wrote: >> --Gives unexpected results >> SELECT c1.cur cur1, c2.cur cur2, COALESCE(self.rate, x.rate) rate >> FROM currency c1 >> CROSS JOIN currency c2 >> LEFT JOIN exchange x >>ON x.cur1=c1.cur >>AND x.

Re: [sqlite] unexpected behavior with CROSS and LEFT JOIN together

2010-02-24 Thread Igor Tandetnik
Mark Brand wrote: > --Gives unexpected results > SELECT c1.cur cur1, c2.cur cur2, COALESCE(self.rate, x.rate) rate > FROM currency c1 > CROSS JOIN currency c2 > LEFT JOIN exchange x >ON x.cur1=c1.cur >AND x.cur2=c2.cur > LEFT JOIN (SELECT 1 rate) self >ON c1.cur=c2.cur; > > /* results

Re: [sqlite] unexpected behavior with CROSS and LEFT JOIN together

2010-02-24 Thread Mark Brand
> It's pretty strange how you try to join with some table not even > mentioning any column of that table in the joining condition. I bet > behavior is not defined for such cases in SQL standard and you're > getting some interpretation of such query. > I'm not aware of any requirement that a JO

Re: [sqlite] unexpected behavior with CROSS and LEFT JOIN together

2010-02-24 Thread Pavel Ivanov
It's pretty strange how you try to join with some table not even mentioning any column of that table in the joining condition. I bet behavior is not defined for such cases in SQL standard and you're getting some interpretation of such query. Probably this query will return what you want: SELECT c