]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the strdup() SQL function extension for use in testing.
authordrh <>
Sat, 4 Jul 2026 15:09:52 +0000 (15:09 +0000)
committerdrh <>
Sat, 4 Jul 2026 15:09:52 +0000 (15:09 +0000)
FossilOrigin-Name: 521a7cf8443d914ae0486aa8a91924ed35a1d5b88082acbe513cef216408c97e

Makefile.msc
ext/misc/strdup.c [new file with mode: 0644]
main.mk
manifest
manifest.uuid
src/shell.c.in
src/test1.c
test/fuzzcheck.c
test/json101.test
test/jsonb01.test

index 87ba812c5ef1e8ffa821b7097c5026c694d14a62..5371e1b0d3cdf9948be2f03d75bf351fe711fbbc 100644 (file)
@@ -1582,6 +1582,7 @@ TESTEXT = \
   $(TOP)\ext\misc\closure.c \
   $(TOP)\ext\misc\csv.c \
   $(TOP)\ext\misc\decimal.c \
+  $(TOP)\ext\misc\diskused.c\
   $(TOP)\ext\misc\eval.c \
   $(TOP)\ext\misc\explain.c \
   $(TOP)\ext\misc\fileio.c \
@@ -1601,6 +1602,7 @@ TESTEXT = \
   $(TOP)\ext\misc\series.c \
   $(TOP)\ext\misc\spellfix.c \
   $(TOP)\ext\misc\stmtrand.c \
+  $(TOP)\ext\misc\strdup.c \
   $(TOP)\ext\misc\totype.c \
   $(TOP)\ext\misc\unionvtab.c \
   $(TOP)\ext\misc\wholenumber.c \
@@ -1778,6 +1780,7 @@ FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\misc\series.c
 FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\misc\shathree.c
 FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\misc\sha1.c
 FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\misc\stmtrand.c
+FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\misc\strdup.c
 
 OSSSHELL_SRC = $(TOP)\test\ossshell.c $(TOP)\test\ossfuzz.c
 DBFUZZ_COMPILE_OPTS = -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION
