From: drh <> Date: Wed, 8 Oct 2025 15:32:55 +0000 (+0000) Subject: Were we to choose to integrate the carray() table-valued function into the X-Git-Tag: major-release~99^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cdaff852bf8069605edb4af03a3d279fd8926749;p=thirdparty%2Fsqlite.git Were we to choose to integrate the carray() table-valued function into the amalgamation, that integration might look something like this. FossilOrigin-Name: 2b43d5d7dcc5aee14a050c824a5e09b6a38a9c78ddcc25a994eba5d4c5ad9ba2 --- diff --git a/Makefile.msc b/Makefile.msc index 2ce79ab6d1..d850923ceb 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1343,7 +1343,7 @@ LTLIBS = $(LTLIBS) $(LIBICU) # LIBOBJS0 = vdbe.lo parse.lo alter.lo analyze.lo attach.lo auth.lo \ backup.lo bitvec.lo btmutex.lo btree.lo build.lo \ - callback.lo complete.lo ctime.lo \ + callback.lo carray.lo complete.lo ctime.lo \ date.lo dbpage.lo dbstat.lo delete.lo \ expr.lo fault.lo fkey.lo \ fts3.lo fts3_aux.lo fts3_expr.lo fts3_hash.lo fts3_icu.lo \ @@ -1405,6 +1405,7 @@ SRC00 = \ $(TOP)\src\btree.c \ $(TOP)\src\build.c \ $(TOP)\src\callback.c \ + $(TOP)\src\carray.c \ $(TOP)\src\complete.c \ ctime.c \ $(TOP)\src\date.c \ @@ -2101,6 +2102,9 @@ build.lo: $(TOP)\src\build.c $(HDR) callback.lo: $(TOP)\src\callback.c $(HDR) $(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\callback.c +carray.lo: $(TOP)\src\carray.c $(HDR) + $(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\carray.c + complete.lo: $(TOP)\src\complete.c $(HDR) $(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\complete.c diff --git a/ext/misc/README.md b/ext/misc/README.md index 7404a5ac4b..6d34ab9afb 100644 --- a/ext/misc/README.md +++ b/ext/misc/README.md @@ -9,11 +9,6 @@ Each source file contains a description in its header comment. See the header comments for details about each extension. Additional notes are as follows: - * **carray.c** — This module implements the - [carray](https://sqlite.org/carray.html) table-valued function. - It is a good example of how to go about implementing a custom - [table-valued function](https://sqlite.org/vtab.html#tabfunc2). - * **csv.c** — A [virtual table](https://sqlite.org/vtab.html) for reading [Comma-Separated-Value (CSV) files](https://en.wikipedia.org/wiki/Comma-separated_values). diff --git a/ext/misc/carray.h b/ext/misc/carray.h deleted file mode 100644 index 90b82a727d..0000000000 --- a/ext/misc/carray.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -** 2020-11-17 -** -** 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. -** -************************************************************************* -** -** Interface definitions for the CARRAY table-valued function -** extension. -*/ - -#ifndef _CARRAY_H -#define _CARRAY_H - -#include "sqlite3.h" /* Required for error code definitions */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Use this interface to bind an array to the single-argument version -** of CARRAY(). -*/ -SQLITE_API int sqlite3_carray_bind( - sqlite3_stmt *pStmt, /* Statement to be bound */ - int i, /* Parameter index */ - void *aData, /* Pointer to array data */ - int nData, /* Number of data elements */ - int mFlags, /* CARRAY flags */ - void (*xDel)(void*) /* Destructor for aData */ -); - -/* Allowed values for the mFlags parameter to sqlite3_carray_bind(). -*/ -#define CARRAY_INT32 0 /* Data is 32-bit signed integers */ -#define CARRAY_INT64 1 /* Data is 64-bit signed integers */ -#define CARRAY_DOUBLE 2 /* Data is doubles */ -#define CARRAY_TEXT 3 /* Data is char* */ -#define CARRAY_BLOB 4 /* Data is struct iovec */ - -#ifdef __cplusplus -} /* end of the 'extern "C"' block */ -#endif - -#endif /* ifndef _CARRAY_H */ diff --git a/main.mk b/main.mk index 08229844f5..3704176e1b 100644 --- a/main.mk +++ b/main.mk @@ -535,7 +535,7 @@ clean: clean-sanity-check # LIBOBJS0 = alter.o analyze.o attach.o auth.o \ backup.o bitvec.o btmutex.o btree.o build.o \ - callback.o complete.o ctime.o \ + callback.o carray.o complete.o ctime.o \ date.o dbpage.o dbstat.o delete.o \ expr.o fault.o fkey.o \ fts3.o fts3_aux.o fts3_expr.o fts3_hash.o fts3_icu.o \ @@ -588,6 +588,7 @@ SRC = \ $(TOP)/src/btreeInt.h \ $(TOP)/src/build.c \ $(TOP)/src/callback.c \ + $(TOP)/src/carray.c \ $(TOP)/src/complete.c \ ctime.c \ $(TOP)/src/date.c \ @@ -793,7 +794,6 @@ TESTSRC += \ $(TOP)/ext/misc/amatch.c \ $(TOP)/ext/misc/appendvfs.c \ $(TOP)/ext/misc/basexx.c \ - $(TOP)/ext/misc/carray.c \ $(TOP)/ext/misc/cksumvfs.c \ $(TOP)/ext/misc/closure.c \ $(TOP)/ext/misc/csv.c \ @@ -832,6 +832,7 @@ TESTSRC2 = \ $(TOP)/src/bitvec.c \ $(TOP)/src/btree.c \ $(TOP)/src/build.c \ + $(TOP)/src/carray.c \ ctime.c \ $(TOP)/src/date.c \ $(TOP)/src/dbpage.c \ @@ -1207,6 +1208,9 @@ build.o: $(TOP)/src/build.c $(DEPS_OBJ_COMMON) callback.o: $(TOP)/src/callback.c $(DEPS_OBJ_COMMON) $(T.cc.sqlite) -c $(TOP)/src/callback.c +carray.o: $(TOP)/src/carray.c $(DEPS_OBJ_COMMON) + $(T.cc.sqlite) -c $(TOP)/src/carray.c + complete.o: $(TOP)/src/complete.c $(DEPS_OBJ_COMMON) $(T.cc.sqlite) -c $(TOP)/src/complete.c diff --git a/manifest b/manifest index 499d196f4b..2a34646fa7 100644 --- a/manifest +++ b/manifest @@ -1,12 +1,12 @@ -C Fix\sharmless\sinteger\soverflow\sin\sthe\sCLI\swhen\sarguments\sto\s--lookaside\sare\nridiculously\slarge. -D 2025-10-08T12:37:01.286 +C Were\swe\sto\schoose\sto\sintegrate\sthe\scarray()\stable-valued\sfunction\sinto\sthe\namalgamation,\sthat\sintegration\smight\slook\ssomething\slike\sthis. +D 2025-10-08T15:32:55.195 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d F Makefile.in 3ce07126d7e87c7464301482e161fdae6a51d0a2aa06b200b8f0000ef4d6163b F Makefile.linux-generic bd3e3cacd369821a6241d4ea1967395c962dfe3057e38cb0a435cee0e8b789d0 -F Makefile.msc b87ac9041d87f61fabd6074e6d8b71dd7f78c884a2307bbb9301f9d436ce9242 +F Makefile.msc a401fdcb7553e04f6e1ec4af0cfe43e0e2bfeff09efdfb6e13be482523a7387a F README.md e28077cfbef795e99c9c75ed95aa7257a1166709b562076441a8506ac421b7c1 F VERSION 16eddb43056a79c1977427ab7a05f3457c373fa159dcdced8754eb89ce7e06b8 F art/icon-243x273.gif 9750b734f82fdb3dc43127753d5e6fbf3b62c9f4e136c2fbf573b2f57ea87af5 @@ -353,7 +353,7 @@ F ext/jni/src/org/sqlite/jni/wrapper1/WindowFunction.java c7d1452f9ff26175b3c19b F ext/jni/src/tests/000-000-sanity.test c3427a0e0ac84d7cbe4c95fdc1cd4b61f9ddcf43443408f3000139478c4dc745 F ext/jni/src/tests/000-001-ignored.test e17e874c6ab3c437f1293d88093cf06286083b65bf162317f91bbfd92f961b70 F ext/jni/src/tests/900-001-fts.test bf0ce17a8d082773450e91f2388f5bbb2dfa316d0b676c313c637a91198090f0 -F ext/misc/README.md de71b57b507ab78c03f0d2aceb85fef88a658119d314700391b35a59648cf5f0 +F ext/misc/README.md 6243cdc4d7eb791c41ef0716f3980b8b5f6aa8c61ff76a3958cbf0031c6ebfa7 F ext/misc/amatch.c 2db45b1499b275d8340af6337a13d6216e4ceb2ddb41f4042b9801be7b5e593d F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb F ext/misc/appendvfs.c 9642c7a194a2a25dca7ad3e36af24a0a46d7702168c4ad7e59c9f9b0e16a3824 @@ -362,8 +362,6 @@ F ext/misc/base85.c ff54cc676c6ec86231f75ecc86ea45416fcb69751dfb79690d5f5da5f7d3 F ext/misc/basexx.c 89ad6b76558efbceb627afd5e2ef1d84b2e96d9aaf9b7ecb20e3d00b51be6fcf F ext/misc/blobio.c a867c4c4617f6ec223a307ebfe0eabb45e0992f74dd47722b96f3e631c0edb2a F ext/misc/btreeinfo.c 8f5e6da2c82ec2f06ee0216e922370a436dafdbb06ffa7a552203515ff9e7ddf -F ext/misc/carray.c 9f7f838b3343660256c519f05aae05303d54a62770f64e8e4bbad255d5c78c94 -F ext/misc/carray.h 4bef8af4e9ddda024f5540cc4d456c3e4a4a7624d6315edf85dce1ce8419beb8 F ext/misc/cksumvfs.c 9d7d0cf1a8893ac5d48922bfe9f3f217b4a61a6265f559263a02bb2001259913 F ext/misc/closure.c 5559daf1daf742228431db929d1aa86dd535a4224cc634a81d2fd0d1e6ad7839 F ext/misc/completion.c c27b64fdd0943c1b7f152376599814cee2641f7d67a7bb9bd2b957c2a64a5591 @@ -659,7 +657,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 fd45a3578989f38bbeb2564a63883f6f6c077105c9f1361c3eac411d31f3afbd +F main.mk a97cb12fad3905f2b823c86a17599a2e1baeda10988ac28ab5e8b4b286aa3542 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -679,8 +677,9 @@ F src/btmutex.c 30dada73a819a1ef5b7583786370dce1842e12e1ad941e4d05ac29695528daea F src/btree.c cb5b8ceb9baa02a63a2f83dec09c4153e1cfbdf9c2adef5c62c26d2160eeb067 F src/btree.h e823c46d87f63d904d735a24b76146d19f51f04445ea561f71cc3382fd1307f0 F src/btreeInt.h 9c0f9ea5c9b5f4dcaea18111d43efe95f2ac276cd86d770dce10fd99ccc93886 -F src/build.c f3c5f5b6b4b6654d3680c15b31a1a2ba4fdf0c3b1e8bea10cb20233c5423972f +F src/build.c b014128de988a83bc8a2ad3d778018b698aeb06bff0089b7d263a3a45be8e8bf F src/callback.c acae8c8dddda41ee85cfdf19b926eefe830f371069f8aadca3aa39adf5b1c859 +F src/carray.c 104766efc2199f3afa23bd42ef207d07de5b3287531352fb86476d3c85939109 w ext/misc/carray.c F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/date.c e19e0cfff9a41bfdd884c655755f6f00bca4c1a22272b56e0dd6667b7ea893a2 F src/dbpage.c 081c59d84f187aa0eb48d98faf9578a00bde360f68438d646a86b618653d2479 @@ -737,16 +736,16 @@ F src/resolve.c f8d1d011aba0964ff1bdccd049d4d2c2fec217efd90d202a4bb775e926b2c25d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c b95181711d59c36d9789e67f76c4cfec64b99f9629a50be5e6566e117b87d957 F src/shell.c.in a7f6691c887e7efc1a8466c03d14447dd44e9542642c0d2a5f8366047ba70247 -F src/sqlite.h.in 7032dcc3ee97d1b504a77b987653941c0decfb34158bc3cfe4eb8cb7b7164fad +F src/sqlite.h.in 5e15c4eec691b4e26a7a740627b4ebe0dc8f75565e6484500992c62fe528674b F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479 F src/sqlite3ext.h 3f0c4ed6934e7309a61c6f3c30f70a30a5b869f785bb3d9f721a36c5e4359126 -F src/sqliteInt.h 673c7c5d7e77552452b21499717233329809f252458f77a798977737f51b31b8 +F src/sqliteInt.h c188da4652be436ced01aa29bcbcf8be7069fc640cad5ac872af6641af4d26fd F src/sqliteLimit.h fe70bd8983e5d317a264f2ea97473b359faf3ebb0827877a76813f5cf0cdc364 F src/status.c 0e72e4f6be6ccfde2488eb63210297e75f569f3ce9920f6c3d77590ec6ce5ffd F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c 3c604c49e6cf4211960a9ddb9505280fd22cde32175f40884c641c0f5a286036 F src/tclsqlite.h 614b3780a62522bc9f8f2b9fb22689e8009958e7aa77e572d0f3149050af348a -F src/test1.c ed505d52b164be9db8c5a4b4501c0a58affe010a5b38a30ffa81036878dd516f +F src/test1.c c7c0f304ffa927fd31dac97e48bce5ec8f9466fe5b9e7e303f2a18e1c7b53139 F src/test2.c 62f0830958f9075692c29c6de51b495ae8969e1bef85f239ffcd9ba5fb44a5ff F src/test3.c 432646f581d8af1bb495e58fc98234380250954f5d5535e507fc785eccc3987a F src/test4.c 0ac87fc13cdb334ab3a71823f99b6c32a6bebe5d603cd6a71d84c823d43a25a0 @@ -949,8 +948,8 @@ F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4 F test/capi3c.test 31d3a6778f2d06f2d9222bd7660c41a516d1518a059b069e96ebbeadb5a490f7 F test/capi3d.test 8b778794af891b0dca3d900bd345fbc8ebd2aa2aae425a9dccdd10d5233dfbde F test/capi3e.test 3d49c01ef2a1a55f41d73cba2b23b5059ec460fe -F test/carray01.test 23ed7074307c4a829ba5ff2970993a9d87db7c5cdbbe1a2cbef672d0df6d6e31 -F test/carray02.test 6df8d1bf95f7c5f41f80b81e47f14332222ac820cf3de50af10ec2fb989a903c +F test/carray01.test 49e2aedfdf2c715bc002d2773cdc1217166679639542c79c8aa4115f06421407 +F test/carray02.test 9d070b54f24a34d1f3b3c552ba34db0375a9d1c4219067416fb07d1595987c9d F test/carrayfault.test 52ef4956acbcb7b34eb177167e7af2b5ac8d9cbb80213ef4a3a9d7efb1a1f4be F test/cast.test a2a3b32df86e3c0601ffa2e9f028a18796305d251801efea807092dbf374a040 F test/cffault.test 9d6b20606afe712374952eec4f8fd74b1a8097ef @@ -1679,7 +1678,7 @@ F test/sync.test a619e407ede58a7b6e3e44375328628559fc9695a9c24c47cb5690a866b0031 F test/sync2.test 06152269ed73128782c450c355988fe8dd794d305833af75e1a5e79edd4dae47 F test/syscall.test a067468b43b8cb2305e9f9fe414e5f40c875bb5d2cba5f00b8154396e95fcf37 F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 -F test/tabfunc01.test de8b27fdc92d55ec7d416142b77101cb95f8099c446f43182a23cfb302000cc2 +F test/tabfunc01.test bfe594de13c1169618543f9e62d4baf4387da7b27e724c519792d97e28fbd91f F test/table.test e87294bf1c80bfd7792142b84ab32ea5beb4f3f71e535d7fb263a6b2068377bf F test/tableapi.test e37c33e6be2276e3a96bb54b00eea7f321277115d10e5b30fdb52a112b432750 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 @@ -2125,7 +2124,7 @@ F tool/mkpragmatab.tcl 3801ce32f8c55fe63a3b279f231fb26c2c1a2ea9a09d2dd599239d87a F tool/mkshellc.tcl bab0a72a68384181a5706712dfdf6815f6526446d4e8aacace2de5e80cda91b2 F tool/mksourceid.c 36aa8020014aed0836fd13c51d6dc9219b0df1761d6b5f58ff5b616211b079b9 F tool/mksqlite3c-noext.tcl 351c55256213154cabb051a3c870ef9f4487de905015141ae50dc7578a901b84 -F tool/mksqlite3c.tcl f11b63445c4840509248bd4aa151a81aea25d5415fef71943c8d436eba4f3b3c +F tool/mksqlite3c.tcl 7a268139158e5deef27a370bc2f8db6ccf100c1ad7ac5e5b23743c0fd354f609 F tool/mksqlite3h.tcl ef6831c97e6e638d2324863e8125306baea239b23defd75da77edffa3b620e81 F tool/mksqlite3internalh.tcl 46ef6ed6ccd3c36e23051109dd25085d8edef3887635cea25afa81c4adf4d4db F tool/mksrczip.tcl 81efd9974dbb36005383f2cd655520057a2ae5aa85ac2441a80c7c28f803ac52 @@ -2170,8 +2169,11 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 059203f658273712597d45d9b4a9cf1aea20368fe51224b38e28797b045fb6b8 -R da1f656d86a43e258ff4ab5c066d1b90 +P 8bf337e6e609dd38de6002f2d3d3ebf52dd0462ed98a50e4b002a7c6860d30c5 +R 1ad26611eede06cd84cba8f9535e3010 +T *branch * ext-to-core +T *sym-ext-to-core * +T -sym-trunk * U drh -Z 1495f395e969cab2202a33270e40d13e +Z a83e0018e9cc2d7f757c0280294b2197 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.tags b/manifest.tags index bec971799f..879b171929 100644 --- a/manifest.tags +++ b/manifest.tags @@ -1,2 +1,2 @@ -branch trunk -tag trunk +branch ext-to-core +tag ext-to-core diff --git a/manifest.uuid b/manifest.uuid index 0840a937d7..6d06686020 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8bf337e6e609dd38de6002f2d3d3ebf52dd0462ed98a50e4b002a7c6860d30c5 +2b43d5d7dcc5aee14a050c824a5e09b6a38a9c78ddcc25a994eba5d4c5ad9ba2 diff --git a/src/build.c b/src/build.c index e130ce9027..d5e552d76b 100644 --- a/src/build.c +++ b/src/build.c @@ -438,6 +438,9 @@ Table *sqlite3LocateTable( pMod = sqlite3JsonVtabRegister(db, zName); } #endif + if( pMod==0 && sqlite3_stricmp(zName, "carray")==0 ){ + pMod = sqlite3CarrayRegister(db); + } if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){ testcase( pMod->pEpoTab==0 ); return pMod->pEpoTab; diff --git a/ext/misc/carray.c b/src/carray.c similarity index 96% rename from ext/misc/carray.c rename to src/carray.c index df60b7db32..fcc2b40886 100644 --- a/ext/misc/carray.c +++ b/src/carray.c @@ -10,7 +10,7 @@ ** ************************************************************************* ** -** This file demonstrates how to create a table-valued-function that +** This file implements a table-valued-function that ** returns the values in a C-language array. ** Examples: ** @@ -52,12 +52,7 @@ ** as the number of elements in the array. The virtual table steps through ** the array, element by element. */ -#ifndef SQLITE3_H -# include "sqlite3ext.h" - SQLITE_EXTENSION_INIT1 -# include -# include -#endif +#include "sqliteInt.h" #if defined(_WIN32) || defined(__RTP__) || defined(_WRS_KERNEL) struct iovec { void *iov_base; @@ -562,23 +557,13 @@ static void inttoptrFunc( #endif /* SQLITE_OMIT_VIRTUALTABLE */ -SQLITE_API int sqlite3_carray_init( - sqlite3 *db, - char **pzErrMsg, - const sqlite3_api_routines *pApi -){ - int rc = SQLITE_OK; -#ifdef SQLITE_EXTENSION_INIT2 - SQLITE_EXTENSION_INIT2(pApi); -#endif -#ifndef SQLITE_OMIT_VIRTUALTABLE - rc = sqlite3_create_module(db, "carray", &carrayModule, 0); +/* +** Invoke this routine to register the carray() function. +*/ +Module *sqlite3CarrayRegister(sqlite3 *db){ #ifdef SQLITE_TEST - if( rc==SQLITE_OK ){ - rc = sqlite3_create_function(db, "inttoptr", 1, SQLITE_UTF8, 0, + (void)sqlite3_create_function(db, "inttoptr", 1, SQLITE_UTF8, 0, inttoptrFunc, 0, 0); - } -#endif /* SQLITE_TEST */ -#endif /* SQLITE_OMIT_VIRTUALTABLE */ - return rc; +#endif + return sqlite3VtabCreateModule(db, "carray", &carrayModule, 0, 0); } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 70ba574550..a0a2ca695a 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -11115,6 +11115,41 @@ int sqlite3_deserialize( #define SQLITE_DESERIALIZE_RESIZEABLE 2 /* Resize using sqlite3_realloc64() */ #define SQLITE_DESERIALIZE_READONLY 4 /* Database is read-only */ +/* +** CAPI3REF: Bind array values to the CARRAY table-valued function +** +** The sqlite3_carray_bind(S,I,P,N,F,X) interface binds an array value to +** one of the first argument of the [carray() table-valued function]. The +** S parameter is a pointer to the [prepared statement] that uses the carray() +** functions. I is the parameter index to be bound. P is a pointer to the +** array to be bound, and N is the number of eements in the array. The +** F argument is one of constants [CARRAY_INT32], [CARRAY_INT64], [CARRAY_DOUBLE], +** [CARRAY_TEXT], or [CARRAY_BLOB] to indicate the datatype of the array +** being bound. The X argument is not a NULL pointer, then SQLite will +** invoke the function X on the P parameter after it has finished using P. +*/ +SQLITE_API int sqlite3_carray_bind( + sqlite3_stmt *pStmt, /* Statement to be bound */ + int i, /* Parameter index */ + void *aData, /* Pointer to array data */ + int nData, /* Number of data elements */ + int mFlags, /* CARRAY flags */ + void (*xDel)(void*) /* Destructor for aData */ +); + +/* +** CAPI3REF: Datatypes for the CARRAY table-valued funtion +** +** The fifth argument to the [sqlite3_carray_bind()] interface musts be +** one of the following constants, to specify the datatype of the array +** that is being bound into the [carray table-valued function]. +*/ +#define CARRAY_INT32 0 /* Data is 32-bit signed integers */ +#define CARRAY_INT64 1 /* Data is 64-bit signed integers */ +#define CARRAY_DOUBLE 2 /* Data is doubles */ +#define CARRAY_TEXT 3 /* Data is char* */ +#define CARRAY_BLOB 4 /* Data is struct iovec */ + /* ** Undo the hack that converts floating point types to integer for ** builds on processors without floating point support. diff --git a/src/sqliteInt.h b/src/sqliteInt.h index cf9294dccc..a0b2097946 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -5227,6 +5227,8 @@ int sqlite3SafetyCheckSickOrOk(sqlite3*); void sqlite3ChangeCookie(Parse*, int); With *sqlite3WithDup(sqlite3 *db, With *p); +Module *sqlite3CarrayRegister(sqlite3*); + #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int); #endif diff --git a/src/test1.c b/src/test1.c index 1cb3a6524d..331fc657dd 100644 --- a/src/test1.c +++ b/src/test1.c @@ -4457,14 +4457,6 @@ static int SQLITE_TCLAPI test_carray_bind( static void *aStaticData = 0; static int nStaticData = 0; static int eStaticType = 0; - extern int sqlite3_carray_bind( - sqlite3_stmt *pStmt, - int i, - void *aData, - int nData, - int mFlags, - void (*xDestroy)(void*) - ); if( aStaticData ){ /* Always clear preexisting static data on every call */ @@ -8297,7 +8289,6 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd( extern int sqlite3_amatch_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_appendvfs_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_basexx_init(sqlite3*,char**,const sqlite3_api_routines*); - extern int sqlite3_carray_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_closure_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_csv_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_eval_init(sqlite3*,char**,const sqlite3_api_routines*); @@ -8331,7 +8322,6 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd( { "amatch", sqlite3_amatch_init }, { "appendvfs", sqlite3_appendvfs_init }, { "basexx", sqlite3_basexx_init }, - { "carray", sqlite3_carray_init }, { "closure", sqlite3_closure_init }, { "csv", sqlite3_csv_init }, { "decimal", sqlite3_decimal_init }, diff --git a/test/carray01.test b/test/carray01.test index 1af9cb66e3..86ea069961 100644 --- a/test/carray01.test +++ b/test/carray01.test @@ -20,7 +20,7 @@ ifcapable !vtab { finish_test return } -load_static_extension db carray +#load_static_extension db carray # Parameter $stmt must be a prepared statement created using # the sqlite3_prepare_v2 command and with parameters fully bound. diff --git a/test/carray02.test b/test/carray02.test index 07b5424e5f..c75ca42719 100644 --- a/test/carray02.test +++ b/test/carray02.test @@ -20,7 +20,6 @@ ifcapable !vtab { finish_test return } -load_static_extension db carray proc run_stmt {stmt} { set r {} @@ -161,5 +160,3 @@ do_test 3.1 { } {SQLITE_ERROR {unknown datatype: 'apples'}} finish_test - - diff --git a/test/tabfunc01.test b/test/tabfunc01.test index 177eb7495b..11142b04ce 100644 --- a/test/tabfunc01.test +++ b/test/tabfunc01.test @@ -22,7 +22,6 @@ ifcapable !vtab { return } load_static_extension db series -load_static_extension db carray load_static_extension db remember do_execsql_test tabfunc01-1.1 { diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index 7b6f57e426..0c058672f9 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -491,6 +491,7 @@ set flist { sqlite3rbu.c dbstat.c dbpage.c + carray.c sqlite3session.c fts5.c stmt.c