SQLite

Check-in [96cd07a881]
Login

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

Overview
Comment:Fix a bug that could cause UPDATE to fail for a table that contains both an INTEGER PRIMARY KEY and an index. (CVS 346)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 96cd07a881d7bea86a66d7dfe54713be9c81cb4c
User & Date: drh 2002-01-14 02:56:25.000
Context
2002-01-14
03:00
Version 2.2.2 (CVS 451) (check-in: 7da00a33fe user: drh tags: trunk)
02:56
Fix a bug that could cause UPDATE to fail for a table that contains both an INTEGER PRIMARY KEY and an index. (CVS 346) (check-in: 96cd07a881 user: drh tags: trunk)
2002-01-10
14:31
Fix a problem with the way temporary tables mask permanent tables. (CVS 345) (check-in: ba89da6031 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/update.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 UPDATE statements.
**
** $Id: update.c,v 1.25 2001/12/31 02:48:51 drh Exp $
*/
#include "sqliteInt.h"

/*
** Process an UPDATE statement.
*/
void sqliteUpdate(







|







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 UPDATE statements.
**
** $Id: update.c,v 1.26 2002/01/14 02:56:25 drh Exp $
*/
#include "sqliteInt.h"

/*
** Process an UPDATE statement.
*/
void sqliteUpdate(
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
      goto update_cleanup;
    }
    if( sqliteExprCheck(pParse, pChanges->a[i].pExpr, 0, 0) ){
      goto update_cleanup;
    }
    for(j=0; j<pTab->nCol; j++){
      if( sqliteStrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){
        if( i==pTab->iPKey ){
          chngRecno = 1;
          pRecnoExpr = pChanges->a[i].pExpr;
        }
        aXRef[j] = i;
        break;
      }
    }







|







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
      goto update_cleanup;
    }
    if( sqliteExprCheck(pParse, pChanges->a[i].pExpr, 0, 0) ){
      goto update_cleanup;
    }
    for(j=0; j<pTab->nCol; j++){
      if( sqliteStrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){
        if( j==pTab->iPKey ){
          chngRecno = 1;
          pRecnoExpr = pChanges->a[i].pExpr;
        }
        aXRef[j] = i;
        break;
      }
    }
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.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
#







|







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.5 2002/01/14 02:56:26 drh Exp $

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

# Create a table with a primary key and a datatype other than
# integer
#
406
407
408
409
410
411
412
413






















414
  }
} {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








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
  }
} {30 new row}
do_test intpkey-7.2 {
  execsql {
    SELECT * FROM t1 WHERE rowid>20;
  }
} {22 b-22 c-22 30 new row}

# Do an insert from a select statement.
#
do_test intpkey-8.1 {
  execsql {
    CREATE TABLE t2(x INTEGER PRIMARY KEY, y, z);
    INSERT INTO t2 SELECT * FROM t1;
    SELECT rowid FROM t2;
  }
} {-4 0 5 6 11 20 22 30}
do_test intpkey-8.2 {
  execsql {
    SELECT x FROM t2;
  }
} {-4 0 5 6 11 20 22 30}

do_test intpkey-9.1 {
  execsql {
    UPDATE t1 SET c='www' WHERE c='world';
    SELECT rowid, a, c FROM t1 WHERE c=='www';
  }
} {5 5 www 11 11 www}

finish_test
Changes to www/changes.tcl.
13
14
15
16
17
18
19
20
21
22


23
24
25
26
27
28
29


proc chng {date desc} {
  puts "<DT><B>$date</B></DT>"
  puts "<DD><P><UL>$desc</UL></P></DD>"
}

chng {2002 Jan 10 (2.2.2)} {
<li>Bug fix: An assertion was failing when a temporary table with an index
    had the same name as a permanent table created by a separate process.</li>


}

chng {2002 Jan 9 (2.2.1)} {
<li>Bug fix: An attempt to delete a single row of a table with a WHERE
    clause of "ROWID=x" when no such rowid exists was causing an error.</li>
<li>Bug fix: Passing in a NULL as the 3rd parameter to <b>sqlite_open()</b>
    would sometimes cause a coredump.</li>







|


>
>







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31


proc chng {date desc} {
  puts "<DT><B>$date</B></DT>"
  puts "<DD><P><UL>$desc</UL></P></DD>"
}

chng {2002 Jan 13 (2.2.2)} {
<li>Bug fix: An assertion was failing when a temporary table with an index
    had the same name as a permanent table created by a separate process.</li>
<li>Bug fix: Updates to tables containing an INTEGER PRIMARY KEY and an
    index could fail.</li>
}

chng {2002 Jan 9 (2.2.1)} {
<li>Bug fix: An attempt to delete a single row of a table with a WHERE
    clause of "ROWID=x" when no such rowid exists was causing an error.</li>
<li>Bug fix: Passing in a NULL as the 3rd parameter to <b>sqlite_open()</b>
    would sometimes cause a coredump.</li>