Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-12 Thread Joe Wilson
It appears that Postgres, DB2 and SQL Server CE have issues with certain types of alias expresssions in GROUP BY, while MySQL does not. Postgres will allow column aliases in GROUP BY - even aliases overriding table column names - as long as every table column component of that alias'

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-11 Thread Robert Wishlaw
On 12/11/07, Robert Wishlaw <[EMAIL PROTECTED]> wrote: > On 12/11/07, Joe Wilson <[EMAIL PROTECTED]> wrote: > > --- [EMAIL PROTECTED] wrote: > > > The current name resolution rules for SQLite are that it > > > first tries to resolve names using just the tables in the > > > join. If that fails,

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-11 Thread Robert Wishlaw
On 12/11/07, Joe Wilson <[EMAIL PROTECTED]> wrote: > --- [EMAIL PROTECTED] wrote: > > The current name resolution rules for SQLite are that it > > first tries to resolve names using just the tables in the > > join. If that fails, then it looks at result column aliases. > > I think that approach

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-11 Thread Joe Wilson
--- [EMAIL PROTECTED] wrote: > The current name resolution rules for SQLite are that it > first tries to resolve names using just the tables in the > join. If that fails, then it looks at result column aliases. > I think that approach continues to work on WHERE. But I need > to reverse the

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-11 Thread drh
Dennis Cote <[EMAIL PROTECTED]> wrote: > > So SQLite should be sorting by the result column "c" not the column "c" > in the table T1 which it doing. > My understand as of yesterday is that column name aliases are significant for ORDER BY, but not for WHERE, in standard SQL. This is not as

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-11 Thread Michael Schlenker
Joe Wilson schrieb: --- Trevor Talbot <[EMAIL PROTECTED]> wrote: On 12/10/07, Robert Wishlaw <[EMAIL PROTECTED]> wrote: IBM DB2 9.5 select a AS "foo" from t1 union select b from t1 order by foo SQL0206N "FOO" is not valid in the context where it is used. SQLSTATE=42703 The problem here is

