/ Check-in [876d09d9]
Login

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

Overview
Comment:Fix an infinite loop in the code generator for INSERT. Ticket #1140. (CVS 2410)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:876d09d9145775956913e975c29e81d7553839ac
User & Date: drh 2005-03-21 01:20:58
Context
2005-03-21
01:24
fix typo in CREATE VIEW documentation. Ticket #1135. (CVS 2411) check-in: 38897a50 user: drh tags: trunk
01:20
Fix an infinite loop in the code generator for INSERT. Ticket #1140. (CVS 2410) check-in: 876d09d9 user: drh tags: trunk
00:47
README file updated to suggest running "make install". Ticket #1168. (CVS 2409) check-in: b48784cf user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/insert.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle INSERT statements in SQLite.
    14     14   **
    15         -** $Id: insert.c,v 1.137 2005/03/16 12:15:21 danielk1977 Exp $
           15  +** $Id: insert.c,v 1.138 2005/03/21 01:20:58 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Set P3 of the most recently inserted opcode to a column affinity
    21     21   ** string for index pIdx. A column affinity string has one character
    22     22   ** for each column in the table, according to the affinity of the column:
................................................................................
   104    104   */
   105    105   static int selectReadsTable(Select *p, int iDb, int iTab){
   106    106     int i;
   107    107     struct SrcList_item *pItem;
   108    108     if( p->pSrc==0 ) return 0;
   109    109     for(i=0, pItem=p->pSrc->a; i<p->pSrc->nSrc; i++, pItem++){
   110    110       if( pItem->pSelect ){
   111         -      if( selectReadsTable(p, iDb, iTab) ) return 1;
          111  +      if( selectReadsTable(pItem->pSelect, iDb, iTab) ) return 1;
   112    112       }else{
   113    113         if( pItem->pTab->iDb==iDb && pItem->pTab->tnum==iTab ) return 1;
   114    114       }
   115    115     }
   116    116     return 0;
   117    117   }
   118    118   

Changes to test/insert.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the INSERT statement.
    13     13   #
    14         -# $Id: insert.test,v 1.23 2005/01/21 03:12:16 danielk1977 Exp $
           14  +# $Id: insert.test,v 1.24 2005/03/21 01:20:58 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Try to insert into a non-existant table.
    20     20   #
    21     21   do_test insert-1.1 {
................................................................................
   335    335     }
   336    336   } {}
   337    337   do_test insert-7.3 {
   338    338     execsql {
   339    339       SELECT a FROM t1;
   340    340     }
   341    341   } {1 2 2}
          342  +
          343  +# Ticket #1140:  Check for an infinite loop in the algorithm that tests
          344  +# to see if the right-hand side of an INSERT...SELECT references the left-hand
          345  +# side.
          346  +#
          347  +do_test insert-8.1 {
          348  +  execsql {
          349  +    INSERT INTO t3 SELECT * FROM (SELECT * FROM t3 UNION ALL SELECT 1,2,3)
          350  +  }
          351  +} {}
          352  +
   342    353   
   343    354   integrity_check insert-99.0
   344    355   
   345    356   finish_test