/ Check-in [8cb43edd]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Generate complete samples for sqlite_stat4 on WITHOUT ROWID tables. Ticket [b2fa5424e6fcb15b5]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | stat4-without-rowid
Files: files | file ages | folders
SHA1: 8cb43eddab83c68b2163441df70e0e9496d5fa33
User & Date: drh 2014-06-30 13:32:39
Context
2014-06-30
13:56
Omit non-primary-key columns from the STAT4 samples for WITHOUT ROWID tables. Indexes, both rowid and without-rowid, still hold an exact copy of the index entry. check-in: de826c31 user: drh tags: stat4-without-rowid
13:32
Generate complete samples for sqlite_stat4 on WITHOUT ROWID tables. Ticket [b2fa5424e6fcb15b5] check-in: 8cb43edd user: drh tags: stat4-without-rowid
11:14
Add makefile targets for various diagnostic tools, such as showstat4. Fix harmless compiler warnings in diagnostic tools. check-in: 6f86d89b user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/analyze.c.

  1041   1041       **  end_of_scan:
  1042   1042       */
  1043   1043   
  1044   1044       /* Make sure there are enough memory cells allocated to accommodate 
  1045   1045       ** the regPrev array and a trailing rowid (the rowid slot is required
  1046   1046       ** when building a record to insert into the sample column of 
  1047   1047       ** the sqlite_stat4 table.  */
  1048         -    pParse->nMem = MAX(pParse->nMem, regPrev+nCol);
         1048  +    pParse->nMem = MAX(pParse->nMem, regPrev+pIdx->nColumn);
  1049   1049   
  1050   1050       /* Open a read-only cursor on the index being analyzed. */
  1051   1051       assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) );
  1052   1052       sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb);
  1053   1053       sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
  1054   1054       VdbeComment((v, "%s", pIdx->zName));
  1055   1055   
................................................................................
  1182   1182         ** the previous loop.  Thus the not-found jump of seekOp will never
  1183   1183         ** be taken */
  1184   1184         VdbeCoverageNeverTaken(v);
  1185   1185   #ifdef SQLITE_ENABLE_STAT3
  1186   1186         sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, 
  1187   1187                                         pIdx->aiColumn[0], regSample);
  1188   1188   #else
  1189         -      for(i=0; i<nCol; i++){
         1189  +      i = HasRowid(pTab) ? nCol-1 : pIdx->nColumn-1;
         1190  +      for(; i>=0; i--){
  1190   1191           i16 iCol = pIdx->aiColumn[i];
  1191   1192           sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, iCol, regCol+i);
  1192   1193         }
  1193         -      sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nCol+1, regSample);
         1194  +      sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, pIdx->nColumn, regSample);
  1194   1195   #endif
  1195   1196         sqlite3VdbeAddOp3(v, OP_MakeRecord, regTabname, 6, regTemp);
  1196   1197         sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid);
  1197   1198         sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regTemp, regNewRowid);
  1198   1199         sqlite3VdbeAddOp2(v, OP_Goto, 1, addrNext); /* P1==1 for end-of-loop */
  1199   1200         sqlite3VdbeJumpHere(v, addrIsNull);
  1200   1201       }