Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | When initializing the sqlite_sequence entry for an AUTOINCREMENT table, make sure the value is an reasonable integer even if the initial insert failed. Ticket #3148. (CVS 5175) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
7e6847852d4517b1d14bebb8f0ae4d93 |
User & Date: | drh 2008-05-29 03:20:59.000 |
Context
2008-05-29
| ||
03:54 | Moved check and define for OS_WINCE from os_win.c to os.h (with the other OS_* defines). This allows OS_WINCE to be available for mutex_w32.c which is included earlier than os_win.c in the almagamation. (CVS 5176) (check-in: ad6a782e7c user: shane tags: trunk) | |
03:20 | When initializing the sqlite_sequence entry for an AUTOINCREMENT table, make sure the value is an reasonable integer even if the initial insert failed. Ticket #3148. (CVS 5175) (check-in: 7e6847852d user: drh tags: trunk) | |
03:12 | Fix an obsolete comment on the OP_Rowid opcode in the VDBE. (CVS 5174) (check-in: 0d55328e68 user: drh tags: trunk) | |
Changes
Changes to src/insert.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** 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. ** | | | 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.239 2008/05/29 03:20:59 drh Exp $ */ #include "sqliteInt.h" /* ** Set P4 of the most recently inserted opcode to a column affinity ** string for index pIdx. A column affinity string has one character ** for each column in the table, according to the affinity of the column: |
︙ | ︙ | |||
171 172 173 174 175 176 177 | assert( v ); pParse->nMem++; /* Holds name of table */ memId = ++pParse->nMem; pParse->nMem++; sqlite3OpenTable(pParse, iCur, iDb, pDb->pSchema->pSeqTab, OP_OpenRead); addr = sqlite3VdbeCurrentAddr(v); sqlite3VdbeAddOp4(v, OP_String8, 0, memId-1, 0, pTab->zName, 0); | | | > | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | assert( v ); pParse->nMem++; /* Holds name of table */ memId = ++pParse->nMem; pParse->nMem++; sqlite3OpenTable(pParse, iCur, iDb, pDb->pSchema->pSeqTab, OP_OpenRead); addr = sqlite3VdbeCurrentAddr(v); sqlite3VdbeAddOp4(v, OP_String8, 0, memId-1, 0, pTab->zName, 0); sqlite3VdbeAddOp2(v, OP_Rewind, iCur, addr+9); sqlite3VdbeAddOp3(v, OP_Column, iCur, 0, memId); sqlite3VdbeAddOp3(v, OP_Ne, memId-1, addr+7, memId); sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL); sqlite3VdbeAddOp2(v, OP_Rowid, iCur, memId+1); sqlite3VdbeAddOp3(v, OP_Column, iCur, 1, memId); sqlite3VdbeAddOp2(v, OP_Goto, 0, addr+9); sqlite3VdbeAddOp2(v, OP_Next, iCur, addr+2); sqlite3VdbeAddOp2(v, OP_Integer, 0, memId); sqlite3VdbeAddOp2(v, OP_Close, iCur, 0); } return memId; } /* ** Update the maximum rowid for an autoincrement calculation. |
︙ | ︙ |
Changes to test/autoinc.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2004 November 12 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # 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 is testing the AUTOINCREMENT features. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2004 November 12 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # 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 is testing the AUTOINCREMENT features. # # $Id: autoinc.test,v 1.12 2008/05/29 03:20:59 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # If the library is not compiled with autoincrement support then # skip all tests in this file. |
︙ | ︙ | |||
530 531 532 533 534 535 536 537 538 | sqlite3_step $STMT sqlite3_finalize $STMT execsql { INSERT INTO t1 VALUES(NULL); SELECT * FROM t1; } } {1} finish_test | > > > > > > > > > > > > > > > > > | 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | sqlite3_step $STMT sqlite3_finalize $STMT execsql { INSERT INTO t1 VALUES(NULL); SELECT * FROM t1; } } {1} # Ticket #3148 # Make sure the sqlite_sequence table is not damaged when doing # an empty insert - an INSERT INTO ... SELECT ... where the SELECT # clause returns an empty set. # do_test autoinc-9.1 { db eval { CREATE TABLE t2(x INTEGER PRIMARY KEY AUTOINCREMENT, y); INSERT INTO t2 VALUES(NULL, 1); CREATE TABLE t3(a INTEGER PRIMARY KEY AUTOINCREMENT, b); INSERT INTO t3 SELECT * FROM t2 WHERE y>1; SELECT * FROM sqlite_sequence WHERE name='t3'; } } {t3 0} finish_test |