Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Merge the latest trunk changes into the sessions branch. This merge should fix the build for WinRT. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | sessions |
Files: | files | file ages | folders |
SHA1: |
e111e4edf9d7b2d4d6d6673a75768018 |
User & Date: | drh 2013-10-15 14:10:44.320 |
Context
2013-10-16
| ||
14:32 | Merge the latest trunk changes. (check-in: 5806546822 user: drh tags: sessions) | |
2013-10-15
| ||
14:10 | Merge the latest trunk changes into the sessions branch. This merge should fix the build for WinRT. (check-in: e111e4edf9 user: drh tags: sessions) | |
11:58 | Fix harmless macro redefinition warnings in the totype extension. (check-in: c9c1f8d670 user: drh tags: trunk) | |
2013-10-10
| ||
20:13 | Synchronize with the trunk. (check-in: 136445ba02 user: drh tags: sessions) | |
Changes
Changes to Makefile.in.
︙ | ︙ | |||
400 401 402 403 404 405 406 407 408 409 410 411 412 413 | $(TOP)/ext/misc/closure.c \ $(TOP)/ext/misc/fuzzer.c \ $(TOP)/ext/misc/ieee754.c \ $(TOP)/ext/misc/nextchar.c \ $(TOP)/ext/misc/percentile.c \ $(TOP)/ext/misc/regexp.c \ $(TOP)/ext/misc/spellfix.c \ $(TOP)/ext/misc/wholenumber.c # Source code to the library files needed by the test fixture # TESTSRC2 = \ $(TOP)/src/attach.c \ $(TOP)/src/backup.c \ | > | 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | $(TOP)/ext/misc/closure.c \ $(TOP)/ext/misc/fuzzer.c \ $(TOP)/ext/misc/ieee754.c \ $(TOP)/ext/misc/nextchar.c \ $(TOP)/ext/misc/percentile.c \ $(TOP)/ext/misc/regexp.c \ $(TOP)/ext/misc/spellfix.c \ $(TOP)/ext/misc/totype.c \ $(TOP)/ext/misc/wholenumber.c # Source code to the library files needed by the test fixture # TESTSRC2 = \ $(TOP)/src/attach.c \ $(TOP)/src/backup.c \ |
︙ | ︙ | |||
505 506 507 508 509 510 511 | Makefile: $(TOP)/Makefile.in ./config.status sqlite3.pc: $(TOP)/sqlite3.pc.in ./config.status libsqlite3.la: $(LIBOBJ) | | | | 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | Makefile: $(TOP)/Makefile.in ./config.status sqlite3.pc: $(TOP)/sqlite3.pc.in ./config.status libsqlite3.la: $(LIBOBJ) $(LTLINK) -no-undefined -o $@ $(LIBOBJ) $(TLIBS) \ ${ALLOWRELEASE} -rpath "$(libdir)" -version-info "8:6:8" libtclsqlite3.la: tclsqlite.lo libsqlite3.la $(LTLINK) -no-undefined -o $@ tclsqlite.lo \ libsqlite3.la @TCL_STUB_LIB_SPEC@ $(TLIBS) \ -rpath "$(TCLLIBDIR)" \ -version-info "8:6:8" \ -avoid-version sqlite3$(TEXE): $(TOP)/src/shell.c libsqlite3.la sqlite3.h $(LTLINK) $(READLINE_FLAGS) \ |
︙ | ︙ |
Changes to Makefile.msc.
︙ | ︙ | |||
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 | TOP = . # Set this non-0 to create and use the SQLite amalgamation file. # !IFNDEF USE_AMALGAMATION USE_AMALGAMATION = 1 !ENDIF # Set this non-0 to use the International Components for Unicode (ICU). # !IFNDEF USE_ICU USE_ICU = 0 !ENDIF # Set this non-0 to dynamically link to the MSVC runtime library. # !IFNDEF USE_CRT_DLL USE_CRT_DLL = 0 !ENDIF # Set this non-0 to attempt setting the native compiler automatically # for cross-compiling the command line tools needed during the compilation # process. # !IFNDEF XCOMPILE XCOMPILE = 0 | > > > > > > > > > > > > > > | 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 | TOP = . # Set this non-0 to create and use the SQLite amalgamation file. # !IFNDEF USE_AMALGAMATION USE_AMALGAMATION = 1 !ENDIF # Set this non-0 to split the SQLite amalgamation file into chunks to # be used for debugging with Visual Studio. # !IFNDEF SPLIT_AMALGAMATION SPLIT_AMALGAMATION = 0 !ENDIF # Set this non-0 to use the International Components for Unicode (ICU). # !IFNDEF USE_ICU USE_ICU = 0 !ENDIF # Set this non-0 to dynamically link to the MSVC runtime library. # !IFNDEF USE_CRT_DLL USE_CRT_DLL = 0 !ENDIF # Set this non-0 to generate assembly code listings for the source code # files. # !IFNDEF USE_LISTINGS USE_LISTINGS = 0 !ENDIF # Set this non-0 to attempt setting the native compiler automatically # for cross-compiling the command line tools needed during the compilation # process. # !IFNDEF XCOMPILE XCOMPILE = 0 |
︙ | ︙ | |||
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 | NSDKLIBPATH = $(NSDKLIBPATH:\\=\) # C compiler and options for use in building executables that # will run on the platform that is doing the build. # BCC = $(NCC) -W3 # Check if the native library paths should be used when compiling # the command line tools used during the compilation process. If # so, set the necessary macro now. # !IF $(USE_NATIVE_LIBPATHS)!=0 NLTLIBPATHS = "/LIBPATH:$(NCRTLIBPATH)" "/LIBPATH:$(NSDKLIBPATH)" !ENDIF # C compiler and options for use in building executables that # will run on the target platform. (BCC and TCC are usually the # same unless your are cross-compiling.) # TCC = $(CC) -W3 -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src -fp:precise RCC = $(RC) -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src # When compiling the library for use in the WinRT environment, # the following compile-time options must be used as well to # disable use of Win32 APIs that are not available and to enable # use of Win32 APIs that are specific to Windows 8 and/or WinRT. # !IF $(FOR_WINRT)!=0 | > > > > > > > > > > > > > > | 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 | NSDKLIBPATH = $(NSDKLIBPATH:\\=\) # C compiler and options for use in building executables that # will run on the platform that is doing the build. # BCC = $(NCC) -W3 # Check if assembly code listings should be generated for the source # code files to be compiled. # !IF $(USE_LISTINGS)!=0 BCC = $(BCC) -FAcs !ENDIF # Check if the native library paths should be used when compiling # the command line tools used during the compilation process. If # so, set the necessary macro now. # !IF $(USE_NATIVE_LIBPATHS)!=0 NLTLIBPATHS = "/LIBPATH:$(NCRTLIBPATH)" "/LIBPATH:$(NSDKLIBPATH)" !ENDIF # C compiler and options for use in building executables that # will run on the target platform. (BCC and TCC are usually the # same unless your are cross-compiling.) # TCC = $(CC) -W3 -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src -fp:precise RCC = $(RC) -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src # Check if assembly code listings should be generated for the source # code files to be compiled. # !IF $(USE_LISTINGS)!=0 TCC = $(TCC) -FAcs !ENDIF # When compiling the library for use in the WinRT environment, # the following compile-time options must be used as well to # disable use of Win32 APIs that are not available and to enable # use of Win32 APIs that are specific to Windows 8 and/or WinRT. # !IF $(FOR_WINRT)!=0 |
︙ | ︙ | |||
759 760 761 762 763 764 765 766 767 768 769 770 771 772 | $(TOP)\ext\misc\closure.c \ $(TOP)\ext\misc\fuzzer.c \ $(TOP)\ext\misc\ieee754.c \ $(TOP)\ext\misc\nextchar.c \ $(TOP)\ext\misc\percentile.c \ $(TOP)\ext\misc\regexp.c \ $(TOP)\ext\misc\spellfix.c \ $(TOP)\ext\misc\wholenumber.c # Source code to the library files needed by the test fixture # (non-amalgamation) # TESTSRC2 = \ | > | 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 | $(TOP)\ext\misc\closure.c \ $(TOP)\ext\misc\fuzzer.c \ $(TOP)\ext\misc\ieee754.c \ $(TOP)\ext\misc\nextchar.c \ $(TOP)\ext\misc\percentile.c \ $(TOP)\ext\misc\regexp.c \ $(TOP)\ext\misc\spellfix.c \ $(TOP)\ext\misc\totype.c \ $(TOP)\ext\misc\wholenumber.c # Source code to the library files needed by the test fixture # (non-amalgamation) # TESTSRC2 = \ |
︙ | ︙ | |||
907 908 909 910 911 912 913 914 915 916 | $(TCLSH_CMD) $(TOP)\tool\mksqlite3c.tcl copy tsrc\shell.c . copy tsrc\sqlite3ext.h . copy $(TOP)\ext\session\sqlite3session.h . sqlite3-all.c: sqlite3.c $(TOP)\tool\split-sqlite3c.tcl $(TCLSH_CMD) $(TOP)\tool\split-sqlite3c.tcl # Rule to build the amalgamation # | > > > > > > > > > | | | 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 | $(TCLSH_CMD) $(TOP)\tool\mksqlite3c.tcl copy tsrc\shell.c . copy tsrc\sqlite3ext.h . copy $(TOP)\ext\session\sqlite3session.h . sqlite3-all.c: sqlite3.c $(TOP)\tool\split-sqlite3c.tcl $(TCLSH_CMD) $(TOP)\tool\split-sqlite3c.tcl # Set the source code file to be used by executables and libraries when # they need the amalgamation. # !IF $(SPLIT_AMALGAMATION)!=0 SQLITE3C = sqlite3-all.c !ELSE SQLITE3C = sqlite3.c !ENDIF # Rule to build the amalgamation # sqlite3.lo: $(SQLITE3C) $(LTCOMPILE) -c $(SQLITE3C) # Rules to build the LEMON compiler generator # lempar.c: $(TOP)\src\lempar.c copy $(TOP)\src\lempar.c . lemon.exe: $(TOP)\tool\lemon.c lempar.c |
︙ | ︙ | |||
1274 1275 1276 1277 1278 1279 1280 | # necessary because the test fixture requires non-API symbols which are # hidden when the library is built via the amalgamation). # TESTFIXTURE_FLAGS = -DTCLSH=1 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1 TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_SERVER=1 -DSQLITE_PRIVATE="" -DSQLITE_CORE TESTFIXTURE_SRC0 = $(TESTEXT) $(TESTSRC2) libsqlite3.lib | | | 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 | # necessary because the test fixture requires non-API symbols which are # hidden when the library is built via the amalgamation). # TESTFIXTURE_FLAGS = -DTCLSH=1 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1 TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_SERVER=1 -DSQLITE_PRIVATE="" -DSQLITE_CORE TESTFIXTURE_SRC0 = $(TESTEXT) $(TESTSRC2) libsqlite3.lib TESTFIXTURE_SRC1 = $(TESTEXT) $(TESTSRC3) $(SQLITE3C) !IF $(USE_AMALGAMATION)==0 TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC0) !ELSE TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC1) !ENDIF testfixture.exe: $(TESTFIXTURE_SRC) $(LIBRESOBJS) $(HDR) |
︙ | ︙ | |||
1302 1303 1304 1305 1306 1307 1308 | queryplantest: testfixture.exe sqlite3.exe .\testfixture.exe $(TOP)\test\permutations.test queryplanner test: testfixture.exe sqlite3.exe .\testfixture.exe $(TOP)\test\veryquick.test | | | | | | 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 | queryplantest: testfixture.exe sqlite3.exe .\testfixture.exe $(TOP)\test\permutations.test queryplanner test: testfixture.exe sqlite3.exe .\testfixture.exe $(TOP)\test\veryquick.test sqlite3_analyzer.c: $(SQLITE3C) $(TOP)\src\test_stat.c $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl copy $(SQLITE3C) + $(TOP)\src\test_stat.c + $(TOP)\src\tclsqlite.c $@ echo static const char *tclsh_main_loop(void){ >> $@ echo static const char *zMainloop = >> $@ $(NAWK) -f $(TOP)\tool\tostr.awk $(TOP)\tool\spaceanal.tcl >> $@ echo ; return zMainloop; } >> $@ sqlite3_analyzer.exe: sqlite3_analyzer.c $(LIBRESOBJS) $(LTLINK) -DBUILD_sqlite -DTCLSH=2 -I$(TCLINCDIR) sqlite3_analyzer.c \ /link $(LTLINKOPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LTLIBS) $(TLIBS) clean: del /Q *.lo *.ilk *.lib *.obj *.pdb sqlite3.exe libsqlite3.lib del /Q *.cod *.da *.bb *.bbg gmon.out del /Q sqlite3.h opcodes.c opcodes.h del /Q lemon.exe lempar.c parse.* del /Q mkkeywordhash.exe keywordhash.h -rmdir /Q/S .deps -rmdir /Q/S .libs -rmdir /Q/S quota2a -rmdir /Q/S quota2b -rmdir /Q/S quota2c -rmdir /Q/S tsrc del /Q .target_source del /Q tclsqlite3.exe tclsqlite3.exp del /Q testfixture.exe testfixture.exp test.db del /Q sqlite3.dll sqlite3.lib sqlite3.exp sqlite3.def del /Q sqlite3.c sqlite3-*.c del /Q sqlite3rc.h del /Q shell.c sqlite3ext.h del /Q sqlite3_analyzer.exe sqlite3_analyzer.exp sqlite3_analyzer.c del /Q sqlite-*-output.vsix del /Q mptester.exe # Dynamic link library section. |
︙ | ︙ |
Changes to ext/fts3/fts3.c.
︙ | ︙ | |||
4323 4324 4325 4326 4327 4328 4329 | memset(a, 0, sizeof(a)); assert( p->nToken<=MAX_INCR_PHRASE_TOKENS ); assert( p->iDoclistToken<MAX_INCR_PHRASE_TOKENS ); while( bEof==0 ){ int bMaxSet = 0; | | | | 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 | memset(a, 0, sizeof(a)); assert( p->nToken<=MAX_INCR_PHRASE_TOKENS ); assert( p->iDoclistToken<MAX_INCR_PHRASE_TOKENS ); while( bEof==0 ){ int bMaxSet = 0; sqlite3_int64 iMax = 0; /* Largest docid for all iterators */ int i; /* Used to iterate through tokens */ /* Advance the iterator for each token in the phrase once. */ for(i=0; rc==SQLITE_OK && i<p->nToken && bEof==0; i++){ rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof); if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){ iMax = a[i].iDocid; bMaxSet = 1; } } assert( rc!=SQLITE_OK || a[p->nToken-1].bIgnore==0 ); |
︙ | ︙ | |||
4366 4367 4368 4369 4370 4371 4372 | if( a[i].bIgnore==0 ){ char *pL = a[i].pList; char *pR = aDoclist; char *pOut = aDoclist; int nDist = p->nToken-1-i; int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR); if( res==0 ) break; | | | 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 | if( a[i].bIgnore==0 ){ char *pL = a[i].pList; char *pR = aDoclist; char *pOut = aDoclist; int nDist = p->nToken-1-i; int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR); if( res==0 ) break; nList = (int)(pOut - aDoclist); } } if( i==(p->nToken-1) ){ pDL->iDocid = iMax; pDL->pList = aDoclist; pDL->nList = nList; pDL->bFreeList = 1; |
︙ | ︙ |
Added ext/misc/totype.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | /* ** 2013-10-14 ** ** 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 SQLite extension implements functions tointeger(X) and toreal(X). ** ** If X is an integer, real, or string value that can be ** losslessly represented as an integer, then tointeger(X) ** returns the corresponding integer value. ** If X is an 8-byte BLOB then that blob is interpreted as ** a signed two-compliment little-endian encoding of an integer ** and tointeger(X) returns the corresponding integer value. ** Otherwise tointeger(X) return NULL. ** ** If X is an integer, real, or string value that can be ** convert into a real number, preserving at least 15 digits ** of precision, then toreal(X) returns the corresponding real value. ** If X is an 8-byte BLOB then that blob is interpreted as ** a 64-bit IEEE754 big-endian floating point value ** and toreal(X) returns the corresponding real value. ** Otherwise toreal(X) return NULL. ** ** Note that tointeger(X) of an 8-byte BLOB assumes a little-endian ** encoding whereas toreal(X) of an 8-byte BLOB assumes a big-endian ** encoding. */ #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 #include <assert.h> #include <string.h> /* ** Determine if this is running on a big-endian or little-endian ** processor */ #if defined(i386) || defined(__i386__) || defined(_M_IX86)\ || defined(__x86_64) || defined(__x86_64__) # define TOTYPE_BIGENDIAN 0 # define TOTYPE_LITTLEENDIAN 1 #else const int totype_one = 1; # define TOTYPE_BIGENDIAN (*(char *)(&totype_one)==0) # define TOTYPE_LITTLEENDIAN (*(char *)(&totype_one)==1) #endif /* ** Constants for the largest and smallest possible 64-bit signed integers. ** These macros are designed to work correctly on both 32-bit and 64-bit ** compilers. */ #ifndef LARGEST_INT64 # define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32)) #endif #ifndef SMALLEST_INT64 # define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64) #endif /* ** Return TRUE if character c is a whitespace character */ static int totypeIsspace(unsigned char c){ return c==' ' || c=='\t' || c=='\n' || c=='\v' || c=='\f' || c=='\r'; } /* ** Return TRUE if character c is a digit */ static int totypeIsdigit(unsigned char c){ return c>='0' && c<='9'; } /* ** Compare the 19-character string zNum against the text representation ** value 2^63: 9223372036854775808. Return negative, zero, or positive ** if zNum is less than, equal to, or greater than the string. ** Note that zNum must contain exactly 19 characters. ** ** Unlike memcmp() this routine is guaranteed to return the difference ** in the values of the last digit if the only difference is in the ** last digit. So, for example, ** ** totypeCompare2pow63("9223372036854775800") ** ** will return -8. */ static int totypeCompare2pow63(const char *zNum){ int c = 0; int i; /* 012345678901234567 */ const char *pow63 = "922337203685477580"; for(i=0; c==0 && i<18; i++){ c = (zNum[i]-pow63[i])*10; } if( c==0 ){ c = zNum[18] - '8'; } return c; } /* ** Convert zNum to a 64-bit signed integer. ** ** If the zNum value is representable as a 64-bit twos-complement ** integer, then write that value into *pNum and return 0. ** ** If zNum is exactly 9223372036854665808, return 2. This special ** case is broken out because while 9223372036854665808 cannot be a ** signed 64-bit integer, its negative -9223372036854665808 can be. ** ** If zNum is too big for a 64-bit integer and is not ** 9223372036854665808 or if zNum contains any non-numeric text, ** then return 1. ** ** The string is not necessarily zero-terminated. */ static int totypeAtoi64(const char *zNum, sqlite3_int64 *pNum, int length){ sqlite3_uint64 u = 0; int neg = 0; /* assume positive */ int i; int c = 0; int nonNum = 0; const char *zStart; const char *zEnd = zNum + length; while( zNum<zEnd && totypeIsspace(*zNum) ) zNum++; if( zNum<zEnd ){ if( *zNum=='-' ){ neg = 1; zNum++; }else if( *zNum=='+' ){ zNum++; } } zStart = zNum; while( zNum<zEnd && zNum[0]=='0' ){ zNum++; } /* Skip leading zeros. */ for(i=0; &zNum[i]<zEnd && (c=zNum[i])>='0' && c<='9'; i++){ u = u*10 + c - '0'; } if( u>LARGEST_INT64 ){ *pNum = SMALLEST_INT64; }else if( neg ){ *pNum = -(sqlite3_int64)u; }else{ *pNum = (sqlite3_int64)u; } if( (c!=0 && &zNum[i]<zEnd) || (i==0 && zStart==zNum) || i>19 || nonNum ){ /* zNum is empty or contains non-numeric text or is longer ** than 19 digits (thus guaranteeing that it is too large) */ return 1; }else if( i<19 ){ /* Less than 19 digits, so we know that it fits in 64 bits */ assert( u<=LARGEST_INT64 ); return 0; }else{ /* zNum is a 19-digit numbers. Compare it against 9223372036854775808. */ c = totypeCompare2pow63(zNum); if( c<0 ){ /* zNum is less than 9223372036854775808 so it fits */ assert( u<=LARGEST_INT64 ); return 0; }else if( c>0 ){ /* zNum is greater than 9223372036854775808 so it overflows */ return 1; }else{ /* zNum is exactly 9223372036854775808. Fits if negative. The ** special case 2 overflow if positive */ assert( u-1==LARGEST_INT64 ); assert( (*pNum)==SMALLEST_INT64 ); return neg ? 0 : 2; } } } /* ** The string z[] is an text representation of a real number. ** Convert this string to a double and write it into *pResult. ** ** The string is not necessarily zero-terminated. ** ** Return TRUE if the result is a valid real number (or integer) and FALSE ** if the string is empty or contains extraneous text. Valid numbers ** are in one of these formats: ** ** [+-]digits[E[+-]digits] ** [+-]digits.[digits][E[+-]digits] ** [+-].digits[E[+-]digits] ** ** Leading and trailing whitespace is ignored for the purpose of determining ** validity. ** ** If some prefix of the input string is a valid number, this routine ** returns FALSE but it still converts the prefix and writes the result ** into *pResult. */ static int totypeAtoF(const char *z, double *pResult, int length){ const char *zEnd = z + length; /* sign * significand * (10 ^ (esign * exponent)) */ int sign = 1; /* sign of significand */ sqlite3_int64 s = 0; /* significand */ int d = 0; /* adjust exponent for shifting decimal point */ int esign = 1; /* sign of exponent */ int e = 0; /* exponent */ int eValid = 1; /* True exponent is either not used or is well-formed */ double result; int nDigits = 0; int nonNum = 0; *pResult = 0.0; /* Default return value, in case of an error */ /* skip leading spaces */ while( z<zEnd && totypeIsspace(*z) ) z++; if( z>=zEnd ) return 0; /* get sign of significand */ if( *z=='-' ){ sign = -1; z++; }else if( *z=='+' ){ z++; } /* skip leading zeroes */ while( z<zEnd && z[0]=='0' ) z++, nDigits++; /* copy max significant digits to significand */ while( z<zEnd && totypeIsdigit(*z) && s<((LARGEST_INT64-9)/10) ){ s = s*10 + (*z - '0'); z++, nDigits++; } /* skip non-significant significand digits ** (increase exponent by d to shift decimal left) */ while( z<zEnd && totypeIsdigit(*z) ) z++, nDigits++, d++; if( z>=zEnd ) goto totype_atof_calc; /* if decimal point is present */ if( *z=='.' ){ z++; /* copy digits from after decimal to significand ** (decrease exponent by d to shift decimal right) */ while( z<zEnd && totypeIsdigit(*z) && s<((LARGEST_INT64-9)/10) ){ s = s*10 + (*z - '0'); z++, nDigits++, d--; } /* skip non-significant digits */ while( z<zEnd && totypeIsdigit(*z) ) z++, nDigits++; } if( z>=zEnd ) goto totype_atof_calc; /* if exponent is present */ if( *z=='e' || *z=='E' ){ z++; eValid = 0; if( z>=zEnd ) goto totype_atof_calc; /* get sign of exponent */ if( *z=='-' ){ esign = -1; z++; }else if( *z=='+' ){ z++; } /* copy digits to exponent */ while( z<zEnd && totypeIsdigit(*z) ){ e = e<10000 ? (e*10 + (*z - '0')) : 10000; z++; eValid = 1; } } /* skip trailing spaces */ if( nDigits && eValid ){ while( z<zEnd && totypeIsspace(*z) ) z++; } totype_atof_calc: /* adjust exponent by d, and update sign */ e = (e*esign) + d; if( e<0 ) { esign = -1; e *= -1; } else { esign = 1; } /* if 0 significand */ if( !s ) { /* In the IEEE 754 standard, zero is signed. ** Add the sign if we've seen at least one digit */ result = (sign<0 && nDigits) ? -(double)0 : (double)0; } else { /* attempt to reduce exponent */ if( esign>0 ){ while( s<(LARGEST_INT64/10) && e>0 ) e--,s*=10; }else{ while( !(s%10) && e>0 ) e--,s/=10; } /* adjust the sign of significand */ s = sign<0 ? -s : s; /* if exponent, scale significand as appropriate ** and store in result. */ if( e ){ double scale = 1.0; /* attempt to handle extremely small/large numbers better */ if( e>307 && e<342 ){ while( e%308 ) { scale *= 1.0e+1; e -= 1; } if( esign<0 ){ result = s / scale; result /= 1.0e+308; }else{ result = s * scale; result *= 1.0e+308; } }else if( e>=342 ){ if( esign<0 ){ result = 0.0*s; }else{ result = 1e308*1e308*s; /* Infinity */ } }else{ /* 1.0e+22 is the largest power of 10 than can be ** represented exactly. */ while( e%22 ) { scale *= 1.0e+1; e -= 1; } while( e>0 ) { scale *= 1.0e+22; e -= 22; } if( esign<0 ){ result = s / scale; }else{ result = s * scale; } } } else { result = (double)s; } } /* store the result */ *pResult = result; /* return true if number and no extra non-whitespace chracters after */ return z>=zEnd && nDigits>0 && eValid && nonNum==0; } /* ** tointeger(X): If X is any value (integer, double, blob, or string) that ** can be losslessly converted into an integer, then make the conversion and ** return the result. Otherwise, return NULL. */ static void tointegerFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ assert( argc==1 ); (void)argc; switch( sqlite3_value_type(argv[0]) ){ case SQLITE_FLOAT: { double rVal = sqlite3_value_double(argv[0]); sqlite3_int64 iVal = (sqlite3_int64)rVal; if( rVal==(double)iVal ){ sqlite3_result_int64(context, iVal); } break; } case SQLITE_INTEGER: { sqlite3_result_int64(context, sqlite3_value_int64(argv[0])); break; } case SQLITE_BLOB: { const unsigned char *zBlob = sqlite3_value_blob(argv[0]); if( zBlob ){ int nBlob = sqlite3_value_bytes(argv[0]); if( nBlob==sizeof(sqlite3_int64) ){ sqlite3_int64 iVal; if( TOTYPE_BIGENDIAN ){ int i; unsigned char zBlobRev[sizeof(sqlite3_int64)]; for(i=0; i<sizeof(sqlite3_int64); i++){ zBlobRev[i] = zBlob[sizeof(sqlite3_int64)-1-i]; } memcpy(&iVal, zBlobRev, sizeof(sqlite3_int64)); }else{ memcpy(&iVal, zBlob, sizeof(sqlite3_int64)); } sqlite3_result_int64(context, iVal); } } break; } case SQLITE_TEXT: { const unsigned char *zStr = sqlite3_value_text(argv[0]); if( zStr ){ int nStr = sqlite3_value_bytes(argv[0]); if( nStr && !totypeIsspace(zStr[0]) ){ sqlite3_int64 iVal; if( !totypeAtoi64((const char*)zStr, &iVal, nStr) ){ sqlite3_result_int64(context, iVal); } } } break; } default: { assert( sqlite3_value_type(argv[0])==SQLITE_NULL ); break; } } } /* ** toreal(X): If X is any value (integer, double, blob, or string) that can ** be losslessly converted into a real number, then do so and return that ** real number. Otherwise return NULL. */ #if defined(_MSC_VER) #pragma warning(disable: 4748) #pragma optimize("", off) #endif static void torealFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ assert( argc==1 ); (void)argc; switch( sqlite3_value_type(argv[0]) ){ case SQLITE_FLOAT: { sqlite3_result_double(context, sqlite3_value_double(argv[0])); break; } case SQLITE_INTEGER: { sqlite3_int64 iVal = sqlite3_value_int64(argv[0]); double rVal = (double)iVal; if( iVal==(sqlite3_int64)rVal ){ sqlite3_result_double(context, rVal); } break; } case SQLITE_BLOB: { const unsigned char *zBlob = sqlite3_value_blob(argv[0]); if( zBlob ){ int nBlob = sqlite3_value_bytes(argv[0]); if( nBlob==sizeof(double) ){ double rVal; if( TOTYPE_LITTLEENDIAN ){ int i; unsigned char zBlobRev[sizeof(double)]; for(i=0; i<sizeof(double); i++){ zBlobRev[i] = zBlob[sizeof(double)-1-i]; } memcpy(&rVal, zBlobRev, sizeof(double)); }else{ memcpy(&rVal, zBlob, sizeof(double)); } sqlite3_result_double(context, rVal); } } break; } case SQLITE_TEXT: { const unsigned char *zStr = sqlite3_value_text(argv[0]); if( zStr ){ int nStr = sqlite3_value_bytes(argv[0]); if( nStr && !totypeIsspace(zStr[0]) && !totypeIsspace(zStr[nStr-1]) ){ double rVal; if( totypeAtoF((const char*)zStr, &rVal, nStr) ){ sqlite3_result_double(context, rVal); return; } } } break; } default: { assert( sqlite3_value_type(argv[0])==SQLITE_NULL ); break; } } } #if defined(_MSC_VER) #pragma optimize("", on) #pragma warning(default: 4748) #endif #ifdef _WIN32 __declspec(dllexport) #endif int sqlite3_totype_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ){ int rc = SQLITE_OK; SQLITE_EXTENSION_INIT2(pApi); (void)pzErrMsg; /* Unused parameter */ rc = sqlite3_create_function(db, "tointeger", 1, SQLITE_UTF8, 0, tointegerFunc, 0, 0); if( rc==SQLITE_OK ){ rc = sqlite3_create_function(db, "toreal", 1, SQLITE_UTF8, 0, torealFunc, 0, 0); } return rc; } |
Changes to ext/misc/vfslog.c.
︙ | ︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ** are not logged. */ #include "sqlite3.h" #include <string.h> #include <assert.h> #include <stdio.h> /* ** Forward declaration of objects used by this utility */ typedef struct VLogLog VLogLog; typedef struct VLogVfs VLogVfs; typedef struct VLogFile VLogFile; | > > > | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | ** are not logged. */ #include "sqlite3.h" #include <string.h> #include <assert.h> #include <stdio.h> #if SQLITE_OS_UNIX # include <unistd.h> #endif /* ** Forward declaration of objects used by this utility */ typedef struct VLogLog VLogLog; typedef struct VLogVfs VLogVfs; typedef struct VLogFile VLogFile; |
︙ | ︙ | |||
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | pLog->pNext = allLogs; allLogs = pLog; } sqlite3_mutex_leave(pMutex); if( pTemp ){ sqlite3_free(pTemp); }else{ char zHost[200]; zHost[0] = 0; gethostname(zHost, sizeof(zHost)-1); zHost[sizeof(zHost)-1] = 0; vlogLogPrint(pLog, tNow, 0, "IDENT", getpid(), -1, zHost, 0); } if( pLog && isJournal ) pLog++; pLog->nRef++; return pLog; } | > > | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | pLog->pNext = allLogs; allLogs = pLog; } sqlite3_mutex_leave(pMutex); if( pTemp ){ sqlite3_free(pTemp); }else{ #if SQLITE_OS_UNIX char zHost[200]; zHost[0] = 0; gethostname(zHost, sizeof(zHost)-1); zHost[sizeof(zHost)-1] = 0; vlogLogPrint(pLog, tNow, 0, "IDENT", getpid(), -1, zHost, 0); #endif } if( pLog && isJournal ) pLog++; pLog->nRef++; return pLog; } |
︙ | ︙ |
Changes to magic.txt.
︙ | ︙ | |||
22 23 24 25 26 27 28 29 | >68 belong =0x0f055112 Fossil checkout - >68 belong =0x0f055113 Fossil global configuration - >68 belong =0x0f055111 Fossil repository - >68 belong =0x42654462 Bentley Systems BeSQLite Database - >68 belong =0x42654c6e Bentley Systems Localization File - >60 belong =0x5f4d544e Monotone source repository - >68 belong =0x47504b47 OGC GeoPackage file - >0 string =SQLite SQLite3 database | > | 22 23 24 25 26 27 28 29 30 | >68 belong =0x0f055112 Fossil checkout - >68 belong =0x0f055113 Fossil global configuration - >68 belong =0x0f055111 Fossil repository - >68 belong =0x42654462 Bentley Systems BeSQLite Database - >68 belong =0x42654c6e Bentley Systems Localization File - >60 belong =0x5f4d544e Monotone source repository - >68 belong =0x47504b47 OGC GeoPackage file - >68 belong =0x47503130 OGC GeoPackage version 1.0 file - >0 string =SQLite SQLite3 database |
Changes to main.mk.
︙ | ︙ | |||
279 280 281 282 283 284 285 286 287 288 289 290 291 292 | $(TOP)/ext/misc/closure.c \ $(TOP)/ext/misc/fuzzer.c \ $(TOP)/ext/misc/ieee754.c \ $(TOP)/ext/misc/nextchar.c \ $(TOP)/ext/misc/percentile.c \ $(TOP)/ext/misc/regexp.c \ $(TOP)/ext/misc/spellfix.c \ $(TOP)/ext/misc/wholenumber.c \ $(TOP)/ext/misc/vfslog.c #TESTSRC += $(TOP)/ext/fts2/fts2_tokenizer.c #TESTSRC += $(TOP)/ext/fts3/fts3_tokenizer.c | > | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | $(TOP)/ext/misc/closure.c \ $(TOP)/ext/misc/fuzzer.c \ $(TOP)/ext/misc/ieee754.c \ $(TOP)/ext/misc/nextchar.c \ $(TOP)/ext/misc/percentile.c \ $(TOP)/ext/misc/regexp.c \ $(TOP)/ext/misc/spellfix.c \ $(TOP)/ext/misc/totype.c \ $(TOP)/ext/misc/wholenumber.c \ $(TOP)/ext/misc/vfslog.c #TESTSRC += $(TOP)/ext/fts2/fts2_tokenizer.c #TESTSRC += $(TOP)/ext/fts3/fts3_tokenizer.c |
︙ | ︙ | |||
663 664 665 666 667 668 669 | rm -rf quota2a quota2b quota2c rm -rf tsrc target_source rm -f testloadext.dll libtestloadext.so rm -f amalgamation-testfixture amalgamation-testfixture.exe rm -f fts3-testfixture fts3-testfixture.exe rm -f testfixture testfixture.exe rm -f threadtest3 threadtest3.exe | | | 664 665 666 667 668 669 670 671 672 673 674 675 676 677 | rm -rf quota2a quota2b quota2c rm -rf tsrc target_source rm -f testloadext.dll libtestloadext.so rm -f amalgamation-testfixture amalgamation-testfixture.exe rm -f fts3-testfixture fts3-testfixture.exe rm -f testfixture testfixture.exe rm -f threadtest3 threadtest3.exe rm -f sqlite3.c sqlite3-*.c fts?amal.c tclsqlite3.c rm -f sqlite3rc.h rm -f shell.c sqlite3ext.h rm -f sqlite3_analyzer sqlite3_analyzer.exe sqlite3_analyzer.c rm -f sqlite-*-output.vsix rm -f mptester mptester.exe rm -f showdb |
Changes to src/analyze.c.
︙ | ︙ | |||
27 28 29 30 31 32 33 | ** is between 3.6.18 and 3.7.8, inclusive, and unless SQLite is compiled ** with SQLITE_ENABLE_STAT2. The sqlite_stat2 table is deprecated. ** The sqlite_stat2 table is superseded by sqlite_stat3, which is only ** created and used by SQLite versions 3.7.9 and later and with ** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3 ** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced ** version of sqlite_stat3 and is only available when compiled with | | | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ** is between 3.6.18 and 3.7.8, inclusive, and unless SQLite is compiled ** with SQLITE_ENABLE_STAT2. The sqlite_stat2 table is deprecated. ** The sqlite_stat2 table is superseded by sqlite_stat3, which is only ** created and used by SQLite versions 3.7.9 and later and with ** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3 ** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced ** version of sqlite_stat3 and is only available when compiled with ** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.1 and later. It is ** not possible to enable both STAT3 and STAT4 at the same time. If they ** are both enabled, then STAT4 takes precedence. ** ** For most applications, sqlite_stat1 provides all the statisics required ** for the query planner to make good choices. ** ** Format of sqlite_stat1: |
︙ | ︙ | |||
103 104 105 106 107 108 109 | ** that indexed columns are compared against in the WHERE clauses of ** queries. ** ** The sqlite_stat4 table contains multiple entries for each index. ** The idx column names the index and the tbl column is the table of the ** index. If the idx and tbl columns are the same, then the sample is ** of the INTEGER PRIMARY KEY. The sample column is a blob which is the | | | | | | | | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | ** that indexed columns are compared against in the WHERE clauses of ** queries. ** ** The sqlite_stat4 table contains multiple entries for each index. ** The idx column names the index and the tbl column is the table of the ** index. If the idx and tbl columns are the same, then the sample is ** of the INTEGER PRIMARY KEY. The sample column is a blob which is the ** binary encoding of a key from the index. The nEq column is a ** list of integers. The first integer is the approximate number ** of entries in the index whose left-most column exactly matches ** the left-most column of the sample. The second integer in nEq ** is the approximate number of entries in the index where the ** first two columns match the first two columns of the sample. ** And so forth. nLt is another list of integers that show the approximate ** number of entries that are strictly less than the sample. The first ** integer in nLt contains the number of entries in the index where the ** left-most column is less than the left-most column of the sample. ** The K-th integer in the nLt entry is the number of index entries ** where the first K columns are less than the first K columns of the ** sample. The nDLt column is like nLt except that it contains the |
︙ | ︙ | |||
440 441 442 443 444 445 446 | return (nEqNew==nEqOld && pNew->iHash>pOld->iHash); #endif } /* ** Copy the contents of object (*pFrom) into (*pTo). */ | | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | return (nEqNew==nEqOld && pNew->iHash>pOld->iHash); #endif } /* ** Copy the contents of object (*pFrom) into (*pTo). */ static void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){ pTo->iRowid = pFrom->iRowid; pTo->isPSample = pFrom->isPSample; pTo->iCol = pFrom->iCol; pTo->iHash = pFrom->iHash; memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol); memcpy(pTo->anLt, pFrom->anLt, sizeof(tRowcnt)*p->nCol); memcpy(pTo->anDLt, pFrom->anDLt, sizeof(tRowcnt)*p->nCol); |
︙ | ︙ | |||
585 586 587 588 589 590 591 592 593 594 595 596 597 598 | if( p->nSample<p->mxSample || sampleIsBetter(p, &p->current, &p->a[p->iMin]) ){ sampleInsert(p, &p->current, 0); } } #endif } /* ** Implementation of the stat_push SQL function: stat_push(P,R,C) ** Arguments: ** ** P Pointer to the Stat4Accum object created by stat_init() | > > > > > | 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | if( p->nSample<p->mxSample || sampleIsBetter(p, &p->current, &p->a[p->iMin]) ){ sampleInsert(p, &p->current, 0); } } #endif #ifndef SQLITE_ENABLE_STAT3_OR_STAT4 UNUSED_PARAMETER( p ); UNUSED_PARAMETER( iChng ); #endif } /* ** Implementation of the stat_push SQL function: stat_push(P,R,C) ** Arguments: ** ** P Pointer to the Stat4Accum object created by stat_init() |
︙ | ︙ | |||
610 611 612 613 614 615 616 617 618 619 620 621 622 623 | ){ int i; /* The three function arguments */ Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]); int iChng = sqlite3_value_int(argv[1]); assert( p->nCol>1 ); /* Includes rowid field */ assert( iChng<p->nCol ); if( p->nRow==0 ){ /* This is the first call to this function. Do initialization. */ for(i=0; i<p->nCol; i++) p->current.anEq[i] = 1; }else{ | > > | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 | ){ int i; /* The three function arguments */ Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]); int iChng = sqlite3_value_int(argv[1]); UNUSED_PARAMETER( argc ); UNUSED_PARAMETER( context ); assert( p->nCol>1 ); /* Includes rowid field */ assert( iChng<p->nCol ); if( p->nRow==0 ){ /* This is the first call to this function. Do initialization. */ for(i=0; i<p->nCol; i++) p->current.anEq[i] = 1; }else{ |
︙ | ︙ | |||
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | assert( z[0]=='\0' && z>zRet ); z[-1] = '\0'; sqlite3_result_text(context, zRet, -1, sqlite3_free); } } } #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */ } static const FuncDef statGetFuncdef = { 1+IsStat34, /* nArg */ SQLITE_UTF8, /* funcFlags */ 0, /* pUserData */ 0, /* pNext */ statGet, /* xFunc */ 0, /* xStep */ 0, /* xFinalize */ "stat_get", /* zName */ 0, /* pHash */ 0 /* pDestructor */ }; static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){ assert( regOut!=regStat4 && regOut!=regStat4+1 ); #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1); | > > > | > > | 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | assert( z[0]=='\0' && z>zRet ); z[-1] = '\0'; sqlite3_result_text(context, zRet, -1, sqlite3_free); } } } #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */ #ifndef SQLITE_DEBUG UNUSED_PARAMETER( argc ); #endif } static const FuncDef statGetFuncdef = { 1+IsStat34, /* nArg */ SQLITE_UTF8, /* funcFlags */ 0, /* pUserData */ 0, /* pNext */ statGet, /* xFunc */ 0, /* xStep */ 0, /* xFinalize */ "stat_get", /* zName */ 0, /* pHash */ 0 /* pDestructor */ }; static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){ assert( regOut!=regStat4 && regOut!=regStat4+1 ); #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1); #elif SQLITE_DEBUG assert( iParam==STAT_GET_STAT1 ); #else UNUSED_PARAMETER( iParam ); #endif sqlite3VdbeAddOp3(v, OP_Function, 0, regStat4, regOut); sqlite3VdbeChangeP4(v, -1, (char*)&statGetFuncdef, P4_FUNCDEF); sqlite3VdbeChangeP5(v, 1 + IsStat34); } /* |
︙ | ︙ |
Changes to src/build.c.
︙ | ︙ | |||
1109 1110 1111 1112 1113 1114 1115 | ** estimate is scaled so that the size of an integer is 1. */ if( pszEst ){ *pszEst = 1; /* default size is approx 4 bytes */ if( aff<=SQLITE_AFF_NONE ){ if( zChar ){ while( zChar[0] ){ if( sqlite3Isdigit(zChar[0]) ){ | | | 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 | ** estimate is scaled so that the size of an integer is 1. */ if( pszEst ){ *pszEst = 1; /* default size is approx 4 bytes */ if( aff<=SQLITE_AFF_NONE ){ if( zChar ){ while( zChar[0] ){ if( sqlite3Isdigit(zChar[0]) ){ int v = 0; sqlite3GetInt32(zChar, &v); v = v/4 + 1; if( v>255 ) v = 255; *pszEst = v; /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */ break; } zChar++; |
︙ | ︙ |
Changes to src/date.c.
︙ | ︙ | |||
422 423 424 425 426 427 428 429 430 431 432 433 434 435 | ** The following routine implements the rough equivalent of localtime_r() ** using whatever operating-system specific localtime facility that ** is available. This routine returns 0 on success and ** non-zero on any kind of error. ** ** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this ** routine will always fail. */ static int osLocaltime(time_t *t, struct tm *pTm){ int rc; #if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \ && (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S) struct tm *pX; #if SQLITE_THREADSAFE>0 | > > > > | 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | ** The following routine implements the rough equivalent of localtime_r() ** using whatever operating-system specific localtime facility that ** is available. This routine returns 0 on success and ** non-zero on any kind of error. ** ** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this ** routine will always fail. ** ** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C ** library function localtime_r() is used to assist in the calculation of ** local time. */ static int osLocaltime(time_t *t, struct tm *pTm){ int rc; #if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \ && (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S) struct tm *pX; #if SQLITE_THREADSAFE>0 |
︙ | ︙ | |||
478 479 480 481 482 483 484 485 486 487 488 489 490 491 | /* Initialize the contents of sLocal to avoid a compiler warning. */ memset(&sLocal, 0, sizeof(sLocal)); x = *p; computeYMD_HMS(&x); if( x.Y<1971 || x.Y>=2038 ){ x.Y = 2000; x.M = 1; x.D = 1; x.h = 0; x.m = 0; x.s = 0.0; } else { | > > > > > | 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | /* Initialize the contents of sLocal to avoid a compiler warning. */ memset(&sLocal, 0, sizeof(sLocal)); x = *p; computeYMD_HMS(&x); if( x.Y<1971 || x.Y>=2038 ){ /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only ** works for years between 1970 and 2037. For dates outside this range, ** SQLite attempts to map the year into an equivalent year within this ** range, do the calculation, then map the year back. */ x.Y = 2000; x.M = 1; x.D = 1; x.h = 0; x.m = 0; x.s = 0.0; } else { |
︙ | ︙ |
Changes to src/fkey.c.
︙ | ︙ | |||
652 653 654 655 656 657 658 | /* Search for a deferred foreign key constraint for which this table ** is the child table. If one cannot be found, return without ** generating any VDBE code. If one can be found, then jump over ** the entire DELETE if there are no outstanding deferred constraints ** when this statement is run. */ FKey *p; for(p=pTab->pFKey; p; p=p->pNextFrom){ | | | > > > > > > | | | | > | 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 | /* Search for a deferred foreign key constraint for which this table ** is the child table. If one cannot be found, return without ** generating any VDBE code. If one can be found, then jump over ** the entire DELETE if there are no outstanding deferred constraints ** when this statement is run. */ FKey *p; for(p=pTab->pFKey; p; p=p->pNextFrom){ if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break; } if( !p ) return; iSkip = sqlite3VdbeMakeLabel(v); sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip); } pParse->disableTriggers = 1; sqlite3DeleteFrom(pParse, sqlite3SrcListDup(db, pName, 0), 0); pParse->disableTriggers = 0; /* If the DELETE has generated immediate foreign key constraint ** violations, halt the VDBE and return an error at this point, before ** any modifications to the schema are made. This is because statement ** transactions are not able to rollback schema changes. ** ** If the SQLITE_DeferFKs flag is set, then this is not required, as ** the statement transaction will not be rolled back even if FK ** constraints are violated. */ if( (db->flags & SQLITE_DeferFKs)==0 ){ sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2); sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY, OE_Abort, "foreign key constraint failed", P4_STATIC ); } if( iSkip ){ sqlite3VdbeResolveLabel(v, iSkip); } } } |
︙ | ︙ |
Changes to src/os_win.c.
︙ | ︙ | |||
678 679 680 681 682 683 684 | #else { "GetVersionExA", (SYSCALL)0, 0 }, #endif #define osGetVersionExA ((BOOL(WINAPI*)( \ LPOSVERSIONINFOA))aSyscall[34].pCurrent) | | | 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 | #else { "GetVersionExA", (SYSCALL)0, 0 }, #endif #define osGetVersionExA ((BOOL(WINAPI*)( \ LPOSVERSIONINFOA))aSyscall[34].pCurrent) #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "GetVersionExW", (SYSCALL)GetVersionExW, 0 }, #else { "GetVersionExW", (SYSCALL)0, 0 }, #endif #define osGetVersionExW ((BOOL(WINAPI*)( \ LPOSVERSIONINFOW))aSyscall[35].pCurrent) |
︙ | ︙ |
Changes to src/pragma.c.
︙ | ︙ | |||
52 53 54 55 56 57 58 | #define PragTyp_LOCKING_MODE 21 #define PragTyp_PAGE_COUNT 22 #define PragTyp_MMAP_SIZE 23 #define PragTyp_PAGE_SIZE 24 #define PragTyp_SECURE_DELETE 25 #define PragTyp_SHRINK_MEMORY 26 #define PragTyp_SOFT_HEAP_LIMIT 27 | > | | | | | | | | | | | | | 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 | #define PragTyp_LOCKING_MODE 21 #define PragTyp_PAGE_COUNT 22 #define PragTyp_MMAP_SIZE 23 #define PragTyp_PAGE_SIZE 24 #define PragTyp_SECURE_DELETE 25 #define PragTyp_SHRINK_MEMORY 26 #define PragTyp_SOFT_HEAP_LIMIT 27 #define PragTyp_STATS 28 #define PragTyp_SYNCHRONOUS 29 #define PragTyp_TABLE_INFO 30 #define PragTyp_TEMP_STORE 31 #define PragTyp_TEMP_STORE_DIRECTORY 32 #define PragTyp_WAL_AUTOCHECKPOINT 33 #define PragTyp_WAL_CHECKPOINT 34 #define PragTyp_ACTIVATE_EXTENSIONS 35 #define PragTyp_HEXKEY 36 #define PragTyp_KEY 37 #define PragTyp_REKEY 38 #define PragTyp_LOCK_STATUS 39 #define PragTyp_PARSER_TRACE 40 #define PragFlag_NeedSchema 0x01 static const struct sPragmaNames { const char *const zName; /* Name of pragma */ u8 ePragTyp; /* PragTyp_XXX value */ u8 mPragFlag; /* Zero or more PragFlag_XXX values */ u32 iArg; /* Extra argument */ } aPragmaNames[] = { |
︙ | ︙ | |||
354 355 356 357 358 359 360 361 362 363 364 365 366 367 | /* ePragFlag: */ 0, /* iArg: */ 0 }, #if defined(SQLITE_DEBUG) { /* zName: */ "sql_trace", /* ePragTyp: */ PragTyp_FLAG, /* ePragFlag: */ 0, /* iArg: */ SQLITE_SqlTrace }, #endif #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) { /* zName: */ "synchronous", /* ePragTyp: */ PragTyp_SYNCHRONOUS, /* ePragFlag: */ PragFlag_NeedSchema, /* iArg: */ 0 }, #endif | > > > > > > | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | /* ePragFlag: */ 0, /* iArg: */ 0 }, #if defined(SQLITE_DEBUG) { /* zName: */ "sql_trace", /* ePragTyp: */ PragTyp_FLAG, /* ePragFlag: */ 0, /* iArg: */ SQLITE_SqlTrace }, #endif #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) { /* zName: */ "stats", /* ePragTyp: */ PragTyp_STATS, /* ePragFlag: */ PragFlag_NeedSchema, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) { /* zName: */ "synchronous", /* ePragTyp: */ PragTyp_SYNCHRONOUS, /* ePragFlag: */ PragFlag_NeedSchema, /* iArg: */ 0 }, #endif |
︙ | ︙ | |||
416 417 418 419 420 421 422 | /* iArg: */ 0 }, #endif { /* zName: */ "writable_schema", /* ePragTyp: */ PragTyp_FLAG, /* ePragFlag: */ 0, /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode }, }; | | | 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | /* iArg: */ 0 }, #endif { /* zName: */ "writable_schema", /* ePragTyp: */ PragTyp_FLAG, /* ePragFlag: */ 0, /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode }, }; /* Number of pragmas: 56 on by default, 68 total. */ /* End of the automatically generated pragma table. ***************************************************************************/ /* ** Interpret the given string as a safety level. Return 0 for OFF, ** 1 for ON or NORMAL and 2 for FULL. Return 1 for an empty or ** unrecognized string argument. The FULL option is disallowed |
︙ | ︙ | |||
1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 | } sqlite3VdbeAddOp2(v, OP_Integer, k, 6); sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6); } } } break; case PragTyp_INDEX_INFO: if( zRight ){ Index *pIdx; Table *pTab; pIdx = sqlite3FindIndex(db, zRight, zDb); if( pIdx ){ int i; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 | } sqlite3VdbeAddOp2(v, OP_Integer, k, 6); sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6); } } } break; case PragTyp_STATS: { Index *pIdx; HashElem *i; v = sqlite3GetVdbe(pParse); sqlite3VdbeSetNumCols(v, 4); pParse->nMem = 4; sqlite3CodeVerifySchema(pParse, iDb); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "table", SQLITE_STATIC); sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "index", SQLITE_STATIC); sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "width", SQLITE_STATIC); sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "height", SQLITE_STATIC); for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){ Table *pTab = sqliteHashData(i); sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, pTab->zName, 0); sqlite3VdbeAddOp2(v, OP_Null, 0, 2); sqlite3VdbeAddOp2(v, OP_Integer, (int)sqlite3LogEstToInt(pTab->szTabRow), 3); sqlite3VdbeAddOp2(v, OP_Integer, (int)pTab->nRowEst, 4); sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4); for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0); sqlite3VdbeAddOp2(v, OP_Integer, (int)sqlite3LogEstToInt(pIdx->szIdxRow), 3); sqlite3VdbeAddOp2(v, OP_Integer, (int)pIdx->aiRowEst[0], 4); sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4); } } } break; case PragTyp_INDEX_INFO: if( zRight ){ Index *pIdx; Table *pTab; pIdx = sqlite3FindIndex(db, zRight, zDb); if( pIdx ){ int i; |
︙ | ︙ | |||
1453 1454 1455 1456 1457 1458 1459 | case PragTyp_INDEX_LIST: if( zRight ){ Index *pIdx; Table *pTab; int i; pTab = sqlite3FindTable(db, zRight, zDb); if( pTab ){ v = sqlite3GetVdbe(pParse); | | | < < < < < < < | < < | | 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 | case PragTyp_INDEX_LIST: if( zRight ){ Index *pIdx; Table *pTab; int i; pTab = sqlite3FindTable(db, zRight, zDb); if( pTab ){ v = sqlite3GetVdbe(pParse); sqlite3VdbeSetNumCols(v, 3); pParse->nMem = 3; sqlite3CodeVerifySchema(pParse, iDb); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC); sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC); for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){ sqlite3VdbeAddOp2(v, OP_Integer, i, 1); sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0); sqlite3VdbeAddOp2(v, OP_Integer, pIdx->onError!=OE_None, 3); sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3); } } } break; case PragTyp_DATABASE_LIST: { int i; |
︙ | ︙ | |||
1606 1607 1608 1609 1610 1611 1612 | if( pTab==0 || pTab->pFKey==0 ) continue; sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow; sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead); sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName, P4_TRANSIENT); for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){ | | | > | < > | | > | | > | | | | > | 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 | if( pTab==0 || pTab->pFKey==0 ) continue; sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow; sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead); sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName, P4_TRANSIENT); for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){ pParent = sqlite3FindTable(db, pFK->zTo, zDb); if( pParent==0 ) continue; pIdx = 0; sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName); x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0); if( x==0 ){ if( pIdx==0 ){ sqlite3OpenTable(pParse, i, iDb, pParent, OP_OpenRead); }else{ KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx); sqlite3VdbeAddOp3(v, OP_OpenRead, i, pIdx->tnum, iDb); sqlite3VdbeChangeP4(v, -1, (char*)pKey, P4_KEYINFO_HANDOFF); } }else{ k = 0; break; } } assert( pParse->nErr>0 || pFK==0 ); if( pFK ) break; if( pParse->nTab<i ) pParse->nTab = i; addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0); for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){ pParent = sqlite3FindTable(db, pFK->zTo, zDb); pIdx = 0; aiCols = 0; if( pParent ){ x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols); assert( x==0 ); } addrOk = sqlite3VdbeMakeLabel(v); if( pParent && pIdx==0 ){ int iKey = pFK->aCol[0].iFrom; assert( iKey>=0 && iKey<pTab->nCol ); if( iKey!=pTab->iPKey ){ sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow); sqlite3ColumnDefault(v, pTab, iKey, regRow); sqlite3VdbeAddOp2(v, OP_IsNull, regRow, addrOk); sqlite3VdbeAddOp2(v, OP_MustBeInt, regRow, sqlite3VdbeCurrentAddr(v)+3); }else{ sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow); } sqlite3VdbeAddOp3(v, OP_NotExists, i, 0, regRow); sqlite3VdbeAddOp2(v, OP_Goto, 0, addrOk); sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2); }else{ for(j=0; j<pFK->nCol; j++){ sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, aiCols ? aiCols[j] : pFK->aCol[j].iFrom, regRow+j); sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); } if( pParent ){ sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey); sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT); sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0); } } sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1); sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0, pFK->zTo, P4_TRANSIENT); sqlite3VdbeAddOp2(v, OP_Integer, i-1, regResult+3); sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4); sqlite3VdbeResolveLabel(v, addrOk); |
︙ | ︙ |
Changes to src/resolve.c.
︙ | ︙ | |||
703 704 705 706 707 708 709 710 711 712 713 714 715 716 | pExpr->iTable = exprProbability(pList->a[1].pExpr); if( pExpr->iTable<0 ){ sqlite3ErrorMsg(pParse, "second argument to likelihood() must be a " "constant between 0.0 and 1.0"); pNC->nErr++; } }else{ pExpr->iTable = 62; /* TUNING: Default 2nd arg to unlikely() is 0.0625 */ } } } #ifndef SQLITE_OMIT_AUTHORIZATION if( pDef ){ auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0); | > > > > | 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 | pExpr->iTable = exprProbability(pList->a[1].pExpr); if( pExpr->iTable<0 ){ sqlite3ErrorMsg(pParse, "second argument to likelihood() must be a " "constant between 0.0 and 1.0"); pNC->nErr++; } }else{ /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to ** likelihood(X, 0.0625). ** EVIDENCE-OF: R-35738-39582 The unlikely(X) fucntion is short-hand for ** likelihood(X,0.0625). */ pExpr->iTable = 62; /* TUNING: Default 2nd arg to unlikely() is 0.0625 */ } } } #ifndef SQLITE_OMIT_AUTHORIZATION if( pDef ){ auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0); |
︙ | ︙ |
Changes to src/shell.c.
︙ | ︙ | |||
1200 1201 1202 1203 1204 1205 1206 | for(i=0; i<nCol; i++){ azCols[i] = (char *)sqlite3_column_name(pStmt, i); } do{ /* extract the data and data types */ for(i=0; i<nCol; i++){ aiTypes[i] = x = sqlite3_column_type(pStmt, i); | | | 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 | for(i=0; i<nCol; i++){ azCols[i] = (char *)sqlite3_column_name(pStmt, i); } do{ /* extract the data and data types */ for(i=0; i<nCol; i++){ aiTypes[i] = x = sqlite3_column_type(pStmt, i); if( x==SQLITE_BLOB && pArg && pArg->mode==MODE_Insert ){ azVals[i] = ""; }else{ azVals[i] = (char*)sqlite3_column_text(pStmt, i); } if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){ rc = SQLITE_NOMEM; break; /* from for */ |
︙ | ︙ |
Changes to src/sqlite.h.in.
︙ | ︙ | |||
1608 1609 1610 1611 1612 1613 1614 | ** log message after formatting via [sqlite3_snprintf()]. ** The SQLite logging interface is not reentrant; the logger function ** supplied by the application must not invoke any SQLite interface. ** In a multi-threaded application, the application-defined logger ** function must be threadsafe. </dd> ** ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI | | | | | | | | | | 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 | ** log message after formatting via [sqlite3_snprintf()]. ** The SQLite logging interface is not reentrant; the logger function ** supplied by the application must not invoke any SQLite interface. ** In a multi-threaded application, the application-defined logger ** function must be threadsafe. </dd> ** ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI ** <dd>^(This option takes a single argument of type int. If non-zero, then ** URI handling is globally enabled. If the parameter is zero, then URI handling ** is globally disabled.)^ ^If URI handling is globally enabled, all filenames ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or ** specified as part of [ATTACH] commands are interpreted as URIs, regardless ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database ** connection is opened. ^If it is globally disabled, filenames are ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the ** database connection is opened. ^(By default, URI handling is globally ** disabled. The default value may be changed by compiling with the ** [SQLITE_USE_URI] symbol defined.)^ ** ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN ** <dd>^This option takes a single integer argument which is interpreted as ** a boolean in order to enable or disable the use of covering indices for ** full table scans in the query optimizer. ^The default setting is determined ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on" ** if that compile-time option is omitted. ** The ability to disable the use of covering indices for full table scans ** is because some incorrectly coded legacy applications might malfunction ** when the optimization is enabled. Providing the ability to ** disable the optimization allows the older, buggy application code to work ** without change even with newer versions of SQLite. ** ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]] ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE ** <dd> These options are obsolete and should not be used by new code. ** They are retained for backwards compatibility but are now no-ops. |
︙ | ︙ | |||
1657 1658 1659 1660 1661 1662 1663 | ** the connection being passed as the second parameter is being closed. The ** third parameter is passed NULL In this case. An example of using this ** configuration option can be seen in the "test_sqllog.c" source file in ** the canonical SQLite source tree.</dd> ** ** [[SQLITE_CONFIG_MMAP_SIZE]] ** <dt>SQLITE_CONFIG_MMAP_SIZE | | | | | | | 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 | ** the connection being passed as the second parameter is being closed. The ** third parameter is passed NULL In this case. An example of using this ** configuration option can be seen in the "test_sqllog.c" source file in ** the canonical SQLite source tree.</dd> ** ** [[SQLITE_CONFIG_MMAP_SIZE]] ** <dt>SQLITE_CONFIG_MMAP_SIZE ** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values ** that are the default mmap size limit (the default setting for ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit. ** ^The default setting can be overridden by each database connection using ** either the [PRAGMA mmap_size] command, or by using the ** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size ** cannot be changed at run-time. Nor may the maximum allowed mmap size ** exceed the compile-time maximum mmap size set by the ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^ ** ^If either argument to this option is negative, then that argument is ** changed to its compile-time default. ** </dl> */ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ #define SQLITE_CONFIG_SERIALIZED 3 /* nil */ #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ |
︙ | ︙ |
Changes to src/sqliteInt.h.
︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* ** These #defines should enable >2GB file support on POSIX if the ** underlying operating system supports it. If the OS lacks ** large file support, or if the OS is windows, these should be no-ops. | > | 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. ** ************************************************************************* ** Internal interface definitions for SQLite. ** */ #include "sqlite3.h" #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* ** These #defines should enable >2GB file support on POSIX if the ** underlying operating system supports it. If the OS lacks ** large file support, or if the OS is windows, these should be no-ops. |
︙ | ︙ | |||
301 302 303 304 305 306 307 | ** a boolean expression that is usually true. These hints could, ** in theory, be used by the compiler to generate better code, but ** currently they are just comments for human readers. */ #define likely(X) (X) #define unlikely(X) (X) | < | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | ** a boolean expression that is usually true. These hints could, ** in theory, be used by the compiler to generate better code, but ** currently they are just comments for human readers. */ #define likely(X) (X) #define unlikely(X) (X) #include "hash.h" #include "parse.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <stddef.h> |
︙ | ︙ | |||
3256 3257 3258 3259 3260 3261 3262 | void sqlite3FkDropTable(Parse*, SrcList *, Table*); void sqlite3FkActions(Parse*, Table*, ExprList*, int, int*, int); int sqlite3FkRequired(Parse*, Table*, int*, int); u32 sqlite3FkOldmask(Parse*, Table*); FKey *sqlite3FkReferences(Table *); #else #define sqlite3FkActions(a,b,c,d,e,f) | | | | | 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 | void sqlite3FkDropTable(Parse*, SrcList *, Table*); void sqlite3FkActions(Parse*, Table*, ExprList*, int, int*, int); int sqlite3FkRequired(Parse*, Table*, int*, int); u32 sqlite3FkOldmask(Parse*, Table*); FKey *sqlite3FkReferences(Table *); #else #define sqlite3FkActions(a,b,c,d,e,f) #define sqlite3FkCheck(a,b,c,d,e,f) #define sqlite3FkDropTable(a,b,c) #define sqlite3FkOldmask(a,b) 0 #define sqlite3FkRequired(a,b,c,d) 0 #endif #ifndef SQLITE_OMIT_FOREIGN_KEY void sqlite3FkDelete(sqlite3 *, Table*); int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**); #else #define sqlite3FkDelete(a,b) #define sqlite3FkLocateIndex(a,b,c,d,e) |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 | extern int sqlite3_closure_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_fuzzer_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_ieee_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_nextchar_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_percentile_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_regexp_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_spellfix_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_wholenumber_init(sqlite3*,char**,const sqlite3_api_routines*); static const struct { const char *zExtName; int (*pInit)(sqlite3*,char**,const sqlite3_api_routines*); } aExtension[] = { { "amatch", sqlite3_amatch_init }, { "closure", sqlite3_closure_init }, { "fuzzer", sqlite3_fuzzer_init }, { "ieee754", sqlite3_ieee_init }, { "nextchar", sqlite3_nextchar_init }, { "percentile", sqlite3_percentile_init }, { "regexp", sqlite3_regexp_init }, { "spellfix", sqlite3_spellfix_init }, { "wholenumber", sqlite3_wholenumber_init }, }; sqlite3 *db; const char *zName; int i, j, rc; char *zErrMsg = 0; if( objc<3 ){ | > > | 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 | extern int sqlite3_closure_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_fuzzer_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_ieee_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_nextchar_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_percentile_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_regexp_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_spellfix_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_totype_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_wholenumber_init(sqlite3*,char**,const sqlite3_api_routines*); static const struct { const char *zExtName; int (*pInit)(sqlite3*,char**,const sqlite3_api_routines*); } aExtension[] = { { "amatch", sqlite3_amatch_init }, { "closure", sqlite3_closure_init }, { "fuzzer", sqlite3_fuzzer_init }, { "ieee754", sqlite3_ieee_init }, { "nextchar", sqlite3_nextchar_init }, { "percentile", sqlite3_percentile_init }, { "regexp", sqlite3_regexp_init }, { "spellfix", sqlite3_spellfix_init }, { "totype", sqlite3_totype_init }, { "wholenumber", sqlite3_wholenumber_init }, }; sqlite3 *db; const char *zName; int i, j, rc; char *zErrMsg = 0; if( objc<3 ){ |
︙ | ︙ |
Changes to src/vdbemem.c.
︙ | ︙ | |||
1055 1056 1057 1058 1059 1060 1061 | if( pRec==0 ) return 0; p->ppRec[0] = pRec; } pRec->nField = p->iVal+1; return &pRec->aMem[p->iVal]; } | | > > | | 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 | if( pRec==0 ) return 0; p->ppRec[0] = pRec; } pRec->nField = p->iVal+1; return &pRec->aMem[p->iVal]; } #else UNUSED_PARAMETER(p); #endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */ return sqlite3ValueNew(db); } /* ** Extract a value from the supplied expression in the manner described ** above sqlite3ValueFromExpr(). Allocate the sqlite3_value object ** using valueNew(). ** ** If pCtx is NULL and an error occurs after the sqlite3_value object ** has been allocated, it is freed before returning. Or, if pCtx is not ** NULL, it is assumed that the caller will free any allocated object ** in all cases. */ static int valueFromExpr( sqlite3 *db, /* The database connection */ Expr *pExpr, /* The expression to evaluate */ u8 enc, /* Encoding to use */ u8 affinity, /* Affinity to use */ sqlite3_value **ppVal, /* Write the new value here */ struct ValueNewStat4Ctx *pCtx /* Second argument for valueNew() */ ){ |
︙ | ︙ | |||
1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 | int iSerial; /* Serial type */ int nSerial; /* Bytes of space for iSerial as varint */ int nVal; /* Bytes of space required for argv[0] */ int nRet; sqlite3 *db; u8 *aRet; iSerial = sqlite3VdbeSerialType(argv[0], file_format); nSerial = sqlite3VarintLen(iSerial); nVal = sqlite3VdbeSerialTypeLen(iSerial); db = sqlite3_context_db_handle(context); nRet = 1 + nSerial + nVal; aRet = sqlite3DbMallocRaw(db, nRet); | > | 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 | int iSerial; /* Serial type */ int nSerial; /* Bytes of space for iSerial as varint */ int nVal; /* Bytes of space required for argv[0] */ int nRet; sqlite3 *db; u8 *aRet; UNUSED_PARAMETER( argc ); iSerial = sqlite3VdbeSerialType(argv[0], file_format); nSerial = sqlite3VarintLen(iSerial); nVal = sqlite3VdbeSerialTypeLen(iSerial); db = sqlite3_context_db_handle(context); nRet = 1 + nSerial + nVal; aRet = sqlite3DbMallocRaw(db, nRet); |
︙ | ︙ |
Changes to src/where.c.
︙ | ︙ | |||
2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 | IndexSample *aSample = pIdx->aSample; int iCol; /* Index of required stats in anEq[] etc. */ int iMin = 0; /* Smallest sample not yet tested */ int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */ int iTest; /* Next sample to test */ int res; /* Result of comparison operation */ assert( pRec!=0 || pParse->db->mallocFailed ); if( pRec==0 ) return; iCol = pRec->nField - 1; assert( pIdx->nSample>0 ); assert( pRec->nField>0 && iCol<pIdx->nSampleCol ); do{ iTest = (iMin+i)/2; | > > > | 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 | IndexSample *aSample = pIdx->aSample; int iCol; /* Index of required stats in anEq[] etc. */ int iMin = 0; /* Smallest sample not yet tested */ int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */ int iTest; /* Next sample to test */ int res; /* Result of comparison operation */ #ifndef SQLITE_DEBUG UNUSED_PARAMETER( pParse ); #endif assert( pRec!=0 || pParse->db->mallocFailed ); if( pRec==0 ) return; iCol = pRec->nField - 1; assert( pIdx->nSample>0 ); assert( pRec->nField>0 && iCol<pIdx->nSampleCol ); do{ iTest = (iMin+i)/2; |
︙ | ︙ | |||
2450 2451 2452 2453 2454 2455 2456 | WhereLoopBuilder *pBuilder, WhereTerm *pLower, /* Lower bound on the range. ex: "x>123" Might be NULL */ WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */ WhereLoop *pLoop /* Modify the .nOut and maybe .rRun fields */ ){ int rc = SQLITE_OK; int nOut = pLoop->nOut; | < > | 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 | WhereLoopBuilder *pBuilder, WhereTerm *pLower, /* Lower bound on the range. ex: "x>123" Might be NULL */ WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */ WhereLoop *pLoop /* Modify the .nOut and maybe .rRun fields */ ){ int rc = SQLITE_OK; int nOut = pLoop->nOut; LogEst nNew; #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 Index *p = pLoop->u.btree.pIndex; int nEq = pLoop->u.btree.nEq; if( p->nSample>0 && nEq==pBuilder->nRecValid && nEq<p->nSampleCol && OptimizationEnabled(pParse->db, SQLITE_Stat3) ){ UnpackedRecord *pRec = pBuilder->pRec; |
︙ | ︙ | |||
4178 4179 4180 4181 4182 4183 4184 | ** WHERE clause that reference the loop but which are not used by an ** index. ** ** In the current implementation, the first extra WHERE clause term reduces ** the number of output rows by a factor of 10 and each additional term ** reduces the number of output rows by sqrt(2). */ | | | 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 | ** WHERE clause that reference the loop but which are not used by an ** index. ** ** In the current implementation, the first extra WHERE clause term reduces ** the number of output rows by a factor of 10 and each additional term ** reduces the number of output rows by sqrt(2). */ static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop){ WhereTerm *pTerm, *pX; Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf); int i, j; if( !OptimizationEnabled(pWC->pWInfo->pParse->db, SQLITE_AdjustOutEst) ){ return; } |
︙ | ︙ | |||
4353 4354 4355 4356 4357 4358 4359 | rc = whereEqualScanEst(pParse, pBuilder, pExpr->pRight, &nOut); }else if( (pTerm->eOperator & WO_IN) && !ExprHasProperty(pExpr, EP_xIsSelect) ){ rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut); } assert( nOut==0 || rc==SQLITE_OK ); if( nOut ){ | | | | | 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 | rc = whereEqualScanEst(pParse, pBuilder, pExpr->pRight, &nOut); }else if( (pTerm->eOperator & WO_IN) && !ExprHasProperty(pExpr, EP_xIsSelect) ){ rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut); } assert( nOut==0 || rc==SQLITE_OK ); if( nOut ){ pNew->nOut = sqlite3LogEst(nOut); if( pNew->nOut>saved_nOut ) pNew->nOut = saved_nOut; } } #endif if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){ /* Each row involves a step of the index, then a binary search of ** the main table */ pNew->rRun = sqlite3LogEstAdd(pNew->rRun,rLogSize>27 ? rLogSize-17 : 10); } /* Step cost for each output row */ pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut); whereLoopOutputAdjust(pBuilder->pWC, pNew); rc = whereLoopInsert(pBuilder, pNew); if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 && pNew->u.btree.nEq<(pProbe->nColumn + (pProbe->zName!=0)) ){ whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn); } pNew->nOut = saved_nOut; |
︙ | ︙ | |||
4569 4570 4571 4572 4573 4574 4575 | /* Full table scan */ pNew->iSortIdx = b ? iSortIdx : 0; /* TUNING: Cost of full table scan is 3*(N + log2(N)). ** + The extra 3 factor is to encourage the use of indexed lookups ** over full scans. FIXME */ pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 16; | | | 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 | /* Full table scan */ pNew->iSortIdx = b ? iSortIdx : 0; /* TUNING: Cost of full table scan is 3*(N + log2(N)). ** + The extra 3 factor is to encourage the use of indexed lookups ** over full scans. FIXME */ pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 16; whereLoopOutputAdjust(pWC, pNew); rc = whereLoopInsert(pBuilder, pNew); pNew->nOut = rSize; if( rc ) break; }else{ Bitmask m = pSrc->colUsed & ~columnsInIndex(pProbe); pNew->wsFlags = (m==0) ? (WHERE_IDX_ONLY|WHERE_INDEXED) : WHERE_INDEXED; |
︙ | ︙ | |||
4602 4603 4604 4605 4606 4607 4608 | (15*pProbe->szIdxRow)/pTab->szTabRow; }else{ assert( b!=0 ); /* TUNING: Cost of scanning a non-covering index is (N+1)*log2(N) ** which we will simplify to just N*log2(N) */ pNew->rRun = rSize + rLogSize; } | | | 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 | (15*pProbe->szIdxRow)/pTab->szTabRow; }else{ assert( b!=0 ); /* TUNING: Cost of scanning a non-covering index is (N+1)*log2(N) ** which we will simplify to just N*log2(N) */ pNew->rRun = rSize + rLogSize; } whereLoopOutputAdjust(pWC, pNew); rc = whereLoopInsert(pBuilder, pNew); pNew->nOut = rSize; if( rc ) break; } } rc = whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, 0); |
︙ | ︙ |
Changes to test/attach2.test.
︙ | ︙ | |||
373 374 375 376 377 378 379 380 381 382 383 384 385 386 | } {} do_test attach2-6.2 { catchsql { ATTACH 'test3.db' as aux2; } } {1 {cannot ATTACH database within transaction}} do_test attach2-6.3 { catchsql { DETACH aux; } } {1 {cannot DETACH database within transaction}} do_test attach2-6.4 { execsql { | > > > | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | } {} do_test attach2-6.2 { catchsql { ATTACH 'test3.db' as aux2; } } {1 {cannot ATTACH database within transaction}} # EVIDENCE-OF: R-59740-55581 This statement will fail if SQLite is in # the middle of a transaction. # do_test attach2-6.3 { catchsql { DETACH aux; } } {1 {cannot DETACH database within transaction}} do_test attach2-6.4 { execsql { |
︙ | ︙ |
Changes to test/date.test.
︙ | ︙ | |||
527 528 529 530 531 532 533 534 535 536 537 538 539 540 | expr {$date eq "2008-06-12 00:00:00" || $date eq "2008-06-11 23:59:59"} } {1} } } # Verify that multiple calls to date functions with 'now' return the # same answer. # proc sleeper {} {after 100} do_test date-15.1 { db func sleeper sleeper db eval { SELECT c - a FROM (SELECT julianday('now') AS a, sleeper(), julianday('now') AS c); | > > > > | 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | expr {$date eq "2008-06-12 00:00:00" || $date eq "2008-06-11 23:59:59"} } {1} } } # Verify that multiple calls to date functions with 'now' return the # same answer. # # EVIDENCE-OF: R-34818-13664 The 'now' argument to date and time # functions always returns exactly the same value for multiple # invocations within the same sqlite3_step() call. # proc sleeper {} {after 100} do_test date-15.1 { db func sleeper sleeper db eval { SELECT c - a FROM (SELECT julianday('now') AS a, sleeper(), julianday('now') AS c); |
︙ | ︙ |
Changes to test/fkey5.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file tests the PRAGMA foreign_key_check command. # set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable {!foreignkey} { finish_test return } do_test fkey5-1.1 { | > > > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file tests the PRAGMA foreign_key_check command. # # EVIDENCE-OF: R-05426-18119 PRAGMA foreign_key_check; PRAGMA # foreign_key_check(table-name); set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix fkey5 ifcapable {!foreignkey} { finish_test return } do_test fkey5-1.1 { |
︙ | ︙ | |||
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 | } {c1 87 p1 0 c1 90 p1 0} do_test fkey5-1.4 { db eval { PRAGMA foreign_key_check(c2); } } {} do_test fkey5-2.0 { db eval { INSERT INTO c5 SELECT x FROM c1; DELETE FROM c1; PRAGMA foreign_key_check; } } {c5 1 p1 0 c5 3 p1 0} do_test fkey5-2.1 { db eval { PRAGMA foreign_key_check(c5); } } {c5 1 p1 0 c5 3 p1 0} do_test fkey5-2.2 { db eval { PRAGMA foreign_key_check(c1); } } {} do_test fkey5-3.0 { db eval { INSERT INTO c9 SELECT x FROM c5; DELETE FROM c5; PRAGMA foreign_key_check; } | > > > > > > > > > > > > > > > > > | 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 | } {c1 87 p1 0 c1 90 p1 0} do_test fkey5-1.4 { db eval { PRAGMA foreign_key_check(c2); } } {} # EVIDENCE-OF: R-45728-08709 There are four columns in each result row. # # EVIDENCE-OF: R-55672-01620 The first column is the name of the table # that contains the REFERENCES clause. # # EVIDENCE-OF: R-25219-25618 The second column is the rowid of the row # that contains the invalid REFERENCES clause. # # EVIDENCE-OF: R-40482-20265 The third column is the name of the table # that is referred to. # # EVIDENCE-OF: R-62839-07969 The fourth column is the index of the # specific foreign key constraint that failed. # do_test fkey5-2.0 { db eval { INSERT INTO c5 SELECT x FROM c1; DELETE FROM c1; PRAGMA foreign_key_check; } } {c5 1 p1 0 c5 3 p1 0} do_test fkey5-2.1 { db eval { PRAGMA foreign_key_check(c5); } } {c5 1 p1 0 c5 3 p1 0} do_test fkey5-2.2 { db eval { PRAGMA foreign_key_check(c1); } } {} do_execsql_test fkey5-2.3 { PRAGMA foreign_key_list(c5); } {0 0 p1 x {} {NO ACTION} {NO ACTION} NONE} do_test fkey5-3.0 { db eval { INSERT INTO c9 SELECT x FROM c5; DELETE FROM c5; PRAGMA foreign_key_check; } |
︙ | ︙ | |||
301 302 303 304 305 306 307 308 | db eval { DELETE FROM c22; INSERT INTO c22 VALUES('abc ','ALPHA'); PRAGMA foreign_key_check(c22); } } {} | > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | db eval { DELETE FROM c22; INSERT INTO c22 VALUES('abc ','ALPHA'); PRAGMA foreign_key_check(c22); } } {} #------------------------------------------------------------------------- # Tests 9.* verify that missing parent tables are handled correctly. # do_execsql_test 9.1.1 { CREATE TABLE k1(x REFERENCES s1); PRAGMA foreign_key_check(k1); } {} do_execsql_test 9.1.2 { INSERT INTO k1 VALUES(NULL); PRAGMA foreign_key_check(k1); } {} do_execsql_test 9.1.3 { INSERT INTO k1 VALUES(1); PRAGMA foreign_key_check(k1); } {k1 2 s1 0} do_execsql_test 9.2.1 { CREATE TABLE k2(x, y, FOREIGN KEY(x, y) REFERENCES s1(a, b)); PRAGMA foreign_key_check(k2); } {} do_execsql_test 9.2 { INSERT INTO k2 VALUES(NULL, 'five'); PRAGMA foreign_key_check(k2); } {} do_execsql_test 9.3 { INSERT INTO k2 VALUES('one', NULL); PRAGMA foreign_key_check(k2); } {} do_execsql_test 9.4 { INSERT INTO k2 VALUES('six', 'seven'); PRAGMA foreign_key_check(k2); } {k2 3 s1 0} finish_test |
Changes to test/fkey6.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file tests the PRAGMA defer_foreign_keys and # SQLITE_DBSTATUS_DEFERRED_FKS # set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable {!foreignkey} { finish_test return } do_execsql_test fkey6-1.1 { PRAGMA foreign_keys=ON; CREATE TABLE t1(x INTEGER PRIMARY KEY); CREATE TABLE t2(y INTEGER PRIMARY KEY, z INTEGER REFERENCES t1(x) DEFERRABLE INITIALLY DEFERRED); CREATE INDEX t2z ON t2(z); | > > > > > > > > > > > | 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 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file tests the PRAGMA defer_foreign_keys and # SQLITE_DBSTATUS_DEFERRED_FKS # # EVIDENCE-OF: R-18981-16292 When the defer_foreign_keys PRAGMA is on, # enforcement of all foreign key constraints is delayed until the # outermost transaction is committed. # # EVIDENCE-OF: R-28911-57501 The defer_foreign_keys pragma defaults to # OFF so that foreign key constraints are only deferred if they are # created as "DEFERRABLE INITIALLY DEFERRED". set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable {!foreignkey} { finish_test return } do_execsql_test fkey6-1.0 { PRAGMA defer_foreign_keys; } {0} do_execsql_test fkey6-1.1 { PRAGMA foreign_keys=ON; CREATE TABLE t1(x INTEGER PRIMARY KEY); CREATE TABLE t2(y INTEGER PRIMARY KEY, z INTEGER REFERENCES t1(x) DEFERRABLE INITIALLY DEFERRED); CREATE INDEX t2z ON t2(z); |
︙ | ︙ | |||
66 67 68 69 70 71 72 | BEGIN; DELETE FROM t1 WHERE x=3; } } {} do_test fkey6-1.9 { sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0 } {0 1 0} | | > > > > | > | | | > > > > > | > | 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 | BEGIN; DELETE FROM t1 WHERE x=3; } } {} do_test fkey6-1.9 { sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0 } {0 1 0} # EVIDENCE-OF: R-21752-26913 The defer_foreign_keys pragma is # automatically switched off at each COMMIT or ROLLBACK. Hence, the # defer_foreign_keys pragma must be separately enabled for each # transaction. do_execsql_test fkey6-1.10.1 { PRAGMA defer_foreign_keys; ROLLBACK; PRAGMA defer_foreign_keys; BEGIN; PRAGMA defer_foreign_keys=ON; PRAGMA defer_foreign_keys; COMMIT; PRAGMA defer_foreign_keys; BEGIN; } {1 0 1 0} do_test fkey6-1.10.2 { catchsql {DELETE FROM t1 WHERE x=3} } {1 {foreign key constraint failed}} db eval {ROLLBACK} do_test fkey6-1.20 { execsql { BEGIN; |
︙ | ︙ | |||
95 96 97 98 99 100 101 | } {0 0 0} do_test fkey6-1.22 { execsql { COMMIT; } } {} | > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | } {0 0 0} do_test fkey6-1.22 { execsql { COMMIT; } } {} do_execsql_test fkey6-2.1 { CREATE TABLE p1(a PRIMARY KEY); INSERT INTO p1 VALUES('one'), ('two'); CREATE TABLE c1(x REFERENCES p1); INSERT INTO c1 VALUES('two'), ('one'); } do_execsql_test fkey6-2.2 { BEGIN; PRAGMA defer_foreign_keys = 1; DELETE FROM p1; ROLLBACK; PRAGMA defer_foreign_keys; } {0} do_execsql_test fkey6-2.3 { BEGIN; PRAGMA defer_foreign_keys = 1; DROP TABLE p1; PRAGMA vdbe_trace = 0; ROLLBACK; PRAGMA defer_foreign_keys; } {0} do_execsql_test fkey6-2.4 { BEGIN; PRAGMA defer_foreign_keys = 1; DELETE FROM p1; DROP TABLE c1; COMMIT; PRAGMA defer_foreign_keys; } {0} do_execsql_test fkey6-2.5 { DROP TABLE p1; CREATE TABLE p1(a PRIMARY KEY); INSERT INTO p1 VALUES('one'), ('two'); CREATE TABLE c1(x REFERENCES p1); INSERT INTO c1 VALUES('two'), ('one'); } do_execsql_test fkey6-2.6 { BEGIN; PRAGMA defer_foreign_keys = 1; INSERT INTO c1 VALUES('three'); DROP TABLE c1; COMMIT; PRAGMA defer_foreign_keys; } {0} finish_test |
Changes to test/fts4incr.test.
︙ | ︙ | |||
45 46 47 48 49 50 51 52 53 | foreach s {0 1} { execsql "INSERT INTO t1(t1) VALUES('test-no-incr-doclist=$s')" do_execsql_test 2.$tn.$s $q $res set t($s) [lindex [time [list execsql $q] 100] 0] } puts "with optimization: $t(0) without: $t(1)" } finish_test | > > > > > > > > > > > > > > > > > > > > > > | 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 | foreach s {0 1} { execsql "INSERT INTO t1(t1) VALUES('test-no-incr-doclist=$s')" do_execsql_test 2.$tn.$s $q $res set t($s) [lindex [time [list execsql $q] 100] 0] } puts "with optimization: $t(0) without: $t(1)" } do_test 2.1 { execsql { CREATE VIRTUAL TABLE t2 USING fts4(order=DESC); } set num [list one two three four five six seven eight nine ten] execsql BEGIN for {set i 0} {$i < 10000} {incr i} { set x "[lindex $num [expr $i%10]] zero" execsql { INSERT INTO t2(docid, content) VALUES($i, $x) } } execsql COMMIT execsql { INSERT INTO t2(t2) VALUES('optimize') } } {} do_execsql_test 2.2 { SELECT count(*) FROM t2 WHERE t2 MATCH '"never zero"' } {0} do_execsql_test 2.3 { SELECT count(*) FROM t2 WHERE t2 MATCH '"two zero"' } {1000} finish_test |
Changes to test/fts4unicode.test.
︙ | ︙ | |||
40 41 42 43 44 45 46 | append sql "'" } append sql ")" uplevel [list do_execsql_test $tn $sql [list [list {*}$res]]] } do_unicode_token_test 1.0 {a B c D} {0 a a 1 b B 2 c c 3 d D} | > | > > | > | < | | | > > | | | | | 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 | append sql "'" } append sql ")" uplevel [list do_execsql_test $tn $sql [list [list {*}$res]]] } do_unicode_token_test 1.0 {a B c D} {0 a a 1 b B 2 c c 3 d D} do_unicode_token_test 1.1 "\uC4 \uD6 \uDC" \ "0 \uE4 \uC4 1 \uF6 \uD6 2 \uFC \uDC" do_unicode_token_test 1.2 "x\uC4x x\uD6x x\uDCx" \ "0 x\uE4x x\uC4x 1 x\uF6x x\uD6x 2 x\uFCx x\uDCx" # 0x00DF is a small "sharp s". 0x1E9E is a capital sharp s. do_unicode_token_test 1.3 "\uDF" "0 \uDF \uDF" do_unicode_token_test 1.4 "\u1E9E" "0 \uDF \u1E9E" do_unicode_token_test 1.5 "The quick brown fox" { 0 the The 1 quick quick 2 brown brown 3 fox fox } do_unicode_token_test 1.6 "The\u00bfquick\u224ebrown\u2263fox" { 0 the The 1 quick quick 2 brown brown 3 fox fox } do_unicode_token_test2 1.7 {a B c D} {0 a a 1 b B 2 c c 3 d D} do_unicode_token_test2 1.8 "\uC4 \uD6 \uDC" "0 a \uC4 1 o \uD6 2 u \uDC" do_unicode_token_test2 1.9 "x\uC4x x\uD6x x\uDCx" \ "0 xax x\uC4x 1 xox x\uD6x 2 xux x\uDCx" # Check that diacritics are removed if remove_diacritics=1 is specified. # And that they do not break tokens. do_unicode_token_test2 1.10 "xx\u0301xx" "0 xxxx xx\u301xx" # Title-case mappings work do_unicode_token_test 1.11 "\u01c5" "0 \u01c6 \u01c5" #------------------------------------------------------------------------- # set docs [list { Enhance the INSERT syntax to allow multiple rows to be inserted via the VALUES clause. } { |
︙ | ︙ | |||
374 375 376 377 378 379 380 | do_isspace_test 6.$T.14 $T 8201 do_isspace_test 6.$T.15 $T 8202 do_isspace_test 6.$T.16 $T 8239 do_isspace_test 6.$T.17 $T 8287 do_isspace_test 6.$T.18 $T 12288 do_isspace_test 6.$T.19 $T {32 160 5760 6158} | | | | | | 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | do_isspace_test 6.$T.14 $T 8201 do_isspace_test 6.$T.15 $T 8202 do_isspace_test 6.$T.16 $T 8239 do_isspace_test 6.$T.17 $T 8287 do_isspace_test 6.$T.18 $T 12288 do_isspace_test 6.$T.19 $T {32 160 5760 6158} do_isspace_test 6.$T.20 $T {8192 8193 8194 8195} do_isspace_test 6.$T.21 $T {8196 8197 8198 8199} do_isspace_test 6.$T.22 $T {8200 8201 8202 8239} do_isspace_test 6.$T.23 $T {8287 12288} } #------------------------------------------------------------------------- # Test that the private use ranges are treated as alphanumeric. # breakpoint foreach {tn1 c} { |
︙ | ︙ |
Changes to test/func.test.
︙ | ︙ | |||
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 | } {1000009} do_test func-29.6 { set x [lindex [sqlite3_db_status db CACHE_MISS 1] 1] if {$x<5} {set x 1} set x } {1} do_execsql_test func-30.1 {SELECT unicode('$');} 36 do_execsql_test func-30.2 [subst {SELECT unicode('\u00A2');}] 162 do_execsql_test func-30.3 [subst {SELECT unicode('\u20AC');}] 8364 do_execsql_test func-30.4 {SELECT char(36,162,8364);} [subst {$\u00A2\u20AC}] for {set i 1} {$i<0xd800} {incr i 13} { do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i | > > > > > > > > | 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 | } {1000009} do_test func-29.6 { set x [lindex [sqlite3_db_status db CACHE_MISS 1] 1] if {$x<5} {set x 1} set x } {1} # EVIDENCE-OF: R-29701-50711 The unicode(X) function returns the numeric # unicode code point corresponding to the first character of the string # X. # # EVIDENCE-OF: R-55469-62130 The char(X1,X2,...,XN) function returns a # string composed of characters having the unicode code point values of # integers X1 through XN, respectively. # do_execsql_test func-30.1 {SELECT unicode('$');} 36 do_execsql_test func-30.2 [subst {SELECT unicode('\u00A2');}] 162 do_execsql_test func-30.3 [subst {SELECT unicode('\u20AC');}] 8364 do_execsql_test func-30.4 {SELECT char(36,162,8364);} [subst {$\u00A2\u20AC}] for {set i 1} {$i<0xd800} {incr i 13} { do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i |
︙ | ︙ |
Changes to test/func3.test.
︙ | ︙ | |||
65 66 67 68 69 70 71 72 73 | set destroyed 0 set rc [catch { sqlite3_create_function_v2 db f3 -1 any -func f3 -step f3 -destroy destroy } msg] list $rc $msg } {1 SQLITE_MISUSE} do_test func3-4.2 { set destroyed } 1 finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | set destroyed 0 set rc [catch { sqlite3_create_function_v2 db f3 -1 any -func f3 -step f3 -destroy destroy } msg] list $rc $msg } {1 SQLITE_MISUSE} do_test func3-4.2 { set destroyed } 1 # EVIDENCE-OF: R-41921-05214 The likelihood(X,Y) function returns # argument X unchanged. # do_execsql_test func3-5.1 { SELECT likelihood(9223372036854775807, 0.5); } {9223372036854775807} do_execsql_test func3-5.2 { SELECT likelihood(-9223372036854775808, 0.5); } {-9223372036854775808} do_execsql_test func3-5.3 { SELECT likelihood(14.125, 0.5); } {14.125} do_execsql_test func3-5.4 { SELECT likelihood(NULL, 0.5); } {{}} do_execsql_test func3-5.5 { SELECT likelihood('test-string', 0.5); } {test-string} do_execsql_test func3-5.6 { SELECT quote(likelihood(x'010203000405', 0.5)); } {X'010203000405'} # EVIDENCE-OF: R-44133-61651 The value Y in likelihood(X,Y) must be a # floating point constant between 0.0 and 1.0, inclusive. # do_execsql_test func3-5.7 { SELECT likelihood(123, 1.0), likelihood(456, 0.0); } {123 456} do_test func3-5.8 { catchsql { SELECT likelihood(123, 1.000001); } } {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}} do_test func3-5.9 { catchsql { SELECT likelihood(123, -0.000001); } } {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}} do_test func3-5.10 { catchsql { SELECT likelihood(123, 0.5+0.3); } } {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}} # EVIDENCE-OF: R-28535-44631 The likelihood(X) function is a no-op that # the code generator optimizes away so that it consumes no CPU cycles # during run-time (that is, during calls to sqlite3_step()). # do_test func3-5.20 { db eval {EXPLAIN SELECT likelihood(min(1.0+'2.0',4*11), 0.5)} } [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}] # EVIDENCE-OF: R-11152-23456 The unlikely(X) function returns the # argument X unchanged. # do_execsql_test func3-5.30 { SELECT unlikely(9223372036854775807); } {9223372036854775807} do_execsql_test func3-5.31 { SELECT unlikely(-9223372036854775808); } {-9223372036854775808} do_execsql_test func3-5.32 { SELECT unlikely(14.125); } {14.125} do_execsql_test func3-5.33 { SELECT unlikely(NULL); } {{}} do_execsql_test func3-5.34 { SELECT unlikely('test-string'); } {test-string} do_execsql_test func3-5.35 { SELECT quote(unlikely(x'010203000405')); } {X'010203000405'} # EVIDENCE-OF: R-22887-63324 The unlikely(X) function is a no-op that # the code generator optimizes away so that it consumes no CPU cycles at # run-time (that is, during calls to sqlite3_step()). # do_test func3-5.40 { db eval {EXPLAIN SELECT unlikely(min(1.0+'2.0',4*11))} } [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}] finish_test |
Added test/func4.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 | # 2013 March 10 # # 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 file is testing the tointeger() and toreal() functions. # # Several of the toreal() tests are disabled on platforms where floating # point precision is not high enough to represent their constant integer # expression arguments as double precision floating point values. # set testdir [file dirname $argv0] source $testdir/tester.tcl set saved_tcl_precision $tcl_precision set tcl_precision 0 load_static_extension db totype set highPrecision(1) [expr \ {[db eval {SELECT tointeger(9223372036854775807 + 1);}] eq {{}}}] do_execsql_test func4-1.1 { SELECT tointeger(NULL); } {{}} do_execsql_test func4-1.2 { SELECT tointeger(''); } {{}} do_execsql_test func4-1.3 { SELECT tointeger(' '); } {{}} do_execsql_test func4-1.4 { SELECT tointeger('1234'); } {1234} do_execsql_test func4-1.5 { SELECT tointeger(' 1234'); } {{}} do_execsql_test func4-1.6 { SELECT tointeger('bad'); } {{}} do_execsql_test func4-1.7 { SELECT tointeger('0xBAD'); } {{}} do_execsql_test func4-1.8 { SELECT tointeger('123BAD'); } {{}} do_execsql_test func4-1.9 { SELECT tointeger('0x123BAD'); } {{}} do_execsql_test func4-1.10 { SELECT tointeger('123NO'); } {{}} do_execsql_test func4-1.11 { SELECT tointeger('0x123NO'); } {{}} do_execsql_test func4-1.12 { SELECT tointeger('-0x1'); } {{}} do_execsql_test func4-1.13 { SELECT tointeger('-0x0'); } {{}} do_execsql_test func4-1.14 { SELECT tointeger('0x0'); } {{}} do_execsql_test func4-1.15 { SELECT tointeger('0x1'); } {{}} do_execsql_test func4-1.16 { SELECT tointeger(-1); } {-1} do_execsql_test func4-1.17 { SELECT tointeger(-0); } {0} do_execsql_test func4-1.18 { SELECT tointeger(0); } {0} do_execsql_test func4-1.19 { SELECT tointeger(1); } {1} do_execsql_test func4-1.20 { SELECT tointeger(-1.79769313486232e308 - 1); } {{}} do_execsql_test func4-1.21 { SELECT tointeger(-1.79769313486232e308); } {{}} do_execsql_test func4-1.22 { SELECT tointeger(-1.79769313486232e308 + 1); } {{}} do_execsql_test func4-1.23 { SELECT tointeger(-9223372036854775808 - 1); } {-9223372036854775808} do_execsql_test func4-1.24 { SELECT tointeger(-9223372036854775808); } {-9223372036854775808} do_execsql_test func4-1.25 { SELECT tointeger(-9223372036854775808 + 1); } {-9223372036854775807} do_execsql_test func4-1.26 { SELECT tointeger(-9223372036854775807 - 1); } {-9223372036854775808} do_execsql_test func4-1.27 { SELECT tointeger(-9223372036854775807); } {-9223372036854775807} do_execsql_test func4-1.28 { SELECT tointeger(-9223372036854775807 + 1); } {-9223372036854775806} do_execsql_test func4-1.29 { SELECT tointeger(-2147483648 - 1); } {-2147483649} do_execsql_test func4-1.30 { SELECT tointeger(-2147483648); } {-2147483648} do_execsql_test func4-1.31 { SELECT tointeger(-2147483648 + 1); } {-2147483647} do_execsql_test func4-1.32 { SELECT tointeger(2147483647 - 1); } {2147483646} do_execsql_test func4-1.33 { SELECT tointeger(2147483647); } {2147483647} do_execsql_test func4-1.34 { SELECT tointeger(2147483647 + 1); } {2147483648} do_execsql_test func4-1.35 { SELECT tointeger(9223372036854775807 - 1); } {9223372036854775806} do_execsql_test func4-1.36 { SELECT tointeger(9223372036854775807); } {9223372036854775807} if {$highPrecision(1)} { do_execsql_test func4-1.37 { SELECT tointeger(9223372036854775807 + 1); } {{}} } do_execsql_test func4-1.38 { SELECT tointeger(1.79769313486232e308 - 1); } {{}} do_execsql_test func4-1.39 { SELECT tointeger(1.79769313486232e308); } {{}} do_execsql_test func4-1.40 { SELECT tointeger(1.79769313486232e308 + 1); } {{}} do_execsql_test func4-1.41 { SELECT tointeger(4503599627370496 - 1); } {4503599627370495} do_execsql_test func4-1.42 { SELECT tointeger(4503599627370496); } {4503599627370496} do_execsql_test func4-1.43 { SELECT tointeger(4503599627370496 + 1); } {4503599627370497} do_execsql_test func4-1.44 { SELECT tointeger(9007199254740992 - 1); } {9007199254740991} do_execsql_test func4-1.45 { SELECT tointeger(9007199254740992); } {9007199254740992} do_execsql_test func4-1.46 { SELECT tointeger(9007199254740992 + 1); } {9007199254740993} do_execsql_test func4-1.47 { SELECT tointeger(9223372036854775807 - 1); } {9223372036854775806} do_execsql_test func4-1.48 { SELECT tointeger(9223372036854775807); } {9223372036854775807} if {$highPrecision(1)} { do_execsql_test func4-1.49 { SELECT tointeger(9223372036854775807 + 1); } {{}} do_execsql_test func4-1.50 { SELECT tointeger(9223372036854775808 - 1); } {{}} do_execsql_test func4-1.51 { SELECT tointeger(9223372036854775808); } {{}} do_execsql_test func4-1.52 { SELECT tointeger(9223372036854775808 + 1); } {{}} } do_execsql_test func4-1.53 { SELECT tointeger(18446744073709551616 - 1); } {{}} do_execsql_test func4-1.54 { SELECT tointeger(18446744073709551616); } {{}} do_execsql_test func4-1.55 { SELECT tointeger(18446744073709551616 + 1); } {{}} ifcapable floatingpoint { set highPrecision(2) [expr \ {[db eval {SELECT toreal(-9223372036854775808 + 1);}] eq {{}}}] do_execsql_test func4-2.1 { SELECT toreal(NULL); } {{}} do_execsql_test func4-2.2 { SELECT toreal(''); } {{}} do_execsql_test func4-2.3 { SELECT toreal(' '); } {{}} do_execsql_test func4-2.4 { SELECT toreal('1234'); } {1234.0} do_execsql_test func4-2.5 { SELECT toreal(' 1234'); } {{}} do_execsql_test func4-2.6 { SELECT toreal('bad'); } {{}} do_execsql_test func4-2.7 { SELECT toreal('0xBAD'); } {{}} do_execsql_test func4-2.8 { SELECT toreal('123BAD'); } {{}} do_execsql_test func4-2.9 { SELECT toreal('0x123BAD'); } {{}} do_execsql_test func4-2.10 { SELECT toreal('123NO'); } {{}} do_execsql_test func4-2.11 { SELECT toreal('0x123NO'); } {{}} do_execsql_test func4-2.12 { SELECT toreal('-0x1'); } {{}} do_execsql_test func4-2.13 { SELECT toreal('-0x0'); } {{}} do_execsql_test func4-2.14 { SELECT toreal('0x0'); } {{}} do_execsql_test func4-2.15 { SELECT toreal('0x1'); } {{}} do_execsql_test func4-2.16 { SELECT toreal(-1); } {-1.0} do_execsql_test func4-2.17 { SELECT toreal(-0); } {0.0} do_execsql_test func4-2.18 { SELECT toreal(0); } {0.0} do_execsql_test func4-2.19 { SELECT toreal(1); } {1.0} do_execsql_test func4-2.20 { SELECT toreal(-1.79769313486232e308 - 1); } {-Inf} do_execsql_test func4-2.21 { SELECT toreal(-1.79769313486232e308); } {-Inf} do_execsql_test func4-2.22 { SELECT toreal(-1.79769313486232e308 + 1); } {-Inf} do_execsql_test func4-2.23 { SELECT toreal(-9223372036854775808 - 1); } {-9.223372036854776e+18} do_execsql_test func4-2.24 { SELECT toreal(-9223372036854775808); } {-9.223372036854776e+18} if {$highPrecision(2)} { do_execsql_test func4-2.25 { SELECT toreal(-9223372036854775808 + 1); } {{}} } do_execsql_test func4-2.26 { SELECT toreal(-9223372036854775807 - 1); } {-9.223372036854776e+18} if {$highPrecision(2)} { do_execsql_test func4-2.27 { SELECT toreal(-9223372036854775807); } {{}} do_execsql_test func4-2.28 { SELECT toreal(-9223372036854775807 + 1); } {{}} } do_execsql_test func4-2.29 { SELECT toreal(-2147483648 - 1); } {-2147483649.0} do_execsql_test func4-2.30 { SELECT toreal(-2147483648); } {-2147483648.0} do_execsql_test func4-2.31 { SELECT toreal(-2147483648 + 1); } {-2147483647.0} do_execsql_test func4-2.32 { SELECT toreal(2147483647 - 1); } {2147483646.0} do_execsql_test func4-2.33 { SELECT toreal(2147483647); } {2147483647.0} do_execsql_test func4-2.34 { SELECT toreal(2147483647 + 1); } {2147483648.0} if {$highPrecision(2)} { do_execsql_test func4-2.35 { SELECT toreal(9223372036854775807 - 1); } {{}} if {$highPrecision(1)} { do_execsql_test func4-2.36 { SELECT toreal(9223372036854775807); } {{}} } } do_execsql_test func4-2.37 { SELECT toreal(9223372036854775807 + 1); } {9.223372036854776e+18} do_execsql_test func4-2.38 { SELECT toreal(1.79769313486232e308 - 1); } {Inf} do_execsql_test func4-2.39 { SELECT toreal(1.79769313486232e308); } {Inf} do_execsql_test func4-2.40 { SELECT toreal(1.79769313486232e308 + 1); } {Inf} do_execsql_test func4-2.41 { SELECT toreal(4503599627370496 - 1); } {4503599627370495.0} do_execsql_test func4-2.42 { SELECT toreal(4503599627370496); } {4503599627370496.0} do_execsql_test func4-2.43 { SELECT toreal(4503599627370496 + 1); } {4503599627370497.0} do_execsql_test func4-2.44 { SELECT toreal(9007199254740992 - 1); } {9007199254740991.0} do_execsql_test func4-2.45 { SELECT toreal(9007199254740992); } {9007199254740992.0} if {$highPrecision(2)} { do_execsql_test func4-2.46 { SELECT toreal(9007199254740992 + 1); } {{}} } do_execsql_test func4-2.47 { SELECT toreal(9007199254740992 + 2); } {9007199254740994.0} do_execsql_test func4-2.48 { SELECT toreal(tointeger(9223372036854775808) - 1); } {{}} if {$highPrecision(1)} { do_execsql_test func4-2.49 { SELECT toreal(tointeger(9223372036854775808)); } {{}} do_execsql_test func4-2.50 { SELECT toreal(tointeger(9223372036854775808) + 1); } {{}} } do_execsql_test func4-2.51 { SELECT toreal(tointeger(18446744073709551616) - 1); } {{}} do_execsql_test func4-2.52 { SELECT toreal(tointeger(18446744073709551616)); } {{}} do_execsql_test func4-2.53 { SELECT toreal(tointeger(18446744073709551616) + 1); } {{}} } ifcapable check { do_execsql_test func4-3.1 { CREATE TABLE t1( x INTEGER CHECK(tointeger(x) IS NOT NULL) ); } {} do_test func4-3.2 { catchsql { INSERT INTO t1 (x) VALUES (NULL); } } {1 {constraint failed}} do_test func4-3.3 { catchsql { INSERT INTO t1 (x) VALUES (NULL); } } {1 {constraint failed}} do_test func4-3.4 { catchsql { INSERT INTO t1 (x) VALUES (''); } } {1 {constraint failed}} do_test func4-3.5 { catchsql { INSERT INTO t1 (x) VALUES ('bad'); } } {1 {constraint failed}} do_test func4-3.6 { catchsql { INSERT INTO t1 (x) VALUES ('1234bad'); } } {1 {constraint failed}} do_test func4-3.7 { catchsql { INSERT INTO t1 (x) VALUES ('1234.56bad'); } } {1 {constraint failed}} do_test func4-3.8 { catchsql { INSERT INTO t1 (x) VALUES (1234); } } {0 {}} do_test func4-3.9 { catchsql { INSERT INTO t1 (x) VALUES (1234.56); } } {1 {constraint failed}} do_test func4-3.10 { catchsql { INSERT INTO t1 (x) VALUES ('1234'); } } {0 {}} do_test func4-3.11 { catchsql { INSERT INTO t1 (x) VALUES ('1234.56'); } } {1 {constraint failed}} do_test func4-3.12 { catchsql { INSERT INTO t1 (x) VALUES (ZEROBLOB(4)); } } {1 {constraint failed}} do_test func4-3.13 { catchsql { INSERT INTO t1 (x) VALUES (X''); } } {1 {constraint failed}} do_test func4-3.14 { catchsql { INSERT INTO t1 (x) VALUES (X'1234'); } } {1 {constraint failed}} do_test func4-3.15 { catchsql { INSERT INTO t1 (x) VALUES (X'12345678'); } } {1 {constraint failed}} do_test func4-3.16 { catchsql { INSERT INTO t1 (x) VALUES ('1234.00'); } } {1 {constraint failed}} do_test func4-3.17 { catchsql { INSERT INTO t1 (x) VALUES (1234.00); } } {0 {}} do_test func4-3.18 { catchsql { INSERT INTO t1 (x) VALUES ('-9223372036854775809'); } } {1 {constraint failed}} if {$highPrecision(1)} { do_test func4-3.19 { catchsql { INSERT INTO t1 (x) VALUES (9223372036854775808); } } {1 {constraint failed}} } do_execsql_test func4-3.20 { SELECT x FROM t1 ORDER BY x; } {1234 1234 1234} ifcapable floatingpoint { do_execsql_test func4-4.1 { CREATE TABLE t2( x REAL CHECK(toreal(x) IS NOT NULL) ); } {} do_test func4-4.2 { catchsql { INSERT INTO t2 (x) VALUES (NULL); } } {1 {constraint failed}} do_test func4-4.3 { catchsql { INSERT INTO t2 (x) VALUES (NULL); } } {1 {constraint failed}} do_test func4-4.4 { catchsql { INSERT INTO t2 (x) VALUES (''); } } {1 {constraint failed}} do_test func4-4.5 { catchsql { INSERT INTO t2 (x) VALUES ('bad'); } } {1 {constraint failed}} do_test func4-4.6 { catchsql { INSERT INTO t2 (x) VALUES ('1234bad'); } } {1 {constraint failed}} do_test func4-4.7 { catchsql { INSERT INTO t2 (x) VALUES ('1234.56bad'); } } {1 {constraint failed}} do_test func4-4.8 { catchsql { INSERT INTO t2 (x) VALUES (1234); } } {0 {}} do_test func4-4.9 { catchsql { INSERT INTO t2 (x) VALUES (1234.56); } } {0 {}} do_test func4-4.10 { catchsql { INSERT INTO t2 (x) VALUES ('1234'); } } {0 {}} do_test func4-4.11 { catchsql { INSERT INTO t2 (x) VALUES ('1234.56'); } } {0 {}} do_test func4-4.12 { catchsql { INSERT INTO t2 (x) VALUES (ZEROBLOB(4)); } } {1 {constraint failed}} do_test func4-4.13 { catchsql { INSERT INTO t2 (x) VALUES (X''); } } {1 {constraint failed}} do_test func4-4.14 { catchsql { INSERT INTO t2 (x) VALUES (X'1234'); } } {1 {constraint failed}} do_test func4-4.15 { catchsql { INSERT INTO t2 (x) VALUES (X'12345678'); } } {1 {constraint failed}} do_execsql_test func4-4.16 { SELECT x FROM t2 ORDER BY x; } {1234.0 1234.0 1234.56 1234.56} } } ifcapable floatingpoint { do_execsql_test func4-5.1 { SELECT tointeger(toreal('1234')); } {1234} do_execsql_test func4-5.2 { SELECT tointeger(toreal(-1)); } {-1} do_execsql_test func4-5.3 { SELECT tointeger(toreal(-0)); } {0} do_execsql_test func4-5.4 { SELECT tointeger(toreal(0)); } {0} do_execsql_test func4-5.5 { SELECT tointeger(toreal(1)); } {1} do_execsql_test func4-5.6 { SELECT tointeger(toreal(-9223372036854775808 - 1)); } {-9223372036854775808} do_execsql_test func4-5.7 { SELECT tointeger(toreal(-9223372036854775808)); } {-9223372036854775808} if {$highPrecision(2)} { do_execsql_test func4-5.8 { SELECT tointeger(toreal(-9223372036854775808 + 1)); } {{}} } do_execsql_test func4-5.9 { SELECT tointeger(toreal(-2147483648 - 1)); } {-2147483649} do_execsql_test func4-5.10 { SELECT tointeger(toreal(-2147483648)); } {-2147483648} do_execsql_test func4-5.11 { SELECT tointeger(toreal(-2147483648 + 1)); } {-2147483647} do_execsql_test func4-5.12 { SELECT tointeger(toreal(2147483647 - 1)); } {2147483646} do_execsql_test func4-5.13 { SELECT tointeger(toreal(2147483647)); } {2147483647} do_execsql_test func4-5.14 { SELECT tointeger(toreal(2147483647 + 1)); } {2147483648} do_execsql_test func4-5.15 { SELECT tointeger(toreal(9223372036854775807 - 1)); } {{}} if {$highPrecision(1)} { do_execsql_test func4-5.16 { SELECT tointeger(toreal(9223372036854775807)); } {{}} do_execsql_test func4-5.17 { SELECT tointeger(toreal(9223372036854775807 + 1)); } {{}} } do_execsql_test func4-5.18 { SELECT tointeger(toreal(4503599627370496 - 1)); } {4503599627370495} do_execsql_test func4-5.19 { SELECT tointeger(toreal(4503599627370496)); } {4503599627370496} do_execsql_test func4-5.20 { SELECT tointeger(toreal(4503599627370496 + 1)); } {4503599627370497} do_execsql_test func4-5.21 { SELECT tointeger(toreal(9007199254740992 - 1)); } {9007199254740991} do_execsql_test func4-5.22 { SELECT tointeger(toreal(9007199254740992)); } {9007199254740992} if {$highPrecision(2)} { do_execsql_test func4-5.23 { SELECT tointeger(toreal(9007199254740992 + 1)); } {{}} } do_execsql_test func4-5.24 { SELECT tointeger(toreal(9007199254740992 + 2)); } {9007199254740994} if {$highPrecision(1)} { do_execsql_test func4-5.25 { SELECT tointeger(toreal(9223372036854775808 - 1)); } {{}} do_execsql_test func4-5.26 { SELECT tointeger(toreal(9223372036854775808)); } {{}} do_execsql_test func4-5.27 { SELECT tointeger(toreal(9223372036854775808 + 1)); } {{}} } do_execsql_test func4-5.28 { SELECT tointeger(toreal(18446744073709551616 - 1)); } {{}} do_execsql_test func4-5.29 { SELECT tointeger(toreal(18446744073709551616)); } {{}} do_execsql_test func4-5.30 { SELECT tointeger(toreal(18446744073709551616 + 1)); } {{}} } for {set i 0} {$i < 10} {incr i} { if {$i == 8} continue do_execsql_test func4-6.1.$i.1 [subst { SELECT tointeger(x'[string repeat 01 $i]'); }] {{}} ifcapable floatingpoint { do_execsql_test func4-6.1.$i.2 [subst { SELECT toreal(x'[string repeat 01 $i]'); }] {{}} } } do_execsql_test func4-6.2.1 { SELECT tointeger(x'0102030405060708'); } {578437695752307201} do_execsql_test func4-6.2.2 { SELECT tointeger(x'0807060504030201'); } {72623859790382856} ifcapable floatingpoint { do_execsql_test func4-6.3.1 { SELECT toreal(x'ffefffffffffffff'); } {-1.7976931348623157e+308} do_execsql_test func4-6.3.2 { SELECT toreal(x'8010000000000000'); } {-2.2250738585072014e-308} do_execsql_test func4-6.3.3 { SELECT toreal(x'c000000000000000'); } {-2.0} do_execsql_test func4-6.3.4 { SELECT toreal(x'bff0000000000000'); } {-1.0} do_execsql_test func4-6.3.5 { SELECT toreal(x'8000000000000000'); } {-0.0} do_execsql_test func4-6.3.6 { SELECT toreal(x'0000000000000000'); } {0.0} do_execsql_test func4-6.3.7 { SELECT toreal(x'3ff0000000000000'); } {1.0} do_execsql_test func4-6.3.8 { SELECT toreal(x'4000000000000000'); } {2.0} do_execsql_test func4-6.3.9 { SELECT toreal(x'0010000000000000'); } {2.2250738585072014e-308} do_execsql_test func4-6.3.10 { SELECT toreal(x'7fefffffffffffff'); } {1.7976931348623157e+308} do_execsql_test func4-6.3.11 { SELECT toreal(x'8000000000000001'); } {-5e-324} do_execsql_test func4-6.3.12 { SELECT toreal(x'800fffffffffffff'); } {-2.225073858507201e-308} do_execsql_test func4-6.3.13 { SELECT toreal(x'0000000000000001'); } {5e-324} do_execsql_test func4-6.3.14 { SELECT toreal(x'000fffffffffffff'); } {2.225073858507201e-308} do_execsql_test func4-6.3.15 { SELECT toreal(x'fff0000000000000'); } {-Inf} do_execsql_test func4-6.3.16 { SELECT toreal(x'7ff0000000000000'); } {Inf} do_execsql_test func4-6.3.17 { SELECT toreal(x'fff8000000000000'); } {{}} do_execsql_test func4-6.3.18 { SELECT toreal(x'fff0000000000001'); } {{}} do_execsql_test func4-6.3.19 { SELECT toreal(x'fff7ffffffffffff'); } {{}} do_execsql_test func4-6.3.20 { SELECT toreal(x'7ff0000000000001'); } {{}} do_execsql_test func4-6.3.21 { SELECT toreal(x'7ff7ffffffffffff'); } {{}} do_execsql_test func4-6.3.22 { SELECT toreal(x'fff8000000000001'); } {{}} do_execsql_test func4-6.3.23 { SELECT toreal(x'ffffffffffffffff'); } {{}} do_execsql_test func4-6.3.24 { SELECT toreal(x'7ff8000000000000'); } {{}} do_execsql_test func4-6.3.25 { SELECT toreal(x'7fffffffffffffff'); } {{}} } set tcl_precision $saved_tcl_precision unset saved_tcl_precision finish_test |
Changes to test/instr.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # 2012 October 24 # # 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 file is testing the built-in INSTR() functions. # set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a table to work with. # do_test instr-1.1 { | > > > > > | 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 | # 2012 October 24 # # 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 file is testing the built-in INSTR() functions. # # EVIDENCE-OF: R-27549-59611 The instr(X,Y) function finds the first # occurrence of string Y within string X and returns the number of prior # characters plus 1, or 0 if Y is nowhere found within X. # set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a table to work with. # do_test instr-1.1 { |
︙ | ︙ | |||
195 196 197 198 199 200 201 | } {106496} do_test instr-1.54 { db eval {SELECT instr(x'78c3a4e282ac79','x');} } {1} do_test instr-1.55 { db eval {SELECT instr(x'78c3a4e282ac79','y');} } {4} | > > > > > | | > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > | 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 | } {106496} do_test instr-1.54 { db eval {SELECT instr(x'78c3a4e282ac79','x');} } {1} do_test instr-1.55 { db eval {SELECT instr(x'78c3a4e282ac79','y');} } {4} # EVIDENCE-OF: R-46421-32541 Or, if X and Y are both BLOBs, then # instr(X,Y) returns one more than the number bytes prior to the first # occurrence of Y, or 0 if Y does not occur anywhere within X. # do_test instr-1.56.1 { db eval {SELECT instr(x'78c3a4e282ac79',x'79');} } {7} do_test instr-1.56.2 { db eval {SELECT instr(x'78c3a4e282ac79',x'7a');} } {0} do_test instr-1.56.3 { db eval {SELECT instr(x'78c3a4e282ac79',x'78');} } {1} do_test instr-1.56.3 { db eval {SELECT instr(x'78c3a4e282ac79',x'a4');} } {3} # EVIDENCE-OF: R-17329-35644 If both arguments X and Y to instr(X,Y) are # non-NULL and are not BLOBs then both are interpreted as strings. # do_test instr-1.57.1 { db eval {SELECT instr('xä€y',x'79');} } {4} do_test instr-1.57.2 { db eval {SELECT instr('xä€y',x'a4');} } {0} do_test instr-1.57.3 { db eval {SELECT instr(x'78c3a4e282ac79','y');} } {4} # EVIDENCE-OF: R-14708-27487 If either X or Y are NULL in instr(X,Y) # then the result is NULL. # do_execsql_test instr-1.60 { SELECT coalesce(instr(NULL,'abc'), 999); } {999} do_execsql_test instr-1.61 { SELECT coalesce(instr('abc',NULL), 999); } {999} do_execsql_test instr-1.62 { SELECT coalesce(instr(NULL,NULL), 999); } {999} finish_test |
Changes to test/pragma.test.
︙ | ︙ | |||
570 571 572 573 574 575 576 | pragma foreign_key_list(t5); } } {} do_test pragma-6.4 { execsql { pragma index_list(t3); } | | | 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | pragma foreign_key_list(t5); } } {} do_test pragma-6.4 { execsql { pragma index_list(t3); } } {0 sqlite_autoindex_t3_1 1} } ifcapable {!foreignkey} { execsql {CREATE TABLE t3(a,b UNIQUE)} } do_test pragma-6.5.1 { execsql { CREATE INDEX t3i1 ON t3(a,b); |
︙ | ︙ | |||
643 644 645 646 647 648 649 | do_test pragma-7.1.1 { # Make sure a pragma knows to read the schema if it needs to db close sqlite3 db test.db execsql { pragma index_list(t3); } | | | 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 | do_test pragma-7.1.1 { # Make sure a pragma knows to read the schema if it needs to db close sqlite3 db test.db execsql { pragma index_list(t3); } } {0 t3i1 0 1 sqlite_autoindex_t3_1 1} do_test pragma-7.1.2 { execsql { pragma index_list(t3_bogus); } } {} } ;# ifcapable schema_pragmas ifcapable {utf16} { |
︙ | ︙ | |||
1657 1658 1659 1660 1661 1662 1663 | db2 eval {PRAGMA index_info(i2)} } {0 2 c 1 3 d 2 1 b} do_test 23.3 { db eval { CREATE INDEX i3 ON t1(d,b,c); } db2 eval {PRAGMA index_list(t1)} | | | 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 | db2 eval {PRAGMA index_info(i2)} } {0 2 c 1 3 d 2 1 b} do_test 23.3 { db eval { CREATE INDEX i3 ON t1(d,b,c); } db2 eval {PRAGMA index_list(t1)} } {0 i3 0 1 i2 0 2 i1 0} do_test 23.4 { db eval { ALTER TABLE t1 ADD COLUMN e; } db2 eval { PRAGMA table_info(t1); } |
︙ | ︙ |
Changes to test/pragma2.test.
︙ | ︙ | |||
115 116 117 118 119 120 121 122 123 124 125 126 127 128 | PRAGMA aux.freelist_count; } } {9 9} } # Default setting of PRAGMA cache_spill is always ON # db close delete_file test.db test.db-journal delete_file test2.db test2.db-journal sqlite3 db test.db do_execsql_test pragma2-4.1 { PRAGMA cache_spill; PRAGMA main.cache_spill; | > > > > > | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | PRAGMA aux.freelist_count; } } {9 9} } # Default setting of PRAGMA cache_spill is always ON # # EVIDENCE-OF: R-51036-62828 PRAGMA cache_spill; PRAGMA # cache_spill=boolean; # # EVIDENCE-OF: R-23955-02765 Cache_spill is enabled by default # db close delete_file test.db test.db-journal delete_file test2.db test2.db-journal sqlite3 db test.db do_execsql_test pragma2-4.1 { PRAGMA cache_spill; PRAGMA main.cache_spill; |
︙ | ︙ | |||
151 152 153 154 155 156 157 158 159 160 161 162 163 164 | ATTACH 'test2.db' AS aux1; CREATE TABLE aux1.t2(a INTEGER PRIMARY KEY, b, c, d); INSERT INTO t2 SELECT * FROM t1; DETACH aux1; PRAGMA cache_spill=ON; } {} sqlite3_release_memory do_test pragma2-4.4 { db eval { BEGIN; UPDATE t1 SET c=c+1; PRAGMA lock_status; } } {main exclusive temp unknown} ;# EXCLUSIVE lock due to cache spill | > > > > > | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | ATTACH 'test2.db' AS aux1; CREATE TABLE aux1.t2(a INTEGER PRIMARY KEY, b, c, d); INSERT INTO t2 SELECT * FROM t1; DETACH aux1; PRAGMA cache_spill=ON; } {} sqlite3_release_memory # # EVIDENCE-OF: R-07634-40532 The cache_spill pragma enables or disables # the ability of the pager to spill dirty cache pages to the database # file in the middle of a transaction. # do_test pragma2-4.4 { db eval { BEGIN; UPDATE t1 SET c=c+1; PRAGMA lock_status; } } {main exclusive temp unknown} ;# EXCLUSIVE lock due to cache spill |
︙ | ︙ |
Changes to test/shared7.test.
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ifcapable !shared_cache { finish_test ; return } do_test shared7-1.1 { set ::enable_shared_cache [sqlite3_enable_shared_cache 1] sqlite3_enable_shared_cache } {1} do_test shared7-1.2 { db close sqlite3 db test.db db eval { CREATE TABLE t1(x); } catchsql { | > > > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ifcapable !shared_cache { finish_test ; return } do_test shared7-1.1 { set ::enable_shared_cache [sqlite3_enable_shared_cache 1] sqlite3_enable_shared_cache } {1} # EVIDENCE-OF: R-05098-06501 In shared cache mode, attempting to attach # the same database file more than once results in an error. # do_test shared7-1.2 { db close sqlite3 db test.db db eval { CREATE TABLE t1(x); } catchsql { |
︙ | ︙ |
Changes to tool/lemon.c.
︙ | ︙ | |||
3454 3455 3456 3457 3458 3459 3460 | hash = (hash & 0x7fffffff)%arraysize; while( types[hash] ){ if( strcmp(types[hash],stddt)==0 ){ sp->dtnum = hash + 1; break; } hash++; | | | 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 | hash = (hash & 0x7fffffff)%arraysize; while( types[hash] ){ if( strcmp(types[hash],stddt)==0 ){ sp->dtnum = hash + 1; break; } hash++; if( hash>=(unsigned)arraysize ) hash = 0; } if( types[hash]==0 ){ sp->dtnum = hash + 1; types[hash] = (char*)malloc( lemonStrlen(stddt)+1 ); if( types[hash]==0 ){ fprintf(stderr,"Out of memory.\n"); exit(1); |
︙ | ︙ |
Changes to tool/mkpragmatab.tcl.
︙ | ︙ | |||
165 166 167 168 169 170 171 172 173 174 175 176 177 178 | IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE NAME: synchronous FLAG: NeedSchema IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) NAME: table_info FLAG: NeedSchema IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) NAME: index_info FLAG: NeedSchema IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) | > > > > | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE NAME: synchronous FLAG: NeedSchema IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) NAME: table_info FLAG: NeedSchema IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) NAME: stats FLAG: NeedSchema IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) NAME: index_info FLAG: NeedSchema IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
︙ | ︙ |
Changes to tool/mksqlite3c.tcl.
︙ | ︙ | |||
118 119 120 121 122 123 124 125 126 127 128 129 130 131 | vdbeInt.h wal.h } { set available_hdr($hdr) 1 } set available_hdr(sqliteInt.h) 0 set available_hdr(sqlite3session.h) 0 # 78 stars used for comment formatting. set s78 \ {*****************************************************************************} # Insert a comment into the code # | > | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | vdbeInt.h wal.h } { set available_hdr($hdr) 1 } set available_hdr(sqliteInt.h) 0 set available_hdr(sqlite3session.h) 0 set available_hdr(sqlite3.h) 0 # 78 stars used for comment formatting. set s78 \ {*****************************************************************************} # Insert a comment into the code # |
︙ | ︙ | |||
225 226 227 228 229 230 231 232 233 234 235 236 237 238 | # Process the source files. Process files containing commonly # used subroutines first in order to help the compiler find # inlining opportunities. # foreach file { sqliteInt.h global.c ctime.c status.c date.c os.c | > | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | # Process the source files. Process files containing commonly # used subroutines first in order to help the compiler find # inlining opportunities. # foreach file { sqlite3.h sqliteInt.h global.c ctime.c status.c date.c os.c |
︙ | ︙ |
Changes to tool/mkvsix.tcl.
︙ | ︙ | |||
275 276 277 278 279 280 281 282 | set shortName SQLite.WP80 set displayName "SQLite for Windows Phone" set targetPlatformIdentifier "Windows Phone" set targetPlatformVersion v8.0 set minVsVersion 11.0 set extraSdkPath "\\..\\$targetPlatformIdentifier" set extraFileListAttributes "" } else { | > > > > > > > > > > | | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | set shortName SQLite.WP80 set displayName "SQLite for Windows Phone" set targetPlatformIdentifier "Windows Phone" set targetPlatformVersion v8.0 set minVsVersion 11.0 set extraSdkPath "\\..\\$targetPlatformIdentifier" set extraFileListAttributes "" } elseif {[string equal -nocase $packageFlavor Win32]} then { set shortName SQLite.Win32 set displayName "SQLite for Windows" set targetPlatformIdentifier Windows set targetPlatformVersion v8.0 set minVsVersion 11.0 set extraSdkPath "" set extraFileListAttributes [appendArgs \ "\r\n " {AppliesTo="VisualC"} \ "\r\n " {DependsOn="Microsoft.VCLibs, version=11.0"}] } else { fail "unsupported package flavor, must be one of: WinRT WinRT81 WP80 Win32" } if {$argc >= 4} then { set platformNames [list] foreach platformName [split [lindex $argv 3] ", "] { if {[string length $platformName] > 0} then { |
︙ | ︙ |
Changes to tool/warnings.sh.
1 2 3 4 5 6 7 8 9 10 11 | #/bin/sh # # Run this script in a directory with a working makefile to check for # compiler warnings in SQLite. # rm -f sqlite3.c make sqlite3.c-debug echo '********** No optimizations. Includes FTS4 and RTREE *********' gcc -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ -ansi -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \ sqlite3.c | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #/bin/sh # # Run this script in a directory with a working makefile to check for # compiler warnings in SQLite. # rm -f sqlite3.c make sqlite3.c-debug echo '********** No optimizations. Includes FTS4 and RTREE *********' gcc -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ -ansi -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \ sqlite3.c echo '********** No optimizations. ENABLE_STAT4. THREADSAFE=0 *******' gcc -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ -ansi -DSQLITE_ENABLE_STAT4 -DSQLITE_THREADSAFE=0 \ sqlite3.c echo '********** Optimized -O3. Includes FTS4 and RTREE ************' gcc -O3 -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ -ansi -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \ sqlite3.c |