From 586381f8db3497c24c11f96234f1879b34e74bc7 Mon Sep 17 00:00:00 2001 From: "mpcomplete@google.com" Date: Tue, 6 Jan 2009 22:39:41 +0000 Subject: Upgrade our sqlite to 3.6.1, with the local changes made by Gears. I'm checking in the full sqlite tree to make upstream merges easier. This means we'll have generated sources split out from the originals. One important change this makes is that "BEGIN" now defaults to "BEGIN IMMEDIATE" rather than "BEGIN DEFERRED". This doesn't affect us because we don't use unqualified BEGIN statements. The full CL is too big for Rietveld. I'm splitting it into 2. This one is reviewable. The other CL is just a fresh drop of: //depot/googleclient/gears/opensource/third_party/sqlite_google Review URL: http://codereview.chromium.org/15067 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7623 0039d316-1c4b-4281-b951-d872f2087c98 --- third_party/sqlite/src/test_func.c | 431 +++++++++++++++++++++++++++++++++++++ 1 file changed, 431 insertions(+) create mode 100755 third_party/sqlite/src/test_func.c (limited to 'third_party/sqlite/src/test_func.c') diff --git a/third_party/sqlite/src/test_func.c b/third_party/sqlite/src/test_func.c new file mode 100755 index 0000000..eaafc23 --- /dev/null +++ b/third_party/sqlite/src/test_func.c @@ -0,0 +1,431 @@ +/* +** 2008 March 19 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** Code for testing all sorts of SQLite interfaces. This code +** implements new SQL functions used by the test scripts. +** +** $Id: test_func.c,v 1.10 2008/08/02 03:50:39 drh Exp $ +*/ +#include "sqlite3.h" +#include "tcl.h" +#include +#include +#include + + +/* +** Allocate nByte bytes of space using sqlite3_malloc(). If the +** allocation fails, call sqlite3_result_error_nomem() to notify +** the database handle that malloc() has failed. +*/ +static void *testContextMalloc(sqlite3_context *context, int nByte){ + char *z = sqlite3_malloc(nByte); + if( !z && nByte>0 ){ + sqlite3_result_error_nomem(context); + } + return z; +} + +/* +** This function generates a string of random characters. Used for +** generating test data. +*/ +static void randStr(sqlite3_context *context, int argc, sqlite3_value **argv){ + static const unsigned char zSrc[] = + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789" + ".-!,:*^+=_|?/<> "; + int iMin, iMax, n, r, i; + unsigned char zBuf[1000]; + + /* It used to be possible to call randstr() with any number of arguments, + ** but now it is registered with SQLite as requiring exactly 2. + */ + assert(argc==2); + + iMin = sqlite3_value_int(argv[0]); + if( iMin<0 ) iMin = 0; + if( iMin>=sizeof(zBuf) ) iMin = sizeof(zBuf)-1; + iMax = sqlite3_value_int(argv[1]); + if( iMax=sizeof(zBuf) ) iMax = sizeof(zBuf)-1; + n = iMin; + if( iMax>iMin ){ + sqlite3_randomness(sizeof(r), &r); + r &= 0x7fffffff; + n += r%(iMax + 1 - iMin); + } + assert( n