diff --git a/ext/misc/strdup.c b/ext/misc/strdup.c
new file mode 100644 (file)
index 0000000..022b5eb
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+** 2026-07-04
+**
+** The author disclaims copyright to this source code.  In place of
+** a legal notice, here is a blessing:
+**
+**    May you do good and not evil.
+**    May you find forgiveness for yourself and forgive others.
+**    May you share freely, never taking more than you give.
+**
+******************************************************************************
+**
+** Since this module was written (coincidentally) on the 250th anniversary
+** of the signing of the Declaration of Independence of The United States,
+** it seems fitting to quote from that document:
+**
+**    We hold these truths to be self-evident, that all men are created
+**    equal, that they are endowed by their Creator with certain unalienable
+**    Rights, that among these are Life, Liberty and the pursuit of Happiness
+**    - That to secure these rights, Governments are instituted among Men,
+**    deriving their just powers from the consent of the governed,....
+**
+** Two core ideas that (1) rights come from God and not from government,
+** and that (2) there should not be special privileged classes of people
+** were radical thoughts then, and are indeed disputed even today.  Many
+** people still hold that human rights derive from the beneficence of
+** government and that certain classes of people have special rights and
+** privileges not available to all.  Yet, were it not for the crazy ideas
+** espoused in the original Declaration of Independence, this software
+** project, and indeed most of modern technology, would not exist.
+**
+** Therefore let us give thanks for the bold leadership and vision
+** demonstrated by the authors of the American Revolution, 250 years ago
+** this day.
+**
+******************************************************************************
+**
+** Implementation of the strdup() SQL function.  strdup() makes a copy
+** of its argument (a string or a BLOB) into memory obtained directly
+** from system malloc() (not from sqlite3_malloc()) and sized exactly
+** to hold the string or BLOB.  This is intended for testing purposes,
+** particularly testing with ASAN.  This function serves no practical
+** purpose beyond testing and not not intended for production use.
+**
+** NULL, BLOB, and TEXT values come through as NULL, BLOB, and TEXT,
+** respectively.  Numeric values are rendered as strings and come out
+** as text.
+*/
+#include "sqlite3ext.h"
+SQLITE_EXTENSION_INIT1
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+
+/*
+** Make a copy of a string or BLOB in memory obtained from malloc().
+*/
+static void strdupfunc(
+  sqlite3_context *context,
+  int argc,
+  sqlite3_value **argv
+){
+  const unsigned char *zIn;
+  int nIn;
+  unsigned char *zOut;
+
+  assert( argc==1 );
+  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
+  if( sqlite3_value_type(argv[0])==SQLITE_BLOB ){
+    zIn = (const unsigned char*)sqlite3_value_blob(argv[0]);
+    nIn = sqlite3_value_bytes(argv[0]);
+    zOut = malloc( nIn==0 ? 1 : nIn );
+    if( zOut==0 ){
+      sqlite3_result_error_nomem(context);
+      return;
+    }
+    memcpy(zOut, zIn, nIn);
+    sqlite3_result_blob(context, zOut, nIn, free);
+  }else{
+    zIn = (const unsigned char*)sqlite3_value_text(argv[0]);
+    if( zIn==0 ) return;
+    nIn = (int)strlen((char*)zIn);
+    zOut = malloc( nIn+1 );
+    if( zOut==0 ){
+      sqlite3_result_error_nomem(context);
+      return;
+    }
+    memcpy(zOut, zIn, nIn);
+    zOut[nIn] = 0;
+    sqlite3_result_text64(context, (char*)zOut, nIn, free,
+                          SQLITE_UTF8_ZT);
+  }
+}
+
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int sqlite3_strdup_init(
+  sqlite3 *db, 
+  char **pzErrMsg, 
+  const sqlite3_api_routines *pApi
+){
+  int rc = SQLITE_OK;
+  SQLITE_EXTENSION_INIT2(pApi);
+  (void)pzErrMsg;  /* Unused parameter */
+  rc = sqlite3_create_function(db, "strdup", 1, SQLITE_UTF8,
+                   0, strdupfunc, 0, 0);
+  return rc;
+}
diff --git a/main.mk b/main.mk
index 7d01b3eed0d570ece4dc5ba078d34180c6ff740f..ac768333beecd3978dea280c82880ff4254503b3 100644 (file)
--- a/main.mk
+++ b/main.mk
@@ -784,6 +784,7 @@ TESTSRC += \
   $(TOP)/ext/misc/closure.c \
   $(TOP)/ext/misc/csv.c \
   $(TOP)/ext/misc/decimal.c \
+  $(TOP)/ext/misc/diskused.c \
   $(TOP)/ext/misc/eval.c \
   $(TOP)/ext/misc/explain.c \
   $(TOP)/ext/misc/fileio.c \
@@ -803,6 +804,7 @@ TESTSRC += \
   $(TOP)/ext/misc/series.c \
   $(TOP)/ext/misc/spellfix.c \
   $(TOP)/ext/misc/stmtrand.c \
+  $(TOP)/ext/misc/strdup.c \
   $(TOP)/ext/misc/totype.c \
   $(TOP)/ext/misc/unionvtab.c \
   $(TOP)/ext/misc/wholenumber.c \
@@ -993,7 +995,8 @@ FUZZCHECK_SRC = sqlite3.c \
    $(TOP)/ext/misc/series.c \
    $(TOP)/ext/misc/shathree.c \
    $(TOP)/ext/misc/sha1.c \
-   $(TOP)/ext/misc/stmtrand.c
+   $(TOP)/ext/misc/stmtrand.c \
+   $(TOP)/ext/misc/strdup.c
 
 FUZZCHECK_DEP = sqlite3.h
 DBFUZZ_OPT =
@@ -2355,6 +2358,7 @@ SHELL_DEP = \
     $(TOP)/ext/misc/sha1.c \
     $(TOP)/ext/misc/shathree.c \
     $(TOP)/ext/misc/sqlar.c \
