1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Enable adding JSON1 by appending the json1.c source file to the amalgamation

and compiling with -DSQLITE_ENABLE_JSON1

FossilOrigin-Name: 33404b2029120d4aabe1e25d484871810777e934
This commit is contained in:
drh
2015-09-26 17:44:59 +00:00
parent 32498f1321
commit 2f20e13b83
8 changed files with 47 additions and 29 deletions

View File

@ -544,7 +544,7 @@ FUZZDATA = \
# Extra arguments for including json1 in the build of tools # Extra arguments for including json1 in the build of tools
# #
JSON1_DEP = $(TOP)/ext/misc/json1.c sqlite3ext.h JSON1_DEP = $(TOP)/ext/misc/json1.c sqlite3ext.h
JSON1_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_CORE JSON1_OPT = -DSQLITE_SHELL_JSON1 -DSQLITE_CORE
JSON1_SRC = $(TOP)/ext/misc/json1.c JSON1_SRC = $(TOP)/ext/misc/json1.c
# Standard options to testfixture # Standard options to testfixture
@ -625,6 +625,9 @@ sqlite3.c: .target_source $(TOP)/tool/mksqlite3c.tcl
$(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl $(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl
cp tsrc/shell.c tsrc/sqlite3ext.h . cp tsrc/shell.c tsrc/sqlite3ext.h .
sqlite3ext.h: .target_source
cp tsrc/sqlite3ext.h .
tclsqlite3.c: sqlite3.c tclsqlite3.c: sqlite3.c
echo '#ifndef USE_SYSTEM_SQLITE' >tclsqlite3.c echo '#ifndef USE_SYSTEM_SQLITE' >tclsqlite3.c
cat sqlite3.c >>tclsqlite3.c cat sqlite3.c >>tclsqlite3.c

View File

@ -390,9 +390,9 @@ CORE_LINK_OPTS = /DEF:sqlite3.def
# #
!IFNDEF SHELL_COMPILE_OPTS !IFNDEF SHELL_COMPILE_OPTS
!IF $(DYNAMIC_SHELL)!=0 !IF $(DYNAMIC_SHELL)!=0
SHELL_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 $(SHELL_CCONV_OPTS) -DSQLITE_API=__declspec(dllimport) SHELL_COMPILE_OPTS = -DSQLITE_SHELL_JSON1 $(SHELL_CCONV_OPTS) -DSQLITE_API=__declspec(dllimport)
!ELSE !ELSE
SHELL_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 $(SHELL_CCONV_OPTS) SHELL_COMPILE_OPTS = -DSQLITE_SHELL_JSON1 $(SHELL_CCONV_OPTS)
!ENDIF !ENDIF
!ENDIF !ENDIF

View File

@ -1937,19 +1937,12 @@ static sqlite3_module jsonTreeModule = {
#endif /* SQLITE_OMIT_VIRTUALTABLE */ #endif /* SQLITE_OMIT_VIRTUALTABLE */
/**************************************************************************** /****************************************************************************
** The following routine is the only publically visible identifier in this ** The following routines are the only publically visible identifiers in this
** file. Call the following routine in order to register the various SQL ** file. Call the following routines in order to register the various SQL
** functions and the virtual table implemented by this file. ** functions and the virtual table implemented by this file.
****************************************************************************/ ****************************************************************************/
#ifdef _WIN32 int sqlite3Json1Init(sqlite3 *db){
__declspec(dllexport)
#endif
int sqlite3_json_init(
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi
){
int rc = SQLITE_OK; int rc = SQLITE_OK;
unsigned int i; unsigned int i;
static const struct { static const struct {
@ -1987,8 +1980,6 @@ int sqlite3_json_init(
{ "json_tree", &jsonTreeModule }, { "json_tree", &jsonTreeModule },
}; };
#endif #endif
SQLITE_EXTENSION_INIT2(pApi);
(void)pzErrMsg; /* Unused parameter */
for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){ for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg, rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,
SQLITE_UTF8 | SQLITE_DETERMINISTIC, SQLITE_UTF8 | SQLITE_DETERMINISTIC,
@ -2002,3 +1993,17 @@ int sqlite3_json_init(
#endif #endif
return rc; return rc;
} }
#ifdef _WIN32
__declspec(dllexport)
#endif
int sqlite3_json_init(
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi
){
SQLITE_EXTENSION_INIT2(pApi);
(void)pzErrMsg; /* Unused parameter */
return sqlite3Json1Init(db);
}

View File

@ -454,7 +454,7 @@ FUZZDATA = \
# Extra arguments for including json1 in the build of tools # Extra arguments for including json1 in the build of tools
# #
JSON1_DEP = $(TOP)/ext/misc/json1.c sqlite3ext.h JSON1_DEP = $(TOP)/ext/misc/json1.c sqlite3ext.h
JSON1_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_CORE JSON1_OPT = -DSQLITE_SHELL_JSON1 -DSQLITE_CORE
JSON1_SRC = $(TOP)/ext/misc/json1.c JSON1_SRC = $(TOP)/ext/misc/json1.c
# Standard options to testfixture # Standard options to testfixture
@ -532,6 +532,9 @@ sqlite3.c: target_source $(TOP)/tool/mksqlite3c.tcl
echo '#endif /* USE_SYSTEM_SQLITE */' >>tclsqlite3.c echo '#endif /* USE_SYSTEM_SQLITE */' >>tclsqlite3.c
cat $(TOP)/src/tclsqlite.c >>tclsqlite3.c cat $(TOP)/src/tclsqlite.c >>tclsqlite3.c
sqlite3ext.h: target_source
cp tsrc/sqlite3ext.h .
sqlite3.c-debug: target_source $(TOP)/tool/mksqlite3c.tcl sqlite3.c-debug: target_source $(TOP)/tool/mksqlite3c.tcl
tclsh $(TOP)/tool/mksqlite3c.tcl --linemacros tclsh $(TOP)/tool/mksqlite3c.tcl --linemacros
echo '#ifndef USE_SYSTEM_SQLITE' >tclsqlite3.c echo '#ifndef USE_SYSTEM_SQLITE' >tclsqlite3.c

View File

@ -1,9 +1,9 @@
C Fix\sa\smemory\sleak\sthat\scan\soccur\sfollowing\sa\ssyntax\serror\sin\sCREATE\sVIEW. C Enable\sadding\sJSON1\sby\sappending\sthe\sjson1.c\ssource\sfile\sto\sthe\samalgamation\nand\scompiling\swith\s-DSQLITE_ENABLE_JSON1
D 2015-09-26T11:15:44.897 D 2015-09-26T17:44:59.245
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in e1afa6fb2de2bddd50e0ddae8166c2ee9d69b301 F Makefile.in 2143eeef6d0cc26006ae5fc4bb242a4a8b973412
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F Makefile.msc f090cdf036f3c07fb13aa2f4494e388c0b1ed1e4 F Makefile.msc b9054642ab305be4174d8b0433c9951c2839701d
F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858
F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7
F VERSION ccfc4d1576dbfdeece0a4372a2e6a2e37d3e7975 F VERSION ccfc4d1576dbfdeece0a4372a2e6a2e37d3e7975
@ -195,7 +195,7 @@ F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2
F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f
F ext/misc/fuzzer.c 4c84635c71c26cfa7c2e5848cf49fe2d2cfcd767 F ext/misc/fuzzer.c 4c84635c71c26cfa7c2e5848cf49fe2d2cfcd767
F ext/misc/ieee754.c b0362167289170627659e84173f5d2e8fee8566e F ext/misc/ieee754.c b0362167289170627659e84173f5d2e8fee8566e
F ext/misc/json1.c 557d6b2d0c3d26625e686a4b4ef8d4a50b8cec94 F ext/misc/json1.c 263cac0292302b7cf7ecb2e8bd698a50d1aedecc
F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342
F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63
F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc
@ -261,7 +261,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
F main.mk d12601118f1d1dadebe1329a53a6d5c512b36d44 F main.mk 151fcaba704fdeeb0a1941857ef6e1d6216732d8
F mkopcodec.awk c2ff431854d702cdd2d779c9c0d1f58fa16fa4ea F mkopcodec.awk c2ff431854d702cdd2d779c9c0d1f58fa16fa4ea
F mkopcodeh.awk 0e7f04a8eb90f92259e47d80110e4e98d7ce337a F mkopcodeh.awk 0e7f04a8eb90f92259e47d80110e4e98d7ce337a
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
@ -305,7 +305,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e
F src/lempar.c d344a95d60c24e2f490ee59db9784b1b17439012 F src/lempar.c d344a95d60c24e2f490ee59db9784b1b17439012
F src/loadext.c f0b66d28e377fd6c6d36cc9d92df1ff251ebee44 F src/loadext.c f0b66d28e377fd6c6d36cc9d92df1ff251ebee44
F src/main.c e17fcffae4306a9b8334faf3bac80d7396850b54 F src/main.c c80ea19ec71609ccbec21f334fbcf475bb6af2fc
F src/malloc.c 3a37ce6979a40f499d8cea9e9ab4e8517854d35d F src/malloc.c 3a37ce6979a40f499d8cea9e9ab4e8517854d35d
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987 F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987
@ -341,7 +341,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
F src/resolve.c 1954a0f01bf65d78d7d559aea3d5c67f33376d91 F src/resolve.c 1954a0f01bf65d78d7d559aea3d5c67f33376d91
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
F src/select.c 33230303f5f32430ee971a6fcc6a370e4a93ae1a F src/select.c 33230303f5f32430ee971a6fcc6a370e4a93ae1a
F src/shell.c 6332ef06db1390ef812cfdff1fc97b4fd76cdd42 F src/shell.c a11b20da4c6630e0e8f83c47ce36f717dd0422f0
F src/sqlite.h.in 02f6ed7de3a96d10bd1e6e5803e4e4b786dff014 F src/sqlite.h.in 02f6ed7de3a96d10bd1e6e5803e4e4b786dff014
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
F src/sqlite3ext.h 64350bf36833a56ad675e27392a913f417c5c308 F src/sqlite3ext.h 64350bf36833a56ad675e27392a913f417c5c308
@ -1388,7 +1388,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P b79023542458f7e839469c5e313694f1e4cf223a P f4704035a6134f702c00110358e36f1579e2ea78
R 5bffdcb8f106214b20b1e8dd3d8300df R 6dd9af66a4beb7d52dbecad30f413fd3
U drh U drh
Z 606c03f040a7d5d452758b762c64cca4 Z 2dae51b0464af5412711a65e5f2d84bb

View File

@ -1 +1 @@
f4704035a6134f702c00110358e36f1579e2ea78 33404b2029120d4aabe1e25d484871810777e934

View File

@ -2896,6 +2896,13 @@ static int openDatabase(
} }
#endif #endif
#ifdef SQLITE_ENABLE_JSON1
if( !db->mallocFailed && rc==SQLITE_OK){
extern int sqlite3Json1Init(sqlite3*);
rc = sqlite3Json1Init(db);
}
#endif
/* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking
** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking
** mode. Doing nothing at all also makes NORMAL the default. ** mode. Doing nothing at all also makes NORMAL the default.

View File

@ -4619,7 +4619,7 @@ int SQLITE_CDECL main(int argc, char **argv){
} }
data.out = stdout; data.out = stdout;
#ifdef SQLITE_ENABLE_JSON1 #ifdef SQLITE_SHELL_JSON1
{ {
extern int sqlite3_json_init(sqlite3*); extern int sqlite3_json_init(sqlite3*);
sqlite3_auto_extension((void(*)(void))sqlite3_json_init); sqlite3_auto_extension((void(*)(void))sqlite3_json_init);