diff options
Diffstat (limited to 'src/test_func.c')
-rw-r--r-- | src/test_func.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/test_func.c b/src/test_func.c index 20f330718..275359e38 100644 --- a/src/test_func.c +++ b/src/test_func.c @@ -12,7 +12,7 @@ ** 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.13 2008/08/28 02:26:07 drh Exp $ +** $Id: test_func.c,v 1.14 2009/03/19 18:51:07 danielk1977 Exp $ */ #include "sqlite3.h" #include "tcl.h" @@ -147,6 +147,25 @@ static void test_destructor_count( } /* +** The following aggregate function, test_agg_errmsg16(), takes zero +** arguments. It returns the text value returned by the sqlite3_errmsg16() +** API function. +*/ +void sqlite3BeginBenignMalloc(void); +void sqlite3EndBenignMalloc(void); +static void test_agg_errmsg16_step(sqlite3_context *a, int b,sqlite3_value **c){ +} +static void test_agg_errmsg16_final(sqlite3_context *ctx){ + const void *z; + sqlite3 * db = sqlite3_context_db_handle(ctx); + sqlite3_aggregate_context(ctx, 2048); + sqlite3BeginBenignMalloc(); + z = sqlite3_errmsg16(db); + sqlite3EndBenignMalloc(); + sqlite3_result_text16(ctx, z, -1, SQLITE_TRANSIENT); +} + +/* ** Routines for testing the sqlite3_get_auxdata() and sqlite3_set_auxdata() ** interface. ** @@ -318,6 +337,10 @@ static int registerTestFunctions(sqlite3 *db){ sqlite3_create_function(db, aFuncs[i].zName, aFuncs[i].nArg, aFuncs[i].eTextRep, 0, aFuncs[i].xFunc, 0, 0); } + + sqlite3_create_function(db, "test_agg_errmsg16", 0, SQLITE_ANY, 0, 0, + test_agg_errmsg16_step, test_agg_errmsg16_final); + return SQLITE_OK; } |