]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improve performance of sqlite3VdbeRecordCompare() by using an approximation
authordrh <drh@noemail.net>
Mon, 5 Aug 2013 15:32:09 +0000 (15:32 +0000)
committerdrh <drh@noemail.net>
Mon, 5 Aug 2013 15:32:09 +0000 (15:32 +0000)
that might give false negatives and only running the more expensive exact
subexpression if the approximation fails.

FossilOrigin-Name: 28979dcd16f53e0ddca8eed74b668834e2856f03

manifest
manifest.uuid
src/vdbeaux.c

index b354557f646e2d2877515747e148d31e19848992..14fc750b6ff5e3ea0b9be708b5bc14961195a9a3 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sa\smissing\s'#include\s"tcl.h"'\sto\stest_rtree.c.
-D 2013-08-05T12:31:41.375
+C Improve\sperformance\sof\ssqlite3VdbeRecordCompare()\sby\susing\san\sapproximation\nthat\smight\sgive\sfalse\snegatives\sand\sonly\srunning\sthe\smore\sexpensive\sexact\s\nsubexpression\sif\sthe\sapproximation\sfails.
+D 2013-08-05T15:32:09.754
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -281,7 +281,7 @@ F src/vdbe.c d6048a720c197db2f0e7d618e918bd2e2eff0322
 F src/vdbe.h 4f554b5627f26710c4c36d919110a3fc611ca5c4
 F src/vdbeInt.h e9b7c6b165a31a4715c5aa97223d20d265515231
 F src/vdbeapi.c 4d13580bd058b39623e8fcfc233b7df4b8191e8b
-F src/vdbeaux.c 4389b3692969b4415fcfd00de36818a02f84df28
+F src/vdbeaux.c 1a149d406d812b767d70c932dfc472d586d04c45
 F src/vdbeblob.c 5dc79627775bd9a9b494dd956e26297946417d69
 F src/vdbemem.c 833005f1cbbf447289f1973dba2a0c2228c7b8ab
 F src/vdbesort.c 3937e06b2a0e354500e17dc206ef4c35770a5017
@@ -1105,7 +1105,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P 213020769f310aec1591d97756b53891d0b64005
-R 0448e5af5431e1ece697200cba67ff6c
+P 4b8b426f10f8ae13bf553f7adf5ae09383fa0bd4
+R 338de61a71c3cd74b79152f7e9194e12
 U drh
-Z ddf1308995835ea195d91d2476e0f474
+Z 467c61e8c494116a000cdb09272cb823
index 2ba9bc5a79b142b86780af99132dbe1dcd9a9427..caf82026b265ce48aa9728512b40432bbcaf3276 100644 (file)
@@ -1 +1 @@
-4b8b426f10f8ae13bf553f7adf5ae09383fa0bd4
\ No newline at end of file
+28979dcd16f53e0ddca8eed74b668834e2856f03
\ No newline at end of file
index 880a6299ca277dbbb4dd87ca0f55e752df5e3fba..de2de6a7f8b798baddd5a62aecab613f970c9366 100644 (file)
@@ -3023,7 +3023,18 @@ int sqlite3VdbeRecordCompare(
 
     /* Read the serial types for the next element in each key. */
     idx1 += getVarint32( aKey1+idx1, serial_type1 );
-    if( d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1 ) break;
+
+    /* Verify that there is enough key space remaining to avoid
+    ** a buffer overread.  The "d1+serial_type1+2" subexpression will
+    ** always be greater than or equal to the amount of required key space.
+    ** Use that approximation to avoid the more expensive call to
+    ** sqlite3VdbeSerialTypeLen() in the common case.
+    */
+    if( d1+serial_type1+2>(u32)nKey1
+     && d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1 
+    ){
+      break;
+    }
 
     /* Extract the values to be compared.
     */