+    $(TOP)/ext/misc/strdup.c \
     $(TOP)/ext/misc/uint.c \
     $(TOP)/ext/misc/vfstrace.c \
     $(TOP)/ext/misc/windirent.h \
index 1d99f24dab020de188acb78d64875e5ec4c45ca1..f60c7d3b124eaacc0127ef47dd250ce0d80783c4 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C The\sjsonSkipLabel()\sroutine,\spart\sof\sjson_each()\sand\sjson_next(),\sshould\nnever\sreturn\san\sindex\soutside\sof\sthe\srange\sof\sbytes\sof\sthe\sinput\sJSONB.\n[bugs:/info/2026-07-04T04:58:54Z|Bug\s2026-07-04T04:58:54Z]
-D 2026-07-04T12:12:16.747
+C Add\sthe\sstrdup()\sSQL\sfunction\sextension\sfor\suse\sin\stesting.
+D 2026-07-04T15:09:52.291
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -7,7 +7,7 @@ F AGENTS.md 44ddfb38ef23e277888bd70ae378e6cbf5f5cab0e2a4420bd21d89b6caff7a4a
 F LICENSE.md 6bc480fc673fb4acbc4094e77edb326267dd460162d7723c7f30bee2d3d9e97d
 F Makefile.in 5fda086f33b144da08119255da1d2557f983d0764a13707f05acf0159fd89ba5
 F Makefile.linux-generic bd3e3cacd369821a6241d4ea1967395c962dfe3057e38cb0a435cee0e8b789d0
-F Makefile.msc ae6c8f8c39ed9cec7e3fc27390209117a943acd81941b5e81e8cd828b1875d93
+F Makefile.msc 82edb7e63db4768908bb4223b36df2bd58dbd853f93f517153e2a92860bf484d
 F README.md f00091ffb5c6379b783afb57ca5f443a5742e119082f37c407f64a5e16c56346
 F VERSION 99cf3be5f13d091183e4314b7fc2e0c0e69accfbe64608b45a313338bbdd7b62
 F art/icon-243x273.gif 9750b734f82fdb3dc43127753d5e6fbf3b62c9f4e136c2fbf573b2f57ea87af5
@@ -406,6 +406,7 @@ F ext/misc/sqlite3_stdio.c b43a0f530c6f0fb3d41d9af8c0b40f3f71198a1db55ab8ffffbef
 F ext/misc/sqlite3_stdio.h 27a4ecea47e61bc9574ccdf2806f468afe23af2f95028c9b689bfa08ab1ce99f
 F ext/misc/stmt.c b090086cd6bd6281c21271d38d576eeffe662f0e6b67536352ce32bbaa438321
 F ext/misc/stmtrand.c 1c7c6a478e9c808d53a2efa9a744c86c265b6b95b4a96964e1b960c7c642ad49
+F ext/misc/strdup.c a98c889601e18c3525d58c109e84f19cf2ea7543364653d39f5b6931275a186e
 F ext/misc/templatevtab.c f2771161158bb78a0bfeaed9b50a018a731c7566df6a67181df0acea1920ab9c
 F ext/misc/tmstmpvfs.c 240caad4441328dc52bd2871f48811db46dff858d5598030e389176837a2f4df
 F ext/misc/totype.c ba11aac3c0b52c685bd25aa4e0f80c41c624fb1cc5ab763250e09ddc762bc3a8
@@ -661,7 +662,7 @@ F ext/wasm/tests/opfs/sahpool/index.html be736567fd92d3ecb9754c145755037cbbd2bca
 F ext/wasm/tests/opfs/sahpool/sahpool-pausing.js f264925cfc82155de38cecb3d204c36e0f6991460fff0cb7c15079454679a4e2
 F ext/wasm/tests/opfs/sahpool/sahpool-worker.js bd25a43fc2ab2d1bafd8f2854ad3943ef673f7c3be03e95ecf1612ff6e8e2a61
 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0
