Enhance speedtest1.c so that is works on older versions of SQLite, before
the introduction of the group_concat() aggregate function. FossilOrigin-Name: 9979ba80a649ee61d9d174dc9d9fcab7e9fc1332
This commit is contained in:
parent
c10b9dac84
commit
89500dcd0b
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sharmless\scompiler\swarnings.
|
||||
D 2016-11-20T17:59:59.686
|
||||
C Enhance\sspeedtest1.c\sso\sthat\sis\sworks\son\solder\sversions\sof\sSQLite,\sbefore\nthe\sintroduction\sof\sthe\sgroup_concat()\saggregate\sfunction.
|
||||
D 2016-11-21T18:15:35.996
|
||||
F Makefile.in 6b572807415d3f0a379cebc9461416d8df4a12c8
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc bb4d970894abbbe0e88d00aac29bd52af8bc95f4
|
||||
@ -1120,7 +1120,7 @@ F test/speed3.test 694affeb9100526007436334cf7d08f3d74b85ef
|
||||
F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715
|
||||
F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa
|
||||
F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b
|
||||
F test/speedtest1.c 2699cdb3c04cdaa44f47bf3cb0b720d8c52883e6
|
||||
F test/speedtest1.c dae4b22c620743e2767d0ec9fc11f2d1d6383ff1
|
||||
F test/spellfix.test f9c1f431e2c096c8775fec032952320c0e4700db
|
||||
F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3
|
||||
F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33
|
||||
@ -1534,7 +1534,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 0a98c8d76ac86412d5eb68de994658c250989349
|
||||
R 38b98996abd27ed143b71be3145a6356
|
||||
P b3b7b42d9a4a0e7e2be8b2933328a7bec2f49a81
|
||||
R 142d4e960b1bc74fe4e27f638486681b
|
||||
U drh
|
||||
Z ab3b36c0e8942c1f47487ebf38a820ad
|
||||
Z 46dbec5fea6f8ea94f3f3ff9f77bd1e2
|
||||
|
@ -1 +1 @@
|
||||
b3b7b42d9a4a0e7e2be8b2933328a7bec2f49a81
|
||||
9979ba80a649ee61d9d174dc9d9fcab7e9fc1332
|
@ -456,6 +456,68 @@ static int est_square_root(int x){
|
||||
return y0;
|
||||
}
|
||||
|
||||
|
||||
#if SQLITE_VERSION_NUMBER<3005004
|
||||
/*
|
||||
** An implementation of group_concat(). Used only when testing older
|
||||
** versions of SQLite that lack the built-in group_concat().
|
||||
*/
|
||||
struct groupConcat {
|
||||
char *z;
|
||||
int nAlloc;
|
||||
int nUsed;
|
||||
};
|
||||
static void groupAppend(struct groupConcat *p, const char *z, int n){
|
||||
if( p->nUsed+n >= p->nAlloc ){
|
||||
int n2 = (p->nAlloc+n+1)*2;
|
||||
char *z2 = sqlite3_realloc(p->z, n2);
|
||||
if( z2==0 ) return;
|
||||
p->z = z2;
|
||||
p->nAlloc = n2;
|
||||
}
|
||||
memcpy(p->z+p->nUsed, z, n);
|
||||
p->nUsed += n;
|
||||
}
|
||||
static void groupStep(
|
||||
sqlite3_context *context,
|
||||
int argc,
|
||||
sqlite3_value **argv
|
||||
){
|
||||
const char *zVal;
|
||||
struct groupConcat *p;
|
||||
const char *zSep;
|
||||
int nVal, nSep;
|
||||
assert( argc==1 || argc==2 );
|
||||
if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
|
||||
p= (struct groupConcat*)sqlite3_aggregate_context(context, sizeof(*p));
|
||||
|
||||
if( p ){
|
||||
int firstTerm = p->nUsed==0;
|
||||
if( !firstTerm ){
|
||||
if( argc==2 ){
|
||||
zSep = (char*)sqlite3_value_text(argv[1]);
|
||||
nSep = sqlite3_value_bytes(argv[1]);
|
||||
}else{
|
||||
zSep = ",";
|
||||
nSep = 1;
|
||||
}
|
||||
if( nSep ) groupAppend(p, zSep, nSep);
|
||||
}
|
||||
zVal = (char*)sqlite3_value_text(argv[0]);
|
||||
nVal = sqlite3_value_bytes(argv[0]);
|
||||
if( zVal ) groupAppend(p, zVal, nVal);
|
||||
}
|
||||
}
|
||||
static void groupFinal(sqlite3_context *context){
|
||||
struct groupConcat *p;
|
||||
p = sqlite3_aggregate_context(context, 0);
|
||||
if( p && p->z ){
|
||||
p->z[p->nUsed] = 0;
|
||||
sqlite3_result_text(context, p->z, p->nUsed, sqlite3_free);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The main and default testset
|
||||
*/
|
||||
@ -525,6 +587,10 @@ void testset_main(void){
|
||||
speedtest1_exec("COMMIT");
|
||||
speedtest1_end_test();
|
||||
|
||||
#if SQLITE_VERSION_NUMBER<3005004
|
||||
sqlite3_create_function(g.db, "group_concat", 1, SQLITE_UTF8, 0,
|
||||
0, groupStep, groupFinal);
|
||||
#endif
|
||||
|
||||
n = 25;
|
||||
speedtest1_begin_test(130, "%d SELECTS, numeric BETWEEN, unindexed", n);
|
||||
@ -1371,10 +1437,12 @@ int main(int argc, char **argv){
|
||||
nLook = integerValue(argv[i+1]);
|
||||
szLook = integerValue(argv[i+2]);
|
||||
i += 2;
|
||||
#if SQLITE_VERSION_NUMBER>=3006000
|
||||
}else if( strcmp(z,"multithread")==0 ){
|
||||
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
|
||||
}else if( strcmp(z,"nomemstat")==0 ){
|
||||
sqlite3_config(SQLITE_CONFIG_MEMSTATUS, 0);
|
||||
#endif
|
||||
}else if( strcmp(z,"nosync")==0 ){
|
||||
noSync = 1;
|
||||
}else if( strcmp(z,"notnull")==0 ){
|
||||
@ -1406,10 +1474,12 @@ int main(int argc, char **argv){
|
||||
nScratch = integerValue(argv[i+1]);
|
||||
szScratch = integerValue(argv[i+2]);
|
||||
i += 2;
|
||||
#if SQLITE_VERSION_NUMBER>=3006000
|
||||
}else if( strcmp(z,"serialized")==0 ){
|
||||
sqlite3_config(SQLITE_CONFIG_SERIALIZED);
|
||||
}else if( strcmp(z,"singlethread")==0 ){
|
||||
sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
|
||||
#endif
|
||||
}else if( strcmp(z,"sqlonly")==0 ){
|
||||
g.bSqlOnly = 1;
|
||||
}else if( strcmp(z,"shrink-memory")==0 ){
|
||||
|
Loading…
x
Reference in New Issue
Block a user