Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch toTypeFuncs Excluding Merge-Ins
This is equivalent to a diff from f0cf8c85 to a88b5be0
2013-10-14
| ||
19:35 | Add implementations for the toInteger() and toReal() SQL functions. (check-in: a0f7cbc0 user: drh tags: trunk) | |
10:46 | Add a new application_id for GeoPackage version 1.0. (check-in: 98ddfe45 user: drh tags: trunk) | |
2013-10-12
| ||
23:39 | Merge updates from trunk. (Closed-Leaf check-in: a88b5be0 user: mistachkin tags: toTypeFuncs) | |
20:22 | Restore the index_list pragma back to its former operation. Create a new PRAGMA stats used to access the table and index widths and heights. (check-in: f0cf8c85 user: drh tags: trunk) | |
15:12 | Fix handling of "DROP TABLE" commands when "PRAGMA defer_foreign_keys=1" is set. (check-in: 27001356 user: dan tags: trunk) | |
2013-09-24
| ||
19:07 | Merge updates from trunk. (check-in: 435ce3b3 user: mistachkin tags: toTypeFuncs) | |
Changes to Makefile.msc.
︙ | ︙ | |||
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | !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 | > > > > > > > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | !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 |
︙ | ︙ | |||
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 | 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 |
︙ | ︙ | |||
1308 1309 1310 1311 1312 1313 1314 | 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 | | | 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 | 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 |
︙ | ︙ |
Changes to src/func.c.
︙ | ︙ | |||
961 962 963 964 965 966 967 968 969 970 971 972 973 974 | assert( sqlite3_value_type(argv[0])==SQLITE_NULL ); sqlite3_result_text(context, "NULL", 4, SQLITE_STATIC); break; } } } /* ** The unicode() function. Return the integer unicode code-point value ** for the first character of the input string. */ static void unicodeFunc( sqlite3_context *context, int argc, | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 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 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 | assert( sqlite3_value_type(argv[0])==SQLITE_NULL ); sqlite3_result_text(context, "NULL", 4, SQLITE_STATIC); break; } } } /* ** 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 ); UNUSED_PARAMETER(argc); switch( sqlite3_value_type(argv[0]) ){ case SQLITE_FLOAT: { double rVal = sqlite3_value_double(argv[0]); i64 iVal = (i64)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(i64) ){ i64 iVal; if( SQLITE_BIGENDIAN ){ int i; unsigned char *zBlobRev = contextMalloc(context, nBlob); if( !zBlobRev ) break; for(i=0; i<nBlob; i++) zBlobRev[i] = zBlob[nBlob-1-i]; memcpy(&iVal, zBlobRev, sizeof(i64)); sqlite3_free(zBlobRev); }else{ memcpy(&iVal, zBlob, sizeof(i64)); } 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 && !sqlite3Isspace(zStr[0]) ){ i64 iVal; if( !sqlite3Atoi64((const char*)zStr, &iVal, nStr, SQLITE_UTF8) ){ 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 optimize("", off) #endif static void torealFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ assert( argc==1 ); UNUSED_PARAMETER(argc); switch( sqlite3_value_type(argv[0]) ){ case SQLITE_FLOAT: { sqlite3_result_double(context, sqlite3_value_double(argv[0])); break; } case SQLITE_INTEGER: { i64 iVal = sqlite3_value_int64(argv[0]); double rVal = (double)iVal; if( iVal==(i64)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( SQLITE_LITTLEENDIAN ){ int i; unsigned char *zBlobRev = contextMalloc(context, nBlob); if( !zBlobRev ) break; for(i=0; i<nBlob; i++) zBlobRev[i] = zBlob[nBlob-1-i]; memcpy(&rVal, zBlobRev, sizeof(double)); sqlite3_free(zBlobRev); }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 && !sqlite3Isspace(zStr[0]) && !sqlite3Isspace(zStr[nStr-1]) ){ double rVal; if( sqlite3AtoF((const char*)zStr, &rVal, nStr, SQLITE_UTF8) ){ sqlite3_result_double(context, rVal); return; } } } break; } default: { assert( sqlite3_value_type(argv[0])==SQLITE_NULL ); break; } } } #if defined(_MSC_VER) #pragma optimize("", on) #endif /* ** The unicode() function. Return the integer unicode code-point value ** for the first character of the input string. */ static void unicodeFunc( sqlite3_context *context, int argc, |
︙ | ︙ | |||
1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 | FUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ), FUNCTION(sqlite_log, 2, 0, 0, errlogFunc ), #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS FUNCTION(sqlite_compileoption_used,1, 0, 0, compileoptionusedFunc ), FUNCTION(sqlite_compileoption_get, 1, 0, 0, compileoptiongetFunc ), #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ FUNCTION(quote, 1, 0, 0, quoteFunc ), FUNCTION(last_insert_rowid, 0, 0, 0, last_insert_rowid), FUNCTION(changes, 0, 0, 0, changes ), FUNCTION(total_changes, 0, 0, 0, total_changes ), FUNCTION(replace, 3, 0, 0, replaceFunc ), FUNCTION(zeroblob, 1, 0, 0, zeroblobFunc ), #ifdef SQLITE_SOUNDEX FUNCTION(soundex, 1, 0, 0, soundexFunc ), | > > | 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 | FUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ), FUNCTION(sqlite_log, 2, 0, 0, errlogFunc ), #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS FUNCTION(sqlite_compileoption_used,1, 0, 0, compileoptionusedFunc ), FUNCTION(sqlite_compileoption_get, 1, 0, 0, compileoptiongetFunc ), #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ FUNCTION(quote, 1, 0, 0, quoteFunc ), FUNCTION(tointeger, 1, 0, 0, tointegerFunc ), FUNCTION(toreal, 1, 0, 0, torealFunc ), FUNCTION(last_insert_rowid, 0, 0, 0, last_insert_rowid), FUNCTION(changes, 0, 0, 0, changes ), FUNCTION(total_changes, 0, 0, 0, total_changes ), FUNCTION(replace, 3, 0, 0, replaceFunc ), FUNCTION(zeroblob, 1, 0, 0, zeroblobFunc ), #ifdef SQLITE_SOUNDEX FUNCTION(soundex, 1, 0, 0, soundexFunc ), |
︙ | ︙ |
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 | # 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 set highPrecision(1) [expr \ {[memdbsql {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 \ {[memdbsql {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 |