RE: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-11 Thread Samuel R. Neff
MSSQL results match your MySQL and PostgreSQL results. (I only changed the table name to be a temporary table) create table #t1(a INT, b INT, c INT); insert into #t1 values(1, 2, 4); insert into #t1 values(2, -1000, 5); (1 row(s) affected) (1 row(s) affected) -- See if select alias

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-11 Thread Brad Stiles
> Could someone please post the results of these queries on Oracle, > DB2 or SQL Server? On MS SQL Server 2000, your queries result in the following: a c --- --- 2-998 1 3 (2 row(s) affected) foo ---

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-11 Thread Dennis Cote
Joe Wilson wrote: Let's add another row to table t1... postgres=> insert into t1 values(2, -1000, 5); INSERT 0 1 test=> select * from t1; a | b | c ---+---+--- 1 | 2 | 4 2 | -1000 | 5 postgres=> select a, a+b AS "c" from t1 order by c; a | c ---+-- 2 | -998 1 |3

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-11 Thread Joe Wilson
--- Trevor Talbot <[EMAIL PROTECTED]> wrote: > On 12/10/07, Robert Wishlaw <[EMAIL PROTECTED]> wrote: > > > IBM DB2 9.5 > > > > select a AS "foo" from t1 union select b from t1 order by foo > > SQL0206N "FOO" is not valid in the context where it is used. > > SQLSTATE=42703 > > The problem

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-10 Thread Trevor Talbot
On 12/10/07, Robert Wishlaw <[EMAIL PROTECTED]> wrote: > IBM DB2 9.5 > > select a AS "foo" from t1 union select b from t1 order by foo > SQL0206N "FOO" is not valid in the context where it is used. SQLSTATE=42703 The problem here is with the inconsistent quoting. PostgreSQL uses the opposite

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-10 Thread Robert Wishlaw
On 12/10/07, Joe Wilson <[EMAIL PROTECTED]> wrote: > --- [EMAIL PROTECTED] wrote: > > Dennis Cote <[EMAIL PROTECTED]> wrote: > > > [EMAIL PROTECTED] wrote: > > > > > > > > Can you please tell me what > > > > other databases do with this: > > > > > > > >CREATE TABLE t1(a,b,c); > > > >INSERT

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-10 Thread Robert Wishlaw
On 12/8/07, Joe Wilson <[EMAIL PROTECTED]> wrote: > --- Robert Wishlaw <[EMAIL PROTECTED]> wrote: > > > >CREATE TABLE t1(a,b,c); > > > IBM DB2 9.5 > > > > INSERT INTO t1 VALUES(1,2,4); > > SELECT a+b AS c FROM t1 WHERE c=4; > > > > returns > > > > C > > > >

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-10 Thread Joe Wilson
--- [EMAIL PROTECTED] wrote: > Dennis Cote <[EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] wrote: > > > > > > Can you please tell me what > > > other databases do with this: > > > > > >CREATE TABLE t1(a,b,c); > > >INSERT INTO t1 VALUES(1,2,4); > > >SELECT a+b AS c FROM t1 WHERE c==4;

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-10 Thread drh
Dennis Cote <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > > Can you please tell me what > > other databases do with this: > > > >CREATE TABLE t1(a,b,c); > >INSERT INTO t1 VALUES(1,2,4); > >SELECT a+b AS c FROM t1 WHERE c==4; > > > > In the WHERE clause, should the "c"

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-10 Thread Dennis Cote
[EMAIL PROTECTED] wrote: Can you please tell me what other databases do with this: CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(1,2,4); SELECT a+b AS c FROM t1 WHERE c==4; In the WHERE clause, should the "c" resolve to the column "c" or to the "a+b" expression? I'm guessing the

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-08 Thread Joe Wilson
> >CREATE TABLE t1(a,b,c); > >INSERT INTO t1 VALUES(1,2,4); > >SELECT a+b AS c FROM t1 WHERE c=4; > > SQL Server returns a 3. > ORACLE 9 returns a 3. PostgreSQL 8.1.5 also returns a 3 Never

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-08 Thread Joe Wilson
--- Robert Wishlaw <[EMAIL PROTECTED]> wrote: > > >CREATE TABLE t1(a,b,c); > IBM DB2 9.5 > > INSERT INTO t1 VALUES(1,2,4); > SELECT a+b AS c FROM t1 WHERE c=4; > > returns > > C > >3 >3 >3 >

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-08 Thread Robert Wishlaw
On Dec 8, 2007 11:49 PM, Trey Mack <[EMAIL PROTECTED]> wrote: > > Can you please tell me what > > other databases do with this: > > > >CREATE TABLE t1(a,b,c); > >INSERT INTO t1 VALUES(1,2,4); > >SELECT a+b AS c FROM t1 WHERE c==4; > > SQL Server returns a 3. > ORACLE 9 returns a 3. >

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-08 Thread Trey Mack
Can you please tell me what other databases do with this: CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(1,2,4); SELECT a+b AS c FROM t1 WHERE c==4; SQL Server returns a 3. ORACLE 9 returns a 3. - To

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-08 Thread Joe Wilson
>CREATE TABLE t1(a,b,c); >INSERT INTO t1 VALUES(1,2,4); >SELECT a+b AS c FROM t1 WHERE c==4; MySQL 5.0.45: create table t1(a INT, b INT, c INT); INSERT INTO t1 VALUES(1,2,4); SELECT a+b AS c FROM t1 WHERE c=4; +--+ | c| +--+ |3 | +--+ > In the WHERE clause,

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-08 Thread drh
Joe Wilson <[EMAIL PROTECTED]> wrote: > > My interest is to make sqlite more compatible with > other databases or to improve its speed. > I'm happy for the help. Can you please tell me what other databases do with this: CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(1,2,4); SELECT a+b

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-08 Thread Joe Wilson
--- [EMAIL PROTECTED] wrote: > Joe Wilson <[EMAIL PROTECTED]> wrote: > > > > So few lines of code are changed by the patch that one could easily > > add a new PRAGMA to have the old compound SELECT behavior to be the > > default. If a database is explicitly created or altered with the new > >

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-08 Thread drh
Joe Wilson <[EMAIL PROTECTED]> wrote: > > So few lines of code are changed by the patch that one could easily > add a new PRAGMA to have the old compound SELECT behavior to be the > default. If a database is explicitly created or altered with the new > PRAGMA setting, it could have the new

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-08 Thread Joe Wilson
--- "D. Richard Hipp" <[EMAIL PROTECTED]> wrote: > On Dec 7, 2007, at 11:47 PM, Joe Wilson wrote: > > > > I believe it makes compound query behavior more compatible with other > > popular databases. It is mostly backwards compatible with the previous > > syntax and only 2 tests performed by "make

Re: [sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-08 Thread D. Richard Hipp
On Dec 7, 2007, at 11:47 PM, Joe Wilson wrote: I believe it makes compound query behavior more compatible with other popular databases. It is mostly backwards compatible with the previous syntax and only 2 tests performed by "make test" had to be altered. Compatibility with other databases

[sqlite] PATCH: compound query column naming and resolving (Ticket #2822)

2007-12-07 Thread Joe Wilson
The attached sqlite 3.5.3 patch addresses several different compound query column naming and resolving issues in ORDER BY and the SELECT expression list mentioned in this ticket: http://www.sqlite.org/cvstrac/tktview?tn=2822 (The exception being it does not support expressions in the ORDER