diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 14:07:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 14:07:38 +0000 |
commit | 8cb0288fa14ba73d0f6eea982bb7d30414460bfb (patch) | |
tree | 0ea6af723f53807b69ff4060b07381b45def1c15 /src/test1.c | |
parent | Adding debian version 3.45.1-1. (diff) | |
download | sqlite3-8cb0288fa14ba73d0f6eea982bb7d30414460bfb.tar.xz sqlite3-8cb0288fa14ba73d0f6eea982bb7d30414460bfb.zip |
Merging upstream version 3.45.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test1.c')
-rw-r--r-- | src/test1.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/test1.c b/src/test1.c index 9c28259..8faf5a3 100644 --- a/src/test1.c +++ b/src/test1.c @@ -992,6 +992,39 @@ static void intrealFunction( } /* +** These SQL functions attempt to return a value (their first argument) +** that has been modified to have multiple datatypes. For example both +** TEXT and INTEGER. +*/ +static void addTextTypeFunction( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + (void)sqlite3_value_text(argv[0]); + (void)argc; + sqlite3_result_value(context, argv[0]); +} +static void addIntTypeFunction( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + (void)sqlite3_value_int64(argv[0]); + (void)argc; + sqlite3_result_value(context, argv[0]); +} +static void addRealTypeFunction( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + (void)sqlite3_value_double(argv[0]); + (void)argc; + sqlite3_result_value(context, argv[0]); +} + +/* ** SQL function: strtod(X) ** ** Use the C-library strtod() function to convert string X into a double. @@ -1103,6 +1136,22 @@ static int SQLITE_TCLAPI test_create_function( 0, intrealFunction, 0, 0); } + /* The add_text_type(), add_int_type(), and add_real_type() functions + ** attempt to return a value that has multiple datatypes. + */ + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "add_text_type", 1, SQLITE_UTF8, + 0, addTextTypeFunction, 0, 0); + } + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "add_int_type", 1, SQLITE_UTF8, + 0, addIntTypeFunction, 0, 0); + } + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "add_real_type", 1, SQLITE_UTF8, + 0, addRealTypeFunction, 0, 0); + } + /* Functions strtod() and dtostr() work as in the shell. These routines ** use the standard C library to convert between floating point and ** text. This is used to compare SQLite's internal conversion routines |