-F main.mk 77e33a16a795abd4a07a55f7eb2e11136326998db597b67c8655d5d2d9b98054
+F main.mk a070741c2aa50883c370c55c1351be46b3db6958164426a3c4dfc456072e8343
 F make.bat a136fd0b1c93e89854a86d5f4edcf0386d211e5d5ec2434480f6eea436c7420c
 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
@@ -740,7 +741,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
 F src/resolve.c d0724113da9f5c0430d2052808ce59519f51ae7c4fbb1f5ef21fe3a832956086
 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
 F src/select.c f553420eaf5c72a49cef786621eea79dd8c4411671839fb05250bb49ca74a0a0
-F src/shell.c.in a4e83895cfa336065ad7f7a7dea8fc2a19d050f7ce7466621c67208acaac9e44
+F src/shell.c.in 1bdd1d402ab9e50515010b1f3d1de86f7f98c103fb29f609b068aca513aff995
 F src/sqlite.h.in d9ec41feb4cd804e68b174328b43beb3f1f71bba13e1c7a439efb826d301cccc
 F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479
 F src/sqlite3ext.h 0efd4723bad9124ea1f581d9f1ea0254ac1c6f3e5fb29e4f3dcf36c72485a456
@@ -750,7 +751,7 @@ F src/status.c 7565d63a79aa2f326339a24a0461a60096d0bd2bce711fefb50b5c89335f3592
 F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
 F src/tclsqlite.c 7401c73c917a4d1b380c896a324c8d8eb533a999559d9e339d479596553bebfd
 F src/tclsqlite.h 614b3780a62522bc9f8f2b9fb22689e8009958e7aa77e572d0f3149050af348a
-F src/test1.c fe1316579a1778eb96d0bd12807f9dddc5e3984f5950127e2e1718c050cb6304
+F src/test1.c df2df0a74c9aa81cbbad9d7d8277e49ac255334cba97da9ee22501beac274201
 F src/test2.c 2b9ab96bba63a1c369d5769390475259ad210f144a877805f2e32e563f9e93c1
 F src/test3.c 432646f581d8af1bb495e58fc98234380250954f5d5535e507fc785eccc3987a
 F src/test4.c 0ac87fc13cdb334ab3a71823f99b6c32a6bebe5d603cd6a71d84c823d43a25a0
@@ -1254,7 +1255,7 @@ F test/fuzz3.test 70ba57260364b83e964707b9d4b5625284239768ab907dd387c740c0370ce3
 F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634
 F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830
 F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2
-F test/fuzzcheck.c 674d246742da18270abeef9e8510e3cd9e0e14cddca1f1e8131428928e996a6f
+F test/fuzzcheck.c e07f0a883881cc81f958fa21d01a9cc48aa9563da7243d90aa2d89e8663bb677
 F test/fuzzdata1.db 3e86d9cf5aea68ddb8e27c02d7dfdaa226347426c7eb814918e4d95475bf8517
 F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f
 F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba
@@ -1364,7 +1365,7 @@ F test/json/json-generator.tcl dc0dd0f393800c98658fc4c47eaa6af29d4e17527380cd286
 F test/json/json-q1.txt 65f9d1cdcc4cffa9823fb73ed936aae5658700cd001fde448f68bfb91c807307
 F test/json/json-speed-check.sh 45862b216f1f8bbf16d74e2ad6ea20c773ee77774b299a7e0f76a22eb98e91f1 x
 F test/json/jsonb-q1.txt 1e180fe6491efab307e318b22879e3a736ac9a96539bbde7911a13ee5b33abc7
-F test/json101.test 320107839fef110de72d3950340e19ba21c7e77f09c88657eed6d4a453e4352d
+F test/json101.test 9911cb0a2a337987350bd206cabc6626e94677a791d4905177fffe9bae91c7d4
 F test/json102.test ea5c9811e408e115c8fc539548deef431fda4924c23cacd79dd4b783f4449f07
 F test/json103.test e626d109cd0bdb8282ec9bf755af3befa50e3e03a255362fc53433d31e1d66d4
 F test/json104.test 1b844a70cddcfa2e4cd81a5db0657b2e61e7f00868310f24f56a9ba0114348c1
