Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add simple tests for the xColumnText() extension api. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | fts5 |
Files: | files | file ages | folders |
SHA1: |
1e9053abdaf5e128d44504ee00dfd909 |
User & Date: | dan 2014-07-19 20:27:54.153 |
Context
2014-07-21
| ||
11:44 | Fix the xColumnSize() extension API. (check-in: 19504c4108 user: dan tags: fts5) | |
2014-07-19
| ||
20:27 | Add simple tests for the xColumnText() extension api. (check-in: 1e9053abda user: dan tags: fts5) | |
15:35 | Fixes for the xColumnSize() fts5 extension API. (check-in: 43fcb84472 user: dan tags: fts5) | |
Changes
Changes to ext/fts5/fts5.c.
︙ | ︙ | |||
653 654 655 656 657 658 659 | int iCol, const char **pz, int *pn ){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; int rc = fts5SeekCursor(pCsr); if( rc==SQLITE_OK ){ | | | | 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | int iCol, const char **pz, int *pn ){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; int rc = fts5SeekCursor(pCsr); if( rc==SQLITE_OK ){ *pz = (const char*)sqlite3_column_text(pCsr->pStmt, iCol+1); *pn = sqlite3_column_bytes(pCsr->pStmt, iCol+1); } return rc; } static int fts5ApiColumnSize(Fts5Context *pCtx, int iCol, int *pnToken){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab); |
︙ | ︙ |
Changes to ext/fts5/fts5.h.
︙ | ︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 | ** ** xColumnCount: ** Returns the number of columns in the FTS5 table. ** ** xColumnSize: ** Reports the size in tokens of a column value from the current row. ** ** xPhraseCount: ** Returns the number of phrases in the current query expression. ** ** xPhraseSize: ** Returns the number of tokens in phrase iPhrase of the query. Phrases ** are numbered starting from zero. ** | > > > | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | ** ** xColumnCount: ** Returns the number of columns in the FTS5 table. ** ** xColumnSize: ** Reports the size in tokens of a column value from the current row. ** ** xColumnText: ** Reports the size in tokens of a column value from the current row. ** ** xPhraseCount: ** Returns the number of phrases in the current query expression. ** ** xPhraseSize: ** Returns the number of tokens in phrase iPhrase of the query. Phrases ** are numbered starting from zero. ** |
︙ | ︙ |
Changes to ext/fts5/fts5Int.h.
︙ | ︙ | |||
85 86 87 88 89 90 91 92 93 94 95 96 97 98 | void sqlite3Fts5BufferAppendVarint(int*, Fts5Buffer*, i64); void sqlite3Fts5BufferAppendBlob(int*, Fts5Buffer*, int, const u8*); void sqlite3Fts5BufferAppendString(int *, Fts5Buffer*, const char*); void sqlite3Fts5BufferFree(Fts5Buffer*); void sqlite3Fts5BufferZero(Fts5Buffer*); void sqlite3Fts5BufferSet(int*, Fts5Buffer*, int, const u8*); void sqlite3Fts5BufferAppendPrintf(int *, Fts5Buffer*, char *zFmt, ...); #define fts5BufferZero(x) sqlite3Fts5BufferZero(x) #define fts5BufferGrow(a,b,c) sqlite3Fts5BufferGrow(a,b,c) #define fts5BufferAppendVarint(a,b,c) sqlite3Fts5BufferAppendVarint(a,b,c) #define fts5BufferFree(a) sqlite3Fts5BufferFree(a) #define fts5BufferAppendBlob(a,b,c,d) sqlite3Fts5BufferAppendBlob(a,b,c,d) #define fts5BufferSet(a,b,c,d) sqlite3Fts5BufferSet(a,b,c,d) | > | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | void sqlite3Fts5BufferAppendVarint(int*, Fts5Buffer*, i64); void sqlite3Fts5BufferAppendBlob(int*, Fts5Buffer*, int, const u8*); void sqlite3Fts5BufferAppendString(int *, Fts5Buffer*, const char*); void sqlite3Fts5BufferFree(Fts5Buffer*); void sqlite3Fts5BufferZero(Fts5Buffer*); void sqlite3Fts5BufferSet(int*, Fts5Buffer*, int, const u8*); void sqlite3Fts5BufferAppendPrintf(int *, Fts5Buffer*, char *zFmt, ...); void sqlite3Fts5BufferAppendListElem(int*, Fts5Buffer*, const char*, int); #define fts5BufferZero(x) sqlite3Fts5BufferZero(x) #define fts5BufferGrow(a,b,c) sqlite3Fts5BufferGrow(a,b,c) #define fts5BufferAppendVarint(a,b,c) sqlite3Fts5BufferAppendVarint(a,b,c) #define fts5BufferFree(a) sqlite3Fts5BufferFree(a) #define fts5BufferAppendBlob(a,b,c,d) sqlite3Fts5BufferAppendBlob(a,b,c,d) #define fts5BufferSet(a,b,c,d) sqlite3Fts5BufferSet(a,b,c,d) |
︙ | ︙ |
Changes to ext/fts5/fts5_aux.c.
︙ | ︙ | |||
60 61 62 63 64 65 66 67 68 69 70 71 72 73 | for(i=0; rc==SQLITE_OK && i<nCol; i++){ int colsz = 0; rc = pApi->xColumnSize(pFts, i, &colsz); sqlite3Fts5BufferAppendPrintf(&rc, &s, "%s%d", i==0?"":" ", colsz); } if( zReq==0 && nCol>1 ) sqlite3Fts5BufferAppendPrintf(&rc, &s, "}"); } if( zReq==0 ){ sqlite3Fts5BufferAppendPrintf(&rc, &s, " phrasecount "); } nPhrase = pApi->xPhraseCount(pFts); if( 0==zReq || 0==sqlite3_stricmp(zReq, "phrasecount") ){ sqlite3Fts5BufferAppendPrintf(&rc, &s, "%d", nPhrase); | > > > > > > > > > > > > > | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | for(i=0; rc==SQLITE_OK && i<nCol; i++){ int colsz = 0; rc = pApi->xColumnSize(pFts, i, &colsz); sqlite3Fts5BufferAppendPrintf(&rc, &s, "%s%d", i==0?"":" ", colsz); } if( zReq==0 && nCol>1 ) sqlite3Fts5BufferAppendPrintf(&rc, &s, "}"); } if( zReq==0 ){ sqlite3Fts5BufferAppendPrintf(&rc, &s, "columntext "); } if( 0==zReq || 0==sqlite3_stricmp(zReq, "columntext") ){ for(i=0; rc==SQLITE_OK && i<nCol; i++){ const char *z; int n; rc = pApi->xColumnText(pFts, i, &z, &n); if( i!=0 ) sqlite3Fts5BufferAppendPrintf(&rc, &s, " "); sqlite3Fts5BufferAppendListElem(&rc, &s, z, n); } } if( zReq==0 ){ sqlite3Fts5BufferAppendPrintf(&rc, &s, " phrasecount "); } nPhrase = pApi->xPhraseCount(pFts); if( 0==zReq || 0==sqlite3_stricmp(zReq, "phrasecount") ){ sqlite3Fts5BufferAppendPrintf(&rc, &s, "%d", nPhrase); |
︙ | ︙ |
Changes to ext/fts5/fts5_buffer.c.
︙ | ︙ | |||
227 228 229 230 231 232 233 234 235 | *piOff = 0; i += getVarint32(&a[i], iVal); } *piOff += (iVal-2); *pi = i; return 0; } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | *piOff = 0; i += getVarint32(&a[i], iVal); } *piOff += (iVal-2); *pi = i; return 0; } void sqlite3Fts5BufferAppendListElem( int *pRc, /* IN/OUT: Error code */ Fts5Buffer *pBuf, /* Buffer to append to */ const char *z, int n /* Value to append to buffer */ ){ int bParen = (n==0); int nMax = n*2 + 2 + 1; u8 *pOut; int i; /* Ensure the buffer has space for the new list element */ if( sqlite3Fts5BufferGrow(pRc, pBuf, nMax) ) return; pOut = &pBuf->p[pBuf->n]; /* Figure out if we need the enclosing {} */ for(i=0; i<n && bParen==0; i++){ if( z[i]=='"' || z[i]==' ' ){ bParen = 1; } } if( bParen ) *pOut++ = '{'; for(i=0; i<n; i++){ *pOut++ = z[i]; } if( bParen ) *pOut++ = '}'; pBuf->n = pOut - pBuf->p; *pOut = '\0'; } |
Changes to test/fts5ae.test.
︙ | ︙ | |||
142 143 144 145 146 147 148 149 150 151 152 | SELECT rowid, fts5_test(t5, 'columnsize') FROM t5 WHERE t5 MATCH 'a' ORDER BY rowid DESC; } { 3 {1 0} 2 {0 1} 1 {4 6} } finish_test | > > > > > > > > > | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | SELECT rowid, fts5_test(t5, 'columnsize') FROM t5 WHERE t5 MATCH 'a' ORDER BY rowid DESC; } { 3 {1 0} 2 {0 1} 1 {4 6} } do_execsql_test 5.2 { SELECT rowid, fts5_test(t5, 'columntext') FROM t5 WHERE t5 MATCH 'a' ORDER BY rowid DESC; } { 3 {a {}} 2 {{} a} 1 {{a b c d} {e f g h i j}} } finish_test |