diff options
author | drh <drh@noemail.net> | 2015-09-10 20:34:56 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2015-09-10 20:34:56 +0000 |
commit | bcdf78a61caa6263e84e8b3f5e2fff6afa0410ac (patch) | |
tree | 820be03b347c0bf3f3b18e4f434d0ea840425f3b /src/test_func.c | |
parent | 0b19c96935b38bb47ffac79a63f3507611e99ca3 (diff) | |
download | sqlite-bcdf78a61caa6263e84e8b3f5e2fff6afa0410ac.tar.gz sqlite-bcdf78a61caa6263e84e8b3f5e2fff6afa0410ac.zip |
Experimental implementation of sqlite3_result_subtype() and
sqlite3_value_subtype() interfaces.
FossilOrigin-Name: 7b5be299c617a3d3ed327ed30ef0a66a62c85b1f
Diffstat (limited to 'src/test_func.c')
-rw-r--r-- | src/test_func.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/test_func.c b/src/test_func.c index 2e34fa074..63cf18e3f 100644 --- a/src/test_func.c +++ b/src/test_func.c @@ -462,7 +462,7 @@ static void real2hex( } /* -** tclcmd: test_extract(record, field) +** test_extract(record, field) ** ** This function implements an SQL user-function that accepts a blob ** containing a formatted database record as the first argument. The @@ -509,7 +509,7 @@ static void test_extract( } /* -** tclcmd: test_decode(record) +** test_decode(record) ** ** This function implements an SQL user-function that accepts a blob ** containing a formatted database record as its only argument. It returns @@ -601,6 +601,8 @@ static void test_decode( } /* +** test_zeroblob(N) +** ** The implementation of scalar SQL function "test_zeroblob()". This is ** similar to the built-in zeroblob() function, except that it does not ** check that the integer parameter is within range before passing it @@ -615,6 +617,31 @@ static void test_zeroblob( sqlite3_result_zeroblob(context, nZero); } +/* test_getsubtype(V) +** +** Return the subtype for value V. +*/ +static void test_getsubtype( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + sqlite3_result_int(context, (int)sqlite3_value_subtype(argv[0])); +} + +/* test_setsubtype(V, T) +** +** Return the value V with its subtype changed to T +*/ +static void test_setsubtype( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + sqlite3_result_value(context, argv[0]); + sqlite3_result_subtype(context, (unsigned int)sqlite3_value_int(argv[1])); +} + static int registerTestFunctions(sqlite3 *db){ static const struct { char *zName; @@ -641,6 +668,8 @@ static int registerTestFunctions(sqlite3 *db){ { "test_decode", 1, SQLITE_UTF8, test_decode}, { "test_extract", 2, SQLITE_UTF8, test_extract}, { "test_zeroblob", 1, SQLITE_UTF8|SQLITE_DETERMINISTIC, test_zeroblob}, + { "test_getsubtype", 1, SQLITE_UTF8, test_getsubtype}, + { "test_setsubtype", 2, SQLITE_UTF8, test_setsubtype}, }; int i; |