@@ -1375,7 +1376,7 @@ F test/json108.test 0a5f1e2d4b35a1bc33052563d2a5ede03052e2099e58cb424547656c898e
 F test/json109.test 441cea5d73c24a1a34d284101740dfae5a082237c048c8a66b03aeebe5e3643e
 F test/json501.test b95e2d14988b682a5cadf079dd6162f0f85fb74cd59c6b1f1624110104a974eb
 F test/json502.test 4ef68e4f272dfb083d4cbceb4e9e51d67ec1186a185e0c13637c50a4dc2f9796
-F test/jsonb01.test f8137807a3c05cd9bc0be6e13cc65c98300cfd67de5f9dfcd8dacd2b09582fa9
+F test/jsonb01.test 42419c8080af5660cdfd3fddec322d28bdbc244d9800ee9569091d455f1c0dea
 F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff
 F test/kvtest.c 6e0228409ea7ca0497dad503fbd109badb5e59545d131014b6aaac68b56f484a
 F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63
@@ -2210,8 +2211,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
 F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P 8001a373d1c91f92639fb34fca18f9667f1ee92eb6bfa49df06b8cc256385292
-R b41067a37609013040cce892a6305d05
+P 96072f5f872c8e62dedf48a4ba47ca5f3bd55e98b122f62199a1d0be06de95b4
+R 414dc3f80a7cc685e5663396651ccaf5
 U drh
-Z cf57bc37eb11e4c63f1c131cfd61eba1
+Z 93dc4f3e94c84ded35b9bcfd94d32163
 # Remove this line to create a well-formed Fossil manifest.
index ca6e8cb132dfbb50e030b619e4be9d19114619e9..15011a3968961961e210f46b65fc4c7eec148e26 100644 (file)
@@ -1 +1 @@
-96072f5f872c8e62dedf48a4ba47ca5f3bd55e98b122f62199a1d0be06de95b4
+521a7cf8443d914ae0486aa8a91924ed35a1d5b88082acbe513cef216408c97e
index 49b667866f08e147a59f765b92a30358b79217bc..99d9464948166cc82bfdf14e9f3c18f82a668135 100644 (file)
@@ -302,6 +302,7 @@ INCLUDE ../ext/intck/sqlite3intck.c
 INCLUDE ../ext/misc/stmtrand.c
 INCLUDE ../ext/misc/vfstrace.c
 INCLUDE ../ext/misc/diskused.c
+INCLUDE ../ext/misc/strdup.c
 
 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
 #define SQLITE_SHELL_HAVE_RECOVER 1
