1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Enhanced testing and documentation of sqlite3_result_error_code().

Ticket #2940. (CVS 4983)

FossilOrigin-Name: 5be56dbe879f89351239accf5069e4cb166e0792
This commit is contained in:
drh
2008-04-10 17:14:07 +00:00
parent e296582705
commit 00e087b24b
6 changed files with 56 additions and 21 deletions

View File

@@ -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.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"
@@ -190,14 +190,18 @@ static void 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){
@@ -213,6 +217,7 @@ static int registerTestFunctions(sqlite3 *db){
{ "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*);