SQLite

Check-in [42511a7e12]
Login

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

Overview
Comment:The NGQP might not find a solution if INDEXED BY constraints on the query are set wrong. If that is the case, print a "no query solution" error and abort before trying to use the non-existant solution.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | nextgen-query-plan-exp
Files: files | file ages | folders
SHA1: 42511a7e12a70cf3436d25e4d069e5d309dfd678
User & Date: drh 2013-05-31 20:43:57.656
Context
2013-06-03
14:15
Add test cases to verify that ticket [bc1aea7b725f2761] has been fixed in the NGQP. (check-in: 9b97af94ae user: drh tags: nextgen-query-plan-exp)
2013-05-31
20:43
The NGQP might not find a solution if INDEXED BY constraints on the query are set wrong. If that is the case, print a "no query solution" error and abort before trying to use the non-existant solution. (check-in: 42511a7e12 user: drh tags: nextgen-query-plan-exp)
20:28
Do not search using ON clause constraints of LEFT JOINs to the right of the table. (check-in: 723f901a63 user: drh tags: nextgen-query-plan-exp)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/where.c.
4860
4861
4862
4863
4864
4865
4866
4867

4868
4869


4870
4871
4872
4873
4874
4875
4876
    /* Swap the roles of aFrom and aTo for the next generation */
    pFrom = aTo;
    aTo = aFrom;
    aFrom = pFrom;
    nFrom = nTo;
  }

  /* TEMPORARY */

  if( nFrom==0 ){ sqlite3DbFree(db, pSpace); return SQLITE_ERROR; }
  assert( nFrom>0 );


  
  /* Find the lowest cost path.  pFrom will be left pointing to that path */
  pFrom = aFrom;
  for(ii=1; ii<nFrom; ii++){
    if( pFrom->rCost>aFrom[ii].rCost ) pFrom = &aFrom[ii];
  }
  assert( pWInfo->nLevel==nLoop );







|
>
|
<
>
>







4860
4861
4862
4863
4864
4865
4866
4867
4868
4869

4870
4871
4872
4873
4874
4875
4876
4877
4878
    /* Swap the roles of aFrom and aTo for the next generation */
    pFrom = aTo;
    aTo = aFrom;
    aFrom = pFrom;
    nFrom = nTo;
  }

  if( nFrom==0 ){
    sqlite3ErrorMsg(pWInfo->pParse, "no query solution");
    sqlite3DbFree(db, pSpace);

    return SQLITE_ERROR;
  }
  
  /* Find the lowest cost path.  pFrom will be left pointing to that path */
  pFrom = aFrom;
  for(ii=1; ii<nFrom; ii++){
    if( pFrom->rCost>aFrom[ii].rCost ) pFrom = &aFrom[ii];
  }
  assert( pWInfo->nLevel==nLoop );
5147
5148
5149
5150
5151
5152
5153



5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178

  wherePathSolver(pWInfo, -1);
  if( db->mallocFailed ) goto whereBeginError;
  if( pWInfo->pOrderBy ){
     wherePathSolver(pWInfo, pWInfo->nRowOut);
     if( db->mallocFailed ) goto whereBeginError;
  }



#ifdef WHERETRACE_ENABLED
  if( sqlite3WhereTrace ){
    int ii;
    sqlite3DebugPrintf("---- Solution");
    if( pWInfo->nOBSat ){
      sqlite3DebugPrintf(" ORDER BY omitted rev=0x%llx\n", pWInfo->revMask);
    }else{
      sqlite3DebugPrintf("\n");
    }
    for(ii=0; ii<nTabList; ii++){
      whereLoopPrint(pWInfo->a[ii].pWLoop, pTabList);
    }
  }
#endif
  WHERETRACE(("*** Optimizer Finished ***\n"));
  if( pParse->nErr || db->mallocFailed ){
    goto whereBeginError;
  }

#if 0  /* FIXME: Add this back in? */
  /* If the caller is an UPDATE or DELETE statement that is requesting
  ** to use a one-pass algorithm, determine if this is appropriate.
  ** The one-pass algorithm only works if the WHERE clause constraints
  ** the statement to update a single row.
  */







>
>
>















<
<
<







5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173



5174
5175
5176
5177
5178
5179
5180

  wherePathSolver(pWInfo, -1);
  if( db->mallocFailed ) goto whereBeginError;
  if( pWInfo->pOrderBy ){
     wherePathSolver(pWInfo, pWInfo->nRowOut);
     if( db->mallocFailed ) goto whereBeginError;
  }
  if( pParse->nErr || db->mallocFailed ){
    goto whereBeginError;
  }
#ifdef WHERETRACE_ENABLED
  if( sqlite3WhereTrace ){
    int ii;
    sqlite3DebugPrintf("---- Solution");
    if( pWInfo->nOBSat ){
      sqlite3DebugPrintf(" ORDER BY omitted rev=0x%llx\n", pWInfo->revMask);
    }else{
      sqlite3DebugPrintf("\n");
    }
    for(ii=0; ii<nTabList; ii++){
      whereLoopPrint(pWInfo->a[ii].pWLoop, pTabList);
    }
  }
#endif
  WHERETRACE(("*** Optimizer Finished ***\n"));




#if 0  /* FIXME: Add this back in? */
  /* If the caller is an UPDATE or DELETE statement that is requesting
  ** to use a one-pass algorithm, determine if this is appropriate.
  ** The one-pass algorithm only works if the WHERE clause constraints
  ** the statement to update a single row.
  */