diff options
author | rdc <rdc@noemail.net> | 2004-02-20 22:53:38 +0000 |
---|---|---|
committer | rdc <rdc@noemail.net> | 2004-02-20 22:53:38 +0000 |
commit | b0c374ffbb7bcc4e590b69233e1b994fa296abf4 (patch) | |
tree | 621c4acc2bca8fbf8b93883fcb6b87109728346e /src/func.c | |
parent | fcabd4641e1a273de8ddadce87e2097148bb8a26 (diff) | |
download | sqlite-b0c374ffbb7bcc4e590b69233e1b994fa296abf4.tar.gz sqlite-b0c374ffbb7bcc4e590b69233e1b994fa296abf4.zip |
Fixed behaviour of last_insert_rowid() with triggers and add last_statement_change_count() function that works correctly with triggers. (CVS 1251)
FossilOrigin-Name: 3383413a53bff0fef0765144de3bb9a298a5bb5c
Diffstat (limited to 'src/func.c')
-rw-r--r-- | src/func.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/func.c b/src/func.c index 688f50cff..2f30619de 100644 --- a/src/func.c +++ b/src/func.c @@ -16,7 +16,7 @@ ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** -** $Id: func.c,v 1.39 2004/02/11 09:46:32 drh Exp $ +** $Id: func.c,v 1.40 2004/02/20 22:53:39 rdc Exp $ */ #include <ctype.h> #include <math.h> @@ -209,6 +209,16 @@ static void last_insert_rowid(sqlite_func *context, int arg, const char **argv){ sqlite_set_result_int(context, sqlite_last_insert_rowid(db)); } +static void change_count(sqlite_func *context, int arg, const char **argv){ + sqlite *db = sqlite_user_data(context); + sqlite_set_result_int(context, sqlite_changes(db)); +} +static void last_statement_change_count(sqlite_func *context, int arg, + const char **argv){ + sqlite *db = sqlite_user_data(context); + sqlite_set_result_int(context, sqlite_last_statement_changes(db)); +} + /* ** Implementation of the like() SQL function. This function implements ** the build-in LIKE operator. The first argument to the function is the @@ -613,6 +623,12 @@ void sqliteRegisterBuiltinFunctions(sqlite *db){ sqlite_create_function(db, "last_insert_rowid", 0, last_insert_rowid, db); sqlite_function_type(db, "last_insert_rowid", SQLITE_NUMERIC); + sqlite_create_function(db, "change_count", 0, change_count, db); + sqlite_function_type(db, "change_count", SQLITE_NUMERIC); + sqlite_create_function(db, "last_statement_change_count", 0, + last_statement_change_count, db); + sqlite_function_type(db, "last_statement_change_count", SQLITE_NUMERIC); + for(i=0; i<sizeof(aAggs)/sizeof(aAggs[0]); i++){ sqlite_create_aggregate(db, aAggs[i].zName, aAggs[i].nArg, aAggs[i].xStep, aAggs[i].xFinalize, 0); |