Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Get the -DSQLITE_OMIT_XFER_OPT option working. Run speed tests on a full regression. Add the script for generating sqlite3.c. (CVS 3723) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
42c038518c4ba0ef827a5717d450f951 |
User & Date: | drh 2007-03-27 12:04:05.000 |
Context
2007-03-27
| ||
12:04 | Get the -DSQLITE_OMIT_XFER_OPT option working. Run speed tests on a full regression. Add the script for generating sqlite3.c. (CVS 3724) (check-in: 1dd9d0775a user: drh tags: trunk) | |
12:04 | Get the -DSQLITE_OMIT_XFER_OPT option working. Run speed tests on a full regression. Add the script for generating sqlite3.c. (CVS 3723) (check-in: 42c038518c user: drh tags: trunk) | |
2007-03-26
| ||
22:05 | Modify sources to that they can be combined into a single sqlite3.c source file. Eliminate all type-pruned pointer warnings. (CVS 3722) (check-in: 0b832e218e user: drh tags: trunk) | |
Changes
Changes to src/insert.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** ** $Id: insert.c,v 1.177 2007/03/27 12:04:05 drh Exp $ */ #include "sqliteInt.h" /* ** Set P3 of the most recently inserted opcode to a column affinity ** string for index pIdx. A column affinity string has one character ** for each column in the table, according to the affinity of the column: |
︙ | ︙ | |||
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 | VdbeComment((v, "# %s", pIdx->zName)); sqlite3VdbeOp3(v, op, i+base, pIdx->tnum, (char*)pKey, P3_KEYINFO_HANDOFF); } if( pParse->nTab<=base+i ){ pParse->nTab = base+i; } } #ifndef SQLITE_OMIT_XFER_OPT /* ** Check to collation names to see if they are compatible. */ static int xferCompatibleCollation(const char *z1, const char *z2){ if( z1==0 ){ | > > > > > > > > > > > > | 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 | VdbeComment((v, "# %s", pIdx->zName)); sqlite3VdbeOp3(v, op, i+base, pIdx->tnum, (char*)pKey, P3_KEYINFO_HANDOFF); } if( pParse->nTab<=base+i ){ pParse->nTab = base+i; } } #ifdef SQLITE_TEST /* ** The following global variable is incremented whenever the ** transfer optimization is used. This is used for testing ** purposes only - to make sure the transfer optimization really ** is happening when it is suppose to. */ int sqlite3_xferopt_count; #endif /* SQLITE_TEST */ #ifndef SQLITE_OMIT_XFER_OPT /* ** Check to collation names to see if they are compatible. */ static int xferCompatibleCollation(const char *z1, const char *z2){ if( z1==0 ){ |
︙ | ︙ | |||
1293 1294 1295 1296 1297 1298 1299 | } } /* If no test above fails then the indices must be compatible */ return 1; } | < < < < < < < < < < | 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 | } } /* If no test above fails then the indices must be compatible */ return 1; } /* ** Attempt the transfer optimization on INSERTs of the form ** ** INSERT INTO tab1 SELECT * FROM tab2; ** ** This optimization is only attempted if ** |
︙ | ︙ |
Changes to test/all.test.
1 2 3 4 5 6 7 8 9 10 11 12 | # 2001 September 15 # # 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. # #*********************************************************************** # This file runs all tests. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # 2001 September 15 # # 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. # #*********************************************************************** # This file runs all tests. # # $Id: all.test,v 1.38 2007/03/27 12:04:06 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl rename finish_test really_finish_test proc finish_test {} {memleak_check} if {[file exists ./sqlite_test_count]} { |
︙ | ︙ | |||
53 54 55 56 57 58 59 | crash.test crash2.test autovacuum_crash.test quick.test malloc.test misuse.test memleak.test | < | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | crash.test crash2.test autovacuum_crash.test quick.test malloc.test misuse.test memleak.test } # Files to include in the test. If this list is empty then everything # that is not in the EXCLUDE list is run. # set INCLUDE { } |
︙ | ︙ |
Changes to test/speed2.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2006 November 23 # # 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. # #************************************************************************* # This file implements regression tests for SQLite library. The # focus of this script is measuring executing speed. # | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | # 2006 November 23 # # 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. # #************************************************************************* # This file implements regression tests for SQLite library. The # focus of this script is measuring executing speed. # # $Id: speed2.test,v 1.3 2007/03/27 12:04:06 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # Set a uniform random seed expr srand(0) set sqlout [open speed2.txt w] proc tracesql {sql} { puts $::sqlout $sql\; } #db trace tracesql # The number_name procedure below converts its argment (an integer) # into a string which is the English-language name for that number. |
︙ | ︙ | |||
58 59 60 61 62 63 64 | set txt [string trim $txt] if {$txt==""} {set txt zero} return $txt } # Create a database schema. # | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | set txt [string trim $txt] if {$txt==""} {set txt zero} return $txt } # Create a database schema. # do_test speed2-1.0 { execsql { PRAGMA page_size=1024; PRAGMA cache_size=8192; PRAGMA locking_mode=EXCLUSIVE; CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT); CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT); CREATE INDEX i2a ON t2(a); |
︙ | ︙ | |||
82 83 84 85 86 87 88 | # set sql {} for {set i 1} {$i<=50000} {incr i} { set r [expr {int(rand()*500000)}] append sql "INSERT INTO t1 VALUES($i,$r,'[number_name $r]');\n" } db eval BEGIN | | | | | | | | | | | | | | | | | | | | | | | | | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | # set sql {} for {set i 1} {$i<=50000} {incr i} { set r [expr {int(rand()*500000)}] append sql "INSERT INTO t1 VALUES($i,$r,'[number_name $r]');\n" } db eval BEGIN speed_trial speed2-insert1 50000 row $sql db eval COMMIT # 50000 INSERTs on an indexed table # set sql {} for {set i 1} {$i<=50000} {incr i} { set r [expr {int(rand()*500000)}] append sql "INSERT INTO t2 VALUES($i,$r,'[number_name $r]');\n" } db eval BEGIN speed_trial speed2-insert2 50000 row $sql db eval COMMIT # 50 SELECTs on an integer comparison. There is no index so # a full table scan is required. # set sql {} for {set i 0} {$i<50} {incr i} { set lwr [expr {$i*100}] set upr [expr {($i+10)*100}] append sql "SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr;" } speed_trial speed2-select1 [expr {50*50000}] row $sql # 50 SELECTs on an LIKE comparison. There is no index so a full # table scan is required. # set sql {} for {set i 0} {$i<50} {incr i} { append sql \ "SELECT count(*), avg(b) FROM t1 WHERE c LIKE '%[number_name $i]%';" } speed_trial speed2-select2 [expr {50*50000}] row $sql # Create indices # db eval BEGIN speed_trial speed2-createidx 150000 row { CREATE INDEX i1a ON t1(a); CREATE INDEX i1b ON t1(b); CREATE INDEX i1c ON t1(c); } db eval COMMIT # 5000 SELECTs on an integer comparison where the integer is # indexed. # set sql {} for {set i 0} {$i<5000} {incr i} { set lwr [expr {$i*100}] set upr [expr {($i+10)*100}] append sql "SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr;" } speed_trial speed2-select3 5000 stmt $sql # 100000 random SELECTs against rowid. # set sql {} for {set i 1} {$i<=100000} {incr i} { set id [expr {int(rand()*50000)+1}] append sql "SELECT c=='hi' FROM t1 WHERE rowid=$id;\n" } speed_trial speed2-select4 100000 row $sql # 100000 random SELECTs against a unique indexed column. # set sql {} for {set i 1} {$i<=100000} {incr i} { set id [expr {int(rand()*50000)+1}] append sql "SELECT c FROM t1 WHERE a=$id;" } speed_trial speed2-select5 100000 row $sql # 50000 random SELECTs against an indexed column text column # set sql {} db eval {SELECT c FROM t1 ORDER BY random() LIMIT 50000} { append sql "SELECT c FROM t1 WHERE c='$c';" } speed_trial speed2-select6 50000 row $sql # Vacuum speed_trial speed2-vacuum 100000 row VACUUM # 5000 updates of ranges where the field being compared is indexed. # set sql {} for {set i 0} {$i<5000} {incr i} { set lwr [expr {$i*2}] set upr [expr {($i+1)*2}] append sql "UPDATE t1 SET b=b*2 WHERE a>=$lwr AND a<$upr;" } db eval BEGIN speed_trial speed2-update1 5000 stmt $sql db eval COMMIT # 50000 single-row updates. An index is used to find the row quickly. # set sql {} for {set i 0} {$i<50000} {incr i} { set r [expr {int(rand()*500000)}] append sql "UPDATE t1 SET b=$r WHERE a=$i;" } db eval BEGIN speed_trial speed2-update2 50000 row $sql db eval COMMIT # 1 big text update that touches every row in the table. # speed_trial speed2-update3 50000 row { UPDATE t1 SET c=a; } # Many individual text updates. Each row in the table is # touched through an index. # set sql {} for {set i 1} {$i<=50000} {incr i} { set r [expr {int(rand()*500000)}] append sql "UPDATE t1 SET c='[number_name $r]' WHERE a=$i;" } db eval BEGIN speed_trial speed2-update4 50000 row $sql db eval COMMIT # Delete all content in a table. # speed_trial speed2-delete1 50000 row {DELETE FROM t1} # Copy one table into another # speed_trial speed2-copy1 50000 row {INSERT INTO t1 SELECT * FROM t2} # Delete all content in a table, one row at a time. # speed_trial speed2-delete2 50000 row {DELETE FROM t1 WHERE 1} # Refill the table yet again # speed_trial speed2-copy2 50000 row {INSERT INTO t1 SELECT * FROM t2} # Drop the table and recreate it without its indices. # db eval BEGIN speed_trial speed2-drop1 50000 row { DROP TABLE t1; CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT); } db eval COMMIT # Refill the table yet again. This copy should be faster because # there are no indices to deal with. # speed_trial speed2-copy3 50000 row {INSERT INTO t1 SELECT * FROM t2} # Select 20000 rows from the table at random. # speed_trial speed2-random1 50000 row { SELECT rowid FROM t1 ORDER BY random() LIMIT 20000 } # Delete 20000 random rows from the table. # speed_trial speed2-random-del1 20000 row { DELETE FROM t1 WHERE rowid IN (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000) } do_test speed2-1.1 { db one {SELECT count(*) FROM t1} } 30000 # Delete 20000 more rows at random from the table. # speed_trial speed2-random-del2 20000 row { DELETE FROM t1 WHERE rowid IN (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000) } do_test speed2-1.2 { db one {SELECT count(*) FROM t1} } 10000 finish_test |
Added tool/mksqlite3c.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | #!/usr/bin/tclsh # # To build a single huge source file holding all of SQLite (or at # least the core components - the test harness, shell, and TCL # interface are omitted.) first do # # make target_source # # Then run this script # # tclsh mkonebigsourcefile.tcl # # The combined SQLite source code will be written into sqlite3.c # # Open the output file and write a header comment at the beginning # of the file. # set out [open sqlite3.c w] puts $out \ "/****************************************************************************** ** This file is a amalgamation of many separate source files from SQLite. By ** pulling all the source files into this single unified source file, the ** entire code can be compiled as a single translation unit, which allows the ** compiler to do a better job of optimizing. */" # These are the header files used by SQLite. The first time any of these # files are seen in a #include statement in the C code, include the complete # text of the file in-line. The file only needs to be included once. # foreach hdr { btree.h hash.h keywordhash.h opcodes.h os_common.h os.h os_os2.h pager.h parse.h sqlite3ext.h sqlite3.h sqliteInt.h vdbe.h vdbeInt.h } { set available_hdr($hdr) 1 } # 78 stars used for comment formatting. set s78 \ {*****************************************************************************} # Insert a comment into the code # proc section_comment {text} { global out s78 set n [string length $text] set nstar [expr {60 - $n}] set stars [string range $s78 0 $nstar] puts $out "/************** $text $stars/" } # Read the source file named $filename and write it into the # sqlite3.c output file. If any #include statements are seen, # process them approprately. # proc copy_file {filename} { global seen_hdr available_hdr out set tail [file tail $filename] section_comment "Begin file $tail" set in [open $filename r] while {![eof $in]} { set line [gets $in] if {[regexp {^#\s*include\s+["<]([^">]+)[">]} $line all hdr]} { if {[info exists available_hdr($hdr)]} { if {$available_hdr($hdr)} { if {$hdr!="os_common.h"} { set available_hdr($hdr) 0 } section_comment "Include $hdr in the middle of $tail" copy_file tsrc/$hdr section_comment "Continuing where we left off in $tail" } } elseif {![info exists seen_hdr($hdr)]} { set seen_hdr($hdr) 1 puts $out $line } } elseif {[regexp {^#ifdef __cplusplus} $line]} { puts $out "#if 0" } elseif {[regexp {^#line} $line]} { # Skip #line directives. } else { puts $out $line } } close $in section_comment "End of $tail" } # Process the source files. Process files containing commonly # used subroutines first in order to help the compiler find # inlining opportunities. # foreach file { printf.c random.c utf.c util.c hash.c opcodes.c os.c os_os2.c os_unix.c os_win.c pager.c btree.c vdbefifo.c vdbemem.c vdbeaux.c vdbeapi.c vdbe.c expr.c alter.c analyze.c attach.c auth.c build.c callback.c complete.c date.c delete.c func.c insert.c legacy.c loadext.c pragma.c prepare.c select.c table.c trigger.c update.c vacuum.c vtab.c where.c parse.c tokenize.c main.c } { copy_file tsrc/$file } if 0 { puts $out "#ifdef SQLITE_TEST" foreach file { test1.c test2.c test3.c test4.c test5.c test6.c test7.c test8.c test_async.c test_autoext.c test_loadext.c test_md5.c test_schema.c test_server.c test_tclvar.c } { copy_file ../sqlite/src/$file } puts $out "#endif /* SQLITE_TEST */" puts $out "#ifdef SQLITE_TCL" copy_file ../sqlite/src/tclsqlite.c puts $out "#endif /* SQLITE_TCL */" } close $out |