@@ -5097,6 +5098,7 @@ static void open_db(ShellState *p, int openFlags){
     sqlite3_ieee_init(p->db, 0, 0);
     sqlite3_series_init(p->db, 0, 0);
     sqlite3_diskused_init(p->db, 0, 0);
+    sqlite3_strdup_init(p->db, 0, 0);
 #ifndef SQLITE_SHELL_FIDDLE
     sqlite3_fileio_init(p->db, 0, 0);
     sqlite3_completion_init(p->db, 0, 0);
index 53d3c6ac88856df94edce2c21153a0f036dc7f07..6044983add859d87d907900bb240e33cce57de86 100644 (file)
@@ -8381,6 +8381,7 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd(
   extern int sqlite3_explain_init(sqlite3*,char**,const sqlite3_api_routines*);
   extern int sqlite3_fileio_init(sqlite3*,char**,const sqlite3_api_routines*);
   extern int sqlite3_decimal_init(sqlite3*,char**,const sqlite3_api_routines*);
+  extern int sqlite3_diskused_init(sqlite3*,char**,const sqlite3_api_routines*);
   extern int sqlite3_fuzzer_init(sqlite3*,char**,const sqlite3_api_routines*);
   extern int sqlite3_ieee_init(sqlite3*,char**,const sqlite3_api_routines*);
   extern int sqlite3_nextchar_init(sqlite3*,char**,const sqlite3_api_routines*);
@@ -8394,6 +8395,7 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd(
   extern int sqlite3_series_init(sqlite3*,char**,const sqlite3_api_routines*);
   extern int sqlite3_spellfix_init(sqlite3*,char**,const sqlite3_api_routines*);
   extern int sqlite3_stmtrand_init(sqlite3*,char**,const sqlite3_api_routines*);
+  extern int sqlite3_strdup_init(sqlite3*,char**,const sqlite3_api_routines*);
   extern int sqlite3_totype_init(sqlite3*,char**,const sqlite3_api_routines*);
   extern int sqlite3_wholenumber_init(sqlite3*,char**,const sqlite3_api_routines*);
   extern int sqlite3_unionvtab_init(sqlite3*,char**,const sqlite3_api_routines*);
@@ -8410,6 +8412,7 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd(
     { "closure",               sqlite3_closure_init              },
     { "csv",                   sqlite3_csv_init                  },
     { "decimal",               sqlite3_decimal_init              },
+    { "diskused",              sqlite3_diskused_init             },
     { "eval",                  sqlite3_eval_init                 },
     { "explain",               sqlite3_explain_init              },
     { "fileio",                sqlite3_fileio_init               },
@@ -8426,6 +8429,7 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd(
     { "series",                sqlite3_series_init               },
     { "spellfix",              sqlite3_spellfix_init             },
     { "stmtrand",              sqlite3_stmtrand_init             },
+    { "strdup",                sqlite3_strdup_init               },
     { "totype",                sqlite3_totype_init               },
     { "unionvtab",             sqlite3_unionvtab_init            },
     { "wholenumber",           sqlite3_wholenumber_init          },
index fcee2178ed9c777770fb6e201e766078c2ed762c..393d29884488c217916bc77547b42bb93f6ce0ce 100644 (file)
@@ -182,6 +182,7 @@ extern int sqlite3_regexp_init(sqlite3*,char**,void*);
 extern int sqlite3_shathree_init(sqlite3*,char**,void*);
 extern int sqlite3_sha_init(sqlite3*,char**,void*);
 extern int sqlite3_stmtrand_init(sqlite3*,char**,void*);
+extern int sqlite3_strdup_init(sqlite3*,char**,void*);
 
 /*
 ** Print an error message and quit.
@@ -1404,6 +1405,7 @@ int runCombinedDbSqlInput(
   sqlite3_shathree_init(cx.db, 0, 0);
   sqlite3_sha_init(cx.db, 0, 0);
   sqlite3_stmtrand_init(cx.db, 0, 0);
+  sqlite3_strdup_init(cx.db, 0, 0);
 
   /* Add support for sqlite_dbdata and sqlite_dbptr virtual tables used
   ** by the recovery API */
index e947d8d6b7634e4520aedf96977afd35f93ca0d8..45dda3a117a72aca63b85fd6a4a21b73caa770f3 100644 (file)
@@ -1195,6 +1195,10 @@ do_execsql_test json101-25.1 {
 do_execsql_test json101-26.1 {
   SELECT value FROM json_each(x'CC141761133117621332176313331764133437656565') WHERE key='eee';
 } {eee}
+load_static_extension db strdup
+do_execsql_test json101-26.1b {
+  SELECT value FROM json_each(strdup(x'CC141761133117621332176313331764133437656565')) WHERE key='eee';
+} {eee}
 do_execsql_test json101-26.2 {
   SELECT json_valid(x'CC141761133117621332176313331764133437656565',8);
 } {0}
index 05f160468beadafc637e1b7e5ab6ca2e971a028d..4cabb201852ff9a3d901ded7edda9282b2083faa 100644 (file)
@@ -56,5 +56,9 @@ do_catchsql_test jsonb01-2.0 {
 do_catchsql_test jsonb01-3.0 {
   SELECT json(x'6B37616263162d');
 } {1 {malformed JSON}}
+load_static_extension db strdup
+do_catchsql_test jsonb01-3.1 {
+  SELECT json(strdup(x'6B37616263162d'));
+} {1 {malformed JSON}}
 
 finish_test