-C Subquery\sflattening\sis\simplemented\sand\spasses\sall\sregression\stests.\nWe\sstill\sneed\sto\sadd\saddition\stests\sto\sthe\ssuite\sto\sfurther\sexercise\nthe\sflattener,\showever.\s(CVS\s408)
-D 2002-03-02T17:04:08
+C Change\sthe\sbtree\snode\sbalancers\sto\ssort\snodes\sinto\saccending\sorder.\s\sThis\nimproves\sinsert\sand\sdelete\sspeed\sby\s25%.\s(CVS\s409)
+D 2002-03-02T19:00:31
F Makefile.in 50f1b3351df109b5774771350d8c1b8d3640130d
F Makefile.template 89e373b2dad0321df00400fa968dc14b61a03296
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
F publish.sh 5b59f4aff037aafa0e4a3b6fa599495dbd73f360
F sqlite.1 2e2bb0529ef468ade9e4322bd609d0695fb9ded9
F src/TODO af7f3cab0228e34149cf98e073aa83d45878e7e6
-F src/btree.c 495275fe14f3b718cf2f691dce979d4c0e1f8e5d
+F src/btree.c 360c0aa4db058bd2d33269d7416178bdc7b7fe41
F src/btree.h 8abeabfe6e0b1a990b64fa457592a6482f6674f3
F src/build.c 2f6d3136e6b824b2b446c54db2d2be5703033203
F src/delete.c bf569eeb66dc851966b5681e5154d5fe2aee92c2
F src/expr.c 17e3db6f115d60530a55530e3046312196c5eb36
-F src/func.c 0db438ba17f3394dc5a3ffcd2ee41ca0c8e80b21
+F src/func.c 5b4d9707b0c8f463824c1f04547b524cba24bf7b
F src/hash.c cc259475e358baaf299b00a2c7370f2b03dda892
F src/hash.h dca065dda89d4575f3176e75e9a3dc0f4b4fb8b9
F src/insert.c 4fb3428f591afe106f6e60029a61f87fa0e79920
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
F www/tclsqlite.tcl 829b393d1ab187fd7a5e978631b3429318885c49
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P e14b0c82f3514f41934a7c0d173b6fdb186aafc8
-R f60c0ec90c7ca3b07c137c446692b495
+P d5d3e79cc58da5bd315cc1fea1f7cbf46274da16
+R e2a0844c770bfd758020b0af68cec917
U drh
-Z 28d7598277d139ff75ed8a6bf05f4a82
+Z fff6edd2a1ed34d852214cfe902efd49
-d5d3e79cc58da5bd315cc1fea1f7cbf46274da16
\ No newline at end of file
+abbb999d4fc3fe142567b6ede5e625e7bf0da714
\ No newline at end of file
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.55 2002/02/19 22:43:59 drh Exp $
+** $Id: btree.c,v 1.56 2002/03/02 19:00:31 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
apNew[i]->isInit = 1;
}
+ /*
+ ** Put the new pages in accending order. This helps to
+ ** keep entries in the disk file in order so that a scan
+ ** of the table is a linear scan through the file. That
+ ** in turn helps the operating system to deliver pages
+ ** from the disk more rapidly.
+ **
+ ** An O(n^2) insertion sort algorithm is used, but since
+ ** n is never more than 3, that should not be a problem.
+ **
+ ** This one optimization makes the database about 25%
+ ** faster for large insertions and deletions.
+ */
+ for(i=0; i<k-1; i++){
+ int minV = pgnoNew[i];
+ int minI = i;
+ for(j=i+1; j<k; j++){
+ if( pgnoNew[j]<minV ){
+ minI = j;
+ minV = pgnoNew[j];
+ }
+ }
+ if( minI>i ){
+ int t;
+ MemPage *pT;
+ t = pgnoNew[i];
+ pT = apNew[i];
+ pgnoNew[i] = pgnoNew[minI];
+ apNew[i] = apNew[minI];
+ pgnoNew[minI] = t;
+ apNew[minI] = pT;
+ }
+ }
+
/*
** Evenly distribute the data in apCell[] across the new pages.
** Insert divider cells into pParent as necessary.
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
-** $Id: func.c,v 1.12 2002/02/28 04:00:12 drh Exp $
+** $Id: func.c,v 1.13 2002/03/02 19:00:31 drh Exp $
*/
#include <ctype.h>
#include <math.h>
}
}
+/*
+** Implementation of random(). Return a random integer.
+*/
+static void randomFunc(sqlite_func *context, int argc, const char **argv){
+ sqlite_set_result_int(context, sqliteRandomInteger());
+}
+
/*
** An instance of the following structure holds the context of a
** sum() or avg() aggregate computation.
{ "coalesce", -1, ifnullFunc },
{ "coalesce", 0, 0 },
{ "coalesce", 1, 0 },
-
+ { "random", -1, randomFunc },
};
static struct {
char *zName;