Compare commits

..

4 Commits

Author SHA1 Message Date
drh 76076d442a Fix a typo accidently added to the prior check-in.
FossilOrigin-Name: fb2f283038f9329b6f791d92d6f943269f24f1a0efd5859165b63f517ed52ddb
2025-04-01 16:26:51 +00:00
drh 3a7042e0e2 This is an experimental optimization that attempts to keep a JSONB value
the same size (same number of bytes) after doing a replace of an elements
with a slightly smaller element, by denormalizing the size field.  This
can perhaps avoid unnecessary page updates and memmove() operations when
making small changes in the middle of a large JSONB value.

FossilOrigin-Name: b5de9584b7f49586c5387d8a74af5e41dba50f1817a54257bf9da00deb695f72
2025-04-01 15:17:01 +00:00
drh 4d9384cba3 Fix a harmless typo in a code comment.
FossilOrigin-Name: dd251377bd1a8e95a4a0179c50595f290b08ea93659f4906f88f5a9dff534aa1
2025-03-31 23:18:06 +00:00
stephan 0a0367f387 Ensure that the compilation of extensions get the same CFLAGS as the core lib. Move the feature flags enabled by --dev out of TARGET_DEBUG and into OPT_FEATURE_FLAGS (for consistency). Rename the make-internal gcov-related flags to be more descriptive. At the end of the configure script, if SQLITE_DEBUG is active then emit a note reminding the builder that performance will suffer.
FossilOrigin-Name: e64c6a3856b839e4e8c0a1cb1713b0d2f1d3cb9b915dd215b0d3cb229502d539
2025-03-31 13:08:29 +00:00
9 changed files with 152 additions and 67 deletions
+2 -11
View File
@@ -138,15 +138,6 @@ libsqlite3.DLL.install-rules = @SQLITE_DLL_INSTALL_RULES@
# -fsanitize flags for the fuzzcheck-asap app
CFLAGS.fuzzcheck-asan.fsanitize = @CFLAGS_ASAN_FSANITIZE@
#
# Define -D_HAVE_SQLITE_CONFIG_H so that the code knows it
# can include the generated sqlite_cfg.h.
#
# main.mk will fill out T.cc.sqlite with additional flags common to
# all builds.
#
T.cc.sqlite.extras = -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite
#
# Intended to either be empty or be set to -g -DSQLITE_DEBUG=1.
#
@@ -249,8 +240,8 @@ TSTRNNR_OPTS = @TSTRNNR_OPTS@
CFLAGS.gcov1 = -DSQLITE_COVERAGE_TEST=1 -fprofile-arcs -ftest-coverage
LDFLAGS.gcov1 = -lgcov
USE_GCOV = @USE_GCOV@
T.compile.extras = $(CFLAGS.gcov$(USE_GCOV))
T.link.extras = $(LDFLAGS.gcov$(USE_GCOV))
T.compile.gcov = $(CFLAGS.gcov$(USE_GCOV))
T.link.gcov = $(LDFLAGS.gcov$(USE_GCOV))
#
# Vars with the AS_ prefix are specifically related to AutoSetup.
+1 -1
View File
@@ -26,7 +26,7 @@ sqlite-configure canonical {
# [proj-get-env] and we want this to supercede that.
sqlite-munge-cflags; # straighten out -DSQLITE_ENABLE/OMIT flags
}
sqlite-handle-debug
sqlite-handle-debug ;# must come after --dev flag check
sqlite-check-common-bins ;# must come before [sqlite-handle-wasi-sdk]
sqlite-handle-wasi-sdk ;# must run relatively early, as it changes the environment
sqlite-check-common-system-deps
+9 -4
View File
@@ -525,7 +525,8 @@ define OPT_SHELL {} ; # Feature-related CFLAGS for the sqlite3 CLI app
# Adds $args, if not empty, to OPT_FEATURE_FLAGS. If the first arg is
# -shell then it strips that arg and passes the remaining args the
# sqlite-add-shell-opt in addition to adding them to
# OPT_FEATURE_FLAGS.
# OPT_FEATURE_FLAGS. This is intended only for holding
# -DSQLITE_ENABLE/OMIT/... flags, but that is not enforced here.
proc sqlite-add-feature-flag {args} {
set shell ""
if {"-shell" eq [lindex $args 0]} {
@@ -771,6 +772,9 @@ proc sqlite-finalize-feature-flags {} {
proj-assert {"canonical" eq $::sqliteConfig(build-mode)}
msg-result "Appending source files to amalgamation: $extraSrc"
}
if {[lsearch [get-define TARGET_DEBUG ""] -DSQLITE_DEBUG=1] > -1} {
msg-result "Note: this is a debug build, so performance will suffer."
}
}
########################################################################
@@ -780,7 +784,8 @@ proc sqlite-finalize-feature-flags {} {
proc sqlite-handle-debug {} {
msg-checking "SQLITE_DEBUG build? "
proj-if-opt-truthy debug {
define TARGET_DEBUG {-g -DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0 -Wall}
define TARGET_DEBUG {-g -DSQLITE_DEBUG=1 -O0 -Wall}
sqlite-add-feature-flag -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE
proj-opt-set memsys5
msg-result yes
} {
@@ -1384,7 +1389,7 @@ proc sqlite-handle-load-extension {} {
msg-result "Loadable extension support enabled."
} else {
msg-result "Disabling loadable extension support. Use --enable-load-extension to enable them."
sqlite-add-feature-flag {-DSQLITE_OMIT_LOAD_EXTENSION=1}
sqlite-add-feature-flag -DSQLITE_OMIT_LOAD_EXTENSION=1
}
return $found
}
@@ -1398,7 +1403,7 @@ proc sqlite-handle-math {} {
}
define LDFLAGS_MATH [get-define lib_ceil]
undefine lib_ceil
sqlite-add-feature-flag {-DSQLITE_ENABLE_MATH_FUNCTIONS}
sqlite-add-feature-flag -DSQLITE_ENABLE_MATH_FUNCTIONS
msg-result "Enabling math SQL functions"
} {
define LDFLAGS_MATH ""
+31 -11
View File
@@ -260,8 +260,9 @@ EXTRA_SRC ?=
#
# $(OPTS)=... is another way of influencing C compilation. It is
# distinctly separate from $(OPTIONS) and $(OPT_FEATURE_FLAGS) but,
# like those, $(OPTS) applies to all invocations of $(T.cc). The
# configure process does not set either of $(OPTIONS) or $(OPTS).
# like those, $(OPTS) applies to all invocations of $(T.cc) (and some
# invocations of $(B.cc). The configure process does not set either of
# $(OPTIONS) or $(OPTS).
#
OPT_FEATURE_FLAGS ?=
#
@@ -364,24 +365,43 @@ INSTALL.noexec = $(INSTALL) -m 0644
# ^^^ do not use GNU-specific flags to $(INSTALL), e.g. --mode=...
#
# $(T.compile) = generic target platform compiler invocation,
# differing only from $(T.cc) in that it appends $(T.compile.extras),
# which are primarily intended for use with gcov-related flags.
# T.compile.gcov = gcov-specific compilation flags for the target
# platform.
#
T.compile = $(T.cc) $(T.compile.extras)
T.compile.gcov ?=
#
# T.link.gcov = gcov-specific link flags for the target platform.
#
T.link.gcov ?=
#
# $(T.compile) = generic target platform compiler invocation,
# differing only from $(T.cc) in that it appends $(T.compile.gcov),
# which is intended for use with gcov-related flags.
#
T.compile = $(T.cc) $(T.compile.gcov)
#
# Optionally set by the configure script to include -DSQLITE_DEBUG=1
# and other debug-related flags.
#
T.cc.TARGET_DEBUG ?=
#
# Extra CFLAGS for both the core sqlite3 components and extensions.
#
# Define -D_HAVE_SQLITE_CONFIG_H so that the code knows it
# can include the generated sqlite_cfg.h.
#
T.cc.sqlite.extras = -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite $(T.cc.TARGET_DEBUG)
#
# $(T.cc.sqlite) is $(T.cc) plus any flags which are desired for the
# library as a whole, but not necessarily needed for every binary. It
# will normally get initially populated with flags by the
# configure-generated makefile.
#
T.cc.sqlite ?= $(T.cc) $(T.cc.sqlite.extras) $(T.cc.TARGET_DEBUG)
T.cc.sqlite ?= $(T.compile) $(T.cc.sqlite.extras)
#
# $(CFLAGS.intree_includes) = -I... flags relevant specifically to
@@ -397,16 +417,16 @@ T.cc.sqlite += $(CFLAGS.intree_includes)
#
# $(T.cc.extension) = compiler invocation for loadable extensions.
#
T.cc.extension = $(T.compile) -I. -I$(TOP)/src $(T.cc.TARGET_DEBUG) -DSQLITE_CORE
T.cc.extension = $(T.compile) -I. -I$(TOP)/src $(T.cc.sqlite.extras) -DSQLITE_CORE
#
# $(T.link) = compiler invocation for when the target will be an
# executable.
#
# $(T.link.extras) = optional config-specific flags for $(T.link),
# primarily intended for use with gcov-related flags.
# $(T.link.gcov) = optional config-specific flags for $(T.link),
# intended for use with gcov-related flags.
#
T.link = $(T.cc.sqlite) $(T.link.extras)
T.link = $(T.cc.sqlite) $(T.link.gcov)
#
# $(T.link.shared) = $(T.link) invocation specifically for shared libraries
#
+13 -16
View File
@@ -1,10 +1,10 @@
C Add\sthe\s?ENCODING?\sparameter\sto\sthe\s"db\scopy"\scommand.\sIf\sused,\sit\swill\stranslate\sfrom\sthe\sgiven\sencoding\sto\sUTF-8
D 2025-03-31T11:24:10.202
C Fix\sa\stypo\saccidently\sadded\sto\sthe\sprior\scheck-in.
D 2025-04-01T16:26:51.792
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 34794659ddf442225267c4c9b743b7817d2321be88d5eb44d87f35443dc284b6
F Makefile.in 24a030d8507a7e040907ea3eb7740bd583f89ef8019ef23826dfc1cf3d6f26f0
F Makefile.linux-generic bd3e3cacd369821a6241d4ea1967395c962dfe3057e38cb0a435cee0e8b789d0
F Makefile.msc bb2cc6f75bbcb2d690fbdd1489914a2febd5e99bad9c77538cb3330d304694c6
F README.md a953c0cffd6e4f2501a306c00ee2b6e1e6630c25031e094629307fe99dd003d1
@@ -15,7 +15,7 @@ F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2
F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90
F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2
F art/sqlite370.svg 40b7e2fe8aac3add5d56dd86ab8d427a4eca5bcb3fe4f8946cb3794e1821d531
F auto.def 80e6d7f7172fcfc53c67e9304c80482637aee04d3370f172f82d1244ff1f19ef
F auto.def 3c423bc80e144784abeff067ade482fc4d64979bf2d3d673d974d952cf6c6260
F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac
F autoconf/Makefile.in 66d98d473556c4e2daf7252355f4b5db129091800027f280082804eb4c45784f
F autoconf/Makefile.msc 5bc67d3912444c40c6f96d003e5c90663e51abb83d204a520110b1b2038dcd8b
@@ -52,7 +52,7 @@ F autosetup/find_tclconfig.tcl e64886ffe3b982d4df42cd28ed91fe0b5940c2c5785e126c1
F autosetup/jimsh0.c a57c16e65dcffc9c76e496757cb3f7fb47e01ecbd1631a0a5e01751fc856f049
F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba
F autosetup/proj.tcl cac07d75249fa127500b8e96080dc807e9ae97fe98d29e84a17bc28f4628e93f
F autosetup/sqlite-config.tcl b9ab4e0305833757cdc9ba8d366434f31e5ee46083230f5b3343ff09bc2ea0d7
F autosetup/sqlite-config.tcl f4ee2028c603fdffb0dfec1a1ac16f5477c8047c728eac6357382f3767ec203b
F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9
F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x
F contrib/sqlitecon.tcl eb4c6578e08dd353263958da0dc620f8400b869a50d06e271ab0be85a51a08d3
@@ -709,7 +709,7 @@ F ext/wasm/tests/opfs/sahpool/sahpool-pausing.js f264925cfc82155de38cecb3d204c36
F ext/wasm/tests/opfs/sahpool/sahpool-worker.js bd25a43fc2ab2d1bafd8f2854ad3943ef673f7c3be03e95ecf1612ff6e8e2a61
F ext/wasm/wasmfs.make 68999f5bd8c489239592d59a420f8c627c99169bbd6fa16a404751f757b9f702
F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0
F main.mk c35bf589abc5baa7dc4bc44d7f666b82bbc6891fa67486c95d942af9343870b5
F main.mk ed671b5709a4f3e4ed156c0d9e323206fec612d819995d1845e93594d4de7ea2
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421
@@ -746,7 +746,7 @@ F src/hash.h 46b92795a95bfefb210f52f0c316e9d7cdbcdd7e7fcfb0d8be796d3a5767cddf
F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
F src/insert.c a5f0366266be993ebf533808f22cb7a788624805b55bc45424ceed3f48c54a16
F src/json.c 81e2012796a0e139b18c50ee3444c8ef86a020ab360511882216f5b610657e0c
F src/json.c fbae43c3920110be8d5307003d37d2b85b9bfb6d6d70fcb56ab68204026141af
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36
F src/main.c 07f78d917ffcdf327982840cfd8e855fd000527a2ea5ace372ce4febcbd0bf97
@@ -794,7 +794,7 @@ F src/sqliteInt.h 96133c5b4371629b30644a88108a0ca99e6a95a55509cdfc8de9961fba4bbd
F src/sqliteLimit.h 6d817c28a8f19af95e6f4921933b7fbbca48a962bce0eb0ec81e8bb3ef38e68b
F src/status.c 0e72e4f6be6ccfde2488eb63210297e75f569f3ce9920f6c3d77590ec6ce5ffd
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
F src/tclsqlite.c b13fe776a38910f237b5b9861060c83eaa671533f341f49b5eff9a084468f78d
F src/tclsqlite.c 767a11d470b031e85f51b8924a0e8929b2362ff1975aee3474a10eba3c2e0d36
F src/tclsqlite.h 65e2c761446e1c9fa0342b7d2612a703483643c8b6a316d12a65b745a4727395
F src/test1.c e89a11192dd15da20e8f7dc0731297182b2fff56cf4afe6ca6f9aeab890595c5
F src/test2.c 62f0830958f9075692c29c6de51b495ae8969e1bef85f239ffcd9ba5fb44a5ff
@@ -1725,7 +1725,7 @@ F test/tabfunc01.test e85679a3800aa632dee787966b8482fce0bd47629dad82f102fd52f319
F test/table.test 7862a00b58b5541511a26757ea9c5c7c3f8298766e98aa099deec703d9c0a8e0
F test/tableapi.test e37c33e6be2276e3a96bb54b00eea7f321277115d10e5b30fdb52a112b432750
F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930
F test/tclsqlite.test c627fd82e2028d9f03d3f2aafb25361daeb3fd09ea3f933db9114f63e320d7e7
F test/tclsqlite.test ad0bbd92edabe64cc91d990a0748142fe5ab962d74ac71fa3bfa94d50d2f4c87
F test/tempdb.test 4cdaa23ddd8acb4d79cbb1b68ccdfd09b0537aaba909ca69a876157c2a2cbd08
F test/tempdb2.test 353864e96fd3ae2f70773d0ffbf8b1fe48589b02c2ec05013b540879410c3440
F test/tempfault.test 0c0d349c9a99bf5f374655742577f8712c647900
@@ -2216,11 +2216,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 3e96b772a46638bc25e036de053d620ded3350871ee10e06fd6fe51429934b0d
R 998b143fedcb6afb3f27ef334de6e12f
T *branch * db-copy-encoding
T *sym-db-copy-encoding *
T -sym-trunk *
U jan.nijtmans
Z e388c1b3a45ffe93645e261095f25c2d
P b5de9584b7f49586c5387d8a74af5e41dba50f1817a54257bf9da00deb695f72
R f7b3decde4c91460fa618a18904e7ef3
U drh
Z 4f8d1e55abbb72c60ce6fde5ac11a1ee
# Remove this line to create a well-formed Fossil manifest.
+1 -1
View File
@@ -1 +1 @@
ac27c2f81654f8d6ce8ef084c98b408c8e9e96dbfccc24a4c8d3d8d5190d932d
fb2f283038f9329b6f791d92d6f943269f24f1a0efd5859165b63f517ed52ddb
+90 -7
View File
@@ -23,8 +23,8 @@
** Beginning with version 3.45.0 (circa 2024-01-01), these routines also
** accept BLOB values that have JSON encoded using a binary representation
** called "JSONB". The name JSONB comes from PostgreSQL, however the on-disk
** format SQLite JSONB is completely different and incompatible with
** PostgreSQL JSONB.
** format for SQLite-JSONB is completely different and incompatible with
** PostgreSQL-JSONB.
**
** Decoding and interpreting JSONB is still O(N) where N is the size of
** the input, the same as text JSON. However, the constant of proportionality
@@ -81,7 +81,7 @@
**
** The payload size need not be expressed in its minimal form. For example,
** if the payload size is 10, the size can be expressed in any of 5 different
** ways: (1) (X>>4)==10, (2) (X>>4)==12 following by on 0x0a byte,
** ways: (1) (X>>4)==10, (2) (X>>4)==12 following by one 0x0a byte,
** (3) (X>>4)==13 followed by 0x00 and 0x0a, (4) (X>>4)==14 followed by
** 0x00 0x00 0x00 0x0a, or (5) (X>>4)==15 followed by 7 bytes of 0x00 and
** a single byte of 0x0a. The shorter forms are preferred, of course, but
@@ -91,7 +91,7 @@
** the size when it becomes known, resulting in a non-minimal encoding.
**
** The value (X>>4)==15 is not actually used in the current implementation
** (as SQLite is currently unable handle BLOBs larger than about 2GB)
** (as SQLite is currently unable to handle BLOBs larger than about 2GB)
** but is included in the design to allow for future enhancements.
**
** The payload follows the header. NULL, TRUE, and FALSE have no payload and
@@ -1165,7 +1165,7 @@ static SQLITE_NOINLINE void jsonBlobExpandAndAppendNode(
}
/* Append an node type byte together with the payload size and
/* Append a node type byte together with the payload size and
** possibly also the payload.
**
** If aPayload is not NULL, then it is a pointer to the payload which
@@ -2500,6 +2500,82 @@ static void jsonAfterEditSizeAdjust(JsonParse *pParse, u32 iRoot){
pParse->delta += jsonBlobChangePayloadSize(pParse, iRoot, sz);
}
/*
** If the JSONB at aIns[0..nIns-1] can be expanded (by denormalizing the
** size field) by d bytes, then write the expansion into aOut[] and
** return true. In this way, an overwrite happens without changing the
** size of the JSONB, which reduces memcpy() operations and also make it
** faster and easier to update the B-Tree entry that contains the JSONB
** in the database.
**
** If the expansion of aIns[] by d bytes cannot be (easily) accomplished
** then return false.
**
** The d parameter is guaranteed to be between 1 and 8.
**
** This routine is an optimization. A correct answer is obtained if it
** always leaves the output unchanged and returns false.
*/
static int jsonBlobOverwrite(
u8 *aOut, /* Overwrite here */
const u8 *aIns, /* New content */
u32 nIns, /* Bytes of new content */
u32 d /* Need to expand new content by this much */
){
u32 szPayload; /* Bytes of payload */
u32 i; /* New header size, after expansion & a loop counter */
u8 szHdr; /* Size of header before expansion */
/* Lookup table for finding the upper 4 bits of the first byte of the
** expanded aIns[], based on the size of the expanded aIns[] header:
**
** 2 3 4 5 6 7 8 9 */
static const u8 aType[] = { 0xc0, 0xd0, 0, 0xe0, 0, 0, 0, 0xf0 };
if( (aIns[0]&0x0f)<=2 ) return 0; /* Cannot enlarge NULL, true, false */
switch( aIns[0]>>4 ){
default: { /* aIns[] header size 1 */
if( ((1<<d)&0x116)==0 ) return 0; /* d must be 1, 2, 4, or 8 */
i = d + 1; /* New hdr sz: 2, 3, 5, or 9 */
szHdr = 1;
break;
}
case 12: { /* aIns[] header size is 2 */
if( ((1<<d)&0x8a)==0) return 0; /* d must be 1, 3, or 7 */
i = d + 2; /* New hdr sz: 2, 5, or 9 */
szHdr = 2;
break;
}
case 13: { /* aIns[] header size is 3 */
if( d!=2 && d!=6 ) return 0; /* d must be 2 or 6 */
i = d + 3; /* New hdr sz: 5 or 9 */
szHdr = 3;
break;
}
case 14: { /* aIns[] header size is 5 */
if( d!=4 ) return 0; /* d must be 4 */
i = 9; /* New hdr sz: 9 */
szHdr = 5;
break;
}
case 15: { /* aIns[] header size is 9 */
return 0; /* No solution */
}
}
assert( i>=2 && i<=9 && aType[i-2]!=0 );
aOut[0] = (aIns[0] & 0x0f) | aType[i-2];
memcpy(&aOut[i], &aIns[szHdr], nIns-szHdr);
szPayload = nIns - szHdr;
while( 1/*edit-by-break*/ ){
i--;
aOut[i] = szPayload & 0xff;
if( i==1 ) break;
szPayload >>= 8;
}
assert( (szPayload>>8)==0 );
return 1;
}
/*
** Modify the JSONB blob at pParse->aBlob by removing nDel bytes of
** content beginning at iDel, and replacing them with nIns bytes of
@@ -2521,6 +2597,11 @@ static void jsonBlobEdit(
u32 nIns /* Bytes of content to insert */
){
i64 d = (i64)nIns - (i64)nDel;
if( d<0 && d>=(-8) && aIns!=0
&& jsonBlobOverwrite(&pParse->aBlob[iDel], aIns, nIns, (int)-d)
){
return;
}
if( d!=0 ){
if( pParse->nBlob + d > pParse->nBlobAlloc ){
jsonBlobExpand(pParse, pParse->nBlob+d);
@@ -2532,7 +2613,9 @@ static void jsonBlobEdit(
pParse->nBlob += d;
pParse->delta += d;
}
if( nIns && aIns ) memcpy(&pParse->aBlob[iDel], aIns, nIns);
if( nIns && aIns ){
memcpy(&pParse->aBlob[iDel], aIns, nIns);
}
}
/*
@@ -3295,7 +3378,7 @@ static char *jsonBadPathError(
}
/* argv[0] is a BLOB that seems likely to be a JSONB. Subsequent
** arguments come in parse where each pair contains a JSON path and
** arguments come in pairs where each pair contains a JSON path and
** content to insert or set at that patch. Do the updates
** and return the result.
**
+4 -15
View File
@@ -2531,11 +2531,10 @@ static int SQLITE_TCLAPI DbObjCmd(
Tcl_Obj *pResult; /* interp result */
const char *zSep;
const char *zEnc = NULL;
const char *zNull;
if( objc<5 || objc>8 ){
if( objc<5 || objc>7 ){
Tcl_WrongNumArgs(interp, 2, objv,
"CONFLICT-ALGORITHM TABLE FILENAME ?SEPARATOR? ?NULLINDICATOR? ?ENCODING?");
"CONFLICT-ALGORITHM TABLE FILENAME ?SEPARATOR? ?NULLINDICATOR?");
return TCL_ERROR;
}
if( objc>=6 ){
@@ -2548,9 +2547,6 @@ static int SQLITE_TCLAPI DbObjCmd(
}else{
zNull = "";
}
if( objc>=8 ){
zEnc = Tcl_GetStringFromObj(objv[7], 0);
}
zConflict = Tcl_GetStringFromObj(objv[2], 0);
zTable = Tcl_GetStringFromObj(objv[3], 0);
zFile = Tcl_GetStringFromObj(objv[4], 0);
@@ -2616,10 +2612,6 @@ static int SQLITE_TCLAPI DbObjCmd(
return TCL_ERROR;
}
Tcl_SetChannelOption(NULL, in, "-translation", "auto");
if (zEnc && *zEnc && Tcl_SetChannelOption(interp, in, "-encoding", zEnc) != TCL_OK) {
sqlite3_finalize(pStmt);
return TCL_ERROR;
}
azCol = malloc( sizeof(azCol[0])*(nCol+1) );
if( azCol==0 ) {
Tcl_AppendResult(interp, "Error: can't malloc()", (char*)0);
@@ -2632,12 +2624,9 @@ static int SQLITE_TCLAPI DbObjCmd(
zCommit = "COMMIT";
while( Tcl_GetsObj(in, str)>=0 ) {
char *z;
Tcl_Size byteLen;
lineno++;
if (zEnc && *zEnc) {
zLine = Tcl_GetString(str);
}else {
zLine = (char *)Tcl_GetByteArrayFromObj(str, NULL);
}
zLine = (char *)Tcl_GetByteArrayFromObj(str, &byteLen);
azCol[0] = zLine;
for(i=0, z=zLine; *z; z++){
if( *z==zSep[0] && strncmp(z, zSep, nSep)==0 ){
+1 -1
View File
@@ -153,7 +153,7 @@ do_test tcl-1.21 {
do_test tcl-1.22 {
set v [catch {db copy} msg]
lappend v $msg
} {1 {wrong # args: should be "db copy CONFLICT-ALGORITHM TABLE FILENAME ?SEPARATOR? ?NULLINDICATOR? ?ENCODING?"}}
} {1 {wrong # args: should be "db copy CONFLICT-ALGORITHM TABLE FILENAME ?SEPARATOR? ?NULLINDICATOR?"}}
do_test tcl-1.23 {
set v [catch {sqlite3 db2 test.db -vfs nosuchvfs} msg]
lappend v $msg