aboutsummaryrefslogtreecommitdiff
path: root/src/printf.c
diff options
context:
space:
mode:
authordrh <>2021-10-03 00:12:43 +0000
committerdrh <>2021-10-03 00:12:43 +0000
commit5bf4715e0184cceca87c372af609959c6df75b43 (patch)
tree751bc0d7f1b1d84d7acc6dc1704cecbaeaad4618 /src/printf.c
parentad1188b21c6fc7a08a6639c7c09beb5295c15a09 (diff)
downloadsqlite-5bf4715e0184cceca87c372af609959c6df75b43.tar.gz
sqlite-5bf4715e0184cceca87c372af609959c6df75b43.zip
Add the sqlite3ResultStrAccum() internal interface to simplify the
the implementation of functions that return strings. FossilOrigin-Name: e548e9299d3fd6ce5b647cf0dd93ff8e917a5eda43076c6a02389c52640e2e50
Diffstat (limited to 'src/printf.c')
-rw-r--r--src/printf.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/printf.c b/src/printf.c
index eb06e1a23..e63518450 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -1045,6 +1045,22 @@ char *sqlite3StrAccumFinish(StrAccum *p){
}
/*
+** Use the content of the StrAccum passed as the second argument
+** as the result of an SQL function.
+*/
+void sqlite3ResultStrAccum(sqlite3_context *pCtx, StrAccum *p){
+ if( p->accError ){
+ sqlite3_result_error_code(pCtx, p->accError);
+ sqlite3_str_reset(p);
+ }else if( isMalloced(p) ){
+ sqlite3_result_text(pCtx, p->zText, p->nChar, SQLITE_DYNAMIC);
+ }else{
+ sqlite3_result_text(pCtx, "", 0, SQLITE_STATIC);
+ sqlite3_str_reset(p);
+ }
+}
+
+/*
** This singleton is an sqlite3_str object that is returned if
** sqlite3_malloc() fails to provide space for a real one. This
** sqlite3_str object accepts no new text and always returns