**
** SELECT * FROM carray($ptr,10,'char*');
**
+** There is a second table-valued funnction named "carrray_asc" that works
+** exactly like carray except that it requires the values in the $ptr array
+** to be in ascending order. Queries involving ORDER BY clauses can sometimes
+** be a little faster with carray_asc compared to plain carray. However, if
+** the application provides carray_asc($ptr) with a $ptr array in which the
+** elements are not in ascending order, then incorrect query results might
+** result.
+**
** HOW IT WORKS
**
** The carray "function" is really a virtual table with the
*/
static const char *azType[] = { "int32", "int64", "double", "char*" };
+/* carray_vtab is a subclass of sqlite3_vtab containing carray-specific
+** extensions.
+*/
+typedef struct carray_vtab carray_vtab;
+struct carray_vtab {
+ sqlite3_vtab base; /* Base class - must be first */
+ unsigned int mFlags; /* Operational flags */
+};
+
+/*
+** Possible values for carray_vtab.mFlags
+*/
+#define CARRAY_ASC 0x0001 /* Values are always in ascending order */
+
/* carray_cursor is a subclass of sqlite3_vtab_cursor which will
** serve as the underlying representation of a cursor that scans
sqlite3_vtab **ppVtab,
char **pzErr
){
- sqlite3_vtab *pNew;
+ carray_vtab *pNew;
int rc;
/* Column numbers */
rc = sqlite3_declare_vtab(db,
"CREATE TABLE x(value,pointer hidden,count hidden,ctype hidden)");
if( rc==SQLITE_OK ){
- pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) );
+ pNew = sqlite3_malloc( sizeof(*pNew) );
+ *ppVtab = (sqlite3_vtab*)pNew;
if( pNew==0 ) return SQLITE_NOMEM;
memset(pNew, 0, sizeof(*pNew));
+ if( pAux ) pNew->mFlags = *(unsigned int*)pAux;
}
return rc;
}
pIdxInfo->estimatedCost = (double)1;
pIdxInfo->estimatedRows = 100;
pIdxInfo->idxNum = 2;
+ if( pIdxInfo->nOrderBy==1
+ && pIdxInfo->aOrderBy[0].iColumn==0
+ && pIdxInfo->aOrderBy[0].desc==0
+ && (((carray_vtab*)tab)->mFlags & CARRAY_ASC)!=0
+ ){
+ pIdxInfo->orderByConsumed = 1;
+ }
if( ctypeIdx>=0 ){
pIdxInfo->aConstraintUsage[ctypeIdx].argvIndex = 3;
pIdxInfo->aConstraintUsage[ctypeIdx].omit = 1;
const sqlite3_api_routines *pApi
){
int rc = SQLITE_OK;
+ static const unsigned int mAscFlags = CARRAY_ASC;
SQLITE_EXTENSION_INIT2(pApi);
#ifndef SQLITE_OMIT_VIRTUALTABLE
rc = sqlite3_create_module(db, "carray", &carrayModule, 0);
+ if( rc==SQLITE_OK ){
+ rc = sqlite3_create_module(db, "carray_asc", &carrayModule,
+ (void*)&mAscFlags);
+ }
#endif
return rc;
}
-C Remove\sthe\sCLANG_VERSION\smacro,\ssince\swe\shave\slearned\sthat\sversion\snumbers\sin\nclang\sare\s"marketing"\sand\sare\sinconsistent\sand\sunreliable.\s\sBuilds\susing\sclang\nwill\sstill\suse\sthe\sGCC_VERSION\smacro\ssince\sclang\sworks\shard\sto\sbe\sgcc\ncompatible.
-D 2017-02-15T15:09:09.031
+C Add\sthe\scompanion\s"carray_asc"\stable-valued\sfunction\sto\sthe\scarray\sextension.
+D 2017-02-15T16:11:06.169
F Makefile.in edb6bcdd37748d2b1c3422ff727c748df7ffe918
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 067a6766f800cc8d72845ab61f8de4ffe8f3fc99
F ext/icu/icu.c 84900472a088a3a172c6c079f58a1d3a1952c332
F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37
F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234
-F ext/misc/carray.c 40c27641010a4dc67e3690bdb7c9d36ca58b3c2d
+F ext/misc/carray.c f98fc506df22b74b3cde996da5d702b520f84945
F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704
F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83
F ext/misc/csv.c 531a46cbad789fca0aa9db69a0e6c8ac9e68767d
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P ee1e689633e517ce46307b9afbf1eda03482c928
-R 09fd15812127544dc0546a143adbc35f
+P 810d29320b853b3a01aa50d8f2a0bceacf79e0aa
+Q +396b9d99ae43cc5c9ce18509754aac001eae0ecf
+R 854f2bd98a5aec3c801c3b865d9cafe4
+T *branch * carray_asc
+T *sym-carray_asc *
+T -sym-trunk *
U drh
-Z f21515d79bd695dc7bd9e01927424a91
+Z 5a5965a82585c6466315592e6eda4385