SQLite

Check-in [a26d0880b2]
Login

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

Overview
Comment:Bug fix in the out-of-order INSERT. (CVS 336)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a26d0880b20ca5534400a3689d1da31fe6aaa934
User & Date: drh 2001-12-22 21:48:30.000
Context
2001-12-22
22:00
Version 2.2.0 (CVS 453) (check-in: 6bb62d8fab user: drh tags: trunk)
21:48
Bug fix in the out-of-order INSERT. (CVS 336) (check-in: a26d0880b2 user: drh tags: trunk)
19:27
Update documentation for the 2.2.0 release. (CVS 335) (check-in: 14392258c5 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/insert.c.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    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 INSERT statements in SQLite.
**
** $Id: insert.c,v 1.28 2001/12/22 14:49:25 drh Exp $
*/
#include "sqliteInt.h"

/*
** This routine is call to handle SQL of the following forms:
**
**    insert into TABLE (IDLIST) values(EXPRLIST)







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    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 INSERT statements in SQLite.
**
** $Id: insert.c,v 1.29 2001/12/22 21:48:30 drh Exp $
*/
#include "sqliteInt.h"

/*
** This routine is call to handle SQL of the following forms:
**
**    insert into TABLE (IDLIST) values(EXPRLIST)
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
      pColumn->a[i].idx = -1;
    }
    for(i=0; i<pColumn->nId; i++){
      for(j=0; j<pTab->nCol; j++){
        if( sqliteStrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){
          pColumn->a[i].idx = j;
          if( j==pTab->iPKey ){
            keyColumn = j;
          }
          break;
        }
      }
      if( j>=pTab->nCol ){
        sqliteSetString(&pParse->zErrMsg, "table ", pTab->zName,
           " has no column named ", pColumn->a[i].zName, 0);







|







138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
      pColumn->a[i].idx = -1;
    }
    for(i=0; i<pColumn->nId; i++){
      for(j=0; j<pTab->nCol; j++){
        if( sqliteStrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){
          pColumn->a[i].idx = j;
          if( j==pTab->iPKey ){
            keyColumn = i;
          }
          break;
        }
      }
      if( j>=pTab->nCol ){
        sqliteSetString(&pParse->zErrMsg, "table ", pTab->zName,
           " has no column named ", pColumn->a[i].zName, 0);
Changes to test/intpkey.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for the special processing associated
# with INTEGER PRIMARY KEY columns.
#
# $Id: intpkey.test,v 1.3 2001/12/22 19:27:41 drh Exp $

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

# Create a table with a primary key and a datatype other than
# integer
#







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for the special processing associated
# with INTEGER PRIMARY KEY columns.
#
# $Id: intpkey.test,v 1.4 2001/12/22 21:48:30 drh Exp $

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

# Create a table with a primary key and a datatype other than
# integer
#
395
396
397
398
399
400
401
402
403
404
405
406
407
408



409


410
  execsql {
    SELECT * FROM t1 WHERE a>=20
  }
} {20 b-20 c-20 22 b-22 c-22}

# Do an insert of values with the columns specified out of order.
#
execsql {pragma vdbe_trace=on;}
do_test intpkey-7.1 {
  execsql {
    INSERT INTO t1(c,b,a) VALUES('row','new',30);
    SELECT * FROM t1 WHERE rowid>=30;
  }
} {30 new row}






finish_test







<






>
>
>
|
>
>

395
396
397
398
399
400
401

402
403
404
405
406
407
408
409
410
411
412
413
414
  execsql {
    SELECT * FROM t1 WHERE a>=20
  }
} {20 b-20 c-20 22 b-22 c-22}

# Do an insert of values with the columns specified out of order.
#

do_test intpkey-7.1 {
  execsql {
    INSERT INTO t1(c,b,a) VALUES('row','new',30);
    SELECT * FROM t1 WHERE rowid>=30;
  }
} {30 new row}
do_test intpkey-7.2 {
  execsql {
    SELECT * FROM t1 WHERE rowid>20;
  }
} {22 b-22 c-22 30 new row}

finish_test