aboutsummaryrefslogtreecommitdiff
path: root/src/func.c
diff options
context:
space:
mode:
authordrh <>2022-01-09 16:54:02 +0000
committerdrh <>2022-01-09 16:54:02 +0000
commit9d44f18b3ccf2ca757ee27ae294b859cb32ec127 (patch)
treedf666a585b5769effdd2979cf232dfaf13b740fa /src/func.c
parentdaefcd9e009616b379eb4c0528a0440dcd0394f8 (diff)
downloadsqlite-9d44f18b3ccf2ca757ee27ae294b859cb32ec127.tar.gz
sqlite-9d44f18b3ccf2ca757ee27ae294b859cb32ec127.zip
Add a new built-in subtype() function.
FossilOrigin-Name: a25f4ce255c034fc694c33728aedb98289ebccda9c48920829ef780b92b8faee
Diffstat (limited to 'src/func.c')
-rw-r--r--src/func.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/func.c b/src/func.c
index 360967a08..596a1bb3a 100644
--- a/src/func.c
+++ b/src/func.c
@@ -97,6 +97,17 @@ static void typeofFunc(
sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC);
}
+/* subtype(X)
+**
+** Return the subtype of X
+*/
+static void subtypeFunc(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ sqlite3_result_int(context, sqlite3_value_subtype(argv[0]));
+}
/*
** Implementation of the length() function
@@ -2246,6 +2257,7 @@ void sqlite3RegisterBuiltinFunctions(void){
WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
+ FUNCTION2(subtype, 1, 0, 0, subtypeFunc, SQLITE_FUNC_TYPEOF),
FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
FUNCTION(instr, 2, 0, 0, instrFunc ),
FUNCTION(printf, -1, 0, 0, printfFunc ),