/ Check-in [4f56949b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Bug fix in cases where a compound select has an ORDER BY clause with multiple terms. (CVS 3011)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:4f56949bd69fed6167fa2ae115d0251e8369d796
User & Date: drh 2006-01-23 18:42:21
Context
2006-01-23
21:37
Progress toward getting SQLITE_OMIT_FLOATING_POINT to pass all tests. Ticket #1621 (CVS 3012) check-in: c4c90965 user: drh tags: trunk
18:42
Bug fix in cases where a compound select has an ORDER BY clause with multiple terms. (CVS 3011) check-in: 4f56949b user: drh tags: trunk
18:14
Add documentation on the IF NOT EXISTS clause to CREATE statements. Ticket #1608. (CVS 3010) check-in: d4e4ba13 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/select.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.299 2006/01/22 21:52:57 drh Exp $
*/
#include "sqliteInt.h"


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
................................................................................

    if( pOrderBy ){
      struct ExprList_item *pOTerm = pOrderBy->a;
      int nOrderByExpr = pOrderBy->nExpr;
      int addr;
      u8 *pSortOrder;

      aCopy = (CollSeq**)&pKeyInfo[1];
      pSortOrder = pKeyInfo->aSortOrder = (u8*)&aCopy[nCol];
      memcpy(aCopy, pKeyInfo->aColl, nCol*sizeof(CollSeq*));
      apColl = pKeyInfo->aColl;
      for(i=0; i<nOrderByExpr; i++, pOTerm++, apColl++, pSortOrder++){
        Expr *pExpr = pOTerm->pExpr;
        char *zName = pOTerm->zName;
        assert( pExpr->op==TK_COLUMN && pExpr->iColumn<nCol );







|







 







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.300 2006/01/23 18:42:21 drh Exp $
*/
#include "sqliteInt.h"


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
................................................................................

    if( pOrderBy ){
      struct ExprList_item *pOTerm = pOrderBy->a;
      int nOrderByExpr = pOrderBy->nExpr;
      int addr;
      u8 *pSortOrder;

      aCopy = &pKeyInfo->aColl[nCol];
      pSortOrder = pKeyInfo->aSortOrder = (u8*)&aCopy[nCol];
      memcpy(aCopy, pKeyInfo->aColl, nCol*sizeof(CollSeq*));
      apColl = pKeyInfo->aColl;
      for(i=0; i<nOrderByExpr; i++, pOTerm++, apColl++, pSortOrder++){
        Expr *pExpr = pOTerm->pExpr;
        char *zName = pOTerm->zName;
        assert( pExpr->op==TK_COLUMN && pExpr->iColumn<nCol );

Changes to test/bind.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script testing the sqlite_bind API.
#
# $Id: bind.test,v 1.36 2006/01/03 00:33:50 drh Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

proc sqlite_step {stmt N VALS COLS} {
  upvar VALS vals
................................................................................
do_test bind-10.10 {
  execsql {SELECT * FROM t2}
} {1 999 1000 1001 {} {} 1 2 1 3 2 1}

# Ticket #918
#
do_test bind-10.11 {
  catch {sqlite3_finalize $VM}
  set VM [
    sqlite3_prepare $DB {
      INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,?,?4,:pqr,:abc,?4)
    } -1 TAIL
  ]
  sqlite3_bind_parameter_count $VM
} 5







|







 







|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script testing the sqlite_bind API.
#
# $Id: bind.test,v 1.37 2006/01/23 18:42:21 drh Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

proc sqlite_step {stmt N VALS COLS} {
  upvar VALS vals
................................................................................
do_test bind-10.10 {
  execsql {SELECT * FROM t2}
} {1 999 1000 1001 {} {} 1 2 1 3 2 1}

# Ticket #918
#
do_test bind-10.11 {
  # catch {sqlite3_finalize $VM}
  set VM [
    sqlite3_prepare $DB {
      INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,?,?4,:pqr,:abc,?4)
    } -1 TAIL
  ]
  sqlite3_bind_parameter_count $VM
} 5

Changes to test/insert3.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
55
56
57
58
59
60
61
62
63
64
65
66






67
68
69
70
71
72
73
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing corner cases of the INSERT statement.
#
# $Id: insert3.test,v 1.3 2005/01/29 08:32:46 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# All the tests in this file require trigger support
#
ifcapable {trigger} {
................................................................................
} {5 2 453 1 hello 2}
do_test insert3-1.3 {
  execsql {
    SELECT * FROM log2 ORDER BY x;
  }
} {hi 1}
ifcapable compound {
  do_test insert3-1.4 {
    execsql {
      INSERT INTO t1 SELECT * FROM t1;
      SELECT 'a:', x, y FROM log UNION ALL 
          SELECT 'b:', x, y FROM log2 ORDER BY x;






    }
  } {a: 5 4 b: 10 2 b: 20 1 a: 453 2 a: hello 4 b: hi 2 b: world 1}
  do_test insert3-1.5 {
    execsql {
      INSERT INTO t1(a) VALUES('xyz');
      SELECT * FROM log ORDER BY x;
    }







|







 







|




>
>
>
>
>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing corner cases of the INSERT statement.
#
# $Id: insert3.test,v 1.4 2006/01/23 18:42:21 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# All the tests in this file require trigger support
#
ifcapable {trigger} {
................................................................................
} {5 2 453 1 hello 2}
do_test insert3-1.3 {
  execsql {
    SELECT * FROM log2 ORDER BY x;
  }
} {hi 1}
ifcapable compound {
  do_test insert3-1.4.1 {
    execsql {
      INSERT INTO t1 SELECT * FROM t1;
      SELECT 'a:', x, y FROM log UNION ALL 
          SELECT 'b:', x, y FROM log2 ORDER BY x;
    }
  } {a: 5 4 b: 10 2 b: 20 1 a: 453 2 a: hello 4 b: hi 2 b: world 1}
  do_test insert3-1.4.2 {
    execsql {
      SELECT 'a:', x, y FROM log UNION ALL 
          SELECT 'b:', x, y FROM log2 ORDER BY x, y;
    }
  } {a: 5 4 b: 10 2 b: 20 1 a: 453 2 a: hello 4 b: hi 2 b: world 1}
  do_test insert3-1.5 {
    execsql {
      INSERT INTO t1(a) VALUES('xyz');
      SELECT * FROM log ORDER BY x;
    }