Index: src/sqlite.h.in ================================================================== --- src/sqlite.h.in +++ src/sqlite.h.in @@ -28,11 +28,11 @@ ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** -** @(#) $Id: sqlite.h.in,v 1.303 2008/04/10 13:38:18 drh Exp $ +** @(#) $Id: sqlite.h.in,v 1.304 2008/04/10 17:14:07 drh Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ #include /* Needed for the definition of va_list */ @@ -3944,11 +3944,12 @@ ** routines make a copy private copy of the error message text before ** they return. Hence, the calling function can deallocate or ** modify the text after they return without harm. ** The sqlite3_result_error_code() function changes the error code ** returned by SQLite as a result of an error in a function. By default, -** the error code is SQLITE_ERROR. +** the error code is SQLITE_ERROR. A subsequent call to sqlite3_result_error() +** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. ** ** The sqlite3_result_toobig() interface causes SQLite ** to throw an error indicating that a string or BLOB is to long ** to represent. The sqlite3_result_nomem() interface ** causes SQLite to throw an exception indicating that the a Index: src/test_func.c ================================================================== --- src/test_func.c +++ src/test_func.c @@ -10,11 +10,11 @@ ** ************************************************************************* ** 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.3 2008/03/19 19:01:22 drh Exp $ +** $Id: test_func.c,v 1.4 2008/04/10 17:14:07 drh Exp $ */ #include "sqlite3.h" #include "tcl.h" #include #include @@ -188,18 +188,22 @@ sqlite3_result_text(pCtx, zRet, 2*nArg-1, free_test_auxdata); } /* ** A function to test error reporting from user functions. This function -** returns a copy of its first argument as an error. +** returns a copy of its first argument as the error message. If the +** second argument exists, it becomes the error code. */ static void test_error( sqlite3_context *pCtx, int nArg, sqlite3_value **argv ){ - sqlite3_result_error(pCtx, (char*)sqlite3_value_text(argv[0]), 0); + sqlite3_result_error(pCtx, (char*)sqlite3_value_text(argv[0]), -1); + if( nArg==2 ){ + sqlite3_result_error_code(pCtx, sqlite3_value_int(argv[1])); + } } static int registerTestFunctions(sqlite3 *db){ static const struct { char *zName; @@ -211,10 +215,11 @@ { "test_destructor", 1, SQLITE_UTF8, test_destructor}, { "test_destructor16", 1, SQLITE_UTF8, test_destructor16}, { "test_destructor_count", 0, SQLITE_UTF8, test_destructor_count}, { "test_auxdata", -1, SQLITE_UTF8, test_auxdata}, { "test_error", 1, SQLITE_UTF8, test_error}, + { "test_error", 2, SQLITE_UTF8, test_error}, }; int i; extern int Md5_Register(sqlite3*); for(i=0; i