/ Check-in [ee30fb35]
Login

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

Overview
Comment:Avoid O(N*N) behavior with very long lists of VALUES.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | many-VALUEs
Files: files | file ages | folders
SHA1: ee30fb35217f3429ee89aaad7c19f29710420e4c
User & Date: drh 2015-01-05 20:04:51
Context
2015-01-05
20:13
Enhance "INSERT INTO ... VALUES" so that the number of rows in the VALUES clause is not limited by SQLITE_LIMIT_COMPOUND_SELECT, and so that the stack depth is constant regardless of the number of rows in VALUES. check-in: e1c4a359 user: drh tags: trunk
20:04
Avoid O(N*N) behavior with very long lists of VALUES. Closed-Leaf check-in: ee30fb35 user: drh tags: many-VALUEs
19:16
Handle compound-select statements originating from VALUES clauses as a special case that does not use recursion. check-in: 9ce9e43a user: drh tags: many-VALUEs
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

  4111   4111       return WRC_Abort;
  4112   4112     }
  4113   4113     if( NEVER(p->pSrc==0) || (selFlags & SF_Expanded)!=0 ){
  4114   4114       return WRC_Prune;
  4115   4115     }
  4116   4116     pTabList = p->pSrc;
  4117   4117     pEList = p->pEList;
  4118         -  sqlite3WithPush(pParse, findRightmost(p)->pWith, 0);
         4118  +  if( pWalker->xSelectCallback2==selectPopWith ){
         4119  +    sqlite3WithPush(pParse, findRightmost(p)->pWith, 0);
         4120  +  }
  4119   4121   
  4120   4122     /* Make sure cursor numbers have been assigned to all entries in
  4121   4123     ** the FROM clause of the SELECT statement.
  4122   4124     */
  4123   4125     sqlite3SrcListAssignCursors(pParse, pTabList);
  4124   4126   
  4125   4127     /* Look up every table named in the FROM clause of the select.  If
................................................................................
  4402   4404     w.xExprCallback = exprWalkNoop;
  4403   4405     w.pParse = pParse;
  4404   4406     if( pParse->hasCompound ){
  4405   4407       w.xSelectCallback = convertCompoundSelectToSubquery;
  4406   4408       sqlite3WalkSelect(&w, pSelect);
  4407   4409     }
  4408   4410     w.xSelectCallback = selectExpander;
  4409         -  w.xSelectCallback2 = selectPopWith;
         4411  +  if( (pSelect->selFlags & SF_AllValues)==0 ){
         4412  +    w.xSelectCallback2 = selectPopWith;
         4413  +  }
  4410   4414     sqlite3WalkSelect(&w, pSelect);
  4411   4415   }
  4412   4416   
  4413   4417   
  4414   4418   #ifndef SQLITE_OMIT_SUBQUERY
  4415   4419   /*
  4416   4420   ** This is a Walker.xSelectCallback callback for the sqlite3SelectTypeInfo()