aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2002-04-09 03:28:01 +0000
committerdrh <drh@noemail.net>2002-04-09 03:28:01 +0000
commitfeeb1394eea276e9b3da6c75952f6d1bc6ae2e11 (patch)
tree7d9c9c09a1521f8198af1b2ec5a5a315b0b63973 /src
parentfe1a1773a821d81fc33304d63f2e999005e83cb4 (diff)
downloadsqlite-feeb1394eea276e9b3da6c75952f6d1bc6ae2e11.tar.gz
sqlite-feeb1394eea276e9b3da6c75952f6d1bc6ae2e11.zip
Fix for bug #11: Output the correct row count when and INSERT does an
IGNORE action. (CVS 524) FossilOrigin-Name: bb83642e9a6c1c9ade861618496933c9f922a8f8
Diffstat (limited to 'src')
-rw-r--r--src/insert.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/insert.c b/src/insert.c
index 0a05c0819..55e2a212a 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle INSERT statements in SQLite.
**
-** $Id: insert.c,v 1.49 2002/04/09 03:15:07 drh Exp $
+** $Id: insert.c,v 1.50 2002/04/09 03:28:01 drh Exp $
*/
#include "sqliteInt.h"
@@ -183,15 +183,18 @@ void sqliteInsert(
}
pParse->nTab += idx;
+ /* Initialize the count of rows to be inserted
+ */
+ if( db->flags & SQLITE_CountRows ){
+ sqliteVdbeAddOp(v, OP_Integer, 0, 0); /* Initialize the row count */
+ }
+
/* If the data source is a SELECT statement, then we have to create
** a loop because there might be multiple rows of data. If the data
** source is an expression list, then exactly one row will be inserted
** and the loop is not used.
*/
if( srcTab>=0 ){
- if( db->flags & SQLITE_CountRows ){
- sqliteVdbeAddOp(v, OP_Integer, 0, 0); /* Initialize the row count */
- }
iBreak = sqliteVdbeMakeLabel(v);
sqliteVdbeAddOp(v, OP_Rewind, srcTab, iBreak);
iCont = sqliteVdbeCurrentAddr(v);
@@ -258,10 +261,9 @@ void sqliteInsert(
sqliteGenerateConstraintChecks(pParse, pTab, base, 0,0,0, onError, endOfLoop);
sqliteCompleteInsertion(pParse, pTab, base, 0,0,0);
- /* If inserting from a SELECT, keep a count of the number of
- ** rows inserted.
+ /* Update the count of rows that are inserted
*/
- if( srcTab>=0 && (db->flags & SQLITE_CountRows)!=0 ){
+ if( (db->flags & SQLITE_CountRows)!=0 ){
sqliteVdbeAddOp(v, OP_AddImm, 1, 0);
}
@@ -286,9 +288,6 @@ void sqliteInsert(
sqliteVdbeAddOp(v, OP_ColumnCount, 1, 0);
sqliteVdbeAddOp(v, OP_ColumnName, 0, 0);
sqliteVdbeChangeP3(v, -1, "rows inserted", P3_STATIC);
- if( srcTab<0 ){
- sqliteVdbeAddOp(v, OP_Integer, 1, 0);
- }
sqliteVdbeAddOp(v, OP_Callback, 1, 0);
}