Browse Source

Update the parameters validation mask for "create_function/create_aggregate" to allow pass the optional user_data parameter to created functions.

mingodad 13 years ago
parent
commit
36500b4e84
2 changed files with 6 additions and 3 deletions
  1. 2 2
      SquiLu-ext/sq_sqlite3.cpp
  2. 4 1
      SquiLu/samples/test-sqlite3.nut

+ 2 - 2
SquiLu-ext/sq_sqlite3.cpp

@@ -2002,8 +2002,8 @@ static SQRegFunction sq_sqlite3_methods[] =
 	_DECL_FUNC(trace,  -2, _SC("x c|o .")),
 	_DECL_FUNC(trace,  -2, _SC("x c|o .")),
 	_DECL_FUNC(busy_handler,  -2, _SC("x c|o .")),
 	_DECL_FUNC(busy_handler,  -2, _SC("x c|o .")),
 	_DECL_FUNC(busy_timeout,  2, _SC("xi")),
 	_DECL_FUNC(busy_timeout,  2, _SC("xi")),
-	_DECL_FUNC(create_function,  4, _SC("xsic")),
-	_DECL_FUNC(create_aggregate,  5, _SC("xsicc")),
+	_DECL_FUNC(create_function,  -4, _SC("xsic.")),
+	_DECL_FUNC(create_aggregate,  -5, _SC("xsicc.")),
 #ifndef WIN32
 #ifndef WIN32
 	_DECL_FUNC(temp_directory,  2, _SC("xs")),
 	_DECL_FUNC(temp_directory,  2, _SC("xs")),
 #endif
 #endif

+ 4 - 1
SquiLu/samples/test-sqlite3.nut

@@ -1,7 +1,10 @@
 local db = SQLite3(":memory:");
 local db = SQLite3(":memory:");
 print(db);
 print(db);
 
 
-db.create_function("multiply3",3,function(ctx,a,b,c){ctx.result_double(a*b*c);});
+db.create_function("multiply3",3,function(ctx,a,b,c){
+		//print(ctx.user_data());
+		ctx.result_double(a*b*c);
+	}, "user_data_any");
 
 
 local sql = "select 1.2*2.5*3.6;";
 local sql = "select 1.2*2.5*3.6;";
 local sql_squilu = "select multiply3(1.2,2.5,3.6);";
 local sql_squilu = "select multiply3(1.2,2.5,3.6);";