Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | 1.0.55.0 |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | sourceforge |
Files: | files | file ages | folders |
SHA1: |
24425920c86f90fa36074d5f3dc0d302 |
User & Date: | rmsimpson 2008-08-06 21:40:17.000 |
Context
2008-08-06
| ||
21:48 | 3.6.1 debug sources check-in: add0673a62 user: rmsimpson tags: sourceforge | |
21:40 | 1.0.55.0 check-in: 24425920c8 user: rmsimpson tags: sourceforge | |
2008-07-26
| ||
04:34 | 1.0.54.0 check-in: 41d8f0f895 user: rmsimpson tags: sourceforge | |
Changes
Changes to SQLite.Interop/SQLite.Interop.rc.
︙ | ︙ | |||
49 50 51 52 53 54 55 | ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO | | | | | 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 | ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION 1,0,55,0 PRODUCTVERSION 1,0,0,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x2L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "Comments", "http://sqlite.phxsoftware.com" VALUE "FileDescription", "System.Data.SQLite Interop Library" VALUE "FileVersion", "1.0.55.0" VALUE "InternalName", "SQLite.Interop.DLL" VALUE "LegalCopyright", "Released to the public domain" VALUE "OriginalFilename", "SQLite3.DLL 3.6.1" VALUE "ProductName", "System.Data.SQLite" VALUE "ProductVersion", "1.0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 |
︙ | ︙ |
Changes to SQLite.Interop/SQLite.Interop.vcproj.
︙ | ︙ | |||
28 29 30 31 32 33 34 | <Configuration Name="Release|Win32" OutputDirectory="$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="2" CharacterSet="2" ManagedExtensions="0" | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | <Configuration Name="Release|Win32" OutputDirectory="$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="2" CharacterSet="2" ManagedExtensions="0" WholeProgramOptimization="3" > <Tool Name="VCPreBuildEventTool" CommandLine="" /> <Tool Name="VCCustomBuildTool" |
︙ | ︙ | |||
51 52 53 54 55 56 57 | Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" AdditionalOptions="/GS-" Optimization="2" FavorSizeOrSpeed="1" | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" AdditionalOptions="/GS-" Optimization="2" FavorSizeOrSpeed="1" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;NO_TCL;THREADSAFE=1;SQLITE_HAS_CODEC;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_ENABLE_FTS3;SQLITE_ENABLE_RTREE;SQLITE_ENABLE_LOAD_EXTENSION;SQLITE_SOUNDEX" StringPooling="true" ExceptionHandling="0" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool |
︙ | ︙ | |||
132 133 134 135 136 137 138 | Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" ExecutionBucket="7" Optimization="1" FavorSizeOrSpeed="2" | | | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" ExecutionBucket="7" Optimization="1" FavorSizeOrSpeed="2" PreprocessorDefinitions="_WIN32_WCE=$(CEVER);UNDER_CE=$(CEVER);WINCE;$(PLATFORMDEFINES);NDEBUG;_WINDOWS;_USRDLL;CPPSMART_EXPORTS;$(ARCHFAM);$(_ARCHFAM_);UNICODE;_UNICODE;SQLITE_HAS_CODEC;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_ENABLE_FTS3;SQLITE_ENABLE_RTREE;SQLITE_ENABLE_LOAD_EXTENSION;SQLITE_SOUNDEX;INVALID_FILE_ATTRIBUTES=((DWORD)-1)" StringPooling="true" ExceptionHandling="0" BufferSecurityCheck="false" EnableFunctionLevelLinking="true" /> <Tool Name="VCManagedResourceCompilerTool" |
︙ | ︙ | |||
228 229 230 231 232 233 234 | TargetEnvironment="2" /> <Tool Name="VCCLCompilerTool" AdditionalOptions="/GS-" Optimization="2" FavorSizeOrSpeed="1" | | | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | TargetEnvironment="2" /> <Tool Name="VCCLCompilerTool" AdditionalOptions="/GS-" Optimization="2" FavorSizeOrSpeed="1" PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;NO_TCL;THREADSAFE=1;WIN64;SQLITE_HAS_CODEC;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_ENABLE_FTS3;SQLITE_ENABLE_RTREE;SQLITE_ENABLE_LOAD_EXTENSION;SQLITE_SOUNDEX" StringPooling="true" ExceptionHandling="0" BufferSecurityCheck="false" EnableFunctionLevelLinking="true" RuntimeTypeInfo="false" /> <Tool |
︙ | ︙ | |||
312 313 314 315 316 317 318 | TargetEnvironment="3" /> <Tool Name="VCCLCompilerTool" AdditionalOptions="/GS-" Optimization="2" FavorSizeOrSpeed="1" | | | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | TargetEnvironment="3" /> <Tool Name="VCCLCompilerTool" AdditionalOptions="/GS-" Optimization="2" FavorSizeOrSpeed="1" PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;NO_TCL;THREADSAFE=1;WIN64;SQLITE_HAS_CODEC;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_ENABLE_FTS3;SQLITE_ENABLE_RTREE;SQLITE_ENABLE_LOAD_EXTENSION;SQLITE_SOUNDEX" StringPooling="true" ExceptionHandling="0" BufferSecurityCheck="false" EnableFunctionLevelLinking="true" RuntimeTypeInfo="false" /> <Tool |
︙ | ︙ | |||
394 395 396 397 398 399 400 | <Tool Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" AdditionalOptions="/GS-" Optimization="0" | | | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | <Tool Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" AdditionalOptions="/GS-" Optimization="0" PreprocessorDefinitions="WIN32;SQLITE_DEBUG;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;NO_TCL;THREADSAFE=1;SQLITE_HAS_CODEC;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_ENABLE_FTS3;SQLITE_ENABLE_RTREE;SQLITE_ENABLE_LOAD_EXTENSION;SQLITE_SOUNDEX;SQLITE_CORE" RuntimeLibrary="3" RuntimeTypeInfo="false" DebugInformationFormat="3" /> <Tool Name="VCManagedResourceCompilerTool" /> |
︙ | ︙ | |||
476 477 478 479 480 481 482 | TargetEnvironment="1" /> <Tool Name="VCCLCompilerTool" ExecutionBucket="7" AdditionalOptions="/GS-" Optimization="0" | | | 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | TargetEnvironment="1" /> <Tool Name="VCCLCompilerTool" ExecutionBucket="7" AdditionalOptions="/GS-" Optimization="0" PreprocessorDefinitions="SQLITE_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE=$(CEVER);WINCE;$(PLATFORMDEFINES);_DEBUG;_WINDOWS;_USRDLL;CPPSMART_EXPORTS;$(ARCHFAM);$(_ARCHFAM_);UNICODE;_UNICODE;SQLITE_HAS_CODEC;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_ENABLE_FTS3;SQLITE_ENABLE_RTREE;SQLITE_ENABLE_LOAD_EXTENSION;SQLITE_SOUNDEX;SQLITE_CORE;INVALID_FILE_ATTRIBUTES=((DWORD)-1)" DebugInformationFormat="3" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool Name="VCResourceCompilerTool" |
︙ | ︙ | |||
564 565 566 567 568 569 570 | Name="VCMIDLTool" TargetEnvironment="2" /> <Tool Name="VCCLCompilerTool" AdditionalOptions="/GS-" Optimization="0" | | | 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 | Name="VCMIDLTool" TargetEnvironment="2" /> <Tool Name="VCCLCompilerTool" AdditionalOptions="/GS-" Optimization="0" PreprocessorDefinitions="SQLITE_DEBUG;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;NO_TCL;THREADSAFE=1;WIN64;SQLITE_HAS_CODEC;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_ENABLE_FTS3;SQLITE_ENABLE_RTREE;SQLITE_ENABLE_LOAD_EXTENSION;SQLITE_SOUNDEX" RuntimeLibrary="3" RuntimeTypeInfo="false" DebugInformationFormat="3" /> <Tool Name="VCManagedResourceCompilerTool" /> |
︙ | ︙ | |||
644 645 646 647 648 649 650 | Name="VCMIDLTool" TargetEnvironment="3" /> <Tool Name="VCCLCompilerTool" AdditionalOptions="/GS-" Optimization="0" | | | 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | Name="VCMIDLTool" TargetEnvironment="3" /> <Tool Name="VCCLCompilerTool" AdditionalOptions="/GS-" Optimization="0" PreprocessorDefinitions="SQLITE_DEBUG;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;NO_TCL;THREADSAFE=1;WIN64;SQLITE_HAS_CODEC;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_ENABLE_FTS3;SQLITE_ENABLE_RTREE;SQLITE_ENABLE_LOAD_EXTENSION;SQLITE_SOUNDEX" RuntimeLibrary="3" RuntimeTypeInfo="false" DebugInformationFormat="3" /> <Tool Name="VCManagedResourceCompilerTool" /> |
︙ | ︙ | |||
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 | Name="Extras" > <File RelativePath=".\interop.c" > </File> </Filter> <File RelativePath=".\SQLite.Interop.rc" > </File> </Files> <Globals> </Globals> </VisualStudioProject> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 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 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 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 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 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 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 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 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 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 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 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 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 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 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 | Name="Extras" > <File RelativePath=".\interop.c" > </File> </Filter> <Filter Name="src" > <File RelativePath=".\splitsource\alter.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\analyze.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\attach.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\auth.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\bitvec.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\btmutex.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\btree.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\build.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\callback.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\complete.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\date.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\delete.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\expr.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\fault.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\fts3.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\fts3_hash.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\fts3_porter.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\fts3_tokenizer.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\fts3_tokenizer1.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\func.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\global.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\hash.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\insert.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\journal.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\legacy.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\loadext.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\main.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\malloc.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\mem1.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\mem2.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\mem3.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\mem4.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\mem5.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\mutex.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\mutex_w32.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\opcodes.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\os.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\os_win.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\pager.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Debug|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Debug|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Debug|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Debug|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\parse.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\pragma.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\prepare.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\printf.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\random.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\rtree.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\select.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\status.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\table.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\tokenize.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\trigger.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\update.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\utf.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\util.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\vacuum.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\vdbe.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\vdbeapi.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\vdbeaux.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\vdbeblob.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\vdbefifo.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\vdbemem.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\vtab.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> <File RelativePath=".\splitsource\where.c" > <FileConfiguration Name="Release|Win32" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Pocket PC 2003 (ARMV4)" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|Itanium" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> <FileConfiguration Name="Release|x64" ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" /> </FileConfiguration> </File> </Filter> <File RelativePath=".\SQLite.Interop.rc" > </File> </Files> <Globals> </Globals> </VisualStudioProject> |
Changes to SQLite.Interop/crypt.c.
1 2 3 4 5 6 7 8 9 | #ifndef SQLITE_OMIT_DISKIO #ifdef SQLITE_HAS_CODEC #include <windows.h> #include <wincrypt.h> // Extra padding before and after the cryptographic buffer #define CRYPT_OFFSET 8 | > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | #ifndef SQLITE_OMIT_DISKIO #ifdef SQLITE_HAS_CODEC #if _DEBUG #include "splitsource\pager.c" #endif #include <windows.h> #include <wincrypt.h> // Extra padding before and after the cryptographic buffer #define CRYPT_OFFSET 8 |
︙ | ︙ | |||
51 52 53 54 55 56 57 58 59 60 61 62 63 64 | static LPCRYPTBLOCK CreateCryptBlock(HCRYPTKEY hKey, Pager *pager, LPCRYPTBLOCK pExisting) { LPCRYPTBLOCK pBlock; if (!pExisting) // Creating a new cryptblock { pBlock = sqlite3_malloc(sizeof(CRYPTBLOCK)); ZeroMemory(pBlock, sizeof(CRYPTBLOCK)); pBlock->hReadKey = hKey; pBlock->hWriteKey = hKey; } else // Updating an existing cryptblock { pBlock = pExisting; | > > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | static LPCRYPTBLOCK CreateCryptBlock(HCRYPTKEY hKey, Pager *pager, LPCRYPTBLOCK pExisting) { LPCRYPTBLOCK pBlock; if (!pExisting) // Creating a new cryptblock { pBlock = sqlite3_malloc(sizeof(CRYPTBLOCK)); if (!pBlock) return NULL; ZeroMemory(pBlock, sizeof(CRYPTBLOCK)); pBlock->hReadKey = hKey; pBlock->hWriteKey = hKey; } else // Updating an existing cryptblock { pBlock = pExisting; |
︙ | ︙ | |||
74 75 76 77 78 79 80 81 82 83 84 85 86 87 | sqlite3_free(pBlock->pvCrypt); pBlock->pvCrypt = NULL; } // Figure out how big to make our spare crypt block CryptEncrypt(hKey, 0, TRUE, 0, NULL, &pBlock->dwCryptSize, pBlock->dwCryptSize * 2); pBlock->pvCrypt = sqlite3_malloc(pBlock->dwCryptSize + (CRYPT_OFFSET * 2)); return pBlock; } // Destroy a cryptographic context and any buffers and keys allocated therein static void DestroyCryptBlock(LPCRYPTBLOCK pBlock) { | > > > > > | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | sqlite3_free(pBlock->pvCrypt); pBlock->pvCrypt = NULL; } // Figure out how big to make our spare crypt block CryptEncrypt(hKey, 0, TRUE, 0, NULL, &pBlock->dwCryptSize, pBlock->dwCryptSize * 2); pBlock->pvCrypt = sqlite3_malloc(pBlock->dwCryptSize + (CRYPT_OFFSET * 2)); if (!pBlock->pvCrypt) { sqlite3_free(pBlock); return NULL; } return pBlock; } // Destroy a cryptographic context and any buffers and keys allocated therein static void DestroyCryptBlock(LPCRYPTBLOCK pBlock) { |
︙ | ︙ | |||
272 273 274 275 276 277 278 | LPCRYPTBLOCK pBlock = (LPCRYPTBLOCK)sqlite3pager_get_codecarg(p); if (ppKey) *ppKey = 0; if (pnKeyLen && pBlock) *pnKeyLen = 1; } // We do not attach this key to the temp store, only the main database. | | | > > > | 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 | LPCRYPTBLOCK pBlock = (LPCRYPTBLOCK)sqlite3pager_get_codecarg(p); if (ppKey) *ppKey = 0; if (pnKeyLen && pBlock) *pnKeyLen = 1; } // We do not attach this key to the temp store, only the main database. int sqlite3_key(sqlite3 *db, const void *pKey, int nKeySize) { return sqlite3CodecAttach(db, 0, pKey, nKeySize); } // Changes the encryption key for an existing database. int sqlite3_rekey(sqlite3 *db, const void *pKey, int nKeySize) { Btree *pbt = db->aDb[0].pBt; Pager *p = sqlite3BtreePager(pbt); LPCRYPTBLOCK pBlock = (LPCRYPTBLOCK)sqlite3pager_get_codecarg(p); HCRYPTKEY hKey = DeriveKey(pKey, nKeySize); int rc = SQLITE_ERROR; if (hKey == MAXDWORD) { sqlite3Error(db, rc, SQLITECRYPTERROR_PROVIDER); return rc; } if (!pBlock && !hKey) return SQLITE_OK; // Wasn't encrypted to begin with // To rekey a database, we change the writekey for the pager. The readkey remains // the same if (!pBlock) // Encrypt an unencrypted database { pBlock = CreateCryptBlock(hKey, p, NULL); if (!pBlock) return SQLITE_NOMEM; pBlock->hReadKey = 0; // Original database is not encrypted sqlite3PagerSetCodec(sqlite3BtreePager(pbt), sqlite3Codec, pBlock); db->aDb[0].pAux = pBlock; db->aDb[0].xFreeAux = DestroyCryptBlock; } else // Change the writekey for an already-encrypted database { |
︙ | ︙ | |||
380 381 382 383 384 385 386 | db->aDb[0].xFreeAux = NULL; DestroyCryptBlock(pBlock); } return rc; } | < < < < < < < < < < | 394 395 396 397 398 399 400 401 402 403 | db->aDb[0].xFreeAux = NULL; DestroyCryptBlock(pBlock); } return rc; } #endif // SQLITE_HAS_CODEC #endif // SQLITE_OMIT_DISKIO |
Added SQLite.Interop/extension-functions.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 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 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 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 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 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 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 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 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 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 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 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 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 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 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 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 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 | /* This library will provide common mathematical and string functions in SQL queries using the operating system math library. It includes the following functions: Math: acos, asin, atan, atn2, atan2, acosh, asinh, atanh, difference, degrees, radians, cos, sin, tan, cot, cosh, sinh, tanh, coth, exp, log, log10, power, sign, sqrt, square, ceil, floor, pi. String: replicate, charindex, leftstr, rightstr, ltrim, rtrim, trim, replace, reverse, proper, padl, padr, padc, strfilter. Aggregate: stdev, variance, mode, median, lower_quartile, upper_quartile. The string functions ltrim, rtrim, trim, replace are included in recent versions of SQLite and so by default do not build. Instructions: 1) Compile with Linux: gcc -fPIC -lm -shared extension-functions.c -o libsqlitefunctions.so Mac OS X: gcc -fno-common -dynamiclib extension-functions.c -o libsqlitefunctions.dylib (You may need to add flags -I /opt/local/include/ -L/opt/local/lib -lsqlite3 if your sqlite3 is installed from Mac ports, or -I /sw/include/ -L/sw/lib -lsqlite3 if installed with Fink.) 2) In your application, call sqlite3_enable_load_extension(db,1) to allow loading external libraries. Then load the library libsqlitefunctions using sqlite3_load_extension; the third argument should be 0. See http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions. 3) Use, for example: SELECT cos(radians(inclination)) FROM satsum WHERE satnum = 25544; Note: Loading extensions is by default prohibited as a security measure; see "Security Considerations" in http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions. If the sqlite3 program and library are built this way, you cannot use these functions from the program, you must write your own program using the sqlite3 API, and call sqlite3_enable_load_extension as described above. If the program is built so that loading extensions is permitted, the following will work: sqlite> SELECT load_extension('./libsqlitefunctions.so'); sqlite> select cos(radians(45)); 0.707106781186548 Alterations: The instructions are for Linux or Mac OS X; users of other OSes may need to modify this procedure. In particular, if your math library lacks one or more of the needed trig or log functions, comment out the appropriate HAVE_ #define at the top of file. If you do not wish to make a loadable module, comment out the define for COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE. If you are using a version of SQLite without the trim functions and replace, comment out the HAVE_TRIM #define. Liam Healy History: 2008-06-13 Change to instructions to indicate use of the math library and that program might work. 2007-10-01 Minor clarification to instructions. 2007-09-29 Compilation as loadable module is optional with COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE. 2007-09-28 Use sqlite3_extension_init and macros SQLITE_EXTENSION_INIT1, SQLITE_EXTENSION_INIT2, so that it works with sqlite3_load_extension. Thanks to Eric Higashino and Joe Wilson. New instructions for Mac compilation. 2007-09-17 With help from Joe Wilson and Nuno Luca, made use of external interfaces so that compilation is no longer dependent on SQLite source code. Merged source, header, and README into a single file. Added casts so that Mac will compile without warnings (unsigned and signed char). 2007-09-05 Included some definitions from sqlite 3.3.13 so that this will continue to work in newer versions of sqlite. Completed description of functions available. 2007-03-27 Revised description. 2007-03-23 Small cleanup and a bug fix on the code. This was mainly letting errno flag errors encountered in the math library and checking the result, rather than pre-checking. This fixes a bug in power that would cause an error if any non-positive number was raised to any power. 2007-02-07 posted by Mikey C to sqlite mailing list. Original code 2006 June 05 by relicoder. */ //#include "config.h" #include <windows.h> // #define COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE //#define HAVE_ACOSH 1 //#define HAVE_ASINH 1 //#define HAVE_ATANH 1 #define HAVE_SINH 1 #define HAVE_COSH 1 #define HAVE_TANH 1 #define HAVE_LOG10 1 //#define HAVE_ISBLANK 1 #define SQLITE_SOUNDEX 1 #define HAVE_TRIM 1 /* LMH 2007-03-25 if sqlite has trim functions */ #ifdef COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 #else #include "src/sqlite3.h" #endif #include <ctype.h> /* relicoder */ #include <math.h> #include <string.h> #include <stdio.h> #ifndef _WIN32_WCE #include <errno.h> /* LMH 2007-03-25 */ #else int errno; #define strerror(x) "" #endif #include <stdlib.h> #include <assert.h> #ifndef _MAP_H_ #define _MAP_H_ //#include <stdint.h> typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed int int16_t; typedef unsigned int uint16_t; typedef signed long int int32_t; typedef unsigned long int uint32_t; typedef signed long long int int64_t; typedef unsigned long long int uint64_t; /* ** Simple binary tree implementation to use in median, mode and quartile calculations ** Tree is not necessarily balanced. That would require something like red&black trees of AVL */ typedef int(*cmp_func)(const void *, const void *); typedef void(*map_iterator)(void*, int64_t, void*); typedef struct node{ struct node *l; struct node *r; void* data; int64_t count; } node; typedef struct map{ node *base; cmp_func cmp; short free; } map; /* ** creates a map given a comparison function */ map map_make(cmp_func cmp); /* ** inserts the element e into map m */ void map_insert(map *m, void *e); /* ** executes function iter over all elements in the map, in key increasing order */ void map_iterate(map *m, map_iterator iter, void* p); /* ** frees all memory used by a map */ void map_destroy(map *m); /* ** compares 2 integers ** to use with map_make */ int int_cmp(const void *a, const void *b); /* ** compares 2 doubles ** to use with map_make */ int double_cmp(const void *a, const void *b); #endif /* _MAP_H_ */ typedef uint8_t u8; //typedef uint16_t u16; typedef int64_t i64; static char *sqlite3StrDup( const char *z ) { char *res = sqlite3_malloc( strlen(z)+1 ); return strcpy( res, z ); } /* ** These are copied verbatim from fun.c so as to not have the names exported */ /* LMH from sqlite3 3.3.13 */ /* ** This table maps from the first byte of a UTF-8 character to the number ** of trailing bytes expected. A value '4' indicates that the table key ** is not a legal first byte for a UTF-8 character. */ static const u8 xtra_utf8_bytes[256] = { /* 0xxxxxxx */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10wwwwww */ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, /* 110yyyyy */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 1110zzzz */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 11110yyy */ 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, }; /* ** This table maps from the number of trailing bytes in a UTF-8 character ** to an integer constant that is effectively calculated for each character ** read by a naive implementation of a UTF-8 character reader. The code ** in the READ_UTF8 macro explains things best. */ static const int xtra_utf8_bits[] = { 0, 12416, /* (0xC0 << 6) + (0x80) */ 925824, /* (0xE0 << 12) + (0x80 << 6) + (0x80) */ 63447168 /* (0xF0 << 18) + (0x80 << 12) + (0x80 << 6) + 0x80 */ }; /* ** If a UTF-8 character contains N bytes extra bytes (N bytes follow ** the initial byte so that the total character length is N+1) then ** masking the character with utf8_mask[N] must produce a non-zero ** result. Otherwise, we have an (illegal) overlong encoding. */ static const int utf_mask[] = { 0x00000000, 0xffffff80, 0xfffff800, 0xffff0000, }; /* LMH salvaged from sqlite3 3.3.13 source code src/utf.c */ #define OLD_READ_UTF8(zIn, c) { \ int xtra; \ c = *(zIn)++; \ xtra = xtra_utf8_bytes[c]; \ switch( xtra ){ \ case 4: c = (int)0xFFFD; break; \ case 3: c = (c<<6) + *(zIn)++; \ case 2: c = (c<<6) + *(zIn)++; \ case 1: c = (c<<6) + *(zIn)++; \ c -= xtra_utf8_bits[xtra]; \ if( (utf_mask[xtra]&c)==0 \ || (c&0xFFFFF800)==0xD800 \ || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \ } \ } static int sqlite3ReadUtf8(const unsigned char *z){ int c; OLD_READ_UTF8(z, c); return c; } #define SKIP_UTF8(zIn) { \ zIn += (xtra_utf8_bytes[*(u8 *)zIn] + 1); \ } /* ** X is a pointer to the first byte of a UTF-8 character. Increment ** X so that it points to the next character. This only works right ** if X points to a well-formed UTF-8 string. */ #define sqliteNextChar(X) while( (0xc0&*++(X))==0x80 ){} #define sqliteCharVal(X) sqlite3ReadUtf8(X) /* ** This is a macro that facilitates writting wrappers for math.h functions ** it creates code for a function to use in SQlite that gets one numeric input ** and returns a floating point value. ** ** Could have been implemented using pointers to functions but this way it's inline ** and thus more efficient. Lower * ranking though... ** ** Parameters: ** name: function name to de defined (eg: sinFunc) ** function: function defined in math.h to wrap (eg: sin) ** domain: boolean condition that CAN'T happen in terms of the input parameter rVal ** (eg: rval<0 for sqrt) */ /* LMH 2007-03-25 Changed to use errno and remove domain; no pre-checking for errors. */ #define GEN_MATH_WRAP_DOUBLE_1(name, function) \ static void name(sqlite3_context *context, int argc, sqlite3_value **argv){\ double rVal = 0.0, val;\ assert( argc==1 );\ switch( sqlite3_value_type(argv[0]) ){\ case SQLITE_NULL: {\ sqlite3_result_null(context);\ break;\ }\ default: {\ rVal = sqlite3_value_double(argv[0]);\ errno = 0;\ val = function(rVal);\ if (errno == 0) {\ sqlite3_result_double(context, val);\ } else {\ sqlite3_result_error(context, strerror(errno), errno);\ }\ break;\ }\ }\ }\ /* ** Example of GEN_MATH_WRAP_DOUBLE_1 usage ** this creates function sqrtFunc to wrap the math.h standard function sqrt(x)=x^0.5 */ GEN_MATH_WRAP_DOUBLE_1(sqrtFunc, sqrt) /* trignometric functions */ GEN_MATH_WRAP_DOUBLE_1(acosFunc, acos) GEN_MATH_WRAP_DOUBLE_1(asinFunc, asin) GEN_MATH_WRAP_DOUBLE_1(atanFunc, atan) /* ** Many of systems don't have inverse hyperbolic trig functions so this will emulate ** them on those systems in terms of log and sqrt (formulas are too trivial to demand ** written proof here) */ #ifndef HAVE_ACOSH static double acosh(double x){ return log(x + sqrt(x*x - 1.0)); } #endif GEN_MATH_WRAP_DOUBLE_1(acoshFunc, acosh) #ifndef HAVE_ASINH static double asinh(double x){ return log(x + sqrt(x*x + 1.0)); } #endif GEN_MATH_WRAP_DOUBLE_1(asinhFunc, asinh) #ifndef HAVE_ATANH static double atanh(double x){ return (1.0/2.0)*log((1+x)/(1-x)) ; } #endif GEN_MATH_WRAP_DOUBLE_1(atanhFunc, atanh) /* ** math.h doesn't require cot (cotangent) so it's defined here */ static double cot(double x){ return 1.0/tan(x); } GEN_MATH_WRAP_DOUBLE_1(sinFunc, sin) GEN_MATH_WRAP_DOUBLE_1(cosFunc, cos) GEN_MATH_WRAP_DOUBLE_1(tanFunc, tan) GEN_MATH_WRAP_DOUBLE_1(cotFunc, cot) static double coth(double x){ return 1.0/tanh(x); } /* ** Many systems don't have hyperbolic trigonometric functions so this will emulate ** them on those systems directly from the definition in terms of exp */ #ifndef HAVE_SINH static double sinh(double x){ return (exp(x)-exp(-x))/2.0; } #endif GEN_MATH_WRAP_DOUBLE_1(sinhFunc, sinh) #ifndef HAVE_COSH static double cosh(double x){ return (exp(x)+exp(-x))/2.0; } #endif GEN_MATH_WRAP_DOUBLE_1(coshFunc, cosh) #ifndef HAVE_TANH static double tanh(double x){ return sinh(x)/cosh(x); } #endif GEN_MATH_WRAP_DOUBLE_1(tanhFunc, tanh) GEN_MATH_WRAP_DOUBLE_1(cothFunc, coth) /* ** Some systems lack log in base 10. This will emulate it */ #ifndef HAVE_LOG10 static double log10(double x){ static double l10 = -1.0; if( l10<0.0 ){ l10 = log(10.0); } return log(x)/l10; } #endif GEN_MATH_WRAP_DOUBLE_1(logFunc, log) GEN_MATH_WRAP_DOUBLE_1(log10Func, log10) GEN_MATH_WRAP_DOUBLE_1(expFunc, exp) /* ** Fallback for systems where math.h doesn't define M_PI */ #undef M_PI #ifndef M_PI /* ** static double PI = acos(-1.0); ** #define M_PI (PI) */ #define M_PI 3.14159265358979323846 #endif /* Convert Degrees into Radians */ static double deg2rad(double x){ return x*M_PI/180.0; } /* Convert Radians into Degrees */ static double rad2deg(double x){ return 180.0*x/M_PI; } GEN_MATH_WRAP_DOUBLE_1(rad2degFunc, rad2deg) GEN_MATH_WRAP_DOUBLE_1(deg2radFunc, deg2rad) /* constant function that returns the value of PI=3.1415... */ static void piFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ sqlite3_result_double(context, M_PI); } /* ** Implements the sqrt function, it has the peculiarity of returning an integer when the ** the argument is an integer. ** Since SQLite isn't strongly typed (almost untyped actually) this is a bit pedantic */ static void squareFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ i64 iVal = 0; double rVal = 0.0; assert( argc==2 ); switch( sqlite3_value_type(argv[0]) ){ case SQLITE_INTEGER: { iVal = sqlite3_value_int64(argv[0]); sqlite3_result_int64(context, iVal*iVal); break; } case SQLITE_NULL: { sqlite3_result_null(context); break; } default: { rVal = sqlite3_value_double(argv[0]); sqlite3_result_double(context, rVal*rVal); break; } } } /* ** Wraps the pow math.h function ** When both the base and the exponent are integers the result should be integer ** (see sqrt just before this). Here the result is always double */ /* LMH 2007-03-25 Changed to use errno; no pre-checking for errors. Also removes but that was present in the pre-checking that called sqlite3_result_error on a non-positive first argument, which is not always an error. */ static void powerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ double r1 = 0.0; double r2 = 0.0; double val; assert( argc==2 ); if( sqlite3_value_type(argv[0]) == SQLITE_NULL || sqlite3_value_type(argv[1]) == SQLITE_NULL ){ sqlite3_result_null(context); }else{ r1 = sqlite3_value_double(argv[0]); r2 = sqlite3_value_double(argv[1]); errno = 0; val = pow(r1,r2); if (errno == 0) { sqlite3_result_double(context, val); } else { sqlite3_result_error(context, strerror(errno), errno); } } } /* ** atan2 wrapper */ static void atn2Func(sqlite3_context *context, int argc, sqlite3_value **argv){ double r1 = 0.0; double r2 = 0.0; assert( argc==2 ); if( sqlite3_value_type(argv[0]) == SQLITE_NULL || sqlite3_value_type(argv[1]) == SQLITE_NULL ){ sqlite3_result_null(context); }else{ r1 = sqlite3_value_double(argv[0]); r2 = sqlite3_value_double(argv[1]); sqlite3_result_double(context, atan2(r1,r2)); } } /* ** Implementation of the sign() function ** return one of 3 possibilities +1,0 or -1 when the argument is respectively ** positive, 0 or negative. ** When the argument is NULL the result is also NULL (completly conventional) */ static void signFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ double rVal=0.0; i64 iVal=0; assert( argc==1 ); switch( sqlite3_value_type(argv[0]) ){ case SQLITE_INTEGER: { iVal = sqlite3_value_int64(argv[0]); iVal = ( iVal > 0) ? 1: ( iVal < 0 ) ? -1: 0; sqlite3_result_int64(context, iVal); break; } case SQLITE_NULL: { sqlite3_result_null(context); break; } default: { /* 2nd change below. Line for abs was: if( rVal<0 ) rVal = rVal * -1.0; */ rVal = sqlite3_value_double(argv[0]); rVal = ( rVal > 0) ? 1: ( rVal < 0 ) ? -1: 0; sqlite3_result_double(context, rVal); break; } } } /* ** smallest integer value not less than argument */ static void ceilFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ double rVal=0.0; i64 iVal=0; assert( argc==1 ); switch( sqlite3_value_type(argv[0]) ){ case SQLITE_INTEGER: { i64 iVal = sqlite3_value_int64(argv[0]); sqlite3_result_int64(context, iVal); break; } case SQLITE_NULL: { sqlite3_result_null(context); break; } default: { rVal = sqlite3_value_double(argv[0]); sqlite3_result_int64(context, (i64) ceil(rVal)); break; } } } /* ** largest integer value not greater than argument */ static void floorFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ double rVal=0.0; i64 iVal=0; assert( argc==1 ); switch( sqlite3_value_type(argv[0]) ){ case SQLITE_INTEGER: { i64 iVal = sqlite3_value_int64(argv[0]); sqlite3_result_int64(context, iVal); break; } case SQLITE_NULL: { sqlite3_result_null(context); break; } default: { rVal = sqlite3_value_double(argv[0]); sqlite3_result_int64(context, (i64) floor(rVal)); break; } } } /* ** Given a string (s) in the first argument and an integer (n) in the second returns the ** string that constains s contatenated n times */ static void replicateFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ unsigned char *z; /* input string */ unsigned char *zo; /* result string */ i64 iCount; /* times to repeat */ i64 nLen; /* length of the input string (no multibyte considerations) */ i64 nTLen; /* length of the result string (no multibyte considerations) */ i64 i=0; if( argc!=2 || SQLITE_NULL==sqlite3_value_type(argv[0]) ) return; iCount = sqlite3_value_int64(argv[1]); if( iCount<0 ){ sqlite3_result_error(context, "domain error", -1); }else{ nLen = sqlite3_value_bytes(argv[0]); nTLen = nLen*iCount; z=sqlite3_malloc(nTLen+1); zo=sqlite3_malloc(nLen+1); if (!z || !zo){ sqlite3_result_error_nomem(context); if (z) sqlite3_free(z); if (zo) sqlite3_free(zo); return; } strcpy((char*)zo, (char*)sqlite3_value_text(argv[0])); for(i=0; i<iCount; ++i){ strcpy((char*)(z+i*nLen), (char*)zo); } sqlite3_result_text(context, (char*)z, -1, SQLITE_TRANSIENT); sqlite3_free(z); sqlite3_free(zo); } } /* ** Some systems (win32 among others) don't have an isblank function, this will emulate it. ** This function is not UFT-8 safe since it only analyses a byte character. */ #ifndef HAVE_ISBLANK int isblank(char c){ return( ' '==c || '\t'==c ); } #endif static void properFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ const unsigned char *z; /* input string */ unsigned char *zo; /* output string */ unsigned char *zt; /* iterator */ char r; int c=1; assert( argc!=1); if( SQLITE_NULL==sqlite3_value_type(argv[0]) ){ sqlite3_result_null(context); return; } z = sqlite3_value_text(argv[0]); zo = (unsigned char *)sqlite3StrDup((char *) z); if (!zo) { sqlite3_result_error_nomem(context); return; } zt = zo; while( (r = *(z++))!=0 ){ if( isblank(r) ){ c=1; }else{ if( c==1 ){ r = toupper(r); }else{ r = tolower(r); } c=0; } *(zt++) = r; } *zt = '\0'; sqlite3_result_text(context, (char*)zo, -1, SQLITE_TRANSIENT); sqlite3_free(zo); } /* ** given an input string (s) and an integer (n) adds spaces at the begining of s ** until it has a length of n characters. ** When s has a length >=n it's a NOP ** padl(NULL) = NULL */ static void padlFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ i64 ilen; /* length to pad to */ i64 zl; /* length of the input string (UTF-8 chars) */ int i = 0; const char *zi; /* input string */ char *zo; /* output string */ char *zt; assert( argc==2 ); if( sqlite3_value_type(argv[0]) == SQLITE_NULL ){ sqlite3_result_null(context); }else{ zi = (char *)sqlite3_value_text(argv[0]); ilen = sqlite3_value_int64(argv[1]); /* check domain */ if(ilen<0){ sqlite3_result_error(context, "domain error", -1); return; } zl = sqlite3Utf8CharLen(zi, -1); if( zl>=ilen ){ /* string is longer than the requested pad length, return the same string (dup it) */ zo = sqlite3StrDup(zi); if (!zo){ sqlite3_result_error_nomem(context); return; } sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT); }else{ zo = sqlite3_malloc(strlen(zi)+ilen-zl+1); if (!zo){ sqlite3_result_error_nomem(context); return; } zt = zo; for(i=1; i+zl<=ilen; ++i){ *(zt++)=' '; } /* no need to take UTF-8 into consideration here */ strcpy(zt,zi); } sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT); sqlite3_free(zo); } } /* ** given an input string (s) and an integer (n) appends spaces at the end of s ** until it has a length of n characters. ** When s has a length >=n it's a NOP ** padl(NULL) = NULL */ static void padrFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ i64 ilen; /* length to pad to */ i64 zl; /* length of the input string (UTF-8 chars) */ i64 zll; /* length of the input string (bytes) */ int i = 0; const char *zi; /* input string */ char *zo; /* output string */ char *zt; assert( argc==2 ); if( sqlite3_value_type(argv[0]) == SQLITE_NULL ){ sqlite3_result_null(context); }else{ zi = (char *)sqlite3_value_text(argv[0]); ilen = sqlite3_value_int64(argv[1]); /* check domain */ if(ilen<0){ sqlite3_result_error(context, "domain error", -1); return; } zl = sqlite3Utf8CharLen(zi, -1); if( zl>=ilen ){ /* string is longer than the requested pad length, return the same string (dup it) */ zo = sqlite3StrDup(zi); if (!zo){ sqlite3_result_error_nomem(context); return; } sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT); }else{ zll = strlen(zi); zo = sqlite3_malloc(zll+ilen-zl+1); if (!zo){ sqlite3_result_error_nomem(context); return; } zt = strcpy(zo,zi)+zll; for(i=1; i+zl<=ilen; ++i){ *(zt++) = ' '; } *zt = '\0'; } sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT); sqlite3_free(zo); } } /* ** given an input string (s) and an integer (n) appends spaces at the end of s ** and adds spaces at the begining of s until it has a length of n characters. ** Tries to add has many characters at the left as at the right. ** When s has a length >=n it's a NOP ** padl(NULL) = NULL */ static void padcFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ i64 ilen; /* length to pad to */ i64 zl; /* length of the input string (UTF-8 chars) */ i64 zll; /* length of the input string (bytes) */ int i = 0; const char *zi; /* input string */ char *zo; /* output string */ char *zt; assert( argc==2 ); if( sqlite3_value_type(argv[0]) == SQLITE_NULL ){ sqlite3_result_null(context); }else{ zi = (char *)sqlite3_value_text(argv[0]); ilen = sqlite3_value_int64(argv[1]); /* check domain */ if(ilen<0){ sqlite3_result_error(context, "domain error", -1); return; } zl = sqlite3Utf8CharLen(zi, -1); if( zl>=ilen ){ /* string is longer than the requested pad length, return the same string (dup it) */ zo = sqlite3StrDup(zi); if (!zo){ sqlite3_result_error_nomem(context); return; } sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT); }else{ zll = strlen(zi); zo = sqlite3_malloc(zll+ilen-zl+1); if (!zo){ sqlite3_result_error_nomem(context); return; } zt = zo; for(i=1; 2*i+zl<=ilen; ++i){ *(zt++) = ' '; } strcpy(zt, zi); zt+=zll; for(; i+zl<=ilen; ++i){ *(zt++) = ' '; } *zt = '\0'; } sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT); sqlite3_free(zo); } } /* ** given 2 string (s1,s2) returns the string s1 with the characters NOT in s2 removed ** assumes strings are UTF-8 encoded */ static void strfilterFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ const char *zi1; /* first parameter string (searched string) */ const char *zi2; /* second parameter string (vcontains valid characters) */ const char *z1; const char *z21; const char *z22; char *zo; /* output string */ char *zot; int c1 = 0; int c2 = 0; assert( argc==2 ); if( sqlite3_value_type(argv[0]) == SQLITE_NULL || sqlite3_value_type(argv[1]) == SQLITE_NULL ){ sqlite3_result_null(context); }else{ zi1 = (char *)sqlite3_value_text(argv[0]); zi2 = (char *)sqlite3_value_text(argv[1]); /* ** maybe I could allocate less, but that would imply 2 passes, rather waste ** (possibly) some memory */ zo = sqlite3_malloc(strlen(zi1)+1); if (!zo){ sqlite3_result_error_nomem(context); return; } zot = zo; z1 = zi1; while( (c1=sqliteCharVal((unsigned char *)z1))!=0 ){ z21=zi2; while( (c2=sqliteCharVal((unsigned char *)z21))!=0 && c2!=c1 ){ sqliteNextChar(z21); } if( c2!=0){ z22=z21; sqliteNextChar(z22); strncpy(zot, z21, z22-z21); zot+=z22-z21; } sqliteNextChar(z1); } *zot = '\0'; sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT); sqlite3_free(zo); } } /* ** Given a string z1, retutns the (0 based) index of it's first occurence ** in z2 after the first s characters. ** Returns -1 when there isn't a match. ** updates p to point to the character where the match occured. ** This is an auxiliary function. */ static int _substr(const char* z1, const char* z2, int s, CollSeq *pColl, const char** p){ int c = 0; int rVal=-1; const char* zt1; const char* zt2; int c1,c2; if( '\0'==*z1 ){ return -1; } while( (sqliteCharVal((unsigned char *)z2) != 0) && (c++)<s){ sqliteNextChar(z2); } c = 0; while( (sqliteCharVal((unsigned char *)z2)) != 0 ){ zt1 = z1; zt2 = z2; do{ c1 = sqliteCharVal((unsigned char *)zt1); c2 = sqliteCharVal((unsigned char *)zt2); if (pColl->enc == SQLITE_UTF8){ if (pColl->xCmp(pColl->pUser, 1, zt1, 1, zt2) == 0) { c1 = c2; } else { c1 = (c1) ? 1 : 0; c2 = (c2) ? 2 : 0; } } // TODO: Maybe try and convert the chars to UTF16 and run them thru the collating sequence? sqliteNextChar(zt1); sqliteNextChar(zt2); }while( c1 == c2 && c1 != 0 && c2 != 0 ); if( c1 == 0 ){ rVal = c; break; } sqliteNextChar(z2); ++c; } if(p){ *p=z2; } return rVal >=0 ? rVal+s : rVal; } /* ** given 2 input strings (s1,s2) and an integer (n) searches from the nth character ** for the string s1. Returns the position where the match occured. ** Characters are counted from 1. ** 0 is returned when no match occurs. */ static void charindexFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ const u8 *z1; /* s1 string */ u8 *z2; /* s2 string */ int s=0; int rVal=0; CollSeq *pColl = context->pColl; assert( argc==3 ||argc==2); if( SQLITE_NULL==sqlite3_value_type(argv[0]) || SQLITE_NULL==sqlite3_value_type(argv[1])){ sqlite3_result_null(context); return; } z1 = sqlite3_value_text(argv[0]); if( z1==0 ) return; z2 = (u8*) sqlite3_value_text(argv[1]); if(argc==3){ s = sqlite3_value_int(argv[2])-1; if(s<0){ s=0; } }else{ s = 0; } rVal = _substr((char *)z1,(char *)z2,s,pColl,NULL); sqlite3_result_int(context, rVal+1); } /* ** given a string (s) and an integer (n) returns the n leftmost (UTF-8) characters ** if the string has a length<=n or is NULL this function is NOP */ static void leftFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ int c=0; int cc=0; int l=0; const unsigned char *z; /* input string */ const unsigned char *zt; unsigned char *rz; /* output string */ assert( argc==2); if( SQLITE_NULL==sqlite3_value_type(argv[0]) || SQLITE_NULL==sqlite3_value_type(argv[1])){ sqlite3_result_null(context); return; } z = sqlite3_value_text(argv[0]); l = sqlite3_value_int(argv[1]); zt = z; while( sqliteCharVal(zt) && c++<l) sqliteNextChar(zt); cc=zt-z; rz = sqlite3_malloc(zt-z+1); if (!rz){ sqlite3_result_error_nomem(context); return; } strncpy((char*) rz, (char*) z, zt-z); *(rz+cc) = '\0'; sqlite3_result_text(context, (char*)rz, -1, SQLITE_TRANSIENT); sqlite3_free(rz); } /* ** given a string (s) and an integer (n) returns the n rightmost (UTF-8) characters ** if the string has a length<=n or is NULL this function is NOP */ static void rightFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ int l=0; int c=0; int cc=0; const char *z; const char *zt; const char *ze; char *rz; assert( argc==2); if( SQLITE_NULL == sqlite3_value_type(argv[0]) || SQLITE_NULL == sqlite3_value_type(argv[1])){ sqlite3_result_null(context); return; } z = (char *)sqlite3_value_text(argv[0]); l = sqlite3_value_int(argv[1]); zt = z; while( sqliteCharVal((unsigned char *)zt)!=0){ sqliteNextChar(zt); ++c; } ze = zt; zt = z; cc=c-l; if(cc<0) cc=0; while( cc-- > 0 ){ sqliteNextChar(zt); } rz = sqlite3_malloc(ze-zt+1); if (!rz){ sqlite3_result_error_nomem(context); return; } strcpy((char*) rz, (char*) (zt)); sqlite3_result_text(context, (char*)rz, -1, SQLITE_TRANSIENT); sqlite3_free(rz); } #ifndef HAVE_TRIM /* ** removes the whitespaces at the begining of a string. */ const char* ltrim(const char* s){ while( *s==' ' ) ++s; return s; } /* ** removes the whitespaces at the end of a string. ** !mutates the input string! */ void rtrim(char* s){ char* ss = s+strlen(s)-1; while( ss>=s && *ss==' ' ) --ss; *(ss+1)='\0'; } /* ** Removes the whitespace at the begining of a string */ static void ltrimFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ const char *z; assert( argc==1); if( SQLITE_NULL==sqlite3_value_type(argv[0]) ){ sqlite3_result_null(context); return; } z = sqlite3_value_text(argv[0]); sqlite3_result_text(context, ltrim(z), -1, SQLITE_TRANSIENT); } /* ** Removes the whitespace at the end of a string */ static void rtrimFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ const char *z; char *rz; /* try not to change data in argv */ assert( argc==1); if( SQLITE_NULL==sqlite3_value_type(argv[0]) ){ sqlite3_result_null(context); return; } z = sqlite3_value_text(argv[0]); rz = sqlite3StrDup(z); rtrim(rz); sqlite3_result_text(context, rz, -1, SQLITE_TRANSIENT); sqlite3_free(rz); } /* ** Removes the whitespace at the begining and end of a string */ static void trimFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ const char *z; char *rz; /* try not to change data in argv */ assert( argc==1); if( SQLITE_NULL==sqlite3_value_type(argv[0]) ){ sqlite3_result_null(context); return; } z = sqlite3_value_text(argv[0]); rz = sqlite3StrDup(z); rtrim(rz); sqlite3_result_text(context, ltrim(rz), -1, SQLITE_TRANSIENT); sqlite3_free(rz); } #endif /* ** given a pointer to a string s1, the length of that string (l1), a new string (s2) ** and it's length (l2) appends s2 to s1. ** All lengths in bytes. ** This is just an auxiliary function */ // static void _append(char **s1, int l1, const char *s2, int l2){ // *s1 = realloc(*s1, (l1+l2+1)*sizeof(char)); // strncpy((*s1)+l1, s2, l2); // *(*(s1)+l1+l2) = '\0'; // } #ifndef HAVE_TRIM /* ** given strings s, s1 and s2 replaces occurrences of s1 in s by s2 */ static void replaceFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ const char *z1; /* string s (first parameter) */ const char *z2; /* string s1 (second parameter) string to look for */ const char *z3; /* string s2 (third parameter) string to replace occurrences of s1 with */ int lz1; int lz2; int lz3; int lzo=0; char *zo=0; int ret=0; const char *zt1; const char *zt2; assert( 3==argc ); if( SQLITE_NULL==sqlite3_value_type(argv[0]) ){ sqlite3_result_null(context); return; } z1 = sqlite3_value_text(argv[0]); z2 = sqlite3_value_text(argv[1]); z3 = sqlite3_value_text(argv[2]); /* handle possible null values */ if( 0==z2 ){ z2=""; } if( 0==z3 ){ z3=""; } lz1 = strlen(z1); lz2 = strlen(z2); lz3 = strlen(z3); #if 0 /* special case when z2 is empty (or null) nothing will be changed */ if( 0==lz2 ){ sqlite3_result_text(context, z1, -1, SQLITE_TRANSIENT); return; } #endif zt1=z1; zt2=z1; while(1){ ret=_substr(z2,zt1 , 0, &zt2); if( ret<0 ) break; _append(&zo, lzo, zt1, zt2-zt1); lzo+=zt2-zt1; _append(&zo, lzo, z3, lz3); lzo+=lz3; zt1=zt2+lz2; } _append(&zo, lzo, zt1, lz1-(zt1-z1)); sqlite3_result_text(context, zo, -1, SQLITE_TRANSIENT); sqlite3_free(zo); } #endif /* ** given a string returns the same string but with the characters in reverse order */ static void reverseFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ const char *z; const char *zt; char *rz; char *rzt; int l = 0; int i = 0; assert( 1==argc ); if( SQLITE_NULL==sqlite3_value_type(argv[0]) ){ sqlite3_result_null(context); return; } z = (char *)sqlite3_value_text(argv[0]); l = strlen(z); rz = sqlite3_malloc(l+1); if (!rz){ sqlite3_result_error_nomem(context); return; } rzt = rz+l; *(rzt--) = '\0'; zt=z; while( sqliteCharVal((unsigned char *)zt)!=0 ){ z=zt; sqliteNextChar(zt); for(i=1; zt-i>=z; ++i){ *(rzt--)=*(zt-i); } } sqlite3_result_text(context, rz, -1, SQLITE_TRANSIENT); sqlite3_free(rz); } /* ** An instance of the following structure holds the context of a ** stdev() or variance() aggregate computation. ** implementaion of http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Algorithm_II ** less prone to rounding errors */ typedef struct StdevCtx StdevCtx; struct StdevCtx { double rM; double rS; i64 cnt; /* number of elements */ }; /* ** An instance of the following structure holds the context of a ** mode() or median() aggregate computation. ** Depends on structures defined in map.c (see map & map) ** These aggregate functions only work for integers and floats although ** they could be made to work for strings. This is usually considered meaningless. ** Only usuall order (for median), no use of collation functions (would this even make sense?) */ typedef struct ModeCtx ModeCtx; struct ModeCtx { i64 riM; /* integer value found so far */ double rdM; /* double value found so far */ i64 cnt; /* number of elements so far */ double pcnt; /* number of elements smaller than a percentile */ i64 mcnt; /* maximum number of occurrences (for mode) */ i64 mn; /* number of occurrences (for mode and percentiles) */ i64 is_double; /* whether the computation is being done for doubles (>0) or integers (=0) */ map* m; /* map structure used for the computation */ int done; /* whether the answer has been found */ }; /* ** called for each value received during a calculation of stdev or variance */ static void varianceStep(sqlite3_context *context, int argc, sqlite3_value **argv){ StdevCtx *p; double delta; double x; assert( argc==1 ); p = sqlite3_aggregate_context(context, sizeof(*p)); /* only consider non-null values */ if( SQLITE_NULL != sqlite3_value_numeric_type(argv[0]) ){ p->cnt++; x = sqlite3_value_double(argv[0]); delta = (x-p->rM); p->rM += delta/p->cnt; p->rS += delta*(x-p->rM); } } /* ** called for each value received during a calculation of mode of median */ static void modeStep(sqlite3_context *context, int argc, sqlite3_value **argv){ ModeCtx *p; i64 xi=0; double xd=0.0; i64 *iptr; double *dptr; int type; assert( argc==1 ); type = sqlite3_value_numeric_type(argv[0]); if( type == SQLITE_NULL) return; p = sqlite3_aggregate_context(context, sizeof(*p)); if( 0==(p->m) ){ p->m = calloc(1, sizeof(map)); if( type==SQLITE_INTEGER ){ /* map will be used for integers */ *(p->m) = map_make(int_cmp); p->is_double = 0; }else{ p->is_double = 1; /* map will be used for doubles */ *(p->m) = map_make(double_cmp); } } ++(p->cnt); if( 0==p->is_double ){ xi = sqlite3_value_int64(argv[0]); iptr = (i64*)calloc(1,sizeof(i64)); *iptr = xi; map_insert(p->m, iptr); }else{ xd = sqlite3_value_double(argv[0]); dptr = (double*)calloc(1,sizeof(double)); *dptr = xd; map_insert(p->m, dptr); } } /* ** Auxiliary function that iterates all elements in a map and finds the mode ** (most frequent value) */ static void modeIterate(void* e, i64 c, void* pp){ i64 ei; double ed; ModeCtx *p = (ModeCtx*)pp; if( 0==p->is_double ){ ei = *(int*)(e); if( p->mcnt==c ){ ++p->mn; }else if( p->mcnt<c ){ p->riM = ei; p->mcnt = c; p->mn=1; } }else{ ed = *(double*)(e); if( p->mcnt==c ){ ++p->mn; }else if(p->mcnt<c){ p->rdM = ed; p->mcnt = c; p->mn=1; } } } /* ** Auxiliary function that iterates all elements in a map and finds the median ** (the value such that the number of elements smaller is equal the the number of ** elements larger) */ static void medianIterate(void* e, i64 c, void* pp){ i64 ei; double ed; double iL; double iR; int il; int ir; ModeCtx *p = (ModeCtx*)pp; if(p->done>0) return; iL = p->pcnt; iR = p->cnt - p->pcnt; il = p->mcnt + c; ir = p->cnt - p->mcnt; if( il >= iL ){ if( ir >= iR ){ ++p->mn; if( 0==p->is_double ){ ei = *(int*)(e); p->riM += ei; }else{ ed = *(double*)(e); p->rdM += ed; } }else{ p->done=1; } } p->mcnt+=c; } /* ** Returns the mode value */ static void modeFinalize(sqlite3_context *context){ ModeCtx *p; p = sqlite3_aggregate_context(context, 0); if( p && p->m ){ map_iterate(p->m, modeIterate, p); map_destroy(p->m); free(p->m); if( 1==p->mn ){ if( 0==p->is_double ) sqlite3_result_int64(context, p->riM); else sqlite3_result_double(context, p->rdM); } } } /* ** auxiliary function for percentiles */ static void _medianFinalize(sqlite3_context *context){ ModeCtx *p; p = (ModeCtx*) sqlite3_aggregate_context(context, 0); if( p && p->m ){ p->done=0; map_iterate(p->m, medianIterate, p); map_destroy(p->m); free(p->m); if( 0==p->is_double ) if( 1==p->mn ) sqlite3_result_int64(context, p->riM); else sqlite3_result_double(context, p->riM*1.0/p->mn); else sqlite3_result_double(context, p->rdM/p->mn); } } /* ** Returns the median value */ static void medianFinalize(sqlite3_context *context){ ModeCtx *p; p = (ModeCtx*) sqlite3_aggregate_context(context, 0); if( p!=0 ){ p->pcnt = (p->cnt)/2.0; _medianFinalize(context); } } /* ** Returns the lower_quartile value */ static void lower_quartileFinalize(sqlite3_context *context){ ModeCtx *p; p = (ModeCtx*) sqlite3_aggregate_context(context, 0); if( p!=0 ){ p->pcnt = (p->cnt)/4.0; _medianFinalize(context); } } /* ** Returns the upper_quartile value */ static void upper_quartileFinalize(sqlite3_context *context){ ModeCtx *p; p = (ModeCtx*) sqlite3_aggregate_context(context, 0); if( p!=0 ){ p->pcnt = (p->cnt)*3/4.0; _medianFinalize(context); } } /* ** Returns the stdev value */ static void stdevFinalize(sqlite3_context *context){ StdevCtx *p; p = sqlite3_aggregate_context(context, 0); if( p && p->cnt>1 ){ sqlite3_result_double(context, sqrt(p->rS/(p->cnt-1))); }else{ sqlite3_result_double(context, 0.0); } } /* ** Returns the variance value */ static void varianceFinalize(sqlite3_context *context){ StdevCtx *p; p = sqlite3_aggregate_context(context, 0); if( p && p->cnt>1 ){ sqlite3_result_double(context, p->rS/(p->cnt-1)); }else{ sqlite3_result_double(context, 0.0); } } #ifdef SQLITE_SOUNDEX /* relicoder factored code */ /* ** Calculates the soundex value of a string */ static void soundex(const u8 *zIn, char *zResult){ int i, j; static const unsigned char iCode[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0, 1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0, 1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0, }; for(i=0; zIn[i] && !isalpha(zIn[i]); i++){} if( zIn[i] ){ zResult[0] = toupper(zIn[i]); for(j=1; j<4 && zIn[i]; i++){ int code = iCode[zIn[i]&0x7f]; if( code>0 ){ zResult[j++] = code + '0'; } } while( j<4 ){ zResult[j++] = '0'; } zResult[j] = 0; }else{ strcpy(zResult, "?000"); } } /* ** computes the number of different characters between the soundex value fo 2 strings */ static void differenceFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ char zResult1[8]; char zResult2[8]; char *zR1 = zResult1; char *zR2 = zResult2; int rVal = 0; int i = 0; const u8 *zIn1; const u8 *zIn2; assert( argc==2 ); if( sqlite3_value_type(argv[0])==SQLITE_NULL || sqlite3_value_type(argv[1])==SQLITE_NULL ){ sqlite3_result_null(context); return; } zIn1 = (u8*)sqlite3_value_text(argv[0]); zIn2 = (u8*)sqlite3_value_text(argv[1]); soundex(zIn1, zR1); soundex(zIn2, zR2); for(i=0; i<4; ++i){ if( sqliteCharVal((unsigned char *)zR1)==sqliteCharVal((unsigned char *)zR2) ) ++rVal; sqliteNextChar(zR1); sqliteNextChar(zR2); } sqlite3_result_int(context, rVal); } #endif static void lastRowsFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ sqlite3 *db = sqlite3_context_db_handle(context); sqlite3_result_int64(context, sqlite3_changes(db)); } /* ** This function registered all of the above C functions as SQL ** functions. This should be the only routine in this file with ** external linkage. */ int RegisterExtensionFunctions(sqlite3 *db){ static const struct FuncDefs { char *zName; signed char nArg; u8 argType; /* 0: none. 1: db 2: (-1) */ u8 eTextRep; /* 1: UTF-16. 0: UTF-8 */ u8 needCollSeq; void (*xFunc)(sqlite3_context*,int,sqlite3_value **); } aFuncs[] = { /* math.h */ { "acos", 1, 0, SQLITE_UTF8, 0, acosFunc }, { "asin", 1, 0, SQLITE_UTF8, 0, asinFunc }, { "atan", 1, 0, SQLITE_UTF8, 0, atanFunc }, { "atn2", 2, 0, SQLITE_UTF8, 0, atn2Func }, /* XXX alias */ { "atan2", 2, 0, SQLITE_UTF8, 0, atn2Func }, { "acosh", 1, 0, SQLITE_UTF8, 0, acoshFunc }, { "asinh", 1, 0, SQLITE_UTF8, 0, asinhFunc }, { "atanh", 1, 0, SQLITE_UTF8, 0, atanhFunc }, { "difference", 2, 0, SQLITE_UTF8, 0, differenceFunc}, { "degrees", 1, 0, SQLITE_UTF8, 0, rad2degFunc }, { "radians", 1, 0, SQLITE_UTF8, 0, deg2radFunc }, { "cos", 1, 0, SQLITE_UTF8, 0, cosFunc }, { "sin", 1, 0, SQLITE_UTF8, 0, sinFunc }, { "tan", 1, 0, SQLITE_UTF8, 0, tanFunc }, { "cot", 1, 0, SQLITE_UTF8, 0, cotFunc }, { "cosh", 1, 0, SQLITE_UTF8, 0, coshFunc }, { "sinh", 1, 0, SQLITE_UTF8, 0, sinhFunc }, { "tanh", 1, 0, SQLITE_UTF8, 0, tanhFunc }, { "coth", 1, 0, SQLITE_UTF8, 0, cothFunc }, { "exp", 1, 0, SQLITE_UTF8, 0, expFunc }, { "log", 1, 0, SQLITE_UTF8, 0, logFunc }, { "log10", 1, 0, SQLITE_UTF8, 0, log10Func }, { "power", 2, 0, SQLITE_UTF8, 0, powerFunc }, { "sign", 1, 0, SQLITE_UTF8, 0, signFunc }, { "sqrt", 1, 0, SQLITE_UTF8, 0, sqrtFunc }, { "square", 1, 0, SQLITE_UTF8, 0, squareFunc }, { "ceil", 1, 0, SQLITE_UTF8, 0, ceilFunc }, { "ceiling", 1, 0, SQLITE_UTF8, 0, ceilFunc }, { "floor", 1, 0, SQLITE_UTF8, 0, floorFunc }, { "pi", 0, 0, SQLITE_UTF8, 0, piFunc }, { "last_rows_affected", 0, 0, SQLITE_UTF8, 0, lastRowsFunc }, /* string */ { "replicate", 2, 0, SQLITE_UTF8, 0, replicateFunc }, { "charindex", 2, 0, SQLITE_UTF8, 1, charindexFunc }, { "charindex", 3, 0, SQLITE_UTF8, 1, charindexFunc }, { "leftstr", 2, 0, SQLITE_UTF8, 0, leftFunc }, { "rightstr", 2, 0, SQLITE_UTF8, 0, rightFunc }, #ifndef HAVE_TRIM { "ltrim", 1, 0, SQLITE_UTF8, 0, ltrimFunc }, { "rtrim", 1, 0, SQLITE_UTF8, 0, rtrimFunc }, { "trim", 1, 0, SQLITE_UTF8, 0, trimFunc }, { "replace", 3, 0, SQLITE_UTF8, 0, replaceFunc }, #endif { "reverse", 1, 0, SQLITE_UTF8, 0, reverseFunc }, { "proper", 1, 0, SQLITE_UTF8, 0, properFunc }, { "padl", 2, 0, SQLITE_UTF8, 0, padlFunc }, { "padr", 2, 0, SQLITE_UTF8, 0, padrFunc }, { "padc", 2, 0, SQLITE_UTF8, 0, padcFunc }, { "strfilter", 2, 0, SQLITE_UTF8, 0, strfilterFunc }, }; /* Aggregate functions */ static const struct FuncDefAgg { char *zName; signed char nArg; u8 argType; u8 needCollSeq; void (*xStep)(sqlite3_context*,int,sqlite3_value**); void (*xFinalize)(sqlite3_context*); } aAggs[] = { { "stdev", 1, 0, 0, varianceStep, stdevFinalize }, { "variance", 1, 0, 0, varianceStep, varianceFinalize }, { "mode", 1, 0, 0, modeStep, modeFinalize }, { "median", 1, 0, 0, modeStep, medianFinalize }, { "lower_quartile", 1, 0, 0, modeStep, lower_quartileFinalize }, { "upper_quartile", 1, 0, 0, modeStep, upper_quartileFinalize }, }; int i; for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){ void *pArg = 0; switch( aFuncs[i].argType ){ case 1: pArg = db; break; case 2: pArg = (void *)(-1); break; } //sqlite3CreateFunc /* LMH no error checking */ sqlite3_create_function(db, aFuncs[i].zName, aFuncs[i].nArg, aFuncs[i].eTextRep, pArg, aFuncs[i].xFunc, 0, 0); #if 1 if( aFuncs[i].needCollSeq ){ struct FuncDef *pFunc = sqlite3FindFunction(db, aFuncs[i].zName, strlen(aFuncs[i].zName), aFuncs[i].nArg, aFuncs[i].eTextRep, 0); if( pFunc && aFuncs[i].needCollSeq ){ pFunc->needCollSeq = 1; } } #endif } for(i=0; i<sizeof(aAggs)/sizeof(aAggs[0]); i++){ void *pArg = 0; switch( aAggs[i].argType ){ case 1: pArg = db; break; case 2: pArg = (void *)(-1); break; } //sqlite3CreateFunc /* LMH no error checking */ sqlite3_create_function(db, aAggs[i].zName, aAggs[i].nArg, SQLITE_UTF8, pArg, 0, aAggs[i].xStep, aAggs[i].xFinalize); #if 0 if( aAggs[i].needCollSeq ){ struct FuncDefAgg *pFunc = sqlite3FindFunction( db, aAggs[i].zName, strlen(aAggs[i].zName), aAggs[i].nArg, SQLITE_UTF8, 0); if( pFunc && aAggs[i].needCollSeq ){ pFunc->needCollSeq = 1; } } #endif } return 0; } #ifdef COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi){ SQLITE_EXTENSION_INIT2(pApi); RegisterExtensionFunctions(db); return 0; } #endif /* COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE */ map map_make(cmp_func cmp){ map r; r.cmp=cmp; r.base = 0; return r; } void* xcalloc(size_t nmemb, size_t size, char* s){ void* ret = calloc(nmemb, size); return ret; } void xfree(void* p){ free(p); } void node_insert(node** n, cmp_func cmp, void *e){ int c; node* nn; if(*n==0){ nn = (node*)xcalloc(1,sizeof(node), "for node"); nn->data = e; nn->count = 1; *n=nn; }else{ c=cmp((*n)->data,e); if(0==c){ ++((*n)->count); xfree(e); }else if(c>0){ /* put it right here */ node_insert(&((*n)->l), cmp, e); }else{ node_insert(&((*n)->r), cmp, e); } } } void map_insert(map *m, void *e){ node_insert(&(m->base), m->cmp, e); } void node_iterate(node *n, map_iterator iter, void* p){ if(n){ if(n->l) node_iterate(n->l, iter, p); iter(n->data, n->count, p); if(n->r) node_iterate(n->r, iter, p); } } void map_iterate(map *m, map_iterator iter, void* p){ node_iterate(m->base, iter, p); } void node_destroy(node *n){ if(0!=n){ xfree(n->data); if(n->l) node_destroy(n->l); if(n->r) node_destroy(n->r); xfree(n); } } void map_destroy(map *m){ node_destroy(m->base); } int int_cmp(const void *a, const void *b){ int64_t aa = *(int64_t *)(a); int64_t bb = *(int64_t *)(b); /* printf("cmp %d <=> %d\n",aa,bb); */ if(aa==bb) return 0; else if(aa<bb) return -1; else return 1; } int double_cmp(const void *a, const void *b){ double aa = *(double *)(a); double bb = *(double *)(b); /* printf("cmp %d <=> %d\n",aa,bb); */ if(aa==bb) return 0; else if(aa<bb) return -1; else return 1; } void print_elem(void *e, int64_t c, void* p){ int ee = *(int*)(e); printf("%d => %lld\n", ee,c); } |
Changes to SQLite.Interop/interop.c.
1 2 3 4 | #include "src/sqlite3.c" #include "crypt.c" #include <tchar.h> | > > > > > > > > | > > | | | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 | #ifdef NDEBUG #include "src/sqlite3.c" #else #include "splitsource\btreeint.h" #include "splitsource\vdbeint.h" #include "splitsource\sqliteInt.h" #endif #include "extension-functions.c" #include "crypt.c" #include <tchar.h> #ifdef NDEBUG #if _WIN32_WCE #include "merge.h" #else #include "merge_full.h" #endif // _WIN32_WCE #endif // NDEBUG extern int RegisterExtensionFunctions(sqlite3 *db); #ifdef SQLITE_OS_WIN // Additional flag for sqlite3.flags, we use it as a reference counter #define SQLITE_WantClose 0x10000000 // Additional open flags, we use this one privately //#define SQLITE_OPEN_SHAREDCACHE 0x01000000 typedef void (*SQLITEUSERFUNC)(sqlite3_context *, int, sqlite3_value **); typedef void (*SQLITEFUNCFINAL)(sqlite3_context *); typedef HANDLE (WINAPI *CREATEFILEW)( LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE); static CRITICAL_SECTION g_cs; static LONG g_dwcsInit = 0; void EnterGlobalMutex() { if (InterlockedCompareExchange(&g_dwcsInit, 1, 0) == 0) InitializeCriticalSection(&g_cs); EnterCriticalSection(&g_cs); } void LeaveGlobalMutex() { LeaveCriticalSection(&g_cs); } int SetCompression(const wchar_t *pwszFilename, unsigned short ufLevel) { #ifdef FSCTL_SET_COMPRESSION HMODULE hMod = GetModuleHandle(_T("KERNEL32")); CREATEFILEW pfunc; HANDLE hFile; |
︙ | ︙ | |||
149 150 151 152 153 154 155 | } __declspec(dllexport) int WINAPI sqlite3_decompressfile(const wchar_t *pwszFilename) { return SetCompression(pwszFilename, COMPRESSION_FORMAT_NONE); } | < < < < < < < < < < < < < < < < < < < < | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | } __declspec(dllexport) int WINAPI sqlite3_decompressfile(const wchar_t *pwszFilename) { return SetCompression(pwszFilename, COMPRESSION_FORMAT_NONE); } /* The goal of this version of close is different than that of sqlite3_close(), and is designed to lend itself better to .NET's non-deterministic finalizers and the GC thread. SQLite will not close a database if statements are open on it -- but for our purposes, we'd rather finalize all active statements and forcibly close the database. The reason is simple -- a lot of people don't Dispose() of their objects correctly and let the garbage collector do it. This leads to unexpected behavior when a user thinks they've closed a database, but it's still open because not all the statements have hit the GC yet. |
︙ | ︙ | |||
230 231 232 233 234 235 236 | } LeaveGlobalMutex(); return ret; } | < < < < < | | | | < < | < | | < | < < | < < < < | < < < < | < | < < | < < < < | < < < < < < < < | < | < < < < < < < | < < < < < < < < < < | | | < < | < < < | < > | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 | } LeaveGlobalMutex(); return ret; } __declspec(dllexport) int WINAPI sqlite3_open_interop(const char*filename, int flags, sqlite3 **ppdb) { int ret; //int sharedcache = ((flags & SQLITE_OPEN_SHAREDCACHE) != 0); //flags &= ~SQLITE_OPEN_SHAREDCACHE; //EnterGlobalMutex(); //sqlite3_enable_shared_cache(sharedcache); ret = sqlite3_open_v2(filename, ppdb, flags, NULL); //sqlite3_enable_shared_cache(0); if (ret == 0) RegisterExtensionFunctions(*ppdb); //LeaveGlobalMutex(); return ret; } __declspec(dllexport) int WINAPI sqlite3_open16_interop(const char *filename, int flags, sqlite3 **ppdb) { int ret = sqlite3_open_interop(filename, flags, ppdb); if (!ret) { if(!DbHasProperty(*ppdb, 0, DB_SchemaLoaded)) ENC(*ppdb) = SQLITE_UTF16NATIVE; } return ret; } __declspec(dllexport) const char * WINAPI sqlite3_errmsg_interop(sqlite3 *db, int *plen) { const char *pval = sqlite3_errmsg(db); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } __declspec(dllexport) int WINAPI sqlite3_prepare_interop(sqlite3 *db, const char *sql, int nbytes, sqlite3_stmt **ppstmt, const char **pztail, int *plen) { int n; n = sqlite3_prepare(db, sql, nbytes, ppstmt, pztail); *plen = (*pztail != 0) ? strlen(*pztail) : 0; return n; } __declspec(dllexport) int WINAPI sqlite3_prepare16_interop(sqlite3 *db, const void *sql, int nchars, sqlite3_stmt **ppstmt, const void **pztail, int *plen) { int n; n = sqlite3_prepare16(db, sql, nchars * sizeof(wchar_t), ppstmt, pztail); *plen = (*pztail != 0) ? wcslen((wchar_t *)*pztail) * sizeof(wchar_t) : 0; return n; } __declspec(dllexport) int WINAPI sqlite3_bind_double_interop(sqlite3_stmt *stmt, int iCol, double *val) { return sqlite3_bind_double(stmt,iCol,*val); } __declspec(dllexport) int WINAPI sqlite3_bind_int64_interop(sqlite3_stmt *stmt, int iCol, sqlite_int64 *val) { return sqlite3_bind_int64(stmt,iCol,*val); } __declspec(dllexport) const char * WINAPI sqlite3_bind_parameter_name_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const char *pval = sqlite3_bind_parameter_name(stmt, iCol); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } __declspec(dllexport) const char * WINAPI sqlite3_column_name_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const char *pval = sqlite3_column_name(stmt, iCol); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } |
︙ | ︙ | |||
440 441 442 443 444 445 446 | __declspec(dllexport) const void * WINAPI sqlite3_column_decltype16_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const void *pval = sqlite3_column_decltype16(stmt, iCol); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0; return pval; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 | __declspec(dllexport) const void * WINAPI sqlite3_column_decltype16_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const void *pval = sqlite3_column_decltype16(stmt, iCol); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0; return pval; } __declspec(dllexport) void WINAPI sqlite3_column_double_interop(sqlite3_stmt *stmt, int iCol, double *val) { *val = sqlite3_column_double(stmt,iCol); } __declspec(dllexport) void WINAPI sqlite3_column_int64_interop(sqlite3_stmt *stmt, int iCol, sqlite_int64 *val) { *val = sqlite3_column_int64(stmt,iCol); } __declspec(dllexport) const unsigned char * WINAPI sqlite3_column_text_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const unsigned char *pval = sqlite3_column_text(stmt, iCol); *plen = (pval != 0) ? strlen((char *)pval) : 0; return pval; } __declspec(dllexport) const void * WINAPI sqlite3_column_text16_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const void *pval = sqlite3_column_text16(stmt, iCol); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t): 0; return pval; } __declspec(dllexport) int WINAPI sqlite3_finalize_interop(sqlite3_stmt *stmt) { // Try and finalize a statement, and close the database it belonged to if the database was marked for closing Vdbe *p; sqlite3 *db; int ret; |
︙ | ︙ | |||
557 558 559 560 561 562 563 | int ret; if (((Vdbe *)stmt)->magic == VDBE_MAGIC_DEAD) return SQLITE_SCHEMA; ret = sqlite3_reset(stmt); return ret; } | | < < < < | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < | < < | < | < < | < | < | < < < < < | < | | < < < | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | > | | < | | > | | | | < | | < | < > | < > | | < < < | 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 | int ret; if (((Vdbe *)stmt)->magic == VDBE_MAGIC_DEAD) return SQLITE_SCHEMA; ret = sqlite3_reset(stmt); return ret; } __declspec(dllexport) int WINAPI sqlite3_create_function_interop(sqlite3 *psql, const char *zFunctionName, int nArg, int eTextRep, void *pvUser, SQLITEUSERFUNC func, SQLITEUSERFUNC funcstep, SQLITEFUNCFINAL funcfinal, int needCollSeq) { int n; if (eTextRep == SQLITE_UTF16) eTextRep = SQLITE_UTF16NATIVE; n = sqlite3_create_function(psql, zFunctionName, nArg, eTextRep, 0, func, funcstep, funcfinal); if (n == 0) { if (needCollSeq) { FuncDef *pFunc = sqlite3FindFunction(psql, zFunctionName, strlen(zFunctionName), nArg, eTextRep, 0); if( pFunc ) { pFunc->needCollSeq = 1; } } } return n; } __declspec(dllexport) void WINAPI sqlite3_value_double_interop(sqlite3_value *pval, double *val) { *val = sqlite3_value_double(pval); } __declspec(dllexport) void WINAPI sqlite3_value_int64_interop(sqlite3_value *pval, sqlite_int64 *val) { *val = sqlite3_value_int64(pval); } __declspec(dllexport) const unsigned char * WINAPI sqlite3_value_text_interop(sqlite3_value *val, int *plen) { const unsigned char *pval = sqlite3_value_text(val); *plen = (pval != 0) ? strlen((char *)pval) : 0; return pval; } __declspec(dllexport) const void * WINAPI sqlite3_value_text16_interop(sqlite3_value *val, int *plen) { const void *pval = sqlite3_value_text16(val); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0; return pval; } __declspec(dllexport) void WINAPI sqlite3_result_double_interop(sqlite3_context *pctx, double *val) { sqlite3_result_double(pctx, *val); } __declspec(dllexport) void WINAPI sqlite3_result_int64_interop(sqlite3_context *pctx, sqlite_int64 *val) { sqlite3_result_int64(pctx, *val); } __declspec(dllexport) int WINAPI sqlite3_context_collcompare(sqlite3_context *ctx, const void *p1, int p1len, const void *p2, int p2len) { if (ctx->pFunc->needCollSeq == 0) return 2; return ctx->pColl->xCmp(ctx->pColl->pUser, p1len, p1, p2len, p2); } __declspec(dllexport) const char * WINAPI sqlite3_context_collseq(sqlite3_context *ctx, int *ptype, int *enc, int *plen) { CollSeq *pColl = ctx->pColl; *ptype = 0; *plen = 0; *enc = 0; if (ctx->pFunc->needCollSeq == 0) return NULL; if (pColl) { *enc = pColl->enc; *ptype = pColl->type; *plen = (pColl->zName != 0) ? strlen(pColl->zName) : 0; return pColl->zName; } return NULL; } __declspec(dllexport) const char * WINAPI sqlite3_column_database_name_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const char *pval = sqlite3_column_database_name(stmt, iCol); *plen = (pval != 0) ? strlen(pval) : 0; return pval; |
︙ | ︙ | |||
790 791 792 793 794 795 796 | n = sqlite3_table_column_metadata(db, zDbName, zTableName, zColumnName, pzDataType, pzCollSeq, pNotNull, pPrimaryKey, pAutoinc); *pdtLen = (*pzDataType != 0) ? strlen(*pzDataType) : 0; *pcsLen = (*pzCollSeq != 0) ? strlen(*pzCollSeq) : 0; return n; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | n = sqlite3_table_column_metadata(db, zDbName, zTableName, zColumnName, pzDataType, pzCollSeq, pNotNull, pPrimaryKey, pAutoinc); *pdtLen = (*pzDataType != 0) ? strlen(*pzDataType) : 0; *pcsLen = (*pzCollSeq != 0) ? strlen(*pzCollSeq) : 0; return n; } __declspec(dllexport) int WINAPI sqlite3_index_column_info_interop(sqlite3 *db, const char *zDb, const char *zIndexName, const char *zColumnName, int *sortOrder, int *onError, char **pzColl, int *plen) { Index *pIdx; Table *pTab; char *zErrMsg = 0; int n; pIdx = sqlite3FindIndex(db, zIndexName, zDb); |
︙ | ︙ | |||
857 858 859 860 861 862 863 | return SQLITE_OK; } } return SQLITE_ERROR; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | return SQLITE_OK; } } return SQLITE_ERROR; } __declspec(dllexport) int WINAPI sqlite3_table_cursor(sqlite3_stmt *pstmt, int iDb, Pgno tableRootPage) { Vdbe *p = (Vdbe *)pstmt; sqlite3 *db = (p == NULL) ? NULL : p->db; int n; int ret = -1; |
︙ | ︙ | |||
970 971 972 973 974 975 976 | break; } sqlite3_mutex_leave(db->mutex); return ret; } | < < < < < < < | 584 585 586 587 588 589 590 591 592 | break; } sqlite3_mutex_leave(db->mutex); return ret; } #endif // SQLITE_OS_WIN |
Changes to SQLite.Interop/merge.h.
1 2 3 4 5 6 7 | // This code was automatically generated from assembly // C:\Src\SQLite.NET\System.Data.SQLite\bin\CompactFramework\System.Data.SQLite.dll #include <windef.h> #pragma data_seg(push,clrseg,".clr") #pragma comment(linker, "/SECTION:.clr,ER") | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // This code was automatically generated from assembly // C:\Src\SQLite.NET\System.Data.SQLite\bin\CompactFramework\System.Data.SQLite.dll #include <windef.h> #pragma data_seg(push,clrseg,".clr") #pragma comment(linker, "/SECTION:.clr,ER") char __ph[143492] = {0}; // The number of bytes to reserve #pragma data_seg(pop,clrseg) typedef BOOL (WINAPI *DLLMAIN)(HANDLE, DWORD, LPVOID); typedef struct EXTRA_STUFF { DWORD dwNativeEntryPoint; } EXTRA_STUFF, *LPEXTRA_STUFF; |
︙ | ︙ |
Changes to SQLite.Interop/merge_full.h.
1 2 3 4 5 6 7 | // This code was automatically generated from assembly // C:\Src\SQLite.NET\System.Data.SQLite\bin\System.Data.SQLite.dll #include <windef.h> #pragma data_seg(push,clrseg,".clr") #pragma comment(linker, "/SECTION:.clr,ER") | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // This code was automatically generated from assembly // C:\Src\SQLite.NET\System.Data.SQLite\bin\System.Data.SQLite.dll #include <windef.h> #pragma data_seg(push,clrseg,".clr") #pragma comment(linker, "/SECTION:.clr,ER") char __ph[157228] = {0}; // The number of bytes to reserve #pragma data_seg(pop,clrseg) typedef BOOL (WINAPI *DLLMAIN)(HANDLE, DWORD, LPVOID); typedef struct EXTRA_STUFF { DWORD dwNativeEntryPoint; } EXTRA_STUFF, *LPEXTRA_STUFF; |
︙ | ︙ |
Changes to SQLite.Interop/src/sqlite3.c.
1 2 | /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite | | | | | 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 | /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite ** version 3.6.1. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a one translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements ** of 5% are more are commonly seen when SQLite is compiled as a single ** translation unit. ** ** This file is all you need to compile SQLite. To use SQLite in other ** programs, you need this file and the "sqlite3.h" header file that defines ** the programming interface to the SQLite library. (If you do not have ** the "sqlite3.h" header file at hand, you will find a copy in the first ** 6279 lines past this header comment.) Additional code files may be ** needed if you want a wrapper to interface SQLite with your choice of ** programming language. The code for the "sqlite3" command-line shell ** is also in a separate file. This file contains only code for the core ** SQLite library. ** ** This amalgamation was generated on 2008-08-05 21:36:42 UTC. */ #define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 #ifndef SQLITE_PRIVATE # define SQLITE_PRIVATE static #endif #ifndef SQLITE_API |
︙ | ︙ | |||
37 38 39 40 41 42 43 | ** 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. ** ************************************************************************* ** Internal interface definitions for SQLite. ** | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | ** 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. ** ************************************************************************* ** Internal interface definitions for SQLite. ** ** @(#) $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* ** Include the configuration header output by 'configure' if we're using the ** autoconf-based build |
︙ | ︙ | |||
66 67 68 69 70 71 72 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file defines various limits of what SQLite can process. ** | | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file defines various limits of what SQLite can process. ** ** @(#) $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** The maximum length of a TEXT or BLOB in bytes. This also ** limits the size of a row in a table or index. ** ** The hard limit is the ability of a 32-bit signed integer |
︙ | ︙ | |||
249 250 251 252 253 254 255 | #pragma warn -ccc /* Condition is always true or false */ #pragma warn -aus /* Assigned value is never used */ #pragma warn -csu /* Comparing signed and unsigned */ #pragma warn -spa /* Suspicous pointer arithmetic */ #endif /* Needed for various definitions... */ | > | > | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | #pragma warn -ccc /* Condition is always true or false */ #pragma warn -aus /* Assigned value is never used */ #pragma warn -csu /* Comparing signed and unsigned */ #pragma warn -spa /* Suspicous pointer arithmetic */ #endif /* Needed for various definitions... */ #ifndef _GNU_SOURCE # define _GNU_SOURCE #endif /* ** Include standard header files as necessary */ #ifdef HAVE_STDINT_H #include <stdint.h> #endif |
︙ | ︙ | |||
468 469 470 471 472 473 474 | ** on how SQLite interfaces are suppose to operate. ** ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** | | | 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | ** on how SQLite interfaces are suppose to operate. ** ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** ** @(#) $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ #include <stdarg.h> /* Needed for the definition of va_list */ /* ** Make sure we can call this stuff from C++. |
︙ | ︙ | |||
500 501 502 503 504 505 506 | # undef SQLITE_VERSION #endif #ifdef SQLITE_VERSION_NUMBER # undef SQLITE_VERSION_NUMBER #endif /* | | | | | | | | | | | | 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 | # undef SQLITE_VERSION #endif #ifdef SQLITE_VERSION_NUMBER # undef SQLITE_VERSION_NUMBER #endif /* ** CAPI3REF: Compile-Time Library Version Numbers {H10010} <S60100> ** ** The SQLITE_VERSION and SQLITE_VERSION_NUMBER #defines in ** the sqlite3.h file specify the version of SQLite with which ** that header file is associated. ** ** The "version" of SQLite is a string of the form "X.Y.Z". ** The phrase "alpha" or "beta" might be appended after the Z. ** The X value is major version number always 3 in SQLite3. ** The X value only changes when backwards compatibility is ** broken and we intend to never break backwards compatibility. ** The Y value is the minor version number and only changes when ** there are major feature enhancements that are forwards compatible ** but not backwards compatible. ** The Z value is the release number and is incremented with ** each release but resets back to 0 whenever Y is incremented. ** ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()]. ** ** INVARIANTS: ** ** {H10011} The SQLITE_VERSION #define in the sqlite3.h header file shall ** evaluate to a string literal that is the SQLite version ** with which the header file is associated. ** ** {H10014} The SQLITE_VERSION_NUMBER #define shall resolve to an integer ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z ** are the major version, minor version, and release number. */ #define SQLITE_VERSION "3.6.1" #define SQLITE_VERSION_NUMBER 3006001 /* ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100> ** KEYWORDS: sqlite3_version ** ** These features provide the same information as the [SQLITE_VERSION] ** and [SQLITE_VERSION_NUMBER] #defines in the header, but are associated ** with the library instead of the header file. Cautious programmers might ** include a check in their application to verify that ** sqlite3_libversion_number() always returns the value ** [SQLITE_VERSION_NUMBER]. ** ** The sqlite3_libversion() function returns the same information as is ** in the sqlite3_version[] string constant. The function is provided ** for use in DLLs since DLL users usually do not have direct access to string ** constants within the DLL. ** ** INVARIANTS: ** ** {H10021} The [sqlite3_libversion_number()] interface shall return ** an integer equal to [SQLITE_VERSION_NUMBER]. ** ** {H10022} The [sqlite3_version] string constant shall contain ** the text of the [SQLITE_VERSION] string. ** ** {H10023} The [sqlite3_libversion()] function shall return ** a pointer to the [sqlite3_version] string constant. */ SQLITE_API const char sqlite3_version[]; SQLITE_API const char *sqlite3_libversion(void); SQLITE_API int sqlite3_libversion_number(void); /* ** CAPI3REF: Test To See If The Library Is Threadsafe {H10100} <S60100> ** ** SQLite can be compiled with or without mutexes. When ** the [SQLITE_THREADSAFE] C preprocessor macro is true, mutexes ** are enabled and SQLite is threadsafe. When that macro is false, ** the mutexes are omitted. Without the mutexes, it is not safe ** to use SQLite concurrently from more than one thread. ** |
︙ | ︙ | |||
592 593 594 595 596 597 598 | ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], ** or [SQLITE_CONFIG_MUTEX]. The return value of this function shows ** only the default compile-time setting, not any run-time changes ** to that setting. ** ** INVARIANTS: ** | | | | | | | | 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 | ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], ** or [SQLITE_CONFIG_MUTEX]. The return value of this function shows ** only the default compile-time setting, not any run-time changes ** to that setting. ** ** INVARIANTS: ** ** {H10101} The [sqlite3_threadsafe()] function shall return nonzero if ** SQLite was compiled with the its mutexes enabled by default ** or zero if SQLite was compiled such that mutexes are ** permanently disabled. ** ** {H10102} The value returned by the [sqlite3_threadsafe()] function ** shall not change when mutex setting are modified at ** runtime using the [sqlite3_config()] interface and ** especially the [SQLITE_CONFIG_SINGLETHREAD], ** [SQLITE_CONFIG_MULTITHREAD], [SQLITE_CONFIG_SERIALIZED], ** and [SQLITE_CONFIG_MUTEX] verbs. */ SQLITE_API int sqlite3_threadsafe(void); /* ** CAPI3REF: Database Connection Handle {H12000} <S40200> ** KEYWORDS: {database connection} {database connections} ** ** Each open SQLite database is represented by a pointer to an instance of ** the opaque structure named "sqlite3". It is useful to think of an sqlite3 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] ** is its destructor. There are many other interfaces (such as ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and ** [sqlite3_busy_timeout()] to name but three) that are methods on an ** sqlite3 object. */ typedef struct sqlite3 sqlite3; /* ** CAPI3REF: 64-Bit Integer Types {H10200} <S10110> ** KEYWORDS: sqlite_int64 sqlite_uint64 ** ** Because there is no cross-platform way to specify 64-bit integer types ** SQLite includes typedefs for 64-bit signed and unsigned integers. ** ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. ** The sqlite_int64 and sqlite_uint64 types are supported for backwards ** compatibility only. ** ** INVARIANTS: ** ** {H10201} The [sqlite_int64] and [sqlite3_int64] type shall specify ** a 64-bit signed integer. ** ** {H10202} The [sqlite_uint64] and [sqlite3_uint64] type shall specify ** a 64-bit unsigned integer. */ #ifdef SQLITE_INT64_TYPE typedef SQLITE_INT64_TYPE sqlite_int64; typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; #elif defined(_MSC_VER) || defined(__BORLANDC__) typedef __int64 sqlite_int64; |
︙ | ︙ | |||
662 663 664 665 666 667 668 | ** substitute integer for floating-point. */ #ifdef SQLITE_OMIT_FLOATING_POINT # define double sqlite3_int64 #endif /* | | | 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | ** substitute integer for floating-point. */ #ifdef SQLITE_OMIT_FLOATING_POINT # define double sqlite3_int64 #endif /* ** CAPI3REF: Closing A Database Connection {H12010} <S30100><S40200> ** ** This routine is the destructor for the [sqlite3] object. ** ** Applications should [sqlite3_finalize | finalize] all [prepared statements] ** and [sqlite3_blob_close | close] all [BLOB handles] associated with ** the [sqlite3] object prior to attempting to close the object. ** The [sqlite3_next_stmt()] interface can be used to locate all |
︙ | ︙ | |||
685 686 687 688 689 690 691 | ** </pre></blockquote> ** ** If [sqlite3_close()] is invoked while a transaction is open, ** the transaction is automatically rolled back. ** ** INVARIANTS: ** | | | | | | | | | | | 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 | ** </pre></blockquote> ** ** If [sqlite3_close()] is invoked while a transaction is open, ** the transaction is automatically rolled back. ** ** INVARIANTS: ** ** {H12011} A successful call to [sqlite3_close(C)] shall destroy the ** [database connection] object C. ** ** {H12012} A successful call to [sqlite3_close(C)] shall return SQLITE_OK. ** ** {H12013} A successful call to [sqlite3_close(C)] shall release all ** memory and system resources associated with [database connection] ** C. ** ** {H12014} A call to [sqlite3_close(C)] on a [database connection] C that ** has one or more open [prepared statements] shall fail with ** an [SQLITE_BUSY] error code. ** ** {H12015} A call to [sqlite3_close(C)] where C is a NULL pointer shall ** return SQLITE_OK. ** ** {H12019} When [sqlite3_close(C)] is invoked on a [database connection] C ** that has a pending transaction, the transaction shall be ** rolled back. ** ** ASSUMPTIONS: ** ** {A12016} The C parameter to [sqlite3_close(C)] must be either a NULL ** pointer or an [sqlite3] object pointer obtained ** from [sqlite3_open()], [sqlite3_open16()], or ** [sqlite3_open_v2()], and not previously closed. */ SQLITE_API int sqlite3_close(sqlite3 *); /* ** The type for a callback function. ** This is legacy and deprecated. It is included for historical ** compatibility and is not documented. */ typedef int (*sqlite3_callback)(void*,int,char**, char**); /* ** CAPI3REF: One-Step Query Execution Interface {H12100} <S10000> ** ** The sqlite3_exec() interface is a convenient way of running one or more ** SQL statements without having to write a lot of C code. The UTF-8 encoded ** SQL statements are passed in as the second parameter to sqlite3_exec(). ** The statements are evaluated one by one until either an error or ** an interrupt is encountered, or until they are all done. The 3rd parameter ** is an optional callback that is invoked once for each row of any query |
︙ | ︙ | |||
750 751 752 753 754 755 756 | ** The sqlite3_exec() interface is implemented in terms of ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()]. ** The sqlite3_exec() routine does nothing to the database that cannot be done ** by [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()]. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 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 820 821 822 823 824 825 826 827 828 | ** The sqlite3_exec() interface is implemented in terms of ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()]. ** The sqlite3_exec() routine does nothing to the database that cannot be done ** by [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()]. ** ** INVARIANTS: ** ** {H12101} A successful invocation of [sqlite3_exec(D,S,C,A,E)] ** shall sequentially evaluate all of the UTF-8 encoded, ** semicolon-separated SQL statements in the zero-terminated ** string S within the context of the [database connection] D. ** ** {H12102} If the S parameter to [sqlite3_exec(D,S,C,A,E)] is NULL then ** the actions of the interface shall be the same as if the ** S parameter were an empty string. ** ** {H12104} The return value of [sqlite3_exec()] shall be [SQLITE_OK] if all ** SQL statements run successfully and to completion. ** ** {H12105} The return value of [sqlite3_exec()] shall be an appropriate ** non-zero [error code] if any SQL statement fails. ** ** {H12107} If one or more of the SQL statements handed to [sqlite3_exec()] ** return results and the 3rd parameter is not NULL, then ** the callback function specified by the 3rd parameter shall be ** invoked once for each row of result. ** ** {H12110} If the callback returns a non-zero value then [sqlite3_exec()] ** shall abort the SQL statement it is currently evaluating, ** skip all subsequent SQL statements, and return [SQLITE_ABORT]. ** ** {H12113} The [sqlite3_exec()] routine shall pass its 4th parameter through ** as the 1st parameter of the callback. ** ** {H12116} The [sqlite3_exec()] routine shall set the 2nd parameter of its ** callback to be the number of columns in the current row of ** result. ** ** {H12119} The [sqlite3_exec()] routine shall set the 3rd parameter of its ** callback to be an array of pointers to strings holding the ** values for each column in the current result set row as ** obtained from [sqlite3_column_text()]. ** ** {H12122} The [sqlite3_exec()] routine shall set the 4th parameter of its ** callback to be an array of pointers to strings holding the ** names of result columns as obtained from [sqlite3_column_name()]. ** ** {H12125} If the 3rd parameter to [sqlite3_exec()] is NULL then ** [sqlite3_exec()] shall silently discard query results. ** ** {H12131} If an error occurs while parsing or evaluating any of the SQL ** statements in the S parameter of [sqlite3_exec(D,S,C,A,E)] and if ** the E parameter is not NULL, then [sqlite3_exec()] shall store ** in *E an appropriate error message written into memory obtained ** from [sqlite3_malloc()]. ** ** {H12134} The [sqlite3_exec(D,S,C,A,E)] routine shall set the value of ** *E to NULL if E is not NULL and there are no errors. ** ** {H12137} The [sqlite3_exec(D,S,C,A,E)] function shall set the [error code] ** and message accessible via [sqlite3_errcode()], ** [sqlite3_errmsg()], and [sqlite3_errmsg16()]. ** ** {H12138} If the S parameter to [sqlite3_exec(D,S,C,A,E)] is NULL or an ** empty string or contains nothing other than whitespace, comments, ** and/or semicolons, then results of [sqlite3_errcode()], ** [sqlite3_errmsg()], and [sqlite3_errmsg16()] ** shall reset to indicate no errors. ** ** ASSUMPTIONS: ** ** {A12141} The first parameter to [sqlite3_exec()] must be an valid and open ** [database connection]. ** ** {A12142} The database connection must not be closed while ** [sqlite3_exec()] is running. ** |
︙ | ︙ | |||
836 837 838 839 840 841 842 | const char *sql, /* SQL to be evaluated */ int (*callback)(void*,int,char**,char**), /* Callback function */ void *, /* 1st argument to callback */ char **errmsg /* Error msg written here */ ); /* | | | 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | const char *sql, /* SQL to be evaluated */ int (*callback)(void*,int,char**,char**), /* Callback function */ void *, /* 1st argument to callback */ char **errmsg /* Error msg written here */ ); /* ** CAPI3REF: Result Codes {H10210} <S10700> ** KEYWORDS: SQLITE_OK {error code} {error codes} ** KEYWORDS: {result code} {result codes} ** ** Many SQLite functions return an integer result code from the set shown ** here in order to indicates success or failure. ** ** New error codes may be added in future versions of SQLite. |
︙ | ︙ | |||
880 881 882 883 884 885 886 | #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ #define SQLITE_NOTADB 26 /* File opened that is not a database file */ #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ /* end-of-error-codes */ /* | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ #define SQLITE_NOTADB 26 /* File opened that is not a database file */ #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ /* end-of-error-codes */ /* ** CAPI3REF: Extended Result Codes {H10220} <S10700> ** KEYWORDS: {extended error code} {extended error codes} ** KEYWORDS: {extended result code} {extended result codes} ** ** In its default configuration, SQLite API routines return one of 26 integer ** [SQLITE_OK | result codes]. However, experience has shown that many of ** these result codes are too coarse-grained. They do not provide as ** much information about problems as programmers might like. In an effort to |
︙ | ︙ | |||
904 905 906 907 908 909 910 | ** to see new result codes in future releases of SQLite. ** ** The SQLITE_OK result code will never be extended. It will always ** be exactly zero. ** ** INVARIANTS: ** | | | | | | | 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 | ** to see new result codes in future releases of SQLite. ** ** The SQLITE_OK result code will never be extended. It will always ** be exactly zero. ** ** INVARIANTS: ** ** {H10223} The symbolic name for an extended result code shall contains ** a related primary result code as a prefix. ** ** {H10224} Primary result code names shall contain a single "_" character. ** ** {H10225} Extended result code names shall contain two or more "_" characters. ** ** {H10226} The numeric value of an extended result code shall contain the ** numeric value of its corresponding primary result code in ** its least significant 8 bits. */ #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8)) #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8)) #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8)) #define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8)) #define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8)) #define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8)) #define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8)) #define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8)) #define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8)) #define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8)) #define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) /* ** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700> ** ** These bit values are intended for use in the ** 3rd parameter to the [sqlite3_open_v2()] interface and ** in the 4th parameter to the xOpen method of the ** [sqlite3_vfs] object. */ #define SQLITE_OPEN_READONLY 0x00000001 |
︙ | ︙ | |||
953 954 955 956 957 958 959 | #define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 #define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 #define SQLITE_OPEN_SUBJOURNAL 0x00002000 #define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 #define SQLITE_OPEN_NOMUTEX 0x00008000 /* | | | 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 | #define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 #define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 #define SQLITE_OPEN_SUBJOURNAL 0x00002000 #define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 #define SQLITE_OPEN_NOMUTEX 0x00008000 /* ** CAPI3REF: Device Characteristics {H10240} <H11120> ** ** The xDeviceCapabilities method of the [sqlite3_io_methods] ** object returns an integer which is a vector of the these ** bit values expressing I/O characteristics of the mass storage ** device that holds the file that the [sqlite3_io_methods] ** refers to. ** |
︙ | ︙ | |||
985 986 987 988 989 990 991 | #define SQLITE_IOCAP_ATOMIC16K 0x00000040 #define SQLITE_IOCAP_ATOMIC32K 0x00000080 #define SQLITE_IOCAP_ATOMIC64K 0x00000100 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 /* | | | | | | 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 | #define SQLITE_IOCAP_ATOMIC16K 0x00000040 #define SQLITE_IOCAP_ATOMIC32K 0x00000080 #define SQLITE_IOCAP_ATOMIC64K 0x00000100 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 /* ** CAPI3REF: File Locking Levels {H10250} <H11120> <H11310> ** ** SQLite uses one of these integer values as the second ** argument to calls it makes to the xLock() and xUnlock() methods ** of an [sqlite3_io_methods] object. */ #define SQLITE_LOCK_NONE 0 #define SQLITE_LOCK_SHARED 1 #define SQLITE_LOCK_RESERVED 2 #define SQLITE_LOCK_PENDING 3 #define SQLITE_LOCK_EXCLUSIVE 4 /* ** CAPI3REF: Synchronization Type Flags {H10260} <H11120> ** ** When SQLite invokes the xSync() method of an ** [sqlite3_io_methods] object it uses a combination of ** these integer values as the second argument. ** ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the ** sync operation only needs to flush data to mass storage. Inode ** information need not be flushed. The SQLITE_SYNC_NORMAL flag means ** to use normal fsync() semantics. The SQLITE_SYNC_FULL flag means ** to use Mac OS-X style fullsync instead of fsync(). */ #define SQLITE_SYNC_NORMAL 0x00002 #define SQLITE_SYNC_FULL 0x00003 #define SQLITE_SYNC_DATAONLY 0x00010 /* ** CAPI3REF: OS Interface Open File Handle {H11110} <S20110> ** ** An [sqlite3_file] object represents an open file in the OS ** interface layer. Individual OS interface implementations will ** want to subclass this object by appending additional fields ** for their own use. The pMethods entry is a pointer to an ** [sqlite3_io_methods] object that defines methods for performing ** I/O operations on the open file. */ typedef struct sqlite3_file sqlite3_file; struct sqlite3_file { const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ }; /* ** CAPI3REF: OS Interface File Virtual Methods Object {H11120} <S20110> ** ** Every file opened by the [sqlite3_vfs] xOpen method populates an ** [sqlite3_file] object (or, more commonly, a subclass of the ** [sqlite3_file] object) with a pointer to an instance of this object. ** This object defines the methods used to perform various operations ** against the open file represented by the [sqlite3_file] object. ** |
︙ | ︙ | |||
1123 1124 1125 1126 1127 1128 1129 | int (*xFileControl)(sqlite3_file*, int op, void *pArg); int (*xSectorSize)(sqlite3_file*); int (*xDeviceCharacteristics)(sqlite3_file*); /* Additional methods may be added in future releases */ }; /* | | | | | 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 | int (*xFileControl)(sqlite3_file*, int op, void *pArg); int (*xSectorSize)(sqlite3_file*); int (*xDeviceCharacteristics)(sqlite3_file*); /* Additional methods may be added in future releases */ }; /* ** CAPI3REF: Standard File Control Opcodes {H11310} <S30800> ** ** These integer constants are opcodes for the xFileControl method ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] ** interface. ** ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This ** opcode causes the xFileControl method to write the current state of ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) ** into an integer that the pArg argument points to. This capability ** is used during testing and only needs to be supported when SQLITE_TEST ** is defined. */ #define SQLITE_FCNTL_LOCKSTATE 1 /* ** CAPI3REF: Mutex Handle {H17110} <S20130> ** ** The mutex module within SQLite defines [sqlite3_mutex] to be an ** abstract type for a mutex object. The SQLite core never looks ** at the internal representation of an [sqlite3_mutex]. It only ** deals with pointers to the [sqlite3_mutex] object. ** ** Mutexes are created using [sqlite3_mutex_alloc()]. */ typedef struct sqlite3_mutex sqlite3_mutex; /* ** CAPI3REF: OS Interface Object {H11140} <S20100> ** ** An instance of the sqlite3_vfs object defines the interface between ** the SQLite core and the underlying operating system. The "vfs" ** in the name of the object stands for "virtual file system". ** ** The value of the iVersion field is initially 1 but may be larger in ** future versions of SQLite. Additional fields may be appended to this |
︙ | ︙ | |||
1185 1186 1187 1188 1189 1190 1191 | ** or modify this field while holding a particular static mutex. ** The application should never modify anything within the sqlite3_vfs ** object once the object has been registered. ** ** The zName field holds the name of the VFS module. The name must ** be unique across all VFS modules. ** | | | | | | 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 | ** or modify this field while holding a particular static mutex. ** The application should never modify anything within the sqlite3_vfs ** object once the object has been registered. ** ** The zName field holds the name of the VFS module. The name must ** be unique across all VFS modules. ** ** {H11141} SQLite will guarantee that the zFilename parameter to xOpen ** is either a NULL pointer or string obtained ** from xFullPathname(). SQLite further guarantees that ** the string will be valid and unchanged until xClose() is ** called. {END} Because of the previous sentense, ** the [sqlite3_file] can safely store a pointer to the ** filename if it needs to remember the filename for some reason. ** If the zFilename parameter is xOpen is a NULL pointer then xOpen ** must invite its own temporary name for the file. Whenever the ** xFilename parameter is NULL it will also be the case that the ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. ** ** {H11142} The flags argument to xOpen() includes all bits set in ** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] ** or [sqlite3_open16()] is used, then flags includes at least ** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. {END} ** If xOpen() opens a file read-only then it sets *pOutFlags to ** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. ** ** {H11143} SQLite will also add one of the following flags to the xOpen() ** call, depending on the object being opened: ** ** <ul> ** <li> [SQLITE_OPEN_MAIN_DB] ** <li> [SQLITE_OPEN_MAIN_JOURNAL] ** <li> [SQLITE_OPEN_TEMP_DB] ** <li> [SQLITE_OPEN_TEMP_JOURNAL] |
︙ | ︙ | |||
1233 1234 1235 1236 1237 1238 1239 | ** SQLite might also add one of the following flags to the xOpen method: ** ** <ul> ** <li> [SQLITE_OPEN_DELETEONCLOSE] ** <li> [SQLITE_OPEN_EXCLUSIVE] ** </ul> ** | | | | | | | | | 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 | ** SQLite might also add one of the following flags to the xOpen method: ** ** <ul> ** <li> [SQLITE_OPEN_DELETEONCLOSE] ** <li> [SQLITE_OPEN_EXCLUSIVE] ** </ul> ** ** {H11145} The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be ** deleted when it is closed. {H11146} The [SQLITE_OPEN_DELETEONCLOSE] ** will be set for TEMP databases, journals and for subjournals. ** ** {H11147} The [SQLITE_OPEN_EXCLUSIVE] flag means the file should be opened ** for exclusive access. This flag is set for all files except ** for the main database file. ** ** {H11148} At least szOsFile bytes of memory are allocated by SQLite ** to hold the [sqlite3_file] structure passed as the third ** argument to xOpen. {END} The xOpen method does not have to ** allocate the structure; it should just fill it in. ** ** {H11149} The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] ** to test whether a file is at least readable. {END} The file can be a ** directory. ** ** {H11150} SQLite will always allocate at least mxPathname+1 bytes for the ** output buffer xFullPathname. {H11151} The exact size of the output buffer ** is also passed as a parameter to both methods. {END} If the output buffer ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is ** handled as a fatal error by SQLite, vfs implementations should endeavor ** to prevent this by setting mxPathname to a sufficiently large value. ** ** The xRandomness(), xSleep(), and xCurrentTime() interfaces ** are not strictly a part of the filesystem, but they are |
︙ | ︙ | |||
1295 1296 1297 1298 1299 1300 1301 | int (*xCurrentTime)(sqlite3_vfs*, double*); int (*xGetLastError)(sqlite3_vfs*, int, char *); /* New fields may be appended in figure versions. The iVersion ** value will increment whenever this happens. */ }; /* | | | | | | | | 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 | int (*xCurrentTime)(sqlite3_vfs*, double*); int (*xGetLastError)(sqlite3_vfs*, int, char *); /* New fields may be appended in figure versions. The iVersion ** value will increment whenever this happens. */ }; /* ** CAPI3REF: Flags for the xAccess VFS method {H11190} <H11140> ** ** {H11191} These integer constants can be used as the third parameter to ** the xAccess method of an [sqlite3_vfs] object. {END} They determine ** what kind of permissions the xAccess method is looking for. ** {H11192} With SQLITE_ACCESS_EXISTS, the xAccess method ** simply checks whether the file exists. ** {H11193} With SQLITE_ACCESS_READWRITE, the xAccess method ** checks whether the file is both readable and writable. ** {H11194} With SQLITE_ACCESS_READ, the xAccess method ** checks whether the file is readable. */ #define SQLITE_ACCESS_EXISTS 0 #define SQLITE_ACCESS_READWRITE 1 #define SQLITE_ACCESS_READ 2 /* ** CAPI3REF: Initialize The SQLite Library {H10130} <S20000><S30100> ** ** The sqlite3_initialize() routine initializes the ** SQLite library. The sqlite3_shutdown() routine ** deallocates any resources that were allocated by sqlite3_initialize(). ** ** A call to sqlite3_initialize() is an "effective" call if it is ** the first time sqlite3_initialize() is invoked during the lifetime of |
︙ | ︙ | |||
1377 1378 1379 1380 1381 1382 1383 | */ SQLITE_API int sqlite3_initialize(void); SQLITE_API int sqlite3_shutdown(void); SQLITE_API int sqlite3_os_init(void); SQLITE_API int sqlite3_os_end(void); /* | | > | 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 | */ SQLITE_API int sqlite3_initialize(void); SQLITE_API int sqlite3_shutdown(void); SQLITE_API int sqlite3_os_init(void); SQLITE_API int sqlite3_os_end(void); /* ** CAPI3REF: Configuring The SQLite Library {H10145} <S20000><S30200> ** EXPERIMENTAL ** ** The sqlite3_config() interface is used to make global configuration ** changes to SQLite in order to tune SQLite to the specific needs of ** the application. The default configuration is recommended for most ** applications and so this routine is usually not necessary. It is ** provided to support rare applications with unusual needs. ** |
︙ | ︙ | |||
1402 1403 1404 1405 1406 1407 1408 | ** what property of SQLite is to be configured. Subsequent arguments ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option] ** in the first argument. ** ** When a configuration option is set, sqlite3_config() returns SQLITE_OK. ** If the option is unknown or SQLite is unable to set the option ** then this routine returns a non-zero [error code]. | < < < < > > > > > > > > > > > > > > > > > > > > > | > | 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 | ** what property of SQLite is to be configured. Subsequent arguments ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option] ** in the first argument. ** ** When a configuration option is set, sqlite3_config() returns SQLITE_OK. ** If the option is unknown or SQLite is unable to set the option ** then this routine returns a non-zero [error code]. */ SQLITE_API int sqlite3_config(int, ...); /* ** CAPI3REF: Configure database connections {H10180} <S20000> ** EXPERIMENTAL ** ** The sqlite3_db_config() interface is used to make configuration ** changes to a [database connection]. The interface is similar to ** [sqlite3_config()] except that the changes apply to a single ** [database connection] (specified in the first argument). The ** sqlite3_db_config() interface can only be used immediately after ** the database connection is created using [sqlite3_open()], ** [sqlite3_open16()], or [sqlite3_open_v2()]. ** ** The second argument to sqlite3_db_config(D,V,...) is the ** configuration verb - an integer code that indicates what ** aspect of the [database connection] is being configured. ** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE]. ** New verbs are likely to be added in future releases of SQLite. ** Additional arguments depend on the verb. */ SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); /* ** CAPI3REF: Memory Allocation Routines {H10155} <S20120> ** EXPERIMENTAL ** ** An instance of this object defines the interface between SQLite ** and low-level memory allocation routines. ** ** This object is used in only one place in the SQLite interface. ** A pointer to an instance of this object is the argument to ** [sqlite3_config()] when the configuration option is |
︙ | ︙ | |||
1464 1465 1466 1467 1468 1469 1470 | int (*xRoundup)(int); /* Round up request size to allocation size */ int (*xInit)(void*); /* Initialize the memory allocator */ void (*xShutdown)(void*); /* Deinitialize the memory allocator */ void *pAppData; /* Argument to xInit() and xShutdown() */ }; /* | | > | 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 | int (*xRoundup)(int); /* Round up request size to allocation size */ int (*xInit)(void*); /* Initialize the memory allocator */ void (*xShutdown)(void*); /* Deinitialize the memory allocator */ void *pAppData; /* Argument to xInit() and xShutdown() */ }; /* ** CAPI3REF: Configuration Options {H10160} <S20000> ** EXPERIMENTAL ** ** These constants are the available integer configuration options that ** can be passed as the first argument to the [sqlite3_config()] interface. ** ** New configuration options may be added in future releases of SQLite. ** Existing configuration options might be discontinued. Applications ** should check the return code from [sqlite3_config()] to make sure that |
︙ | ︙ | |||
1520 1521 1522 1523 1524 1525 1526 | ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] ** structure is filled with the currently defined memory allocation routines. ** This option can be used to overload the default memory allocation ** routines with a wrapper that simulations memory allocation failure or ** tracks memory usage, for example.</dd> ** ** <dt>SQLITE_CONFIG_MEMSTATUS</dt> | | | | > | | > > | | | > > | 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 | ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] ** structure is filled with the currently defined memory allocation routines. ** This option can be used to overload the default memory allocation ** routines with a wrapper that simulations memory allocation failure or ** tracks memory usage, for example.</dd> ** ** <dt>SQLITE_CONFIG_MEMSTATUS</dt> ** <dd>This option takes single argument of type int, interpreted as a ** boolean, which enables or disables the collection of memory allocation ** statistics. When disabled, the following SQLite interfaces become ** non-operational: ** <ul> ** <li> [sqlite3_memory_used()] ** <li> [sqlite3_memory_highwater()] ** <li> [sqlite3_soft_heap_limit()] ** <li> [sqlite3_status()] ** </ul> ** </dd> ** ** <dt>SQLITE_CONFIG_SCRATCH</dt> ** <dd>This option specifies a static memory buffer that SQLite can use for ** scratch memory. There are three arguments: A pointer to the memory, the ** size of each scratch buffer (sz), and the number of buffers (N). The sz ** argument must be a multiple of 16. The sz parameter should be a few bytes ** larger than the actual scratch space required due internal overhead. ** The first ** argument should point to an allocation of at least sz*N bytes of memory. ** SQLite will use no more than one scratch buffer at once per thread, so ** N should be set to the expected maximum number of threads. The sz ** parameter should be 6 times the size of the largest database page size. ** Scratch buffers are used as part of the btree balance operation. If ** The btree balancer needs additional memory beyond what is provided by ** scratch buffers or if no scratch buffer space is specified, then SQLite ** goes to [sqlite3_malloc()] to obtain the memory it needs.</dd> ** ** <dt>SQLITE_CONFIG_PAGECACHE</dt> ** <dd>This option specifies a static memory buffer that SQLite can use for ** the database page cache. There are three arguments: A pointer to the ** memory, the size of each page buffer (sz), and the number of pages (N). ** The sz argument must be a power of two between 512 and 32768. The first ** argument should point to an allocation of at least sz*N bytes of memory. ** SQLite will use the memory provided by the first argument to satisfy its ** memory needs for the first N pages that it adds to cache. If additional ** page cache memory is needed beyond what is provided by this option, then ** SQLite goes to [sqlite3_malloc()] for the additional storage space. ** The implementation might use one or more of the N buffers to hold ** memory accounting information. </dd> ** ** <dt>SQLITE_CONFIG_HEAP</dt> ** <dd>This option specifies a static memory buffer that SQLite will use ** for all of its dynamic memory allocation needs beyond those provided ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. ** There are three arguments: A pointer to the memory, the number of ** bytes in the memory buffer, and the minimum allocation size. If |
︙ | ︙ | |||
1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 | ** <dd>This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mutex_methods] structure. The ** [sqlite3_mutex_methods] ** structure is filled with the currently defined mutex routines. ** This option can be used to overload the default mutex allocation ** routines with a wrapper used to track mutex usage for performance ** profiling or testing, for example.</dd> */ #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* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ #define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ #define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ #define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ #define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ #define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ /* | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | 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 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 | ** <dd>This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mutex_methods] structure. The ** [sqlite3_mutex_methods] ** structure is filled with the currently defined mutex routines. ** This option can be used to overload the default mutex allocation ** routines with a wrapper used to track mutex usage for performance ** profiling or testing, for example.</dd> ** ** <dt>SQLITE_CONFIG_LOOKASIDE</dt> ** <dd>This option takes two arguments that determine the default ** memory allcation lookaside optimization. The first argument is the ** size of each lookaside buffer slot and the second is the number of ** slots allocated to each database connection.</dd> ** ** </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* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ #define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ #define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ #define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ #define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ #define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ #define SQLITE_CONFIG_CHUNKALLOC 12 /* int threshold */ #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ /* ** CAPI3REF: Configuration Options {H10170} <S20000> ** EXPERIMENTAL ** ** These constants are the available integer configuration options that ** can be passed as the second argument to the [sqlite3_db_config()] interface. ** ** New configuration options may be added in future releases of SQLite. ** Existing configuration options might be discontinued. Applications ** should check the return code from [sqlite3_db_config()] to make sure that ** the call worked. The [sqlite3_db_config()] interface will return a ** non-zero [error code] if a discontinued or unsupported configuration option ** is invoked. ** ** <dl> ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt> ** <dd>This option takes three additional arguments that determine the ** [lookaside memory allocator] configuration for the [database connection]. ** The first argument (the third parameter to [sqlite3_db_config()] is a ** pointer to a memory buffer to use for lookaside memory. The first ** argument may be NULL in which case SQLite will allocate the lookaside ** buffer itself using [sqlite3_malloc()]. The second argument is the ** size of each lookaside buffer slot and the third argument is the number of ** slots. The size of the buffer in the first argument must be greater than ** or equal to the product of the second and third arguments.</dd> ** ** </dl> */ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ /* ** CAPI3REF: Enable Or Disable Extended Result Codes {H12200} <S10700> ** ** The sqlite3_extended_result_codes() routine enables or disables the ** [extended result codes] feature of SQLite. The extended result ** codes are disabled by default for historical compatibility considerations. ** ** INVARIANTS: ** ** {H12201} Each new [database connection] shall have the ** [extended result codes] feature disabled by default. ** ** {H12202} The [sqlite3_extended_result_codes(D,F)] interface shall enable ** [extended result codes] for the [database connection] D ** if the F parameter is true, or disable them if F is false. */ SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); /* ** CAPI3REF: Last Insert Rowid {H12220} <S10700> ** ** Each entry in an SQLite table has a unique 64-bit signed ** integer key called the "rowid". The rowid is always available ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those ** names are not also used by explicitly declared columns. If ** the table has a column of type INTEGER PRIMARY KEY then that column ** is another alias for the rowid. |
︙ | ︙ | |||
1650 1651 1652 1653 1654 1655 1656 | ** the return value of this interface. ** ** For the purposes of this routine, an INSERT is considered to ** be successful even if it is subsequently rolled back. ** ** INVARIANTS: ** | | | | | | 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 | ** the return value of this interface. ** ** For the purposes of this routine, an INSERT is considered to ** be successful even if it is subsequently rolled back. ** ** INVARIANTS: ** ** {H12221} The [sqlite3_last_insert_rowid()] function returns the rowid ** of the most recent successful INSERT performed on the same ** [database connection] and within the same or higher level ** trigger context, or zero if there have been no qualifying inserts. ** ** {H12223} The [sqlite3_last_insert_rowid()] function returns the ** same value when called from the same trigger context ** immediately before and after a ROLLBACK. ** ** ASSUMPTIONS: ** ** {A12232} If a separate thread performs a new INSERT on the same ** database connection while the [sqlite3_last_insert_rowid()] ** function is running and thus changes the last insert rowid, ** then the value returned by [sqlite3_last_insert_rowid()] is ** unpredictable and might not equal either the old or the new ** last insert rowid. */ SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); /* ** CAPI3REF: Count The Number Of Rows Modified {H12240} <S10600> ** ** This function returns the number of database rows that were changed ** or inserted or deleted by the most recently completed SQL statement ** on the [database connection] specified by the first parameter. ** Only changes that are directly specified by the INSERT, UPDATE, ** or DELETE statement are counted. Auxiliary changes caused by ** triggers are not counted. Use the [sqlite3_total_changes()] function |
︙ | ︙ | |||
1721 1722 1723 1724 1725 1726 1727 | ** will not be counted by the sqlite3_changes() or [sqlite3_total_changes()] ** functions, regardless of the number of elements that were originally ** in the table. To get an accurate count of the number of rows deleted, use ** "DELETE FROM table WHERE 1" instead. ** ** INVARIANTS: ** | | | | | | 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 | ** will not be counted by the sqlite3_changes() or [sqlite3_total_changes()] ** functions, regardless of the number of elements that were originally ** in the table. To get an accurate count of the number of rows deleted, use ** "DELETE FROM table WHERE 1" instead. ** ** INVARIANTS: ** ** {H12241} The [sqlite3_changes()] function shall return the number of ** row changes caused by the most recent INSERT, UPDATE, ** or DELETE statement on the same database connection and ** within the same or higher trigger context, or zero if there have ** not been any qualifying row changes. ** ** {H12243} Statements of the form "DELETE FROM tablename" with no ** WHERE clause shall cause subsequent calls to ** [sqlite3_changes()] to return zero, regardless of the ** number of rows originally in the table. ** ** ASSUMPTIONS: ** ** {A12252} If a separate thread makes changes on the same database connection ** while [sqlite3_changes()] is running then the value returned ** is unpredictable and not meaningful. */ SQLITE_API int sqlite3_changes(sqlite3*); /* ** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600> ** ** This function returns the number of row changes caused by INSERT, ** UPDATE or DELETE statements since the [database connection] was opened. ** The count includes all changes from all trigger contexts. However, ** the count does not include changes used to implement REPLACE constraints, ** do rollbacks or ABORT processing, or DROP table processing. ** The changes are counted as soon as the statement that makes them is |
︙ | ︙ | |||
1765 1766 1767 1768 1769 1770 1771 | ** in the table. To get an accurate count of the number of rows deleted, use ** "DELETE FROM table WHERE 1" instead. ** ** See also the [sqlite3_changes()] interface. ** ** INVARIANTS: ** | | | | | | 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 | ** in the table. To get an accurate count of the number of rows deleted, use ** "DELETE FROM table WHERE 1" instead. ** ** See also the [sqlite3_changes()] interface. ** ** INVARIANTS: ** ** {H12261} The [sqlite3_total_changes()] returns the total number ** of row changes caused by INSERT, UPDATE, and/or DELETE ** statements on the same [database connection], in any ** trigger context, since the database connection was created. ** ** {H12263} Statements of the form "DELETE FROM tablename" with no ** WHERE clause shall not change the value returned ** by [sqlite3_total_changes()]. ** ** ASSUMPTIONS: ** ** {A12264} If a separate thread makes changes on the same database connection ** while [sqlite3_total_changes()] is running then the value ** returned is unpredictable and not meaningful. */ SQLITE_API int sqlite3_total_changes(sqlite3*); /* ** CAPI3REF: Interrupt A Long-Running Query {H12270} <S30500> ** ** This function causes any pending database operation to abort and ** return at its earliest opportunity. This routine is typically ** called in response to a user action such as pressing "Cancel" ** or Ctrl-C where the user wants a long query operation to halt ** immediately. ** |
︙ | ︙ | |||
1810 1811 1812 1813 1814 1815 1816 | ** will be rolled back automatically. ** ** A call to sqlite3_interrupt() has no effect on SQL statements ** that are started after sqlite3_interrupt() returns. ** ** INVARIANTS: ** | | | | | | | | | | 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 | ** will be rolled back automatically. ** ** A call to sqlite3_interrupt() has no effect on SQL statements ** that are started after sqlite3_interrupt() returns. ** ** INVARIANTS: ** ** {H12271} The [sqlite3_interrupt()] interface will force all running ** SQL statements associated with the same database connection ** to halt after processing at most one additional row of data. ** ** {H12272} Any SQL statement that is interrupted by [sqlite3_interrupt()] ** will return [SQLITE_INTERRUPT]. ** ** ASSUMPTIONS: ** ** {A12279} If the database connection closes while [sqlite3_interrupt()] ** is running then bad things will likely happen. */ SQLITE_API void sqlite3_interrupt(sqlite3*); /* ** CAPI3REF: Determine If An SQL Statement Is Complete {H10510} <S70200> ** ** These routines are useful for command-line input to determine if the ** currently entered text seems to form complete a SQL statement or ** if additional input is needed before sending the text into ** SQLite for parsing. These routines return true if the input string ** appears to be a complete SQL statement. A statement is judged to be ** complete if it ends with a semicolon token and is not a fragment of a ** CREATE TRIGGER statement. Semicolons that are embedded within ** string literals or quoted identifier names or comments are not ** independent tokens (they are part of the token in which they are ** embedded) and thus do not count as a statement terminator. ** ** These routines do not parse the SQL statements thus ** will not detect syntactically incorrect SQL. ** ** INVARIANTS: ** ** {H10511} A successful evaluation of [sqlite3_complete()] or ** [sqlite3_complete16()] functions shall ** return a numeric 1 if and only if the last non-whitespace ** token in their input is a semicolon that is not in between ** the BEGIN and END of a CREATE TRIGGER statement. ** ** {H10512} If a memory allocation error occurs during an invocation ** of [sqlite3_complete()] or [sqlite3_complete16()] then the ** routine shall return [SQLITE_NOMEM]. ** ** ASSUMPTIONS: ** ** {A10512} The input to [sqlite3_complete()] must be a zero-terminated ** UTF-8 string. ** ** {A10513} The input to [sqlite3_complete16()] must be a zero-terminated ** UTF-16 string in native byte order. */ SQLITE_API int sqlite3_complete(const char *sql); SQLITE_API int sqlite3_complete16(const void *sql); /* ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors {H12310} <S40400> ** ** This routine sets a callback function that might be invoked whenever ** an attempt is made to open a database table that another thread ** or process has locked. ** ** If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] ** is returned immediately upon encountering the lock. If the busy callback |
︙ | ︙ | |||
1923 1924 1925 1926 1927 1928 1929 | ** There can only be a single busy handler defined for each ** [database connection]. Setting a new busy handler clears any ** previously set handler. Note that calling [sqlite3_busy_timeout()] ** will also set or clear the busy handler. ** ** INVARIANTS: ** | | | | | | | | | | | | | | 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 | ** There can only be a single busy handler defined for each ** [database connection]. Setting a new busy handler clears any ** previously set handler. Note that calling [sqlite3_busy_timeout()] ** will also set or clear the busy handler. ** ** INVARIANTS: ** ** {H12311} The [sqlite3_busy_handler(D,C,A)] function shall replace ** busy callback in the [database connection] D with a new ** a new busy handler C and application data pointer A. ** ** {H12312} Newly created [database connections] shall have a busy ** handler of NULL. ** ** {H12314} When two or more [database connections] share a ** [sqlite3_enable_shared_cache | common cache], ** the busy handler for the database connection currently using ** the cache shall be invoked when the cache encounters a lock. ** ** {H12316} If a busy handler callback returns zero, then the SQLite interface ** that provoked the locking event shall return [SQLITE_BUSY]. ** ** {H12318} SQLite shall invokes the busy handler with two arguments which ** are a copy of the pointer supplied by the 3rd parameter to ** [sqlite3_busy_handler()] and a count of the number of prior ** invocations of the busy handler for the same locking event. ** ** ASSUMPTIONS: ** ** {A12319} A busy handler must not close the database connection ** or [prepared statement] that invoked the busy handler. */ SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); /* ** CAPI3REF: Set A Busy Timeout {H12340} <S40410> ** ** This routine sets a [sqlite3_busy_handler | busy handler] that sleeps ** for a specified amount of time when a table is locked. The handler ** will sleep multiple times until at least "ms" milliseconds of sleeping ** have accumulated. {H12343} After "ms" milliseconds of sleeping, ** the handler returns 0 which causes [sqlite3_step()] to return ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. ** ** Calling this routine with an argument less than or equal to zero ** turns off all busy handlers. ** ** There can only be a single busy handler for a particular ** [database connection] any any given moment. If another busy handler ** was defined (using [sqlite3_busy_handler()]) prior to calling ** this routine, that other busy handler is cleared. ** ** INVARIANTS: ** ** {H12341} The [sqlite3_busy_timeout()] function shall override any prior ** [sqlite3_busy_timeout()] or [sqlite3_busy_handler()] setting ** on the same [database connection]. ** ** {H12343} If the 2nd parameter to [sqlite3_busy_timeout()] is less than ** or equal to zero, then the busy handler shall be cleared so that ** all subsequent locking events immediately return [SQLITE_BUSY]. ** ** {H12344} If the 2nd parameter to [sqlite3_busy_timeout()] is a positive ** number N, then a busy handler shall be set that repeatedly calls ** the xSleep() method in the [sqlite3_vfs | VFS interface] until ** either the lock clears or until the cumulative sleep time ** reported back by xSleep() exceeds N milliseconds. */ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); /* ** CAPI3REF: Convenience Routines For Running Queries {H12370} <S10000> ** ** Definition: A <b>result table</b> is memory data structure created by the ** [sqlite3_get_table()] interface. A result table records the ** complete query results from one or more queries. ** ** The table conceptually has a number of rows and columns. But ** these numbers are not part of the result table itself. These |
︙ | ︙ | |||
2056 2057 2058 2059 2060 2061 2062 | ** to any internal data structures of SQLite. It uses only the public ** interface defined here. As a consequence, errors that occur in the ** wrapper layer outside of the internal [sqlite3_exec()] call are not ** reflected in subsequent calls to [sqlite3_errcode()] or [sqlite3_errmsg()]. ** ** INVARIANTS: ** | | | | | | | | | 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 | ** to any internal data structures of SQLite. It uses only the public ** interface defined here. As a consequence, errors that occur in the ** wrapper layer outside of the internal [sqlite3_exec()] call are not ** reflected in subsequent calls to [sqlite3_errcode()] or [sqlite3_errmsg()]. ** ** INVARIANTS: ** ** {H12371} If a [sqlite3_get_table()] fails a memory allocation, then ** it shall free the result table under construction, abort the ** query in process, skip any subsequent queries, set the ** *pazResult output pointer to NULL and return [SQLITE_NOMEM]. ** ** {H12373} If the pnColumn parameter to [sqlite3_get_table()] is not NULL ** then a successful invocation of [sqlite3_get_table()] shall ** write the number of columns in the ** result set of the query into *pnColumn. ** ** {H12374} If the pnRow parameter to [sqlite3_get_table()] is not NULL ** then a successful invocation of [sqlite3_get_table()] shall ** writes the number of rows in the ** result set of the query into *pnRow. ** ** {H12376} A successful invocation of [sqlite3_get_table()] that computes ** N rows of result with C columns per row shall make *pazResult ** point to an array of pointers to (N+1)*C strings where the first ** C strings are column names as obtained from ** [sqlite3_column_name()] and the rest are column result values ** obtained from [sqlite3_column_text()]. ** ** {H12379} The values in the pazResult array returned by [sqlite3_get_table()] ** shall remain valid until cleared by [sqlite3_free_table()]. ** ** {H12382} When an error occurs during evaluation of [sqlite3_get_table()] ** the function shall set *pazResult to NULL, write an error message ** into memory obtained from [sqlite3_malloc()], make ** **pzErrmsg point to that error message, and return a ** appropriate [error code]. */ SQLITE_API int sqlite3_get_table( sqlite3 *db, /* An open database */ const char *zSql, /* SQL to be evaluated */ char ***pazResult, /* Results of the query */ int *pnRow, /* Number of result rows written here */ int *pnColumn, /* Number of result columns written here */ char **pzErrmsg /* Error msg written here */ ); SQLITE_API void sqlite3_free_table(char **result); /* ** CAPI3REF: Formatted String Printing Functions {H17400} <S70000><S20000> ** ** These routines are workalikes of the "printf()" family of functions ** from the standard C library. ** ** The sqlite3_mprintf() and sqlite3_vmprintf() routines write their ** results into memory obtained from [sqlite3_malloc()]. ** The strings returned by these two routines should be |
︙ | ︙ | |||
2191 2192 2193 2194 2195 2196 2197 | ** ** The "%z" formatting option works exactly like "%s" with the ** addition that after the string has been read and copied into ** the result, [sqlite3_free()] is called on the input string. {END} ** ** INVARIANTS: ** | | | | | | 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 | ** ** The "%z" formatting option works exactly like "%s" with the ** addition that after the string has been read and copied into ** the result, [sqlite3_free()] is called on the input string. {END} ** ** INVARIANTS: ** ** {H17403} The [sqlite3_mprintf()] and [sqlite3_vmprintf()] interfaces ** return either pointers to zero-terminated UTF-8 strings held in ** memory obtained from [sqlite3_malloc()] or NULL pointers if ** a call to [sqlite3_malloc()] fails. ** ** {H17406} The [sqlite3_snprintf()] interface writes a zero-terminated ** UTF-8 string into the buffer pointed to by the second parameter ** provided that the first parameter is greater than zero. ** ** {H17407} The [sqlite3_snprintf()] interface does not write slots of ** its output buffer (the second parameter) outside the range ** of 0 through N-1 (where N is the first parameter) ** regardless of the length of the string ** requested by the format specification. */ SQLITE_API char *sqlite3_mprintf(const char*,...); SQLITE_API char *sqlite3_vmprintf(const char*, va_list); SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); /* ** CAPI3REF: Memory Allocation Subsystem {H17300} <S20000> ** ** The SQLite core uses these three routines for all of its own ** internal memory allocation needs. "Core" in the previous sentence ** does not include operating-system specific VFS implementation. The ** Windows VFS uses native malloc() and free() for some operations. ** ** The sqlite3_malloc() routine returns a pointer to a block |
︙ | ︙ | |||
2258 2259 2260 2261 2262 2263 2264 | ** is not freed. ** ** The memory returned by sqlite3_malloc() and sqlite3_realloc() ** is always aligned to at least an 8 byte boundary. {END} ** ** The default implementation of the memory allocation subsystem uses ** the malloc(), realloc() and free() provided by the standard C library. | | | 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 | ** is not freed. ** ** The memory returned by sqlite3_malloc() and sqlite3_realloc() ** is always aligned to at least an 8 byte boundary. {END} ** ** The default implementation of the memory allocation subsystem uses ** the malloc(), realloc() and free() provided by the standard C library. ** {H17382} However, if SQLite is compiled with the ** SQLITE_MEMORY_SIZE=<i>NNN</i> C preprocessor macro (where <i>NNN</i> ** is an integer), then SQLite create a static array of at least ** <i>NNN</i> bytes in size and uses that array for all of its dynamic ** memory allocation needs. {END} Additional memory allocator options ** may be added in future releases. ** ** In SQLite version 3.5.0 and 3.5.1, it was possible to define |
︙ | ︙ | |||
2280 2281 2282 2283 2284 2285 2286 | ** and whatever filename encoding is used by the particular Windows ** installation. Memory allocation errors are detected, but ** they are reported back as [SQLITE_CANTOPEN] or ** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | | | | | 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 | ** and whatever filename encoding is used by the particular Windows ** installation. Memory allocation errors are detected, but ** they are reported back as [SQLITE_CANTOPEN] or ** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. ** ** INVARIANTS: ** ** {H17303} The [sqlite3_malloc(N)] interface returns either a pointer to ** a newly checked-out block of at least N bytes of memory ** that is 8-byte aligned, or it returns NULL if it is unable ** to fulfill the request. ** ** {H17304} The [sqlite3_malloc(N)] interface returns a NULL pointer if ** N is less than or equal to zero. ** ** {H17305} The [sqlite3_free(P)] interface releases memory previously ** returned from [sqlite3_malloc()] or [sqlite3_realloc()], ** making it available for reuse. ** ** {H17306} A call to [sqlite3_free(NULL)] is a harmless no-op. ** ** {H17310} A call to [sqlite3_realloc(0,N)] is equivalent to a call ** to [sqlite3_malloc(N)]. ** ** {H17312} A call to [sqlite3_realloc(P,0)] is equivalent to a call ** to [sqlite3_free(P)]. ** ** {H17315} The SQLite core uses [sqlite3_malloc()], [sqlite3_realloc()], ** and [sqlite3_free()] for all of its memory allocation and ** deallocation needs. ** ** {H17318} The [sqlite3_realloc(P,N)] interface returns either a pointer ** to a block of checked-out memory of at least N bytes in size ** that is 8-byte aligned, or a NULL pointer. ** ** {H17321} When [sqlite3_realloc(P,N)] returns a non-NULL pointer, it first ** copies the first K bytes of content from P into the newly ** allocated block, where K is the lesser of N and the size of ** the buffer P. ** ** {H17322} When [sqlite3_realloc(P,N)] returns a non-NULL pointer, it first ** releases the buffer P. ** ** {H17323} When [sqlite3_realloc(P,N)] returns NULL, the buffer P is ** not modified or released. ** ** ASSUMPTIONS: ** ** {A17350} The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] ** must be either NULL or else pointers obtained from a prior ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have ** not yet been released. ** ** {A17351} The application must not read or write any part of ** a block of memory after it has been released using ** [sqlite3_free()] or [sqlite3_realloc()]. */ SQLITE_API void *sqlite3_malloc(int); SQLITE_API void *sqlite3_realloc(void*, int); SQLITE_API void sqlite3_free(void*); /* ** CAPI3REF: Memory Allocator Statistics {H17370} <S30210> ** ** SQLite provides these two interfaces for reporting on the status ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] ** routines, which form the built-in memory allocation subsystem. ** ** INVARIANTS: ** ** {H17371} The [sqlite3_memory_used()] routine returns the number of bytes ** of memory currently outstanding (malloced but not freed). ** ** {H17373} The [sqlite3_memory_highwater()] routine returns the maximum ** value of [sqlite3_memory_used()] since the high-water mark ** was last reset. ** ** {H17374} The values returned by [sqlite3_memory_used()] and ** [sqlite3_memory_highwater()] include any overhead ** added by SQLite in its implementation of [sqlite3_malloc()], ** but not overhead added by the any underlying system library ** routines that [sqlite3_malloc()] may call. ** ** {H17375} The memory high-water mark is reset to the current value of ** [sqlite3_memory_used()] if and only if the parameter to ** [sqlite3_memory_highwater()] is true. The value returned ** by [sqlite3_memory_highwater(1)] is the high-water mark ** prior to the reset. */ SQLITE_API sqlite3_int64 sqlite3_memory_used(void); SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); /* ** CAPI3REF: Pseudo-Random Number Generator {H17390} <S20000> ** ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to ** select random ROWIDs when inserting new records into a table that ** already uses the largest possible ROWID. The PRNG is also used for ** the build-in random() and randomblob() SQL functions. This interface allows ** applications to access the same PRNG for other purposes. ** ** A call to this routine stores N bytes of randomness into buffer P. ** ** The first time this routine is invoked (either internally or by ** the application) the PRNG is seeded using randomness obtained ** from the xRandomness method of the default [sqlite3_vfs] object. ** On all subsequent invocations, the pseudo-randomness is generated ** internally and without recourse to the [sqlite3_vfs] xRandomness ** method. ** ** INVARIANTS: ** ** {H17392} The [sqlite3_randomness(N,P)] interface writes N bytes of ** high-quality pseudo-randomness into buffer P. */ SQLITE_API void sqlite3_randomness(int N, void *P); /* ** CAPI3REF: Compile-Time Authorization Callbacks {H12500} <S70100> ** ** This routine registers a authorizer callback with a particular ** [database connection], supplied in the first argument. ** The authorizer callback is invoked as SQL statements are being compiled ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. At various ** points during the compilation process, as logic is being created |
︙ | ︙ | |||
2455 2456 2457 2458 2459 2460 2461 | ** ** Note that the authorizer callback is invoked only during ** [sqlite3_prepare()] or its variants. Authorization is not ** performed during statement evaluation in [sqlite3_step()]. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | | | | 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 | ** ** Note that the authorizer callback is invoked only during ** [sqlite3_prepare()] or its variants. Authorization is not ** performed during statement evaluation in [sqlite3_step()]. ** ** INVARIANTS: ** ** {H12501} The [sqlite3_set_authorizer(D,...)] interface registers a ** authorizer callback with database connection D. ** ** {H12502} The authorizer callback is invoked as SQL statements are ** being compiled. ** ** {H12503} If the authorizer callback returns any value other than ** [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY], then ** the [sqlite3_prepare_v2()] or equivalent call that caused ** the authorizer callback to run shall fail with an ** [SQLITE_ERROR] error code and an appropriate error message. ** ** {H12504} When the authorizer callback returns [SQLITE_OK], the operation ** described is processed normally. ** ** {H12505} When the authorizer callback returns [SQLITE_DENY], the ** [sqlite3_prepare_v2()] or equivalent call that caused the ** authorizer callback to run shall fail ** with an [SQLITE_ERROR] error code and an error message ** explaining that access is denied. ** ** {H12506} If the authorizer code (the 2nd parameter to the authorizer ** callback) is [SQLITE_READ] and the authorizer callback returns ** [SQLITE_IGNORE], then the prepared statement is constructed to ** insert a NULL value in place of the table column that would have ** been read if [SQLITE_OK] had been returned. ** ** {H12507} If the authorizer code (the 2nd parameter to the authorizer ** callback) is anything other than [SQLITE_READ], then ** a return of [SQLITE_IGNORE] has the same effect as [SQLITE_DENY]. ** ** {H12510} The first parameter to the authorizer callback is a copy of ** the third parameter to the [sqlite3_set_authorizer()] interface. ** ** {H12511} The second parameter to the callback is an integer ** [SQLITE_COPY | action code] that specifies the particular action ** to be authorized. ** ** {H12512} The third through sixth parameters to the callback are ** zero-terminated strings that contain ** additional details about the action to be authorized. ** ** {H12520} Each call to [sqlite3_set_authorizer()] overrides ** any previously installed authorizer. ** ** {H12521} A NULL authorizer means that no authorization ** callback is invoked. ** ** {H12522} The default authorizer is NULL. */ SQLITE_API int sqlite3_set_authorizer( sqlite3*, int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), void *pUserData ); /* ** CAPI3REF: Authorizer Return Codes {H12590} <H12500> ** ** The [sqlite3_set_authorizer | authorizer callback function] must ** return either [SQLITE_OK] or one of these two constants in order ** to signal SQLite whether or not the action is permitted. See the ** [sqlite3_set_authorizer | authorizer documentation] for additional ** information. */ #define SQLITE_DENY 1 /* Abort the SQL statement with an error */ #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ /* ** CAPI3REF: Authorizer Action Codes {H12550} <H12500> ** ** The [sqlite3_set_authorizer()] interface registers a callback function ** that is invoked to authorize certain SQL statement actions. The ** second parameter to the callback is an integer code that specifies ** what action is being authorized. These are the integer action codes that ** the authorizer callback may be passed. ** ** These action code values signify what kind of operation is to be ** authorized. The 3rd and 4th parameters to the authorization ** callback function will be parameters or NULL depending on which of these ** codes is used as the second parameter. The 5th parameter to the ** authorizer callback is the name of the database ("main", "temp", ** etc.) if applicable. The 6th parameter to the authorizer callback ** is the name of the inner-most trigger or view that is responsible for ** the access attempt or NULL if this access attempt is directly from ** top-level SQL code. ** ** INVARIANTS: ** ** {H12551} The second parameter to an ** [sqlite3_set_authorizer | authorizer callback] is always an integer ** [SQLITE_COPY | authorizer code] that specifies what action ** is being authorized. ** ** {H12552} The 3rd and 4th parameters to the ** [sqlite3_set_authorizer | authorization callback] ** will be parameters or NULL depending on which ** [SQLITE_COPY | authorizer code] is used as the second parameter. ** ** {H12553} The 5th parameter to the ** [sqlite3_set_authorizer | authorizer callback] is the name ** of the database (example: "main", "temp", etc.) if applicable. ** ** {H12554} The 6th parameter to the ** [sqlite3_set_authorizer | authorizer callback] is the name ** of the inner-most trigger or view that is responsible for ** the access attempt or NULL if this access attempt is directly from ** top-level SQL code. */ /******************************************* 3rd ************ 4th ***********/ #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ |
︙ | ︙ | |||
2599 2600 2601 2602 2603 2604 2605 | #define SQLITE_ANALYZE 28 /* Table Name NULL */ #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ #define SQLITE_FUNCTION 31 /* Function Name NULL */ #define SQLITE_COPY 0 /* No longer used */ /* | | > < < < < < < < < | | | | | | | | | | | | | | | | | | > | | 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 | #define SQLITE_ANALYZE 28 /* Table Name NULL */ #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ #define SQLITE_FUNCTION 31 /* Function Name NULL */ #define SQLITE_COPY 0 /* No longer used */ /* ** CAPI3REF: Tracing And Profiling Functions {H12280} <S60400> ** EXPERIMENTAL ** ** These routines register callback functions that can be used for ** tracing and profiling the execution of SQL statements. ** ** The callback function registered by sqlite3_trace() is invoked at ** various times when an SQL statement is being run by [sqlite3_step()]. ** The callback returns a UTF-8 rendering of the SQL statement text ** as the statement first begins executing. Additional callbacks occur ** as each triggered subprogram is entered. The callbacks for triggers ** contain a UTF-8 SQL comment that identifies the trigger. ** ** The callback function registered by sqlite3_profile() is invoked ** as each SQL statement finishes. The profile callback contains ** the original statement text and an estimate of wall-clock time ** of how long that statement took to run. ** ** INVARIANTS: ** ** {H12281} The callback function registered by [sqlite3_trace()] is ** whenever an SQL statement first begins to execute and ** whenever a trigger subprogram first begins to run. ** ** {H12282} Each call to [sqlite3_trace()] overrides the previously ** registered trace callback. ** ** {H12283} A NULL trace callback disables tracing. ** ** {H12284} The first argument to the trace callback is a copy of ** the pointer which was the 3rd argument to [sqlite3_trace()]. ** ** {H12285} The second argument to the trace callback is a ** zero-terminated UTF-8 string containing the original text ** of the SQL statement as it was passed into [sqlite3_prepare_v2()] ** or the equivalent, or an SQL comment indicating the beginning ** of a trigger subprogram. ** ** {H12287} The callback function registered by [sqlite3_profile()] is invoked ** as each SQL statement finishes. ** ** {H12288} The first parameter to the profile callback is a copy of ** the 3rd parameter to [sqlite3_profile()]. ** ** {H12289} The second parameter to the profile callback is a ** zero-terminated UTF-8 string that contains the complete text of ** the SQL statement as it was processed by [sqlite3_prepare_v2()] ** or the equivalent. ** ** {H12290} The third parameter to the profile callback is an estimate ** of the number of nanoseconds of wall-clock time required to ** run the SQL statement from start to finish. */ SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); SQLITE_API void *sqlite3_profile(sqlite3*, void(*xProfile)(void*,const char*,sqlite3_uint64), void*); /* ** CAPI3REF: Query Progress Callbacks {H12910} <S60400> ** ** This routine configures a callback function - the ** progress callback - that is invoked periodically during long ** running calls to [sqlite3_exec()], [sqlite3_step()] and ** [sqlite3_get_table()]. An example use for this ** interface is to keep a GUI updated during a large query. ** ** If the progress callback returns non-zero, the operation is ** interrupted. This feature can be used to implement a ** "Cancel" button on a GUI dialog box. ** ** INVARIANTS: ** ** {H12911} The callback function registered by sqlite3_progress_handler() ** is invoked periodically during long running calls to ** [sqlite3_step()]. ** ** {H12912} The progress callback is invoked once for every N virtual ** machine opcodes, where N is the second argument to ** the [sqlite3_progress_handler()] call that registered ** the callback. If N is less than 1, sqlite3_progress_handler() ** acts as if a NULL progress handler had been specified. ** ** {H12913} The progress callback itself is identified by the third ** argument to sqlite3_progress_handler(). ** ** {H12914} The fourth argument to sqlite3_progress_handler() is a ** void pointer passed to the progress callback ** function each time it is invoked. ** ** {H12915} If a call to [sqlite3_step()] results in fewer than N opcodes ** being executed, then the progress callback is never invoked. ** ** {H12916} Every call to [sqlite3_progress_handler()] ** overwrites any previously registered progress handler. ** ** {H12917} If the progress handler callback is NULL then no progress ** handler is invoked. ** ** {H12918} If the progress callback returns a result other than 0, then ** the behavior is a if [sqlite3_interrupt()] had been called. ** <S30500> */ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); /* ** CAPI3REF: Opening A New Database Connection {H12700} <S40200> ** ** These routines open an SQLite database file whose name is given by the ** filename argument. The filename argument is interpreted as UTF-8 for ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte ** order for sqlite3_open16(). A [database connection] handle is usually ** returned in *ppDb, even if an error occurs. The only exception is that ** if SQLite is unable to allocate memory to hold the [sqlite3] object, |
︙ | ︙ | |||
2792 2793 2794 2795 2796 2797 2798 | ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever ** codepage is currently defined. Filenames containing international ** characters must be converted to UTF-8 prior to passing them into ** sqlite3_open() or sqlite3_open_v2(). ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | | | | | | | 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 | ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever ** codepage is currently defined. Filenames containing international ** characters must be converted to UTF-8 prior to passing them into ** sqlite3_open() or sqlite3_open_v2(). ** ** INVARIANTS: ** ** {H12701} The [sqlite3_open()], [sqlite3_open16()], and ** [sqlite3_open_v2()] interfaces create a new ** [database connection] associated with ** the database file given in their first parameter. ** ** {H12702} The filename argument is interpreted as UTF-8 ** for [sqlite3_open()] and [sqlite3_open_v2()] and as UTF-16 ** in the native byte order for [sqlite3_open16()]. ** ** {H12703} A successful invocation of [sqlite3_open()], [sqlite3_open16()], ** or [sqlite3_open_v2()] writes a pointer to a new ** [database connection] into *ppDb. ** ** {H12704} The [sqlite3_open()], [sqlite3_open16()], and ** [sqlite3_open_v2()] interfaces return [SQLITE_OK] upon success, ** or an appropriate [error code] on failure. ** ** {H12706} The default text encoding for a new database created using ** [sqlite3_open()] or [sqlite3_open_v2()] will be UTF-8. ** ** {H12707} The default text encoding for a new database created using ** [sqlite3_open16()] will be UTF-16. ** ** {H12709} The [sqlite3_open(F,D)] interface is equivalent to ** [sqlite3_open_v2(F,D,G,0)] where the G parameter is ** [SQLITE_OPEN_READWRITE]|[SQLITE_OPEN_CREATE]. ** ** {H12711} If the G parameter to [sqlite3_open_v2(F,D,G,V)] contains the ** bit value [SQLITE_OPEN_READONLY] then the database is opened ** for reading only. ** ** {H12712} If the G parameter to [sqlite3_open_v2(F,D,G,V)] contains the ** bit value [SQLITE_OPEN_READWRITE] then the database is opened ** reading and writing if possible, or for reading only if the ** file is write protected by the operating system. ** ** {H12713} If the G parameter to [sqlite3_open(v2(F,D,G,V)] omits the ** bit value [SQLITE_OPEN_CREATE] and the database does not ** previously exist, an error is returned. ** ** {H12714} If the G parameter to [sqlite3_open(v2(F,D,G,V)] contains the ** bit value [SQLITE_OPEN_CREATE] and the database does not ** previously exist, then an attempt is made to create and ** initialize the database. ** ** {H12717} If the filename argument to [sqlite3_open()], [sqlite3_open16()], ** or [sqlite3_open_v2()] is ":memory:", then an private, ** ephemeral, in-memory database is created for the connection. ** <todo>Is SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE required ** in sqlite3_open_v2()?</todo> ** ** {H12719} If the filename is NULL or an empty string, then a private, ** ephemeral on-disk database will be created. ** <todo>Is SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE required ** in sqlite3_open_v2()?</todo> ** ** {H12721} The [database connection] created by [sqlite3_open_v2(F,D,G,V)] ** will use the [sqlite3_vfs] object identified by the V parameter, ** or the default [sqlite3_vfs] object if V is a NULL pointer. ** ** {H12723} Two [database connections] will share a common cache if both were ** opened with the same VFS while [shared cache mode] was enabled and ** if both filenames compare equal using memcmp() after having been ** processed by the [sqlite3_vfs | xFullPathname] method of the VFS. */ SQLITE_API int sqlite3_open( const char *filename, /* Database filename (UTF-8) */ sqlite3 **ppDb /* OUT: SQLite db handle */ ); SQLITE_API int sqlite3_open16( const void *filename, /* Database filename (UTF-16) */ sqlite3 **ppDb /* OUT: SQLite db handle */ ); SQLITE_API int sqlite3_open_v2( const char *filename, /* Database filename (UTF-8) */ sqlite3 **ppDb, /* OUT: SQLite db handle */ int flags, /* Flags */ const char *zVfs /* Name of VFS module to use */ ); /* ** CAPI3REF: Error Codes And Messages {H12800} <S60200> ** ** The sqlite3_errcode() interface returns the numeric [result code] or ** [extended result code] for the most recent failed sqlite3_* API call ** associated with a [database connection]. If a prior API call failed ** but the most recent API call succeeded, the return value from ** sqlite3_errcode() is undefined. ** ** The sqlite3_errmsg() and sqlite3_errmsg16() return English-language ** text that describes the error, as either UTF-8 or UTF-16 respectively. ** Memory to hold the error message string is managed internally. ** The application does not need to worry about freeing the result. ** However, the error string might be overwritten or deallocated by ** subsequent calls to other SQLite interface functions. ** ** If an interface fails with SQLITE_MISUSE, that means the interface ** was invoked incorrectly by the application. In that case, the ** error code and message may or may not be set. ** ** INVARIANTS: ** ** {H12801} The [sqlite3_errcode(D)] interface returns the numeric ** [result code] or [extended result code] for the most recently ** failed interface call associated with the [database connection] D. ** ** {H12803} The [sqlite3_errmsg(D)] and [sqlite3_errmsg16(D)] ** interfaces return English-language text that describes ** the error in the mostly recently failed interface call, ** encoded as either UTF-8 or UTF-16 respectively. ** ** {H12807} The strings returned by [sqlite3_errmsg()] and [sqlite3_errmsg16()] ** are valid until the next SQLite interface call. ** ** {H12808} Calls to API routines that do not return an error code ** (example: [sqlite3_data_count()]) do not ** change the error code or message returned by ** [sqlite3_errcode()], [sqlite3_errmsg()], or [sqlite3_errmsg16()]. ** ** {H12809} Interfaces that are not associated with a specific ** [database connection] (examples: ** [sqlite3_mprintf()] or [sqlite3_enable_shared_cache()] ** do not change the values returned by ** [sqlite3_errcode()], [sqlite3_errmsg()], or [sqlite3_errmsg16()]. */ SQLITE_API int sqlite3_errcode(sqlite3 *db); SQLITE_API const char *sqlite3_errmsg(sqlite3*); SQLITE_API const void *sqlite3_errmsg16(sqlite3*); /* ** CAPI3REF: SQL Statement Object {H13000} <H13010> ** KEYWORDS: {prepared statement} {prepared statements} ** ** An instance of this object represents a single SQL statement. ** This object is variously known as a "prepared statement" or a ** "compiled SQL statement" or simply as a "statement". ** ** The life of a statement object goes something like this: |
︙ | ︙ | |||
2948 2949 2950 2951 2952 2953 2954 | ** ** Refer to documentation on individual methods above for additional ** information. */ typedef struct sqlite3_stmt sqlite3_stmt; /* | | | 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 | ** ** Refer to documentation on individual methods above for additional ** information. */ typedef struct sqlite3_stmt sqlite3_stmt; /* ** CAPI3REF: Run-time Limits {H12760} <S20600> ** ** This interface allows the size of various constructs to be limited ** on a connection by connection basis. The first parameter is the ** [database connection] whose limit is to be set or queried. The ** second parameter is one of the [limit categories] that define a ** class of constructs to be size limited. The third parameter is the ** new limit for that construct. The function returns the old limit. |
︙ | ︙ | |||
2981 2982 2983 2984 2985 2986 2987 | ** created by an untrusted script can be contained using the ** [max_page_count] [PRAGMA]. ** ** New run-time limit categories may be added in future releases. ** ** INVARIANTS: ** | | | | | | 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 | ** created by an untrusted script can be contained using the ** [max_page_count] [PRAGMA]. ** ** New run-time limit categories may be added in future releases. ** ** INVARIANTS: ** ** {H12762} A successful call to [sqlite3_limit(D,C,V)] where V is ** positive changes the limit on the size of construct C in the ** [database connection] D to the lesser of V and the hard upper ** bound on the size of C that is set at compile-time. ** ** {H12766} A successful call to [sqlite3_limit(D,C,V)] where V is negative ** leaves the state of the [database connection] D unchanged. ** ** {H12769} A successful call to [sqlite3_limit(D,C,V)] returns the ** value of the limit on the size of construct C in the ** [database connection] D as it was prior to the call. */ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); /* ** CAPI3REF: Run-Time Limit Categories {H12790} <H12760> ** KEYWORDS: {limit category} {limit categories} ** ** These constants define various aspects of a [database connection] ** that can be limited in size by calls to [sqlite3_limit()]. ** The meanings of the various limits are as follows: ** ** <dl> |
︙ | ︙ | |||
3052 3053 3054 3055 3056 3057 3058 | #define SQLITE_LIMIT_VDBE_OP 5 #define SQLITE_LIMIT_FUNCTION_ARG 6 #define SQLITE_LIMIT_ATTACHED 7 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 #define SQLITE_LIMIT_VARIABLE_NUMBER 9 /* | | | 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 | #define SQLITE_LIMIT_VDBE_OP 5 #define SQLITE_LIMIT_FUNCTION_ARG 6 #define SQLITE_LIMIT_ATTACHED 7 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 #define SQLITE_LIMIT_VARIABLE_NUMBER 9 /* ** CAPI3REF: Compiling An SQL Statement {H13010} <S10000> ** KEYWORDS: {SQL statement compiler} ** ** To execute an SQL query, it must first be compiled into a byte-code ** program using one of these routines. ** ** The first argument, "db", is a [database connection] obtained from a ** prior call to [sqlite3_open()], [sqlite3_open_v2()] or [sqlite3_open16()]. |
︙ | ︙ | |||
3122 3123 3124 3125 3126 3127 3128 | ** to find the underlying cause of the problem. With the "v2" prepare ** interfaces, the underlying reason for the error is returned immediately. ** </li> ** </ol> ** ** INVARIANTS: ** | | | | | | | | | | 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 | ** to find the underlying cause of the problem. With the "v2" prepare ** interfaces, the underlying reason for the error is returned immediately. ** </li> ** </ol> ** ** INVARIANTS: ** ** {H13011} The [sqlite3_prepare(db,zSql,...)] and ** [sqlite3_prepare_v2(db,zSql,...)] interfaces interpret the ** text in their zSql parameter as UTF-8. ** ** {H13012} The [sqlite3_prepare16(db,zSql,...)] and ** [sqlite3_prepare16_v2(db,zSql,...)] interfaces interpret the ** text in their zSql parameter as UTF-16 in the native byte order. ** ** {H13013} If the nByte argument to [sqlite3_prepare_v2(db,zSql,nByte,...)] ** and its variants is less than zero, the SQL text is ** read from zSql is read up to the first zero terminator. ** ** {H13014} If the nByte argument to [sqlite3_prepare_v2(db,zSql,nByte,...)] ** and its variants is non-negative, then at most nBytes bytes of ** SQL text is read from zSql. ** ** {H13015} In [sqlite3_prepare_v2(db,zSql,N,P,pzTail)] and its variants ** if the zSql input text contains more than one SQL statement ** and pzTail is not NULL, then *pzTail is made to point to the ** first byte past the end of the first SQL statement in zSql. ** <todo>What does *pzTail point to if there is one statement?</todo> ** ** {H13016} A successful call to [sqlite3_prepare_v2(db,zSql,N,ppStmt,...)] ** or one of its variants writes into *ppStmt a pointer to a new ** [prepared statement] or a pointer to NULL if zSql contains ** nothing other than whitespace or comments. ** ** {H13019} The [sqlite3_prepare_v2()] interface and its variants return ** [SQLITE_OK] or an appropriate [error code] upon failure. ** ** {H13021} Before [sqlite3_prepare(db,zSql,nByte,ppStmt,pzTail)] or its ** variants returns an error (any value other than [SQLITE_OK]), ** they first set *ppStmt to NULL. */ SQLITE_API int sqlite3_prepare( sqlite3 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ int nByte, /* Maximum length of zSql in bytes. */ |
︙ | ︙ | |||
3186 3187 3188 3189 3190 3191 3192 | const void *zSql, /* SQL statement, UTF-16 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); /* | | | | | | | 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 | const void *zSql, /* SQL statement, UTF-16 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); /* ** CAPIREF: Retrieving Statement SQL {H13100} <H13000> ** ** This interface can be used to retrieve a saved copy of the original ** SQL text used to create a [prepared statement] if that statement was ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. ** ** INVARIANTS: ** ** {H13101} If the [prepared statement] passed as the argument to ** [sqlite3_sql()] was compiled using either [sqlite3_prepare_v2()] or ** [sqlite3_prepare16_v2()], then [sqlite3_sql()] returns ** a pointer to a zero-terminated string containing a UTF-8 rendering ** of the original SQL statement. ** ** {H13102} If the [prepared statement] passed as the argument to ** [sqlite3_sql()] was compiled using either [sqlite3_prepare()] or ** [sqlite3_prepare16()], then [sqlite3_sql()] returns a NULL pointer. ** ** {H13103} The string returned by [sqlite3_sql(S)] is valid until the ** [prepared statement] S is deleted using [sqlite3_finalize(S)]. */ SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); /* ** CAPI3REF: Dynamically Typed Value Object {H15000} <S20200> ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} ** ** SQLite uses the sqlite3_value object to represent all values ** that can be stored in a database table. SQLite uses dynamic typing ** for the values it stores. Values stored in sqlite3_value objects ** can be integers, floating point values, strings, BLOBs, or NULL. ** |
︙ | ︙ | |||
3249 3250 3251 3252 3253 3254 3255 | ** [sqlite3_result_value()] and [sqlite3_bind_value()]. ** The [sqlite3_value_blob | sqlite3_value_type()] family of ** interfaces require protected sqlite3_value objects. */ typedef struct Mem sqlite3_value; /* | | | | 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 | ** [sqlite3_result_value()] and [sqlite3_bind_value()]. ** The [sqlite3_value_blob | sqlite3_value_type()] family of ** interfaces require protected sqlite3_value objects. */ typedef struct Mem sqlite3_value; /* ** CAPI3REF: SQL Function Context Object {H16001} <S20200> ** ** The context in which an SQL function executes is stored in an ** sqlite3_context object. A pointer to an sqlite3_context object ** is always first parameter to [application-defined SQL functions]. ** The application-defined SQL function implementation will pass this ** pointer through into calls to [sqlite3_result_int | sqlite3_result()], ** [sqlite3_aggregate_context()], [sqlite3_user_data()], ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], ** and/or [sqlite3_set_auxdata()]. */ typedef struct sqlite3_context sqlite3_context; /* ** CAPI3REF: Binding Values To Prepared Statements {H13500} <S70300> ** KEYWORDS: {host parameter} {host parameters} {host parameter name} ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} ** ** In the SQL strings input to [sqlite3_prepare_v2()] and its variants, ** literals may be replaced by a parameter in one of these forms: ** ** <ul> |
︙ | ︙ | |||
3343 3344 3345 3346 3347 3348 3349 | ** panic rather than return SQLITE_MISUSE. ** ** See also: [sqlite3_bind_parameter_count()], ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | | | | 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 | ** panic rather than return SQLITE_MISUSE. ** ** See also: [sqlite3_bind_parameter_count()], ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. ** ** INVARIANTS: ** ** {H13506} The [SQL statement compiler] recognizes tokens of the forms ** "?", "?NNN", "$VVV", ":VVV", and "@VVV" as SQL parameters, ** where NNN is any sequence of one or more digits ** and where VVV is any sequence of one or more alphanumeric ** characters or "::" optionally followed by a string containing ** no spaces and contained within parentheses. ** ** {H13509} The initial value of an SQL parameter is NULL. ** ** {H13512} The index of an "?" SQL parameter is one larger than the ** largest index of SQL parameter to the left, or 1 if ** the "?" is the leftmost SQL parameter. ** ** {H13515} The index of an "?NNN" SQL parameter is the integer NNN. ** ** {H13518} The index of an ":VVV", "$VVV", or "@VVV" SQL parameter is ** the same as the index of leftmost occurrences of the same ** parameter, or one more than the largest index over all ** parameters to the left if this is the first occurrence ** of this parameter, or 1 if this is the leftmost parameter. ** ** {H13521} The [SQL statement compiler] fails with an [SQLITE_RANGE] ** error if the index of an SQL parameter is less than 1 ** or greater than the compile-time SQLITE_MAX_VARIABLE_NUMBER ** parameter. ** ** {H13524} Calls to [sqlite3_bind_text | sqlite3_bind(S,N,V,...)] ** associate the value V with all SQL parameters having an ** index of N in the [prepared statement] S. ** ** {H13527} Calls to [sqlite3_bind_text | sqlite3_bind(S,N,...)] ** override prior calls with the same values of S and N. ** ** {H13530} Bindings established by [sqlite3_bind_text | sqlite3_bind(S,...)] ** persist across calls to [sqlite3_reset(S)]. ** ** {H13533} In calls to [sqlite3_bind_blob(S,N,V,L,D)], ** [sqlite3_bind_text(S,N,V,L,D)], or ** [sqlite3_bind_text16(S,N,V,L,D)] SQLite binds the first L ** bytes of the BLOB or string pointed to by V, when L ** is non-negative. ** ** {H13536} In calls to [sqlite3_bind_text(S,N,V,L,D)] or ** [sqlite3_bind_text16(S,N,V,L,D)] SQLite binds characters ** from V through the first zero character when L is negative. ** ** {H13539} In calls to [sqlite3_bind_blob(S,N,V,L,D)], ** [sqlite3_bind_text(S,N,V,L,D)], or ** [sqlite3_bind_text16(S,N,V,L,D)] when D is the special ** constant [SQLITE_STATIC], SQLite assumes that the value V ** is held in static unmanaged space that will not change ** during the lifetime of the binding. ** ** {H13542} In calls to [sqlite3_bind_blob(S,N,V,L,D)], ** [sqlite3_bind_text(S,N,V,L,D)], or ** [sqlite3_bind_text16(S,N,V,L,D)] when D is the special ** constant [SQLITE_TRANSIENT], the routine makes a ** private copy of the value V before it returns. ** ** {H13545} In calls to [sqlite3_bind_blob(S,N,V,L,D)], ** [sqlite3_bind_text(S,N,V,L,D)], or ** [sqlite3_bind_text16(S,N,V,L,D)] when D is a pointer to ** a function, SQLite invokes that function to destroy the ** value V after it has finished using the value V. ** ** {H13548} In calls to [sqlite3_bind_zeroblob(S,N,V,L)] the value bound ** is a BLOB of L bytes, or a zero-length BLOB if L is negative. ** ** {H13551} In calls to [sqlite3_bind_value(S,N,V)] the V argument may ** be either a [protected sqlite3_value] object or an ** [unprotected sqlite3_value] object. */ SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int); SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*)); SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); /* ** CAPI3REF: Number Of SQL Parameters {H13600} <S70300> ** ** This routine can be used to find the number of [SQL parameters] ** in a [prepared statement]. SQL parameters are tokens of the ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as ** placeholders for values that are [sqlite3_bind_blob | bound] ** to the parameters at a later time. ** ** This routine actually returns the index of the largest (rightmost) ** parameter. For all forms except ?NNN, this will correspond to the ** number of unique parameters. If parameters of the ?NNN are used, ** there may be gaps in the list. ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_name()], and ** [sqlite3_bind_parameter_index()]. ** ** INVARIANTS: ** ** {H13601} The [sqlite3_bind_parameter_count(S)] interface returns ** the largest index of all SQL parameters in the ** [prepared statement] S, or 0 if S contains no SQL parameters. */ SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*); /* ** CAPI3REF: Name Of A Host Parameter {H13620} <S70300> ** ** This routine returns a pointer to the name of the n-th ** [SQL parameter] in a [prepared statement]. ** SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA" ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" ** respectively. ** In other words, the initial ":" or "$" or "@" or "?" |
︙ | ︙ | |||
3478 3479 3480 3481 3482 3483 3484 | ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_count()], and ** [sqlite3_bind_parameter_index()]. ** ** INVARIANTS: ** | | | | | | | | | | 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 | ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_count()], and ** [sqlite3_bind_parameter_index()]. ** ** INVARIANTS: ** ** {H13621} The [sqlite3_bind_parameter_name(S,N)] interface returns ** a UTF-8 rendering of the name of the SQL parameter in ** the [prepared statement] S having index N, or ** NULL if there is no SQL parameter with index N or if the ** parameter with index N is an anonymous parameter "?". */ SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); /* ** CAPI3REF: Index Of A Parameter With A Given Name {H13640} <S70300> ** ** Return the index of an SQL parameter given its name. The ** index value returned is suitable for use as the second ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. A zero ** is returned if no matching parameter is found. The parameter ** name must be given in UTF-8 even if the original statement ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()]. ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_count()], and ** [sqlite3_bind_parameter_index()]. ** ** INVARIANTS: ** ** {H13641} The [sqlite3_bind_parameter_index(S,N)] interface returns ** the index of SQL parameter in the [prepared statement] ** S whose name matches the UTF-8 string N, or 0 if there is ** no match. */ SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); /* ** CAPI3REF: Reset All Bindings On A Prepared Statement {H13660} <S70300> ** ** Contrary to the intuition of many, [sqlite3_reset()] does not reset ** the [sqlite3_bind_blob | bindings] on a [prepared statement]. ** Use this routine to reset all host parameters to NULL. ** ** INVARIANTS: ** ** {H13661} The [sqlite3_clear_bindings(S)] interface resets all SQL ** parameter bindings in the [prepared statement] S back to NULL. */ SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*); /* ** CAPI3REF: Number Of Columns In A Result Set {H13710} <S10700> ** ** Return the number of columns in the result set returned by the ** [prepared statement]. This routine returns 0 if pStmt is an SQL ** statement that does not return data (for example an [UPDATE]). ** ** INVARIANTS: ** ** {H13711} The [sqlite3_column_count(S)] interface returns the number of ** columns in the result set generated by the [prepared statement] S, ** or 0 if S does not generate a result set. */ SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt); /* ** CAPI3REF: Column Names In A Result Set {H13720} <S10700> ** ** These routines return the name assigned to a particular column ** in the result set of a [SELECT] statement. The sqlite3_column_name() ** interface returns a pointer to a zero-terminated UTF-8 string ** and sqlite3_column_name16() returns a pointer to a zero-terminated ** UTF-16 string. The first parameter is the [prepared statement] ** that implements the [SELECT] statement. The second parameter is the |
︙ | ︙ | |||
3564 3565 3566 3567 3568 3569 3570 | ** The name of a result column is the value of the "AS" clause for ** that column, if there is an AS clause. If there is no AS clause ** then the name of the column is unspecified and may change from ** one release of SQLite to the next. ** ** INVARIANTS: ** | | | | | | | | | 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 | ** The name of a result column is the value of the "AS" clause for ** that column, if there is an AS clause. If there is no AS clause ** then the name of the column is unspecified and may change from ** one release of SQLite to the next. ** ** INVARIANTS: ** ** {H13721} A successful invocation of the [sqlite3_column_name(S,N)] ** interface returns the name of the Nth column (where 0 is ** the leftmost column) for the result set of the ** [prepared statement] S as a zero-terminated UTF-8 string. ** ** {H13723} A successful invocation of the [sqlite3_column_name16(S,N)] ** interface returns the name of the Nth column (where 0 is ** the leftmost column) for the result set of the ** [prepared statement] S as a zero-terminated UTF-16 string ** in the native byte order. ** ** {H13724} The [sqlite3_column_name()] and [sqlite3_column_name16()] ** interfaces return a NULL pointer if they are unable to ** allocate memory to hold their normal return strings. ** ** {H13725} If the N parameter to [sqlite3_column_name(S,N)] or ** [sqlite3_column_name16(S,N)] is out of range, then the ** interfaces return a NULL pointer. ** ** {H13726} The strings returned by [sqlite3_column_name(S,N)] and ** [sqlite3_column_name16(S,N)] are valid until the next ** call to either routine with the same S and N parameters ** or until [sqlite3_finalize(S)] is called. ** ** {H13727} When a result column of a [SELECT] statement contains ** an AS clause, the name of that column is the identifier ** to the right of the AS keyword. */ SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N); SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); /* ** CAPI3REF: Source Of Data In A Query Result {H13740} <S10700> ** ** These routines provide a means to determine what column of what ** table in which database a result of a [SELECT] statement comes from. ** The name of the database or table or column can be returned as ** either a UTF-8 or UTF-16 string. The _database_ routines return ** the database name, the _table_ routines return the table name, and ** the origin_ routines return the column name. |
︙ | ︙ | |||
3634 3635 3636 3637 3638 3639 3640 | ** {A13751} ** If two or more threads call one or more of these routines against the same ** prepared statement and column at the same time then the results are ** undefined. ** ** INVARIANTS: ** | | | | | | | | | | | 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 | ** {A13751} ** If two or more threads call one or more of these routines against the same ** prepared statement and column at the same time then the results are ** undefined. ** ** INVARIANTS: ** ** {H13741} The [sqlite3_column_database_name(S,N)] interface returns either ** the UTF-8 zero-terminated name of the database from which the ** Nth result column of the [prepared statement] S is extracted, ** or NULL if the Nth column of S is a general expression ** or if unable to allocate memory to store the name. ** ** {H13742} The [sqlite3_column_database_name16(S,N)] interface returns either ** the UTF-16 native byte order zero-terminated name of the database ** from which the Nth result column of the [prepared statement] S is ** extracted, or NULL if the Nth column of S is a general expression ** or if unable to allocate memory to store the name. ** ** {H13743} The [sqlite3_column_table_name(S,N)] interface returns either ** the UTF-8 zero-terminated name of the table from which the ** Nth result column of the [prepared statement] S is extracted, ** or NULL if the Nth column of S is a general expression ** or if unable to allocate memory to store the name. ** ** {H13744} The [sqlite3_column_table_name16(S,N)] interface returns either ** the UTF-16 native byte order zero-terminated name of the table ** from which the Nth result column of the [prepared statement] S is ** extracted, or NULL if the Nth column of S is a general expression ** or if unable to allocate memory to store the name. ** ** {H13745} The [sqlite3_column_origin_name(S,N)] interface returns either ** the UTF-8 zero-terminated name of the table column from which the ** Nth result column of the [prepared statement] S is extracted, ** or NULL if the Nth column of S is a general expression ** or if unable to allocate memory to store the name. ** ** {H13746} The [sqlite3_column_origin_name16(S,N)] interface returns either ** the UTF-16 native byte order zero-terminated name of the table ** column from which the Nth result column of the ** [prepared statement] S is extracted, or NULL if the Nth column ** of S is a general expression or if unable to allocate memory ** to store the name. ** ** {H13748} The return values from ** [sqlite3_column_database_name | column metadata interfaces] ** are valid for the lifetime of the [prepared statement] ** or until the encoding is changed by another metadata ** interface call for the same prepared statement and column. ** ** ASSUMPTIONS: ** ** {A13751} If two or more threads call one or more ** [sqlite3_column_database_name | column metadata interfaces] ** for the same [prepared statement] and result column ** at the same time then the results are undefined. */ SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int); SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int); SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int); SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int); SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int); SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); /* ** CAPI3REF: Declared Datatype Of A Query Result {H13760} <S10700> ** ** The first parameter is a [prepared statement]. ** If this statement is a [SELECT] statement and the Nth column of the ** returned result set of that [SELECT] is a table column (not an ** expression or subquery) then the declared type of the table ** column is returned. If the Nth column of the result set is an ** expression or subquery, then a NULL pointer is returned. |
︙ | ︙ | |||
3722 3723 3724 3725 3726 3727 3728 | ** data stored in that column is of the declared type. SQLite is ** strongly typed, but the typing is dynamic not static. Type ** is associated with individual values, not with the containers ** used to hold those values. ** ** INVARIANTS: ** | | | | | | 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 | ** data stored in that column is of the declared type. SQLite is ** strongly typed, but the typing is dynamic not static. Type ** is associated with individual values, not with the containers ** used to hold those values. ** ** INVARIANTS: ** ** {H13761} A successful call to [sqlite3_column_decltype(S,N)] returns a ** zero-terminated UTF-8 string containing the declared datatype ** of the table column that appears as the Nth column (numbered ** from 0) of the result set to the [prepared statement] S. ** ** {H13762} A successful call to [sqlite3_column_decltype16(S,N)] ** returns a zero-terminated UTF-16 native byte order string ** containing the declared datatype of the table column that appears ** as the Nth column (numbered from 0) of the result set to the ** [prepared statement] S. ** ** {H13763} If N is less than 0 or N is greater than or equal to ** the number of columns in the [prepared statement] S, ** or if the Nth column of S is an expression or subquery rather ** than a table column, or if a memory allocation failure ** occurs during encoding conversions, then ** calls to [sqlite3_column_decltype(S,N)] or ** [sqlite3_column_decltype16(S,N)] return NULL. */ SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int); SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); /* ** CAPI3REF: Evaluate An SQL Statement {H13200} <S10000> ** ** After a [prepared statement] has been prepared using either ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function ** must be called one or more times to evaluate the statement. ** ** The details of the behavior of the sqlite3_step() interface depend |
︙ | ︙ | |||
3811 3812 3813 3814 3815 3816 3817 | ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, ** then the more specific [error codes] are returned directly ** by sqlite3_step(). The use of the "v2" interface is recommended. ** ** INVARIANTS: ** | | | | | | | | | | | | 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 | ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, ** then the more specific [error codes] are returned directly ** by sqlite3_step(). The use of the "v2" interface is recommended. ** ** INVARIANTS: ** ** {H13202} If the [prepared statement] S is ready to be run, then ** [sqlite3_step(S)] advances that prepared statement until ** completion or until it is ready to return another row of the ** result set, or until an [sqlite3_interrupt | interrupt] ** or a run-time error occurs. ** ** {H15304} When a call to [sqlite3_step(S)] causes the [prepared statement] ** S to run to completion, the function returns [SQLITE_DONE]. ** ** {H15306} When a call to [sqlite3_step(S)] stops because it is ready to ** return another row of the result set, it returns [SQLITE_ROW]. ** ** {H15308} If a call to [sqlite3_step(S)] encounters an ** [sqlite3_interrupt | interrupt] or a run-time error, ** it returns an appropriate error code that is not one of ** [SQLITE_OK], [SQLITE_ROW], or [SQLITE_DONE]. ** ** {H15310} If an [sqlite3_interrupt | interrupt] or a run-time error ** occurs during a call to [sqlite3_step(S)] ** for a [prepared statement] S created using ** legacy interfaces [sqlite3_prepare()] or ** [sqlite3_prepare16()], then the function returns either ** [SQLITE_ERROR], [SQLITE_BUSY], or [SQLITE_MISUSE]. */ SQLITE_API int sqlite3_step(sqlite3_stmt*); /* ** CAPI3REF: Number of columns in a result set {H13770} <S10700> ** ** Returns the number of values in the current row of the result set. ** ** INVARIANTS: ** ** {H13771} After a call to [sqlite3_step(S)] that returns [SQLITE_ROW], ** the [sqlite3_data_count(S)] routine will return the same value ** as the [sqlite3_column_count(S)] function. ** ** {H13772} After [sqlite3_step(S)] has returned any value other than ** [SQLITE_ROW] or before [sqlite3_step(S)] has been called on the ** [prepared statement] for the first time since it was ** [sqlite3_prepare | prepared] or [sqlite3_reset | reset], ** the [sqlite3_data_count(S)] routine returns zero. */ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); /* ** CAPI3REF: Fundamental Datatypes {H10265} <S10110><S10120> ** KEYWORDS: SQLITE_TEXT ** ** {H10266} Every value in SQLite has one of five fundamental datatypes: ** ** <ul> ** <li> 64-bit signed integer ** <li> 64-bit IEEE floating point number ** <li> string ** <li> BLOB ** <li> NULL |
︙ | ︙ | |||
3889 3890 3891 3892 3893 3894 3895 | # undef SQLITE_TEXT #else # define SQLITE_TEXT 3 #endif #define SQLITE3_TEXT 3 /* | | | 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 | # undef SQLITE_TEXT #else # define SQLITE_TEXT 3 #endif #define SQLITE3_TEXT 3 /* ** CAPI3REF: Result Values From A Query {H13800} <S10700> ** KEYWORDS: {column access functions} ** ** These routines form the "result set query" interface. ** ** These routines return information about a single column of the current ** result row of a query. In every case the first argument is a pointer ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] |
︙ | ︙ | |||
4042 4043 4044 4045 4046 4047 4048 | ** of these routines, a default value is returned. The default value ** is either the integer 0, the floating point number 0.0, or a NULL ** pointer. Subsequent calls to [sqlite3_errcode()] will return ** [SQLITE_NOMEM]. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | | | | 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 | ** of these routines, a default value is returned. The default value ** is either the integer 0, the floating point number 0.0, or a NULL ** pointer. Subsequent calls to [sqlite3_errcode()] will return ** [SQLITE_NOMEM]. ** ** INVARIANTS: ** ** {H13803} The [sqlite3_column_blob(S,N)] interface converts the ** Nth column in the current row of the result set for ** the [prepared statement] S into a BLOB and then returns a ** pointer to the converted value. ** ** {H13806} The [sqlite3_column_bytes(S,N)] interface returns the ** number of bytes in the BLOB or string (exclusive of the ** zero terminator on the string) that was returned by the ** most recent call to [sqlite3_column_blob(S,N)] or ** [sqlite3_column_text(S,N)]. ** ** {H13809} The [sqlite3_column_bytes16(S,N)] interface returns the ** number of bytes in the string (exclusive of the ** zero terminator on the string) that was returned by the ** most recent call to [sqlite3_column_text16(S,N)]. ** ** {H13812} The [sqlite3_column_double(S,N)] interface converts the ** Nth column in the current row of the result set for the ** [prepared statement] S into a floating point value and ** returns a copy of that value. ** ** {H13815} The [sqlite3_column_int(S,N)] interface converts the ** Nth column in the current row of the result set for the ** [prepared statement] S into a 64-bit signed integer and ** returns the lower 32 bits of that integer. ** ** {H13818} The [sqlite3_column_int64(S,N)] interface converts the ** Nth column in the current row of the result set for the ** [prepared statement] S into a 64-bit signed integer and ** returns a copy of that integer. ** ** {H13821} The [sqlite3_column_text(S,N)] interface converts the ** Nth column in the current row of the result set for ** the [prepared statement] S into a zero-terminated UTF-8 ** string and returns a pointer to that string. ** ** {H13824} The [sqlite3_column_text16(S,N)] interface converts the ** Nth column in the current row of the result set for the ** [prepared statement] S into a zero-terminated 2-byte ** aligned UTF-16 native byte order string and returns ** a pointer to that string. ** ** {H13827} The [sqlite3_column_type(S,N)] interface returns ** one of [SQLITE_NULL], [SQLITE_INTEGER], [SQLITE_FLOAT], ** [SQLITE_TEXT], or [SQLITE_BLOB] as appropriate for ** the Nth column in the current row of the result set for ** the [prepared statement] S. ** ** {H13830} The [sqlite3_column_value(S,N)] interface returns a ** pointer to an [unprotected sqlite3_value] object for the ** Nth column in the current row of the result set for ** the [prepared statement] S. */ SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol); SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol); SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); /* ** CAPI3REF: Destroy A Prepared Statement Object {H13300} <S70300><S30100> ** ** The sqlite3_finalize() function is called to delete a [prepared statement]. ** If the statement was executed successfully or not executed at all, then ** SQLITE_OK is returned. If execution of the statement failed then an ** [error code] or [extended error code] is returned. ** ** This routine can be called at any point during the execution of the ** [prepared statement]. If the virtual machine has not ** completed execution when this routine is called, that is like ** encountering an error or an [sqlite3_interrupt | interrupt]. ** Incomplete updates may be rolled back and transactions canceled, ** depending on the circumstances, and the ** [error code] returned will be [SQLITE_ABORT]. ** ** INVARIANTS: ** ** {H11302} The [sqlite3_finalize(S)] interface destroys the ** [prepared statement] S and releases all ** memory and file resources held by that object. ** ** {H11304} If the most recent call to [sqlite3_step(S)] for the ** [prepared statement] S returned an error, ** then [sqlite3_finalize(S)] returns that same error. */ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); /* ** CAPI3REF: Reset A Prepared Statement Object {H13330} <S70300> ** ** The sqlite3_reset() function is called to reset a [prepared statement] ** object back to its initial state, ready to be re-executed. ** Any SQL statement variables that had values bound to them using ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. ** Use [sqlite3_clear_bindings()] to reset the bindings. ** ** {H11332} The [sqlite3_reset(S)] interface resets the [prepared statement] S ** back to the beginning of its program. ** ** {H11334} If the most recent call to [sqlite3_step(S)] for the ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], ** or if [sqlite3_step(S)] has never before been called on S, ** then [sqlite3_reset(S)] returns [SQLITE_OK]. ** ** {H11336} If the most recent call to [sqlite3_step(S)] for the ** [prepared statement] S indicated an error, then ** [sqlite3_reset(S)] returns an appropriate [error code]. ** ** {H11338} The [sqlite3_reset(S)] interface does not change the values ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. */ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); /* ** CAPI3REF: Create Or Redefine SQL Functions {H16100} <S20200> ** KEYWORDS: {function creation routines} ** KEYWORDS: {application-defined SQL function} ** KEYWORDS: {application-defined SQL functions} ** ** These two functions (collectively known as "function creation routines") ** are used to add SQL functions or aggregates or to redefine the behavior ** of existing SQL functions or aggregates. The only difference between the |
︙ | ︙ | |||
4219 4220 4221 4222 4223 4224 4225 | ** functions with the same name but with either differing numbers of ** arguments or differing preferred text encodings. SQLite will use ** the implementation most closely matches the way in which the ** SQL function is used. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 | ** functions with the same name but with either differing numbers of ** arguments or differing preferred text encodings. SQLite will use ** the implementation most closely matches the way in which the ** SQL function is used. ** ** INVARIANTS: ** ** {H16103} The [sqlite3_create_function16()] interface behaves exactly ** like [sqlite3_create_function()] in every way except that it ** interprets the zFunctionName argument as zero-terminated UTF-16 ** native byte order instead of as zero-terminated UTF-8. ** ** {H16106} A successful invocation of ** the [sqlite3_create_function(D,X,N,E,...)] interface registers ** or replaces callback functions in the [database connection] D ** used to implement the SQL function named X with N parameters ** and having a preferred text encoding of E. ** ** {H16109} A successful call to [sqlite3_create_function(D,X,N,E,P,F,S,L)] ** replaces the P, F, S, and L values from any prior calls with ** the same D, X, N, and E values. ** ** {H16112} The [sqlite3_create_function(D,X,...)] interface fails with ** a return code of [SQLITE_ERROR] if the SQL function name X is ** longer than 255 bytes exclusive of the zero terminator. ** ** {H16118} Either F must be NULL and S and L are non-NULL or else F ** is non-NULL and S and L are NULL, otherwise ** [sqlite3_create_function(D,X,N,E,P,F,S,L)] returns [SQLITE_ERROR]. ** ** {H16121} The [sqlite3_create_function(D,...)] interface fails with an ** error code of [SQLITE_BUSY] if there exist [prepared statements] ** associated with the [database connection] D. ** ** {H16124} The [sqlite3_create_function(D,X,N,...)] interface fails with an ** error code of [SQLITE_ERROR] if parameter N (specifying the number ** of arguments to the SQL function being registered) is less ** than -1 or greater than 127. ** ** {H16127} When N is non-negative, the [sqlite3_create_function(D,X,N,...)] ** interface causes callbacks to be invoked for the SQL function ** named X when the number of arguments to the SQL function is ** exactly N. ** ** {H16130} When N is -1, the [sqlite3_create_function(D,X,N,...)] ** interface causes callbacks to be invoked for the SQL function ** named X with any number of arguments. ** ** {H16133} When calls to [sqlite3_create_function(D,X,N,...)] ** specify multiple implementations of the same function X ** and when one implementation has N>=0 and the other has N=(-1) ** the implementation with a non-zero N is preferred. ** ** {H16136} When calls to [sqlite3_create_function(D,X,N,E,...)] ** specify multiple implementations of the same function X with ** the same number of arguments N but with different ** encodings E, then the implementation where E matches the ** database encoding is preferred. ** ** {H16139} For an aggregate SQL function created using ** [sqlite3_create_function(D,X,N,E,P,0,S,L)] the finalizer ** function L will always be invoked exactly once if the ** step function S is called one or more times. ** ** {H16142} When SQLite invokes either the xFunc or xStep function of ** an application-defined SQL function or aggregate created ** by [sqlite3_create_function()] or [sqlite3_create_function16()], ** then the array of [sqlite3_value] objects passed as the ** third parameter are always [protected sqlite3_value] objects. */ SQLITE_API int sqlite3_create_function( sqlite3 *db, |
︙ | ︙ | |||
4304 4305 4306 4307 4308 4309 4310 | void *pApp, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*) ); /* | | | > | | | | | 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 | void *pApp, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*) ); /* ** CAPI3REF: Text Encodings {H10267} <S50200> <H16100> ** ** These constant define integer codes that represent the various ** text encodings supported by SQLite. */ #define SQLITE_UTF8 1 #define SQLITE_UTF16LE 2 #define SQLITE_UTF16BE 3 #define SQLITE_UTF16 4 /* Use native byte order */ #define SQLITE_ANY 5 /* sqlite3_create_function only */ #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ /* ** CAPI3REF: Deprecated Functions ** DEPRECATED ** ** These functions are [deprecated]. In order to maintain ** backwards compatibility with older code, these functions continue ** to be supported. However, new applications should avoid ** the use of these functions. To help encourage people to avoid ** using these functions, we are not going to tell you want they do. */ SQLITE_API int sqlite3_aggregate_count(sqlite3_context*); SQLITE_API int sqlite3_expired(sqlite3_stmt*); SQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); SQLITE_API int sqlite3_global_recover(void); SQLITE_API void sqlite3_thread_cleanup(void); SQLITE_API int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64); /* ** CAPI3REF: Obtaining SQL Function Parameter Values {H15100} <S20200> ** ** The C-language implementation of SQL functions and aggregates uses ** this set of interface routines to access the parameter values on ** the function or aggregate. ** ** The xFunc (for scalar functions) or xStep (for aggregates) parameters ** to [sqlite3_create_function()] and [sqlite3_create_function16()] |
︙ | ︙ | |||
4379 4380 4381 4382 4383 4384 4385 | ** or [sqlite3_value_text16()]. ** ** These routines must be called from the same thread as ** the SQL function that supplied the [sqlite3_value*] parameters. ** ** INVARIANTS: ** | | | | | | | | | | | | | | 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 | ** or [sqlite3_value_text16()]. ** ** These routines must be called from the same thread as ** the SQL function that supplied the [sqlite3_value*] parameters. ** ** INVARIANTS: ** ** {H15103} The [sqlite3_value_blob(V)] interface converts the ** [protected sqlite3_value] object V into a BLOB and then ** returns a pointer to the converted value. ** ** {H15106} The [sqlite3_value_bytes(V)] interface returns the ** number of bytes in the BLOB or string (exclusive of the ** zero terminator on the string) that was returned by the ** most recent call to [sqlite3_value_blob(V)] or ** [sqlite3_value_text(V)]. ** ** {H15109} The [sqlite3_value_bytes16(V)] interface returns the ** number of bytes in the string (exclusive of the ** zero terminator on the string) that was returned by the ** most recent call to [sqlite3_value_text16(V)], ** [sqlite3_value_text16be(V)], or [sqlite3_value_text16le(V)]. ** ** {H15112} The [sqlite3_value_double(V)] interface converts the ** [protected sqlite3_value] object V into a floating point value and ** returns a copy of that value. ** ** {H15115} The [sqlite3_value_int(V)] interface converts the ** [protected sqlite3_value] object V into a 64-bit signed integer and ** returns the lower 32 bits of that integer. ** ** {H15118} The [sqlite3_value_int64(V)] interface converts the ** [protected sqlite3_value] object V into a 64-bit signed integer and ** returns a copy of that integer. ** ** {H15121} The [sqlite3_value_text(V)] interface converts the ** [protected sqlite3_value] object V into a zero-terminated UTF-8 ** string and returns a pointer to that string. ** ** {H15124} The [sqlite3_value_text16(V)] interface converts the ** [protected sqlite3_value] object V into a zero-terminated 2-byte ** aligned UTF-16 native byte order ** string and returns a pointer to that string. ** ** {H15127} The [sqlite3_value_text16be(V)] interface converts the ** [protected sqlite3_value] object V into a zero-terminated 2-byte ** aligned UTF-16 big-endian ** string and returns a pointer to that string. ** ** {H15130} The [sqlite3_value_text16le(V)] interface converts the ** [protected sqlite3_value] object V into a zero-terminated 2-byte ** aligned UTF-16 little-endian ** string and returns a pointer to that string. ** ** {H15133} The [sqlite3_value_type(V)] interface returns ** one of [SQLITE_NULL], [SQLITE_INTEGER], [SQLITE_FLOAT], ** [SQLITE_TEXT], or [SQLITE_BLOB] as appropriate for ** the [sqlite3_value] object V. ** ** {H15136} The [sqlite3_value_numeric_type(V)] interface converts ** the [protected sqlite3_value] object V into either an integer or ** a floating point value if it can do so without loss of ** information, and returns one of [SQLITE_NULL], ** [SQLITE_INTEGER], [SQLITE_FLOAT], [SQLITE_TEXT], or ** [SQLITE_BLOB] as appropriate for the ** [protected sqlite3_value] object V after the conversion attempt. */ |
︙ | ︙ | |||
4453 4454 4455 4456 4457 4458 4459 | SQLITE_API const void *sqlite3_value_text16(sqlite3_value*); SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); SQLITE_API int sqlite3_value_type(sqlite3_value*); SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); /* | | | 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 | SQLITE_API const void *sqlite3_value_text16(sqlite3_value*); SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); SQLITE_API int sqlite3_value_type(sqlite3_value*); SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); /* ** CAPI3REF: Obtain Aggregate Function Context {H16210} <S20200> ** ** The implementation of aggregate SQL functions use this routine to allocate ** a structure for storing their state. ** ** The first time the sqlite3_aggregate_context() routine is called for a ** particular aggregate, SQLite allocates nBytes of memory, zeroes out that ** memory, and returns a pointer to it. On second and subsequent calls to |
︙ | ︙ | |||
4477 4478 4479 4480 4481 4482 4483 | ** to the callback routine that implements the aggregate function. ** ** This routine must be called from the same thread in which ** the aggregate SQL function is running. ** ** INVARIANTS: ** | | | | | | | | | | | 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 | ** to the callback routine that implements the aggregate function. ** ** This routine must be called from the same thread in which ** the aggregate SQL function is running. ** ** INVARIANTS: ** ** {H16211} The first invocation of [sqlite3_aggregate_context(C,N)] for ** a particular instance of an aggregate function (for a particular ** context C) causes SQLite to allocate N bytes of memory, ** zero that memory, and return a pointer to the allocated memory. ** ** {H16213} If a memory allocation error occurs during ** [sqlite3_aggregate_context(C,N)] then the function returns 0. ** ** {H16215} Second and subsequent invocations of ** [sqlite3_aggregate_context(C,N)] for the same context pointer C ** ignore the N parameter and return a pointer to the same ** block of memory returned by the first invocation. ** ** {H16217} The memory allocated by [sqlite3_aggregate_context(C,N)] is ** automatically freed on the next call to [sqlite3_reset()] ** or [sqlite3_finalize()] for the [prepared statement] containing ** the aggregate function associated with context C. */ SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); /* ** CAPI3REF: User Data For Functions {H16240} <S20200> ** ** The sqlite3_user_data() interface returns a copy of ** the pointer that was the pUserData parameter (the 5th parameter) ** of the [sqlite3_create_function()] ** and [sqlite3_create_function16()] routines that originally ** registered the application defined function. {END} ** ** This routine must be called from the same thread in which ** the application-defined function is running. ** ** INVARIANTS: ** ** {H16243} The [sqlite3_user_data(C)] interface returns a copy of the ** P pointer from the [sqlite3_create_function(D,X,N,E,P,F,S,L)] ** or [sqlite3_create_function16(D,X,N,E,P,F,S,L)] call that ** registered the SQL function associated with [sqlite3_context] C. */ SQLITE_API void *sqlite3_user_data(sqlite3_context*); /* ** CAPI3REF: Database Connection For Functions {H16250} <S60600><S20200> ** ** The sqlite3_context_db_handle() interface returns a copy of ** the pointer to the [database connection] (the 1st parameter) ** of the [sqlite3_create_function()] ** and [sqlite3_create_function16()] routines that originally ** registered the application defined function. ** ** INVARIANTS: ** ** {H16253} The [sqlite3_context_db_handle(C)] interface returns a copy of the ** D pointer from the [sqlite3_create_function(D,X,N,E,P,F,S,L)] ** or [sqlite3_create_function16(D,X,N,E,P,F,S,L)] call that ** registered the SQL function associated with [sqlite3_context] C. */ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); /* ** CAPI3REF: Function Auxiliary Data {H16270} <S20200> ** ** The following two functions may be used by scalar SQL functions to ** associate metadata with argument values. If the same value is passed to ** multiple invocations of the same SQL function during query execution, under ** some circumstances the associated metadata may be preserved. This may ** be used, for example, to add a regular-expression matching scalar ** function. The compiled version of the regular expression is stored as |
︙ | ︙ | |||
4580 4581 4582 4583 4584 4585 4586 | ** values and SQL variables. ** ** These routines must be called from the same thread in which ** the SQL function is running. ** ** INVARIANTS: ** | | | | | | | | | | 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 | ** values and SQL variables. ** ** These routines must be called from the same thread in which ** the SQL function is running. ** ** INVARIANTS: ** ** {H16272} The [sqlite3_get_auxdata(C,N)] interface returns a pointer ** to metadata associated with the Nth parameter of the SQL function ** whose context is C, or NULL if there is no metadata associated ** with that parameter. ** ** {H16274} The [sqlite3_set_auxdata(C,N,P,D)] interface assigns a metadata ** pointer P to the Nth parameter of the SQL function with context C. ** ** {H16276} SQLite will invoke the destructor D with a single argument ** which is the metadata pointer P following a call to ** [sqlite3_set_auxdata(C,N,P,D)] when SQLite ceases to hold ** the metadata. ** ** {H16277} SQLite ceases to hold metadata for an SQL function parameter ** when the value of that parameter changes. ** ** {H16278} When [sqlite3_set_auxdata(C,N,P,D)] is invoked, the destructor ** is called for any prior metadata associated with the same function ** context C and parameter N. ** ** {H16279} SQLite will call destructors for any metadata it is holding ** in a particular [prepared statement] S when either ** [sqlite3_reset(S)] or [sqlite3_finalize(S)] is called. */ SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); /* ** CAPI3REF: Constants Defining Special Destructor Behavior {H10280} <S30100> ** ** These are special values for the destructor that is passed in as the ** final argument to routines like [sqlite3_result_blob()]. If the destructor ** argument is SQLITE_STATIC, it means that the content pointer is constant ** and will never change. It does not need to be destroyed. The ** SQLITE_TRANSIENT value means that the content will likely change in ** the near future and that SQLite should make its own private copy of ** the content before returning. ** ** The typedef is necessary to work around problems in certain ** C++ compilers. See ticket #2191. */ typedef void (*sqlite3_destructor_type)(void*); #define SQLITE_STATIC ((sqlite3_destructor_type)0) #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) /* ** CAPI3REF: Setting The Result Of An SQL Function {H16400} <S20200> ** ** These routines are used by the xFunc or xFinal callbacks that ** implement SQL functions and aggregates. See ** [sqlite3_create_function()] and [sqlite3_create_function16()] ** for additional information. ** ** These functions work very much like the [parameter binding] family of |
︙ | ︙ | |||
4732 4733 4734 4735 4736 4737 4738 | ** ** If these routines are called from within the different thread ** than the one containing the application-defined function that received ** the [sqlite3_context] pointer, the results are undefined. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | | | | | | 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 | ** ** If these routines are called from within the different thread ** than the one containing the application-defined function that received ** the [sqlite3_context] pointer, the results are undefined. ** ** INVARIANTS: ** ** {H16403} The default return value from any SQL function is NULL. ** ** {H16406} The [sqlite3_result_blob(C,V,N,D)] interface changes the ** return value of function C to be a BLOB that is N bytes ** in length and with content pointed to by V. ** ** {H16409} The [sqlite3_result_double(C,V)] interface changes the ** return value of function C to be the floating point value V. ** ** {H16412} The [sqlite3_result_error(C,V,N)] interface changes the return ** value of function C to be an exception with error code ** [SQLITE_ERROR] and a UTF-8 error message copied from V up to the ** first zero byte or until N bytes are read if N is positive. ** ** {H16415} The [sqlite3_result_error16(C,V,N)] interface changes the return ** value of function C to be an exception with error code ** [SQLITE_ERROR] and a UTF-16 native byte order error message ** copied from V up to the first zero terminator or until N bytes ** are read if N is positive. ** ** {H16418} The [sqlite3_result_error_toobig(C)] interface changes the return ** value of the function C to be an exception with error code ** [SQLITE_TOOBIG] and an appropriate error message. ** ** {H16421} The [sqlite3_result_error_nomem(C)] interface changes the return ** value of the function C to be an exception with error code ** [SQLITE_NOMEM] and an appropriate error message. ** ** {H16424} The [sqlite3_result_error_code(C,E)] interface changes the return ** value of the function C to be an exception with error code E. ** The error message text is unchanged. ** ** {H16427} The [sqlite3_result_int(C,V)] interface changes the ** return value of function C to be the 32-bit integer value V. ** ** {H16430} The [sqlite3_result_int64(C,V)] interface changes the ** return value of function C to be the 64-bit integer value V. ** ** {H16433} The [sqlite3_result_null(C)] interface changes the ** return value of function C to be NULL. ** ** {H16436} The [sqlite3_result_text(C,V,N,D)] interface changes the ** return value of function C to be the UTF-8 string ** V up to the first zero if N is negative ** or the first N bytes of V if N is non-negative. ** ** {H16439} The [sqlite3_result_text16(C,V,N,D)] interface changes the ** return value of function C to be the UTF-16 native byte order ** string V up to the first zero if N is negative ** or the first N bytes of V if N is non-negative. ** ** {H16442} The [sqlite3_result_text16be(C,V,N,D)] interface changes the ** return value of function C to be the UTF-16 big-endian ** string V up to the first zero if N is negative ** or the first N bytes or V if N is non-negative. ** ** {H16445} The [sqlite3_result_text16le(C,V,N,D)] interface changes the ** return value of function C to be the UTF-16 little-endian ** string V up to the first zero if N is negative ** or the first N bytes of V if N is non-negative. ** ** {H16448} The [sqlite3_result_value(C,V)] interface changes the ** return value of function C to be the [unprotected sqlite3_value] ** object V. ** ** {H16451} The [sqlite3_result_zeroblob(C,N)] interface changes the ** return value of function C to be an N-byte BLOB of all zeros. ** ** {H16454} The [sqlite3_result_error()] and [sqlite3_result_error16()] ** interfaces make a copy of their error message strings before ** returning. ** ** {H16457} If the D destructor parameter to [sqlite3_result_blob(C,V,N,D)], ** [sqlite3_result_text(C,V,N,D)], [sqlite3_result_text16(C,V,N,D)], ** [sqlite3_result_text16be(C,V,N,D)], or ** [sqlite3_result_text16le(C,V,N,D)] is the constant [SQLITE_STATIC] ** then no destructor is ever called on the pointer V and SQLite ** assumes that V is immutable. ** ** {H16460} If the D destructor parameter to [sqlite3_result_blob(C,V,N,D)], ** [sqlite3_result_text(C,V,N,D)], [sqlite3_result_text16(C,V,N,D)], ** [sqlite3_result_text16be(C,V,N,D)], or ** [sqlite3_result_text16le(C,V,N,D)] is the constant ** [SQLITE_TRANSIENT] then the interfaces makes a copy of the ** content of V and retains the copy. ** ** {H16463} If the D destructor parameter to [sqlite3_result_blob(C,V,N,D)], ** [sqlite3_result_text(C,V,N,D)], [sqlite3_result_text16(C,V,N,D)], ** [sqlite3_result_text16be(C,V,N,D)], or ** [sqlite3_result_text16le(C,V,N,D)] is some value other than ** the constants [SQLITE_STATIC] and [SQLITE_TRANSIENT] then ** SQLite will invoke the destructor D with V as its only argument ** when it has finished with the V value. */ |
︙ | ︙ | |||
4844 4845 4846 4847 4848 4849 4850 | SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); /* | | | 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 | SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); /* ** CAPI3REF: Define New Collating Sequences {H16600} <S20300> ** ** These functions are used to add new collation sequences to the ** [database connection] specified as the first argument. ** ** The name of the new collation sequence is specified as a UTF-8 string ** for sqlite3_create_collation() and sqlite3_create_collation_v2() ** and a UTF-16 string for sqlite3_create_collation16(). In all cases |
︙ | ︙ | |||
4887 4888 4889 4890 4891 4892 4893 | ** of the sqlite3_create_collation_v2(). ** Collations are destroyed when they are overridden by later calls to the ** collation creation functions or when the [database connection] is closed ** using [sqlite3_close()]. ** ** INVARIANTS: ** | | | | | | | | | | | | | 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 | ** of the sqlite3_create_collation_v2(). ** Collations are destroyed when they are overridden by later calls to the ** collation creation functions or when the [database connection] is closed ** using [sqlite3_close()]. ** ** INVARIANTS: ** ** {H16603} A successful call to the ** [sqlite3_create_collation_v2(B,X,E,P,F,D)] interface ** registers function F as the comparison function used to ** implement collation X on the [database connection] B for ** databases having encoding E. ** ** {H16604} SQLite understands the X parameter to ** [sqlite3_create_collation_v2(B,X,E,P,F,D)] as a zero-terminated ** UTF-8 string in which case is ignored for ASCII characters and ** is significant for non-ASCII characters. ** ** {H16606} Successive calls to [sqlite3_create_collation_v2(B,X,E,P,F,D)] ** with the same values for B, X, and E, override prior values ** of P, F, and D. ** ** {H16609} If the destructor D in [sqlite3_create_collation_v2(B,X,E,P,F,D)] ** is not NULL then it is called with argument P when the ** collating function is dropped by SQLite. ** ** {H16612} A collating function is dropped when it is overloaded. ** ** {H16615} A collating function is dropped when the database connection ** is closed using [sqlite3_close()]. ** ** {H16618} The pointer P in [sqlite3_create_collation_v2(B,X,E,P,F,D)] ** is passed through as the first parameter to the comparison ** function F for all subsequent invocations of F. ** ** {H16621} A call to [sqlite3_create_collation(B,X,E,P,F)] is exactly ** the same as a call to [sqlite3_create_collation_v2()] with ** the same parameters and a NULL destructor. ** ** {H16624} Following a [sqlite3_create_collation_v2(B,X,E,P,F,D)], ** SQLite uses the comparison function F for all text comparison ** operations on the [database connection] B on text values that ** use the collating sequence named X. ** ** {H16627} The [sqlite3_create_collation16(B,X,E,P,F)] works the same ** as [sqlite3_create_collation(B,X,E,P,F)] except that the ** collation name X is understood as UTF-16 in native byte order ** instead of UTF-8. ** ** {H16630} When multiple comparison functions are available for the same ** collating sequence, SQLite chooses the one whose text encoding ** requires the least amount of conversion from the default ** text encoding of the database. */ SQLITE_API int sqlite3_create_collation( sqlite3*, const char *zName, |
︙ | ︙ | |||
4958 4959 4960 4961 4962 4963 4964 | const void *zName, int eTextRep, void*, int(*xCompare)(void*,int,const void*,int,const void*) ); /* | | | | | | | 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 | const void *zName, int eTextRep, void*, int(*xCompare)(void*,int,const void*,int,const void*) ); /* ** CAPI3REF: Collation Needed Callbacks {H16700} <S20300> ** ** To avoid having to register all collation sequences before a database ** can be used, a single callback function may be registered with the ** [database connection] to be called whenever an undefined collation ** sequence is required. ** ** If the function is registered using the sqlite3_collation_needed() API, ** then it is passed the names of undefined collation sequences as strings ** encoded in UTF-8. {H16703} If sqlite3_collation_needed16() is used, ** the names are passed as UTF-16 in machine native byte order. ** A call to either function replaces any existing callback. ** ** When the callback is invoked, the first argument passed is a copy ** of the second argument to sqlite3_collation_needed() or ** sqlite3_collation_needed16(). The second argument is the database ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation ** sequence function required. The fourth parameter is the name of the ** required collation sequence. ** ** The callback function should register the desired collation using ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or ** [sqlite3_create_collation_v2()]. ** ** INVARIANTS: ** ** {H16702} A successful call to [sqlite3_collation_needed(D,P,F)] ** or [sqlite3_collation_needed16(D,P,F)] causes ** the [database connection] D to invoke callback F with first ** parameter P whenever it needs a comparison function for a ** collating sequence that it does not know about. ** ** {H16704} Each successful call to [sqlite3_collation_needed()] or ** [sqlite3_collation_needed16()] overrides the callback registered ** on the same [database connection] by prior calls to either ** interface. ** ** {H16706} The name of the requested collating function passed in the ** 4th parameter to the callback is in UTF-8 if the callback ** was registered using [sqlite3_collation_needed()] and ** is in UTF-16 native byte order if the callback was ** registered using [sqlite3_collation_needed16()]. */ SQLITE_API int sqlite3_collation_needed( sqlite3*, |
︙ | ︙ | |||
5039 5040 5041 5042 5043 5044 5045 | */ SQLITE_API int sqlite3_rekey( sqlite3 *db, /* Database to be rekeyed */ const void *pKey, int nKey /* The new key */ ); /* | | | | | | | | | | | | | | | | | | > > > > > > | | 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 | */ SQLITE_API int sqlite3_rekey( sqlite3 *db, /* Database to be rekeyed */ const void *pKey, int nKey /* The new key */ ); /* ** CAPI3REF: Suspend Execution For A Short Time {H10530} <S40410> ** ** The sqlite3_sleep() function causes the current thread to suspend execution ** for at least a number of milliseconds specified in its parameter. ** ** If the operating system does not support sleep requests with ** millisecond time resolution, then the time will be rounded up to ** the nearest second. The number of milliseconds of sleep actually ** requested from the operating system is returned. ** ** SQLite implements this interface by calling the xSleep() ** method of the default [sqlite3_vfs] object. ** ** INVARIANTS: ** ** {H10533} The [sqlite3_sleep(M)] interface invokes the xSleep ** method of the default [sqlite3_vfs|VFS] in order to ** suspend execution of the current thread for at least ** M milliseconds. ** ** {H10536} The [sqlite3_sleep(M)] interface returns the number of ** milliseconds of sleep actually requested of the operating ** system, which might be larger than the parameter M. */ SQLITE_API int sqlite3_sleep(int); /* ** CAPI3REF: Name Of The Folder Holding Temporary Files {H10310} <S20000> ** ** If this global variable is made to point to a string which is ** the name of a folder (a.k.a. directory), then all temporary files ** created by SQLite will be placed in that directory. If this variable ** is a NULL pointer, then SQLite performs a search for an appropriate ** temporary file directory. ** ** It is not safe to modify this variable once a [database connection] ** has been opened. It is intended that this variable be set once ** as part of process initialization and before any SQLite interface ** routines have been call and remain unchanged thereafter. */ SQLITE_API char *sqlite3_temp_directory; /* ** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200> ** KEYWORDS: {autocommit mode} ** ** The sqlite3_get_autocommit() interface returns non-zero or ** zero if the given database connection is or is not in autocommit mode, ** respectively. Autocommit mode is on by default. ** Autocommit mode is disabled by a [BEGIN] statement. ** Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK]. ** ** If certain kinds of errors occur on a statement within a multi-statement ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the ** transaction might be rolled back automatically. The only way to ** find out whether SQLite automatically rolled back the transaction after ** an error is to use this function. ** ** INVARIANTS: ** ** {H12931} The [sqlite3_get_autocommit(D)] interface returns non-zero or ** zero if the [database connection] D is or is not in autocommit ** mode, respectively. ** ** {H12932} Autocommit mode is on by default. ** ** {H12933} Autocommit mode is disabled by a successful [BEGIN] statement. ** ** {H12934} Autocommit mode is enabled by a successful [COMMIT] or [ROLLBACK] ** statement. ** ** ASSUMPTIONS: ** ** {A12936} If another thread changes the autocommit status of the database ** connection while this routine is running, then the return value ** is undefined. */ SQLITE_API int sqlite3_get_autocommit(sqlite3*); /* ** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600> ** ** The sqlite3_db_handle interface returns the [database connection] handle ** to which a [prepared statement] belongs. The database handle returned by ** sqlite3_db_handle is the same database handle that was the first argument ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to ** create the statement in the first place. ** ** INVARIANTS: ** ** {H13123} The [sqlite3_db_handle(S)] interface returns a pointer ** to the [database connection] associated with the ** [prepared statement] S. */ SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); /* ** CAPI3REF: Find the next prepared statement {H13140} <S60600> ** ** This interface returns a pointer to the next [prepared statement] after ** pStmt associated with the [database connection] pDb. If pStmt is NULL ** then this interface returns a pointer to the first prepared statement ** associated with the database connection pDb. If no prepared statement ** satisfies the conditions of this routine, it returns NULL. ** ** INVARIANTS: ** ** {H13143} If D is a [database connection] that holds one or more ** unfinalized [prepared statements] and S is a NULL pointer, ** then [sqlite3_next_stmt(D, S)] routine shall return a pointer ** to one of the prepared statements associated with D. ** ** {H13146} If D is a [database connection] that holds no unfinalized ** [prepared statements] and S is a NULL pointer, then ** [sqlite3_next_stmt(D, S)] routine shall return a NULL pointer. ** ** {H13149} If S is a [prepared statement] in the [database connection] D ** and S is not the last prepared statement in D, then ** [sqlite3_next_stmt(D, S)] routine shall return a pointer ** to the next prepared statement in D after S. ** ** {H13152} If S is the last [prepared statement] in the ** [database connection] D then the [sqlite3_next_stmt(D, S)] ** routine shall return a NULL pointer. ** ** ASSUMPTIONS: ** ** {A13154} The [database connection] pointer D in a call to ** [sqlite3_next_stmt(D,S)] must refer to an open database ** connection and in particular must not be a NULL pointer. */ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); /* ** CAPI3REF: Commit And Rollback Notification Callbacks {H12950} <S60400> ** ** The sqlite3_commit_hook() interface registers a callback ** function to be invoked whenever a transaction is committed. ** Any callback set by a previous call to sqlite3_commit_hook() ** for the same database connection is overridden. ** The sqlite3_rollback_hook() interface registers a callback ** function to be invoked whenever a transaction is committed. |
︙ | ︙ | |||
5198 5199 5200 5201 5202 5203 5204 | ** automatically rolled back because the database connection is closed. ** The rollback callback is not invoked if a transaction is ** rolled back because a commit callback returned non-zero. ** <todo> Check on this </todo> ** ** INVARIANTS: ** | | | | | | | | | | | | 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 | ** automatically rolled back because the database connection is closed. ** The rollback callback is not invoked if a transaction is ** rolled back because a commit callback returned non-zero. ** <todo> Check on this </todo> ** ** INVARIANTS: ** ** {H12951} The [sqlite3_commit_hook(D,F,P)] interface registers the ** callback function F to be invoked with argument P whenever ** a transaction commits on the [database connection] D. ** ** {H12952} The [sqlite3_commit_hook(D,F,P)] interface returns the P argument ** from the previous call with the same [database connection] D, ** or NULL on the first call for a particular database connection D. ** ** {H12953} Each call to [sqlite3_commit_hook()] overwrites the callback ** registered by prior calls. ** ** {H12954} If the F argument to [sqlite3_commit_hook(D,F,P)] is NULL ** then the commit hook callback is canceled and no callback ** is invoked when a transaction commits. ** ** {H12955} If the commit callback returns non-zero then the commit is ** converted into a rollback. ** ** {H12961} The [sqlite3_rollback_hook(D,F,P)] interface registers the ** callback function F to be invoked with argument P whenever ** a transaction rolls back on the [database connection] D. ** ** {H12962} The [sqlite3_rollback_hook(D,F,P)] interface returns the P ** argument from the previous call with the same ** [database connection] D, or NULL on the first call ** for a particular database connection D. ** ** {H12963} Each call to [sqlite3_rollback_hook()] overwrites the callback ** registered by prior calls. ** ** {H12964} If the F argument to [sqlite3_rollback_hook(D,F,P)] is NULL ** then the rollback hook callback is canceled and no callback ** is invoked when a transaction rolls back. */ SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); /* ** CAPI3REF: Data Change Notification Callbacks {H12970} <S60400> ** ** The sqlite3_update_hook() interface registers a callback function ** with the [database connection] identified by the first argument ** to be invoked whenever a row is updated, inserted or deleted. ** Any callback set by a previous call to this function ** for the same database connection is overridden. ** |
︙ | ︙ | |||
5264 5265 5266 5267 5268 5269 5270 | ** modified (i.e. sqlite_master and sqlite_sequence). ** ** If another function was previously registered, its pArg value ** is returned. Otherwise NULL is returned. ** ** INVARIANTS: ** | | | | | | | | | | | 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 | ** modified (i.e. sqlite_master and sqlite_sequence). ** ** If another function was previously registered, its pArg value ** is returned. Otherwise NULL is returned. ** ** INVARIANTS: ** ** {H12971} The [sqlite3_update_hook(D,F,P)] interface causes the callback ** function F to be invoked with first parameter P whenever ** a table row is modified, inserted, or deleted on ** the [database connection] D. ** ** {H12973} The [sqlite3_update_hook(D,F,P)] interface returns the value ** of P for the previous call on the same [database connection] D, ** or NULL for the first call. ** ** {H12975} If the update hook callback F in [sqlite3_update_hook(D,F,P)] ** is NULL then the no update callbacks are made. ** ** {H12977} Each call to [sqlite3_update_hook(D,F,P)] overrides prior calls ** to the same interface on the same [database connection] D. ** ** {H12979} The update hook callback is not invoked when internal system ** tables such as sqlite_master and sqlite_sequence are modified. ** ** {H12981} The second parameter to the update callback ** is one of [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], ** depending on the operation that caused the callback to be invoked. ** ** {H12983} The third and fourth arguments to the callback contain pointers ** to zero-terminated UTF-8 strings which are the names of the ** database and table that is being updated. ** {H12985} The final callback parameter is the rowid of the row after ** the change occurs. */ SQLITE_API void *sqlite3_update_hook( sqlite3*, void(*)(void *,int ,char const *,char const *,sqlite3_int64), void* ); /* ** CAPI3REF: Enable Or Disable Shared Pager Cache {H10330} <S30900> ** KEYWORDS: {shared cache} {shared cache mode} ** ** This routine enables or disables the sharing of the database cache ** and schema data structures between [database connection | connections] ** to the same database. Sharing is enabled if the argument is true ** and disabled if the argument is false. ** |
︙ | ︙ | |||
5330 5331 5332 5333 5334 5335 5336 | ** ** Shared cache is disabled by default. But this might change in ** future releases of SQLite. Applications that care about shared ** cache setting should set it explicitly. ** ** INVARIANTS: ** | | | | | | | | | | 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 | ** ** Shared cache is disabled by default. But this might change in ** future releases of SQLite. Applications that care about shared ** cache setting should set it explicitly. ** ** INVARIANTS: ** ** {H10331} A successful invocation of [sqlite3_enable_shared_cache(B)] ** will enable or disable shared cache mode for any subsequently ** created [database connection] in the same process. ** ** {H10336} When shared cache is enabled, the [sqlite3_create_module()] ** interface will always return an error. ** ** {H10337} The [sqlite3_enable_shared_cache(B)] interface returns ** [SQLITE_OK] if shared cache was enabled or disabled successfully. ** ** {H10339} Shared cache is disabled by default. */ SQLITE_API int sqlite3_enable_shared_cache(int); /* ** CAPI3REF: Attempt To Free Heap Memory {H17340} <S30220> ** ** The sqlite3_release_memory() interface attempts to free N bytes ** of heap memory by deallocating non-essential memory allocations ** held by the database library. {END} Memory used to cache database ** pages to improve performance is an example of non-essential memory. ** sqlite3_release_memory() returns the number of bytes actually freed, ** which might be more or less than the amount requested. ** ** INVARIANTS: ** ** {H17341} The [sqlite3_release_memory(N)] interface attempts to ** free N bytes of heap memory by deallocating non-essential ** memory allocations held by the database library. ** ** {H16342} The [sqlite3_release_memory(N)] returns the number ** of bytes actually freed, which might be more or less ** than the amount requested. */ SQLITE_API int sqlite3_release_memory(int); /* ** CAPI3REF: Impose A Limit On Heap Size {H17350} <S30220> ** ** The sqlite3_soft_heap_limit() interface places a "soft" limit ** on the amount of heap memory that may be allocated by SQLite. ** If an internal allocation is requested that would exceed the ** soft heap limit, [sqlite3_release_memory()] is invoked one or ** more times to free up some space before the allocation is performed. ** |
︙ | ︙ | |||
5398 5399 5400 5401 5402 5403 5404 | ** applied to all threads. The value specified for the soft heap limit ** is an upper bound on the total memory allocation for all threads. In ** version 3.5.0 there is no mechanism for limiting the heap usage for ** individual threads. ** ** INVARIANTS: ** | | | | | | | | | 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 | ** applied to all threads. The value specified for the soft heap limit ** is an upper bound on the total memory allocation for all threads. In ** version 3.5.0 there is no mechanism for limiting the heap usage for ** individual threads. ** ** INVARIANTS: ** ** {H16351} The [sqlite3_soft_heap_limit(N)] interface places a soft limit ** of N bytes on the amount of heap memory that may be allocated ** using [sqlite3_malloc()] or [sqlite3_realloc()] at any point ** in time. ** ** {H16352} If a call to [sqlite3_malloc()] or [sqlite3_realloc()] would ** cause the total amount of allocated memory to exceed the ** soft heap limit, then [sqlite3_release_memory()] is invoked ** in an attempt to reduce the memory usage prior to proceeding ** with the memory allocation attempt. ** ** {H16353} Calls to [sqlite3_malloc()] or [sqlite3_realloc()] that trigger ** attempts to reduce memory usage through the soft heap limit ** mechanism continue even if the attempt to reduce memory ** usage is unsuccessful. ** ** {H16354} A negative or zero value for N in a call to ** [sqlite3_soft_heap_limit(N)] means that there is no soft ** heap limit and [sqlite3_release_memory()] will only be ** called when memory is completely exhausted. ** ** {H16355} The default value for the soft heap limit is zero. ** ** {H16358} Each call to [sqlite3_soft_heap_limit(N)] overrides the ** values set by all prior calls. */ SQLITE_API void sqlite3_soft_heap_limit(int); /* ** CAPI3REF: Extract Metadata About A Column Of A Table {H12850} <S60300> ** ** This routine returns metadata about a specific column of a specific ** database table accessible using the [database connection] handle ** passed as the first function argument. ** ** The column is identified by the second, third and fourth parameters to ** this function. The second parameter is either the name of the database |
︙ | ︙ | |||
5501 5502 5503 5504 5505 5506 5507 | char const **pzCollSeq, /* OUTPUT: Collation sequence name */ int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ int *pPrimaryKey, /* OUTPUT: True if column part of PK */ int *pAutoinc /* OUTPUT: True if column is auto-increment */ ); /* | | | | | | | | | | | | | | | | | | | | 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 | char const **pzCollSeq, /* OUTPUT: Collation sequence name */ int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ int *pPrimaryKey, /* OUTPUT: True if column part of PK */ int *pAutoinc /* OUTPUT: True if column is auto-increment */ ); /* ** CAPI3REF: Load An Extension {H12600} <S20500> ** ** This interface loads an SQLite extension library from the named file. ** ** {H12601} The sqlite3_load_extension() interface attempts to load an ** SQLite extension library contained in the file zFile. ** ** {H12602} The entry point is zProc. ** ** {H12603} zProc may be 0, in which case the name of the entry point ** defaults to "sqlite3_extension_init". ** ** {H12604} The sqlite3_load_extension() interface shall return ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. ** ** {H12605} If an error occurs and pzErrMsg is not 0, then the ** [sqlite3_load_extension()] interface shall attempt to ** fill *pzErrMsg with error message text stored in memory ** obtained from [sqlite3_malloc()]. {END} The calling function ** should free this memory by calling [sqlite3_free()]. ** ** {H12606} Extension loading must be enabled using ** [sqlite3_enable_load_extension()] prior to calling this API, ** otherwise an error will be returned. */ SQLITE_API int sqlite3_load_extension( sqlite3 *db, /* Load the extension into this database connection */ const char *zFile, /* Name of the shared library containing extension */ const char *zProc, /* Entry point. Derived from zFile if 0 */ char **pzErrMsg /* Put error message here if not 0 */ ); /* ** CAPI3REF: Enable Or Disable Extension Loading {H12620} <S20500> ** ** So as not to open security holes in older applications that are ** unprepared to deal with extension loading, and as a means of disabling ** extension loading while evaluating user-entered SQL, the following API ** is provided to turn the [sqlite3_load_extension()] mechanism on and off. ** ** Extension loading is off by default. See ticket #1863. ** ** {H12621} Call the sqlite3_enable_load_extension() routine with onoff==1 ** to turn extension loading on and call it with onoff==0 to turn ** it back off again. ** ** {H12622} Extension loading is off by default. */ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); /* ** CAPI3REF: Automatically Load An Extensions {H12640} <S20500> ** ** This API can be invoked at program startup in order to register ** one or more statically linked extensions that will be available ** to all new [database connections]. {END} ** ** This routine stores a pointer to the extension in an array that is ** obtained from [sqlite3_malloc()]. If you run a memory leak checker ** on your program and it reports a leak because of this array, invoke ** [sqlite3_reset_auto_extension()] prior to shutdown to free the memory. ** ** {H12641} This function registers an extension entry point that is ** automatically invoked whenever a new [database connection] ** is opened using [sqlite3_open()], [sqlite3_open16()], ** or [sqlite3_open_v2()]. ** ** {H12642} Duplicate extensions are detected so calling this routine ** multiple times with the same extension is harmless. ** ** {H12643} This routine stores a pointer to the extension in an array ** that is obtained from [sqlite3_malloc()]. ** ** {H12644} Automatic extensions apply across all threads. */ SQLITE_API int sqlite3_auto_extension(void *xEntryPoint); /* ** CAPI3REF: Reset Automatic Extension Loading {H12660} <S20500> ** ** This function disables all previously registered automatic ** extensions. {END} It undoes the effect of all prior ** [sqlite3_auto_extension()] calls. ** ** {H12661} This function disables all previously registered ** automatic extensions. ** ** {H12662} This function disables automatic extensions in all threads. */ SQLITE_API void sqlite3_reset_auto_extension(void); /* ****** EXPERIMENTAL - subject to change without notice ************** ** ** The interface to the virtual-table mechanism is currently considered |
︙ | ︙ | |||
5612 5613 5614 5615 5616 5617 5618 | */ typedef struct sqlite3_vtab sqlite3_vtab; typedef struct sqlite3_index_info sqlite3_index_info; typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; typedef struct sqlite3_module sqlite3_module; /* | | > | 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 | */ typedef struct sqlite3_vtab sqlite3_vtab; typedef struct sqlite3_index_info sqlite3_index_info; typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; typedef struct sqlite3_module sqlite3_module; /* ** CAPI3REF: Virtual Table Object {H18000} <S20400> ** KEYWORDS: sqlite3_module ** EXPERIMENTAL ** ** A module is a class of virtual tables. Each module is defined ** by an instance of the following structure. This structure consists ** mostly of methods for the module. ** ** This interface is experimental and is subject to change or ** removal in future releases of SQLite. |
︙ | ︙ | |||
5649 5650 5651 5652 5653 5654 5655 | int (*xBegin)(sqlite3_vtab *pVTab); int (*xSync)(sqlite3_vtab *pVTab); int (*xCommit)(sqlite3_vtab *pVTab); int (*xRollback)(sqlite3_vtab *pVTab); int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName, void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), void **ppArg); | < | > | 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 | int (*xBegin)(sqlite3_vtab *pVTab); int (*xSync)(sqlite3_vtab *pVTab); int (*xCommit)(sqlite3_vtab *pVTab); int (*xRollback)(sqlite3_vtab *pVTab); int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName, void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), void **ppArg); int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); }; /* ** CAPI3REF: Virtual Table Indexing Information {H18100} <S20400> ** KEYWORDS: sqlite3_index_info ** EXPERIMENTAL ** ** The sqlite3_index_info structure and its substructures is used to ** pass information into and receive the reply from the xBestIndex ** method of an sqlite3_module. The fields under **Inputs** are the ** inputs to xBestIndex and are read-only. xBestIndex inserts its ** results into the **Outputs** fields. ** |
︙ | ︙ | |||
5718 5719 5720 5721 5722 5723 5724 | int iTermOffset; /* Used internally - xBestIndex should ignore */ } *aConstraint; /* Table of WHERE clause constraints */ int nOrderBy; /* Number of terms in the ORDER BY clause */ struct sqlite3_index_orderby { int iColumn; /* Column number */ unsigned char desc; /* True for DESC. False for ASC. */ } *aOrderBy; /* The ORDER BY clause */ | < | > | > | > | 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 | int iTermOffset; /* Used internally - xBestIndex should ignore */ } *aConstraint; /* Table of WHERE clause constraints */ int nOrderBy; /* Number of terms in the ORDER BY clause */ struct sqlite3_index_orderby { int iColumn; /* Column number */ unsigned char desc; /* True for DESC. False for ASC. */ } *aOrderBy; /* The ORDER BY clause */ /* Outputs */ struct sqlite3_index_constraint_usage { int argvIndex; /* if >0, constraint is part of argv to xFilter */ unsigned char omit; /* Do not code a test for this constraint */ } *aConstraintUsage; int idxNum; /* Number used to identify the index */ char *idxStr; /* String, possibly obtained from sqlite3_malloc */ int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ int orderByConsumed; /* True if output is already ordered */ double estimatedCost; /* Estimated cost of using this index */ }; #define SQLITE_INDEX_CONSTRAINT_EQ 2 #define SQLITE_INDEX_CONSTRAINT_GT 4 #define SQLITE_INDEX_CONSTRAINT_LE 8 #define SQLITE_INDEX_CONSTRAINT_LT 16 #define SQLITE_INDEX_CONSTRAINT_GE 32 #define SQLITE_INDEX_CONSTRAINT_MATCH 64 /* ** CAPI3REF: Register A Virtual Table Implementation {H18200} <S20400> ** EXPERIMENTAL ** ** This routine is used to register a new module name with a ** [database connection]. Module names must be registered before ** creating new virtual tables on the module, or before using ** preexisting virtual tables of the module. ** ** This interface is experimental and is subject to change or ** removal in future releases of SQLite. */ SQLITE_API int sqlite3_create_module( sqlite3 *db, /* SQLite connection to register module with */ const char *zName, /* Name of the module */ const sqlite3_module *, /* Methods for the module */ void * /* Client data for xCreate/xConnect */ ); /* ** CAPI3REF: Register A Virtual Table Implementation {H18210} <S20400> ** EXPERIMENTAL ** ** This routine is identical to the [sqlite3_create_module()] method above, ** except that it allows a destructor function to be specified. It is ** even more experimental than the rest of the virtual tables API. */ SQLITE_API int sqlite3_create_module_v2( sqlite3 *db, /* SQLite connection to register module with */ const char *zName, /* Name of the module */ const sqlite3_module *, /* Methods for the module */ void *, /* Client data for xCreate/xConnect */ void(*xDestroy)(void*) /* Module destructor function */ ); /* ** CAPI3REF: Virtual Table Instance Object {H18010} <S20400> ** KEYWORDS: sqlite3_vtab ** EXPERIMENTAL ** ** Every module implementation uses a subclass of the following structure ** to describe a particular instance of the module. Each subclass will ** be tailored to the specific needs of the module implementation. ** The purpose of this superclass is to define certain fields that are ** common to all module implementations. ** |
︙ | ︙ | |||
5801 5802 5803 5804 5805 5806 5807 | const sqlite3_module *pModule; /* The module for this virtual table */ int nRef; /* Used internally */ char *zErrMsg; /* Error message from sqlite3_mprintf() */ /* Virtual table implementations will typically add additional fields */ }; /* | | > | > | > | 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 | const sqlite3_module *pModule; /* The module for this virtual table */ int nRef; /* Used internally */ char *zErrMsg; /* Error message from sqlite3_mprintf() */ /* Virtual table implementations will typically add additional fields */ }; /* ** CAPI3REF: Virtual Table Cursor Object {H18020} <S20400> ** KEYWORDS: sqlite3_vtab_cursor ** EXPERIMENTAL ** ** Every module implementation uses a subclass of the following structure ** to describe cursors that point into the virtual table and are used ** to loop through the virtual table. Cursors are created using the ** xOpen method of the module. Each module implementation will define ** the content of a cursor structure to suit its own needs. ** ** This superclass exists in order to define fields of the cursor that ** are common to all implementations. ** ** This interface is experimental and is subject to change or ** removal in future releases of SQLite. */ struct sqlite3_vtab_cursor { sqlite3_vtab *pVtab; /* Virtual table of this cursor */ /* Virtual table implementations will typically add additional fields */ }; /* ** CAPI3REF: Declare The Schema Of A Virtual Table {H18280} <S20400> ** EXPERIMENTAL ** ** The xCreate and xConnect methods of a module use the following API ** to declare the format (the names and datatypes of the columns) of ** the virtual tables they implement. ** ** This interface is experimental and is subject to change or ** removal in future releases of SQLite. */ SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zCreateTable); /* ** CAPI3REF: Overload A Function For A Virtual Table {H18300} <S20400> ** EXPERIMENTAL ** ** Virtual tables can provide alternative implementations of functions ** using the xFindFunction method. But global versions of those functions ** must exist in order to be overloaded. ** ** This API makes sure a global version of a function with a particular ** name and number of parameters exists. If no such function exists |
︙ | ︙ | |||
5866 5867 5868 5869 5870 5871 5872 | ** When the virtual-table mechanism stabilizes, we will declare the ** interface fixed, support it indefinitely, and remove this comment. ** ****** EXPERIMENTAL - subject to change without notice ************** */ /* | | | | 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 | ** When the virtual-table mechanism stabilizes, we will declare the ** interface fixed, support it indefinitely, and remove this comment. ** ****** EXPERIMENTAL - subject to change without notice ************** */ /* ** CAPI3REF: A Handle To An Open BLOB {H17800} <S30230> ** KEYWORDS: {BLOB handle} {BLOB handles} ** ** An instance of this object represents an open BLOB on which ** [sqlite3_blob_open | incremental BLOB I/O] can be performed. ** Objects of this type are created by [sqlite3_blob_open()] ** and destroyed by [sqlite3_blob_close()]. ** The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces ** can be used to read or write small subsections of the BLOB. ** The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes. */ typedef struct sqlite3_blob sqlite3_blob; /* ** CAPI3REF: Open A BLOB For Incremental I/O {H17810} <S30230> ** ** This interfaces opens a [BLOB handle | handle] to the BLOB located ** in row iRow, column zColumn, table zTable in database zDb; ** in other words, the same BLOB that would be selected by: ** ** <pre> ** SELECT zColumn FROM zDb.zTable WHERE rowid = iRow; |
︙ | ︙ | |||
5918 5919 5920 5921 5922 5923 5924 | ** a expired BLOB handle fail with an return code of [SQLITE_ABORT]. ** Changes written into a BLOB prior to the BLOB expiring are not ** rollback by the expiration of the BLOB. Such changes will eventually ** commit if the transaction continues to completion. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | | | | | | | 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 | ** a expired BLOB handle fail with an return code of [SQLITE_ABORT]. ** Changes written into a BLOB prior to the BLOB expiring are not ** rollback by the expiration of the BLOB. Such changes will eventually ** commit if the transaction continues to completion. ** ** INVARIANTS: ** ** {H17813} A successful invocation of the [sqlite3_blob_open(D,B,T,C,R,F,P)] ** interface shall open an [sqlite3_blob] object P on the BLOB ** in column C of the table T in the database B on ** the [database connection] D. ** ** {H17814} A successful invocation of [sqlite3_blob_open(D,...)] shall start ** a new transaction on the [database connection] D if that ** connection is not already in a transaction. ** ** {H17816} The [sqlite3_blob_open(D,B,T,C,R,F,P)] interface shall open ** the BLOB for read and write access if and only if the F ** parameter is non-zero. ** ** {H17819} The [sqlite3_blob_open()] interface shall return [SQLITE_OK] on ** success and an appropriate [error code] on failure. ** ** {H17821} If an error occurs during evaluation of [sqlite3_blob_open(D,...)] ** then subsequent calls to [sqlite3_errcode(D)], ** [sqlite3_errmsg(D)], and [sqlite3_errmsg16(D)] shall return ** information appropriate for that error. ** ** {H17824} If any column in the row that a [sqlite3_blob] has open is ** changed by a separate [UPDATE] or [DELETE] statement or by ** an [ON CONFLICT] side effect, then the [sqlite3_blob] shall ** be marked as invalid. */ SQLITE_API int sqlite3_blob_open( sqlite3*, const char *zDb, const char *zTable, const char *zColumn, sqlite3_int64 iRow, int flags, sqlite3_blob **ppBlob ); /* ** CAPI3REF: Close A BLOB Handle {H17830} <S30230> ** ** Closes an open [BLOB handle]. ** ** Closing a BLOB shall cause the current transaction to commit ** if there are no other BLOBs, no pending prepared statements, and the ** database connection is in [autocommit mode]. ** If any writes were made to the BLOB, they might be held in cache ** until the close operation if they will fit. {END} ** ** Closing the BLOB often forces the changes ** out to disk and so if any I/O errors occur, they will likely occur ** at the time when the BLOB is closed. {H17833} Any errors that occur during ** closing are reported as a non-zero return value. ** ** The BLOB is closed unconditionally. Even if this routine returns ** an error code, the BLOB is still closed. ** ** INVARIANTS: ** ** {H17833} The [sqlite3_blob_close(P)] interface closes an [sqlite3_blob] ** object P previously opened using [sqlite3_blob_open()]. ** ** {H17836} Closing an [sqlite3_blob] object using ** [sqlite3_blob_close()] shall cause the current transaction to ** commit if there are no other open [sqlite3_blob] objects ** or [prepared statements] on the same [database connection] and ** the database connection is in [autocommit mode]. ** ** {H17839} The [sqlite3_blob_close(P)] interfaces shall close the ** [sqlite3_blob] object P unconditionally, even if ** [sqlite3_blob_close(P)] returns something other than [SQLITE_OK]. */ SQLITE_API int sqlite3_blob_close(sqlite3_blob *); /* ** CAPI3REF: Return The Size Of An Open BLOB {H17840} <S30230> ** ** Returns the size in bytes of the BLOB accessible via the open ** []BLOB handle] in its only argument. ** ** INVARIANTS: ** ** {H17843} The [sqlite3_blob_bytes(P)] interface returns the size ** in bytes of the BLOB that the [sqlite3_blob] object P ** refers to. */ SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *); /* ** CAPI3REF: Read Data From A BLOB Incrementally {H17850} <S30230> ** ** This function is used to read data from an open [BLOB handle] into a ** caller-supplied buffer. N bytes of data are copied into buffer Z ** from the open BLOB, starting at offset iOffset. ** ** If offset iOffset is less than N bytes from the end of the BLOB, ** [SQLITE_ERROR] is returned and no data is read. If N or iOffset is ** less than zero, [SQLITE_ERROR] is returned and no data is read. ** ** An attempt to read from an expired [BLOB handle] fails with an ** error code of [SQLITE_ABORT]. ** ** On success, SQLITE_OK is returned. ** Otherwise, an [error code] or an [extended error code] is returned. ** ** INVARIANTS: ** ** {H17853} A successful invocation of [sqlite3_blob_read(P,Z,N,X)] ** shall reads N bytes of data out of the BLOB referenced by ** [BLOB handle] P beginning at offset X and store those bytes ** into buffer Z. ** ** {H17856} In [sqlite3_blob_read(P,Z,N,X)] if the size of the BLOB ** is less than N+X bytes, then the function shall leave the ** Z buffer unchanged and return [SQLITE_ERROR]. ** ** {H17859} In [sqlite3_blob_read(P,Z,N,X)] if X or N is less than zero ** then the function shall leave the Z buffer unchanged ** and return [SQLITE_ERROR]. ** ** {H17862} The [sqlite3_blob_read(P,Z,N,X)] interface shall return [SQLITE_OK] ** if N bytes are successfully read into buffer Z. ** ** {H17863} If the [BLOB handle] P is expired and X and N are within bounds ** then [sqlite3_blob_read(P,Z,N,X)] shall leave the Z buffer ** unchanged and return [SQLITE_ABORT]. ** ** {H17865} If the requested read could not be completed, ** the [sqlite3_blob_read(P,Z,N,X)] interface shall return an ** appropriate [error code] or [extended error code]. ** ** {H17868} If an error occurs during evaluation of [sqlite3_blob_read(P,...)] ** then subsequent calls to [sqlite3_errcode(D)], ** [sqlite3_errmsg(D)], and [sqlite3_errmsg16(D)] shall return ** information appropriate for that error, where D is the ** [database connection] that was used to open the [BLOB handle] P. */ SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); /* ** CAPI3REF: Write Data Into A BLOB Incrementally {H17870} <S30230> ** ** This function is used to write data into an open [BLOB handle] from a ** caller-supplied buffer. N bytes of data are copied from the buffer Z ** into the open BLOB, starting at offset iOffset. ** ** If the [BLOB handle] passed as the first argument was not opened for ** writing (the flags parameter to [sqlite3_blob_open()] was zero), |
︙ | ︙ | |||
6084 6085 6086 6087 6088 6089 6090 | ** or by other independent statements. ** ** On success, SQLITE_OK is returned. ** Otherwise, an [error code] or an [extended error code] is returned. ** ** INVARIANTS: ** | | | | | | | | | | | | 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 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 | ** or by other independent statements. ** ** On success, SQLITE_OK is returned. ** Otherwise, an [error code] or an [extended error code] is returned. ** ** INVARIANTS: ** ** {H17873} A successful invocation of [sqlite3_blob_write(P,Z,N,X)] ** shall write N bytes of data from buffer Z into the BLOB ** referenced by [BLOB handle] P beginning at offset X into ** the BLOB. ** ** {H17874} In the absence of other overridding changes, the changes ** written to a BLOB by [sqlite3_blob_write()] shall ** remain in effect after the associated [BLOB handle] expires. ** ** {H17875} If the [BLOB handle] P was opened for reading only then ** an invocation of [sqlite3_blob_write(P,Z,N,X)] shall leave ** the referenced BLOB unchanged and return [SQLITE_READONLY]. ** ** {H17876} If the size of the BLOB referenced by [BLOB handle] P is ** less than N+X bytes then [sqlite3_blob_write(P,Z,N,X)] shall ** leave the BLOB unchanged and return [SQLITE_ERROR]. ** ** {H17877} If the [BLOB handle] P is expired and X and N are within bounds ** then [sqlite3_blob_read(P,Z,N,X)] shall leave the BLOB ** unchanged and return [SQLITE_ABORT]. ** ** {H17879} If X or N are less than zero then [sqlite3_blob_write(P,Z,N,X)] ** shall leave the BLOB referenced by [BLOB handle] P unchanged ** and return [SQLITE_ERROR]. ** ** {H17882} The [sqlite3_blob_write(P,Z,N,X)] interface shall return ** [SQLITE_OK] if N bytes where successfully written into the BLOB. ** ** {H17885} If the requested write could not be completed, ** the [sqlite3_blob_write(P,Z,N,X)] interface shall return an ** appropriate [error code] or [extended error code]. ** ** {H17888} If an error occurs during evaluation of [sqlite3_blob_write(D,...)] ** then subsequent calls to [sqlite3_errcode(D)], ** [sqlite3_errmsg(D)], and [sqlite3_errmsg16(D)] shall return ** information appropriate for that error. */ SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); /* ** CAPI3REF: Virtual File System Objects {H11200} <S20100> ** ** A virtual filesystem (VFS) is an [sqlite3_vfs] object ** that SQLite uses to interact ** with the underlying operating system. Most SQLite builds come with a ** single default VFS that is appropriate for the host computer. ** New VFSes can be registered and existing VFSes can be unregistered. ** The following interfaces are provided. |
︙ | ︙ | |||
6154 6155 6156 6157 6158 6159 6160 | ** ** Unregister a VFS with the sqlite3_vfs_unregister() interface. ** If the default VFS is unregistered, another VFS is chosen as ** the default. The choice for the new VFS is arbitrary. ** ** INVARIANTS: ** | | | | | | | | | 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 | ** ** Unregister a VFS with the sqlite3_vfs_unregister() interface. ** If the default VFS is unregistered, another VFS is chosen as ** the default. The choice for the new VFS is arbitrary. ** ** INVARIANTS: ** ** {H11203} The [sqlite3_vfs_find(N)] interface returns a pointer to the ** registered [sqlite3_vfs] object whose name exactly matches ** the zero-terminated UTF-8 string N, or it returns NULL if ** there is no match. ** ** {H11206} If the N parameter to [sqlite3_vfs_find(N)] is NULL then ** the function returns a pointer to the default [sqlite3_vfs] ** object if there is one, or NULL if there is no default ** [sqlite3_vfs] object. ** ** {H11209} The [sqlite3_vfs_register(P,F)] interface registers the ** well-formed [sqlite3_vfs] object P using the name given ** by the zName field of the object. ** ** {H11212} Using the [sqlite3_vfs_register(P,F)] interface to register ** the same [sqlite3_vfs] object multiple times is a harmless no-op. ** ** {H11215} The [sqlite3_vfs_register(P,F)] interface makes the [sqlite3_vfs] ** object P the default [sqlite3_vfs] object if F is non-zero. ** ** {H11218} The [sqlite3_vfs_unregister(P)] interface unregisters the ** [sqlite3_vfs] object P so that it is no longer returned by ** subsequent calls to [sqlite3_vfs_find()]. */ SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName); SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); /* ** CAPI3REF: Mutexes {H17000} <S20000> ** ** The SQLite core uses these routines for thread ** synchronization. Though they are intended for internal ** use by SQLite, code that links against SQLite is ** permitted to use any of these routines. ** ** The SQLite source code contains multiple implementations |
︙ | ︙ | |||
6216 6217 6218 6219 6220 6221 6222 | ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex ** implementation is included with the library. In this case the ** application must supply a custom mutex implementation using the ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function ** before calling sqlite3_initialize() or any other public sqlite3_ ** function that calls sqlite3_initialize(). ** | | | | | | | | | | | | | | | | | | | | | | > | | | 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 | ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex ** implementation is included with the library. In this case the ** application must supply a custom mutex implementation using the ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function ** before calling sqlite3_initialize() or any other public sqlite3_ ** function that calls sqlite3_initialize(). ** ** {H17011} The sqlite3_mutex_alloc() routine allocates a new ** mutex and returns a pointer to it. {H17012} If it returns NULL ** that means that a mutex could not be allocated. {H17013} SQLite ** will unwind its stack and return an error. {H17014} The argument ** to sqlite3_mutex_alloc() is one of these integer constants: ** ** <ul> ** <li> SQLITE_MUTEX_FAST ** <li> SQLITE_MUTEX_RECURSIVE ** <li> SQLITE_MUTEX_STATIC_MASTER ** <li> SQLITE_MUTEX_STATIC_MEM ** <li> SQLITE_MUTEX_STATIC_MEM2 ** <li> SQLITE_MUTEX_STATIC_PRNG ** <li> SQLITE_MUTEX_STATIC_LRU ** <li> SQLITE_MUTEX_STATIC_LRU2 ** </ul> ** ** {H17015} The first two constants cause sqlite3_mutex_alloc() to create ** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. {END} ** The mutex implementation does not need to make a distinction ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does ** not want to. {H17016} But SQLite will only request a recursive mutex in ** cases where it really needs one. {END} If a faster non-recursive mutex ** implementation is available on the host platform, the mutex subsystem ** might return such a mutex in response to SQLITE_MUTEX_FAST. ** ** {H17017} The other allowed parameters to sqlite3_mutex_alloc() each return ** a pointer to a static preexisting mutex. {END} Four static mutexes are ** used by the current version of SQLite. Future versions of SQLite ** may add additional static mutexes. Static mutexes are for internal ** use by SQLite only. Applications that use SQLite mutexes should ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or ** SQLITE_MUTEX_RECURSIVE. ** ** {H17018} Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() ** returns a different mutex on every call. {H17034} But for the static ** mutex types, the same mutex is returned on every call that has ** the same type number. ** ** {H17019} The sqlite3_mutex_free() routine deallocates a previously ** allocated dynamic mutex. {H17020} SQLite is careful to deallocate every ** dynamic mutex that it allocates. {A17021} The dynamic mutexes must not be in ** use when they are deallocated. {A17022} Attempting to deallocate a static ** mutex results in undefined behavior. {H17023} SQLite never deallocates ** a static mutex. {END} ** ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt ** to enter a mutex. {H17024} If another thread is already within the mutex, ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return ** SQLITE_BUSY. {H17025} The sqlite3_mutex_try() interface returns [SQLITE_OK] ** upon successful entry. {H17026} Mutexes created using ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. ** {H17027} In such cases the, ** mutex must be exited an equal number of times before another thread ** can enter. {A17028} If the same thread tries to enter any other ** kind of mutex more than once, the behavior is undefined. ** {H17029} SQLite will never exhibit ** such behavior in its own use of mutexes. ** ** Some systems (for example, Windows 95) do not support the operation ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() ** will always return SQLITE_BUSY. {H17030} The SQLite core only ever uses ** sqlite3_mutex_try() as an optimization so this is acceptable behavior. ** ** {H17031} The sqlite3_mutex_leave() routine exits a mutex that was ** previously entered by the same thread. {A17032} The behavior ** is undefined if the mutex is not currently entered by the ** calling thread or is not currently allocated. {H17033} SQLite will ** never do either. {END} ** ** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or ** sqlite3_mutex_leave() is a NULL pointer, then all three routines ** behave as no-ops. ** ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. */ SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int); SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*); SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*); SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*); SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*); /* ** CAPI3REF: Mutex Methods Object {H17120} <S20130> ** EXPERIMENTAL ** ** An instance of this structure defines the low-level routines ** used to allocate and use mutexes. ** ** Usually, the default mutex implementations provided by SQLite are ** sufficient, however the user has the option of substituting a custom ** implementation for specialized deployments or systems for which SQLite ** does not provide a suitable implementation. In this case, the user ** creates and populates an instance of this structure to pass ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. ** Additionally, an instance of this structure can be used as an ** output variable when querying the system for the current mutex ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. ** ** The xMutexInit method defined by this structure is invoked as ** part of system initialization by the sqlite3_initialize() function. ** {H17001} The xMutexInit routine shall be called by SQLite once for each ** effective call to [sqlite3_initialize()]. ** ** The xMutexEnd method defined by this structure is invoked as ** part of system shutdown by the sqlite3_shutdown() function. The ** implementation of this method is expected to release all outstanding ** resources obtained by the mutex methods implementation, especially ** those obtained by the xMutexInit method. {H17003} The xMutexEnd() ** interface shall be invoked once for each call to [sqlite3_shutdown()]. ** ** The remaining seven methods defined by this structure (xMutexAlloc, ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and ** xMutexNotheld) implement the following interfaces (respectively): ** ** <ul> |
︙ | ︙ | |||
6364 6365 6366 6367 6368 6369 6370 | int (*xMutexTry)(sqlite3_mutex *); void (*xMutexLeave)(sqlite3_mutex *); int (*xMutexHeld)(sqlite3_mutex *); int (*xMutexNotheld)(sqlite3_mutex *); }; /* | | | | | | | | | > > > > | | | | | | | | | | | > | 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 | int (*xMutexTry)(sqlite3_mutex *); void (*xMutexLeave)(sqlite3_mutex *); int (*xMutexHeld)(sqlite3_mutex *); int (*xMutexNotheld)(sqlite3_mutex *); }; /* ** CAPI3REF: Mutex Verification Routines {H17080} <S20130> <S30800> ** ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines ** are intended for use inside assert() statements. {H17081} The SQLite core ** never uses these routines except inside an assert() and applications ** are advised to follow the lead of the core. {H17082} The core only ** provides implementations for these routines when it is compiled ** with the SQLITE_DEBUG flag. {A17087} External mutex implementations ** are only required to provide these routines if SQLITE_DEBUG is ** defined and if NDEBUG is not defined. ** ** {H17083} These routines should return true if the mutex in their argument ** is held or not held, respectively, by the calling thread. ** ** {X17084} The implementation is not required to provided versions of these ** routines that actually work. If the implementation does not provide working ** versions of these routines, it should at least provide stubs that always ** return true so that one does not get spurious assertion failures. ** ** {H17085} If the argument to sqlite3_mutex_held() is a NULL pointer then ** the routine should return 1. {END} This seems counter-intuitive since ** clearly the mutex cannot be held if it does not exist. But the ** the reason the mutex does not exist is because the build is not ** using mutexes. And we do not want the assert() containing the ** call to sqlite3_mutex_held() to fail, so a non-zero return is ** the appropriate thing to do. {H17086} The sqlite3_mutex_notheld() ** interface should also return 1 when given a NULL pointer. */ SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*); SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*); /* ** CAPI3REF: Mutex Types {H17001} <H17000> ** ** The [sqlite3_mutex_alloc()] interface takes a single argument ** which is one of these integer constants. ** ** The set of static mutexes may change from one SQLite release to the ** next. Applications that override the built-in mutex logic must be ** prepared to accommodate additional static mutexes. */ #define SQLITE_MUTEX_FAST 0 #define SQLITE_MUTEX_RECURSIVE 1 #define SQLITE_MUTEX_STATIC_MASTER 2 #define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ #define SQLITE_MUTEX_STATIC_MEM2 4 /* sqlite3_release_memory() */ #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ #define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */ /* ** CAPI3REF: Low-Level Control Of Database Files {H11300} <S30800> ** ** {H11301} The [sqlite3_file_control()] interface makes a direct call to the ** xFileControl method for the [sqlite3_io_methods] object associated ** with a particular database identified by the second argument. {H11302} The ** name of the database is the name assigned to the database by the ** <a href="lang_attach.html">ATTACH</a> SQL command that opened the ** database. {H11303} To control the main database file, use the name "main" ** or a NULL pointer. {H11304} The third and fourth parameters to this routine ** are passed directly through to the second and third parameters of ** the xFileControl method. {H11305} The return value of the xFileControl ** method becomes the return value of this routine. ** ** {H11306} If the second parameter (zDbName) does not match the name of any ** open database file, then SQLITE_ERROR is returned. {H11307} This error ** code is not remembered and will not be recalled by [sqlite3_errcode()] ** or [sqlite3_errmsg()]. {A11308} The underlying xFileControl method might ** also return SQLITE_ERROR. {A11309} There is no way to distinguish between ** an incorrect zDbName and an SQLITE_ERROR return from the underlying ** xFileControl method. {END} ** ** See also: [SQLITE_FCNTL_LOCKSTATE] */ SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*); /* ** CAPI3REF: Testing Interface {H11400} <S30800> ** ** The sqlite3_test_control() interface is used to read out internal ** state of SQLite and to inject faults into SQLite for testing ** purposes. The first parameter is an operation code that determines ** the number, meaning, and operation of all subsequent parameters. ** ** This interface is not for use by applications. It exists solely ** for verifying the correct operation of the SQLite library. Depending ** on how the SQLite library is compiled, this interface might not exist. ** ** The details of the operation codes, their meanings, the parameters ** they take, and what they do are all subject to change without notice. ** Unlike most of the SQLite API, this function is not guaranteed to ** operate consistently from one release to the next. */ SQLITE_API int sqlite3_test_control(int op, ...); /* ** CAPI3REF: Testing Interface Operation Codes {H11410} <H11400> ** ** These constants are the valid operation code parameters used ** as the first argument to [sqlite3_test_control()]. ** ** These parameters and their meanings are subject to change ** without notice. These values are for testing purposes only. ** Applications should not use any of these parameters or the ** [sqlite3_test_control()] interface. */ #define SQLITE_TESTCTRL_PRNG_SAVE 5 #define SQLITE_TESTCTRL_PRNG_RESTORE 6 #define SQLITE_TESTCTRL_PRNG_RESET 7 #define SQLITE_TESTCTRL_BITVEC_TEST 8 #define SQLITE_TESTCTRL_FAULT_INSTALL 9 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 /* ** CAPI3REF: SQLite Runtime Status {H17200} <S60200> ** EXPERIMENTAL ** ** This interface is used to retrieve runtime status information ** about the preformance of SQLite, and optionally to reset various ** highwater marks. The first argument is an integer code for ** the specific parameter to measure. Recognized integer codes ** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...]. ** The current value of the parameter is returned into *pCurrent. |
︙ | ︙ | |||
6500 6501 6502 6503 6504 6505 6506 | ** This routine is threadsafe but is not atomic. This routine can ** called while other threads are running the same or different SQLite ** interfaces. However the values returned in *pCurrent and ** *pHighwater reflect the status of SQLite at different points in time ** and it is possible that another thread might change the parameter ** in between the times when *pCurrent and *pHighwater are written. ** | | < > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > | | > > > > > > > > > > | | | > > > > > | | < | | > > > > > > > > > > > > > > > > > > > > | 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 | ** This routine is threadsafe but is not atomic. This routine can ** called while other threads are running the same or different SQLite ** interfaces. However the values returned in *pCurrent and ** *pHighwater reflect the status of SQLite at different points in time ** and it is possible that another thread might change the parameter ** in between the times when *pCurrent and *pHighwater are written. ** ** See also: [sqlite3_db_status()] */ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); /* ** CAPI3REF: Database Connection Status {H17201} <S60200> ** EXPERIMENTAL ** ** This interface is used to retrieve runtime status information ** about a single [database connection]. The first argument is the ** database connection object to be interrogated. The second argument ** is the parameter to interrogate. Currently, the only allowed value ** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED]. ** Additional options will likely appear in future releases of SQLite. ** ** The current value of the request parameter is written into *pCur ** and the highest instantaneous value is written into *pHiwtr. If ** the resetFlg is true, then the highest instantaneous value is ** reset back down to the current value. ** ** See also: [sqlite3_status()]. */ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); /* ** CAPI3REF: Status Parameters {H17250} <H17200> ** EXPERIMENTAL ** ** These integer constants designate various run-time status parameters ** that can be returned by [sqlite3_status()]. ** ** <dl> ** <dt>SQLITE_STATUS_MEMORY_USED</dt> ** <dd>This parameter is the current amount of memory checked out ** using [sqlite3_malloc()], either directly or indirectly. The ** figure includes calls made to [sqlite3_malloc()] by the application ** and internal memory usage by the SQLite library. Scratch memory ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in ** this parameter. The amount returned is the sum of the allocation ** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd> ** ** <dt>SQLITE_STATUS_MALLOC_SIZE</dt> ** <dd>This parameter records the largest memory allocation request ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their ** internal equivalents). Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.</dd> ** ** <dt>SQLITE_STATUS_PAGECACHE_USED</dt> ** <dd>This parameter returns the number of pages used out of the ** [pagecache memory allocator] that was configured using ** [SQLITE_CONFIG_PAGECACHE]. The ** value returned is in pages, not in bytes.</dd> ** ** <dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt> ** <dd>This parameter returns the number of bytes of page cache ** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE] ** buffer and where forced to overflow to [sqlite3_malloc()]. The ** returned value includes allocations that overflowed because they ** where too large (they were larger than the "sz" parameter to ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because ** no space was left in the page cache.</dd> ** ** <dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> ** <dd>This parameter records the largest memory allocation request ** handed to [pagecache memory allocator]. Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.</dd> ** ** <dt>SQLITE_STATUS_SCRATCH_USED</dt> ** <dd>This parameter returns the number of allocations used out of the ** [scratch memory allocator] configured using ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not ** in bytes. Since a single thread may only have one scratch allocation ** outstanding at time, this parameter also reports the number of threads ** using scratch memory at the same time.</dd> ** ** <dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt> ** <dd>This parameter returns the number of bytes of scratch memory ** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH] ** buffer and where forced to overflow to [sqlite3_malloc()]. The values ** returned include overflows because the requested allocation was too ** larger (that is, because the requested allocation was larger than the ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer ** slots were available. ** </dd> ** ** <dt>SQLITE_STATUS_SCRATCH_SIZE</dt> ** <dd>This parameter records the largest memory allocation request ** handed to [scratch memory allocator]. Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.</dd> ** ** <dt>SQLITE_STATUS_PARSER_STACK</dt> ** <dd>This parameter records the deepest parser stack. It is only ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd> ** </dl> ** ** New status parameters may be added from time to time. */ #define SQLITE_STATUS_MEMORY_USED 0 #define SQLITE_STATUS_PAGECACHE_USED 1 #define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 #define SQLITE_STATUS_SCRATCH_USED 3 #define SQLITE_STATUS_SCRATCH_OVERFLOW 4 #define SQLITE_STATUS_MALLOC_SIZE 5 #define SQLITE_STATUS_PARSER_STACK 6 #define SQLITE_STATUS_PAGECACHE_SIZE 7 #define SQLITE_STATUS_SCRATCH_SIZE 8 /* ** CAPI3REF: Status Parameters for database connections {H17275} <H17200> ** EXPERIMENTAL ** ** Status verbs for [sqlite3_db_status()]. ** ** <dl> ** <dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> ** <dd>This parameter returns the number of lookaside memory slots currently ** checked out.</dd> ** </dl> */ #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 /* ** Undo the hack that converts floating point types to integer for ** builds on processors without floating point support. */ #ifdef SQLITE_OMIT_FLOATING_POINT # undef double |
︙ | ︙ | |||
6594 6595 6596 6597 6598 6599 6600 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the header file for the generic hash-table implemenation ** used in SQLite. ** | | | 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the header file for the generic hash-table implemenation ** used in SQLite. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _SQLITE_HASH_H_ #define _SQLITE_HASH_H_ /* Forward declarations of structures. */ typedef struct Hash Hash; typedef struct HashElem HashElem; |
︙ | ︙ | |||
7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 | /* ** A convenience macro that returns the number of elements in ** an array. */ #define ArraySize(X) (sizeof(X)/sizeof(X[0])) /* ** Forward references to structures */ typedef struct AggInfo AggInfo; typedef struct AuthContext AuthContext; typedef struct Bitvec Bitvec; typedef struct CollSeq CollSeq; typedef struct Column Column; typedef struct Db Db; typedef struct Schema Schema; typedef struct Expr Expr; typedef struct ExprList ExprList; typedef struct FKey FKey; typedef struct FuncDef FuncDef; typedef struct IdList IdList; typedef struct Index Index; typedef struct KeyClass KeyClass; typedef struct KeyInfo KeyInfo; typedef struct Module Module; typedef struct NameContext NameContext; typedef struct Parse Parse; typedef struct Select Select; typedef struct SrcList SrcList; typedef struct StrAccum StrAccum; typedef struct Table Table; | > > > > > > > > | 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 | /* ** A convenience macro that returns the number of elements in ** an array. */ #define ArraySize(X) (sizeof(X)/sizeof(X[0])) /* ** The following value as a destructor means to use sqlite3DbFree(). ** This is an internal extension to SQLITE_STATIC and SQLITE_TRANSIENT. */ #define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3DbFree) /* ** Forward references to structures */ typedef struct AggInfo AggInfo; typedef struct AuthContext AuthContext; typedef struct Bitvec Bitvec; typedef struct CollSeq CollSeq; typedef struct Column Column; typedef struct Db Db; typedef struct Schema Schema; typedef struct Expr Expr; typedef struct ExprList ExprList; typedef struct FKey FKey; typedef struct FuncDef FuncDef; typedef struct IdList IdList; typedef struct Index Index; typedef struct KeyClass KeyClass; typedef struct KeyInfo KeyInfo; typedef struct Lookaside Lookaside; typedef struct LookasideSlot LookasideSlot; typedef struct Module Module; typedef struct NameContext NameContext; typedef struct Parse Parse; typedef struct Select Select; typedef struct SrcList SrcList; typedef struct StrAccum StrAccum; typedef struct Table Table; |
︙ | ︙ | |||
7111 7112 7113 7114 7115 7116 7117 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the sqlite B-Tree file ** subsystem. See comments in the source code for a detailed description ** of what each interface routine does. ** | | | 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the sqlite B-Tree file ** subsystem. See comments in the source code for a detailed description ** of what each interface routine does. ** ** @(#) $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _BTREE_H_ #define _BTREE_H_ /* TODO: This definition is just included so other modules compile. It ** needs to be revisited. */ |
︙ | ︙ | |||
7337 7338 7339 7340 7341 7342 7343 | ************************************************************************* ** Header file for the Virtual DataBase Engine (VDBE) ** ** This header defines the interface to the virtual database engine ** or VDBE. The VDBE implements an abstract machine that runs a ** simple program to access and modify the underlying database. ** | | | 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 | ************************************************************************* ** Header file for the Virtual DataBase Engine (VDBE) ** ** This header defines the interface to the virtual database engine ** or VDBE. The VDBE implements an abstract machine that runs a ** simple program to access and modify the underlying database. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _SQLITE_VDBE_H_ #define _SQLITE_VDBE_H_ /* ** A single VDBE is an opaque structure named "Vdbe". Only routines ** in the source file sqliteVdbe.c are allowed to see the insides |
︙ | ︙ | |||
7679 7680 7681 7682 7683 7684 7685 | SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int); SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*); #ifdef SQLITE_DEBUG SQLITE_PRIVATE void sqlite3VdbeTrace(Vdbe*,FILE*); #endif SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*); | | | 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 | SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int); SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*); #ifdef SQLITE_DEBUG SQLITE_PRIVATE void sqlite3VdbeTrace(Vdbe*,FILE*); #endif SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*); SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int); SQLITE_PRIVATE int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, int); SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*); SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n); SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*); |
︙ | ︙ | |||
7726 7727 7728 7729 7730 7731 7732 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the sqlite page cache ** subsystem. The page cache subsystem reads and writes a file a page ** at a time and provides a journal for rollback. ** | | | 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the sqlite page cache ** subsystem. The page cache subsystem reads and writes a file a page ** at a time and provides a journal for rollback. ** ** @(#) $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _PAGER_H_ #define _PAGER_H_ /* ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise |
︙ | ︙ | |||
7818 7819 7820 7821 7822 7823 7824 | SQLITE_PRIVATE void sqlite3PagerSetSafetyLevel(Pager*,int,int); SQLITE_PRIVATE const char *sqlite3PagerFilename(Pager*); SQLITE_PRIVATE const sqlite3_vfs *sqlite3PagerVfs(Pager*); SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*); SQLITE_PRIVATE const char *sqlite3PagerDirname(Pager*); SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*); SQLITE_PRIVATE int sqlite3PagerNosync(Pager*); | | | 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 | SQLITE_PRIVATE void sqlite3PagerSetSafetyLevel(Pager*,int,int); SQLITE_PRIVATE const char *sqlite3PagerFilename(Pager*); SQLITE_PRIVATE const sqlite3_vfs *sqlite3PagerVfs(Pager*); SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*); SQLITE_PRIVATE const char *sqlite3PagerDirname(Pager*); SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*); SQLITE_PRIVATE int sqlite3PagerNosync(Pager*); SQLITE_PRIVATE int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int); SQLITE_PRIVATE void *sqlite3PagerGetData(DbPage *); SQLITE_PRIVATE void *sqlite3PagerGetExtra(DbPage *); SQLITE_PRIVATE int sqlite3PagerLockingMode(Pager *, int); SQLITE_PRIVATE int sqlite3PagerJournalMode(Pager *, int); SQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *, i64); SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); SQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager); |
︙ | ︙ | |||
7880 7881 7882 7883 7884 7885 7886 | ** This header file (together with is companion C source-code file ** "os.c") attempt to abstract the underlying operating system so that ** the SQLite library will work on both POSIX and windows systems. ** ** This header file is #include-ed by sqliteInt.h and thus ends up ** being included by every source file. ** | | | 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 | ** This header file (together with is companion C source-code file ** "os.c") attempt to abstract the underlying operating system so that ** the SQLite library will work on both POSIX and windows systems. ** ** This header file is #include-ed by sqliteInt.h and thus ends up ** being included by every source file. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _SQLITE_OS_H_ #define _SQLITE_OS_H_ /* ** Figure out if we are dealing with Unix, Windows, or some other ** operating system. After the following block of preprocess macros, |
︙ | ︙ | |||
8162 8163 8164 8165 8166 8167 8168 | ** to all source files. We break it out in an effort to keep the code ** better organized. ** ** NOTE: source files should *not* #include this header file directly. ** Source files should #include the sqliteInt.h file and let that file ** include this one indirectly. ** | | | 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 | ** to all source files. We break it out in an effort to keep the code ** better organized. ** ** NOTE: source files should *not* #include this header file directly. ** Source files should #include the sqliteInt.h file and let that file ** include this one indirectly. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifdef SQLITE_MUTEX_APPDEF /* ** If SQLITE_MUTEX_APPDEF is defined, then this whole module is ** omitted and equivalent functionality must be provided by the |
︙ | ︙ | |||
8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 | /* ** The number of different kinds of things that can be limited ** using the sqlite3_limit() interface. */ #define SQLITE_N_LIMIT (SQLITE_LIMIT_VARIABLE_NUMBER+1) /* ** Each database is an instance of the following structure. ** ** The sqlite.lastRowid records the last insert rowid generated by an ** insert statement. Inserts on views do not affect its value. Each ** trigger has its own context, so that lastRowid can be updated inside ** triggers as usual. The previous value will be restored once the trigger | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 | /* ** The number of different kinds of things that can be limited ** using the sqlite3_limit() interface. */ #define SQLITE_N_LIMIT (SQLITE_LIMIT_VARIABLE_NUMBER+1) /* ** Lookaside malloc is a set of fixed-size buffers that can be used ** to satisify small transient memory allocation requests for objects ** associated with a particular database connection. The use of ** lookaside malloc provides a significant performance enhancement ** (approx 10%) by avoiding numerous malloc/free requests while parsing ** SQL statements. ** ** The Lookaside structure holds configuration information about the ** lookaside malloc subsystem. Each available memory allocation in ** the lookaside subsystem is stored on a linked list of LookasideSlot ** objects. */ struct Lookaside { u16 sz; /* Size of each buffer in bytes */ u8 bEnabled; /* True if use lookaside. False to ignore it */ u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */ int nOut; /* Number of buffers currently checked out */ int mxOut; /* Highwater mark for nOut */ LookasideSlot *pFree; /* List if available buffers */ void *pStart; /* First byte of available memory space */ void *pEnd; /* First byte past end of available space */ }; struct LookasideSlot { LookasideSlot *pNext; /* Next buffer in the list of free buffers */ }; /* ** Each database is an instance of the following structure. ** ** The sqlite.lastRowid records the last insert rowid generated by an ** insert statement. Inserts on views do not affect its value. Each ** trigger has its own context, so that lastRowid can be updated inside ** triggers as usual. The previous value will be restored once the trigger |
︙ | ︙ | |||
8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 | sqlite3_value *pErr; /* Most recent error message */ char *zErrMsg; /* Most recent error message (UTF-8 encoded) */ char *zErrMsg16; /* Most recent error message (UTF-16 encoded) */ union { int isInterrupted; /* True if sqlite3_interrupt has been called */ double notUsed1; /* Spacer */ } u1; #ifndef SQLITE_OMIT_AUTHORIZATION int (*xAuth)(void*,int,const char*,const char*,const char*,const char*); /* Access authorization function */ void *pAuthArg; /* 1st argument to the access auth function */ #endif #ifndef SQLITE_OMIT_PROGRESS_CALLBACK int (*xProgress)(void *); /* The progress callback */ | > | 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 | sqlite3_value *pErr; /* Most recent error message */ char *zErrMsg; /* Most recent error message (UTF-8 encoded) */ char *zErrMsg16; /* Most recent error message (UTF-16 encoded) */ union { int isInterrupted; /* True if sqlite3_interrupt has been called */ double notUsed1; /* Spacer */ } u1; Lookaside lookaside; /* Lookaside malloc configuration */ #ifndef SQLITE_OMIT_AUTHORIZATION int (*xAuth)(void*,int,const char*,const char*,const char*,const char*); /* Access authorization function */ void *pAuthArg; /* 1st argument to the access auth function */ #endif #ifndef SQLITE_OMIT_PROGRESS_CALLBACK int (*xProgress)(void *); /* The progress callback */ |
︙ | ︙ | |||
8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 | ** when the VDBE cursor to the table is closed. In this case Table.tnum ** refers VDBE cursor number that holds the table open, not to the root ** page number. Transient tables are used to hold the results of a ** sub-query that appears instead of a real table name in the FROM clause ** of a SELECT statement. */ struct Table { char *zName; /* Name of the table */ int nCol; /* Number of columns in this table */ Column *aCol; /* Information about each column */ int iPKey; /* If not less then 0, use aCol[iPKey] as the primary key */ Index *pIndex; /* List of SQL indexes on this table. */ int tnum; /* Root BTree node for this table (see note above) */ Select *pSelect; /* NULL for tables. Points to definition if a view. */ | > | 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 | ** when the VDBE cursor to the table is closed. In this case Table.tnum ** refers VDBE cursor number that holds the table open, not to the root ** page number. Transient tables are used to hold the results of a ** sub-query that appears instead of a real table name in the FROM clause ** of a SELECT statement. */ struct Table { sqlite3 *db; /* Associated database connection. Might be NULL. */ char *zName; /* Name of the table */ int nCol; /* Number of columns in this table */ Column *aCol; /* Information about each column */ int iPKey; /* If not less then 0, use aCol[iPKey] as the primary key */ Index *pIndex; /* List of SQL indexes on this table. */ int tnum; /* Root BTree node for this table (see note above) */ Select *pSelect; /* NULL for tables. Points to definition if a view. */ |
︙ | ︙ | |||
9499 9500 9501 9502 9503 9504 9505 | }; /* ** An objected used to accumulate the text of a string where we ** do not necessarily know how big the string will be in the end. */ struct StrAccum { | > | | | | | 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 | }; /* ** An objected used to accumulate the text of a string where we ** do not necessarily know how big the string will be in the end. */ struct StrAccum { sqlite3 *db; /* Optional database for lookaside. Can be NULL */ char *zBase; /* A base allocation. Not from malloc. */ char *zText; /* The string collected so far */ int nChar; /* Length of the string so far */ int nAlloc; /* Amount of space allocated in zText */ int mxAlloc; /* Maximum allowed string length */ u8 mallocFailed; /* Becomes true if any memory allocation fails */ u8 useMalloc; /* True if zText is enlargable using realloc */ u8 tooBig; /* Becomes true if string size exceeds limits */ }; /* |
︙ | ︙ | |||
9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 | ** This structure also contains some state information. */ struct Sqlite3Config { int bMemstat; /* True to enable memory status */ int bCoreMutex; /* True to enable core mutexing */ int bFullMutex; /* True to enable full mutexing */ int mxStrlen; /* Maximum string length */ sqlite3_mem_methods m; /* Low-level memory allocation interface */ sqlite3_mutex_methods mutex; /* Low-level mutex interface */ void *pHeap; /* Heap storage space */ int nHeap; /* Size of pHeap[] */ int mnReq, mxReq; /* Min and max heap requests sizes */ void *pScratch; /* Scratch memory */ int szScratch; /* Size of each scratch buffer */ int nScratch; /* Number of scratch buffers */ void *pPage; /* Page cache memory */ int szPage; /* Size of each page in pPage[] */ int nPage; /* Number of pages in pPage[] */ int isInit; /* True after initialization has finished */ int isMallocInit; /* True after malloc is initialized */ sqlite3_mutex *pInitMutex; /* Mutex used by sqlite3_initialize() */ }; /* ** Assuming zIn points to the first byte of a UTF-8 character, ** advance zIn to point to the first byte of the next UTF-8 character. */ #define SQLITE_SKIP_UTF8(zIn) { \ | > > > > | 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 | ** This structure also contains some state information. */ struct Sqlite3Config { int bMemstat; /* True to enable memory status */ int bCoreMutex; /* True to enable core mutexing */ int bFullMutex; /* True to enable full mutexing */ int mxStrlen; /* Maximum string length */ int szLookaside; /* Default lookaside buffer size */ int nLookaside; /* Default lookaside buffer count */ sqlite3_mem_methods m; /* Low-level memory allocation interface */ sqlite3_mutex_methods mutex; /* Low-level mutex interface */ void *pHeap; /* Heap storage space */ int nHeap; /* Size of pHeap[] */ int mnReq, mxReq; /* Min and max heap requests sizes */ void *pScratch; /* Scratch memory */ int szScratch; /* Size of each scratch buffer */ int nScratch; /* Number of scratch buffers */ void *pPage; /* Page cache memory */ int szPage; /* Size of each page in pPage[] */ int nPage; /* Number of pages in pPage[] */ int isInit; /* True after initialization has finished */ int isMallocInit; /* True after malloc is initialized */ sqlite3_mutex *pInitMutex; /* Mutex used by sqlite3_initialize() */ int nSmall; /* alloc size threshold used by mem6.c */ int mxParserStack; /* maximum depth of the parser stack */ }; /* ** Assuming zIn points to the first byte of a UTF-8 character, ** advance zIn to point to the first byte of the next UTF-8 character. */ #define SQLITE_SKIP_UTF8(zIn) { \ |
︙ | ︙ | |||
9583 9584 9585 9586 9587 9588 9589 | SQLITE_PRIVATE int sqlite3MallocInit(void); SQLITE_PRIVATE void sqlite3MallocEnd(void); SQLITE_PRIVATE void *sqlite3Malloc(int); SQLITE_PRIVATE void *sqlite3MallocZero(int); SQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3*, int); SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3*, int); | < < > | > > > > | 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 | SQLITE_PRIVATE int sqlite3MallocInit(void); SQLITE_PRIVATE void sqlite3MallocEnd(void); SQLITE_PRIVATE void *sqlite3Malloc(int); SQLITE_PRIVATE void *sqlite3MallocZero(int); SQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3*, int); SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3*, int); SQLITE_PRIVATE char *sqlite3DbStrDup(sqlite3*,const char*); SQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3*,const char*, int); SQLITE_PRIVATE void *sqlite3Realloc(void*, int); SQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *, void *, int); SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *, void *, int); SQLITE_PRIVATE void sqlite3DbFree(sqlite3*, void*); SQLITE_PRIVATE int sqlite3MallocSize(void*); SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3*, void*); SQLITE_PRIVATE void *sqlite3ScratchMalloc(int); SQLITE_PRIVATE void sqlite3ScratchFree(void*); SQLITE_PRIVATE void *sqlite3PageMalloc(int); SQLITE_PRIVATE void sqlite3PageFree(void*); SQLITE_PRIVATE void sqlite3MemSetDefault(void); SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetDefault(void); SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys5(void); SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys3(void); SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys6(void); SQLITE_PRIVATE void sqlite3BenignMallocHooks(void (*)(void), void (*)(void)); #ifndef SQLITE_MUTEX_NOOP SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void); SQLITE_PRIVATE sqlite3_mutex *sqlite3MutexAlloc(int); SQLITE_PRIVATE int sqlite3MutexInit(void); SQLITE_PRIVATE int sqlite3MutexEnd(void); #endif SQLITE_PRIVATE void sqlite3StatusReset(void); SQLITE_PRIVATE int sqlite3StatusValue(int); SQLITE_PRIVATE void sqlite3StatusAdd(int, int); SQLITE_PRIVATE void sqlite3StatusSet(int, int); SQLITE_PRIVATE int sqlite3IsNaN(double); SQLITE_PRIVATE void sqlite3VXPrintf(StrAccum*, int, const char*, va_list); SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...); SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list); SQLITE_PRIVATE char *sqlite3MAppendf(sqlite3*,char*,const char*,...); #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) SQLITE_PRIVATE void sqlite3DebugPrintf(const char*, ...); #endif #if defined(SQLITE_TEST) SQLITE_PRIVATE void *sqlite3TestTextToPtr(const char*); #endif SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*, ...); |
︙ | ︙ | |||
9642 9643 9644 9645 9646 9647 9648 | SQLITE_PRIVATE Expr *sqlite3Expr(sqlite3*, int, Expr*, Expr*, const Token*); SQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token*); SQLITE_PRIVATE Expr *sqlite3RegisterExpr(Parse*,Token*); SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*); SQLITE_PRIVATE void sqlite3ExprSpan(Expr*,Token*,Token*); SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*); SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*); | | | | 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 | SQLITE_PRIVATE Expr *sqlite3Expr(sqlite3*, int, Expr*, Expr*, const Token*); SQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token*); SQLITE_PRIVATE Expr *sqlite3RegisterExpr(Parse*,Token*); SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*); SQLITE_PRIVATE void sqlite3ExprSpan(Expr*,Token*,Token*); SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*); SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*); SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*,Token*); SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*); SQLITE_PRIVATE int sqlite3Init(sqlite3*, char**); SQLITE_PRIVATE int sqlite3InitCallback(void*, int, char**, char**); SQLITE_PRIVATE void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); SQLITE_PRIVATE void sqlite3ResetInternalSchema(sqlite3*, int); SQLITE_PRIVATE void sqlite3BeginParse(Parse*,int); SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*); SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,char*,Select*); |
︙ | ︙ | |||
9689 9690 9691 9692 9693 9694 9695 | SQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*); SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*); SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*); SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*, Token*, Select*, Expr*, IdList*); SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*); SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*); | | | | | 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 | SQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*); SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*); SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*); SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*, Token*, Select*, Expr*, IdList*); SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*); SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*); SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*); SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*); SQLITE_PRIVATE void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, Token*, int, int); SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int); SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*, Select*, int, int*); SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, Expr*,ExprList*,int,Expr*,Expr*); SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*); SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*); SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int); SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*); SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, u8); SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*); |
︙ | ︙ | |||
9786 9787 9788 9789 9790 9791 9792 | SQLITE_PRIVATE void sqlite3FinishTrigger(Parse*, TriggerStep*, Token*); SQLITE_PRIVATE void sqlite3DropTrigger(Parse*, SrcList*, int); SQLITE_PRIVATE void sqlite3DropTriggerPtr(Parse*, Trigger*); SQLITE_PRIVATE int sqlite3TriggersExist(Parse*, Table*, int, ExprList*); SQLITE_PRIVATE int sqlite3CodeRowTrigger(Parse*, int, ExprList*, int, Table *, int, int, int, int, u32*, u32*); void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*); | | | | | 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 | SQLITE_PRIVATE void sqlite3FinishTrigger(Parse*, TriggerStep*, Token*); SQLITE_PRIVATE void sqlite3DropTrigger(Parse*, SrcList*, int); SQLITE_PRIVATE void sqlite3DropTriggerPtr(Parse*, Trigger*); SQLITE_PRIVATE int sqlite3TriggersExist(Parse*, Table*, int, ExprList*); SQLITE_PRIVATE int sqlite3CodeRowTrigger(Parse*, int, ExprList*, int, Table *, int, int, int, int, u32*, u32*); void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*); SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*); SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*); SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*, ExprList*,Select*,int); SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, int); SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*); SQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3*, Trigger*); SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*); #else # define sqlite3TriggersExist(A,B,C,D,E,F) 0 # define sqlite3DeleteTrigger(A,B) # define sqlite3DropTriggerPtr(A,B) # define sqlite3UnlinkAndDeleteTrigger(A,B,C) # define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I,J,K) 0 #endif SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*); SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); |
︙ | ︙ | |||
9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 | /* ** The interface to the LEMON-generated parser */ SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(size_t)); SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*)); SQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*); SQLITE_PRIVATE int sqlite3AutoLoadExtensions(sqlite3*); #ifndef SQLITE_OMIT_LOAD_EXTENSION SQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3*); #else # define sqlite3CloseExtensions(X) #endif #ifndef SQLITE_OMIT_SHARED_CACHE SQLITE_PRIVATE void sqlite3TableLock(Parse *, int, int, u8, const char *); #else #define sqlite3TableLock(v,w,x,y,z) #endif #ifdef SQLITE_TEST SQLITE_PRIVATE int sqlite3Utf8To8(unsigned char*); #endif #ifdef SQLITE_OMIT_VIRTUALTABLE # define sqlite3VtabClear(X) | > > > | | | 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 | /* ** The interface to the LEMON-generated parser */ SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(size_t)); SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*)); SQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*); #ifdef YYTRACKMAXSTACKDEPTH SQLITE_PRIVATE int sqlite3ParserStackPeak(void*); #endif SQLITE_PRIVATE int sqlite3AutoLoadExtensions(sqlite3*); #ifndef SQLITE_OMIT_LOAD_EXTENSION SQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3*); #else # define sqlite3CloseExtensions(X) #endif #ifndef SQLITE_OMIT_SHARED_CACHE SQLITE_PRIVATE void sqlite3TableLock(Parse *, int, int, u8, const char *); #else #define sqlite3TableLock(v,w,x,y,z) #endif #ifdef SQLITE_TEST SQLITE_PRIVATE int sqlite3Utf8To8(unsigned char*); #endif #ifdef SQLITE_OMIT_VIRTUALTABLE # define sqlite3VtabClear(X) # define sqlite3VtabSync(X,Y) SQLITE_OK # define sqlite3VtabRollback(X) # define sqlite3VtabCommit(X) #else SQLITE_PRIVATE void sqlite3VtabClear(Table*); SQLITE_PRIVATE int sqlite3VtabSync(sqlite3 *db, char **); SQLITE_PRIVATE int sqlite3VtabRollback(sqlite3 *db); SQLITE_PRIVATE int sqlite3VtabCommit(sqlite3 *db); #endif SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*); SQLITE_PRIVATE void sqlite3VtabLock(sqlite3_vtab*); SQLITE_PRIVATE void sqlite3VtabUnlock(sqlite3*, sqlite3_vtab*); SQLITE_PRIVATE void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*); |
︙ | ︙ | |||
10077 10078 10079 10080 10081 10082 10083 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains definitions of global variables and contants. ** | | | 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains definitions of global variables and contants. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* An array to map all upper-case characters into their corresponding ** lower-case character. ** ** SQLite only considers US-ASCII (or EBCDIC) characters. We do not |
︙ | ︙ | |||
10130 10131 10132 10133 10134 10135 10136 | #endif }; /* ** The following singleton contains the global configuration for ** the SQLite library. */ | | > > > > > > > > | | | | 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 | #endif }; /* ** The following singleton contains the global configuration for ** the SQLite library. */ SQLITE_PRIVATE struct Sqlite3Config sqlite3Config = { 1, /* bMemstat */ 1, /* bCoreMutex */ 1, /* bFullMutex */ 0x7ffffffe, /* mxStrlen */ 100, /* szLookaside */ 500, /* nLookaside */ /* Other fields all default to zero */ }; /************** End of global.c **********************************************/ /************** Begin file status.c ******************************************/ /* ** 2008 June 18 ** ** 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 module implements the sqlite3_status() interface and related ** functionality. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** Variables in which to record status information. */ static struct { int nowValue[9]; /* Current value */ int mxValue[9]; /* Maximum value */ } sqlite3Stat; /* ** Reset the status records. This routine is called by ** sqlite3_initialize(). */ |
︙ | ︙ | |||
10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 | *pCurrent = sqlite3Stat.nowValue[op]; *pHighwater = sqlite3Stat.mxValue[op]; if( resetFlag ){ sqlite3Stat.mxValue[op] = sqlite3Stat.nowValue[op]; } return SQLITE_OK; } /************** End of status.c **********************************************/ /************** Begin file date.c ********************************************/ /* ** 2003 October 31 ** ** The author disclaims copyright to this source code. In place of | > > > > > > > > > > > > > > > > > > > > > > > > > > | 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 | *pCurrent = sqlite3Stat.nowValue[op]; *pHighwater = sqlite3Stat.mxValue[op]; if( resetFlag ){ sqlite3Stat.mxValue[op] = sqlite3Stat.nowValue[op]; } return SQLITE_OK; } /* ** Query status information for a single database connection */ SQLITE_API int sqlite3_db_status( sqlite3 *db, /* The database connection whose status is desired */ int op, /* Status verb */ int *pCurrent, /* Write current value here */ int *pHighwater, /* Write high-water mark here */ int resetFlag /* Reset high-water mark if true */ ){ switch( op ){ case SQLITE_DBSTATUS_LOOKASIDE_USED: { *pCurrent = db->lookaside.nOut; *pHighwater = db->lookaside.mxOut; if( resetFlag ){ db->lookaside.mxOut = db->lookaside.nOut; } break; } default: { return SQLITE_ERROR; } } return SQLITE_OK; } /************** End of status.c **********************************************/ /************** Begin file date.c ********************************************/ /* ** 2003 October 31 ** ** The author disclaims copyright to this source code. In place of |
︙ | ︙ | |||
10239 10240 10241 10242 10243 10244 10245 | ** This file contains the C functions that implement date and time ** functions for SQLite. ** ** There is only one exported symbol in this file - the function ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** All other code has file scope. ** | | | 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 | ** This file contains the C functions that implement date and time ** functions for SQLite. ** ** There is only one exported symbol in this file - the function ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** All other code has file scope. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ ** ** SQLite processes all times and dates as Julian Day numbers. The ** dates and times are stored as the number of days since noon ** in Greenwich on November 24, 4714 B.C. according to the Gregorian ** calendar system. ** ** 1970-01-01 00:00:00 is JD 2440587.5 |
︙ | ︙ | |||
10773 10774 10775 10776 10777 10778 10779 | ** Treat the current value of p->iJD as the number of ** seconds since 1970. Convert to a real julian day number. */ if( strcmp(z, "unixepoch")==0 && p->validJD ){ p->iJD = p->iJD/86400.0 + 2440587.5*86400000.0; clearYMD_HMS_TZ(p); rc = 0; | > > | > | 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 | ** Treat the current value of p->iJD as the number of ** seconds since 1970. Convert to a real julian day number. */ if( strcmp(z, "unixepoch")==0 && p->validJD ){ p->iJD = p->iJD/86400.0 + 2440587.5*86400000.0; clearYMD_HMS_TZ(p); rc = 0; } #ifndef SQLITE_OMIT_LOCALTIME else if( strcmp(z, "utc")==0 ){ double c1; computeJD(p); c1 = localtimeOffset(p); p->iJD -= c1; clearYMD_HMS_TZ(p); p->iJD += c1 - localtimeOffset(p); rc = 0; } #endif break; } case 'w': { /* ** weekday N ** ** Move the date to the same time on the next occurrence of |
︙ | ︙ | |||
11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 | int argc, sqlite3_value **argv ){ DateTime x; u64 n; int i, j; char *z; const char *zFmt = (const char*)sqlite3_value_text(argv[0]); char zBuf[100]; if( zFmt==0 || isDate(context, argc-1, argv+1, &x) ) return; for(i=0, n=1; zFmt[i]; i++, n++){ if( zFmt[i]=='%' ){ switch( zFmt[i+1] ){ case 'd': case 'H': case 'm': case 'M': | > > | 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 | int argc, sqlite3_value **argv ){ DateTime x; u64 n; int i, j; char *z; sqlite3 *db; const char *zFmt = (const char*)sqlite3_value_text(argv[0]); char zBuf[100]; if( zFmt==0 || isDate(context, argc-1, argv+1, &x) ) return; db = sqlite3_context_db_handle(context); for(i=0, n=1; zFmt[i]; i++, n++){ if( zFmt[i]=='%' ){ switch( zFmt[i+1] ){ case 'd': case 'H': case 'm': case 'M': |
︙ | ︙ | |||
11104 11105 11106 11107 11108 11109 11110 | return; /* ERROR. return a NULL */ } i++; } } if( n<sizeof(zBuf) ){ z = zBuf; | | | | 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 | return; /* ERROR. return a NULL */ } i++; } } if( n<sizeof(zBuf) ){ z = zBuf; }else if( n>db->aLimit[SQLITE_LIMIT_LENGTH] ){ sqlite3_result_error_toobig(context); return; }else{ z = sqlite3DbMallocRaw(db, n); if( z==0 ){ sqlite3_result_error_nomem(context); return; } } computeJD(&x); computeYMD_HMS(&x); |
︙ | ︙ | |||
11173 11174 11175 11176 11177 11178 11179 | case 'Y': sqlite3_snprintf(5,&z[j],"%04d",x.Y); j+=strlen(&z[j]);break; default: z[j++] = '%'; break; } } } z[j] = 0; sqlite3_result_text(context, z, -1, | | | 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 | case 'Y': sqlite3_snprintf(5,&z[j],"%04d",x.Y); j+=strlen(&z[j]);break; default: z[j++] = '%'; break; } } } z[j] = 0; sqlite3_result_text(context, z, -1, z==zBuf ? SQLITE_TRANSIENT : SQLITE_DYNAMIC); } /* ** current_time() ** ** This function returns the same value as time('now'). */ |
︙ | ︙ | |||
11324 11325 11326 11327 11328 11329 11330 | ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains OS interface code that is common to all ** architectures. ** | | | 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 | ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains OS interface code that is common to all ** architectures. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #define _SQLITE_OS_C_ 1 #undef _SQLITE_OS_C_ /* ** The default SQLite sqlite3_vfs implementations do not allocate ** memory (actually, os_unix.c allocates a small amount of memory |
︙ | ︙ | |||
11346 11347 11348 11349 11350 11351 11352 | ** sqlite3OsOpen() ** sqlite3OsRead() ** sqlite3OsWrite() ** sqlite3OsSync() ** sqlite3OsLock() ** */ | | | 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 | ** sqlite3OsOpen() ** sqlite3OsRead() ** sqlite3OsWrite() ** sqlite3OsSync() ** sqlite3OsLock() ** */ #if defined(SQLITE_TEST) && (SQLITE_OS_WIN==0) && 0 #define DO_OS_MALLOC_TEST if (1) { \ void *pTstAlloc = sqlite3Malloc(10); \ if (!pTstAlloc) return SQLITE_IOERR_NOMEM; \ sqlite3_free(pTstAlloc); \ } #else #define DO_OS_MALLOC_TEST |
︙ | ︙ | |||
11600 11601 11602 11603 11604 11605 11606 | ** ** 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. ** ************************************************************************* ** | | | 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 | ** ** 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. ** ************************************************************************* ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** This file contains code to support the concept of "benign" ** malloc failures (when the xMalloc() or xRealloc() method of the ** sqlite3_mem_methods structure fails to allocate a block of memory ** and returns 0). |
︙ | ︙ | |||
11680 11681 11682 11683 11684 11685 11686 | ** This file contains low-level memory allocation drivers for when ** SQLite will use the standard C-library malloc/realloc/free interface ** to obtain the memory it needs. ** ** This file contains implementations of the low-level memory allocation ** routines specified in the sqlite3_mem_methods object. ** | | | 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 | ** This file contains low-level memory allocation drivers for when ** SQLite will use the standard C-library malloc/realloc/free interface ** to obtain the memory it needs. ** ** This file contains implementations of the low-level memory allocation ** routines specified in the sqlite3_mem_methods object. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** This version of the memory allocator is the default. It is ** used when no other memory allocator is specified using compile-time ** macros. */ |
︙ | ︙ | |||
11782 11783 11784 11785 11786 11787 11788 | /* ** Deinitialize this module. */ static void sqlite3MemShutdown(void *NotUsed){ return; } | < < < < < < | > > > > > > > > > > | | 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 | /* ** Deinitialize this module. */ static void sqlite3MemShutdown(void *NotUsed){ return; } SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetDefault(void){ static const sqlite3_mem_methods defaultMethods = { sqlite3MemMalloc, sqlite3MemFree, sqlite3MemRealloc, sqlite3MemSize, sqlite3MemRoundup, sqlite3MemInit, sqlite3MemShutdown, 0 }; return &defaultMethods; } /* ** This routine is the only routine in this file with external linkage. ** ** Populate the low-level memory allocation function pointers in ** sqlite3Config.m with pointers to the routines in this file. */ SQLITE_PRIVATE void sqlite3MemSetDefault(void){ sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetDefault()); } #endif /* SQLITE_SYSTEM_MALLOC */ /************** End of mem1.c ************************************************/ /************** Begin file mem2.c ********************************************/ /* |
︙ | ︙ | |||
11827 11828 11829 11830 11831 11832 11833 | ** to obtain the memory it needs while adding lots of additional debugging ** information to each allocation in order to help detect and fix memory ** leaks and memory usage errors. ** ** This file contains implementations of the low-level memory allocation ** routines specified in the sqlite3_mem_methods object. ** | | | 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 | ** to obtain the memory it needs while adding lots of additional debugging ** information to each allocation in order to help detect and fix memory ** leaks and memory usage errors. ** ** This file contains implementations of the low-level memory allocation ** routines specified in the sqlite3_mem_methods object. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** This version of the memory allocator is used only if the ** SQLITE_MEMDEBUG macro is defined */ #ifdef SQLITE_MEMDEBUG |
︙ | ︙ | |||
11919 11920 11921 11922 11923 11924 11925 | ** sqlite3MallocDisallow() increments the following counter. ** sqlite3MallocAllow() decrements it. */ int disallow; /* Do not allow memory allocation */ /* ** Gather statistics on the sizes of memory allocations. | | | > > > > > > > > > > > > > > > > > > > > > > > | 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 | ** sqlite3MallocDisallow() increments the following counter. ** sqlite3MallocAllow() decrements it. */ int disallow; /* Do not allow memory allocation */ /* ** Gather statistics on the sizes of memory allocations. ** nAlloc[i] is the number of allocation attempts of i*8 ** bytes. i==NCSIZE is the number of allocation attempts for ** sizes more than NCSIZE*8 bytes. */ int nAlloc[NCSIZE]; /* Total number of allocations */ int nCurrent[NCSIZE]; /* Current number of allocations */ int mxCurrent[NCSIZE]; /* Highwater mark for nCurrent */ } mem; /* ** Adjust memory usage statistics */ static void adjustStats(int iSize, int increment){ int i = ((iSize+7)&~7)/8; if( i>NCSIZE-1 ){ i = NCSIZE - 1; } if( increment>0 ){ mem.nAlloc[i]++; mem.nCurrent[i]++; if( mem.nCurrent[i]>mem.mxCurrent[i] ){ mem.mxCurrent[i] = mem.nCurrent[i]; } }else{ mem.nCurrent[i]--; assert( mem.nCurrent[i]>=0 ); } } /* ** Given an allocation, find the MemBlockHdr for that allocation. ** ** This routine checks the guards at either end of the allocation and ** if they are incorrect it asserts. */ static struct MemBlockHdr *sqlite3MemsysGetHeader(void *pAllocation){ |
︙ | ︙ | |||
12004 12005 12006 12007 12008 12009 12010 | int *pInt; void *p = 0; int totalSize; int nReserve; sqlite3_mutex_enter(mem.mutex); assert( mem.disallow==0 ); nReserve = (nByte+7)&~7; | < < < < < | 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 | int *pInt; void *p = 0; int totalSize; int nReserve; sqlite3_mutex_enter(mem.mutex); assert( mem.disallow==0 ); nReserve = (nByte+7)&~7; totalSize = nReserve + sizeof(*pHdr) + sizeof(int) + mem.nBacktrace*sizeof(void*) + mem.nTitle; p = malloc(totalSize); if( p ){ z = p; pBt = (void**)&z[mem.nTitle]; pHdr = (struct MemBlockHdr*)&pBt[mem.nBacktrace]; |
︙ | ︙ | |||
12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 | }else{ pHdr->nBacktrace = 0; } if( mem.nTitle ){ memcpy(z, mem.zTitle, mem.nTitle); } pHdr->iSize = nByte; pInt = (int*)&pHdr[1]; pInt[nReserve/sizeof(int)] = REARGUARD; memset(pInt, 0x65, nReserve); p = (void*)pInt; } sqlite3_mutex_leave(mem.mutex); return p; | > | 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 | }else{ pHdr->nBacktrace = 0; } if( mem.nTitle ){ memcpy(z, mem.zTitle, mem.nTitle); } pHdr->iSize = nByte; adjustStats(nByte, +1); pInt = (int*)&pHdr[1]; pInt[nReserve/sizeof(int)] = REARGUARD; memset(pInt, 0x65, nReserve); p = (void*)pInt; } sqlite3_mutex_leave(mem.mutex); return p; |
︙ | ︙ | |||
12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 | pHdr->pNext->pPrev = pHdr->pPrev; }else{ assert( mem.pLast==pHdr ); mem.pLast = pHdr->pPrev; } z = (char*)pBt; z -= pHdr->nTitle; memset(z, 0x2b, sizeof(void*)*pHdr->nBacktraceSlots + sizeof(*pHdr) + pHdr->iSize + sizeof(int) + pHdr->nTitle); free(z); sqlite3_mutex_leave(mem.mutex); } /* | > | 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 | pHdr->pNext->pPrev = pHdr->pPrev; }else{ assert( mem.pLast==pHdr ); mem.pLast = pHdr->pPrev; } z = (char*)pBt; z -= pHdr->nTitle; adjustStats(pHdr->iSize, -1); memset(z, 0x2b, sizeof(void*)*pHdr->nBacktraceSlots + sizeof(*pHdr) + pHdr->iSize + sizeof(int) + pHdr->nTitle); free(z); sqlite3_mutex_leave(mem.mutex); } /* |
︙ | ︙ | |||
12110 12111 12112 12113 12114 12115 12116 | } sqlite3MemFree(pPrior); } return pNew; } | < < < < | > > > > > > > > | | 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 | } sqlite3MemFree(pPrior); } return pNew; } SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetDefault(void){ static const sqlite3_mem_methods defaultMethods = { sqlite3MemMalloc, sqlite3MemFree, sqlite3MemRealloc, sqlite3MemSize, sqlite3MemRoundup, sqlite3MemInit, sqlite3MemShutdown, 0 }; return &defaultMethods; } /* ** Populate the low-level memory allocation function pointers in ** sqlite3Config.m with pointers to the routines in this file. */ SQLITE_PRIVATE void sqlite3MemSetDefault(void){ sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetDefault()); } /* ** Set the number of backtrace levels kept for each allocation. ** A value of zero turns off backtracing. The number is always rounded ** up to a multiple of 2. */ |
︙ | ︙ | |||
12196 12197 12198 12199 12200 12201 12202 | pBt -= pHdr->nBacktraceSlots; backtrace_symbols_fd(pBt, pHdr->nBacktrace, fileno(out)); fprintf(out, "\n"); } } fprintf(out, "COUNTS:\n"); for(i=0; i<NCSIZE-1; i++){ | | | > | | > > | | 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 | pBt -= pHdr->nBacktraceSlots; backtrace_symbols_fd(pBt, pHdr->nBacktrace, fileno(out)); fprintf(out, "\n"); } } fprintf(out, "COUNTS:\n"); for(i=0; i<NCSIZE-1; i++){ if( mem.nAlloc[i] ){ fprintf(out, " %5d: %10d %10d %10d\n", i*8, mem.nAlloc[i], mem.nCurrent[i], mem.mxCurrent[i]); } } if( mem.nAlloc[NCSIZE-1] ){ fprintf(out, " %5d: %10d %10d %10d\n", NCSIZE*8-8, mem.nAlloc[NCSIZE-1], mem.nCurrent[NCSIZE-1], mem.mxCurrent[NCSIZE-1]); } fclose(out); } /* ** Return the number of times sqlite3MemMalloc() has been called. */ SQLITE_PRIVATE int sqlite3MemdebugMallocCount(){ int i; int nTotal = 0; for(i=0; i<NCSIZE; i++){ nTotal += mem.nAlloc[i]; } return nTotal; } #endif /* SQLITE_MEMDEBUG */ |
︙ | ︙ | |||
12248 12249 12250 12251 12252 12253 12254 | ** implementations. Once sqlite3_initialize() has been called, ** the amount of memory available to SQLite is fixed and cannot ** be changed. ** ** This version of the memory allocation subsystem is included ** in the build only if SQLITE_ENABLE_MEMSYS3 is defined. ** | | | 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 | ** implementations. Once sqlite3_initialize() has been called, ** the amount of memory available to SQLite is fixed and cannot ** be changed. ** ** This version of the memory allocation subsystem is included ** in the build only if SQLITE_ENABLE_MEMSYS3 is defined. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** This version of the memory allocator is only built into the library ** SQLITE_ENABLE_MEMSYS3 is defined. Defining this symbol does not ** mean that the library will use a memory-pool by default, just that ** it is available. The mempool allocator is activated by calling |
︙ | ︙ | |||
12362 12363 12364 12365 12366 12367 12368 | /* ** Memory available for allocation. nPool is the size of the array ** (in Mem3Blocks) pointed to by aPool less 2. */ u32 nPool; Mem3Block *aPool; | < | 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 | /* ** Memory available for allocation. nPool is the size of the array ** (in Mem3Blocks) pointed to by aPool less 2. */ u32 nPool; Mem3Block *aPool; } mem3; /* ** Unlink the chunk at mem3.aPool[i] from list it is currently ** on. *pRoot is the list that i is a member of. */ static void memsys3UnlinkFromList(u32 i, u32 *pRoot){ |
︙ | ︙ | |||
12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 | memsys3Unlink(mem3.iMaster+mem3.szMaster); mem3.szMaster += mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x/4; mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x; mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster; } } } /* ** Allocate nBytes of memory. */ static void *memsys3Malloc(int nBytes){ sqlite3_int64 *p; assert( nBytes>0 ); /* malloc.c filters out 0 byte requests */ | > > > > > > > > > > > > > > > > > > > > > > > > | 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 | memsys3Unlink(mem3.iMaster+mem3.szMaster); mem3.szMaster += mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x/4; mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x; mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster; } } } /* ** Return the size of an outstanding allocation, in bytes. The ** size returned omits the 8-byte header overhead. This only ** works for chunks that are currently checked out. */ static int memsys3Size(void *p){ Mem3Block *pBlock; if( p==0 ) return 0; pBlock = (Mem3Block*)p; assert( (pBlock[-1].u.hdr.size4x&1)!=0 ); return (pBlock[-1].u.hdr.size4x&~3)*2 - 4; } /* ** Round up a request size to the next valid allocation size. */ static int memsys3Roundup(int n){ if( n<=12 ){ return 12; }else{ return ((n+11)&~7) - 4; } } /* ** Allocate nBytes of memory. */ static void *memsys3Malloc(int nBytes){ sqlite3_int64 *p; assert( nBytes>0 ); /* malloc.c filters out 0 byte requests */ |
︙ | ︙ | |||
12716 12717 12718 12719 12720 12721 12722 | void memsys3Free(void *pPrior){ assert( pPrior ); memsys3Enter(); memsys3FreeUnsafe(pPrior); memsys3Leave(); } | < < < < < < < < < < < < < | 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 | void memsys3Free(void *pPrior){ assert( pPrior ); memsys3Enter(); memsys3FreeUnsafe(pPrior); memsys3Leave(); } /* ** Change the size of an existing memory allocation */ void *memsys3Realloc(void *pPrior, int nBytes){ int nOld; void *p; if( pPrior==0 ){ |
︙ | ︙ | |||
12760 12761 12762 12763 12764 12765 12766 | } memsys3FreeUnsafe(pPrior); } memsys3Leave(); return p; } | < < < < < < < | 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 | } memsys3FreeUnsafe(pPrior); } memsys3Leave(); return p; } /* ** Initialize this module. */ static int memsys3Init(void *NotUsed){ if( !sqlite3Config.pHeap ){ return SQLITE_ERROR; } |
︙ | ︙ | |||
12929 12930 12931 12932 12933 12934 12935 | ** implementations. Once sqlite3_initialize() has been called, ** the amount of memory available to SQLite is fixed and cannot ** be changed. ** ** This version of the memory allocation subsystem is included ** in the build only if SQLITE_ENABLE_MEMSYS5 is defined. ** | | | 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 | ** implementations. Once sqlite3_initialize() has been called, ** the amount of memory available to SQLite is fixed and cannot ** be changed. ** ** This version of the memory allocation subsystem is included ** in the build only if SQLITE_ENABLE_MEMSYS5 is defined. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** This version of the memory allocator is used only when ** SQLITE_POW2_MEMORY_SIZE is defined. */ #ifdef SQLITE_ENABLE_MEMSYS5 |
︙ | ︙ | |||
13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 | }; return &memsys5Methods; } #endif /* SQLITE_ENABLE_MEMSYS5 */ /************** End of mem5.c ************************************************/ /************** Begin file mutex.c *******************************************/ /* ** 2007 August 14 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 | }; return &memsys5Methods; } #endif /* SQLITE_ENABLE_MEMSYS5 */ /************** End of mem5.c ************************************************/ /************** Begin file mem6.c ********************************************/ /* ** 2008 July 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 contains an alternative memory allocation system for SQLite. ** This system is implemented as a wrapper around the system provided ** by the operating system - vanilla malloc(), realloc() and free(). ** ** This system differentiates between requests for "small" allocations ** (by default those of 128 bytes or less) and "large" allocations (all ** others). The 256 byte threshhold is configurable at runtime. ** ** All requests for large allocations are passed through to the ** default system. ** ** Requests for small allocations are met by allocating space within ** one or more larger "chunks" of memory obtained from the default ** memory allocation system. Chunks of memory are usually 64KB or ** larger. The algorithm used to manage space within each chunk is ** the same as that used by mem5.c. ** ** This strategy is designed to prevent the default memory allocation ** system (usually the system malloc) from suffering from heap ** fragmentation. On some systems, heap fragmentation can cause a ** significant real-time slowdown. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifdef SQLITE_ENABLE_MEMSYS6 /* ** Maximum size of any "small" allocation is ((1<<LOGMAX)*Mem6Chunk.nAtom). ** Mem6Chunk.nAtom is always at least 8, so this is not a practical ** limitation */ #define LOGMAX 30 /* ** Default value for the "small" allocation size threshold. */ #define SMALL_MALLOC_DEFAULT_THRESHOLD 256 /* ** Minimum size for a memory chunk. */ #define MIN_CHUNKSIZE (1<<16) #define LOG2_MINALLOC 4 typedef struct Mem6Chunk Mem6Chunk; typedef struct Mem6Link Mem6Link; /* ** A minimum allocation is an instance of the following structure. ** Larger allocations are an array of these structures where the ** size of the array is a power of 2. */ struct Mem6Link { int next; /* Index of next free chunk */ int prev; /* Index of previous free chunk */ }; /* ** Masks used for mem5.aCtrl[] elements. */ #define CTRL_LOGSIZE 0x1f /* Log2 Size of this block relative to POW2_MIN */ #define CTRL_FREE 0x20 /* True if not checked out */ struct Mem6Chunk { Mem6Chunk *pNext; /* ** Lists of free blocks of various sizes. */ int aiFreelist[LOGMAX+1]; int nCheckedOut; /* Number of currently outstanding allocations */ /* ** Space for tracking which blocks are checked out and the size ** of each block. One byte per block. */ u8 *aCtrl; /* ** Memory available for allocation */ int nAtom; /* Smallest possible allocation in bytes */ int nBlock; /* Number of nAtom sized blocks in zPool */ u8 *zPool; /* Pointer to memory chunk from which allocations are made */ }; #define MEM6LINK(idx) ((Mem6Link *)(&pChunk->zPool[(idx)*pChunk->nAtom])) struct Mem6Global { int nMinAlloc; /* Minimum allowed allocation size */ int nThreshold; /* Allocs larger than this go to malloc() */ int nLogThreshold; /* log2 of (nThreshold/nMinAlloc) */ sqlite3_mutex *mutex; Mem6Chunk *pChunk; /* Singly linked list of all memory chunks */ } mem6; /* ** Unlink the chunk at pChunk->aPool[i] from list it is currently ** on. It should be found on pChunk->aiFreelist[iLogsize]. */ static void memsys6Unlink(Mem6Chunk *pChunk, int i, int iLogsize){ int next, prev; assert( i>=0 && i<pChunk->nBlock ); assert( iLogsize>=0 && iLogsize<=mem6.nLogThreshold ); assert( (pChunk->aCtrl[i] & CTRL_LOGSIZE)==iLogsize ); next = MEM6LINK(i)->next; prev = MEM6LINK(i)->prev; if( prev<0 ){ pChunk->aiFreelist[iLogsize] = next; }else{ MEM6LINK(prev)->next = next; } if( next>=0 ){ MEM6LINK(next)->prev = prev; } } /* ** Link the chunk at mem5.aPool[i] so that is on the iLogsize ** free list. */ static void memsys6Link(Mem6Chunk *pChunk, int i, int iLogsize){ int x; assert( i>=0 && i<pChunk->nBlock ); assert( iLogsize>=0 && iLogsize<=mem6.nLogThreshold ); assert( (pChunk->aCtrl[i] & CTRL_LOGSIZE)==iLogsize ); x = MEM6LINK(i)->next = pChunk->aiFreelist[iLogsize]; MEM6LINK(i)->prev = -1; if( x>=0 ){ assert( x<pChunk->nBlock ); MEM6LINK(x)->prev = i; } pChunk->aiFreelist[iLogsize] = i; } /* ** Find the first entry on the freelist iLogsize. Unlink that ** entry and return its index. */ static int memsys6UnlinkFirst(Mem6Chunk *pChunk, int iLogsize){ int i; int iFirst; assert( iLogsize>=0 && iLogsize<=mem6.nLogThreshold ); i = iFirst = pChunk->aiFreelist[iLogsize]; assert( iFirst>=0 ); memsys6Unlink(pChunk, iFirst, iLogsize); return iFirst; } static int roundupLog2(int n){ static const char LogTable256[256] = { 0, /* 1 */ 1, /* 2 */ 2, 2, /* 3..4 */ 3, 3, 3, 3, /* 5..8 */ 4, 4, 4, 4, 4, 4, 4, 4, /* 9..16 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, /* 17..32 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, /* 33..64 */ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, /* 65..128 */ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, /* 129..256 */ }; assert(n<=(1<<16) && n>0); if( n<=256 ) return LogTable256[n-1]; return LogTable256[(n>>8) - ((n&0xFF)?0:1)] + 8; } /* ** Allocate and return a block of (pChunk->nAtom << iLogsize) bytes from chunk ** pChunk. If the allocation request cannot be satisfied, return 0. */ static void *chunkMalloc(Mem6Chunk *pChunk, int iLogsize){ int i; /* Index of a mem5.aPool[] slot */ int iBin; /* Index into mem5.aiFreelist[] */ /* Make sure mem5.aiFreelist[iLogsize] contains at least one free ** block. If not, then split a block of the next larger power of ** two in order to create a new free block of size iLogsize. */ for(iBin=iLogsize; pChunk->aiFreelist[iBin]<0 && iBin<=mem6.nLogThreshold; iBin++){} if( iBin>mem6.nLogThreshold ) return 0; i = memsys6UnlinkFirst(pChunk, iBin); while( iBin>iLogsize ){ int newSize; iBin--; newSize = 1 << iBin; pChunk->aCtrl[i+newSize] = CTRL_FREE | iBin; memsys6Link(pChunk, i+newSize, iBin); } pChunk->aCtrl[i] = iLogsize; /* Return a pointer to the allocated memory. */ pChunk->nCheckedOut++; return (void*)&pChunk->zPool[i*pChunk->nAtom]; } /* ** Free the allocation pointed to by p, which is guaranteed to be non-zero ** and a part of chunk object pChunk. */ static void chunkFree(Mem6Chunk *pChunk, void *pOld){ u32 size, iLogsize; int iBlock; /* Set iBlock to the index of the block pointed to by pOld in ** the array of pChunk->nAtom byte blocks pointed to by pChunk->zPool. */ iBlock = ((u8 *)pOld-pChunk->zPool)/pChunk->nAtom; /* Check that the pointer pOld points to a valid, non-free block. */ assert( iBlock>=0 && iBlock<pChunk->nBlock ); assert( ((u8 *)pOld-pChunk->zPool)%pChunk->nAtom==0 ); assert( (pChunk->aCtrl[iBlock] & CTRL_FREE)==0 ); iLogsize = pChunk->aCtrl[iBlock] & CTRL_LOGSIZE; size = 1<<iLogsize; assert( iBlock+size-1<pChunk->nBlock ); pChunk->aCtrl[iBlock] |= CTRL_FREE; pChunk->aCtrl[iBlock+size-1] |= CTRL_FREE; pChunk->aCtrl[iBlock] = CTRL_FREE | iLogsize; while( iLogsize<mem6.nLogThreshold ){ int iBuddy; if( (iBlock>>iLogsize) & 1 ){ iBuddy = iBlock - size; }else{ iBuddy = iBlock + size; } assert( iBuddy>=0 ); if( (iBuddy+(1<<iLogsize))>pChunk->nBlock ) break; if( pChunk->aCtrl[iBuddy]!=(CTRL_FREE | iLogsize) ) break; memsys6Unlink(pChunk, iBuddy, iLogsize); iLogsize++; if( iBuddy<iBlock ){ pChunk->aCtrl[iBuddy] = CTRL_FREE | iLogsize; pChunk->aCtrl[iBlock] = 0; iBlock = iBuddy; }else{ pChunk->aCtrl[iBlock] = CTRL_FREE | iLogsize; pChunk->aCtrl[iBuddy] = 0; } size *= 2; } pChunk->nCheckedOut--; memsys6Link(pChunk, iBlock, iLogsize); } /* ** Return the actual size of the block pointed to by p, which is guaranteed ** to have been allocated from chunk pChunk. */ static int chunkSize(Mem6Chunk *pChunk, void *p){ int iSize = 0; if( p ){ int i = ((u8 *)p-pChunk->zPool)/pChunk->nAtom; assert( i>=0 && i<pChunk->nBlock ); iSize = pChunk->nAtom * (1 << (pChunk->aCtrl[i]&CTRL_LOGSIZE)); } return iSize; } /* ** Return true if there are currently no outstanding allocations. */ static int chunkIsEmpty(Mem6Chunk *pChunk){ return (pChunk->nCheckedOut==0); } /* ** Initialize the buffer zChunk, which is nChunk bytes in size, as ** an Mem6Chunk object. Return a copy of the zChunk pointer. */ static Mem6Chunk *chunkInit(u8 *zChunk, int nChunk, int nMinAlloc){ int ii; int iOffset; Mem6Chunk *pChunk = (Mem6Chunk *)zChunk; assert( nChunk>sizeof(Mem6Chunk) ); assert( nMinAlloc>sizeof(Mem6Link) ); memset(pChunk, 0, sizeof(Mem6Chunk)); pChunk->nAtom = nMinAlloc; pChunk->nBlock = ((nChunk-sizeof(Mem6Chunk)) / (pChunk->nAtom+sizeof(u8))); pChunk->zPool = (u8 *)&pChunk[1]; pChunk->aCtrl = &pChunk->zPool[pChunk->nBlock*pChunk->nAtom]; for(ii=0; ii<=mem6.nLogThreshold; ii++){ pChunk->aiFreelist[ii] = -1; } iOffset = 0; for(ii=mem6.nLogThreshold; ii>=0; ii--){ int nAlloc = (1<<ii); while( (iOffset+nAlloc)<=pChunk->nBlock ){ pChunk->aCtrl[iOffset] = ii | CTRL_FREE; memsys6Link(pChunk, iOffset, ii); iOffset += nAlloc; } } return pChunk; } static void mem6Enter(void){ sqlite3_mutex_enter(mem6.mutex); } static void mem6Leave(void){ sqlite3_mutex_leave(mem6.mutex); } /* ** Based on the number and size of the currently allocated chunks, return ** the size of the next chunk to allocate, in bytes. */ static int nextChunkSize(void){ int iTotal = MIN_CHUNKSIZE; Mem6Chunk *p; for(p=mem6.pChunk; p; p=p->pNext){ iTotal = iTotal*2; } return iTotal; } static void freeChunk(Mem6Chunk *pChunk){ Mem6Chunk **pp = &mem6.pChunk; for( pp=&mem6.pChunk; *pp!=pChunk; pp = &(*pp)->pNext ); *pp = (*pp)->pNext; free(pChunk); } static void *memsys6Malloc(int nByte){ Mem6Chunk *pChunk; void *p = 0; int nTotal = nByte+8; int iOffset = 0; if( nTotal>mem6.nThreshold ){ p = malloc(nTotal); }else{ int iLogsize = 0; if( nTotal>(1<<LOG2_MINALLOC) ){ iLogsize = roundupLog2(nTotal) - LOG2_MINALLOC; } mem6Enter(); for(pChunk=mem6.pChunk; pChunk; pChunk=pChunk->pNext){ p = chunkMalloc(pChunk, iLogsize); if( p ){ break; } } if( !p ){ int iSize = nextChunkSize(); p = malloc(iSize); if( p ){ pChunk = chunkInit((u8 *)p, iSize, mem6.nMinAlloc); pChunk->pNext = mem6.pChunk; mem6.pChunk = pChunk; p = chunkMalloc(pChunk, iLogsize); assert(p); } } iOffset = ((u8*)p - (u8*)pChunk); mem6Leave(); } if( !p ){ return 0; } ((u32 *)p)[0] = iOffset; ((u32 *)p)[1] = nByte; return &((u32 *)p)[2]; } static int memsys6Size(void *pPrior){ if( pPrior==0 ) return 0; return ((u32*)pPrior)[-1]; } static void memsys6Free(void *pPrior){ int iSlot; void *p = &((u32 *)pPrior)[-2]; iSlot = ((u32 *)p)[0]; if( iSlot ){ Mem6Chunk *pChunk; mem6Enter(); pChunk = (Mem6Chunk *)(&((u8 *)p)[-1 * iSlot]); chunkFree(pChunk, p); if( chunkIsEmpty(pChunk) ){ freeChunk(pChunk); } mem6Leave(); }else{ free(p); } } static void *memsys6Realloc(void *p, int nByte){ void *p2; if( p && nByte<=memsys6Size(p) ){ p2 = p; }else{ p2 = memsys6Malloc(nByte); if( p && p2 ){ memcpy(p2, p, memsys6Size(p)); memsys6Free(p); } } return p2; } static int memsys6Roundup(int n){ if( n>mem6.nThreshold ){ return n; }else{ return (1<<roundupLog2(n)); } } static int memsys6Init(void *pCtx){ u8 bMemstat = sqlite3Config.bMemstat; mem6.nMinAlloc = (1 << LOG2_MINALLOC); mem6.pChunk = 0; mem6.nThreshold = sqlite3Config.nSmall; if( mem6.nThreshold<=0 ){ mem6.nThreshold = SMALL_MALLOC_DEFAULT_THRESHOLD; } mem6.nLogThreshold = roundupLog2(mem6.nThreshold) - LOG2_MINALLOC; if( !bMemstat ){ mem6.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); } return SQLITE_OK; } static void memsys6Shutdown(void *pCtx){ memset(&mem6, 0, sizeof(mem6)); } /* ** This routine is the only routine in this file with external ** linkage. It returns a pointer to a static sqlite3_mem_methods ** struct populated with the memsys6 methods. */ SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys6(void){ static const sqlite3_mem_methods memsys6Methods = { memsys6Malloc, memsys6Free, memsys6Realloc, memsys6Size, memsys6Roundup, memsys6Init, memsys6Shutdown, 0 }; return &memsys6Methods; } #endif /************** End of mem6.c ************************************************/ /************** Begin file mutex.c *******************************************/ /* ** 2007 August 14 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** |
︙ | ︙ | |||
13442 13443 13444 13445 13446 13447 13448 | ** exclusion and is thus suitable for use only in applications ** that use SQLite in a single thread. But this implementation ** does do a lot of error checking on mutexes to make sure they ** are called correctly and at appropriate times. Hence, this ** implementation is suitable for testing. ** debugging purposes ** | | | 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 | ** exclusion and is thus suitable for use only in applications ** that use SQLite in a single thread. But this implementation ** does do a lot of error checking on mutexes to make sure they ** are called correctly and at appropriate times. Hence, this ** implementation is suitable for testing. ** debugging purposes ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef SQLITE_MUTEX_NOOP /* ** Initialize the mutex system. */ SQLITE_PRIVATE int sqlite3MutexInit(void){ |
︙ | ︙ | |||
13709 13710 13711 13712 13713 13714 13715 | ** 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 contains the C functions that implement mutexes for OS/2 ** | | | 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 | ** 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 contains the C functions that implement mutexes for OS/2 ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** The code in this file is only used if SQLITE_MUTEX_OS2 is defined. ** See the mutex.h file for details. */ #ifdef SQLITE_MUTEX_OS2 |
︙ | ︙ | |||
13984 13985 13986 13987 13988 13989 13990 | ** 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 contains the C functions that implement mutexes for pthreads ** | | | 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 | ** 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 contains the C functions that implement mutexes for pthreads ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** The code in this file is only used if we are compiling threadsafe ** under unix with pthreads. ** ** Note that this implementation requires a version of pthreads that |
︙ | ︙ | |||
14311 14312 14313 14314 14315 14316 14317 | ** 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 contains the C functions that implement mutexes for win32 ** | | | 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 | ** 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 contains the C functions that implement mutexes for win32 ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** The code in this file is only used if we are compiling multithreaded ** on a win32 system. */ #ifdef SQLITE_MUTEX_W32 |
︙ | ︙ | |||
14558 14559 14560 14561 14562 14563 14564 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** Memory allocation functions used throughout sqlite. ** | | | 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** Memory allocation functions used throughout sqlite. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** This routine runs when the memory allocator sees that the ** total memory allocation is about to exceed the soft heap ** limit. */ |
︙ | ︙ | |||
14655 14656 14657 14658 14659 14660 14661 | if( sqlite3Config.m.xMalloc==0 ){ sqlite3MemSetDefault(); } memset(&mem0, 0, sizeof(mem0)); if( sqlite3Config.bCoreMutex ){ mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); } | | | > | > > > > > | 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 15442 15443 15444 15445 15446 15447 15448 15449 | if( sqlite3Config.m.xMalloc==0 ){ sqlite3MemSetDefault(); } memset(&mem0, 0, sizeof(mem0)); if( sqlite3Config.bCoreMutex ){ mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); } if( sqlite3Config.pScratch && sqlite3Config.szScratch>=100 && sqlite3Config.nScratch>=0 ){ int i; sqlite3Config.szScratch -= 4; mem0.aScratchFree = (u32*)&((char*)sqlite3Config.pScratch) [sqlite3Config.szScratch*sqlite3Config.nScratch]; for(i=0; i<sqlite3Config.nScratch; i++){ mem0.aScratchFree[i] = i; } mem0.nScratchFree = sqlite3Config.nScratch; }else{ sqlite3Config.pScratch = 0; sqlite3Config.szScratch = 0; } if( sqlite3Config.pPage && sqlite3Config.szPage>=512 && sqlite3Config.nPage>=1 ){ int i; int overhead; int sz = sqlite3Config.szPage; int n = sqlite3Config.nPage; overhead = (4*n + sz - 1)/sz; sqlite3Config.nPage -= overhead; mem0.aPageFree = (u32*)&((char*)sqlite3Config.pPage) [sqlite3Config.szPage*sqlite3Config.nPage]; for(i=0; i<sqlite3Config.nPage; i++){ mem0.aPageFree[i] = i; } mem0.nPageFree = sqlite3Config.nPage; }else{ sqlite3Config.pPage = 0; sqlite3Config.szPage = 0; |
︙ | ︙ | |||
14767 14768 14769 14770 14771 14772 14773 | } } p = sqlite3Config.m.xMalloc(nFull); if( p==0 && mem0.alarmCallback ){ sqlite3MallocAlarm(nFull); p = sqlite3Config.m.xMalloc(nFull); } | > > | > | 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 | } } p = sqlite3Config.m.xMalloc(nFull); if( p==0 && mem0.alarmCallback ){ sqlite3MallocAlarm(nFull); p = sqlite3Config.m.xMalloc(nFull); } if( p ){ nFull = sqlite3MallocSize(p); sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull); } *pp = p; return nFull; } /* ** Allocate memory. This routine is like sqlite3_malloc() except that it ** assumes the memory subsystem has already been initialized. |
︙ | ︙ | |||
14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 | goto scratch_overflow; }else{ int i; i = mem0.aScratchFree[--mem0.nScratchFree]; sqlite3_mutex_leave(mem0.mutex); i *= sqlite3Config.szScratch; sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1); p = (void*)&((char*)sqlite3Config.pScratch)[i]; } } #if SQLITE_THREADSAFE==0 && !defined(NDEBUG) scratchAllocOut = p!=0; #endif return p; scratch_overflow: if( sqlite3Config.bMemstat ){ sqlite3_mutex_enter(mem0.mutex); n = mallocWithAlarm(n, &p); if( p ) sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, n); sqlite3_mutex_leave(mem0.mutex); }else{ p = sqlite3Config.m.xMalloc(n); } #if SQLITE_THREADSAFE==0 && !defined(NDEBUG) | > > | 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 15640 15641 15642 15643 | goto scratch_overflow; }else{ int i; i = mem0.aScratchFree[--mem0.nScratchFree]; sqlite3_mutex_leave(mem0.mutex); i *= sqlite3Config.szScratch; sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1); sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n); p = (void*)&((char*)sqlite3Config.pScratch)[i]; } } #if SQLITE_THREADSAFE==0 && !defined(NDEBUG) scratchAllocOut = p!=0; #endif return p; scratch_overflow: if( sqlite3Config.bMemstat ){ sqlite3_mutex_enter(mem0.mutex); sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n); n = mallocWithAlarm(n, &p); if( p ) sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, n); sqlite3_mutex_leave(mem0.mutex); }else{ p = sqlite3Config.m.xMalloc(n); } #if SQLITE_THREADSAFE==0 && !defined(NDEBUG) |
︙ | ︙ | |||
14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 | sqlite3_mutex_leave(mem0.mutex); goto page_overflow; }else{ int i; i = mem0.aPageFree[--mem0.nPageFree]; sqlite3_mutex_leave(mem0.mutex); i *= sqlite3Config.szPage; sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1); p = (void*)&((char*)sqlite3Config.pPage)[i]; } } return p; page_overflow: if( sqlite3Config.bMemstat ){ sqlite3_mutex_enter(mem0.mutex); n = mallocWithAlarm(n, &p); if( p ) sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, n); sqlite3_mutex_leave(mem0.mutex); }else{ p = sqlite3Config.m.xMalloc(n); } return p; | > > | 15704 15705 15706 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 | sqlite3_mutex_leave(mem0.mutex); goto page_overflow; }else{ int i; i = mem0.aPageFree[--mem0.nPageFree]; sqlite3_mutex_leave(mem0.mutex); i *= sqlite3Config.szPage; sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, n); sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1); p = (void*)&((char*)sqlite3Config.pPage)[i]; } } return p; page_overflow: if( sqlite3Config.bMemstat ){ sqlite3_mutex_enter(mem0.mutex); sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, n); n = mallocWithAlarm(n, &p); if( p ) sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, n); sqlite3_mutex_leave(mem0.mutex); }else{ p = sqlite3Config.m.xMalloc(n); } return p; |
︙ | ︙ | |||
14983 14984 14985 14986 14987 14988 14989 | i /= sqlite3Config.szPage; assert( i>=0 && i<sqlite3Config.nPage ); sqlite3_mutex_enter(mem0.mutex); assert( mem0.nPageFree<sqlite3Config.nPage ); mem0.aPageFree[mem0.nPageFree++] = i; sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, -1); sqlite3_mutex_leave(mem0.mutex); | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 | i /= sqlite3Config.szPage; assert( i>=0 && i<sqlite3Config.nPage ); sqlite3_mutex_enter(mem0.mutex); assert( mem0.nPageFree<sqlite3Config.nPage ); mem0.aPageFree[mem0.nPageFree++] = i; sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, -1); sqlite3_mutex_leave(mem0.mutex); #if !defined(NDEBUG) && 0 /* Assert that a duplicate was not just inserted into aPageFree[]. */ for(i=0; i<mem0.nPageFree-1; i++){ assert( mem0.aPageFree[i]!=mem0.aPageFree[mem0.nPageFree-1] ); } #endif } } } /* ** TRUE if p is a lookaside memory allocation from db */ static int isLookaside(sqlite3 *db, void *p){ return db && p && p>=db->lookaside.pStart && p<db->lookaside.pEnd; } /* ** Return the size of a memory allocation previously obtained from ** sqlite3Malloc() or sqlite3_malloc(). */ SQLITE_PRIVATE int sqlite3MallocSize(void *p){ return sqlite3Config.m.xSize(p); } SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){ if( isLookaside(db, p) ){ return db->lookaside.sz; }else{ return sqlite3Config.m.xSize(p); } } /* ** Free memory previously obtained from sqlite3Malloc(). */ SQLITE_API void sqlite3_free(void *p){ if( p==0 ) return; if( sqlite3Config.bMemstat ){ sqlite3_mutex_enter(mem0.mutex); sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -sqlite3MallocSize(p)); sqlite3Config.m.xFree(p); sqlite3_mutex_leave(mem0.mutex); }else{ sqlite3Config.m.xFree(p); } } /* ** Free memory that might be associated with a particular database ** connection. */ SQLITE_PRIVATE void sqlite3DbFree(sqlite3 *db, void *p){ if( isLookaside(db, p) ){ LookasideSlot *pBuf = (LookasideSlot*)p; pBuf->pNext = db->lookaside.pFree; db->lookaside.pFree = pBuf; db->lookaside.nOut--; }else{ sqlite3_free(p); } } /* ** Change the size of an existing memory allocation */ SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, int nBytes){ int nOld, nNew; void *pNew; |
︙ | ︙ | |||
15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 | } pNew = sqlite3Config.m.xRealloc(pOld, nNew); if( pNew==0 && mem0.alarmCallback ){ sqlite3MallocAlarm(nBytes); pNew = sqlite3Config.m.xRealloc(pOld, nNew); } if( pNew ){ sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld); } } sqlite3_mutex_leave(mem0.mutex); }else{ pNew = sqlite3Config.m.xRealloc(pOld, nBytes); } | > | 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 15864 | } pNew = sqlite3Config.m.xRealloc(pOld, nNew); if( pNew==0 && mem0.alarmCallback ){ sqlite3MallocAlarm(nBytes); pNew = sqlite3Config.m.xRealloc(pOld, nNew); } if( pNew ){ nNew = sqlite3MallocSize(pNew); sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld); } } sqlite3_mutex_leave(mem0.mutex); }else{ pNew = sqlite3Config.m.xRealloc(pOld, nBytes); } |
︙ | ︙ | |||
15097 15098 15099 15100 15101 15102 15103 | } /* ** Allocate and zero memory. If the allocation fails, make ** the mallocFailed flag in the connection pointer. */ SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3 *db, int n){ | | > > | > > > > > > > > > > > > | | | < | > > > > > > > > > > > > > | | | > | | | | < < < | | < < | > | < < < < < < < < < | > > > > > | > | | | 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 15920 15921 15922 15923 15924 15925 15926 15927 15928 15929 15930 15931 15932 15933 15934 15935 15936 15937 15938 15939 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 | } /* ** Allocate and zero memory. If the allocation fails, make ** the mallocFailed flag in the connection pointer. */ SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3 *db, int n){ void *p; if( db ){ LookasideSlot *pBuf; if( db->mallocFailed ){ return 0; } if( db->lookaside.bEnabled && n<=db->lookaside.sz && (pBuf = db->lookaside.pFree)!=0 ){ db->lookaside.pFree = pBuf->pNext; db->lookaside.nOut++; if( db->lookaside.nOut>db->lookaside.mxOut ){ db->lookaside.mxOut = db->lookaside.nOut; } return (void*)pBuf; } } p = sqlite3Malloc(n); if( !p && db ){ db->mallocFailed = 1; } return p; } /* ** Resize the block of memory pointed to by p to n bytes. If the ** resize fails, set the mallocFailed flag in the connection object. */ SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, int n){ void *pNew = 0; if( db->mallocFailed==0 ){ if( p==0 ){ return sqlite3DbMallocRaw(db, n); } if( isLookaside(db, p) ){ if( n<=db->lookaside.sz ){ return p; } pNew = sqlite3DbMallocRaw(db, n); if( pNew ){ memcpy(pNew, p, db->lookaside.sz); sqlite3DbFree(db, p); } }else{ pNew = sqlite3_realloc(p, n); if( !pNew ){ db->mallocFailed = 1; } } } return pNew; } /* ** Attempt to reallocate p. If the reallocation fails, then free p ** and set the mallocFailed flag in the database connection. */ SQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *db, void *p, int n){ void *pNew; pNew = sqlite3DbRealloc(db, p, n); if( !pNew ){ sqlite3DbFree(db, p); } return pNew; } /* ** Make a copy of a string in memory obtained from sqliteMalloc(). These ** functions call sqlite3MallocRaw() directly instead of sqliteMalloc(). This ** is because when memory debugging is turned on, these two functions are ** called via macros that record the current file and line number in the ** ThreadData structure. */ SQLITE_PRIVATE char *sqlite3DbStrDup(sqlite3 *db, const char *z){ char *zNew; size_t n; if( z==0 ){ return 0; } n = strlen(z)+1; assert( (n&0x7fffffff)==n ); zNew = sqlite3DbMallocRaw(db, (int)n); if( zNew ){ memcpy(zNew, z, n); } return zNew; } SQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3 *db, const char *z, int n){ char *zNew; if( z==0 ){ return 0; } assert( (n&0x7fffffff)==n ); zNew = sqlite3DbMallocRaw(db, n+1); if( zNew ){ memcpy(zNew, z, n); zNew[n] = 0; } return zNew; } /* ** Create a string from the zFromat argument and the va_list that follows. ** Store the string in memory obtained from sqliteMalloc() and make *pz ** point to that string. */ SQLITE_PRIVATE void sqlite3SetString(char **pz, sqlite3 *db, const char *zFormat, ...){ va_list ap; char *z; va_start(ap, zFormat); z = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); sqlite3DbFree(db, *pz); *pz = z; } /* ** This function must be called before exiting any API function (i.e. ** returning control to the user) that has called sqlite3_malloc or |
︙ | ︙ | |||
15230 15231 15232 15233 15234 15235 15236 | /* ** The "printf" code that follows dates from the 1980's. It is in ** the public domain. The original comments are included here for ** completeness. They are very out-of-date but might be useful as ** an historical reference. Most of the "enhancements" have been backed ** out so that the functionality is now the same as standard printf(). ** | | | 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 16064 16065 16066 16067 16068 | /* ** The "printf" code that follows dates from the 1980's. It is in ** the public domain. The original comments are included here for ** completeness. They are very out-of-date but might be useful as ** an historical reference. Most of the "enhancements" have been backed ** out so that the functionality is now the same as standard printf(). ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ ** ************************************************************************** ** ** The following modules is an enhanced replacement for the "printf" subroutines ** found in the standard C library. The following enhancements are ** supported: ** |
︙ | ︙ | |||
15970 15971 15972 15973 15974 15975 15976 | if( szNew > p->mxAlloc ){ sqlite3StrAccumReset(p); p->tooBig = 1; return; }else{ p->nAlloc = szNew; } | | | 16794 16795 16796 16797 16798 16799 16800 16801 16802 16803 16804 16805 16806 16807 16808 | if( szNew > p->mxAlloc ){ sqlite3StrAccumReset(p); p->tooBig = 1; return; }else{ p->nAlloc = szNew; } zNew = sqlite3DbMallocRaw(p->db, p->nAlloc ); if( zNew ){ memcpy(zNew, p->zText, p->nChar); sqlite3StrAccumReset(p); p->zText = zNew; }else{ p->mallocFailed = 1; sqlite3StrAccumReset(p); |
︙ | ︙ | |||
15995 15996 15997 15998 15999 16000 16001 | ** Return a pointer to the resulting string. Return a NULL ** pointer if any kind of error was encountered. */ SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum *p){ if( p->zText ){ p->zText[p->nChar] = 0; if( p->useMalloc && p->zText==p->zBase ){ | | | > > > > > > > > > > > > > > > > > > > > | 16819 16820 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 16836 16837 16838 16839 16840 16841 16842 16843 16844 16845 16846 16847 16848 16849 16850 16851 16852 16853 16854 16855 16856 16857 16858 16859 16860 16861 16862 16863 16864 16865 16866 16867 16868 16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 16881 16882 16883 16884 16885 16886 16887 16888 16889 16890 16891 16892 16893 16894 16895 16896 16897 16898 16899 16900 16901 16902 16903 16904 16905 16906 16907 16908 16909 16910 16911 16912 16913 16914 16915 16916 | ** Return a pointer to the resulting string. Return a NULL ** pointer if any kind of error was encountered. */ SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum *p){ if( p->zText ){ p->zText[p->nChar] = 0; if( p->useMalloc && p->zText==p->zBase ){ p->zText = sqlite3DbMallocRaw(p->db, p->nChar+1 ); if( p->zText ){ memcpy(p->zText, p->zBase, p->nChar+1); }else{ p->mallocFailed = 1; } } } return p->zText; } /* ** Reset an StrAccum string. Reclaim all malloced memory. */ SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum *p){ if( p->zText!=p->zBase ){ sqlite3DbFree(p->db, p->zText); } p->zText = 0; } /* ** Initialize a string accumulator */ SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum *p, char *zBase, int n, int mx){ p->zText = p->zBase = zBase; p->db = 0; p->nChar = 0; p->nAlloc = n; p->mxAlloc = mx; p->useMalloc = 1; p->tooBig = 0; p->mallocFailed = 0; } /* ** Print into memory obtained from sqliteMalloc(). Use the internal ** %-conversion extensions. */ SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){ char *z; char zBase[SQLITE_PRINT_BUF_SIZE]; StrAccum acc; sqlite3StrAccumInit(&acc, zBase, sizeof(zBase), db ? db->aLimit[SQLITE_LIMIT_LENGTH] : SQLITE_MAX_LENGTH); acc.db = db; sqlite3VXPrintf(&acc, 1, zFormat, ap); z = sqlite3StrAccumFinish(&acc); if( acc.mallocFailed && db ){ db->mallocFailed = 1; } return z; } /* ** Print into memory obtained from sqliteMalloc(). Use the internal ** %-conversion extensions. */ SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3 *db, const char *zFormat, ...){ va_list ap; char *z; va_start(ap, zFormat); z = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); return z; } /* ** Like sqlite3MPrintf(), but call sqlite3DbFree() on zStr after formatting ** the string and before returnning. This routine is intended to be used ** to modify an existing string. For example: ** ** x = sqlite3MPrintf(db, x, "prefix %s suffix", x); ** */ SQLITE_PRIVATE char *sqlite3MAppendf(sqlite3 *db, char *zStr, const char *zFormat, ...){ va_list ap; char *z; va_start(ap, zFormat); z = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); sqlite3DbFree(db, zStr); return z; } /* ** Print into memory obtained from sqlite3_malloc(). Omit the internal ** %-conversion extensions. */ SQLITE_API char *sqlite3_vmprintf(const char *zFormat, va_list ap){ char *z; |
︙ | ︙ | |||
16156 16157 16158 16159 16160 16161 16162 | ************************************************************************* ** This file contains code to implement a pseudo-random number ** generator (PRNG) for SQLite. ** ** Random numbers are used by some of the database backends in order ** to generate random integer keys for tables or random filenames. ** | | | 17000 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 17011 17012 17013 17014 | ************************************************************************* ** This file contains code to implement a pseudo-random number ** generator (PRNG) for SQLite. ** ** Random numbers are used by some of the database backends in order ** to generate random integer keys for tables or random filenames. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* All threads share a single random number generator. ** This structure is the current state of the generator. */ static struct sqlite3PrngType { |
︙ | ︙ | |||
16277 16278 16279 16280 16281 16282 16283 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** | | | 17121 17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ ** ** Notes on UTF-8: ** ** Byte-0 Byte-1 Byte-2 Byte-3 Value ** 0xxxxxxx 00000000 00000000 0xxxxxxx ** 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx ** 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx |
︙ | ︙ | |||
16319 16320 16321 16322 16323 16324 16325 | ************************************************************************* ** This is the header file for information that is private to the ** VDBE. This information used to all be at the top of the single ** source code file "vdbe.c". When that file became too big (over ** 6000 lines long) it was split up into several smaller files and ** this header information was factored out. ** | | | 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 17176 17177 | ************************************************************************* ** This is the header file for information that is private to the ** VDBE. This information used to all be at the top of the single ** source code file "vdbe.c". When that file became too big (over ** 6000 lines long) it was split up into several smaller files and ** this header information was factored out. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _VDBEINT_H_ #define _VDBEINT_H_ /* ** intToKey() and keyToInt() used to transform the rowid. But with ** the latest versions of the design they are no-ops. |
︙ | ︙ | |||
16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 | ** of that structure is private to this file. ** ** The Fifo structure describes the entire fifo. */ typedef struct Fifo Fifo; struct Fifo { int nEntry; /* Total number of entries */ FifoPage *pFirst; /* First page on the list */ FifoPage *pLast; /* Last page on the list */ }; /* ** A Context stores the last insert rowid, the last statement change count, ** and the current statement change count (i.e. changes since last statement). | > | 17393 17394 17395 17396 17397 17398 17399 17400 17401 17402 17403 17404 17405 17406 17407 | ** of that structure is private to this file. ** ** The Fifo structure describes the entire fifo. */ typedef struct Fifo Fifo; struct Fifo { int nEntry; /* Total number of entries */ sqlite3 *db; /* The associated database connection */ FifoPage *pFirst; /* First page on the list */ FifoPage *pLast; /* Last page on the list */ }; /* ** A Context stores the last insert rowid, the last statement change count, ** and the current statement change count (i.e. changes since last statement). |
︙ | ︙ | |||
16621 16622 16623 16624 16625 16626 16627 | int inTempTrans; /* True if temp database is transactioned */ int nResColumn; /* Number of columns in one row of the result set */ char **azResColumn; /* Values for one row of result */ char *zErrMsg; /* Error message written here */ Mem *pResultSet; /* Pointer to an array of results */ u8 explain; /* True if EXPLAIN present on SQL command */ u8 changeCntOn; /* True to update the change-counter */ | < | 17466 17467 17468 17469 17470 17471 17472 17473 17474 17475 17476 17477 17478 17479 | int inTempTrans; /* True if temp database is transactioned */ int nResColumn; /* Number of columns in one row of the result set */ char **azResColumn; /* Values for one row of result */ char *zErrMsg; /* Error message written here */ Mem *pResultSet; /* Pointer to an array of results */ u8 explain; /* True if EXPLAIN present on SQL command */ u8 changeCntOn; /* True to update the change-counter */ u8 expired; /* True if the VM needs to be recompiled */ u8 minWriteFileFormat; /* Minimum file format for writable database files */ u8 inVtabMethod; /* See comments above */ int nChange; /* Number of db changes made since last reset */ i64 startTime; /* Time when query started - used for profiling */ int btreeMask; /* Bitmask of db->aDb[] entries referenced */ BtreeMutexArray aMutex; /* An array of Btree used here and needing locks */ |
︙ | ︙ | |||
16694 16695 16696 16697 16698 16699 16700 | SQLITE_PRIVATE int sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*); SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int); int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *); SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(Cursor*,UnpackedRecord *,int,const unsigned char*,int*); SQLITE_PRIVATE int sqlite3VdbeIdxRowid(BtCursor *, i64 *); SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*); | | < | 17538 17539 17540 17541 17542 17543 17544 17545 17546 17547 17548 17549 17550 17551 17552 17553 17554 17555 17556 17557 17558 17559 17560 17561 17562 17563 17564 17565 17566 17567 | SQLITE_PRIVATE int sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*); SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int); int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *); SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(Cursor*,UnpackedRecord *,int,const unsigned char*,int*); SQLITE_PRIVATE int sqlite3VdbeIdxRowid(BtCursor *, i64 *); SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*); SQLITE_PRIVATE int sqlite3VdbeIdxRowidLen(const u8*, int, int*); SQLITE_PRIVATE int sqlite3VdbeExec(Vdbe*); SQLITE_PRIVATE int sqlite3VdbeList(Vdbe*); SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe*); SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *, int); SQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem*, const Mem*); SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int); SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*); SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*)); SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64); SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double); SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*); SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int); SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, int); SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*); SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*); SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*); |
︙ | ︙ | |||
16738 16739 16740 16741 16742 16743 16744 | #endif SQLITE_PRIVATE int sqlite3VdbeMemTranslate(Mem*, u8); #ifdef SQLITE_DEBUG SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf); #endif SQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem); | | | 17581 17582 17583 17584 17585 17586 17587 17588 17589 17590 17591 17592 17593 17594 17595 | #endif SQLITE_PRIVATE int sqlite3VdbeMemTranslate(Mem*, u8); #ifdef SQLITE_DEBUG SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf); #endif SQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem); SQLITE_PRIVATE void sqlite3VdbeFifoInit(Fifo*, sqlite3*); SQLITE_PRIVATE int sqlite3VdbeFifoPush(Fifo*, i64); SQLITE_PRIVATE int sqlite3VdbeFifoPop(Fifo*, i64*); SQLITE_PRIVATE void sqlite3VdbeFifoClear(Fifo*); #ifndef SQLITE_OMIT_INCRBLOB SQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *); #else |
︙ | ︙ | |||
16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 | ** and rendered as themselves even though they are technically ** invalid characters. ** ** * This routine accepts an infinite number of different UTF8 encodings ** for unicode values 0x80 and greater. It do not change over-length ** encodings to 0xfffd as some systems recommend. */ SQLITE_PRIVATE int sqlite3Utf8Read( const unsigned char *z, /* First byte of UTF-8 character */ const unsigned char *zTerm, /* Pretend this byte is 0x00 */ const unsigned char **pzNext /* Write first byte past UTF-8 char here */ ){ | > > > > > > > > > > > | < < < < < | < < < > | 17712 17713 17714 17715 17716 17717 17718 17719 17720 17721 17722 17723 17724 17725 17726 17727 17728 17729 17730 17731 17732 17733 17734 17735 17736 17737 17738 17739 17740 17741 17742 17743 17744 17745 17746 17747 | ** and rendered as themselves even though they are technically ** invalid characters. ** ** * This routine accepts an infinite number of different UTF8 encodings ** for unicode values 0x80 and greater. It do not change over-length ** encodings to 0xfffd as some systems recommend. */ #define READ_UTF8(zIn, zTerm, c) \ c = *(zIn++); \ if( c>=0xc0 ){ \ c = sqlite3UtfTrans1[c-0xc0]; \ while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){ \ c = (c<<6) + (0x3f & *(zIn++)); \ } \ if( c<0x80 \ || (c&0xFFFFF800)==0xD800 \ || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \ } SQLITE_PRIVATE int sqlite3Utf8Read( const unsigned char *z, /* First byte of UTF-8 character */ const unsigned char *zTerm, /* Pretend this byte is 0x00 */ const unsigned char **pzNext /* Write first byte past UTF-8 char here */ ){ int c; READ_UTF8(z, zTerm, c); *pzNext = z; return c; } /* ** If the TRANSLATE_TRACE macro is defined, the value of each Mem is ** printed on stderr on the way into and out of sqlite3VdbeMemTranslate(). */ |
︙ | ︙ | |||
16983 16984 16985 16986 16987 16988 16989 | } z = zOut; if( pMem->enc==SQLITE_UTF8 ){ if( desiredEnc==SQLITE_UTF16LE ){ /* UTF-8 -> UTF-16 Little-endian */ while( zIn<zTerm ){ | | > | > | 17830 17831 17832 17833 17834 17835 17836 17837 17838 17839 17840 17841 17842 17843 17844 17845 17846 17847 17848 17849 17850 17851 17852 17853 | } z = zOut; if( pMem->enc==SQLITE_UTF8 ){ if( desiredEnc==SQLITE_UTF16LE ){ /* UTF-8 -> UTF-16 Little-endian */ while( zIn<zTerm ){ /* c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn); */ READ_UTF8(zIn, zTerm, c); WRITE_UTF16LE(z, c); } }else{ assert( desiredEnc==SQLITE_UTF16BE ); /* UTF-8 -> UTF-16 Big-endian */ while( zIn<zTerm ){ /* c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn); */ READ_UTF8(zIn, zTerm, c); WRITE_UTF16BE(z, c); } } pMem->n = z - zOut; *z++ = 0; }else{ assert( desiredEnc==SQLITE_UTF8 ); |
︙ | ︙ | |||
17256 17257 17258 17259 17260 17261 17262 | ** ************************************************************************* ** Utility functions used throughout sqlite. ** ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** | | | > > > > > > > > > > > > | | | 18105 18106 18107 18108 18109 18110 18111 18112 18113 18114 18115 18116 18117 18118 18119 18120 18121 18122 18123 18124 18125 18126 18127 18128 18129 18130 18131 18132 18133 18134 18135 18136 18137 18138 18139 18140 18141 18142 18143 18144 18145 18146 18147 18148 18149 18150 18151 18152 18153 18154 18155 18156 18157 18158 18159 18160 18161 18162 18163 18164 18165 18166 | ** ************************************************************************* ** Utility functions used throughout sqlite. ** ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** Return true if the floating point value is Not a Number (NaN). */ SQLITE_PRIVATE int sqlite3IsNaN(double x){ /* This NaN test sometimes fails if compiled on GCC with -ffast-math. ** On the other hand, the use of -ffast-math comes with the following ** warning: ** ** This option [-ffast-math] should never be turned on by any ** -O option since it can result in incorrect output for programs ** which depend on an exact implementation of IEEE or ISO ** rules/specifications for math functions. ** ** Under MSVC, this NaN test may fail if compiled with a floating- ** point precision mode other than /fp:precise. From the MSDN ** documentation: ** ** The compiler [with /fp:precise] will properly handle comparisons ** involving NaN. For example, x != x evaluates to true if x is NaN ** ... */ #ifdef __FAST_MATH__ # error SQLite will not work correctly with the -ffast-math option of GCC. #endif volatile double y = x; volatile double z = y; return y!=z; } /* ** Return the length of a string, except do not allow the string length ** to exceed the SQLITE_LIMIT_LENGTH setting. */ SQLITE_PRIVATE int sqlite3Strlen(sqlite3 *db, const char *z){ const char *z2 = z; int len; size_t x; while( *z2 ){ z2++; } x = z2 - z; len = 0x7fffffff & x; if( len!=x || len > db->aLimit[SQLITE_LIMIT_LENGTH] ){ return db->aLimit[SQLITE_LIMIT_LENGTH]; }else{ return len; } } /* ** Set the most recent error code and error string for the sqlite ** handle "db". The error code is set to "err_code". ** |
︙ | ︙ | |||
17325 17326 17327 17328 17329 17330 17331 | db->errCode = err_code; if( zFormat ){ char *z; va_list ap; va_start(ap, zFormat); z = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); | | | 18186 18187 18188 18189 18190 18191 18192 18193 18194 18195 18196 18197 18198 18199 18200 | db->errCode = err_code; if( zFormat ){ char *z; va_list ap; va_start(ap, zFormat); z = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); sqlite3ValueSetStr(db->pErr, -1, z, SQLITE_UTF8, SQLITE_DYNAMIC); }else{ sqlite3ValueSetStr(db->pErr, 0, 0, SQLITE_UTF8, SQLITE_STATIC); } } } /* |
︙ | ︙ | |||
17351 17352 17353 17354 17355 17356 17357 17358 | ** last thing the sqlite3_prepare() function does is copy the error ** stored by this function into the database handle using sqlite3Error(). ** Function sqlite3Error() should be used during statement execution ** (sqlite3_step() etc.). */ SQLITE_PRIVATE void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){ va_list ap; pParse->nErr++; | > | | | | 18212 18213 18214 18215 18216 18217 18218 18219 18220 18221 18222 18223 18224 18225 18226 18227 18228 18229 18230 18231 18232 18233 18234 18235 18236 18237 18238 18239 18240 18241 | ** last thing the sqlite3_prepare() function does is copy the error ** stored by this function into the database handle using sqlite3Error(). ** Function sqlite3Error() should be used during statement execution ** (sqlite3_step() etc.). */ SQLITE_PRIVATE void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){ va_list ap; sqlite3 *db = pParse->db; pParse->nErr++; sqlite3DbFree(db, pParse->zErrMsg); va_start(ap, zFormat); pParse->zErrMsg = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); if( pParse->rc==SQLITE_OK ){ pParse->rc = SQLITE_ERROR; } } /* ** Clear the error message in pParse, if any */ SQLITE_PRIVATE void sqlite3ErrorClear(Parse *pParse){ sqlite3DbFree(pParse->db, pParse->zErrMsg); pParse->zErrMsg = 0; pParse->nErr = 0; } /* ** Convert an SQL-style quoted string into a normal string by removing ** the quote characters. The conversion is done in-place. If the |
︙ | ︙ | |||
18193 18194 18195 18196 18197 18198 18199 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the implementation of generic hash-tables ** used in SQLite. ** | | | 19055 19056 19057 19058 19059 19060 19061 19062 19063 19064 19065 19066 19067 19068 19069 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the implementation of generic hash-tables ** used in SQLite. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* Turn bulk memory into a hash table object by initializing the ** fields of the Hash structure. ** ** "pNew" is a pointer to the hash table that is to be initialized. ** keyClass is one of the constants SQLITE_HASH_INT, SQLITE_HASH_POINTER, |
︙ | ︙ | |||
18771 18772 18773 18774 18775 18776 18777 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains code that is specific to OS/2. ** | | | 19633 19634 19635 19636 19637 19638 19639 19640 19641 19642 19643 19644 19645 19646 19647 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains code that is specific to OS/2. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #if SQLITE_OS_OS2 /* ** A Note About Memory Allocation: |
︙ | ︙ | |||
18834 18835 18836 18837 18838 18839 18840 | ** This file contains macros and a little bit of code that is common to ** all of the platform-specific files (os_*.c) and is #included into those ** files. ** ** This file should be #included by the os_*.c files only. It is not a ** general purpose header file. ** | | | 19696 19697 19698 19699 19700 19701 19702 19703 19704 19705 19706 19707 19708 19709 19710 | ** This file contains macros and a little bit of code that is common to ** all of the platform-specific files (os_*.c) and is #included into those ** files. ** ** This file should be #included by the os_*.c files only. It is not a ** general purpose header file. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _OS_COMMON_H_ #define _OS_COMMON_H_ /* ** At least two bugs have slipped in because we changed the MEMORY_DEBUG ** macro to SQLITE_DEBUG and some older makefiles have not yet made the |
︙ | ︙ | |||
18905 18906 18907 18908 18909 18910 18911 | ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains inline asm code for retrieving "high-performance" ** counters for x86 class CPUs. ** | | | 19767 19768 19769 19770 19771 19772 19773 19774 19775 19776 19777 19778 19779 19780 19781 | ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains inline asm code for retrieving "high-performance" ** counters for x86 class CPUs. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _HWTIME_H_ #define _HWTIME_H_ /* ** The following routine only works on pentium-class (or newer) processors. ** It uses the RDTSC opcode to read the cycle count value out of the |
︙ | ︙ | |||
18946 18947 18948 18949 18950 18951 18952 18953 18954 18955 18956 18957 18958 18959 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long val; __asm__ __volatile__ ("rdtsc" : "=A" (val)); return val; } #else #error Need implementation of sqlite3Hwtime() for your platform. /* ** To compile without implementing sqlite3Hwtime() for your platform, ** you can remove the above #error and use the following | > > > > > > > > > > > > > > > | 19808 19809 19810 19811 19812 19813 19814 19815 19816 19817 19818 19819 19820 19821 19822 19823 19824 19825 19826 19827 19828 19829 19830 19831 19832 19833 19834 19835 19836 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long val; __asm__ __volatile__ ("rdtsc" : "=A" (val)); return val; } #elif (defined(__GNUC__) && defined(__ppc__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long long retval; unsigned long junk; __asm__ __volatile__ ("\n\ 1: mftbu %1\n\ mftb %L0\n\ mftbu %0\n\ cmpw %0,%1\n\ bne 1b" : "=r" (retval), "=r" (junk)); return retval; } #else #error Need implementation of sqlite3Hwtime() for your platform. /* ** To compile without implementing sqlite3Hwtime() for your platform, ** you can remove the above #error and use the following |
︙ | ︙ | |||
19533 19534 19535 19536 19537 19538 19539 | static UconvObject ucUtf8 = NULL; /* convert between UTF-8 and UCS-2 */ static UconvObject uclCp = NULL; /* convert between local codepage and UCS-2 */ /* ** Helper function to initialize the conversion objects from and to UTF-8. */ static void initUconvObjects( void ){ | < < < < < < | 20410 20411 20412 20413 20414 20415 20416 20417 20418 20419 20420 20421 20422 20423 20424 20425 20426 20427 20428 20429 20430 20431 20432 20433 20434 20435 20436 20437 20438 20439 20440 20441 20442 20443 20444 20445 20446 20447 20448 20449 20450 20451 20452 20453 20454 20455 20456 20457 20458 20459 20460 20461 20462 20463 20464 20465 20466 20467 20468 20469 20470 20471 20472 20473 20474 20475 20476 20477 20478 20479 20480 20481 20482 20483 20484 20485 20486 20487 20488 20489 20490 20491 20492 20493 | static UconvObject ucUtf8 = NULL; /* convert between UTF-8 and UCS-2 */ static UconvObject uclCp = NULL; /* convert between local codepage and UCS-2 */ /* ** Helper function to initialize the conversion objects from and to UTF-8. */ static void initUconvObjects( void ){ if( UniCreateUconvObject( UTF_8, &ucUtf8 ) != ULS_SUCCESS ) ucUtf8 = NULL; if ( UniCreateUconvObject( (UniChar *)L"@path=yes", &uclCp ) != ULS_SUCCESS ) uclCp = NULL; } /* ** Helper function to free the conversion objects from and to UTF-8. */ static void freeUconvObjects( void ){ if ( ucUtf8 ) UniFreeUconvObject( ucUtf8 ); if ( uclCp ) UniFreeUconvObject( uclCp ); ucUtf8 = NULL; uclCp = NULL; } /* ** Helper function to convert UTF-8 filenames to local OS/2 codepage. ** The two-step process: first convert the incoming UTF-8 string ** into UCS-2 and then from UCS-2 to the current codepage. ** The returned char pointer has to be freed. */ static char *convertUtf8PathToCp( const char *in ){ UniChar tempPath[CCHMAXPATH]; char *out = (char *)calloc( CCHMAXPATH, 1 ); if( !out ) return NULL; if( !ucUtf8 || !uclCp ) initUconvObjects(); /* determine string for the conversion of UTF-8 which is CP1208 */ if( UniStrToUcs( ucUtf8, tempPath, (char *)in, CCHMAXPATH ) != ULS_SUCCESS ) return out; /* if conversion fails, return the empty string */ /* conversion for current codepage which can be used for paths */ UniStrFromUcs( uclCp, out, tempPath, CCHMAXPATH ); return out; } /* ** Helper function to convert filenames from local codepage to UTF-8. ** The two-step process: first convert the incoming codepage-specific ** string into UCS-2 and then from UCS-2 to the codepage of UTF-8. ** The returned char pointer has to be freed. ** ** This function is non-static to be able to use this in shell.c and ** similar applications that take command line arguments. */ char *convertCpPathToUtf8( const char *in ){ UniChar tempPath[CCHMAXPATH]; char *out = (char *)calloc( CCHMAXPATH, 1 ); if( !out ) return NULL; if( !ucUtf8 || !uclCp ) initUconvObjects(); /* conversion for current codepage which can be used for paths */ if( UniStrToUcs( uclCp, tempPath, (char *)in, CCHMAXPATH ) != ULS_SUCCESS ) return out; /* if conversion fails, return the empty string */ /* determine string for the conversion of UTF-8 which is CP1208 */ UniStrFromUcs( ucUtf8, out, tempPath, CCHMAXPATH ); return out; } /* ** This vector defines all the methods that can operate on an ** sqlite3_file for os2. */ |
︙ | ︙ | |||
19691 19692 19693 19694 19695 19696 19697 19698 19699 19700 19701 19702 19703 19704 | zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; } zBuf[j] = 0; OSTRACE2( "TEMP FILENAME: %s\n", zBuf ); return SQLITE_OK; } /* ** Open a file. */ static int os2Open( sqlite3_vfs *pVfs, /* Not used */ const char *zName, /* Name of the file */ | > > > > > > > > > > > > > > > > > > > > > > > > | 20562 20563 20564 20565 20566 20567 20568 20569 20570 20571 20572 20573 20574 20575 20576 20577 20578 20579 20580 20581 20582 20583 20584 20585 20586 20587 20588 20589 20590 20591 20592 20593 20594 20595 20596 20597 20598 20599 | zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; } zBuf[j] = 0; OSTRACE2( "TEMP FILENAME: %s\n", zBuf ); return SQLITE_OK; } /* ** Turn a relative pathname into a full pathname. Write the full ** pathname into zFull[]. zFull[] will be at least pVfs->mxPathname ** bytes in size. */ static int os2FullPathname( sqlite3_vfs *pVfs, /* Pointer to vfs object */ const char *zRelative, /* Possibly relative input path */ int nFull, /* Size of output buffer in bytes */ char *zFull /* Output buffer */ ){ char *zRelativeCp = convertUtf8PathToCp( zRelative ); char zFullCp[CCHMAXPATH] = "\0"; char *zFullUTF; APIRET rc = DosQueryPathInfo( zRelativeCp, FIL_QUERYFULLNAME, zFullCp, CCHMAXPATH ); free( zRelativeCp ); zFullUTF = convertCpPathToUtf8( zFullCp ); sqlite3_snprintf( nFull, zFull, zFullUTF ); free( zFullUTF ); return rc == NO_ERROR ? SQLITE_OK : SQLITE_IOERR; } /* ** Open a file. */ static int os2Open( sqlite3_vfs *pVfs, /* Not used */ const char *zName, /* Name of the file */ |
︙ | ︙ | |||
19758 19759 19760 19761 19762 19763 19764 | ulOpenMode |= OPEN_SHARE_DENYWRITE; OSTRACE1( "OPEN share read only\n" ); } if( flags & (SQLITE_OPEN_TEMP_DB | SQLITE_OPEN_TEMP_JOURNAL | SQLITE_OPEN_SUBJOURNAL) ){ char pathUtf8[CCHMAXPATH]; | > | > | | 20653 20654 20655 20656 20657 20658 20659 20660 20661 20662 20663 20664 20665 20666 20667 20668 20669 20670 20671 | ulOpenMode |= OPEN_SHARE_DENYWRITE; OSTRACE1( "OPEN share read only\n" ); } if( flags & (SQLITE_OPEN_TEMP_DB | SQLITE_OPEN_TEMP_JOURNAL | SQLITE_OPEN_SUBJOURNAL) ){ char pathUtf8[CCHMAXPATH]; #ifdef NDEBUG /* when debugging we want to make sure it is deleted */ ulFileAttribute = FILE_HIDDEN; #endif ulFileAttribute = FILE_NORMAL; os2FullPathname( pVfs, zName, CCHMAXPATH, pathUtf8 ); pFile->pathToDel = convertUtf8PathToCp( pathUtf8 ); OSTRACE1( "OPEN hidden/delete on close file attributes\n" ); }else{ ulFileAttribute = FILE_ARCHIVED | FILE_NORMAL; pFile->pathToDel = NULL; OSTRACE1( "OPEN normal file attribute\n" ); } |
︙ | ︙ | |||
19792 19793 19794 19795 19796 19797 19798 | OSTRACE7( "OPEN Invalid handle rc=%d: zName=%s, ulAction=%#lx, ulAttr=%#lx, ulFlags=%#lx, ulMode=%#lx\n", rc, zName, ulAction, ulFileAttribute, ulOpenFlags, ulOpenMode ); if( pFile->pathToDel ) free( pFile->pathToDel ); pFile->pathToDel = NULL; if( flags & SQLITE_OPEN_READWRITE ){ OSTRACE2( "OPEN %d Invalid handle\n", ((flags | SQLITE_OPEN_READONLY) & ~SQLITE_OPEN_READWRITE) ); | | | 20689 20690 20691 20692 20693 20694 20695 20696 20697 20698 20699 20700 20701 20702 20703 | OSTRACE7( "OPEN Invalid handle rc=%d: zName=%s, ulAction=%#lx, ulAttr=%#lx, ulFlags=%#lx, ulMode=%#lx\n", rc, zName, ulAction, ulFileAttribute, ulOpenFlags, ulOpenMode ); if( pFile->pathToDel ) free( pFile->pathToDel ); pFile->pathToDel = NULL; if( flags & SQLITE_OPEN_READWRITE ){ OSTRACE2( "OPEN %d Invalid handle\n", ((flags | SQLITE_OPEN_READONLY) & ~SQLITE_OPEN_READWRITE) ); return os2Open( pVfs, zName, id, ((flags | SQLITE_OPEN_READONLY) & ~SQLITE_OPEN_READWRITE), pOutFlags ); }else{ return SQLITE_CANTOPEN; } } |
︙ | ︙ | |||
19865 19866 19867 19868 19869 19870 19871 | assert( !"Invalid flags argument" ); } *pOut = rc; return SQLITE_OK; } | < < < < < < < < < < < < < < < < < < < < < < < | 20762 20763 20764 20765 20766 20767 20768 20769 20770 20771 20772 20773 20774 20775 | assert( !"Invalid flags argument" ); } *pOut = rc; return SQLITE_OK; } #ifndef SQLITE_OMIT_LOAD_EXTENSION /* ** Interfaces for opening a shared library, finding entry points ** within the shared library, and closing the shared library. */ /* ** Interfaces for opening a shared library, finding entry points |
︙ | ︙ | |||
20064 20065 20066 20067 20068 20069 20070 | return 0; } /* ** Initialize and deinitialize the operating system interface. */ SQLITE_API int sqlite3_os_init(void){ | < < | 20938 20939 20940 20941 20942 20943 20944 20945 20946 20947 20948 20949 20950 20951 | return 0; } /* ** Initialize and deinitialize the operating system interface. */ SQLITE_API int sqlite3_os_init(void){ static sqlite3_vfs os2Vfs = { 1, /* iVersion */ sizeof(os2File), /* szOsFile */ CCHMAXPATH, /* mxPathname */ 0, /* pNext */ "os2", /* zName */ 0, /* pAppData */ |
︙ | ︙ | |||
20088 20089 20090 20091 20092 20093 20094 20095 20096 20097 20098 20099 20100 20101 | os2DlClose, /* xDlClose */ os2Randomness, /* xRandomness */ os2Sleep, /* xSleep */ os2CurrentTime, /* xCurrentTime */ os2GetLastError /* xGetLastError */ }; sqlite3_vfs_register(&os2Vfs, 1); return SQLITE_OK; } SQLITE_API int sqlite3_os_end(void){ freeUconvObjects(); return SQLITE_OK; } | > | 20960 20961 20962 20963 20964 20965 20966 20967 20968 20969 20970 20971 20972 20973 20974 | os2DlClose, /* xDlClose */ os2Randomness, /* xRandomness */ os2Sleep, /* xSleep */ os2CurrentTime, /* xCurrentTime */ os2GetLastError /* xGetLastError */ }; sqlite3_vfs_register(&os2Vfs, 1); initUconvObjects(); return SQLITE_OK; } SQLITE_API int sqlite3_os_end(void){ freeUconvObjects(); return SQLITE_OK; } |
︙ | ︙ | |||
20113 20114 20115 20116 20117 20118 20119 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains code that is specific to Unix systems. ** | | | 20986 20987 20988 20989 20990 20991 20992 20993 20994 20995 20996 20997 20998 20999 21000 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains code that is specific to Unix systems. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #if SQLITE_OS_UNIX /* This file is used on unix only */ /* ** If SQLITE_ENABLE_LOCKING_STYLE is defined, then several different ** locking implementations are provided: ** |
︙ | ︙ | |||
20237 20238 20239 20240 20241 20242 20243 | ** This file contains macros and a little bit of code that is common to ** all of the platform-specific files (os_*.c) and is #included into those ** files. ** ** This file should be #included by the os_*.c files only. It is not a ** general purpose header file. ** | | | 21110 21111 21112 21113 21114 21115 21116 21117 21118 21119 21120 21121 21122 21123 21124 | ** This file contains macros and a little bit of code that is common to ** all of the platform-specific files (os_*.c) and is #included into those ** files. ** ** This file should be #included by the os_*.c files only. It is not a ** general purpose header file. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _OS_COMMON_H_ #define _OS_COMMON_H_ /* ** At least two bugs have slipped in because we changed the MEMORY_DEBUG ** macro to SQLITE_DEBUG and some older makefiles have not yet made the |
︙ | ︙ | |||
20308 20309 20310 20311 20312 20313 20314 | ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains inline asm code for retrieving "high-performance" ** counters for x86 class CPUs. ** | | | 21181 21182 21183 21184 21185 21186 21187 21188 21189 21190 21191 21192 21193 21194 21195 | ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains inline asm code for retrieving "high-performance" ** counters for x86 class CPUs. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _HWTIME_H_ #define _HWTIME_H_ /* ** The following routine only works on pentium-class (or newer) processors. ** It uses the RDTSC opcode to read the cycle count value out of the |
︙ | ︙ | |||
20349 20350 20351 20352 20353 20354 20355 20356 20357 20358 20359 20360 20361 20362 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long val; __asm__ __volatile__ ("rdtsc" : "=A" (val)); return val; } #else #error Need implementation of sqlite3Hwtime() for your platform. /* ** To compile without implementing sqlite3Hwtime() for your platform, ** you can remove the above #error and use the following | > > > > > > > > > > > > > > > | 21222 21223 21224 21225 21226 21227 21228 21229 21230 21231 21232 21233 21234 21235 21236 21237 21238 21239 21240 21241 21242 21243 21244 21245 21246 21247 21248 21249 21250 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long val; __asm__ __volatile__ ("rdtsc" : "=A" (val)); return val; } #elif (defined(__GNUC__) && defined(__ppc__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long long retval; unsigned long junk; __asm__ __volatile__ ("\n\ 1: mftbu %1\n\ mftb %L0\n\ mftbu %0\n\ cmpw %0,%1\n\ bne 1b" : "=r" (retval), "=r" (junk)); return retval; } #else #error Need implementation of sqlite3Hwtime() for your platform. /* ** To compile without implementing sqlite3Hwtime() for your platform, ** you can remove the above #error and use the following |
︙ | ︙ | |||
20626 20627 20628 20629 20630 20631 20632 20633 20634 20635 20636 20637 20638 20639 | ** object keeps a count of the number of unixFile pointing to it. */ struct lockInfo { struct lockKey key; /* The lookup key */ int cnt; /* Number of SHARED locks held */ int locktype; /* One of SHARED_LOCK, RESERVED_LOCK etc. */ int nRef; /* Number of pointers to this structure */ }; /* ** An instance of the following structure serves as the key used ** to locate a particular openCnt structure given its inode. This ** is the same as the lockKey except that the thread ID is omitted. */ | > | 21514 21515 21516 21517 21518 21519 21520 21521 21522 21523 21524 21525 21526 21527 21528 | ** object keeps a count of the number of unixFile pointing to it. */ struct lockInfo { struct lockKey key; /* The lookup key */ int cnt; /* Number of SHARED locks held */ int locktype; /* One of SHARED_LOCK, RESERVED_LOCK etc. */ int nRef; /* Number of pointers to this structure */ struct lockInfo *pNext, *pPrev; /* List of all lockInfo objects */ }; /* ** An instance of the following structure serves as the key used ** to locate a particular openCnt structure given its inode. This ** is the same as the lockKey except that the thread ID is omitted. */ |
︙ | ︙ | |||
20651 20652 20653 20654 20655 20656 20657 20658 20659 | */ struct openCnt { struct openKey key; /* The lookup key */ int nRef; /* Number of pointers to this structure */ int nLock; /* Number of outstanding locks */ int nPending; /* Number of pending close() operations */ int *aPending; /* Malloced space holding fd's awaiting a close() */ }; | > | < | | > > | | | | | 21540 21541 21542 21543 21544 21545 21546 21547 21548 21549 21550 21551 21552 21553 21554 21555 21556 21557 21558 21559 21560 21561 21562 21563 21564 21565 21566 21567 21568 21569 21570 21571 21572 21573 21574 21575 21576 21577 21578 21579 21580 21581 21582 21583 21584 | */ struct openCnt { struct openKey key; /* The lookup key */ int nRef; /* Number of pointers to this structure */ int nLock; /* Number of outstanding locks */ int nPending; /* Number of pending close() operations */ int *aPending; /* Malloced space holding fd's awaiting a close() */ struct openCnt *pNext, *pPrev; /* List of all openCnt objects */ }; /* ** List of all lockInfo and openCnt objects. This used to be a hash ** table. But the number of objects is rarely more than a dozen and ** never exceeds a few thousand. And lookup is not on a critical ** path oo a simple linked list will suffice. */ static struct lockInfo *lockList = 0; static struct openCnt *openList = 0; /* ** The locking styles are associated with the different file locking ** capabilities supported by different file systems. ** ** POSIX locking style fully supports shared and exclusive byte-range locks ** AFP locking only supports exclusive byte-range locks ** FLOCK only supports a single file-global exclusive lock ** DOTLOCK isn't a true locking style, it refers to the use of a special ** file named the same as the database file with a '.lock' extension, this ** can be used on file systems that do not offer any reliable file locking ** NO locking means that no locking will be attempted, this is only used for ** read-only file systems currently ** UNSUPPORTED means that no locking will be attempted, this is only used for ** file systems that are known to be unsupported */ #define LOCKING_STYLE_POSIX 1 #define LOCKING_STYLE_NONE 2 #define LOCKING_STYLE_DOTFILE 3 #define LOCKING_STYLE_FLOCK 4 #define LOCKING_STYLE_AFP 5 /* ** Helper functions to obtain and relinquish the global mutex. */ static void enterMutex(){ sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); |
︙ | ︙ | |||
20838 20839 20840 20841 20842 20843 20844 | /* ** Release a lockInfo structure previously allocated by findLockInfo(). */ static void releaseLockInfo(struct lockInfo *pLock){ if( pLock ){ pLock->nRef--; if( pLock->nRef==0 ){ | | > > > > > > > > > > | > > > > > > > > > > | | 21729 21730 21731 21732 21733 21734 21735 21736 21737 21738 21739 21740 21741 21742 21743 21744 21745 21746 21747 21748 21749 21750 21751 21752 21753 21754 21755 21756 21757 21758 21759 21760 21761 21762 21763 21764 21765 21766 21767 21768 21769 21770 21771 21772 21773 21774 21775 21776 21777 | /* ** Release a lockInfo structure previously allocated by findLockInfo(). */ static void releaseLockInfo(struct lockInfo *pLock){ if( pLock ){ pLock->nRef--; if( pLock->nRef==0 ){ if( pLock->pPrev ){ assert( pLock->pPrev->pNext==pLock ); pLock->pPrev->pNext = pLock->pNext; }else{ assert( lockList==pLock ); lockList = pLock->pNext; } if( pLock->pNext ){ assert( pLock->pNext->pPrev==pLock ); pLock->pNext->pPrev = pLock->pPrev; } sqlite3_free(pLock); } } } /* ** Release a openCnt structure previously allocated by findLockInfo(). */ static void releaseOpenCnt(struct openCnt *pOpen){ if( pOpen ){ pOpen->nRef--; if( pOpen->nRef==0 ){ if( pOpen->pPrev ){ assert( pOpen->pPrev->pNext==pOpen ); pOpen->pPrev->pNext = pOpen->pNext; }else{ assert( openList==pOpen ); openList = pOpen->pNext; } if( pOpen->pNext ){ assert( pOpen->pNext->pPrev==pOpen ); pOpen->pNext->pPrev = pOpen->pPrev; } sqlite3_free(pOpen->aPending); sqlite3_free(pOpen); } } } #ifdef SQLITE_ENABLE_LOCKING_STYLE /* |
︙ | ︙ | |||
20965 20966 20967 20968 20969 20970 20971 20972 20973 20974 20975 20976 20977 20978 20979 20980 20981 20982 20983 20984 | rc = fstat(fd, &statbuf); if( rc!=0 ){ #ifdef EOVERFLOW if( errno==EOVERFLOW ) return SQLITE_NOLFS; #endif return SQLITE_IOERR; } memset(&key1, 0, sizeof(key1)); key1.dev = statbuf.st_dev; key1.ino = statbuf.st_ino; #if SQLITE_THREADSAFE if( threadsOverrideEachOthersLocks<0 ){ testThreadLockingBehavior(fd); } key1.tid = threadsOverrideEachOthersLocks ? 0 : pthread_self(); #endif memset(&key2, 0, sizeof(key2)); key2.dev = statbuf.st_dev; key2.ino = statbuf.st_ino; | > > > > > > > > > > > > > > > > > > > | > > < < < | | | | < > | > > < | < | | < | < < | 21876 21877 21878 21879 21880 21881 21882 21883 21884 21885 21886 21887 21888 21889 21890 21891 21892 21893 21894 21895 21896 21897 21898 21899 21900 21901 21902 21903 21904 21905 21906 21907 21908 21909 21910 21911 21912 21913 21914 21915 21916 21917 21918 21919 21920 21921 21922 21923 21924 21925 21926 21927 21928 21929 21930 21931 21932 21933 21934 21935 21936 21937 21938 21939 21940 21941 21942 21943 21944 21945 21946 21947 21948 21949 21950 21951 21952 21953 21954 21955 21956 21957 21958 21959 21960 21961 21962 21963 | rc = fstat(fd, &statbuf); if( rc!=0 ){ #ifdef EOVERFLOW if( errno==EOVERFLOW ) return SQLITE_NOLFS; #endif return SQLITE_IOERR; } /* On OS X on an msdos filesystem, the inode number is reported ** incorrectly for zero-size files. See ticket #3260. To work ** around this problem (we consider it a bug in OS X, not SQLite) ** we always increase the file size to 1 by writing a single byte ** prior to accessing the inode number. The one byte written is ** an ASCII 'S' character which also happens to be the first byte ** in the header of every SQLite database. In this way, if there ** is a race condition such that another thread has already populated ** the first page of the database, no damage is done. */ if( statbuf.st_size==0 ){ write(fd, "S", 1); rc = fstat(fd, &statbuf); if( rc!=0 ){ return SQLITE_IOERR; } } memset(&key1, 0, sizeof(key1)); key1.dev = statbuf.st_dev; key1.ino = statbuf.st_ino; #if SQLITE_THREADSAFE if( threadsOverrideEachOthersLocks<0 ){ testThreadLockingBehavior(fd); } key1.tid = threadsOverrideEachOthersLocks ? 0 : pthread_self(); #endif memset(&key2, 0, sizeof(key2)); key2.dev = statbuf.st_dev; key2.ino = statbuf.st_ino; pLock = lockList; while( pLock && memcmp(&key1, &pLock->key, sizeof(key1)) ){ pLock = pLock->pNext; } if( pLock==0 ){ pLock = sqlite3_malloc( sizeof(*pLock) ); if( pLock==0 ){ rc = SQLITE_NOMEM; goto exit_findlockinfo; } pLock->key = key1; pLock->nRef = 1; pLock->cnt = 0; pLock->locktype = 0; pLock->pNext = lockList; pLock->pPrev = 0; if( lockList ) lockList->pPrev = pLock; lockList = pLock; }else{ pLock->nRef++; } *ppLock = pLock; if( ppOpen!=0 ){ pOpen = openList; while( pOpen && memcmp(&key2, &pOpen->key, sizeof(key2)) ){ pOpen = pOpen->pNext; } if( pOpen==0 ){ pOpen = sqlite3_malloc( sizeof(*pOpen) ); if( pOpen==0 ){ releaseLockInfo(pLock); rc = SQLITE_NOMEM; goto exit_findlockinfo; } pOpen->key = key2; pOpen->nRef = 1; pOpen->nLock = 0; pOpen->nPending = 0; pOpen->aPending = 0; pOpen->pNext = openList; pOpen->pPrev = 0; if( openList ) openList->pPrev = pOpen; openList = pOpen; }else{ pOpen->nRef++; } *ppOpen = pOpen; } exit_findlockinfo: |
︙ | ︙ | |||
21387 21388 21389 21390 21391 21392 21393 21394 21395 21396 21397 21398 21399 21400 | assert( id ); rc = fstat(((unixFile*)id)->h, &buf); SimulateIOError( rc=1 ); if( rc!=0 ){ return SQLITE_IOERR_FSTAT; } *pSize = buf.st_size; return SQLITE_OK; } /* ** This routine checks if there is a RESERVED lock held on the specified ** file by this or any other process. If such a lock is held, return ** non-zero. If the file is unlocked or holds only SHARED locks, then | > > > > > > > > > > | 22313 22314 22315 22316 22317 22318 22319 22320 22321 22322 22323 22324 22325 22326 22327 22328 22329 22330 22331 22332 22333 22334 22335 22336 | assert( id ); rc = fstat(((unixFile*)id)->h, &buf); SimulateIOError( rc=1 ); if( rc!=0 ){ return SQLITE_IOERR_FSTAT; } *pSize = buf.st_size; /* When opening a zero-size database, the findLockInfo() procedure ** writes a single byte into that file in order to work around a bug ** in the OS-X msdos filesystem. In order to avoid problems with upper ** layers, we need to report this file size as zero even though it is ** really 1. Ticket #3260. */ if( *pSize==1 ) *pSize = 0; return SQLITE_OK; } /* ** This routine checks if there is a RESERVED lock held on the specified ** file by this or any other process. If such a lock is held, return ** non-zero. If the file is unlocked or holds only SHARED locks, then |
︙ | ︙ | |||
21739 21740 21741 21742 21743 21744 21745 | pOpen->nLock--; assert( pOpen->nLock>=0 ); if( pOpen->nLock==0 && pOpen->nPending>0 ){ int i; for(i=0; i<pOpen->nPending; i++){ close(pOpen->aPending[i]); } | | | 22675 22676 22677 22678 22679 22680 22681 22682 22683 22684 22685 22686 22687 22688 22689 | pOpen->nLock--; assert( pOpen->nLock>=0 ); if( pOpen->nLock==0 && pOpen->nPending>0 ){ int i; for(i=0; i<pOpen->nPending; i++){ close(pOpen->aPending[i]); } sqlite3_free(pOpen->aPending); pOpen->nPending = 0; pOpen->aPending = 0; } } } leaveMutex(); if( rc==SQLITE_OK ) pFile->locktype = locktype; |
︙ | ︙ | |||
21788 21789 21790 21791 21792 21793 21794 | /* If there are outstanding locks, do not actually close the file just ** yet because that would clear those locks. Instead, add the file ** descriptor to pOpen->aPending. It will be automatically closed when ** the last lock is cleared. */ int *aNew; struct openCnt *pOpen = pFile->pOpen; | | | 22724 22725 22726 22727 22728 22729 22730 22731 22732 22733 22734 22735 22736 22737 22738 | /* If there are outstanding locks, do not actually close the file just ** yet because that would clear those locks. Instead, add the file ** descriptor to pOpen->aPending. It will be automatically closed when ** the last lock is cleared. */ int *aNew; struct openCnt *pOpen = pFile->pOpen; aNew = sqlite3_realloc(pOpen->aPending, (pOpen->nPending+1)*sizeof(int) ); if( aNew==0 ){ /* If a malloc fails, just leak the file descriptor */ }else{ pOpen->aPending = aNew; pOpen->aPending[pOpen->nPending] = pFile->h; pOpen->nPending++; pFile->h = -1; |
︙ | ︙ | |||
22285 22286 22287 22288 22289 22290 22291 | dotlockUnlock(id, NO_LOCK); sqlite3_free(pFile->lockingContext); } return closeUnixFile(id); } | | | 23221 23222 23223 23224 23225 23226 23227 23228 23229 23230 23231 23232 23233 23234 23235 | dotlockUnlock(id, NO_LOCK); sqlite3_free(pFile->lockingContext); } return closeUnixFile(id); } #endif /* SQLITE_ENABLE_LOCKING_STYLE */ /* ** The nolockLockingContext is void */ typedef void nolockLockingContext; static int nolockCheckReservedLock(sqlite3_file *id, int *pResOut) { |
︙ | ︙ | |||
22312 22313 22314 22315 22316 22317 22318 | /* ** Close a file. */ static int nolockClose(sqlite3_file *id) { return closeUnixFile(id); } | < < | 23248 23249 23250 23251 23252 23253 23254 23255 23256 23257 23258 23259 23260 23261 | /* ** Close a file. */ static int nolockClose(sqlite3_file *id) { return closeUnixFile(id); } /* ** Information and control of an open file handle. */ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ switch( op ){ case SQLITE_FCNTL_LOCKSTATE: { |
︙ | ︙ | |||
22362 22363 22364 22365 22366 22367 22368 | ** and assigned here also. */ static int fillInUnixFile( sqlite3_vfs *pVfs, /* Pointer to vfs object */ int h, /* Open file descriptor of file being opened */ int dirfd, /* Directory file descriptor */ sqlite3_file *pId, /* Write to the unixFile structure here */ | | > > > > > | 23296 23297 23298 23299 23300 23301 23302 23303 23304 23305 23306 23307 23308 23309 23310 23311 23312 23313 23314 23315 23316 | ** and assigned here also. */ static int fillInUnixFile( sqlite3_vfs *pVfs, /* Pointer to vfs object */ int h, /* Open file descriptor of file being opened */ int dirfd, /* Directory file descriptor */ sqlite3_file *pId, /* Write to the unixFile structure here */ const char *zFilename, /* Name of the file being opened */ int noLock /* Omit locking if true */ ){ int eLockingStyle; unixFile *pNew = (unixFile *)pId; int rc = SQLITE_OK; /* Macro to define the static contents of an sqlite3_io_methods ** structure for a unix backend file. Different locking methods ** require different functions for the xClose, xLock, xUnlock and ** xCheckReservedLock methods. */ #define IOMETHODS(xClose, xLock, xUnlock, xCheckReservedLock) { \ 1, /* iVersion */ \ |
︙ | ︙ | |||
22386 22387 22388 22389 22390 22391 22392 22393 | xCheckReservedLock, /* xCheckReservedLock */ \ unixFileControl, /* xFileControl */ \ unixSectorSize, /* xSectorSize */ \ unixDeviceCharacteristics /* xDeviceCapabilities */ \ } static sqlite3_io_methods aIoMethod[] = { IOMETHODS(unixClose, unixLock, unixUnlock, unixCheckReservedLock) #ifdef SQLITE_ENABLE_LOCKING_STYLE | > < | | | | | > > > > | < < | | | > | 23325 23326 23327 23328 23329 23330 23331 23332 23333 23334 23335 23336 23337 23338 23339 23340 23341 23342 23343 23344 23345 23346 23347 23348 23349 23350 23351 23352 23353 23354 23355 23356 23357 23358 23359 23360 23361 23362 23363 23364 23365 23366 23367 | xCheckReservedLock, /* xCheckReservedLock */ \ unixFileControl, /* xFileControl */ \ unixSectorSize, /* xSectorSize */ \ unixDeviceCharacteristics /* xDeviceCapabilities */ \ } static sqlite3_io_methods aIoMethod[] = { IOMETHODS(unixClose, unixLock, unixUnlock, unixCheckReservedLock) ,IOMETHODS(nolockClose, nolockLock, nolockUnlock, nolockCheckReservedLock) #ifdef SQLITE_ENABLE_LOCKING_STYLE ,IOMETHODS(dotlockClose, dotlockLock, dotlockUnlock,dotlockCheckReservedLock) ,IOMETHODS(flockClose, flockLock, flockUnlock, flockCheckReservedLock) ,IOMETHODS(afpClose, afpLock, afpUnlock, afpCheckReservedLock) #endif }; /* The order of the IOMETHODS macros above is important. It must be the ** same order as the LOCKING_STYLE numbers */ assert(LOCKING_STYLE_POSIX==1); assert(LOCKING_STYLE_NONE==2); assert(LOCKING_STYLE_DOTFILE==3); assert(LOCKING_STYLE_FLOCK==4); assert(LOCKING_STYLE_AFP==5); assert( pNew->pLock==NULL ); assert( pNew->pOpen==NULL ); OSTRACE3("OPEN %-3d %s\n", h, zFilename); pNew->h = h; pNew->dirfd = dirfd; SET_THREADID(pNew); if( noLock ){ eLockingStyle = LOCKING_STYLE_NONE; }else{ eLockingStyle = detectLockingStyle(pVfs, zFilename, h); } switch( eLockingStyle ){ case LOCKING_STYLE_POSIX: { enterMutex(); rc = findLockInfo(h, &pNew->pLock, &pNew->pOpen); leaveMutex(); |
︙ | ︙ | |||
22595 22596 22597 22598 22599 22600 22601 22602 22603 22604 22605 22606 22607 22608 | int flags, int *pOutFlags ){ int fd = 0; /* File descriptor returned by open() */ int dirfd = -1; /* Directory file descriptor */ int oflags = 0; /* Flags to pass to open() */ int eType = flags&0xFFFFFF00; /* Type of file to open */ int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE); int isDelete = (flags & SQLITE_OPEN_DELETEONCLOSE); int isCreate = (flags & SQLITE_OPEN_CREATE); int isReadonly = (flags & SQLITE_OPEN_READONLY); int isReadWrite = (flags & SQLITE_OPEN_READWRITE); | > | 23537 23538 23539 23540 23541 23542 23543 23544 23545 23546 23547 23548 23549 23550 23551 | int flags, int *pOutFlags ){ int fd = 0; /* File descriptor returned by open() */ int dirfd = -1; /* Directory file descriptor */ int oflags = 0; /* Flags to pass to open() */ int eType = flags&0xFFFFFF00; /* Type of file to open */ int noLock; /* True to omit locking primitives */ int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE); int isDelete = (flags & SQLITE_OPEN_DELETEONCLOSE); int isCreate = (flags & SQLITE_OPEN_CREATE); int isReadonly = (flags & SQLITE_OPEN_READONLY); int isReadWrite = (flags & SQLITE_OPEN_READWRITE); |
︙ | ︙ | |||
22690 22691 22692 22693 22694 22695 22696 | } } #ifdef FD_CLOEXEC fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC); #endif | > | | 23633 23634 23635 23636 23637 23638 23639 23640 23641 23642 23643 23644 23645 23646 23647 23648 | } } #ifdef FD_CLOEXEC fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC); #endif noLock = eType!=SQLITE_OPEN_MAIN_DB; return fillInUnixFile(pVfs, fd, dirfd, pFile, zPath, noLock); } /* ** Delete the file at zPath. If the dirSync argument is true, fsync() ** the directory after deleting the file. */ static int unixDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ |
︙ | ︙ | |||
23024 23025 23026 23027 23028 23029 23030 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains code that is specific to windows. ** | | | 23968 23969 23970 23971 23972 23973 23974 23975 23976 23977 23978 23979 23980 23981 23982 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains code that is specific to windows. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #if SQLITE_OS_WIN /* This file is used for windows only */ /* ** A Note About Memory Allocation: ** |
︙ | ︙ | |||
23092 23093 23094 23095 23096 23097 23098 | ** This file contains macros and a little bit of code that is common to ** all of the platform-specific files (os_*.c) and is #included into those ** files. ** ** This file should be #included by the os_*.c files only. It is not a ** general purpose header file. ** | | | 24036 24037 24038 24039 24040 24041 24042 24043 24044 24045 24046 24047 24048 24049 24050 | ** This file contains macros and a little bit of code that is common to ** all of the platform-specific files (os_*.c) and is #included into those ** files. ** ** This file should be #included by the os_*.c files only. It is not a ** general purpose header file. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _OS_COMMON_H_ #define _OS_COMMON_H_ /* ** At least two bugs have slipped in because we changed the MEMORY_DEBUG ** macro to SQLITE_DEBUG and some older makefiles have not yet made the |
︙ | ︙ | |||
23163 23164 23165 23166 23167 23168 23169 | ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains inline asm code for retrieving "high-performance" ** counters for x86 class CPUs. ** | | | 24107 24108 24109 24110 24111 24112 24113 24114 24115 24116 24117 24118 24119 24120 24121 | ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains inline asm code for retrieving "high-performance" ** counters for x86 class CPUs. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _HWTIME_H_ #define _HWTIME_H_ /* ** The following routine only works on pentium-class (or newer) processors. ** It uses the RDTSC opcode to read the cycle count value out of the |
︙ | ︙ | |||
23204 23205 23206 23207 23208 23209 23210 23211 23212 23213 23214 23215 23216 23217 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long val; __asm__ __volatile__ ("rdtsc" : "=A" (val)); return val; } #else #error Need implementation of sqlite3Hwtime() for your platform. /* ** To compile without implementing sqlite3Hwtime() for your platform, ** you can remove the above #error and use the following | > > > > > > > > > > > > > > > | 24148 24149 24150 24151 24152 24153 24154 24155 24156 24157 24158 24159 24160 24161 24162 24163 24164 24165 24166 24167 24168 24169 24170 24171 24172 24173 24174 24175 24176 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long val; __asm__ __volatile__ ("rdtsc" : "=A" (val)); return val; } #elif (defined(__GNUC__) && defined(__ppc__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long long retval; unsigned long junk; __asm__ __volatile__ ("\n\ 1: mftbu %1\n\ mftb %L0\n\ mftbu %0\n\ cmpw %0,%1\n\ bne 1b" : "=r" (retval), "=r" (junk)); return retval; } #else #error Need implementation of sqlite3Hwtime() for your platform. /* ** To compile without implementing sqlite3Hwtime() for your platform, ** you can remove the above #error and use the following |
︙ | ︙ | |||
24310 24311 24312 24313 24314 24315 24316 | ** hold at pVfs->mxPathname characters. */ static int getTempname(int nBuf, char *zBuf){ static char zChars[] = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789"; | | | 25269 25270 25271 25272 25273 25274 25275 25276 25277 25278 25279 25280 25281 25282 25283 | ** hold at pVfs->mxPathname characters. */ static int getTempname(int nBuf, char *zBuf){ static char zChars[] = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789"; size_t i, j; char zTempPath[MAX_PATH+1]; if( sqlite3_temp_directory ){ sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory); }else if( isNT() ){ char *zMulti; WCHAR zWidePath[MAX_PATH]; GetTempPathW(MAX_PATH-30, zWidePath); |
︙ | ︙ | |||
24350 24351 24352 24353 24354 24355 24356 24357 24358 24359 24360 24361 24362 24363 | for(i=0; i<20; i++, j++){ zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; } zBuf[j] = 0; OSTRACE2("TEMP FILENAME: %s\n", zBuf); return SQLITE_OK; } /* ** Open a file. */ static int winOpen( sqlite3_vfs *pVfs, /* Not used */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 25309 25310 25311 25312 25313 25314 25315 25316 25317 25318 25319 25320 25321 25322 25323 25324 25325 25326 25327 25328 25329 25330 25331 25332 25333 25334 25335 25336 25337 25338 25339 25340 25341 25342 25343 25344 25345 25346 25347 25348 25349 25350 25351 25352 | for(i=0; i<20; i++, j++){ zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; } zBuf[j] = 0; OSTRACE2("TEMP FILENAME: %s\n", zBuf); return SQLITE_OK; } /* ** The return value of getLastErrorMsg ** is zero if the error message fits in the buffer, or non-zero ** otherwise (if the message was truncated). */ static int getLastErrorMsg(int nBuf, char *zBuf){ DWORD error = GetLastError(); #if SQLITE_OS_WINCE sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error); #else /* FormatMessage returns 0 on failure. Otherwise it ** returns the number of TCHARs written to the output ** buffer, excluding the terminating null char. */ if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, zBuf, nBuf-1, 0)) { sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error); } #endif return 0; } /* ** Open a file. */ static int winOpen( sqlite3_vfs *pVfs, /* Not used */ |
︙ | ︙ | |||
24431 24432 24433 24434 24435 24436 24437 | dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL ); }else{ | < < < < | 25420 25421 25422 25423 25424 25425 25426 25427 25428 25429 25430 25431 25432 25433 25434 25435 25436 25437 25438 25439 25440 25441 | dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL ); }else{ h = CreateFileA((char*)zConverted, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL ); } if( h==INVALID_HANDLE_VALUE ){ free(zConverted); if( flags & SQLITE_OPEN_READWRITE ){ return winOpen(0, zName, id, ((flags|SQLITE_OPEN_READONLY)&~SQLITE_OPEN_READWRITE), pOutFlags); }else{ |
︙ | ︙ | |||
24489 24490 24491 24492 24493 24494 24495 | /* ** Delete the named file. ** ** Note that windows does not allow a file to be deleted if some other ** process has it open. Sometimes a virus scanner or indexing program ** will open a journal file shortly after it is created in order to do | | > | > | > < < < | > | | > | < < < < | | 25474 25475 25476 25477 25478 25479 25480 25481 25482 25483 25484 25485 25486 25487 25488 25489 25490 25491 25492 25493 25494 25495 25496 25497 25498 25499 25500 25501 25502 25503 25504 25505 25506 25507 25508 25509 25510 25511 25512 25513 25514 25515 25516 25517 25518 25519 25520 25521 25522 25523 25524 25525 25526 25527 25528 25529 25530 25531 25532 25533 25534 25535 25536 25537 25538 25539 25540 25541 25542 25543 25544 25545 25546 25547 25548 25549 25550 25551 25552 25553 | /* ** Delete the named file. ** ** Note that windows does not allow a file to be deleted if some other ** process has it open. Sometimes a virus scanner or indexing program ** will open a journal file shortly after it is created in order to do ** whatever it does. While this other process is holding the ** file open, we will be unable to delete it. To work around this ** problem, we delay 100 milliseconds and try to delete again. Up ** to MX_DELETION_ATTEMPTs deletion attempts are run before giving ** up and returning an error. */ #define MX_DELETION_ATTEMPTS 5 static int winDelete( sqlite3_vfs *pVfs, /* Not used on win32 */ const char *zFilename, /* Name of file to delete */ int syncDir /* Not used on win32 */ ){ int cnt = 0; int rc; DWORD error; void *zConverted = convertUtf8Filename(zFilename); if( zConverted==0 ){ return SQLITE_NOMEM; } SimulateIOError(return SQLITE_IOERR_DELETE); if( isNT() ){ do{ DeleteFileW(zConverted); }while( ( ((rc = GetFileAttributesW(zConverted)) != INVALID_FILE_ATTRIBUTES) || ((error = GetLastError()) == ERROR_ACCESS_DENIED)) && (cnt++ < MX_DELETION_ATTEMPTS) && (Sleep(100), 1) ); }else{ do{ DeleteFileA(zConverted); }while( ( ((rc = GetFileAttributesA(zConverted)) != INVALID_FILE_ATTRIBUTES) || ((error = GetLastError()) == ERROR_ACCESS_DENIED)) && (cnt++ < MX_DELETION_ATTEMPTS) && (Sleep(100), 1) ); } free(zConverted); OSTRACE2("DELETE \"%s\"\n", zFilename); return ( (rc==INVALID_FILE_ATTRIBUTES) && (error == ERROR_FILE_NOT_FOUND)) ? SQLITE_OK : SQLITE_IOERR_DELETE; } /* ** Check the existance and status of a file. */ static int winAccess( sqlite3_vfs *pVfs, /* Not used on win32 */ const char *zFilename, /* Name of file to check */ int flags, /* Type of test to make on this file */ int *pResOut /* OUT: Result */ ){ DWORD attr; int rc; void *zConverted = convertUtf8Filename(zFilename); if( zConverted==0 ){ return SQLITE_NOMEM; } if( isNT() ){ attr = GetFileAttributesW((WCHAR*)zConverted); }else{ attr = GetFileAttributesA((char*)zConverted); } free(zConverted); switch( flags ){ case SQLITE_ACCESS_READ: case SQLITE_ACCESS_EXISTS: rc = attr!=INVALID_FILE_ATTRIBUTES; break; case SQLITE_ACCESS_READWRITE: rc = (attr & FILE_ATTRIBUTE_READONLY)==0; break; default: assert(!"Invalid flags argument"); } |
︙ | ︙ | |||
24650 24651 24652 24653 24654 24655 24656 | void *zConverted = convertUtf8Filename(zFilename); if( zConverted==0 ){ return 0; } if( isNT() ){ h = LoadLibraryW((WCHAR*)zConverted); }else{ | < < < < < < < < < < < < < < < | < < < < < < | 25633 25634 25635 25636 25637 25638 25639 25640 25641 25642 25643 25644 25645 25646 25647 25648 25649 25650 25651 25652 25653 | void *zConverted = convertUtf8Filename(zFilename); if( zConverted==0 ){ return 0; } if( isNT() ){ h = LoadLibraryW((WCHAR*)zConverted); }else{ h = LoadLibraryA((char*)zConverted); } free(zConverted); return (void*)h; } static void winDlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){ getLastErrorMsg(nBuf, zBufOut); } void *winDlSym(sqlite3_vfs *pVfs, void *pHandle, const char *zSymbol){ #if SQLITE_OS_WINCE /* The GetProcAddressA() routine is only available on wince. */ return GetProcAddressA((HANDLE)pHandle, zSymbol); #else /* All other windows platforms expect GetProcAddress() to take |
︙ | ︙ | |||
24761 24762 24763 24764 24765 24766 24767 | /* FILETIME structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). */ double now; #if SQLITE_OS_WINCE SYSTEMTIME time; GetSystemTime(&time); | > | > > > > > > > > > > > > > > > > > > > > > > > | > | > > > > > > > > | 25723 25724 25725 25726 25727 25728 25729 25730 25731 25732 25733 25734 25735 25736 25737 25738 25739 25740 25741 25742 25743 25744 25745 25746 25747 25748 25749 25750 25751 25752 25753 25754 25755 25756 25757 25758 25759 25760 25761 25762 25763 25764 25765 25766 25767 25768 25769 25770 25771 25772 25773 25774 25775 25776 25777 25778 25779 25780 25781 25782 25783 25784 25785 | /* FILETIME structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). */ double now; #if SQLITE_OS_WINCE SYSTEMTIME time; GetSystemTime(&time); /* if SystemTimeToFileTime() fails, it returns zero. */ if (!SystemTimeToFileTime(&time,&ft)){ return 1; } #else GetSystemTimeAsFileTime( &ft ); #endif now = ((double)ft.dwHighDateTime) * 4294967296.0; *prNow = (now + ft.dwLowDateTime)/864000000000.0 + 2305813.5; #ifdef SQLITE_TEST if( sqlite3_current_time ){ *prNow = sqlite3_current_time/86400.0 + 2440587.5; } #endif return 0; } /* ** The idea is that this function works like a combination of ** GetLastError() and FormatMessage() on windows (or errno and ** strerror_r() on unix). After an error is returned by an OS ** function, SQLite calls this function with zBuf pointing to ** a buffer of nBuf bytes. The OS layer should populate the ** buffer with a nul-terminated UTF-8 encoded error message ** describing the last IO error to have occured within the calling ** thread. ** ** If the error message is too large for the supplied buffer, ** it should be truncated. The return value of xGetLastError ** is zero if the error message fits in the buffer, or non-zero ** otherwise (if the message was truncated). If non-zero is returned, ** then it is not necessary to include the nul-terminator character ** in the output buffer. ** ** Not supplying an error message will have no adverse effect ** on SQLite. It is fine to have an implementation that never ** returns an error message: ** ** int xGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){ ** assert(zBuf[0]=='\0'); ** return 0; ** } ** ** However if an error message is supplied, it will be incorporated ** by sqlite into the error message available to the user using ** sqlite3_errmsg(), possibly making IO errors easier to debug. */ static int winGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){ return getLastErrorMsg(nBuf, zBuf); } /* ** Initialize and deinitialize the operating system interface. */ SQLITE_API int sqlite3_os_init(void){ static sqlite3_vfs winVfs = { |
︙ | ︙ | |||
24849 24850 24851 24852 24853 24854 24855 | ** Clear operations are exceedingly rare. There are usually between ** 5 and 500 set operations per Bitvec object, though the number of sets can ** sometimes grow into tens of thousands or larger. The size of the ** Bitvec object is the number of pages in the database file at the ** start of a transaction, and is thus usually less than a few thousand, ** but can be as large as 2 billion for a really big database. ** | | | 25844 25845 25846 25847 25848 25849 25850 25851 25852 25853 25854 25855 25856 25857 25858 | ** Clear operations are exceedingly rare. There are usually between ** 5 and 500 set operations per Bitvec object, though the number of sets can ** sometimes grow into tens of thousands or larger. The size of the ** Bitvec object is the number of pages in the database file at the ** start of a transaction, and is thus usually less than a few thousand, ** but can be as large as 2 billion for a really big database. ** ** @(#) $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #define BITVEC_SZ 512 /* Round the union size down to the nearest pointer boundary, since that's how ** it will be aligned within the Bitvec struct. */ #define BITVEC_USIZE (((BITVEC_SZ-12)/sizeof(Bitvec*))*sizeof(Bitvec*)) #define BITVEC_NCHAR BITVEC_USIZE |
︙ | ︙ | |||
25162 25163 25164 25165 25166 25167 25168 | ** The pager is used to access a database disk file. It implements ** atomic commit and rollback through the use of a journal file that ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** | | | 26157 26158 26159 26160 26161 26162 26163 26164 26165 26166 26167 26168 26169 26170 26171 | ** The pager is used to access a database disk file. It implements ** atomic commit and rollback through the use of a journal file that ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** ** @(#) $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef SQLITE_OMIT_DISKIO /* ** Macros for troubleshooting. Normally turned off */ #if 0 |
︙ | ︙ | |||
26037 26038 26039 26040 26041 26042 26043 | ** SQLITE_OK returned. */ static int readMasterJournal(sqlite3_file *pJrnl, char *zMaster, int nMaster){ int rc; u32 len; i64 szJ; u32 cksum; | | | 27032 27033 27034 27035 27036 27037 27038 27039 27040 27041 27042 27043 27044 27045 27046 | ** SQLITE_OK returned. */ static int readMasterJournal(sqlite3_file *pJrnl, char *zMaster, int nMaster){ int rc; u32 len; i64 szJ; u32 cksum; u32 u; /* Unsigned loop counter */ unsigned char aMagic[8]; /* A buffer to hold the magic header */ zMaster[0] = '\0'; rc = sqlite3OsFileSize(pJrnl, &szJ); if( rc!=SQLITE_OK || szJ<16 ) return rc; |
︙ | ︙ | |||
26065 26066 26067 26068 26069 26070 26071 | rc = sqlite3OsRead(pJrnl, zMaster, len, szJ-16-len); if( rc!=SQLITE_OK ){ return rc; } zMaster[len] = '\0'; /* See if the checksum matches the master journal name */ | | | | 27060 27061 27062 27063 27064 27065 27066 27067 27068 27069 27070 27071 27072 27073 27074 27075 | rc = sqlite3OsRead(pJrnl, zMaster, len, szJ-16-len); if( rc!=SQLITE_OK ){ return rc; } zMaster[len] = '\0'; /* See if the checksum matches the master journal name */ for(u=0; u<len; u++){ cksum -= zMaster[u]; } if( cksum ){ /* If the checksum doesn't add up, then one or more of the disk sectors ** containing the master journal filename is corrupted. This means ** definitely roll back, so just return SQLITE_OK and report a (nul) ** master-journal filename. */ |
︙ | ︙ | |||
26989 26990 26991 26992 26993 26994 26995 | ** If an I/O or malloc() error occurs, the journal-file is not deleted ** and an error code is returned. */ static int pager_playback(Pager *pPager, int isHot){ sqlite3_vfs *pVfs = pPager->pVfs; i64 szJ; /* Size of the journal file in bytes */ u32 nRec; /* Number of Records in the journal */ | | | 27984 27985 27986 27987 27988 27989 27990 27991 27992 27993 27994 27995 27996 27997 27998 | ** If an I/O or malloc() error occurs, the journal-file is not deleted ** and an error code is returned. */ static int pager_playback(Pager *pPager, int isHot){ sqlite3_vfs *pVfs = pPager->pVfs; i64 szJ; /* Size of the journal file in bytes */ u32 nRec; /* Number of Records in the journal */ u32 u; /* Unsigned loop counter */ Pgno mxPg = 0; /* Size of the original file in pages */ int rc; /* Result code of a subroutine */ int res = 1; /* Value returned by sqlite3OsAccess() */ char *zMaster = 0; /* Name of master journal file if any */ /* Figure out how many records are in the journal. Abort early if ** the journal is empty. |
︙ | ︙ | |||
27072 27073 27074 27075 27076 27077 27078 | if( rc!=SQLITE_OK ){ goto end_playback; } } /* Copy original pages out of the journal and back into the database file. */ | | | 28067 28068 28069 28070 28071 28072 28073 28074 28075 28076 28077 28078 28079 28080 28081 | if( rc!=SQLITE_OK ){ goto end_playback; } } /* Copy original pages out of the journal and back into the database file. */ for(u=0; u<nRec; u++){ rc = pager_playback_one_page(pPager, pPager->jfd, pPager->journalOff, 1); if( rc!=SQLITE_OK ){ if( rc==SQLITE_DONE ){ rc = SQLITE_OK; pPager->journalOff = szJ; break; }else{ |
︙ | ︙ | |||
28285 28286 28287 28288 28289 28290 28291 | ** journal file that has been deleted, and hence not be hot. Or ** the header of the journal might be zeroed out. This routine ** does not discover these cases of a non-hot journal - if the ** journal file exists and is not empty this routine assumes it ** is hot. The pager_playback() routine will discover that the ** journal file is not really hot and will no-op. */ | | > | < | > | > | | | | < | | 29280 29281 29282 29283 29284 29285 29286 29287 29288 29289 29290 29291 29292 29293 29294 29295 29296 29297 29298 29299 29300 29301 29302 29303 29304 29305 29306 29307 29308 29309 29310 29311 29312 29313 29314 29315 29316 29317 29318 29319 29320 | ** journal file that has been deleted, and hence not be hot. Or ** the header of the journal might be zeroed out. This routine ** does not discover these cases of a non-hot journal - if the ** journal file exists and is not empty this routine assumes it ** is hot. The pager_playback() routine will discover that the ** journal file is not really hot and will no-op. */ static int hasHotJournal(Pager *pPager, int *pExists){ sqlite3_vfs *pVfs = pPager->pVfs; int rc = SQLITE_OK; *pExists = 0; if( pPager->useJournal && pPager->fd->pMethods ){ int exists; int locked; rc = sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &exists); if( rc==SQLITE_OK && exists ){ rc = sqlite3OsCheckReservedLock(pPager->fd, &locked); } if( rc==SQLITE_OK && exists && !locked ){ int nPage; rc = sqlite3PagerPagecount(pPager, &nPage); if( rc==SQLITE_OK ){ if( nPage==0 ){ sqlite3OsDelete(pVfs, pPager->zJournal, 0); }else{ *pExists = 1; } } } } return rc; } /* ** Try to find a page in the cache that can be recycled. ** ** This routine may return SQLITE_IOERR, SQLITE_FULL or SQLITE_OK. It ** does not set the pPager->errCode variable. |
︙ | ︙ | |||
28576 28577 28578 28579 28580 28581 28582 | ** ** Immediately after obtaining the shared lock (if required), this function ** checks for a hot-journal file. If one is found, an emergency rollback ** is performed immediately. */ static int pagerSharedLock(Pager *pPager){ int rc = SQLITE_OK; | | | | > > | | < | | > | | 29572 29573 29574 29575 29576 29577 29578 29579 29580 29581 29582 29583 29584 29585 29586 29587 29588 29589 29590 29591 29592 29593 29594 29595 29596 29597 29598 29599 29600 29601 29602 29603 29604 29605 29606 29607 29608 29609 29610 29611 29612 29613 29614 29615 29616 29617 29618 29619 29620 29621 29622 29623 29624 29625 29626 29627 29628 29629 29630 29631 29632 | ** ** Immediately after obtaining the shared lock (if required), this function ** checks for a hot-journal file. If one is found, an emergency rollback ** is performed immediately. */ static int pagerSharedLock(Pager *pPager){ int rc = SQLITE_OK; int isErrorReset = 0; /* If this database is opened for exclusive access, has no outstanding ** page references and is in an error-state, now is the chance to clear ** the error. Discard the contents of the pager-cache and treat any ** open journal file as a hot-journal. */ if( !MEMDB && pPager->exclusiveMode && pPager->nRef==0 && pPager->errCode ){ if( pPager->journalOpen ){ isErrorReset = 1; } pPager->errCode = SQLITE_OK; pager_reset(pPager); } /* If the pager is still in an error state, do not proceed. The error ** state will be cleared at some point in the future when all page ** references are dropped and the cache can be discarded. */ if( pPager->errCode && pPager->errCode!=SQLITE_FULL ){ return pPager->errCode; } if( pPager->state==PAGER_UNLOCK || isErrorReset ){ sqlite3_vfs *pVfs = pPager->pVfs; if( !MEMDB ){ int isHotJournal; assert( pPager->nRef==0 ); if( !pPager->noReadlock ){ rc = pager_wait_on_lock(pPager, SHARED_LOCK); if( rc!=SQLITE_OK ){ assert( pPager->state==PAGER_UNLOCK ); return pager_error(pPager, rc); } assert( pPager->state>=SHARED_LOCK ); } /* If a journal file exists, and there is no RESERVED lock on the ** database file, then it either needs to be played back or deleted. */ if( !isErrorReset ){ rc = hasHotJournal(pPager, &isHotJournal); if( rc!=SQLITE_OK ){ goto failed; } } if( isErrorReset || isHotJournal ){ /* Get an EXCLUSIVE lock on the database file. At this point it is ** important that a RESERVED lock is not obtained on the way to the ** EXCLUSIVE lock. If it were, another process might open the ** database file, detect the RESERVED lock, and conclude that the ** database is safe to read while this process is still rolling it ** back. ** |
︙ | ︙ | |||
28647 28648 28649 28650 28651 28652 28653 | /* Open the journal for read/write access. This is because in ** exclusive-access mode the file descriptor will be kept open and ** possibly used for a transaction later on. On some systems, the ** OsTruncate() call used in exclusive-access mode also requires ** a read/write file handle. */ | | | 29645 29646 29647 29648 29649 29650 29651 29652 29653 29654 29655 29656 29657 29658 29659 | /* Open the journal for read/write access. This is because in ** exclusive-access mode the file descriptor will be kept open and ** possibly used for a transaction later on. On some systems, the ** OsTruncate() call used in exclusive-access mode also requires ** a read/write file handle. */ if( !isErrorReset && pPager->journalOpen==0 ){ int res; rc = sqlite3OsAccess(pVfs,pPager->zJournal,SQLITE_ACCESS_EXISTS,&res); if( rc==SQLITE_OK ){ if( res ){ int fout = 0; int f = SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_JOURNAL; assert( !pPager->tempFile ); |
︙ | ︙ | |||
29718 29719 29720 29721 29722 29723 29724 29725 29726 29727 29728 29729 29730 29731 29732 29733 29734 29735 29736 29737 29738 29739 29740 29741 29742 29743 29744 29745 29746 29747 29748 29749 29750 29751 29752 29753 | ** stored at byte 24 of the pager file. */ static int pager_incr_changecounter(Pager *pPager, int isDirect){ PgHdr *pPgHdr; u32 change_counter; int rc = SQLITE_OK; if( !pPager->changeCountDone ){ /* Open page 1 of the file for writing. */ rc = sqlite3PagerGet(pPager, 1, &pPgHdr); if( rc!=SQLITE_OK ) return rc; if( !isDirect ){ rc = sqlite3PagerWrite(pPgHdr); if( rc!=SQLITE_OK ){ sqlite3PagerUnref(pPgHdr); return rc; } } /* Increment the value just read and write it back to byte 24. */ change_counter = sqlite3Get4byte((u8*)pPager->dbFileVers); change_counter++; put32bits(((char*)PGHDR_TO_DATA(pPgHdr))+24, change_counter); if( isDirect && pPager->fd->pMethods ){ const void *zBuf = PGHDR_TO_DATA(pPgHdr); rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0); } /* Release the page reference. */ sqlite3PagerUnref(pPgHdr); pPager->changeCountDone = 1; } return rc; } | > > > > > | 30716 30717 30718 30719 30720 30721 30722 30723 30724 30725 30726 30727 30728 30729 30730 30731 30732 30733 30734 30735 30736 30737 30738 30739 30740 30741 30742 30743 30744 30745 30746 30747 30748 30749 30750 30751 30752 30753 30754 30755 30756 | ** stored at byte 24 of the pager file. */ static int pager_incr_changecounter(Pager *pPager, int isDirect){ PgHdr *pPgHdr; u32 change_counter; int rc = SQLITE_OK; #ifndef SQLITE_ENABLE_ATOMIC_WRITE assert( isDirect==0 ); /* isDirect is only true for atomic writes */ #endif if( !pPager->changeCountDone ){ /* Open page 1 of the file for writing. */ rc = sqlite3PagerGet(pPager, 1, &pPgHdr); if( rc!=SQLITE_OK ) return rc; if( !isDirect ){ rc = sqlite3PagerWrite(pPgHdr); if( rc!=SQLITE_OK ){ sqlite3PagerUnref(pPgHdr); return rc; } } /* Increment the value just read and write it back to byte 24. */ change_counter = sqlite3Get4byte((u8*)pPager->dbFileVers); change_counter++; put32bits(((char*)PGHDR_TO_DATA(pPgHdr))+24, change_counter); #ifdef SQLITE_ENABLE_ATOMIC_WRITE if( isDirect && pPager->fd->pMethods ){ const void *zBuf = PGHDR_TO_DATA(pPgHdr); rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0); } #endif /* Release the page reference. */ sqlite3PagerUnref(pPgHdr); pPager->changeCountDone = 1; } return rc; } |
︙ | ︙ | |||
30325 30326 30327 30328 30329 30330 30331 30332 | ** meta-data associated with pPg (i.e. data stored in the nExtra bytes ** allocated along with the page) is the responsibility of the caller. ** ** A transaction must be active when this routine is called. It used to be ** required that a statement transaction was not active, but this restriction ** has been removed (CREATE INDEX needs to move a page when a statement ** transaction is active). */ | > > > > > | > > > > > > > > | | 31328 31329 31330 31331 31332 31333 31334 31335 31336 31337 31338 31339 31340 31341 31342 31343 31344 31345 31346 31347 31348 31349 31350 31351 31352 31353 31354 31355 31356 31357 31358 31359 31360 31361 31362 31363 31364 31365 31366 31367 31368 31369 | ** meta-data associated with pPg (i.e. data stored in the nExtra bytes ** allocated along with the page) is the responsibility of the caller. ** ** A transaction must be active when this routine is called. It used to be ** required that a statement transaction was not active, but this restriction ** has been removed (CREATE INDEX needs to move a page when a statement ** transaction is active). ** ** If the fourth argument, isCommit, is non-zero, then this page is being ** moved as part of a database reorganization just before the transaction ** is being committed. In this case, it is guaranteed that the database page ** pPg refers to will not be written to again within this transaction. */ SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){ PgHdr *pPgOld; /* The page being overwritten. */ int h; Pgno needSyncPgno = 0; pagerEnter(pPager); assert( pPg->nRef>0 ); PAGERTRACE5("MOVE %d page %d (needSync=%d) moves to %d\n", PAGERID(pPager), pPg->pgno, pPg->needSync, pgno); IOTRACE(("MOVE %p %d %d\n", pPager, pPg->pgno, pgno)) pager_get_content(pPg); /* If the journal needs to be sync()ed before page pPg->pgno can ** be written to, store pPg->pgno in local variable needSyncPgno. ** ** If the isCommit flag is set, there is no need to remember that ** the journal needs to be sync()ed before database page pPg->pgno ** can be written to. The caller has already promised not to write to it. */ if( pPg->needSync && !isCommit ){ needSyncPgno = pPg->pgno; assert( pPg->inJournal || (int)pgno>pPager->origDbSize ); assert( pPg->dirty ); assert( pPager->needSync ); } /* Unlink pPg from its hash-chain */ |
︙ | ︙ | |||
30386 30387 30388 30389 30390 30391 30392 | pPager->dirtyCache = 1; pPager->dbModified = 1; if( needSyncPgno ){ /* If needSyncPgno is non-zero, then the journal file needs to be ** sync()ed before any data is written to database file page needSyncPgno. ** Currently, no such page exists in the page-cache and the | | | > | 31402 31403 31404 31405 31406 31407 31408 31409 31410 31411 31412 31413 31414 31415 31416 31417 31418 | pPager->dirtyCache = 1; pPager->dbModified = 1; if( needSyncPgno ){ /* If needSyncPgno is non-zero, then the journal file needs to be ** sync()ed before any data is written to database file page needSyncPgno. ** Currently, no such page exists in the page-cache and the ** "is journaled" bitvec flag has been set. This needs to be remedied by ** loading the page into the pager-cache and setting the PgHdr.needSync ** flag. ** ** If the attempt to load the page into the page-cache fails, (due ** to a malloc() or IO failure), clear the bit in the pInJournal[] ** array. Otherwise, if the page is loaded and written again in ** this transaction, it may be written to the database file before ** it is synced into the journal file. This way, it may end up in ** the journal file twice, but that is not a problem. |
︙ | ︙ | |||
30509 30510 30511 30512 30513 30514 30515 | ** ** 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. ** ************************************************************************* ** | | | | 31526 31527 31528 31529 31530 31531 31532 31533 31534 31535 31536 31537 31538 31539 31540 31541 31542 31543 31544 31545 31546 31547 31548 31549 31550 31551 31552 31553 31554 31555 31556 31557 31558 31559 31560 | ** ** 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. ** ************************************************************************* ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ ** ** This file contains code used to implement mutexes on Btree objects. ** This code really belongs in btree.c. But btree.c is getting too ** big and we want to break it down some. This packaged seemed like ** a good breakout. */ /************** Include btreeInt.h in the middle of btmutex.c ****************/ /************** Begin file btreeInt.h ****************************************/ /* ** 2004 April 6 ** ** 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. ** ************************************************************************* ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** For a detailed discussion of BTrees, refer to ** ** Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3: ** "Sorting And Searching", pages 473-480. Addison-Wesley ** Publishing Company, Reading, Massachusetts. |
︙ | ︙ | |||
30790 30791 30792 30793 30794 30795 30796 | */ struct MemPage { u8 isInit; /* True if previously initialized. MUST BE FIRST! */ u8 idxShift; /* True if Cell indices have changed */ u8 nOverflow; /* Number of overflow cell bodies in aCell[] */ u8 intKey; /* True if intkey flag is set */ u8 leaf; /* True if leaf flag is set */ | < < > | 31807 31808 31809 31810 31811 31812 31813 31814 31815 31816 31817 31818 31819 31820 31821 31822 31823 31824 31825 31826 31827 31828 31829 31830 | */ struct MemPage { u8 isInit; /* True if previously initialized. MUST BE FIRST! */ u8 idxShift; /* True if Cell indices have changed */ u8 nOverflow; /* Number of overflow cell bodies in aCell[] */ u8 intKey; /* True if intkey flag is set */ u8 leaf; /* True if leaf flag is set */ u8 hasData; /* True if this page stores data */ u8 hdrOffset; /* 100 for page 1. 0 otherwise */ u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */ u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */ u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */ u16 cellOffset; /* Index in aData of first cell pointer */ u16 idxParent; /* Index in parent of this node */ u16 nFree; /* Number of free bytes on the page */ u16 nCell; /* Number of cells on this page, local and ovfl */ u16 maskPage; /* Mask for page offset */ struct _OvflCell { /* Cells that will not fit on aData[] */ u8 *pCell; /* Pointers to the body of the overflow cell */ u16 idx; /* Insert this cell before idx-th non-overflow cell */ } aOvfl[5]; BtShared *pBt; /* Pointer to BtShared that this page is part of */ u8 *aData; /* Pointer to disk image of the page data */ DbPage *pDbPage; /* Pager page handle */ |
︙ | ︙ | |||
31043 31044 31045 31046 31047 31048 31049 | ** ** If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page, ** then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be ** used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements ** this test. */ #define PTRMAP_PAGENO(pBt, pgno) ptrmapPageno(pBt, pgno) | | | 32059 32060 32061 32062 32063 32064 32065 32066 32067 32068 32069 32070 32071 32072 32073 | ** ** If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page, ** then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be ** used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements ** this test. */ #define PTRMAP_PAGENO(pBt, pgno) ptrmapPageno(pBt, pgno) #define PTRMAP_PTROFFSET(pgptrmap, pgno) (5*(pgno-pgptrmap-1)) #define PTRMAP_ISPAGE(pBt, pgno) (PTRMAP_PAGENO((pBt),(pgno))==(pgno)) /* ** The pointer map is a lookup table that identifies the parent page for ** each child page in the database file. The parent page is the page that ** contains a pointer to the child. Every page in the database contains ** 0 or 1 parent pages. (In this context 'database page' refers |
︙ | ︙ | |||
31117 31118 31119 31120 31121 31122 31123 31124 31125 31126 31127 31128 31129 31130 | struct IntegrityCk { BtShared *pBt; /* The tree being checked out */ Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */ int nPage; /* Number of pages in the database */ int *anRef; /* Number of times each page is referenced */ int mxErr; /* Stop accumulating errors when this reaches zero */ int nErr; /* Number of messages written to zErrMsg so far */ StrAccum errMsg; /* Accumulate the error message text here */ }; /* ** Read or write a two- and four-byte big-endian integer values. */ #define get2byte(x) ((x)[0]<<8 | (x)[1]) | > | 32133 32134 32135 32136 32137 32138 32139 32140 32141 32142 32143 32144 32145 32146 32147 | struct IntegrityCk { BtShared *pBt; /* The tree being checked out */ Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */ int nPage; /* Number of pages in the database */ int *anRef; /* Number of times each page is referenced */ int mxErr; /* Stop accumulating errors when this reaches zero */ int nErr; /* Number of messages written to zErrMsg so far */ int mallocFailed; /* A memory allocation error has occurred */ StrAccum errMsg; /* Accumulate the error message text here */ }; /* ** Read or write a two- and four-byte big-endian integer values. */ #define get2byte(x) ((x)[0]<<8 | (x)[1]) |
︙ | ︙ | |||
31454 31455 31456 31457 31458 31459 31460 | ** 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. ** ************************************************************************* | | | 32471 32472 32473 32474 32475 32476 32477 32478 32479 32480 32481 32482 32483 32484 32485 | ** 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. ** ************************************************************************* ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** See the header comment on "btreeInt.h" for additional information. ** Including a description of file format and an overview of operation. */ /* |
︙ | ︙ | |||
31902 31903 31904 31905 31906 31907 31908 | return SQLITE_CORRUPT_BKPT; } iPtrmap = PTRMAP_PAGENO(pBt, key); rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage); if( rc!=SQLITE_OK ){ return rc; } | | | 32919 32920 32921 32922 32923 32924 32925 32926 32927 32928 32929 32930 32931 32932 32933 | return SQLITE_CORRUPT_BKPT; } iPtrmap = PTRMAP_PAGENO(pBt, key); rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage); if( rc!=SQLITE_OK ){ return rc; } offset = PTRMAP_PTROFFSET(iPtrmap, key); pPtrmap = (u8 *)sqlite3PagerGetData(pDbPage); if( eType!=pPtrmap[offset] || get4byte(&pPtrmap[offset+1])!=parent ){ TRACE(("PTRMAP_UPDATE: %d->(%d,%d)\n", key, eType, parent)); rc = sqlite3PagerWrite(pDbPage); if( rc==SQLITE_OK ){ pPtrmap[offset] = eType; |
︙ | ︙ | |||
31941 31942 31943 31944 31945 31946 31947 | iPtrmap = PTRMAP_PAGENO(pBt, key); rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage); if( rc!=0 ){ return rc; } pPtrmap = (u8 *)sqlite3PagerGetData(pDbPage); | | | > > > > | | | 32958 32959 32960 32961 32962 32963 32964 32965 32966 32967 32968 32969 32970 32971 32972 32973 32974 32975 32976 32977 32978 32979 32980 32981 32982 32983 32984 32985 32986 32987 32988 32989 32990 32991 32992 32993 32994 32995 32996 | iPtrmap = PTRMAP_PAGENO(pBt, key); rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage); if( rc!=0 ){ return rc; } pPtrmap = (u8 *)sqlite3PagerGetData(pDbPage); offset = PTRMAP_PTROFFSET(iPtrmap, key); assert( pEType!=0 ); *pEType = pPtrmap[offset]; if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]); sqlite3PagerUnref(pDbPage); if( *pEType<1 || *pEType>5 ) return SQLITE_CORRUPT_BKPT; return SQLITE_OK; } #else /* if defined SQLITE_OMIT_AUTOVACUUM */ #define ptrmapPut(w,x,y,z) SQLITE_OK #define ptrmapGet(w,x,y,z) SQLITE_OK #define ptrmapPutOvfl(y,z) SQLITE_OK #endif /* ** Given a btree page and a cell index (0 means the first cell on ** the page, 1 means the second cell, and so forth) return a pointer ** to the cell content. ** ** This routine works only for pages that do not contain overflow cells. */ #define findCell(P,I) \ ((P)->aData + ((P)->maskPage & get2byte(&(P)->aData[(P)->cellOffset+2*(I)]))) /* ** This a more complex version of findCell() that works for ** pages that do contain overflow cells. See insert */ static u8 *findOverflowCell(MemPage *pPage, int iCell){ int i; |
︙ | ︙ | |||
32008 32009 32010 32011 32012 32013 32014 | assert( sqlite3_mutex_held(pPage->pBt->mutex) ); pInfo->pCell = pCell; assert( pPage->leaf==0 || pPage->leaf==1 ); n = pPage->childPtrSize; assert( n==4-4*pPage->leaf ); | > | | | | | > | < < | | | < | > | < | 33029 33030 33031 33032 33033 33034 33035 33036 33037 33038 33039 33040 33041 33042 33043 33044 33045 33046 33047 33048 33049 33050 33051 33052 33053 33054 33055 33056 33057 33058 33059 33060 33061 33062 33063 33064 33065 33066 | assert( sqlite3_mutex_held(pPage->pBt->mutex) ); pInfo->pCell = pCell; assert( pPage->leaf==0 || pPage->leaf==1 ); n = pPage->childPtrSize; assert( n==4-4*pPage->leaf ); if( pPage->intKey ){ if( pPage->hasData ){ n += getVarint32(&pCell[n], nPayload); }else{ nPayload = 0; } n += getVarint(&pCell[n], (u64*)&pInfo->nKey); pInfo->nData = nPayload; }else{ pInfo->nData = 0; n += getVarint32(&pCell[n], nPayload); pInfo->nKey = nPayload; } pInfo->nPayload = nPayload; pInfo->nHeader = n; if( likely(nPayload<=pPage->maxLocal) ){ /* This is the (easy) common case where the entire payload fits ** on the local page. No overflow is required. */ int nSize; /* Total size of cell content in bytes */ nSize = nPayload + n; pInfo->nLocal = nPayload; pInfo->iOverflow = 0; if( (nSize & ~3)==0 ){ nSize = 4; /* Minimum cell size is 4 */ } pInfo->nSize = nSize; }else{ /* If the payload will not fit completely on the local page, we have ** to decide how much to store locally and how much to spill onto ** overflow pages. The strategy is to minimize the amount of unused |
︙ | ︙ | |||
32315 32316 32317 32318 32319 32320 32321 32322 | put2byte(&data[hdr+5], top + get2byte(&data[pbegin+2])); } } /* ** Decode the flags byte (the first byte of the header) for a page ** and initialize fields of the MemPage structure accordingly. */ | > > > > > > > > | < | | | | > | | > | > > < > | 33335 33336 33337 33338 33339 33340 33341 33342 33343 33344 33345 33346 33347 33348 33349 33350 33351 33352 33353 33354 33355 33356 33357 33358 33359 33360 33361 33362 33363 33364 33365 33366 33367 33368 33369 33370 33371 33372 33373 33374 33375 33376 33377 33378 33379 33380 | put2byte(&data[hdr+5], top + get2byte(&data[pbegin+2])); } } /* ** Decode the flags byte (the first byte of the header) for a page ** and initialize fields of the MemPage structure accordingly. ** ** Only the following combinations are supported. Anything different ** indicates a corrupt database files: ** ** PTF_ZERODATA ** PTF_ZERODATA | PTF_LEAF ** PTF_LEAFDATA | PTF_INTKEY ** PTF_LEAFDATA | PTF_INTKEY | PTF_LEAF */ static int decodeFlags(MemPage *pPage, int flagByte){ BtShared *pBt; /* A copy of pPage->pBt */ assert( pPage->hdrOffset==(pPage->pgno==1 ? 100 : 0) ); assert( sqlite3_mutex_held(pPage->pBt->mutex) ); pPage->leaf = flagByte>>3; assert( PTF_LEAF == 1<<3 ); flagByte &= ~PTF_LEAF; pPage->childPtrSize = 4-4*pPage->leaf; pBt = pPage->pBt; if( flagByte==(PTF_LEAFDATA | PTF_INTKEY) ){ pPage->intKey = 1; pPage->hasData = pPage->leaf; pPage->maxLocal = pBt->maxLeaf; pPage->minLocal = pBt->minLeaf; }else if( flagByte==PTF_ZERODATA ){ pPage->intKey = 0; pPage->hasData = 0; pPage->maxLocal = pBt->maxLocal; pPage->minLocal = pBt->minLocal; }else{ return SQLITE_CORRUPT_BKPT; } return SQLITE_OK; } /* ** Initialize the auxiliary information for a disk block. ** ** The pParent parameter must be a pointer to the MemPage which ** is the parent of the page being initialized. The root of a |
︙ | ︙ | |||
32363 32364 32365 32366 32367 32368 32369 | int hdr; /* Offset to beginning of page header */ u8 *data; /* Equal to pPage->aData */ BtShared *pBt; /* The main btree structure */ int usableSize; /* Amount of usable space on each page */ int cellOffset; /* Offset from start of page to first cell pointer */ int nFree; /* Number of unused bytes on the page */ int top; /* First byte of the cell content area */ | < < < | > > | 33394 33395 33396 33397 33398 33399 33400 33401 33402 33403 33404 33405 33406 33407 33408 33409 33410 33411 33412 33413 33414 33415 33416 33417 33418 33419 33420 33421 33422 33423 33424 33425 33426 33427 33428 33429 | int hdr; /* Offset to beginning of page header */ u8 *data; /* Equal to pPage->aData */ BtShared *pBt; /* The main btree structure */ int usableSize; /* Amount of usable space on each page */ int cellOffset; /* Offset from start of page to first cell pointer */ int nFree; /* Number of unused bytes on the page */ int top; /* First byte of the cell content area */ pBt = pPage->pBt; assert( pBt!=0 ); assert( pParent==0 || pParent->pBt==pBt ); assert( sqlite3_mutex_held(pBt->mutex) ); assert( pPage->pgno==sqlite3PagerPagenumber(pPage->pDbPage) ); assert( pPage == sqlite3PagerGetExtra(pPage->pDbPage) ); assert( pPage->aData == sqlite3PagerGetData(pPage->pDbPage) ); if( pPage->pParent!=pParent && (pPage->pParent!=0 || pPage->isInit) ){ /* The parent page should never change unless the file is corrupt */ return SQLITE_CORRUPT_BKPT; } if( pPage->isInit ) return SQLITE_OK; if( pPage->pParent==0 && pParent!=0 ){ pPage->pParent = pParent; sqlite3PagerRef(pParent->pDbPage); } hdr = pPage->hdrOffset; data = pPage->aData; if( decodeFlags(pPage, data[hdr]) ) return SQLITE_CORRUPT_BKPT; assert( pBt->pageSize>=512 && pBt->pageSize<=32768 ); pPage->maskPage = pBt->pageSize - 1; pPage->nOverflow = 0; pPage->idxShift = 0; usableSize = pBt->usableSize; pPage->cellOffset = cellOffset = hdr + 12 - 4*pPage->leaf; top = get2byte(&data[hdr+5]); pPage->nCell = get2byte(&data[hdr+3]); if( pPage->nCell>MX_CELL(pBt) ){ |
︙ | ︙ | |||
32425 32426 32427 32428 32429 32430 32431 | } pPage->nFree = nFree; if( nFree>=usableSize ){ /* Free space cannot exceed total page size */ return SQLITE_CORRUPT_BKPT; } | > | > > > > > > > > > | | | | | | > > | > > | 33455 33456 33457 33458 33459 33460 33461 33462 33463 33464 33465 33466 33467 33468 33469 33470 33471 33472 33473 33474 33475 33476 33477 33478 33479 33480 33481 33482 33483 33484 33485 33486 33487 33488 33489 33490 33491 33492 33493 33494 33495 33496 33497 33498 33499 33500 33501 33502 33503 33504 33505 33506 33507 33508 33509 33510 33511 33512 33513 33514 33515 33516 33517 33518 33519 33520 | } pPage->nFree = nFree; if( nFree>=usableSize ){ /* Free space cannot exceed total page size */ return SQLITE_CORRUPT_BKPT; } #if 0 /* Check that all the offsets in the cell offset array are within range. ** ** Omitting this consistency check and using the pPage->maskPage mask ** to prevent overrunning the page buffer in findCell() results in a ** 2.5% performance gain. */ { u8 *pOff; /* Iterator used to check all cell offsets are in range */ u8 *pEnd; /* Pointer to end of cell offset array */ u8 mask; /* Mask of bits that must be zero in MSB of cell offsets */ mask = ~(((u8)(pBt->pageSize>>8))-1); pEnd = &data[cellOffset + pPage->nCell*2]; for(pOff=&data[cellOffset]; pOff!=pEnd && !((*pOff)&mask); pOff+=2); if( pOff!=pEnd ){ return SQLITE_CORRUPT_BKPT; } } #endif pPage->isInit = 1; return SQLITE_OK; } /* ** Set up a raw page so that it looks like a database page holding ** no entries. */ static void zeroPage(MemPage *pPage, int flags){ unsigned char *data = pPage->aData; BtShared *pBt = pPage->pBt; int hdr = pPage->hdrOffset; int first; assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno ); assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage ); assert( sqlite3PagerGetData(pPage->pDbPage) == data ); assert( sqlite3PagerIswriteable(pPage->pDbPage) ); assert( sqlite3_mutex_held(pBt->mutex) ); /*memset(&data[hdr], 0, pBt->usableSize - hdr);*/ data[hdr] = flags; first = hdr + 8 + 4*((flags&PTF_LEAF)==0); memset(&data[hdr+1], 0, 4); data[hdr+7] = 0; put2byte(&data[hdr+5], pBt->usableSize); pPage->nFree = pBt->usableSize - first; decodeFlags(pPage, flags); pPage->hdrOffset = hdr; pPage->cellOffset = first; pPage->nOverflow = 0; assert( pBt->pageSize>=512 && pBt->pageSize<=32768 ); pPage->maskPage = pBt->pageSize - 1; pPage->idxShift = 0; pPage->nCell = 0; pPage->isInit = 1; } /* ** Get a page from the pager. Initialize the MemPage.pBt and |
︙ | ︙ | |||
33435 33436 33437 33438 33439 33440 33441 33442 33443 33444 33445 33446 33447 33448 | trans_begun: btreeIntegrity(p); sqlite3BtreeLeave(p); return rc; } #ifndef SQLITE_OMIT_AUTOVACUUM /* ** Set the pointer-map entries for all children of page pPage. Also, if ** pPage contains cells that point to overflow pages, set the pointer ** map entries for the overflow pages as well. | > > > > > > > > > > > > | 34479 34480 34481 34482 34483 34484 34485 34486 34487 34488 34489 34490 34491 34492 34493 34494 34495 34496 34497 34498 34499 34500 34501 34502 34503 34504 | trans_begun: btreeIntegrity(p); sqlite3BtreeLeave(p); return rc; } /* ** Return the size of the database file in pages. Or return -1 if ** there is any kind of error. */ static int pagerPagecount(Pager *pPager){ int rc; int nPage; rc = sqlite3PagerPagecount(pPager, &nPage); return (rc==SQLITE_OK?nPage:-1); } #ifndef SQLITE_OMIT_AUTOVACUUM /* ** Set the pointer-map entries for all children of page pPage. Also, if ** pPage contains cells that point to overflow pages, set the pointer ** map entries for the overflow pages as well. |
︙ | ︙ | |||
33556 33557 33558 33559 33560 33561 33562 | ** database. The pDbPage reference remains valid. */ static int relocatePage( BtShared *pBt, /* Btree */ MemPage *pDbPage, /* Open page to move */ u8 eType, /* Pointer map 'type' entry for pDbPage */ Pgno iPtrPage, /* Pointer map 'page-no' entry for pDbPage */ | | > | | 34612 34613 34614 34615 34616 34617 34618 34619 34620 34621 34622 34623 34624 34625 34626 34627 34628 34629 34630 34631 34632 34633 34634 34635 34636 34637 34638 34639 34640 34641 34642 | ** database. The pDbPage reference remains valid. */ static int relocatePage( BtShared *pBt, /* Btree */ MemPage *pDbPage, /* Open page to move */ u8 eType, /* Pointer map 'type' entry for pDbPage */ Pgno iPtrPage, /* Pointer map 'page-no' entry for pDbPage */ Pgno iFreePage, /* The location to move pDbPage to */ int isCommit ){ MemPage *pPtrPage; /* The page that contains a pointer to pDbPage */ Pgno iDbPage = pDbPage->pgno; Pager *pPager = pBt->pPager; int rc; assert( eType==PTRMAP_OVERFLOW2 || eType==PTRMAP_OVERFLOW1 || eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE ); assert( sqlite3_mutex_held(pBt->mutex) ); assert( pDbPage->pBt==pBt ); /* Move page iDbPage from its current location to page number iFreePage */ TRACE(("AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\n", iDbPage, iFreePage, iPtrPage, eType)); rc = sqlite3PagerMovepage(pPager, pDbPage->pDbPage, iFreePage, isCommit); if( rc!=SQLITE_OK ){ return rc; } pDbPage->pgno = iFreePage; /* If pDbPage was a btree-page, then it may have child pages and/or cells ** that point to overflow pages. The pointer map entries for all these |
︙ | ︙ | |||
33623 33624 33625 33626 33627 33628 33629 | if( rc==SQLITE_OK ){ rc = ptrmapPut(pBt, iFreePage, eType, iPtrPage); } } return rc; } | < < < < < < < | 34680 34681 34682 34683 34684 34685 34686 34687 34688 34689 34690 34691 34692 34693 | if( rc==SQLITE_OK ){ rc = ptrmapPut(pBt, iFreePage, eType, iPtrPage); } } return rc; } /* Forward declaration required by incrVacuumStep(). */ static int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8); /* ** Perform a single step of an incremental-vacuum. If successful, ** return SQLITE_OK. If there is no work to do (and therefore no ** point in calling this function again), return SQLITE_DONE. |
︙ | ︙ | |||
33721 33722 33723 33724 33725 33726 33727 | } releasePage(pFreePg); }while( nFin!=0 && iFreePg>nFin ); assert( iFreePg<iLastPg ); rc = sqlite3PagerWrite(pLastPg->pDbPage); if( rc==SQLITE_OK ){ | | | 34771 34772 34773 34774 34775 34776 34777 34778 34779 34780 34781 34782 34783 34784 34785 | } releasePage(pFreePg); }while( nFin!=0 && iFreePg>nFin ); assert( iFreePg<iLastPg ); rc = sqlite3PagerWrite(pLastPg->pDbPage); if( rc==SQLITE_OK ){ rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg, nFin!=0); } releasePage(pLastPg); if( rc!=SQLITE_OK ){ return rc; } } } |
︙ | ︙ | |||
35200 35201 35202 35203 35204 35205 35206 | c = sqlite3VdbeRecordCompare(nCellKey, pCellKey, pUnKey); sqlite3_free(pCellKey); if( rc ) goto moveto_finish; } } if( c==0 ){ pCur->info.nKey = nCellKey; | | | 36250 36251 36252 36253 36254 36255 36256 36257 36258 36259 36260 36261 36262 36263 36264 | c = sqlite3VdbeRecordCompare(nCellKey, pCellKey, pUnKey); sqlite3_free(pCellKey); if( rc ) goto moveto_finish; } } if( c==0 ){ pCur->info.nKey = nCellKey; if( pPage->intKey && !pPage->leaf ){ lwr = pCur->idx; upr = lwr - 1; break; }else{ if( pRes ) *pRes = 0; rc = SQLITE_OK; goto moveto_finish; |
︙ | ︙ | |||
35327 35328 35329 35330 35331 35332 35333 | pCur->eState = CURSOR_INVALID; return SQLITE_OK; } sqlite3BtreeMoveToParent(pCur); pPage = pCur->pPage; }while( pCur->idx>=pPage->nCell ); *pRes = 0; | | | 36377 36378 36379 36380 36381 36382 36383 36384 36385 36386 36387 36388 36389 36390 36391 | pCur->eState = CURSOR_INVALID; return SQLITE_OK; } sqlite3BtreeMoveToParent(pCur); pPage = pCur->pPage; }while( pCur->idx>=pPage->nCell ); *pRes = 0; if( pPage->intKey ){ rc = sqlite3BtreeNext(pCur, pRes); }else{ rc = SQLITE_OK; } return rc; } *pRes = 0; |
︙ | ︙ | |||
35394 35395 35396 35397 35398 35399 35400 | } sqlite3BtreeMoveToParent(pCur); pPage = pCur->pPage; } pCur->idx--; pCur->info.nSize = 0; pCur->validNKey = 0; | | | 36444 36445 36446 36447 36448 36449 36450 36451 36452 36453 36454 36455 36456 36457 36458 | } sqlite3BtreeMoveToParent(pCur); pPage = pCur->pPage; } pCur->idx--; pCur->info.nSize = 0; pCur->validNKey = 0; if( pPage->intKey && !pPage->leaf ){ rc = sqlite3BtreePrevious(pCur, pRes); }else{ rc = SQLITE_OK; } } *pRes = 0; return rc; |
︙ | ︙ | |||
35698 35699 35700 35701 35702 35703 35704 | ** always fully overwrite deleted information with zeros. */ rc = sqlite3PagerWrite(pPage->pDbPage); if( rc ) return rc; memset(pPage->aData, 0, pPage->pBt->pageSize); #endif | < | < | 36748 36749 36750 36751 36752 36753 36754 36755 36756 36757 36758 36759 36760 36761 36762 36763 36764 36765 36766 36767 36768 | ** always fully overwrite deleted information with zeros. */ rc = sqlite3PagerWrite(pPage->pDbPage); if( rc ) return rc; memset(pPage->aData, 0, pPage->pBt->pageSize); #endif /* If the database supports auto-vacuum, write an entry in the pointer-map ** to indicate that the page is free. */ if( ISAUTOVACUUM ){ rc = ptrmapPut(pBt, pPage->pgno, PTRMAP_FREEPAGE, 0); if( rc ) return rc; } if( n==0 ){ /* This is the first free page */ rc = sqlite3PagerWrite(pPage->pDbPage); if( rc ) return rc; memset(pPage->aData, 0, 8); put4byte(&pPage1->aData[32], pPage->pgno); |
︙ | ︙ | |||
35936 35937 35938 35939 35940 35941 35942 35943 35944 35945 35946 35947 35948 | nSrc = nData; pSrc = pData; } } releasePage(pToRelease); return SQLITE_OK; } /* ** Change the MemPage.pParent pointer on the page whose number is ** given in the second argument so that MemPage.pParent holds the ** pointer in the third argument. */ | > > > > > | > > > > > > | 36984 36985 36986 36987 36988 36989 36990 36991 36992 36993 36994 36995 36996 36997 36998 36999 37000 37001 37002 37003 37004 37005 37006 37007 37008 37009 37010 37011 37012 37013 37014 37015 | nSrc = nData; pSrc = pData; } } releasePage(pToRelease); return SQLITE_OK; } /* ** Change the MemPage.pParent pointer on the page whose number is ** given in the second argument so that MemPage.pParent holds the ** pointer in the third argument. ** ** If the final argument, updatePtrmap, is non-zero and the database ** is an auto-vacuum database, then the pointer-map entry for pgno ** is updated. */ static int reparentPage( BtShared *pBt, /* B-Tree structure */ Pgno pgno, /* Page number of child being adopted */ MemPage *pNewParent, /* New parent of pgno */ int idx, /* Index of child page pgno in pNewParent */ int updatePtrmap /* If true, update pointer-map for pgno */ ){ MemPage *pThis; DbPage *pDbPage; assert( sqlite3_mutex_held(pBt->mutex) ); assert( pNewParent!=0 ); if( pgno==0 ) return SQLITE_OK; assert( pBt->pPager!=0 ); |
︙ | ︙ | |||
35965 35966 35967 35968 35969 35970 35971 | sqlite3PagerRef(pNewParent->pDbPage); } pThis->idxParent = idx; } sqlite3PagerUnref(pDbPage); } | | < > > > > > > > > > > > > > > > > > > > | < < < | > > > | | | | | | < | > | 37024 37025 37026 37027 37028 37029 37030 37031 37032 37033 37034 37035 37036 37037 37038 37039 37040 37041 37042 37043 37044 37045 37046 37047 37048 37049 37050 37051 37052 37053 37054 37055 37056 37057 37058 37059 37060 37061 37062 37063 37064 37065 37066 37067 37068 37069 37070 37071 37072 37073 37074 37075 37076 37077 37078 37079 37080 37081 37082 37083 37084 37085 37086 37087 37088 37089 37090 37091 | sqlite3PagerRef(pNewParent->pDbPage); } pThis->idxParent = idx; } sqlite3PagerUnref(pDbPage); } if( ISAUTOVACUUM && updatePtrmap ){ return ptrmapPut(pBt, pgno, PTRMAP_BTREE, pNewParent->pgno); } #ifndef NDEBUG /* If the updatePtrmap flag was clear, assert that the entry in the ** pointer-map is already correct. */ if( ISAUTOVACUUM ){ pDbPage = sqlite3PagerLookup(pBt->pPager,PTRMAP_PAGENO(pBt,pgno)); if( pDbPage ){ u8 eType; Pgno ii; int rc = ptrmapGet(pBt, pgno, &eType, &ii); assert( rc==SQLITE_OK && ii==pNewParent->pgno && eType==PTRMAP_BTREE ); sqlite3PagerUnref(pDbPage); } } #endif return SQLITE_OK; } /* ** Change the pParent pointer of all children of pPage to point back ** to pPage. ** ** In other words, for every child of pPage, invoke reparentPage() ** to make sure that each child knows that pPage is its parent. ** ** This routine gets called after you memcpy() one page into ** another. ** ** If updatePtrmap is true, then the pointer-map entries for all child ** pages of pPage are updated. */ static int reparentChildPages(MemPage *pPage, int updatePtrmap){ int rc = SQLITE_OK; assert( sqlite3_mutex_held(pPage->pBt->mutex) ); if( !pPage->leaf ){ int i; BtShared *pBt = pPage->pBt; Pgno iRight = get4byte(&pPage->aData[pPage->hdrOffset+8]); for(i=0; i<pPage->nCell; i++){ u8 *pCell = findCell(pPage, i); rc = reparentPage(pBt, get4byte(pCell), pPage, i, updatePtrmap); if( rc!=SQLITE_OK ) return rc; } rc = reparentPage(pBt, iRight, pPage, i, updatePtrmap); pPage->idxShift = 0; } return rc; } /* ** Remove the i-th cell from pPage. This routine effects pPage only. ** The cell content is not freed or deallocated. It is assumed that ** the cell content has been copied someplace else. This routine just |
︙ | ︙ | |||
36271 36272 36273 36274 36275 36276 36277 | fillInCell(pParent, parentCell, 0, info.nKey, 0, 0, 0, &parentSize); assert( parentSize<64 ); assert( sqlite3PagerIswriteable(pParent->pDbPage) ); insertCell(pParent, parentIdx, parentCell, parentSize, 0, 4); put4byte(findOverflowCell(pParent,parentIdx), pPage->pgno); put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew); | < | < | 37348 37349 37350 37351 37352 37353 37354 37355 37356 37357 37358 37359 37360 37361 37362 37363 37364 37365 37366 37367 37368 37369 37370 37371 37372 37373 37374 37375 | fillInCell(pParent, parentCell, 0, info.nKey, 0, 0, 0, &parentSize); assert( parentSize<64 ); assert( sqlite3PagerIswriteable(pParent->pDbPage) ); insertCell(pParent, parentIdx, parentCell, parentSize, 0, 4); put4byte(findOverflowCell(pParent,parentIdx), pPage->pgno); put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew); /* If this is an auto-vacuum database, update the pointer map ** with entries for the new page, and any pointer from the ** cell on the page to an overflow page. */ if( ISAUTOVACUUM ){ rc = ptrmapPut(pBt, pgnoNew, PTRMAP_BTREE, pParent->pgno); if( rc==SQLITE_OK ){ rc = ptrmapPutOvfl(pNew, 0); } if( rc!=SQLITE_OK ){ releasePage(pNew); return rc; } } /* Release the reference to the new page and balance the parent page, ** in case the divider cell inserted caused it to become overfull. */ releasePage(pNew); return balance(pParent, 0); } |
︙ | ︙ | |||
36358 36359 36360 36361 36362 36363 36364 | int cntNew[NB+2]; /* Index in aCell[] of cell after i-th page */ int szNew[NB+2]; /* Combined size of cells place on i-th page */ u8 **apCell = 0; /* All cells begin balanced */ u16 *szCell; /* Local size of all cells in apCell[] */ u8 *aCopy[NB]; /* Space for holding data of apCopy[] */ u8 *aSpace1; /* Space for copies of dividers cells before balance */ u8 *aSpace2 = 0; /* Space for overflow dividers cells after balance */ | < < | 37433 37434 37435 37436 37437 37438 37439 37440 37441 37442 37443 37444 37445 37446 37447 | int cntNew[NB+2]; /* Index in aCell[] of cell after i-th page */ int szNew[NB+2]; /* Combined size of cells place on i-th page */ u8 **apCell = 0; /* All cells begin balanced */ u16 *szCell; /* Local size of all cells in apCell[] */ u8 *aCopy[NB]; /* Space for holding data of apCopy[] */ u8 *aSpace1; /* Space for copies of dividers cells before balance */ u8 *aSpace2 = 0; /* Space for overflow dividers cells after balance */ u8 *aFrom = 0; assert( sqlite3_mutex_held(pPage->pBt->mutex) ); /* ** Find the parent page. */ assert( pPage->isInit ); |
︙ | ︙ | |||
36389 36390 36391 36392 36393 36394 36395 | ** and the new entry is the right-most entry in the tree (it has the ** largest key) then use the special balance_quick() routine for ** balancing. balance_quick() is much faster and results in a tighter ** packing of data in the common case. */ if( pPage->leaf && pPage->intKey && | < > | 37462 37463 37464 37465 37466 37467 37468 37469 37470 37471 37472 37473 37474 37475 37476 37477 37478 37479 37480 37481 | ** and the new entry is the right-most entry in the tree (it has the ** largest key) then use the special balance_quick() routine for ** balancing. balance_quick() is much faster and results in a tighter ** packing of data in the common case. */ if( pPage->leaf && pPage->intKey && pPage->nOverflow==1 && pPage->aOvfl[0].idx==pPage->nCell && pPage->pParent->pgno!=1 && get4byte(&pParent->aData[pParent->hdrOffset+8])==pPage->pgno ){ assert( pPage->intKey ); /* ** TODO: Check the siblings to the left of pPage. It may be that ** they are not full and no new page is required. */ return balance_quick(pPage, pParent); } #endif |
︙ | ︙ | |||
36496 36497 36498 36499 36500 36501 36502 | assert( ((aCopy[0] - (u8*)apCell) & 7)==0 ); /* 8-byte alignment required */ for(i=1; i<NB; i++){ aCopy[i] = &aCopy[i-1][pBt->pageSize+ROUND8(sizeof(MemPage))]; assert( ((aCopy[i] - (u8*)apCell) & 7)==0 ); /* 8-byte alignment required */ } aSpace1 = &aCopy[NB-1][pBt->pageSize+ROUND8(sizeof(MemPage))]; assert( ((aSpace1 - (u8*)apCell) & 7)==0 ); /* 8-byte alignment required */ | | < < | 37569 37570 37571 37572 37573 37574 37575 37576 37577 37578 37579 37580 37581 37582 37583 37584 37585 | assert( ((aCopy[0] - (u8*)apCell) & 7)==0 ); /* 8-byte alignment required */ for(i=1; i<NB; i++){ aCopy[i] = &aCopy[i-1][pBt->pageSize+ROUND8(sizeof(MemPage))]; assert( ((aCopy[i] - (u8*)apCell) & 7)==0 ); /* 8-byte alignment required */ } aSpace1 = &aCopy[NB-1][pBt->pageSize+ROUND8(sizeof(MemPage))]; assert( ((aSpace1 - (u8*)apCell) & 7)==0 ); /* 8-byte alignment required */ if( ISAUTOVACUUM ){ aFrom = &aSpace1[pBt->pageSize]; } aSpace2 = sqlite3PageMalloc(pBt->pageSize); if( aSpace2==0 ){ rc = SQLITE_NOMEM; goto balance_cleanup; } /* |
︙ | ︙ | |||
36538 36539 36540 36541 36542 36543 36544 | ** are alike. ** ** leafCorrection: 4 if pPage is a leaf. 0 if pPage is not a leaf. ** leafData: 1 if pPage holds key+data and pParent holds only keys. */ nCell = 0; leafCorrection = pPage->leaf*4; | | | < < | 37609 37610 37611 37612 37613 37614 37615 37616 37617 37618 37619 37620 37621 37622 37623 37624 37625 37626 37627 37628 37629 37630 37631 37632 37633 37634 37635 37636 37637 37638 37639 37640 | ** are alike. ** ** leafCorrection: 4 if pPage is a leaf. 0 if pPage is not a leaf. ** leafData: 1 if pPage holds key+data and pParent holds only keys. */ nCell = 0; leafCorrection = pPage->leaf*4; leafData = pPage->hasData; for(i=0; i<nOld; i++){ MemPage *pOld = apCopy[i]; int limit = pOld->nCell+pOld->nOverflow; for(j=0; j<limit; j++){ assert( nCell<nMaxCells ); apCell[nCell] = findOverflowCell(pOld, j); szCell[nCell] = cellSizePtr(pOld, apCell[nCell]); if( ISAUTOVACUUM ){ int a; aFrom[nCell] = i; for(a=0; a<pOld->nOverflow; a++){ if( pOld->aOvfl[a].pCell==apCell[nCell] ){ aFrom[nCell] = 0xFF; break; } } } nCell++; } if( i<nOld-1 ){ u16 sz = cellSizePtr(pParent, apDiv[i]); if( leafData ){ /* With the LEAFDATA flag, pParent cells hold only INTKEYs that ** are duplicates of keys on the child pages. We need to remove |
︙ | ︙ | |||
36579 36580 36581 36582 36583 36584 36585 | szCell[nCell] = sz; pTemp = &aSpace1[iSpace1]; iSpace1 += sz; assert( sz<=pBt->pageSize/4 ); assert( iSpace1<=pBt->pageSize ); memcpy(pTemp, apDiv[i], sz); apCell[nCell] = pTemp+leafCorrection; | | < < | 37648 37649 37650 37651 37652 37653 37654 37655 37656 37657 37658 37659 37660 37661 37662 37663 37664 | szCell[nCell] = sz; pTemp = &aSpace1[iSpace1]; iSpace1 += sz; assert( sz<=pBt->pageSize/4 ); assert( iSpace1<=pBt->pageSize ); memcpy(pTemp, apDiv[i], sz); apCell[nCell] = pTemp+leafCorrection; if( ISAUTOVACUUM ){ aFrom[nCell] = 0xFF; } dropCell(pParent, nxDiv, sz); szCell[nCell] -= leafCorrection; assert( get4byte(pTemp)==pgnoOld[i] ); if( !pOld->leaf ){ assert( leafCorrection==0 ); /* The right pointer of the child page pOld becomes the left ** pointer of the divider cell */ |
︙ | ︙ | |||
36765 36766 36767 36768 36769 36770 36771 | assert( j<nMaxCells ); assert( pNew->pgno==pgnoNew[i] ); zeroPage(pNew, pageFlags); assemblePage(pNew, cntNew[i]-j, &apCell[j], &szCell[j]); assert( pNew->nCell>0 || (nNew==1 && cntNew[0]==0) ); assert( pNew->nOverflow==0 ); | < | > > > < > > > > > > > > | 37832 37833 37834 37835 37836 37837 37838 37839 37840 37841 37842 37843 37844 37845 37846 37847 37848 37849 37850 37851 37852 37853 37854 37855 37856 37857 37858 37859 37860 37861 37862 37863 37864 37865 37866 37867 37868 37869 37870 37871 37872 37873 37874 37875 37876 37877 37878 37879 37880 37881 37882 37883 37884 37885 37886 37887 37888 37889 | assert( j<nMaxCells ); assert( pNew->pgno==pgnoNew[i] ); zeroPage(pNew, pageFlags); assemblePage(pNew, cntNew[i]-j, &apCell[j], &szCell[j]); assert( pNew->nCell>0 || (nNew==1 && cntNew[0]==0) ); assert( pNew->nOverflow==0 ); /* If this is an auto-vacuum database, update the pointer map entries ** that point to the siblings that were rearranged. These can be: left ** children of cells, the right-child of the page, or overflow pages ** pointed to by cells. */ if( ISAUTOVACUUM ){ for(k=j; k<cntNew[i]; k++){ assert( k<nMaxCells ); if( aFrom[k]==0xFF || apCopy[aFrom[k]]->pgno!=pNew->pgno ){ rc = ptrmapPutOvfl(pNew, k-j); if( rc==SQLITE_OK && leafCorrection==0 ){ rc = ptrmapPut(pBt, get4byte(apCell[k]), PTRMAP_BTREE, pNew->pgno); } if( rc!=SQLITE_OK ){ goto balance_cleanup; } } } } j = cntNew[i]; /* If the sibling page assembled above was not the right-most sibling, ** insert a divider cell into the parent page. */ if( i<nNew-1 && j<nCell ){ u8 *pCell; u8 *pTemp; int sz; assert( j<nMaxCells ); pCell = apCell[j]; sz = szCell[j] + leafCorrection; pTemp = &aSpace2[iSpace2]; if( !pNew->leaf ){ memcpy(&pNew->aData[8], pCell, 4); if( ISAUTOVACUUM && (aFrom[j]==0xFF || apCopy[aFrom[j]]->pgno!=pNew->pgno) ){ rc = ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno); if( rc!=SQLITE_OK ){ goto balance_cleanup; } } }else if( leafData ){ /* If the tree is a leaf-data tree, and the siblings are leaves, ** then there is no divider cell in apCell[]. Instead, the divider ** cell consists of the integer key for the right-most cell of ** the sibling-page assembled above only. */ CellInfo info; |
︙ | ︙ | |||
36836 36837 36838 36839 36840 36841 36842 | } iSpace2 += sz; assert( sz<=pBt->pageSize/4 ); assert( iSpace2<=pBt->pageSize ); rc = insertCell(pParent, nxDiv, pCell, sz, pTemp, 4); if( rc!=SQLITE_OK ) goto balance_cleanup; put4byte(findOverflowCell(pParent,nxDiv), pNew->pgno); | | | < > > > > > > > > > | > > > > > > | | | 37912 37913 37914 37915 37916 37917 37918 37919 37920 37921 37922 37923 37924 37925 37926 37927 37928 37929 37930 37931 37932 37933 37934 37935 37936 37937 37938 37939 37940 37941 37942 37943 37944 37945 37946 37947 37948 37949 37950 37951 37952 37953 37954 37955 37956 37957 37958 37959 37960 37961 37962 37963 37964 37965 37966 37967 37968 37969 37970 37971 37972 37973 37974 37975 37976 37977 37978 | } iSpace2 += sz; assert( sz<=pBt->pageSize/4 ); assert( iSpace2<=pBt->pageSize ); rc = insertCell(pParent, nxDiv, pCell, sz, pTemp, 4); if( rc!=SQLITE_OK ) goto balance_cleanup; put4byte(findOverflowCell(pParent,nxDiv), pNew->pgno); /* If this is an auto-vacuum database, and not a leaf-data tree, ** then update the pointer map with an entry for the overflow page ** that the cell just inserted points to (if any). */ if( ISAUTOVACUUM && !leafData ){ rc = ptrmapPutOvfl(pParent, nxDiv); if( rc!=SQLITE_OK ){ goto balance_cleanup; } } j++; nxDiv++; } /* Set the pointer-map entry for the new sibling page. */ if( ISAUTOVACUUM ){ rc = ptrmapPut(pBt, pNew->pgno, PTRMAP_BTREE, pParent->pgno); if( rc!=SQLITE_OK ){ goto balance_cleanup; } } } assert( j==nCell ); assert( nOld>0 ); assert( nNew>0 ); if( (pageFlags & PTF_LEAF)==0 ){ u8 *zChild = &apCopy[nOld-1]->aData[8]; memcpy(&apNew[nNew-1]->aData[8], zChild, 4); if( ISAUTOVACUUM ){ rc = ptrmapPut(pBt, get4byte(zChild), PTRMAP_BTREE, apNew[nNew-1]->pgno); if( rc!=SQLITE_OK ){ goto balance_cleanup; } } } if( nxDiv==pParent->nCell+pParent->nOverflow ){ /* Right-most sibling is the right-most child of pParent */ put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew[nNew-1]); }else{ /* Right-most sibling is the left child of the first entry in pParent ** past the right-most divider entry */ put4byte(findOverflowCell(pParent, nxDiv), pgnoNew[nNew-1]); } /* ** Reparent children of all cells. */ for(i=0; i<nNew; i++){ rc = reparentChildPages(apNew[i], 0); if( rc!=SQLITE_OK ) goto balance_cleanup; } rc = reparentChildPages(pParent, 0); if( rc!=SQLITE_OK ) goto balance_cleanup; /* ** Balance the parent page. Note that the current page (pPage) might ** have been added to the freelist so it might no longer be initialized. ** But the parent page will always be initialized. */ |
︙ | ︙ | |||
36982 36983 36984 36985 36986 36987 36988 | pPage->pParent = 0; rc = sqlite3BtreeInitPage(pPage, 0); assert( rc==SQLITE_OK ); freePage(pChild); TRACE(("BALANCE: transfer child %d into root %d\n", pChild->pgno, pPage->pgno)); } | | | < < | 38072 38073 38074 38075 38076 38077 38078 38079 38080 38081 38082 38083 38084 38085 38086 38087 38088 38089 38090 38091 38092 38093 38094 38095 38096 | pPage->pParent = 0; rc = sqlite3BtreeInitPage(pPage, 0); assert( rc==SQLITE_OK ); freePage(pChild); TRACE(("BALANCE: transfer child %d into root %d\n", pChild->pgno, pPage->pgno)); } rc = reparentChildPages(pPage, 1); assert( pPage->nOverflow==0 ); if( ISAUTOVACUUM ){ int i; for(i=0; i<pPage->nCell; i++){ rc = ptrmapPutOvfl(pPage, i); if( rc!=SQLITE_OK ){ goto end_shallow_balance; } } } releasePage(pChild); } end_shallow_balance: sqlite3_free(apCell); return rc; } |
︙ | ︙ | |||
37049 37050 37051 37052 37053 37054 37055 | if( pChild->nOverflow ){ pChild->nFree = 0; } assert( pChild->nCell==pPage->nCell ); zeroPage(pPage, pChild->aData[0] & ~PTF_LEAF); put4byte(&pPage->aData[pPage->hdrOffset+8], pgnoChild); TRACE(("BALANCE: copy root %d into %d\n", pPage->pgno, pChild->pgno)); | | < > | | > | 38137 38138 38139 38140 38141 38142 38143 38144 38145 38146 38147 38148 38149 38150 38151 38152 38153 38154 38155 38156 38157 38158 38159 38160 38161 38162 38163 38164 38165 | if( pChild->nOverflow ){ pChild->nFree = 0; } assert( pChild->nCell==pPage->nCell ); zeroPage(pPage, pChild->aData[0] & ~PTF_LEAF); put4byte(&pPage->aData[pPage->hdrOffset+8], pgnoChild); TRACE(("BALANCE: copy root %d into %d\n", pPage->pgno, pChild->pgno)); if( ISAUTOVACUUM ){ int i; rc = ptrmapPut(pBt, pChild->pgno, PTRMAP_BTREE, pPage->pgno); if( rc ) goto balancedeeper_out; for(i=0; i<pChild->nCell; i++){ rc = ptrmapPutOvfl(pChild, i); if( rc!=SQLITE_OK ){ goto balancedeeper_out; } } rc = reparentChildPages(pChild, 1); } if( rc==SQLITE_OK ){ rc = balance_nonroot(pChild); } balancedeeper_out: releasePage(pChild); return rc; } /* |
︙ | ︙ | |||
37215 37216 37217 37218 37219 37220 37221 | SQLITE_OK!=(rc = sqlite3BtreeMoveto(pCur, pKey, 0, nKey, appendBias, &loc)) ){ return rc; } pPage = pCur->pPage; assert( pPage->intKey || nKey>=0 ); | | | 38304 38305 38306 38307 38308 38309 38310 38311 38312 38313 38314 38315 38316 38317 38318 | SQLITE_OK!=(rc = sqlite3BtreeMoveto(pCur, pKey, 0, nKey, appendBias, &loc)) ){ return rc; } pPage = pCur->pPage; assert( pPage->intKey || nKey>=0 ); assert( pPage->leaf || !pPage->intKey ); TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n", pCur->pgnoRoot, nKey, nData, pPage->pgno, loc==0 ? "overwrite" : "new entry")); assert( pPage->isInit ); allocateTempSpace(pBt); newCell = pBt->pTmpSpace; if( newCell==0 ) return SQLITE_NOMEM; |
︙ | ︙ | |||
37331 37332 37333 37334 37335 37336 37337 | ** next Cell after the one to be deleted is guaranteed to exist and ** to be a leaf so we can use it. */ BtCursor leafCur; unsigned char *pNext; int notUsed; unsigned char *tempCell = 0; | | | 38420 38421 38422 38423 38424 38425 38426 38427 38428 38429 38430 38431 38432 38433 38434 | ** next Cell after the one to be deleted is guaranteed to exist and ** to be a leaf so we can use it. */ BtCursor leafCur; unsigned char *pNext; int notUsed; unsigned char *tempCell = 0; assert( !pPage->intKey ); sqlite3BtreeGetTempCursor(pCur, &leafCur); rc = sqlite3BtreeNext(&leafCur, ¬Used); if( rc==SQLITE_OK ){ rc = sqlite3PagerWrite(leafCur.pPage->pDbPage); } if( rc==SQLITE_OK ){ u16 szNext; |
︙ | ︙ | |||
37474 37475 37476 37477 37478 37479 37480 | assert( eType!=PTRMAP_ROOTPAGE ); assert( eType!=PTRMAP_FREEPAGE ); rc = sqlite3PagerWrite(pRoot->pDbPage); if( rc!=SQLITE_OK ){ releasePage(pRoot); return rc; } | | | 38563 38564 38565 38566 38567 38568 38569 38570 38571 38572 38573 38574 38575 38576 38577 | assert( eType!=PTRMAP_ROOTPAGE ); assert( eType!=PTRMAP_FREEPAGE ); rc = sqlite3PagerWrite(pRoot->pDbPage); if( rc!=SQLITE_OK ){ releasePage(pRoot); return rc; } rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove, 0); releasePage(pRoot); /* Obtain the page at pgnoRoot */ if( rc!=SQLITE_OK ){ return rc; } rc = sqlite3BtreeGetPage(pBt, pgnoRoot, &pRoot, 0); |
︙ | ︙ | |||
37682 37683 37684 37685 37686 37687 37688 | */ MemPage *pMove; releasePage(pPage); rc = sqlite3BtreeGetPage(pBt, maxRootPgno, &pMove, 0); if( rc!=SQLITE_OK ){ return rc; } | | | 38771 38772 38773 38774 38775 38776 38777 38778 38779 38780 38781 38782 38783 38784 38785 | */ MemPage *pMove; releasePage(pPage); rc = sqlite3BtreeGetPage(pBt, maxRootPgno, &pMove, 0); if( rc!=SQLITE_OK ){ return rc; } rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0); releasePage(pMove); if( rc!=SQLITE_OK ){ return rc; } rc = sqlite3BtreeGetPage(pBt, maxRootPgno, &pMove, 0); if( rc!=SQLITE_OK ){ return rc; |
︙ | ︙ | |||
37869 37870 37871 37872 37873 37874 37875 37876 37877 37878 37879 37880 37881 37882 | sqlite3StrAccumAppend(&pCheck->errMsg, "\n", 1); } if( zMsg1 ){ sqlite3StrAccumAppend(&pCheck->errMsg, zMsg1, -1); } sqlite3VXPrintf(&pCheck->errMsg, 1, zFormat, ap); va_end(ap); } #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ #ifndef SQLITE_OMIT_INTEGRITY_CHECK /* ** Add 1 to the reference count for page iPage. If this is the second ** reference to the page, add an error message to pCheck->zErrMsg. | > > > | 38958 38959 38960 38961 38962 38963 38964 38965 38966 38967 38968 38969 38970 38971 38972 38973 38974 | sqlite3StrAccumAppend(&pCheck->errMsg, "\n", 1); } if( zMsg1 ){ sqlite3StrAccumAppend(&pCheck->errMsg, zMsg1, -1); } sqlite3VXPrintf(&pCheck->errMsg, 1, zFormat, ap); va_end(ap); if( pCheck->errMsg.mallocFailed ){ pCheck->mallocFailed = 1; } } #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ #ifndef SQLITE_OMIT_INTEGRITY_CHECK /* ** Add 1 to the reference count for page iPage. If this is the second ** reference to the page, add an error message to pCheck->zErrMsg. |
︙ | ︙ | |||
38112 38113 38114 38115 38116 38117 38118 | } /* Check for complete coverage of the page */ data = pPage->aData; hdr = pPage->hdrOffset; hit = sqlite3PageMalloc( pBt->pageSize ); | | > > | 39204 39205 39206 39207 39208 39209 39210 39211 39212 39213 39214 39215 39216 39217 39218 39219 39220 | } /* Check for complete coverage of the page */ data = pPage->aData; hdr = pPage->hdrOffset; hit = sqlite3PageMalloc( pBt->pageSize ); if( hit==0 ){ pCheck->mallocFailed = 1; }else{ memset(hit, 0, usableSize ); memset(hit, 1, get2byte(&data[hdr+5])); nCell = get2byte(&data[hdr+3]); cellStart = hdr + 12 - 4*pPage->leaf; for(i=0; i<nCell; i++){ int pc = get2byte(&data[cellStart+i*2]); u16 size = cellSizePtr(pPage, &data[pc]); |
︙ | ︙ | |||
38168 38169 38170 38171 38172 38173 38174 | #ifndef SQLITE_OMIT_INTEGRITY_CHECK /* ** This routine does a complete check of the given BTree file. aRoot[] is ** an array of pages numbers were each page number is the root page of ** a table. nRoot is the number of entries in aRoot. ** | | | > | < > | > | < | 39262 39263 39264 39265 39266 39267 39268 39269 39270 39271 39272 39273 39274 39275 39276 39277 39278 39279 39280 39281 39282 39283 39284 39285 39286 39287 39288 39289 39290 39291 39292 39293 39294 39295 39296 39297 39298 39299 39300 39301 39302 39303 39304 39305 39306 39307 39308 39309 39310 39311 39312 39313 39314 39315 39316 39317 39318 39319 39320 39321 39322 39323 39324 | #ifndef SQLITE_OMIT_INTEGRITY_CHECK /* ** This routine does a complete check of the given BTree file. aRoot[] is ** an array of pages numbers were each page number is the root page of ** a table. nRoot is the number of entries in aRoot. ** ** Write the number of error seen in *pnErr. Except for some memory ** allocation errors, nn error message is held in memory obtained from ** malloc is returned if *pnErr is non-zero. If *pnErr==0 then NULL is ** returned. */ SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck( Btree *p, /* The btree to be checked */ int *aRoot, /* An array of root pages numbers for individual trees */ int nRoot, /* Number of entries in aRoot[] */ int mxErr, /* Stop reporting errors after this many */ int *pnErr /* Write number of errors seen to this variable */ ){ int i; int nRef; IntegrityCk sCheck; BtShared *pBt = p->pBt; char zErr[100]; sqlite3BtreeEnter(p); pBt->db = p->db; nRef = sqlite3PagerRefcount(pBt->pPager); if( lockBtreeWithRetry(p)!=SQLITE_OK ){ *pnErr = 1; sqlite3BtreeLeave(p); return sqlite3DbStrDup(0, "cannot acquire a read lock on the database"); } sCheck.pBt = pBt; sCheck.pPager = pBt->pPager; sCheck.nPage = pagerPagecount(sCheck.pPager); sCheck.mxErr = mxErr; sCheck.nErr = 0; sCheck.mallocFailed = 0; *pnErr = 0; #ifndef SQLITE_OMIT_AUTOVACUUM if( pBt->nTrunc!=0 ){ sCheck.nPage = pBt->nTrunc; } #endif if( sCheck.nPage==0 ){ unlockBtreeIfUnused(pBt); sqlite3BtreeLeave(p); return 0; } sCheck.anRef = sqlite3Malloc( (sCheck.nPage+1)*sizeof(sCheck.anRef[0]) ); if( !sCheck.anRef ){ unlockBtreeIfUnused(pBt); *pnErr = 1; sqlite3BtreeLeave(p); return 0; } for(i=0; i<=sCheck.nPage; i++){ sCheck.anRef[i] = 0; } i = PENDING_BYTE_PAGE(pBt); if( i<=sCheck.nPage ){ sCheck.anRef[i] = 1; } sqlite3StrAccumInit(&sCheck.errMsg, zErr, sizeof(zErr), 20000); |
︙ | ︙ | |||
38277 38278 38279 38280 38281 38282 38283 38284 38285 38286 38287 38288 38289 38290 | ); } /* Clean up and report errors. */ sqlite3BtreeLeave(p); sqlite3_free(sCheck.anRef); *pnErr = sCheck.nErr; if( sCheck.nErr==0 ) sqlite3StrAccumReset(&sCheck.errMsg); return sqlite3StrAccumFinish(&sCheck.errMsg); } #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ /* | > > > > > | 39372 39373 39374 39375 39376 39377 39378 39379 39380 39381 39382 39383 39384 39385 39386 39387 39388 39389 39390 | ); } /* Clean up and report errors. */ sqlite3BtreeLeave(p); sqlite3_free(sCheck.anRef); if( sCheck.mallocFailed ){ sqlite3StrAccumReset(&sCheck.errMsg); *pnErr = sCheck.nErr+1; return 0; } *pnErr = sCheck.nErr; if( sCheck.nErr==0 ) sqlite3StrAccumReset(&sCheck.errMsg); return sqlite3StrAccumFinish(&sCheck.errMsg); } #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ /* |
︙ | ︙ | |||
38702 38703 38704 38705 38706 38707 38708 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file implements a FIFO queue of rowids used for processing ** UPDATE and DELETE statements. ** | | | | | > | > | | 39802 39803 39804 39805 39806 39807 39808 39809 39810 39811 39812 39813 39814 39815 39816 39817 39818 39819 39820 39821 39822 39823 39824 39825 39826 39827 39828 39829 39830 39831 39832 39833 39834 39835 39836 39837 39838 39839 39840 39841 39842 39843 39844 39845 39846 39847 39848 39849 39850 39851 39852 39853 39854 39855 39856 39857 39858 39859 39860 39861 39862 39863 39864 39865 39866 39867 39868 39869 39870 39871 39872 39873 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file implements a FIFO queue of rowids used for processing ** UPDATE and DELETE statements. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** Constants FIFOSIZE_FIRST and FIFOSIZE_MAX are the initial ** number of entries in a fifo page and the maximum number of ** entries in a fifo page. */ #define FIFOSIZE_FIRST (((128-sizeof(FifoPage))/8)+1) #ifdef SQLITE_MALLOC_SOFT_LIMIT # define FIFOSIZE_MAX (((SQLITE_MALLOC_SOFT_LIMIT-sizeof(FifoPage))/8)+1) #else # define FIFOSIZE_MAX (((262144-sizeof(FifoPage))/8)+1) #endif /* ** Allocate a new FifoPage and return a pointer to it. Return NULL if ** we run out of memory. Leave space on the page for nEntry entries. */ static FifoPage *allocateFifoPage(sqlite3 *db, int nEntry){ FifoPage *pPage; if( nEntry>FIFOSIZE_MAX ){ nEntry = FIFOSIZE_MAX; } pPage = sqlite3DbMallocRaw(db, sizeof(FifoPage) + sizeof(i64)*(nEntry-1) ); if( pPage ){ pPage->nSlot = nEntry; pPage->iWrite = 0; pPage->iRead = 0; pPage->pNext = 0; } return pPage; } /* ** Initialize a Fifo structure. */ SQLITE_PRIVATE void sqlite3VdbeFifoInit(Fifo *pFifo, sqlite3 *db){ memset(pFifo, 0, sizeof(*pFifo)); pFifo->db = db; } /* ** Push a single 64-bit integer value into the Fifo. Return SQLITE_OK ** normally. SQLITE_NOMEM is returned if we are unable to allocate ** memory. */ SQLITE_PRIVATE int sqlite3VdbeFifoPush(Fifo *pFifo, i64 val){ FifoPage *pPage; pPage = pFifo->pLast; if( pPage==0 ){ pPage = pFifo->pLast = pFifo->pFirst = allocateFifoPage(pFifo->db, FIFOSIZE_FIRST); if( pPage==0 ){ return SQLITE_NOMEM; } }else if( pPage->iWrite>=pPage->nSlot ){ pPage->pNext = allocateFifoPage(pFifo->db, pFifo->nEntry); if( pPage->pNext==0 ){ return SQLITE_NOMEM; } pPage = pFifo->pLast = pPage->pNext; } pPage->aSlot[pPage->iWrite++] = val; pFifo->nEntry++; |
︙ | ︙ | |||
38789 38790 38791 38792 38793 38794 38795 | assert( pPage->iWrite<=pPage->nSlot ); assert( pPage->iRead<pPage->nSlot ); assert( pPage->iRead>=0 ); *pVal = pPage->aSlot[pPage->iRead++]; pFifo->nEntry--; if( pPage->iRead>=pPage->iWrite ){ pFifo->pFirst = pPage->pNext; | | | | | 39891 39892 39893 39894 39895 39896 39897 39898 39899 39900 39901 39902 39903 39904 39905 39906 39907 39908 39909 39910 39911 39912 39913 39914 39915 39916 39917 39918 39919 39920 39921 39922 39923 39924 39925 39926 39927 39928 | assert( pPage->iWrite<=pPage->nSlot ); assert( pPage->iRead<pPage->nSlot ); assert( pPage->iRead>=0 ); *pVal = pPage->aSlot[pPage->iRead++]; pFifo->nEntry--; if( pPage->iRead>=pPage->iWrite ){ pFifo->pFirst = pPage->pNext; sqlite3DbFree(pFifo->db, pPage); if( pFifo->nEntry==0 ){ assert( pFifo->pLast==pPage ); pFifo->pLast = 0; }else{ assert( pFifo->pFirst!=0 ); } }else{ assert( pFifo->nEntry>0 ); } return SQLITE_OK; } /* ** Delete all information from a Fifo object. Free all memory held ** by the Fifo. */ SQLITE_PRIVATE void sqlite3VdbeFifoClear(Fifo *pFifo){ FifoPage *pPage, *pNextPage; for(pPage=pFifo->pFirst; pPage; pPage=pNextPage){ pNextPage = pPage->pNext; sqlite3DbFree(pFifo->db, pPage); } sqlite3VdbeFifoInit(pFifo, pFifo->db); } /************** End of vdbefifo.c ********************************************/ /************** Begin file vdbemem.c *****************************************/ /* ** 2004 May 26 ** |
︙ | ︙ | |||
38834 38835 38836 38837 38838 38839 38840 | ************************************************************************* ** ** This file contains code use to manipulate "Mem" structure. A "Mem" ** stores a single value in the VDBE. Mem is an opaque structure visible ** only within the VDBE. Interface routines refer to a Mem using the ** name sqlite_value ** | | | 39936 39937 39938 39939 39940 39941 39942 39943 39944 39945 39946 39947 39948 39949 39950 | ************************************************************************* ** ** This file contains code use to manipulate "Mem" structure. A "Mem" ** stores a single value in the VDBE. Mem is an opaque structure visible ** only within the VDBE. Interface routines refer to a Mem using the ** name sqlite_value ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem*) ** P if required. */ #define expandBlob(P) (((P)->flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0) |
︙ | ︙ | |||
38899 38900 38901 38902 38903 38904 38905 | ((pMem->zMalloc && pMem->zMalloc==pMem->z) ? 1 : 0) + (((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) + ((pMem->flags&MEM_Ephem) ? 1 : 0) + ((pMem->flags&MEM_Static) ? 1 : 0) ); if( n<32 ) n = 32; | | | | > > > | | 40001 40002 40003 40004 40005 40006 40007 40008 40009 40010 40011 40012 40013 40014 40015 40016 40017 40018 40019 40020 40021 40022 40023 40024 40025 40026 40027 40028 40029 40030 40031 40032 40033 40034 40035 40036 40037 40038 40039 40040 40041 40042 40043 40044 40045 40046 40047 40048 40049 | ((pMem->zMalloc && pMem->zMalloc==pMem->z) ? 1 : 0) + (((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) + ((pMem->flags&MEM_Ephem) ? 1 : 0) + ((pMem->flags&MEM_Static) ? 1 : 0) ); if( n<32 ) n = 32; if( sqlite3DbMallocSize(pMem->db, pMem->zMalloc)<n ){ if( preserve && pMem->z==pMem->zMalloc ){ pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n); if( !pMem->z ){ pMem->flags = MEM_Null; } preserve = 0; }else{ sqlite3DbFree(pMem->db, pMem->zMalloc); pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n); } } if( preserve && pMem->z && pMem->zMalloc && pMem->z!=pMem->zMalloc ){ memcpy(pMem->zMalloc, pMem->z, pMem->n); } if( pMem->flags&MEM_Dyn && pMem->xDel ){ pMem->xDel((void *)(pMem->z)); } pMem->z = pMem->zMalloc; pMem->flags &= ~(MEM_Ephem|MEM_Static); pMem->xDel = 0; return (pMem->z ? SQLITE_OK : SQLITE_NOMEM); } /* ** Make the given Mem object MEM_Dyn. In other words, make it so ** that any TEXT or BLOB content is stored in memory obtained from ** malloc(). In this way, we know that the memory is safe to be ** overwritten or altered. ** ** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails. */ SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){ int f; assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); expandBlob(pMem); f = pMem->flags; if( (f&(MEM_Str|MEM_Blob)) && pMem->z!=pMem->zMalloc ){ if( sqlite3VdbeMemGrow(pMem, pMem->n + 2, 1) ){ return SQLITE_NOMEM; |
︙ | ︙ | |||
38976 38977 38978 38979 38980 38981 38982 | pMem->flags &= ~(MEM_Zero|MEM_Term); } return SQLITE_OK; } #endif | < < < < < < < < < < | 40081 40082 40083 40084 40085 40086 40087 40088 40089 40090 40091 40092 40093 40094 | pMem->flags &= ~(MEM_Zero|MEM_Term); } return SQLITE_OK; } #endif /* ** Make sure the given Mem is \u0000 terminated. */ SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){ assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); if( (pMem->flags & MEM_Term)!=0 || (pMem->flags & MEM_Str)==0 ){ return SQLITE_OK; /* Nothing to do */ |
︙ | ︙ | |||
39071 39072 39073 39074 39075 39076 39077 | ctx.s.db = pMem->db; ctx.s.zMalloc = 0; ctx.pMem = pMem; ctx.pFunc = pFunc; ctx.isError = 0; pFunc->xFinalize(&ctx); assert( 0==(pMem->flags&MEM_Dyn) && !pMem->xDel ); | | | 40166 40167 40168 40169 40170 40171 40172 40173 40174 40175 40176 40177 40178 40179 40180 | ctx.s.db = pMem->db; ctx.s.zMalloc = 0; ctx.pMem = pMem; ctx.pFunc = pFunc; ctx.isError = 0; pFunc->xFinalize(&ctx); assert( 0==(pMem->flags&MEM_Dyn) && !pMem->xDel ); sqlite3DbFree(pMem->db, pMem->zMalloc); *pMem = ctx.s; rc = (ctx.isError?SQLITE_ERROR:SQLITE_OK); } return rc; } /* |
︙ | ︙ | |||
39102 39103 39104 39105 39106 39107 39108 | /* ** Release any memory held by the Mem. This may leave the Mem in an ** inconsistent state, for example with (Mem.z==0) and ** (Mem.type==SQLITE_TEXT). */ SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){ sqlite3VdbeMemReleaseExternal(p); | | | 40197 40198 40199 40200 40201 40202 40203 40204 40205 40206 40207 40208 40209 40210 40211 | /* ** Release any memory held by the Mem. This may leave the Mem in an ** inconsistent state, for example with (Mem.z==0) and ** (Mem.type==SQLITE_TEXT). */ SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){ sqlite3VdbeMemReleaseExternal(p); sqlite3DbFree(p->db, p->zMalloc); p->z = 0; p->zMalloc = 0; p->xDel = 0; } /* ** Convert a 64-bit IEEE double into a 64-bit signed integer. |
︙ | ︙ | |||
39447 39448 39449 39450 39451 39452 39453 39454 39455 39456 39457 39458 39459 39460 | if( flags&MEM_Term ){ nAlloc += (enc==SQLITE_UTF8?1:2); } if( sqlite3VdbeMemGrow(pMem, nAlloc, 0) ){ return SQLITE_NOMEM; } memcpy(pMem->z, z, nAlloc); }else{ sqlite3VdbeMemRelease(pMem); pMem->z = (char *)z; pMem->xDel = xDel; flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn); } | > > > > | 40542 40543 40544 40545 40546 40547 40548 40549 40550 40551 40552 40553 40554 40555 40556 40557 40558 40559 | if( flags&MEM_Term ){ nAlloc += (enc==SQLITE_UTF8?1:2); } if( sqlite3VdbeMemGrow(pMem, nAlloc, 0) ){ return SQLITE_NOMEM; } memcpy(pMem->z, z, nAlloc); }else if( xDel==SQLITE_DYNAMIC ){ sqlite3VdbeMemRelease(pMem); pMem->zMalloc = pMem->z = (char *)z; pMem->xDel = 0; }else{ sqlite3VdbeMemRelease(pMem); pMem->z = (char *)z; pMem->xDel = xDel; flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn); } |
︙ | ︙ | |||
39782 39783 39784 39785 39786 39787 39788 | if( !pExpr ){ *ppVal = 0; return SQLITE_OK; } op = pExpr->op; if( op==TK_STRING || op==TK_FLOAT || op==TK_INTEGER ){ | | | | 40881 40882 40883 40884 40885 40886 40887 40888 40889 40890 40891 40892 40893 40894 40895 40896 40897 40898 40899 | if( !pExpr ){ *ppVal = 0; return SQLITE_OK; } op = pExpr->op; if( op==TK_STRING || op==TK_FLOAT || op==TK_INTEGER ){ zVal = sqlite3DbStrNDup(db, (char*)pExpr->token.z, pExpr->token.n); pVal = sqlite3ValueNew(db); if( !zVal || !pVal ) goto no_mem; sqlite3Dequote(zVal); sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC); if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_NONE ){ sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, enc); }else{ sqlite3ValueApplyAffinity(pVal, affinity, enc); } }else if( op==TK_UMINUS ) { if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) ){ |
︙ | ︙ | |||
39809 39810 39811 39812 39813 39814 39815 | assert( pExpr->token.z[0]=='x' || pExpr->token.z[0]=='X' ); assert( pExpr->token.z[1]=='\'' ); assert( pExpr->token.z[pExpr->token.n-1]=='\'' ); pVal = sqlite3ValueNew(db); nVal = pExpr->token.n - 3; zVal = (char*)pExpr->token.z + 2; sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2, | | | | 40908 40909 40910 40911 40912 40913 40914 40915 40916 40917 40918 40919 40920 40921 40922 40923 40924 40925 40926 40927 40928 40929 40930 40931 | assert( pExpr->token.z[0]=='x' || pExpr->token.z[0]=='X' ); assert( pExpr->token.z[1]=='\'' ); assert( pExpr->token.z[pExpr->token.n-1]=='\'' ); pVal = sqlite3ValueNew(db); nVal = pExpr->token.n - 3; zVal = (char*)pExpr->token.z + 2; sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2, 0, SQLITE_DYNAMIC); } #endif *ppVal = pVal; return SQLITE_OK; no_mem: db->mallocFailed = 1; sqlite3DbFree(db, zVal); sqlite3ValueFree(pVal); *ppVal = 0; return SQLITE_NOMEM; } /* ** Change the string value of an sqlite3_value object |
︙ | ︙ | |||
39843 39844 39845 39846 39847 39848 39849 | /* ** Free an sqlite3_value object */ SQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value *v){ if( !v ) return; sqlite3VdbeMemRelease((Mem *)v); | | | 40942 40943 40944 40945 40946 40947 40948 40949 40950 40951 40952 40953 40954 40955 40956 | /* ** Free an sqlite3_value object */ SQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value *v){ if( !v ) return; sqlite3VdbeMemRelease((Mem *)v); sqlite3DbFree(((Mem*)v)->db, v); } /* ** Return the number of bytes in the sqlite3_value object assuming ** that it uses the encoding "enc" */ SQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value *pVal, u8 enc){ |
︙ | ︙ | |||
39880 39881 39882 39883 39884 39885 39886 | ** ************************************************************************* ** This file contains code used for creating, destroying, and populating ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior ** to version 2.8.7, all this code was combined into the vdbe.c source file. ** But that file was getting too big so this subroutines were split out. ** | | | 40979 40980 40981 40982 40983 40984 40985 40986 40987 40988 40989 40990 40991 40992 40993 | ** ************************************************************************* ** This file contains code used for creating, destroying, and populating ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior ** to version 2.8.7, all this code was combined into the vdbe.c source file. ** But that file was getting too big so this subroutines were split out. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** When debugging the code generator in a symbolic debugger, one can ** set the sqlite3VdbeAddopTrace to 1 and all opcodes will be printed |
︙ | ︙ | |||
40165 40166 40167 40168 40169 40170 40171 | } if( sqlite3VdbeOpcodeHasProperty(opcode, OPFLG_JUMP) && pOp->p2<0 ){ assert( -1-pOp->p2<p->nLabel ); pOp->p2 = aLabel[-1-pOp->p2]; } } | | | 41264 41265 41266 41267 41268 41269 41270 41271 41272 41273 41274 41275 41276 41277 41278 | } if( sqlite3VdbeOpcodeHasProperty(opcode, OPFLG_JUMP) && pOp->p2<0 ){ assert( -1-pOp->p2<p->nLabel ); pOp->p2 = aLabel[-1-pOp->p2]; } } sqlite3DbFree(p->db, p->aLabel); p->aLabel = 0; *pMaxFuncArgs = nMaxArgs; /* If we never rollback a statement transaction, then statement ** transactions are not needed. So change every OP_Statement ** opcode into an OP_Noop. This avoid a call to sqlite3OsOpenExclusive() |
︙ | ︙ | |||
40295 40296 40297 40298 40299 40300 40301 | } /* ** If the input FuncDef structure is ephemeral, then free it. If ** the FuncDef is not ephermal, then do nothing. */ | | | | | | | | > | | 41394 41395 41396 41397 41398 41399 41400 41401 41402 41403 41404 41405 41406 41407 41408 41409 41410 41411 41412 41413 41414 41415 41416 41417 41418 41419 41420 41421 41422 41423 41424 41425 41426 41427 41428 41429 41430 41431 41432 41433 41434 41435 41436 41437 41438 41439 41440 41441 41442 41443 41444 41445 41446 41447 41448 41449 41450 41451 41452 41453 41454 41455 41456 41457 41458 | } /* ** If the input FuncDef structure is ephemeral, then free it. If ** the FuncDef is not ephermal, then do nothing. */ static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){ if( pDef && (pDef->flags & SQLITE_FUNC_EPHEM)!=0 ){ sqlite3DbFree(db, pDef); } } /* ** Delete a P4 value if necessary. */ static void freeP4(sqlite3 *db, int p4type, void *p4){ if( p4 ){ switch( p4type ){ case P4_REAL: case P4_INT64: case P4_MPRINTF: case P4_DYNAMIC: case P4_KEYINFO: case P4_INTARRAY: case P4_KEYINFO_HANDOFF: { sqlite3DbFree(db, p4); break; } case P4_VDBEFUNC: { VdbeFunc *pVdbeFunc = (VdbeFunc *)p4; freeEphemeralFunction(db, pVdbeFunc->pFunc); sqlite3VdbeDeleteAuxData(pVdbeFunc, 0); sqlite3DbFree(db, pVdbeFunc); break; } case P4_FUNCDEF: { freeEphemeralFunction(db, (FuncDef*)p4); break; } case P4_MEM: { sqlite3ValueFree((sqlite3_value*)p4); break; } } } } /* ** Change N opcodes starting at addr to No-ops. */ SQLITE_PRIVATE void sqlite3VdbeChangeToNoop(Vdbe *p, int addr, int N){ if( p && p->aOp ){ VdbeOp *pOp = &p->aOp[addr]; sqlite3 *db = p->db; while( N-- ){ freeP4(db, pOp->p4type, pOp->p4.p); memset(pOp, 0, sizeof(pOp[0])); pOp->opcode = OP_Noop; pOp++; } } } |
︙ | ︙ | |||
40379 40380 40381 40382 40383 40384 40385 40386 40387 | ** to a string or structure that is guaranteed to exist for the lifetime of ** the Vdbe. In these cases we can just copy the pointer. ** ** If addr<0 then change P4 on the most recently inserted instruction. */ SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){ Op *pOp; assert( p!=0 ); assert( p->magic==VDBE_MAGIC_INIT ); | > > | | | | 41479 41480 41481 41482 41483 41484 41485 41486 41487 41488 41489 41490 41491 41492 41493 41494 41495 41496 41497 41498 41499 41500 41501 41502 41503 41504 41505 41506 41507 41508 41509 | ** to a string or structure that is guaranteed to exist for the lifetime of ** the Vdbe. In these cases we can just copy the pointer. ** ** If addr<0 then change P4 on the most recently inserted instruction. */ SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){ Op *pOp; sqlite3 *db; assert( p!=0 ); db = p->db; assert( p->magic==VDBE_MAGIC_INIT ); if( p->aOp==0 || db->mallocFailed ){ if (n != P4_KEYINFO) { freeP4(db, n, (void*)*(char**)&zP4); } return; } assert( addr<p->nOp ); if( addr<0 ){ addr = p->nOp - 1; if( addr<0 ) return; } pOp = &p->aOp[addr]; freeP4(db, pOp->p4type, pOp->p4.p); pOp->p4.p = 0; if( n==P4_INT32 ){ /* Note: this cast is safe, because the origin data point was an int ** that was cast to a (const char *). */ pOp->p4.i = SQLITE_PTR_TO_INT(zP4); pOp->p4type = n; }else if( zP4==0 ){ |
︙ | ︙ | |||
40451 40452 40453 40454 40455 40456 40457 | SQLITE_PRIVATE void sqlite3VdbeComment(Vdbe *p, const char *zFormat, ...){ va_list ap; assert( p->nOp>0 || p->aOp==0 ); assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed ); if( p->nOp ){ char **pz = &p->aOp[p->nOp-1].zComment; va_start(ap, zFormat); | | | | 41553 41554 41555 41556 41557 41558 41559 41560 41561 41562 41563 41564 41565 41566 41567 41568 41569 41570 41571 41572 41573 41574 41575 41576 41577 41578 41579 41580 | SQLITE_PRIVATE void sqlite3VdbeComment(Vdbe *p, const char *zFormat, ...){ va_list ap; assert( p->nOp>0 || p->aOp==0 ); assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed ); if( p->nOp ){ char **pz = &p->aOp[p->nOp-1].zComment; va_start(ap, zFormat); sqlite3DbFree(p->db, *pz); *pz = sqlite3VMPrintf(p->db, zFormat, ap); va_end(ap); } } SQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe *p, const char *zFormat, ...){ va_list ap; sqlite3VdbeAddOp0(p, OP_Noop); assert( p->nOp>0 || p->aOp==0 ); assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed ); if( p->nOp ){ char **pz = &p->aOp[p->nOp-1].zComment; va_start(ap, zFormat); sqlite3DbFree(p->db, *pz); *pz = sqlite3VMPrintf(p->db, zFormat, ap); va_end(ap); } } #endif /* NDEBUG */ /* |
︙ | ︙ | |||
40619 40620 40621 40622 40623 40624 40625 | fflush(pOut); } #endif /* ** Release an array of N Mem elements */ | | < | < < < | | 41721 41722 41723 41724 41725 41726 41727 41728 41729 41730 41731 41732 41733 41734 41735 41736 41737 41738 41739 41740 41741 41742 41743 41744 41745 41746 41747 41748 41749 41750 41751 41752 41753 41754 41755 41756 41757 41758 | fflush(pOut); } #endif /* ** Release an array of N Mem elements */ static void releaseMemArray(Mem *p, int N){ if( p && N ){ sqlite3 *db = p->db; int malloc_failed = db->mallocFailed; while( N-->0 ){ assert( N<2 || p[0].db==p[1].db ); sqlite3VdbeMemRelease(p); p->flags = MEM_Null; p++; } db->mallocFailed = malloc_failed; } } #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT SQLITE_PRIVATE int sqlite3VdbeReleaseBuffers(Vdbe *p){ int ii; int nFree = 0; assert( sqlite3_mutex_held(p->db->mutex) ); for(ii=1; ii<=p->nMem; ii++){ Mem *pMem = &p->aMem[ii]; if( pMem->z && pMem->flags&MEM_Dyn ){ assert( !pMem->xDel ); nFree += sqlite3DbMallocSize(pMem->db, pMem->z); sqlite3VdbeMemRelease(pMem); } } return nFree; } #endif |
︙ | ︙ | |||
40684 40685 40686 40687 40688 40689 40690 | assert( db->magic==SQLITE_MAGIC_BUSY ); assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY ); /* Even though this opcode does not use dynamic strings for ** the result, result columns may become dynamic if the user calls ** sqlite3_column_text16(), causing a translation to UTF-16 encoding. */ | | | 41782 41783 41784 41785 41786 41787 41788 41789 41790 41791 41792 41793 41794 41795 41796 | assert( db->magic==SQLITE_MAGIC_BUSY ); assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY ); /* Even though this opcode does not use dynamic strings for ** the result, result columns may become dynamic if the user calls ** sqlite3_column_text16(), causing a translation to UTF-16 encoding. */ releaseMemArray(pMem, p->nMem); do{ i = p->pc++; }while( i<p->nOp && p->explain==2 && p->aOp[i].opcode!=OP_Explain ); if( i>=p->nOp ){ p->rc = SQLITE_OK; rc = SQLITE_DONE; |
︙ | ︙ | |||
40965 40966 40967 40968 40969 40970 40971 | (void)sqlite3SafetyOff(p->db); pModule->xClose(pVtabCursor); (void)sqlite3SafetyOn(p->db); p->inVtabMethod = 0; } #endif if( !pCx->ephemPseudoTable ){ | | < < < | 42063 42064 42065 42066 42067 42068 42069 42070 42071 42072 42073 42074 42075 42076 42077 42078 | (void)sqlite3SafetyOff(p->db); pModule->xClose(pVtabCursor); (void)sqlite3SafetyOn(p->db); p->inVtabMethod = 0; } #endif if( !pCx->ephemPseudoTable ){ sqlite3DbFree(p->db, pCx->pData); } } /* ** Close all cursors except for VTab cursors that are currently ** in use. */ static void closeAllCursorsExceptActiveVtabs(Vdbe *p){ |
︙ | ︙ | |||
40995 40996 40997 40998 40999 41000 41001 | /* ** Clean up the VM after execution. ** ** This routine will automatically close any cursors, lists, and/or ** sorters that were left open. It also deletes the values of ** variables in the aVar[] array. */ | | > | | | > | | | | | 42090 42091 42092 42093 42094 42095 42096 42097 42098 42099 42100 42101 42102 42103 42104 42105 42106 42107 42108 42109 42110 42111 42112 42113 42114 42115 42116 42117 42118 42119 42120 42121 42122 42123 42124 42125 42126 42127 42128 42129 42130 42131 42132 42133 42134 42135 42136 42137 42138 42139 42140 42141 42142 42143 42144 42145 42146 42147 42148 42149 42150 42151 42152 42153 42154 42155 42156 42157 42158 42159 | /* ** Clean up the VM after execution. ** ** This routine will automatically close any cursors, lists, and/or ** sorters that were left open. It also deletes the values of ** variables in the aVar[] array. */ static void Cleanup(Vdbe *p){ int i; sqlite3 *db = p->db; closeAllCursorsExceptActiveVtabs(p); for(i=1; i<=p->nMem; i++){ MemSetTypeFlag(&p->aMem[i], MEM_Null); } releaseMemArray(&p->aMem[1], p->nMem); sqlite3VdbeFifoClear(&p->sFifo); if( p->contextStack ){ for(i=0; i<p->contextStackTop; i++){ sqlite3VdbeFifoClear(&p->contextStack[i].sFifo); } sqlite3DbFree(db, p->contextStack); } p->contextStack = 0; p->contextStackDepth = 0; p->contextStackTop = 0; sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = 0; p->pResultSet = 0; } /* ** Set the number of result columns that will be returned by this SQL ** statement. This is now set at compile time, rather than during ** execution of the vdbe program so that sqlite3_column_count() can ** be called on an SQL statement before sqlite3_step(). */ SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){ Mem *pColName; int n; sqlite3 *db = p->db; releaseMemArray(p->aColName, p->nResColumn*COLNAME_N); sqlite3DbFree(db, p->aColName); n = nResColumn*COLNAME_N; p->nResColumn = nResColumn; p->aColName = pColName = (Mem*)sqlite3DbMallocZero(db, sizeof(Mem)*n ); if( p->aColName==0 ) return; while( n-- > 0 ){ pColName->flags = MEM_Null; pColName->db = p->db; pColName++; } } /* ** Set the name of the idx'th column to be returned by the SQL statement. ** zName must be a pointer to a nul terminated string. ** ** This call must be made after a call to sqlite3VdbeSetNumCols(). ** ** If N==P4_STATIC it means that zName is a pointer to a constant static ** string and we can just copy the pointer. If it is P4_DYNAMIC, then ** the string is freed using sqlite3DbFree(db, ) when the vdbe is finished with ** it. Otherwise, N bytes of zName are copied. */ SQLITE_PRIVATE int sqlite3VdbeSetColName(Vdbe *p, int idx, int var, const char *zName, int N){ int rc; Mem *pColName; assert( idx<p->nResColumn ); assert( var<COLNAME_N ); |
︙ | ︙ | |||
41077 41078 41079 41080 41081 41082 41083 | /* ** A read or write transaction may or may not be active on database handle ** db. If a transaction is active, commit it. If there is a ** write-transaction spanning more than one database file, this routine ** takes care of the master journal trickery. */ | | | | 42174 42175 42176 42177 42178 42179 42180 42181 42182 42183 42184 42185 42186 42187 42188 42189 42190 42191 42192 42193 42194 42195 42196 42197 42198 42199 42200 | /* ** A read or write transaction may or may not be active on database handle ** db. If a transaction is active, commit it. If there is a ** write-transaction spanning more than one database file, this routine ** takes care of the master journal trickery. */ static int vdbeCommit(sqlite3 *db, Vdbe *p){ int i; int nTrans = 0; /* Number of databases with an active write-transaction */ int rc = SQLITE_OK; int needXcommit = 0; /* Before doing anything else, call the xSync() callback for any ** virtual module tables written in this transaction. This has to ** be done before determining whether a master journal file is ** required, as an xSync() callback may add an attached database ** to the transaction. */ rc = sqlite3VtabSync(db, &p->zErrMsg); if( rc!=SQLITE_OK ){ return rc; } /* This loop determines (a) if the commit hook should be invoked and ** (b) how many database files have open write transactions, not ** including the temp database. (b) is important because if more than |
︙ | ︙ | |||
41168 41169 41170 41171 41172 41173 41174 | sqlite3_file *pMaster = 0; i64 offset = 0; int res; /* Select a master journal file name */ do { u32 random; | | | | 42265 42266 42267 42268 42269 42270 42271 42272 42273 42274 42275 42276 42277 42278 42279 42280 42281 42282 42283 42284 42285 42286 42287 42288 42289 42290 42291 42292 42293 42294 42295 | sqlite3_file *pMaster = 0; i64 offset = 0; int res; /* Select a master journal file name */ do { u32 random; sqlite3DbFree(db, zMaster); sqlite3_randomness(sizeof(random), &random); zMaster = sqlite3MPrintf(db, "%s-mj%08X", zMainFile, random&0x7fffffff); if( !zMaster ){ return SQLITE_NOMEM; } rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, &res); }while( rc==SQLITE_OK && res ); if( rc==SQLITE_OK ){ /* Open the master journal. */ rc = sqlite3OsOpenMalloc(pVfs, zMaster, &pMaster, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE| SQLITE_OPEN_EXCLUSIVE|SQLITE_OPEN_MASTER_JOURNAL, 0 ); } if( rc!=SQLITE_OK ){ sqlite3DbFree(db, zMaster); return rc; } /* Write the name of each database file in the transaction into the new ** master journal file. If an error occurs at this point close ** and delete the master journal file. All the individual journal files ** still have 'null' as the master journal pointer, so they will roll |
︙ | ︙ | |||
41208 41209 41210 41211 41212 41213 41214 | needSync = 1; } rc = sqlite3OsWrite(pMaster, zFile, strlen(zFile)+1, offset); offset += strlen(zFile)+1; if( rc!=SQLITE_OK ){ sqlite3OsCloseFree(pMaster); sqlite3OsDelete(pVfs, zMaster, 0); | | | | 42305 42306 42307 42308 42309 42310 42311 42312 42313 42314 42315 42316 42317 42318 42319 42320 42321 42322 42323 42324 42325 42326 42327 42328 42329 42330 42331 42332 42333 42334 | needSync = 1; } rc = sqlite3OsWrite(pMaster, zFile, strlen(zFile)+1, offset); offset += strlen(zFile)+1; if( rc!=SQLITE_OK ){ sqlite3OsCloseFree(pMaster); sqlite3OsDelete(pVfs, zMaster, 0); sqlite3DbFree(db, zMaster); return rc; } } } /* Sync the master journal file. If the IOCAP_SEQUENTIAL device ** flag is set this is not required. */ zMainFile = sqlite3BtreeGetDirname(db->aDb[0].pBt); if( (needSync && (0==(sqlite3OsDeviceCharacteristics(pMaster)&SQLITE_IOCAP_SEQUENTIAL)) && (rc=sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL))!=SQLITE_OK) ){ sqlite3OsCloseFree(pMaster); sqlite3OsDelete(pVfs, zMaster, 0); sqlite3DbFree(db, zMaster); return rc; } /* Sync all the db files involved in the transaction. The same call ** sets the master journal pointer in each individual journal. If ** an error occurs here, do not delete the master journal file. ** |
︙ | ︙ | |||
41245 41246 41247 41248 41249 41250 41251 | Btree *pBt = db->aDb[i].pBt; if( pBt ){ rc = sqlite3BtreeCommitPhaseOne(pBt, zMaster); } } sqlite3OsCloseFree(pMaster); if( rc!=SQLITE_OK ){ | | | | 42342 42343 42344 42345 42346 42347 42348 42349 42350 42351 42352 42353 42354 42355 42356 42357 42358 42359 42360 42361 42362 42363 42364 42365 | Btree *pBt = db->aDb[i].pBt; if( pBt ){ rc = sqlite3BtreeCommitPhaseOne(pBt, zMaster); } } sqlite3OsCloseFree(pMaster); if( rc!=SQLITE_OK ){ sqlite3DbFree(db, zMaster); return rc; } /* Delete the master journal file. This commits the transaction. After ** doing this the directory is synced again before any individual ** transaction files are deleted. */ rc = sqlite3OsDelete(pVfs, zMaster, 1); sqlite3DbFree(db, zMaster); zMaster = 0; if( rc ){ return rc; } /* All files and directories have already been synced, so the following ** calls to sqlite3BtreeCommitPhaseTwo() are only closing files and |
︙ | ︙ | |||
41453 41454 41455 41456 41457 41458 41459 | */ if( db->autoCommit && db->activeVdbeCnt==1 ){ if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){ /* The auto-commit flag is true, and the vdbe program was ** successful or hit an 'OR FAIL' constraint. This means a commit ** is required. */ | | | 42550 42551 42552 42553 42554 42555 42556 42557 42558 42559 42560 42561 42562 42563 42564 | */ if( db->autoCommit && db->activeVdbeCnt==1 ){ if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){ /* The auto-commit flag is true, and the vdbe program was ** successful or hit an 'OR FAIL' constraint. This means a commit ** is required. */ int rc = vdbeCommit(db, p); if( rc==SQLITE_BUSY ){ sqlite3BtreeMutexArrayLeave(&p->aMutex); return SQLITE_BUSY; }else if( rc!=SQLITE_OK ){ p->rc = rc; sqlite3RollbackAll(db); }else{ |
︙ | ︙ | |||
41496 41497 41498 41499 41500 41501 41502 | for(i=0; xFunc && i<db->nDb; i++){ int rc; Btree *pBt = db->aDb[i].pBt; if( pBt ){ rc = xFunc(pBt); if( rc && (p->rc==SQLITE_OK || p->rc==SQLITE_CONSTRAINT) ){ p->rc = rc; | | | 42593 42594 42595 42596 42597 42598 42599 42600 42601 42602 42603 42604 42605 42606 42607 | for(i=0; xFunc && i<db->nDb; i++){ int rc; Btree *pBt = db->aDb[i].pBt; if( pBt ){ rc = xFunc(pBt); if( rc && (p->rc==SQLITE_OK || p->rc==SQLITE_CONSTRAINT) ){ p->rc = rc; sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = 0; } } } /* If this was an INSERT, UPDATE or DELETE and the statement was committed, ** set the change counter. |
︙ | ︙ | |||
41557 41558 41559 41560 41561 41562 41563 | ** After this routine is run, the VDBE should be ready to be executed ** again. ** ** To look at it another way, this routine resets the state of the ** virtual machine from VDBE_MAGIC_RUN or VDBE_MAGIC_HALT back to ** VDBE_MAGIC_INIT. */ | | | > | > | | 42654 42655 42656 42657 42658 42659 42660 42661 42662 42663 42664 42665 42666 42667 42668 42669 42670 42671 42672 42673 42674 42675 42676 42677 42678 42679 42680 42681 42682 42683 42684 42685 42686 42687 42688 42689 42690 42691 42692 42693 42694 42695 42696 42697 42698 42699 42700 42701 42702 42703 42704 42705 42706 42707 42708 42709 | ** After this routine is run, the VDBE should be ready to be executed ** again. ** ** To look at it another way, this routine resets the state of the ** virtual machine from VDBE_MAGIC_RUN or VDBE_MAGIC_HALT back to ** VDBE_MAGIC_INIT. */ SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe *p){ sqlite3 *db; db = p->db; /* If the VM did not run to completion or if it encountered an ** error, then it might not have been halted properly. So halt ** it now. */ (void)sqlite3SafetyOn(db); sqlite3VdbeHalt(p); (void)sqlite3SafetyOff(db); /* If the VDBE has be run even partially, then transfer the error code ** and error message from the VDBE into the main database structure. But ** if the VDBE has just been set to run but has not actually executed any ** instructions yet, leave the main database error information unchanged. */ if( p->pc>=0 ){ if( p->zErrMsg ){ sqlite3ValueSetStr(db->pErr,-1,p->zErrMsg,SQLITE_UTF8,SQLITE_TRANSIENT); db->errCode = p->rc; sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = 0; }else if( p->rc ){ sqlite3Error(db, p->rc, 0); }else{ sqlite3Error(db, SQLITE_OK, 0); } }else if( p->rc && p->expired ){ /* The expired flag was set on the VDBE before the first call ** to sqlite3_step(). For consistency (since sqlite3_step() was ** called), set the database error in this case as well. */ sqlite3Error(db, p->rc, 0); sqlite3ValueSetStr(db->pErr, -1, p->zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT); sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = 0; } /* Reclaim all memory used by the VDBE */ Cleanup(p); /* Save profiling information from this VDBE run. */ #ifdef VDBE_PROFILE { FILE *out = fopen("vdbe_profile.out", "a"); if( out ){ |
︙ | ︙ | |||
41623 41624 41625 41626 41627 41628 41629 | sqlite3VdbePrintOp(out, i, &p->aOp[i]); } fclose(out); } } #endif p->magic = VDBE_MAGIC_INIT; | < | < | 42722 42723 42724 42725 42726 42727 42728 42729 42730 42731 42732 42733 42734 42735 42736 42737 42738 42739 42740 42741 42742 42743 42744 42745 42746 42747 42748 42749 42750 | sqlite3VdbePrintOp(out, i, &p->aOp[i]); } fclose(out); } } #endif p->magic = VDBE_MAGIC_INIT; return p->rc & db->errMask; } /* ** Clean up and delete a VDBE after execution. Return an integer which is ** the result code. Write any error message text into *pzErrMsg. */ SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe *p){ int rc = SQLITE_OK; if( p->magic==VDBE_MAGIC_RUN || p->magic==VDBE_MAGIC_HALT ){ rc = sqlite3VdbeReset(p); assert( (rc & p->db->errMask)==rc ); }else if( p->magic!=VDBE_MAGIC_INIT ){ return SQLITE_MISUSE; } sqlite3VdbeDelete(p); return rc; } /* ** Call the destructor for each auxdata entry in pVdbeFunc for which ** the corresponding bit in mask is clear. Auxdata entries beyond 31 |
︙ | ︙ | |||
41668 41669 41670 41671 41672 41673 41674 41675 | } /* ** Delete an entire VDBE. */ SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe *p){ int i; if( p==0 ) return; | > > < > | | | | | | | | | | | | | 42765 42766 42767 42768 42769 42770 42771 42772 42773 42774 42775 42776 42777 42778 42779 42780 42781 42782 42783 42784 42785 42786 42787 42788 42789 42790 42791 42792 42793 42794 42795 42796 42797 42798 42799 42800 42801 42802 42803 42804 42805 42806 42807 42808 42809 42810 42811 | } /* ** Delete an entire VDBE. */ SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe *p){ int i; sqlite3 *db; if( p==0 ) return; db = p->db; if( p->pPrev ){ p->pPrev->pNext = p->pNext; }else{ assert( db->pVdbe==p ); db->pVdbe = p->pNext; } if( p->pNext ){ p->pNext->pPrev = p->pPrev; } if( p->aOp ){ Op *pOp = p->aOp; for(i=0; i<p->nOp; i++, pOp++){ freeP4(db, pOp->p4type, pOp->p4.p); #ifdef SQLITE_DEBUG sqlite3DbFree(db, pOp->zComment); #endif } sqlite3DbFree(db, p->aOp); } releaseMemArray(p->aVar, p->nVar); sqlite3DbFree(db, p->aLabel); if( p->aMem ){ sqlite3DbFree(db, &p->aMem[1]); } releaseMemArray(p->aColName, p->nResColumn*COLNAME_N); sqlite3DbFree(db, p->aColName); sqlite3DbFree(db, p->zSql); p->magic = VDBE_MAGIC_DEAD; sqlite3DbFree(db, p); } /* ** If a MoveTo operation is pending on the given cursor, then do that ** MoveTo now. Return an error code. If no MoveTo is pending, this ** routine does nothing and returns SQLITE_OK. */ |
︙ | ︙ | |||
41744 41745 41746 41747 41748 41749 41750 | } /* ** The following functions: ** ** sqlite3VdbeSerialType() ** sqlite3VdbeSerialTypeLen() | | | | | 42843 42844 42845 42846 42847 42848 42849 42850 42851 42852 42853 42854 42855 42856 42857 42858 42859 | } /* ** The following functions: ** ** sqlite3VdbeSerialType() ** sqlite3VdbeSerialTypeLen() ** sqlite3VdbeSerialLen() ** sqlite3VdbeSerialPut() ** sqlite3VdbeSerialGet() ** ** encapsulate the code that serializes values for storage in SQLite ** data and index records. Each serialized value consists of a ** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned ** integer, stored as a varint. ** ** In an SQLite index record, the serial type is stored directly before |
︙ | ︙ | |||
42068 42069 42070 42071 42072 42073 42074 | const void *pKey, /* The binary record */ void *pSpace, /* Space available to hold resulting object */ int szSpace /* Size of pSpace[] in bytes */ ){ const unsigned char *aKey = (const unsigned char *)pKey; UnpackedRecord *p; int nByte; | | > | | | | | | 43167 43168 43169 43170 43171 43172 43173 43174 43175 43176 43177 43178 43179 43180 43181 43182 43183 43184 43185 43186 43187 43188 43189 43190 43191 43192 43193 43194 43195 43196 43197 43198 43199 43200 43201 43202 43203 43204 43205 43206 43207 43208 43209 43210 43211 43212 43213 43214 43215 43216 43217 43218 43219 43220 43221 43222 43223 43224 43225 43226 43227 43228 43229 43230 43231 43232 43233 43234 43235 | const void *pKey, /* The binary record */ void *pSpace, /* Space available to hold resulting object */ int szSpace /* Size of pSpace[] in bytes */ ){ const unsigned char *aKey = (const unsigned char *)pKey; UnpackedRecord *p; int nByte; int idx, d; u16 u; /* Unsigned loop counter */ u32 szHdr; Mem *pMem; assert( sizeof(Mem)>sizeof(*p) ); nByte = sizeof(Mem)*(pKeyInfo->nField+2); if( nByte>szSpace ){ p = sqlite3DbMallocRaw(pKeyInfo->db, nByte); if( p==0 ) return 0; p->needFree = 1; }else{ p = pSpace; p->needFree = 0; } p->pKeyInfo = pKeyInfo; p->nField = pKeyInfo->nField + 1; p->needDestroy = 1; p->aMem = pMem = &((Mem*)p)[1]; idx = getVarint32(aKey, szHdr); d = szHdr; u = 0; while( idx<szHdr && u<p->nField ){ u32 serial_type; idx += getVarint32( aKey+idx, serial_type); if( d>=nKey && sqlite3VdbeSerialTypeLen(serial_type)>0 ) break; pMem->enc = pKeyInfo->enc; pMem->db = pKeyInfo->db; pMem->flags = 0; pMem->zMalloc = 0; d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem); pMem++; u++; } p->nField = u; return (void*)p; } /* ** This routine destroys a UnpackedRecord object */ SQLITE_PRIVATE void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord *p){ if( p ){ if( p->needDestroy ){ int i; Mem *pMem; for(i=0, pMem=p->aMem; i<p->nField; i++, pMem++){ if( pMem->zMalloc ){ sqlite3VdbeMemRelease(pMem); } } } if( p->needFree ){ sqlite3DbFree(p->pKeyInfo->db, p); } } } /* ** This function compares the two table rows or index records ** specified by {nKey1, pKey1} and pPKey2. It returns a negative, zero |
︙ | ︙ | |||
42216 42217 42218 42219 42220 42221 42222 | /* ** The argument is an index entry composed using the OP_MakeRecord opcode. ** The last entry in this record should be an integer (specifically ** an integer rowid). This routine returns the number of bytes in ** that integer. */ | | > > > | > | 43316 43317 43318 43319 43320 43321 43322 43323 43324 43325 43326 43327 43328 43329 43330 43331 43332 43333 43334 43335 43336 43337 43338 43339 43340 | /* ** The argument is an index entry composed using the OP_MakeRecord opcode. ** The last entry in this record should be an integer (specifically ** an integer rowid). This routine returns the number of bytes in ** that integer. */ SQLITE_PRIVATE int sqlite3VdbeIdxRowidLen(const u8 *aKey, int nKey, int *pRowidLen){ u32 szHdr; /* Size of the header */ u32 typeRowid; /* Serial type of the rowid */ (void)getVarint32(aKey, szHdr); if( szHdr>nKey ){ return SQLITE_CORRUPT_BKPT; } (void)getVarint32(&aKey[szHdr-1], typeRowid); *pRowidLen = sqlite3VdbeSerialTypeLen(typeRowid); return SQLITE_OK; } /* ** pCur points at an index entry created using the OP_MakeRecord opcode. ** Read the rowid (the last field in the record) and store it in *rowid. ** Return SQLITE_OK if everything works, or an error code otherwise. |
︙ | ︙ | |||
42291 42292 42293 42294 42295 42296 42297 | if( nCellKey<=0 ){ *res = 0; return SQLITE_OK; } m.db = 0; m.flags = 0; m.zMalloc = 0; | | > | < | 43395 43396 43397 43398 43399 43400 43401 43402 43403 43404 43405 43406 43407 43408 43409 43410 43411 43412 43413 | if( nCellKey<=0 ){ *res = 0; return SQLITE_OK; } m.db = 0; m.flags = 0; m.zMalloc = 0; if( (rc = sqlite3VdbeMemFromBtree(pC->pCursor, 0, nCellKey, 1, &m)) || (rc = sqlite3VdbeIdxRowidLen((u8*)m.z, m.n, &lenRowid)) ){ return rc; } if( !pUnpacked ){ pRec = sqlite3VdbeRecordUnpack(pC->pKeyInfo, nKey, pKey, zSpace, sizeof(zSpace)); }else{ pRec = pUnpacked; } if( pRec==0 ){ |
︙ | ︙ | |||
42372 42373 42374 42375 42376 42377 42378 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains code use to implement APIs that are part of the ** VDBE. ** | | | 43476 43477 43478 43479 43480 43481 43482 43483 43484 43485 43486 43487 43488 43489 43490 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains code use to implement APIs that are part of the ** VDBE. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT /* ** The following structure contains pointers to the end points of a ** doubly-linked list of all compiled SQL statements that may be holding ** buffers eligible for release when the sqlite3_release_memory() interface is |
︙ | ︙ | |||
42585 42586 42587 42588 42589 42590 42591 | SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt){ int rc; if( pStmt==0 ){ rc = SQLITE_OK; }else{ Vdbe *v = (Vdbe*)pStmt; sqlite3_mutex_enter(v->db->mutex); | | | 43689 43690 43691 43692 43693 43694 43695 43696 43697 43698 43699 43700 43701 43702 43703 | SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt){ int rc; if( pStmt==0 ){ rc = SQLITE_OK; }else{ Vdbe *v = (Vdbe*)pStmt; sqlite3_mutex_enter(v->db->mutex); rc = sqlite3VdbeReset(v); stmtLruAdd(v); sqlite3VdbeMakeReady(v, -1, 0, 0, 0); assert( (rc & (v->db->errMask))==rc ); sqlite3_mutex_leave(v->db->mutex); } return rc; } |
︙ | ︙ | |||
42792 42793 42794 42795 42796 42797 42798 | return SQLITE_MISUSE; } /* Assert that malloc() has not failed */ db = p->db; assert( !db->mallocFailed ); | < < < | 43896 43897 43898 43899 43900 43901 43902 43903 43904 43905 43906 43907 43908 43909 | return SQLITE_MISUSE; } /* Assert that malloc() has not failed */ db = p->db; assert( !db->mallocFailed ); if( p->pc<=0 && p->expired ){ if( p->rc==SQLITE_OK ){ p->rc = SQLITE_SCHEMA; } rc = SQLITE_ERROR; goto end_of_step; } |
︙ | ︙ | |||
42854 42855 42856 42857 42858 42859 42860 | sqlite3OsCurrentTime(db->pVfs, &rNow); elapseTime = (rNow - (int)rNow)*3600.0*24.0*1000000000.0 - p->startTime; db->xProfile(db->pProfileArg, p->aOp[0].p4.z, elapseTime); } #endif | > | > | | 43955 43956 43957 43958 43959 43960 43961 43962 43963 43964 43965 43966 43967 43968 43969 43970 43971 43972 43973 43974 43975 43976 43977 43978 | sqlite3OsCurrentTime(db->pVfs, &rNow); elapseTime = (rNow - (int)rNow)*3600.0*24.0*1000000000.0 - p->startTime; db->xProfile(db->pProfileArg, p->aOp[0].p4.z, elapseTime); } #endif db->errCode = rc; /*sqlite3Error(p->db, rc, 0);*/ p->rc = sqlite3ApiExit(p->db, p->rc); end_of_step: assert( (rc&0xff)==rc ); if( p->zSql && (rc&0xff)<SQLITE_ROW ){ /* This behavior occurs if sqlite3_prepare_v2() was used to build ** the prepared statement. Return error codes directly */ p->db->errCode = p->rc; /* sqlite3Error(p->db, p->rc, 0); */ return p->rc; }else{ /* This is for legacy sqlite3_prepare() builds and when the code ** is SQLITE_ROW or SQLITE_DONE */ return rc; } } |
︙ | ︙ | |||
42911 42912 42913 42914 42915 42916 42917 | ** into the database handle. This block copies the error message ** from the database handle into the statement and sets the statement ** program counter to 0 to ensure that when the statement is ** finalized or reset the parser error message is available via ** sqlite3_errmsg() and sqlite3_errcode(). */ const char *zErr = (const char *)sqlite3_value_text(db->pErr); | | | 44014 44015 44016 44017 44018 44019 44020 44021 44022 44023 44024 44025 44026 44027 44028 | ** into the database handle. This block copies the error message ** from the database handle into the statement and sets the statement ** program counter to 0 to ensure that when the statement is ** finalized or reset the parser error message is available via ** sqlite3_errmsg() and sqlite3_errcode(). */ const char *zErr = (const char *)sqlite3_value_text(db->pErr); sqlite3DbFree(db, v->zErrMsg); if( !db->mallocFailed ){ v->zErrMsg = sqlite3DbStrDup(db, zErr); } else { v->zErrMsg = 0; v->rc = SQLITE_NOMEM; } } |
︙ | ︙ | |||
43679 43680 43681 43682 43683 43684 43685 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** | | | 44782 44783 44784 44785 44786 44787 44788 44789 44790 44791 44792 44793 44794 44795 44796 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** The following global variable is incremented every time a cursor ** moves, either by the OP_MoveXX, OP_Next, or OP_Prev opcodes. The test ** procedures use this information to make sure that indices are ** working correctly. This variable has no function other than to |
︙ | ︙ | |||
44120 44121 44122 44123 44124 44125 44126 | ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains inline asm code for retrieving "high-performance" ** counters for x86 class CPUs. ** | | | 45223 45224 45225 45226 45227 45228 45229 45230 45231 45232 45233 45234 45235 45236 45237 | ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains inline asm code for retrieving "high-performance" ** counters for x86 class CPUs. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _HWTIME_H_ #define _HWTIME_H_ /* ** The following routine only works on pentium-class (or newer) processors. ** It uses the RDTSC opcode to read the cycle count value out of the |
︙ | ︙ | |||
44161 44162 44163 44164 44165 44166 44167 44168 44169 44170 44171 44172 44173 44174 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long val; __asm__ __volatile__ ("rdtsc" : "=A" (val)); return val; } #else #error Need implementation of sqlite3Hwtime() for your platform. /* ** To compile without implementing sqlite3Hwtime() for your platform, ** you can remove the above #error and use the following | > > > > > > > > > > > > > > > | 45264 45265 45266 45267 45268 45269 45270 45271 45272 45273 45274 45275 45276 45277 45278 45279 45280 45281 45282 45283 45284 45285 45286 45287 45288 45289 45290 45291 45292 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long val; __asm__ __volatile__ ("rdtsc" : "=A" (val)); return val; } #elif (defined(__GNUC__) && defined(__ppc__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long long retval; unsigned long junk; __asm__ __volatile__ ("\n\ 1: mftbu %1\n\ mftb %L0\n\ mftbu %0\n\ cmpw %0,%1\n\ bne 1b" : "=r" (retval), "=r" (junk)); return retval; } #else #error Need implementation of sqlite3Hwtime() for your platform. /* ** To compile without implementing sqlite3Hwtime() for your platform, ** you can remove the above #error and use the following |
︙ | ︙ | |||
44599 44600 44601 44602 44603 44604 44605 | pOp->opcode = OP_String; pOp->p1 = strlen(pOp->p4.z); #ifndef SQLITE_OMIT_UTF16 if( encoding!=SQLITE_UTF8 ){ sqlite3VdbeMemSetStr(pOut, pOp->p4.z, -1, SQLITE_UTF8, SQLITE_STATIC); if( SQLITE_OK!=sqlite3VdbeChangeEncoding(pOut, encoding) ) goto no_mem; | | | | 45717 45718 45719 45720 45721 45722 45723 45724 45725 45726 45727 45728 45729 45730 45731 45732 45733 45734 45735 45736 | pOp->opcode = OP_String; pOp->p1 = strlen(pOp->p4.z); #ifndef SQLITE_OMIT_UTF16 if( encoding!=SQLITE_UTF8 ){ sqlite3VdbeMemSetStr(pOut, pOp->p4.z, -1, SQLITE_UTF8, SQLITE_STATIC); if( SQLITE_OK!=sqlite3VdbeChangeEncoding(pOut, encoding) ) goto no_mem; if( SQLITE_OK!=sqlite3VdbeMemMakeWriteable(pOut) ) goto no_mem; pOut->zMalloc = 0; pOut->flags |= MEM_Static; pOut->flags &= ~MEM_Dyn; if( pOp->p4type==P4_DYNAMIC ){ sqlite3DbFree(db, pOp->p4.z); } pOp->p4type = P4_DYNAMIC; pOp->p4.z = pOut->z; pOp->p1 = pOut->n; if( pOp->p1>db->aLimit[SQLITE_LIMIT_LENGTH] ){ goto too_big; } |
︙ | ︙ | |||
44888 44889 44890 44891 44892 44893 44894 44895 44896 44897 44898 44899 44900 44901 | */ case OP_Add: /* same as TK_PLUS, in1, in2, out3 */ case OP_Subtract: /* same as TK_MINUS, in1, in2, out3 */ case OP_Multiply: /* same as TK_STAR, in1, in2, out3 */ case OP_Divide: /* same as TK_SLASH, in1, in2, out3 */ case OP_Remainder: { /* same as TK_REM, in1, in2, out3 */ int flags; flags = pIn1->flags | pIn2->flags; if( (flags & MEM_Null)!=0 ) goto arithmetic_result_is_null; if( (pIn1->flags & pIn2->flags & MEM_Int)==MEM_Int ){ i64 a, b; a = pIn1->u.i; b = pIn2->u.i; switch( pOp->opcode ){ | > > | 46006 46007 46008 46009 46010 46011 46012 46013 46014 46015 46016 46017 46018 46019 46020 46021 | */ case OP_Add: /* same as TK_PLUS, in1, in2, out3 */ case OP_Subtract: /* same as TK_MINUS, in1, in2, out3 */ case OP_Multiply: /* same as TK_STAR, in1, in2, out3 */ case OP_Divide: /* same as TK_SLASH, in1, in2, out3 */ case OP_Remainder: { /* same as TK_REM, in1, in2, out3 */ int flags; applyNumericAffinity(pIn1); applyNumericAffinity(pIn2); flags = pIn1->flags | pIn2->flags; if( (flags & MEM_Null)!=0 ) goto arithmetic_result_is_null; if( (pIn1->flags & pIn2->flags & MEM_Int)==MEM_Int ){ i64 a, b; a = pIn1->u.i; b = pIn2->u.i; switch( pOp->opcode ){ |
︙ | ︙ | |||
45864 45865 45866 45867 45868 45869 45870 | ** then there are not enough fields in the record to satisfy the ** request. In this case, set the value NULL or to P4 if P4 is ** a pointer to a Mem object. */ if( aOffset[p2] ){ assert( rc==SQLITE_OK ); if( zRec ){ | < < < | < < < < < | < | 46984 46985 46986 46987 46988 46989 46990 46991 46992 46993 46994 46995 46996 46997 46998 46999 | ** then there are not enough fields in the record to satisfy the ** request. In this case, set the value NULL or to P4 if P4 is ** a pointer to a Mem object. */ if( aOffset[p2] ){ assert( rc==SQLITE_OK ); if( zRec ){ sqlite3VdbeMemReleaseExternal(pDest); sqlite3VdbeSerialGet((u8 *)&zRec[aOffset[p2]], aType[p2], pDest); }else{ len = sqlite3VdbeSerialTypeLen(aType[p2]); sqlite3VdbeMemMove(&sMem, pDest); rc = sqlite3VdbeMemFromBtree(pCrsr, aOffset[p2], len, pC->isIndex, &sMem); if( rc!=SQLITE_OK ){ goto op_column_out; } |
︙ | ︙ | |||
46314 46315 46316 46317 46318 46319 46320 | if( pBt ){ rc = sqlite3BtreeGetMeta(pBt, 1, (u32 *)&iMeta); }else{ rc = SQLITE_OK; iMeta = 0; } if( rc==SQLITE_OK && iMeta!=pOp->p2 ){ | | | 47425 47426 47427 47428 47429 47430 47431 47432 47433 47434 47435 47436 47437 47438 47439 | if( pBt ){ rc = sqlite3BtreeGetMeta(pBt, 1, (u32 *)&iMeta); }else{ rc = SQLITE_OK; iMeta = 0; } if( rc==SQLITE_OK && iMeta!=pOp->p2 ){ sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = sqlite3DbStrDup(db, "database schema has changed"); /* If the schema-cookie from the database file matches the cookie ** stored with the in-memory representation of the schema, do ** not reload the schema from the database file. ** ** If virtual-tables are in use, this is not just an optimization. ** Often, v-tables store their data in other SQLite tables, which |
︙ | ︙ | |||
46845 46846 46847 46848 46849 46850 46851 | /* Make sure K is a string and make zKey point to K */ assert( pK->flags & MEM_Blob ); zKey = pK->z; nKey = pK->n; | > > > > > > | > | 47956 47957 47958 47959 47960 47961 47962 47963 47964 47965 47966 47967 47968 47969 47970 47971 47972 47973 47974 47975 47976 47977 | /* Make sure K is a string and make zKey point to K */ assert( pK->flags & MEM_Blob ); zKey = pK->z; nKey = pK->n; /* sqlite3VdbeIdxRowidLen() only returns other than SQLITE_OK when the ** record passed as an argument corrupt. Since the record in this case ** has just been created by an OP_MakeRecord instruction, and not loaded ** from the database file, it is not possible for it to be corrupt. ** Therefore, assert(rc==SQLITE_OK). */ rc = sqlite3VdbeIdxRowidLen((u8*)zKey, nKey, &szRowid); assert(rc==SQLITE_OK); len = nKey-szRowid; /* Search for an entry in P1 where all but the last four bytes match K. ** If there is no such entry, jump immediately to P2. */ assert( pCx->deferredMoveto==0 ); pCx->cacheStatus = CACHE_STALE; |
︙ | ︙ | |||
47172 47173 47174 47175 47176 47177 47178 | pData->z = 0; pData->n = 0; }else{ assert( pData->flags & (MEM_Blob|MEM_Str) ); } if( pC->pseudoTable ){ if( !pC->ephemPseudoTable ){ | | | 48290 48291 48292 48293 48294 48295 48296 48297 48298 48299 48300 48301 48302 48303 48304 | pData->z = 0; pData->n = 0; }else{ assert( pData->flags & (MEM_Blob|MEM_Str) ); } if( pC->pseudoTable ){ if( !pC->ephemPseudoTable ){ sqlite3DbFree(db, pC->pData); } pC->iKey = iKey; pC->nData = pData->n; if( pData->z==pData->zMalloc || pC->ephemPseudoTable ){ pC->pData = pData->z; if( !pC->ephemPseudoTable ){ pData->flags &= ~MEM_Dyn; |
︙ | ︙ | |||
47851 47852 47853 47854 47855 47856 47857 | if( zSql==0 ) goto no_mem; (void)sqlite3SafetyOff(db); assert( db->init.busy==0 ); db->init.busy = 1; assert( !db->mallocFailed ); rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0); if( rc==SQLITE_ABORT ) rc = initData.rc; | | | 48969 48970 48971 48972 48973 48974 48975 48976 48977 48978 48979 48980 48981 48982 48983 | if( zSql==0 ) goto no_mem; (void)sqlite3SafetyOff(db); assert( db->init.busy==0 ); db->init.busy = 1; assert( !db->mallocFailed ); rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0); if( rc==SQLITE_ABORT ) rc = initData.rc; sqlite3DbFree(db, zSql); db->init.busy = 0; (void)sqlite3SafetyOn(db); if( rc==SQLITE_NOMEM ){ goto no_mem; } break; } |
︙ | ︙ | |||
47943 47944 47945 47946 47947 47948 47949 | int j; /* Loop counter */ int nErr; /* Number of errors reported */ char *z; /* Text of the error report */ Mem *pnErr; /* Register keeping track of errors remaining */ nRoot = pOp->p2; assert( nRoot>0 ); | | > > > < > | 49061 49062 49063 49064 49065 49066 49067 49068 49069 49070 49071 49072 49073 49074 49075 49076 49077 49078 49079 49080 49081 49082 49083 49084 49085 49086 49087 49088 49089 49090 49091 49092 49093 49094 49095 49096 49097 49098 49099 49100 49101 49102 49103 49104 49105 49106 49107 49108 49109 49110 49111 | int j; /* Loop counter */ int nErr; /* Number of errors reported */ char *z; /* Text of the error report */ Mem *pnErr; /* Register keeping track of errors remaining */ nRoot = pOp->p2; assert( nRoot>0 ); aRoot = sqlite3DbMallocRaw(db, sizeof(int)*(nRoot+1) ); if( aRoot==0 ) goto no_mem; assert( pOp->p3>0 && pOp->p3<=p->nMem ); pnErr = &p->aMem[pOp->p3]; assert( (pnErr->flags & MEM_Int)!=0 ); assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 ); pIn1 = &p->aMem[pOp->p1]; for(j=0; j<nRoot; j++){ aRoot[j] = sqlite3VdbeIntValue(&pIn1[j]); } aRoot[j] = 0; assert( pOp->p5<db->nDb ); assert( (p->btreeMask & (1<<pOp->p5))!=0 ); z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, aRoot, nRoot, pnErr->u.i, &nErr); sqlite3DbFree(db, aRoot); pnErr->u.i -= nErr; sqlite3VdbeMemSetNull(pIn1); if( nErr==0 ){ assert( z==0 ); }else if( z==0 ){ goto no_mem; }else{ sqlite3VdbeMemSetStr(pIn1, z, -1, SQLITE_UTF8, sqlite3_free); } UPDATE_MAX_BLOBSIZE(pIn1); sqlite3VdbeChangeEncoding(pIn1, encoding); break; } #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ /* Opcode: FifoWrite P1 * * * * ** ** Write the integer from register P1 into the Fifo. */ case OP_FifoWrite: { /* in1 */ p->sFifo.db = db; if( sqlite3VdbeFifoPush(&p->sFifo, sqlite3VdbeIntValue(pIn1))==SQLITE_NOMEM ){ goto no_mem; } break; } /* Opcode: FifoRead P1 P2 * * * |
︙ | ︙ | |||
48024 48025 48026 48027 48028 48029 48030 | sizeof(Context)*(i+1)); if( p->contextStack==0 ) goto no_mem; } pContext = &p->contextStack[i]; pContext->lastRowid = db->lastRowid; pContext->nChange = p->nChange; pContext->sFifo = p->sFifo; | | | 49145 49146 49147 49148 49149 49150 49151 49152 49153 49154 49155 49156 49157 49158 49159 | sizeof(Context)*(i+1)); if( p->contextStack==0 ) goto no_mem; } pContext = &p->contextStack[i]; pContext->lastRowid = db->lastRowid; pContext->nChange = p->nChange; pContext->sFifo = p->sFifo; sqlite3VdbeFifoInit(&p->sFifo, db); break; } /* Opcode: ContextPop * * * ** ** Restore the Vdbe context to the state it was in when contextPush was last ** executed. The context stores the last insert row id, the last statement |
︙ | ︙ | |||
48278 48279 48280 48281 48282 48283 48284 | break; } #endif /* SQLITE_OMIT_SHARED_CACHE */ #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VBegin * * * P4 * ** | | | > > > > > | > > > > > | 49399 49400 49401 49402 49403 49404 49405 49406 49407 49408 49409 49410 49411 49412 49413 49414 49415 49416 49417 49418 49419 49420 49421 49422 49423 49424 49425 49426 49427 | break; } #endif /* SQLITE_OMIT_SHARED_CACHE */ #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VBegin * * * P4 * ** ** P4 may be a pointer to an sqlite3_vtab structure. If so, call the ** xBegin method for that table. ** ** Also, whether or not P4 is set, check that this is not being called from ** within a callback to a virtual table xSync() method. If it is, set the ** error code to SQLITE_LOCKED. */ case OP_VBegin: { sqlite3_vtab *pVtab = pOp->p4.pVtab; rc = sqlite3VtabBegin(db, pVtab); if( pVtab ){ sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = pVtab->zErrMsg; pVtab->zErrMsg = 0; } break; } #endif /* SQLITE_OMIT_VIRTUALTABLE */ #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VCreate P1 * * P4 * ** |
︙ | ︙ | |||
48330 48331 48332 48333 48334 48335 48336 48337 48338 48339 48340 48341 48342 48343 | sqlite3_vtab *pVtab = pOp->p4.pVtab; sqlite3_module *pModule = (sqlite3_module *)pVtab->pModule; assert(pVtab && pModule); if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; rc = pModule->xOpen(pVtab, &pVtabCursor); if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; if( SQLITE_OK==rc ){ /* Initialize sqlite3_vtab_cursor base class */ pVtabCursor->pVtab = pVtab; /* Initialise vdbe cursor object */ pCur = allocateCursor(p, pOp->p1, &pOp[-1], -1, 0); | > > > | 49461 49462 49463 49464 49465 49466 49467 49468 49469 49470 49471 49472 49473 49474 49475 49476 49477 | sqlite3_vtab *pVtab = pOp->p4.pVtab; sqlite3_module *pModule = (sqlite3_module *)pVtab->pModule; assert(pVtab && pModule); if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; rc = pModule->xOpen(pVtab, &pVtabCursor); sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = pVtab->zErrMsg; pVtab->zErrMsg = 0; if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; if( SQLITE_OK==rc ){ /* Initialize sqlite3_vtab_cursor base class */ pVtabCursor->pVtab = pVtab; /* Initialise vdbe cursor object */ pCur = allocateCursor(p, pOp->p1, &pOp[-1], -1, 0); |
︙ | ︙ | |||
48374 48375 48376 48377 48378 48379 48380 48381 48382 48383 48384 48385 | */ case OP_VFilter: { /* jump */ int nArg; int iQuery; const sqlite3_module *pModule; Mem *pQuery = &p->aMem[pOp->p3]; Mem *pArgc = &pQuery[1]; Cursor *pCur = p->apCsr[pOp->p1]; REGISTER_TRACE(pOp->p3, pQuery); assert( pCur->pVtabCursor ); | > > | > > > | > > > > | > | > > > > > | > > > > | 49508 49509 49510 49511 49512 49513 49514 49515 49516 49517 49518 49519 49520 49521 49522 49523 49524 49525 49526 49527 49528 49529 49530 49531 49532 49533 49534 49535 49536 49537 49538 49539 49540 49541 49542 49543 49544 49545 49546 49547 49548 49549 49550 49551 49552 49553 49554 49555 49556 49557 49558 49559 49560 49561 49562 49563 49564 49565 49566 49567 49568 49569 49570 49571 49572 49573 49574 49575 49576 49577 49578 49579 49580 49581 49582 49583 49584 49585 49586 49587 49588 49589 49590 49591 49592 49593 49594 49595 49596 49597 49598 49599 49600 49601 49602 49603 49604 49605 49606 49607 49608 49609 49610 49611 49612 49613 49614 49615 49616 49617 49618 49619 49620 49621 49622 49623 49624 49625 49626 49627 49628 49629 49630 49631 49632 49633 49634 49635 49636 49637 49638 49639 49640 49641 | */ case OP_VFilter: { /* jump */ int nArg; int iQuery; const sqlite3_module *pModule; Mem *pQuery = &p->aMem[pOp->p3]; Mem *pArgc = &pQuery[1]; sqlite3_vtab_cursor *pVtabCursor; sqlite3_vtab *pVtab; Cursor *pCur = p->apCsr[pOp->p1]; REGISTER_TRACE(pOp->p3, pQuery); assert( pCur->pVtabCursor ); pVtabCursor = pCur->pVtabCursor; pVtab = pVtabCursor->pVtab; pModule = pVtab->pModule; /* Grab the index number and argc parameters */ assert( (pQuery->flags&MEM_Int)!=0 && pArgc->flags==MEM_Int ); nArg = pArgc->u.i; iQuery = pQuery->u.i; /* Invoke the xFilter method */ { int res = 0; int i; Mem **apArg = p->apArg; for(i = 0; i<nArg; i++){ apArg[i] = &pArgc[i+1]; storeTypeInfo(apArg[i], 0); } if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; sqlite3VtabLock(pVtab); p->inVtabMethod = 1; rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg); p->inVtabMethod = 0; sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = pVtab->zErrMsg; pVtab->zErrMsg = 0; sqlite3VtabUnlock(db, pVtab); if( rc==SQLITE_OK ){ res = pModule->xEof(pVtabCursor); } if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; if( res ){ pc = pOp->p2 - 1; } } pCur->nullRow = 0; break; } #endif /* SQLITE_OMIT_VIRTUALTABLE */ #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VRowid P1 P2 * * * ** ** Store into register P2 the rowid of ** the virtual-table that the P1 cursor is pointing to. */ case OP_VRowid: { /* out2-prerelease */ sqlite3_vtab *pVtab; const sqlite3_module *pModule; sqlite_int64 iRow; Cursor *pCur = p->apCsr[pOp->p1]; assert( pCur->pVtabCursor ); if( pCur->nullRow ){ break; } pVtab = pCur->pVtabCursor->pVtab; pModule = pVtab->pModule; assert( pModule->xRowid ); if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; rc = pModule->xRowid(pCur->pVtabCursor, &iRow); sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = pVtab->zErrMsg; pVtab->zErrMsg = 0; if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; MemSetTypeFlag(pOut, MEM_Int); pOut->u.i = iRow; break; } #endif /* SQLITE_OMIT_VIRTUALTABLE */ #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VColumn P1 P2 P3 * * ** ** Store the value of the P2-th column of ** the row of the virtual-table that the ** P1 cursor is pointing to into register P3. */ case OP_VColumn: { sqlite3_vtab *pVtab; const sqlite3_module *pModule; Mem *pDest; sqlite3_context sContext; Cursor *pCur = p->apCsr[pOp->p1]; assert( pCur->pVtabCursor ); assert( pOp->p3>0 && pOp->p3<=p->nMem ); pDest = &p->aMem[pOp->p3]; if( pCur->nullRow ){ sqlite3VdbeMemSetNull(pDest); break; } pVtab = pCur->pVtabCursor->pVtab; pModule = pVtab->pModule; assert( pModule->xColumn ); memset(&sContext, 0, sizeof(sContext)); /* The output cell may already have a buffer allocated. Move ** the current contents to sContext.s so in case the user-function ** can use the already allocated buffer instead of allocating a ** new one. */ sqlite3VdbeMemMove(&sContext.s, pDest); MemSetTypeFlag(&sContext.s, MEM_Null); if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; rc = pModule->xColumn(pCur->pVtabCursor, &sContext, pOp->p2); sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = pVtab->zErrMsg; pVtab->zErrMsg = 0; /* Copy the result of the function to the P3 register. We ** do this regardless of whether or not an error occured to ensure any ** dynamic allocation in sContext.s (a Mem struct) is released. */ sqlite3VdbeChangeEncoding(&sContext.s, encoding); REGISTER_TRACE(pOp->p3, pDest); |
︙ | ︙ | |||
48503 48504 48505 48506 48507 48508 48509 48510 48511 48512 48513 48514 48515 48516 48517 | /* Opcode: VNext P1 P2 * * * ** ** Advance virtual table P1 to the next row in its result set and ** jump to instruction P2. Or, if the virtual table has reached ** the end of its result set, then fall through to the next instruction. */ case OP_VNext: { /* jump */ const sqlite3_module *pModule; int res = 0; Cursor *pCur = p->apCsr[pOp->p1]; assert( pCur->pVtabCursor ); if( pCur->nullRow ){ break; } | > | > > > > > > | 49656 49657 49658 49659 49660 49661 49662 49663 49664 49665 49666 49667 49668 49669 49670 49671 49672 49673 49674 49675 49676 49677 49678 49679 49680 49681 49682 49683 49684 49685 49686 49687 49688 49689 49690 49691 49692 49693 49694 49695 49696 49697 | /* Opcode: VNext P1 P2 * * * ** ** Advance virtual table P1 to the next row in its result set and ** jump to instruction P2. Or, if the virtual table has reached ** the end of its result set, then fall through to the next instruction. */ case OP_VNext: { /* jump */ sqlite3_vtab *pVtab; const sqlite3_module *pModule; int res = 0; Cursor *pCur = p->apCsr[pOp->p1]; assert( pCur->pVtabCursor ); if( pCur->nullRow ){ break; } pVtab = pCur->pVtabCursor->pVtab; pModule = pVtab->pModule; assert( pModule->xNext ); /* Invoke the xNext() method of the module. There is no way for the ** underlying implementation to return an error if one occurs during ** xNext(). Instead, if an error occurs, true is returned (indicating that ** data is available) and the error code returned when xColumn or ** some other method is next invoked on the save virtual table cursor. */ if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; sqlite3VtabLock(pVtab); p->inVtabMethod = 1; rc = pModule->xNext(pCur->pVtabCursor); p->inVtabMethod = 0; sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = pVtab->zErrMsg; pVtab->zErrMsg = 0; sqlite3VtabUnlock(db, pVtab); if( rc==SQLITE_OK ){ res = pModule->xEof(pCur->pVtabCursor); } if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; if( !res ){ /* If there is data, jump to P2 */ |
︙ | ︙ | |||
48555 48556 48557 48558 48559 48560 48561 48562 48563 48564 48565 48566 48567 48568 | REGISTER_TRACE(pOp->p1, pName); Stringify(pName, encoding); if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; sqlite3VtabLock(pVtab); rc = pVtab->pModule->xRename(pVtab, pName->z); sqlite3VtabUnlock(db, pVtab); if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; break; } #endif | > > > | 49715 49716 49717 49718 49719 49720 49721 49722 49723 49724 49725 49726 49727 49728 49729 49730 49731 | REGISTER_TRACE(pOp->p1, pName); Stringify(pName, encoding); if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; sqlite3VtabLock(pVtab); rc = pVtab->pModule->xRename(pVtab, pName->z); sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = pVtab->zErrMsg; pVtab->zErrMsg = 0; sqlite3VtabUnlock(db, pVtab); if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; break; } #endif |
︙ | ︙ | |||
48607 48608 48609 48610 48611 48612 48613 48614 48615 48616 48617 48618 48619 48620 | storeTypeInfo(pX, 0); apArg[i] = pX; pX++; } if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; sqlite3VtabLock(pVtab); rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid); sqlite3VtabUnlock(db, pVtab); if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; if( pOp->p1 && rc==SQLITE_OK ){ assert( nArg>1 && apArg[0] && (apArg[0]->flags&MEM_Null) ); db->lastRowid = rowid; } p->nChange++; | > > > | 49770 49771 49772 49773 49774 49775 49776 49777 49778 49779 49780 49781 49782 49783 49784 49785 49786 | storeTypeInfo(pX, 0); apArg[i] = pX; pX++; } if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; sqlite3VtabLock(pVtab); rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid); sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = pVtab->zErrMsg; pVtab->zErrMsg = 0; sqlite3VtabUnlock(db, pVtab); if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; if( pOp->p1 && rc==SQLITE_OK ){ assert( nArg>1 && apArg[0] && (apArg[0]->flags&MEM_Null) ); db->lastRowid = rowid; } p->nChange++; |
︙ | ︙ | |||
48794 48795 48796 48797 48798 48799 48800 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains code used to implement incremental BLOB I/O. ** | | | 49960 49961 49962 49963 49964 49965 49966 49967 49968 49969 49970 49971 49972 49973 49974 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains code used to implement incremental BLOB I/O. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef SQLITE_OMIT_INCRBLOB /* ** Valid sqlite3_blob* handles point to Incrblob structures. |
︙ | ︙ | |||
48897 48898 48899 48900 48901 48902 48903 | sqlite3ErrorMsg(&sParse, "cannot open view: %s", zTable); } #endif if( !pTab ){ if( sParse.zErrMsg ){ sqlite3_snprintf(sizeof(zErr), zErr, "%s", sParse.zErrMsg); } | | | 50063 50064 50065 50066 50067 50068 50069 50070 50071 50072 50073 50074 50075 50076 50077 | sqlite3ErrorMsg(&sParse, "cannot open view: %s", zTable); } #endif if( !pTab ){ if( sParse.zErrMsg ){ sqlite3_snprintf(sizeof(zErr), zErr, "%s", sParse.zErrMsg); } sqlite3DbFree(db, sParse.zErrMsg); rc = SQLITE_ERROR; (void)sqlite3SafetyOff(db); sqlite3BtreeLeaveAll(db); goto blob_open_out; } /* Now search pTab for the exact column. */ |
︙ | ︙ | |||
49009 49010 49011 49012 49013 49014 49015 | type==0?"null": type==7?"real": "integer" ); rc = SQLITE_ERROR; goto blob_open_out; } pBlob = (Incrblob *)sqlite3DbMallocZero(db, sizeof(Incrblob)); if( db->mallocFailed ){ | | | 50175 50176 50177 50178 50179 50180 50181 50182 50183 50184 50185 50186 50187 50188 50189 | type==0?"null": type==7?"real": "integer" ); rc = SQLITE_ERROR; goto blob_open_out; } pBlob = (Incrblob *)sqlite3DbMallocZero(db, sizeof(Incrblob)); if( db->mallocFailed ){ sqlite3DbFree(db, pBlob); goto blob_open_out; } pBlob->flags = flags; pBlob->pCsr = v->apCsr[0]->pCursor; sqlite3BtreeEnterCursor(pBlob->pCsr); sqlite3BtreeCacheOverflow(pBlob->pCsr); sqlite3BtreeLeaveCursor(pBlob->pCsr); |
︙ | ︙ | |||
49048 49049 49050 49051 49052 49053 49054 | ** sqlite3_blob_open(). */ SQLITE_API int sqlite3_blob_close(sqlite3_blob *pBlob){ Incrblob *p = (Incrblob *)pBlob; int rc; rc = sqlite3_finalize(p->pStmt); | | | 50214 50215 50216 50217 50218 50219 50220 50221 50222 50223 50224 50225 50226 50227 50228 | ** sqlite3_blob_open(). */ SQLITE_API int sqlite3_blob_close(sqlite3_blob *pBlob){ Incrblob *p = (Incrblob *)pBlob; int rc; rc = sqlite3_finalize(p->pStmt); sqlite3DbFree(p->db, p); return rc; } /* ** Perform a read or write operation on a blob */ static int blobReadWrite( |
︙ | ︙ | |||
49141 49142 49143 49144 49145 49146 49147 | ** ** 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. ** ************************************************************************* ** | | | 50307 50308 50309 50310 50311 50312 50313 50314 50315 50316 50317 50318 50319 50320 50321 | ** ** 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. ** ************************************************************************* ** ** @(#) $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifdef SQLITE_ENABLE_ATOMIC_WRITE /* ** This file implements a special kind of sqlite3_file object used ** by SQLite to create journal files if the atomic-write optimization |
︙ | ︙ | |||
49384 49385 49386 49387 49388 49389 49390 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** | | | 50550 50551 50552 50553 50554 50555 50556 50557 50558 50559 50560 50561 50562 50563 50564 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** Return the 'affinity' of the expression pExpr if any. ** ** If pExpr is a column, a reference to a column via an 'AS' alias, ** or a sub-select with a column as the return value, then the |
︙ | ︙ | |||
49426 49427 49428 49429 49430 49431 49432 | ** The collating sequence is marked as "explicit" using the EP_ExpCollate ** flag. An explicit collating sequence will override implicit ** collating sequences. */ SQLITE_PRIVATE Expr *sqlite3ExprSetColl(Parse *pParse, Expr *pExpr, Token *pName){ char *zColl = 0; /* Dequoted name of collation sequence */ CollSeq *pColl; | > | | | 50592 50593 50594 50595 50596 50597 50598 50599 50600 50601 50602 50603 50604 50605 50606 50607 50608 50609 50610 50611 50612 50613 50614 50615 | ** The collating sequence is marked as "explicit" using the EP_ExpCollate ** flag. An explicit collating sequence will override implicit ** collating sequences. */ SQLITE_PRIVATE Expr *sqlite3ExprSetColl(Parse *pParse, Expr *pExpr, Token *pName){ char *zColl = 0; /* Dequoted name of collation sequence */ CollSeq *pColl; sqlite3 *db = pParse->db; zColl = sqlite3NameFromToken(db, pName); if( pExpr && zColl ){ pColl = sqlite3LocateCollSeq(pParse, zColl, -1); if( pColl ){ pExpr->pColl = pColl; pExpr->flags |= EP_ExpCollate; } } sqlite3DbFree(db, zColl); return pExpr; } /* ** Return the default collation sequence for the expression pExpr. If ** there is no default collation type, return 0. */ |
︙ | ︙ | |||
49737 49738 49739 49740 49741 49742 49743 | Expr *pNew; pNew = sqlite3DbMallocZero(db, sizeof(Expr)); if( pNew==0 ){ /* When malloc fails, delete pLeft and pRight. Expressions passed to ** this function must always be allocated with sqlite3Expr() for this ** reason. */ | | | | 50904 50905 50906 50907 50908 50909 50910 50911 50912 50913 50914 50915 50916 50917 50918 50919 | Expr *pNew; pNew = sqlite3DbMallocZero(db, sizeof(Expr)); if( pNew==0 ){ /* When malloc fails, delete pLeft and pRight. Expressions passed to ** this function must always be allocated with sqlite3Expr() for this ** reason. */ sqlite3ExprDelete(db, pLeft); sqlite3ExprDelete(db, pRight); return 0; } pNew->op = op; pNew->pLeft = pLeft; pNew->pRight = pRight; pNew->iAgg = -1; pNew->span.z = (u8*)""; |
︙ | ︙ | |||
49835 49836 49837 49838 49839 49840 49841 | ** Set the Expr.span field of the given expression to span all ** text between the two given tokens. Both tokens must be pointing ** at the same string. */ SQLITE_PRIVATE void sqlite3ExprSpan(Expr *pExpr, Token *pLeft, Token *pRight){ assert( pRight!=0 ); assert( pLeft!=0 ); | | > | | | 51002 51003 51004 51005 51006 51007 51008 51009 51010 51011 51012 51013 51014 51015 51016 51017 51018 51019 51020 51021 51022 51023 51024 51025 51026 51027 51028 51029 51030 51031 51032 | ** Set the Expr.span field of the given expression to span all ** text between the two given tokens. Both tokens must be pointing ** at the same string. */ SQLITE_PRIVATE void sqlite3ExprSpan(Expr *pExpr, Token *pLeft, Token *pRight){ assert( pRight!=0 ); assert( pLeft!=0 ); if( pExpr ){ pExpr->span.z = pLeft->z; pExpr->span.n = pRight->n + (pRight->z - pLeft->z); } } /* ** Construct a new expression node for a function with multiple ** arguments. */ SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse *pParse, ExprList *pList, Token *pToken){ Expr *pNew; sqlite3 *db = pParse->db; assert( pToken ); pNew = sqlite3DbMallocZero(db, sizeof(Expr) ); if( pNew==0 ){ sqlite3ExprListDelete(db, pList); /* Avoid leaking memory when malloc fails */ return 0; } pNew->op = TK_FUNCTION; pNew->pList = pList; assert( pToken->dyn==0 ); pNew->token = *pToken; pNew->span = pNew->token; |
︙ | ︙ | |||
49948 49949 49950 49951 49952 49953 49954 | sqlite3ErrorMsg(pParse, "too many SQL variables"); } } /* ** Recursively delete an expression tree. */ | | | | | | | | | | 51116 51117 51118 51119 51120 51121 51122 51123 51124 51125 51126 51127 51128 51129 51130 51131 51132 51133 51134 51135 51136 51137 51138 | sqlite3ErrorMsg(pParse, "too many SQL variables"); } } /* ** Recursively delete an expression tree. */ SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3 *db, Expr *p){ if( p==0 ) return; if( p->span.dyn ) sqlite3DbFree(db, (char*)p->span.z); if( p->token.dyn ) sqlite3DbFree(db, (char*)p->token.z); sqlite3ExprDelete(db, p->pLeft); sqlite3ExprDelete(db, p->pRight); sqlite3ExprListDelete(db, p->pList); sqlite3SelectDelete(db, p->pSelect); sqlite3DbFree(db, p); } /* ** The Expr.token field might be a string literal that is quoted. ** If so, remove the quotation marks. */ SQLITE_PRIVATE void sqlite3DequoteExpr(sqlite3 *db, Expr *p){ |
︙ | ︙ | |||
50007 50008 50009 50010 50011 50012 50013 | pNew->pLeft = sqlite3ExprDup(db, p->pLeft); pNew->pRight = sqlite3ExprDup(db, p->pRight); pNew->pList = sqlite3ExprListDup(db, p->pList); pNew->pSelect = sqlite3SelectDup(db, p->pSelect); return pNew; } SQLITE_PRIVATE void sqlite3TokenCopy(sqlite3 *db, Token *pTo, Token *pFrom){ | | | | 51175 51176 51177 51178 51179 51180 51181 51182 51183 51184 51185 51186 51187 51188 51189 51190 51191 51192 51193 51194 51195 51196 51197 51198 51199 51200 51201 51202 51203 51204 51205 51206 51207 51208 51209 | pNew->pLeft = sqlite3ExprDup(db, p->pLeft); pNew->pRight = sqlite3ExprDup(db, p->pRight); pNew->pList = sqlite3ExprListDup(db, p->pList); pNew->pSelect = sqlite3SelectDup(db, p->pSelect); return pNew; } SQLITE_PRIVATE void sqlite3TokenCopy(sqlite3 *db, Token *pTo, Token *pFrom){ if( pTo->dyn ) sqlite3DbFree(db, (char*)pTo->z); if( pFrom->z ){ pTo->n = pFrom->n; pTo->z = (u8*)sqlite3DbStrNDup(db, (char*)pFrom->z, pFrom->n); pTo->dyn = 1; }else{ pTo->z = 0; } } SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p){ ExprList *pNew; struct ExprList_item *pItem, *pOldItem; int i; if( p==0 ) return 0; pNew = sqlite3DbMallocRaw(db, sizeof(*pNew) ); if( pNew==0 ) return 0; pNew->iECursor = 0; pNew->nExpr = pNew->nAlloc = p->nExpr; pNew->a = pItem = sqlite3DbMallocRaw(db, p->nExpr*sizeof(p->a[0]) ); if( pItem==0 ){ sqlite3DbFree(db, pNew); return 0; } pOldItem = p->a; for(i=0; i<p->nExpr; i++, pItem++, pOldItem++){ Expr *pNewExpr, *pOldExpr; pItem->pExpr = pNewExpr = sqlite3ExprDup(db, pOldExpr = pOldItem->pExpr); if( pOldExpr->span.z!=0 && pNewExpr ){ |
︙ | ︙ | |||
50098 50099 50100 50101 50102 50103 50104 | int i; if( p==0 ) return 0; pNew = sqlite3DbMallocRaw(db, sizeof(*pNew) ); if( pNew==0 ) return 0; pNew->nId = pNew->nAlloc = p->nId; pNew->a = sqlite3DbMallocRaw(db, p->nId*sizeof(p->a[0]) ); if( pNew->a==0 ){ | | | 51266 51267 51268 51269 51270 51271 51272 51273 51274 51275 51276 51277 51278 51279 51280 | int i; if( p==0 ) return 0; pNew = sqlite3DbMallocRaw(db, sizeof(*pNew) ); if( pNew==0 ) return 0; pNew->nId = pNew->nAlloc = p->nId; pNew->a = sqlite3DbMallocRaw(db, p->nId*sizeof(p->a[0]) ); if( pNew->a==0 ){ sqlite3DbFree(db, pNew); return 0; } for(i=0; i<p->nId; i++){ struct IdList_item *pNewItem = &pNew->a[i]; struct IdList_item *pOldItem = &p->a[i]; pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName); pNewItem->idx = pOldItem->idx; |
︙ | ︙ | |||
50184 50185 50186 50187 50188 50189 50190 | pItem->zName = sqlite3NameFromToken(db, pName); pItem->pExpr = pExpr; } return pList; no_mem: /* Avoid leaking memory if malloc has failed. */ | | | | 51352 51353 51354 51355 51356 51357 51358 51359 51360 51361 51362 51363 51364 51365 51366 51367 | pItem->zName = sqlite3NameFromToken(db, pName); pItem->pExpr = pExpr; } return pList; no_mem: /* Avoid leaking memory if malloc has failed. */ sqlite3ExprDelete(db, pExpr); sqlite3ExprListDelete(db, pList); return 0; } /* ** If the expression list pEList contains more than iLimit elements, ** leave an error message in pParse. */ |
︙ | ︙ | |||
50209 50210 50211 50212 50213 50214 50215 | sqlite3ErrorMsg(pParse, "too many columns in %s", zObject); } } /* ** Delete an entire expression list. */ | | | | | | | 51377 51378 51379 51380 51381 51382 51383 51384 51385 51386 51387 51388 51389 51390 51391 51392 51393 51394 51395 51396 51397 51398 51399 51400 51401 51402 | sqlite3ErrorMsg(pParse, "too many columns in %s", zObject); } } /* ** Delete an entire expression list. */ SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3 *db, ExprList *pList){ int i; struct ExprList_item *pItem; if( pList==0 ) return; assert( pList->a!=0 || (pList->nExpr==0 && pList->nAlloc==0) ); assert( pList->nExpr<=pList->nAlloc ); for(pItem=pList->a, i=0; i<pList->nExpr; i++, pItem++){ sqlite3ExprDelete(db, pItem->pExpr); sqlite3DbFree(db, pItem->zName); } sqlite3DbFree(db, pList->a); sqlite3DbFree(db, pList); } /* ** Walk an expression tree. Call xFunc for each node visited. xFunc ** is called on the node before xFunc is called on the nodes children. ** ** The return value from xFunc determines whether the tree walk continues. |
︙ | ︙ | |||
50634 50635 50636 50637 50638 50639 50640 | Expr *pDup, *pOrig; assert( pExpr->pLeft==0 && pExpr->pRight==0 ); assert( pExpr->pList==0 ); assert( pExpr->pSelect==0 ); pOrig = pEList->a[j].pExpr; if( !pNC->allowAgg && ExprHasProperty(pOrig, EP_Agg) ){ sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs); | | | | | | 51802 51803 51804 51805 51806 51807 51808 51809 51810 51811 51812 51813 51814 51815 51816 51817 51818 51819 51820 51821 51822 51823 51824 51825 51826 51827 | Expr *pDup, *pOrig; assert( pExpr->pLeft==0 && pExpr->pRight==0 ); assert( pExpr->pList==0 ); assert( pExpr->pSelect==0 ); pOrig = pEList->a[j].pExpr; if( !pNC->allowAgg && ExprHasProperty(pOrig, EP_Agg) ){ sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs); sqlite3DbFree(db, zCol); return 2; } pDup = sqlite3ExprDup(db, pOrig); if( pExpr->flags & EP_ExpCollate ){ pDup->pColl = pExpr->pColl; pDup->flags |= EP_ExpCollate; } if( pExpr->span.dyn ) sqlite3DbFree(db, (char*)pExpr->span.z); if( pExpr->token.dyn ) sqlite3DbFree(db, (char*)pExpr->token.z); memcpy(pExpr, pDup, sizeof(*pExpr)); sqlite3DbFree(db, pDup); cnt = 1; pMatch = 0; assert( zTab==0 && zDb==0 ); goto lookupname_end_2; } } } |
︙ | ︙ | |||
50673 50674 50675 50676 50677 50678 50679 | ** case, we need to return right away and not make any changes to ** pExpr. ** ** Because no reference was made to outer contexts, the pNC->nRef ** fields are not changed in any context. */ if( cnt==0 && zTab==0 && pColumnToken->z[0]=='"' ){ | | | 51841 51842 51843 51844 51845 51846 51847 51848 51849 51850 51851 51852 51853 51854 51855 | ** case, we need to return right away and not make any changes to ** pExpr. ** ** Because no reference was made to outer contexts, the pNC->nRef ** fields are not changed in any context. */ if( cnt==0 && zTab==0 && pColumnToken->z[0]=='"' ){ sqlite3DbFree(db, zCol); return 0; } /* ** cnt==0 means there was not match. cnt>1 means there were two or ** more matches. Either way, we have an error. */ |
︙ | ︙ | |||
50713 50714 50715 50716 50717 50718 50719 | assert( pMatch->iCursor==pExpr->iTable ); pMatch->colUsed |= ((Bitmask)1)<<n; } lookupname_end: /* Clean up and return */ | | | | | | | 51881 51882 51883 51884 51885 51886 51887 51888 51889 51890 51891 51892 51893 51894 51895 51896 51897 51898 51899 51900 51901 51902 51903 | assert( pMatch->iCursor==pExpr->iTable ); pMatch->colUsed |= ((Bitmask)1)<<n; } lookupname_end: /* Clean up and return */ sqlite3DbFree(db, zDb); sqlite3DbFree(db, zTab); sqlite3ExprDelete(db, pExpr->pLeft); pExpr->pLeft = 0; sqlite3ExprDelete(db, pExpr->pRight); pExpr->pRight = 0; pExpr->op = TK_COLUMN; lookupname_end_2: sqlite3DbFree(db, zCol); if( cnt==1 ){ assert( pNC!=0 ); sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList); if( pMatch && !pMatch->pSelect ){ pExpr->pTab = pMatch->pTab; } /* Increment the nRef value on all name contexts from TopNC up to |
︙ | ︙ | |||
51336 51337 51338 51339 51340 51341 51342 | sqlite3VdbeAddOp2(v, OP_Null, 0, dest.iParm); VdbeComment((v, "Init subquery result")); }else{ dest.eDest = SRT_Exists; sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iParm); VdbeComment((v, "Init EXISTS result")); } | | | 52504 52505 52506 52507 52508 52509 52510 52511 52512 52513 52514 52515 52516 52517 52518 | sqlite3VdbeAddOp2(v, OP_Null, 0, dest.iParm); VdbeComment((v, "Init subquery result")); }else{ dest.eDest = SRT_Exists; sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iParm); VdbeComment((v, "Init EXISTS result")); } sqlite3ExprDelete(pParse->db, pSel->pLimit); pSel->pLimit = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &one); if( sqlite3Select(pParse, pSel, &dest, 0, 0, 0) ){ return; } pExpr->iColumn = dest.iParm; break; } |
︙ | ︙ | |||
52969 52970 52971 52972 52973 52974 52975 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that used to generate VDBE code ** that implements the ALTER TABLE command. ** | | | 54137 54138 54139 54140 54141 54142 54143 54144 54145 54146 54147 54148 54149 54150 54151 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that used to generate VDBE code ** that implements the ALTER TABLE command. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** The code in this file only exists if we are not omitting the ** ALTER TABLE logic from the build. */ #ifndef SQLITE_OMIT_ALTERTABLE |
︙ | ︙ | |||
53035 53036 53037 53038 53039 53040 53041 | len = sqlite3GetToken(zCsr, &token); } while( token==TK_SPACE || token==TK_COMMENT ); assert( len>0 ); } while( token!=TK_LP && token!=TK_USING ); zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", tname.z - zSql, zSql, zTableName, tname.z+tname.n); | | | 54203 54204 54205 54206 54207 54208 54209 54210 54211 54212 54213 54214 54215 54216 54217 | len = sqlite3GetToken(zCsr, &token); } while( token==TK_SPACE || token==TK_COMMENT ); assert( len>0 ); } while( token!=TK_LP && token!=TK_USING ); zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", tname.z - zSql, zSql, zTableName, tname.z+tname.n); sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC); } } #ifndef SQLITE_OMIT_TRIGGER /* This function is used by SQL generated to implement the ** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER ** statement. The second is a table name. The table name in the CREATE |
︙ | ︙ | |||
53110 53111 53112 53113 53114 53115 53116 | } while( dist!=2 || (token!=TK_WHEN && token!=TK_FOR && token!=TK_BEGIN) ); /* Variable tname now contains the token that is the old table-name ** in the CREATE TRIGGER statement. */ zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", tname.z - zSql, zSql, zTableName, tname.z+tname.n); | | | 54278 54279 54280 54281 54282 54283 54284 54285 54286 54287 54288 54289 54290 54291 54292 | } while( dist!=2 || (token!=TK_WHEN && token!=TK_FOR && token!=TK_BEGIN) ); /* Variable tname now contains the token that is the old table-name ** in the CREATE TRIGGER statement. */ zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", tname.z - zSql, zSql, zTableName, tname.z+tname.n); sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC); } } #endif /* !SQLITE_OMIT_TRIGGER */ /* ** Register built-in functions used to help implement ALTER TABLE */ |
︙ | ︙ | |||
53153 53154 53155 53156 53157 53158 53159 | for( pTrig=pTab->pTrigger; pTrig; pTrig=pTrig->pNext ){ if( pTrig->pSchema==pTempSchema ){ if( !zWhere ){ zWhere = sqlite3MPrintf(db, "name=%Q", pTrig->name); }else{ tmp = zWhere; zWhere = sqlite3MPrintf(db, "%s OR name=%Q", zWhere, pTrig->name); | | | 54321 54322 54323 54324 54325 54326 54327 54328 54329 54330 54331 54332 54333 54334 54335 | for( pTrig=pTab->pTrigger; pTrig; pTrig=pTrig->pNext ){ if( pTrig->pSchema==pTempSchema ){ if( !zWhere ){ zWhere = sqlite3MPrintf(db, "name=%Q", pTrig->name); }else{ tmp = zWhere; zWhere = sqlite3MPrintf(db, "%s OR name=%Q", zWhere, pTrig->name); sqlite3DbFree(db, tmp); } } } } return zWhere; } |
︙ | ︙ | |||
53364 53365 53366 53367 53368 53369 53370 | */ if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){ sqlite3NestedParse(pParse, "UPDATE sqlite_temp_master SET " "sql = sqlite_rename_trigger(sql, %Q), " "tbl_name = %Q " "WHERE %s;", zName, zName, zWhere); | | | | | 54532 54533 54534 54535 54536 54537 54538 54539 54540 54541 54542 54543 54544 54545 54546 54547 54548 54549 54550 54551 54552 54553 54554 54555 | */ if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){ sqlite3NestedParse(pParse, "UPDATE sqlite_temp_master SET " "sql = sqlite_rename_trigger(sql, %Q), " "tbl_name = %Q " "WHERE %s;", zName, zName, zWhere); sqlite3DbFree(db, zWhere); } #endif /* Drop and reload the internal table schema. */ reloadTableSchema(pParse, pTab, zName); exit_rename_table: sqlite3SrcListDelete(db, pSrc); sqlite3DbFree(db, zName); } /* ** This function is called after an "ALTER TABLE ... ADD" statement ** has been parsed. Argument pColDef contains the text of the new ** column definition. |
︙ | ︙ | |||
53473 53474 53475 53476 53477 53478 53479 | sqlite3NestedParse(pParse, "UPDATE \"%w\".%s SET " "sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) " "WHERE type = 'table' AND name = %Q", zDb, SCHEMA_TABLE(iDb), pNew->addColOffset, zCol, pNew->addColOffset+1, zTab ); | | | 54641 54642 54643 54644 54645 54646 54647 54648 54649 54650 54651 54652 54653 54654 54655 | sqlite3NestedParse(pParse, "UPDATE \"%w\".%s SET " "sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) " "WHERE type = 'table' AND name = %Q", zDb, SCHEMA_TABLE(iDb), pNew->addColOffset, zCol, pNew->addColOffset+1, zTab ); sqlite3DbFree(db, zCol); } /* If the default value of the new column is NULL, then set the file ** format to 2. If the default value of the new column is not NULL, ** the file format becomes 3. */ sqlite3MinimumFileFormat(pParse, iDb, pDflt ? 3 : 2); |
︙ | ︙ | |||
53540 53541 53542 53543 53544 53545 53546 53547 53548 53549 53550 53551 53552 53553 | /* Put a copy of the Table struct in Parse.pNewTable for the ** sqlite3AddColumn() function and friends to modify. */ pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table)); if( !pNew ) goto exit_begin_add_column; pParse->pNewTable = pNew; pNew->nRef = 1; pNew->nCol = pTab->nCol; assert( pNew->nCol>0 ); nAlloc = (((pNew->nCol-1)/8)*8)+8; assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 ); pNew->aCol = (Column*)sqlite3DbMallocZero(db, sizeof(Column)*nAlloc); pNew->zName = sqlite3DbStrDup(db, pTab->zName); if( !pNew->aCol || !pNew->zName ){ | > | 54708 54709 54710 54711 54712 54713 54714 54715 54716 54717 54718 54719 54720 54721 54722 | /* Put a copy of the Table struct in Parse.pNewTable for the ** sqlite3AddColumn() function and friends to modify. */ pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table)); if( !pNew ) goto exit_begin_add_column; pParse->pNewTable = pNew; pNew->nRef = 1; pNew->db = db; pNew->nCol = pTab->nCol; assert( pNew->nCol>0 ); nAlloc = (((pNew->nCol-1)/8)*8)+8; assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 ); pNew->aCol = (Column*)sqlite3DbMallocZero(db, sizeof(Column)*nAlloc); pNew->zName = sqlite3DbStrDup(db, pTab->zName); if( !pNew->aCol || !pNew->zName ){ |
︙ | ︙ | |||
53569 53570 53571 53572 53573 53574 53575 | /* Begin a transaction and increment the schema cookie. */ sqlite3BeginWriteOperation(pParse, 0, iDb); v = sqlite3GetVdbe(pParse); if( !v ) goto exit_begin_add_column; sqlite3ChangeCookie(pParse, iDb); exit_begin_add_column: | | | | 54738 54739 54740 54741 54742 54743 54744 54745 54746 54747 54748 54749 54750 54751 54752 54753 54754 54755 54756 54757 54758 54759 54760 54761 54762 54763 54764 54765 54766 54767 54768 54769 54770 54771 54772 | /* Begin a transaction and increment the schema cookie. */ sqlite3BeginWriteOperation(pParse, 0, iDb); v = sqlite3GetVdbe(pParse); if( !v ) goto exit_begin_add_column; sqlite3ChangeCookie(pParse, iDb); exit_begin_add_column: sqlite3SrcListDelete(db, pSrc); return; } #endif /* SQLITE_ALTER_TABLE */ /************** End of alter.c ***********************************************/ /************** Begin file analyze.c *****************************************/ /* ** 2005 July 8 ** ** 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 contains code associated with the ANALYZE command. ** ** @(#) $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef SQLITE_OMIT_ANALYZE /* ** This routine generates code that opens the sqlite_stat1 table on cursor ** iStatCur. ** |
︙ | ︙ | |||
53893 53894 53895 53896 53897 53898 53899 | iDb = sqlite3FindDb(db, pName1); if( iDb>=0 ){ analyzeDatabase(pParse, iDb); }else{ z = sqlite3NameFromToken(db, pName1); if( z ){ pTab = sqlite3LocateTable(pParse, 0, z, 0); | | | | 55062 55063 55064 55065 55066 55067 55068 55069 55070 55071 55072 55073 55074 55075 55076 55077 55078 55079 55080 55081 55082 55083 55084 55085 55086 55087 55088 55089 55090 | iDb = sqlite3FindDb(db, pName1); if( iDb>=0 ){ analyzeDatabase(pParse, iDb); }else{ z = sqlite3NameFromToken(db, pName1); if( z ){ pTab = sqlite3LocateTable(pParse, 0, z, 0); sqlite3DbFree(db, z); if( pTab ){ analyzeTable(pParse, pTab); } } } }else{ /* Form 3: Analyze the fully qualified table name */ iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pTableName); if( iDb>=0 ){ zDb = db->aDb[iDb].zName; z = sqlite3NameFromToken(db, pTableName); if( z ){ pTab = sqlite3LocateTable(pParse, 0, z, zDb); sqlite3DbFree(db, z); if( pTab ){ analyzeTable(pParse, pTab); } } } } } |
︙ | ︙ | |||
53994 53995 53996 53997 53998 53999 54000 | /* Load new statistics out of the sqlite_stat1 table */ zSql = sqlite3MPrintf(db, "SELECT idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase); (void)sqlite3SafetyOff(db); rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0); (void)sqlite3SafetyOn(db); | | | 55163 55164 55165 55166 55167 55168 55169 55170 55171 55172 55173 55174 55175 55176 55177 | /* Load new statistics out of the sqlite_stat1 table */ zSql = sqlite3MPrintf(db, "SELECT idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase); (void)sqlite3SafetyOff(db); rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0); (void)sqlite3SafetyOn(db); sqlite3DbFree(db, zSql); return rc; } #endif /* SQLITE_OMIT_ANALYZE */ /************** End of analyze.c *********************************************/ |
︙ | ︙ | |||
54016 54017 54018 54019 54020 54021 54022 | ** 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 contains code used to implement the ATTACH and DETACH commands. ** | | | 55185 55186 55187 55188 55189 55190 55191 55192 55193 55194 55195 55196 55197 55198 55199 | ** 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 contains code used to implement the ATTACH and DETACH commands. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef SQLITE_OMIT_ATTACH /* ** Resolve an expression that was part of an ATTACH or DETACH statement. This ** is slightly different from resolving a normal SQL expression, because simple ** identifiers are treated as strings, not possible column names or aliases. |
︙ | ︙ | |||
54218 54219 54220 54221 54222 54223 54224 | return; attach_error: /* Return an error if we get here */ if( zErrDyn ){ sqlite3_result_error(context, zErrDyn, -1); | | | 55387 55388 55389 55390 55391 55392 55393 55394 55395 55396 55397 55398 55399 55400 55401 | return; attach_error: /* Return an error if we get here */ if( zErrDyn ){ sqlite3_result_error(context, zErrDyn, -1); sqlite3DbFree(db, zErrDyn); }else{ zErr[sizeof(zErr)-1] = 0; sqlite3_result_error(context, zErr, -1); } if( rc ) sqlite3_result_error_code(context, rc); } |
︙ | ︙ | |||
54309 54310 54311 54312 54313 54314 54315 | assert( db->mallocFailed || pAuthArg ); if( pAuthArg ){ char *zAuthArg = sqlite3NameFromToken(db, &pAuthArg->span); if( !zAuthArg ){ goto attach_end; } rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0); | | | 55478 55479 55480 55481 55482 55483 55484 55485 55486 55487 55488 55489 55490 55491 55492 | assert( db->mallocFailed || pAuthArg ); if( pAuthArg ){ char *zAuthArg = sqlite3NameFromToken(db, &pAuthArg->span); if( !zAuthArg ){ goto attach_end; } rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0); sqlite3DbFree(db, zAuthArg); if(rc!=SQLITE_OK ){ goto attach_end; } } #endif /* SQLITE_OMIT_AUTHORIZATION */ memset(&sName, 0, sizeof(NameContext)); |
︙ | ︙ | |||
54349 54350 54351 54352 54353 54354 54355 | ** statement only). For DETACH, set it to false (expire all existing ** statements). */ sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH)); } attach_end: | | | | | 55518 55519 55520 55521 55522 55523 55524 55525 55526 55527 55528 55529 55530 55531 55532 55533 55534 | ** statement only). For DETACH, set it to false (expire all existing ** statements). */ sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH)); } attach_end: sqlite3ExprDelete(db, pFilename); sqlite3ExprDelete(db, pDbname); sqlite3ExprDelete(db, pKey); } /* ** Called by the parser to compile a DETACH statement. ** ** DETACH pDbname */ |
︙ | ︙ | |||
54545 54546 54547 54548 54549 54550 54551 | ** ************************************************************************* ** This file contains code used to implement the sqlite3_set_authorizer() ** API. This facility is an optional feature of the library. Embedded ** systems that do not need this facility may omit it by recompiling ** the library with -DSQLITE_OMIT_AUTHORIZATION=1 ** | | | 55714 55715 55716 55717 55718 55719 55720 55721 55722 55723 55724 55725 55726 55727 55728 | ** ************************************************************************* ** This file contains code used to implement the sqlite3_set_authorizer() ** API. This facility is an optional feature of the library. Embedded ** systems that do not need this facility may omit it by recompiling ** the library with -DSQLITE_OMIT_AUTHORIZATION=1 ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** All of the code in this file may be omitted by defining a single ** macro. */ #ifndef SQLITE_OMIT_AUTHORIZATION |
︙ | ︙ | |||
54789 54790 54791 54792 54793 54794 54795 | ** CREATE INDEX ** DROP INDEX ** creating ID lists ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** | | | 55958 55959 55960 55961 55962 55963 55964 55965 55966 55967 55968 55969 55970 55971 55972 | ** CREATE INDEX ** DROP INDEX ** creating ID lists ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** This routine is called when a new SQL statement is beginning to ** be parsed. Initialize the pParse structure as needed. */ SQLITE_PRIVATE void sqlite3BeginParse(Parse *pParse, int explainFlag){ |
︙ | ︙ | |||
54902 54903 54904 54905 54906 54907 54908 | sqlite3 *db; Vdbe *v; db = pParse->db; if( db->mallocFailed ) return; if( pParse->nested ) return; if( pParse->nErr ) return; | < < < < < < | 56071 56072 56073 56074 56075 56076 56077 56078 56079 56080 56081 56082 56083 56084 | sqlite3 *db; Vdbe *v; db = pParse->db; if( db->mallocFailed ) return; if( pParse->nested ) return; if( pParse->nErr ) return; /* Begin by generating some termination code at the end of the ** vdbe program */ v = sqlite3GetVdbe(pParse); if( v ){ sqlite3VdbeAddOp0(v, OP_Halt); |
︙ | ︙ | |||
55004 55005 55006 55007 55008 55009 55010 55011 55012 55013 55014 55015 55016 | ** INSERT, UPDATE, and DELETE operations against SQLITE_MASTER. Use ** care if you decide to try to use this routine for some other purposes. */ SQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){ va_list ap; char *zSql; char *zErrMsg = 0; # define SAVE_SZ (sizeof(Parse) - offsetof(Parse,nVar)) char saveBuf[SAVE_SZ]; if( pParse->nErr ) return; assert( pParse->nested<10 ); /* Nesting should only be of limited depth */ va_start(ap, zFormat); | > | < | | | 56167 56168 56169 56170 56171 56172 56173 56174 56175 56176 56177 56178 56179 56180 56181 56182 56183 56184 56185 56186 56187 56188 56189 56190 56191 56192 56193 56194 56195 56196 56197 56198 | ** INSERT, UPDATE, and DELETE operations against SQLITE_MASTER. Use ** care if you decide to try to use this routine for some other purposes. */ SQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){ va_list ap; char *zSql; char *zErrMsg = 0; sqlite3 *db = pParse->db; # define SAVE_SZ (sizeof(Parse) - offsetof(Parse,nVar)) char saveBuf[SAVE_SZ]; if( pParse->nErr ) return; assert( pParse->nested<10 ); /* Nesting should only be of limited depth */ va_start(ap, zFormat); zSql = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); if( zSql==0 ){ return; /* A malloc must have failed */ } pParse->nested++; memcpy(saveBuf, &pParse->nVar, SAVE_SZ); memset(&pParse->nVar, 0, SAVE_SZ); sqlite3RunParser(pParse, zSql, &zErrMsg); sqlite3DbFree(db, zErrMsg); sqlite3DbFree(db, zSql); memcpy(&pParse->nVar, saveBuf, SAVE_SZ); pParse->nested--; } /* ** Locate the in-memory structure that describes a particular database ** table given the name of that table and (optionally) the name of the |
︙ | ︙ | |||
55123 55124 55125 55126 55127 55128 55129 | return p; } /* ** Reclaim the memory used by an index */ static void freeIndex(Index *p){ | > | | | 56286 56287 56288 56289 56290 56291 56292 56293 56294 56295 56296 56297 56298 56299 56300 56301 56302 | return p; } /* ** Reclaim the memory used by an index */ static void freeIndex(Index *p){ sqlite3 *db = p->pTable->db; sqlite3DbFree(db, p->zColAff); sqlite3DbFree(db, p); } /* ** Remove the given index from the index hash table, and free ** its memory structures. ** ** The index is removed from the database hash tables but |
︙ | ︙ | |||
55218 55219 55220 55221 55222 55223 55224 | if( pDb->pAux && pDb->xFreeAux ) pDb->xFreeAux(pDb->pAux); pDb->pAux = 0; } } for(i=j=2; i<db->nDb; i++){ struct Db *pDb = &db->aDb[i]; if( pDb->pBt==0 ){ | | | > | | | | | > > | 56382 56383 56384 56385 56386 56387 56388 56389 56390 56391 56392 56393 56394 56395 56396 56397 56398 56399 56400 56401 56402 56403 56404 56405 56406 56407 56408 56409 56410 56411 56412 56413 56414 56415 56416 56417 56418 56419 56420 56421 56422 56423 56424 56425 56426 56427 56428 56429 56430 56431 56432 56433 56434 56435 56436 56437 56438 56439 56440 56441 56442 56443 56444 56445 56446 56447 56448 56449 56450 56451 56452 56453 56454 56455 56456 56457 56458 | if( pDb->pAux && pDb->xFreeAux ) pDb->xFreeAux(pDb->pAux); pDb->pAux = 0; } } for(i=j=2; i<db->nDb; i++){ struct Db *pDb = &db->aDb[i]; if( pDb->pBt==0 ){ sqlite3DbFree(db, pDb->zName); pDb->zName = 0; continue; } if( j<i ){ db->aDb[j] = db->aDb[i]; } j++; } memset(&db->aDb[j], 0, (db->nDb-j)*sizeof(db->aDb[j])); db->nDb = j; if( db->nDb<=2 && db->aDb!=db->aDbStatic ){ memcpy(db->aDbStatic, db->aDb, 2*sizeof(db->aDb[0])); sqlite3DbFree(db, db->aDb); db->aDb = db->aDbStatic; } } /* ** This routine is called when a commit occurs. */ SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3 *db){ db->flags &= ~SQLITE_InternChanges; } /* ** Clear the column names from a table or view. */ static void sqliteResetColumnNames(Table *pTable){ int i; Column *pCol; sqlite3 *db = pTable->db; assert( pTable!=0 ); if( (pCol = pTable->aCol)!=0 ){ for(i=0; i<pTable->nCol; i++, pCol++){ sqlite3DbFree(db, pCol->zName); sqlite3ExprDelete(db, pCol->pDflt); sqlite3DbFree(db, pCol->zType); sqlite3DbFree(db, pCol->zColl); } sqlite3DbFree(db, pTable->aCol); } pTable->aCol = 0; pTable->nCol = 0; } /* ** Remove the memory data structures associated with the given ** Table. No changes are made to disk by this routine. ** ** This routine just deletes the data structure. It does not unlink ** the table data structure from the hash table. Nor does it remove ** foreign keys from the sqlite.aFKey hash table. But it does destroy ** memory structures of the indices and foreign keys associated with ** the table. */ SQLITE_PRIVATE void sqlite3DeleteTable(Table *pTable){ Index *pIndex, *pNext; FKey *pFKey, *pNextFKey; sqlite3 *db; if( pTable==0 ) return; db = pTable->db; /* Do not delete the table until the reference count reaches zero. */ pTable->nRef--; if( pTable->nRef>0 ){ return; } assert( pTable->nRef==0 ); |
︙ | ︙ | |||
55302 55303 55304 55305 55306 55307 55308 | /* Delete all foreign keys associated with this table. The keys ** should have already been unlinked from the pSchema->aFKey hash table */ for(pFKey=pTable->pFKey; pFKey; pFKey=pNextFKey){ pNextFKey = pFKey->pNextFrom; assert( sqlite3HashFind(&pTable->pSchema->aFKey, pFKey->zTo, strlen(pFKey->zTo)+1)!=pFKey ); | | | | | | | | 56469 56470 56471 56472 56473 56474 56475 56476 56477 56478 56479 56480 56481 56482 56483 56484 56485 56486 56487 56488 56489 56490 56491 56492 56493 56494 56495 56496 56497 | /* Delete all foreign keys associated with this table. The keys ** should have already been unlinked from the pSchema->aFKey hash table */ for(pFKey=pTable->pFKey; pFKey; pFKey=pNextFKey){ pNextFKey = pFKey->pNextFrom; assert( sqlite3HashFind(&pTable->pSchema->aFKey, pFKey->zTo, strlen(pFKey->zTo)+1)!=pFKey ); sqlite3DbFree(db, pFKey); } #endif /* Delete the Table structure itself. */ sqliteResetColumnNames(pTable); sqlite3DbFree(db, pTable->zName); sqlite3DbFree(db, pTable->zColAff); sqlite3SelectDelete(db, pTable->pSelect); #ifndef SQLITE_OMIT_CHECK sqlite3ExprDelete(db, pTable->pCheck); #endif sqlite3VtabClear(pTable); sqlite3DbFree(db, pTable); } /* ** Unlink the given table from the hash tables and the delete the ** table structure with all its indices and foreign keys. */ SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){ |
︙ | ︙ | |||
55406 55407 55408 55409 55410 55411 55412 | n = strlen(zName); for(i=(db->nDb-1), pDb=&db->aDb[i]; i>=0; i--, pDb--){ if( (!OMIT_TEMPDB || i!=1 ) && n==strlen(pDb->zName) && 0==sqlite3StrICmp(pDb->zName, zName) ){ break; } } | | | 56573 56574 56575 56576 56577 56578 56579 56580 56581 56582 56583 56584 56585 56586 56587 | n = strlen(zName); for(i=(db->nDb-1), pDb=&db->aDb[i]; i>=0; i--, pDb--){ if( (!OMIT_TEMPDB || i!=1 ) && n==strlen(pDb->zName) && 0==sqlite3StrICmp(pDb->zName, zName) ){ break; } } sqlite3DbFree(db, zName); } return i; } /* The table or view or trigger name is passed to this routine via tokens ** pName1 and pName2. If the table name was fully qualified, for example: ** |
︙ | ︙ | |||
55597 55598 55599 55600 55601 55602 55603 55604 55605 55606 55607 55608 55609 55610 | pParse->nErr++; goto begin_table_error; } pTable->zName = zName; pTable->iPKey = -1; pTable->pSchema = db->aDb[iDb].pSchema; pTable->nRef = 1; if( pParse->pNewTable ) sqlite3DeleteTable(pParse->pNewTable); pParse->pNewTable = pTable; /* If this is the magic sqlite_sequence table used by autoincrement, ** then record a pointer to this table in the main database structure ** so that INSERT can find the table easily. */ | > | 56764 56765 56766 56767 56768 56769 56770 56771 56772 56773 56774 56775 56776 56777 56778 | pParse->nErr++; goto begin_table_error; } pTable->zName = zName; pTable->iPKey = -1; pTable->pSchema = db->aDb[iDb].pSchema; pTable->nRef = 1; pTable->db = db; if( pParse->pNewTable ) sqlite3DeleteTable(pParse->pNewTable); pParse->pNewTable = pTable; /* If this is the magic sqlite_sequence table used by autoincrement, ** then record a pointer to this table in the main database structure ** so that INSERT can find the table easily. */ |
︙ | ︙ | |||
55676 55677 55678 55679 55680 55681 55682 | } /* Normal (non-error) return. */ return; /* If an error occurs, we jump here */ begin_table_error: | | | 56844 56845 56846 56847 56848 56849 56850 56851 56852 56853 56854 56855 56856 56857 56858 | } /* Normal (non-error) return. */ return; /* If an error occurs, we jump here */ begin_table_error: sqlite3DbFree(db, zName); return; } /* ** This macro is used to compare two strings in a case-insensitive manner. ** It is slightly faster than calling sqlite3StrICmp() directly, but ** produces larger code. |
︙ | ︙ | |||
55719 55720 55721 55722 55723 55724 55725 | } #endif z = sqlite3NameFromToken(pParse->db, pName); if( z==0 ) return; for(i=0; i<p->nCol; i++){ if( STRICMP(z, p->aCol[i].zName) ){ sqlite3ErrorMsg(pParse, "duplicate column name: %s", z); | | | | 56887 56888 56889 56890 56891 56892 56893 56894 56895 56896 56897 56898 56899 56900 56901 56902 56903 56904 56905 56906 56907 56908 56909 | } #endif z = sqlite3NameFromToken(pParse->db, pName); if( z==0 ) return; for(i=0; i<p->nCol; i++){ if( STRICMP(z, p->aCol[i].zName) ){ sqlite3ErrorMsg(pParse, "duplicate column name: %s", z); sqlite3DbFree(db, z); return; } } if( (p->nCol & 0x7)==0 ){ Column *aNew; aNew = sqlite3DbRealloc(pParse->db,p->aCol,(p->nCol+8)*sizeof(p->aCol[0])); if( aNew==0 ){ sqlite3DbFree(db, z); return; } p->aCol = aNew; } pCol = &p->aCol[p->nCol]; memset(pCol, 0, sizeof(p->aCol[0])); pCol->zName = z; |
︙ | ︙ | |||
55834 55835 55836 55837 55838 55839 55840 55841 55842 55843 55844 55845 | ** that contains the typename of the column and store that string ** in zType. */ SQLITE_PRIVATE void sqlite3AddColumnType(Parse *pParse, Token *pType){ Table *p; int i; Column *pCol; if( (p = pParse->pNewTable)==0 ) return; i = p->nCol-1; if( i<0 ) return; pCol = &p->aCol[i]; | > > | | > < | | | 57002 57003 57004 57005 57006 57007 57008 57009 57010 57011 57012 57013 57014 57015 57016 57017 57018 57019 57020 57021 57022 57023 57024 57025 57026 57027 57028 57029 57030 57031 57032 57033 57034 57035 57036 57037 57038 57039 57040 57041 57042 57043 57044 57045 57046 57047 57048 57049 57050 57051 57052 57053 57054 57055 57056 | ** that contains the typename of the column and store that string ** in zType. */ SQLITE_PRIVATE void sqlite3AddColumnType(Parse *pParse, Token *pType){ Table *p; int i; Column *pCol; sqlite3 *db; if( (p = pParse->pNewTable)==0 ) return; i = p->nCol-1; if( i<0 ) return; pCol = &p->aCol[i]; db = pParse->db; sqlite3DbFree(db, pCol->zType); pCol->zType = sqlite3NameFromToken(db, pType); pCol->affinity = sqlite3AffinityType(pType); } /* ** The expression is the default value for the most recently added column ** of the table currently under construction. ** ** Default value expressions must be constant. Raise an exception if this ** is not the case. ** ** This routine is called by the parser while in the middle of ** parsing a CREATE TABLE statement. */ SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse *pParse, Expr *pExpr){ Table *p; Column *pCol; sqlite3 *db = pParse->db; if( (p = pParse->pNewTable)!=0 ){ pCol = &(p->aCol[p->nCol-1]); if( !sqlite3ExprIsConstantOrFunction(pExpr) ){ sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant", pCol->zName); }else{ Expr *pCopy; sqlite3ExprDelete(db, pCol->pDflt); pCol->pDflt = pCopy = sqlite3ExprDup(db, pExpr); if( pCopy ){ sqlite3TokenCopy(db, &pCopy->span, &pExpr->span); } } } sqlite3ExprDelete(db, pExpr); } /* ** Designate the PRIMARY KEY for the table. pList is a list of names ** of columns that form the primary key. If pList is NULL, then the ** most recently added column of the table is the primary key. ** |
︙ | ︙ | |||
55945 55946 55947 55948 55949 55950 55951 | #endif }else{ sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0); pList = 0; } primary_key_exit: | | > < | > | | | | 57115 57116 57117 57118 57119 57120 57121 57122 57123 57124 57125 57126 57127 57128 57129 57130 57131 57132 57133 57134 57135 57136 57137 57138 57139 57140 57141 57142 57143 57144 57145 57146 57147 57148 57149 57150 57151 57152 57153 57154 57155 57156 57157 57158 57159 57160 57161 57162 57163 57164 57165 57166 57167 57168 57169 57170 57171 57172 57173 57174 57175 57176 57177 57178 57179 57180 57181 57182 57183 57184 57185 | #endif }else{ sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0); pList = 0; } primary_key_exit: sqlite3ExprListDelete(pParse->db, pList); return; } /* ** Add a new CHECK constraint to the table currently under construction. */ SQLITE_PRIVATE void sqlite3AddCheckConstraint( Parse *pParse, /* Parsing context */ Expr *pCheckExpr /* The check expression */ ){ sqlite3 *db = pParse->db; #ifndef SQLITE_OMIT_CHECK Table *pTab = pParse->pNewTable; if( pTab && !IN_DECLARE_VTAB ){ /* The CHECK expression must be duplicated so that tokens refer ** to malloced space and not the (ephemeral) text of the CREATE TABLE ** statement */ pTab->pCheck = sqlite3ExprAnd(db, pTab->pCheck, sqlite3ExprDup(db, pCheckExpr)); } #endif sqlite3ExprDelete(db, pCheckExpr); } /* ** Set the collation function of the most recently parsed table column ** to the CollSeq given. */ SQLITE_PRIVATE void sqlite3AddCollateType(Parse *pParse, Token *pToken){ Table *p; int i; char *zColl; /* Dequoted name of collation sequence */ sqlite3 *db; if( (p = pParse->pNewTable)==0 ) return; i = p->nCol-1; db = pParse->db; zColl = sqlite3NameFromToken(db, pToken); if( !zColl ) return; if( sqlite3LocateCollSeq(pParse, zColl, -1) ){ Index *pIdx; p->aCol[i].zColl = zColl; /* If the column is declared as "<name> PRIMARY KEY COLLATE <type>", ** then an index may have been created on this column before the ** collation type was added. Correct this if it is the case. */ for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){ assert( pIdx->nColumn==1 ); if( pIdx->aiColumn[0]==i ){ pIdx->azColl[0] = p->aCol[i].zColl; } } }else{ sqlite3DbFree(db, zColl); } } /* ** This function returns the collation sequence for database native text ** encoding identified by the string zName, length nName. ** |
︙ | ︙ | |||
56287 56288 56289 56290 56291 56292 56293 56294 56295 56296 56297 56298 56299 56300 | ** a schema-lock excludes all other database users, the write-lock would ** be redundant. */ if( pSelect ){ SelectDest dest; Table *pSelTab; sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse->regRoot, iDb); sqlite3VdbeChangeP5(v, 1); pParse->nTab = 2; sqlite3SelectDestInit(&dest, SRT_Table, 1); sqlite3Select(pParse, pSelect, &dest, 0, 0, 0); sqlite3VdbeAddOp1(v, OP_Close, 1); if( pParse->nErr==0 ){ | > | 57458 57459 57460 57461 57462 57463 57464 57465 57466 57467 57468 57469 57470 57471 57472 | ** a schema-lock excludes all other database users, the write-lock would ** be redundant. */ if( pSelect ){ SelectDest dest; Table *pSelTab; assert(pParse->nTab==0); sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse->regRoot, iDb); sqlite3VdbeChangeP5(v, 1); pParse->nTab = 2; sqlite3SelectDestInit(&dest, SRT_Table, 1); sqlite3Select(pParse, pSelect, &dest, 0, 0, 0); sqlite3VdbeAddOp1(v, OP_Close, 1); if( pParse->nErr==0 ){ |
︙ | ︙ | |||
56333 56334 56335 56336 56337 56338 56339 | zType, p->zName, p->zName, pParse->regRoot, zStmt, pParse->regRowid ); | | | 57505 57506 57507 57508 57509 57510 57511 57512 57513 57514 57515 57516 57517 57518 57519 | zType, p->zName, p->zName, pParse->regRoot, zStmt, pParse->regRowid ); sqlite3DbFree(db, zStmt); sqlite3ChangeCookie(pParse, iDb); #ifndef SQLITE_OMIT_AUTOINCREMENT /* Check to see if we need to create an sqlite_sequence table for ** keeping track of autoincrement keys. */ if( p->autoInc ){ |
︙ | ︙ | |||
56423 56424 56425 56426 56427 56428 56429 | DbFixer sFix; Token *pName; int iDb; sqlite3 *db = pParse->db; if( pParse->nVar>0 ){ sqlite3ErrorMsg(pParse, "parameters are not allowed in views"); | | | | | | 57595 57596 57597 57598 57599 57600 57601 57602 57603 57604 57605 57606 57607 57608 57609 57610 57611 57612 57613 57614 57615 57616 57617 57618 57619 57620 57621 57622 57623 57624 57625 57626 57627 57628 57629 57630 57631 57632 57633 | DbFixer sFix; Token *pName; int iDb; sqlite3 *db = pParse->db; if( pParse->nVar>0 ){ sqlite3ErrorMsg(pParse, "parameters are not allowed in views"); sqlite3SelectDelete(db, pSelect); return; } sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr); p = pParse->pNewTable; if( p==0 || pParse->nErr ){ sqlite3SelectDelete(db, pSelect); return; } sqlite3TwoPartName(pParse, pName1, pName2, &pName); iDb = sqlite3SchemaToIndex(db, p->pSchema); if( sqlite3FixInit(&sFix, pParse, iDb, "view", pName) && sqlite3FixSelect(&sFix, pSelect) ){ sqlite3SelectDelete(db, pSelect); return; } /* Make a copy of the entire SELECT statement that defines the view. ** This will force all the Expr.token.z values to be dynamically ** allocated rather than point to the input string - which means that ** they will persist after the current sqlite3_exec() call returns. */ p->pSelect = sqlite3SelectDup(db, pSelect); sqlite3SelectDelete(db, pSelect); if( db->mallocFailed ){ return; } if( !db->init.busy ){ sqlite3ViewGetColumnNames(pParse, p); } |
︙ | ︙ | |||
56554 56555 56556 56557 56558 56559 56560 | pSelTab->aCol = 0; sqlite3DeleteTable(pSelTab); pTable->pSchema->flags |= DB_UnresetViews; }else{ pTable->nCol = 0; nErr++; } | | | 57726 57727 57728 57729 57730 57731 57732 57733 57734 57735 57736 57737 57738 57739 57740 | pSelTab->aCol = 0; sqlite3DeleteTable(pSelTab); pTable->pSchema->flags |= DB_UnresetViews; }else{ pTable->nCol = 0; nErr++; } sqlite3SelectDelete(db, pSel); } else { nErr++; } #endif /* SQLITE_OMIT_VIEW */ return nErr; } #endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */ |
︙ | ︙ | |||
56870 56871 56872 56873 56874 56875 56876 | } sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0); sqlite3ChangeCookie(pParse, iDb); } sqliteViewResetAll(db, iDb); exit_drop_table: | | | 58042 58043 58044 58045 58046 58047 58048 58049 58050 58051 58052 58053 58054 58055 58056 | } sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0); sqlite3ChangeCookie(pParse, iDb); } sqliteViewResetAll(db, iDb); exit_drop_table: sqlite3SrcListDelete(db, pName); } /* ** This routine is called to create a new foreign key on the table ** currently under construction. pFromCol determines which columns ** in the current table point to the foreign key. If pFromCol==0 then ** connect the key to the last column inserted. pTo is the name of |
︙ | ︙ | |||
56905 56906 56907 56908 56909 56910 56911 56912 56913 56914 56915 56916 56917 56918 56919 56920 | #ifndef SQLITE_OMIT_FOREIGN_KEY FKey *pFKey = 0; Table *p = pParse->pNewTable; int nByte; int i; int nCol; char *z; assert( pTo!=0 ); if( p==0 || pParse->nErr || IN_DECLARE_VTAB ) goto fk_end; if( pFromCol==0 ){ int iCol = p->nCol-1; if( iCol<0 ) goto fk_end; if( pToCol && pToCol->nExpr!=1 ){ sqlite3ErrorMsg(pParse, "foreign key on %s" " should reference only one column of table %T", | > > | 58077 58078 58079 58080 58081 58082 58083 58084 58085 58086 58087 58088 58089 58090 58091 58092 58093 58094 | #ifndef SQLITE_OMIT_FOREIGN_KEY FKey *pFKey = 0; Table *p = pParse->pNewTable; int nByte; int i; int nCol; char *z; sqlite3 *db; assert( pTo!=0 ); db = pParse->db; if( p==0 || pParse->nErr || IN_DECLARE_VTAB ) goto fk_end; if( pFromCol==0 ){ int iCol = p->nCol-1; if( iCol<0 ) goto fk_end; if( pToCol && pToCol->nExpr!=1 ){ sqlite3ErrorMsg(pParse, "foreign key on %s" " should reference only one column of table %T", |
︙ | ︙ | |||
56932 56933 56934 56935 56936 56937 56938 | } nByte = sizeof(*pFKey) + nCol*sizeof(pFKey->aCol[0]) + pTo->n + 1; if( pToCol ){ for(i=0; i<pToCol->nExpr; i++){ nByte += strlen(pToCol->a[i].zName) + 1; } } | | | 58106 58107 58108 58109 58110 58111 58112 58113 58114 58115 58116 58117 58118 58119 58120 | } nByte = sizeof(*pFKey) + nCol*sizeof(pFKey->aCol[0]) + pTo->n + 1; if( pToCol ){ for(i=0; i<pToCol->nExpr; i++){ nByte += strlen(pToCol->a[i].zName) + 1; } } pFKey = sqlite3DbMallocZero(db, nByte ); if( pFKey==0 ){ goto fk_end; } pFKey->pFrom = p; pFKey->pNextFrom = p->pFKey; z = (char*)&pFKey[1]; pFKey->aCol = (struct sColMap*)z; |
︙ | ︙ | |||
56986 56987 56988 56989 56990 56991 56992 | /* Link the foreign key to the table as the last step. */ p->pFKey = pFKey; pFKey = 0; fk_end: | | | | | 58160 58161 58162 58163 58164 58165 58166 58167 58168 58169 58170 58171 58172 58173 58174 58175 58176 58177 | /* Link the foreign key to the table as the last step. */ p->pFKey = pFKey; pFKey = 0; fk_end: sqlite3DbFree(db, pFKey); #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */ sqlite3ExprListDelete(db, pFromCol); sqlite3ExprListDelete(db, pToCol); } /* ** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED ** clause is seen as part of a foreign key definition. The isDeferred ** parameter is 1 for INITIALLY DEFERRED and 0 for INITIALLY IMMEDIATE. ** The behavior of the most recently created foreign key is adjusted |
︙ | ︙ | |||
57476 57477 57478 57479 57480 57481 57482 | "INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);", db->aDb[iDb].zName, SCHEMA_TABLE(iDb), pIndex->zName, pTab->zName, iMem, zStmt ); | | | 58650 58651 58652 58653 58654 58655 58656 58657 58658 58659 58660 58661 58662 58663 58664 | "INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);", db->aDb[iDb].zName, SCHEMA_TABLE(iDb), pIndex->zName, pTab->zName, iMem, zStmt ); sqlite3DbFree(db, zStmt); /* Fill the index with data and reparse the schema. Code an OP_Expire ** to invalidate all pre-compiled statements. */ if( pTblName ){ sqlite3RefillIndex(pParse, pIndex, iMem); sqlite3ChangeCookie(pParse, iDb); |
︙ | ︙ | |||
57516 57517 57518 57519 57520 57521 57522 | } /* Clean up before exiting */ exit_create_index: if( pIndex ){ freeIndex(pIndex); } | | | | | 58690 58691 58692 58693 58694 58695 58696 58697 58698 58699 58700 58701 58702 58703 58704 58705 58706 | } /* Clean up before exiting */ exit_create_index: if( pIndex ){ freeIndex(pIndex); } sqlite3ExprListDelete(db, pList); sqlite3SrcListDelete(db, pTblName); sqlite3DbFree(db, zName); return; } /* ** Generate code to make sure the file format number is at least minFormat. ** The generated code will increase the file format number if necessary. */ |
︙ | ︙ | |||
57647 57648 57649 57650 57651 57652 57653 | } sqlite3ChangeCookie(pParse, iDb); destroyRootPage(pParse, pIndex->tnum, iDb); sqlite3VdbeAddOp4(v, OP_DropIndex, iDb, 0, 0, pIndex->zName, 0); } exit_drop_index: | | | 58821 58822 58823 58824 58825 58826 58827 58828 58829 58830 58831 58832 58833 58834 58835 | } sqlite3ChangeCookie(pParse, iDb); destroyRootPage(pParse, pIndex->tnum, iDb); sqlite3VdbeAddOp4(v, OP_DropIndex, iDb, 0, 0, pIndex->zName, 0); } exit_drop_index: sqlite3SrcListDelete(db, pName); } /* ** pArray is a pointer to an array of objects. Each object in the ** array is szEntry bytes in size. This routine allocates a new ** object on the end of the array. ** |
︙ | ︙ | |||
57717 57718 57719 57720 57721 57722 57723 | sizeof(pList->a[0]), 5, &pList->nId, &pList->nAlloc, &i ); if( i<0 ){ | | | | | | | 58891 58892 58893 58894 58895 58896 58897 58898 58899 58900 58901 58902 58903 58904 58905 58906 58907 58908 58909 58910 58911 58912 58913 58914 58915 58916 58917 58918 58919 58920 58921 58922 | sizeof(pList->a[0]), 5, &pList->nId, &pList->nAlloc, &i ); if( i<0 ){ sqlite3IdListDelete(db, pList); return 0; } pList->a[i].zName = sqlite3NameFromToken(db, pToken); return pList; } /* ** Delete an IdList. */ SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3 *db, IdList *pList){ int i; if( pList==0 ) return; for(i=0; i<pList->nId; i++){ sqlite3DbFree(db, pList->a[i].zName); } sqlite3DbFree(db, pList->a); sqlite3DbFree(db, pList); } /* ** Return the index in pList of the identifier named zId. Return -1 ** if not found. */ SQLITE_PRIVATE int sqlite3IdListIndex(IdList *pList, const char *zName){ |
︙ | ︙ | |||
57793 57794 57795 57796 57797 57798 57799 | } if( pList->nSrc>=pList->nAlloc ){ SrcList *pNew; pList->nAlloc *= 2; pNew = sqlite3DbRealloc(db, pList, sizeof(*pList) + (pList->nAlloc-1)*sizeof(pList->a[0]) ); if( pNew==0 ){ | | | 58967 58968 58969 58970 58971 58972 58973 58974 58975 58976 58977 58978 58979 58980 58981 | } if( pList->nSrc>=pList->nAlloc ){ SrcList *pNew; pList->nAlloc *= 2; pNew = sqlite3DbRealloc(db, pList, sizeof(*pList) + (pList->nAlloc-1)*sizeof(pList->a[0]) ); if( pNew==0 ){ sqlite3SrcListDelete(db, pList); return 0; } pList = pNew; } pItem = &pList->a[pList->nSrc]; memset(pItem, 0, sizeof(pList->a[0])); if( pDatabase && pDatabase->z==0 ){ |
︙ | ︙ | |||
57837 57838 57839 57840 57841 57842 57843 | } } } /* ** Delete an entire SrcList including all its substructure. */ | | | | | | | | | | 59011 59012 59013 59014 59015 59016 59017 59018 59019 59020 59021 59022 59023 59024 59025 59026 59027 59028 59029 59030 59031 59032 59033 59034 59035 59036 59037 59038 | } } } /* ** Delete an entire SrcList including all its substructure. */ SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){ int i; struct SrcList_item *pItem; if( pList==0 ) return; for(pItem=pList->a, i=0; i<pList->nSrc; i++, pItem++){ sqlite3DbFree(db, pItem->zDatabase); sqlite3DbFree(db, pItem->zName); sqlite3DbFree(db, pItem->zAlias); sqlite3DeleteTable(pItem->pTab); sqlite3SelectDelete(db, pItem->pSelect); sqlite3ExprDelete(db, pItem->pOn); sqlite3IdListDelete(db, pItem->pUsing); } sqlite3DbFree(db, pList); } /* ** This routine is called by the parser to add a new term to the ** end of a growing FROM clause. The "p" parameter is the part of ** the FROM clause that has already been constructed. "p" is NULL ** if this is the first term of the FROM clause. pTable and pDatabase |
︙ | ︙ | |||
57883 57884 57885 57886 57887 57888 57889 | Expr *pOn, /* The ON clause of a join */ IdList *pUsing /* The USING clause of a join */ ){ struct SrcList_item *pItem; sqlite3 *db = pParse->db; p = sqlite3SrcListAppend(db, p, pTable, pDatabase); if( p==0 || p->nSrc==0 ){ | | | | | 59057 59058 59059 59060 59061 59062 59063 59064 59065 59066 59067 59068 59069 59070 59071 59072 59073 | Expr *pOn, /* The ON clause of a join */ IdList *pUsing /* The USING clause of a join */ ){ struct SrcList_item *pItem; sqlite3 *db = pParse->db; p = sqlite3SrcListAppend(db, p, pTable, pDatabase); if( p==0 || p->nSrc==0 ){ sqlite3ExprDelete(db, pOn); sqlite3IdListDelete(db, pUsing); sqlite3SelectDelete(db, pSubquery); return p; } pItem = &p->a[p->nSrc-1]; if( pAlias && pAlias->n ){ pItem->zAlias = sqlite3NameFromToken(db, pAlias); } pItem->pSelect = pSubquery; |
︙ | ︙ | |||
58190 58191 58192 58193 58194 58195 58196 | assert( pName1->z ); zColl = sqlite3NameFromToken(pParse->db, pName1); if( !zColl ) return; pColl = sqlite3FindCollSeq(db, ENC(db), zColl, -1, 0); if( pColl ){ if( zColl ){ reindexDatabases(pParse, zColl); | | | | | | > | | | 59364 59365 59366 59367 59368 59369 59370 59371 59372 59373 59374 59375 59376 59377 59378 59379 59380 59381 59382 59383 59384 59385 59386 59387 59388 59389 59390 59391 59392 59393 59394 59395 59396 59397 59398 59399 59400 59401 59402 59403 59404 59405 59406 59407 59408 59409 59410 59411 59412 59413 59414 59415 59416 59417 59418 59419 59420 59421 59422 59423 59424 59425 59426 59427 59428 59429 59430 59431 59432 59433 59434 59435 59436 59437 | assert( pName1->z ); zColl = sqlite3NameFromToken(pParse->db, pName1); if( !zColl ) return; pColl = sqlite3FindCollSeq(db, ENC(db), zColl, -1, 0); if( pColl ){ if( zColl ){ reindexDatabases(pParse, zColl); sqlite3DbFree(db, zColl); } return; } sqlite3DbFree(db, zColl); } iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pObjName); if( iDb<0 ) return; z = sqlite3NameFromToken(db, pObjName); if( z==0 ) return; zDb = db->aDb[iDb].zName; pTab = sqlite3FindTable(db, z, zDb); if( pTab ){ reindexTable(pParse, pTab, 0); sqlite3DbFree(db, z); return; } pIndex = sqlite3FindIndex(db, z, zDb); sqlite3DbFree(db, z); if( pIndex ){ sqlite3BeginWriteOperation(pParse, 0, iDb); sqlite3RefillIndex(pParse, pIndex, -1); return; } sqlite3ErrorMsg(pParse, "unable to identify the object to be reindexed"); } #endif /* ** Return a dynamicly allocated KeyInfo structure that can be used ** with OP_OpenRead or OP_OpenWrite to access database index pIdx. ** ** If successful, a pointer to the new structure is returned. In this case ** the caller is responsible for calling sqlite3DbFree(db, ) on the returned ** pointer. If an error occurs (out of memory or missing collation ** sequence), NULL is returned and the state of pParse updated to reflect ** the error. */ SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){ int i; int nCol = pIdx->nColumn; int nBytes = sizeof(KeyInfo) + (nCol-1)*sizeof(CollSeq*) + nCol; sqlite3 *db = pParse->db; KeyInfo *pKey = (KeyInfo *)sqlite3DbMallocZero(db, nBytes); if( pKey ){ pKey->db = pParse->db; pKey->aSortOrder = (u8 *)&(pKey->aColl[nCol]); assert( &pKey->aSortOrder[nCol]==&(((u8 *)pKey)[nBytes]) ); for(i=0; i<nCol; i++){ char *zColl = pIdx->azColl[i]; assert( zColl ); pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl, -1); pKey->aSortOrder[i] = pIdx->aSortOrder[i]; } pKey->nField = nCol; } if( pParse->nErr ){ sqlite3DbFree(db, pKey); pKey = 0; } return pKey; } /************** End of build.c ***********************************************/ /************** Begin file callback.c ****************************************/ |
︙ | ︙ | |||
58271 58272 58273 58274 58275 58276 58277 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains functions used to access the internal hash tables ** of user defined functions and collation sequences. ** | | | | 59446 59447 59448 59449 59450 59451 59452 59453 59454 59455 59456 59457 59458 59459 59460 59461 59462 59463 59464 59465 59466 59467 59468 59469 59470 59471 59472 59473 59474 59475 59476 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains functions used to access the internal hash tables ** of user defined functions and collation sequences. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** Invoke the 'collation needed' callback to request a collation sequence ** in the database text encoding of name zName, length nName. ** If the collation sequence */ static void callCollNeeded(sqlite3 *db, const char *zName, int nName){ assert( !db->xCollNeeded || !db->xCollNeeded16 ); if( nName<0 ) nName = sqlite3Strlen(db, zName); if( db->xCollNeeded ){ char *zExternal = sqlite3DbStrNDup(db, zName, nName); if( !zExternal ) return; db->xCollNeeded(db->pCollNeededArg, db, (int)ENC(db), zExternal); sqlite3DbFree(db, zExternal); } #ifndef SQLITE_OMIT_UTF16 if( db->xCollNeeded16 ){ char const *zExternal; sqlite3_value *pTmp = sqlite3ValueNew(db); sqlite3ValueSetStr(pTmp, nName, zName, SQLITE_UTF8, SQLITE_STATIC); zExternal = sqlite3ValueText(pTmp, SQLITE_UTF16NATIVE); |
︙ | ︙ | |||
58439 58440 58441 58442 58443 58444 58445 | /* If a malloc() failure occured in sqlite3HashInsert(), it will ** return the pColl pointer to be deleted (because it wasn't added ** to the hash table). */ assert( pDel==0 || pDel==pColl ); if( pDel!=0 ){ db->mallocFailed = 1; | | | 59614 59615 59616 59617 59618 59619 59620 59621 59622 59623 59624 59625 59626 59627 59628 | /* If a malloc() failure occured in sqlite3HashInsert(), it will ** return the pColl pointer to be deleted (because it wasn't added ** to the hash table). */ assert( pDel==0 || pDel==pColl ); if( pDel!=0 ){ db->mallocFailed = 1; sqlite3DbFree(db, pDel); pColl = 0; } } } return pColl; } |
︙ | ︙ | |||
58569 58570 58571 58572 58573 58574 58575 | pBest->nArg = nArg; pBest->pNext = pFirst; pBest->iPrefEnc = enc; memcpy(pBest->zName, zName, nName); pBest->zName[nName] = 0; if( pBest==sqlite3HashInsert(&db->aFunc,pBest->zName,nName,(void*)pBest) ){ db->mallocFailed = 1; | | | | | 59744 59745 59746 59747 59748 59749 59750 59751 59752 59753 59754 59755 59756 59757 59758 59759 59760 59761 59762 59763 59764 59765 59766 59767 59768 59769 59770 59771 59772 59773 59774 59775 59776 59777 59778 59779 59780 59781 59782 59783 59784 59785 59786 59787 59788 59789 | pBest->nArg = nArg; pBest->pNext = pFirst; pBest->iPrefEnc = enc; memcpy(pBest->zName, zName, nName); pBest->zName[nName] = 0; if( pBest==sqlite3HashInsert(&db->aFunc,pBest->zName,nName,(void*)pBest) ){ db->mallocFailed = 1; sqlite3DbFree(db, pBest); return 0; } } if( pBest && (pBest->xStep || pBest->xFunc || createFlag) ){ return pBest; } return 0; } /* ** Free all resources held by the schema structure. The void* argument points ** at a Schema struct. This function does not call sqlite3DbFree(db, ) on the ** pointer itself, it just cleans up subsiduary resources (i.e. the contents ** of the schema hash tables). ** ** The Schema.cache_size variable is not cleared. */ SQLITE_PRIVATE void sqlite3SchemaFree(void *p){ Hash temp1; Hash temp2; HashElem *pElem; Schema *pSchema = (Schema *)p; temp1 = pSchema->tblHash; temp2 = pSchema->trigHash; sqlite3HashInit(&pSchema->trigHash, SQLITE_HASH_STRING, 0); sqlite3HashClear(&pSchema->aFKey); sqlite3HashClear(&pSchema->idxHash); for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){ sqlite3DeleteTrigger(0, (Trigger*)sqliteHashData(pElem)); } sqlite3HashClear(&temp2); sqlite3HashInit(&pSchema->tblHash, SQLITE_HASH_STRING, 0); for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){ Table *pTab = sqliteHashData(pElem); sqlite3DeleteTable(pTab); } |
︙ | ︙ | |||
58652 58653 58654 58655 58656 58657 58658 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** in order to generate code for DELETE FROM statements. ** | | | 59827 59828 59829 59830 59831 59832 59833 59834 59835 59836 59837 59838 59839 59840 59841 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** in order to generate code for DELETE FROM statements. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** Look up every table that is named in pSrc. If any table is not found, ** add an error message to pParse->zErrMsg and return NULL. If all tables ** are found, return a pointer to the last table. */ |
︙ | ︙ | |||
58746 58747 58748 58749 58750 58751 58752 | pWhere = sqlite3ExprDup(db, pWhere); pFrom = sqlite3SrcListAppendFromTerm(pParse, 0, 0, 0, 0, pDup, 0, 0); pDup = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0); } sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur); sqlite3Select(pParse, pDup, &dest, 0, 0, 0); | | | 59921 59922 59923 59924 59925 59926 59927 59928 59929 59930 59931 59932 59933 59934 59935 | pWhere = sqlite3ExprDup(db, pWhere); pFrom = sqlite3SrcListAppendFromTerm(pParse, 0, 0, 0, 0, pDup, 0, 0); pDup = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0); } sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur); sqlite3Select(pParse, pDup, &dest, 0, 0, 0); sqlite3SelectDelete(db, pDup); } #endif /* !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) */ /* ** Generate code for a DELETE FROM statement. ** |
︙ | ︙ | |||
59054 59055 59056 59057 59058 59059 59060 | sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1); sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", P4_STATIC); } delete_from_cleanup: sqlite3AuthContextPop(&sContext); | | | | 60229 60230 60231 60232 60233 60234 60235 60236 60237 60238 60239 60240 60241 60242 60243 60244 | sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1); sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", P4_STATIC); } delete_from_cleanup: sqlite3AuthContextPop(&sContext); sqlite3SrcListDelete(db, pTabList); sqlite3ExprDelete(db, pWhere); return; } /* ** This routine generates VDBE code that causes a single row of a ** single table to be deleted. ** |
︙ | ︙ | |||
59202 59203 59204 59205 59206 59207 59208 | ** This file contains the C functions that implement various SQL ** functions of SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** | | | 60377 60378 60379 60380 60381 60382 60383 60384 60385 60386 60387 60388 60389 60390 60391 | ** This file contains the C functions that implement various SQL ** functions of SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** Return the collating function associated with a function. */ static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){ |
︙ | ︙ | |||
60013 60014 60015 60016 60017 60018 60019 | zOut[j++] = zStr[i]; }else{ u8 *zOld; sqlite3 *db = sqlite3_context_db_handle(context); nOut += nRep - nPattern; if( nOut>=db->aLimit[SQLITE_LIMIT_LENGTH] ){ sqlite3_result_error_toobig(context); | | | | 61188 61189 61190 61191 61192 61193 61194 61195 61196 61197 61198 61199 61200 61201 61202 61203 61204 61205 61206 61207 61208 61209 | zOut[j++] = zStr[i]; }else{ u8 *zOld; sqlite3 *db = sqlite3_context_db_handle(context); nOut += nRep - nPattern; if( nOut>=db->aLimit[SQLITE_LIMIT_LENGTH] ){ sqlite3_result_error_toobig(context); sqlite3DbFree(db, zOut); return; } zOld = zOut; zOut = sqlite3_realloc(zOut, (int)nOut); if( zOut==0 ){ sqlite3_result_error_nomem(context); sqlite3DbFree(db, zOld); return; } memcpy(&zOut[j], zRep, nRep); j += nRep; i += nPattern-1; } } |
︙ | ︙ | |||
60595 60596 60597 60598 60599 60600 60601 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** | | | 61770 61771 61772 61773 61774 61775 61776 61777 61778 61779 61780 61781 61782 61783 61784 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** Set P4 of the most recently inserted opcode to a column affinity ** string for index pIdx. A column affinity string has one character ** for each column in the table, according to the affinity of the column: ** |
︙ | ︙ | |||
60627 60628 60629 60630 60631 60632 60633 | ** The column affinity string will eventually be deleted by ** sqliteDeleteIndex() when the Index structure itself is cleaned ** up. */ int n; Table *pTab = pIdx->pTable; sqlite3 *db = sqlite3VdbeDb(v); | | > | 61802 61803 61804 61805 61806 61807 61808 61809 61810 61811 61812 61813 61814 61815 61816 61817 61818 | ** The column affinity string will eventually be deleted by ** sqliteDeleteIndex() when the Index structure itself is cleaned ** up. */ int n; Table *pTab = pIdx->pTable; sqlite3 *db = sqlite3VdbeDb(v); pIdx->zColAff = (char *)sqlite3Malloc(pIdx->nColumn+2); if( !pIdx->zColAff ){ db->mallocFailed = 1; return; } for(n=0; n<pIdx->nColumn; n++){ pIdx->zColAff[n] = pTab->aCol[pIdx->aiColumn[n]].affinity; } pIdx->zColAff[n++] = SQLITE_AFF_NONE; pIdx->zColAff[n] = 0; |
︙ | ︙ | |||
60668 60669 60670 60671 60672 60673 60674 | ** sqlite3DeleteTable() when the Table structure itself is cleaned up. */ if( !pTab->zColAff ){ char *zColAff; int i; sqlite3 *db = sqlite3VdbeDb(v); | | > | 61844 61845 61846 61847 61848 61849 61850 61851 61852 61853 61854 61855 61856 61857 61858 61859 61860 | ** sqlite3DeleteTable() when the Table structure itself is cleaned up. */ if( !pTab->zColAff ){ char *zColAff; int i; sqlite3 *db = sqlite3VdbeDb(v); zColAff = (char *)sqlite3Malloc(pTab->nCol+1); if( !zColAff ){ db->mallocFailed = 1; return; } for(i=0; i<pTab->nCol; i++){ zColAff[i] = pTab->aCol[i].affinity; } zColAff[pTab->nCol] = '\0'; |
︙ | ︙ | |||
61576 61577 61578 61579 61580 61581 61582 | if( db->flags & SQLITE_CountRows && pParse->nested==0 && !pParse->trigStack ){ sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows inserted", P4_STATIC); } insert_cleanup: | | | | | | | 62753 62754 62755 62756 62757 62758 62759 62760 62761 62762 62763 62764 62765 62766 62767 62768 62769 62770 62771 | if( db->flags & SQLITE_CountRows && pParse->nested==0 && !pParse->trigStack ){ sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows inserted", P4_STATIC); } insert_cleanup: sqlite3SrcListDelete(db, pTabList); sqlite3ExprListDelete(db, pList); sqlite3SelectDelete(db, pSelect); sqlite3IdListDelete(db, pColumn); sqlite3DbFree(db, aRegIdx); } /* ** Generate code to do constraint checks prior to an INSERT or an UPDATE. ** ** The input is a range of consecutive registers as follows: ** |
︙ | ︙ | |||
62335 62336 62337 62338 62339 62340 62341 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** | | | 63512 63513 63514 63515 63516 63517 63518 63519 63520 63521 63522 63523 63524 63525 63526 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** Execute SQL code. Return one of the SQLITE_ success/failure ** codes. Also write an error message into memory obtained from ** malloc() and make *pzErrMsg point to that message. |
︙ | ︙ | |||
62403 62404 62405 62406 62407 62408 62409 | azCols = sqlite3DbMallocZero(db, 2*nCol*sizeof(const char*) + 1); if( azCols==0 ){ goto exec_out; } } for(i=0; i<nCol; i++){ azCols[i] = (char *)sqlite3_column_name(pStmt, i); | > > | < < < | 63580 63581 63582 63583 63584 63585 63586 63587 63588 63589 63590 63591 63592 63593 63594 63595 63596 | azCols = sqlite3DbMallocZero(db, 2*nCol*sizeof(const char*) + 1); if( azCols==0 ){ goto exec_out; } } for(i=0; i<nCol; i++){ azCols[i] = (char *)sqlite3_column_name(pStmt, i); /* sqlite3VdbeSetColName() installs column names as UTF8 ** strings so there is no way for sqlite3_column_name() to fail. */ assert( azCols[i]!=0 ); } nCallback++; } if( rc==SQLITE_ROW ){ azVals = &azCols[nCol]; for(i=0; i<nCol; i++){ azVals[i] = (char *)sqlite3_column_text(pStmt, i); |
︙ | ︙ | |||
62441 62442 62443 62444 62445 62446 62447 | zSql = zLeftover; while( isspace((unsigned char)zSql[0]) ) zSql++; } break; } } | | | | 63617 63618 63619 63620 63621 63622 63623 63624 63625 63626 63627 63628 63629 63630 63631 63632 63633 63634 63635 63636 63637 | zSql = zLeftover; while( isspace((unsigned char)zSql[0]) ) zSql++; } break; } } sqlite3DbFree(db, azCols); azCols = 0; } exec_out: if( pStmt ) sqlite3_finalize(pStmt); sqlite3DbFree(db, azCols); rc = sqlite3ApiExit(db, rc); if( rc!=SQLITE_OK && rc==sqlite3_errcode(db) && pzErrMsg ){ int nErrMsg = 1 + strlen(sqlite3_errmsg(db)); *pzErrMsg = sqlite3Malloc(nErrMsg); if( *pzErrMsg ){ memcpy(*pzErrMsg, sqlite3_errmsg(db), nErrMsg); |
︙ | ︙ | |||
62481 62482 62483 62484 62485 62486 62487 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code used to dynamically load extensions into ** the SQLite library. ** | | | 63657 63658 63659 63660 63661 63662 63663 63664 63665 63666 63667 63668 63669 63670 63671 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code used to dynamically load extensions into ** the SQLite library. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef SQLITE_CORE #define SQLITE_CORE 1 /* Disable the API redefinition in sqlite3ext.h */ #endif /************** Include sqlite3ext.h in the middle of loadext.c **************/ /************** Begin file sqlite3ext.h **************************************/ |
︙ | ︙ | |||
62506 62507 62508 62509 62510 62511 62512 | ************************************************************************* ** This header file defines the SQLite interface for use by ** shared libraries that want to be imported as extensions into ** an SQLite instance. Shared libraries that intend to be loaded ** as extensions by SQLite should #include this file instead of ** sqlite3.h. ** | | | 63682 63683 63684 63685 63686 63687 63688 63689 63690 63691 63692 63693 63694 63695 63696 | ************************************************************************* ** This header file defines the SQLite interface for use by ** shared libraries that want to be imported as extensions into ** an SQLite instance. Shared libraries that intend to be loaded ** as extensions by SQLite should #include this file instead of ** sqlite3.h. ** ** @(#) $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef _SQLITE3EXT_H_ #define _SQLITE3EXT_H_ typedef struct sqlite3_api_routines sqlite3_api_routines; /* |
︙ | ︙ | |||
63167 63168 63169 63170 63171 63172 63173 | ** default entry point name (sqlite3_extension_init) is used. Use ** of the default name is recommended. ** ** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong. ** ** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with ** error message text. The calling function should free this memory | | | 64343 64344 64345 64346 64347 64348 64349 64350 64351 64352 64353 64354 64355 64356 64357 | ** default entry point name (sqlite3_extension_init) is used. Use ** of the default name is recommended. ** ** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong. ** ** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with ** error message text. The calling function should free this memory ** by calling sqlite3DbFree(db, ). */ static int sqlite3LoadExtension( sqlite3 *db, /* Load the extension into this database connection */ const char *zFile, /* Name of the shared library containing extension */ const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */ char **pzErrMsg /* Put error message here if not 0 */ ){ |
︙ | ︙ | |||
63206 63207 63208 63209 63210 63211 63212 | if( handle==0 ){ if( pzErrMsg ){ char zErr[256]; zErr[sizeof(zErr)-1] = '\0'; sqlite3_snprintf(sizeof(zErr)-1, zErr, "unable to open shared library [%s]", zFile); sqlite3OsDlError(pVfs, sizeof(zErr)-1, zErr); | | | < | | | | | 64382 64383 64384 64385 64386 64387 64388 64389 64390 64391 64392 64393 64394 64395 64396 64397 64398 64399 64400 64401 64402 64403 64404 64405 64406 64407 64408 64409 64410 64411 64412 64413 64414 64415 64416 64417 64418 64419 64420 64421 64422 64423 64424 64425 64426 64427 64428 64429 64430 64431 64432 64433 | if( handle==0 ){ if( pzErrMsg ){ char zErr[256]; zErr[sizeof(zErr)-1] = '\0'; sqlite3_snprintf(sizeof(zErr)-1, zErr, "unable to open shared library [%s]", zFile); sqlite3OsDlError(pVfs, sizeof(zErr)-1, zErr); *pzErrMsg = sqlite3DbStrDup(0, zErr); } return SQLITE_ERROR; } xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*)) sqlite3OsDlSym(pVfs, handle, zProc); if( xInit==0 ){ if( pzErrMsg ){ char zErr[256]; zErr[sizeof(zErr)-1] = '\0'; sqlite3_snprintf(sizeof(zErr)-1, zErr, "no entry point [%s] in shared library [%s]", zProc,zFile); sqlite3OsDlError(pVfs, sizeof(zErr)-1, zErr); *pzErrMsg = sqlite3DbStrDup(0, zErr); sqlite3OsDlClose(pVfs, handle); } return SQLITE_ERROR; }else if( xInit(db, &zErrmsg, &sqlite3Apis) ){ if( pzErrMsg ){ *pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg); } sqlite3_free(zErrmsg); sqlite3OsDlClose(pVfs, handle); return SQLITE_ERROR; } /* Append the new shared library handle to the db->aExtension array. */ aHandle = sqlite3DbMallocZero(db, sizeof(handle)*(db->nExtension+1)); if( aHandle==0 ){ return SQLITE_NOMEM; } if( db->nExtension>0 ){ memcpy(aHandle, db->aExtension, sizeof(handle)*db->nExtension); } sqlite3DbFree(db, db->aExtension); db->aExtension = aHandle; db->aExtension[db->nExtension++] = handle; return SQLITE_OK; } SQLITE_API int sqlite3_load_extension( sqlite3 *db, /* Load the extension into this database connection */ const char *zFile, /* Name of the shared library containing extension */ const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */ char **pzErrMsg /* Put error message here if not 0 */ |
︙ | ︙ | |||
63270 63271 63272 63273 63274 63275 63276 | */ SQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3 *db){ int i; assert( sqlite3_mutex_held(db->mutex) ); for(i=0; i<db->nExtension; i++){ sqlite3OsDlClose(db->pVfs, db->aExtension[i]); } | | | 64445 64446 64447 64448 64449 64450 64451 64452 64453 64454 64455 64456 64457 64458 64459 | */ SQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3 *db){ int i; assert( sqlite3_mutex_held(db->mutex) ); for(i=0; i<db->nExtension; i++){ sqlite3OsDlClose(db->pVfs, db->aExtension[i]); } sqlite3DbFree(db, db->aExtension); } /* ** Enable or disable extension loading. Extension loading is disabled by ** default so as not to open security holes in older applications. */ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){ |
︙ | ︙ | |||
63425 63426 63427 63428 63429 63430 63431 | ** 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 contains code used to implement the PRAGMA command. ** | | | 64600 64601 64602 64603 64604 64605 64606 64607 64608 64609 64610 64611 64612 64613 64614 | ** 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 contains code used to implement the PRAGMA command. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* Ignore this whole file if pragmas are disabled */ #if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER) /* |
︙ | ︙ | |||
64094 64095 64096 64097 64098 64099 64100 | || (SQLITE_TEMP_STORE==1 && db->temp_store<=1) || (SQLITE_TEMP_STORE==2 && db->temp_store==1) ){ invalidateTempStorage(pParse); } sqlite3_free(sqlite3_temp_directory); if( zRight[0] ){ | | < | 65269 65270 65271 65272 65273 65274 65275 65276 65277 65278 65279 65280 65281 65282 65283 | || (SQLITE_TEMP_STORE==1 && db->temp_store<=1) || (SQLITE_TEMP_STORE==2 && db->temp_store==1) ){ invalidateTempStorage(pParse); } sqlite3_free(sqlite3_temp_directory); if( zRight[0] ){ sqlite3_temp_directory = sqlite3DbStrDup(0, zRight); }else{ sqlite3_temp_directory = 0; } } }else /* |
︙ | ︙ | |||
64735 64736 64737 64738 64739 64740 64741 | if( db->autoCommit ){ sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level, (db->flags&SQLITE_FullFSync)!=0); } #endif } pragma_out: | | | | 65909 65910 65911 65912 65913 65914 65915 65916 65917 65918 65919 65920 65921 65922 65923 65924 | if( db->autoCommit ){ sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level, (db->flags&SQLITE_FullFSync)!=0); } #endif } pragma_out: sqlite3DbFree(db, zLeft); sqlite3DbFree(db, zRight); } #endif /* SQLITE_OMIT_PRAGMA || SQLITE_OMIT_PARSER */ /************** End of pragma.c **********************************************/ /************** Begin file prepare.c *****************************************/ /* |
︙ | ︙ | |||
64758 64759 64760 64761 64762 64763 64764 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains the implementation of the sqlite3_prepare() ** interface, and routines that contribute to loading the database schema ** from disk. ** | | | | 65932 65933 65934 65935 65936 65937 65938 65939 65940 65941 65942 65943 65944 65945 65946 65947 65948 65949 65950 65951 65952 65953 65954 65955 65956 65957 65958 65959 65960 65961 65962 65963 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains the implementation of the sqlite3_prepare() ** interface, and routines that contribute to loading the database schema ** from disk. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** Fill the InitData structure with an error message that indicates ** that the database is corrupt. */ static void corruptSchema( InitData *pData, /* Initialization context */ const char *zObj, /* Object being parsed at the point of error */ const char *zExtra /* Error information */ ){ if( !pData->db->mallocFailed ){ if( zObj==0 ) zObj = "?"; sqlite3SetString(pData->pzErrMsg, pData->db, "malformed database schema (%s)", zObj); if( zExtra && zExtra[0] ){ *pData->pzErrMsg = sqlite3MAppendf(pData->db, *pData->pzErrMsg, "%s - %s", *pData->pzErrMsg, zExtra); } } pData->rc = SQLITE_CORRUPT; } /* |
︙ | ︙ | |||
64822 64823 64824 64825 64826 64827 64828 64829 64830 64831 64832 64833 64834 64835 64836 64837 64838 64839 64840 64841 | /* Call the parser to process a CREATE TABLE, INDEX or VIEW. ** But because db->init.busy is set to 1, no VDBE code is generated ** or executed. All the parser does is build the internal data ** structures that describe the table, index, or view. */ char *zErr; int rc; assert( db->init.busy ); db->init.iDb = iDb; db->init.newTnum = atoi(argv[1]); rc = sqlite3_exec(db, argv[2], 0, 0, &zErr); db->init.iDb = 0; assert( rc!=SQLITE_OK || zErr==0 ); if( SQLITE_OK!=rc ){ pData->rc = rc; if( rc==SQLITE_NOMEM ){ db->mallocFailed = 1; }else if( rc!=SQLITE_INTERRUPT ){ corruptSchema(pData, argv[0], zErr); } | > > > > | | 65996 65997 65998 65999 66000 66001 66002 66003 66004 66005 66006 66007 66008 66009 66010 66011 66012 66013 66014 66015 66016 66017 66018 66019 66020 66021 66022 66023 66024 66025 66026 66027 | /* Call the parser to process a CREATE TABLE, INDEX or VIEW. ** But because db->init.busy is set to 1, no VDBE code is generated ** or executed. All the parser does is build the internal data ** structures that describe the table, index, or view. */ char *zErr; int rc; u8 lookasideEnabled; assert( db->init.busy ); db->init.iDb = iDb; db->init.newTnum = atoi(argv[1]); lookasideEnabled = db->lookaside.bEnabled; db->lookaside.bEnabled = 0; rc = sqlite3_exec(db, argv[2], 0, 0, &zErr); db->init.iDb = 0; db->lookaside.bEnabled = lookasideEnabled; assert( rc!=SQLITE_OK || zErr==0 ); if( SQLITE_OK!=rc ){ pData->rc = rc; if( rc==SQLITE_NOMEM ){ db->mallocFailed = 1; }else if( rc!=SQLITE_INTERRUPT ){ corruptSchema(pData, argv[0], zErr); } sqlite3DbFree(db, zErr); return 1; } }else if( argv[0]==0 ){ corruptSchema(pData, 0, 0); }else{ /* If the SQL column is blank it means this is an index that ** was created to be the PRIMARY KEY or to fulfill a UNIQUE |
︙ | ︙ | |||
64963 64964 64965 64966 64967 64968 64969 | rc = SQLITE_NOMEM; goto error_out; } sqlite3BtreeEnter(pDb->pBt); rc = sqlite3BtreeCursor(pDb->pBt, MASTER_ROOT, 0, 0, curMain); if( rc!=SQLITE_OK && rc!=SQLITE_EMPTY ){ sqlite3SetString(pzErrMsg, db, "%s", sqlite3ErrStr(rc)); | | | 66141 66142 66143 66144 66145 66146 66147 66148 66149 66150 66151 66152 66153 66154 66155 | rc = SQLITE_NOMEM; goto error_out; } sqlite3BtreeEnter(pDb->pBt); rc = sqlite3BtreeCursor(pDb->pBt, MASTER_ROOT, 0, 0, curMain); if( rc!=SQLITE_OK && rc!=SQLITE_EMPTY ){ sqlite3SetString(pzErrMsg, db, "%s", sqlite3ErrStr(rc)); goto initone_error_out; } /* Get the database meta information. ** ** Meta values are as follows: ** meta[0] Schema cookie. Changes with each schema change. ** meta[1] File format of schema layer. |
︙ | ︙ | |||
64985 64986 64987 64988 64989 64990 64991 | ** meta[9] ** ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to ** the possible values of meta[4]. */ if( rc==SQLITE_OK ){ int i; | | < | | | > | 66163 66164 66165 66166 66167 66168 66169 66170 66171 66172 66173 66174 66175 66176 66177 66178 66179 66180 66181 66182 | ** meta[9] ** ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to ** the possible values of meta[4]. */ if( rc==SQLITE_OK ){ int i; for(i=0; i<sizeof(meta)/sizeof(meta[0]); i++){ rc = sqlite3BtreeGetMeta(pDb->pBt, i+1, (u32 *)&meta[i]); if( rc ){ sqlite3SetString(pzErrMsg, db, "%s", sqlite3ErrStr(rc)); goto initone_error_out; } } }else{ memset(meta, 0, sizeof(meta)); } pDb->pSchema->schema_cookie = meta[0]; /* If opening a non-empty database, check the text encoding. For the |
︙ | ︙ | |||
65013 65014 65015 65016 65017 65018 65019 | db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 6, 0); }else{ /* If opening an attached database, the encoding much match ENC(db) */ if( meta[4]!=ENC(db) ){ sqlite3SetString(pzErrMsg, db, "attached databases must use the same" " text encoding as main database"); rc = SQLITE_ERROR; | | | 66191 66192 66193 66194 66195 66196 66197 66198 66199 66200 66201 66202 66203 66204 66205 | db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 6, 0); }else{ /* If opening an attached database, the encoding much match ENC(db) */ if( meta[4]!=ENC(db) ){ sqlite3SetString(pzErrMsg, db, "attached databases must use the same" " text encoding as main database"); rc = SQLITE_ERROR; goto initone_error_out; } } }else{ DbSetProperty(db, iDb, DB_Empty); } pDb->pSchema->enc = ENC(db); |
︙ | ︙ | |||
65042 65043 65044 65045 65046 65047 65048 | pDb->pSchema->file_format = meta[1]; if( pDb->pSchema->file_format==0 ){ pDb->pSchema->file_format = 1; } if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){ sqlite3SetString(pzErrMsg, db, "unsupported file format"); rc = SQLITE_ERROR; | | | 66220 66221 66222 66223 66224 66225 66226 66227 66228 66229 66230 66231 66232 66233 66234 | pDb->pSchema->file_format = meta[1]; if( pDb->pSchema->file_format==0 ){ pDb->pSchema->file_format = 1; } if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){ sqlite3SetString(pzErrMsg, db, "unsupported file format"); rc = SQLITE_ERROR; goto initone_error_out; } /* Ticket #2804: When we open a database in the newer file format, ** clear the legacy_file_format pragma flag so that a VACUUM will ** not downgrade the database and thus invalidate any descending ** indices that the user might have created. */ |
︙ | ︙ | |||
65079 65080 65081 65082 65083 65084 65085 | rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0); #ifndef SQLITE_OMIT_AUTHORIZATION db->xAuth = xAuth; } #endif if( rc==SQLITE_ABORT ) rc = initData.rc; (void)sqlite3SafetyOn(db); | | | 66257 66258 66259 66260 66261 66262 66263 66264 66265 66266 66267 66268 66269 66270 66271 | rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0); #ifndef SQLITE_OMIT_AUTHORIZATION db->xAuth = xAuth; } #endif if( rc==SQLITE_ABORT ) rc = initData.rc; (void)sqlite3SafetyOn(db); sqlite3DbFree(db, zSql); #ifndef SQLITE_OMIT_ANALYZE if( rc==SQLITE_OK ){ sqlite3AnalysisLoad(db, iDb); } #endif } if( db->mallocFailed ){ |
︙ | ︙ | |||
65107 65108 65109 65110 65111 65112 65113 | rc = SQLITE_OK; } /* Jump here for an error that occurs after successfully allocating ** curMain and calling sqlite3BtreeEnter(). For an error that occurs ** before that point, jump to error_out. */ | | | 66285 66286 66287 66288 66289 66290 66291 66292 66293 66294 66295 66296 66297 66298 66299 | rc = SQLITE_OK; } /* Jump here for an error that occurs after successfully allocating ** curMain and calling sqlite3BtreeEnter(). For an error that occurs ** before that point, jump to error_out. */ initone_error_out: sqlite3BtreeCloseCursor(curMain); sqlite3_free(curMain); sqlite3BtreeLeave(pDb->pBt); error_out: if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){ db->mallocFailed = 1; |
︙ | ︙ | |||
65311 65312 65313 65314 65315 65316 65317 | sqlite3Error(db, SQLITE_TOOBIG, "statement too long"); (void)sqlite3SafetyOff(db); return sqlite3ApiExit(db, SQLITE_TOOBIG); } zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes); if( zSqlCopy ){ sqlite3RunParser(&sParse, zSqlCopy, &zErrMsg); | | | 66489 66490 66491 66492 66493 66494 66495 66496 66497 66498 66499 66500 66501 66502 66503 | sqlite3Error(db, SQLITE_TOOBIG, "statement too long"); (void)sqlite3SafetyOff(db); return sqlite3ApiExit(db, SQLITE_TOOBIG); } zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes); if( zSqlCopy ){ sqlite3RunParser(&sParse, zSqlCopy, &zErrMsg); sqlite3DbFree(db, zSqlCopy); sParse.zTail = &zSql[sParse.zTail-zSqlCopy]; }else{ sParse.zTail = &zSql[nBytes]; } }else{ sqlite3RunParser(&sParse, zSql, &zErrMsg); } |
︙ | ︙ | |||
65375 65376 65377 65378 65379 65380 65381 | assert(!(*ppStmt)); }else{ *ppStmt = (sqlite3_stmt*)sParse.pVdbe; } if( zErrMsg ){ sqlite3Error(db, rc, "%s", zErrMsg); | | | 66553 66554 66555 66556 66557 66558 66559 66560 66561 66562 66563 66564 66565 66566 66567 | assert(!(*ppStmt)); }else{ *ppStmt = (sqlite3_stmt*)sParse.pVdbe; } if( zErrMsg ){ sqlite3Error(db, rc, "%s", zErrMsg); sqlite3DbFree(db, zErrMsg); }else{ sqlite3Error(db, rc, 0); } rc = sqlite3ApiExit(db, rc); assert( (rc&db->errMask)==rc ); return rc; |
︙ | ︙ | |||
65510 65511 65512 65513 65514 65515 65516 | ** equivalent pointer into the UTF-16 string by counting the unicode ** characters between zSql8 and zTail8, and then returning a pointer ** the same number of characters into the UTF-16 string. */ int chars_parsed = sqlite3Utf8CharLen(zSql8, zTail8-zSql8); *pzTail = (u8 *)zSql + sqlite3Utf16ByteLen(zSql, chars_parsed); } | | | 66688 66689 66690 66691 66692 66693 66694 66695 66696 66697 66698 66699 66700 66701 66702 | ** equivalent pointer into the UTF-16 string by counting the unicode ** characters between zSql8 and zTail8, and then returning a pointer ** the same number of characters into the UTF-16 string. */ int chars_parsed = sqlite3Utf8CharLen(zSql8, zTail8-zSql8); *pzTail = (u8 *)zSql + sqlite3Utf16ByteLen(zSql, chars_parsed); } sqlite3DbFree(db, zSql8); rc = sqlite3ApiExit(db, rc); sqlite3_mutex_leave(db->mutex); return rc; } /* ** Two versions of the official API. Legacy and new use. In the legacy |
︙ | ︙ | |||
65567 65568 65569 65570 65571 65572 65573 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** | | | | | | | | | | | | | 66745 66746 66747 66748 66749 66750 66751 66752 66753 66754 66755 66756 66757 66758 66759 66760 66761 66762 66763 66764 66765 66766 66767 66768 66769 66770 66771 66772 66773 66774 66775 66776 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** Delete all the content of a Select structure but do not deallocate ** the select structure itself. */ static void clearSelect(sqlite3 *db, Select *p){ sqlite3ExprListDelete(db, p->pEList); sqlite3SrcListDelete(db, p->pSrc); sqlite3ExprDelete(db, p->pWhere); sqlite3ExprListDelete(db, p->pGroupBy); sqlite3ExprDelete(db, p->pHaving); sqlite3ExprListDelete(db, p->pOrderBy); sqlite3SelectDelete(db, p->pPrior); sqlite3ExprDelete(db, p->pLimit); sqlite3ExprDelete(db, p->pOffset); } /* ** Initialize a SelectDest structure. */ SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){ pDest->eDest = eDest; |
︙ | ︙ | |||
65642 65643 65644 65645 65646 65647 65648 | assert( pOffset==0 || pLimit!=0 ); pNew->pLimit = pLimit; pNew->pOffset = pOffset; pNew->addrOpenEphm[0] = -1; pNew->addrOpenEphm[1] = -1; pNew->addrOpenEphm[2] = -1; if( pNew==&standin) { | | | | | | 66820 66821 66822 66823 66824 66825 66826 66827 66828 66829 66830 66831 66832 66833 66834 66835 66836 66837 66838 66839 66840 66841 66842 66843 66844 66845 66846 | assert( pOffset==0 || pLimit!=0 ); pNew->pLimit = pLimit; pNew->pOffset = pOffset; pNew->addrOpenEphm[0] = -1; pNew->addrOpenEphm[1] = -1; pNew->addrOpenEphm[2] = -1; if( pNew==&standin) { clearSelect(db, pNew); pNew = 0; } return pNew; } /* ** Delete the given Select structure and all of its substructures. */ SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){ if( p ){ clearSelect(db, p); sqlite3DbFree(db, p); } } /* ** Given 1 to 3 identifiers preceeding the JOIN keyword, determine the ** type of join. Return an integer constant that expresses that type ** in terms of the following bit values: |
︙ | ︙ | |||
66717 66718 66719 66720 66721 66722 66723 66724 66725 66726 66727 66728 66729 66730 66731 66732 66733 66734 66735 66736 | if( rc ){ return 0; } pTab = sqlite3DbMallocZero(db, sizeof(Table) ); if( pTab==0 ){ return 0; } pTab->nRef = 1; pTab->zName = zTabName ? sqlite3DbStrDup(db, zTabName) : 0; pEList = pSelect->pEList; pTab->nCol = pEList->nExpr; assert( pTab->nCol>0 ); pTab->aCol = aCol = sqlite3DbMallocZero(db, sizeof(pTab->aCol[0])*pTab->nCol); for(i=0, pCol=aCol; i<pTab->nCol; i++, pCol++){ Expr *p; char *zType; char *zName; int nName; CollSeq *pColl; int cnt; | > > | 67895 67896 67897 67898 67899 67900 67901 67902 67903 67904 67905 67906 67907 67908 67909 67910 67911 67912 67913 67914 67915 67916 | if( rc ){ return 0; } pTab = sqlite3DbMallocZero(db, sizeof(Table) ); if( pTab==0 ){ return 0; } pTab->db = db; pTab->nRef = 1; pTab->zName = zTabName ? sqlite3DbStrDup(db, zTabName) : 0; pEList = pSelect->pEList; pTab->nCol = pEList->nExpr; assert( pTab->nCol>0 ); pTab->aCol = aCol = sqlite3DbMallocZero(db, sizeof(pTab->aCol[0])*pTab->nCol); testcase( aCol==0 ); for(i=0, pCol=aCol; i<pTab->nCol; i++, pCol++){ Expr *p; char *zType; char *zName; int nName; CollSeq *pColl; int cnt; |
︙ | ︙ | |||
66748 66749 66750 66751 66752 66753 66754 | int iCol = p->iColumn; if( iCol<0 ) iCol = p->pTab->iPKey; zName = sqlite3MPrintf(db, "%s", p->pTab->aCol[iCol].zName); }else{ /* Use the original text of the column expression as its name */ zName = sqlite3MPrintf(db, "%T", &p->span); } | < | | < | > | > > > > > > | 67928 67929 67930 67931 67932 67933 67934 67935 67936 67937 67938 67939 67940 67941 67942 67943 67944 67945 67946 67947 67948 67949 67950 67951 67952 67953 67954 67955 67956 67957 67958 67959 67960 67961 67962 67963 67964 67965 67966 67967 67968 67969 67970 67971 67972 67973 67974 67975 67976 67977 67978 67979 67980 67981 67982 | int iCol = p->iColumn; if( iCol<0 ) iCol = p->pTab->iPKey; zName = sqlite3MPrintf(db, "%s", p->pTab->aCol[iCol].zName); }else{ /* Use the original text of the column expression as its name */ zName = sqlite3MPrintf(db, "%T", &p->span); } if( db->mallocFailed ){ sqlite3DbFree(db, zName); break; } sqlite3Dequote(zName); /* Make sure the column name is unique. If the name is not unique, ** append a integer to the name so that it becomes unique. */ nName = strlen(zName); for(j=cnt=0; j<i; j++){ if( sqlite3StrICmp(aCol[j].zName, zName)==0 ){ char *zNewName; zName[nName] = 0; zNewName = sqlite3MPrintf(db, "%s:%d", zName, ++cnt); sqlite3DbFree(db, zName); zName = zNewName; j = -1; if( zName==0 ) break; } } pCol->zName = zName; /* Get the typename, type affinity, and collating sequence for the ** column. */ memset(&sNC, 0, sizeof(sNC)); sNC.pSrcList = pSelect->pSrc; zType = sqlite3DbStrDup(db, columnType(&sNC, p, 0, 0, 0)); pCol->zType = zType; pCol->affinity = sqlite3ExprAffinity(p); pColl = sqlite3ExprCollSeq(pParse, p); if( pColl ){ pCol->zColl = sqlite3DbStrDup(db, pColl->zName); } } pTab->iPKey = -1; if( db->mallocFailed ){ sqlite3DeleteTable(pTab); return 0; } return pTab; } /* ** Prepare a SELECT statement for processing by doing the following ** things: ** |
︙ | ︙ | |||
67025 67026 67027 67028 67029 67030 67031 | if( zTName ){ sqlite3ErrorMsg(pParse, "no such table: %s", zTName); }else{ sqlite3ErrorMsg(pParse, "no tables specified"); } rc = 1; } | | | | 68210 68211 68212 68213 68214 68215 68216 68217 68218 68219 68220 68221 68222 68223 68224 68225 68226 68227 | if( zTName ){ sqlite3ErrorMsg(pParse, "no such table: %s", zTName); }else{ sqlite3ErrorMsg(pParse, "no tables specified"); } rc = 1; } sqlite3DbFree(db, zTName); } } sqlite3ExprListDelete(db, pEList); p->pEList = pNew; } #if SQLITE_MAX_COLUMN if( p->pEList && p->pEList->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){ sqlite3ErrorMsg(pParse, "too many columns in result set"); rc = SQLITE_ERROR; } |
︙ | ︙ | |||
67089 67090 67091 67092 67093 67094 67095 | char *zCol = sqlite3NameFromToken(db, &pE->token); if( zCol==0 ){ return -1; } for(i=0; i<pEList->nExpr; i++){ char *zAs = pEList->a[i].zName; if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){ | | | | 68274 68275 68276 68277 68278 68279 68280 68281 68282 68283 68284 68285 68286 68287 68288 68289 68290 68291 68292 | char *zCol = sqlite3NameFromToken(db, &pE->token); if( zCol==0 ){ return -1; } for(i=0; i<pEList->nExpr; i++){ char *zAs = pEList->a[i].zName; if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){ sqlite3DbFree(db, zCol); return i+1; } } sqlite3DbFree(db, zCol); } /* Resolve all names in the ORDER BY term expression */ memset(&nc, 0, sizeof(nc)); nc.pParse = pParse; nc.pSrcList = pSelect->pSrc; |
︙ | ︙ | |||
67182 67183 67184 67185 67186 67187 67188 | if( iCol<0 ){ return 1; } } if( iCol>0 ){ CollSeq *pColl = pE->pColl; int flags = pE->flags & EP_ExpCollate; | | | 68367 68368 68369 68370 68371 68372 68373 68374 68375 68376 68377 68378 68379 68380 68381 | if( iCol<0 ){ return 1; } } if( iCol>0 ){ CollSeq *pColl = pE->pColl; int flags = pE->flags & EP_ExpCollate; sqlite3ExprDelete(db, pE); pE = sqlite3ExprDup(db, pEList->a[iCol-1].pExpr); pOrderBy->a[i].pExpr = pE; if( pE && pColl && flags ){ pE->pColl = pColl; pE->flags |= flags; } } |
︙ | ︙ | |||
67253 67254 67255 67256 67257 67258 67259 | } }else{ pDup = sqlite3ExprDup(db, pE); if( !db->mallocFailed ){ assert(pDup); iCol = matchOrderByTermToExprList(pParse, pSelect, pDup, i+1, 1, 0); } | | | 68438 68439 68440 68441 68442 68443 68444 68445 68446 68447 68448 68449 68450 68451 68452 | } }else{ pDup = sqlite3ExprDup(db, pE); if( !db->mallocFailed ){ assert(pDup); iCol = matchOrderByTermToExprList(pParse, pSelect, pDup, i+1, 1, 0); } sqlite3ExprDelete(db, pDup); if( iCol<0 ){ return 1; } } if( iCol>0 ){ pE->op = TK_INTEGER; pE->flags |= EP_IntValue; |
︙ | ︙ | |||
67433 67434 67435 67436 67437 67438 67439 67440 67441 67442 67443 | SelectDest *pDest /* What to do with query results */ ){ int rc = SQLITE_OK; /* Success code from a subroutine */ Select *pPrior; /* Another SELECT immediately to our left */ Vdbe *v; /* Generate code to this VDBE */ SelectDest dest; /* Alternative data destination */ Select *pDelete = 0; /* Chain of simple selects to delete */ /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT. */ | > | | < < < < | < < < | 68618 68619 68620 68621 68622 68623 68624 68625 68626 68627 68628 68629 68630 68631 68632 68633 68634 68635 68636 68637 68638 68639 68640 68641 68642 68643 68644 68645 68646 68647 68648 68649 68650 68651 68652 68653 68654 68655 68656 | SelectDest *pDest /* What to do with query results */ ){ int rc = SQLITE_OK; /* Success code from a subroutine */ Select *pPrior; /* Another SELECT immediately to our left */ Vdbe *v; /* Generate code to this VDBE */ SelectDest dest; /* Alternative data destination */ Select *pDelete = 0; /* Chain of simple selects to delete */ sqlite3 *db; /* Database connection */ /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT. */ assert( p && p->pPrior ); /* Calling function guarantees this much */ db = pParse->db; pPrior = p->pPrior; assert( pPrior->pRightmost!=pPrior ); assert( pPrior->pRightmost==p->pRightmost ); if( pPrior->pOrderBy ){ sqlite3ErrorMsg(pParse,"ORDER BY clause should come after %s not before", selectOpName(p->op)); rc = 1; goto multi_select_end; } if( pPrior->pLimit ){ sqlite3ErrorMsg(pParse,"LIMIT clause should come after %s not before", selectOpName(p->op)); rc = 1; goto multi_select_end; } v = sqlite3GetVdbe(pParse); assert( v!=0 ); /* The VDBE already created by calling function */ /* Create the destination temporary table if necessary */ dest = *pDest; if( dest.eDest==SRT_EphemTab ){ assert( p->pEList ); sqlite3VdbeAddOp2(v, OP_OpenEphemeral, dest.iParm, p->pEList->nExpr); |
︙ | ︙ | |||
67562 67563 67564 67565 67566 67567 67568 | rc = sqlite3Select(pParse, pPrior, &uniondest, 0, 0, 0); if( rc ){ goto multi_select_end; } /* Code the current SELECT statement */ | | | > | | | | | 68741 68742 68743 68744 68745 68746 68747 68748 68749 68750 68751 68752 68753 68754 68755 68756 68757 68758 68759 68760 68761 68762 68763 68764 68765 68766 68767 68768 68769 68770 68771 68772 68773 68774 68775 | rc = sqlite3Select(pParse, pPrior, &uniondest, 0, 0, 0); if( rc ){ goto multi_select_end; } /* Code the current SELECT statement */ if( p->op==TK_EXCEPT ){ op = SRT_Except; }else{ assert( p->op==TK_UNION ); op = SRT_Union; } p->pPrior = 0; p->disallowOrderBy = 0; pLimit = p->pLimit; p->pLimit = 0; pOffset = p->pOffset; p->pOffset = 0; uniondest.eDest = op; rc = sqlite3Select(pParse, p, &uniondest, 0, 0, 0); /* Query flattening in sqlite3Select() might refill p->pOrderBy. ** Be sure to delete p->pOrderBy, therefore, to avoid a memory leak. */ sqlite3ExprListDelete(db, p->pOrderBy); pDelete = p->pPrior; p->pPrior = pPrior; p->pOrderBy = 0; sqlite3ExprDelete(db, p->pLimit); p->pLimit = pLimit; p->pOffset = pOffset; p->iLimit = 0; p->iOffset = 0; if( rc ){ goto multi_select_end; } |
︙ | ︙ | |||
67660 67661 67662 67663 67664 67665 67666 | p->pLimit = 0; pOffset = p->pOffset; p->pOffset = 0; intersectdest.iParm = tab2; rc = sqlite3Select(pParse, p, &intersectdest, 0, 0, 0); pDelete = p->pPrior; p->pPrior = pPrior; | | | 68840 68841 68842 68843 68844 68845 68846 68847 68848 68849 68850 68851 68852 68853 68854 | p->pLimit = 0; pOffset = p->pOffset; p->pOffset = 0; intersectdest.iParm = tab2; rc = sqlite3Select(pParse, p, &intersectdest, 0, 0, 0); pDelete = p->pPrior; p->pPrior = pPrior; sqlite3ExprDelete(db, p->pLimit); p->pLimit = pLimit; p->pOffset = pOffset; if( rc ){ goto multi_select_end; } /* Generate code to take the intersection of the two temporary |
︙ | ︙ | |||
67713 67714 67715 67716 67717 67718 67719 | KeyInfo *pKeyInfo; /* Collating sequence for the result set */ Select *pLoop; /* For looping through SELECT statements */ CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */ int nCol; /* Number of columns in result set */ assert( p->pRightmost==p ); nCol = p->pEList->nExpr; | | | | | | | 68893 68894 68895 68896 68897 68898 68899 68900 68901 68902 68903 68904 68905 68906 68907 68908 68909 68910 68911 68912 68913 68914 68915 68916 68917 68918 68919 68920 68921 68922 68923 68924 68925 68926 68927 68928 68929 68930 68931 68932 68933 68934 68935 68936 68937 68938 68939 68940 68941 68942 68943 68944 | KeyInfo *pKeyInfo; /* Collating sequence for the result set */ Select *pLoop; /* For looping through SELECT statements */ CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */ int nCol; /* Number of columns in result set */ assert( p->pRightmost==p ); nCol = p->pEList->nExpr; pKeyInfo = sqlite3DbMallocZero(db, sizeof(*pKeyInfo)+nCol*(sizeof(CollSeq*) + 1)); if( !pKeyInfo ){ rc = SQLITE_NOMEM; goto multi_select_end; } pKeyInfo->enc = ENC(db); pKeyInfo->nField = nCol; for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){ *apColl = multiSelectCollSeq(pParse, p, i); if( 0==*apColl ){ *apColl = db->pDfltColl; } } for(pLoop=p; pLoop; pLoop=pLoop->pPrior){ for(i=0; i<2; i++){ int addr = pLoop->addrOpenEphm[i]; if( addr<0 ){ /* If [0] is unused then [1] is also unused. So we can ** always safely abort as soon as the first unused slot is found */ assert( pLoop->addrOpenEphm[1]<0 ); break; } sqlite3VdbeChangeP2(v, addr, nCol); sqlite3VdbeChangeP4(v, addr, (char*)pKeyInfo, P4_KEYINFO); pLoop->addrOpenEphm[i] = -1; } } sqlite3DbFree(db, pKeyInfo); } multi_select_end: pDest->iMem = dest.iMem; pDest->nMem = dest.nMem; sqlite3SelectDelete(db, pDelete); return rc; } #endif /* SQLITE_OMIT_COMPOUND_SELECT */ /* ** Code an output subroutine for a coroutine implementation of a ** SELECT statment. |
︙ | ︙ | |||
67999 68000 68001 68002 68003 68004 68005 68006 68007 68008 68009 68010 68011 68012 | ** End: ... ** ** We call AltB, AeqB, AgtB, EofA, and EofB "subroutines" but they are not ** actually called using Gosub and they do not Return. EofA and EofB loop ** until all data is exhausted then jump to the "end" labe. AltB, AeqB, ** and AgtB jump to either L2 or to one of EofA or EofB. */ static int multiSelectOrderBy( Parse *pParse, /* Parsing context */ Select *p, /* The right-most of SELECTs to be coded */ SelectDest *pDest /* What to do with query results */ ){ int i, j; /* Loop counters */ Select *pPrior; /* Another SELECT immediately to our left */ | > | 69179 69180 69181 69182 69183 69184 69185 69186 69187 69188 69189 69190 69191 69192 69193 | ** End: ... ** ** We call AltB, AeqB, AgtB, EofA, and EofB "subroutines" but they are not ** actually called using Gosub and they do not Return. EofA and EofB loop ** until all data is exhausted then jump to the "end" labe. AltB, AeqB, ** and AgtB jump to either L2 or to one of EofA or EofB. */ #ifndef SQLITE_OMIT_COMPOUND_SELECT static int multiSelectOrderBy( Parse *pParse, /* Parsing context */ Select *p, /* The right-most of SELECTs to be coded */ SelectDest *pDest /* What to do with query results */ ){ int i, j; /* Loop counters */ Select *pPrior; /* Another SELECT immediately to our left */ |
︙ | ︙ | |||
68173 68174 68175 68176 68177 68178 68179 | regLimitB = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_Copy, p->iOffset ? p->iOffset+1 : p->iLimit, regLimitA); sqlite3VdbeAddOp2(v, OP_Copy, regLimitA, regLimitB); }else{ regLimitA = regLimitB = 0; } | | | | 69354 69355 69356 69357 69358 69359 69360 69361 69362 69363 69364 69365 69366 69367 69368 69369 69370 | regLimitB = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_Copy, p->iOffset ? p->iOffset+1 : p->iLimit, regLimitA); sqlite3VdbeAddOp2(v, OP_Copy, regLimitA, regLimitB); }else{ regLimitA = regLimitB = 0; } sqlite3ExprDelete(db, p->pLimit); p->pLimit = 0; sqlite3ExprDelete(db, p->pOffset); p->pOffset = 0; regAddrA = ++pParse->nMem; regEofA = ++pParse->nMem; regAddrB = ++pParse->nMem; regEofB = ++pParse->nMem; regOutA = ++pParse->nMem; |
︙ | ︙ | |||
68337 68338 68339 68340 68341 68342 68343 | while( pFirst->pPrior ) pFirst = pFirst->pPrior; generateColumnNames(pParse, 0, pFirst->pEList); } /* Reassembly the compound query so that it will be freed correctly ** by the calling function */ if( p->pPrior ){ | | > | | 69518 69519 69520 69521 69522 69523 69524 69525 69526 69527 69528 69529 69530 69531 69532 69533 69534 69535 69536 69537 69538 69539 69540 69541 69542 | while( pFirst->pPrior ) pFirst = pFirst->pPrior; generateColumnNames(pParse, 0, pFirst->pEList); } /* Reassembly the compound query so that it will be freed correctly ** by the calling function */ if( p->pPrior ){ sqlite3SelectDelete(db, p->pPrior); } p->pPrior = pPrior; /*** TBD: Insert subroutine calls to close cursors on incomplete **** subqueries ****/ return SQLITE_OK; } #endif #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) /* Forward Declarations */ static void substExprList(sqlite3*, ExprList*, int, ExprList*); static void substSelect(sqlite3*, Select *, int, ExprList *); /* ** Scan through the expression pExpr. Replace every reference to ** a column in table number iTable with a copy of the iColumn-th |
︙ | ︙ | |||
68429 68430 68431 68432 68433 68434 68435 | substExprList(db, p->pEList, iTable, pEList); substExprList(db, p->pGroupBy, iTable, pEList); substExprList(db, p->pOrderBy, iTable, pEList); substExpr(db, p->pHaving, iTable, pEList); substExpr(db, p->pWhere, iTable, pEList); substSelect(db, p->pPrior, iTable, pEList); } | | | | 69611 69612 69613 69614 69615 69616 69617 69618 69619 69620 69621 69622 69623 69624 69625 69626 69627 | substExprList(db, p->pEList, iTable, pEList); substExprList(db, p->pGroupBy, iTable, pEList); substExprList(db, p->pOrderBy, iTable, pEList); substExpr(db, p->pHaving, iTable, pEList); substExpr(db, p->pWhere, iTable, pEList); substSelect(db, p->pPrior, iTable, pEList); } #endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */ #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) /* ** This routine attempts to flatten subqueries in order to speed ** execution. It returns 1 if it makes changes and 0 if no flattening ** occurs. ** ** To understand the concept of flattening, consider the following ** query: |
︙ | ︙ | |||
68706 68707 68708 68709 68710 68711 68712 | ** elements we are now copying in. */ if( pSrc ){ pSubitem = &pSrc->a[iFrom]; nSubSrc = pSubSrc->nSrc; jointype = pSubitem->jointype; sqlite3DeleteTable(pSubitem->pTab); | | | | | 69888 69889 69890 69891 69892 69893 69894 69895 69896 69897 69898 69899 69900 69901 69902 69903 69904 | ** elements we are now copying in. */ if( pSrc ){ pSubitem = &pSrc->a[iFrom]; nSubSrc = pSubSrc->nSrc; jointype = pSubitem->jointype; sqlite3DeleteTable(pSubitem->pTab); sqlite3DbFree(db, pSubitem->zDatabase); sqlite3DbFree(db, pSubitem->zName); sqlite3DbFree(db, pSubitem->zAlias); pSubitem->pTab = 0; pSubitem->zDatabase = 0; pSubitem->zName = 0; pSubitem->zAlias = 0; } if( nSubSrc!=1 || !pSrc ){ int extra = nSubSrc - 1; |
︙ | ︙ | |||
68805 68806 68807 68808 68809 68810 68811 | pSub->pLimit = 0; } } /* Finially, delete what is left of the subquery and return ** success. */ | | | | 69987 69988 69989 69990 69991 69992 69993 69994 69995 69996 69997 69998 69999 70000 70001 70002 70003 70004 70005 | pSub->pLimit = 0; } } /* Finially, delete what is left of the subquery and return ** success. */ sqlite3SelectDelete(db, pSub1); return 1; } #endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */ /* ** Analyze the SELECT statement passed as an argument to see if it ** is a min() or max() query. Return WHERE_ORDERBY_MIN or WHERE_ORDERBY_MAX if ** it is, or 0 otherwise. At present, a query is considered to be ** a min()/max() query if: ** |
︙ | ︙ | |||
69076 69077 69078 69079 69080 69081 69082 | } for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){ sqlite3ExprCode(pParse, pC->pExpr, pC->iMem); } pAggInfo->directMode = 0; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < | 70258 70259 70260 70261 70262 70263 70264 70265 70266 70267 70268 70269 70270 70271 | } for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){ sqlite3ExprCode(pParse, pC->pExpr, pC->iMem); } pAggInfo->directMode = 0; } /* ** Generate code for the given SELECT statement. ** ** The results are distributed in various ways depending on the ** contents of the SelectDest structure pointed to by argument pDest ** as follows: ** |
︙ | ︙ | |||
69571 69572 69573 69574 69575 69576 69577 | sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, 0); sqlite3VdbeAddOp2(v, OP_Sequence, sAggInfo.sortingIdx,regBase+nGroupBy); j = nGroupBy+1; for(i=0; i<sAggInfo.nColumn; i++){ struct AggInfo_col *pCol = &sAggInfo.aCol[i]; if( pCol->iSorterColumn>=j ){ int r1 = j + regBase; | > > > | < < < > > > > > > > > | 70726 70727 70728 70729 70730 70731 70732 70733 70734 70735 70736 70737 70738 70739 70740 70741 70742 70743 70744 70745 70746 70747 70748 70749 70750 70751 70752 70753 | sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, 0); sqlite3VdbeAddOp2(v, OP_Sequence, sAggInfo.sortingIdx,regBase+nGroupBy); j = nGroupBy+1; for(i=0; i<sAggInfo.nColumn; i++){ struct AggInfo_col *pCol = &sAggInfo.aCol[i]; if( pCol->iSorterColumn>=j ){ int r1 = j + regBase; #ifndef NDEBUG int r2 = #endif sqlite3ExprCodeGetColumn(pParse, pCol->pTab, pCol->iColumn, pCol->iTable, r1, 0); j++; /* sAggInfo.aCol[] only contains one entry per column. So ** The reference to pCol->iColumn,pCol->iTable must have been ** the first reference to that column. Hence, ** sqliteExprCodeGetColumn is guaranteed to put the result in ** the column requested. */ assert( r1==r2 ); } } regRecord = sqlite3GetTempReg(pParse); sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regRecord); sqlite3VdbeAddOp2(v, OP_IdxInsert, sAggInfo.sortingIdx, regRecord); sqlite3ReleaseTempReg(pParse, regRecord); sqlite3ReleaseTempRange(pParse, regBase, nCol); |
︙ | ︙ | |||
69695 69696 69697 69698 69699 69700 69701 | /* This case runs if the aggregate has no GROUP BY clause. The ** processing is much simpler since there is only a single row ** of output. */ resetAccumulator(pParse, &sAggInfo); pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, &pMinMax, flag); if( pWInfo==0 ){ | | | | 70858 70859 70860 70861 70862 70863 70864 70865 70866 70867 70868 70869 70870 70871 70872 70873 70874 70875 70876 70877 70878 70879 70880 70881 70882 70883 70884 70885 70886 70887 70888 70889 | /* This case runs if the aggregate has no GROUP BY clause. The ** processing is much simpler since there is only a single row ** of output. */ resetAccumulator(pParse, &sAggInfo); pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, &pMinMax, flag); if( pWInfo==0 ){ sqlite3ExprListDelete(db, pDel); goto select_end; } updateAccumulator(pParse, &sAggInfo); if( !pMinMax && flag ){ sqlite3VdbeAddOp2(v, OP_Goto, 0, pWInfo->iBreak); VdbeComment((v, "%s() by index",(flag==WHERE_ORDERBY_MIN?"min":"max"))); } sqlite3WhereEnd(pWInfo); finalizeAggFunctions(pParse, &sAggInfo); pOrderBy = 0; if( pHaving ){ sqlite3ExprIfFalse(pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL); } selectInnerLoop(pParse, p, p->pEList, 0, 0, 0, -1, pDest, addrEnd, addrEnd); sqlite3ExprListDelete(db, pDel); } sqlite3VdbeResolveLabel(v, addrEnd); } /* endif aggregate query */ /* If there is an ORDER BY clause, then we need to sort the results ** and send them to the callback one by one. |
︙ | ︙ | |||
69759 69760 69761 69762 69763 69764 69765 | /* Identify column names if we will be using them in a callback. This ** step is skipped if the output is going to some other destination. */ if( rc==SQLITE_OK && pDest->eDest==SRT_Callback ){ generateColumnNames(pParse, pTabList, pEList); } | | | | 70922 70923 70924 70925 70926 70927 70928 70929 70930 70931 70932 70933 70934 70935 70936 70937 | /* Identify column names if we will be using them in a callback. This ** step is skipped if the output is going to some other destination. */ if( rc==SQLITE_OK && pDest->eDest==SRT_Callback ){ generateColumnNames(pParse, pTabList, pEList); } sqlite3DbFree(db, sAggInfo.aCol); sqlite3DbFree(db, sAggInfo.aFunc); return rc; } #if defined(SQLITE_DEBUG) /* ******************************************************************************* ** The following code is used for testing and debugging only. The code |
︙ | ︙ | |||
69880 69881 69882 69883 69884 69885 69886 | ** This file contains the sqlite3_get_table() and sqlite3_free_table() ** interface routines. These are just wrappers around the main ** interface routine of sqlite3_exec(). ** ** These routines are in a separate files so that they will not be linked ** if they are not used. ** | | | 71043 71044 71045 71046 71047 71048 71049 71050 71051 71052 71053 71054 71055 71056 71057 | ** This file contains the sqlite3_get_table() and sqlite3_free_table() ** interface routines. These are just wrappers around the main ** interface routine of sqlite3_exec(). ** ** These routines are in a separate files so that they will not be linked ** if they are not used. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef SQLITE_OMIT_GET_TABLE /* ** This structure is used to pass data from sqlite3_get_table() through ** to the callback function is uses to build the result. |
︙ | ︙ | |||
70075 70076 70077 70078 70079 70080 70081 | ** 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. ** ************************************************************************* ** ** | | | | | | | | | | 71238 71239 71240 71241 71242 71243 71244 71245 71246 71247 71248 71249 71250 71251 71252 71253 71254 71255 71256 71257 71258 71259 71260 71261 71262 71263 71264 71265 71266 71267 71268 71269 71270 | ** 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. ** ************************************************************************* ** ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef SQLITE_OMIT_TRIGGER /* ** Delete a linked list of TriggerStep structures. */ SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3 *db, TriggerStep *pTriggerStep){ while( pTriggerStep ){ TriggerStep * pTmp = pTriggerStep; pTriggerStep = pTriggerStep->pNext; if( pTmp->target.dyn ) sqlite3DbFree(db, (char*)pTmp->target.z); sqlite3ExprDelete(db, pTmp->pWhere); sqlite3ExprListDelete(db, pTmp->pExprList); sqlite3SelectDelete(db, pTmp->pSelect); sqlite3IdListDelete(db, pTmp->pIdList); sqlite3DbFree(db, pTmp); } } /* ** This is called by the parser when it sees a CREATE TRIGGER statement ** up to the point of the BEGIN before the trigger actions. A Trigger ** structure is generated based on the information available and stored |
︙ | ︙ | |||
70250 70251 70252 70253 70254 70255 70256 | pTrigger->pWhen = sqlite3ExprDup(db, pWhen); pTrigger->pColumns = sqlite3IdListDup(db, pColumns); sqlite3TokenCopy(db, &pTrigger->nameToken,pName); assert( pParse->pNewTrigger==0 ); pParse->pNewTrigger = pTrigger; trigger_cleanup: | | | | | | | 71413 71414 71415 71416 71417 71418 71419 71420 71421 71422 71423 71424 71425 71426 71427 71428 71429 71430 71431 71432 | pTrigger->pWhen = sqlite3ExprDup(db, pWhen); pTrigger->pColumns = sqlite3IdListDup(db, pColumns); sqlite3TokenCopy(db, &pTrigger->nameToken,pName); assert( pParse->pNewTrigger==0 ); pParse->pNewTrigger = pTrigger; trigger_cleanup: sqlite3DbFree(db, zName); sqlite3SrcListDelete(db, pTableName); sqlite3IdListDelete(db, pColumns); sqlite3ExprDelete(db, pWhen); if( !pParse->pNewTrigger ){ sqlite3DeleteTrigger(db, pTrigger); }else{ assert( pParse->pNewTrigger==pTrigger ); } } /* ** This routine is called after all of the trigger actions have been parsed |
︙ | ︙ | |||
70305 70306 70307 70308 70309 70310 70311 | if( v==0 ) goto triggerfinish_cleanup; sqlite3BeginWriteOperation(pParse, 0, iDb); z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n); sqlite3NestedParse(pParse, "INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')", db->aDb[iDb].zName, SCHEMA_TABLE(iDb), pTrig->name, pTrig->table, z); | | | 71468 71469 71470 71471 71472 71473 71474 71475 71476 71477 71478 71479 71480 71481 71482 | if( v==0 ) goto triggerfinish_cleanup; sqlite3BeginWriteOperation(pParse, 0, iDb); z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n); sqlite3NestedParse(pParse, "INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')", db->aDb[iDb].zName, SCHEMA_TABLE(iDb), pTrig->name, pTrig->table, z); sqlite3DbFree(db, z); sqlite3ChangeCookie(pParse, iDb); sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0, sqlite3MPrintf( db, "type='trigger' AND name='%q'", pTrig->name), P4_DYNAMIC ); } if( db->init.busy ){ |
︙ | ︙ | |||
70332 70333 70334 70335 70336 70337 70338 | assert( pTab!=0 ); pTrig->pNext = pTab->pTrigger; pTab->pTrigger = pTrig; pTrig = 0; } triggerfinish_cleanup: | | | | | | | | | 71495 71496 71497 71498 71499 71500 71501 71502 71503 71504 71505 71506 71507 71508 71509 71510 71511 71512 71513 71514 71515 71516 71517 71518 71519 71520 71521 71522 71523 71524 71525 71526 71527 71528 71529 71530 71531 71532 71533 71534 71535 71536 71537 71538 71539 71540 71541 71542 71543 71544 71545 71546 71547 71548 71549 71550 71551 71552 71553 71554 71555 71556 71557 71558 71559 71560 71561 | assert( pTab!=0 ); pTrig->pNext = pTab->pTrigger; pTab->pTrigger = pTrig; pTrig = 0; } triggerfinish_cleanup: sqlite3DeleteTrigger(db, pTrig); assert( !pParse->pNewTrigger ); sqlite3DeleteTriggerStep(db, pStepList); } /* ** Make a copy of all components of the given trigger step. This has ** the effect of copying all Expr.token.z values into memory obtained ** from sqlite3_malloc(). As initially created, the Expr.token.z values ** all point to the input string that was fed to the parser. But that ** string is ephemeral - it will go away as soon as the sqlite3_exec() ** call that started the parser exits. This routine makes a persistent ** copy of all the Expr.token.z strings so that the TriggerStep structure ** will be valid even after the sqlite3_exec() call returns. */ static void sqlitePersistTriggerStep(sqlite3 *db, TriggerStep *p){ if( p->target.z ){ p->target.z = (u8*)sqlite3DbStrNDup(db, (char*)p->target.z, p->target.n); p->target.dyn = 1; } if( p->pSelect ){ Select *pNew = sqlite3SelectDup(db, p->pSelect); sqlite3SelectDelete(db, p->pSelect); p->pSelect = pNew; } if( p->pWhere ){ Expr *pNew = sqlite3ExprDup(db, p->pWhere); sqlite3ExprDelete(db, p->pWhere); p->pWhere = pNew; } if( p->pExprList ){ ExprList *pNew = sqlite3ExprListDup(db, p->pExprList); sqlite3ExprListDelete(db, p->pExprList); p->pExprList = pNew; } if( p->pIdList ){ IdList *pNew = sqlite3IdListDup(db, p->pIdList); sqlite3IdListDelete(db, p->pIdList); p->pIdList = pNew; } } /* ** Turn a SELECT statement (that the pSelect parameter points to) into ** a trigger step. Return a pointer to a TriggerStep structure. ** ** The parser calls this routine when it finds a SELECT statement in ** body of a TRIGGER. */ SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3 *db, Select *pSelect){ TriggerStep *pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep)); if( pTriggerStep==0 ) { sqlite3SelectDelete(db, pSelect); return 0; } pTriggerStep->op = TK_SELECT; pTriggerStep->pSelect = pSelect; pTriggerStep->orconf = OE_Default; sqlitePersistTriggerStep(db, pTriggerStep); |
︙ | ︙ | |||
70426 70427 70428 70429 70430 70431 70432 | pTriggerStep->pSelect = pSelect; pTriggerStep->target = *pTableName; pTriggerStep->pIdList = pColumn; pTriggerStep->pExprList = pEList; pTriggerStep->orconf = orconf; sqlitePersistTriggerStep(db, pTriggerStep); }else{ | | | | | | | 71589 71590 71591 71592 71593 71594 71595 71596 71597 71598 71599 71600 71601 71602 71603 71604 71605 71606 71607 71608 71609 71610 71611 71612 71613 71614 71615 71616 71617 71618 71619 71620 71621 71622 71623 71624 71625 71626 | pTriggerStep->pSelect = pSelect; pTriggerStep->target = *pTableName; pTriggerStep->pIdList = pColumn; pTriggerStep->pExprList = pEList; pTriggerStep->orconf = orconf; sqlitePersistTriggerStep(db, pTriggerStep); }else{ sqlite3IdListDelete(db, pColumn); sqlite3ExprListDelete(db, pEList); sqlite3SelectDelete(db, pSelect); } return pTriggerStep; } /* ** Construct a trigger step that implements an UPDATE statement and return ** a pointer to that trigger step. The parser calls this routine when it ** sees an UPDATE statement inside the body of a CREATE TRIGGER. */ SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep( sqlite3 *db, /* The database connection */ Token *pTableName, /* Name of the table to be updated */ ExprList *pEList, /* The SET clause: list of column and new values */ Expr *pWhere, /* The WHERE clause */ int orconf /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */ ){ TriggerStep *pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep)); if( pTriggerStep==0 ){ sqlite3ExprListDelete(db, pEList); sqlite3ExprDelete(db, pWhere); return 0; } pTriggerStep->op = TK_UPDATE; pTriggerStep->target = *pTableName; pTriggerStep->pExprList = pEList; pTriggerStep->pWhere = pWhere; |
︙ | ︙ | |||
70475 70476 70477 70478 70479 70480 70481 | SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep( sqlite3 *db, /* Database connection */ Token *pTableName, /* The table from which rows are deleted */ Expr *pWhere /* The WHERE clause */ ){ TriggerStep *pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep)); if( pTriggerStep==0 ){ | | | | | | | | | | | 71638 71639 71640 71641 71642 71643 71644 71645 71646 71647 71648 71649 71650 71651 71652 71653 71654 71655 71656 71657 71658 71659 71660 71661 71662 71663 71664 71665 71666 71667 71668 71669 71670 71671 71672 71673 71674 71675 71676 | SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep( sqlite3 *db, /* Database connection */ Token *pTableName, /* The table from which rows are deleted */ Expr *pWhere /* The WHERE clause */ ){ TriggerStep *pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep)); if( pTriggerStep==0 ){ sqlite3ExprDelete(db, pWhere); return 0; } pTriggerStep->op = TK_DELETE; pTriggerStep->target = *pTableName; pTriggerStep->pWhere = pWhere; pTriggerStep->orconf = OE_Default; sqlitePersistTriggerStep(db, pTriggerStep); return pTriggerStep; } /* ** Recursively delete a Trigger structure */ SQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3 *db, Trigger *pTrigger){ if( pTrigger==0 ) return; sqlite3DeleteTriggerStep(db, pTrigger->step_list); sqlite3DbFree(db, pTrigger->name); sqlite3DbFree(db, pTrigger->table); sqlite3ExprDelete(db, pTrigger->pWhen); sqlite3IdListDelete(db, pTrigger->pColumns); if( pTrigger->nameToken.dyn ) sqlite3DbFree(db, (char*)pTrigger->nameToken.z); sqlite3DbFree(db, pTrigger); } /* ** This function is called to drop a trigger from the database schema. ** ** This may be called directly from the parser and therefore identifies ** the trigger by name. The sqlite3DropTriggerPtr() routine does the |
︙ | ︙ | |||
70542 70543 70544 70545 70546 70547 70548 | sqlite3ErrorMsg(pParse, "no such trigger: %S", pName, 0); } goto drop_trigger_cleanup; } sqlite3DropTriggerPtr(pParse, pTrigger); drop_trigger_cleanup: | | | 71705 71706 71707 71708 71709 71710 71711 71712 71713 71714 71715 71716 71717 71718 71719 | sqlite3ErrorMsg(pParse, "no such trigger: %S", pName, 0); } goto drop_trigger_cleanup; } sqlite3DropTriggerPtr(pParse, pTrigger); drop_trigger_cleanup: sqlite3SrcListDelete(db, pName); } /* ** Return a pointer to the Table structure for the table that a trigger ** is set on. */ static Table *tableOfTrigger(Trigger *pTrigger){ |
︙ | ︙ | |||
70634 70635 70636 70637 70638 70639 70640 | cc->pNext = cc->pNext->pNext; break; } cc = cc->pNext; } assert(cc); } | | | 71797 71798 71799 71800 71801 71802 71803 71804 71805 71806 71807 71808 71809 71810 71811 | cc->pNext = cc->pNext->pNext; break; } cc = cc->pNext; } assert(cc); } sqlite3DeleteTrigger(db, pTrigger); db->flags |= SQLITE_InternChanges; } } /* ** pEList is the SET clause of an UPDATE statement. Each entry ** in pEList is of the format <id>=<expr>. If any of the entries |
︙ | ︙ | |||
70745 70746 70747 70748 70749 70750 70751 | Select *ss = sqlite3SelectDup(db, pTriggerStep->pSelect); if( ss ){ SelectDest dest; sqlite3SelectDestInit(&dest, SRT_Discard, 0); sqlite3SelectResolve(pParse, ss, 0); sqlite3Select(pParse, ss, &dest, 0, 0, 0); | | | 71908 71909 71910 71911 71912 71913 71914 71915 71916 71917 71918 71919 71920 71921 71922 | Select *ss = sqlite3SelectDup(db, pTriggerStep->pSelect); if( ss ){ SelectDest dest; sqlite3SelectDestInit(&dest, SRT_Discard, 0); sqlite3SelectResolve(pParse, ss, 0); sqlite3Select(pParse, ss, &dest, 0, 0, 0); sqlite3SelectDelete(db, ss); } break; } case TK_UPDATE: { SrcList *pSrc; pSrc = targetSrcList(pParse, pTriggerStep); sqlite3VdbeAddOp2(v, OP_ResetCount, 0, 0); |
︙ | ︙ | |||
70895 70896 70897 70898 70899 70900 70901 | sqlite3AuthContextPush(pParse, &sContext, p->name); /* code the WHEN clause */ endTrigger = sqlite3VdbeMakeLabel(pParse->pVdbe); whenExpr = sqlite3ExprDup(db, p->pWhen); if( db->mallocFailed || sqlite3ExprResolveNames(&sNC, whenExpr) ){ pParse->trigStack = trigStackEntry.pNext; | | | | 72058 72059 72060 72061 72062 72063 72064 72065 72066 72067 72068 72069 72070 72071 72072 72073 72074 72075 72076 | sqlite3AuthContextPush(pParse, &sContext, p->name); /* code the WHEN clause */ endTrigger = sqlite3VdbeMakeLabel(pParse->pVdbe); whenExpr = sqlite3ExprDup(db, p->pWhen); if( db->mallocFailed || sqlite3ExprResolveNames(&sNC, whenExpr) ){ pParse->trigStack = trigStackEntry.pNext; sqlite3ExprDelete(db, whenExpr); return 1; } sqlite3ExprIfFalse(pParse, whenExpr, endTrigger, SQLITE_JUMPIFNULL); sqlite3ExprDelete(db, whenExpr); codeTriggerProgram(pParse, p->step_list, orconf); /* Pop the entry off the trigger stack */ pParse->trigStack = trigStackEntry.pNext; sqlite3AuthContextPop(&sContext); |
︙ | ︙ | |||
70932 70933 70934 70935 70936 70937 70938 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle UPDATE statements. ** | | | 72095 72096 72097 72098 72099 72100 72101 72102 72103 72104 72105 72106 72107 72108 72109 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle UPDATE statements. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef SQLITE_OMIT_VIRTUALTABLE /* Forward declaration */ static void updateVirtualTable( Parse *pParse, /* The parsing context */ SrcList *pSrc, /* The virtual table to be modified */ |
︙ | ︙ | |||
71489 71490 71491 71492 71493 71494 71495 | sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", P4_STATIC); } update_cleanup: sqlite3AuthContextPop(&sContext); | | | | | | | 72652 72653 72654 72655 72656 72657 72658 72659 72660 72661 72662 72663 72664 72665 72666 72667 72668 72669 72670 | sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", P4_STATIC); } update_cleanup: sqlite3AuthContextPop(&sContext); sqlite3DbFree(db, aRegIdx); sqlite3DbFree(db, aXRef); sqlite3SrcListDelete(db, pTabList); sqlite3ExprListDelete(db, pChanges); sqlite3ExprDelete(db, pWhere); return; } #ifndef SQLITE_OMIT_VIRTUALTABLE /* ** Generate code for an UPDATE of a virtual table. ** |
︙ | ︙ | |||
71587 71588 71589 71590 71591 71592 71593 | sqlite3VtabMakeWritable(pParse, pTab); sqlite3VdbeAddOp4(v, OP_VUpdate, 0, pTab->nCol+2, iReg, pVtab, P4_VTAB); sqlite3VdbeAddOp2(v, OP_Next, ephemTab, addr); sqlite3VdbeJumpHere(v, addr-1); sqlite3VdbeAddOp2(v, OP_Close, ephemTab, 0); /* Cleanup */ | | | 72750 72751 72752 72753 72754 72755 72756 72757 72758 72759 72760 72761 72762 72763 72764 | sqlite3VtabMakeWritable(pParse, pTab); sqlite3VdbeAddOp4(v, OP_VUpdate, 0, pTab->nCol+2, iReg, pVtab, P4_VTAB); sqlite3VdbeAddOp2(v, OP_Next, ephemTab, addr); sqlite3VdbeJumpHere(v, addr-1); sqlite3VdbeAddOp2(v, OP_Close, ephemTab, 0); /* Cleanup */ sqlite3SelectDelete(db, pSelect); } #endif /* SQLITE_OMIT_VIRTUALTABLE */ /* Make sure "isView" gets undefined in case this file becomes part of ** the amalgamation - so that subsequent files do not see isView as a ** macro. */ #undef isView |
︙ | ︙ | |||
71614 71615 71616 71617 71618 71619 71620 | ** ************************************************************************* ** This file contains code used to implement the VACUUM command. ** ** Most of the code in this file may be omitted by defining the ** SQLITE_OMIT_VACUUM macro. ** | | | 72777 72778 72779 72780 72781 72782 72783 72784 72785 72786 72787 72788 72789 72790 72791 | ** ************************************************************************* ** This file contains code used to implement the VACUUM command. ** ** Most of the code in this file may be omitted by defining the ** SQLITE_OMIT_VACUUM macro. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH) /* ** Execute zSql on database db. Return an error code. */ static int execSql(sqlite3 *db, const char *zSql){ |
︙ | ︙ | |||
71905 71906 71907 71908 71909 71910 71911 | ** 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 contains code used to help implement virtual tables. ** | | | 73068 73069 73070 73071 73072 73073 73074 73075 73076 73077 73078 73079 73080 73081 73082 | ** 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 contains code used to help implement virtual tables. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef SQLITE_OMIT_VIRTUALTABLE static int createModule( sqlite3 *db, /* Database in which module is registered */ const char *zName, /* Name assigned to this module */ const sqlite3_module *pModule, /* The definition of the module */ |
︙ | ︙ | |||
71934 71935 71936 71937 71938 71939 71940 | pMod->pModule = pModule; pMod->pAux = pAux; pMod->xDestroy = xDestroy; pDel = (Module *)sqlite3HashInsert(&db->aModule, zCopy, nName, (void*)pMod); if( pDel && pDel->xDestroy ){ pDel->xDestroy(pDel->pAux); } | | | 73097 73098 73099 73100 73101 73102 73103 73104 73105 73106 73107 73108 73109 73110 73111 | pMod->pModule = pModule; pMod->pAux = pAux; pMod->xDestroy = xDestroy; pDel = (Module *)sqlite3HashInsert(&db->aModule, zCopy, nName, (void*)pMod); if( pDel && pDel->xDestroy ){ pDel->xDestroy(pDel->pAux); } sqlite3DbFree(db, pDel); if( pDel==pMod ){ db->mallocFailed = 1; } sqlite3ResetInternalSchema(db, 0); } rc = sqlite3ApiExit(db, SQLITE_OK); sqlite3_mutex_leave(db->mutex); |
︙ | ︙ | |||
72009 72010 72011 72012 72013 72014 72015 72016 72017 | /* ** Clear any and all virtual-table information from the Table record. ** This routine is called, for example, just before deleting the Table ** record. */ SQLITE_PRIVATE void sqlite3VtabClear(Table *p){ sqlite3_vtab *pVtab = p->pVtab; if( pVtab ){ assert( p->pMod && p->pMod->pModule ); | > | | | | | | | 73172 73173 73174 73175 73176 73177 73178 73179 73180 73181 73182 73183 73184 73185 73186 73187 73188 73189 73190 73191 73192 73193 73194 73195 73196 73197 73198 73199 73200 73201 73202 73203 73204 73205 73206 73207 73208 73209 73210 73211 73212 73213 73214 73215 73216 73217 73218 | /* ** Clear any and all virtual-table information from the Table record. ** This routine is called, for example, just before deleting the Table ** record. */ SQLITE_PRIVATE void sqlite3VtabClear(Table *p){ sqlite3_vtab *pVtab = p->pVtab; sqlite3 *db = p->db; if( pVtab ){ assert( p->pMod && p->pMod->pModule ); sqlite3VtabUnlock(db, pVtab); p->pVtab = 0; } if( p->azModuleArg ){ int i; for(i=0; i<p->nModuleArg; i++){ sqlite3DbFree(db, p->azModuleArg[i]); } sqlite3DbFree(db, p->azModuleArg); } } /* ** Add a new module argument to pTable->azModuleArg[]. ** The string is not copied - the pointer is stored. The ** string will be freed automatically when the table is ** deleted. */ static void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){ int i = pTable->nModuleArg++; int nBytes = sizeof(char *)*(1+pTable->nModuleArg); char **azModuleArg; azModuleArg = sqlite3DbRealloc(db, pTable->azModuleArg, nBytes); if( azModuleArg==0 ){ int j; for(j=0; j<i; j++){ sqlite3DbFree(db, pTable->azModuleArg[j]); } sqlite3DbFree(db, zArg); sqlite3DbFree(db, pTable->azModuleArg); pTable->nModuleArg = 0; }else{ azModuleArg[i] = zArg; azModuleArg[i+1] = 0; } pTable->azModuleArg = azModuleArg; } |
︙ | ︙ | |||
72171 72172 72173 72174 72175 72176 72177 | "WHERE rowid=#%d", db->aDb[iDb].zName, SCHEMA_TABLE(iDb), pTab->zName, pTab->zName, zStmt, pParse->regRowid ); | | | 73335 73336 73337 73338 73339 73340 73341 73342 73343 73344 73345 73346 73347 73348 73349 | "WHERE rowid=#%d", db->aDb[iDb].zName, SCHEMA_TABLE(iDb), pTab->zName, pTab->zName, zStmt, pParse->regRowid ); sqlite3DbFree(db, zStmt); v = sqlite3GetVdbe(pParse); sqlite3ChangeCookie(pParse, iDb); sqlite3VdbeAddOp2(v, OP_Expire, 0, 0); zWhere = sqlite3MPrintf(db, "name='%q'", pTab->zName); sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 1, 0, zWhere, P4_DYNAMIC); sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0, |
︙ | ︙ | |||
72270 72271 72272 72273 72274 72275 72276 | } if( SQLITE_OK!=rc ){ if( zErr==0 ){ *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName); }else { *pzErr = sqlite3MPrintf(db, "%s", zErr); | | | | 73434 73435 73436 73437 73438 73439 73440 73441 73442 73443 73444 73445 73446 73447 73448 73449 73450 73451 73452 73453 73454 73455 73456 73457 73458 73459 | } if( SQLITE_OK!=rc ){ if( zErr==0 ){ *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName); }else { *pzErr = sqlite3MPrintf(db, "%s", zErr); sqlite3DbFree(db, zErr); } }else if( db->pVTab ){ const char *zFormat = "vtable constructor did not declare schema: %s"; *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName); rc = SQLITE_ERROR; } if( rc==SQLITE_OK ){ rc = rc2; } db->pVTab = 0; sqlite3DbFree(db, zModuleName); /* If everything went according to plan, loop through the columns ** of the table to see if any of them contain the token "hidden". ** If so, set the Column.isHidden flag and remove the token from ** the type string. */ if( rc==SQLITE_OK ){ |
︙ | ︙ | |||
72350 72351 72352 72353 72354 72355 72356 | } else { char *zErr = 0; sqlite3 *db = pParse->db; rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xConnect, &zErr); if( rc!=SQLITE_OK ){ sqlite3ErrorMsg(pParse, "%s", zErr); } | | | 73514 73515 73516 73517 73518 73519 73520 73521 73522 73523 73524 73525 73526 73527 73528 | } else { char *zErr = 0; sqlite3 *db = pParse->db; rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xConnect, &zErr); if( rc!=SQLITE_OK ){ sqlite3ErrorMsg(pParse, "%s", zErr); } sqlite3DbFree(db, zErr); } return rc; } /* ** Add the virtual table pVtab to the array sqlite3.aVTrans[]. |
︙ | ︙ | |||
72386 72387 72388 72389 72390 72391 72392 | /* ** This function is invoked by the vdbe to call the xCreate method ** of the virtual table named zTab in database iDb. ** ** If an error occurs, *pzErr is set to point an an English language ** description of the error and an SQLITE_XXX error code is returned. | | | 73550 73551 73552 73553 73554 73555 73556 73557 73558 73559 73560 73561 73562 73563 73564 | /* ** This function is invoked by the vdbe to call the xCreate method ** of the virtual table named zTab in database iDb. ** ** If an error occurs, *pzErr is set to point an an English language ** description of the error and an SQLITE_XXX error code is returned. ** In this case the caller must call sqlite3DbFree(db, ) on *pzErr. */ SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){ int rc = SQLITE_OK; Table *pTab; Module *pMod; const char *zModule; |
︙ | ︙ | |||
72455 72456 72457 72458 72459 72460 72461 | pTab->aCol = sParse.pNewTable->aCol; pTab->nCol = sParse.pNewTable->nCol; sParse.pNewTable->nCol = 0; sParse.pNewTable->aCol = 0; db->pVTab = 0; } else { sqlite3Error(db, SQLITE_ERROR, zErr); | | | 73619 73620 73621 73622 73623 73624 73625 73626 73627 73628 73629 73630 73631 73632 73633 | pTab->aCol = sParse.pNewTable->aCol; pTab->nCol = sParse.pNewTable->nCol; sParse.pNewTable->nCol = 0; sParse.pNewTable->aCol = 0; db->pVTab = 0; } else { sqlite3Error(db, SQLITE_ERROR, zErr); sqlite3DbFree(db, zErr); rc = SQLITE_ERROR; } sParse.declareVtab = 0; sqlite3_finalize((sqlite3_stmt*)sParse.pVdbe); sqlite3DeleteTable(sParse.pNewTable); sParse.pNewTable = 0; |
︙ | ︙ | |||
72525 72526 72527 72528 72529 72530 72531 | for(i=0; i<db->nVTrans && db->aVTrans[i]; i++){ sqlite3_vtab *pVtab = db->aVTrans[i]; int (*x)(sqlite3_vtab *); x = *(int (**)(sqlite3_vtab *))((char *)pVtab->pModule + offset); if( x ) x(pVtab); sqlite3VtabUnlock(db, pVtab); } | | < | | | > > > | < > > > | 73689 73690 73691 73692 73693 73694 73695 73696 73697 73698 73699 73700 73701 73702 73703 73704 73705 73706 73707 73708 73709 73710 73711 73712 73713 73714 73715 73716 73717 73718 73719 73720 73721 73722 73723 73724 73725 73726 73727 73728 73729 73730 73731 73732 73733 | for(i=0; i<db->nVTrans && db->aVTrans[i]; i++){ sqlite3_vtab *pVtab = db->aVTrans[i]; int (*x)(sqlite3_vtab *); x = *(int (**)(sqlite3_vtab *))((char *)pVtab->pModule + offset); if( x ) x(pVtab); sqlite3VtabUnlock(db, pVtab); } sqlite3DbFree(db, db->aVTrans); db->nVTrans = 0; db->aVTrans = 0; } } /* ** Invoke the xSync method of all virtual tables in the sqlite3.aVTrans ** array. Return the error code for the first error that occurs, or ** SQLITE_OK if all xSync operations are successful. ** ** Set *pzErrmsg to point to a buffer that should be released using ** sqlite3DbFree() containing an error message, if one is available. */ SQLITE_PRIVATE int sqlite3VtabSync(sqlite3 *db, char **pzErrmsg){ int i; int rc = SQLITE_OK; int rcsafety; sqlite3_vtab **aVTrans = db->aVTrans; rc = sqlite3SafetyOff(db); db->aVTrans = 0; for(i=0; rc==SQLITE_OK && i<db->nVTrans && aVTrans[i]; i++){ sqlite3_vtab *pVtab = aVTrans[i]; int (*x)(sqlite3_vtab *); x = pVtab->pModule->xSync; if( x ){ rc = x(pVtab); sqlite3DbFree(db, *pzErrmsg); *pzErrmsg = pVtab->zErrMsg; pVtab->zErrMsg = 0; } } db->aVTrans = aVTrans; rcsafety = sqlite3SafetyOn(db); if( rc==SQLITE_OK ){ rc = rcsafety; |
︙ | ︙ | |||
72619 72620 72621 72622 72623 72624 72625 | if( db->aVTrans[i]==pVtab ){ return SQLITE_OK; } } /* Invoke the xBegin method */ rc = pModule->xBegin(pVtab); | | | < < | 73787 73788 73789 73790 73791 73792 73793 73794 73795 73796 73797 73798 73799 73800 73801 73802 73803 | if( db->aVTrans[i]==pVtab ){ return SQLITE_OK; } } /* Invoke the xBegin method */ rc = pModule->xBegin(pVtab); if( rc==SQLITE_OK ){ rc = addToVTrans(db, pVtab); } } return rc; } /* ** The first parameter (pDef) is a function implementation. The ** second parameter (pExpr) is the first argument to this function. |
︙ | ︙ | |||
72679 72680 72681 72682 72683 72684 72685 | */ zLowerName = sqlite3DbStrDup(db, pDef->zName); if( zLowerName ){ for(z=(unsigned char*)zLowerName; *z; z++){ *z = sqlite3UpperToLower[*z]; } rc = pMod->xFindFunction(pVtab, nArg, zLowerName, &xFunc, &pArg); | | > > > > > | 73845 73846 73847 73848 73849 73850 73851 73852 73853 73854 73855 73856 73857 73858 73859 73860 73861 73862 73863 73864 | */ zLowerName = sqlite3DbStrDup(db, pDef->zName); if( zLowerName ){ for(z=(unsigned char*)zLowerName; *z; z++){ *z = sqlite3UpperToLower[*z]; } rc = pMod->xFindFunction(pVtab, nArg, zLowerName, &xFunc, &pArg); sqlite3DbFree(db, zLowerName); if( pVtab->zErrMsg ){ sqlite3Error(db, rc, "%s", pVtab->zErrMsg); sqlite3DbFree(db, pVtab->zErrMsg); pVtab->zErrMsg = 0; } } if( rc==0 ){ return pDef; } /* Create a new ephemeral function definition for the overloaded ** function */ |
︙ | ︙ | |||
72742 72743 72744 72745 72746 72747 72748 | ** This module contains C code that generates VDBE code used to process ** the WHERE clause of SQL statements. This module is responsible for ** generating the code that loops through a table looking for applicable ** rows. Indices are selected and used to speed the search when doing ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** | | | 73913 73914 73915 73916 73917 73918 73919 73920 73921 73922 73923 73924 73925 73926 73927 | ** This module contains C code that generates VDBE code used to process ** the WHERE clause of SQL statements. This module is responsible for ** generating the code that loops through a table looking for applicable ** rows. Indices are selected and used to speed the search when doing ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** The number of bits in a Bitmask. "BMS" means "BitMask Size". */ #define BMS (sizeof(Bitmask)*8) |
︙ | ︙ | |||
72817 72818 72819 72820 72821 72822 72823 | Bitmask prereqRight; /* Bitmask of tables used by pRight */ Bitmask prereqAll; /* Bitmask of tables referenced by p */ }; /* ** Allowed values of WhereTerm.flags */ | | | 73988 73989 73990 73991 73992 73993 73994 73995 73996 73997 73998 73999 74000 74001 74002 | Bitmask prereqRight; /* Bitmask of tables used by pRight */ Bitmask prereqAll; /* Bitmask of tables referenced by p */ }; /* ** Allowed values of WhereTerm.flags */ #define TERM_DYNAMIC 0x01 /* Need to call sqlite3ExprDelete(db, pExpr) */ #define TERM_VIRTUAL 0x02 /* Added by the optimizer. Do not code */ #define TERM_CODED 0x04 /* This term is already coded */ #define TERM_COPIED 0x08 /* Has a child */ #define TERM_OR_OK 0x10 /* Used during OR-clause processing */ /* ** An instance of the following structure holds all information about a |
︙ | ︙ | |||
72928 72929 72930 72931 72932 72933 72934 72935 72936 | /* ** Deallocate a WhereClause structure. The WhereClause structure ** itself is not freed. This routine is the inverse of whereClauseInit(). */ static void whereClauseClear(WhereClause *pWC){ int i; WhereTerm *a; for(i=pWC->nTerm-1, a=pWC->a; i>=0; i--, a++){ if( a->flags & TERM_DYNAMIC ){ | > | | > | < | | | 74099 74100 74101 74102 74103 74104 74105 74106 74107 74108 74109 74110 74111 74112 74113 74114 74115 74116 74117 74118 74119 74120 74121 74122 74123 74124 74125 74126 74127 74128 74129 74130 74131 74132 74133 74134 74135 74136 74137 74138 74139 74140 74141 74142 74143 74144 74145 74146 74147 74148 74149 74150 74151 74152 | /* ** Deallocate a WhereClause structure. The WhereClause structure ** itself is not freed. This routine is the inverse of whereClauseInit(). */ static void whereClauseClear(WhereClause *pWC){ int i; WhereTerm *a; sqlite3 *db = pWC->pParse->db; for(i=pWC->nTerm-1, a=pWC->a; i>=0; i--, a++){ if( a->flags & TERM_DYNAMIC ){ sqlite3ExprDelete(db, a->pExpr); } } if( pWC->a!=pWC->aStatic ){ sqlite3DbFree(db, pWC->a); } } /* ** Add a new entries to the WhereClause structure. Increase the allocated ** space as necessary. ** ** If the flags argument includes TERM_DYNAMIC, then responsibility ** for freeing the expression p is assumed by the WhereClause object. ** ** WARNING: This routine might reallocate the space used to store ** WhereTerms. All pointers to WhereTerms should be invalidated after ** calling this routine. Such pointers may be reinitialized by referencing ** the pWC->a[] array. */ static int whereClauseInsert(WhereClause *pWC, Expr *p, int flags){ WhereTerm *pTerm; int idx; if( pWC->nTerm>=pWC->nSlot ){ WhereTerm *pOld = pWC->a; sqlite3 *db = pWC->pParse->db; pWC->a = sqlite3DbMallocRaw(db, sizeof(pWC->a[0])*pWC->nSlot*2 ); if( pWC->a==0 ){ if( flags & TERM_DYNAMIC ){ sqlite3ExprDelete(db, p); } pWC->a = pOld; return 0; } memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm); if( pOld!=pWC->aStatic ){ sqlite3DbFree(db, pOld); } pWC->nSlot *= 2; } pTerm = &pWC->a[idx = pWC->nTerm]; pWC->nTerm++; pTerm->pExpr = p; pTerm->flags = flags; |
︙ | ︙ | |||
73498 73499 73500 73501 73502 73503 73504 | if( pRight && pRight->op==TK_COLUMN ){ WhereTerm *pNew; Expr *pDup; if( pTerm->leftCursor>=0 ){ int idxNew; pDup = sqlite3ExprDup(db, pExpr); if( db->mallocFailed ){ | | | 74670 74671 74672 74673 74674 74675 74676 74677 74678 74679 74680 74681 74682 74683 74684 | if( pRight && pRight->op==TK_COLUMN ){ WhereTerm *pNew; Expr *pDup; if( pTerm->leftCursor>=0 ){ int idxNew; pDup = sqlite3ExprDup(db, pExpr); if( db->mallocFailed ){ sqlite3ExprDelete(db, pDup); return; } idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC); if( idxNew==0 ) return; pNew = &pWC->a[idxNew]; pNew->iParent = idxTerm; pTerm = &pWC->a[idxTerm]; |
︙ | ︙ | |||
73614 73615 73616 73617 73618 73619 73620 | pNew->pList = pList; idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC); exprAnalyze(pSrc, pWC, idxNew); pTerm = &pWC->a[idxTerm]; pWC->a[idxNew].iParent = idxTerm; pTerm->nChild = 1; }else{ | | | 74786 74787 74788 74789 74790 74791 74792 74793 74794 74795 74796 74797 74798 74799 74800 | pNew->pList = pList; idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC); exprAnalyze(pSrc, pWC, idxNew); pTerm = &pWC->a[idxTerm]; pWC->a[idxNew].iParent = idxTerm; pTerm->nChild = 1; }else{ sqlite3ExprListDelete(db, pList); } } or_not_possible: whereClauseClear(&sOr); } #endif /* SQLITE_OMIT_OR_OPTIMIZATION */ |
︙ | ︙ | |||
73983 73984 73985 73986 73987 73988 73989 73990 73991 73992 73993 73994 73995 73996 | struct SrcList_item *pSrc, /* The FROM clause term to search */ Bitmask notReady, /* Mask of cursors that are not available */ ExprList *pOrderBy, /* The order by clause */ int orderByUsable, /* True if we can potential sort */ sqlite3_index_info **ppIdxInfo /* Index information passed to xBestIndex */ ){ Table *pTab = pSrc->pTab; sqlite3_index_info *pIdxInfo; struct sqlite3_index_constraint *pIdxCons; struct sqlite3_index_orderby *pIdxOrderBy; struct sqlite3_index_constraint_usage *pUsage; WhereTerm *pTerm; int i, j; int nOrderBy; | > | 75155 75156 75157 75158 75159 75160 75161 75162 75163 75164 75165 75166 75167 75168 75169 | struct SrcList_item *pSrc, /* The FROM clause term to search */ Bitmask notReady, /* Mask of cursors that are not available */ ExprList *pOrderBy, /* The order by clause */ int orderByUsable, /* True if we can potential sort */ sqlite3_index_info **ppIdxInfo /* Index information passed to xBestIndex */ ){ Table *pTab = pSrc->pTab; sqlite3_vtab *pVtab = pTab->pVtab; sqlite3_index_info *pIdxInfo; struct sqlite3_index_constraint *pIdxCons; struct sqlite3_index_orderby *pIdxOrderBy; struct sqlite3_index_constraint_usage *pUsage; WhereTerm *pTerm; int i, j; int nOrderBy; |
︙ | ︙ | |||
74094 74095 74096 74097 74098 74099 74100 | */ /* The module name must be defined. Also, by this point there must ** be a pointer to an sqlite3_vtab structure. Otherwise ** sqlite3ViewGetColumnNames() would have picked up the error. */ assert( pTab->azModuleArg && pTab->azModuleArg[0] ); | | | 75267 75268 75269 75270 75271 75272 75273 75274 75275 75276 75277 75278 75279 75280 75281 | */ /* The module name must be defined. Also, by this point there must ** be a pointer to an sqlite3_vtab structure. Otherwise ** sqlite3ViewGetColumnNames() would have picked up the error. */ assert( pTab->azModuleArg && pTab->azModuleArg[0] ); assert( pVtab ); #if 0 if( pTab->pVtab==0 ){ sqlite3ErrorMsg(pParse, "undefined module %s for table %s", pTab->azModuleArg[0], pTab->zName); return 0.0; } #endif |
︙ | ︙ | |||
74147 74148 74149 74150 74151 74152 74153 | if( pIdxInfo->nOrderBy && !orderByUsable ){ *(int*)&pIdxInfo->nOrderBy = 0; } (void)sqlite3SafetyOff(pParse->db); WHERETRACE(("xBestIndex for %s\n", pTab->zName)); TRACE_IDX_INPUTS(pIdxInfo); | | > > > > > > > > > > > > < < < < < < < < | 75320 75321 75322 75323 75324 75325 75326 75327 75328 75329 75330 75331 75332 75333 75334 75335 75336 75337 75338 75339 75340 75341 75342 75343 75344 75345 75346 75347 75348 75349 75350 75351 75352 75353 75354 75355 75356 75357 75358 | if( pIdxInfo->nOrderBy && !orderByUsable ){ *(int*)&pIdxInfo->nOrderBy = 0; } (void)sqlite3SafetyOff(pParse->db); WHERETRACE(("xBestIndex for %s\n", pTab->zName)); TRACE_IDX_INPUTS(pIdxInfo); rc = pVtab->pModule->xBestIndex(pVtab, pIdxInfo); TRACE_IDX_OUTPUTS(pIdxInfo); (void)sqlite3SafetyOn(pParse->db); if( rc!=SQLITE_OK ){ if( rc==SQLITE_NOMEM ){ pParse->db->mallocFailed = 1; }else if( !pVtab->zErrMsg ){ sqlite3ErrorMsg(pParse, "%s", sqlite3ErrStr(rc)); }else{ sqlite3ErrorMsg(pParse, "%s", pVtab->zErrMsg); } } sqlite3DbFree(pParse->db, pVtab->zErrMsg); pVtab->zErrMsg = 0; for(i=0; i<pIdxInfo->nConstraint; i++){ if( !pIdxInfo->aConstraint[i].usable && pUsage[i].argvIndex>0 ){ sqlite3ErrorMsg(pParse, "table %s: xBestIndex returned an invalid plan", pTab->zName); return 0.0; } } *(int*)&pIdxInfo->nOrderBy = nOrderBy; return pIdxInfo->estimatedCost; } #endif /* SQLITE_OMIT_VIRTUALTABLE */ /* ** Find the best index for accessing a particular table. Return a pointer ** to the index, flags that describe how the index should be used, the |
︙ | ︙ | |||
74633 74634 74635 74636 74637 74638 74639 74640 74641 74642 74643 | /* ** Free a WhereInfo structure */ static void whereInfoFree(WhereInfo *pWInfo){ if( pWInfo ){ int i; for(i=0; i<pWInfo->nLevel; i++){ sqlite3_index_info *pInfo = pWInfo->a[i].pIdxInfo; if( pInfo ){ assert( pInfo->needToFreeIdxStr==0 ); | > | | | 75810 75811 75812 75813 75814 75815 75816 75817 75818 75819 75820 75821 75822 75823 75824 75825 75826 75827 75828 75829 75830 75831 75832 | /* ** Free a WhereInfo structure */ static void whereInfoFree(WhereInfo *pWInfo){ if( pWInfo ){ int i; sqlite3 *db = pWInfo->pParse->db; for(i=0; i<pWInfo->nLevel; i++){ sqlite3_index_info *pInfo = pWInfo->a[i].pIdxInfo; if( pInfo ){ assert( pInfo->needToFreeIdxStr==0 ); sqlite3DbFree(db, pInfo); } } sqlite3DbFree(db, pWInfo); } } /* ** Generate the beginning of the loop used for WHERE clause processing. ** The return value is a pointer to an opaque structure that contains |
︙ | ︙ | |||
74973 74974 74975 74976 74977 74978 74979 | #ifndef SQLITE_OMIT_EXPLAIN if( pParse->explain==2 ){ char *zMsg; struct SrcList_item *pItem = &pTabList->a[pLevel->iFrom]; zMsg = sqlite3MPrintf(db, "TABLE %s", pItem->zName); if( pItem->zAlias ){ | | | | | | | 76151 76152 76153 76154 76155 76156 76157 76158 76159 76160 76161 76162 76163 76164 76165 76166 76167 76168 76169 76170 76171 76172 76173 76174 76175 76176 76177 76178 76179 76180 | #ifndef SQLITE_OMIT_EXPLAIN if( pParse->explain==2 ){ char *zMsg; struct SrcList_item *pItem = &pTabList->a[pLevel->iFrom]; zMsg = sqlite3MPrintf(db, "TABLE %s", pItem->zName); if( pItem->zAlias ){ zMsg = sqlite3MAppendf(db, zMsg, "%s AS %s", zMsg, pItem->zAlias); } if( (pIx = pLevel->pIdx)!=0 ){ zMsg = sqlite3MAppendf(db, zMsg, "%s WITH INDEX %s", zMsg, pIx->zName); }else if( pLevel->flags & (WHERE_ROWID_EQ|WHERE_ROWID_RANGE) ){ zMsg = sqlite3MAppendf(db, zMsg, "%s USING PRIMARY KEY", zMsg); } #ifndef SQLITE_OMIT_VIRTUALTABLE else if( pLevel->pBestIdx ){ sqlite3_index_info *pBestIdx = pLevel->pBestIdx; zMsg = sqlite3MAppendf(db, zMsg, "%s VIRTUAL TABLE INDEX %d:%s", zMsg, pBestIdx->idxNum, pBestIdx->idxStr); } #endif if( pLevel->flags & WHERE_ORDERBY ){ zMsg = sqlite3MAppendf(db, zMsg, "%s ORDER BY", zMsg); } sqlite3VdbeAddOp4(v, OP_Explain, i, pLevel->iFrom, 0, zMsg, P4_DYNAMIC); } #endif /* SQLITE_OMIT_EXPLAIN */ pTabItem = &pTabList->a[pLevel->iFrom]; pTab = pTabItem->pTab; iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); |
︙ | ︙ | |||
75504 75505 75506 75507 75508 75509 75510 | } /* ** Generate the end of the WHERE loop. See comments on ** sqlite3WhereBegin() for additional information. */ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ | | > > | | | 76682 76683 76684 76685 76686 76687 76688 76689 76690 76691 76692 76693 76694 76695 76696 76697 76698 76699 76700 76701 76702 76703 76704 76705 76706 76707 76708 76709 76710 76711 76712 76713 76714 76715 76716 76717 76718 76719 76720 76721 | } /* ** Generate the end of the WHERE loop. See comments on ** sqlite3WhereBegin() for additional information. */ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ Parse *pParse = pWInfo->pParse; Vdbe *v = pParse->pVdbe; int i; WhereLevel *pLevel; SrcList *pTabList = pWInfo->pTabList; sqlite3 *db = pParse->db; /* Generate loop termination code. */ sqlite3ExprClearColumnCache(pParse, -1); for(i=pTabList->nSrc-1; i>=0; i--){ pLevel = &pWInfo->a[i]; sqlite3VdbeResolveLabel(v, pLevel->cont); if( pLevel->op!=OP_Noop ){ sqlite3VdbeAddOp2(v, pLevel->op, pLevel->p1, pLevel->p2); } if( pLevel->nIn ){ struct InLoop *pIn; int j; sqlite3VdbeResolveLabel(v, pLevel->nxt); for(j=pLevel->nIn, pIn=&pLevel->aInLoop[j-1]; j>0; j--, pIn--){ sqlite3VdbeJumpHere(v, pIn->topAddr+1); sqlite3VdbeAddOp2(v, OP_Next, pIn->iCur, pIn->topAddr); sqlite3VdbeJumpHere(v, pIn->topAddr-1); } sqlite3DbFree(db, pLevel->aInLoop); } sqlite3VdbeResolveLabel(v, pLevel->brk); if( pLevel->iLeftJoin ){ int addr; addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor); if( pLevel->iIdxCur>=0 ){ |
︙ | ︙ | |||
76366 76367 76368 76369 76370 76371 76372 | ** (In other words, the "major" token.) ** ** + The semantic value stored at this level of the stack. This is ** the information used by the action routines in the grammar. ** It is sometimes called the "minor" token. */ struct yyStackEntry { | | | | | | > > > | 77546 77547 77548 77549 77550 77551 77552 77553 77554 77555 77556 77557 77558 77559 77560 77561 77562 77563 77564 77565 77566 77567 77568 77569 77570 77571 77572 77573 77574 | ** (In other words, the "major" token.) ** ** + The semantic value stored at this level of the stack. This is ** the information used by the action routines in the grammar. ** It is sometimes called the "minor" token. */ struct yyStackEntry { YYACTIONTYPE stateno; /* The state-number */ YYCODETYPE major; /* The major token value. This is the code ** number for the token at this stack level */ YYMINORTYPE minor; /* The user-supplied minor token value. This ** is the value of the token */ }; typedef struct yyStackEntry yyStackEntry; /* The state of the parser is completely contained in an instance of ** the following structure */ struct yyParser { int yyidx; /* Index of top element in stack */ #ifdef YYTRACKMAXSTACKDEPTH int yyidxMax; /* Maximum value of yyidx */ #endif int yyerrcnt; /* Shifts left before out of the error */ sqlite3ParserARG_SDECL /* A place to hold %extra_argument */ #if YYSTACKDEPTH<=0 int yystksz; /* Current side of the stack */ yyStackEntry *yystack; /* The parser's stack */ #else yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ |
︙ | ︙ | |||
76850 76851 76852 76853 76854 76855 76856 76857 76858 76859 76860 76861 76862 76863 76864 76865 76866 76867 76868 | ** to sqlite3Parser and sqlite3ParserFree. */ SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(size_t)){ yyParser *pParser; pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); if( pParser ){ pParser->yyidx = -1; #if YYSTACKDEPTH<=0 yyGrowStack(pParser); #endif } return pParser; } /* The following function deletes the value associated with a ** symbol. The symbol can be either a terminal or nonterminal. ** "yymajor" is the symbol code, and "yypminor" is a pointer to ** the value. */ | > > > | > > > > > | | | | | | | | 78033 78034 78035 78036 78037 78038 78039 78040 78041 78042 78043 78044 78045 78046 78047 78048 78049 78050 78051 78052 78053 78054 78055 78056 78057 78058 78059 78060 78061 78062 78063 78064 78065 78066 78067 78068 78069 78070 78071 78072 78073 78074 78075 78076 78077 78078 78079 78080 78081 78082 78083 78084 78085 78086 78087 78088 78089 78090 78091 78092 78093 78094 78095 78096 78097 78098 78099 78100 78101 78102 78103 78104 78105 78106 78107 78108 78109 78110 78111 78112 78113 78114 78115 78116 78117 78118 78119 78120 78121 78122 78123 78124 78125 78126 78127 78128 78129 78130 78131 78132 78133 78134 78135 78136 78137 78138 78139 78140 | ** to sqlite3Parser and sqlite3ParserFree. */ SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(size_t)){ yyParser *pParser; pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); if( pParser ){ pParser->yyidx = -1; #ifdef YYTRACKMAXSTACKDEPTH pParser->yyidxMax = 0; #endif #if YYSTACKDEPTH<=0 yyGrowStack(pParser); #endif } return pParser; } /* The following function deletes the value associated with a ** symbol. The symbol can be either a terminal or nonterminal. ** "yymajor" is the symbol code, and "yypminor" is a pointer to ** the value. */ static void yy_destructor( yyParser *yypParser, /* The parser */ YYCODETYPE yymajor, /* Type code for object to destroy */ YYMINORTYPE *yypminor /* The object to be destroyed */ ){ sqlite3ParserARG_FETCH; switch( yymajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen ** when the symbol is popped from the stack during a ** reduce or during error processing or when a parser is ** being destroyed before it is finished parsing. ** ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are not used ** inside the C code. */ case 155: /* select */ case 189: /* oneselect */ case 206: /* seltablist_paren */ { sqlite3SelectDelete(pParse->db, (yypminor->yy219)); } break; case 169: /* term */ case 170: /* expr */ case 194: /* where_opt */ case 196: /* having_opt */ case 204: /* on_opt */ case 210: /* sortitem */ case 218: /* escape */ case 221: /* case_operand */ case 223: /* case_else */ case 235: /* when_clause */ case 238: /* key_opt */ { sqlite3ExprDelete(pParse->db, (yypminor->yy172)); } break; case 174: /* idxlist_opt */ case 182: /* idxlist */ case 192: /* selcollist */ case 195: /* groupby_opt */ case 197: /* orderby_opt */ case 199: /* sclp */ case 209: /* sortlist */ case 211: /* nexprlist */ case 212: /* setlist */ case 215: /* itemlist */ case 216: /* exprlist */ case 222: /* case_exprlist */ { sqlite3ExprListDelete(pParse->db, (yypminor->yy174)); } break; case 188: /* fullname */ case 193: /* from */ case 201: /* seltablist */ case 202: /* stl_prefix */ { sqlite3SrcListDelete(pParse->db, (yypminor->yy373)); } break; case 205: /* using_opt */ case 208: /* inscollist */ case 214: /* inscollist_opt */ { sqlite3IdListDelete(pParse->db, (yypminor->yy432)); } break; case 231: /* trigger_cmd_list */ case 236: /* trigger_cmd */ { sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy243)); } break; case 233: /* trigger_event */ { sqlite3IdListDelete(pParse->db, (yypminor->yy370).b); } break; default: break; /* If no destructor action specified: do nothing */ } } /* |
︙ | ︙ | |||
76963 76964 76965 76966 76967 76968 76969 | if( yyTraceFILE && pParser->yyidx>=0 ){ fprintf(yyTraceFILE,"%sPopping %s\n", yyTracePrompt, yyTokenName[yytos->major]); } #endif yymajor = yytos->major; | | | 78154 78155 78156 78157 78158 78159 78160 78161 78162 78163 78164 78165 78166 78167 78168 | if( yyTraceFILE && pParser->yyidx>=0 ){ fprintf(yyTraceFILE,"%sPopping %s\n", yyTracePrompt, yyTokenName[yytos->major]); } #endif yymajor = yytos->major; yy_destructor(pParser, yymajor, &yytos->minor); pParser->yyidx--; return yymajor; } /* ** Deallocate and destroy a parser. Destructors are all called for ** all stack elements before shutting the parser down. |
︙ | ︙ | |||
76993 76994 76995 76996 76997 76998 76999 77000 77001 77002 77003 77004 77005 77006 | while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); #if YYSTACKDEPTH<=0 free(pParser->yystack); #endif (*freeProc)((void*)pParser); } /* ** Find the appropriate action for a parser given the terminal ** look-ahead token iLookAhead. ** ** If the look-ahead token is YYNOCODE, then check to see if the action is ** independent of the look-ahead. If it is, return the action, otherwise ** return YY_NO_ACTION. | > > > > > > > > > > | 78184 78185 78186 78187 78188 78189 78190 78191 78192 78193 78194 78195 78196 78197 78198 78199 78200 78201 78202 78203 78204 78205 78206 78207 | while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); #if YYSTACKDEPTH<=0 free(pParser->yystack); #endif (*freeProc)((void*)pParser); } /* ** Return the peak depth of the stack for a parser. */ #ifdef YYTRACKMAXSTACKDEPTH SQLITE_PRIVATE int sqlite3ParserStackPeak(void *p){ yyParser *pParser = (yyParser*)p; return pParser->yyidxMax; } #endif /* ** Find the appropriate action for a parser given the terminal ** look-ahead token iLookAhead. ** ** If the look-ahead token is YYNOCODE, then check to see if the action is ** independent of the look-ahead. If it is, return the action, otherwise ** return YY_NO_ACTION. |
︙ | ︙ | |||
77115 77116 77117 77118 77119 77120 77121 77122 77123 77124 77125 77126 77127 77128 | yyParser *yypParser, /* The parser to be shifted */ int yyNewState, /* The new state to shift in */ int yyMajor, /* The major token to shift in */ YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */ ){ yyStackEntry *yytos; yypParser->yyidx++; #if YYSTACKDEPTH>0 if( yypParser->yyidx>=YYSTACKDEPTH ){ yyStackOverflow(yypParser, yypMinor); return; } #else if( yypParser->yyidx>=yypParser->yystksz ){ | > > > > > | 78316 78317 78318 78319 78320 78321 78322 78323 78324 78325 78326 78327 78328 78329 78330 78331 78332 78333 78334 | yyParser *yypParser, /* The parser to be shifted */ int yyNewState, /* The new state to shift in */ int yyMajor, /* The major token to shift in */ YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */ ){ yyStackEntry *yytos; yypParser->yyidx++; #ifdef YYTRACKMAXSTACKDEPTH if( yypParser->yyidx>yypParser->yyidxMax ){ yypParser->yyidxMax = yypParser->yyidx; } #endif #if YYSTACKDEPTH>0 if( yypParser->yyidx>=YYSTACKDEPTH ){ yyStackOverflow(yypParser, yypMinor); return; } #else if( yypParser->yyidx>=yypParser->yystksz ){ |
︙ | ︙ | |||
77625 77626 77627 77628 77629 77630 77631 | { sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0); } break; case 27: /* create_table_args ::= AS select */ { sqlite3EndTable(pParse,0,0,yymsp[0].minor.yy219); | | | 78831 78832 78833 78834 78835 78836 78837 78838 78839 78840 78841 78842 78843 78844 78845 | { sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0); } break; case 27: /* create_table_args ::= AS select */ { sqlite3EndTable(pParse,0,0,yymsp[0].minor.yy219); sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy219); } break; case 30: /* column ::= columnid type carglist */ { yygotominor.yy0.z = yymsp[-2].minor.yy0.z; yygotominor.yy0.n = (pParse->sLastToken.z-yymsp[-2].minor.yy0.z) + pParse->sLastToken.n; } |
︙ | ︙ | |||
77807 77808 77809 77810 77811 77812 77813 | sqlite3DropTable(pParse, yymsp[0].minor.yy373, 1, yymsp[-1].minor.yy46); } break; case 104: /* cmd ::= select */ { SelectDest dest = {SRT_Callback, 0, 0, 0, 0}; sqlite3Select(pParse, yymsp[0].minor.yy219, &dest, 0, 0, 0); | | | | 79013 79014 79015 79016 79017 79018 79019 79020 79021 79022 79023 79024 79025 79026 79027 79028 79029 79030 79031 79032 79033 79034 79035 79036 79037 79038 79039 79040 | sqlite3DropTable(pParse, yymsp[0].minor.yy373, 1, yymsp[-1].minor.yy46); } break; case 104: /* cmd ::= select */ { SelectDest dest = {SRT_Callback, 0, 0, 0, 0}; sqlite3Select(pParse, yymsp[0].minor.yy219, &dest, 0, 0, 0); sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy219); } break; case 105: /* select ::= oneselect */ case 128: /* seltablist_paren ::= select */ {yygotominor.yy219 = yymsp[0].minor.yy219;} break; case 106: /* select ::= select multiselect_op oneselect */ { if( yymsp[0].minor.yy219 ){ yymsp[0].minor.yy219->op = yymsp[-1].minor.yy46; yymsp[0].minor.yy219->pPrior = yymsp[-2].minor.yy219; }else{ sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy219); } yygotominor.yy219 = yymsp[0].minor.yy219; } break; case 108: /* multiselect_op ::= UNION ALL */ {yygotominor.yy46 = TK_ALL;} break; |
︙ | ︙ | |||
77857 77858 77859 77860 77861 77862 77863 | { Expr *p = sqlite3PExpr(pParse, TK_ALL, 0, 0, 0); yygotominor.yy174 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy174, p, 0); } break; case 118: /* selcollist ::= sclp nm DOT STAR */ { | | | 79063 79064 79065 79066 79067 79068 79069 79070 79071 79072 79073 79074 79075 79076 79077 | { Expr *p = sqlite3PExpr(pParse, TK_ALL, 0, 0, 0); yygotominor.yy174 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy174, p, 0); } break; case 118: /* selcollist ::= sclp nm DOT STAR */ { Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0); Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0); yygotominor.yy174 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy174, pDot, 0); } break; case 121: /* as ::= */ {yygotominor.yy0.n = 0;} |
︙ | ︙ | |||
78179 78180 78181 78182 78183 78184 78185 | { ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy172, 0); pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy172, 0); yygotominor.yy172 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy172, 0, 0); if( yygotominor.yy172 ){ yygotominor.yy172->pList = pList; }else{ | | | | | | | | | 79385 79386 79387 79388 79389 79390 79391 79392 79393 79394 79395 79396 79397 79398 79399 79400 79401 79402 79403 79404 79405 79406 79407 79408 79409 79410 79411 79412 79413 79414 79415 79416 79417 79418 79419 79420 79421 79422 79423 79424 79425 79426 79427 79428 79429 79430 79431 79432 79433 79434 79435 79436 79437 79438 79439 79440 79441 79442 79443 79444 79445 79446 79447 79448 79449 79450 79451 79452 79453 79454 79455 79456 79457 79458 79459 79460 79461 79462 79463 79464 79465 79466 79467 79468 79469 79470 79471 79472 79473 79474 79475 79476 | { ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy172, 0); pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy172, 0); yygotominor.yy172 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy172, 0, 0); if( yygotominor.yy172 ){ yygotominor.yy172->pList = pList; }else{ sqlite3ExprListDelete(pParse->db, pList); } if( yymsp[-3].minor.yy46 ) yygotominor.yy172 = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy172, 0, 0); sqlite3ExprSpan(yygotominor.yy172,&yymsp[-4].minor.yy172->span,&yymsp[0].minor.yy172->span); } break; case 218: /* expr ::= expr in_op LP exprlist RP */ { yygotominor.yy172 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy172, 0, 0); if( yygotominor.yy172 ){ yygotominor.yy172->pList = yymsp[-1].minor.yy174; sqlite3ExprSetHeight(pParse, yygotominor.yy172); }else{ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy174); } if( yymsp[-3].minor.yy46 ) yygotominor.yy172 = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy172, 0, 0); sqlite3ExprSpan(yygotominor.yy172,&yymsp[-4].minor.yy172->span,&yymsp[0].minor.yy0); } break; case 219: /* expr ::= LP select RP */ { yygotominor.yy172 = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0); if( yygotominor.yy172 ){ yygotominor.yy172->pSelect = yymsp[-1].minor.yy219; sqlite3ExprSetHeight(pParse, yygotominor.yy172); }else{ sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy219); } sqlite3ExprSpan(yygotominor.yy172,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); } break; case 220: /* expr ::= expr in_op LP select RP */ { yygotominor.yy172 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy172, 0, 0); if( yygotominor.yy172 ){ yygotominor.yy172->pSelect = yymsp[-1].minor.yy219; sqlite3ExprSetHeight(pParse, yygotominor.yy172); }else{ sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy219); } if( yymsp[-3].minor.yy46 ) yygotominor.yy172 = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy172, 0, 0); sqlite3ExprSpan(yygotominor.yy172,&yymsp[-4].minor.yy172->span,&yymsp[0].minor.yy0); } break; case 221: /* expr ::= expr in_op nm dbnm */ { SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); yygotominor.yy172 = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy172, 0, 0); if( yygotominor.yy172 ){ yygotominor.yy172->pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); sqlite3ExprSetHeight(pParse, yygotominor.yy172); }else{ sqlite3SrcListDelete(pParse->db, pSrc); } if( yymsp[-2].minor.yy46 ) yygotominor.yy172 = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy172, 0, 0); sqlite3ExprSpan(yygotominor.yy172,&yymsp[-3].minor.yy172->span,yymsp[0].minor.yy0.z?&yymsp[0].minor.yy0:&yymsp[-1].minor.yy0); } break; case 222: /* expr ::= EXISTS LP select RP */ { Expr *p = yygotominor.yy172 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0); if( p ){ p->pSelect = yymsp[-1].minor.yy219; sqlite3ExprSpan(p,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); sqlite3ExprSetHeight(pParse, yygotominor.yy172); }else{ sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy219); } } break; case 223: /* expr ::= CASE case_operand case_exprlist case_else END */ { yygotominor.yy172 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy172, yymsp[-1].minor.yy172, 0); if( yygotominor.yy172 ){ yygotominor.yy172->pList = yymsp[-2].minor.yy174; sqlite3ExprSetHeight(pParse, yygotominor.yy172); }else{ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy174); } sqlite3ExprSpan(yygotominor.yy172, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0); } break; case 224: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ { yygotominor.yy174 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy174, yymsp[-2].minor.yy172, 0); |
︙ | ︙ | |||
78681 78682 78683 78684 78685 78686 78687 | if( yymx==YYERRORSYMBOL || yyerrorhit ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sDiscard input token %s\n", yyTracePrompt,yyTokenName[yymajor]); } #endif | | | | 79887 79888 79889 79890 79891 79892 79893 79894 79895 79896 79897 79898 79899 79900 79901 79902 79903 79904 79905 79906 79907 79908 79909 79910 79911 79912 79913 79914 | if( yymx==YYERRORSYMBOL || yyerrorhit ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sDiscard input token %s\n", yyTracePrompt,yyTokenName[yymajor]); } #endif yy_destructor(yypParser, yymajor,&yyminorunion); yymajor = YYNOCODE; }else{ while( yypParser->yyidx >= 0 && yymx != YYERRORSYMBOL && (yyact = yy_find_reduce_action( yypParser->yystack[yypParser->yyidx].stateno, YYERRORSYMBOL)) >= YYNSTATE ){ yy_pop_parser_stack(yypParser); } if( yypParser->yyidx < 0 || yymajor==0 ){ yy_destructor(yypParser,yymajor,&yyminorunion); yy_parse_failed(yypParser); yymajor = YYNOCODE; }else if( yymx!=YYERRORSYMBOL ){ YYMINORTYPE u2; u2.YYERRSYMDT = 0; yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); } |
︙ | ︙ | |||
78719 78720 78721 78722 78723 78724 78725 | ** As before, subsequent error messages are suppressed until ** three input tokens have been successfully shifted. */ if( yypParser->yyerrcnt<=0 ){ yy_syntax_error(yypParser,yymajor,yyminorunion); } yypParser->yyerrcnt = 3; | | | 79925 79926 79927 79928 79929 79930 79931 79932 79933 79934 79935 79936 79937 79938 79939 | ** As before, subsequent error messages are suppressed until ** three input tokens have been successfully shifted. */ if( yypParser->yyerrcnt<=0 ){ yy_syntax_error(yypParser,yymajor,yyminorunion); } yypParser->yyerrcnt = 3; yy_destructor(yypParser,yymajor,&yyminorunion); if( yyendofinput ){ yy_parse_failed(yypParser); } yymajor = YYNOCODE; #endif } }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); |
︙ | ︙ | |||
78749 78750 78751 78752 78753 78754 78755 | ************************************************************************* ** An tokenizer for SQL ** ** This file contains C code that splits an SQL input string up into ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** | | | 79955 79956 79957 79958 79959 79960 79961 79962 79963 79964 79965 79966 79967 79968 79969 | ************************************************************************* ** An tokenizer for SQL ** ** This file contains C code that splits an SQL input string up into ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ /* ** The charMap() macro maps alphabetic characters into their ** lower-case ASCII equivalent. On ASCII machines, this is just ** an upper-to-lower case map. On EBCDIC machines we also need ** to adjust the encoding. Only alphabetic characters and underscores |
︙ | ︙ | |||
78802 78803 78804 78805 78806 78807 78808 | */ /************** Include keywordhash.h in the middle of tokenize.c ************/ /************** Begin file keywordhash.h *************************************/ /***** This file contains automatically generated code ****** ** ** The code in this file has been automatically generated by ** | | | 80008 80009 80010 80011 80012 80013 80014 80015 80016 80017 80018 80019 80020 80021 80022 | */ /************** Include keywordhash.h in the middle of tokenize.c ************/ /************** Begin file keywordhash.h *************************************/ /***** This file contains automatically generated code ****** ** ** The code in this file has been automatically generated by ** ** $Header: /cvsroot/sqlite-dotnet2/SQLite.NET/SQLite.Interop/src/sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ ** ** The code in this file implements a function that determines whether ** or not a given identifier is really an SQL keyword. The same thing ** might be implemented more directly using a hand-written hash table. ** But by using this automatically generated code, the size of the code ** is substantially reduced. This is important for embedded applications ** on platforms with limited memory. |
︙ | ︙ | |||
79274 79275 79276 79277 79278 79279 79280 | pParse->rc = SQLITE_INTERRUPT; sqlite3SetString(pzErrMsg, db, "interrupt"); goto abort_parse; } break; } case TK_ILLEGAL: { | | | 80480 80481 80482 80483 80484 80485 80486 80487 80488 80489 80490 80491 80492 80493 80494 | pParse->rc = SQLITE_INTERRUPT; sqlite3SetString(pzErrMsg, db, "interrupt"); goto abort_parse; } break; } case TK_ILLEGAL: { sqlite3DbFree(db, *pzErrMsg); *pzErrMsg = sqlite3MPrintf(db, "unrecognized token: \"%T\"", &pParse->sLastToken); nErr++; goto abort_parse; } case TK_SEMI: { pParse->zTail = &zSql[i]; |
︙ | ︙ | |||
79302 79303 79304 79305 79306 79307 79308 79309 79310 79311 79312 79313 79314 79315 79316 79317 79318 79319 | if( zSql[i]==0 && nErr==0 && pParse->rc==SQLITE_OK ){ if( lastTokenParsed!=TK_SEMI ){ sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse); pParse->zTail = &zSql[i]; } sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse); } sqlite3ParserFree(pEngine, sqlite3_free); if( db->mallocFailed ){ pParse->rc = SQLITE_NOMEM; } if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){ sqlite3SetString(&pParse->zErrMsg, db, "%s", sqlite3ErrStr(pParse->rc)); } if( pParse->zErrMsg ){ if( *pzErrMsg==0 ){ *pzErrMsg = pParse->zErrMsg; }else{ | > > > > > | | | | | | 80508 80509 80510 80511 80512 80513 80514 80515 80516 80517 80518 80519 80520 80521 80522 80523 80524 80525 80526 80527 80528 80529 80530 80531 80532 80533 80534 80535 80536 80537 80538 80539 80540 80541 80542 80543 80544 80545 80546 80547 80548 80549 80550 80551 80552 80553 80554 80555 80556 80557 80558 80559 80560 80561 80562 80563 80564 80565 80566 80567 | if( zSql[i]==0 && nErr==0 && pParse->rc==SQLITE_OK ){ if( lastTokenParsed!=TK_SEMI ){ sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse); pParse->zTail = &zSql[i]; } sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse); } #ifdef YYTRACKMAXSTACKDEPTH sqlite3StatusSet(SQLITE_STATUS_PARSER_STACK, sqlite3ParserStackPeak(pEngine) ); #endif /* YYDEBUG */ sqlite3ParserFree(pEngine, sqlite3_free); if( db->mallocFailed ){ pParse->rc = SQLITE_NOMEM; } if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){ sqlite3SetString(&pParse->zErrMsg, db, "%s", sqlite3ErrStr(pParse->rc)); } if( pParse->zErrMsg ){ if( *pzErrMsg==0 ){ *pzErrMsg = pParse->zErrMsg; }else{ sqlite3DbFree(db, pParse->zErrMsg); } pParse->zErrMsg = 0; nErr++; } if( pParse->pVdbe && pParse->nErr>0 && pParse->nested==0 ){ sqlite3VdbeDelete(pParse->pVdbe); pParse->pVdbe = 0; } #ifndef SQLITE_OMIT_SHARED_CACHE if( pParse->nested==0 ){ sqlite3DbFree(db, pParse->aTableLock); pParse->aTableLock = 0; pParse->nTableLock = 0; } #endif #ifndef SQLITE_OMIT_VIRTUALTABLE sqlite3DbFree(db, pParse->apVtabLock); #endif if( !IN_DECLARE_VTAB ){ /* If the pParse->declareVtab flag is set, do not delete any table ** structure built up in pParse->pNewTable. The calling code (see vtab.c) ** will take responsibility for freeing the Table structure. */ sqlite3DeleteTable(pParse->pNewTable); } sqlite3DeleteTrigger(db, pParse->pNewTrigger); sqlite3DbFree(db, pParse->apVarExpr); if( nErr>0 && (pParse->rc==SQLITE_OK || pParse->rc==SQLITE_DONE) ){ pParse->rc = SQLITE_ERROR; } return nErr; } /************** End of tokenize.c ********************************************/ |
︙ | ︙ | |||
79369 79370 79371 79372 79373 79374 79375 | ** An tokenizer for SQL ** ** This file contains C code that implements the sqlite3_complete() API. ** This code used to be part of the tokenizer.c source file. But by ** separating it out, the code will be automatically omitted from ** static links that do not use it. ** | | | 80580 80581 80582 80583 80584 80585 80586 80587 80588 80589 80590 80591 80592 80593 80594 | ** An tokenizer for SQL ** ** This file contains C code that implements the sqlite3_complete() API. ** This code used to be part of the tokenizer.c source file. But by ** separating it out, the code will be automatically omitted from ** static links that do not use it. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifndef SQLITE_OMIT_COMPLETE /* ** This is defined in tokenize.c. We just have to import the definition. */ #ifndef SQLITE_AMALGAMATION |
︙ | ︙ | |||
79646 79647 79648 79649 79650 79651 79652 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** | | | 80857 80858 80859 80860 80861 80862 80863 80864 80865 80866 80867 80868 80869 80870 80871 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #ifdef SQLITE_ENABLE_FTS3 /************** Include fts3.h in the middle of main.c ***********************/ /************** Begin file fts3.h ********************************************/ /* ** 2006 Oct 10 |
︙ | ︙ | |||
79805 79806 79807 79808 79809 79810 79811 79812 79813 79814 79815 79816 79817 79818 | sqlite3StatusReset(); inProgress = 1; rc = sqlite3_os_init(); inProgress = 0; sqlite3Config.isInit = (rc==SQLITE_OK ? 1 : 0); sqlite3_mutex_leave(sqlite3Config.pInitMutex); } return rc; } /* ** Undo the effects of sqlite3_initialize(). Must not be called while ** there are outstanding database connections or memory allocations or ** while any part of SQLite is otherwise in use in any thread. This | > > > > > > > > > > > > > > | 81016 81017 81018 81019 81020 81021 81022 81023 81024 81025 81026 81027 81028 81029 81030 81031 81032 81033 81034 81035 81036 81037 81038 81039 81040 81041 81042 81043 | sqlite3StatusReset(); inProgress = 1; rc = sqlite3_os_init(); inProgress = 0; sqlite3Config.isInit = (rc==SQLITE_OK ? 1 : 0); sqlite3_mutex_leave(sqlite3Config.pInitMutex); } /* Check NaN support. */ #ifndef NDEBUG /* This section of code's only "output" is via assert() statements. */ if ( rc==SQLITE_OK ){ u64 x = (((u64)1)<<63)-1; double y; assert(sizeof(x)==8); assert(sizeof(x)==sizeof(y)); memcpy(&y, &x, 8); assert( sqlite3IsNaN(y) ); } #endif return rc; } /* ** Undo the effects of sqlite3_initialize(). Must not be called while ** there are outstanding database connections or memory allocations or ** while any part of SQLite is otherwise in use in any thread. This |
︙ | ︙ | |||
79941 79942 79943 79944 79945 79946 79947 79948 79949 79950 79951 79952 79953 79954 | sqlite3Config.m = *sqlite3MemGetMemsys5(); #endif } break; } #endif default: { rc = SQLITE_ERROR; break; } } va_end(ap); return rc; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 81166 81167 81168 81169 81170 81171 81172 81173 81174 81175 81176 81177 81178 81179 81180 81181 81182 81183 81184 81185 81186 81187 81188 81189 81190 81191 81192 81193 81194 81195 81196 81197 81198 81199 81200 81201 81202 81203 81204 81205 81206 81207 81208 81209 81210 81211 81212 81213 81214 81215 81216 81217 81218 81219 81220 81221 81222 81223 81224 81225 81226 81227 81228 81229 81230 81231 81232 81233 81234 81235 81236 81237 81238 81239 81240 81241 81242 81243 81244 81245 81246 81247 81248 81249 81250 81251 81252 81253 81254 81255 81256 81257 81258 81259 81260 81261 81262 81263 81264 81265 81266 81267 81268 | sqlite3Config.m = *sqlite3MemGetMemsys5(); #endif } break; } #endif #if defined(SQLITE_ENABLE_MEMSYS6) case SQLITE_CONFIG_CHUNKALLOC: { sqlite3Config.nSmall = va_arg(ap, int); sqlite3Config.m = *sqlite3MemGetMemsys6(); break; } #endif case SQLITE_CONFIG_LOOKASIDE: { sqlite3Config.szLookaside = va_arg(ap, int); sqlite3Config.nLookaside = va_arg(ap, int); break; } default: { rc = SQLITE_ERROR; break; } } va_end(ap); return rc; } /* ** Set up the lookaside buffers for a database connection. ** Return SQLITE_OK on success. ** If lookaside is already active, return SQLITE_BUSY. ** ** The sz parameter is the number of bytes in each lookaside slot. ** The cnt parameter is the number of slots. If pStart is NULL the ** space for the lookaside memory is obtained from sqlite3_malloc(). ** If pStart is not NULL then it is sz*cnt bytes of memory to use for ** the lookaside memory. */ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){ void *pStart; if( db->lookaside.nOut ){ return SQLITE_BUSY; } if( sz<0 ) sz = 0; if( cnt<0 ) cnt = 0; sz = (sz+7)&~7; if( pBuf==0 ){ sqlite3BeginBenignMalloc(); pStart = sqlite3Malloc( sz*cnt ); sqlite3EndBenignMalloc(); }else{ pStart = pBuf; } if( db->lookaside.bMalloced ){ sqlite3_free(db->lookaside.pStart); } db->lookaside.pStart = pStart; db->lookaside.pFree = 0; db->lookaside.sz = sz; db->lookaside.bMalloced = pBuf==0; if( pStart ){ int i; LookasideSlot *p; p = (LookasideSlot*)pStart; for(i=cnt-1; i>=0; i--){ p->pNext = db->lookaside.pFree; db->lookaside.pFree = p; p = (LookasideSlot*)&((u8*)p)[sz]; } db->lookaside.pEnd = p; db->lookaside.bEnabled = 1; }else{ db->lookaside.pEnd = 0; db->lookaside.bEnabled = 0; } return SQLITE_OK; } /* ** Configuration settings for an individual database connection */ SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){ va_list ap; int rc; va_start(ap, op); switch( op ){ case SQLITE_DBCONFIG_LOOKASIDE: { void *pBuf = va_arg(ap, void*); int sz = va_arg(ap, int); int cnt = va_arg(ap, int); rc = setupLookaside(db, pBuf, sz, cnt); break; } default: { rc = SQLITE_ERROR; break; } } va_end(ap); return rc; |
︙ | ︙ | |||
80099 80100 80101 80102 80103 80104 80105 | sqlite3ResetInternalSchema(db, 0); assert( db->nDb<=2 ); assert( db->aDb==db->aDbStatic ); for(i=sqliteHashFirst(&db->aFunc); i; i=sqliteHashNext(i)){ FuncDef *pFunc, *pNext; for(pFunc = (FuncDef*)sqliteHashData(i); pFunc; pFunc=pNext){ pNext = pFunc->pNext; | | | | | > > > | 81413 81414 81415 81416 81417 81418 81419 81420 81421 81422 81423 81424 81425 81426 81427 81428 81429 81430 81431 81432 81433 81434 81435 81436 81437 81438 81439 81440 81441 81442 81443 81444 81445 81446 81447 81448 81449 81450 81451 81452 81453 81454 81455 81456 81457 81458 81459 81460 81461 81462 81463 81464 81465 81466 81467 81468 81469 81470 81471 81472 81473 81474 | sqlite3ResetInternalSchema(db, 0); assert( db->nDb<=2 ); assert( db->aDb==db->aDbStatic ); for(i=sqliteHashFirst(&db->aFunc); i; i=sqliteHashNext(i)){ FuncDef *pFunc, *pNext; for(pFunc = (FuncDef*)sqliteHashData(i); pFunc; pFunc=pNext){ pNext = pFunc->pNext; sqlite3DbFree(db, pFunc); } } for(i=sqliteHashFirst(&db->aCollSeq); i; i=sqliteHashNext(i)){ CollSeq *pColl = (CollSeq *)sqliteHashData(i); /* Invoke any destructors registered for collation sequence user data. */ for(j=0; j<3; j++){ if( pColl[j].xDel ){ pColl[j].xDel(pColl[j].pUser); } } sqlite3DbFree(db, pColl); } sqlite3HashClear(&db->aCollSeq); #ifndef SQLITE_OMIT_VIRTUALTABLE for(i=sqliteHashFirst(&db->aModule); i; i=sqliteHashNext(i)){ Module *pMod = (Module *)sqliteHashData(i); if( pMod->xDestroy ){ pMod->xDestroy(pMod->pAux); } sqlite3DbFree(db, pMod); } sqlite3HashClear(&db->aModule); #endif sqlite3HashClear(&db->aFunc); sqlite3Error(db, SQLITE_OK, 0); /* Deallocates any cached error strings. */ if( db->pErr ){ sqlite3ValueFree(db->pErr); } sqlite3CloseExtensions(db); db->magic = SQLITE_MAGIC_ERROR; /* The temp-database schema is allocated differently from the other schema ** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()). ** So it needs to be freed here. Todo: Why not roll the temp schema into ** the same sqliteMalloc() as the one that allocates the database ** structure? */ sqlite3DbFree(db, db->aDb[1].pSchema); sqlite3_mutex_leave(db->mutex); db->magic = SQLITE_MAGIC_CLOSED; sqlite3_mutex_free(db->mutex); if( db->lookaside.bMalloced ){ sqlite3_free(db->lookaside.pStart); } sqlite3_free(db); return SQLITE_OK; } /* ** Rollback all database files. */ |
︙ | ︙ | |||
80473 80474 80475 80476 80477 80478 80479 | ){ int rc; char *zFunc8; sqlite3_mutex_enter(db->mutex); assert( !db->mallocFailed ); zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1); rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xFunc, xStep, xFinal); | | | 81790 81791 81792 81793 81794 81795 81796 81797 81798 81799 81800 81801 81802 81803 81804 | ){ int rc; char *zFunc8; sqlite3_mutex_enter(db->mutex); assert( !db->mallocFailed ); zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1); rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xFunc, xStep, xFinal); sqlite3DbFree(db, zFunc8); rc = sqlite3ApiExit(db, rc); sqlite3_mutex_leave(db->mutex); return rc; } #endif |
︙ | ︙ | |||
80978 80979 80980 80981 80982 80983 80984 80985 80986 80987 80988 80989 80990 80991 | } sqlite3_mutex_enter(db->mutex); db->errMask = 0xff; db->priorNewRowid = 0; db->nDb = 2; db->magic = SQLITE_MAGIC_BUSY; db->aDb = db->aDbStatic; assert( sizeof(db->aLimit)==sizeof(aHardLimit) ); memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit)); db->autoCommit = 1; db->nextAutovac = -1; db->nextPagesize = 0; db->flags |= SQLITE_ShortColNames #if SQLITE_DEFAULT_FILE_FORMAT<4 | > | 82295 82296 82297 82298 82299 82300 82301 82302 82303 82304 82305 82306 82307 82308 82309 | } sqlite3_mutex_enter(db->mutex); db->errMask = 0xff; db->priorNewRowid = 0; db->nDb = 2; db->magic = SQLITE_MAGIC_BUSY; db->aDb = db->aDbStatic; assert( sizeof(db->aLimit)==sizeof(aHardLimit) ); memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit)); db->autoCommit = 1; db->nextAutovac = -1; db->nextPagesize = 0; db->flags |= SQLITE_ShortColNames #if SQLITE_DEFAULT_FILE_FORMAT<4 |
︙ | ︙ | |||
81119 81120 81121 81122 81123 81124 81125 81126 81127 81128 81129 81130 81131 81132 | */ #ifdef SQLITE_DEFAULT_LOCKING_MODE db->dfltLockMode = SQLITE_DEFAULT_LOCKING_MODE; sqlite3PagerLockingMode(sqlite3BtreePager(db->aDb[0].pBt), SQLITE_DEFAULT_LOCKING_MODE); #endif opendb_out: if( db ){ assert( db->mutex!=0 || isThreadsafe==0 || sqlite3Config.bFullMutex==0 ); sqlite3_mutex_leave(db->mutex); } if( SQLITE_NOMEM==(rc = sqlite3_errcode(db)) ){ sqlite3_close(db); | > > > | 82437 82438 82439 82440 82441 82442 82443 82444 82445 82446 82447 82448 82449 82450 82451 82452 82453 | */ #ifdef SQLITE_DEFAULT_LOCKING_MODE db->dfltLockMode = SQLITE_DEFAULT_LOCKING_MODE; sqlite3PagerLockingMode(sqlite3BtreePager(db->aDb[0].pBt), SQLITE_DEFAULT_LOCKING_MODE); #endif /* Enable the lookaside-malloc subsystem */ setupLookaside(db, 0, sqlite3Config.szLookaside, sqlite3Config.nLookaside); opendb_out: if( db ){ assert( db->mutex!=0 || isThreadsafe==0 || sqlite3Config.bFullMutex==0 ); sqlite3_mutex_leave(db->mutex); } if( SQLITE_NOMEM==(rc = sqlite3_errcode(db)) ){ sqlite3_close(db); |
︙ | ︙ | |||
81246 81247 81248 81249 81250 81251 81252 | int rc = SQLITE_OK; char *zName8; sqlite3_mutex_enter(db->mutex); assert( !db->mallocFailed ); zName8 = sqlite3Utf16to8(db, zName, -1); if( zName8 ){ rc = createCollation(db, zName8, enc, pCtx, xCompare, 0); | | | 82567 82568 82569 82570 82571 82572 82573 82574 82575 82576 82577 82578 82579 82580 82581 | int rc = SQLITE_OK; char *zName8; sqlite3_mutex_enter(db->mutex); assert( !db->mallocFailed ); zName8 = sqlite3Utf16to8(db, zName, -1); if( zName8 ){ rc = createCollation(db, zName8, enc, pCtx, xCompare, 0); sqlite3DbFree(db, zName8); } rc = sqlite3ApiExit(db, rc); sqlite3_mutex_leave(db->mutex); return rc; } #endif /* SQLITE_OMIT_UTF16 */ |
︙ | ︙ | |||
81435 81436 81437 81438 81439 81440 81441 | if( pzDataType ) *pzDataType = zDataType; if( pzCollSeq ) *pzCollSeq = zCollSeq; if( pNotNull ) *pNotNull = notnull; if( pPrimaryKey ) *pPrimaryKey = primarykey; if( pAutoinc ) *pAutoinc = autoinc; if( SQLITE_OK==rc && !pTab ){ | | | | 82756 82757 82758 82759 82760 82761 82762 82763 82764 82765 82766 82767 82768 82769 82770 82771 82772 82773 82774 82775 82776 | if( pzDataType ) *pzDataType = zDataType; if( pzCollSeq ) *pzCollSeq = zCollSeq; if( pNotNull ) *pNotNull = notnull; if( pPrimaryKey ) *pPrimaryKey = primarykey; if( pAutoinc ) *pAutoinc = autoinc; if( SQLITE_OK==rc && !pTab ){ sqlite3DbFree(db, zErrMsg); zErrMsg = sqlite3MPrintf(db, "no such table column: %s.%s", zTableName, zColumnName); rc = SQLITE_ERROR; } sqlite3Error(db, rc, (zErrMsg?"%s":0), zErrMsg); sqlite3DbFree(db, zErrMsg); rc = sqlite3ApiExit(db, rc); sqlite3_mutex_leave(db->mutex); return rc; } #endif /* |
︙ | ︙ | |||
85943 85944 85945 85946 85947 85948 85949 | sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */ int idxNum, const char *idxStr, /* Which indexing scheme to use */ int argc, sqlite3_value **argv /* Arguments for the indexing scheme */ ){ fulltext_cursor *c = (fulltext_cursor *) pCursor; fulltext_vtab *v = cursor_vtab(c); int rc; | < > > > > > > > > > > > > > > > > > > > | | | | | < | > | | > > > > | | | 87264 87265 87266 87267 87268 87269 87270 87271 87272 87273 87274 87275 87276 87277 87278 87279 87280 87281 87282 87283 87284 87285 87286 87287 87288 87289 87290 87291 87292 87293 87294 87295 87296 87297 87298 87299 87300 87301 87302 87303 87304 87305 87306 87307 87308 87309 87310 87311 87312 87313 87314 | sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */ int idxNum, const char *idxStr, /* Which indexing scheme to use */ int argc, sqlite3_value **argv /* Arguments for the indexing scheme */ ){ fulltext_cursor *c = (fulltext_cursor *) pCursor; fulltext_vtab *v = cursor_vtab(c); int rc; FTSTRACE(("FTS3 Filter %p\n",pCursor)); /* If the cursor has a statement that was not prepared according to ** idxNum, clear it. I believe all calls to fulltextFilter with a ** given cursor will have the same idxNum , but in this case it's ** easy to be safe. */ if( c->pStmt && c->iCursorType!=idxNum ){ sqlite3_finalize(c->pStmt); c->pStmt = NULL; } /* Get a fresh statement appropriate to idxNum. */ /* TODO(shess): Add a prepared-statement cache in the vt structure. ** The cache must handle multiple open cursors. Easier to cache the ** statement variants at the vt to reduce malloc/realloc/free here. ** Or we could have a StringBuffer variant which allowed stack ** construction for small values. */ if( !c->pStmt ){ StringBuffer sb; initStringBuffer(&sb); append(&sb, "SELECT docid, "); appendList(&sb, v->nColumn, v->azContentColumn); append(&sb, " FROM %_content"); if( idxNum!=QUERY_GENERIC ) append(&sb, " WHERE docid = ?"); rc = sql_prepare(v->db, v->zDb, v->zName, &c->pStmt, stringBufferData(&sb)); stringBufferDestroy(&sb); if( rc!=SQLITE_OK ) return rc; c->iCursorType = idxNum; }else{ sqlite3_reset(c->pStmt); assert( c->iCursorType==idxNum ); } switch( idxNum ){ case QUERY_GENERIC: break; case QUERY_DOCID: rc = sqlite3_bind_int64(c->pStmt, 1, sqlite3_value_int64(argv[0])); if( rc!=SQLITE_OK ) return rc; |
︙ | ︙ | |||
90656 90657 90658 90659 90660 90661 90662 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code for implementations of the r-tree and r*-tree ** algorithms packaged as an SQLite virtual table module. ** | | | 91999 92000 92001 92002 92003 92004 92005 92006 92007 92008 92009 92010 92011 92012 92013 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code for implementations of the r-tree and r*-tree ** algorithms packaged as an SQLite virtual table module. ** ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ */ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE) /* ** This file contains an implementation of a couple of different variants ** of the r-tree algorithm. See the README file for further details. The |
︙ | ︙ | |||
93468 93469 93470 93471 93472 93473 93474 | return sqlite3RtreeInit(db); } #endif #endif /************** End of rtree.c ***********************************************/ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 94811 94812 94813 94814 94815 94816 94817 94818 94819 94820 94821 94822 94823 94824 94825 94826 94827 94828 94829 94830 94831 94832 94833 94834 94835 94836 94837 94838 94839 94840 94841 94842 94843 94844 94845 94846 94847 94848 94849 94850 94851 94852 94853 94854 94855 94856 94857 94858 94859 94860 94861 94862 94863 94864 94865 94866 94867 94868 94869 94870 94871 94872 94873 94874 94875 94876 94877 94878 94879 94880 94881 94882 94883 94884 94885 94886 94887 94888 94889 94890 94891 94892 94893 94894 94895 94896 94897 94898 94899 94900 94901 94902 94903 94904 94905 94906 94907 94908 94909 94910 94911 94912 94913 94914 94915 94916 94917 94918 94919 94920 94921 94922 94923 94924 94925 94926 94927 94928 94929 94930 94931 94932 94933 94934 94935 94936 94937 94938 94939 94940 94941 94942 94943 94944 94945 94946 94947 94948 94949 94950 94951 94952 94953 94954 94955 94956 94957 94958 94959 94960 94961 94962 94963 94964 94965 94966 94967 94968 94969 94970 94971 94972 94973 94974 94975 94976 94977 94978 94979 94980 94981 94982 94983 94984 94985 94986 94987 94988 94989 94990 94991 94992 94993 94994 94995 94996 94997 94998 94999 95000 95001 95002 95003 95004 95005 95006 95007 95008 95009 95010 95011 95012 95013 95014 95015 95016 95017 95018 95019 95020 95021 95022 95023 95024 95025 95026 95027 95028 95029 95030 95031 95032 95033 95034 95035 95036 95037 95038 95039 95040 95041 95042 95043 95044 95045 95046 95047 95048 95049 95050 95051 95052 95053 95054 95055 95056 95057 95058 95059 95060 95061 95062 95063 95064 95065 95066 95067 95068 95069 95070 95071 95072 95073 95074 95075 95076 95077 95078 95079 95080 95081 95082 95083 95084 95085 95086 95087 95088 95089 95090 95091 95092 95093 95094 95095 95096 95097 95098 95099 95100 95101 95102 95103 95104 95105 95106 95107 95108 95109 95110 95111 95112 95113 95114 95115 95116 95117 95118 95119 95120 95121 95122 95123 95124 95125 95126 95127 95128 95129 95130 95131 95132 95133 95134 95135 95136 95137 95138 95139 95140 95141 95142 95143 95144 95145 95146 95147 95148 95149 95150 95151 95152 95153 95154 95155 95156 95157 95158 95159 95160 95161 95162 95163 95164 95165 95166 95167 95168 95169 95170 95171 95172 95173 95174 95175 95176 95177 95178 95179 95180 95181 95182 95183 95184 95185 95186 95187 95188 95189 95190 95191 95192 95193 95194 95195 95196 95197 95198 95199 95200 95201 95202 95203 95204 95205 95206 95207 95208 95209 95210 95211 95212 95213 95214 95215 95216 95217 95218 95219 95220 95221 95222 95223 95224 95225 95226 95227 95228 95229 95230 95231 95232 95233 95234 95235 95236 95237 95238 95239 95240 95241 95242 95243 95244 95245 95246 95247 95248 95249 95250 95251 95252 95253 95254 95255 95256 95257 95258 95259 95260 95261 95262 95263 95264 95265 95266 95267 95268 95269 95270 95271 95272 95273 95274 95275 95276 95277 95278 95279 95280 95281 95282 95283 95284 95285 95286 95287 95288 95289 95290 95291 95292 95293 95294 95295 95296 95297 95298 95299 95300 95301 95302 95303 95304 95305 95306 95307 95308 95309 95310 95311 95312 95313 95314 95315 95316 95317 95318 | return sqlite3RtreeInit(db); } #endif #endif /************** End of rtree.c ***********************************************/ /************** Begin file icu.c *********************************************/ /* ** 2007 May 6 ** ** 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. ** ************************************************************************* ** $Id: sqlite3.c,v 1.9 2008/08/06 21:45:28 rmsimpson Exp $ ** ** This file implements an integration between the ICU library ** ("International Components for Unicode", an open-source library ** for handling unicode data) and SQLite. The integration uses ** ICU to provide the following to SQLite: ** ** * An implementation of the SQL regexp() function (and hence REGEXP ** operator) using the ICU uregex_XX() APIs. ** ** * Implementations of the SQL scalar upper() and lower() functions ** for case mapping. ** ** * Integration of ICU and SQLite collation seqences. ** ** * An implementation of the LIKE operator that uses ICU to ** provide case-independent matching. */ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU) /* Include ICU headers */ #include <unicode/utypes.h> #include <unicode/uregex.h> #include <unicode/ustring.h> #include <unicode/ucol.h> #ifndef SQLITE_CORE #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 #else #include "sqlite3.h" #endif /* ** Maximum length (in bytes) of the pattern in a LIKE or GLOB ** operator. */ #ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH # define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000 #endif /* ** Version of sqlite3_free() that is always a function, never a macro. */ static void xFree(void *p){ sqlite3_free(p); } /* ** Compare two UTF-8 strings for equality where the first string is ** a "LIKE" expression. Return true (1) if they are the same and ** false (0) if they are different. */ static int icuLikeCompare( const uint8_t *zPattern, /* LIKE pattern */ const uint8_t *zString, /* The UTF-8 string to compare against */ const UChar32 uEsc /* The escape character */ ){ static const int MATCH_ONE = (UChar32)'_'; static const int MATCH_ALL = (UChar32)'%'; int iPattern = 0; /* Current byte index in zPattern */ int iString = 0; /* Current byte index in zString */ int prevEscape = 0; /* True if the previous character was uEsc */ while( zPattern[iPattern]!=0 ){ /* Read (and consume) the next character from the input pattern. */ UChar32 uPattern; U8_NEXT_UNSAFE(zPattern, iPattern, uPattern); assert(uPattern!=0); /* There are now 4 possibilities: ** ** 1. uPattern is an unescaped match-all character "%", ** 2. uPattern is an unescaped match-one character "_", ** 3. uPattern is an unescaped escape character, or ** 4. uPattern is to be handled as an ordinary character */ if( !prevEscape && uPattern==MATCH_ALL ){ /* Case 1. */ uint8_t c; /* Skip any MATCH_ALL or MATCH_ONE characters that follow a ** MATCH_ALL. For each MATCH_ONE, skip one character in the ** test string. */ while( (c=zPattern[iPattern]) == MATCH_ALL || c == MATCH_ONE ){ if( c==MATCH_ONE ){ if( zString[iString]==0 ) return 0; U8_FWD_1_UNSAFE(zString, iString); } iPattern++; } if( zPattern[iPattern]==0 ) return 1; while( zString[iString] ){ if( icuLikeCompare(&zPattern[iPattern], &zString[iString], uEsc) ){ return 1; } U8_FWD_1_UNSAFE(zString, iString); } return 0; }else if( !prevEscape && uPattern==MATCH_ONE ){ /* Case 2. */ if( zString[iString]==0 ) return 0; U8_FWD_1_UNSAFE(zString, iString); }else if( !prevEscape && uPattern==uEsc){ /* Case 3. */ prevEscape = 1; }else{ /* Case 4. */ UChar32 uString; U8_NEXT_UNSAFE(zString, iString, uString); uString = u_foldCase(uString, U_FOLD_CASE_DEFAULT); uPattern = u_foldCase(uPattern, U_FOLD_CASE_DEFAULT); if( uString!=uPattern ){ return 0; } prevEscape = 0; } } return zString[iString]==0; } /* ** Implementation of the like() SQL function. This function implements ** the build-in LIKE operator. The first argument to the function is the ** pattern and the second argument is the string. So, the SQL statements: ** ** A LIKE B ** ** is implemented as like(B, A). If there is an escape character E, ** ** A LIKE B ESCAPE E ** ** is mapped to like(B, A, E). */ static void icuLikeFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ const unsigned char *zA = sqlite3_value_text(argv[0]); const unsigned char *zB = sqlite3_value_text(argv[1]); UChar32 uEsc = 0; /* Limit the length of the LIKE or GLOB pattern to avoid problems ** of deep recursion and N*N behavior in patternCompare(). */ if( sqlite3_value_bytes(argv[0])>SQLITE_MAX_LIKE_PATTERN_LENGTH ){ sqlite3_result_error(context, "LIKE or GLOB pattern too complex", -1); return; } if( argc==3 ){ /* The escape character string must consist of a single UTF-8 character. ** Otherwise, return an error. */ int nE= sqlite3_value_bytes(argv[2]); const unsigned char *zE = sqlite3_value_text(argv[2]); int i = 0; if( zE==0 ) return; U8_NEXT(zE, i, nE, uEsc); if( i!=nE){ sqlite3_result_error(context, "ESCAPE expression must be a single character", -1); return; } } if( zA && zB ){ sqlite3_result_int(context, icuLikeCompare(zA, zB, uEsc)); } } /* ** This function is called when an ICU function called from within ** the implementation of an SQL scalar function returns an error. ** ** The scalar function context passed as the first argument is ** loaded with an error message based on the following two args. */ static void icuFunctionError( sqlite3_context *pCtx, /* SQLite scalar function context */ const char *zName, /* Name of ICU function that failed */ UErrorCode e /* Error code returned by ICU function */ ){ char zBuf[128]; sqlite3_snprintf(128, zBuf, "ICU error: %s(): %s", zName, u_errorName(e)); zBuf[127] = '\0'; sqlite3_result_error(pCtx, zBuf, -1); } /* ** Function to delete compiled regexp objects. Registered as ** a destructor function with sqlite3_set_auxdata(). */ static void icuRegexpDelete(void *p){ URegularExpression *pExpr = (URegularExpression *)p; uregex_close(pExpr); } /* ** Implementation of SQLite REGEXP operator. This scalar function takes ** two arguments. The first is a regular expression pattern to compile ** the second is a string to match against that pattern. If either ** argument is an SQL NULL, then NULL Is returned. Otherwise, the result ** is 1 if the string matches the pattern, or 0 otherwise. ** ** SQLite maps the regexp() function to the regexp() operator such ** that the following two are equivalent: ** ** zString REGEXP zPattern ** regexp(zPattern, zString) ** ** Uses the following ICU regexp APIs: ** ** uregex_open() ** uregex_matches() ** uregex_close() */ static void icuRegexpFunc(sqlite3_context *p, int nArg, sqlite3_value **apArg){ UErrorCode status = U_ZERO_ERROR; URegularExpression *pExpr; UBool res; const UChar *zString = sqlite3_value_text16(apArg[1]); /* If the left hand side of the regexp operator is NULL, ** then the result is also NULL. */ if( !zString ){ return; } pExpr = sqlite3_get_auxdata(p, 0); if( !pExpr ){ const UChar *zPattern = sqlite3_value_text16(apArg[0]); if( !zPattern ){ return; } pExpr = uregex_open(zPattern, -1, 0, 0, &status); if( U_SUCCESS(status) ){ sqlite3_set_auxdata(p, 0, pExpr, icuRegexpDelete); }else{ assert(!pExpr); icuFunctionError(p, "uregex_open", status); return; } } /* Configure the text that the regular expression operates on. */ uregex_setText(pExpr, zString, -1, &status); if( !U_SUCCESS(status) ){ icuFunctionError(p, "uregex_setText", status); return; } /* Attempt the match */ res = uregex_matches(pExpr, 0, &status); if( !U_SUCCESS(status) ){ icuFunctionError(p, "uregex_matches", status); return; } /* Set the text that the regular expression operates on to a NULL ** pointer. This is not really necessary, but it is tidier than ** leaving the regular expression object configured with an invalid ** pointer after this function returns. */ uregex_setText(pExpr, 0, 0, &status); /* Return 1 or 0. */ sqlite3_result_int(p, res ? 1 : 0); } /* ** Implementations of scalar functions for case mapping - upper() and ** lower(). Function upper() converts its input to upper-case (ABC). ** Function lower() converts to lower-case (abc). ** ** ICU provides two types of case mapping, "general" case mapping and ** "language specific". Refer to ICU documentation for the differences ** between the two. ** ** To utilise "general" case mapping, the upper() or lower() scalar ** functions are invoked with one argument: ** ** upper('ABC') -> 'abc' ** lower('abc') -> 'ABC' ** ** To access ICU "language specific" case mapping, upper() or lower() ** should be invoked with two arguments. The second argument is the name ** of the locale to use. Passing an empty string ("") or SQL NULL value ** as the second argument is the same as invoking the 1 argument version ** of upper() or lower(). ** ** lower('I', 'en_us') -> 'i' ** lower('I', 'tr_tr') -> 'ı' (small dotless i) ** ** http://www.icu-project.org/userguide/posix.html#case_mappings */ static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){ const UChar *zInput; UChar *zOutput; int nInput; int nOutput; UErrorCode status = U_ZERO_ERROR; const char *zLocale = 0; assert(nArg==1 || nArg==2); if( nArg==2 ){ zLocale = (const char *)sqlite3_value_text(apArg[1]); } zInput = sqlite3_value_text16(apArg[0]); if( !zInput ){ return; } nInput = sqlite3_value_bytes16(apArg[0]); nOutput = nInput * 2 + 2; zOutput = sqlite3_malloc(nOutput); if( !zOutput ){ return; } if( sqlite3_user_data(p) ){ u_strToUpper(zOutput, nOutput/2, zInput, nInput/2, zLocale, &status); }else{ u_strToLower(zOutput, nOutput/2, zInput, nInput/2, zLocale, &status); } if( !U_SUCCESS(status) ){ icuFunctionError(p, "u_strToLower()/u_strToUpper", status); return; } sqlite3_result_text16(p, zOutput, -1, xFree); } /* ** Collation sequence destructor function. The pCtx argument points to ** a UCollator structure previously allocated using ucol_open(). */ static void icuCollationDel(void *pCtx){ UCollator *p = (UCollator *)pCtx; ucol_close(p); } /* ** Collation sequence comparison function. The pCtx argument points to ** a UCollator structure previously allocated using ucol_open(). */ static int icuCollationColl( void *pCtx, int nLeft, const void *zLeft, int nRight, const void *zRight ){ UCollationResult res; UCollator *p = (UCollator *)pCtx; res = ucol_strcoll(p, (UChar *)zLeft, nLeft/2, (UChar *)zRight, nRight/2); switch( res ){ case UCOL_LESS: return -1; case UCOL_GREATER: return +1; case UCOL_EQUAL: return 0; } assert(!"Unexpected return value from ucol_strcoll()"); return 0; } /* ** Implementation of the scalar function icu_load_collation(). ** ** This scalar function is used to add ICU collation based collation ** types to an SQLite database connection. It is intended to be called ** as follows: ** ** SELECT icu_load_collation(<locale>, <collation-name>); ** ** Where <locale> is a string containing an ICU locale identifier (i.e. ** "en_AU", "tr_TR" etc.) and <collation-name> is the name of the ** collation sequence to create. */ static void icuLoadCollation( sqlite3_context *p, int nArg, sqlite3_value **apArg ){ sqlite3 *db = (sqlite3 *)sqlite3_user_data(p); UErrorCode status = U_ZERO_ERROR; const char *zLocale; /* Locale identifier - (eg. "jp_JP") */ const char *zName; /* SQL Collation sequence name (eg. "japanese") */ UCollator *pUCollator; /* ICU library collation object */ int rc; /* Return code from sqlite3_create_collation_x() */ assert(nArg==2); zLocale = (const char *)sqlite3_value_text(apArg[0]); zName = (const char *)sqlite3_value_text(apArg[1]); if( !zLocale || !zName ){ return; } pUCollator = ucol_open(zLocale, &status); if( !U_SUCCESS(status) ){ icuFunctionError(p, "ucol_open", status); return; } assert(p); rc = sqlite3_create_collation_v2(db, zName, SQLITE_UTF16, (void *)pUCollator, icuCollationColl, icuCollationDel ); if( rc!=SQLITE_OK ){ ucol_close(pUCollator); sqlite3_result_error(p, "Error registering collation function", -1); } } /* ** Register the ICU extension functions with database db. */ SQLITE_PRIVATE int sqlite3IcuInit(sqlite3 *db){ struct IcuScalar { const char *zName; /* Function name */ int nArg; /* Number of arguments */ int enc; /* Optimal text encoding */ void *pContext; /* sqlite3_user_data() context */ void (*xFunc)(sqlite3_context*,int,sqlite3_value**); } scalars[] = { {"regexp",-1, SQLITE_ANY, 0, icuRegexpFunc}, {"lower", 1, SQLITE_UTF16, 0, icuCaseFunc16}, {"lower", 2, SQLITE_UTF16, 0, icuCaseFunc16}, {"upper", 1, SQLITE_UTF16, (void*)1, icuCaseFunc16}, {"upper", 2, SQLITE_UTF16, (void*)1, icuCaseFunc16}, {"lower", 1, SQLITE_UTF8, 0, icuCaseFunc16}, {"lower", 2, SQLITE_UTF8, 0, icuCaseFunc16}, {"upper", 1, SQLITE_UTF8, (void*)1, icuCaseFunc16}, {"upper", 2, SQLITE_UTF8, (void*)1, icuCaseFunc16}, {"like", 2, SQLITE_UTF8, 0, icuLikeFunc}, {"like", 3, SQLITE_UTF8, 0, icuLikeFunc}, {"icu_load_collation", 2, SQLITE_UTF8, (void*)db, icuLoadCollation}, }; int rc = SQLITE_OK; int i; for(i=0; rc==SQLITE_OK && i<(sizeof(scalars)/sizeof(struct IcuScalar)); i++){ struct IcuScalar *p = &scalars[i]; rc = sqlite3_create_function( db, p->zName, p->nArg, p->enc, p->pContext, p->xFunc, 0, 0 ); } return rc; } #if !SQLITE_CORE SQLITE_API int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ){ SQLITE_EXTENSION_INIT2(pApi) return sqlite3IcuInit(db); } #endif #endif /************** End of icu.c *************************************************/ |
Changes to SQLite.Interop/src/sqlite3.def.
︙ | ︙ | |||
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 | sqlite3_close sqlite3_collation_needed sqlite3_collation_needed16 sqlite3_column_blob sqlite3_column_bytes sqlite3_column_bytes16 sqlite3_column_count sqlite3_column_decltype sqlite3_column_decltype16 sqlite3_column_double sqlite3_column_int sqlite3_column_int64 sqlite3_column_name sqlite3_column_name16 sqlite3_column_text sqlite3_column_text16 sqlite3_column_type sqlite3_column_value sqlite3_commit_hook sqlite3_complete sqlite3_complete16 sqlite3_create_collation sqlite3_create_collation16 sqlite3_create_collation_v2 sqlite3_create_function sqlite3_create_function16 sqlite3_create_module sqlite3_create_module_v2 sqlite3_data_count sqlite3_db_handle sqlite3_declare_vtab sqlite3_enable_load_extension sqlite3_enable_shared_cache sqlite3_errcode sqlite3_errmsg sqlite3_errmsg16 sqlite3_exec sqlite3_expired sqlite3_extended_result_codes sqlite3_file_control sqlite3_finalize sqlite3_free sqlite3_free_table sqlite3_get_autocommit sqlite3_get_auxdata sqlite3_get_table sqlite3_global_recover sqlite3_interrupt sqlite3_last_insert_rowid sqlite3_libversion sqlite3_libversion_number sqlite3_load_extension sqlite3_malloc sqlite3_memory_alarm sqlite3_memory_highwater sqlite3_memory_used sqlite3_mprintf sqlite3_mutex_alloc sqlite3_mutex_enter sqlite3_mutex_free sqlite3_mutex_leave sqlite3_mutex_try sqlite3_open sqlite3_open16 sqlite3_open_v2 sqlite3_overload_function sqlite3_prepare sqlite3_prepare16 sqlite3_prepare16_v2 sqlite3_prepare_v2 | > > > > > > > > > > > > > > > | | 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 | sqlite3_close sqlite3_collation_needed sqlite3_collation_needed16 sqlite3_column_blob sqlite3_column_bytes sqlite3_column_bytes16 sqlite3_column_count sqlite3_column_database_name sqlite3_column_database_name16 sqlite3_column_decltype sqlite3_column_decltype16 sqlite3_column_double sqlite3_column_int sqlite3_column_int64 sqlite3_column_name sqlite3_column_name16 sqlite3_column_origin_name sqlite3_column_origin_name16 sqlite3_column_table_name sqlite3_column_table_name16 sqlite3_column_text sqlite3_column_text16 sqlite3_column_type sqlite3_column_value sqlite3_commit_hook sqlite3_complete sqlite3_complete16 sqlite3_config sqlite3_context_db_handle sqlite3_create_collation sqlite3_create_collation16 sqlite3_create_collation_v2 sqlite3_create_function sqlite3_create_function16 sqlite3_create_module sqlite3_create_module_v2 sqlite3_data_count sqlite3_db_config sqlite3_db_handle sqlite3_db_status sqlite3_declare_vtab sqlite3_enable_load_extension sqlite3_enable_shared_cache sqlite3_errcode sqlite3_errmsg sqlite3_errmsg16 sqlite3_exec sqlite3_expired sqlite3_extended_result_codes sqlite3_file_control sqlite3_finalize sqlite3_free sqlite3_free_table sqlite3_get_autocommit sqlite3_get_auxdata sqlite3_get_table sqlite3_global_recover sqlite3_initialize sqlite3_interrupt sqlite3_last_insert_rowid sqlite3_libversion sqlite3_libversion_number sqlite3_limit sqlite3_load_extension sqlite3_malloc sqlite3_memory_alarm sqlite3_memory_highwater sqlite3_memory_used sqlite3_mprintf sqlite3_mutex_alloc sqlite3_mutex_enter sqlite3_mutex_free sqlite3_mutex_leave sqlite3_mutex_try sqlite3_next_stmt sqlite3_open sqlite3_open16 sqlite3_open_v2 sqlite3_os_end sqlite3_os_init sqlite3_overload_function sqlite3_prepare sqlite3_prepare16 sqlite3_prepare16_v2 sqlite3_prepare_v2 sqlite3_profile sqlite3_progress_handler sqlite3_randomness sqlite3_realloc sqlite3_release_memory sqlite3_reset sqlite3_reset_auto_extension sqlite3_result_blob |
︙ | ︙ | |||
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | sqlite3_result_text16be sqlite3_result_text16le sqlite3_result_value sqlite3_result_zeroblob sqlite3_rollback_hook sqlite3_set_authorizer sqlite3_set_auxdata sqlite3_sleep sqlite3_snprintf sqlite3_soft_heap_limit sqlite3_sql sqlite3_step sqlite3_test_control sqlite3_thread_cleanup sqlite3_threadsafe sqlite3_total_changes | > > > | > | 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 | sqlite3_result_text16be sqlite3_result_text16le sqlite3_result_value sqlite3_result_zeroblob sqlite3_rollback_hook sqlite3_set_authorizer sqlite3_set_auxdata sqlite3_shutdown sqlite3_sleep sqlite3_snprintf sqlite3_soft_heap_limit sqlite3_sql sqlite3_status sqlite3_step sqlite3_table_column_metadata sqlite3_test_control sqlite3_thread_cleanup sqlite3_threadsafe sqlite3_total_changes sqlite3_trace sqlite3_transfer_bindings sqlite3_update_hook sqlite3_user_data sqlite3_value_blob sqlite3_value_bytes sqlite3_value_bytes16 sqlite3_value_double sqlite3_value_int sqlite3_value_int64 sqlite3_value_numeric_type sqlite3_value_text sqlite3_value_text16 sqlite3_value_text16be sqlite3_value_text16le sqlite3_value_type sqlite3_version sqlite3_vfs_find sqlite3_vfs_register sqlite3_vfs_unregister sqlite3_vmprintf sqlite3_key sqlite3_rekey |
Changes to SQLite.Interop/src/sqlite3.h.
︙ | ︙ | |||
26 27 28 29 30 31 32 | ** on how SQLite interfaces are suppose to operate. ** ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ** on how SQLite interfaces are suppose to operate. ** ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** ** @(#) $Id: sqlite3.h,v 1.36 2008/08/06 21:45:32 rmsimpson Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ #include <stdarg.h> /* Needed for the definition of va_list */ /* ** Make sure we can call this stuff from C++. |
︙ | ︙ | |||
58 59 60 61 62 63 64 | # undef SQLITE_VERSION #endif #ifdef SQLITE_VERSION_NUMBER # undef SQLITE_VERSION_NUMBER #endif /* | | | | | | | | | | | | 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 | # undef SQLITE_VERSION #endif #ifdef SQLITE_VERSION_NUMBER # undef SQLITE_VERSION_NUMBER #endif /* ** CAPI3REF: Compile-Time Library Version Numbers {H10010} <S60100> ** ** The SQLITE_VERSION and SQLITE_VERSION_NUMBER #defines in ** the sqlite3.h file specify the version of SQLite with which ** that header file is associated. ** ** The "version" of SQLite is a string of the form "X.Y.Z". ** The phrase "alpha" or "beta" might be appended after the Z. ** The X value is major version number always 3 in SQLite3. ** The X value only changes when backwards compatibility is ** broken and we intend to never break backwards compatibility. ** The Y value is the minor version number and only changes when ** there are major feature enhancements that are forwards compatible ** but not backwards compatible. ** The Z value is the release number and is incremented with ** each release but resets back to 0 whenever Y is incremented. ** ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()]. ** ** INVARIANTS: ** ** {H10011} The SQLITE_VERSION #define in the sqlite3.h header file shall ** evaluate to a string literal that is the SQLite version ** with which the header file is associated. ** ** {H10014} The SQLITE_VERSION_NUMBER #define shall resolve to an integer ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z ** are the major version, minor version, and release number. */ #define SQLITE_VERSION "3.6.1" #define SQLITE_VERSION_NUMBER 3006001 /* ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100> ** KEYWORDS: sqlite3_version ** ** These features provide the same information as the [SQLITE_VERSION] ** and [SQLITE_VERSION_NUMBER] #defines in the header, but are associated ** with the library instead of the header file. Cautious programmers might ** include a check in their application to verify that ** sqlite3_libversion_number() always returns the value ** [SQLITE_VERSION_NUMBER]. ** ** The sqlite3_libversion() function returns the same information as is ** in the sqlite3_version[] string constant. The function is provided ** for use in DLLs since DLL users usually do not have direct access to string ** constants within the DLL. ** ** INVARIANTS: ** ** {H10021} The [sqlite3_libversion_number()] interface shall return ** an integer equal to [SQLITE_VERSION_NUMBER]. ** ** {H10022} The [sqlite3_version] string constant shall contain ** the text of the [SQLITE_VERSION] string. ** ** {H10023} The [sqlite3_libversion()] function shall return ** a pointer to the [sqlite3_version] string constant. */ SQLITE_EXTERN const char sqlite3_version[]; const char *sqlite3_libversion(void); int sqlite3_libversion_number(void); /* ** CAPI3REF: Test To See If The Library Is Threadsafe {H10100} <S60100> ** ** SQLite can be compiled with or without mutexes. When ** the [SQLITE_THREADSAFE] C preprocessor macro is true, mutexes ** are enabled and SQLite is threadsafe. When that macro is false, ** the mutexes are omitted. Without the mutexes, it is not safe ** to use SQLite concurrently from more than one thread. ** |
︙ | ︙ | |||
150 151 152 153 154 155 156 | ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], ** or [SQLITE_CONFIG_MUTEX]. The return value of this function shows ** only the default compile-time setting, not any run-time changes ** to that setting. ** ** INVARIANTS: ** | | | | | | | | 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 | ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], ** or [SQLITE_CONFIG_MUTEX]. The return value of this function shows ** only the default compile-time setting, not any run-time changes ** to that setting. ** ** INVARIANTS: ** ** {H10101} The [sqlite3_threadsafe()] function shall return nonzero if ** SQLite was compiled with the its mutexes enabled by default ** or zero if SQLite was compiled such that mutexes are ** permanently disabled. ** ** {H10102} The value returned by the [sqlite3_threadsafe()] function ** shall not change when mutex setting are modified at ** runtime using the [sqlite3_config()] interface and ** especially the [SQLITE_CONFIG_SINGLETHREAD], ** [SQLITE_CONFIG_MULTITHREAD], [SQLITE_CONFIG_SERIALIZED], ** and [SQLITE_CONFIG_MUTEX] verbs. */ int sqlite3_threadsafe(void); /* ** CAPI3REF: Database Connection Handle {H12000} <S40200> ** KEYWORDS: {database connection} {database connections} ** ** Each open SQLite database is represented by a pointer to an instance of ** the opaque structure named "sqlite3". It is useful to think of an sqlite3 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] ** is its destructor. There are many other interfaces (such as ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and ** [sqlite3_busy_timeout()] to name but three) that are methods on an ** sqlite3 object. */ typedef struct sqlite3 sqlite3; /* ** CAPI3REF: 64-Bit Integer Types {H10200} <S10110> ** KEYWORDS: sqlite_int64 sqlite_uint64 ** ** Because there is no cross-platform way to specify 64-bit integer types ** SQLite includes typedefs for 64-bit signed and unsigned integers. ** ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. ** The sqlite_int64 and sqlite_uint64 types are supported for backwards ** compatibility only. ** ** INVARIANTS: ** ** {H10201} The [sqlite_int64] and [sqlite3_int64] type shall specify ** a 64-bit signed integer. ** ** {H10202} The [sqlite_uint64] and [sqlite3_uint64] type shall specify ** a 64-bit unsigned integer. */ #ifdef SQLITE_INT64_TYPE typedef SQLITE_INT64_TYPE sqlite_int64; typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; #elif defined(_MSC_VER) || defined(__BORLANDC__) typedef __int64 sqlite_int64; |
︙ | ︙ | |||
220 221 222 223 224 225 226 | ** substitute integer for floating-point. */ #ifdef SQLITE_OMIT_FLOATING_POINT # define double sqlite3_int64 #endif /* | | | 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | ** substitute integer for floating-point. */ #ifdef SQLITE_OMIT_FLOATING_POINT # define double sqlite3_int64 #endif /* ** CAPI3REF: Closing A Database Connection {H12010} <S30100><S40200> ** ** This routine is the destructor for the [sqlite3] object. ** ** Applications should [sqlite3_finalize | finalize] all [prepared statements] ** and [sqlite3_blob_close | close] all [BLOB handles] associated with ** the [sqlite3] object prior to attempting to close the object. ** The [sqlite3_next_stmt()] interface can be used to locate all |
︙ | ︙ | |||
243 244 245 246 247 248 249 | ** </pre></blockquote> ** ** If [sqlite3_close()] is invoked while a transaction is open, ** the transaction is automatically rolled back. ** ** INVARIANTS: ** | | | | | | | | | | | 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 | ** </pre></blockquote> ** ** If [sqlite3_close()] is invoked while a transaction is open, ** the transaction is automatically rolled back. ** ** INVARIANTS: ** ** {H12011} A successful call to [sqlite3_close(C)] shall destroy the ** [database connection] object C. ** ** {H12012} A successful call to [sqlite3_close(C)] shall return SQLITE_OK. ** ** {H12013} A successful call to [sqlite3_close(C)] shall release all ** memory and system resources associated with [database connection] ** C. ** ** {H12014} A call to [sqlite3_close(C)] on a [database connection] C that ** has one or more open [prepared statements] shall fail with ** an [SQLITE_BUSY] error code. ** ** {H12015} A call to [sqlite3_close(C)] where C is a NULL pointer shall ** return SQLITE_OK. ** ** {H12019} When [sqlite3_close(C)] is invoked on a [database connection] C ** that has a pending transaction, the transaction shall be ** rolled back. ** ** ASSUMPTIONS: ** ** {A12016} The C parameter to [sqlite3_close(C)] must be either a NULL ** pointer or an [sqlite3] object pointer obtained ** from [sqlite3_open()], [sqlite3_open16()], or ** [sqlite3_open_v2()], and not previously closed. */ int sqlite3_close(sqlite3 *); /* ** The type for a callback function. ** This is legacy and deprecated. It is included for historical ** compatibility and is not documented. */ typedef int (*sqlite3_callback)(void*,int,char**, char**); /* ** CAPI3REF: One-Step Query Execution Interface {H12100} <S10000> ** ** The sqlite3_exec() interface is a convenient way of running one or more ** SQL statements without having to write a lot of C code. The UTF-8 encoded ** SQL statements are passed in as the second parameter to sqlite3_exec(). ** The statements are evaluated one by one until either an error or ** an interrupt is encountered, or until they are all done. The 3rd parameter ** is an optional callback that is invoked once for each row of any query |
︙ | ︙ | |||
308 309 310 311 312 313 314 | ** The sqlite3_exec() interface is implemented in terms of ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()]. ** The sqlite3_exec() routine does nothing to the database that cannot be done ** by [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()]. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | 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 | ** The sqlite3_exec() interface is implemented in terms of ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()]. ** The sqlite3_exec() routine does nothing to the database that cannot be done ** by [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()]. ** ** INVARIANTS: ** ** {H12101} A successful invocation of [sqlite3_exec(D,S,C,A,E)] ** shall sequentially evaluate all of the UTF-8 encoded, ** semicolon-separated SQL statements in the zero-terminated ** string S within the context of the [database connection] D. ** ** {H12102} If the S parameter to [sqlite3_exec(D,S,C,A,E)] is NULL then ** the actions of the interface shall be the same as if the ** S parameter were an empty string. ** ** {H12104} The return value of [sqlite3_exec()] shall be [SQLITE_OK] if all ** SQL statements run successfully and to completion. ** ** {H12105} The return value of [sqlite3_exec()] shall be an appropriate ** non-zero [error code] if any SQL statement fails. ** ** {H12107} If one or more of the SQL statements handed to [sqlite3_exec()] ** return results and the 3rd parameter is not NULL, then ** the callback function specified by the 3rd parameter shall be ** invoked once for each row of result. ** ** {H12110} If the callback returns a non-zero value then [sqlite3_exec()] ** shall abort the SQL statement it is currently evaluating, ** skip all subsequent SQL statements, and return [SQLITE_ABORT]. ** ** {H12113} The [sqlite3_exec()] routine shall pass its 4th parameter through ** as the 1st parameter of the callback. ** ** {H12116} The [sqlite3_exec()] routine shall set the 2nd parameter of its ** callback to be the number of columns in the current row of ** result. ** ** {H12119} The [sqlite3_exec()] routine shall set the 3rd parameter of its ** callback to be an array of pointers to strings holding the ** values for each column in the current result set row as ** obtained from [sqlite3_column_text()]. ** ** {H12122} The [sqlite3_exec()] routine shall set the 4th parameter of its ** callback to be an array of pointers to strings holding the ** names of result columns as obtained from [sqlite3_column_name()]. ** ** {H12125} If the 3rd parameter to [sqlite3_exec()] is NULL then ** [sqlite3_exec()] shall silently discard query results. ** ** {H12131} If an error occurs while parsing or evaluating any of the SQL ** statements in the S parameter of [sqlite3_exec(D,S,C,A,E)] and if ** the E parameter is not NULL, then [sqlite3_exec()] shall store ** in *E an appropriate error message written into memory obtained ** from [sqlite3_malloc()]. ** ** {H12134} The [sqlite3_exec(D,S,C,A,E)] routine shall set the value of ** *E to NULL if E is not NULL and there are no errors. ** ** {H12137} The [sqlite3_exec(D,S,C,A,E)] function shall set the [error code] ** and message accessible via [sqlite3_errcode()], ** [sqlite3_errmsg()], and [sqlite3_errmsg16()]. ** ** {H12138} If the S parameter to [sqlite3_exec(D,S,C,A,E)] is NULL or an ** empty string or contains nothing other than whitespace, comments, ** and/or semicolons, then results of [sqlite3_errcode()], ** [sqlite3_errmsg()], and [sqlite3_errmsg16()] ** shall reset to indicate no errors. ** ** ASSUMPTIONS: ** ** {A12141} The first parameter to [sqlite3_exec()] must be an valid and open ** [database connection]. ** ** {A12142} The database connection must not be closed while ** [sqlite3_exec()] is running. ** |
︙ | ︙ | |||
394 395 396 397 398 399 400 | const char *sql, /* SQL to be evaluated */ int (*callback)(void*,int,char**,char**), /* Callback function */ void *, /* 1st argument to callback */ char **errmsg /* Error msg written here */ ); /* | | | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | const char *sql, /* SQL to be evaluated */ int (*callback)(void*,int,char**,char**), /* Callback function */ void *, /* 1st argument to callback */ char **errmsg /* Error msg written here */ ); /* ** CAPI3REF: Result Codes {H10210} <S10700> ** KEYWORDS: SQLITE_OK {error code} {error codes} ** KEYWORDS: {result code} {result codes} ** ** Many SQLite functions return an integer result code from the set shown ** here in order to indicates success or failure. ** ** New error codes may be added in future versions of SQLite. |
︙ | ︙ | |||
438 439 440 441 442 443 444 | #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ #define SQLITE_NOTADB 26 /* File opened that is not a database file */ #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ /* end-of-error-codes */ /* | | | 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ #define SQLITE_NOTADB 26 /* File opened that is not a database file */ #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ /* end-of-error-codes */ /* ** CAPI3REF: Extended Result Codes {H10220} <S10700> ** KEYWORDS: {extended error code} {extended error codes} ** KEYWORDS: {extended result code} {extended result codes} ** ** In its default configuration, SQLite API routines return one of 26 integer ** [SQLITE_OK | result codes]. However, experience has shown that many of ** these result codes are too coarse-grained. They do not provide as ** much information about problems as programmers might like. In an effort to |
︙ | ︙ | |||
462 463 464 465 466 467 468 | ** to see new result codes in future releases of SQLite. ** ** The SQLITE_OK result code will never be extended. It will always ** be exactly zero. ** ** INVARIANTS: ** | | | | | | | 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 | ** to see new result codes in future releases of SQLite. ** ** The SQLITE_OK result code will never be extended. It will always ** be exactly zero. ** ** INVARIANTS: ** ** {H10223} The symbolic name for an extended result code shall contains ** a related primary result code as a prefix. ** ** {H10224} Primary result code names shall contain a single "_" character. ** ** {H10225} Extended result code names shall contain two or more "_" characters. ** ** {H10226} The numeric value of an extended result code shall contain the ** numeric value of its corresponding primary result code in ** its least significant 8 bits. */ #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8)) #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8)) #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8)) #define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8)) #define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8)) #define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8)) #define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8)) #define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8)) #define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8)) #define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8)) #define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) /* ** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700> ** ** These bit values are intended for use in the ** 3rd parameter to the [sqlite3_open_v2()] interface and ** in the 4th parameter to the xOpen method of the ** [sqlite3_vfs] object. */ #define SQLITE_OPEN_READONLY 0x00000001 |
︙ | ︙ | |||
511 512 513 514 515 516 517 | #define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 #define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 #define SQLITE_OPEN_SUBJOURNAL 0x00002000 #define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 #define SQLITE_OPEN_NOMUTEX 0x00008000 /* | | | 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | #define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 #define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 #define SQLITE_OPEN_SUBJOURNAL 0x00002000 #define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 #define SQLITE_OPEN_NOMUTEX 0x00008000 /* ** CAPI3REF: Device Characteristics {H10240} <H11120> ** ** The xDeviceCapabilities method of the [sqlite3_io_methods] ** object returns an integer which is a vector of the these ** bit values expressing I/O characteristics of the mass storage ** device that holds the file that the [sqlite3_io_methods] ** refers to. ** |
︙ | ︙ | |||
543 544 545 546 547 548 549 | #define SQLITE_IOCAP_ATOMIC16K 0x00000040 #define SQLITE_IOCAP_ATOMIC32K 0x00000080 #define SQLITE_IOCAP_ATOMIC64K 0x00000100 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 /* | | | | | | 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 | #define SQLITE_IOCAP_ATOMIC16K 0x00000040 #define SQLITE_IOCAP_ATOMIC32K 0x00000080 #define SQLITE_IOCAP_ATOMIC64K 0x00000100 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 /* ** CAPI3REF: File Locking Levels {H10250} <H11120> <H11310> ** ** SQLite uses one of these integer values as the second ** argument to calls it makes to the xLock() and xUnlock() methods ** of an [sqlite3_io_methods] object. */ #define SQLITE_LOCK_NONE 0 #define SQLITE_LOCK_SHARED 1 #define SQLITE_LOCK_RESERVED 2 #define SQLITE_LOCK_PENDING 3 #define SQLITE_LOCK_EXCLUSIVE 4 /* ** CAPI3REF: Synchronization Type Flags {H10260} <H11120> ** ** When SQLite invokes the xSync() method of an ** [sqlite3_io_methods] object it uses a combination of ** these integer values as the second argument. ** ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the ** sync operation only needs to flush data to mass storage. Inode ** information need not be flushed. The SQLITE_SYNC_NORMAL flag means ** to use normal fsync() semantics. The SQLITE_SYNC_FULL flag means ** to use Mac OS-X style fullsync instead of fsync(). */ #define SQLITE_SYNC_NORMAL 0x00002 #define SQLITE_SYNC_FULL 0x00003 #define SQLITE_SYNC_DATAONLY 0x00010 /* ** CAPI3REF: OS Interface Open File Handle {H11110} <S20110> ** ** An [sqlite3_file] object represents an open file in the OS ** interface layer. Individual OS interface implementations will ** want to subclass this object by appending additional fields ** for their own use. The pMethods entry is a pointer to an ** [sqlite3_io_methods] object that defines methods for performing ** I/O operations on the open file. */ typedef struct sqlite3_file sqlite3_file; struct sqlite3_file { const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ }; /* ** CAPI3REF: OS Interface File Virtual Methods Object {H11120} <S20110> ** ** Every file opened by the [sqlite3_vfs] xOpen method populates an ** [sqlite3_file] object (or, more commonly, a subclass of the ** [sqlite3_file] object) with a pointer to an instance of this object. ** This object defines the methods used to perform various operations ** against the open file represented by the [sqlite3_file] object. ** |
︙ | ︙ | |||
681 682 683 684 685 686 687 | int (*xFileControl)(sqlite3_file*, int op, void *pArg); int (*xSectorSize)(sqlite3_file*); int (*xDeviceCharacteristics)(sqlite3_file*); /* Additional methods may be added in future releases */ }; /* | | | | | 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 | int (*xFileControl)(sqlite3_file*, int op, void *pArg); int (*xSectorSize)(sqlite3_file*); int (*xDeviceCharacteristics)(sqlite3_file*); /* Additional methods may be added in future releases */ }; /* ** CAPI3REF: Standard File Control Opcodes {H11310} <S30800> ** ** These integer constants are opcodes for the xFileControl method ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] ** interface. ** ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This ** opcode causes the xFileControl method to write the current state of ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) ** into an integer that the pArg argument points to. This capability ** is used during testing and only needs to be supported when SQLITE_TEST ** is defined. */ #define SQLITE_FCNTL_LOCKSTATE 1 /* ** CAPI3REF: Mutex Handle {H17110} <S20130> ** ** The mutex module within SQLite defines [sqlite3_mutex] to be an ** abstract type for a mutex object. The SQLite core never looks ** at the internal representation of an [sqlite3_mutex]. It only ** deals with pointers to the [sqlite3_mutex] object. ** ** Mutexes are created using [sqlite3_mutex_alloc()]. */ typedef struct sqlite3_mutex sqlite3_mutex; /* ** CAPI3REF: OS Interface Object {H11140} <S20100> ** ** An instance of the sqlite3_vfs object defines the interface between ** the SQLite core and the underlying operating system. The "vfs" ** in the name of the object stands for "virtual file system". ** ** The value of the iVersion field is initially 1 but may be larger in ** future versions of SQLite. Additional fields may be appended to this |
︙ | ︙ | |||
743 744 745 746 747 748 749 | ** or modify this field while holding a particular static mutex. ** The application should never modify anything within the sqlite3_vfs ** object once the object has been registered. ** ** The zName field holds the name of the VFS module. The name must ** be unique across all VFS modules. ** | | | | | | 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 | ** or modify this field while holding a particular static mutex. ** The application should never modify anything within the sqlite3_vfs ** object once the object has been registered. ** ** The zName field holds the name of the VFS module. The name must ** be unique across all VFS modules. ** ** {H11141} SQLite will guarantee that the zFilename parameter to xOpen ** is either a NULL pointer or string obtained ** from xFullPathname(). SQLite further guarantees that ** the string will be valid and unchanged until xClose() is ** called. {END} Because of the previous sentense, ** the [sqlite3_file] can safely store a pointer to the ** filename if it needs to remember the filename for some reason. ** If the zFilename parameter is xOpen is a NULL pointer then xOpen ** must invite its own temporary name for the file. Whenever the ** xFilename parameter is NULL it will also be the case that the ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. ** ** {H11142} The flags argument to xOpen() includes all bits set in ** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] ** or [sqlite3_open16()] is used, then flags includes at least ** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. {END} ** If xOpen() opens a file read-only then it sets *pOutFlags to ** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. ** ** {H11143} SQLite will also add one of the following flags to the xOpen() ** call, depending on the object being opened: ** ** <ul> ** <li> [SQLITE_OPEN_MAIN_DB] ** <li> [SQLITE_OPEN_MAIN_JOURNAL] ** <li> [SQLITE_OPEN_TEMP_DB] ** <li> [SQLITE_OPEN_TEMP_JOURNAL] |
︙ | ︙ | |||
791 792 793 794 795 796 797 | ** SQLite might also add one of the following flags to the xOpen method: ** ** <ul> ** <li> [SQLITE_OPEN_DELETEONCLOSE] ** <li> [SQLITE_OPEN_EXCLUSIVE] ** </ul> ** | | | | | | | | | 791 792 793 794 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 820 821 822 823 824 825 | ** SQLite might also add one of the following flags to the xOpen method: ** ** <ul> ** <li> [SQLITE_OPEN_DELETEONCLOSE] ** <li> [SQLITE_OPEN_EXCLUSIVE] ** </ul> ** ** {H11145} The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be ** deleted when it is closed. {H11146} The [SQLITE_OPEN_DELETEONCLOSE] ** will be set for TEMP databases, journals and for subjournals. ** ** {H11147} The [SQLITE_OPEN_EXCLUSIVE] flag means the file should be opened ** for exclusive access. This flag is set for all files except ** for the main database file. ** ** {H11148} At least szOsFile bytes of memory are allocated by SQLite ** to hold the [sqlite3_file] structure passed as the third ** argument to xOpen. {END} The xOpen method does not have to ** allocate the structure; it should just fill it in. ** ** {H11149} The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] ** to test whether a file is at least readable. {END} The file can be a ** directory. ** ** {H11150} SQLite will always allocate at least mxPathname+1 bytes for the ** output buffer xFullPathname. {H11151} The exact size of the output buffer ** is also passed as a parameter to both methods. {END} If the output buffer ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is ** handled as a fatal error by SQLite, vfs implementations should endeavor ** to prevent this by setting mxPathname to a sufficiently large value. ** ** The xRandomness(), xSleep(), and xCurrentTime() interfaces ** are not strictly a part of the filesystem, but they are |
︙ | ︙ | |||
853 854 855 856 857 858 859 | int (*xCurrentTime)(sqlite3_vfs*, double*); int (*xGetLastError)(sqlite3_vfs*, int, char *); /* New fields may be appended in figure versions. The iVersion ** value will increment whenever this happens. */ }; /* | | | | | | | | 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 | int (*xCurrentTime)(sqlite3_vfs*, double*); int (*xGetLastError)(sqlite3_vfs*, int, char *); /* New fields may be appended in figure versions. The iVersion ** value will increment whenever this happens. */ }; /* ** CAPI3REF: Flags for the xAccess VFS method {H11190} <H11140> ** ** {H11191} These integer constants can be used as the third parameter to ** the xAccess method of an [sqlite3_vfs] object. {END} They determine ** what kind of permissions the xAccess method is looking for. ** {H11192} With SQLITE_ACCESS_EXISTS, the xAccess method ** simply checks whether the file exists. ** {H11193} With SQLITE_ACCESS_READWRITE, the xAccess method ** checks whether the file is both readable and writable. ** {H11194} With SQLITE_ACCESS_READ, the xAccess method ** checks whether the file is readable. */ #define SQLITE_ACCESS_EXISTS 0 #define SQLITE_ACCESS_READWRITE 1 #define SQLITE_ACCESS_READ 2 /* ** CAPI3REF: Initialize The SQLite Library {H10130} <S20000><S30100> ** ** The sqlite3_initialize() routine initializes the ** SQLite library. The sqlite3_shutdown() routine ** deallocates any resources that were allocated by sqlite3_initialize(). ** ** A call to sqlite3_initialize() is an "effective" call if it is ** the first time sqlite3_initialize() is invoked during the lifetime of |
︙ | ︙ | |||
935 936 937 938 939 940 941 | */ int sqlite3_initialize(void); int sqlite3_shutdown(void); int sqlite3_os_init(void); int sqlite3_os_end(void); /* | | > | 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 | */ int sqlite3_initialize(void); int sqlite3_shutdown(void); int sqlite3_os_init(void); int sqlite3_os_end(void); /* ** CAPI3REF: Configuring The SQLite Library {H10145} <S20000><S30200> ** EXPERIMENTAL ** ** The sqlite3_config() interface is used to make global configuration ** changes to SQLite in order to tune SQLite to the specific needs of ** the application. The default configuration is recommended for most ** applications and so this routine is usually not necessary. It is ** provided to support rare applications with unusual needs. ** |
︙ | ︙ | |||
960 961 962 963 964 965 966 | ** what property of SQLite is to be configured. Subsequent arguments ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option] ** in the first argument. ** ** When a configuration option is set, sqlite3_config() returns SQLITE_OK. ** If the option is unknown or SQLite is unable to set the option ** then this routine returns a non-zero [error code]. | < < < < > > > > > > > > > > > > > > > > > > > > > | > | 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 | ** what property of SQLite is to be configured. Subsequent arguments ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option] ** in the first argument. ** ** When a configuration option is set, sqlite3_config() returns SQLITE_OK. ** If the option is unknown or SQLite is unable to set the option ** then this routine returns a non-zero [error code]. */ int sqlite3_config(int, ...); /* ** CAPI3REF: Configure database connections {H10180} <S20000> ** EXPERIMENTAL ** ** The sqlite3_db_config() interface is used to make configuration ** changes to a [database connection]. The interface is similar to ** [sqlite3_config()] except that the changes apply to a single ** [database connection] (specified in the first argument). The ** sqlite3_db_config() interface can only be used immediately after ** the database connection is created using [sqlite3_open()], ** [sqlite3_open16()], or [sqlite3_open_v2()]. ** ** The second argument to sqlite3_db_config(D,V,...) is the ** configuration verb - an integer code that indicates what ** aspect of the [database connection] is being configured. ** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE]. ** New verbs are likely to be added in future releases of SQLite. ** Additional arguments depend on the verb. */ int sqlite3_db_config(sqlite3*, int op, ...); /* ** CAPI3REF: Memory Allocation Routines {H10155} <S20120> ** EXPERIMENTAL ** ** An instance of this object defines the interface between SQLite ** and low-level memory allocation routines. ** ** This object is used in only one place in the SQLite interface. ** A pointer to an instance of this object is the argument to ** [sqlite3_config()] when the configuration option is |
︙ | ︙ | |||
1022 1023 1024 1025 1026 1027 1028 | int (*xRoundup)(int); /* Round up request size to allocation size */ int (*xInit)(void*); /* Initialize the memory allocator */ void (*xShutdown)(void*); /* Deinitialize the memory allocator */ void *pAppData; /* Argument to xInit() and xShutdown() */ }; /* | | > | 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 | int (*xRoundup)(int); /* Round up request size to allocation size */ int (*xInit)(void*); /* Initialize the memory allocator */ void (*xShutdown)(void*); /* Deinitialize the memory allocator */ void *pAppData; /* Argument to xInit() and xShutdown() */ }; /* ** CAPI3REF: Configuration Options {H10160} <S20000> ** EXPERIMENTAL ** ** These constants are the available integer configuration options that ** can be passed as the first argument to the [sqlite3_config()] interface. ** ** New configuration options may be added in future releases of SQLite. ** Existing configuration options might be discontinued. Applications ** should check the return code from [sqlite3_config()] to make sure that |
︙ | ︙ | |||
1078 1079 1080 1081 1082 1083 1084 | ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] ** structure is filled with the currently defined memory allocation routines. ** This option can be used to overload the default memory allocation ** routines with a wrapper that simulations memory allocation failure or ** tracks memory usage, for example.</dd> ** ** <dt>SQLITE_CONFIG_MEMSTATUS</dt> | | | | > | | > > | | | > > | 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 | ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] ** structure is filled with the currently defined memory allocation routines. ** This option can be used to overload the default memory allocation ** routines with a wrapper that simulations memory allocation failure or ** tracks memory usage, for example.</dd> ** ** <dt>SQLITE_CONFIG_MEMSTATUS</dt> ** <dd>This option takes single argument of type int, interpreted as a ** boolean, which enables or disables the collection of memory allocation ** statistics. When disabled, the following SQLite interfaces become ** non-operational: ** <ul> ** <li> [sqlite3_memory_used()] ** <li> [sqlite3_memory_highwater()] ** <li> [sqlite3_soft_heap_limit()] ** <li> [sqlite3_status()] ** </ul> ** </dd> ** ** <dt>SQLITE_CONFIG_SCRATCH</dt> ** <dd>This option specifies a static memory buffer that SQLite can use for ** scratch memory. There are three arguments: A pointer to the memory, the ** size of each scratch buffer (sz), and the number of buffers (N). The sz ** argument must be a multiple of 16. The sz parameter should be a few bytes ** larger than the actual scratch space required due internal overhead. ** The first ** argument should point to an allocation of at least sz*N bytes of memory. ** SQLite will use no more than one scratch buffer at once per thread, so ** N should be set to the expected maximum number of threads. The sz ** parameter should be 6 times the size of the largest database page size. ** Scratch buffers are used as part of the btree balance operation. If ** The btree balancer needs additional memory beyond what is provided by ** scratch buffers or if no scratch buffer space is specified, then SQLite ** goes to [sqlite3_malloc()] to obtain the memory it needs.</dd> ** ** <dt>SQLITE_CONFIG_PAGECACHE</dt> ** <dd>This option specifies a static memory buffer that SQLite can use for ** the database page cache. There are three arguments: A pointer to the ** memory, the size of each page buffer (sz), and the number of pages (N). ** The sz argument must be a power of two between 512 and 32768. The first ** argument should point to an allocation of at least sz*N bytes of memory. ** SQLite will use the memory provided by the first argument to satisfy its ** memory needs for the first N pages that it adds to cache. If additional ** page cache memory is needed beyond what is provided by this option, then ** SQLite goes to [sqlite3_malloc()] for the additional storage space. ** The implementation might use one or more of the N buffers to hold ** memory accounting information. </dd> ** ** <dt>SQLITE_CONFIG_HEAP</dt> ** <dd>This option specifies a static memory buffer that SQLite will use ** for all of its dynamic memory allocation needs beyond those provided ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. ** There are three arguments: A pointer to the memory, the number of ** bytes in the memory buffer, and the minimum allocation size. If |
︙ | ︙ | |||
1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 | ** <dd>This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mutex_methods] structure. The ** [sqlite3_mutex_methods] ** structure is filled with the currently defined mutex routines. ** This option can be used to overload the default mutex allocation ** routines with a wrapper used to track mutex usage for performance ** profiling or testing, for example.</dd> */ #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* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ #define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ #define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ #define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ #define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ #define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ /* | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 | ** <dd>This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mutex_methods] structure. The ** [sqlite3_mutex_methods] ** structure is filled with the currently defined mutex routines. ** This option can be used to overload the default mutex allocation ** routines with a wrapper used to track mutex usage for performance ** profiling or testing, for example.</dd> ** ** <dt>SQLITE_CONFIG_LOOKASIDE</dt> ** <dd>This option takes two arguments that determine the default ** memory allcation lookaside optimization. The first argument is the ** size of each lookaside buffer slot and the second is the number of ** slots allocated to each database connection.</dd> ** ** </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* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ #define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ #define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ #define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ #define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ #define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ #define SQLITE_CONFIG_CHUNKALLOC 12 /* int threshold */ #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ /* ** CAPI3REF: Configuration Options {H10170} <S20000> ** EXPERIMENTAL ** ** These constants are the available integer configuration options that ** can be passed as the second argument to the [sqlite3_db_config()] interface. ** ** New configuration options may be added in future releases of SQLite. ** Existing configuration options might be discontinued. Applications ** should check the return code from [sqlite3_db_config()] to make sure that ** the call worked. The [sqlite3_db_config()] interface will return a ** non-zero [error code] if a discontinued or unsupported configuration option ** is invoked. ** ** <dl> ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt> ** <dd>This option takes three additional arguments that determine the ** [lookaside memory allocator] configuration for the [database connection]. ** The first argument (the third parameter to [sqlite3_db_config()] is a ** pointer to a memory buffer to use for lookaside memory. The first ** argument may be NULL in which case SQLite will allocate the lookaside ** buffer itself using [sqlite3_malloc()]. The second argument is the ** size of each lookaside buffer slot and the third argument is the number of ** slots. The size of the buffer in the first argument must be greater than ** or equal to the product of the second and third arguments.</dd> ** ** </dl> */ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ /* ** CAPI3REF: Enable Or Disable Extended Result Codes {H12200} <S10700> ** ** The sqlite3_extended_result_codes() routine enables or disables the ** [extended result codes] feature of SQLite. The extended result ** codes are disabled by default for historical compatibility considerations. ** ** INVARIANTS: ** ** {H12201} Each new [database connection] shall have the ** [extended result codes] feature disabled by default. ** ** {H12202} The [sqlite3_extended_result_codes(D,F)] interface shall enable ** [extended result codes] for the [database connection] D ** if the F parameter is true, or disable them if F is false. */ int sqlite3_extended_result_codes(sqlite3*, int onoff); /* ** CAPI3REF: Last Insert Rowid {H12220} <S10700> ** ** Each entry in an SQLite table has a unique 64-bit signed ** integer key called the "rowid". The rowid is always available ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those ** names are not also used by explicitly declared columns. If ** the table has a column of type INTEGER PRIMARY KEY then that column ** is another alias for the rowid. |
︙ | ︙ | |||
1208 1209 1210 1211 1212 1213 1214 | ** the return value of this interface. ** ** For the purposes of this routine, an INSERT is considered to ** be successful even if it is subsequently rolled back. ** ** INVARIANTS: ** | | | | | | 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 | ** the return value of this interface. ** ** For the purposes of this routine, an INSERT is considered to ** be successful even if it is subsequently rolled back. ** ** INVARIANTS: ** ** {H12221} The [sqlite3_last_insert_rowid()] function returns the rowid ** of the most recent successful INSERT performed on the same ** [database connection] and within the same or higher level ** trigger context, or zero if there have been no qualifying inserts. ** ** {H12223} The [sqlite3_last_insert_rowid()] function returns the ** same value when called from the same trigger context ** immediately before and after a ROLLBACK. ** ** ASSUMPTIONS: ** ** {A12232} If a separate thread performs a new INSERT on the same ** database connection while the [sqlite3_last_insert_rowid()] ** function is running and thus changes the last insert rowid, ** then the value returned by [sqlite3_last_insert_rowid()] is ** unpredictable and might not equal either the old or the new ** last insert rowid. */ sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); /* ** CAPI3REF: Count The Number Of Rows Modified {H12240} <S10600> ** ** This function returns the number of database rows that were changed ** or inserted or deleted by the most recently completed SQL statement ** on the [database connection] specified by the first parameter. ** Only changes that are directly specified by the INSERT, UPDATE, ** or DELETE statement are counted. Auxiliary changes caused by ** triggers are not counted. Use the [sqlite3_total_changes()] function |
︙ | ︙ | |||
1279 1280 1281 1282 1283 1284 1285 | ** will not be counted by the sqlite3_changes() or [sqlite3_total_changes()] ** functions, regardless of the number of elements that were originally ** in the table. To get an accurate count of the number of rows deleted, use ** "DELETE FROM table WHERE 1" instead. ** ** INVARIANTS: ** | | | | | | 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 | ** will not be counted by the sqlite3_changes() or [sqlite3_total_changes()] ** functions, regardless of the number of elements that were originally ** in the table. To get an accurate count of the number of rows deleted, use ** "DELETE FROM table WHERE 1" instead. ** ** INVARIANTS: ** ** {H12241} The [sqlite3_changes()] function shall return the number of ** row changes caused by the most recent INSERT, UPDATE, ** or DELETE statement on the same database connection and ** within the same or higher trigger context, or zero if there have ** not been any qualifying row changes. ** ** {H12243} Statements of the form "DELETE FROM tablename" with no ** WHERE clause shall cause subsequent calls to ** [sqlite3_changes()] to return zero, regardless of the ** number of rows originally in the table. ** ** ASSUMPTIONS: ** ** {A12252} If a separate thread makes changes on the same database connection ** while [sqlite3_changes()] is running then the value returned ** is unpredictable and not meaningful. */ int sqlite3_changes(sqlite3*); /* ** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600> ** ** This function returns the number of row changes caused by INSERT, ** UPDATE or DELETE statements since the [database connection] was opened. ** The count includes all changes from all trigger contexts. However, ** the count does not include changes used to implement REPLACE constraints, ** do rollbacks or ABORT processing, or DROP table processing. ** The changes are counted as soon as the statement that makes them is |
︙ | ︙ | |||
1323 1324 1325 1326 1327 1328 1329 | ** in the table. To get an accurate count of the number of rows deleted, use ** "DELETE FROM table WHERE 1" instead. ** ** See also the [sqlite3_changes()] interface. ** ** INVARIANTS: ** | | | | | | 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 | ** in the table. To get an accurate count of the number of rows deleted, use ** "DELETE FROM table WHERE 1" instead. ** ** See also the [sqlite3_changes()] interface. ** ** INVARIANTS: ** ** {H12261} The [sqlite3_total_changes()] returns the total number ** of row changes caused by INSERT, UPDATE, and/or DELETE ** statements on the same [database connection], in any ** trigger context, since the database connection was created. ** ** {H12263} Statements of the form "DELETE FROM tablename" with no ** WHERE clause shall not change the value returned ** by [sqlite3_total_changes()]. ** ** ASSUMPTIONS: ** ** {A12264} If a separate thread makes changes on the same database connection ** while [sqlite3_total_changes()] is running then the value ** returned is unpredictable and not meaningful. */ int sqlite3_total_changes(sqlite3*); /* ** CAPI3REF: Interrupt A Long-Running Query {H12270} <S30500> ** ** This function causes any pending database operation to abort and ** return at its earliest opportunity. This routine is typically ** called in response to a user action such as pressing "Cancel" ** or Ctrl-C where the user wants a long query operation to halt ** immediately. ** |
︙ | ︙ | |||
1368 1369 1370 1371 1372 1373 1374 | ** will be rolled back automatically. ** ** A call to sqlite3_interrupt() has no effect on SQL statements ** that are started after sqlite3_interrupt() returns. ** ** INVARIANTS: ** | | | | | | | | | | 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 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 | ** will be rolled back automatically. ** ** A call to sqlite3_interrupt() has no effect on SQL statements ** that are started after sqlite3_interrupt() returns. ** ** INVARIANTS: ** ** {H12271} The [sqlite3_interrupt()] interface will force all running ** SQL statements associated with the same database connection ** to halt after processing at most one additional row of data. ** ** {H12272} Any SQL statement that is interrupted by [sqlite3_interrupt()] ** will return [SQLITE_INTERRUPT]. ** ** ASSUMPTIONS: ** ** {A12279} If the database connection closes while [sqlite3_interrupt()] ** is running then bad things will likely happen. */ void sqlite3_interrupt(sqlite3*); /* ** CAPI3REF: Determine If An SQL Statement Is Complete {H10510} <S70200> ** ** These routines are useful for command-line input to determine if the ** currently entered text seems to form complete a SQL statement or ** if additional input is needed before sending the text into ** SQLite for parsing. These routines return true if the input string ** appears to be a complete SQL statement. A statement is judged to be ** complete if it ends with a semicolon token and is not a fragment of a ** CREATE TRIGGER statement. Semicolons that are embedded within ** string literals or quoted identifier names or comments are not ** independent tokens (they are part of the token in which they are ** embedded) and thus do not count as a statement terminator. ** ** These routines do not parse the SQL statements thus ** will not detect syntactically incorrect SQL. ** ** INVARIANTS: ** ** {H10511} A successful evaluation of [sqlite3_complete()] or ** [sqlite3_complete16()] functions shall ** return a numeric 1 if and only if the last non-whitespace ** token in their input is a semicolon that is not in between ** the BEGIN and END of a CREATE TRIGGER statement. ** ** {H10512} If a memory allocation error occurs during an invocation ** of [sqlite3_complete()] or [sqlite3_complete16()] then the ** routine shall return [SQLITE_NOMEM]. ** ** ASSUMPTIONS: ** ** {A10512} The input to [sqlite3_complete()] must be a zero-terminated ** UTF-8 string. ** ** {A10513} The input to [sqlite3_complete16()] must be a zero-terminated ** UTF-16 string in native byte order. */ int sqlite3_complete(const char *sql); int sqlite3_complete16(const void *sql); /* ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors {H12310} <S40400> ** ** This routine sets a callback function that might be invoked whenever ** an attempt is made to open a database table that another thread ** or process has locked. ** ** If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] ** is returned immediately upon encountering the lock. If the busy callback |
︙ | ︙ | |||
1481 1482 1483 1484 1485 1486 1487 | ** There can only be a single busy handler defined for each ** [database connection]. Setting a new busy handler clears any ** previously set handler. Note that calling [sqlite3_busy_timeout()] ** will also set or clear the busy handler. ** ** INVARIANTS: ** | | | | | | | | | | | | | | 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 | ** There can only be a single busy handler defined for each ** [database connection]. Setting a new busy handler clears any ** previously set handler. Note that calling [sqlite3_busy_timeout()] ** will also set or clear the busy handler. ** ** INVARIANTS: ** ** {H12311} The [sqlite3_busy_handler(D,C,A)] function shall replace ** busy callback in the [database connection] D with a new ** a new busy handler C and application data pointer A. ** ** {H12312} Newly created [database connections] shall have a busy ** handler of NULL. ** ** {H12314} When two or more [database connections] share a ** [sqlite3_enable_shared_cache | common cache], ** the busy handler for the database connection currently using ** the cache shall be invoked when the cache encounters a lock. ** ** {H12316} If a busy handler callback returns zero, then the SQLite interface ** that provoked the locking event shall return [SQLITE_BUSY]. ** ** {H12318} SQLite shall invokes the busy handler with two arguments which ** are a copy of the pointer supplied by the 3rd parameter to ** [sqlite3_busy_handler()] and a count of the number of prior ** invocations of the busy handler for the same locking event. ** ** ASSUMPTIONS: ** ** {A12319} A busy handler must not close the database connection ** or [prepared statement] that invoked the busy handler. */ int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); /* ** CAPI3REF: Set A Busy Timeout {H12340} <S40410> ** ** This routine sets a [sqlite3_busy_handler | busy handler] that sleeps ** for a specified amount of time when a table is locked. The handler ** will sleep multiple times until at least "ms" milliseconds of sleeping ** have accumulated. {H12343} After "ms" milliseconds of sleeping, ** the handler returns 0 which causes [sqlite3_step()] to return ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. ** ** Calling this routine with an argument less than or equal to zero ** turns off all busy handlers. ** ** There can only be a single busy handler for a particular ** [database connection] any any given moment. If another busy handler ** was defined (using [sqlite3_busy_handler()]) prior to calling ** this routine, that other busy handler is cleared. ** ** INVARIANTS: ** ** {H12341} The [sqlite3_busy_timeout()] function shall override any prior ** [sqlite3_busy_timeout()] or [sqlite3_busy_handler()] setting ** on the same [database connection]. ** ** {H12343} If the 2nd parameter to [sqlite3_busy_timeout()] is less than ** or equal to zero, then the busy handler shall be cleared so that ** all subsequent locking events immediately return [SQLITE_BUSY]. ** ** {H12344} If the 2nd parameter to [sqlite3_busy_timeout()] is a positive ** number N, then a busy handler shall be set that repeatedly calls ** the xSleep() method in the [sqlite3_vfs | VFS interface] until ** either the lock clears or until the cumulative sleep time ** reported back by xSleep() exceeds N milliseconds. */ int sqlite3_busy_timeout(sqlite3*, int ms); /* ** CAPI3REF: Convenience Routines For Running Queries {H12370} <S10000> ** ** Definition: A <b>result table</b> is memory data structure created by the ** [sqlite3_get_table()] interface. A result table records the ** complete query results from one or more queries. ** ** The table conceptually has a number of rows and columns. But ** these numbers are not part of the result table itself. These |
︙ | ︙ | |||
1614 1615 1616 1617 1618 1619 1620 | ** to any internal data structures of SQLite. It uses only the public ** interface defined here. As a consequence, errors that occur in the ** wrapper layer outside of the internal [sqlite3_exec()] call are not ** reflected in subsequent calls to [sqlite3_errcode()] or [sqlite3_errmsg()]. ** ** INVARIANTS: ** | | | | | | | | | 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 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 | ** to any internal data structures of SQLite. It uses only the public ** interface defined here. As a consequence, errors that occur in the ** wrapper layer outside of the internal [sqlite3_exec()] call are not ** reflected in subsequent calls to [sqlite3_errcode()] or [sqlite3_errmsg()]. ** ** INVARIANTS: ** ** {H12371} If a [sqlite3_get_table()] fails a memory allocation, then ** it shall free the result table under construction, abort the ** query in process, skip any subsequent queries, set the ** *pazResult output pointer to NULL and return [SQLITE_NOMEM]. ** ** {H12373} If the pnColumn parameter to [sqlite3_get_table()] is not NULL ** then a successful invocation of [sqlite3_get_table()] shall ** write the number of columns in the ** result set of the query into *pnColumn. ** ** {H12374} If the pnRow parameter to [sqlite3_get_table()] is not NULL ** then a successful invocation of [sqlite3_get_table()] shall ** writes the number of rows in the ** result set of the query into *pnRow. ** ** {H12376} A successful invocation of [sqlite3_get_table()] that computes ** N rows of result with C columns per row shall make *pazResult ** point to an array of pointers to (N+1)*C strings where the first ** C strings are column names as obtained from ** [sqlite3_column_name()] and the rest are column result values ** obtained from [sqlite3_column_text()]. ** ** {H12379} The values in the pazResult array returned by [sqlite3_get_table()] ** shall remain valid until cleared by [sqlite3_free_table()]. ** ** {H12382} When an error occurs during evaluation of [sqlite3_get_table()] ** the function shall set *pazResult to NULL, write an error message ** into memory obtained from [sqlite3_malloc()], make ** **pzErrmsg point to that error message, and return a ** appropriate [error code]. */ int sqlite3_get_table( sqlite3 *db, /* An open database */ const char *zSql, /* SQL to be evaluated */ char ***pazResult, /* Results of the query */ int *pnRow, /* Number of result rows written here */ int *pnColumn, /* Number of result columns written here */ char **pzErrmsg /* Error msg written here */ ); void sqlite3_free_table(char **result); /* ** CAPI3REF: Formatted String Printing Functions {H17400} <S70000><S20000> ** ** These routines are workalikes of the "printf()" family of functions ** from the standard C library. ** ** The sqlite3_mprintf() and sqlite3_vmprintf() routines write their ** results into memory obtained from [sqlite3_malloc()]. ** The strings returned by these two routines should be |
︙ | ︙ | |||
1749 1750 1751 1752 1753 1754 1755 | ** ** The "%z" formatting option works exactly like "%s" with the ** addition that after the string has been read and copied into ** the result, [sqlite3_free()] is called on the input string. {END} ** ** INVARIANTS: ** | | | | | | 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 | ** ** The "%z" formatting option works exactly like "%s" with the ** addition that after the string has been read and copied into ** the result, [sqlite3_free()] is called on the input string. {END} ** ** INVARIANTS: ** ** {H17403} The [sqlite3_mprintf()] and [sqlite3_vmprintf()] interfaces ** return either pointers to zero-terminated UTF-8 strings held in ** memory obtained from [sqlite3_malloc()] or NULL pointers if ** a call to [sqlite3_malloc()] fails. ** ** {H17406} The [sqlite3_snprintf()] interface writes a zero-terminated ** UTF-8 string into the buffer pointed to by the second parameter ** provided that the first parameter is greater than zero. ** ** {H17407} The [sqlite3_snprintf()] interface does not write slots of ** its output buffer (the second parameter) outside the range ** of 0 through N-1 (where N is the first parameter) ** regardless of the length of the string ** requested by the format specification. */ char *sqlite3_mprintf(const char*,...); char *sqlite3_vmprintf(const char*, va_list); char *sqlite3_snprintf(int,char*,const char*, ...); /* ** CAPI3REF: Memory Allocation Subsystem {H17300} <S20000> ** ** The SQLite core uses these three routines for all of its own ** internal memory allocation needs. "Core" in the previous sentence ** does not include operating-system specific VFS implementation. The ** Windows VFS uses native malloc() and free() for some operations. ** ** The sqlite3_malloc() routine returns a pointer to a block |
︙ | ︙ | |||
1816 1817 1818 1819 1820 1821 1822 | ** is not freed. ** ** The memory returned by sqlite3_malloc() and sqlite3_realloc() ** is always aligned to at least an 8 byte boundary. {END} ** ** The default implementation of the memory allocation subsystem uses ** the malloc(), realloc() and free() provided by the standard C library. | | | 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 | ** is not freed. ** ** The memory returned by sqlite3_malloc() and sqlite3_realloc() ** is always aligned to at least an 8 byte boundary. {END} ** ** The default implementation of the memory allocation subsystem uses ** the malloc(), realloc() and free() provided by the standard C library. ** {H17382} However, if SQLite is compiled with the ** SQLITE_MEMORY_SIZE=<i>NNN</i> C preprocessor macro (where <i>NNN</i> ** is an integer), then SQLite create a static array of at least ** <i>NNN</i> bytes in size and uses that array for all of its dynamic ** memory allocation needs. {END} Additional memory allocator options ** may be added in future releases. ** ** In SQLite version 3.5.0 and 3.5.1, it was possible to define |
︙ | ︙ | |||
1838 1839 1840 1841 1842 1843 1844 | ** and whatever filename encoding is used by the particular Windows ** installation. Memory allocation errors are detected, but ** they are reported back as [SQLITE_CANTOPEN] or ** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | | | | | 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 | ** and whatever filename encoding is used by the particular Windows ** installation. Memory allocation errors are detected, but ** they are reported back as [SQLITE_CANTOPEN] or ** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. ** ** INVARIANTS: ** ** {H17303} The [sqlite3_malloc(N)] interface returns either a pointer to ** a newly checked-out block of at least N bytes of memory ** that is 8-byte aligned, or it returns NULL if it is unable ** to fulfill the request. ** ** {H17304} The [sqlite3_malloc(N)] interface returns a NULL pointer if ** N is less than or equal to zero. ** ** {H17305} The [sqlite3_free(P)] interface releases memory previously ** returned from [sqlite3_malloc()] or [sqlite3_realloc()], ** making it available for reuse. ** ** {H17306} A call to [sqlite3_free(NULL)] is a harmless no-op. ** ** {H17310} A call to [sqlite3_realloc(0,N)] is equivalent to a call ** to [sqlite3_malloc(N)]. ** ** {H17312} A call to [sqlite3_realloc(P,0)] is equivalent to a call ** to [sqlite3_free(P)]. ** ** {H17315} The SQLite core uses [sqlite3_malloc()], [sqlite3_realloc()], ** and [sqlite3_free()] for all of its memory allocation and ** deallocation needs. ** ** {H17318} The [sqlite3_realloc(P,N)] interface returns either a pointer ** to a block of checked-out memory of at least N bytes in size ** that is 8-byte aligned, or a NULL pointer. ** ** {H17321} When [sqlite3_realloc(P,N)] returns a non-NULL pointer, it first ** copies the first K bytes of content from P into the newly ** allocated block, where K is the lesser of N and the size of ** the buffer P. ** ** {H17322} When [sqlite3_realloc(P,N)] returns a non-NULL pointer, it first ** releases the buffer P. ** ** {H17323} When [sqlite3_realloc(P,N)] returns NULL, the buffer P is ** not modified or released. ** ** ASSUMPTIONS: ** ** {A17350} The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] ** must be either NULL or else pointers obtained from a prior ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have ** not yet been released. ** ** {A17351} The application must not read or write any part of ** a block of memory after it has been released using ** [sqlite3_free()] or [sqlite3_realloc()]. */ void *sqlite3_malloc(int); void *sqlite3_realloc(void*, int); void sqlite3_free(void*); /* ** CAPI3REF: Memory Allocator Statistics {H17370} <S30210> ** ** SQLite provides these two interfaces for reporting on the status ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] ** routines, which form the built-in memory allocation subsystem. ** ** INVARIANTS: ** ** {H17371} The [sqlite3_memory_used()] routine returns the number of bytes ** of memory currently outstanding (malloced but not freed). ** ** {H17373} The [sqlite3_memory_highwater()] routine returns the maximum ** value of [sqlite3_memory_used()] since the high-water mark ** was last reset. ** ** {H17374} The values returned by [sqlite3_memory_used()] and ** [sqlite3_memory_highwater()] include any overhead ** added by SQLite in its implementation of [sqlite3_malloc()], ** but not overhead added by the any underlying system library ** routines that [sqlite3_malloc()] may call. ** ** {H17375} The memory high-water mark is reset to the current value of ** [sqlite3_memory_used()] if and only if the parameter to ** [sqlite3_memory_highwater()] is true. The value returned ** by [sqlite3_memory_highwater(1)] is the high-water mark ** prior to the reset. */ sqlite3_int64 sqlite3_memory_used(void); sqlite3_int64 sqlite3_memory_highwater(int resetFlag); /* ** CAPI3REF: Pseudo-Random Number Generator {H17390} <S20000> ** ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to ** select random ROWIDs when inserting new records into a table that ** already uses the largest possible ROWID. The PRNG is also used for ** the build-in random() and randomblob() SQL functions. This interface allows ** applications to access the same PRNG for other purposes. ** ** A call to this routine stores N bytes of randomness into buffer P. ** ** The first time this routine is invoked (either internally or by ** the application) the PRNG is seeded using randomness obtained ** from the xRandomness method of the default [sqlite3_vfs] object. ** On all subsequent invocations, the pseudo-randomness is generated ** internally and without recourse to the [sqlite3_vfs] xRandomness ** method. ** ** INVARIANTS: ** ** {H17392} The [sqlite3_randomness(N,P)] interface writes N bytes of ** high-quality pseudo-randomness into buffer P. */ void sqlite3_randomness(int N, void *P); /* ** CAPI3REF: Compile-Time Authorization Callbacks {H12500} <S70100> ** ** This routine registers a authorizer callback with a particular ** [database connection], supplied in the first argument. ** The authorizer callback is invoked as SQL statements are being compiled ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. At various ** points during the compilation process, as logic is being created |
︙ | ︙ | |||
2013 2014 2015 2016 2017 2018 2019 | ** ** Note that the authorizer callback is invoked only during ** [sqlite3_prepare()] or its variants. Authorization is not ** performed during statement evaluation in [sqlite3_step()]. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | | | | 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 | ** ** Note that the authorizer callback is invoked only during ** [sqlite3_prepare()] or its variants. Authorization is not ** performed during statement evaluation in [sqlite3_step()]. ** ** INVARIANTS: ** ** {H12501} The [sqlite3_set_authorizer(D,...)] interface registers a ** authorizer callback with database connection D. ** ** {H12502} The authorizer callback is invoked as SQL statements are ** being compiled. ** ** {H12503} If the authorizer callback returns any value other than ** [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY], then ** the [sqlite3_prepare_v2()] or equivalent call that caused ** the authorizer callback to run shall fail with an ** [SQLITE_ERROR] error code and an appropriate error message. ** ** {H12504} When the authorizer callback returns [SQLITE_OK], the operation ** described is processed normally. ** ** {H12505} When the authorizer callback returns [SQLITE_DENY], the ** [sqlite3_prepare_v2()] or equivalent call that caused the ** authorizer callback to run shall fail ** with an [SQLITE_ERROR] error code and an error message ** explaining that access is denied. ** ** {H12506} If the authorizer code (the 2nd parameter to the authorizer ** callback) is [SQLITE_READ] and the authorizer callback returns ** [SQLITE_IGNORE], then the prepared statement is constructed to ** insert a NULL value in place of the table column that would have ** been read if [SQLITE_OK] had been returned. ** ** {H12507} If the authorizer code (the 2nd parameter to the authorizer ** callback) is anything other than [SQLITE_READ], then ** a return of [SQLITE_IGNORE] has the same effect as [SQLITE_DENY]. ** ** {H12510} The first parameter to the authorizer callback is a copy of ** the third parameter to the [sqlite3_set_authorizer()] interface. ** ** {H12511} The second parameter to the callback is an integer ** [SQLITE_COPY | action code] that specifies the particular action ** to be authorized. ** ** {H12512} The third through sixth parameters to the callback are ** zero-terminated strings that contain ** additional details about the action to be authorized. ** ** {H12520} Each call to [sqlite3_set_authorizer()] overrides ** any previously installed authorizer. ** ** {H12521} A NULL authorizer means that no authorization ** callback is invoked. ** ** {H12522} The default authorizer is NULL. */ int sqlite3_set_authorizer( sqlite3*, int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), void *pUserData ); /* ** CAPI3REF: Authorizer Return Codes {H12590} <H12500> ** ** The [sqlite3_set_authorizer | authorizer callback function] must ** return either [SQLITE_OK] or one of these two constants in order ** to signal SQLite whether or not the action is permitted. See the ** [sqlite3_set_authorizer | authorizer documentation] for additional ** information. */ #define SQLITE_DENY 1 /* Abort the SQL statement with an error */ #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ /* ** CAPI3REF: Authorizer Action Codes {H12550} <H12500> ** ** The [sqlite3_set_authorizer()] interface registers a callback function ** that is invoked to authorize certain SQL statement actions. The ** second parameter to the callback is an integer code that specifies ** what action is being authorized. These are the integer action codes that ** the authorizer callback may be passed. ** ** These action code values signify what kind of operation is to be ** authorized. The 3rd and 4th parameters to the authorization ** callback function will be parameters or NULL depending on which of these ** codes is used as the second parameter. The 5th parameter to the ** authorizer callback is the name of the database ("main", "temp", ** etc.) if applicable. The 6th parameter to the authorizer callback ** is the name of the inner-most trigger or view that is responsible for ** the access attempt or NULL if this access attempt is directly from ** top-level SQL code. ** ** INVARIANTS: ** ** {H12551} The second parameter to an ** [sqlite3_set_authorizer | authorizer callback] is always an integer ** [SQLITE_COPY | authorizer code] that specifies what action ** is being authorized. ** ** {H12552} The 3rd and 4th parameters to the ** [sqlite3_set_authorizer | authorization callback] ** will be parameters or NULL depending on which ** [SQLITE_COPY | authorizer code] is used as the second parameter. ** ** {H12553} The 5th parameter to the ** [sqlite3_set_authorizer | authorizer callback] is the name ** of the database (example: "main", "temp", etc.) if applicable. ** ** {H12554} The 6th parameter to the ** [sqlite3_set_authorizer | authorizer callback] is the name ** of the inner-most trigger or view that is responsible for ** the access attempt or NULL if this access attempt is directly from ** top-level SQL code. */ /******************************************* 3rd ************ 4th ***********/ #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ |
︙ | ︙ | |||
2157 2158 2159 2160 2161 2162 2163 | #define SQLITE_ANALYZE 28 /* Table Name NULL */ #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ #define SQLITE_FUNCTION 31 /* Function Name NULL */ #define SQLITE_COPY 0 /* No longer used */ /* | | > < < < < < < < < | | | | | | | | | | | | | | | | | | > | | 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 | #define SQLITE_ANALYZE 28 /* Table Name NULL */ #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ #define SQLITE_FUNCTION 31 /* Function Name NULL */ #define SQLITE_COPY 0 /* No longer used */ /* ** CAPI3REF: Tracing And Profiling Functions {H12280} <S60400> ** EXPERIMENTAL ** ** These routines register callback functions that can be used for ** tracing and profiling the execution of SQL statements. ** ** The callback function registered by sqlite3_trace() is invoked at ** various times when an SQL statement is being run by [sqlite3_step()]. ** The callback returns a UTF-8 rendering of the SQL statement text ** as the statement first begins executing. Additional callbacks occur ** as each triggered subprogram is entered. The callbacks for triggers ** contain a UTF-8 SQL comment that identifies the trigger. ** ** The callback function registered by sqlite3_profile() is invoked ** as each SQL statement finishes. The profile callback contains ** the original statement text and an estimate of wall-clock time ** of how long that statement took to run. ** ** INVARIANTS: ** ** {H12281} The callback function registered by [sqlite3_trace()] is ** whenever an SQL statement first begins to execute and ** whenever a trigger subprogram first begins to run. ** ** {H12282} Each call to [sqlite3_trace()] overrides the previously ** registered trace callback. ** ** {H12283} A NULL trace callback disables tracing. ** ** {H12284} The first argument to the trace callback is a copy of ** the pointer which was the 3rd argument to [sqlite3_trace()]. ** ** {H12285} The second argument to the trace callback is a ** zero-terminated UTF-8 string containing the original text ** of the SQL statement as it was passed into [sqlite3_prepare_v2()] ** or the equivalent, or an SQL comment indicating the beginning ** of a trigger subprogram. ** ** {H12287} The callback function registered by [sqlite3_profile()] is invoked ** as each SQL statement finishes. ** ** {H12288} The first parameter to the profile callback is a copy of ** the 3rd parameter to [sqlite3_profile()]. ** ** {H12289} The second parameter to the profile callback is a ** zero-terminated UTF-8 string that contains the complete text of ** the SQL statement as it was processed by [sqlite3_prepare_v2()] ** or the equivalent. ** ** {H12290} The third parameter to the profile callback is an estimate ** of the number of nanoseconds of wall-clock time required to ** run the SQL statement from start to finish. */ void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); void *sqlite3_profile(sqlite3*, void(*xProfile)(void*,const char*,sqlite3_uint64), void*); /* ** CAPI3REF: Query Progress Callbacks {H12910} <S60400> ** ** This routine configures a callback function - the ** progress callback - that is invoked periodically during long ** running calls to [sqlite3_exec()], [sqlite3_step()] and ** [sqlite3_get_table()]. An example use for this ** interface is to keep a GUI updated during a large query. ** ** If the progress callback returns non-zero, the operation is ** interrupted. This feature can be used to implement a ** "Cancel" button on a GUI dialog box. ** ** INVARIANTS: ** ** {H12911} The callback function registered by sqlite3_progress_handler() ** is invoked periodically during long running calls to ** [sqlite3_step()]. ** ** {H12912} The progress callback is invoked once for every N virtual ** machine opcodes, where N is the second argument to ** the [sqlite3_progress_handler()] call that registered ** the callback. If N is less than 1, sqlite3_progress_handler() ** acts as if a NULL progress handler had been specified. ** ** {H12913} The progress callback itself is identified by the third ** argument to sqlite3_progress_handler(). ** ** {H12914} The fourth argument to sqlite3_progress_handler() is a ** void pointer passed to the progress callback ** function each time it is invoked. ** ** {H12915} If a call to [sqlite3_step()] results in fewer than N opcodes ** being executed, then the progress callback is never invoked. ** ** {H12916} Every call to [sqlite3_progress_handler()] ** overwrites any previously registered progress handler. ** ** {H12917} If the progress handler callback is NULL then no progress ** handler is invoked. ** ** {H12918} If the progress callback returns a result other than 0, then ** the behavior is a if [sqlite3_interrupt()] had been called. ** <S30500> */ void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); /* ** CAPI3REF: Opening A New Database Connection {H12700} <S40200> ** ** These routines open an SQLite database file whose name is given by the ** filename argument. The filename argument is interpreted as UTF-8 for ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte ** order for sqlite3_open16(). A [database connection] handle is usually ** returned in *ppDb, even if an error occurs. The only exception is that ** if SQLite is unable to allocate memory to hold the [sqlite3] object, |
︙ | ︙ | |||
2350 2351 2352 2353 2354 2355 2356 | ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever ** codepage is currently defined. Filenames containing international ** characters must be converted to UTF-8 prior to passing them into ** sqlite3_open() or sqlite3_open_v2(). ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | | | | | | | 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 | ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever ** codepage is currently defined. Filenames containing international ** characters must be converted to UTF-8 prior to passing them into ** sqlite3_open() or sqlite3_open_v2(). ** ** INVARIANTS: ** ** {H12701} The [sqlite3_open()], [sqlite3_open16()], and ** [sqlite3_open_v2()] interfaces create a new ** [database connection] associated with ** the database file given in their first parameter. ** ** {H12702} The filename argument is interpreted as UTF-8 ** for [sqlite3_open()] and [sqlite3_open_v2()] and as UTF-16 ** in the native byte order for [sqlite3_open16()]. ** ** {H12703} A successful invocation of [sqlite3_open()], [sqlite3_open16()], ** or [sqlite3_open_v2()] writes a pointer to a new ** [database connection] into *ppDb. ** ** {H12704} The [sqlite3_open()], [sqlite3_open16()], and ** [sqlite3_open_v2()] interfaces return [SQLITE_OK] upon success, ** or an appropriate [error code] on failure. ** ** {H12706} The default text encoding for a new database created using ** [sqlite3_open()] or [sqlite3_open_v2()] will be UTF-8. ** ** {H12707} The default text encoding for a new database created using ** [sqlite3_open16()] will be UTF-16. ** ** {H12709} The [sqlite3_open(F,D)] interface is equivalent to ** [sqlite3_open_v2(F,D,G,0)] where the G parameter is ** [SQLITE_OPEN_READWRITE]|[SQLITE_OPEN_CREATE]. ** ** {H12711} If the G parameter to [sqlite3_open_v2(F,D,G,V)] contains the ** bit value [SQLITE_OPEN_READONLY] then the database is opened ** for reading only. ** ** {H12712} If the G parameter to [sqlite3_open_v2(F,D,G,V)] contains the ** bit value [SQLITE_OPEN_READWRITE] then the database is opened ** reading and writing if possible, or for reading only if the ** file is write protected by the operating system. ** ** {H12713} If the G parameter to [sqlite3_open(v2(F,D,G,V)] omits the ** bit value [SQLITE_OPEN_CREATE] and the database does not ** previously exist, an error is returned. ** ** {H12714} If the G parameter to [sqlite3_open(v2(F,D,G,V)] contains the ** bit value [SQLITE_OPEN_CREATE] and the database does not ** previously exist, then an attempt is made to create and ** initialize the database. ** ** {H12717} If the filename argument to [sqlite3_open()], [sqlite3_open16()], ** or [sqlite3_open_v2()] is ":memory:", then an private, ** ephemeral, in-memory database is created for the connection. ** <todo>Is SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE required ** in sqlite3_open_v2()?</todo> ** ** {H12719} If the filename is NULL or an empty string, then a private, ** ephemeral on-disk database will be created. ** <todo>Is SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE required ** in sqlite3_open_v2()?</todo> ** ** {H12721} The [database connection] created by [sqlite3_open_v2(F,D,G,V)] ** will use the [sqlite3_vfs] object identified by the V parameter, ** or the default [sqlite3_vfs] object if V is a NULL pointer. ** ** {H12723} Two [database connections] will share a common cache if both were ** opened with the same VFS while [shared cache mode] was enabled and ** if both filenames compare equal using memcmp() after having been ** processed by the [sqlite3_vfs | xFullPathname] method of the VFS. */ int sqlite3_open( const char *filename, /* Database filename (UTF-8) */ sqlite3 **ppDb /* OUT: SQLite db handle */ ); int sqlite3_open16( const void *filename, /* Database filename (UTF-16) */ sqlite3 **ppDb /* OUT: SQLite db handle */ ); int sqlite3_open_v2( const char *filename, /* Database filename (UTF-8) */ sqlite3 **ppDb, /* OUT: SQLite db handle */ int flags, /* Flags */ const char *zVfs /* Name of VFS module to use */ ); /* ** CAPI3REF: Error Codes And Messages {H12800} <S60200> ** ** The sqlite3_errcode() interface returns the numeric [result code] or ** [extended result code] for the most recent failed sqlite3_* API call ** associated with a [database connection]. If a prior API call failed ** but the most recent API call succeeded, the return value from ** sqlite3_errcode() is undefined. ** ** The sqlite3_errmsg() and sqlite3_errmsg16() return English-language ** text that describes the error, as either UTF-8 or UTF-16 respectively. ** Memory to hold the error message string is managed internally. ** The application does not need to worry about freeing the result. ** However, the error string might be overwritten or deallocated by ** subsequent calls to other SQLite interface functions. ** ** If an interface fails with SQLITE_MISUSE, that means the interface ** was invoked incorrectly by the application. In that case, the ** error code and message may or may not be set. ** ** INVARIANTS: ** ** {H12801} The [sqlite3_errcode(D)] interface returns the numeric ** [result code] or [extended result code] for the most recently ** failed interface call associated with the [database connection] D. ** ** {H12803} The [sqlite3_errmsg(D)] and [sqlite3_errmsg16(D)] ** interfaces return English-language text that describes ** the error in the mostly recently failed interface call, ** encoded as either UTF-8 or UTF-16 respectively. ** ** {H12807} The strings returned by [sqlite3_errmsg()] and [sqlite3_errmsg16()] ** are valid until the next SQLite interface call. ** ** {H12808} Calls to API routines that do not return an error code ** (example: [sqlite3_data_count()]) do not ** change the error code or message returned by ** [sqlite3_errcode()], [sqlite3_errmsg()], or [sqlite3_errmsg16()]. ** ** {H12809} Interfaces that are not associated with a specific ** [database connection] (examples: ** [sqlite3_mprintf()] or [sqlite3_enable_shared_cache()] ** do not change the values returned by ** [sqlite3_errcode()], [sqlite3_errmsg()], or [sqlite3_errmsg16()]. */ int sqlite3_errcode(sqlite3 *db); const char *sqlite3_errmsg(sqlite3*); const void *sqlite3_errmsg16(sqlite3*); /* ** CAPI3REF: SQL Statement Object {H13000} <H13010> ** KEYWORDS: {prepared statement} {prepared statements} ** ** An instance of this object represents a single SQL statement. ** This object is variously known as a "prepared statement" or a ** "compiled SQL statement" or simply as a "statement". ** ** The life of a statement object goes something like this: |
︙ | ︙ | |||
2506 2507 2508 2509 2510 2511 2512 | ** ** Refer to documentation on individual methods above for additional ** information. */ typedef struct sqlite3_stmt sqlite3_stmt; /* | | | 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 | ** ** Refer to documentation on individual methods above for additional ** information. */ typedef struct sqlite3_stmt sqlite3_stmt; /* ** CAPI3REF: Run-time Limits {H12760} <S20600> ** ** This interface allows the size of various constructs to be limited ** on a connection by connection basis. The first parameter is the ** [database connection] whose limit is to be set or queried. The ** second parameter is one of the [limit categories] that define a ** class of constructs to be size limited. The third parameter is the ** new limit for that construct. The function returns the old limit. |
︙ | ︙ | |||
2539 2540 2541 2542 2543 2544 2545 | ** created by an untrusted script can be contained using the ** [max_page_count] [PRAGMA]. ** ** New run-time limit categories may be added in future releases. ** ** INVARIANTS: ** | | | | | | 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 | ** created by an untrusted script can be contained using the ** [max_page_count] [PRAGMA]. ** ** New run-time limit categories may be added in future releases. ** ** INVARIANTS: ** ** {H12762} A successful call to [sqlite3_limit(D,C,V)] where V is ** positive changes the limit on the size of construct C in the ** [database connection] D to the lesser of V and the hard upper ** bound on the size of C that is set at compile-time. ** ** {H12766} A successful call to [sqlite3_limit(D,C,V)] where V is negative ** leaves the state of the [database connection] D unchanged. ** ** {H12769} A successful call to [sqlite3_limit(D,C,V)] returns the ** value of the limit on the size of construct C in the ** [database connection] D as it was prior to the call. */ int sqlite3_limit(sqlite3*, int id, int newVal); /* ** CAPI3REF: Run-Time Limit Categories {H12790} <H12760> ** KEYWORDS: {limit category} {limit categories} ** ** These constants define various aspects of a [database connection] ** that can be limited in size by calls to [sqlite3_limit()]. ** The meanings of the various limits are as follows: ** ** <dl> |
︙ | ︙ | |||
2610 2611 2612 2613 2614 2615 2616 | #define SQLITE_LIMIT_VDBE_OP 5 #define SQLITE_LIMIT_FUNCTION_ARG 6 #define SQLITE_LIMIT_ATTACHED 7 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 #define SQLITE_LIMIT_VARIABLE_NUMBER 9 /* | | | 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 | #define SQLITE_LIMIT_VDBE_OP 5 #define SQLITE_LIMIT_FUNCTION_ARG 6 #define SQLITE_LIMIT_ATTACHED 7 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 #define SQLITE_LIMIT_VARIABLE_NUMBER 9 /* ** CAPI3REF: Compiling An SQL Statement {H13010} <S10000> ** KEYWORDS: {SQL statement compiler} ** ** To execute an SQL query, it must first be compiled into a byte-code ** program using one of these routines. ** ** The first argument, "db", is a [database connection] obtained from a ** prior call to [sqlite3_open()], [sqlite3_open_v2()] or [sqlite3_open16()]. |
︙ | ︙ | |||
2680 2681 2682 2683 2684 2685 2686 | ** to find the underlying cause of the problem. With the "v2" prepare ** interfaces, the underlying reason for the error is returned immediately. ** </li> ** </ol> ** ** INVARIANTS: ** | | | | | | | | | | 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 | ** to find the underlying cause of the problem. With the "v2" prepare ** interfaces, the underlying reason for the error is returned immediately. ** </li> ** </ol> ** ** INVARIANTS: ** ** {H13011} The [sqlite3_prepare(db,zSql,...)] and ** [sqlite3_prepare_v2(db,zSql,...)] interfaces interpret the ** text in their zSql parameter as UTF-8. ** ** {H13012} The [sqlite3_prepare16(db,zSql,...)] and ** [sqlite3_prepare16_v2(db,zSql,...)] interfaces interpret the ** text in their zSql parameter as UTF-16 in the native byte order. ** ** {H13013} If the nByte argument to [sqlite3_prepare_v2(db,zSql,nByte,...)] ** and its variants is less than zero, the SQL text is ** read from zSql is read up to the first zero terminator. ** ** {H13014} If the nByte argument to [sqlite3_prepare_v2(db,zSql,nByte,...)] ** and its variants is non-negative, then at most nBytes bytes of ** SQL text is read from zSql. ** ** {H13015} In [sqlite3_prepare_v2(db,zSql,N,P,pzTail)] and its variants ** if the zSql input text contains more than one SQL statement ** and pzTail is not NULL, then *pzTail is made to point to the ** first byte past the end of the first SQL statement in zSql. ** <todo>What does *pzTail point to if there is one statement?</todo> ** ** {H13016} A successful call to [sqlite3_prepare_v2(db,zSql,N,ppStmt,...)] ** or one of its variants writes into *ppStmt a pointer to a new ** [prepared statement] or a pointer to NULL if zSql contains ** nothing other than whitespace or comments. ** ** {H13019} The [sqlite3_prepare_v2()] interface and its variants return ** [SQLITE_OK] or an appropriate [error code] upon failure. ** ** {H13021} Before [sqlite3_prepare(db,zSql,nByte,ppStmt,pzTail)] or its ** variants returns an error (any value other than [SQLITE_OK]), ** they first set *ppStmt to NULL. */ int sqlite3_prepare( sqlite3 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ int nByte, /* Maximum length of zSql in bytes. */ |
︙ | ︙ | |||
2744 2745 2746 2747 2748 2749 2750 | const void *zSql, /* SQL statement, UTF-16 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); /* | | | | | | | 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 | const void *zSql, /* SQL statement, UTF-16 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); /* ** CAPIREF: Retrieving Statement SQL {H13100} <H13000> ** ** This interface can be used to retrieve a saved copy of the original ** SQL text used to create a [prepared statement] if that statement was ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. ** ** INVARIANTS: ** ** {H13101} If the [prepared statement] passed as the argument to ** [sqlite3_sql()] was compiled using either [sqlite3_prepare_v2()] or ** [sqlite3_prepare16_v2()], then [sqlite3_sql()] returns ** a pointer to a zero-terminated string containing a UTF-8 rendering ** of the original SQL statement. ** ** {H13102} If the [prepared statement] passed as the argument to ** [sqlite3_sql()] was compiled using either [sqlite3_prepare()] or ** [sqlite3_prepare16()], then [sqlite3_sql()] returns a NULL pointer. ** ** {H13103} The string returned by [sqlite3_sql(S)] is valid until the ** [prepared statement] S is deleted using [sqlite3_finalize(S)]. */ const char *sqlite3_sql(sqlite3_stmt *pStmt); /* ** CAPI3REF: Dynamically Typed Value Object {H15000} <S20200> ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} ** ** SQLite uses the sqlite3_value object to represent all values ** that can be stored in a database table. SQLite uses dynamic typing ** for the values it stores. Values stored in sqlite3_value objects ** can be integers, floating point values, strings, BLOBs, or NULL. ** |
︙ | ︙ | |||
2807 2808 2809 2810 2811 2812 2813 | ** [sqlite3_result_value()] and [sqlite3_bind_value()]. ** The [sqlite3_value_blob | sqlite3_value_type()] family of ** interfaces require protected sqlite3_value objects. */ typedef struct Mem sqlite3_value; /* | | | | 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 | ** [sqlite3_result_value()] and [sqlite3_bind_value()]. ** The [sqlite3_value_blob | sqlite3_value_type()] family of ** interfaces require protected sqlite3_value objects. */ typedef struct Mem sqlite3_value; /* ** CAPI3REF: SQL Function Context Object {H16001} <S20200> ** ** The context in which an SQL function executes is stored in an ** sqlite3_context object. A pointer to an sqlite3_context object ** is always first parameter to [application-defined SQL functions]. ** The application-defined SQL function implementation will pass this ** pointer through into calls to [sqlite3_result_int | sqlite3_result()], ** [sqlite3_aggregate_context()], [sqlite3_user_data()], ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], ** and/or [sqlite3_set_auxdata()]. */ typedef struct sqlite3_context sqlite3_context; /* ** CAPI3REF: Binding Values To Prepared Statements {H13500} <S70300> ** KEYWORDS: {host parameter} {host parameters} {host parameter name} ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} ** ** In the SQL strings input to [sqlite3_prepare_v2()] and its variants, ** literals may be replaced by a parameter in one of these forms: ** ** <ul> |
︙ | ︙ | |||
2901 2902 2903 2904 2905 2906 2907 | ** panic rather than return SQLITE_MISUSE. ** ** See also: [sqlite3_bind_parameter_count()], ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | | | | 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 | ** panic rather than return SQLITE_MISUSE. ** ** See also: [sqlite3_bind_parameter_count()], ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. ** ** INVARIANTS: ** ** {H13506} The [SQL statement compiler] recognizes tokens of the forms ** "?", "?NNN", "$VVV", ":VVV", and "@VVV" as SQL parameters, ** where NNN is any sequence of one or more digits ** and where VVV is any sequence of one or more alphanumeric ** characters or "::" optionally followed by a string containing ** no spaces and contained within parentheses. ** ** {H13509} The initial value of an SQL parameter is NULL. ** ** {H13512} The index of an "?" SQL parameter is one larger than the ** largest index of SQL parameter to the left, or 1 if ** the "?" is the leftmost SQL parameter. ** ** {H13515} The index of an "?NNN" SQL parameter is the integer NNN. ** ** {H13518} The index of an ":VVV", "$VVV", or "@VVV" SQL parameter is ** the same as the index of leftmost occurrences of the same ** parameter, or one more than the largest index over all ** parameters to the left if this is the first occurrence ** of this parameter, or 1 if this is the leftmost parameter. ** ** {H13521} The [SQL statement compiler] fails with an [SQLITE_RANGE] ** error if the index of an SQL parameter is less than 1 ** or greater than the compile-time SQLITE_MAX_VARIABLE_NUMBER ** parameter. ** ** {H13524} Calls to [sqlite3_bind_text | sqlite3_bind(S,N,V,...)] ** associate the value V with all SQL parameters having an ** index of N in the [prepared statement] S. ** ** {H13527} Calls to [sqlite3_bind_text | sqlite3_bind(S,N,...)] ** override prior calls with the same values of S and N. ** ** {H13530} Bindings established by [sqlite3_bind_text | sqlite3_bind(S,...)] ** persist across calls to [sqlite3_reset(S)]. ** ** {H13533} In calls to [sqlite3_bind_blob(S,N,V,L,D)], ** [sqlite3_bind_text(S,N,V,L,D)], or ** [sqlite3_bind_text16(S,N,V,L,D)] SQLite binds the first L ** bytes of the BLOB or string pointed to by V, when L ** is non-negative. ** ** {H13536} In calls to [sqlite3_bind_text(S,N,V,L,D)] or ** [sqlite3_bind_text16(S,N,V,L,D)] SQLite binds characters ** from V through the first zero character when L is negative. ** ** {H13539} In calls to [sqlite3_bind_blob(S,N,V,L,D)], ** [sqlite3_bind_text(S,N,V,L,D)], or ** [sqlite3_bind_text16(S,N,V,L,D)] when D is the special ** constant [SQLITE_STATIC], SQLite assumes that the value V ** is held in static unmanaged space that will not change ** during the lifetime of the binding. ** ** {H13542} In calls to [sqlite3_bind_blob(S,N,V,L,D)], ** [sqlite3_bind_text(S,N,V,L,D)], or ** [sqlite3_bind_text16(S,N,V,L,D)] when D is the special ** constant [SQLITE_TRANSIENT], the routine makes a ** private copy of the value V before it returns. ** ** {H13545} In calls to [sqlite3_bind_blob(S,N,V,L,D)], ** [sqlite3_bind_text(S,N,V,L,D)], or ** [sqlite3_bind_text16(S,N,V,L,D)] when D is a pointer to ** a function, SQLite invokes that function to destroy the ** value V after it has finished using the value V. ** ** {H13548} In calls to [sqlite3_bind_zeroblob(S,N,V,L)] the value bound ** is a BLOB of L bytes, or a zero-length BLOB if L is negative. ** ** {H13551} In calls to [sqlite3_bind_value(S,N,V)] the V argument may ** be either a [protected sqlite3_value] object or an ** [unprotected sqlite3_value] object. */ int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); int sqlite3_bind_double(sqlite3_stmt*, int, double); int sqlite3_bind_int(sqlite3_stmt*, int, int); int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); int sqlite3_bind_null(sqlite3_stmt*, int); int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*)); int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); /* ** CAPI3REF: Number Of SQL Parameters {H13600} <S70300> ** ** This routine can be used to find the number of [SQL parameters] ** in a [prepared statement]. SQL parameters are tokens of the ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as ** placeholders for values that are [sqlite3_bind_blob | bound] ** to the parameters at a later time. ** ** This routine actually returns the index of the largest (rightmost) ** parameter. For all forms except ?NNN, this will correspond to the ** number of unique parameters. If parameters of the ?NNN are used, ** there may be gaps in the list. ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_name()], and ** [sqlite3_bind_parameter_index()]. ** ** INVARIANTS: ** ** {H13601} The [sqlite3_bind_parameter_count(S)] interface returns ** the largest index of all SQL parameters in the ** [prepared statement] S, or 0 if S contains no SQL parameters. */ int sqlite3_bind_parameter_count(sqlite3_stmt*); /* ** CAPI3REF: Name Of A Host Parameter {H13620} <S70300> ** ** This routine returns a pointer to the name of the n-th ** [SQL parameter] in a [prepared statement]. ** SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA" ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" ** respectively. ** In other words, the initial ":" or "$" or "@" or "?" |
︙ | ︙ | |||
3036 3037 3038 3039 3040 3041 3042 | ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_count()], and ** [sqlite3_bind_parameter_index()]. ** ** INVARIANTS: ** | | | | | | | | | | 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 | ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_count()], and ** [sqlite3_bind_parameter_index()]. ** ** INVARIANTS: ** ** {H13621} The [sqlite3_bind_parameter_name(S,N)] interface returns ** a UTF-8 rendering of the name of the SQL parameter in ** the [prepared statement] S having index N, or ** NULL if there is no SQL parameter with index N or if the ** parameter with index N is an anonymous parameter "?". */ const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); /* ** CAPI3REF: Index Of A Parameter With A Given Name {H13640} <S70300> ** ** Return the index of an SQL parameter given its name. The ** index value returned is suitable for use as the second ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. A zero ** is returned if no matching parameter is found. The parameter ** name must be given in UTF-8 even if the original statement ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()]. ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_count()], and ** [sqlite3_bind_parameter_index()]. ** ** INVARIANTS: ** ** {H13641} The [sqlite3_bind_parameter_index(S,N)] interface returns ** the index of SQL parameter in the [prepared statement] ** S whose name matches the UTF-8 string N, or 0 if there is ** no match. */ int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); /* ** CAPI3REF: Reset All Bindings On A Prepared Statement {H13660} <S70300> ** ** Contrary to the intuition of many, [sqlite3_reset()] does not reset ** the [sqlite3_bind_blob | bindings] on a [prepared statement]. ** Use this routine to reset all host parameters to NULL. ** ** INVARIANTS: ** ** {H13661} The [sqlite3_clear_bindings(S)] interface resets all SQL ** parameter bindings in the [prepared statement] S back to NULL. */ int sqlite3_clear_bindings(sqlite3_stmt*); /* ** CAPI3REF: Number Of Columns In A Result Set {H13710} <S10700> ** ** Return the number of columns in the result set returned by the ** [prepared statement]. This routine returns 0 if pStmt is an SQL ** statement that does not return data (for example an [UPDATE]). ** ** INVARIANTS: ** ** {H13711} The [sqlite3_column_count(S)] interface returns the number of ** columns in the result set generated by the [prepared statement] S, ** or 0 if S does not generate a result set. */ int sqlite3_column_count(sqlite3_stmt *pStmt); /* ** CAPI3REF: Column Names In A Result Set {H13720} <S10700> ** ** These routines return the name assigned to a particular column ** in the result set of a [SELECT] statement. The sqlite3_column_name() ** interface returns a pointer to a zero-terminated UTF-8 string ** and sqlite3_column_name16() returns a pointer to a zero-terminated ** UTF-16 string. The first parameter is the [prepared statement] ** that implements the [SELECT] statement. The second parameter is the |
︙ | ︙ | |||
3122 3123 3124 3125 3126 3127 3128 | ** The name of a result column is the value of the "AS" clause for ** that column, if there is an AS clause. If there is no AS clause ** then the name of the column is unspecified and may change from ** one release of SQLite to the next. ** ** INVARIANTS: ** | | | | | | | | | 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 | ** The name of a result column is the value of the "AS" clause for ** that column, if there is an AS clause. If there is no AS clause ** then the name of the column is unspecified and may change from ** one release of SQLite to the next. ** ** INVARIANTS: ** ** {H13721} A successful invocation of the [sqlite3_column_name(S,N)] ** interface returns the name of the Nth column (where 0 is ** the leftmost column) for the result set of the ** [prepared statement] S as a zero-terminated UTF-8 string. ** ** {H13723} A successful invocation of the [sqlite3_column_name16(S,N)] ** interface returns the name of the Nth column (where 0 is ** the leftmost column) for the result set of the ** [prepared statement] S as a zero-terminated UTF-16 string ** in the native byte order. ** ** {H13724} The [sqlite3_column_name()] and [sqlite3_column_name16()] ** interfaces return a NULL pointer if they are unable to ** allocate memory to hold their normal return strings. ** ** {H13725} If the N parameter to [sqlite3_column_name(S,N)] or ** [sqlite3_column_name16(S,N)] is out of range, then the ** interfaces return a NULL pointer. ** ** {H13726} The strings returned by [sqlite3_column_name(S,N)] and ** [sqlite3_column_name16(S,N)] are valid until the next ** call to either routine with the same S and N parameters ** or until [sqlite3_finalize(S)] is called. ** ** {H13727} When a result column of a [SELECT] statement contains ** an AS clause, the name of that column is the identifier ** to the right of the AS keyword. */ const char *sqlite3_column_name(sqlite3_stmt*, int N); const void *sqlite3_column_name16(sqlite3_stmt*, int N); /* ** CAPI3REF: Source Of Data In A Query Result {H13740} <S10700> ** ** These routines provide a means to determine what column of what ** table in which database a result of a [SELECT] statement comes from. ** The name of the database or table or column can be returned as ** either a UTF-8 or UTF-16 string. The _database_ routines return ** the database name, the _table_ routines return the table name, and ** the origin_ routines return the column name. |
︙ | ︙ | |||
3192 3193 3194 3195 3196 3197 3198 | ** {A13751} ** If two or more threads call one or more of these routines against the same ** prepared statement and column at the same time then the results are ** undefined. ** ** INVARIANTS: ** | | | | | | | | | | | 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 | ** {A13751} ** If two or more threads call one or more of these routines against the same ** prepared statement and column at the same time then the results are ** undefined. ** ** INVARIANTS: ** ** {H13741} The [sqlite3_column_database_name(S,N)] interface returns either ** the UTF-8 zero-terminated name of the database from which the ** Nth result column of the [prepared statement] S is extracted, ** or NULL if the Nth column of S is a general expression ** or if unable to allocate memory to store the name. ** ** {H13742} The [sqlite3_column_database_name16(S,N)] interface returns either ** the UTF-16 native byte order zero-terminated name of the database ** from which the Nth result column of the [prepared statement] S is ** extracted, or NULL if the Nth column of S is a general expression ** or if unable to allocate memory to store the name. ** ** {H13743} The [sqlite3_column_table_name(S,N)] interface returns either ** the UTF-8 zero-terminated name of the table from which the ** Nth result column of the [prepared statement] S is extracted, ** or NULL if the Nth column of S is a general expression ** or if unable to allocate memory to store the name. ** ** {H13744} The [sqlite3_column_table_name16(S,N)] interface returns either ** the UTF-16 native byte order zero-terminated name of the table ** from which the Nth result column of the [prepared statement] S is ** extracted, or NULL if the Nth column of S is a general expression ** or if unable to allocate memory to store the name. ** ** {H13745} The [sqlite3_column_origin_name(S,N)] interface returns either ** the UTF-8 zero-terminated name of the table column from which the ** Nth result column of the [prepared statement] S is extracted, ** or NULL if the Nth column of S is a general expression ** or if unable to allocate memory to store the name. ** ** {H13746} The [sqlite3_column_origin_name16(S,N)] interface returns either ** the UTF-16 native byte order zero-terminated name of the table ** column from which the Nth result column of the ** [prepared statement] S is extracted, or NULL if the Nth column ** of S is a general expression or if unable to allocate memory ** to store the name. ** ** {H13748} The return values from ** [sqlite3_column_database_name | column metadata interfaces] ** are valid for the lifetime of the [prepared statement] ** or until the encoding is changed by another metadata ** interface call for the same prepared statement and column. ** ** ASSUMPTIONS: ** ** {A13751} If two or more threads call one or more ** [sqlite3_column_database_name | column metadata interfaces] ** for the same [prepared statement] and result column ** at the same time then the results are undefined. */ const char *sqlite3_column_database_name(sqlite3_stmt*,int); const void *sqlite3_column_database_name16(sqlite3_stmt*,int); const char *sqlite3_column_table_name(sqlite3_stmt*,int); const void *sqlite3_column_table_name16(sqlite3_stmt*,int); const char *sqlite3_column_origin_name(sqlite3_stmt*,int); const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); /* ** CAPI3REF: Declared Datatype Of A Query Result {H13760} <S10700> ** ** The first parameter is a [prepared statement]. ** If this statement is a [SELECT] statement and the Nth column of the ** returned result set of that [SELECT] is a table column (not an ** expression or subquery) then the declared type of the table ** column is returned. If the Nth column of the result set is an ** expression or subquery, then a NULL pointer is returned. |
︙ | ︙ | |||
3280 3281 3282 3283 3284 3285 3286 | ** data stored in that column is of the declared type. SQLite is ** strongly typed, but the typing is dynamic not static. Type ** is associated with individual values, not with the containers ** used to hold those values. ** ** INVARIANTS: ** | | | | | | 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 | ** data stored in that column is of the declared type. SQLite is ** strongly typed, but the typing is dynamic not static. Type ** is associated with individual values, not with the containers ** used to hold those values. ** ** INVARIANTS: ** ** {H13761} A successful call to [sqlite3_column_decltype(S,N)] returns a ** zero-terminated UTF-8 string containing the declared datatype ** of the table column that appears as the Nth column (numbered ** from 0) of the result set to the [prepared statement] S. ** ** {H13762} A successful call to [sqlite3_column_decltype16(S,N)] ** returns a zero-terminated UTF-16 native byte order string ** containing the declared datatype of the table column that appears ** as the Nth column (numbered from 0) of the result set to the ** [prepared statement] S. ** ** {H13763} If N is less than 0 or N is greater than or equal to ** the number of columns in the [prepared statement] S, ** or if the Nth column of S is an expression or subquery rather ** than a table column, or if a memory allocation failure ** occurs during encoding conversions, then ** calls to [sqlite3_column_decltype(S,N)] or ** [sqlite3_column_decltype16(S,N)] return NULL. */ const char *sqlite3_column_decltype(sqlite3_stmt*,int); const void *sqlite3_column_decltype16(sqlite3_stmt*,int); /* ** CAPI3REF: Evaluate An SQL Statement {H13200} <S10000> ** ** After a [prepared statement] has been prepared using either ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function ** must be called one or more times to evaluate the statement. ** ** The details of the behavior of the sqlite3_step() interface depend |
︙ | ︙ | |||
3369 3370 3371 3372 3373 3374 3375 | ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, ** then the more specific [error codes] are returned directly ** by sqlite3_step(). The use of the "v2" interface is recommended. ** ** INVARIANTS: ** | | | | | | | | | | | | 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 | ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, ** then the more specific [error codes] are returned directly ** by sqlite3_step(). The use of the "v2" interface is recommended. ** ** INVARIANTS: ** ** {H13202} If the [prepared statement] S is ready to be run, then ** [sqlite3_step(S)] advances that prepared statement until ** completion or until it is ready to return another row of the ** result set, or until an [sqlite3_interrupt | interrupt] ** or a run-time error occurs. ** ** {H15304} When a call to [sqlite3_step(S)] causes the [prepared statement] ** S to run to completion, the function returns [SQLITE_DONE]. ** ** {H15306} When a call to [sqlite3_step(S)] stops because it is ready to ** return another row of the result set, it returns [SQLITE_ROW]. ** ** {H15308} If a call to [sqlite3_step(S)] encounters an ** [sqlite3_interrupt | interrupt] or a run-time error, ** it returns an appropriate error code that is not one of ** [SQLITE_OK], [SQLITE_ROW], or [SQLITE_DONE]. ** ** {H15310} If an [sqlite3_interrupt | interrupt] or a run-time error ** occurs during a call to [sqlite3_step(S)] ** for a [prepared statement] S created using ** legacy interfaces [sqlite3_prepare()] or ** [sqlite3_prepare16()], then the function returns either ** [SQLITE_ERROR], [SQLITE_BUSY], or [SQLITE_MISUSE]. */ int sqlite3_step(sqlite3_stmt*); /* ** CAPI3REF: Number of columns in a result set {H13770} <S10700> ** ** Returns the number of values in the current row of the result set. ** ** INVARIANTS: ** ** {H13771} After a call to [sqlite3_step(S)] that returns [SQLITE_ROW], ** the [sqlite3_data_count(S)] routine will return the same value ** as the [sqlite3_column_count(S)] function. ** ** {H13772} After [sqlite3_step(S)] has returned any value other than ** [SQLITE_ROW] or before [sqlite3_step(S)] has been called on the ** [prepared statement] for the first time since it was ** [sqlite3_prepare | prepared] or [sqlite3_reset | reset], ** the [sqlite3_data_count(S)] routine returns zero. */ int sqlite3_data_count(sqlite3_stmt *pStmt); /* ** CAPI3REF: Fundamental Datatypes {H10265} <S10110><S10120> ** KEYWORDS: SQLITE_TEXT ** ** {H10266} Every value in SQLite has one of five fundamental datatypes: ** ** <ul> ** <li> 64-bit signed integer ** <li> 64-bit IEEE floating point number ** <li> string ** <li> BLOB ** <li> NULL |
︙ | ︙ | |||
3447 3448 3449 3450 3451 3452 3453 | # undef SQLITE_TEXT #else # define SQLITE_TEXT 3 #endif #define SQLITE3_TEXT 3 /* | | | 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 | # undef SQLITE_TEXT #else # define SQLITE_TEXT 3 #endif #define SQLITE3_TEXT 3 /* ** CAPI3REF: Result Values From A Query {H13800} <S10700> ** KEYWORDS: {column access functions} ** ** These routines form the "result set query" interface. ** ** These routines return information about a single column of the current ** result row of a query. In every case the first argument is a pointer ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] |
︙ | ︙ | |||
3600 3601 3602 3603 3604 3605 3606 | ** of these routines, a default value is returned. The default value ** is either the integer 0, the floating point number 0.0, or a NULL ** pointer. Subsequent calls to [sqlite3_errcode()] will return ** [SQLITE_NOMEM]. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | | | | 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 | ** of these routines, a default value is returned. The default value ** is either the integer 0, the floating point number 0.0, or a NULL ** pointer. Subsequent calls to [sqlite3_errcode()] will return ** [SQLITE_NOMEM]. ** ** INVARIANTS: ** ** {H13803} The [sqlite3_column_blob(S,N)] interface converts the ** Nth column in the current row of the result set for ** the [prepared statement] S into a BLOB and then returns a ** pointer to the converted value. ** ** {H13806} The [sqlite3_column_bytes(S,N)] interface returns the ** number of bytes in the BLOB or string (exclusive of the ** zero terminator on the string) that was returned by the ** most recent call to [sqlite3_column_blob(S,N)] or ** [sqlite3_column_text(S,N)]. ** ** {H13809} The [sqlite3_column_bytes16(S,N)] interface returns the ** number of bytes in the string (exclusive of the ** zero terminator on the string) that was returned by the ** most recent call to [sqlite3_column_text16(S,N)]. ** ** {H13812} The [sqlite3_column_double(S,N)] interface converts the ** Nth column in the current row of the result set for the ** [prepared statement] S into a floating point value and ** returns a copy of that value. ** ** {H13815} The [sqlite3_column_int(S,N)] interface converts the ** Nth column in the current row of the result set for the ** [prepared statement] S into a 64-bit signed integer and ** returns the lower 32 bits of that integer. ** ** {H13818} The [sqlite3_column_int64(S,N)] interface converts the ** Nth column in the current row of the result set for the ** [prepared statement] S into a 64-bit signed integer and ** returns a copy of that integer. ** ** {H13821} The [sqlite3_column_text(S,N)] interface converts the ** Nth column in the current row of the result set for ** the [prepared statement] S into a zero-terminated UTF-8 ** string and returns a pointer to that string. ** ** {H13824} The [sqlite3_column_text16(S,N)] interface converts the ** Nth column in the current row of the result set for the ** [prepared statement] S into a zero-terminated 2-byte ** aligned UTF-16 native byte order string and returns ** a pointer to that string. ** ** {H13827} The [sqlite3_column_type(S,N)] interface returns ** one of [SQLITE_NULL], [SQLITE_INTEGER], [SQLITE_FLOAT], ** [SQLITE_TEXT], or [SQLITE_BLOB] as appropriate for ** the Nth column in the current row of the result set for ** the [prepared statement] S. ** ** {H13830} The [sqlite3_column_value(S,N)] interface returns a ** pointer to an [unprotected sqlite3_value] object for the ** Nth column in the current row of the result set for ** the [prepared statement] S. */ const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); int sqlite3_column_bytes(sqlite3_stmt*, int iCol); int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); double sqlite3_column_double(sqlite3_stmt*, int iCol); int sqlite3_column_int(sqlite3_stmt*, int iCol); sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); int sqlite3_column_type(sqlite3_stmt*, int iCol); sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); /* ** CAPI3REF: Destroy A Prepared Statement Object {H13300} <S70300><S30100> ** ** The sqlite3_finalize() function is called to delete a [prepared statement]. ** If the statement was executed successfully or not executed at all, then ** SQLITE_OK is returned. If execution of the statement failed then an ** [error code] or [extended error code] is returned. ** ** This routine can be called at any point during the execution of the ** [prepared statement]. If the virtual machine has not ** completed execution when this routine is called, that is like ** encountering an error or an [sqlite3_interrupt | interrupt]. ** Incomplete updates may be rolled back and transactions canceled, ** depending on the circumstances, and the ** [error code] returned will be [SQLITE_ABORT]. ** ** INVARIANTS: ** ** {H11302} The [sqlite3_finalize(S)] interface destroys the ** [prepared statement] S and releases all ** memory and file resources held by that object. ** ** {H11304} If the most recent call to [sqlite3_step(S)] for the ** [prepared statement] S returned an error, ** then [sqlite3_finalize(S)] returns that same error. */ int sqlite3_finalize(sqlite3_stmt *pStmt); /* ** CAPI3REF: Reset A Prepared Statement Object {H13330} <S70300> ** ** The sqlite3_reset() function is called to reset a [prepared statement] ** object back to its initial state, ready to be re-executed. ** Any SQL statement variables that had values bound to them using ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. ** Use [sqlite3_clear_bindings()] to reset the bindings. ** ** {H11332} The [sqlite3_reset(S)] interface resets the [prepared statement] S ** back to the beginning of its program. ** ** {H11334} If the most recent call to [sqlite3_step(S)] for the ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], ** or if [sqlite3_step(S)] has never before been called on S, ** then [sqlite3_reset(S)] returns [SQLITE_OK]. ** ** {H11336} If the most recent call to [sqlite3_step(S)] for the ** [prepared statement] S indicated an error, then ** [sqlite3_reset(S)] returns an appropriate [error code]. ** ** {H11338} The [sqlite3_reset(S)] interface does not change the values ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. */ int sqlite3_reset(sqlite3_stmt *pStmt); /* ** CAPI3REF: Create Or Redefine SQL Functions {H16100} <S20200> ** KEYWORDS: {function creation routines} ** KEYWORDS: {application-defined SQL function} ** KEYWORDS: {application-defined SQL functions} ** ** These two functions (collectively known as "function creation routines") ** are used to add SQL functions or aggregates or to redefine the behavior ** of existing SQL functions or aggregates. The only difference between the |
︙ | ︙ | |||
3777 3778 3779 3780 3781 3782 3783 | ** functions with the same name but with either differing numbers of ** arguments or differing preferred text encodings. SQLite will use ** the implementation most closely matches the way in which the ** SQL function is used. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 | ** functions with the same name but with either differing numbers of ** arguments or differing preferred text encodings. SQLite will use ** the implementation most closely matches the way in which the ** SQL function is used. ** ** INVARIANTS: ** ** {H16103} The [sqlite3_create_function16()] interface behaves exactly ** like [sqlite3_create_function()] in every way except that it ** interprets the zFunctionName argument as zero-terminated UTF-16 ** native byte order instead of as zero-terminated UTF-8. ** ** {H16106} A successful invocation of ** the [sqlite3_create_function(D,X,N,E,...)] interface registers ** or replaces callback functions in the [database connection] D ** used to implement the SQL function named X with N parameters ** and having a preferred text encoding of E. ** ** {H16109} A successful call to [sqlite3_create_function(D,X,N,E,P,F,S,L)] ** replaces the P, F, S, and L values from any prior calls with ** the same D, X, N, and E values. ** ** {H16112} The [sqlite3_create_function(D,X,...)] interface fails with ** a return code of [SQLITE_ERROR] if the SQL function name X is ** longer than 255 bytes exclusive of the zero terminator. ** ** {H16118} Either F must be NULL and S and L are non-NULL or else F ** is non-NULL and S and L are NULL, otherwise ** [sqlite3_create_function(D,X,N,E,P,F,S,L)] returns [SQLITE_ERROR]. ** ** {H16121} The [sqlite3_create_function(D,...)] interface fails with an ** error code of [SQLITE_BUSY] if there exist [prepared statements] ** associated with the [database connection] D. ** ** {H16124} The [sqlite3_create_function(D,X,N,...)] interface fails with an ** error code of [SQLITE_ERROR] if parameter N (specifying the number ** of arguments to the SQL function being registered) is less ** than -1 or greater than 127. ** ** {H16127} When N is non-negative, the [sqlite3_create_function(D,X,N,...)] ** interface causes callbacks to be invoked for the SQL function ** named X when the number of arguments to the SQL function is ** exactly N. ** ** {H16130} When N is -1, the [sqlite3_create_function(D,X,N,...)] ** interface causes callbacks to be invoked for the SQL function ** named X with any number of arguments. ** ** {H16133} When calls to [sqlite3_create_function(D,X,N,...)] ** specify multiple implementations of the same function X ** and when one implementation has N>=0 and the other has N=(-1) ** the implementation with a non-zero N is preferred. ** ** {H16136} When calls to [sqlite3_create_function(D,X,N,E,...)] ** specify multiple implementations of the same function X with ** the same number of arguments N but with different ** encodings E, then the implementation where E matches the ** database encoding is preferred. ** ** {H16139} For an aggregate SQL function created using ** [sqlite3_create_function(D,X,N,E,P,0,S,L)] the finalizer ** function L will always be invoked exactly once if the ** step function S is called one or more times. ** ** {H16142} When SQLite invokes either the xFunc or xStep function of ** an application-defined SQL function or aggregate created ** by [sqlite3_create_function()] or [sqlite3_create_function16()], ** then the array of [sqlite3_value] objects passed as the ** third parameter are always [protected sqlite3_value] objects. */ int sqlite3_create_function( sqlite3 *db, |
︙ | ︙ | |||
3862 3863 3864 3865 3866 3867 3868 | void *pApp, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*) ); /* | | | > | | | | | 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 | void *pApp, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*) ); /* ** CAPI3REF: Text Encodings {H10267} <S50200> <H16100> ** ** These constant define integer codes that represent the various ** text encodings supported by SQLite. */ #define SQLITE_UTF8 1 #define SQLITE_UTF16LE 2 #define SQLITE_UTF16BE 3 #define SQLITE_UTF16 4 /* Use native byte order */ #define SQLITE_ANY 5 /* sqlite3_create_function only */ #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ /* ** CAPI3REF: Deprecated Functions ** DEPRECATED ** ** These functions are [deprecated]. In order to maintain ** backwards compatibility with older code, these functions continue ** to be supported. However, new applications should avoid ** the use of these functions. To help encourage people to avoid ** using these functions, we are not going to tell you want they do. */ int sqlite3_aggregate_count(sqlite3_context*); int sqlite3_expired(sqlite3_stmt*); int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); int sqlite3_global_recover(void); void sqlite3_thread_cleanup(void); int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64); /* ** CAPI3REF: Obtaining SQL Function Parameter Values {H15100} <S20200> ** ** The C-language implementation of SQL functions and aggregates uses ** this set of interface routines to access the parameter values on ** the function or aggregate. ** ** The xFunc (for scalar functions) or xStep (for aggregates) parameters ** to [sqlite3_create_function()] and [sqlite3_create_function16()] |
︙ | ︙ | |||
3937 3938 3939 3940 3941 3942 3943 | ** or [sqlite3_value_text16()]. ** ** These routines must be called from the same thread as ** the SQL function that supplied the [sqlite3_value*] parameters. ** ** INVARIANTS: ** | | | | | | | | | | | | | | 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 | ** or [sqlite3_value_text16()]. ** ** These routines must be called from the same thread as ** the SQL function that supplied the [sqlite3_value*] parameters. ** ** INVARIANTS: ** ** {H15103} The [sqlite3_value_blob(V)] interface converts the ** [protected sqlite3_value] object V into a BLOB and then ** returns a pointer to the converted value. ** ** {H15106} The [sqlite3_value_bytes(V)] interface returns the ** number of bytes in the BLOB or string (exclusive of the ** zero terminator on the string) that was returned by the ** most recent call to [sqlite3_value_blob(V)] or ** [sqlite3_value_text(V)]. ** ** {H15109} The [sqlite3_value_bytes16(V)] interface returns the ** number of bytes in the string (exclusive of the ** zero terminator on the string) that was returned by the ** most recent call to [sqlite3_value_text16(V)], ** [sqlite3_value_text16be(V)], or [sqlite3_value_text16le(V)]. ** ** {H15112} The [sqlite3_value_double(V)] interface converts the ** [protected sqlite3_value] object V into a floating point value and ** returns a copy of that value. ** ** {H15115} The [sqlite3_value_int(V)] interface converts the ** [protected sqlite3_value] object V into a 64-bit signed integer and ** returns the lower 32 bits of that integer. ** ** {H15118} The [sqlite3_value_int64(V)] interface converts the ** [protected sqlite3_value] object V into a 64-bit signed integer and ** returns a copy of that integer. ** ** {H15121} The [sqlite3_value_text(V)] interface converts the ** [protected sqlite3_value] object V into a zero-terminated UTF-8 ** string and returns a pointer to that string. ** ** {H15124} The [sqlite3_value_text16(V)] interface converts the ** [protected sqlite3_value] object V into a zero-terminated 2-byte ** aligned UTF-16 native byte order ** string and returns a pointer to that string. ** ** {H15127} The [sqlite3_value_text16be(V)] interface converts the ** [protected sqlite3_value] object V into a zero-terminated 2-byte ** aligned UTF-16 big-endian ** string and returns a pointer to that string. ** ** {H15130} The [sqlite3_value_text16le(V)] interface converts the ** [protected sqlite3_value] object V into a zero-terminated 2-byte ** aligned UTF-16 little-endian ** string and returns a pointer to that string. ** ** {H15133} The [sqlite3_value_type(V)] interface returns ** one of [SQLITE_NULL], [SQLITE_INTEGER], [SQLITE_FLOAT], ** [SQLITE_TEXT], or [SQLITE_BLOB] as appropriate for ** the [sqlite3_value] object V. ** ** {H15136} The [sqlite3_value_numeric_type(V)] interface converts ** the [protected sqlite3_value] object V into either an integer or ** a floating point value if it can do so without loss of ** information, and returns one of [SQLITE_NULL], ** [SQLITE_INTEGER], [SQLITE_FLOAT], [SQLITE_TEXT], or ** [SQLITE_BLOB] as appropriate for the ** [protected sqlite3_value] object V after the conversion attempt. */ |
︙ | ︙ | |||
4011 4012 4013 4014 4015 4016 4017 | const void *sqlite3_value_text16(sqlite3_value*); const void *sqlite3_value_text16le(sqlite3_value*); const void *sqlite3_value_text16be(sqlite3_value*); int sqlite3_value_type(sqlite3_value*); int sqlite3_value_numeric_type(sqlite3_value*); /* | | | 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 | const void *sqlite3_value_text16(sqlite3_value*); const void *sqlite3_value_text16le(sqlite3_value*); const void *sqlite3_value_text16be(sqlite3_value*); int sqlite3_value_type(sqlite3_value*); int sqlite3_value_numeric_type(sqlite3_value*); /* ** CAPI3REF: Obtain Aggregate Function Context {H16210} <S20200> ** ** The implementation of aggregate SQL functions use this routine to allocate ** a structure for storing their state. ** ** The first time the sqlite3_aggregate_context() routine is called for a ** particular aggregate, SQLite allocates nBytes of memory, zeroes out that ** memory, and returns a pointer to it. On second and subsequent calls to |
︙ | ︙ | |||
4035 4036 4037 4038 4039 4040 4041 | ** to the callback routine that implements the aggregate function. ** ** This routine must be called from the same thread in which ** the aggregate SQL function is running. ** ** INVARIANTS: ** | | | | | | | | | | | 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 | ** to the callback routine that implements the aggregate function. ** ** This routine must be called from the same thread in which ** the aggregate SQL function is running. ** ** INVARIANTS: ** ** {H16211} The first invocation of [sqlite3_aggregate_context(C,N)] for ** a particular instance of an aggregate function (for a particular ** context C) causes SQLite to allocate N bytes of memory, ** zero that memory, and return a pointer to the allocated memory. ** ** {H16213} If a memory allocation error occurs during ** [sqlite3_aggregate_context(C,N)] then the function returns 0. ** ** {H16215} Second and subsequent invocations of ** [sqlite3_aggregate_context(C,N)] for the same context pointer C ** ignore the N parameter and return a pointer to the same ** block of memory returned by the first invocation. ** ** {H16217} The memory allocated by [sqlite3_aggregate_context(C,N)] is ** automatically freed on the next call to [sqlite3_reset()] ** or [sqlite3_finalize()] for the [prepared statement] containing ** the aggregate function associated with context C. */ void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); /* ** CAPI3REF: User Data For Functions {H16240} <S20200> ** ** The sqlite3_user_data() interface returns a copy of ** the pointer that was the pUserData parameter (the 5th parameter) ** of the [sqlite3_create_function()] ** and [sqlite3_create_function16()] routines that originally ** registered the application defined function. {END} ** ** This routine must be called from the same thread in which ** the application-defined function is running. ** ** INVARIANTS: ** ** {H16243} The [sqlite3_user_data(C)] interface returns a copy of the ** P pointer from the [sqlite3_create_function(D,X,N,E,P,F,S,L)] ** or [sqlite3_create_function16(D,X,N,E,P,F,S,L)] call that ** registered the SQL function associated with [sqlite3_context] C. */ void *sqlite3_user_data(sqlite3_context*); /* ** CAPI3REF: Database Connection For Functions {H16250} <S60600><S20200> ** ** The sqlite3_context_db_handle() interface returns a copy of ** the pointer to the [database connection] (the 1st parameter) ** of the [sqlite3_create_function()] ** and [sqlite3_create_function16()] routines that originally ** registered the application defined function. ** ** INVARIANTS: ** ** {H16253} The [sqlite3_context_db_handle(C)] interface returns a copy of the ** D pointer from the [sqlite3_create_function(D,X,N,E,P,F,S,L)] ** or [sqlite3_create_function16(D,X,N,E,P,F,S,L)] call that ** registered the SQL function associated with [sqlite3_context] C. */ sqlite3 *sqlite3_context_db_handle(sqlite3_context*); /* ** CAPI3REF: Function Auxiliary Data {H16270} <S20200> ** ** The following two functions may be used by scalar SQL functions to ** associate metadata with argument values. If the same value is passed to ** multiple invocations of the same SQL function during query execution, under ** some circumstances the associated metadata may be preserved. This may ** be used, for example, to add a regular-expression matching scalar ** function. The compiled version of the regular expression is stored as |
︙ | ︙ | |||
4138 4139 4140 4141 4142 4143 4144 | ** values and SQL variables. ** ** These routines must be called from the same thread in which ** the SQL function is running. ** ** INVARIANTS: ** | | | | | | | | | | 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 | ** values and SQL variables. ** ** These routines must be called from the same thread in which ** the SQL function is running. ** ** INVARIANTS: ** ** {H16272} The [sqlite3_get_auxdata(C,N)] interface returns a pointer ** to metadata associated with the Nth parameter of the SQL function ** whose context is C, or NULL if there is no metadata associated ** with that parameter. ** ** {H16274} The [sqlite3_set_auxdata(C,N,P,D)] interface assigns a metadata ** pointer P to the Nth parameter of the SQL function with context C. ** ** {H16276} SQLite will invoke the destructor D with a single argument ** which is the metadata pointer P following a call to ** [sqlite3_set_auxdata(C,N,P,D)] when SQLite ceases to hold ** the metadata. ** ** {H16277} SQLite ceases to hold metadata for an SQL function parameter ** when the value of that parameter changes. ** ** {H16278} When [sqlite3_set_auxdata(C,N,P,D)] is invoked, the destructor ** is called for any prior metadata associated with the same function ** context C and parameter N. ** ** {H16279} SQLite will call destructors for any metadata it is holding ** in a particular [prepared statement] S when either ** [sqlite3_reset(S)] or [sqlite3_finalize(S)] is called. */ void *sqlite3_get_auxdata(sqlite3_context*, int N); void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); /* ** CAPI3REF: Constants Defining Special Destructor Behavior {H10280} <S30100> ** ** These are special values for the destructor that is passed in as the ** final argument to routines like [sqlite3_result_blob()]. If the destructor ** argument is SQLITE_STATIC, it means that the content pointer is constant ** and will never change. It does not need to be destroyed. The ** SQLITE_TRANSIENT value means that the content will likely change in ** the near future and that SQLite should make its own private copy of ** the content before returning. ** ** The typedef is necessary to work around problems in certain ** C++ compilers. See ticket #2191. */ typedef void (*sqlite3_destructor_type)(void*); #define SQLITE_STATIC ((sqlite3_destructor_type)0) #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) /* ** CAPI3REF: Setting The Result Of An SQL Function {H16400} <S20200> ** ** These routines are used by the xFunc or xFinal callbacks that ** implement SQL functions and aggregates. See ** [sqlite3_create_function()] and [sqlite3_create_function16()] ** for additional information. ** ** These functions work very much like the [parameter binding] family of |
︙ | ︙ | |||
4290 4291 4292 4293 4294 4295 4296 | ** ** If these routines are called from within the different thread ** than the one containing the application-defined function that received ** the [sqlite3_context] pointer, the results are undefined. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | | | | | | 4350 4351 4352 4353 4354 4355 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 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 | ** ** If these routines are called from within the different thread ** than the one containing the application-defined function that received ** the [sqlite3_context] pointer, the results are undefined. ** ** INVARIANTS: ** ** {H16403} The default return value from any SQL function is NULL. ** ** {H16406} The [sqlite3_result_blob(C,V,N,D)] interface changes the ** return value of function C to be a BLOB that is N bytes ** in length and with content pointed to by V. ** ** {H16409} The [sqlite3_result_double(C,V)] interface changes the ** return value of function C to be the floating point value V. ** ** {H16412} The [sqlite3_result_error(C,V,N)] interface changes the return ** value of function C to be an exception with error code ** [SQLITE_ERROR] and a UTF-8 error message copied from V up to the ** first zero byte or until N bytes are read if N is positive. ** ** {H16415} The [sqlite3_result_error16(C,V,N)] interface changes the return ** value of function C to be an exception with error code ** [SQLITE_ERROR] and a UTF-16 native byte order error message ** copied from V up to the first zero terminator or until N bytes ** are read if N is positive. ** ** {H16418} The [sqlite3_result_error_toobig(C)] interface changes the return ** value of the function C to be an exception with error code ** [SQLITE_TOOBIG] and an appropriate error message. ** ** {H16421} The [sqlite3_result_error_nomem(C)] interface changes the return ** value of the function C to be an exception with error code ** [SQLITE_NOMEM] and an appropriate error message. ** ** {H16424} The [sqlite3_result_error_code(C,E)] interface changes the return ** value of the function C to be an exception with error code E. ** The error message text is unchanged. ** ** {H16427} The [sqlite3_result_int(C,V)] interface changes the ** return value of function C to be the 32-bit integer value V. ** ** {H16430} The [sqlite3_result_int64(C,V)] interface changes the ** return value of function C to be the 64-bit integer value V. ** ** {H16433} The [sqlite3_result_null(C)] interface changes the ** return value of function C to be NULL. ** ** {H16436} The [sqlite3_result_text(C,V,N,D)] interface changes the ** return value of function C to be the UTF-8 string ** V up to the first zero if N is negative ** or the first N bytes of V if N is non-negative. ** ** {H16439} The [sqlite3_result_text16(C,V,N,D)] interface changes the ** return value of function C to be the UTF-16 native byte order ** string V up to the first zero if N is negative ** or the first N bytes of V if N is non-negative. ** ** {H16442} The [sqlite3_result_text16be(C,V,N,D)] interface changes the ** return value of function C to be the UTF-16 big-endian ** string V up to the first zero if N is negative ** or the first N bytes or V if N is non-negative. ** ** {H16445} The [sqlite3_result_text16le(C,V,N,D)] interface changes the ** return value of function C to be the UTF-16 little-endian ** string V up to the first zero if N is negative ** or the first N bytes of V if N is non-negative. ** ** {H16448} The [sqlite3_result_value(C,V)] interface changes the ** return value of function C to be the [unprotected sqlite3_value] ** object V. ** ** {H16451} The [sqlite3_result_zeroblob(C,N)] interface changes the ** return value of function C to be an N-byte BLOB of all zeros. ** ** {H16454} The [sqlite3_result_error()] and [sqlite3_result_error16()] ** interfaces make a copy of their error message strings before ** returning. ** ** {H16457} If the D destructor parameter to [sqlite3_result_blob(C,V,N,D)], ** [sqlite3_result_text(C,V,N,D)], [sqlite3_result_text16(C,V,N,D)], ** [sqlite3_result_text16be(C,V,N,D)], or ** [sqlite3_result_text16le(C,V,N,D)] is the constant [SQLITE_STATIC] ** then no destructor is ever called on the pointer V and SQLite ** assumes that V is immutable. ** ** {H16460} If the D destructor parameter to [sqlite3_result_blob(C,V,N,D)], ** [sqlite3_result_text(C,V,N,D)], [sqlite3_result_text16(C,V,N,D)], ** [sqlite3_result_text16be(C,V,N,D)], or ** [sqlite3_result_text16le(C,V,N,D)] is the constant ** [SQLITE_TRANSIENT] then the interfaces makes a copy of the ** content of V and retains the copy. ** ** {H16463} If the D destructor parameter to [sqlite3_result_blob(C,V,N,D)], ** [sqlite3_result_text(C,V,N,D)], [sqlite3_result_text16(C,V,N,D)], ** [sqlite3_result_text16be(C,V,N,D)], or ** [sqlite3_result_text16le(C,V,N,D)] is some value other than ** the constants [SQLITE_STATIC] and [SQLITE_TRANSIENT] then ** SQLite will invoke the destructor D with V as its only argument ** when it has finished with the V value. */ |
︙ | ︙ | |||
4402 4403 4404 4405 4406 4407 4408 | void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); void sqlite3_result_value(sqlite3_context*, sqlite3_value*); void sqlite3_result_zeroblob(sqlite3_context*, int n); /* | | | 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 | void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); void sqlite3_result_value(sqlite3_context*, sqlite3_value*); void sqlite3_result_zeroblob(sqlite3_context*, int n); /* ** CAPI3REF: Define New Collating Sequences {H16600} <S20300> ** ** These functions are used to add new collation sequences to the ** [database connection] specified as the first argument. ** ** The name of the new collation sequence is specified as a UTF-8 string ** for sqlite3_create_collation() and sqlite3_create_collation_v2() ** and a UTF-16 string for sqlite3_create_collation16(). In all cases |
︙ | ︙ | |||
4445 4446 4447 4448 4449 4450 4451 | ** of the sqlite3_create_collation_v2(). ** Collations are destroyed when they are overridden by later calls to the ** collation creation functions or when the [database connection] is closed ** using [sqlite3_close()]. ** ** INVARIANTS: ** | | | | | | | | | | | | | 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 | ** of the sqlite3_create_collation_v2(). ** Collations are destroyed when they are overridden by later calls to the ** collation creation functions or when the [database connection] is closed ** using [sqlite3_close()]. ** ** INVARIANTS: ** ** {H16603} A successful call to the ** [sqlite3_create_collation_v2(B,X,E,P,F,D)] interface ** registers function F as the comparison function used to ** implement collation X on the [database connection] B for ** databases having encoding E. ** ** {H16604} SQLite understands the X parameter to ** [sqlite3_create_collation_v2(B,X,E,P,F,D)] as a zero-terminated ** UTF-8 string in which case is ignored for ASCII characters and ** is significant for non-ASCII characters. ** ** {H16606} Successive calls to [sqlite3_create_collation_v2(B,X,E,P,F,D)] ** with the same values for B, X, and E, override prior values ** of P, F, and D. ** ** {H16609} If the destructor D in [sqlite3_create_collation_v2(B,X,E,P,F,D)] ** is not NULL then it is called with argument P when the ** collating function is dropped by SQLite. ** ** {H16612} A collating function is dropped when it is overloaded. ** ** {H16615} A collating function is dropped when the database connection ** is closed using [sqlite3_close()]. ** ** {H16618} The pointer P in [sqlite3_create_collation_v2(B,X,E,P,F,D)] ** is passed through as the first parameter to the comparison ** function F for all subsequent invocations of F. ** ** {H16621} A call to [sqlite3_create_collation(B,X,E,P,F)] is exactly ** the same as a call to [sqlite3_create_collation_v2()] with ** the same parameters and a NULL destructor. ** ** {H16624} Following a [sqlite3_create_collation_v2(B,X,E,P,F,D)], ** SQLite uses the comparison function F for all text comparison ** operations on the [database connection] B on text values that ** use the collating sequence named X. ** ** {H16627} The [sqlite3_create_collation16(B,X,E,P,F)] works the same ** as [sqlite3_create_collation(B,X,E,P,F)] except that the ** collation name X is understood as UTF-16 in native byte order ** instead of UTF-8. ** ** {H16630} When multiple comparison functions are available for the same ** collating sequence, SQLite chooses the one whose text encoding ** requires the least amount of conversion from the default ** text encoding of the database. */ int sqlite3_create_collation( sqlite3*, const char *zName, |
︙ | ︙ | |||
4516 4517 4518 4519 4520 4521 4522 | const void *zName, int eTextRep, void*, int(*xCompare)(void*,int,const void*,int,const void*) ); /* | | | | | | | 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 | const void *zName, int eTextRep, void*, int(*xCompare)(void*,int,const void*,int,const void*) ); /* ** CAPI3REF: Collation Needed Callbacks {H16700} <S20300> ** ** To avoid having to register all collation sequences before a database ** can be used, a single callback function may be registered with the ** [database connection] to be called whenever an undefined collation ** sequence is required. ** ** If the function is registered using the sqlite3_collation_needed() API, ** then it is passed the names of undefined collation sequences as strings ** encoded in UTF-8. {H16703} If sqlite3_collation_needed16() is used, ** the names are passed as UTF-16 in machine native byte order. ** A call to either function replaces any existing callback. ** ** When the callback is invoked, the first argument passed is a copy ** of the second argument to sqlite3_collation_needed() or ** sqlite3_collation_needed16(). The second argument is the database ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation ** sequence function required. The fourth parameter is the name of the ** required collation sequence. ** ** The callback function should register the desired collation using ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or ** [sqlite3_create_collation_v2()]. ** ** INVARIANTS: ** ** {H16702} A successful call to [sqlite3_collation_needed(D,P,F)] ** or [sqlite3_collation_needed16(D,P,F)] causes ** the [database connection] D to invoke callback F with first ** parameter P whenever it needs a comparison function for a ** collating sequence that it does not know about. ** ** {H16704} Each successful call to [sqlite3_collation_needed()] or ** [sqlite3_collation_needed16()] overrides the callback registered ** on the same [database connection] by prior calls to either ** interface. ** ** {H16706} The name of the requested collating function passed in the ** 4th parameter to the callback is in UTF-8 if the callback ** was registered using [sqlite3_collation_needed()] and ** is in UTF-16 native byte order if the callback was ** registered using [sqlite3_collation_needed16()]. */ int sqlite3_collation_needed( sqlite3*, |
︙ | ︙ | |||
4597 4598 4599 4600 4601 4602 4603 | */ int sqlite3_rekey( sqlite3 *db, /* Database to be rekeyed */ const void *pKey, int nKey /* The new key */ ); /* | | | | | | | | | | | | | | | | | | > > > > > > | | 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 | */ int sqlite3_rekey( sqlite3 *db, /* Database to be rekeyed */ const void *pKey, int nKey /* The new key */ ); /* ** CAPI3REF: Suspend Execution For A Short Time {H10530} <S40410> ** ** The sqlite3_sleep() function causes the current thread to suspend execution ** for at least a number of milliseconds specified in its parameter. ** ** If the operating system does not support sleep requests with ** millisecond time resolution, then the time will be rounded up to ** the nearest second. The number of milliseconds of sleep actually ** requested from the operating system is returned. ** ** SQLite implements this interface by calling the xSleep() ** method of the default [sqlite3_vfs] object. ** ** INVARIANTS: ** ** {H10533} The [sqlite3_sleep(M)] interface invokes the xSleep ** method of the default [sqlite3_vfs|VFS] in order to ** suspend execution of the current thread for at least ** M milliseconds. ** ** {H10536} The [sqlite3_sleep(M)] interface returns the number of ** milliseconds of sleep actually requested of the operating ** system, which might be larger than the parameter M. */ int sqlite3_sleep(int); /* ** CAPI3REF: Name Of The Folder Holding Temporary Files {H10310} <S20000> ** ** If this global variable is made to point to a string which is ** the name of a folder (a.k.a. directory), then all temporary files ** created by SQLite will be placed in that directory. If this variable ** is a NULL pointer, then SQLite performs a search for an appropriate ** temporary file directory. ** ** It is not safe to modify this variable once a [database connection] ** has been opened. It is intended that this variable be set once ** as part of process initialization and before any SQLite interface ** routines have been call and remain unchanged thereafter. */ SQLITE_EXTERN char *sqlite3_temp_directory; /* ** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200> ** KEYWORDS: {autocommit mode} ** ** The sqlite3_get_autocommit() interface returns non-zero or ** zero if the given database connection is or is not in autocommit mode, ** respectively. Autocommit mode is on by default. ** Autocommit mode is disabled by a [BEGIN] statement. ** Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK]. ** ** If certain kinds of errors occur on a statement within a multi-statement ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the ** transaction might be rolled back automatically. The only way to ** find out whether SQLite automatically rolled back the transaction after ** an error is to use this function. ** ** INVARIANTS: ** ** {H12931} The [sqlite3_get_autocommit(D)] interface returns non-zero or ** zero if the [database connection] D is or is not in autocommit ** mode, respectively. ** ** {H12932} Autocommit mode is on by default. ** ** {H12933} Autocommit mode is disabled by a successful [BEGIN] statement. ** ** {H12934} Autocommit mode is enabled by a successful [COMMIT] or [ROLLBACK] ** statement. ** ** ASSUMPTIONS: ** ** {A12936} If another thread changes the autocommit status of the database ** connection while this routine is running, then the return value ** is undefined. */ int sqlite3_get_autocommit(sqlite3*); /* ** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600> ** ** The sqlite3_db_handle interface returns the [database connection] handle ** to which a [prepared statement] belongs. The database handle returned by ** sqlite3_db_handle is the same database handle that was the first argument ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to ** create the statement in the first place. ** ** INVARIANTS: ** ** {H13123} The [sqlite3_db_handle(S)] interface returns a pointer ** to the [database connection] associated with the ** [prepared statement] S. */ sqlite3 *sqlite3_db_handle(sqlite3_stmt*); /* ** CAPI3REF: Find the next prepared statement {H13140} <S60600> ** ** This interface returns a pointer to the next [prepared statement] after ** pStmt associated with the [database connection] pDb. If pStmt is NULL ** then this interface returns a pointer to the first prepared statement ** associated with the database connection pDb. If no prepared statement ** satisfies the conditions of this routine, it returns NULL. ** ** INVARIANTS: ** ** {H13143} If D is a [database connection] that holds one or more ** unfinalized [prepared statements] and S is a NULL pointer, ** then [sqlite3_next_stmt(D, S)] routine shall return a pointer ** to one of the prepared statements associated with D. ** ** {H13146} If D is a [database connection] that holds no unfinalized ** [prepared statements] and S is a NULL pointer, then ** [sqlite3_next_stmt(D, S)] routine shall return a NULL pointer. ** ** {H13149} If S is a [prepared statement] in the [database connection] D ** and S is not the last prepared statement in D, then ** [sqlite3_next_stmt(D, S)] routine shall return a pointer ** to the next prepared statement in D after S. ** ** {H13152} If S is the last [prepared statement] in the ** [database connection] D then the [sqlite3_next_stmt(D, S)] ** routine shall return a NULL pointer. ** ** ASSUMPTIONS: ** ** {A13154} The [database connection] pointer D in a call to ** [sqlite3_next_stmt(D,S)] must refer to an open database ** connection and in particular must not be a NULL pointer. */ sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); /* ** CAPI3REF: Commit And Rollback Notification Callbacks {H12950} <S60400> ** ** The sqlite3_commit_hook() interface registers a callback ** function to be invoked whenever a transaction is committed. ** Any callback set by a previous call to sqlite3_commit_hook() ** for the same database connection is overridden. ** The sqlite3_rollback_hook() interface registers a callback ** function to be invoked whenever a transaction is committed. |
︙ | ︙ | |||
4756 4757 4758 4759 4760 4761 4762 | ** automatically rolled back because the database connection is closed. ** The rollback callback is not invoked if a transaction is ** rolled back because a commit callback returned non-zero. ** <todo> Check on this </todo> ** ** INVARIANTS: ** | | | | | | | | | | | | 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 | ** automatically rolled back because the database connection is closed. ** The rollback callback is not invoked if a transaction is ** rolled back because a commit callback returned non-zero. ** <todo> Check on this </todo> ** ** INVARIANTS: ** ** {H12951} The [sqlite3_commit_hook(D,F,P)] interface registers the ** callback function F to be invoked with argument P whenever ** a transaction commits on the [database connection] D. ** ** {H12952} The [sqlite3_commit_hook(D,F,P)] interface returns the P argument ** from the previous call with the same [database connection] D, ** or NULL on the first call for a particular database connection D. ** ** {H12953} Each call to [sqlite3_commit_hook()] overwrites the callback ** registered by prior calls. ** ** {H12954} If the F argument to [sqlite3_commit_hook(D,F,P)] is NULL ** then the commit hook callback is canceled and no callback ** is invoked when a transaction commits. ** ** {H12955} If the commit callback returns non-zero then the commit is ** converted into a rollback. ** ** {H12961} The [sqlite3_rollback_hook(D,F,P)] interface registers the ** callback function F to be invoked with argument P whenever ** a transaction rolls back on the [database connection] D. ** ** {H12962} The [sqlite3_rollback_hook(D,F,P)] interface returns the P ** argument from the previous call with the same ** [database connection] D, or NULL on the first call ** for a particular database connection D. ** ** {H12963} Each call to [sqlite3_rollback_hook()] overwrites the callback ** registered by prior calls. ** ** {H12964} If the F argument to [sqlite3_rollback_hook(D,F,P)] is NULL ** then the rollback hook callback is canceled and no callback ** is invoked when a transaction rolls back. */ void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); /* ** CAPI3REF: Data Change Notification Callbacks {H12970} <S60400> ** ** The sqlite3_update_hook() interface registers a callback function ** with the [database connection] identified by the first argument ** to be invoked whenever a row is updated, inserted or deleted. ** Any callback set by a previous call to this function ** for the same database connection is overridden. ** |
︙ | ︙ | |||
4822 4823 4824 4825 4826 4827 4828 | ** modified (i.e. sqlite_master and sqlite_sequence). ** ** If another function was previously registered, its pArg value ** is returned. Otherwise NULL is returned. ** ** INVARIANTS: ** | | | | | | | | | | | 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 | ** modified (i.e. sqlite_master and sqlite_sequence). ** ** If another function was previously registered, its pArg value ** is returned. Otherwise NULL is returned. ** ** INVARIANTS: ** ** {H12971} The [sqlite3_update_hook(D,F,P)] interface causes the callback ** function F to be invoked with first parameter P whenever ** a table row is modified, inserted, or deleted on ** the [database connection] D. ** ** {H12973} The [sqlite3_update_hook(D,F,P)] interface returns the value ** of P for the previous call on the same [database connection] D, ** or NULL for the first call. ** ** {H12975} If the update hook callback F in [sqlite3_update_hook(D,F,P)] ** is NULL then the no update callbacks are made. ** ** {H12977} Each call to [sqlite3_update_hook(D,F,P)] overrides prior calls ** to the same interface on the same [database connection] D. ** ** {H12979} The update hook callback is not invoked when internal system ** tables such as sqlite_master and sqlite_sequence are modified. ** ** {H12981} The second parameter to the update callback ** is one of [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], ** depending on the operation that caused the callback to be invoked. ** ** {H12983} The third and fourth arguments to the callback contain pointers ** to zero-terminated UTF-8 strings which are the names of the ** database and table that is being updated. ** {H12985} The final callback parameter is the rowid of the row after ** the change occurs. */ void *sqlite3_update_hook( sqlite3*, void(*)(void *,int ,char const *,char const *,sqlite3_int64), void* ); /* ** CAPI3REF: Enable Or Disable Shared Pager Cache {H10330} <S30900> ** KEYWORDS: {shared cache} {shared cache mode} ** ** This routine enables or disables the sharing of the database cache ** and schema data structures between [database connection | connections] ** to the same database. Sharing is enabled if the argument is true ** and disabled if the argument is false. ** |
︙ | ︙ | |||
4888 4889 4890 4891 4892 4893 4894 | ** ** Shared cache is disabled by default. But this might change in ** future releases of SQLite. Applications that care about shared ** cache setting should set it explicitly. ** ** INVARIANTS: ** | | | | | | | | | | 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 | ** ** Shared cache is disabled by default. But this might change in ** future releases of SQLite. Applications that care about shared ** cache setting should set it explicitly. ** ** INVARIANTS: ** ** {H10331} A successful invocation of [sqlite3_enable_shared_cache(B)] ** will enable or disable shared cache mode for any subsequently ** created [database connection] in the same process. ** ** {H10336} When shared cache is enabled, the [sqlite3_create_module()] ** interface will always return an error. ** ** {H10337} The [sqlite3_enable_shared_cache(B)] interface returns ** [SQLITE_OK] if shared cache was enabled or disabled successfully. ** ** {H10339} Shared cache is disabled by default. */ int sqlite3_enable_shared_cache(int); /* ** CAPI3REF: Attempt To Free Heap Memory {H17340} <S30220> ** ** The sqlite3_release_memory() interface attempts to free N bytes ** of heap memory by deallocating non-essential memory allocations ** held by the database library. {END} Memory used to cache database ** pages to improve performance is an example of non-essential memory. ** sqlite3_release_memory() returns the number of bytes actually freed, ** which might be more or less than the amount requested. ** ** INVARIANTS: ** ** {H17341} The [sqlite3_release_memory(N)] interface attempts to ** free N bytes of heap memory by deallocating non-essential ** memory allocations held by the database library. ** ** {H16342} The [sqlite3_release_memory(N)] returns the number ** of bytes actually freed, which might be more or less ** than the amount requested. */ int sqlite3_release_memory(int); /* ** CAPI3REF: Impose A Limit On Heap Size {H17350} <S30220> ** ** The sqlite3_soft_heap_limit() interface places a "soft" limit ** on the amount of heap memory that may be allocated by SQLite. ** If an internal allocation is requested that would exceed the ** soft heap limit, [sqlite3_release_memory()] is invoked one or ** more times to free up some space before the allocation is performed. ** |
︙ | ︙ | |||
4956 4957 4958 4959 4960 4961 4962 | ** applied to all threads. The value specified for the soft heap limit ** is an upper bound on the total memory allocation for all threads. In ** version 3.5.0 there is no mechanism for limiting the heap usage for ** individual threads. ** ** INVARIANTS: ** | | | | | | | | | 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 | ** applied to all threads. The value specified for the soft heap limit ** is an upper bound on the total memory allocation for all threads. In ** version 3.5.0 there is no mechanism for limiting the heap usage for ** individual threads. ** ** INVARIANTS: ** ** {H16351} The [sqlite3_soft_heap_limit(N)] interface places a soft limit ** of N bytes on the amount of heap memory that may be allocated ** using [sqlite3_malloc()] or [sqlite3_realloc()] at any point ** in time. ** ** {H16352} If a call to [sqlite3_malloc()] or [sqlite3_realloc()] would ** cause the total amount of allocated memory to exceed the ** soft heap limit, then [sqlite3_release_memory()] is invoked ** in an attempt to reduce the memory usage prior to proceeding ** with the memory allocation attempt. ** ** {H16353} Calls to [sqlite3_malloc()] or [sqlite3_realloc()] that trigger ** attempts to reduce memory usage through the soft heap limit ** mechanism continue even if the attempt to reduce memory ** usage is unsuccessful. ** ** {H16354} A negative or zero value for N in a call to ** [sqlite3_soft_heap_limit(N)] means that there is no soft ** heap limit and [sqlite3_release_memory()] will only be ** called when memory is completely exhausted. ** ** {H16355} The default value for the soft heap limit is zero. ** ** {H16358} Each call to [sqlite3_soft_heap_limit(N)] overrides the ** values set by all prior calls. */ void sqlite3_soft_heap_limit(int); /* ** CAPI3REF: Extract Metadata About A Column Of A Table {H12850} <S60300> ** ** This routine returns metadata about a specific column of a specific ** database table accessible using the [database connection] handle ** passed as the first function argument. ** ** The column is identified by the second, third and fourth parameters to ** this function. The second parameter is either the name of the database |
︙ | ︙ | |||
5059 5060 5061 5062 5063 5064 5065 | char const **pzCollSeq, /* OUTPUT: Collation sequence name */ int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ int *pPrimaryKey, /* OUTPUT: True if column part of PK */ int *pAutoinc /* OUTPUT: True if column is auto-increment */ ); /* | | | | | | | | | | | | | | | | | | | | 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 | char const **pzCollSeq, /* OUTPUT: Collation sequence name */ int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ int *pPrimaryKey, /* OUTPUT: True if column part of PK */ int *pAutoinc /* OUTPUT: True if column is auto-increment */ ); /* ** CAPI3REF: Load An Extension {H12600} <S20500> ** ** This interface loads an SQLite extension library from the named file. ** ** {H12601} The sqlite3_load_extension() interface attempts to load an ** SQLite extension library contained in the file zFile. ** ** {H12602} The entry point is zProc. ** ** {H12603} zProc may be 0, in which case the name of the entry point ** defaults to "sqlite3_extension_init". ** ** {H12604} The sqlite3_load_extension() interface shall return ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. ** ** {H12605} If an error occurs and pzErrMsg is not 0, then the ** [sqlite3_load_extension()] interface shall attempt to ** fill *pzErrMsg with error message text stored in memory ** obtained from [sqlite3_malloc()]. {END} The calling function ** should free this memory by calling [sqlite3_free()]. ** ** {H12606} Extension loading must be enabled using ** [sqlite3_enable_load_extension()] prior to calling this API, ** otherwise an error will be returned. */ int sqlite3_load_extension( sqlite3 *db, /* Load the extension into this database connection */ const char *zFile, /* Name of the shared library containing extension */ const char *zProc, /* Entry point. Derived from zFile if 0 */ char **pzErrMsg /* Put error message here if not 0 */ ); /* ** CAPI3REF: Enable Or Disable Extension Loading {H12620} <S20500> ** ** So as not to open security holes in older applications that are ** unprepared to deal with extension loading, and as a means of disabling ** extension loading while evaluating user-entered SQL, the following API ** is provided to turn the [sqlite3_load_extension()] mechanism on and off. ** ** Extension loading is off by default. See ticket #1863. ** ** {H12621} Call the sqlite3_enable_load_extension() routine with onoff==1 ** to turn extension loading on and call it with onoff==0 to turn ** it back off again. ** ** {H12622} Extension loading is off by default. */ int sqlite3_enable_load_extension(sqlite3 *db, int onoff); /* ** CAPI3REF: Automatically Load An Extensions {H12640} <S20500> ** ** This API can be invoked at program startup in order to register ** one or more statically linked extensions that will be available ** to all new [database connections]. {END} ** ** This routine stores a pointer to the extension in an array that is ** obtained from [sqlite3_malloc()]. If you run a memory leak checker ** on your program and it reports a leak because of this array, invoke ** [sqlite3_reset_auto_extension()] prior to shutdown to free the memory. ** ** {H12641} This function registers an extension entry point that is ** automatically invoked whenever a new [database connection] ** is opened using [sqlite3_open()], [sqlite3_open16()], ** or [sqlite3_open_v2()]. ** ** {H12642} Duplicate extensions are detected so calling this routine ** multiple times with the same extension is harmless. ** ** {H12643} This routine stores a pointer to the extension in an array ** that is obtained from [sqlite3_malloc()]. ** ** {H12644} Automatic extensions apply across all threads. */ int sqlite3_auto_extension(void *xEntryPoint); /* ** CAPI3REF: Reset Automatic Extension Loading {H12660} <S20500> ** ** This function disables all previously registered automatic ** extensions. {END} It undoes the effect of all prior ** [sqlite3_auto_extension()] calls. ** ** {H12661} This function disables all previously registered ** automatic extensions. ** ** {H12662} This function disables automatic extensions in all threads. */ void sqlite3_reset_auto_extension(void); /* ****** EXPERIMENTAL - subject to change without notice ************** ** ** The interface to the virtual-table mechanism is currently considered |
︙ | ︙ | |||
5170 5171 5172 5173 5174 5175 5176 | */ typedef struct sqlite3_vtab sqlite3_vtab; typedef struct sqlite3_index_info sqlite3_index_info; typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; typedef struct sqlite3_module sqlite3_module; /* | | > | 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 | */ typedef struct sqlite3_vtab sqlite3_vtab; typedef struct sqlite3_index_info sqlite3_index_info; typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; typedef struct sqlite3_module sqlite3_module; /* ** CAPI3REF: Virtual Table Object {H18000} <S20400> ** KEYWORDS: sqlite3_module ** EXPERIMENTAL ** ** A module is a class of virtual tables. Each module is defined ** by an instance of the following structure. This structure consists ** mostly of methods for the module. ** ** This interface is experimental and is subject to change or ** removal in future releases of SQLite. |
︙ | ︙ | |||
5207 5208 5209 5210 5211 5212 5213 | int (*xBegin)(sqlite3_vtab *pVTab); int (*xSync)(sqlite3_vtab *pVTab); int (*xCommit)(sqlite3_vtab *pVTab); int (*xRollback)(sqlite3_vtab *pVTab); int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName, void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), void **ppArg); | < | > | 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 | int (*xBegin)(sqlite3_vtab *pVTab); int (*xSync)(sqlite3_vtab *pVTab); int (*xCommit)(sqlite3_vtab *pVTab); int (*xRollback)(sqlite3_vtab *pVTab); int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName, void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), void **ppArg); int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); }; /* ** CAPI3REF: Virtual Table Indexing Information {H18100} <S20400> ** KEYWORDS: sqlite3_index_info ** EXPERIMENTAL ** ** The sqlite3_index_info structure and its substructures is used to ** pass information into and receive the reply from the xBestIndex ** method of an sqlite3_module. The fields under **Inputs** are the ** inputs to xBestIndex and are read-only. xBestIndex inserts its ** results into the **Outputs** fields. ** |
︙ | ︙ | |||
5276 5277 5278 5279 5280 5281 5282 | int iTermOffset; /* Used internally - xBestIndex should ignore */ } *aConstraint; /* Table of WHERE clause constraints */ int nOrderBy; /* Number of terms in the ORDER BY clause */ struct sqlite3_index_orderby { int iColumn; /* Column number */ unsigned char desc; /* True for DESC. False for ASC. */ } *aOrderBy; /* The ORDER BY clause */ | < | > | > | > | 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 | int iTermOffset; /* Used internally - xBestIndex should ignore */ } *aConstraint; /* Table of WHERE clause constraints */ int nOrderBy; /* Number of terms in the ORDER BY clause */ struct sqlite3_index_orderby { int iColumn; /* Column number */ unsigned char desc; /* True for DESC. False for ASC. */ } *aOrderBy; /* The ORDER BY clause */ /* Outputs */ struct sqlite3_index_constraint_usage { int argvIndex; /* if >0, constraint is part of argv to xFilter */ unsigned char omit; /* Do not code a test for this constraint */ } *aConstraintUsage; int idxNum; /* Number used to identify the index */ char *idxStr; /* String, possibly obtained from sqlite3_malloc */ int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ int orderByConsumed; /* True if output is already ordered */ double estimatedCost; /* Estimated cost of using this index */ }; #define SQLITE_INDEX_CONSTRAINT_EQ 2 #define SQLITE_INDEX_CONSTRAINT_GT 4 #define SQLITE_INDEX_CONSTRAINT_LE 8 #define SQLITE_INDEX_CONSTRAINT_LT 16 #define SQLITE_INDEX_CONSTRAINT_GE 32 #define SQLITE_INDEX_CONSTRAINT_MATCH 64 /* ** CAPI3REF: Register A Virtual Table Implementation {H18200} <S20400> ** EXPERIMENTAL ** ** This routine is used to register a new module name with a ** [database connection]. Module names must be registered before ** creating new virtual tables on the module, or before using ** preexisting virtual tables of the module. ** ** This interface is experimental and is subject to change or ** removal in future releases of SQLite. */ int sqlite3_create_module( sqlite3 *db, /* SQLite connection to register module with */ const char *zName, /* Name of the module */ const sqlite3_module *, /* Methods for the module */ void * /* Client data for xCreate/xConnect */ ); /* ** CAPI3REF: Register A Virtual Table Implementation {H18210} <S20400> ** EXPERIMENTAL ** ** This routine is identical to the [sqlite3_create_module()] method above, ** except that it allows a destructor function to be specified. It is ** even more experimental than the rest of the virtual tables API. */ int sqlite3_create_module_v2( sqlite3 *db, /* SQLite connection to register module with */ const char *zName, /* Name of the module */ const sqlite3_module *, /* Methods for the module */ void *, /* Client data for xCreate/xConnect */ void(*xDestroy)(void*) /* Module destructor function */ ); /* ** CAPI3REF: Virtual Table Instance Object {H18010} <S20400> ** KEYWORDS: sqlite3_vtab ** EXPERIMENTAL ** ** Every module implementation uses a subclass of the following structure ** to describe a particular instance of the module. Each subclass will ** be tailored to the specific needs of the module implementation. ** The purpose of this superclass is to define certain fields that are ** common to all module implementations. ** |
︙ | ︙ | |||
5359 5360 5361 5362 5363 5364 5365 | const sqlite3_module *pModule; /* The module for this virtual table */ int nRef; /* Used internally */ char *zErrMsg; /* Error message from sqlite3_mprintf() */ /* Virtual table implementations will typically add additional fields */ }; /* | | > | > | > | 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 | const sqlite3_module *pModule; /* The module for this virtual table */ int nRef; /* Used internally */ char *zErrMsg; /* Error message from sqlite3_mprintf() */ /* Virtual table implementations will typically add additional fields */ }; /* ** CAPI3REF: Virtual Table Cursor Object {H18020} <S20400> ** KEYWORDS: sqlite3_vtab_cursor ** EXPERIMENTAL ** ** Every module implementation uses a subclass of the following structure ** to describe cursors that point into the virtual table and are used ** to loop through the virtual table. Cursors are created using the ** xOpen method of the module. Each module implementation will define ** the content of a cursor structure to suit its own needs. ** ** This superclass exists in order to define fields of the cursor that ** are common to all implementations. ** ** This interface is experimental and is subject to change or ** removal in future releases of SQLite. */ struct sqlite3_vtab_cursor { sqlite3_vtab *pVtab; /* Virtual table of this cursor */ /* Virtual table implementations will typically add additional fields */ }; /* ** CAPI3REF: Declare The Schema Of A Virtual Table {H18280} <S20400> ** EXPERIMENTAL ** ** The xCreate and xConnect methods of a module use the following API ** to declare the format (the names and datatypes of the columns) of ** the virtual tables they implement. ** ** This interface is experimental and is subject to change or ** removal in future releases of SQLite. */ int sqlite3_declare_vtab(sqlite3*, const char *zCreateTable); /* ** CAPI3REF: Overload A Function For A Virtual Table {H18300} <S20400> ** EXPERIMENTAL ** ** Virtual tables can provide alternative implementations of functions ** using the xFindFunction method. But global versions of those functions ** must exist in order to be overloaded. ** ** This API makes sure a global version of a function with a particular ** name and number of parameters exists. If no such function exists |
︙ | ︙ | |||
5424 5425 5426 5427 5428 5429 5430 | ** When the virtual-table mechanism stabilizes, we will declare the ** interface fixed, support it indefinitely, and remove this comment. ** ****** EXPERIMENTAL - subject to change without notice ************** */ /* | | | | 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 | ** When the virtual-table mechanism stabilizes, we will declare the ** interface fixed, support it indefinitely, and remove this comment. ** ****** EXPERIMENTAL - subject to change without notice ************** */ /* ** CAPI3REF: A Handle To An Open BLOB {H17800} <S30230> ** KEYWORDS: {BLOB handle} {BLOB handles} ** ** An instance of this object represents an open BLOB on which ** [sqlite3_blob_open | incremental BLOB I/O] can be performed. ** Objects of this type are created by [sqlite3_blob_open()] ** and destroyed by [sqlite3_blob_close()]. ** The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces ** can be used to read or write small subsections of the BLOB. ** The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes. */ typedef struct sqlite3_blob sqlite3_blob; /* ** CAPI3REF: Open A BLOB For Incremental I/O {H17810} <S30230> ** ** This interfaces opens a [BLOB handle | handle] to the BLOB located ** in row iRow, column zColumn, table zTable in database zDb; ** in other words, the same BLOB that would be selected by: ** ** <pre> ** SELECT zColumn FROM zDb.zTable WHERE rowid = iRow; |
︙ | ︙ | |||
5476 5477 5478 5479 5480 5481 5482 | ** a expired BLOB handle fail with an return code of [SQLITE_ABORT]. ** Changes written into a BLOB prior to the BLOB expiring are not ** rollback by the expiration of the BLOB. Such changes will eventually ** commit if the transaction continues to completion. ** ** INVARIANTS: ** | | | | | | | | | | | | | | | | | | | | | | | | 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 | ** a expired BLOB handle fail with an return code of [SQLITE_ABORT]. ** Changes written into a BLOB prior to the BLOB expiring are not ** rollback by the expiration of the BLOB. Such changes will eventually ** commit if the transaction continues to completion. ** ** INVARIANTS: ** ** {H17813} A successful invocation of the [sqlite3_blob_open(D,B,T,C,R,F,P)] ** interface shall open an [sqlite3_blob] object P on the BLOB ** in column C of the table T in the database B on ** the [database connection] D. ** ** {H17814} A successful invocation of [sqlite3_blob_open(D,...)] shall start ** a new transaction on the [database connection] D if that ** connection is not already in a transaction. ** ** {H17816} The [sqlite3_blob_open(D,B,T,C,R,F,P)] interface shall open ** the BLOB for read and write access if and only if the F ** parameter is non-zero. ** ** {H17819} The [sqlite3_blob_open()] interface shall return [SQLITE_OK] on ** success and an appropriate [error code] on failure. ** ** {H17821} If an error occurs during evaluation of [sqlite3_blob_open(D,...)] ** then subsequent calls to [sqlite3_errcode(D)], ** [sqlite3_errmsg(D)], and [sqlite3_errmsg16(D)] shall return ** information appropriate for that error. ** ** {H17824} If any column in the row that a [sqlite3_blob] has open is ** changed by a separate [UPDATE] or [DELETE] statement or by ** an [ON CONFLICT] side effect, then the [sqlite3_blob] shall ** be marked as invalid. */ int sqlite3_blob_open( sqlite3*, const char *zDb, const char *zTable, const char *zColumn, sqlite3_int64 iRow, int flags, sqlite3_blob **ppBlob ); /* ** CAPI3REF: Close A BLOB Handle {H17830} <S30230> ** ** Closes an open [BLOB handle]. ** ** Closing a BLOB shall cause the current transaction to commit ** if there are no other BLOBs, no pending prepared statements, and the ** database connection is in [autocommit mode]. ** If any writes were made to the BLOB, they might be held in cache ** until the close operation if they will fit. {END} ** ** Closing the BLOB often forces the changes ** out to disk and so if any I/O errors occur, they will likely occur ** at the time when the BLOB is closed. {H17833} Any errors that occur during ** closing are reported as a non-zero return value. ** ** The BLOB is closed unconditionally. Even if this routine returns ** an error code, the BLOB is still closed. ** ** INVARIANTS: ** ** {H17833} The [sqlite3_blob_close(P)] interface closes an [sqlite3_blob] ** object P previously opened using [sqlite3_blob_open()]. ** ** {H17836} Closing an [sqlite3_blob] object using ** [sqlite3_blob_close()] shall cause the current transaction to ** commit if there are no other open [sqlite3_blob] objects ** or [prepared statements] on the same [database connection] and ** the database connection is in [autocommit mode]. ** ** {H17839} The [sqlite3_blob_close(P)] interfaces shall close the ** [sqlite3_blob] object P unconditionally, even if ** [sqlite3_blob_close(P)] returns something other than [SQLITE_OK]. */ int sqlite3_blob_close(sqlite3_blob *); /* ** CAPI3REF: Return The Size Of An Open BLOB {H17840} <S30230> ** ** Returns the size in bytes of the BLOB accessible via the open ** []BLOB handle] in its only argument. ** ** INVARIANTS: ** ** {H17843} The [sqlite3_blob_bytes(P)] interface returns the size ** in bytes of the BLOB that the [sqlite3_blob] object P ** refers to. */ int sqlite3_blob_bytes(sqlite3_blob *); /* ** CAPI3REF: Read Data From A BLOB Incrementally {H17850} <S30230> ** ** This function is used to read data from an open [BLOB handle] into a ** caller-supplied buffer. N bytes of data are copied into buffer Z ** from the open BLOB, starting at offset iOffset. ** ** If offset iOffset is less than N bytes from the end of the BLOB, ** [SQLITE_ERROR] is returned and no data is read. If N or iOffset is ** less than zero, [SQLITE_ERROR] is returned and no data is read. ** ** An attempt to read from an expired [BLOB handle] fails with an ** error code of [SQLITE_ABORT]. ** ** On success, SQLITE_OK is returned. ** Otherwise, an [error code] or an [extended error code] is returned. ** ** INVARIANTS: ** ** {H17853} A successful invocation of [sqlite3_blob_read(P,Z,N,X)] ** shall reads N bytes of data out of the BLOB referenced by ** [BLOB handle] P beginning at offset X and store those bytes ** into buffer Z. ** ** {H17856} In [sqlite3_blob_read(P,Z,N,X)] if the size of the BLOB ** is less than N+X bytes, then the function shall leave the ** Z buffer unchanged and return [SQLITE_ERROR]. ** ** {H17859} In [sqlite3_blob_read(P,Z,N,X)] if X or N is less than zero ** then the function shall leave the Z buffer unchanged ** and return [SQLITE_ERROR]. ** ** {H17862} The [sqlite3_blob_read(P,Z,N,X)] interface shall return [SQLITE_OK] ** if N bytes are successfully read into buffer Z. ** ** {H17863} If the [BLOB handle] P is expired and X and N are within bounds ** then [sqlite3_blob_read(P,Z,N,X)] shall leave the Z buffer ** unchanged and return [SQLITE_ABORT]. ** ** {H17865} If the requested read could not be completed, ** the [sqlite3_blob_read(P,Z,N,X)] interface shall return an ** appropriate [error code] or [extended error code]. ** ** {H17868} If an error occurs during evaluation of [sqlite3_blob_read(P,...)] ** then subsequent calls to [sqlite3_errcode(D)], ** [sqlite3_errmsg(D)], and [sqlite3_errmsg16(D)] shall return ** information appropriate for that error, where D is the ** [database connection] that was used to open the [BLOB handle] P. */ int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); /* ** CAPI3REF: Write Data Into A BLOB Incrementally {H17870} <S30230> ** ** This function is used to write data into an open [BLOB handle] from a ** caller-supplied buffer. N bytes of data are copied from the buffer Z ** into the open BLOB, starting at offset iOffset. ** ** If the [BLOB handle] passed as the first argument was not opened for ** writing (the flags parameter to [sqlite3_blob_open()] was zero), |
︙ | ︙ | |||
5642 5643 5644 5645 5646 5647 5648 | ** or by other independent statements. ** ** On success, SQLITE_OK is returned. ** Otherwise, an [error code] or an [extended error code] is returned. ** ** INVARIANTS: ** | | | | | | | | | | | | 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 | ** or by other independent statements. ** ** On success, SQLITE_OK is returned. ** Otherwise, an [error code] or an [extended error code] is returned. ** ** INVARIANTS: ** ** {H17873} A successful invocation of [sqlite3_blob_write(P,Z,N,X)] ** shall write N bytes of data from buffer Z into the BLOB ** referenced by [BLOB handle] P beginning at offset X into ** the BLOB. ** ** {H17874} In the absence of other overridding changes, the changes ** written to a BLOB by [sqlite3_blob_write()] shall ** remain in effect after the associated [BLOB handle] expires. ** ** {H17875} If the [BLOB handle] P was opened for reading only then ** an invocation of [sqlite3_blob_write(P,Z,N,X)] shall leave ** the referenced BLOB unchanged and return [SQLITE_READONLY]. ** ** {H17876} If the size of the BLOB referenced by [BLOB handle] P is ** less than N+X bytes then [sqlite3_blob_write(P,Z,N,X)] shall ** leave the BLOB unchanged and return [SQLITE_ERROR]. ** ** {H17877} If the [BLOB handle] P is expired and X and N are within bounds ** then [sqlite3_blob_read(P,Z,N,X)] shall leave the BLOB ** unchanged and return [SQLITE_ABORT]. ** ** {H17879} If X or N are less than zero then [sqlite3_blob_write(P,Z,N,X)] ** shall leave the BLOB referenced by [BLOB handle] P unchanged ** and return [SQLITE_ERROR]. ** ** {H17882} The [sqlite3_blob_write(P,Z,N,X)] interface shall return ** [SQLITE_OK] if N bytes where successfully written into the BLOB. ** ** {H17885} If the requested write could not be completed, ** the [sqlite3_blob_write(P,Z,N,X)] interface shall return an ** appropriate [error code] or [extended error code]. ** ** {H17888} If an error occurs during evaluation of [sqlite3_blob_write(D,...)] ** then subsequent calls to [sqlite3_errcode(D)], ** [sqlite3_errmsg(D)], and [sqlite3_errmsg16(D)] shall return ** information appropriate for that error. */ int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); /* ** CAPI3REF: Virtual File System Objects {H11200} <S20100> ** ** A virtual filesystem (VFS) is an [sqlite3_vfs] object ** that SQLite uses to interact ** with the underlying operating system. Most SQLite builds come with a ** single default VFS that is appropriate for the host computer. ** New VFSes can be registered and existing VFSes can be unregistered. ** The following interfaces are provided. |
︙ | ︙ | |||
5712 5713 5714 5715 5716 5717 5718 | ** ** Unregister a VFS with the sqlite3_vfs_unregister() interface. ** If the default VFS is unregistered, another VFS is chosen as ** the default. The choice for the new VFS is arbitrary. ** ** INVARIANTS: ** | | | | | | | | | 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 | ** ** Unregister a VFS with the sqlite3_vfs_unregister() interface. ** If the default VFS is unregistered, another VFS is chosen as ** the default. The choice for the new VFS is arbitrary. ** ** INVARIANTS: ** ** {H11203} The [sqlite3_vfs_find(N)] interface returns a pointer to the ** registered [sqlite3_vfs] object whose name exactly matches ** the zero-terminated UTF-8 string N, or it returns NULL if ** there is no match. ** ** {H11206} If the N parameter to [sqlite3_vfs_find(N)] is NULL then ** the function returns a pointer to the default [sqlite3_vfs] ** object if there is one, or NULL if there is no default ** [sqlite3_vfs] object. ** ** {H11209} The [sqlite3_vfs_register(P,F)] interface registers the ** well-formed [sqlite3_vfs] object P using the name given ** by the zName field of the object. ** ** {H11212} Using the [sqlite3_vfs_register(P,F)] interface to register ** the same [sqlite3_vfs] object multiple times is a harmless no-op. ** ** {H11215} The [sqlite3_vfs_register(P,F)] interface makes the [sqlite3_vfs] ** object P the default [sqlite3_vfs] object if F is non-zero. ** ** {H11218} The [sqlite3_vfs_unregister(P)] interface unregisters the ** [sqlite3_vfs] object P so that it is no longer returned by ** subsequent calls to [sqlite3_vfs_find()]. */ sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName); int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); int sqlite3_vfs_unregister(sqlite3_vfs*); /* ** CAPI3REF: Mutexes {H17000} <S20000> ** ** The SQLite core uses these routines for thread ** synchronization. Though they are intended for internal ** use by SQLite, code that links against SQLite is ** permitted to use any of these routines. ** ** The SQLite source code contains multiple implementations |
︙ | ︙ | |||
5774 5775 5776 5777 5778 5779 5780 | ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex ** implementation is included with the library. In this case the ** application must supply a custom mutex implementation using the ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function ** before calling sqlite3_initialize() or any other public sqlite3_ ** function that calls sqlite3_initialize(). ** | | | | | | | | | | | | | | | | | | | | | | > | | | 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 | ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex ** implementation is included with the library. In this case the ** application must supply a custom mutex implementation using the ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function ** before calling sqlite3_initialize() or any other public sqlite3_ ** function that calls sqlite3_initialize(). ** ** {H17011} The sqlite3_mutex_alloc() routine allocates a new ** mutex and returns a pointer to it. {H17012} If it returns NULL ** that means that a mutex could not be allocated. {H17013} SQLite ** will unwind its stack and return an error. {H17014} The argument ** to sqlite3_mutex_alloc() is one of these integer constants: ** ** <ul> ** <li> SQLITE_MUTEX_FAST ** <li> SQLITE_MUTEX_RECURSIVE ** <li> SQLITE_MUTEX_STATIC_MASTER ** <li> SQLITE_MUTEX_STATIC_MEM ** <li> SQLITE_MUTEX_STATIC_MEM2 ** <li> SQLITE_MUTEX_STATIC_PRNG ** <li> SQLITE_MUTEX_STATIC_LRU ** <li> SQLITE_MUTEX_STATIC_LRU2 ** </ul> ** ** {H17015} The first two constants cause sqlite3_mutex_alloc() to create ** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. {END} ** The mutex implementation does not need to make a distinction ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does ** not want to. {H17016} But SQLite will only request a recursive mutex in ** cases where it really needs one. {END} If a faster non-recursive mutex ** implementation is available on the host platform, the mutex subsystem ** might return such a mutex in response to SQLITE_MUTEX_FAST. ** ** {H17017} The other allowed parameters to sqlite3_mutex_alloc() each return ** a pointer to a static preexisting mutex. {END} Four static mutexes are ** used by the current version of SQLite. Future versions of SQLite ** may add additional static mutexes. Static mutexes are for internal ** use by SQLite only. Applications that use SQLite mutexes should ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or ** SQLITE_MUTEX_RECURSIVE. ** ** {H17018} Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() ** returns a different mutex on every call. {H17034} But for the static ** mutex types, the same mutex is returned on every call that has ** the same type number. ** ** {H17019} The sqlite3_mutex_free() routine deallocates a previously ** allocated dynamic mutex. {H17020} SQLite is careful to deallocate every ** dynamic mutex that it allocates. {A17021} The dynamic mutexes must not be in ** use when they are deallocated. {A17022} Attempting to deallocate a static ** mutex results in undefined behavior. {H17023} SQLite never deallocates ** a static mutex. {END} ** ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt ** to enter a mutex. {H17024} If another thread is already within the mutex, ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return ** SQLITE_BUSY. {H17025} The sqlite3_mutex_try() interface returns [SQLITE_OK] ** upon successful entry. {H17026} Mutexes created using ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. ** {H17027} In such cases the, ** mutex must be exited an equal number of times before another thread ** can enter. {A17028} If the same thread tries to enter any other ** kind of mutex more than once, the behavior is undefined. ** {H17029} SQLite will never exhibit ** such behavior in its own use of mutexes. ** ** Some systems (for example, Windows 95) do not support the operation ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() ** will always return SQLITE_BUSY. {H17030} The SQLite core only ever uses ** sqlite3_mutex_try() as an optimization so this is acceptable behavior. ** ** {H17031} The sqlite3_mutex_leave() routine exits a mutex that was ** previously entered by the same thread. {A17032} The behavior ** is undefined if the mutex is not currently entered by the ** calling thread or is not currently allocated. {H17033} SQLite will ** never do either. {END} ** ** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or ** sqlite3_mutex_leave() is a NULL pointer, then all three routines ** behave as no-ops. ** ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. */ sqlite3_mutex *sqlite3_mutex_alloc(int); void sqlite3_mutex_free(sqlite3_mutex*); void sqlite3_mutex_enter(sqlite3_mutex*); int sqlite3_mutex_try(sqlite3_mutex*); void sqlite3_mutex_leave(sqlite3_mutex*); /* ** CAPI3REF: Mutex Methods Object {H17120} <S20130> ** EXPERIMENTAL ** ** An instance of this structure defines the low-level routines ** used to allocate and use mutexes. ** ** Usually, the default mutex implementations provided by SQLite are ** sufficient, however the user has the option of substituting a custom ** implementation for specialized deployments or systems for which SQLite ** does not provide a suitable implementation. In this case, the user ** creates and populates an instance of this structure to pass ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. ** Additionally, an instance of this structure can be used as an ** output variable when querying the system for the current mutex ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. ** ** The xMutexInit method defined by this structure is invoked as ** part of system initialization by the sqlite3_initialize() function. ** {H17001} The xMutexInit routine shall be called by SQLite once for each ** effective call to [sqlite3_initialize()]. ** ** The xMutexEnd method defined by this structure is invoked as ** part of system shutdown by the sqlite3_shutdown() function. The ** implementation of this method is expected to release all outstanding ** resources obtained by the mutex methods implementation, especially ** those obtained by the xMutexInit method. {H17003} The xMutexEnd() ** interface shall be invoked once for each call to [sqlite3_shutdown()]. ** ** The remaining seven methods defined by this structure (xMutexAlloc, ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and ** xMutexNotheld) implement the following interfaces (respectively): ** ** <ul> |
︙ | ︙ | |||
5922 5923 5924 5925 5926 5927 5928 | int (*xMutexTry)(sqlite3_mutex *); void (*xMutexLeave)(sqlite3_mutex *); int (*xMutexHeld)(sqlite3_mutex *); int (*xMutexNotheld)(sqlite3_mutex *); }; /* | | | | | | | | | > > > > | | | | | | | | | | | > | 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 | int (*xMutexTry)(sqlite3_mutex *); void (*xMutexLeave)(sqlite3_mutex *); int (*xMutexHeld)(sqlite3_mutex *); int (*xMutexNotheld)(sqlite3_mutex *); }; /* ** CAPI3REF: Mutex Verification Routines {H17080} <S20130> <S30800> ** ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines ** are intended for use inside assert() statements. {H17081} The SQLite core ** never uses these routines except inside an assert() and applications ** are advised to follow the lead of the core. {H17082} The core only ** provides implementations for these routines when it is compiled ** with the SQLITE_DEBUG flag. {A17087} External mutex implementations ** are only required to provide these routines if SQLITE_DEBUG is ** defined and if NDEBUG is not defined. ** ** {H17083} These routines should return true if the mutex in their argument ** is held or not held, respectively, by the calling thread. ** ** {X17084} The implementation is not required to provided versions of these ** routines that actually work. If the implementation does not provide working ** versions of these routines, it should at least provide stubs that always ** return true so that one does not get spurious assertion failures. ** ** {H17085} If the argument to sqlite3_mutex_held() is a NULL pointer then ** the routine should return 1. {END} This seems counter-intuitive since ** clearly the mutex cannot be held if it does not exist. But the ** the reason the mutex does not exist is because the build is not ** using mutexes. And we do not want the assert() containing the ** call to sqlite3_mutex_held() to fail, so a non-zero return is ** the appropriate thing to do. {H17086} The sqlite3_mutex_notheld() ** interface should also return 1 when given a NULL pointer. */ int sqlite3_mutex_held(sqlite3_mutex*); int sqlite3_mutex_notheld(sqlite3_mutex*); /* ** CAPI3REF: Mutex Types {H17001} <H17000> ** ** The [sqlite3_mutex_alloc()] interface takes a single argument ** which is one of these integer constants. ** ** The set of static mutexes may change from one SQLite release to the ** next. Applications that override the built-in mutex logic must be ** prepared to accommodate additional static mutexes. */ #define SQLITE_MUTEX_FAST 0 #define SQLITE_MUTEX_RECURSIVE 1 #define SQLITE_MUTEX_STATIC_MASTER 2 #define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ #define SQLITE_MUTEX_STATIC_MEM2 4 /* sqlite3_release_memory() */ #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ #define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */ /* ** CAPI3REF: Low-Level Control Of Database Files {H11300} <S30800> ** ** {H11301} The [sqlite3_file_control()] interface makes a direct call to the ** xFileControl method for the [sqlite3_io_methods] object associated ** with a particular database identified by the second argument. {H11302} The ** name of the database is the name assigned to the database by the ** <a href="lang_attach.html">ATTACH</a> SQL command that opened the ** database. {H11303} To control the main database file, use the name "main" ** or a NULL pointer. {H11304} The third and fourth parameters to this routine ** are passed directly through to the second and third parameters of ** the xFileControl method. {H11305} The return value of the xFileControl ** method becomes the return value of this routine. ** ** {H11306} If the second parameter (zDbName) does not match the name of any ** open database file, then SQLITE_ERROR is returned. {H11307} This error ** code is not remembered and will not be recalled by [sqlite3_errcode()] ** or [sqlite3_errmsg()]. {A11308} The underlying xFileControl method might ** also return SQLITE_ERROR. {A11309} There is no way to distinguish between ** an incorrect zDbName and an SQLITE_ERROR return from the underlying ** xFileControl method. {END} ** ** See also: [SQLITE_FCNTL_LOCKSTATE] */ int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*); /* ** CAPI3REF: Testing Interface {H11400} <S30800> ** ** The sqlite3_test_control() interface is used to read out internal ** state of SQLite and to inject faults into SQLite for testing ** purposes. The first parameter is an operation code that determines ** the number, meaning, and operation of all subsequent parameters. ** ** This interface is not for use by applications. It exists solely ** for verifying the correct operation of the SQLite library. Depending ** on how the SQLite library is compiled, this interface might not exist. ** ** The details of the operation codes, their meanings, the parameters ** they take, and what they do are all subject to change without notice. ** Unlike most of the SQLite API, this function is not guaranteed to ** operate consistently from one release to the next. */ int sqlite3_test_control(int op, ...); /* ** CAPI3REF: Testing Interface Operation Codes {H11410} <H11400> ** ** These constants are the valid operation code parameters used ** as the first argument to [sqlite3_test_control()]. ** ** These parameters and their meanings are subject to change ** without notice. These values are for testing purposes only. ** Applications should not use any of these parameters or the ** [sqlite3_test_control()] interface. */ #define SQLITE_TESTCTRL_PRNG_SAVE 5 #define SQLITE_TESTCTRL_PRNG_RESTORE 6 #define SQLITE_TESTCTRL_PRNG_RESET 7 #define SQLITE_TESTCTRL_BITVEC_TEST 8 #define SQLITE_TESTCTRL_FAULT_INSTALL 9 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 /* ** CAPI3REF: SQLite Runtime Status {H17200} <S60200> ** EXPERIMENTAL ** ** This interface is used to retrieve runtime status information ** about the preformance of SQLite, and optionally to reset various ** highwater marks. The first argument is an integer code for ** the specific parameter to measure. Recognized integer codes ** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...]. ** The current value of the parameter is returned into *pCurrent. |
︙ | ︙ | |||
6058 6059 6060 6061 6062 6063 6064 | ** This routine is threadsafe but is not atomic. This routine can ** called while other threads are running the same or different SQLite ** interfaces. However the values returned in *pCurrent and ** *pHighwater reflect the status of SQLite at different points in time ** and it is possible that another thread might change the parameter ** in between the times when *pCurrent and *pHighwater are written. ** | | < > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > | | > > > > > > > > > > | | | > > > > > | | < | | > > > > > > > > > > > > > > > > > > > > | 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 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 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 | ** This routine is threadsafe but is not atomic. This routine can ** called while other threads are running the same or different SQLite ** interfaces. However the values returned in *pCurrent and ** *pHighwater reflect the status of SQLite at different points in time ** and it is possible that another thread might change the parameter ** in between the times when *pCurrent and *pHighwater are written. ** ** See also: [sqlite3_db_status()] */ int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); /* ** CAPI3REF: Database Connection Status {H17201} <S60200> ** EXPERIMENTAL ** ** This interface is used to retrieve runtime status information ** about a single [database connection]. The first argument is the ** database connection object to be interrogated. The second argument ** is the parameter to interrogate. Currently, the only allowed value ** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED]. ** Additional options will likely appear in future releases of SQLite. ** ** The current value of the request parameter is written into *pCur ** and the highest instantaneous value is written into *pHiwtr. If ** the resetFlg is true, then the highest instantaneous value is ** reset back down to the current value. ** ** See also: [sqlite3_status()]. */ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); /* ** CAPI3REF: Status Parameters {H17250} <H17200> ** EXPERIMENTAL ** ** These integer constants designate various run-time status parameters ** that can be returned by [sqlite3_status()]. ** ** <dl> ** <dt>SQLITE_STATUS_MEMORY_USED</dt> ** <dd>This parameter is the current amount of memory checked out ** using [sqlite3_malloc()], either directly or indirectly. The ** figure includes calls made to [sqlite3_malloc()] by the application ** and internal memory usage by the SQLite library. Scratch memory ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in ** this parameter. The amount returned is the sum of the allocation ** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd> ** ** <dt>SQLITE_STATUS_MALLOC_SIZE</dt> ** <dd>This parameter records the largest memory allocation request ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their ** internal equivalents). Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.</dd> ** ** <dt>SQLITE_STATUS_PAGECACHE_USED</dt> ** <dd>This parameter returns the number of pages used out of the ** [pagecache memory allocator] that was configured using ** [SQLITE_CONFIG_PAGECACHE]. The ** value returned is in pages, not in bytes.</dd> ** ** <dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt> ** <dd>This parameter returns the number of bytes of page cache ** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE] ** buffer and where forced to overflow to [sqlite3_malloc()]. The ** returned value includes allocations that overflowed because they ** where too large (they were larger than the "sz" parameter to ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because ** no space was left in the page cache.</dd> ** ** <dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> ** <dd>This parameter records the largest memory allocation request ** handed to [pagecache memory allocator]. Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.</dd> ** ** <dt>SQLITE_STATUS_SCRATCH_USED</dt> ** <dd>This parameter returns the number of allocations used out of the ** [scratch memory allocator] configured using ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not ** in bytes. Since a single thread may only have one scratch allocation ** outstanding at time, this parameter also reports the number of threads ** using scratch memory at the same time.</dd> ** ** <dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt> ** <dd>This parameter returns the number of bytes of scratch memory ** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH] ** buffer and where forced to overflow to [sqlite3_malloc()]. The values ** returned include overflows because the requested allocation was too ** larger (that is, because the requested allocation was larger than the ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer ** slots were available. ** </dd> ** ** <dt>SQLITE_STATUS_SCRATCH_SIZE</dt> ** <dd>This parameter records the largest memory allocation request ** handed to [scratch memory allocator]. Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.</dd> ** ** <dt>SQLITE_STATUS_PARSER_STACK</dt> ** <dd>This parameter records the deepest parser stack. It is only ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd> ** </dl> ** ** New status parameters may be added from time to time. */ #define SQLITE_STATUS_MEMORY_USED 0 #define SQLITE_STATUS_PAGECACHE_USED 1 #define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 #define SQLITE_STATUS_SCRATCH_USED 3 #define SQLITE_STATUS_SCRATCH_OVERFLOW 4 #define SQLITE_STATUS_MALLOC_SIZE 5 #define SQLITE_STATUS_PARSER_STACK 6 #define SQLITE_STATUS_PAGECACHE_SIZE 7 #define SQLITE_STATUS_SCRATCH_SIZE 8 /* ** CAPI3REF: Status Parameters for database connections {H17275} <H17200> ** EXPERIMENTAL ** ** Status verbs for [sqlite3_db_status()]. ** ** <dl> ** <dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> ** <dd>This parameter returns the number of lookaside memory slots currently ** checked out.</dd> ** </dl> */ #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 /* ** Undo the hack that converts floating point types to integer for ** builds on processors without floating point support. */ #ifdef SQLITE_OMIT_FLOATING_POINT # undef double #endif #ifdef __cplusplus } /* End of the 'extern "C"' block */ #endif #endif |
Changes to SQLite.Interop/src/sqlite3ext.h.
︙ | ︙ | |||
11 12 13 14 15 16 17 | ************************************************************************* ** This header file defines the SQLite interface for use by ** shared libraries that want to be imported as extensions into ** an SQLite instance. Shared libraries that intend to be loaded ** as extensions by SQLite should #include this file instead of ** sqlite3.h. ** | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ************************************************************************* ** This header file defines the SQLite interface for use by ** shared libraries that want to be imported as extensions into ** an SQLite instance. Shared libraries that intend to be loaded ** as extensions by SQLite should #include this file instead of ** sqlite3.h. ** ** @(#) $Id: sqlite3ext.h,v 1.13 2008/08/06 21:45:32 rmsimpson Exp $ */ #ifndef _SQLITE3EXT_H_ #define _SQLITE3EXT_H_ #include "sqlite3.h" typedef struct sqlite3_api_routines sqlite3_api_routines; |
︙ | ︙ |
Changes to SQLite.NET.sln.
1 2 3 4 5 6 7 8 9 10 11 | Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{39A3B743-1EBD-4CC0-8E37-ACE3DD38B1C0}" ProjectSection(SolutionItems) = preProject readme.htm = readme.htm EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Data.SQLite - Compact", "System.Data.SQLite\System.Data.SQLite - Compact.csproj", "{AC139951-261A-4463-B6FA-AEBC25283A66}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "test\test.csproj", "{E27B1B1E-19C0-45E8-AA74-B6E1C041A130}" | < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{39A3B743-1EBD-4CC0-8E37-ACE3DD38B1C0}" ProjectSection(SolutionItems) = preProject readme.htm = readme.htm EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Data.SQLite - Compact", "System.Data.SQLite\System.Data.SQLite - Compact.csproj", "{AC139951-261A-4463-B6FA-AEBC25283A66}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "test\test.csproj", "{E27B1B1E-19C0-45E8-AA74-B6E1C041A130}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SQLite.Interop", "SQLite.Interop\SQLite.Interop.vcproj", "{10B51CE8-A838-44DE-BD82-B658F0296F80}" ProjectSection(ProjectDependencies) = postProject {AC139951-261A-4463-B6FA-AEBC25283A66} = {AC139951-261A-4463-B6FA-AEBC25283A66} {AC139952-261A-4463-B6FA-AEBC25283A66} = {AC139952-261A-4463-B6FA-AEBC25283A66} EndProjectSection EndProject |
︙ | ︙ | |||
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 | EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Data.SQLite.Linq", "System.Data.SQLite.Linq\System.Data.SQLite.Linq.csproj", "{E6BF9F74-58E2-413B-A7CE-EA653ECB728D}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testlinq", "testlinq\testlinq.csproj", "{9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|Compact Framework (ARMV4) = Debug|Compact Framework (ARMV4) Debug|Itanium = Debug|Itanium Debug|Mixed Platforms = Debug|Mixed Platforms Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Any CPU = Release|Any CPU Release|Compact Framework (ARMV4) = Release|Compact Framework (ARMV4) Release|Itanium = Release|Itanium Release|Mixed Platforms = Release|Mixed Platforms Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Any CPU.Build.0 = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Compact Framework (ARMV4).ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Compact Framework (ARMV4).Build.0 = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Itanium.ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU | > > > > > > > > > > > > > > > > > > > > > | | > | > > > > > > > < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < > > > > > > > | < < < | 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 | EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Data.SQLite.Linq", "System.Data.SQLite.Linq\System.Data.SQLite.Linq.csproj", "{E6BF9F74-58E2-413B-A7CE-EA653ECB728D}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testlinq", "testlinq\testlinq.csproj", "{9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug - Stock|Any CPU = Debug - Stock|Any CPU Debug - Stock|Compact Framework (ARMV4) = Debug - Stock|Compact Framework (ARMV4) Debug - Stock|Itanium = Debug - Stock|Itanium Debug - Stock|Mixed Platforms = Debug - Stock|Mixed Platforms Debug - Stock|Win32 = Debug - Stock|Win32 Debug - Stock|x64 = Debug - Stock|x64 Debug|Any CPU = Debug|Any CPU Debug|Compact Framework (ARMV4) = Debug|Compact Framework (ARMV4) Debug|Itanium = Debug|Itanium Debug|Mixed Platforms = Debug|Mixed Platforms Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release - Stock|Any CPU = Release - Stock|Any CPU Release - Stock|Compact Framework (ARMV4) = Release - Stock|Compact Framework (ARMV4) Release - Stock|Itanium = Release - Stock|Itanium Release - Stock|Mixed Platforms = Release - Stock|Mixed Platforms Release - Stock|Win32 = Release - Stock|Win32 Release - Stock|x64 = Release - Stock|x64 Release|Any CPU = Release|Any CPU Release|Compact Framework (ARMV4) = Release|Compact Framework (ARMV4) Release|Itanium = Release|Itanium Release|Mixed Platforms = Release|Mixed Platforms Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Any CPU.ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Any CPU.Build.0 = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Compact Framework (ARMV4).ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Compact Framework (ARMV4).Build.0 = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Itanium.ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Mixed Platforms.ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Mixed Platforms.Build.0 = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Win32.ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|x64.ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Any CPU.Build.0 = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Compact Framework (ARMV4).ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Compact Framework (ARMV4).Build.0 = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Itanium.ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|Win32.ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Debug|x64.ActiveCfg = Debug|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Any CPU.ActiveCfg = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Any CPU.Build.0 = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Compact Framework (ARMV4).ActiveCfg = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Compact Framework (ARMV4).Build.0 = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Itanium.ActiveCfg = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Mixed Platforms.ActiveCfg = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Mixed Platforms.Build.0 = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Win32.ActiveCfg = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release - Stock|x64.ActiveCfg = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release|Any CPU.ActiveCfg = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release|Any CPU.Build.0 = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release|Compact Framework (ARMV4).ActiveCfg = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release|Compact Framework (ARMV4).Build.0 = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release|Itanium.ActiveCfg = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release|Mixed Platforms.Build.0 = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release|Win32.ActiveCfg = Release|Any CPU {AC139951-261A-4463-B6FA-AEBC25283A66}.Release|x64.ActiveCfg = Release|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug - Stock|Any CPU.ActiveCfg = Debug|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug - Stock|Any CPU.Build.0 = Debug|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug - Stock|Compact Framework (ARMV4).ActiveCfg = Debug|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug - Stock|Itanium.ActiveCfg = Debug|Itanium {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug - Stock|Itanium.Build.0 = Debug|Itanium {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug - Stock|Mixed Platforms.ActiveCfg = Debug|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug - Stock|Mixed Platforms.Build.0 = Debug|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug - Stock|Win32.ActiveCfg = Debug|x86 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug - Stock|Win32.Build.0 = Debug|x86 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug - Stock|x64.ActiveCfg = Debug|x64 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug - Stock|x64.Build.0 = Debug|x64 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug|Any CPU.Build.0 = Debug|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug|Compact Framework (ARMV4).ActiveCfg = Debug|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug|Itanium.ActiveCfg = Debug|Itanium {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug|Itanium.Build.0 = Debug|Itanium {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug|Win32.ActiveCfg = Debug|x86 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug|Win32.Build.0 = Debug|x86 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug|x64.ActiveCfg = Debug|x64 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Debug|x64.Build.0 = Debug|x64 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release - Stock|Any CPU.ActiveCfg = Release|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release - Stock|Any CPU.Build.0 = Release|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release - Stock|Compact Framework (ARMV4).ActiveCfg = Release|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release - Stock|Itanium.ActiveCfg = Release|Itanium {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release - Stock|Itanium.Build.0 = Release|Itanium {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release - Stock|Mixed Platforms.ActiveCfg = Release|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release - Stock|Mixed Platforms.Build.0 = Release|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release - Stock|Win32.ActiveCfg = Release|x86 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release - Stock|Win32.Build.0 = Release|x86 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release - Stock|x64.ActiveCfg = Release|x64 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release - Stock|x64.Build.0 = Release|x64 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Any CPU.ActiveCfg = Release|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Any CPU.Build.0 = Release|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Compact Framework (ARMV4).ActiveCfg = Release|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Itanium.ActiveCfg = Release|Itanium {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Itanium.Build.0 = Release|Itanium {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Mixed Platforms.Build.0 = Release|Any CPU {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Win32.ActiveCfg = Release|x86 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|Win32.Build.0 = Release|x86 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|x64.ActiveCfg = Release|x64 {E27B1B1E-19C0-45E8-AA74-B6E1C041A130}.Release|x64.Build.0 = Release|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug - Stock|Any CPU.ActiveCfg = Debug|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug - Stock|Compact Framework (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4) {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug - Stock|Compact Framework (ARMV4).Build.0 = Debug|Pocket PC 2003 (ARMV4) {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug - Stock|Compact Framework (ARMV4).Deploy.0 = Debug|Pocket PC 2003 (ARMV4) {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug - Stock|Itanium.ActiveCfg = Debug|Itanium {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug - Stock|Itanium.Build.0 = Debug|Itanium {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug - Stock|Itanium.Deploy.0 = Debug|Itanium {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug - Stock|Mixed Platforms.ActiveCfg = Debug|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug - Stock|Mixed Platforms.Build.0 = Debug|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug - Stock|Win32.ActiveCfg = Debug|Win32 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug - Stock|Win32.Deploy.0 = Debug|Win32 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug - Stock|x64.ActiveCfg = Debug|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug - Stock|x64.Build.0 = Debug|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug - Stock|x64.Deploy.0 = Debug|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Any CPU.ActiveCfg = Debug|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Compact Framework (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4) {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Compact Framework (ARMV4).Build.0 = Debug|Pocket PC 2003 (ARMV4) {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Compact Framework (ARMV4).Deploy.0 = Debug|Pocket PC 2003 (ARMV4) {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Itanium.ActiveCfg = Debug|Itanium {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Itanium.Build.0 = Debug|Itanium {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Itanium.Deploy.0 = Debug|Itanium {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Mixed Platforms.Build.0 = Debug|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Win32.ActiveCfg = Debug|Win32 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Win32.Build.0 = Debug|Win32 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|Win32.Deploy.0 = Debug|Win32 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|x64.ActiveCfg = Debug|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|x64.Build.0 = Debug|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Debug|x64.Deploy.0 = Debug|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release - Stock|Any CPU.ActiveCfg = Release|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release - Stock|Compact Framework (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4) {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release - Stock|Compact Framework (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4) {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release - Stock|Compact Framework (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4) {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release - Stock|Itanium.ActiveCfg = Release|Itanium {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release - Stock|Itanium.Build.0 = Release|Itanium {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release - Stock|Mixed Platforms.ActiveCfg = Release|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release - Stock|Mixed Platforms.Build.0 = Release|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release - Stock|Win32.ActiveCfg = Release|Win32 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release - Stock|x64.ActiveCfg = Release|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release - Stock|x64.Build.0 = Release|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Any CPU.ActiveCfg = Release|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Compact Framework (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4) {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Compact Framework (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4) {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Compact Framework (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4) {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Itanium.ActiveCfg = Release|Itanium {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Itanium.Build.0 = Release|Itanium {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Mixed Platforms.ActiveCfg = Release|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Mixed Platforms.Build.0 = Release|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Win32.ActiveCfg = Release|Win32 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|Win32.Build.0 = Release|Win32 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|x64.ActiveCfg = Release|x64 {10B51CE8-A838-44DE-BD82-B658F0296F80}.Release|x64.Build.0 = Release|x64 {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug - Stock|Any CPU.ActiveCfg = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug - Stock|Any CPU.Build.0 = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug - Stock|Any CPU.Deploy.0 = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug - Stock|Compact Framework (ARMV4).ActiveCfg = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug - Stock|Compact Framework (ARMV4).Build.0 = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug - Stock|Compact Framework (ARMV4).Deploy.0 = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug - Stock|Itanium.ActiveCfg = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug - Stock|Mixed Platforms.ActiveCfg = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug - Stock|Mixed Platforms.Build.0 = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug - Stock|Mixed Platforms.Deploy.0 = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug - Stock|Win32.ActiveCfg = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug - Stock|x64.ActiveCfg = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Any CPU.Build.0 = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Compact Framework (ARMV4).ActiveCfg = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Compact Framework (ARMV4).Build.0 = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Compact Framework (ARMV4).Deploy.0 = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Itanium.ActiveCfg = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Mixed Platforms.Deploy.0 = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|Win32.ActiveCfg = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Debug|x64.ActiveCfg = Debug|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release - Stock|Any CPU.ActiveCfg = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release - Stock|Any CPU.Build.0 = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release - Stock|Any CPU.Deploy.0 = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release - Stock|Compact Framework (ARMV4).ActiveCfg = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release - Stock|Compact Framework (ARMV4).Build.0 = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release - Stock|Compact Framework (ARMV4).Deploy.0 = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release - Stock|Itanium.ActiveCfg = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release - Stock|Mixed Platforms.ActiveCfg = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release - Stock|Mixed Platforms.Build.0 = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release - Stock|Mixed Platforms.Deploy.0 = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release - Stock|Win32.ActiveCfg = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release - Stock|x64.ActiveCfg = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Any CPU.ActiveCfg = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Any CPU.Build.0 = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Any CPU.Deploy.0 = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Compact Framework (ARMV4).ActiveCfg = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Compact Framework (ARMV4).Build.0 = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Compact Framework (ARMV4).Deploy.0 = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Itanium.ActiveCfg = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Mixed Platforms.Build.0 = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Mixed Platforms.Deploy.0 = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|Win32.ActiveCfg = Release|Any CPU {B86CE504-C4E4-496F-A0F0-E613BCFD3DF7}.Release|x64.ActiveCfg = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Any CPU.ActiveCfg = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Any CPU.Build.0 = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Compact Framework (ARMV4).ActiveCfg = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Itanium.ActiveCfg = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Itanium.Build.0 = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Mixed Platforms.ActiveCfg = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Mixed Platforms.Build.0 = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Win32.ActiveCfg = StockDebug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|Win32.Build.0 = StockDebug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|x64.ActiveCfg = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug - Stock|x64.Build.0 = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug|Any CPU.Build.0 = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug|Compact Framework (ARMV4).ActiveCfg = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug|Itanium.ActiveCfg = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug|Itanium.Build.0 = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug|Win32.ActiveCfg = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug|Win32.Build.0 = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug|x64.ActiveCfg = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Debug|x64.Build.0 = Debug|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Any CPU.ActiveCfg = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Any CPU.Build.0 = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Compact Framework (ARMV4).ActiveCfg = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Itanium.ActiveCfg = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Itanium.Build.0 = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Mixed Platforms.ActiveCfg = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Mixed Platforms.Build.0 = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Win32.ActiveCfg = StockRelease|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release - Stock|Win32.Build.0 = StockRelease|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release - Stock|x64.ActiveCfg = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release - Stock|x64.Build.0 = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release|Any CPU.ActiveCfg = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release|Any CPU.Build.0 = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release|Compact Framework (ARMV4).ActiveCfg = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release|Itanium.ActiveCfg = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release|Itanium.Build.0 = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release|Mixed Platforms.Build.0 = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release|Win32.ActiveCfg = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release|Win32.Build.0 = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release|x64.ActiveCfg = Release|Any CPU {AC139952-261A-4463-B6FA-AEBC25283A66}.Release|x64.Build.0 = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug - Stock|Any CPU.ActiveCfg = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug - Stock|Any CPU.Build.0 = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug - Stock|Compact Framework (ARMV4).ActiveCfg = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug - Stock|Itanium.ActiveCfg = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug - Stock|Itanium.Build.0 = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug - Stock|Mixed Platforms.ActiveCfg = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug - Stock|Mixed Platforms.Build.0 = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug - Stock|Win32.ActiveCfg = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug - Stock|Win32.Build.0 = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug - Stock|x64.ActiveCfg = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug - Stock|x64.Build.0 = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug|Any CPU.Build.0 = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug|Compact Framework (ARMV4).ActiveCfg = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug|Itanium.ActiveCfg = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug|Itanium.Build.0 = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug|Win32.ActiveCfg = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug|Win32.Build.0 = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug|x64.ActiveCfg = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Debug|x64.Build.0 = Debug|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release - Stock|Any CPU.ActiveCfg = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release - Stock|Any CPU.Build.0 = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release - Stock|Compact Framework (ARMV4).ActiveCfg = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release - Stock|Itanium.ActiveCfg = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release - Stock|Itanium.Build.0 = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release - Stock|Mixed Platforms.ActiveCfg = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release - Stock|Mixed Platforms.Build.0 = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release - Stock|Win32.ActiveCfg = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release - Stock|Win32.Build.0 = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release - Stock|x64.ActiveCfg = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release - Stock|x64.Build.0 = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release|Any CPU.ActiveCfg = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release|Any CPU.Build.0 = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release|Compact Framework (ARMV4).ActiveCfg = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release|Itanium.ActiveCfg = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release|Itanium.Build.0 = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release|Mixed Platforms.Build.0 = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release|Win32.ActiveCfg = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release|Win32.Build.0 = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release|x64.ActiveCfg = Release|Any CPU {E6BF9F74-58E2-413B-A7CE-EA653ECB728D}.Release|x64.Build.0 = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug - Stock|Any CPU.ActiveCfg = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug - Stock|Any CPU.Build.0 = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug - Stock|Compact Framework (ARMV4).ActiveCfg = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug - Stock|Itanium.ActiveCfg = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug - Stock|Mixed Platforms.ActiveCfg = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug - Stock|Mixed Platforms.Build.0 = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug - Stock|Win32.ActiveCfg = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug - Stock|Win32.Build.0 = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug - Stock|x64.ActiveCfg = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug|Any CPU.Build.0 = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug|Compact Framework (ARMV4).ActiveCfg = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug|Itanium.ActiveCfg = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug|Win32.ActiveCfg = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug|Win32.Build.0 = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Debug|x64.ActiveCfg = Debug|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release - Stock|Any CPU.ActiveCfg = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release - Stock|Any CPU.Build.0 = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release - Stock|Compact Framework (ARMV4).ActiveCfg = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release - Stock|Itanium.ActiveCfg = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release - Stock|Mixed Platforms.ActiveCfg = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release - Stock|Mixed Platforms.Build.0 = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release - Stock|Win32.ActiveCfg = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release - Stock|x64.ActiveCfg = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release|Any CPU.ActiveCfg = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release|Any CPU.Build.0 = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release|Compact Framework (ARMV4).ActiveCfg = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release|Itanium.ActiveCfg = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release|Mixed Platforms.Build.0 = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release|Win32.ActiveCfg = Release|Any CPU {9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}.Release|x64.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal |
Changes to SQLite.NET.suo.
cannot compute difference between binary files
Changes to System.Data.SQLite.Linq/AssemblyInfo.cs.
︙ | ︙ | |||
28 29 30 31 32 33 34 | // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] | | | 28 29 30 31 32 33 34 35 36 | // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.0.36.0")] [assembly: AssemblyFileVersion("1.0.0.0")] |
Changes to System.Data.SQLite.Linq/Resources/SQLiteProviderServices.ProviderManifest.xml.
1 2 3 4 5 6 7 8 9 | <?xml version="1.0" encoding="utf-8"?> <!-- #################################################################################################################### BE AWARE THAT THE ORDER IN WHICH TYPES ARE DESCRIBED IN THE PROVIDER MANIFEST IS RELEVANT AND HAVE IMPACT IN LOOKUP PROCESS #################################################################################################################### --> | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <?xml version="1.0" encoding="utf-8"?> <!-- #################################################################################################################### BE AWARE THAT THE ORDER IN WHICH TYPES ARE DESCRIBED IN THE PROVIDER MANIFEST IS RELEVANT AND HAVE IMPACT IN LOOKUP PROCESS #################################################################################################################### --> <ProviderManifest Namespace="SQLite" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/providermanifest"> <Types> <Type Name="tinyint" PrimitiveTypeKind="Byte"> </Type> <Type Name="smallint" PrimitiveTypeKind="Int16"> </Type> <Type Name="int" PrimitiveTypeKind="Int32"> </Type> |
︙ | ︙ | |||
33 34 35 36 37 38 39 | <FixedLength DefaultValue="false" Constant="true" /> </FacetDescriptions> </Type> <Type Name="bit" PrimitiveTypeKind="Boolean"> </Type> <Type Name="datetime" PrimitiveTypeKind="DateTime"> <FacetDescriptions> | | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | <FixedLength DefaultValue="false" Constant="true" /> </FacetDescriptions> </Type> <Type Name="bit" PrimitiveTypeKind="Boolean"> </Type> <Type Name="datetime" PrimitiveTypeKind="DateTime"> <FacetDescriptions> <Precision DefaultValue="3" Constant="true" /> </FacetDescriptions> </Type> <Type Name="nvarchar" PrimitiveTypeKind="String"> <FacetDescriptions> <MaxLength Minimum="1" Maximum="2147483647" DefaultValue="2147483647" Constant="false" /> <Unicode DefaultValue="true" Constant="true" /> <FixedLength DefaultValue="false" Constant="true" /> |
︙ | ︙ | |||
248 249 250 251 252 253 254 | <Parameter Name="arg" Type="Collection(Decimal)" Mode="In" /> </Function> <Function Name="SUM" Aggregate="true" BuiltIn="true"> <ReturnType Type="Double" /> <Parameter Name="arg" Type="Collection(Double)" Mode="In" /> </Function> | | | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | <Parameter Name="arg" Type="Collection(Decimal)" Mode="In" /> </Function> <Function Name="SUM" Aggregate="true" BuiltIn="true"> <ReturnType Type="Double" /> <Parameter Name="arg" Type="Collection(Double)" Mode="In" /> </Function> <!-- TOTAL --> <Function Name="TOTAL" Aggregate="true" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="arg" Type="Collection(Int32)" Mode="In" /> </Function> <Function Name="TOTAL" Aggregate="true" BuiltIn="true"> <ReturnType Type="Int64" /> |
︙ | ︙ | |||
270 271 272 273 274 275 276 | <ReturnType Type="Double" /> <Parameter Name="arg" Type="Collection(Double)" Mode="In" /> </Function> | | | | | | | | | | | | | | 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 | <ReturnType Type="Double" /> <Parameter Name="arg" Type="Collection(Double)" Mode="In" /> </Function> <!-- END AGGREGATES ############################################# --> <!-- Begin Scalars http://www.sqlite.org/lang_corefunc.html --> <Function Name="ABS" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="arg" Type="Int32" Mode="In" /> </Function> <Function Name="ABS" BuiltIn="true"> <ReturnType Type="Int64" /> <Parameter Name="arg" Type="Int64" Mode="In" /> </Function> <Function Name="ABS" BuiltIn="true"> <ReturnType Type="Decimal" /> <Parameter Name="arg" Type="Decimal" Mode="In" /> </Function> <Function Name="ABS" BuiltIn="true"> <ReturnType Type="Double" /> <Parameter Name="arg" Type="Double" Mode="In" /> </Function> <Function Name="HEX" BuiltIn="true"> <ReturnType Type="String" /> <Parameter Name="arg" Type="Binary" Mode="In" /> </Function> <Function Name="LENGTH" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="string_expression" Type="String" Mode="In" /> </Function> <!-- LOWER( str ) str: char, nchar, varchar, nvarchar, varchar(max), nvarchar(max) returns: varchar, nvarchar --> <Function Name="LOWER" BuiltIn="true"> <ReturnType Type="String" /> <Parameter Name="str" Type="String" Mode="In" /> </Function> <!-- LTRIM( str ) str: char, nchar, varchar, nvarchar, varchar(max), nvarchar(max) returns: varchar, nvarchar --> <Function Name="LTRIM" BuiltIn="true"> <ReturnType Type="String" /> <Parameter Name="str" Type="String" Mode="In" /> </Function> <Function Name="LTRIM" BuiltIn="true"> <ReturnType Type="String" /> <Parameter Name="str" Type="String" Mode="In" /> <Parameter Name="to_remove" Type="String" Mode="In" /> </Function> <!-- TODO: Min and Max Scalar functions --> <!-- QUOTE( character_string [,quote_character] ) character_string: nchar, nvarchar, nvarchar(max) quote_character: nchar, char, varchar, nvarchar returns: nvarchar --> <Function Name="QUOTE" BuiltIn="true"> |
︙ | ︙ | |||
348 349 350 351 352 353 354 | seed: tinyint, smallint, int returns: float --> <Function Name="RANDOM" BuiltIn="true"> <ReturnType Type="Int64" /> </Function> <Function Name="RANDOMBLOB" BuiltIn="true"> | | | | | | 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 | seed: tinyint, smallint, int returns: float --> <Function Name="RANDOM" BuiltIn="true"> <ReturnType Type="Int64" /> </Function> <Function Name="RANDOMBLOB" BuiltIn="true"> <Parameter Name="numBytes" Type="Int64" Mode="In" /> <ReturnType Type="Binary" /> </Function> <!-- REPLACE( strTarget, strSearch, strReplacement ) strTarget: char, nchar, varchar, nvarchar, varchar(max), nvarchar(max) strSearch: char, nchar, varchar, nvarchar, varchar(max), nvarchar(max) strReplacement: char, nchar, varchar, nvarchar, varchar(max), nvarchar(max) returns: varchar, nvarchar --> <Function Name="REPLACE" BuiltIn="true"> <ReturnType Type="String" /> <Parameter Name="strTarget" Type="String" Mode="In" /> <Parameter Name="strSearch" Type="String" Mode="In" /> <Parameter Name="strReplacement" Type="String" Mode="In" /> </Function> <Function Name="ROUND" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="numeric_expression" Type="Int32" Mode="In" /> <Parameter Name="length" Type="Int32" Mode="In" /> </Function> <Function Name="ROUND" BuiltIn="true"> <ReturnType Type="Int64" /> <Parameter Name="numeric_expression" Type="Int64" Mode="In" /> |
︙ | ︙ | |||
409 410 411 412 413 414 415 | </Function> <Function Name="ROUND" BuiltIn="true"> <ReturnType Type="Double" /> <Parameter Name="numeric_expression" Type="Double" Mode="In" /> <Parameter Name="length" Type="Int32" Mode="In" /> <Parameter Name="function" Type="Int32" Mode="In" /> </Function> | | | | | | | > > > > > > > > > > | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | 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 | </Function> <Function Name="ROUND" BuiltIn="true"> <ReturnType Type="Double" /> <Parameter Name="numeric_expression" Type="Double" Mode="In" /> <Parameter Name="length" Type="Int32" Mode="In" /> <Parameter Name="function" Type="Int32" Mode="In" /> </Function> <Function Name="RTRIM" BuiltIn="true"> <ReturnType Type="String" /> <Parameter Name="str" Type="String" Mode="In" /> </Function> <Function Name="RTRIM" BuiltIn="true"> <ReturnType Type="String" /> <Parameter Name="str" Type="String" Mode="In" /> <Parameter Name="to_remove" Type="String" Mode="In" /> </Function> <!-- SOUNDEX( arg ) arg: char, nchar, varchar, nvarchar, varchar(max), nvarchar(max) returns: varchar --> <Function Name="SOUNDEX" BuiltIn="true"> <ReturnType Type="String" /> <Parameter Name="arg" Type="String" Mode="In" /> </Function> <Function Name="SUBSTR" BuiltIn="true"> <ReturnType Type="String" /> <Parameter Name="str" Type="String" Mode="In" /> <Parameter Name="start" Type="Int64" Mode="In" /> <Parameter Name="length" Type="Int64" Mode="In" /> </Function> <Function Name="SUBSTR" BuiltIn="true"> <ReturnType Type="Binary" /> <Parameter Name="str" Type="Binary" Mode="In" /> <Parameter Name="start" Type="Int64" Mode="In" /> <Parameter Name="length" Type="Int64" Mode="In" /> </Function> <Function Name="SUBSTR" BuiltIn="true"> <ReturnType Type="String" /> <Parameter Name="str" Type="String" Mode="In" /> <Parameter Name="start" Type="Int64" Mode="In" /> </Function> <Function Name="SUBSTR" BuiltIn="true"> <ReturnType Type="Binary" /> <Parameter Name="str" Type="Binary" Mode="In" /> <Parameter Name="start" Type="Int64" Mode="In" /> </Function> <Function Name="TRIM" BuiltIn="true"> <ReturnType Type="String" /> <Parameter Name="str" Type="String" Mode="In" /> </Function> <Function Name="TRIM" BuiltIn="true"> <ReturnType Type="String" /> <Parameter Name="str" Type="String" Mode="In" /> <Parameter Name="to_remove" Type="String" Mode="In" /> </Function> <Function Name="UPPER" BuiltIn="true"> <ReturnType Type="String" /> <Parameter Name="str" Type="String" Mode="In" /> </Function> <!-- BEGIN DATE FUNCTIONS ####################################### --> <!-- DATEADD datepart: nvarchar number: tinyint, smallint, int, bigint, numeric, decimal, real, float date: smalldatetime, datetime, varchar, nvarchar, char, nchar returns: SMALLTIME, datetime --> <Function Name="DATEADD" BuiltIn="true"> <ReturnType Type="DateTime" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="number" Type="Double" Mode="In" /> <Parameter Name="date" Type="DateTime" Mode="In" /> </Function> <Function Name="DATEADD" BuiltIn="true"> <ReturnType Type="Time" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="number" Type="Double" Mode="In" /> <Parameter Name="time" Type="Time" Mode="In" /> </Function> <Function Name="DATEADD" BuiltIn="true"> <ReturnType Type="DateTime" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="number" Type="Double" Mode="In" /> <Parameter Name="date" Type="String" Mode="In" /> </Function> <!-- DATEDIFF( datepart, startdate, enddate ) datepart: nvarchar startdate: smalldatetime, datetime, char, nchar, varchar, nvarchar enddate: smalldatetime, datetime, char, nchar, varchar, nvarchar returns: int --> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="DateTime" Mode="In" /> <Parameter Name="enddate" Type="DateTime" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="DateTimeOffset" Mode="In" /> <Parameter Name="enddate" Type="DateTimeOffset" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="Time" Mode="In" /> <Parameter Name="enddate" Type="Time" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="String" Mode="In" /> <Parameter Name="enddate" Type="DateTime" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="String" Mode="In" /> <Parameter Name="enddate" Type="DateTimeOffset" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="String" Mode="In" /> <Parameter Name="enddate" Type="Time" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="Time" Mode="In" /> <Parameter Name="enddate" Type="String" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="DateTime" Mode="In" /> <Parameter Name="enddate" Type="String" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="DateTimeOffset" Mode="In" /> <Parameter Name="enddate" Type="String" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="String" Mode="In" /> <Parameter Name="enddate" Type="String" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="Time" Mode="In" /> <Parameter Name="enddate" Type="DateTime" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="Time" Mode="In" /> <Parameter Name="enddate" Type="DateTimeOffset" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="DateTime" Mode="In" /> <Parameter Name="enddate" Type="Time" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="DateTimeOffset" Mode="In" /> <Parameter Name="enddate" Type="Time" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="DateTime" Mode="In" /> <Parameter Name="enddate" Type="DateTimeOffset" Mode="In" /> </Function> <Function Name="DATEDIFF" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="startdate" Type="DateTimeOffset" Mode="In" /> <Parameter Name="enddate" Type="DateTime" Mode="In" /> </Function> <!-- DATEPART( datepart, date ) datepart: nvarchar date: smalldatetime, datetime, char, nchar, varchar, nvarchar returns: int --> <Function Name="DATEPART" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="date" Type="DateTime" Mode="In" /> </Function> <Function Name="DATEPART" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="date" Type="DateTimeOffset" Mode="In" /> </Function> <Function Name="DATEPART" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="date" Type="String" Mode="In" /> </Function> <Function Name="DATEPART" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="datepart" Type="String" Mode="In" /> <Parameter Name="date" Type="Time" Mode="In" /> </Function> <!-- DAY( date ) date: smalldatetime, datetime returns: int --> <Function Name="DAY" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="date" Type="DateTime" Mode="In" /> </Function> <Function Name="DAY" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="date" Type="DateTimeOffset" Mode="In" /> </Function> <Function Name="DAY" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="date" Type="String" Mode="In" /> </Function> <!-- GETDATE() returns: datetime --> <Function Name="GETDATE" BuiltIn="true"> <ReturnType Type="DateTime"/> </Function> <!-- GETUTCDATE() returns: datetime --> <Function Name="GETUTCDATE" BuiltIn="true"> <ReturnType Type="DateTime"/> </Function> <!-- MONTH( date ) date: smalldatetime, datetime returns: int --> <Function Name="MONTH" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="date" Type="DateTime" Mode="In" /> </Function> <Function Name="MONTH" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="date" Type="DateTimeOffset" Mode="In" /> </Function> <Function Name="MONTH" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="date" Type="String" Mode="In" /> </Function> <!-- YEAR( date ) date: smalldatetime, datetime returns: int --> <Function Name="YEAR" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="date" Type="DateTime" Mode="In" /> </Function> <Function Name="YEAR" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="date" Type="DateTimeOffset" Mode="In" /> </Function> <Function Name="YEAR" BuiltIn="true"> <ReturnType Type="Int32" /> <Parameter Name="date" Type="String" Mode="In" /> </Function> <!-- END DATE FUNCTIONS ######################################### --> <!-- NEWID() --> <Function Name="NEWID" BuiltIn="true"> <ReturnType Type="Guid" /> </Function> <!-- CURRENT_TIMESTAMP --> <Function Name="CURRENT_TIME" BuiltIn="true" NiladicFunction="true"> <ReturnType Type="DateTime" /> </Function> <Function Name="CURRENT_DATE" BuiltIn="true" NiladicFunction="true"> <ReturnType Type="DateTime" /> </Function> <Function Name="CURRENT_TIMESTAMP" BuiltIn="true" NiladicFunction="true"> <ReturnType Type="DateTime" /> </Function> <!-- END SYSTEM FUNCTIONS ####################################### --> </Functions> </ProviderManifest> |
Changes to System.Data.SQLite.Linq/Resources/SQLiteProviderServices.StoreSchemaDefinition.ssdl.
1 | <?xml version="1.0" encoding="utf-8"?> | | | | | | 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 | <?xml version="1.0" encoding="utf-8"?> <Schema Namespace="SQLite" Provider="System.Data.SQLite" ProviderManifestToken="ISO8601" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl"> <EntityContainer Name="Schema"> <EntitySet Name="STables" EntityType="Self.Table"> <DefiningQuery> SELECT '[' || TABLE_NAME || ']' COLLATE NOCASE [Id] , TABLE_CATALOG [CatalogName] , TABLE_SCHEMA [SchemaName] , TABLE_NAME [Name] FROM TEMP.SCHEMATABLES WHERE TABLE_TYPE LIKE 'table' </DefiningQuery> </EntitySet> <EntitySet Name="STableColumns" EntityType="Self.TableColumn"> <DefiningQuery> SELECT '[' || c.TABLE_NAME || ']' || '[' || c.COLUMN_NAME || ']' COLLATE NOCASE [Id] , '[' || c.TABLE_NAME || ']' COLLATE NOCASE [ParentId] , c.COLUMN_NAME [Name] , c.ORDINAL_POSITION [Ordinal] , c.IS_NULLABLE [IsNullable] , c.EDM_TYPE [TypeName] , c.CHARACTER_MAXIMUM_LENGTH [MaxLength] , c.NUMERIC_PRECISION [Precision] , c.DATETIME_PRECISION [DateTimePrecision] |
︙ | ︙ | |||
42 43 44 45 46 47 48 | TEMP.SCHEMACOLUMNS c </DefiningQuery> </EntitySet> <EntitySet Name="SViews" EntityType="Self.View"> <DefiningQuery> SELECT | | | | | 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 | TEMP.SCHEMACOLUMNS c </DefiningQuery> </EntitySet> <EntitySet Name="SViews" EntityType="Self.View"> <DefiningQuery> SELECT '[' || TABLE_NAME || ']' COLLATE NOCASE [Id] , TABLE_CATALOG [CatalogName] , TABLE_SCHEMA [SchemaName] , TABLE_NAME [Name] , VIEW_DEFINITION [ViewDefinition] , IS_UPDATABLE [IsUpdatable] FROM TEMP.SCHEMAVIEWS </DefiningQuery> </EntitySet> <EntitySet Name="SViewColumns" EntityType="Self.ViewColumn"> <DefiningQuery> SELECT '[' || c.TABLE_NAME || ']' || '[' || c.COLUMN_NAME || ']' COLLATE NOCASE [Id] , '[' || c.TABLE_NAME || ']' COLLATE NOCASE [ParentId] , c.COLUMN_NAME [Name] , c.ORDINAL_POSITION [Ordinal] , c.IS_NULLABLE [IsNullable] , c.EDM_TYPE [TypeName] , c.CHARACTER_MAXIMUM_LENGTH [MaxLength] , c.NUMERIC_PRECISION [Precision] , c.DATETIME_PRECISION as [DateTimePrecision] |
︙ | ︙ | |||
171 172 173 174 175 176 177 | WHERE 1=2 </DefiningQuery> </EntitySet> <EntitySet Name="SConstraints" EntityType="Self.Constraint"> <DefiningQuery> SELECT | | | | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | WHERE 1=2 </DefiningQuery> </EntitySet> <EntitySet Name="SConstraints" EntityType="Self.Constraint"> <DefiningQuery> SELECT '[' || tc.CONSTRAINT_NAME || ']' COLLATE NOCASE [Id] , '[' || tc.TABLE_NAME || ']' COLLATE NOCASE [ParentId] , tc.CONSTRAINT_NAME [Name] , tc.CONSTRAINT_TYPE [ConstraintType] , tc.IS_DEFERRABLE [IsDeferrable] , tc.INITIALLY_DEFERRED [IsInitiallyDeferred] FROM TEMP.SCHEMACONSTRAINTS tc </DefiningQuery> |
︙ | ︙ | |||
194 195 196 197 198 199 200 | WHERE 1 = 2 </DefiningQuery> </EntitySet> <EntitySet Name="SConstraintColumns" EntityType="Self.ConstraintColumn"> <DefiningQuery> SELECT | | | | | | | | | | | 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 | WHERE 1 = 2 </DefiningQuery> </EntitySet> <EntitySet Name="SConstraintColumns" EntityType="Self.ConstraintColumn"> <DefiningQuery> SELECT '[' || CONSTRAINT_NAME || ']' COLLATE NOCASE [ConstraintId] , '[' || TABLE_NAME || ']' || '[' || COLUMN_NAME || ']' COLLATE NOCASE [ColumnId] FROM TEMP.SCHEMACONSTRAINTCOLUMNS </DefiningQuery> </EntitySet> <EntitySet Name="SForeignKeyConstraints" EntityType="Self.ForeignKeyConstraint"> <DefiningQuery> SELECT '[' || rc.CONSTRAINT_NAME || ']' COLLATE NOCASE [Id] , 'NO ACTION' COLLATE NOCASE [UpdateRule] , 'NO ACTION' COLLATE NOCASE [DeleteRule] FROM TEMP.SCHEMAFOREIGNKEYS rc </DefiningQuery> </EntitySet> <EntitySet Name="SForeignKeys" EntityType="Self.ForeignKey"> <DefiningQuery> SELECT '[' || FC.CONSTRAINT_NAME || ']' || '[' || FC.FKEY_FROM_ORDINAL_POSITION || ']' COLLATE NOCASE [Id] , '[' || FC.FKEY_TO_TABLE || ']' || '[' || FC.FKEY_TO_COLUMN || ']' COLLATE NOCASE [ToColumnId] , '[' || FC.TABLE_NAME || ']' || '[' || FC.FKEY_FROM_COLUMN || ']' COLLATE NOCASE [FromColumnId] , '[' || FC.CONSTRAINT_NAME || ']' COLLATE NOCASE [ConstraintId] , FC.FKEY_FROM_ORDINAL_POSITION [Ordinal] FROM TEMP.SCHEMAFOREIGNKEYS FC </DefiningQuery> </EntitySet> <EntitySet Name="SViewConstraints" EntityType="Self.ViewConstraint"> |
︙ | ︙ |
Added System.Data.SQLite.Linq/Resources/System.Data.Resources.CodeGenerationSchema.xsd.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | <?xml version="1.0" encoding="utf-8" ?> <xs:schema id="CodeGenerationSchema" targetNamespace="http://schemas.microsoft.com/ado/2006/04/codegeneration" elementFormDefault="unqualified" xmlns="http://schemas.microsoft.com/ado/2006/04/codegeneration" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:attribute name="SetterAccess" type="TAccess"/> <xs:attribute name="GetterAccess" type="TAccess"/> <xs:attribute name="TypeAccess" type="TPublicOrInternalAccess"/> <xs:attribute name="MethodAccess" type="TAccess"/> <xs:simpleType name="TAccess"> <xs:restriction base="xs:string"> <xs:enumeration value="Public" /> <xs:enumeration value="Internal" /> <xs:enumeration value="Protected" /> <xs:enumeration value="Private" /> </xs:restriction> </xs:simpleType> <xs:simpleType name="TPublicOrInternalAccess"> <xs:restriction base="TAccess"> <xs:enumeration value="Public" /> <xs:enumeration value="Internal" /> </xs:restriction> </xs:simpleType> </xs:schema> |
Changes to System.Data.SQLite.Linq/SQL.
︙ | ︙ | |||
196 197 198 199 200 201 202 203 204 205 206 207 208 209 | /// Thus, <c>b.x</c> is resolved to <c>Symbol(c).x</c> if there is reuse, and to /// <c>Symbol(b).x</c> if there is no reuse. /// </example> /// </para> /// </remarks> internal sealed class SqlGenerator : DbExpressionVisitor<ISqlFragment> { #region Visitor parameter stacks /// <summary> /// Every relational node has to pass its SELECT statement to its children /// This allows them (DbVariableReferenceExpression eventually) to update the list of /// outer extents (free variables) used by this select statement. /// </summary> Stack<SqlSelectStatement> selectStatementStack; | > > | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | /// Thus, <c>b.x</c> is resolved to <c>Symbol(c).x</c> if there is reuse, and to /// <c>Symbol(b).x</c> if there is no reuse. /// </example> /// </para> /// </remarks> internal sealed class SqlGenerator : DbExpressionVisitor<ISqlFragment> { private SQLiteProviderManifest _manifest; #region Visitor parameter stacks /// <summary> /// Every relational node has to pass its SELECT statement to its children /// This allows them (DbVariableReferenceExpression eventually) to update the list of /// outer extents (free variables) used by this select statement. /// </summary> Stack<SqlSelectStatement> selectStatementStack; |
︙ | ︙ | |||
263 264 265 266 267 268 269 | #endregion #region Statics static private readonly Dictionary<string, FunctionHandler> _builtInFunctionHandlers = InitializeBuiltInFunctionHandlers(); static private readonly Dictionary<string, FunctionHandler> _canonicalFunctionHandlers = InitializeCanonicalFunctionHandlers(); static private readonly Dictionary<string, string> _functionNameToOperatorDictionary = InitializeFunctionNameToOperatorDictionary(); | | | | | | | | | 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 | #endregion #region Statics static private readonly Dictionary<string, FunctionHandler> _builtInFunctionHandlers = InitializeBuiltInFunctionHandlers(); static private readonly Dictionary<string, FunctionHandler> _canonicalFunctionHandlers = InitializeCanonicalFunctionHandlers(); static private readonly Dictionary<string, string> _functionNameToOperatorDictionary = InitializeFunctionNameToOperatorDictionary(); static private readonly Dictionary<string, string> _datepartKeywords = InitializeDatepartKeywords(); static private readonly char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; private delegate ISqlFragment FunctionHandler(SqlGenerator sqlgen, DbFunctionExpression functionExpr); /// <summary> /// All special built-in functions and their handlers /// </summary> /// <returns></returns> private static Dictionary<string, FunctionHandler> InitializeBuiltInFunctionHandlers() { Dictionary<string, FunctionHandler> functionHandlers = new Dictionary<string, FunctionHandler>(7, StringComparer.Ordinal); functionHandlers.Add("CONCAT", HandleConcatFunction); functionHandlers.Add("DATEPART", HandleDatepartDateFunction); functionHandlers.Add("DatePart", HandleDatepartDateFunction); functionHandlers.Add("GETDATE", HandleGetDateFunction); functionHandlers.Add("GETUTCDATE", HandleGetUtcDateFunction); return functionHandlers; } /// <summary> /// All special non-aggregate canonical functions and their handlers /// </summary> /// <returns></returns> |
︙ | ︙ | |||
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | functionHandlers.Add("Month", HandleCanonicalFunctionDatepart); functionHandlers.Add("Day", HandleCanonicalFunctionDatepart); functionHandlers.Add("Hour", HandleCanonicalFunctionDatepart); functionHandlers.Add("Minute", HandleCanonicalFunctionDatepart); functionHandlers.Add("Second", HandleCanonicalFunctionDatepart); functionHandlers.Add("DateAdd", HandleCanonicalFunctionDateAdd); functionHandlers.Add("DateDiff", HandleCanonicalFunctionDateSubtract); //Functions that translate to operators functionHandlers.Add("Concat", HandleConcatFunction); functionHandlers.Add("BitwiseAnd", HandleCanonicalFunctionBitwise); functionHandlers.Add("BitwiseNot", HandleCanonicalFunctionBitwise); functionHandlers.Add("BitwiseOr", HandleCanonicalFunctionBitwise); functionHandlers.Add("BitwiseXor", HandleCanonicalFunctionBitwise); return functionHandlers; } /// <summary> /// Valid datepart values /// </summary> /// <returns></returns> | > > | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | < < | | | > | | | | 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 | functionHandlers.Add("Month", HandleCanonicalFunctionDatepart); functionHandlers.Add("Day", HandleCanonicalFunctionDatepart); functionHandlers.Add("Hour", HandleCanonicalFunctionDatepart); functionHandlers.Add("Minute", HandleCanonicalFunctionDatepart); functionHandlers.Add("Second", HandleCanonicalFunctionDatepart); functionHandlers.Add("DateAdd", HandleCanonicalFunctionDateAdd); functionHandlers.Add("DateDiff", HandleCanonicalFunctionDateSubtract); functionHandlers.Add("DATEADD", HandleCanonicalFunctionDateAdd); // store functionHandlers.Add("DATEDIFF", HandleCanonicalFunctionDateSubtract); // store //Functions that translate to operators functionHandlers.Add("Concat", HandleConcatFunction); functionHandlers.Add("BitwiseAnd", HandleCanonicalFunctionBitwise); functionHandlers.Add("BitwiseNot", HandleCanonicalFunctionBitwise); functionHandlers.Add("BitwiseOr", HandleCanonicalFunctionBitwise); functionHandlers.Add("BitwiseXor", HandleCanonicalFunctionBitwise); return functionHandlers; } /// <summary> /// Valid datepart values /// </summary> /// <returns></returns> private static Dictionary<string, string> InitializeDatepartKeywords() { #region Datepart Keywords // // valid datepart values // Dictionary<string, string> datepartKeywords = new Dictionary<string, string>(30, StringComparer.OrdinalIgnoreCase); datepartKeywords.Add("d", "%d"); datepartKeywords.Add("day", "%d"); datepartKeywords.Add("dayofyear", "%j"); datepartKeywords.Add("dd", "%d"); datepartKeywords.Add("dw", "%w"); datepartKeywords.Add("dy", "%j"); datepartKeywords.Add("hh", "%H"); datepartKeywords.Add("hour", "%H"); datepartKeywords.Add("m", "%m"); datepartKeywords.Add("mi", "%M"); datepartKeywords.Add("millisecond", "%f"); datepartKeywords.Add("minute", "%M"); datepartKeywords.Add("mm", "%m"); datepartKeywords.Add("month", "%m"); datepartKeywords.Add("ms", "%f"); datepartKeywords.Add("n", "%M"); datepartKeywords.Add("s", "%S"); datepartKeywords.Add("second", "%S"); datepartKeywords.Add("ss", "%S"); datepartKeywords.Add("week", "%W"); datepartKeywords.Add("weekday", "%w"); datepartKeywords.Add("wk", "%W"); datepartKeywords.Add("ww", "%W"); datepartKeywords.Add("y", "%Y"); datepartKeywords.Add("year", "%Y"); datepartKeywords.Add("yy", "%Y"); datepartKeywords.Add("yyyy", "%Y"); return datepartKeywords; #endregion } /// <summary> /// Initializes the mapping from functions to T-SQL operators /// for all functions that translate to T-SQL operators /// </summary> /// <returns></returns> private static Dictionary<string, string> InitializeFunctionNameToOperatorDictionary() { Dictionary<string, string> functionNameToOperatorDictionary = new Dictionary<string, string>(5, StringComparer.Ordinal); functionNameToOperatorDictionary.Add("Concat", "||"); //canonical functionNameToOperatorDictionary.Add("CONCAT", "||"); //store functionNameToOperatorDictionary.Add("BitwiseAnd", "&"); functionNameToOperatorDictionary.Add("BitwiseNot", "~"); functionNameToOperatorDictionary.Add("BitwiseOr", "|"); functionNameToOperatorDictionary.Add("BitwiseXor", "^"); return functionNameToOperatorDictionary; } #endregion #region Constructor /// <summary> /// Basic constructor. /// </summary> private SqlGenerator(SQLiteProviderManifest manifest) { _manifest = manifest; } #endregion #region Entry points /// <summary> /// General purpose static function that can be called from System.Data assembly /// </summary> /// <param name="sqlVersion">Server version</param> /// <param name="tree">command tree</param> /// <param name="parameters">Parameters to add to the command tree corresponding /// to constants in the command tree. Used only in ModificationCommandTrees.</param> /// <returns>The string representing the SQL to be executed.</returns> internal static string GenerateSql(SQLiteProviderManifest manifest, DbCommandTree tree, out List<DbParameter> parameters, out CommandType commandType) { commandType = CommandType.Text; //Handle Query DbQueryCommandTree queryCommandTree = tree as DbQueryCommandTree; if (queryCommandTree != null) { SqlGenerator sqlGen = new SqlGenerator(manifest); parameters = null; string sql = sqlGen.GenerateSql((DbQueryCommandTree)tree); return sql; } //Handle Function DbFunctionCommandTree DbFunctionCommandTree = tree as DbFunctionCommandTree; if (DbFunctionCommandTree != null) { SqlGenerator sqlGen = new SqlGenerator(manifest); parameters = null; string sql = sqlGen.GenerateFunctionSql(DbFunctionCommandTree, out commandType); return sql; } |
︙ | ︙ | |||
468 469 470 471 472 473 474 | /// CollectionType => select statement /// non collection type => select expression /// </summary> /// <param name="tree"></param> /// <returns>The string representing the SQL to be executed.</returns> private string GenerateSql(DbQueryCommandTree tree) { | > | > | 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | /// CollectionType => select statement /// non collection type => select expression /// </summary> /// <param name="tree"></param> /// <returns>The string representing the SQL to be executed.</returns> private string GenerateSql(DbQueryCommandTree tree) { // Tree Validation seems to have disappeared from the public method list in SP1 RC //tree.Validate(); tree.GetType().InvokeMember("Validate", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod, null, tree, null); selectStatementStack = new Stack<SqlSelectStatement>(); isParentAJoinStack = new Stack<bool>(); allExtentNames = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); allColumnNames = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); |
︙ | ︙ | |||
522 523 524 525 526 527 528 | } /// <summary> /// Translate a function command tree to a SQL string. /// </summary> private string GenerateFunctionSql(DbFunctionCommandTree tree, out CommandType commandType) { | > | > | | 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | } /// <summary> /// Translate a function command tree to a SQL string. /// </summary> private string GenerateFunctionSql(DbFunctionCommandTree tree, out CommandType commandType) { // Tree Validation seems to have disappeared from the public method list in SP1 RC //tree.Validate(); tree.GetType().InvokeMember("Validate", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod, null, tree, null); EdmFunction function = tree.EdmFunction; // We expect function to always have these properties string userCommandText = (string)function.MetadataProperties["CommandTextAttribute"].Value; string userSchemaName = (string)function.MetadataProperties["Schema"].Value; string userFuncName = (string)function.MetadataProperties["StoreFunctionNameAttribute"].Value; if (String.IsNullOrEmpty(userCommandText)) |
︙ | ︙ | |||
602 603 604 605 606 607 608 | /// An apply is just like a join, so it shares the common join processing /// in <see cref="VisitJoinExpression"/> /// </summary> /// <param name="e"></param> /// <returns>A <see cref="SqlSelectStatement"/>.</returns> public override ISqlFragment Visit(DbApplyExpression e) { | > > | | | | | < > | | | | | | | | | > | < | | | | 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 | /// An apply is just like a join, so it shares the common join processing /// in <see cref="VisitJoinExpression"/> /// </summary> /// <param name="e"></param> /// <returns>A <see cref="SqlSelectStatement"/>.</returns> public override ISqlFragment Visit(DbApplyExpression e) { throw new NotSupportedException("APPLY joins are not supported"); //List<DbExpressionBinding> inputs = new List<DbExpressionBinding>(); //inputs.Add(e.Input); //inputs.Add(e.Apply); //string joinString; //switch (e.ExpressionKind) //{ // case DbExpressionKind.CrossApply: // joinString = "CROSS APPLY"; // break; // case DbExpressionKind.OuterApply: // joinString = "OUTER APPLY"; // break; // default: // Debug.Assert(false); // throw new InvalidOperationException(); //} //// The join condition does not exist in this case, so we use null. //// We do not have a on clause, so we use JoinType.CrossJoin. //return VisitJoinExpression(inputs, DbExpressionKind.CrossJoin, joinString, null); } /// <summary> /// For binary expressions, we delegate to <see cref="VisitBinaryExpression"/>. /// We handle the other expressions directly. /// </summary> /// <param name="e"></param> |
︙ | ︙ | |||
883 884 885 886 887 888 889 | { SqlSelectStatement result = VisitExpressionEnsureSqlStatement(e.Argument); if (!IsCompatible(result, e.ExpressionKind)) { Symbol fromSymbol; TypeUsage inputType = MetadataHelpers.GetElementTypeUsage(e.Argument.ResultType); | | | | 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 | { SqlSelectStatement result = VisitExpressionEnsureSqlStatement(e.Argument); if (!IsCompatible(result, e.ExpressionKind)) { Symbol fromSymbol; TypeUsage inputType = MetadataHelpers.GetElementTypeUsage(e.Argument.ResultType); result = CreateNewSelectStatement(result, "DISTINCT", inputType, out fromSymbol); AddFromSymbol(result, "DISTINCT", fromSymbol, false); } result.IsDistinct = true; return result; } /// <summary> |
︙ | ︙ | |||
1036 1037 1038 1039 1040 1041 1042 | /// FunctionName(arg1, arg2, ..., argn). /// We translate user-defined functions to NamespaceName.FunctionName(arg1, arg2, ..., argn). /// </summary> /// <param name="e"></param> /// <returns>A <see cref="SqlBuilder"/></returns> public override ISqlFragment Visit(DbFunctionExpression e) { | > | < > | < > | 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 | /// FunctionName(arg1, arg2, ..., argn). /// We translate user-defined functions to NamespaceName.FunctionName(arg1, arg2, ..., argn). /// </summary> /// <param name="e"></param> /// <returns>A <see cref="SqlBuilder"/></returns> public override ISqlFragment Visit(DbFunctionExpression e) { // The check for a Lambda expression seems to have disappeared from the public method list in SP1 RC //if (e.IsLambda) //{ // throw new NotSupportedException(); //} // // check if function requires special case processing, if so, delegates to it // if (IsSpecialBuiltInFunction(e)) { return HandleSpecialBuiltInFunction(e); |
︙ | ︙ | |||
1402 1403 1404 1405 1406 1407 1408 | { TypeUsage inputType = MetadataHelpers.GetElementTypeUsage(e.Argument.ResultType); result = CreateNewSelectStatement(result, "top", inputType, out fromSymbol); AddFromSymbol(result, "top", fromSymbol, false); } | | | 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 | { TypeUsage inputType = MetadataHelpers.GetElementTypeUsage(e.Argument.ResultType); result = CreateNewSelectStatement(result, "top", inputType, out fromSymbol); AddFromSymbol(result, "top", fromSymbol, false); } ISqlFragment topCount = HandleCountExpression(e.Limit); result.Top = new TopClause(topCount, e.WithTies); return result; } /// <summary> /// DbNewInstanceExpression is allowed as a child of DbProjectExpression only. |
︙ | ︙ | |||
1726 1727 1728 1729 1730 1731 1732 | /// WHERE Y.[row_number] > count /// ORDER BY sk1, sk2, ... /// </summary> /// <param name="e"></param> /// <returns>A <see cref="SqlBuilder"/></returns> public override ISqlFragment Visit(DbSkipExpression e) { | > | | | | | | < > | > | < | | | | | | | | | | | | | | | | | | | | | | | | < > | | < > | | | | | | | | | > > | < < | < > | | | < > | | | | | | | | | | | | | | | 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 | /// WHERE Y.[row_number] > count /// ORDER BY sk1, sk2, ... /// </summary> /// <param name="e"></param> /// <returns>A <see cref="SqlBuilder"/></returns> public override ISqlFragment Visit(DbSkipExpression e) { throw new NotSupportedException(); //Debug.Assert(e.Count is DbConstantExpression || e.Count is DbParameterReferenceExpression, "DbSkipExpression.Count is of invalid expression type"); ////Visit the input //Symbol fromSymbol; //SqlSelectStatement input = VisitInputExpression(e.Input.Expression, e.Input.VariableName, e.Input.VariableType, out fromSymbol); //// Skip is not compatible with anything that OrderBy is not compatible with, as well as with distinct //if (!IsCompatible(input, e.ExpressionKind)) //{ // input = CreateNewSelectStatement(input, e.Input.VariableName, e.Input.VariableType, out fromSymbol); //} //selectStatementStack.Push(input); //symbolTable.EnterScope(); //AddFromSymbol(input, e.Input.VariableName, fromSymbol); ////Add the default columns //Debug.Assert(input.Select.IsEmpty); //List<Symbol> inputColumns = AddDefaultColumns(input); //input.Select.Append(", row_number() OVER (ORDER BY "); //AddSortKeys(input.Select, e.SortOrder); //input.Select.Append(") AS "); //Symbol row_numberSymbol = new Symbol("row_number", null); //input.Select.Append(row_numberSymbol); ////The inner statement is complete, its scopes need not be valid any longer //symbolTable.ExitScope(); //selectStatementStack.Pop(); ////Create the resulting statement ////See CreateNewSelectStatement, it is very similar //SqlSelectStatement result = new SqlSelectStatement(); //result.From.Append("( "); //result.From.Append(input); //result.From.AppendLine(); //result.From.Append(") "); ////Create a symbol for the input //Symbol resultFromSymbol = null; //if (input.FromExtents.Count == 1) //{ // JoinSymbol oldJoinSymbol = input.FromExtents[0] as JoinSymbol; // if (oldJoinSymbol != null) // { // // Note: input.FromExtents will not do, since it might // // just be an alias of joinSymbol, and we want an actual JoinSymbol. // JoinSymbol newJoinSymbol = new JoinSymbol(e.Input.VariableName, e.Input.VariableType, oldJoinSymbol.ExtentList); // // This indicates that the oldStatement is a blocking scope // // i.e. it hides/renames extent columns // newJoinSymbol.IsNestedJoin = true; // newJoinSymbol.ColumnList = inputColumns; // newJoinSymbol.FlattenedExtentList = oldJoinSymbol.FlattenedExtentList; // resultFromSymbol = newJoinSymbol; // } //} //if (resultFromSymbol == null) //{ // // This is just a simple extent/SqlSelectStatement, // // and we can get the column list from the type. // resultFromSymbol = new Symbol(e.Input.VariableName, e.Input.VariableType); //} ////Add the ORDER BY part //selectStatementStack.Push(result); //symbolTable.EnterScope(); //AddFromSymbol(result, e.Input.VariableName, resultFromSymbol); ////Add the predicate //result.Where.Append(resultFromSymbol); //result.Where.Append("."); //result.Where.Append(row_numberSymbol); //result.Where.Append(" > "); //result.Where.Append(HandaleCountExpression(e.Count)); //AddSortKeys(result.OrderBy, e.SortOrder); //symbolTable.ExitScope(); //selectStatementStack.Pop(); //return result; } /// <summary> /// <see cref="Visit(DbFilterExpression)"/> /// </summary> /// <param name="e"></param> /// <returns>A <see cref="SqlSelectStatement"/></returns> |
︙ | ︙ | |||
1919 1920 1921 1922 1923 1924 1925 | if (functionAggregate == null) { throw new NotSupportedException(); } //The only aggregate function with different name is Big_Count //Note: If another such function is to be added, a dictionary should be created | | | < > | < > | | 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 | if (functionAggregate == null) { throw new NotSupportedException(); } //The only aggregate function with different name is Big_Count //Note: If another such function is to be added, a dictionary should be created //if (MetadataHelpers.IsCanonicalFunction(functionAggregate.Function) // && String.Equals(functionAggregate.Function.Name, "BigCount", StringComparison.Ordinal)) //{ // aggregateResult.Append("COUNT_BIG"); //} //else { WriteFunctionName(aggregateResult, functionAggregate.Function); } aggregateResult.Append("("); DbFunctionAggregate fnAggr = functionAggregate; |
︙ | ︙ | |||
2633 2634 2635 2636 2637 2638 2639 2640 2641 | /// <param name="sqlgen"></param> /// <param name="e"></param> /// <returns></returns> private static ISqlFragment HandleCanonicalFunctionBitwise(SqlGenerator sqlgen, DbFunctionExpression e) { return sqlgen.HandleSpecialFunctionToOperator(e, true); } /// <summary> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > | < | < < > | | | > | > | > > > > | > > | > > > | > > > > > > > | > | | > < < < > > > > > | > > | > < < < < < > > > > | | > < < | > > > > > > | | | > > > > > > > | > | > | | 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 | /// <param name="sqlgen"></param> /// <param name="e"></param> /// <returns></returns> private static ISqlFragment HandleCanonicalFunctionBitwise(SqlGenerator sqlgen, DbFunctionExpression e) { return sqlgen.HandleSpecialFunctionToOperator(e, true); } private static ISqlFragment HandleGetDateFunction(SqlGenerator sqlgen, DbFunctionExpression e) { SqlBuilder result = new SqlBuilder(); Debug.Assert(e.Arguments.Count == 0, "Canonical getdate function should have no arguments"); switch (sqlgen._manifest._dateFormat) { case SQLiteDateFormats.Ticks: result.Append("(STRFTIME('%s', 'now') * 10000000 + 621355968000000000)"); break; case SQLiteDateFormats.JulianDay: result.Append("CAST(STRFTIME('%J', 'now') AS double)"); break; default: result.Append("STRFTIME('%Y-%m-%d %H:%M:%S', 'now')"); break; } return result; } private static ISqlFragment HandleGetUtcDateFunction(SqlGenerator sqlgen, DbFunctionExpression e) { SqlBuilder result = new SqlBuilder(); Debug.Assert(e.Arguments.Count == 0, "Canonical getutcdate function should have no arguments"); switch (sqlgen._manifest._dateFormat) { case SQLiteDateFormats.Ticks: result.Append("(STRFTIME('%s', 'now', 'utc') * 10000000 + 621355968000000000)"); break; case SQLiteDateFormats.JulianDay: result.Append("CAST(STRFTIME('%J', 'now', 'utc') AS double)"); break; default: result.Append("STRFTIME('%Y-%m-%d %H:%M:%S', 'now', 'utc')"); break; } return result; } /// <summary> /// Handles special case in which datepart 'type' parameter is present. all the functions /// handles here have *only* the 1st parameter as datepart. datepart value is passed along /// the QP as string and has to be expanded as TSQL keyword. /// </summary> /// <param name="sqlgen"></param> /// <param name="e"></param> /// <returns></returns> private static ISqlFragment HandleDatepartDateFunction(SqlGenerator sqlgen, DbFunctionExpression e) { Debug.Assert(e.Arguments.Count == 2, "datepart function must have 2 arguments"); DbConstantExpression constExpr = e.Arguments[0] as DbConstantExpression; if (null == constExpr) { throw new InvalidOperationException(String.Format("DATEPART argument to function '{0}.{1}' must be a literal string", e.Function.NamespaceName, e.Function.Name)); } string datepart = constExpr.Value as string; if (null == datepart) { throw new InvalidOperationException(String.Format("DATEPART argument to function '{0}.{1}' must be a literal string", e.Function.NamespaceName, e.Function.Name)); } SqlBuilder result = new SqlBuilder(); // // check if datepart value is valid // string trans; if (!_datepartKeywords.TryGetValue(datepart, out trans)) { throw new InvalidOperationException(String.Format("{0}' is not a valid value for DATEPART argument in '{1}.{2}' function", datepart, e.Function.NamespaceName, e.Function.Name)); } if (trans != "%f") { result.Append("CAST(STRFTIME('"); // expand the datepart literal as tsql kword result.Append(trans); result.Append("', "); switch (sqlgen._manifest._dateFormat) { case SQLiteDateFormats.Ticks: result.Append(String.Format("(({0} - 621355968000000000) / 10000000.0)", e.Arguments[1].Accept(sqlgen))); break; default: result.Append(e.Arguments[1].Accept(sqlgen)); break; } result.Append(") AS integer)"); } else { result.Append("CAST(SUBSTR(STRFTIME('%f', "); switch (sqlgen._manifest._dateFormat) { case SQLiteDateFormats.Ticks: result.Append(String.Format("(({0} - 621355968000000000) / 10000000.0)", e.Arguments[1].Accept(sqlgen))); break; default: result.Append(e.Arguments[1].Accept(sqlgen)); break; } result.Append("), 4) AS integer)"); } return result; } /// <summary> /// DateAdd(datetime, secondsToAdd) -> DATEADD ( seconds , number, date) /// </summary> /// <param name="sqlgen"></param> /// <param name="e"></param> /// <returns></returns> private static ISqlFragment HandleCanonicalFunctionDateAdd(SqlGenerator sqlgen, DbFunctionExpression e) { SqlBuilder result = new SqlBuilder(); Debug.Assert(e.Arguments.Count == 2, "Canonical datepart functions should have exactly two arguments"); switch (sqlgen._manifest._dateFormat) { case SQLiteDateFormats.Ticks: result.Append(String.Format("(STRFTIME('%s', JULIANDAY({1}) - ({0} / 86400.0)) * 10000000 + 621355968000000000)", e.Arguments[0].Accept(sqlgen), e.Arguments[1].Accept(sqlgen))); break; case SQLiteDateFormats.JulianDay: result.Append(String.Format("CAST(STRFTIME('%J', JULIANDAY({1}) - ({0} / 86400.0)) AS double)", e.Arguments[0].Accept(sqlgen), e.Arguments[1].Accept(sqlgen))); break; default: result.Append(String.Format("STRFTIME('%Y-%m-%d %H:%M:%S', JULIANDAY({1}) - ({0} / 86400.0))", e.Arguments[0].Accept(sqlgen), e.Arguments[1].Accept(sqlgen))); break; } return result; } /// <summary> /// DateSubtract(datetime1, datetime2) -> DATEDIFF ( seconds , startdate , enddate ) /// </summary> /// <param name="sqlgen"></param> /// <param name="e"></param> /// <returns></returns> private static ISqlFragment HandleCanonicalFunctionDateSubtract(SqlGenerator sqlgen, DbFunctionExpression e) { SqlBuilder result = new SqlBuilder(); Debug.Assert(e.Arguments.Count == 2, "Canonical datepart functions should have exactly two arguments"); switch (sqlgen._manifest._dateFormat) { case SQLiteDateFormats.Ticks: result.Append(String.Format("CAST((({0} - 621355968000000000) / 10000000.0) - (({1} - 621355968000000000) / 10000000.0) * 86400.0 AS integer)", e.Arguments[0].Accept(sqlgen), e.Arguments[1].Accept(sqlgen))); break; default: result.Append(String.Format("CAST((JULIANDAY({0}) - JULIANDAY({1})) * 86400.0 AS integer)", e.Arguments[0].Accept(sqlgen), e.Arguments[1].Accept(sqlgen))); break; } return result; } /// <summary> /// Handler for canonical functions for extracting date parts. /// For example: /// Year(date) -> DATEPART( year, date) /// </summary> /// <param name="sqlgen"></param> /// <param name="e"></param> /// <returns></returns> private static ISqlFragment HandleCanonicalFunctionDatepart(SqlGenerator sqlgen, DbFunctionExpression e) { string trans; if (!_datepartKeywords.TryGetValue(e.Function.Name, out trans)) { throw new InvalidOperationException(String.Format("{0}' is not a valid value for STRFTIME argument", e.Function.Name)); } SqlBuilder result = new SqlBuilder(); result.Append("CAST(STRFTIME('"); result.Append(trans); result.Append("', "); Debug.Assert(e.Arguments.Count == 1, "Canonical datepart functions should have exactly one argument"); switch (sqlgen._manifest._dateFormat) { case SQLiteDateFormats.Ticks: result.Append(String.Format("(({0} - 621355968000000000) / 10000000.0)", e.Arguments[0].Accept(sqlgen))); break; default: result.Append(e.Arguments[0].Accept(sqlgen)); break; } result.Append(") AS integer)"); return result; } /// <summary> /// Function rename IndexOf -> CHARINDEX /// </summary> |
︙ | ︙ | |||
2780 2781 2782 2783 2784 2785 2786 | /// Function rename NewGuid -> NEWID /// </summary> /// <param name="sqlgen"></param> /// <param name="e"></param> /// <returns></returns> private static ISqlFragment HandleCanonicalFunctionNewGuid(SqlGenerator sqlgen, DbFunctionExpression e) { | > > | | | 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 | /// Function rename NewGuid -> NEWID /// </summary> /// <param name="sqlgen"></param> /// <param name="e"></param> /// <returns></returns> private static ISqlFragment HandleCanonicalFunctionNewGuid(SqlGenerator sqlgen, DbFunctionExpression e) { SqlBuilder result = new SqlBuilder(); result.Append("RANDOMBLOB(16)"); return result; } /// <summary> /// Length(arg) -> LEN(arg + '.') - LEN('.') /// </summary> /// <param name="sqlgen"></param> /// <param name="e"></param> /// <returns></returns> private static ISqlFragment HandleCanonicalFunctionLength(SqlGenerator sqlgen, DbFunctionExpression e) { SqlBuilder result = new SqlBuilder(); result.Append("LENGTH("); Debug.Assert(e.Arguments.Count == 1, "Len should have one argument"); result.Append(e.Arguments[0].Accept(sqlgen)); result.Append(")"); //result.Append(" + '.') - LEN('.')"); |
︙ | ︙ | |||
2834 2835 2836 2837 2838 2839 2840 | /// <param name="sqlgen"></param> /// <param name="e"></param> /// <returns></returns> private static ISqlFragment HandleCanonicalFunctionTrim(SqlGenerator sqlgen, DbFunctionExpression e) { SqlBuilder result = new SqlBuilder(); | | | | 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 | /// <param name="sqlgen"></param> /// <param name="e"></param> /// <returns></returns> private static ISqlFragment HandleCanonicalFunctionTrim(SqlGenerator sqlgen, DbFunctionExpression e) { SqlBuilder result = new SqlBuilder(); result.Append("TRIM("); Debug.Assert(e.Arguments.Count == 1, "Trim should have one argument"); result.Append(e.Arguments[0].Accept(sqlgen)); result.Append(")"); return result; } /// <summary> /// Function rename ToLower -> LOWER /// </summary> |
︙ | ︙ | |||
3254 3255 3256 3257 3258 3259 3260 | /// <summary> /// Before we embed a string literal in a SQL string, we should /// convert all ' to '', and enclose the whole string in single quotes. /// </summary> /// <param name="s"></param> /// <param name="isUnicode"></param> /// <returns>The escaped sql string.</returns> | | | 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 | /// <summary> /// Before we embed a string literal in a SQL string, we should /// convert all ' to '', and enclose the whole string in single quotes. /// </summary> /// <param name="s"></param> /// <param name="isUnicode"></param> /// <returns>The escaped sql string.</returns> private static string EscapeSingleQuote(string s, bool isUnicode) { return "'" + s.Replace("'", "''") + "'"; } /// <summary> /// Returns the sql primitive/native type name. /// It will include size, precision or scale depending on type information present in the |
︙ | ︙ | |||
3382 3383 3384 3385 3386 3387 3388 | /// <summary> /// Handles the expression represending DbLimitExpression.Limit and DbSkipExpression.Count. /// If it is a constant expression, it simply does to string thus avoiding casting it to the specific value /// (which would be done if <see cref="Visit(DbConstantExpression)"/> is called) /// </summary> /// <param name="e"></param> /// <returns></returns> | | | 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 | /// <summary> /// Handles the expression represending DbLimitExpression.Limit and DbSkipExpression.Count. /// If it is a constant expression, it simply does to string thus avoiding casting it to the specific value /// (which would be done if <see cref="Visit(DbConstantExpression)"/> is called) /// </summary> /// <param name="e"></param> /// <returns></returns> private ISqlFragment HandleCountExpression(DbExpression e) { ISqlFragment result; if (e.ExpressionKind == DbExpressionKind.Constant) { //For constant expression we should not cast the value, // thus we don't go throught the default DbConstantExpression handling |
︙ | ︙ |
Changes to System.Data.SQLite.Linq/SQLiteProviderManifest.cs.
︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | /// <summary> /// maximum size of sql server unicode /// </summary> private const int varcharMaxSize = Int32.MaxValue; private const int nvarcharMaxSize = Int32.MaxValue; private const int binaryMaxSize = Int32.MaxValue; private System.Collections.ObjectModel.ReadOnlyCollection<PrimitiveType> _primitiveTypes = null; private System.Collections.ObjectModel.ReadOnlyCollection<EdmFunction> _functions = null; #endregion #region Constructors /// <summary> /// Constructor /// </summary> /// <param name="manifestToken">A token used to infer the capabilities of the store</param> | > | < | < < < < < < < < < < < < < < < < < < < < | 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 | /// <summary> /// maximum size of sql server unicode /// </summary> private const int varcharMaxSize = Int32.MaxValue; private const int nvarcharMaxSize = Int32.MaxValue; private const int binaryMaxSize = Int32.MaxValue; internal SQLiteDateFormats _dateFormat; private System.Collections.ObjectModel.ReadOnlyCollection<PrimitiveType> _primitiveTypes = null; private System.Collections.ObjectModel.ReadOnlyCollection<EdmFunction> _functions = null; #endregion #region Constructors /// <summary> /// Constructor /// </summary> /// <param name="manifestToken">A token used to infer the capabilities of the store</param> public SQLiteProviderManifest(string manifestToken) : base(SQLiteProviderManifest.GetProviderManifest()) { _dateFormat = (SQLiteDateFormats)Enum.Parse(typeof(SQLiteDateFormats), manifestToken, true); } #endregion internal static XmlReader GetProviderManifest() { return GetXmlResource("System.Data.SQLite.Resources.SQLiteProviderServices.ProviderManifest.xml"); |
︙ | ︙ |
Changes to System.Data.SQLite.Linq/SQLiteProviderServices.cs.
︙ | ︙ | |||
31 32 33 34 35 36 37 | SQLiteCommand command = new SQLiteCommand(); try { List<DbParameter> parameters; CommandType commandType; | | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | SQLiteCommand command = new SQLiteCommand(); try { List<DbParameter> parameters; CommandType commandType; command.CommandText = SqlGenerator.GenerateSql((SQLiteProviderManifest)manifest, commandTree, out parameters, out commandType); command.CommandType = commandType; // Get the function (if any) implemented by the command tree since this influences our interpretation of parameters EdmFunction function = null; if (commandTree is DbFunctionCommandTree) { function = ((DbFunctionCommandTree)commandTree).EdmFunction; } // Now make sure we populate the command's parameters from the CQT's parameters: foreach (KeyValuePair<string, TypeUsage> queryParameter in commandTree.Parameters) { SQLiteParameter parameter; |
︙ | ︙ | |||
89 90 91 92 93 94 95 | command.Dispose(); throw; } } protected override string GetDbProviderManifestToken(DbConnection connection) { | > > | > > | | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | command.Dispose(); throw; } } protected override string GetDbProviderManifestToken(DbConnection connection) { if (String.IsNullOrEmpty(connection.ConnectionString)) throw new ArgumentNullException("ConnectionString"); SortedList<string, string> opts = SQLiteConnection.ParseConnectionString(connection.ConnectionString); return SQLiteConnection.FindKey(opts, "DateTimeFormat", "ISO8601"); } protected override DbProviderManifest GetDbProviderManifest(string versionHint) { return new SQLiteProviderManifest(versionHint); } /// <summary> /// Creates a SQLiteParameter given a name, type, and direction /// </summary> internal static SQLiteParameter CreateSqlParameter(string name, TypeUsage type, ParameterMode mode, object value) { |
︙ | ︙ | |||
339 340 341 342 343 344 345 | sql.AppendFormat(CultureInfo.InvariantCulture, "CREATE TEMP TABLE {0} (", builder.QuoteIdentifier(dest)); string separator = String.Empty; foreach (DataColumn dc in table.Columns) { DbType dbtypeName = SQLiteConvert.TypeToDbType(dc.DataType); string typeName = SQLiteConvert.DbTypeToTypeName(dbtypeName); | | | | | 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 | sql.AppendFormat(CultureInfo.InvariantCulture, "CREATE TEMP TABLE {0} (", builder.QuoteIdentifier(dest)); string separator = String.Empty; foreach (DataColumn dc in table.Columns) { DbType dbtypeName = SQLiteConvert.TypeToDbType(dc.DataType); string typeName = SQLiteConvert.DbTypeToTypeName(dbtypeName); sql.AppendFormat(CultureInfo.InvariantCulture, "{2}{0} {1} COLLATE NOCASE", builder.QuoteIdentifier(dc.ColumnName), typeName, separator); separator = ", "; } sql.Append(")"); cmd.CommandText = sql.ToString(); cmd.ExecuteNonQuery(); cmd.CommandText = String.Format("SELECT * FROM TEMP.{0} WHERE 1=2", builder.QuoteIdentifier(dest)); using (SQLiteDataAdapter adp = new SQLiteDataAdapter(cmd)) { builder.DataAdapter = adp; adp.Fill(source); foreach (DataRow row in table.Rows) { object[] arr = row.ItemArray; //for (int n = 0; n < arr.Length; n++) // if (arr[n] is string) arr[n] = ((string)arr[n]).ToLower(); source.Rows.Add(arr); } adp.Update(source); } } } #endregion } } |
Changes to System.Data.SQLite.Linq/System.Data.SQLite.Linq.csproj.
1 2 3 4 5 | <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>9.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{E6BF9F74-58E2-413B-A7CE-EA653ECB728D}</ProjectGuid> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>System.Data.SQLite</RootNamespace> <AssemblyName>System.Data.SQLite.Linq</AssemblyName> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> |
︙ | ︙ | |||
70 71 72 73 74 75 76 | <Compile Include="SQL Generation\SymbolPair.cs" /> <Compile Include="SQL Generation\SymbolTable.cs" /> <Compile Include="SQL Generation\TopClause.cs" /> <Compile Include="SQLiteProviderManifest.cs" /> <Compile Include="SQLiteProviderServices.cs" /> </ItemGroup> <ItemGroup> | | | > | | | | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | <Compile Include="SQL Generation\SymbolPair.cs" /> <Compile Include="SQL Generation\SymbolTable.cs" /> <Compile Include="SQL Generation\TopClause.cs" /> <Compile Include="SQLiteProviderManifest.cs" /> <Compile Include="SQLiteProviderServices.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="Resources\Common.ConceptualSchemaDefinition.csdl" /> <EmbeddedResource Include="Resources\Common.ProviderManifest.xsd" /> <EmbeddedResource Include="Resources\SQLiteProviderServices.StoreSchemaDefinition.ssdl" /> <EmbeddedResource Include="Resources\SQLiteProviderServices.StoreSchemaMapping.msl" /> <EmbeddedResource Include="Resources\System.Data.Resources.CodeGenerationSchema.xsd" /> <EmbeddedResource Include="Resources\System.Data.Resources.CSDLSchema.xsd" /> <EmbeddedResource Include="Resources\System.Data.Resources.CSMSL.xsd" /> <EmbeddedResource Include="Resources\System.Data.Resources.EntityStoreSchemaGenerator.xsd" /> <EmbeddedResource Include="Resources\System.Data.Resources.SSDLSchema.xsd" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="Properties\Resources.resx"> <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> <EmbeddedResource Include="Resources\SQLiteProviderServices.ProviderManifest.xml" /> |
︙ | ︙ |
Changes to System.Data.SQLite/AssemblyInfo.cs.
︙ | ︙ | |||
44 45 46 47 48 49 50 | // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: | | | | 44 45 46 47 48 49 50 51 52 53 54 | // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.55.0")] #if !PLATFORM_COMPACTFRAMEWORK [assembly: AssemblyFileVersion("1.0.55.0")] #endif |
Changes to System.Data.SQLite/DataTypes.xml.
︙ | ︙ | |||
213 214 215 216 217 218 219 220 221 222 223 224 225 226 | <IsFixedPrecisionScale>false</IsFixedPrecisionScale> <IsLong>false</IsLong> <IsNullable>true</IsNullable> <IsSearchable>true</IsSearchable> <IsSearchableWithLike>false</IsSearchableWithLike> <IsBestMatch>false</IsBestMatch> </DataTypes> <DataTypes> <TypeName>tinyint</TypeName> <ProviderDbType>2</ProviderDbType> <ColumnSize>3</ColumnSize> <DataType>System.Byte</DataType> <CreateFormat>tinyint</CreateFormat> <IsAutoIncrementable>false</IsAutoIncrementable> | > > > > > > > > > > > > > > > > | 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 | <IsFixedPrecisionScale>false</IsFixedPrecisionScale> <IsLong>false</IsLong> <IsNullable>true</IsNullable> <IsSearchable>true</IsSearchable> <IsSearchableWithLike>false</IsSearchableWithLike> <IsBestMatch>false</IsBestMatch> </DataTypes> <DataTypes> <TypeName>boolean</TypeName> <ProviderDbType>3</ProviderDbType> <ColumnSize>1</ColumnSize> <DataType>System.Boolean</DataType> <CreateFormat>boolean</CreateFormat> <IsAutoIncrementable>false</IsAutoIncrementable> <IsCaseSensitive>false</IsCaseSensitive> <IsFixedLength>true</IsFixedLength> <IsFixedPrecisionScale>false</IsFixedPrecisionScale> <IsLong>false</IsLong> <IsNullable>true</IsNullable> <IsSearchable>true</IsSearchable> <IsSearchableWithLike>false</IsSearchableWithLike> <IsBestMatch>false</IsBestMatch> </DataTypes> <DataTypes> <TypeName>tinyint</TypeName> <ProviderDbType>2</ProviderDbType> <ColumnSize>3</ColumnSize> <DataType>System.Byte</DataType> <CreateFormat>tinyint</CreateFormat> <IsAutoIncrementable>false</IsAutoIncrementable> |
︙ | ︙ | |||
497 498 499 500 501 502 503 504 505 506 507 508 509 510 | <IsNullable>true</IsNullable> <IsSearchable>true</IsSearchable> <IsSearchableWithLike>true</IsSearchableWithLike> <LiteralPrefix>'</LiteralPrefix> <LiteralSuffix>'</LiteralSuffix> <IsBestMatch>false</IsBestMatch> </DataTypes> <DataTypes> <TypeName>note</TypeName> <ProviderDbType>16</ProviderDbType> <ColumnSize>2147483647</ColumnSize> <CreateParameters>max length</CreateParameters> <DataType>System.String</DataType> <CreateFormat>note({0})</CreateFormat> | > > > > > > > > > > > > > > > > > > > | 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 | <IsNullable>true</IsNullable> <IsSearchable>true</IsSearchable> <IsSearchableWithLike>true</IsSearchableWithLike> <LiteralPrefix>'</LiteralPrefix> <LiteralSuffix>'</LiteralSuffix> <IsBestMatch>false</IsBestMatch> </DataTypes> <DataTypes> <TypeName>longtext</TypeName> <ProviderDbType>16</ProviderDbType> <ColumnSize>2147483647</ColumnSize> <CreateParameters>max length</CreateParameters> <DataType>System.String</DataType> <CreateFormat>longtext({0})</CreateFormat> <IsAutoIncrementable>false</IsAutoIncrementable> <IsCaseSensitive>false</IsCaseSensitive> <IsFixedLength>false</IsFixedLength> <IsFixedPrecisionScale>false</IsFixedPrecisionScale> <IsLong>false</IsLong> <IsNullable>true</IsNullable> <IsSearchable>true</IsSearchable> <IsSearchableWithLike>true</IsSearchableWithLike> <LiteralPrefix>'</LiteralPrefix> <LiteralSuffix>'</LiteralSuffix> <IsBestMatch>false</IsBestMatch> </DataTypes> <DataTypes> <TypeName>note</TypeName> <ProviderDbType>16</ProviderDbType> <ColumnSize>2147483647</ColumnSize> <CreateParameters>max length</CreateParameters> <DataType>System.String</DataType> <CreateFormat>note({0})</CreateFormat> |
︙ | ︙ | |||
629 630 631 632 633 634 635 636 637 638 639 640 641 642 | <IsNullable>true</IsNullable> <IsSearchable>true</IsSearchable> <IsSearchableWithLike>true</IsSearchableWithLike> <LiteralPrefix>'</LiteralPrefix> <LiteralSuffix>'</LiteralSuffix> <IsBestMatch>true</IsBestMatch> </DataTypes> <DataTypes> <TypeName>timestamp</TypeName> <ProviderDbType>6</ProviderDbType> <ColumnSize>23</ColumnSize> <DataType>System.DateTime</DataType> <CreateFormat>timestamp</CreateFormat> <IsAutoIncrementable>false</IsAutoIncrementable> | > > > > > > > > > > > > > > > > > > | 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 | <IsNullable>true</IsNullable> <IsSearchable>true</IsSearchable> <IsSearchableWithLike>true</IsSearchableWithLike> <LiteralPrefix>'</LiteralPrefix> <LiteralSuffix>'</LiteralSuffix> <IsBestMatch>true</IsBestMatch> </DataTypes> <DataTypes> <TypeName>smalldate</TypeName> <ProviderDbType>6</ProviderDbType> <ColumnSize>23</ColumnSize> <DataType>System.DateTime</DataType> <CreateFormat>smalldate</CreateFormat> <IsAutoIncrementable>false</IsAutoIncrementable> <IsCaseSensitive>false</IsCaseSensitive> <IsFixedLength>true</IsFixedLength> <IsFixedPrecisionScale>false</IsFixedPrecisionScale> <IsLong>false</IsLong> <IsNullable>true</IsNullable> <IsSearchable>true</IsSearchable> <IsSearchableWithLike>true</IsSearchableWithLike> <LiteralPrefix>'</LiteralPrefix> <LiteralSuffix>'</LiteralSuffix> <IsBestMatch>false</IsBestMatch> </DataTypes> <DataTypes> <TypeName>timestamp</TypeName> <ProviderDbType>6</ProviderDbType> <ColumnSize>23</ColumnSize> <DataType>System.DateTime</DataType> <CreateFormat>timestamp</CreateFormat> <IsAutoIncrementable>false</IsAutoIncrementable> |
︙ | ︙ |
Changes to System.Data.SQLite/SQLite3.cs.
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | { /// <summary> /// The opaque pointer returned to us by the sqlite provider /// </summary> protected SQLiteConnectionHandle _sql; protected string _fileName; protected bool _usePool; #if !PLATFORM_COMPACTFRAMEWORK private bool _buildingSchema = false; #endif /// <summary> /// The user-defined functions registered on this connection /// </summary> | > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | { /// <summary> /// The opaque pointer returned to us by the sqlite provider /// </summary> protected SQLiteConnectionHandle _sql; protected string _fileName; protected bool _usePool; protected int _poolVersion = 0; #if !PLATFORM_COMPACTFRAMEWORK private bool _buildingSchema = false; #endif /// <summary> /// The user-defined functions registered on this connection /// </summary> |
︙ | ︙ | |||
48 49 50 51 52 53 54 | // previous functions. The SQLiteFunctionCookieHandle will take care of freeing unmanaged // resources belonging to the previously-registered functions. internal override void Close() { if (_sql != null) { if (_usePool) | > > | > | < | | | | > | > > > > > > > > | | | 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 | // previous functions. The SQLiteFunctionCookieHandle will take care of freeing unmanaged // resources belonging to the previously-registered functions. internal override void Close() { if (_sql != null) { if (_usePool) { SQLiteBase.ResetConnection(_sql); SQLiteConnectionPool.Add(_fileName, _sql, _poolVersion); } else _sql.Dispose(); } _sql = null; } internal override void Cancel() { UnsafeNativeMethods.sqlite3_interrupt(_sql); } internal override string Version { get { return UTF8ToString(UnsafeNativeMethods.sqlite3_libversion(), -1); } } internal override int Changes { get { return UnsafeNativeMethods.sqlite3_changes(_sql); } } internal override void Open(string strFilename, SQLiteOpenFlagsEnum flags, int maxPoolSize, bool usePool) { if (_sql != null) return; _usePool = usePool; if (usePool) { _fileName = strFilename; _sql = SQLiteConnectionPool.Remove(strFilename, maxPoolSize, out _poolVersion); } if (_sql == null) { IntPtr db; #if !SQLITE_STANDARD int n = UnsafeNativeMethods.sqlite3_open_interop(ToUTF8(strFilename), (int)flags, out db); #else int n = UnsafeNativeMethods.sqlite3_open_v2(ToUTF8(strFilename), out db, (int)flags, IntPtr.Zero); #endif if (n > 0) throw new SQLiteException(n, null); _sql = db; } // Bind functions to this connection. If any previous functions of the same name // were already bound, then the new bindings replace the old. _functionsArray = SQLiteFunction.BindFunctions(this); SetTimeout(0); } internal override void ClearPool() { SQLiteConnectionPool.ClearPool(_fileName); } internal override void SetTimeout(int nTimeoutMS) { int n = UnsafeNativeMethods.sqlite3_busy_timeout(_sql, nTimeoutMS); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override bool Step(SQLiteStatement stmt) { int n; Random rnd = null; uint starttick = (uint)Environment.TickCount; uint timeout = (uint)(stmt._command._commandTimeout * 1000); while (true) { n = UnsafeNativeMethods.sqlite3_step(stmt._sqlite_stmt); if (n == 100) return true; if (n == 101) return false; if (n > 0) { int r; |
︙ | ︙ | |||
150 151 152 153 154 155 156 | if ((uint)Environment.TickCount - starttick > timeout) { throw new SQLiteException(r, SQLiteLastError()); } else { // Otherwise sleep for a random amount of time up to 250ms | | > > > > | 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 | if ((uint)Environment.TickCount - starttick > timeout) { throw new SQLiteException(r, SQLiteLastError()); } else { // Otherwise sleep for a random amount of time up to 250ms UnsafeNativeMethods.sqlite3_sleep((uint)rnd.Next(1, 250)); } } } } } internal override int Reset(SQLiteStatement stmt) { int n; #if !SQLITE_STANDARD n = UnsafeNativeMethods.sqlite3_reset_interop(stmt._sqlite_stmt); #else n = UnsafeNativeMethods.sqlite3_reset(stmt._sqlite_stmt); #endif // If the schema changed, try and re-prepare it if (n == 17) // SQLITE_SCHEMA { // Recreate a dummy statement string str; using (SQLiteStatement tmp = Prepare(null, stmt._sqlStatement, null, (uint)(stmt._command._commandTimeout * 1000), out str)) |
︙ | ︙ | |||
212 213 214 215 216 217 218 | Random rnd = null; uint starttick = (uint)Environment.TickCount; GCHandle handle = GCHandle.Alloc(b, GCHandleType.Pinned); IntPtr psql = handle.AddrOfPinnedObject(); try { | | > > > > > | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | Random rnd = null; uint starttick = (uint)Environment.TickCount; GCHandle handle = GCHandle.Alloc(b, GCHandleType.Pinned); IntPtr psql = handle.AddrOfPinnedObject(); try { while ((n == 17 || n == 6 || n == 5) && retries < 3) { #if !SQLITE_STANDARD n = UnsafeNativeMethods.sqlite3_prepare_interop(_sql, psql, b.Length - 1, out stmt, out ptr, out len); #else n = UnsafeNativeMethods.sqlite3_prepare(_sql, psql, b.Length - 1, out stmt, out ptr); len = -1; #endif if (n == 17) retries++; else if (n == 1) { if (String.Compare(SQLiteLastError(), "near \"TYPES\": syntax error", StringComparison.OrdinalIgnoreCase) == 0) { |
︙ | ︙ | |||
268 269 270 271 272 273 274 | finally { _buildingSchema = false; } } #endif } | | | > > > > | > > > > | | | | | > > > > | | > > > > | < < < < < < < < > > > > > | 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 | finally { _buildingSchema = false; } } #endif } else if (n == 6 || n == 5) // Locked -- delay a small amount before retrying { // Keep trying if (rnd == null) // First time we've encountered the lock rnd = new Random(); // If we've exceeded the command's timeout, give up and throw an error if ((uint)Environment.TickCount - starttick > timeoutMS) { throw new SQLiteException(n, SQLiteLastError()); } else { // Otherwise sleep for a random amount of time up to 250ms UnsafeNativeMethods.sqlite3_sleep((uint)rnd.Next(1, 250)); } } } if (n > 0) throw new SQLiteException(n, SQLiteLastError()); strRemain = UTF8ToString(ptr, len); if (stmt != IntPtr.Zero) cmd = new SQLiteStatement(this, stmt, strSql.Substring(0, strSql.Length - strRemain.Length), previous); return cmd; } finally { handle.Free(); } } internal override void Bind_Double(SQLiteStatement stmt, int index, double value) { #if !PLATFORM_COMPACTFRAMEWORK int n = UnsafeNativeMethods.sqlite3_bind_double(stmt._sqlite_stmt, index, value); #else int n = UnsafeNativeMethods.sqlite3_bind_double_interop(stmt._sqlite_stmt, index, ref value); #endif if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_Int32(SQLiteStatement stmt, int index, int value) { int n = UnsafeNativeMethods.sqlite3_bind_int(stmt._sqlite_stmt, index, value); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_Int64(SQLiteStatement stmt, int index, long value) { #if !PLATFORM_COMPACTFRAMEWORK int n = UnsafeNativeMethods.sqlite3_bind_int64(stmt._sqlite_stmt, index, value); #else int n = UnsafeNativeMethods.sqlite3_bind_int64_interop(stmt._sqlite_stmt, index, ref value); #endif if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_Text(SQLiteStatement stmt, int index, string value) { byte[] b = ToUTF8(value); int n = UnsafeNativeMethods.sqlite3_bind_text(stmt._sqlite_stmt, index, b, b.Length - 1, (IntPtr)(-1)); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_DateTime(SQLiteStatement stmt, int index, DateTime dt) { byte[] b = ToUTF8(dt); int n = UnsafeNativeMethods.sqlite3_bind_text(stmt._sqlite_stmt, index, b, b.Length - 1, (IntPtr)(-1)); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_Blob(SQLiteStatement stmt, int index, byte[] blobData) { int n = UnsafeNativeMethods.sqlite3_bind_blob(stmt._sqlite_stmt, index, blobData, blobData.Length, (IntPtr)(-1)); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_Null(SQLiteStatement stmt, int index) { int n = UnsafeNativeMethods.sqlite3_bind_null(stmt._sqlite_stmt, index); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override int Bind_ParamCount(SQLiteStatement stmt) { return UnsafeNativeMethods.sqlite3_bind_parameter_count(stmt._sqlite_stmt); } internal override string Bind_ParamName(SQLiteStatement stmt, int index) { #if !SQLITE_STANDARD int len; return UTF8ToString(UnsafeNativeMethods.sqlite3_bind_parameter_name_interop(stmt._sqlite_stmt, index, out len), len); #else return UTF8ToString(UnsafeNativeMethods.sqlite3_bind_parameter_name(stmt._sqlite_stmt, index), -1); #endif } internal override int Bind_ParamIndex(SQLiteStatement stmt, string paramName) { return UnsafeNativeMethods.sqlite3_bind_parameter_index(stmt._sqlite_stmt, ToUTF8(paramName)); } internal override int ColumnCount(SQLiteStatement stmt) { return UnsafeNativeMethods.sqlite3_column_count(stmt._sqlite_stmt); } internal override string ColumnName(SQLiteStatement stmt, int index) { #if !SQLITE_STANDARD int len; return UTF8ToString(UnsafeNativeMethods.sqlite3_column_name_interop(stmt._sqlite_stmt, index, out len), len); #else return UTF8ToString(UnsafeNativeMethods.sqlite3_column_name(stmt._sqlite_stmt, index), -1); #endif } internal override TypeAffinity ColumnAffinity(SQLiteStatement stmt, int index) { return UnsafeNativeMethods.sqlite3_column_type(stmt._sqlite_stmt, index); } internal override string ColumnType(SQLiteStatement stmt, int index, out TypeAffinity nAffinity) { int len; #if !SQLITE_STANDARD IntPtr p = UnsafeNativeMethods.sqlite3_column_decltype_interop(stmt._sqlite_stmt, index, out len); #else len = -1; IntPtr p = UnsafeNativeMethods.sqlite3_column_decltype(stmt._sqlite_stmt, index); #endif nAffinity = ColumnAffinity(stmt, index); if (p != IntPtr.Zero) return UTF8ToString(p, len); else { string[] ar = stmt.TypeDefinitions; if (ar != null) |
︙ | ︙ | |||
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 | return n; } return -1; } internal override string ColumnOriginalName(SQLiteStatement stmt, int index) { int len; return UTF8ToString(UnsafeNativeMethods.sqlite3_column_origin_name_interop(stmt._sqlite_stmt, index, out len), len); } internal override string ColumnDatabaseName(SQLiteStatement stmt, int index) { int len; return UTF8ToString(UnsafeNativeMethods.sqlite3_column_database_name_interop(stmt._sqlite_stmt, index, out len), len); } internal override string ColumnTableName(SQLiteStatement stmt, int index) { int len; return UTF8ToString(UnsafeNativeMethods.sqlite3_column_table_name_interop(stmt._sqlite_stmt, index, out len), len); } internal override void ColumnMetaData(string dataBase, string table, string column, out string dataType, out string collateSequence, out bool notNull, out bool primaryKey, out bool autoIncrement) { IntPtr dataTypePtr; IntPtr collSeqPtr; | > > > > > > > > > > > > < < > > > > > > > > > > > > | > > > > > > > > > > > > | | | 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 | return n; } return -1; } internal override string ColumnOriginalName(SQLiteStatement stmt, int index) { #if !SQLITE_STANDARD int len; return UTF8ToString(UnsafeNativeMethods.sqlite3_column_origin_name_interop(stmt._sqlite_stmt, index, out len), len); #else return UTF8ToString(UnsafeNativeMethods.sqlite3_column_origin_name(stmt._sqlite_stmt, index), -1); #endif } internal override string ColumnDatabaseName(SQLiteStatement stmt, int index) { #if !SQLITE_STANDARD int len; return UTF8ToString(UnsafeNativeMethods.sqlite3_column_database_name_interop(stmt._sqlite_stmt, index, out len), len); #else return UTF8ToString(UnsafeNativeMethods.sqlite3_column_database_name(stmt._sqlite_stmt, index), -1); #endif } internal override string ColumnTableName(SQLiteStatement stmt, int index) { #if !SQLITE_STANDARD int len; return UTF8ToString(UnsafeNativeMethods.sqlite3_column_table_name_interop(stmt._sqlite_stmt, index, out len), len); #else return UTF8ToString(UnsafeNativeMethods.sqlite3_column_table_name(stmt._sqlite_stmt, index), -1); #endif } internal override void ColumnMetaData(string dataBase, string table, string column, out string dataType, out string collateSequence, out bool notNull, out bool primaryKey, out bool autoIncrement) { IntPtr dataTypePtr; IntPtr collSeqPtr; int nnotNull; int nprimaryKey; int nautoInc; int n; int dtLen; int csLen; #if !SQLITE_STANDARD n = UnsafeNativeMethods.sqlite3_table_column_metadata_interop(_sql, ToUTF8(dataBase), ToUTF8(table), ToUTF8(column), out dataTypePtr, out collSeqPtr, out nnotNull, out nprimaryKey, out nautoInc, out dtLen, out csLen); #else dtLen = -1; csLen = -1; n = UnsafeNativeMethods.sqlite3_table_column_metadata(_sql, ToUTF8(dataBase), ToUTF8(table), ToUTF8(column), out dataTypePtr, out collSeqPtr, out nnotNull, out nprimaryKey, out nautoInc); #endif if (n > 0) throw new SQLiteException(n, SQLiteLastError()); dataType = UTF8ToString(dataTypePtr, dtLen); collateSequence = UTF8ToString(collSeqPtr, csLen); notNull = (nnotNull == 1); primaryKey = (nprimaryKey == 1); autoIncrement = (nautoInc == 1); } internal override double GetDouble(SQLiteStatement stmt, int index) { double value; #if !PLATFORM_COMPACTFRAMEWORK value = UnsafeNativeMethods.sqlite3_column_double(stmt._sqlite_stmt, index); #else UnsafeNativeMethods.sqlite3_column_double_interop(stmt._sqlite_stmt, index, out value); #endif return value; } internal override int GetInt32(SQLiteStatement stmt, int index) { return UnsafeNativeMethods.sqlite3_column_int(stmt._sqlite_stmt, index); } internal override long GetInt64(SQLiteStatement stmt, int index) { long value; #if !PLATFORM_COMPACTFRAMEWORK value = UnsafeNativeMethods.sqlite3_column_int64(stmt._sqlite_stmt, index); #else UnsafeNativeMethods.sqlite3_column_int64_interop(stmt._sqlite_stmt, index, out value); #endif return value; } internal override string GetText(SQLiteStatement stmt, int index) { #if !SQLITE_STANDARD int len; return UTF8ToString(UnsafeNativeMethods.sqlite3_column_text_interop(stmt._sqlite_stmt, index, out len), len); #else return UTF8ToString(UnsafeNativeMethods.sqlite3_column_text(stmt._sqlite_stmt, index), -1); #endif } internal override DateTime GetDateTime(SQLiteStatement stmt, int index) { #if !SQLITE_STANDARD int len; return ToDateTime(UnsafeNativeMethods.sqlite3_column_text_interop(stmt._sqlite_stmt, index, out len), len); #else return ToDateTime(UnsafeNativeMethods.sqlite3_column_text(stmt._sqlite_stmt, index), -1); #endif } internal override long GetBytes(SQLiteStatement stmt, int index, int nDataOffset, byte[] bDest, int nStart, int nLength) { IntPtr ptr; int nlen; int nCopied = nLength; nlen = UnsafeNativeMethods.sqlite3_column_bytes(stmt._sqlite_stmt, index); ptr = UnsafeNativeMethods.sqlite3_column_blob(stmt._sqlite_stmt, index); if (bDest == null) return nlen; if (nCopied + nStart > bDest.Length) nCopied = bDest.Length - nStart; if (nCopied + nDataOffset > nlen) nCopied = nlen - nDataOffset; if (nCopied > 0) |
︙ | ︙ | |||
547 548 549 550 551 552 553 | internal override bool IsNull(SQLiteStatement stmt, int index) { return (ColumnAffinity(stmt, index) == TypeAffinity.Null); } internal override int AggregateCount(IntPtr context) { | | | | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > | > | > > > > > > > > > > | > > | > > > > > | > | > > > > > | | > > > > | > > > | | > > > > | > > > > > > > > | | > > > > | | > > > > | | | | | | | | | 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 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 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 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 | internal override bool IsNull(SQLiteStatement stmt, int index) { return (ColumnAffinity(stmt, index) == TypeAffinity.Null); } internal override int AggregateCount(IntPtr context) { return UnsafeNativeMethods.sqlite3_aggregate_count(context); } internal override void CreateFunction(string strFunction, int nArgs, bool needCollSeq, SQLiteCallback func, SQLiteCallback funcstep, SQLiteFinalCallback funcfinal) { int n; #if !SQLITE_STANDARD n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0); if (n == 0) n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0); #else n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal); if (n == 0) n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal); #endif if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void CreateCollation(string strCollation, SQLiteCollation func, SQLiteCollation func16) { int n = UnsafeNativeMethods.sqlite3_create_collation(_sql, ToUTF8(strCollation), 2, IntPtr.Zero, func16); if (n == 0) UnsafeNativeMethods.sqlite3_create_collation(_sql, ToUTF8(strCollation), 1, IntPtr.Zero, func); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override int ContextCollateCompare(CollationEncodingEnum enc, IntPtr context, string s1, string s2) { #if !SQLITE_STANDARD byte[] b1; byte[] b2; System.Text.Encoding converter = null; switch (enc) { case CollationEncodingEnum.UTF8: converter = System.Text.Encoding.UTF8; break; case CollationEncodingEnum.UTF16LE: converter = System.Text.Encoding.Unicode; break; case CollationEncodingEnum.UTF16BE: converter = System.Text.Encoding.BigEndianUnicode; break; } b1 = converter.GetBytes(s1); b2 = converter.GetBytes(s2); return UnsafeNativeMethods.sqlite3_context_collcompare(context, b1, b1.Length, b2, b2.Length); #else throw new NotImplementedException(); #endif } internal override int ContextCollateCompare(CollationEncodingEnum enc, IntPtr context, char[] c1, char[] c2) { #if !SQLITE_STANDARD byte[] b1; byte[] b2; System.Text.Encoding converter = null; switch (enc) { case CollationEncodingEnum.UTF8: converter = System.Text.Encoding.UTF8; break; case CollationEncodingEnum.UTF16LE: converter = System.Text.Encoding.Unicode; break; case CollationEncodingEnum.UTF16BE: converter = System.Text.Encoding.BigEndianUnicode; break; } b1 = converter.GetBytes(c1); b2 = converter.GetBytes(c2); return UnsafeNativeMethods.sqlite3_context_collcompare(context, b1, b1.Length, b2, b2.Length); #else throw new NotImplementedException(); #endif } internal override CollationSequence GetCollationSequence(SQLiteFunction func, IntPtr context) { #if !SQLITE_STANDARD CollationSequence seq = new CollationSequence(); int len; int type; int enc; IntPtr p = UnsafeNativeMethods.sqlite3_context_collseq(context, out type, out enc, out len); if (p != null) seq.Name = UTF8ToString(p, len); seq.Type = (CollationTypeEnum)type; seq._func = func; seq.Encoding = (CollationEncodingEnum)enc; return seq; #else throw new NotImplementedException(); #endif } internal override long GetParamValueBytes(IntPtr p, int nDataOffset, byte[] bDest, int nStart, int nLength) { IntPtr ptr; int nlen; int nCopied = nLength; nlen = UnsafeNativeMethods.sqlite3_value_bytes(p); ptr = UnsafeNativeMethods.sqlite3_value_blob(p); if (bDest == null) return nlen; if (nCopied + nStart > bDest.Length) nCopied = bDest.Length - nStart; if (nCopied + nDataOffset > nlen) nCopied = nlen - nDataOffset; if (nCopied > 0) Marshal.Copy((IntPtr)(ptr.ToInt32() + nDataOffset), bDest, nStart, nCopied); else nCopied = 0; return nCopied; } internal override double GetParamValueDouble(IntPtr ptr) { double value; #if !PLATFORM_COMPACTFRAMEWORK value = UnsafeNativeMethods.sqlite3_value_double(ptr); #else UnsafeNativeMethods.sqlite3_value_double_interop(ptr, out value); #endif return value; } internal override int GetParamValueInt32(IntPtr ptr) { return UnsafeNativeMethods.sqlite3_value_int(ptr); } internal override long GetParamValueInt64(IntPtr ptr) { Int64 value; #if !PLATFORM_COMPACTFRAMEWORK value = UnsafeNativeMethods.sqlite3_value_int64(ptr); #else UnsafeNativeMethods.sqlite3_value_int64_interop(ptr, out value); #endif return value; } internal override string GetParamValueText(IntPtr ptr) { #if !SQLITE_STANDARD int len; return UTF8ToString(UnsafeNativeMethods.sqlite3_value_text_interop(ptr, out len), len); #else return UTF8ToString(UnsafeNativeMethods.sqlite3_value_text(ptr), -1); #endif } internal override TypeAffinity GetParamValueType(IntPtr ptr) { return UnsafeNativeMethods.sqlite3_value_type(ptr); } internal override void ReturnBlob(IntPtr context, byte[] value) { UnsafeNativeMethods.sqlite3_result_blob(context, value, value.Length, (IntPtr)(-1)); } internal override void ReturnDouble(IntPtr context, double value) { #if !PLATFORM_COMPACTFRAMEWORK UnsafeNativeMethods.sqlite3_result_double(context, value); #else UnsafeNativeMethods.sqlite3_result_double_interop(context, ref value); #endif } internal override void ReturnError(IntPtr context, string value) { UnsafeNativeMethods.sqlite3_result_error(context, ToUTF8(value), value.Length); } internal override void ReturnInt32(IntPtr context, int value) { UnsafeNativeMethods.sqlite3_result_int(context, value); } internal override void ReturnInt64(IntPtr context, long value) { #if !PLATFORM_COMPACTFRAMEWORK UnsafeNativeMethods.sqlite3_result_int64(context, value); #else UnsafeNativeMethods.sqlite3_result_int64_interop(context, ref value); #endif } internal override void ReturnNull(IntPtr context) { UnsafeNativeMethods.sqlite3_result_null(context); } internal override void ReturnText(IntPtr context, string value) { byte[] b = ToUTF8(value); UnsafeNativeMethods.sqlite3_result_text(context, ToUTF8(value), b.Length - 1, (IntPtr)(-1)); } internal override IntPtr AggregateContext(IntPtr context) { return UnsafeNativeMethods.sqlite3_aggregate_context(context, 1); } internal override void SetPassword(byte[] passwordBytes) { int n = UnsafeNativeMethods.sqlite3_key(_sql, passwordBytes, passwordBytes.Length); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void ChangePassword(byte[] newPasswordBytes) { int n = UnsafeNativeMethods.sqlite3_rekey(_sql, newPasswordBytes, (newPasswordBytes == null) ? 0 : newPasswordBytes.Length); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void SetUpdateHook(SQLiteUpdateCallback func) { UnsafeNativeMethods.sqlite3_update_hook(_sql, func, IntPtr.Zero); } internal override void SetCommitHook(SQLiteCommitCallback func) { UnsafeNativeMethods.sqlite3_commit_hook(_sql, func, IntPtr.Zero); } internal override void SetRollbackHook(SQLiteRollbackCallback func) { UnsafeNativeMethods.sqlite3_rollback_hook(_sql, func, IntPtr.Zero); } /// <summary> /// Helper function to retrieve a column of data from an active statement. /// </summary> /// <param name="stmt">The statement being step()'d through</param> /// <param name="index">The column index to retrieve</param> |
︙ | ︙ | |||
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 | default: return GetText(stmt, index); } } internal override int GetCursorForTable(SQLiteStatement stmt, int db, int rootPage) { return UnsafeNativeMethods.sqlite3_table_cursor(stmt._sqlite_stmt, db, rootPage); } internal override long GetRowIdForCursor(SQLiteStatement stmt, int cursor) { long rowid; int rc = UnsafeNativeMethods.sqlite3_cursor_rowid(stmt._sqlite_stmt, cursor, out rowid); if (rc == 0) return rowid; return 0; | > > > > > < | | < < > > > | > > > > > | 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 | default: return GetText(stmt, index); } } internal override int GetCursorForTable(SQLiteStatement stmt, int db, int rootPage) { #if !SQLITE_STANDARD return UnsafeNativeMethods.sqlite3_table_cursor(stmt._sqlite_stmt, db, rootPage); #else return -1; #endif } internal override long GetRowIdForCursor(SQLiteStatement stmt, int cursor) { #if !SQLITE_STANDARD long rowid; int rc = UnsafeNativeMethods.sqlite3_cursor_rowid(stmt._sqlite_stmt, cursor, out rowid); if (rc == 0) return rowid; return 0; #else return 0; #endif } internal override void GetIndexColumnExtendedInfo(string database, string index, string column, out int sortMode, out int onError, out string collationSequence) { #if !SQLITE_STANDARD IntPtr coll; int colllen; int rc; rc = UnsafeNativeMethods.sqlite3_index_column_info_interop(_sql, ToUTF8(database), ToUTF8(index), ToUTF8(column), out sortMode, out onError, out coll, out colllen); if (rc != 0) throw new SQLiteException(rc, ""); collationSequence = UTF8ToString(coll, colllen); #else sortMode = 0; onError = 2; collationSequence = "BINARY"; #endif } } } |
Changes to System.Data.SQLite/SQLite3_UTF16.cs.
︙ | ︙ | |||
29 30 31 32 33 34 35 | public override string ToString(IntPtr b, int nbytelen) { return UTF16ToString(b, nbytelen); } public static string UTF16ToString(IntPtr b, int nbytelen) { | | < | | < < > | < < | | | < | | > | > > > > > > | < < < < < < > > > > > > > > > > > > > > > > > > > > > > > < | < < < | < < | < < < < < < < < < < < > > > > | | | 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 | public override string ToString(IntPtr b, int nbytelen) { return UTF16ToString(b, nbytelen); } public static string UTF16ToString(IntPtr b, int nbytelen) { if (nbytelen == 0 || b == IntPtr.Zero) return ""; if (nbytelen == -1) return Marshal.PtrToStringUni(b); else return Marshal.PtrToStringUni(b, nbytelen / 2); } internal override void Open(string strFilename, SQLiteOpenFlagsEnum flags, int maxPoolSize, bool usePool) { if (_sql != null) return; _usePool = usePool; if (usePool) { _fileName = strFilename; _sql = SQLiteConnectionPool.Remove(strFilename, maxPoolSize, out _poolVersion); } if (_sql == null) { IntPtr db; #if !SQLITE_STANDARD int n = UnsafeNativeMethods.sqlite3_open16_interop(ToUTF8(strFilename), (int)flags, out db); #else if ((flags & SQLiteOpenFlagsEnum.Create) == 0 && System.IO.File.Exists(strFilename) == false) throw new SQLiteException((int)SQLiteErrorCode.CantOpen, strFilename); int n = UnsafeNativeMethods.sqlite3_open16(strFilename, out db); #endif if (n > 0) throw new SQLiteException(n, null); _sql = db; } _functionsArray = SQLiteFunction.BindFunctions(this); } internal override void Bind_DateTime(SQLiteStatement stmt, int index, DateTime dt) { Bind_Text(stmt, index, ToString(dt)); } internal override void Bind_Text(SQLiteStatement stmt, int index, string value) { int n = UnsafeNativeMethods.sqlite3_bind_text16(stmt._sqlite_stmt, index, value, value.Length * 2, (IntPtr)(-1)); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override DateTime GetDateTime(SQLiteStatement stmt, int index) { return ToDateTime(GetText(stmt, index)); } internal override string ColumnName(SQLiteStatement stmt, int index) { #if !SQLITE_STANDARD int len; return UTF16ToString(UnsafeNativeMethods.sqlite3_column_name16_interop(stmt._sqlite_stmt, index, out len), len); #else return UTF16ToString(UnsafeNativeMethods.sqlite3_column_name16(stmt._sqlite_stmt, index), -1); #endif } internal override string GetText(SQLiteStatement stmt, int index) { #if !SQLITE_STANDARD int len; return UTF16ToString(UnsafeNativeMethods.sqlite3_column_text16_interop(stmt._sqlite_stmt, index, out len), len); #else return UTF16ToString(UnsafeNativeMethods.sqlite3_column_text16(stmt._sqlite_stmt, index), -1); #endif } internal override string ColumnOriginalName(SQLiteStatement stmt, int index) { #if !SQLITE_STANDARD int len; return UTF16ToString(UnsafeNativeMethods.sqlite3_column_origin_name16_interop(stmt._sqlite_stmt, index, out len), len); #else return UTF16ToString(UnsafeNativeMethods.sqlite3_column_origin_name16(stmt._sqlite_stmt, index), -1); #endif } internal override string ColumnDatabaseName(SQLiteStatement stmt, int index) { #if !SQLITE_STANDARD int len; return UTF16ToString(UnsafeNativeMethods.sqlite3_column_database_name16_interop(stmt._sqlite_stmt, index, out len), len); #else return UTF16ToString(UnsafeNativeMethods.sqlite3_column_database_name16(stmt._sqlite_stmt, index), -1); #endif } internal override string ColumnTableName(SQLiteStatement stmt, int index) { #if !SQLITE_STANDARD int len; return UTF16ToString(UnsafeNativeMethods.sqlite3_column_table_name16_interop(stmt._sqlite_stmt, index, out len), len); #else return UTF16ToString(UnsafeNativeMethods.sqlite3_column_table_name16(stmt._sqlite_stmt, index), -1); #endif } internal override string GetParamValueText(IntPtr ptr) { #if !SQLITE_STANDARD int len; return UTF16ToString(UnsafeNativeMethods.sqlite3_value_text16_interop(ptr, out len), len); #else return UTF16ToString(UnsafeNativeMethods.sqlite3_value_text16(ptr), -1); #endif } internal override void ReturnError(IntPtr context, string value) { UnsafeNativeMethods.sqlite3_result_error16(context, value, value.Length * 2); } internal override void ReturnText(IntPtr context, string value) { UnsafeNativeMethods.sqlite3_result_text16(context, value, value.Length * 2, (IntPtr)(-1)); } } } |
Changes to System.Data.SQLite/SQLiteBase.cs.
︙ | ︙ | |||
28 29 30 31 32 33 34 | /// <summary> /// Returns the number of changes the last executing insert/update caused. /// </summary> internal abstract int Changes { get; } /// <summary> /// Opens a database. /// </summary> | < > > > | > > > > > | 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 | /// <summary> /// Returns the number of changes the last executing insert/update caused. /// </summary> internal abstract int Changes { get; } /// <summary> /// Opens a database. /// </summary> /// <remarks> /// Implementers should call SQLiteFunction.BindFunctions() and save the array after opening a connection /// to bind all attributed user-defined functions and collating sequences to the new connection. /// </remarks> /// <param name="strFilename">The filename of the database to open. SQLite automatically creates it if it doesn't exist.</param> /// <param name="flags">The open flags to use when creating the connection</param> /// <param name="maxPoolSize">The maximum size of the pool for the given filename</param> /// <param name="usePool">If true, the connection can be pulled from the connection pool</param> internal abstract void Open(string strFilename, SQLiteOpenFlagsEnum flags, int maxPoolSize, bool usePool); /// <summary> /// Closes the currently-open database. /// </summary> /// <remarks> /// After the database has been closed implemeters should call SQLiteFunction.UnbindFunctions() to deallocate all interop allocated /// memory associated with the user-defined functions and collating sequences tied to the closed connection. /// </remarks> internal abstract void Close(); /// <summary> /// Sets the busy timeout on the connection. SQLiteCommand will call this before executing any command. /// </summary> /// <param name="nTimeoutMS">The number of milliseconds to wait before returning SQLITE_BUSY</param> internal abstract void SetTimeout(int nTimeoutMS); /// <summary> /// Returns the text of the last error issued by SQLite /// </summary> /// <returns></returns> internal abstract string SQLiteLastError(); /// <summary> /// When pooling is enabled, force this connection to be disposed rather than returned to the pool /// </summary> internal abstract void ClearPool(); /// <summary> /// Prepares a SQL statement for execution. /// </summary> /// <param name="cnn">The source connection preparing the command. Can be null for any caller except LINQ</param> /// <param name="strSql">The SQL command text to prepare</param> /// <param name="previous">The previous statement in a multi-statement command, or null if no previous statement exists</param> /// <param name="timeoutMS">The timeout to wait before aborting the prepare</param> |
︙ | ︙ | |||
79 80 81 82 83 84 85 | /// <summary> /// Resets a prepared statement so it can be executed again. If the error returned is SQLITE_SCHEMA, /// transparently attempt to rebuild the SQL statement and throw an error if that was not possible. /// </summary> /// <param name="stmt">The statement to reset</param> /// <returns>Returns -1 if the schema changed while resetting, 0 if the reset was sucessful or 6 (SQLITE_LOCKED) if the reset failed due to a lock</returns> internal abstract int Reset(SQLiteStatement stmt); | < | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | /// <summary> /// Resets a prepared statement so it can be executed again. If the error returned is SQLITE_SCHEMA, /// transparently attempt to rebuild the SQL statement and throw an error if that was not possible. /// </summary> /// <param name="stmt">The statement to reset</param> /// <returns>Returns -1 if the schema changed while resetting, 0 if the reset was sucessful or 6 (SQLITE_LOCKED) if the reset failed due to a lock</returns> internal abstract int Reset(SQLiteStatement stmt); internal abstract void Cancel(); internal abstract void Bind_Double(SQLiteStatement stmt, int index, double value); internal abstract void Bind_Int32(SQLiteStatement stmt, int index, Int32 value); internal abstract void Bind_Int64(SQLiteStatement stmt, int index, Int64 value); internal abstract void Bind_Text(SQLiteStatement stmt, int index, string value); internal abstract void Bind_Blob(SQLiteStatement stmt, int index, byte[] blobData); |
︙ | ︙ | |||
103 104 105 106 107 108 109 | internal abstract TypeAffinity ColumnAffinity(SQLiteStatement stmt, int index); internal abstract string ColumnType(SQLiteStatement stmt, int index, out TypeAffinity nAffinity); internal abstract int ColumnIndex(SQLiteStatement stmt, string columnName); internal abstract string ColumnOriginalName(SQLiteStatement stmt, int index); internal abstract string ColumnDatabaseName(SQLiteStatement stmt, int index); internal abstract string ColumnTableName(SQLiteStatement stmt, int index); internal abstract void ColumnMetaData(string dataBase, string table, string column, out string dataType, out string collateSequence, out bool notNull, out bool primaryKey, out bool autoIncrement); | < | | > > > | 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 | internal abstract TypeAffinity ColumnAffinity(SQLiteStatement stmt, int index); internal abstract string ColumnType(SQLiteStatement stmt, int index, out TypeAffinity nAffinity); internal abstract int ColumnIndex(SQLiteStatement stmt, string columnName); internal abstract string ColumnOriginalName(SQLiteStatement stmt, int index); internal abstract string ColumnDatabaseName(SQLiteStatement stmt, int index); internal abstract string ColumnTableName(SQLiteStatement stmt, int index); internal abstract void ColumnMetaData(string dataBase, string table, string column, out string dataType, out string collateSequence, out bool notNull, out bool primaryKey, out bool autoIncrement); internal abstract void GetIndexColumnExtendedInfo(string database, string index, string column, out int sortMode, out int onError, out string collationSequence); internal abstract double GetDouble(SQLiteStatement stmt, int index); internal abstract Int32 GetInt32(SQLiteStatement stmt, int index); internal abstract Int64 GetInt64(SQLiteStatement stmt, int index); internal abstract string GetText(SQLiteStatement stmt, int index); internal abstract long GetBytes(SQLiteStatement stmt, int index, int nDataoffset, byte[] bDest, int nStart, int nLength); internal abstract long GetChars(SQLiteStatement stmt, int index, int nDataoffset, char[] bDest, int nStart, int nLength); internal abstract DateTime GetDateTime(SQLiteStatement stmt, int index); internal abstract bool IsNull(SQLiteStatement stmt, int index); internal abstract void CreateCollation(string strCollation, SQLiteCollation func, SQLiteCollation func16); internal abstract void CreateFunction(string strFunction, int nArgs, bool needCollSeq, SQLiteCallback func, SQLiteCallback funcstep, SQLiteFinalCallback funcfinal); internal abstract CollationSequence GetCollationSequence(SQLiteFunction func, IntPtr context); internal abstract int ContextCollateCompare(CollationEncodingEnum enc, IntPtr context, string s1, string s2); internal abstract int ContextCollateCompare(CollationEncodingEnum enc, IntPtr context, char[] c1, char[] c2); internal abstract int AggregateCount(IntPtr context); internal abstract IntPtr AggregateContext(IntPtr context); internal abstract long GetParamValueBytes(IntPtr ptr, int nDataOffset, byte[] bDest, int nStart, int nLength); internal abstract double GetParamValueDouble(IntPtr ptr); internal abstract int GetParamValueInt32(IntPtr ptr); |
︙ | ︙ | |||
145 146 147 148 149 150 151 | internal abstract void SetUpdateHook(SQLiteUpdateCallback func); internal abstract void SetCommitHook(SQLiteCommitCallback func); internal abstract void SetRollbackHook(SQLiteRollbackCallback func); internal abstract int GetCursorForTable(SQLiteStatement stmt, int database, int rootPage); internal abstract long GetRowIdForCursor(SQLiteStatement stmt, int cursor); | < > < | < < < | > > > > > | > > > > > | > > > > > > > > > > | > > > > > > | > > > > > > > > > > > | 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 | internal abstract void SetUpdateHook(SQLiteUpdateCallback func); internal abstract void SetCommitHook(SQLiteCommitCallback func); internal abstract void SetRollbackHook(SQLiteRollbackCallback func); internal abstract int GetCursorForTable(SQLiteStatement stmt, int database, int rootPage); internal abstract long GetRowIdForCursor(SQLiteStatement stmt, int cursor); internal abstract object GetValue(SQLiteStatement stmt, int index, SQLiteType typ); protected virtual void Dispose(bool bDisposing) { } public void Dispose() { Dispose(true); } // These statics are here for lack of a better place to put them. // They exist here because they are called during the finalization of // a SQLiteStatementHandle, SQLiteConnectionHandle, and SQLiteFunctionCookieHandle. // Therefore these functions have to be static, and have to be low-level. internal static string SQLiteLastError(SQLiteConnectionHandle db) { #if !SQLITE_STANDARD int len; return UTF8ToString(UnsafeNativeMethods.sqlite3_errmsg_interop(db, out len), len); #else return UTF8ToString(UnsafeNativeMethods.sqlite3_errmsg(db), -1); #endif } internal static void FinalizeStatement(SQLiteStatementHandle stmt) { #if !SQLITE_STANDARD int n = UnsafeNativeMethods.sqlite3_finalize_interop(stmt); #else int n = UnsafeNativeMethods.sqlite3_finalize(stmt); #endif if (n > 0) throw new SQLiteException(n, null); } internal static void CloseConnection(SQLiteConnectionHandle db) { #if !SQLITE_STANDARD int n = UnsafeNativeMethods.sqlite3_close_interop(db); #else ResetConnection(db); int n = UnsafeNativeMethods.sqlite3_close(db); #endif if (n > 0) throw new SQLiteException(n, SQLiteLastError(db)); } internal static void ResetConnection(SQLiteConnectionHandle db) { IntPtr stmt = IntPtr.Zero; do { stmt = UnsafeNativeMethods.sqlite3_next_stmt(db, stmt); if (stmt != IntPtr.Zero) { #if !SQLITE_STANDARD UnsafeNativeMethods.sqlite3_reset_interop(stmt); #else UnsafeNativeMethods.sqlite3_reset(stmt); #endif } } while (stmt != IntPtr.Zero); // Not overly concerned with the return value from a rollback. UnsafeNativeMethods.sqlite3_exec(db, ToUTF8("ROLLBACK"), IntPtr.Zero, IntPtr.Zero, out stmt); } } internal interface ISQLiteSchemaExtensions { void BuildTempSchema(SQLiteConnection cnn); } [Flags] internal enum SQLiteOpenFlagsEnum { None = 0, ReadOnly = 0x01, ReadWrite = 0x02, Create = 0x04, SharedCache = 0x01000000, Default = 0x06, } } |
Changes to System.Data.SQLite/SQLiteCommand.cs.
︙ | ︙ | |||
13 14 15 16 17 18 19 | using System.Collections.Generic; using System.ComponentModel; /// <summary> /// SQLite implementation of DbCommand. /// </summary> #if !PLATFORM_COMPACTFRAMEWORK | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | using System.Collections.Generic; using System.ComponentModel; /// <summary> /// SQLite implementation of DbCommand. /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [Designer("SQLite.Designer.SQLiteCommandDesigner, SQLite.Designer, Version=1.0.35.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139"), ToolboxItem(true)] #endif public sealed class SQLiteCommand : DbCommand, ICloneable { /// <summary> /// The command text this command is based on /// </summary> private string _commandText; |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteConnection.cs.
︙ | ︙ | |||
10 11 12 13 14 15 16 17 18 19 20 21 22 23 | using System; using System.Data; using System.Data.Common; using System.Collections.Generic; using System.Globalization; using System.ComponentModel; using System.Text; /// <summary> /// SQLite implentation of DbConnection. /// </summary> /// <remarks> /// The <see cref="ConnectionString">ConnectionString</see> property of the SQLiteConnection class can contain the following parameter(s), delimited with a semi-colon: /// <list type="table"> | > > | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | using System; using System.Data; using System.Data.Common; using System.Collections.Generic; using System.Globalization; using System.ComponentModel; using System.Text; using System.Runtime.InteropServices; using System.IO; /// <summary> /// SQLite implentation of DbConnection. /// </summary> /// <remarks> /// The <see cref="ConnectionString">ConnectionString</see> property of the SQLiteConnection class can contain the following parameter(s), delimited with a semi-colon: /// <list type="table"> |
︙ | ︙ | |||
105 106 107 108 109 110 111 | /// <description>N</description> /// <description>0</description> /// </item> /// <item> /// <description>Legacy Format</description> /// <description><b>True</b> - Use the more compatible legacy 3.x database format<br/><b>False</b> - Use the newer 3.3x database format which compresses numbers more effectively</description> /// <description>N</description> | | > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /// <description>N</description> /// <description>0</description> /// </item> /// <item> /// <description>Legacy Format</description> /// <description><b>True</b> - Use the more compatible legacy 3.x database format<br/><b>False</b> - Use the newer 3.3x database format which compresses numbers more effectively</description> /// <description>N</description> /// <description>False</description> /// </item> /// <item> /// <description>Default Timeout</description> /// <description>{time in seconds}<br/>The default command timeout</description> /// <description>N</description> /// <description>30</description> /// </item> /// <item> /// <description>Journal Mode</description> /// <description><b>Delete</b> - Delete the journal file after a commit<br/><b>Persist</b> - Zero out and leave the journal file on disk after a commit<br/><b>Off</b> - Disable the rollback journal entirely</description> /// <description>N</description> /// <description>Delete</description> /// </item> /// <item> /// <description>Read Only</description> /// <description><b>True</b> - Open the database for read only access<br/><b>False</b> - Open the database for normal read/write access</description> /// <description>N</description> /// <description>False</description> /// </item> /// <item> /// <description>Max Pool Size</description> /// <description>The maximum number of connections for the given connection string that can be in the connection pool</description> /// <description>N</description> /// <description>100</description> /// </item> /// <item> /// <description>Default IsolationLevel</description> /// <description>The default transaciton isolation level</description> /// <description>N</description> /// <description>Serializable</description> /// </item> /// </list> /// </remarks> public sealed partial class SQLiteConnection : DbConnection, ICloneable { private const string _dataDirectory = "|DataDirectory|"; private const string _masterdb = "sqlite_master"; private const string _tempmasterdb = "sqlite_temp_master"; /// <summary> /// State of the current connection /// </summary> private ConnectionState _connectionState; /// <summary> /// The connection string /// </summary> private string _connectionString; /// <summary> /// Nesting level of the transactions open on the connection /// </summary> internal int _transactionLevel; /// <summary> /// The default isolation level for new transactions /// </summary> private IsolationLevel _defaultIsolation; #if !PLATFORM_COMPACTFRAMEWORK /// <summary> /// Whether or not the connection is enlisted in a distrubuted transaction /// </summary> internal SQLiteEnlistment _enlistment; #endif /// <summary> |
︙ | ︙ | |||
285 286 287 288 289 290 291 | /// <summary> /// Creates a database file. This just creates a zero-byte file which SQLite /// will turn into a database when the file is opened properly. /// </summary> /// <param name="databaseFileName">The file to create</param> static public void CreateFile(string databaseFileName) { | | > > > > > > | | > | | | > < < | < | > > > > > > > > > | | | > > | > > > > > > | 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 | /// <summary> /// Creates a database file. This just creates a zero-byte file which SQLite /// will turn into a database when the file is opened properly. /// </summary> /// <param name="databaseFileName">The file to create</param> static public void CreateFile(string databaseFileName) { FileStream fs = File.Create(databaseFileName); fs.Close(); } #if !SQLITE_STANDARD /// <summary> /// On NTFS volumes, this function turns on the compression attribute for the given file. /// It must not be open or referenced at the time of the function call. /// </summary> /// <param name="databaseFileName">The file to compress</param> [Obsolete("This functionality is being removed from a future version of the SQLite provider")] static public void CompressFile(string databaseFileName) { UnsafeNativeMethods.sqlite3_compressfile(databaseFileName); } #endif #if !SQLITE_STANDARD /// <summary> /// On NTFS volumes, this function removes the compression attribute for the given file. /// It must not be open or referenced at the time of the function call. /// </summary> /// <param name="databaseFileName">The file to decompress</param> [Obsolete("This functionality is being removed from a future version of the SQLite provider")] static public void DecompressFile(string databaseFileName) { UnsafeNativeMethods.sqlite3_decompressfile(databaseFileName); } #endif /// <summary> /// Raises the state change event when the state of the connection changes /// </summary> /// <param name="newState">The new state. If it is different from the previous state, an event is raised.</param> internal void OnStateChange(ConnectionState newState) { ConnectionState oldState = _connectionState; _connectionState = newState; if (StateChange != null && oldState != newState) { StateChangeEventArgs e = new StateChangeEventArgs(oldState, newState); StateChange(this, e); } } /// <summary> /// OBSOLETE. Creates a new SQLiteTransaction if one isn't already active on the connection. /// </summary> /// <param name="isolationLevel">This parameter is ignored.</param> /// <param name="deferredLock">When TRUE, SQLite defers obtaining a write lock until a write operation is requested. /// When FALSE, a writelock is obtained immediately. The default is TRUE, but in a multi-threaded multi-writer /// environment, one may instead choose to lock the database immediately to avoid any possible writer deadlock.</param> /// <returns>Returns a SQLiteTransaction object.</returns> [Obsolete("Use one of the standard BeginTransaction methods, this one will be removed soon")] public SQLiteTransaction BeginTransaction(IsolationLevel isolationLevel, bool deferredLock) { return (SQLiteTransaction)BeginDbTransaction(deferredLock == false ? IsolationLevel.Serializable : IsolationLevel.ReadCommitted); } /// <summary> /// OBSOLETE. Creates a new SQLiteTransaction if one isn't already active on the connection. /// </summary> /// <param name="deferredLock">When TRUE, SQLite defers obtaining a write lock until a write operation is requested. /// When FALSE, a writelock is obtained immediately. The default is false, but in a multi-threaded multi-writer /// environment, one may instead choose to lock the database immediately to avoid any possible writer deadlock.</param> /// <returns>Returns a SQLiteTransaction object.</returns> [Obsolete("Use one of the standard BeginTransaction methods, this one will be removed soon")] public SQLiteTransaction BeginTransaction(bool deferredLock) { return (SQLiteTransaction)BeginDbTransaction(deferredLock == false ? IsolationLevel.Serializable : IsolationLevel.ReadCommitted); } /// <summary> /// Creates a new SQLiteTransaction if one isn't already active on the connection. /// </summary> /// <param name="isolationLevel">Supported isolation levels are Serializable, ReadCommitted and Unspecified.</param> /// <remarks> /// Unspecified will use the default isolation level specified in the connection string. If no isolation level is specified in the /// connection string, Serializable is used. /// Serializable transactions are the default. In this mode, the engine gets an immediate lock on the database, and no other threads /// may begin a transaction. Other threads may read from the database, but not write. /// With a ReadCommitted isolation level, locks are deferred and elevated as needed. It is possible for multiple threads to start /// a transaction in ReadCommitted mode, but if a thread attempts to commit a transaction while another thread /// has a ReadCommitted lock, it may timeout or cause a deadlock on both threads until both threads' CommandTimeout's are reached. /// </remarks> /// <returns>Returns a SQLiteTransaction object.</returns> public new SQLiteTransaction BeginTransaction(IsolationLevel isolationLevel) { return (SQLiteTransaction)BeginDbTransaction(isolationLevel); } /// <summary> /// Creates a new SQLiteTransaction if one isn't already active on the connection. /// </summary> /// <returns>Returns a SQLiteTransaction object.</returns> public new SQLiteTransaction BeginTransaction() { return (SQLiteTransaction)BeginDbTransaction(_defaultIsolation); } /// <summary> /// Forwards to the local BeginTransaction() function /// </summary> /// <param name="isolationLevel">Supported isolation levels are Unspecified, Serializable, and ReadCommitted</param> /// <returns></returns> protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) { if (_connectionState != ConnectionState.Open) throw new InvalidOperationException(); if (isolationLevel == IsolationLevel.Unspecified) isolationLevel = _defaultIsolation; if (isolationLevel != IsolationLevel.Serializable && isolationLevel != IsolationLevel.ReadCommitted) throw new ArgumentException("isolationLevel"); return new SQLiteTransaction(this, isolationLevel != IsolationLevel.Serializable); } /// <summary> /// Not implemented /// </summary> /// <param name="databaseName"></param> public override void ChangeDatabase(string databaseName) |
︙ | ︙ | |||
429 430 431 432 433 434 435 436 437 438 439 440 441 442 | _sql.Close(); } _sql = null; _transactionLevel = 0; } OnStateChange(ConnectionState.Closed); } /// <summary> /// The connection string containing the parameters for the connection /// </summary> /// <remarks> /// <list type="table"> /// <listheader> | > > > > > > > > > > > > > > > > > > > | 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 | _sql.Close(); } _sql = null; _transactionLevel = 0; } OnStateChange(ConnectionState.Closed); } /// <summary> /// Clears the connection pool associated with the connection. Any other active connections using the same database file /// will be discarded instead of returned to the pool when they are closed. /// </summary> /// <param name="connection"></param> public static void ClearPool(SQLiteConnection connection) { if (connection._sql == null) return; connection._sql.ClearPool(); } /// <summary> /// Clears all connection pools. Any active connections will be discarded instead of sent to the pool when they are closed. /// </summary> public static void ClearAllPools() { SQLiteConnectionPool.ClearAllPools(); } /// <summary> /// The connection string containing the parameters for the connection /// </summary> /// <remarks> /// <list type="table"> /// <listheader> |
︙ | ︙ | |||
523 524 525 526 527 528 529 | /// <description>N</description> /// <description>0</description> /// </item> /// <item> /// <description>Legacy Format</description> /// <description><b>True</b> - Use the more compatible legacy 3.x database format<br/><b>False</b> - Use the newer 3.3x database format which compresses numbers more effectively</description> /// <description>N</description> | | > > > > > > > > > > > > > > > > > > | | 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 | /// <description>N</description> /// <description>0</description> /// </item> /// <item> /// <description>Legacy Format</description> /// <description><b>True</b> - Use the more compatible legacy 3.x database format<br/><b>False</b> - Use the newer 3.3x database format which compresses numbers more effectively</description> /// <description>N</description> /// <description>False</description> /// </item> /// <item> /// <description>Default Timeout</description> /// <description>{time in seconds}<br/>The default command timeout</description> /// <description>N</description> /// <description>30</description> /// </item> /// <item> /// <description>Journal Mode</description> /// <description><b>Delete</b> - Delete the journal file after a commit<br/><b>Persist</b> - Zero out and leave the journal file on disk after a commit<br/><b>Off</b> - Disable the rollback journal entirely</description> /// <description>N</description> /// <description>Delete</description> /// </item> /// <item> /// <description>Read Only</description> /// <description><b>True</b> - Open the database for read only access<br/><b>False</b> - Open the database for normal read/write access</description> /// <description>N</description> /// <description>False</description> /// </item> /// <item> /// <description>Max Pool Size</description> /// <description>The maximum number of connections for the given connection string that can be in the connection pool</description> /// <description>N</description> /// <description>100</description> /// </item> /// <item> /// <description>Default IsolationLevel</description> /// <description>The default transaciton isolation level</description> /// <description>N</description> /// <description>Serializable</description> /// </item> /// </list> /// </remarks> #if !PLATFORM_COMPACTFRAMEWORK [RefreshProperties(RefreshProperties.All), DefaultValue("")] [Editor("SQLite.Designer.SQLiteConnectionStringEditor, SQLite.Designer, Version=1.0.35.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] #endif public override string ConnectionString { get { return _connectionString; } |
︙ | ︙ | |||
607 608 609 610 611 612 613 614 615 616 617 | { get { return "main"; } } /// <summary> /// Parses the connection string into component parts /// </summary> /// <returns>An array of key-value pairs representing each parameter of the connection string</returns> | > > > > > > > > > > > > > | | | 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 | { get { return "main"; } } internal static string MapUriPath(string path) { if (path.StartsWith ("file://")) return path.Substring (7); else if (path.StartsWith ("file:")) return path.Substring (5); else if (path.StartsWith ("/")) return path; else throw new InvalidOperationException ("Invalid connection string: invalid URI"); } /// <summary> /// Parses the connection string into component parts /// </summary> /// <param name="connectionString">The connection string to parse</param> /// <returns>An array of key-value pairs representing each parameter of the connection string</returns> internal static SortedList<string, string> ParseConnectionString(string connectionString) { string s = connectionString; int n; SortedList<string, string> ls = new SortedList<string, string>(StringComparer.OrdinalIgnoreCase); // First split into semi-colon delimited values. The Split() function of SQLiteBase accounts for and properly // skips semi-colons in quoted strings string[] arParts = SQLiteConvert.Split(s, ';'); string[] arPiece; |
︙ | ︙ | |||
679 680 681 682 683 684 685 | public override void Open() { if (_connectionState != ConnectionState.Closed) throw new InvalidOperationException(); Close(); | | > > > | > > > | | | > > > > > | | | | | | | > | < | < < | < < < < > | | < < | | | | 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 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 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 | public override void Open() { if (_connectionState != ConnectionState.Closed) throw new InvalidOperationException(); Close(); SortedList<string, string> opts = ParseConnectionString(_connectionString); string fileName; if (Convert.ToInt32(FindKey(opts, "Version", "3"), CultureInfo.InvariantCulture) != 3) throw new NotSupportedException("Only SQLite Version 3 is supported at this time"); fileName = FindKey(opts, "Data Source", ""); if (String.IsNullOrEmpty(fileName)) { fileName = FindKey(opts, "Uri", ""); if (String.IsNullOrEmpty(fileName)) throw new ArgumentException("Data Source cannot be empty. Use :memory: to open an in-memory database"); else fileName = MapUriPath(fileName); } if (String.Compare(fileName, ":MEMORY:", true, CultureInfo.InvariantCulture) == 0) fileName = ":memory:"; else { #if PLATFORM_COMPACTFRAMEWORK if (fileName.StartsWith(".\\")) fileName = Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().GetName().CodeBase) + fileName.Substring(1); #endif fileName = ExpandFileName(fileName); } try { bool usePooling = (SQLiteConvert.ToBoolean(FindKey(opts, "Pooling", Boolean.FalseString)) == true); bool bUTF16 = (SQLiteConvert.ToBoolean(FindKey(opts, "UseUTF16Encoding", Boolean.FalseString)) == true); int maxPoolSize = Convert.ToInt32(FindKey(opts, "Max Pool Size", "100")); _defaultTimeout = Convert.ToInt32(FindKey(opts, "Default Timeout", "30"), CultureInfo.CurrentCulture); _defaultIsolation = (IsolationLevel)Enum.Parse(typeof(IsolationLevel), FindKey(opts, "Default IsolationLevel", "Serializable"), true); if (_defaultIsolation != IsolationLevel.Serializable && _defaultIsolation != IsolationLevel.ReadCommitted) throw new NotSupportedException("Invalid Default IsolationLevel specified"); SQLiteDateFormats dateFormat = (SQLiteDateFormats)Enum.Parse(typeof(SQLiteDateFormats), FindKey(opts, "DateTimeFormat", "ISO8601"), true); //string temp = FindKey(opts, "DateTimeFormat", "ISO8601"); //if (String.Compare(temp, "ticks", true, CultureInfo.InvariantCulture) == 0) dateFormat = SQLiteDateFormats.Ticks; //else if (String.Compare(temp, "julianday", true, CultureInfo.InvariantCulture) == 0) dateFormat = SQLiteDateFormats.JulianDay; if (bUTF16) // SQLite automatically sets the encoding of the database to UTF16 if called from sqlite3_open16() _sql = new SQLite3_UTF16(dateFormat); else _sql = new SQLite3(dateFormat); SQLiteOpenFlagsEnum flags = SQLiteOpenFlagsEnum.None; if (SQLiteConvert.ToBoolean(FindKey(opts, "FailIfMissing", Boolean.FalseString)) == false) flags |= SQLiteOpenFlagsEnum.Create; if (SQLiteConvert.ToBoolean(FindKey(opts, "Read Only", Boolean.FalseString)) == true) flags |= SQLiteOpenFlagsEnum.ReadOnly; else flags |= SQLiteOpenFlagsEnum.ReadWrite; _sql.Open(fileName, flags, maxPoolSize, usePooling); _binaryGuid = (SQLiteConvert.ToBoolean(FindKey(opts, "BinaryGUID", Boolean.TrueString)) == true); string password = FindKey(opts, "Password", null); if (String.IsNullOrEmpty(password) == false) _sql.SetPassword(System.Text.UTF8Encoding.UTF8.GetBytes(password)); else if (_password != null) _sql.SetPassword(_password); _password = null; _dataSource = Path.GetFileNameWithoutExtension(fileName); OnStateChange(ConnectionState.Open); _version++; using (SQLiteCommand cmd = CreateCommand()) { string defValue; |
︙ | ︙ | |||
772 773 774 775 776 777 778 | defValue = FindKey(opts, "Max Page Count", "0"); if (Convert.ToInt32(defValue, CultureInfo.InvariantCulture) != 0) { cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA max_page_count={0}", defValue); cmd.ExecuteNonQuery(); } | | | | 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 | defValue = FindKey(opts, "Max Page Count", "0"); if (Convert.ToInt32(defValue, CultureInfo.InvariantCulture) != 0) { cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA max_page_count={0}", defValue); cmd.ExecuteNonQuery(); } defValue = FindKey(opts, "Legacy Format", Boolean.FalseString); cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA legacy_file_format={0}", SQLiteConvert.ToBoolean(defValue) == true ? "ON" : "OFF"); cmd.ExecuteNonQuery(); defValue = FindKey(opts, "Synchronous", "Normal"); if (String.Compare(defValue, "Full", StringComparison.OrdinalIgnoreCase) != 0) { cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA synchronous={0}", defValue); cmd.ExecuteNonQuery(); |
︙ | ︙ | |||
799 800 801 802 803 804 805 | { cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA journal_mode={0}", defValue); cmd.ExecuteNonQuery(); } } #if !PLATFORM_COMPACTFRAMEWORK | | < | 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | { cmd.CommandText = String.Format(CultureInfo.InvariantCulture, "PRAGMA journal_mode={0}", defValue); cmd.ExecuteNonQuery(); } } #if !PLATFORM_COMPACTFRAMEWORK if (Transactions.Transaction.Current != null && SQLiteConvert.ToBoolean(FindKey(opts, "Enlist", Boolean.TrueString)) == true) EnlistTransaction(Transactions.Transaction.Current); #endif } catch (SQLiteException) { Close(); throw; |
︙ | ︙ | |||
922 923 924 925 926 927 928 | if (String.IsNullOrEmpty(sourceFile)) return sourceFile; if (sourceFile.StartsWith(_dataDirectory, StringComparison.OrdinalIgnoreCase)) { string dataDirectory; #if PLATFORM_COMPACTFRAMEWORK | | | | | | | 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 | if (String.IsNullOrEmpty(sourceFile)) return sourceFile; if (sourceFile.StartsWith(_dataDirectory, StringComparison.OrdinalIgnoreCase)) { string dataDirectory; #if PLATFORM_COMPACTFRAMEWORK dataDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().GetName().CodeBase); #else dataDirectory = AppDomain.CurrentDomain.GetData("DataDirectory") as string; if (String.IsNullOrEmpty(dataDirectory)) dataDirectory = AppDomain.CurrentDomain.BaseDirectory; #endif if (sourceFile.Length > _dataDirectory.Length) { if (sourceFile[_dataDirectory.Length] == Path.DirectorySeparatorChar || sourceFile[_dataDirectory.Length] == Path.AltDirectorySeparatorChar) sourceFile = sourceFile.Remove(_dataDirectory.Length, 1); } sourceFile = Path.Combine(dataDirectory, sourceFile.Substring(_dataDirectory.Length)); } #if !PLATFORM_COMPACTFRAMEWORK sourceFile = Path.GetFullPath(sourceFile); #endif return sourceFile; } ///<overloads> /// The following commands are used to extract schema information out of the database. Valid schema types are: |
︙ | ︙ | |||
1087 1088 1089 1090 1091 1092 1093 | tbl.Locale = CultureInfo.InvariantCulture; tbl.Columns.Add("CollectionName", typeof(string)); tbl.Columns.Add("NumberOfRestrictions", typeof(int)); tbl.Columns.Add("NumberOfIdentifierParts", typeof(int)); tbl.BeginLoadData(); | | | 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 | tbl.Locale = CultureInfo.InvariantCulture; tbl.Columns.Add("CollectionName", typeof(string)); tbl.Columns.Add("NumberOfRestrictions", typeof(int)); tbl.Columns.Add("NumberOfIdentifierParts", typeof(int)); tbl.BeginLoadData(); StringReader reader = new StringReader(SR.MetaDataCollections); tbl.ReadXml(reader); reader.Close(); tbl.AcceptChanges(); tbl.EndLoadData(); return tbl; |
︙ | ︙ | |||
1272 1273 1274 1275 1276 1277 1278 | /// <param name="strIndex">The name of the index to retrieve information for, can be null</param> /// <param name="strTable">The table to retrieve index information for, can be null</param> /// <returns>DataTable</returns> private DataTable Schema_Indexes(string strCatalog, string strTable, string strIndex) { DataTable tbl = new DataTable("Indexes"); DataRow row; | | | 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 | /// <param name="strIndex">The name of the index to retrieve information for, can be null</param> /// <param name="strTable">The table to retrieve index information for, can be null</param> /// <returns>DataTable</returns> private DataTable Schema_Indexes(string strCatalog, string strTable, string strIndex) { DataTable tbl = new DataTable("Indexes"); DataRow row; List<int> primaryKeys = new List<int>(); bool maybeRowId; tbl.Locale = CultureInfo.InvariantCulture; tbl.Columns.Add("TABLE_CATALOG", typeof(string)); tbl.Columns.Add("TABLE_SCHEMA", typeof(string)); tbl.Columns.Add("TABLE_NAME", typeof(string)); tbl.Columns.Add("INDEX_CATALOG", typeof(string)); |
︙ | ︙ | |||
1504 1505 1506 1507 1508 1509 1510 | tbl.Columns.Add("TABLE_CATALOG", typeof(string)); tbl.Columns.Add("TABLE_SCHEMA", typeof(string)); tbl.Columns.Add("TABLE_NAME", typeof(string)); tbl.Columns.Add("TABLE_TYPE", typeof(string)); tbl.Columns.Add("TABLE_ID", typeof(long)); tbl.Columns.Add("TABLE_ROOTPAGE", typeof(int)); tbl.Columns.Add("TABLE_DEFINITION", typeof(string)); | < | 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 | tbl.Columns.Add("TABLE_CATALOG", typeof(string)); tbl.Columns.Add("TABLE_SCHEMA", typeof(string)); tbl.Columns.Add("TABLE_NAME", typeof(string)); tbl.Columns.Add("TABLE_TYPE", typeof(string)); tbl.Columns.Add("TABLE_ID", typeof(long)); tbl.Columns.Add("TABLE_ROOTPAGE", typeof(int)); tbl.Columns.Add("TABLE_DEFINITION", typeof(string)); tbl.BeginLoadData(); if (String.IsNullOrEmpty(strCatalog)) strCatalog = "main"; string master = (String.Compare(strCatalog, "temp", true, CultureInfo.InvariantCulture) == 0) ? _tempmasterdb : _masterdb; using (SQLiteCommand cmd = new SQLiteCommand(String.Format(CultureInfo.InvariantCulture, "SELECT [type], [name], [tbl_name], [rootpage], [sql], [rowid] FROM [{0}].[{1}] WHERE [type] LIKE 'table'", strCatalog, master), this)) |
︙ | ︙ | |||
1534 1535 1536 1537 1538 1539 1540 | row["TABLE_CATALOG"] = strCatalog; row["TABLE_NAME"] = rd.GetString(2); row["TABLE_TYPE"] = strItem; row["TABLE_ID"] = rd.GetInt64(5); row["TABLE_ROOTPAGE"] = rd.GetInt32(3); row["TABLE_DEFINITION"] = rd.GetString(4); | < | 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 | row["TABLE_CATALOG"] = strCatalog; row["TABLE_NAME"] = rd.GetString(2); row["TABLE_TYPE"] = strItem; row["TABLE_ID"] = rd.GetInt64(5); row["TABLE_ROOTPAGE"] = rd.GetInt32(3); row["TABLE_DEFINITION"] = rd.GetString(4); tbl.Rows.Add(row); } } } } |
︙ | ︙ | |||
1587 1588 1589 1590 1591 1592 1593 | { while (rd.Read()) { if (String.Compare(rd.GetString(1), strView, true, CultureInfo.InvariantCulture) == 0 || String.IsNullOrEmpty(strView)) { strItem = rd.GetString(4).Replace('\r', ' ').Replace('\n', ' ').Replace('\t', ' '); | | | 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 | { while (rd.Read()) { if (String.Compare(rd.GetString(1), strView, true, CultureInfo.InvariantCulture) == 0 || String.IsNullOrEmpty(strView)) { strItem = rd.GetString(4).Replace('\r', ' ').Replace('\n', ' ').Replace('\t', ' '); nPos = CultureInfo.InvariantCulture.CompareInfo.IndexOf(strItem, " AS ", CompareOptions.IgnoreCase); if (nPos > -1) { strItem = strItem.Substring(nPos + 4).Trim(); row = tbl.NewRow(); row["TABLE_CATALOG"] = strCatalog; row["TABLE_NAME"] = rd.GetString(2); |
︙ | ︙ | |||
1682 1683 1684 1685 1686 1687 1688 | tbl.Columns.Add("IsUnsigned", typeof(bool)); tbl.Columns.Add("MaximumScale", typeof(short)); tbl.Columns.Add("MinimumScale", typeof(short)); tbl.Columns.Add("IsConcurrencyType", typeof(bool)); tbl.BeginLoadData(); | | | 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 | tbl.Columns.Add("IsUnsigned", typeof(bool)); tbl.Columns.Add("MaximumScale", typeof(short)); tbl.Columns.Add("MinimumScale", typeof(short)); tbl.Columns.Add("IsConcurrencyType", typeof(bool)); tbl.BeginLoadData(); StringReader reader = new StringReader(SR.DataTypes); tbl.ReadXml(reader); reader.Close(); tbl.AcceptChanges(); tbl.EndLoadData(); return tbl; |
︙ | ︙ | |||
2061 2062 2063 2064 2065 2066 2067 | { _sql.SetUpdateHook(null); _updateCallback = null; } } } | | | | | 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 | { _sql.SetUpdateHook(null); _updateCallback = null; } } } private void UpdateCallback(IntPtr puser, int type, IntPtr database, IntPtr table, Int64 rowid) { _updateHandler(this, new UpdateEventArgs( SQLiteBase.UTF8ToString(database, -1), SQLiteBase.UTF8ToString(table, -1), (UpdateEventType)type, rowid)); } /// <summary> /// This event is raised whenever SQLite is committing a transaction. /// Return non-zero to trigger a rollback |
︙ | ︙ | |||
2123 2124 2125 2126 2127 2128 2129 | _sql.SetRollbackHook(null); _rollbackCallback = null; } } } | | | | 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 | _sql.SetRollbackHook(null); _rollbackCallback = null; } } } private int CommitCallback(IntPtr parg) { CommitEventArgs e = new CommitEventArgs(); _commitHandler(this, e); return (e.AbortTransaction == true) ? 1 : 0; } private void RollbackCallback(IntPtr parg) { _rollbackHandler(this, EventArgs.Empty); } } /// <summary> /// The I/O file cache flushing behavior for the connection |
︙ | ︙ | |||
2155 2156 2157 2158 2159 2160 2161 | Full = 1, /// <summary> /// Use the default operating system's file flushing, SQLite does not explicitly flush the file buffers after writing /// </summary> Off = 2, } | > > > | > > > | > > > | | 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 | Full = 1, /// <summary> /// Use the default operating system's file flushing, SQLite does not explicitly flush the file buffers after writing /// </summary> Off = 2, } #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif internal delegate void SQLiteUpdateCallback(IntPtr puser, int type, IntPtr database, IntPtr table, Int64 rowid); #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif internal delegate int SQLiteCommitCallback(IntPtr puser); #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif internal delegate void SQLiteRollbackCallback(IntPtr puser); /// <summary> /// Raised when a transaction is about to be committed. To roll back a transaction, set the /// rollbackTrans boolean value to true. /// </summary> /// <param name="sender">The connection committing the transaction</param> /// <param name="e">Event arguments on the transaction</param> |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteConnectionPool.cs.
︙ | ︙ | |||
8 9 10 11 12 13 14 | namespace System.Data.SQLite { using System; using System.Collections.Generic; internal static class SQLiteConnectionPool { | > > > > > > > > > | > | > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > | | > > > > > > > > > > > > > | | > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > | | > > > | > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > | 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 | namespace System.Data.SQLite { using System; using System.Collections.Generic; internal static class SQLiteConnectionPool { /// <summary> /// Keeps track of connections made on a specified file. The PoolVersion dictates whether old objects get /// returned to the pool or discarded when no longer in use. /// </summary> internal class Pool { internal readonly Queue<WeakReference> Queue = new Queue<WeakReference>(); internal int PoolVersion; internal int MaxPoolSize; internal Pool(int version, int maxSize) { PoolVersion = version; MaxPoolSize = maxSize; } } /// <summary> /// The connection pool object /// </summary> private static SortedList<string, Pool> _connections = new SortedList<string, Pool>(StringComparer.OrdinalIgnoreCase); /// <summary> /// The default version number new pools will get /// </summary> private static int _poolVersion = 1; /// <summary> /// Attempt to pull a pooled connection out of the queue for active duty /// </summary> /// <param name="fileName">The filename for a desired connection</param> /// <param name="maxPoolSize">The maximum size the connection pool for the filename can be</param> /// <param name="version">The pool version the returned connection will belong to</param> /// <returns>Returns NULL if no connections were available. Even if none are, the poolversion will still be a valid pool version</returns> internal static SQLiteConnectionHandle Remove(string fileName, int maxPoolSize, out int version) { lock (_connections) { Pool queue; // Default to the highest pool version version = _poolVersion; // If we didn't find a pool for this file, create one even though it will be empty. // We have to do this here because otherwise calling ClearPool() on the file will not work for active connections // that have never seen the pool yet. if (_connections.TryGetValue(fileName, out queue) == false) { queue = new Pool(_poolVersion, maxPoolSize); _connections.Add(fileName, queue); return null; } // We found a pool for this file, so use its version number version = queue.PoolVersion; queue.MaxPoolSize = maxPoolSize; ResizePool(queue, false); // Try and get a pooled connection from the queue while (queue.Queue.Count > 0) { WeakReference cnn = queue.Queue.Dequeue(); SQLiteConnectionHandle hdl = cnn.Target as SQLiteConnectionHandle; if (hdl != null) { return hdl; } } return null; } } /// <summary> /// Clears out all pooled connections and rev's up the default pool version to force all old active objects /// not in the pool to get discarded rather than returned to their pools. /// </summary> internal static void ClearAllPools() { lock (_connections) { foreach (KeyValuePair<string, Pool> pair in _connections) { while (pair.Value.Queue.Count > 0) { WeakReference cnn = pair.Value.Queue.Dequeue(); SQLiteConnectionHandle hdl = cnn.Target as SQLiteConnectionHandle; if (hdl != null) { hdl.Dispose(); } } // Keep track of the highest revision so we can go one higher when we're finished if (_poolVersion <= pair.Value.PoolVersion) _poolVersion = pair.Value.PoolVersion + 1; } // All pools are cleared and we have a new highest version number to force all old version active items to get discarded // instead of going back to the queue when they are closed. // We can get away with this because we're pumped up the _poolVersion out of range of all active connections, so they // will all get discarded when they try to put themselves back in their pool. _connections.Clear(); } } /// <summary> /// Clear a given pool for a given filename. Discards anything in the pool for the given file, and revs the pool /// version so current active objects on the old version of the pool will get discarded rather than be returned to the pool. /// </summary> /// <param name="fileName">The filename of the pool to clear</param> internal static void ClearPool(string fileName) { lock (_connections) { Pool queue; if (_connections.TryGetValue(fileName, out queue) == true) { queue.PoolVersion++; while (queue.Queue.Count > 0) { WeakReference cnn = queue.Queue.Dequeue(); SQLiteConnectionHandle hdl = cnn.Target as SQLiteConnectionHandle; if (hdl != null) { hdl.Dispose(); } } } } } /// <summary> /// Return a connection to the pool for someone else to use. /// </summary> /// <param name="fileName">The filename of the pool to use</param> /// <param name="hdl">The connection handle to pool</param> /// <param name="version">The pool version the handle was created under</param> /// <remarks> /// If the version numbers don't match between the connection and the pool, then the handle is discarded. /// </remarks> internal static void Add(string fileName, SQLiteConnectionHandle hdl, int version) { lock (_connections) { // If the queue doesn't exist in the pool, then it must've been cleared sometime after the connection was created. Pool queue; if (_connections.TryGetValue(fileName, out queue) == true && version == queue.PoolVersion) { ResizePool(queue, true); queue.Queue.Enqueue(new WeakReference(hdl, false)); GC.KeepAlive(hdl); } else { hdl.Close(); } } } private static void ResizePool(Pool queue, bool forAdding) { int target = queue.MaxPoolSize; if (forAdding && target > 0) target--; while (queue.Queue.Count > target) { WeakReference cnn = queue.Queue.Dequeue(); SQLiteConnectionHandle hdl = cnn.Target as SQLiteConnectionHandle; if (hdl != null) { hdl.Dispose(); } } } } } |
Changes to System.Data.SQLite/SQLiteConnectionStringBuilder.cs.
︙ | ︙ | |||
68 69 70 71 72 73 74 | [Browsable(true)] [DefaultValue(3)] public int Version { get { object value; | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | > > > | | > > > > > > > > > > > > > > > > > > > > > > > | 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 | [Browsable(true)] [DefaultValue(3)] public int Version { get { object value; TryGetValue("version", out value); return Convert.ToInt32(value, CultureInfo.CurrentCulture); } set { if (value != 3) throw new NotSupportedException(); this["version"] = value; } } /// <summary> /// Gets/Sets the synchronous mode of the connection string. Default is "Normal". /// </summary> [DisplayName("Synchronous")] [Browsable(true)] [DefaultValue(SynchronizationModes.Normal)] public SynchronizationModes SyncMode { get { object value; TryGetValue("synchronous", out value); if (value is string) return (SynchronizationModes)TypeDescriptor.GetConverter(typeof(SynchronizationModes)).ConvertFrom(value); else return (SynchronizationModes)value; } set { this["synchronous"] = value; } } /// <summary> /// Gets/Sets the encoding for the connection string. The default is "False" which indicates UTF-8 encoding. /// </summary> [Browsable(true)] [DefaultValue(false)] public bool UseUTF16Encoding { get { object value; TryGetValue("useutf16encoding", out value); return SQLiteConvert.ToBoolean(value); } set { this["useutf16encoding"] = value; } } /// <summary> /// Gets/Sets whether or not to use connection pooling. The default is "False" /// </summary> [Browsable(true)] [DefaultValue(false)] public bool Pooling { get { object value; TryGetValue("pooling", out value); return SQLiteConvert.ToBoolean(value); } set { this["pooling"] = value; } } /// <summary> /// Gets/Sets whethor not to store GUID's in binary format. The default is True /// which saves space in the database. /// </summary> [Browsable(true)] [DefaultValue(true)] public bool BinaryGUID { get { object value; TryGetValue("binaryguid", out value); return SQLiteConvert.ToBoolean(value); } set { this["binaryguid"] = value; } } /// <summary> /// Gets/Sets the filename to open on the connection string. /// </summary> [DisplayName("Data Source")] [Browsable(true)] [DefaultValue("")] public string DataSource { get { object value; TryGetValue("data source", out value); return value.ToString(); } set { this["data source"] = value; } } /// <summary> /// An alternate to the data source property /// </summary> [Browsable(false)] public string Uri { get { object value; TryGetValue("uri", out value); return value.ToString(); } set { this["uri"] = value; } } /// <summary> /// Gets/sets the default command timeout for newly-created commands. This is especially useful for /// commands used internally such as inside a SQLiteTransaction, where setting the timeout is not possible. /// </summary> [DisplayName("Default Timeout")] [Browsable(true)] [DefaultValue(30)] public int DefaultTimeout { get { object value; TryGetValue("default timeout", out value); return Convert.ToInt32(value, CultureInfo.CurrentCulture); } set { this["default timeout"] = value; } } /// <summary> /// Determines whether or not the connection will automatically participate /// in the current distributed transaction (if one exists) /// </summary> [Browsable(true)] [DefaultValue(true)] public bool Enlist { get { object value; TryGetValue("enlist", out value); return SQLiteConvert.ToBoolean(value); } set { this["enlist"] = value; } } /// <summary> /// If set to true, will throw an exception if the database specified in the connection /// string does not exist. If false, the database will be created automatically. /// </summary> [Browsable(true)] [DefaultValue(false)] [DisplayName("Fail If Missing")] public bool FailIfMissing { get { object value; TryGetValue("failifmissing", out value); return SQLiteConvert.ToBoolean(value); } set { this["failifmissing"] = value; } } /// <summary> /// If enabled, uses the legacy 3.xx format for maximum compatibility, but results in larger /// database sizes. /// </summary> [DisplayName("Legacy Format")] [Browsable(true)] [DefaultValue(false)] public bool LegacyFormat { get { object value; TryGetValue("legacy format", out value); return SQLiteConvert.ToBoolean(value); } set { this["legacy format"] = value; } } /// <summary> /// When enabled, the database will be opened for read-only access and writing will be disabled. /// </summary> [DisplayName("Read Only")] [Browsable(true)] [DefaultValue(false)] public bool ReadOnly { get { object value; TryGetValue("read only", out value); return SQLiteConvert.ToBoolean(value); } set { this["read only"] = value; } } /// <summary> /// Gets/sets the database encryption password /// </summary> [Browsable(true)] [PasswordPropertyText(true)] [DefaultValue("")] public string Password { get { object value; TryGetValue("password", out value); return value.ToString(); } set { this["password"] = value; } } /// <summary> /// Gets/Sets the page size for the connection. /// </summary> [DisplayName("Page Size")] [Browsable(true)] [DefaultValue(1024)] public int PageSize { get { object value; TryGetValue("page size", out value); return Convert.ToInt32(value, CultureInfo.CurrentCulture); } set { this["page size"] = value; } } /// <summary> /// Gets/Sets the maximum number of pages the database may hold /// </summary> [DisplayName("Max Page Count")] [Browsable(true)] [DefaultValue(0)] public int MaxPageCount { get { object value; TryGetValue("max page count", out value); return Convert.ToInt32(value, CultureInfo.CurrentCulture); } set { this["max page count"] = value; } } /// <summary> /// Gets/Sets the cache size for the connection. /// </summary> [DisplayName("Cache Size")] [Browsable(true)] [DefaultValue(2000)] public int CacheSize { get { object value; TryGetValue("cache size", out value); return Convert.ToInt32(value, CultureInfo.CurrentCulture); } set { this["cache size"] = value; } } /// <summary> /// Gets/Sets the datetime format for the connection. /// </summary> [Browsable(true)] [DefaultValue(SQLiteDateFormats.ISO8601)] public SQLiteDateFormats DateTimeFormat { get { object value; TryGetValue("datetimeformat", out value); if (value is string) return (SQLiteDateFormats)TypeDescriptor.GetConverter(typeof(SQLiteDateFormats)).ConvertFrom(value); else return (SQLiteDateFormats)value; } set { this["datetimeformat"] = value; } } /// <summary> /// Determines how SQLite handles the transaction journal file. /// </summary> [Browsable(true)] [DefaultValue(SQLiteJournalModeEnum.Delete)] [DisplayName("Journal Mode")] public SQLiteJournalModeEnum JournalMode { get { object value; TryGetValue("journal mode", out value); if (value is string) return (SQLiteJournalModeEnum)TypeDescriptor.GetConverter(typeof(SQLiteJournalModeEnum)).ConvertFrom(value); else return (SQLiteJournalModeEnum)value; } set { this["journal mode"] = value; } } /// <summary> /// Sets the default isolation level for transactions on the connection. /// </summary> [Browsable(true)] [DefaultValue(IsolationLevel.Serializable)] [DisplayName("Default Isolation Level")] public IsolationLevel DefaultIsolationLevel { get { object value; TryGetValue("default isolationlevel", out value); if (value is string) return (IsolationLevel)TypeDescriptor.GetConverter(typeof(IsolationLevel)).ConvertFrom(value); else return (IsolationLevel)value; } set { this["default isolationlevel"] = value; } } /// <summary> /// Helper function for retrieving values from the connectionstring /// </summary> /// <param name="keyword">The keyword to retrieve settings for</param> |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteConvert.cs.
︙ | ︙ | |||
14 15 16 17 18 19 20 | using System.Globalization; using System.Text; #if !PLATFORM_COMPACTFRAMEWORK using System.ComponentModel.Design; #endif | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | using System.Globalization; using System.Text; #if !PLATFORM_COMPACTFRAMEWORK using System.ComponentModel.Design; #endif /// <summary> /// This base class provides datatype conversion services for the SQLite provider. /// </summary> public abstract class SQLiteConvert { /// <summary> /// An array of ISO8601 datetime formats we support conversion from |
︙ | ︙ | |||
186 187 188 189 190 191 192 | #region UTF-8 Conversion Functions /// <summary> /// Converts a string to a UTF-8 encoded byte array sized to include a null-terminating character. /// </summary> /// <param name="sourceText">The string to convert to UTF-8</param> /// <returns>A byte array containing the converted string plus an extra 0 terminating byte at the end of the array.</returns> | | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | #region UTF-8 Conversion Functions /// <summary> /// Converts a string to a UTF-8 encoded byte array sized to include a null-terminating character. /// </summary> /// <param name="sourceText">The string to convert to UTF-8</param> /// <returns>A byte array containing the converted string plus an extra 0 terminating byte at the end of the array.</returns> public static byte[] ToUTF8(string sourceText) { Byte[] byteArray; int nlen = _utf8.GetByteCount(sourceText) + 1; byteArray = new byte[nlen]; nlen = _utf8.GetBytes(sourceText, 0, sourceText.Length, byteArray, 0); byteArray[nlen] = 0; |
︙ | ︙ | |||
231 232 233 234 235 236 237 | /// Converts a UTF-8 encoded IntPtr of the specified length into a .NET string /// </summary> /// <param name="nativestring">The pointer to the memory where the UTF-8 string is encoded</param> /// <param name="nativestringlen">The number of bytes to decode</param> /// <returns>A string containing the translated character(s)</returns> public static string UTF8ToString(IntPtr nativestring, int nativestringlen) { | > | | > > > > > > | | 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 | /// Converts a UTF-8 encoded IntPtr of the specified length into a .NET string /// </summary> /// <param name="nativestring">The pointer to the memory where the UTF-8 string is encoded</param> /// <param name="nativestringlen">The number of bytes to decode</param> /// <returns>A string containing the translated character(s)</returns> public static string UTF8ToString(IntPtr nativestring, int nativestringlen) { if (nativestringlen == 0 || nativestring == IntPtr.Zero) return ""; if (nativestringlen == -1) { do { nativestringlen++; } while (Marshal.ReadByte(nativestring, nativestringlen) != 0); } byte[] byteArray = new byte[nativestringlen]; Marshal.Copy(nativestring, byteArray, 0, nativestringlen); return _utf8.GetString(byteArray, 0, nativestringlen); } #endregion |
︙ | ︙ | |||
400 401 402 403 404 405 406 407 408 409 410 411 412 413 | } string[] ar = new string[ls.Count]; ls.CopyTo(ar, 0); return ar; } #region Type Conversions /// <summary> /// Determines the data type of a column in a statement /// </summary> /// <param name="stmt">The statement to retrieve information for</param> /// <param name="i">The column to retrieve type information on</param> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | } string[] ar = new string[ls.Count]; ls.CopyTo(ar, 0); return ar; } /// <summary> /// Convert a value to true or false. /// </summary> /// <param name="source">A string or number representing true or false</param> /// <returns></returns> public static bool ToBoolean(object source) { if (source is bool) return (bool)source; return ToBoolean(source.ToString()); } /// <summary> /// Convert a string to true or false. /// </summary> /// <param name="source">A string representing true or false</param> /// <returns></returns> /// <remarks> /// "yes", "no", "y", "n", "0", "1", "on", "off" as well as Boolean.FalseString and Boolean.TrueString will all be /// converted to a proper boolean value. /// </remarks> public static bool ToBoolean(string source) { if (String.Compare(source, bool.TrueString, StringComparison.OrdinalIgnoreCase) == 0) return true; else if (String.Compare(source, bool.FalseString, StringComparison.OrdinalIgnoreCase) == 0) return false; switch(source.ToLower()) { case "yes": case "y": case "1": case "on": return true; case "no": case "n": case "0": case "off": return false; default: throw new ArgumentException("source"); } } #region Type Conversions /// <summary> /// Determines the data type of a column in a statement /// </summary> /// <param name="stmt">The statement to retrieve information for</param> /// <param name="i">The column to retrieve type information on</param> |
︙ | ︙ | |||
753 754 755 756 757 758 759 | new SQLiteTypeNames("UNIQUEIDENTIFIER", DbType.Guid), new SQLiteTypeNames("MEMO", DbType.String), new SQLiteTypeNames("NOTE", DbType.String), new SQLiteTypeNames("SMALLINT", DbType.Int16), new SQLiteTypeNames("BIGINT", DbType.Int64), }; } | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | new SQLiteTypeNames("UNIQUEIDENTIFIER", DbType.Guid), new SQLiteTypeNames("MEMO", DbType.String), new SQLiteTypeNames("NOTE", DbType.String), new SQLiteTypeNames("SMALLINT", DbType.Int16), new SQLiteTypeNames("BIGINT", DbType.Int64), }; } /// <summary> /// SQLite has very limited types, and is inherently text-based. The first 5 types below represent the sum of all types SQLite /// understands. The DateTime extension to the spec is for internal use only. /// </summary> public enum TypeAffinity { /// <summary> /// Not used /// </summary> Uninitialized = 0, /// <summary> /// All integers in SQLite default to Int64 /// </summary> Int64 = 1, /// <summary> /// All floating point numbers in SQLite default to double /// </summary> Double = 2, /// <summary> /// The default data type of SQLite is text /// </summary> Text = 3, /// <summary> /// Typically blob types are only seen when returned from a function /// </summary> Blob = 4, /// <summary> /// Null types can be returned from functions /// </summary> Null = 5, /// <summary> /// Used internally by this provider /// </summary> DateTime = 10, /// <summary> /// Used internally /// </summary> None = 11, } /// <summary> /// This implementation of SQLite for ADO.NET can process date/time fields in databases in only one of three formats. Ticks, ISO8601 /// and JulianDay. /// </summary> /// <remarks> /// ISO8601 is more compatible, readable, fully-processable, but less accurate as it doesn't provide time down to fractions of a second. /// JulianDay is the numeric format the SQLite uses internally and is arguably the most compatible with 3rd party tools. It is /// not readable as text without post-processing. /// Ticks less compatible with 3rd party tools that query the database, and renders the DateTime field unreadable as text without post-processing. /// /// The preferred order of choosing a datetime format is JulianDay, ISO8601, and then Ticks. Ticks is mainly present for legacy /// code support. /// </remarks> public enum SQLiteDateFormats { /// <summary> /// Using ticks is not recommended and is not well supported with LINQ. /// </summary> Ticks = 0, /// <summary> /// The default format for this provider. /// </summary> ISO8601 = 1, /// <summary> /// JulianDay format, which is what SQLite uses internally /// </summary> JulianDay = 2 } /// <summary> /// This enum determines how SQLite treats its journal file. /// </summary> /// <remarks> /// By default SQLite will create and delete the journal file when needed during a transaction. /// However, for some computers running certain filesystem monitoring tools, the rapid /// creation and deletion of the journal file can cause those programs to fail, or to interfere with SQLite. /// /// If a program or virus scanner is interfering with SQLite's journal file, you may receive errors like "unable to open database file" /// when starting a transaction. If this is happening, you may want to change the default journal mode to Persist. /// </remarks> public enum SQLiteJournalModeEnum { /// <summary> /// The default mode, this causes SQLite to create and destroy the journal file as-needed. /// </summary> Delete = 0, /// <summary> /// When this is set, SQLite will keep the journal file even after a transaction has completed. It's contents will be erased, /// and the journal re-used as often as needed. If it is deleted, it will be recreated the next time it is needed. /// </summary> Persist = 1, /// <summary> /// This option disables the rollback journal entirely. Interrupted transactions or a program crash can cause database /// corruption in this mode! /// </summary> Off = 2 } /// <summary> /// Struct used internally to determine the datatype of a column in a resultset /// </summary> internal class SQLiteType { /// <summary> /// The DbType of the column, or DbType.Object if it cannot be determined /// </summary> internal DbType Type; /// <summary> /// The affinity of a column, used for expressions or when Type is DbType.Object /// </summary> internal TypeAffinity Affinity; } internal struct SQLiteTypeNames { internal SQLiteTypeNames(string newtypeName, DbType newdataType) { typeName = newtypeName; dataType = newdataType; } internal string typeName; internal DbType dataType; } } |
Changes to System.Data.SQLite/SQLiteDataAdapter.cs.
︙ | ︙ | |||
13 14 15 16 17 18 19 | using System.ComponentModel; /// <summary> /// SQLite implementation of DbDataAdapter. /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [DefaultEvent("RowUpdated")] | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | using System.ComponentModel; /// <summary> /// SQLite implementation of DbDataAdapter. /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [DefaultEvent("RowUpdated")] [ToolboxItem("SQLite.Designer.SQLiteDataAdapterToolboxItem, SQLite.Designer, Version=1.0.35.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139")] [Designer("Microsoft.VSDesigner.Data.VS.SqlDataAdapterDesigner, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] #endif public sealed class SQLiteDataAdapter : DbDataAdapter { private static object _updatingEventPH = new object(); private static object _updatedEventPH = new object(); |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteFunction.cs.
︙ | ︙ | |||
9 10 11 12 13 14 15 | { using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Globalization; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | { using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Globalization; /// <summary> /// This abstract class is designed to handle user-defined functions easily. An instance of the derived class is made for each /// connection to the database. /// </summary> /// <remarks> /// Although there is one instance of a class derived from SQLiteFunction per database connection, the derived class has no access /// to the underlying connection. This is necessary to deter implementers from thinking it would be a good idea to make database |
︙ | ︙ | |||
70 71 72 73 74 75 76 | /// be automatically freed for you (and Dispose() called if the item supports IDisposable) when the statement completes. /// </remarks> public abstract class SQLiteFunction : IDisposable { /// <summary> /// The base connection this function is attached to /// </summary> | | | < < < | > > > > > > > | 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 | /// be automatically freed for you (and Dispose() called if the item supports IDisposable) when the statement completes. /// </remarks> public abstract class SQLiteFunction : IDisposable { /// <summary> /// The base connection this function is attached to /// </summary> internal SQLiteBase _base; /// <summary> /// Internal array used to keep track of aggregate function context data /// </summary> private Dictionary<long, object> _contextDataList; /// <summary> /// Holds a reference to the callback function for user functions /// </summary> private SQLiteCallback _InvokeFunc; /// <summary> /// Holds a reference to the callbakc function for stepping in an aggregate function /// </summary> private SQLiteCallback _StepFunc; /// <summary> /// Holds a reference to the callback function for finalizing an aggregate function /// </summary> private SQLiteFinalCallback _FinalFunc; /// <summary> /// Holds a reference to the callback function for collation sequences /// </summary> private SQLiteCollation _CompareFunc; private SQLiteCollation _CompareFunc16; /// <summary> /// Current context of the current callback. Only valid during a callback /// </summary> internal IntPtr _context; private int _count = 1; /// <summary> /// This static list contains all the user-defined functions declared using the proper attributes. /// </summary> private static List<SQLiteFunctionAttribute> _registeredFunctions = new List<SQLiteFunctionAttribute>(); |
︙ | ︙ | |||
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | /// Internal scalar callback function, which wraps the raw context pointer and calls the virtual Invoke() method. /// </summary> /// <param name="context">A raw context pointer</param> /// <param name="nArgs">Number of arguments passed in</param> /// <param name="argsptr">A pointer to the array of arguments</param> internal void ScalarCallback(IntPtr context, int nArgs, IntPtr argsptr) { SetReturnValue(context, Invoke(ConvertParams(nArgs, argsptr))); } /// <summary> /// Internal collation sequence function, which wraps up the raw string pointers and executes the Compare() virtual function. /// </summary> /// <param name="len1">Length of the string pv1</param> /// <param name="ptr1">Pointer to the first string to compare</param> /// <param name="len2">Length of the string pv2</param> /// <param name="ptr2">Pointer to the second string to compare</param> /// <returns>Returns -1 if the first string is less than the second. 0 if they are equal, or 1 if the first string is greater /// than the second.</returns> | > > | > > | > > > | 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 | /// Internal scalar callback function, which wraps the raw context pointer and calls the virtual Invoke() method. /// </summary> /// <param name="context">A raw context pointer</param> /// <param name="nArgs">Number of arguments passed in</param> /// <param name="argsptr">A pointer to the array of arguments</param> internal void ScalarCallback(IntPtr context, int nArgs, IntPtr argsptr) { _context = context; SetReturnValue(context, Invoke(ConvertParams(nArgs, argsptr))); } /// <summary> /// Internal collation sequence function, which wraps up the raw string pointers and executes the Compare() virtual function. /// </summary> /// <param name="ptr">Not used</param> /// <param name="len1">Length of the string pv1</param> /// <param name="ptr1">Pointer to the first string to compare</param> /// <param name="len2">Length of the string pv2</param> /// <param name="ptr2">Pointer to the second string to compare</param> /// <returns>Returns -1 if the first string is less than the second. 0 if they are equal, or 1 if the first string is greater /// than the second.</returns> internal int CompareCallback(IntPtr ptr, int len1, IntPtr ptr1, int len2, IntPtr ptr2) { return Compare(SQLiteConvert.UTF8ToString(ptr1, len1), SQLiteConvert.UTF8ToString(ptr2, len2)); } internal int CompareCallback16(IntPtr ptr, int len1, IntPtr ptr1, int len2, IntPtr ptr2) { return Compare(SQLite3_UTF16.UTF16ToString(ptr1, len1), SQLite3_UTF16.UTF16ToString(ptr2, len2)); } /// <summary> /// The internal aggregate Step function callback, which wraps the raw context pointer and calls the virtual Step() method. /// </summary> /// <remarks> /// This function takes care of doing the lookups and getting the important information put together to call the Step() function. |
︙ | ︙ | |||
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | object obj = null; nAux = (long)_base.AggregateContext(context); if (n > 1) obj = _contextDataList[nAux]; try { Step(ConvertParams(nArgs, argsptr), n, ref obj); _contextDataList[nAux] = obj; } finally { _count++; } } /// <summary> /// An internal aggregate Final function callback, which wraps the context pointer and calls the virtual Final() method. /// </summary> /// <param name="context">A raw context pointer</param> | > < < | > | 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 | object obj = null; nAux = (long)_base.AggregateContext(context); if (n > 1) obj = _contextDataList[nAux]; try { _context = context; Step(ConvertParams(nArgs, argsptr), n, ref obj); _contextDataList[nAux] = obj; } finally { _count++; } } /// <summary> /// An internal aggregate Final function callback, which wraps the context pointer and calls the virtual Final() method. /// </summary> /// <param name="context">A raw context pointer</param> internal void FinalCallback(IntPtr context) { long n = (long)_base.AggregateContext(context); object obj = null; _count = 1; if (_contextDataList.ContainsKey(n)) { obj = _contextDataList[n]; _contextDataList.Remove(n); } _context = context; SetReturnValue(context, Final(obj)); IDisposable disp = obj as IDisposable; if (disp != null) disp.Dispose(); } /// <summary> |
︙ | ︙ | |||
419 420 421 422 423 424 425 | #if !PLATFORM_COMPACTFRAMEWORK [Security.Permissions.FileIOPermission(Security.Permissions.SecurityAction.Assert, AllFiles = Security.Permissions.FileIOPermissionAccess.PathDiscovery)] #endif static SQLiteFunction() { try { | < < | 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | #if !PLATFORM_COMPACTFRAMEWORK [Security.Permissions.FileIOPermission(Security.Permissions.SecurityAction.Assert, AllFiles = Security.Permissions.FileIOPermissionAccess.PathDiscovery)] #endif static SQLiteFunction() { try { #if !PLATFORM_COMPACTFRAMEWORK SQLiteFunctionAttribute at; System.Reflection.Assembly[] arAssemblies = System.AppDomain.CurrentDomain.GetAssemblies(); int w = arAssemblies.Length; System.Reflection.AssemblyName sqlite = System.Reflection.Assembly.GetCallingAssembly().GetName(); for (int n = 0; n < w; n++) |
︙ | ︙ | |||
508 509 510 511 512 513 514 | /// <summary> /// Called by SQLiteBase derived classes, this function binds all user-defined functions to a connection. /// It is done this way so that all user-defined functions will access the database using the same encoding scheme /// as the connection (UTF-8 or UTF-16). /// </summary> /// <remarks> | | | > | | > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > | > > > > | > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /// <summary> /// Called by SQLiteBase derived classes, this function binds all user-defined functions to a connection. /// It is done this way so that all user-defined functions will access the database using the same encoding scheme /// as the connection (UTF-8 or UTF-16). /// </summary> /// <remarks> /// The wrapper functions that interop with SQLite will create a unique cookie value, which internally is a pointer to /// all the wrapped callback functions. The interop function uses it to map CDecl callbacks to StdCall callbacks. /// </remarks> /// <param name="sqlbase">The base object on which the functions are to bind</param> /// <returns>Returns an array of functions which the connection object should retain until the connection is closed.</returns> internal static SQLiteFunction[] BindFunctions(SQLiteBase sqlbase) { SQLiteFunction f; List<SQLiteFunction> lFunctions = new List<SQLiteFunction>(); foreach (SQLiteFunctionAttribute pr in _registeredFunctions) { f = (SQLiteFunction)Activator.CreateInstance(pr._instanceType); f._base = sqlbase; f._InvokeFunc = (pr.FuncType == FunctionType.Scalar) ? new SQLiteCallback(f.ScalarCallback) : null; f._StepFunc = (pr.FuncType == FunctionType.Aggregate) ? new SQLiteCallback(f.StepCallback) : null; f._FinalFunc = (pr.FuncType == FunctionType.Aggregate) ? new SQLiteFinalCallback(f.FinalCallback) : null; f._CompareFunc = (pr.FuncType == FunctionType.Collation) ? new SQLiteCollation(f.CompareCallback) : null; f._CompareFunc16 = (pr.FuncType == FunctionType.Collation) ? new SQLiteCollation(f.CompareCallback16) : null; if (pr.FuncType != FunctionType.Collation) sqlbase.CreateFunction(pr.Name, pr.Arguments, (f is SQLiteFunctionEx), f._InvokeFunc, f._StepFunc, f._FinalFunc); else sqlbase.CreateCollation(pr.Name, f._CompareFunc, f._CompareFunc16); lFunctions.Add(f); } SQLiteFunction[] arFunctions = new SQLiteFunction[lFunctions.Count]; lFunctions.CopyTo(arFunctions, 0); return arFunctions; } } /// <summary> /// Extends SQLiteFunction and allows an inherited class to obtain the collating sequence associated with a function call. /// </summary> /// <remarks> /// User-defined functions can call the GetCollationSequence() method in this class and use it to compare strings and char arrays. /// </remarks> public class SQLiteFunctionEx : SQLiteFunction { /// <summary> /// Obtains the collating sequence in effect for the given function. /// </summary> /// <remarks> /// As an optimization, SQLite does not fill in this information when calling functions, unless the NeedCollationSequence /// boolean value is set to true in the SQLiteFunctionAttribute. /// </remarks> /// <returns></returns> protected CollationSequence GetCollationSequence() { return _base.GetCollationSequence(this, _context); } } /// <summary> /// The type of user-defined function to declare /// </summary> public enum FunctionType { /// <summary> /// Scalar functions are designed to be called and return a result immediately. Examples include ABS(), Upper(), Lower(), etc. /// </summary> Scalar = 0, /// <summary> /// Aggregate functions are designed to accumulate data until the end of a call and then return a result gleaned from the accumulated data. /// Examples include SUM(), COUNT(), AVG(), etc. /// </summary> Aggregate = 1, /// <summary> /// Collation sequences are used to sort textual data in a custom manner, and appear in an ORDER BY clause. Typically text in an ORDER BY is /// sorted using a straight case-insensitive comparison function. Custom collating sequences can be used to alter the behavior of text sorting /// in a user-defined manner. /// </summary> Collation = 2, } /// <summary> /// An internal callback delegate declaration. /// </summary> /// <param name="context">Raw context pointer for the user function</param> /// <param name="nArgs">Count of arguments to the function</param> /// <param name="argsptr">A pointer to the array of argument pointers</param> #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif internal delegate void SQLiteCallback(IntPtr context, int nArgs, IntPtr argsptr); /// <summary> /// An internal final callback delegate declaration. /// </summary> /// <param name="context">Raw context pointer for the user function</param> #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif internal delegate void SQLiteFinalCallback(IntPtr context); /// <summary> /// Internal callback delegate for implementing collation sequences /// </summary> /// <param name="puser">Not used</param> /// <param name="len1">Length of the string pv1</param> /// <param name="pv1">Pointer to the first string to compare</param> /// <param name="len2">Length of the string pv2</param> /// <param name="pv2">Pointer to the second string to compare</param> /// <returns>Returns -1 if the first string is less than the second. 0 if they are equal, or 1 if the first string is greater /// than the second.</returns> #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif internal delegate int SQLiteCollation(IntPtr puser, int len1, IntPtr pv1, int len2, IntPtr pv2); /// <summary> /// The type of collating sequence /// </summary> public enum CollationTypeEnum { /// <summary> /// The built-in BINARY collating sequence /// </summary> Binary = 1, /// <summary> /// The built-in NOCASE collating sequence /// </summary> NoCase = 2, /// <summary> /// The built-in REVERSE collating sequence /// </summary> Reverse = 3, /// <summary> /// A custom user-defined collating sequence /// </summary> Custom = 0, } /// <summary> /// The encoding type the collation sequence uses /// </summary> public enum CollationEncodingEnum { /// <summary> /// The collation sequence is UTF8 /// </summary> UTF8 = 1, /// <summary> /// The collation sequence is UTF16 little-endian /// </summary> UTF16LE = 2, /// <summary> /// The collation sequence is UTF16 big-endian /// </summary> UTF16BE = 3, } /// <summary> /// A struct describing the collating sequence a function is executing in /// </summary> public struct CollationSequence { /// <summary> /// The name of the collating sequence /// </summary> public string Name; /// <summary> /// The type of collating sequence /// </summary> public CollationTypeEnum Type; /// <summary> /// The text encoding of the collation sequence /// </summary> public CollationEncodingEnum Encoding; /// <summary> /// Context of the function that requested the collating sequence /// </summary> internal SQLiteFunction _func; /// <summary> /// Calls the base collating sequence to compare two strings /// </summary> /// <param name="s1">The first string to compare</param> /// <param name="s2">The second string to compare</param> /// <returns>-1 if s1 is less than s2, 0 if s1 is equal to s2, and 1 if s1 is greater than s2</returns> public int Compare(string s1, string s2) { return _func._base.ContextCollateCompare(Encoding, _func._context, s1, s2); } /// <summary> /// Calls the base collating sequence to compare two character arrays /// </summary> /// <param name="c1">The first array to compare</param> /// <param name="c2">The second array to compare</param> /// <returns>-1 if c1 is less than c2, 0 if c1 is equal to c2, and 1 if c1 is greater than c2</returns> public int Compare(char[] c1, char[] c2) { return _func._base.ContextCollateCompare(Encoding, _func._context, c1, c2); } } } |
Changes to System.Data.SQLite/SQLiteMetaDataCollectionNames.cs.
︙ | ︙ | |||
42 43 44 45 46 47 48 49 50 | /// Returns underlying column information on the given view /// </summary> public static readonly string ViewColumns = "ViewColumns"; /// <summary> /// Returns foreign key information for the given catalog /// </summary> public static readonly string ForeignKeys = "ForeignKeys"; } } | > > > > | 42 43 44 45 46 47 48 49 50 51 52 53 54 | /// Returns underlying column information on the given view /// </summary> public static readonly string ViewColumns = "ViewColumns"; /// <summary> /// Returns foreign key information for the given catalog /// </summary> public static readonly string ForeignKeys = "ForeignKeys"; /// <summary> /// Returns the triggers on the database /// </summary> public static readonly string Triggers = "Triggers"; } } |
Changes to System.Data.SQLite/SQLiteTransaction.cs.
︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | public sealed class SQLiteTransaction : DbTransaction { /// <summary> /// The connection to which this transaction is bound /// </summary> internal SQLiteConnection _cnn; internal long _version; // Matches the version of the connection /// <summary> /// Constructs the transaction object, binding it to the supplied connection /// </summary> /// <param name="connection">The connection to open a transaction on</param> /// <param name="deferredLock">TRUE to defer the writelock, or FALSE to lock immediately</param> internal SQLiteTransaction(SQLiteConnection connection, bool deferredLock) { _cnn = connection; _version = _cnn._version; if (_cnn._transactionLevel++ == 0) { try { using (SQLiteCommand cmd = _cnn.CreateCommand()) { | > > > | 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 | public sealed class SQLiteTransaction : DbTransaction { /// <summary> /// The connection to which this transaction is bound /// </summary> internal SQLiteConnection _cnn; internal long _version; // Matches the version of the connection private IsolationLevel _level; /// <summary> /// Constructs the transaction object, binding it to the supplied connection /// </summary> /// <param name="connection">The connection to open a transaction on</param> /// <param name="deferredLock">TRUE to defer the writelock, or FALSE to lock immediately</param> internal SQLiteTransaction(SQLiteConnection connection, bool deferredLock) { _cnn = connection; _version = _cnn._version; _level = (deferredLock == true) ? IsolationLevel.ReadCommitted : IsolationLevel.Serializable; if (_cnn._transactionLevel++ == 0) { try { using (SQLiteCommand cmd = _cnn.CreateCommand()) { |
︙ | ︙ | |||
106 107 108 109 110 111 112 | } /// <summary> /// Gets the isolation level of the transaction. SQLite only supports Serializable transactions. /// </summary> public override IsolationLevel IsolationLevel { | | | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | } /// <summary> /// Gets the isolation level of the transaction. SQLite only supports Serializable transactions. /// </summary> public override IsolationLevel IsolationLevel { get { return _level; } } /// <summary> /// Rolls back the active transaction. /// </summary> public override void Rollback() { |
︙ | ︙ |
Changes to System.Data.SQLite/System.Data.SQLite.
1 2 3 4 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | | | < < < < < < | < < < | | < < < > | > > > > > > > > > > > > > > > > | | > > | < > > < < > > > > > > > > < > > | | < < | < < | < < > > > > > > > | 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 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>9.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{AC139952-261A-4463-B6FA-AEBC25283A66}</ProjectGuid> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>System.Data.SQLite</RootNamespace> <AssemblyName>System.Data.SQLite</AssemblyName> <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> <SignAssembly>true</SignAssembly> <AssemblyOriginatorKeyFile>System.Data.SQLite.snk</AssemblyOriginatorKeyFile> <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> <FileUpgradeFlags> </FileUpgradeFlags> <OldToolsVersion>2.0</OldToolsVersion> <UpgradeBackupLocation> </UpgradeBackupLocation> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>..\bin\</OutputPath> <DefineConstants>TRACE;DEBUG;USE_INTEROP_DLL</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <DocumentationFile> </DocumentationFile> <GenerateSerializationAssemblies>off</GenerateSerializationAssemblies> <FileAlignment>512</FileAlignment> <AllowUnsafeBlocks>false</AllowUnsafeBlocks> <PlatformTarget>x86</PlatformTarget> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugSymbols>false</DebugSymbols> <OutputPath>bin\</OutputPath> <DefineConstants> </DefineConstants> <DebugType>none</DebugType> <PlatformTarget>AnyCPU</PlatformTarget> <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression> <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <ErrorReport>prompt</ErrorReport> <FileAlignment>512</FileAlignment> <DocumentationFile>..\bin\System.Data.SQLite.XML</DocumentationFile> <AllowUnsafeBlocks>false</AllowUnsafeBlocks> <Optimize>true</Optimize> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'StockDebug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <OutputPath>..\bin\ManagedOnly\</OutputPath> <DefineConstants>TRACE;DEBUG;USE_INTEROP_DLL;SQLITE_STANDARD</DefineConstants> <DebugType>full</DebugType> <PlatformTarget>x86</PlatformTarget> <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression> <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <ErrorReport>prompt</ErrorReport> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'StockRelease|AnyCPU' "> <OutputPath>..\bin\ManagedOnly\</OutputPath> <DocumentationFile>..\bin\ManagedOnly\System.Data.SQLite.XML</DocumentationFile> <Optimize>true</Optimize> <PlatformTarget>AnyCPU</PlatformTarget> <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression> <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <ErrorReport>prompt</ErrorReport> <DefineConstants>SQLITE_STANDARD</DefineConstants> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Transactions" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="AssemblyInfo.cs" /> <Compile Include="LINQ\SQLiteConnection_Linq.cs"> <SubType>Component</SubType> </Compile> <Compile Include="LINQ\SQLiteFactory_Linq.cs"> <SubType>Code</SubType> </Compile> <Compile Include="SQLite3.cs" /> <Compile Include="SQLite3_UTF16.cs" /> <Compile Include="SQLiteBase.cs" /> <Compile Include="SQLiteCommand.cs"> <SubType>Component</SubType> </Compile> <Compile Include="SQLiteCommandBuilder.cs"> <SubType>Component</SubType> </Compile> <Compile Include="SQLiteConnection.cs"> <SubType>Component</SubType> </Compile> <Compile Include="SQLiteConnectionPool.cs" /> <Compile Include="SQLiteConnectionStringBuilder.cs" /> <Compile Include="SQLiteConvert.cs" /> <Compile Include="SQLiteDataAdapter.cs"> <SubType>Component</SubType> </Compile> <Compile Include="SQLiteDataReader.cs" /> <Compile Include="SQLiteEnlistment.cs" /> <Compile Include="SQLiteException.cs" /> <Compile Include="SQLiteFactory.cs" /> <Compile Include="SQLiteFunction.cs" /> <Compile Include="SQLiteFunctionAttribute.cs" /> <Compile Include="SQLiteKeyReader.cs" /> <Compile Include="SQLiteMetaDataCollectionNames.cs" /> <Compile Include="SQLiteParameter.cs" /> |
︙ | ︙ | |||
119 120 121 122 123 124 125 126 127 128 | </ItemGroup> <ItemGroup> <None Include="DataTypes.xml" /> </ItemGroup> <ItemGroup> <None Include="MetaDataCollections.xml" /> </ItemGroup> <ItemGroup> <Folder Include="Properties\" /> </ItemGroup> | > > > > > | | | < < | | > | < > | < < | 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 | </ItemGroup> <ItemGroup> <None Include="DataTypes.xml" /> </ItemGroup> <ItemGroup> <None Include="MetaDataCollections.xml" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="SQLiteCommand.bmp" /> <EmbeddedResource Include="SQLiteConnection.bmp" /> <EmbeddedResource Include="SQLiteDataAdapter.bmp" /> </ItemGroup> <ItemGroup> <Folder Include="Properties\" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> <PropertyGroup> <PostBuildEvent>"$(SolutionDir)bin\tools\mergebin.exe" /p:"$(TargetPath)" >"$(SolutionDir)SQLite.Interop\merge_full.h"</PostBuildEvent> </PropertyGroup> </Project> |
Changes to System.Data.SQLite/UnsafeNativeMethods.cs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /******************************************************** * ADO.NET 2.0 Data Provider for SQLite Version 3.X * Written by Robert Simpson (robert@blackcastlesoft.com) * * Released to the public domain, use at your own risk! ********************************************************/ namespace System.Data.SQLite { using System; using System.Security; using System.Runtime.InteropServices; #if PLATFORM_COMPACTFRAMEWORK internal abstract class CriticalHandle : IDisposable { private bool _isClosed; protected IntPtr handle; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /******************************************************** * ADO.NET 2.0 Data Provider for SQLite Version 3.X * Written by Robert Simpson (robert@blackcastlesoft.com) * * Released to the public domain, use at your own risk! ********************************************************/ namespace System.Data.SQLite { using System; using System.Security; using System.Runtime.InteropServices; #if !PLATFORM_COMPACTFRAMEWORK [SuppressUnmanagedCodeSecurity] #endif internal static class UnsafeNativeMethods { #if !SQLITE_STANDARD #if !USE_INTEROP_DLL private const string SQLITE_DLL = "System.Data.SQLite.DLL"; #else private const string SQLITE_DLL = "SQLite.Interop.DLL"; #endif #else private const string SQLITE_DLL = "sqlite3"; #endif // This section uses interop calls that also fetch text length to optimize conversion. // When using the standard dll, we can replace these calls with normal sqlite calls and do unoptimized conversions instead afterwards #region interop added textlength calls #if !SQLITE_STANDARD [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_bind_parameter_name_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_database_name_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_database_name16_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_decltype_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_decltype16_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_name_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_name16_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_origin_name_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_origin_name16_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_table_name_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_table_name16_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_text_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_text16_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_errmsg_interop(IntPtr db, out int len); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_prepare_interop(IntPtr db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain, out int nRemain); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_table_column_metadata_interop(IntPtr db, byte[] dbName, byte[] tblName, byte[] colName, out IntPtr ptrDataType, out IntPtr ptrCollSeq, out int notNull, out int primaryKey, out int autoInc, out int dtLen, out int csLen); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_value_text_interop(IntPtr p, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_value_text16_interop(IntPtr p, out int len); #endif #endregion // These functions add existing functionality on top of SQLite and require a little effort to // get working when using the standard SQLite library. #region interop added functionality #if !SQLITE_STANDARD [DllImport(SQLITE_DLL)] internal static extern int sqlite3_close_interop(IntPtr db); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_create_function_interop(IntPtr db, byte[] strName, int nArgs, int nType, IntPtr pvUser, SQLiteCallback func, SQLiteCallback fstep, SQLiteFinalCallback ffinal, int needCollSeq); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_finalize_interop(IntPtr stmt); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_open_interop(byte[] utf8Filename, int flags, out IntPtr db); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_open16_interop(byte[] utf8Filename, int flags, out IntPtr db); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_reset_interop(IntPtr stmt); #endif #endregion // The standard api call equivalents of the above interop calls #region standard versions of interop functions #if SQLITE_STANDARD #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_close(IntPtr db); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_create_function(IntPtr db, byte[] strName, int nArgs, int nType, IntPtr pvUser, SQLiteCallback func, SQLiteCallback fstep, SQLiteFinalCallback ffinal); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_finalize(IntPtr stmt); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_open_v2(byte[] utf8Filename, out IntPtr db, int flags, IntPtr vfs); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)] #else [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] #endif internal static extern int sqlite3_open16(string fileName, out IntPtr db); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_reset(IntPtr stmt); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_bind_parameter_name(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_database_name(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_database_name16(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_decltype(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_decltype16(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_name(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_name16(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_origin_name(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_origin_name16(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_table_name(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_table_name16(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_text(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_text16(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_errmsg(IntPtr db); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_prepare(IntPtr db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_table_column_metadata(IntPtr db, byte[] dbName, byte[] tblName, byte[] colName, out IntPtr ptrDataType, out IntPtr ptrCollSeq, out int notNull, out int primaryKey, out int autoInc); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_value_text(IntPtr p); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_value_text16(IntPtr p); #endif #endregion // These functions are custom and have no equivalent standard library method. // All of them are "nice to haves" and not necessarily "need to haves". #region no equivalent standard method #if !SQLITE_STANDARD [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_context_collseq(IntPtr context, out int type, out int enc, out int len); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_context_collcompare(IntPtr context, byte[] p1, int p1len, byte[] p2, int p2len); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_cursor_rowid(IntPtr stmt, int cursor, out long rowid); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_index_column_info_interop(IntPtr db, byte[] catalog, byte[] IndexName, byte[] ColumnName, out int sortOrder, out int onError, out IntPtr Collation, out int colllen); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_resetall_interop(IntPtr db); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_table_cursor(IntPtr stmt, int db, int tableRootPage); #endif #endregion // These are obsolete and will be removed in the future #region windows ntfs filesystem only #if !SQLITE_STANDARD [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern int sqlite3_compressfile(string fileName); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern int sqlite3_decompressfile(string fileName); #endif #endregion // Standard API calls global across versions. There are a few instances of interop calls // scattered in here, but they are only active when PLATFORM_COMPACTFRAMEWORK is declared. #region standard sqlite api calls #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern void sqlite3_sleep(uint dwMilliseconds); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_libversion(); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern void sqlite3_interrupt(IntPtr db); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_changes(IntPtr db); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_busy_timeout(IntPtr db, int ms); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_bind_blob(IntPtr stmt, int index, Byte[] value, int nSize, IntPtr nTransient); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] internal static extern int sqlite3_bind_double(IntPtr stmt, int index, double value); #else [DllImport(SQLITE_DLL)] internal static extern int sqlite3_bind_double_interop(IntPtr stmt, int index, ref double value); #endif #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_bind_int(IntPtr stmt, int index, int value); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] internal static extern int sqlite3_bind_int64(IntPtr stmt, int index, long value); #else [DllImport(SQLITE_DLL)] internal static extern int sqlite3_bind_int64_interop(IntPtr stmt, int index, ref long value); #endif #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_bind_null(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_bind_text(IntPtr stmt, int index, byte[] value, int nlen, IntPtr pvReserved); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_bind_parameter_count(IntPtr stmt); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_bind_parameter_index(IntPtr stmt, byte[] strName); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_column_count(IntPtr stmt); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_step(IntPtr stmt); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] internal static extern double sqlite3_column_double(IntPtr stmt, int index); #else [DllImport(SQLITE_DLL)] internal static extern void sqlite3_column_double_interop(IntPtr stmt, int index, out double value); #endif #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_column_int(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] internal static extern long sqlite3_column_int64(IntPtr stmt, int index); #else [DllImport(SQLITE_DLL)] internal static extern void sqlite3_column_int64_interop(IntPtr stmt, int index, out long value); #endif #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_blob(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_column_bytes(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern TypeAffinity sqlite3_column_type(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_create_collation(IntPtr db, byte[] strName, int nType, IntPtr pvUser, SQLiteCollation func); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_aggregate_count(IntPtr context); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_value_blob(IntPtr p); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_value_bytes(IntPtr p); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] internal static extern double sqlite3_value_double(IntPtr p); #else [DllImport(SQLITE_DLL)] internal static extern void sqlite3_value_double_interop(IntPtr p, out double value); #endif #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_value_int(IntPtr p); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] internal static extern long sqlite3_value_int64(IntPtr p); #else [DllImport(SQLITE_DLL)] internal static extern void sqlite3_value_int64_interop(IntPtr p, out Int64 value); #endif #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern TypeAffinity sqlite3_value_type(IntPtr p); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern void sqlite3_result_blob(IntPtr context, byte[] value, int nSize, IntPtr pvReserved); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] internal static extern void sqlite3_result_double(IntPtr context, double value); #else [DllImport(SQLITE_DLL)] internal static extern void sqlite3_result_double_interop(IntPtr context, ref double value); #endif #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern void sqlite3_result_error(IntPtr context, byte[] strErr, int nLen); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern void sqlite3_result_int(IntPtr context, int value); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] internal static extern void sqlite3_result_int64(IntPtr context, long value); #else [DllImport(SQLITE_DLL)] internal static extern void sqlite3_result_int64_interop(IntPtr context, ref Int64 value); #endif #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern void sqlite3_result_null(IntPtr context); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern void sqlite3_result_text(IntPtr context, byte[] value, int nLen, IntPtr pvReserved); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_aggregate_context(IntPtr context, int nBytes); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)] #else [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] #endif internal static extern int sqlite3_bind_text16(IntPtr stmt, int index, string value, int nlen, IntPtr pvReserved); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)] #else [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] #endif internal static extern void sqlite3_result_error16(IntPtr context, string strName, int nLen); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)] #else [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] #endif internal static extern void sqlite3_result_text16(IntPtr context, string strName, int nLen, IntPtr pvReserved); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_key(IntPtr db, byte[] key, int keylen); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_rekey(IntPtr db, byte[] key, int keylen); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_update_hook(IntPtr db, SQLiteUpdateCallback func, IntPtr pvUser); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_commit_hook(IntPtr db, SQLiteCommitCallback func, IntPtr pvUser); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_rollback_hook(IntPtr db, SQLiteRollbackCallback func, IntPtr pvUser); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_db_handle(IntPtr stmt); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_next_stmt(IntPtr db, IntPtr stmt); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_exec(IntPtr db, byte[] strSql, IntPtr pvCallback, IntPtr pvParam, out IntPtr errMsg); #endregion } #if PLATFORM_COMPACTFRAMEWORK internal abstract class CriticalHandle : IDisposable { private bool _isClosed; protected IntPtr handle; |
︙ | ︙ | |||
105 106 107 108 109 110 111 | internal SQLiteConnectionHandle() : base(IntPtr.Zero) { } protected override bool ReleaseHandle() { | > > | > > > > | 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | internal SQLiteConnectionHandle() : base(IntPtr.Zero) { } protected override bool ReleaseHandle() { try { SQLiteBase.CloseConnection(this); } catch (SQLiteException) { } return true; } public override bool IsInvalid { get { return (handle == IntPtr.Zero); } } |
︙ | ︙ | |||
141 142 143 144 145 146 147 | internal SQLiteStatementHandle() : base(IntPtr.Zero) { } protected override bool ReleaseHandle() { | < < < | < | < < < | < < < < < < < | | < | < | < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 | internal SQLiteStatementHandle() : base(IntPtr.Zero) { } protected override bool ReleaseHandle() { try { SQLiteBase.FinalizeStatement(this); } catch (SQLiteException) { } return true; } public override bool IsInvalid { get { return (handle == IntPtr.Zero); } } } } |
Changes to readme.htm.
1 2 3 4 5 6 7 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> ADO.NET 2.0 SQLite Data Provider<br> | | | > | 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 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> ADO.NET 2.0 SQLite Data Provider<br> Version 1.0.55.0 August 6, 2008<br> Using SQLite 3.6.1<br> Written by Robert Simpson (<a href="mailto:robert@blackcastlesoft.com">robert@blackcastlesoft.com</a>)<br> Released to the public domain, use at your own risk!<br> Official provider website: <a href="http://sqlite.phxsoftware.com">http://sqlite.phxsoftware.com</a><br /> <br> The latest version can be downloaded <a href="http://sourceforge.net/projects/sqlite-dotnet2"> here</a> <br> <br> <b></b> <h2> <b>Features:</b><br> </h2> <UL> <LI> Written from scratch on VS2008 specifically for ADO.NET 2.0, implementing all the base classes and features recently introduced in the framework, including automatic transaction enlistment.<li>Supports the Full and Compact .NET Framework, as well as native C/C++ development. 100% binary compatible with the original sqlite3.dll.</li> <li>Full Entity Framework support (ADO.NET 3.5 SP1)</li> <LI> On the Compact Framework, it is faster than Sql Server Mobile. SQLite's installed size is a fraction of Sql Mobile's. It uses less memory at runtime, runs queries faster, and has a smaller database file size as well. <li>Encrypted database support. Encrypted databases are fully encrypted and support both binary and cleartext password types.</li> <LI> Visual Studio 2005/2008 Design-Time Support, works with all versions of VS2005/2008, |
︙ | ︙ | |||
116 117 118 119 120 121 122 123 124 125 126 127 128 129 | <p> The core sqlite engine is compiled directly from the unmodified source code available at the sqlite.org website. Several additional pieces are compiled on top of it to extend its functionality, but the core engine's source is not changed.</p> <p></p> <p> <b>Version History</b></p> <p><b>1.0.54.0 - July 25, 2008</b></p> <ul> <li>Fixed the setup project, which somehow "forgot" to include all the binaries in the 53 release.</li> <li>Fixed a crash in the table designer when creating a new table and tabbing past the "Allow Nulls" cell in the grid while creating a new column.</li> <li>Fixed a mostly-benign bug in SQLiteDataReader's GetEnumerator, which failed to | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | <p> The core sqlite engine is compiled directly from the unmodified source code available at the sqlite.org website. Several additional pieces are compiled on top of it to extend its functionality, but the core engine's source is not changed.</p> <p></p> <p> <b>Version History</b></p> <p><b>1.0.55.0 - August 6, 2008</b></p> <ul> <li>Code merge with SQLite 3.6.1</li> <li>Added support for the user-contributed extension-functions at <a href="http://www.sqlite.org/contrib">http://www.sqlite.org/contrib</a>. Feel free to override any of them with your own implementation. The new functions are: <i>acos, asin, atan, atn2, atan2, acosh, asinh, atanh, difference, degrees, radians, cos, sin, tan, cot, cosh, sinh, tanh, coth, exp, log, log10, power, sign, sqrt, square, ceil, floor, pi, replicate, charindex, leftstr, rightstr, reverse, proper, padl, padr, padc, strfilter,</i> and aggregates <i>stdev, variance, mode, median, lower_quartile, upper_quartile.</i></li> <li>Moved the last_rows_affected() function to the C extension library.</li> <li>Added a new class, SQLiteFunctionEx which extends SQLiteFunction and adds the ability for a user-defined function to get the collating sequence during the Invoke/Step methods. User-defined functions can use the collating sequence as a helper to compare values.</li> <li>When registering user-defined collation sequences and functions, the provider will now register both a UTF8 and a UTF16 version instead of just UTF8.</li> <li>Revamped connection pooling and added static ClearPool() and ClearAllPools() functions to SQLiteConnection. Behavior of the pool and its clearing mechanics match SqlClient.</li> <li>Fixed connections going to the pool so that any unfinalized lingering commands from un-collected datareaders are automatically reset and any lurking transactions made on the connection are rolled back.</li> <li>Transaction isolation levels are now partially supported. Serializable is the default, which obtains read/write locks immediately -- this is compatible with previous releases of the provider. Unspecified will default to whatever the default isolation mode is set to, and ReadCommitted will cause a deferred lock to be obtained. No other values are legal.</li> <li>Revamped the test.exe program. It's now an interactive GUI application. Easier for me to add tests now.</li> <li>Tweaks to the VS designer package and installer.</li> <li>More adjustments to the internal SQLite3.Prepare() method to account for both kinds of lock errors when retrying.</li> <li>Stripped a lot of unnecessary interop() calls and replaced with base sqlite calls. Revamped most of UnsafeNativeMethods to make it easier to port the code.</li> <li>Rerigged internal callbacks for userdef functions and other native to managed callbacks. More portable this way.</li> <li>Source can now can be compiled with the SQLITE_STANDARD preprocessor symbol to force the wrapper to use the stock sqlite3 library. Some functionality is missing, but its minimal. None of the precompiled binaries are compiled using this setting, but its useful for testing portability.</li> <li>Added "boolean" and a couple other missing datatypes to the "DataTypes" schema xml file. Used by the VS designer when displaying tables and querying.</li> <li>Added a new connection string option "Read Only". When set to True, the database will be opened in read-only mode.</li> <li>Added a new connection string option "Max Pool Size" to set the maximum size of the connection pool for a given db file connection.</li> <li>Added a new connection string option "Default IsolationLevel" to set the default isolation level of transactions. Possible values are Serializable and ReadCommitted.</li> <li>Added a new connection string option "URI" as an optional parameter for compatibility with other ports of the provider.</li> </ul> <p><b>1.0.54.0 - July 25, 2008</b></p> <ul> <li>Fixed the setup project, which somehow "forgot" to include all the binaries in the 53 release.</li> <li>Fixed a crash in the table designer when creating a new table and tabbing past the "Allow Nulls" cell in the grid while creating a new column.</li> <li>Fixed a mostly-benign bug in SQLiteDataReader's GetEnumerator, which failed to |
︙ | ︙ |
Changes to test/Program.cs.
1 2 3 4 5 6 7 8 9 10 11 12 | using System; using System.Data; using System.Text; using System.Data.Common; using System.Data.SQLite; using System.Threading; using System.Transactions; namespace test { class Program { | > | < < | < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | using System; using System.Data; using System.Text; using System.Data.Common; using System.Data.SQLite; using System.Threading; using System.Transactions; using System.Windows.Forms; namespace test { class Program { static void Main() { Application.Run(new TestCasesDialog()); } static void cnn_RollBack(object sender, EventArgs e) { } static void cnn_Commit(object sender, CommitEventArgs e) |
︙ | ︙ |
Changes to test/TestCases.cs.
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 | using System; using System.Data.Common; using System.Data; using System.Data.SQLite; using System.Transactions; namespace test { /// <summary> /// Scalar user-defined function. In this example, the same class is declared twice with /// different function names to demonstrate how to use alias names for user-defined functions. /// </summary> [SQLiteFunction(Name = "Foo", Arguments = 2, FuncType = FunctionType.Scalar)] [SQLiteFunction(Name = "TestFunc", Arguments = 2, FuncType = FunctionType.Scalar)] class TestFunc : SQLiteFunction { public override object Invoke(object[] args) { if (args[0].GetType() != typeof(int)) return args[0]; int Param1 = Convert.ToInt32(args[0]); // First parameter int Param2 = Convert.ToInt32(args[1]); // Second parameter return Param1 + Param2; } } /// <summary> /// Aggregate user-defined function. Arguments = -1 means any number of arguments is acceptable /// </summary> [SQLiteFunction(Name = "MyCount", Arguments = -1, FuncType = FunctionType.Aggregate)] class MyCount : SQLiteFunction { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 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 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 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 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 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 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 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 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 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 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 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 | using System; using System.Data.Common; using System.Data; using System.Data.SQLite; using System.Transactions; using System.Collections.Generic; using System.Text; namespace test { internal class TestCases : TestCaseBase { internal TestCases(DbProviderFactory factory, string connectionString) : base(factory, connectionString) { } /// <summary> /// Inserts binary data into the database using a named parameter /// </summary> internal void BinaryInsert() { using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "INSERT INTO TestCase(Field6) VALUES(@bin)"; DbParameter Field6 = cmd.CreateParameter(); byte[] b = new byte[4000]; b[0] = 1; b[100] = 2; b[1000] = 3; b[2000] = 4; b[3000] = 5; Field6.ParameterName = "@bin"; Field6.Value = b; cmd.Parameters.Add(Field6); cmd.ExecuteNonQuery(); } } internal void CheckLocked() { // Lets make sure the database isn't locked. If it is, we've failed. using (DbConnection newcnn = ((ICloneable)_cnn).Clone() as DbConnection) using (DbCommand cmd = newcnn.CreateCommand()) { if (newcnn.State != ConnectionState.Open) newcnn.Open(); cmd.CommandText = "INSERT INTO TestCase (Field1) SELECT 1 WHERE 1 = 2"; cmd.ExecuteNonQuery(); } } internal void CheckSQLite() { if (_fact.GetType().Name.IndexOf("SQLite", StringComparison.OrdinalIgnoreCase) == -1) throw new InconclusiveException("Not a SQLite database"); } [Test(Sequence = 1)] internal void FunctionWithCollation() { using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "SELECT CHARINDEX('pat', 'thepat'), CHARINDEX('pat', 'THEPAT'), CHARINDEX('pat' COLLATE NOCASE, 'THEPAT' COLLATE NOCASE)"; using (DbDataReader reader = cmd.ExecuteReader()) { reader.Read(); if (reader.GetInt64(0) != reader.GetInt64(2) || reader.GetInt64(1) != 0 || reader.GetInt64(0) != 4) throw new Exception("CharIndex returned wrong results!"); } } } [Test(Sequence = 2)] internal void FunctionWithCollation2() { using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "SELECT CASETEST('pat', 'pat'), CASETEST('pat', 'PAT'), CASETEST('pat' COLLATE NOCASE, 'PAT' COLLATE NOCASE), CASETEST('pat' COLLATE MYSEQUENCE, 'PAT' COLLATE MYSEQUENCE), CASETEST('tap', 'TAP' COLLATE NOCASE)"; using (DbDataReader reader = cmd.ExecuteReader()) { reader.Read(); if (reader.GetInt64(0) != reader.GetInt64(2) || reader.GetInt64(1) != 1 || reader.GetInt64(0) != 0) throw new Exception("CharIndex returned wrong results!"); } } } /// <summary> /// Make sure our implementation of ClearPool() behaves exactly as the SqlClient version is documented to behave. /// </summary> [Test(Sequence=90)] internal void ClearPoolTest() { CheckSQLite(); object value; if (_cnnstring.TryGetValue("Pooling", out value) == false) throw new Exception("Pooling not present in connection string"); if ((bool)value == false) throw new InconclusiveException("Pooling not enabled in the connection string"); string sql = "CREATE TEMP TABLE clearpool(id int primary key);"; using (DbCommand cmd = _cnn.CreateCommand()) { // Create a temp table in the main connection so we can confirm our new connections are using true new connections cmd.CommandText = sql; cmd.ExecuteNonQuery(); } for (int n = 0; n < 10; n++) { using (DbConnection newcnn = ((ICloneable)_cnn).Clone() as DbConnection) { if (newcnn.State != ConnectionState.Open) newcnn.Open(); using (DbCommand cmd = newcnn.CreateCommand()) { // If the pool is properly implemented and the pooled connection properly destroyed, this command will succeed. // If the new connection was obtained from the pool even after we cleared it, then this table will already exist // and the test fails. cmd.CommandText = sql; cmd.ExecuteNonQuery(); } // Try and clear the pool associated with this file newcnn.GetType().InvokeMember("ClearPool", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public, null, null, new object[] { newcnn }); // At this point when the connection is destroyed, it should not be returned to the pool, but instead disposed. } } } /// <summary> /// This tests ClearAllPools() functionality. Makes sure that the pool is working properly and clearing properly. /// </summary> [Test(Sequence = 100)] internal void ClearAllPoolsTest() { CheckSQLite(); object value; if (_cnnstring.TryGetValue("Pooling", out value) == false) throw new Exception("Pooling not present in connection string"); if ((bool)value == false) throw new InconclusiveException("Pooling not enabled in the connection string"); string sql = "CREATE TEMP TABLE IF NOT EXISTS clearpool(id int primary key);"; _cnn.GetType().InvokeMember("ClearAllPools", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public, null, null, null); DbConnection[] arr = new DbConnection[10]; try { // Create 10 connections and create temporary tables on them for (int n = 0; n < 10; n++) { arr[n] = ((ICloneable)_cnn).Clone() as DbConnection; if (arr[n].State != ConnectionState.Open) arr[n].Open(); using (DbCommand cmd = arr[n].CreateCommand()) { cmd.CommandText = sql; cmd.ExecuteNonQuery(); cmd.CommandText = String.Format("INSERT INTO clearpool (id) VALUES({0})", n); cmd.ExecuteNonQuery(); } switch (n) { case 2: // Put this one back into the pool arr[n].Dispose(); arr[n] = null; break; case 4: // Clear all the pools _cnn.GetType().InvokeMember("ClearAllPools", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public, null, null, null); break; } } // Now close all the connections. Only the last 5 should go into the pool for (int n = 0; n < 10; n++) { if (arr[n] != null) { arr[n].Dispose(); arr[n] = null; } } // Open 10 connections. They should either have a clearpool containing an id of 5 or greater, // or should have no clearpool table at all. for (int n = 0; n < 10; n++) { arr[n] = ((ICloneable)_cnn).Clone() as DbConnection; if (arr[n].State != ConnectionState.Open) arr[n].Open(); using (DbCommand cmd = arr[n].CreateCommand()) { cmd.CommandText = sql; cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT [id] FROM clearpool"; object o = cmd.ExecuteScalar(); if (o == null || o == DBNull.Value) continue; // No data in the table at all, which means we must've just created it -- connection wasn't part of the pool if (Convert.ToInt32(o) < 5) throw new Exception("Unexpected data returned from table!"); } } // Clear all the pools _cnn.GetType().InvokeMember("ClearAllPools", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public, null, null, null); } finally { // Close all the connections for (int n = 0; n < 10; n++) { if (arr[n] != null) { arr[n].Dispose(); arr[n] = null; } } // Clear all the pools _cnn.GetType().InvokeMember("ClearAllPools", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public, null, null, null); } } [Test(Sequence = 50)] internal void CoersionTest() { using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "SELECT Field1, Field2, [Fiëld3], [Fiæld4], Field5, 'A', 1, 1 + 1, 3.14159 FROM TestCase"; using (DbDataReader rd = cmd.ExecuteReader()) { if (rd.Read()) { object Field1 = rd.GetInt32(0); object Field2 = rd.GetDouble(1); object Field3 = rd.GetString(2); object Field4 = rd.GetString(3).TrimEnd(); object Field5 = rd.GetDateTime(4); // The next statement should cause an exception try { Field1 = rd.GetString(0); throw new Exception("Should have failed type checking!"); } catch (InvalidCastException) { } try { Field2 = rd.GetString(1); throw new Exception("Should have failed type checking!"); } catch (InvalidCastException) { } Field3 = rd.GetString(2); Field4 = rd.GetString(3); Field5 = rd.GetString(4); Field1 = rd.GetInt32(0); try { Field2 = rd.GetInt32(1); throw new Exception("Should have failed type checking!"); } catch (InvalidCastException) { } try { Field3 = rd.GetInt32(2); throw new Exception("Should have failed type checking!"); } catch (InvalidCastException) { } try { Field4 = rd.GetInt32(3); throw new Exception("Should have failed type checking!"); } catch (InvalidCastException) { } try { Field5 = rd.GetInt32(4); throw new Exception("Should have failed type checking!"); } catch (InvalidCastException) { } Field1 = rd.GetDecimal(0); Field2 = rd.GetDecimal(1); try { Field3 = rd.GetDecimal(2); throw new Exception("Should have failed type checking!"); } catch (InvalidCastException) { } try { Field4 = rd.GetDecimal(3); throw new Exception("Should have failed type checking!"); } catch (InvalidCastException) { } try { Field5 = rd.GetDecimal(4); throw new Exception("Should have failed type checking!"); } catch (InvalidCastException) { } } else throw new Exception("No data in table"); } } } [Test(Sequence = 10)] internal void CreateTable() { DropTables(false); using (DbCommand cmd = _cnn.CreateCommand()) { if (_fact.GetType().Name.IndexOf("SQLite", StringComparison.OrdinalIgnoreCase) == -1) cmd.CommandText = "CREATE TABLE TestCase (ID bigint primary key identity, Field1 bigint, Field2 Float, [Fiëld3] VARCHAR(50), [Fiæld4] CHAR(10), Field5 DateTime, Field6 Image)"; else cmd.CommandText = "CREATE TABLE TestCase (ID integer primary key autoincrement, Field1 int, Field2 Float, [Fiëld3] VARCHAR(50), [Fiæld4] CHAR(10), Field5 DateTime, Field6 Image)"; cmd.ExecuteNonQuery(); } } [Test(Sequence = 1100)] internal string DataAdapterTest() { return DataAdapter(false); } [Test(Sequence = 1200)] internal string DataAdapterWithIdentityFetch() { return DataAdapter(true); } /// <summary> /// Utilizes the SQLiteCommandBuilder, /// which in turn utilizes SQLiteDataReader's GetSchemaTable() functionality /// This insert is slow because it must raise callbacks before and after every update. /// For a fast update, see the FastInsertMany function beneath this one /// </summary> internal string DataAdapter(bool bWithIdentity) { StringBuilder builder = new StringBuilder(); using (DbTransaction dbTrans = _cnn.BeginTransaction()) { using (DbDataAdapter adp = _fact.CreateDataAdapter()) { using (DbCommand cmd = _cnn.CreateCommand()) { cmd.Transaction = dbTrans; cmd.CommandText = "SELECT * FROM TestCase WHERE 1 = 2"; adp.SelectCommand = cmd; using (DbCommandBuilder bld = _fact.CreateCommandBuilder()) { bld.DataAdapter = adp; using (adp.InsertCommand = (DbCommand)((ICloneable)bld.GetInsertCommand()).Clone()) { if (bWithIdentity) { adp.InsertCommand.CommandText += ";SELECT last_insert_rowid() AS [ID]"; adp.InsertCommand.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord; } bld.DataAdapter = null; using (DataTable tbl = new DataTable()) { adp.Fill(tbl); for (int n = 0; n < 10000; n++) { DataRow row = tbl.NewRow(); row[1] = n + (50000 * ((bWithIdentity == true) ? 2 : 1)); tbl.Rows.Add(row); } //Console.WriteLine(String.Format(" Inserting using CommandBuilder and DataAdapter\r\n ->{0} (10,000 rows) ...", (bWithIdentity == true) ? "(with identity fetch)" : "")); int dtStart = Environment.TickCount; adp.Update(tbl); int dtEnd = Environment.TickCount; dtEnd -= dtStart; builder.AppendFormat("Insert Ends in {0} ms ... ", (dtEnd)); dtStart = Environment.TickCount; dbTrans.Commit(); dtEnd = Environment.TickCount; dtEnd -= dtStart; builder.AppendFormat("Commits in {0} ms", (dtEnd)); if (bWithIdentity) { using (DataTable tbl2 = new DataTable()) { adp.SelectCommand.CommandText = "SELECT * FROM TestCase WHERE Field1 BETWEEN 100000 AND 199999 ORDER BY Field1"; adp.Fill(tbl2); if (tbl2.Rows.Count != tbl.Rows.Count) throw new Exception("Selected data doesn't match updated data!"); for (int n = 0; n < tbl.Rows.Count; n++) { if (tbl.Rows[n][0].Equals(tbl2.Rows[n][0]) == false) throw new Exception("Fetched identity doesn't match selected identity!"); } } } } } } } } } return builder.ToString(); } /// <summary> /// Make sure a datareader can run even if the parent command is disposed, and that the connection is closed /// by the datareader when it is finished. /// </summary> [Test] internal void DataReaderCleanup() { DbConnection newcnn = ((ICloneable)_cnn).Clone() as DbConnection; DbCommand cmd = newcnn.CreateCommand(); try { if (newcnn.State != ConnectionState.Open) newcnn.Open(); cmd.CommandText = "SELECT 1, 2, 3"; using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { cmd.Dispose(); // Dispose of the command while an open reader is active ... should still be able to read try { reader.Read(); } catch { throw new Exception("Unable to read from a DataReader!"); } if (reader.GetInt32(0) != 1 || reader.GetInt32(1) != 2 || reader.GetInt32(2) != 3) throw new Exception("Unexpected return values from reader!"); reader.Close(); // Close the reader, and check if the connection is closed if (newcnn.State != ConnectionState.Closed) throw new Exception("DataReader failed to cleanup!"); } } finally { cmd.Dispose(); newcnn.Dispose(); } } [Test] internal void DataTypeTest() { DateTime now = DateTime.Now; using (DbCommand cmd = _cnn.CreateCommand()) { if (_fact.GetType().Name.IndexOf("SQLite", StringComparison.OrdinalIgnoreCase) == -1) cmd.CommandText = "create table datatypetest(id bigint identity primary key, myvalue sql_variant, datetimevalue datetime, decimalvalue decimal)"; else cmd.CommandText = "create table datatypetest(id integer primary key, myvalue sql_variant, datetimevalue datetime, decimalvalue decimal)"; cmd.ExecuteNonQuery(); cmd.CommandText = "insert into datatypetest(myvalue, datetimevalue, decimalvalue) values(@p1,@p2,@p3)"; DbParameter p1 = cmd.CreateParameter(); DbParameter p2 = cmd.CreateParameter(); DbParameter p3 = cmd.CreateParameter(); cmd.Parameters.Add(p1); cmd.Parameters.Add(p2); cmd.Parameters.Add(p3); p1.ParameterName = "@p1"; p2.ParameterName = "@p2"; p3.ParameterName = "@p3"; p1.Value = 1; p2.Value = new DateTime(1753, 1, 1); p3.Value = (Decimal)1.05; cmd.ExecuteNonQuery(); p1.ResetDbType(); p2.ResetDbType(); p3.ResetDbType(); p1.Value = "One"; p2.Value = "2001-01-01"; p3.Value = (Decimal)1.0; cmd.ExecuteNonQuery(); p1.ResetDbType(); p2.ResetDbType(); p3.ResetDbType(); p1.Value = 1.01; p2.Value = now; p3.Value = (Decimal)9.91; cmd.ExecuteNonQuery(); cmd.CommandText = "select myvalue, datetimevalue, decimalvalue from datatypetest"; cmd.Parameters.Clear(); using (DbDataReader reader = cmd.ExecuteReader()) { for (int n = 0; n < 3; n++) { reader.Read(); if (reader.GetValue(1).GetType() != reader.GetDateTime(1).GetType()) throw new Exception("DateTime type non-match"); if (reader.GetValue(2).GetType() != reader.GetDecimal(2).GetType()) throw new Exception("Decimal type non-match"); switch (n) { case 0: if (reader.GetValue(0).GetType() != typeof(long)) throw new Exception("long type non-match"); if (reader.GetValue(0).Equals((long)1) == false) throw new Exception("long value non-match"); if (reader.GetValue(1).Equals(new DateTime(1753, 1, 1)) == false) throw new Exception("DateTime value non-match"); if (reader.GetValue(2).Equals((Decimal)1.05) == false) throw new Exception("Decimal value non-match"); if (reader.GetInt64(0) != (long)1) throw new Exception("long value non-match"); if (reader.GetValue(1).Equals(reader.GetDateTime(1)) == false) throw new Exception("DateTime value non-match"); if (reader.GetValue(2).Equals(reader.GetDecimal(2)) == false) throw new Exception("Decimal value non-match"); break; case 1: if (reader.GetValue(0).GetType() != typeof(string)) throw new Exception("String type non-match"); if (reader.GetValue(0).Equals("One") == false) throw new Exception("String value non-match"); if (reader.GetValue(1).Equals(new DateTime(2001, 1, 1)) == false) throw new Exception("DateTime value non-match"); if (reader.GetValue(2).Equals((Decimal)1.0) == false) throw new Exception("Decimal value non-match"); if (reader.GetString(0) != "One") throw new Exception("String value non-match"); if (reader.GetValue(1).Equals(reader.GetDateTime(1)) == false) throw new Exception("DateTime value non-match"); if (reader.GetValue(2).Equals(reader.GetDecimal(2)) == false) throw new Exception("Decimal value non-match"); break; case 2: if (reader.GetValue(0).GetType() != typeof(double)) throw new Exception("Double type non-match"); if (reader.GetValue(0).Equals(1.01) == false) throw new Exception("Double value non-match"); if (reader.GetValue(1).Equals(now) == false) throw new Exception("DateTime value non-match"); if (reader.GetValue(2).Equals((Decimal)9.91) == false) throw new Exception("Decimal value non-match"); if (reader.GetDouble(0) != 1.01) throw new Exception("Double value non-match"); if (reader.GetValue(1).Equals(reader.GetDateTime(1)) == false) throw new Exception("DateTime value non-match"); if (reader.GetValue(2).Equals(reader.GetDecimal(2)) == false) throw new Exception("Decimal value non-match"); break; } } } } } /// <summary> /// This is an mean ugly test that leaves a lot of open datareaders out on many connections /// to see if the database can survive being cloned a lot and disposed while active readers are up. /// </summary> [Test(Sequence = 40)] internal void LeakyDataReaders() { try { { DbConnection newcnn = null; try { for (int x = 0; x < 10000; x++) { if (newcnn == null) { newcnn = ((ICloneable)_cnn).Clone() as DbConnection; } if (newcnn.State != ConnectionState.Open) newcnn.Open(); DbCommand cmd = newcnn.CreateCommand(); cmd.CommandText = "SELECT * FROM TestCase"; DbDataReader reader = cmd.ExecuteReader(); reader.Read(); object obj = reader[0]; if (x % 500 == 0) { newcnn.Close(); newcnn = null; } } } finally { if (newcnn != null) newcnn.Close(); newcnn = null; } } CheckLocked(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } } [Test(Sequence = int.MaxValue)] internal void DropTable() { DropTables(true); } internal void DropTables(bool throwError) { string[] arr = new string[] { "TestCase", "datatypetest", "MultiThreadedTest", "fulltext", "guidtest", "keyinfotest", "stepreader", "nonexistent" }; using (DbCommand cmd = _cnn.CreateCommand()) { for (int n = 0; n < arr.Length; n++) { try { cmd.CommandText = String.Format("DROP TABLE{1} [{0}]", arr[n], (throwError == false) ? " IF EXISTS" : ""); cmd.ExecuteNonQuery(); } catch (Exception) { if (throwError == true) throw; } } } } [Test(Sequence = 1000)] internal string FastInsertMany() { StringBuilder builder = new StringBuilder(); using (DbTransaction dbTrans = _cnn.BeginTransaction()) { int dtStart; int dtEnd; using (DbCommand cmd = _cnn.CreateCommand()) { cmd.Transaction = dbTrans; cmd.CommandText = "INSERT INTO TestCase(Field1) VALUES(@p1)"; DbParameter Field1 = cmd.CreateParameter(); Field1.ParameterName = "@p1"; cmd.Parameters.Add(Field1); //Console.WriteLine(String.Format(" Fast insert using parameters and prepared statement\r\n -> (100,000 rows) Begins ... ")); dtStart = Environment.TickCount; for (int n = 0; n < 100000; n++) { Field1.Value = n + 200000; cmd.ExecuteNonQuery(); } dtEnd = Environment.TickCount; dtEnd -= dtStart; builder.AppendFormat("Ends in {0} ms ... ", (dtEnd)); } dtStart = Environment.TickCount; dbTrans.Commit(); dtEnd = Environment.TickCount; dtEnd -= dtStart; builder.AppendFormat("Commits in {0} ms", (dtEnd)); } return builder.ToString(); } [Test] internal void FullTextTest() { CheckSQLite(); using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "CREATE VIRTUAL TABLE FullText USING FTS3(name, ingredients);"; cmd.ExecuteNonQuery(); string[] names = { "broccoli stew", "pumpkin stew", "broccoli pie", "pumpkin pie" }; string[] ingredients = { "broccoli peppers cheese tomatoes", "pumpkin onions garlic celery", "broccoli cheese onions flour", "pumpkin sugar flour butter" }; int n; cmd.CommandText = "insert into FullText (name, ingredients) values (@name, @ingredient);"; DbParameter name = cmd.CreateParameter(); DbParameter ingredient = cmd.CreateParameter(); name.ParameterName = "@name"; ingredient.ParameterName = "@ingredient"; cmd.Parameters.Add(name); cmd.Parameters.Add(ingredient); for (n = 0; n < names.Length; n++) { name.Value = names[n]; ingredient.Value = ingredients[n]; cmd.ExecuteNonQuery(); } cmd.CommandText = "select rowid, name, ingredients from FullText where name match 'pie';"; cmd.Parameters.Clear(); int[] rowids = { 3, 4 }; n = 0; using (DbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { if (reader.GetInt64(0) != rowids[n++]) throw new Exception("Unexpected rowid returned"); if (n > rowids.Length) throw new Exception("Too many rows returned"); } } } } [Test] internal void GuidTest() { using (DbCommand cmd = _cnn.CreateCommand()) { Guid guid = Guid.NewGuid(); cmd.CommandText = "CREATE TABLE GuidTest(MyGuid uniqueidentifier)"; cmd.ExecuteNonQuery(); // Insert a guid as a default binary representation cmd.CommandText = "INSERT INTO GuidTest(MyGuid) VALUES(@b)"; DbParameter parm = cmd.CreateParameter(); parm.ParameterName = "@b"; parm.Value = guid; cmd.Parameters.Add(parm); //((SQLiteParameterCollection)cmd.Parameters).AddWithValue("@b", guid); // Insert a guid as text cmd.ExecuteNonQuery(); cmd.Parameters[0].Value = guid.ToString(); cmd.Parameters[0].DbType = DbType.String; cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT MyGuid FROM GuidTest"; cmd.Parameters.Clear(); using (DbDataReader reader = cmd.ExecuteReader()) { reader.Read(); if (reader.GetFieldType(0) != typeof(Guid)) throw new Exception("Column is not a Guid"); if (reader.GetGuid(0) != guid) throw new Exception(String.Format("Got guid {0}, expected {1}", reader.GetGuid(0), guid)); reader.Read(); if (reader.GetFieldType(0) != typeof(Guid)) throw new Exception("Column is not a Guid"); if (reader.GetGuid(0) != guid) throw new Exception(String.Format("Got guid {0}, expected {1}", reader.GetGuid(0), guid)); } } } [Test(Sequence = 20)] internal void InsertTable() { using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "INSERT INTO TestCase(Field1, Field2, [Fiëld3], [Fiæld4], Field5) VALUES(1, 3.14159, 'Fiëld3', 'Fiæld4', '2005-01-01 13:49:00')"; cmd.ExecuteNonQuery(); } } [Test] internal string IterationTest() { CheckSQLite(); StringBuilder builder = new StringBuilder(); using (DbCommand cmd = _cnn.CreateCommand()) { int dtStart; int dtEnd; int nCount; long n; cmd.CommandText = "SELECT Foo(ID, ID) FROM TestCase"; cmd.Prepare(); dtStart = Environment.TickCount; nCount = 0; using (DbDataReader rd = cmd.ExecuteReader()) { while (rd.Read()) { n = rd.GetInt64(0); nCount++; } dtEnd = Environment.TickCount; } builder.AppendLine(String.Format("User Function iteration of {0} records in {1} ms", nCount, (dtEnd - dtStart))); cmd.CommandText = "SELECT ID FROM TestCase"; cmd.Prepare(); dtStart = Environment.TickCount; nCount = 0; using (DbDataReader rd = cmd.ExecuteReader()) { while (rd.Read()) { n = rd.GetInt64(0); nCount++; } dtEnd = Environment.TickCount; } builder.AppendLine(String.Format("Raw iteration of {0} records in {1} ms", nCount, (dtEnd - dtStart))); cmd.CommandText = "SELECT ABS(ID) FROM TestCase"; cmd.Prepare(); dtStart = Environment.TickCount; nCount = 0; using (DbDataReader rd = cmd.ExecuteReader()) { while (rd.Read()) { n = rd.GetInt64(0); nCount++; } dtEnd = Environment.TickCount; } builder.Append(String.Format("Intrinsic Function iteration of {0} records in {1} ms", nCount, (dtEnd - dtStart))); } return builder.ToString(); } [Test(Sequence=21)] internal void KeyInfoTest() { try { using (DbCommand cmd = _cnn.CreateCommand()) { try { // First test against integer primary key (optimized) keyinfo fetch cmd.CommandText = "Create table keyinfotest (id integer primary key, myuniquevalue integer unique not null, myvalue varchar(50))"; cmd.ExecuteNonQuery(); cmd.CommandText = "Select * from keyinfotest"; using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly)) { using (DataTable tbl = reader.GetSchemaTable()) { if (tbl.Rows.Count != 3) throw new Exception("Wrong number of columns returned"); } } cmd.CommandText = "SELECT MyValue FROM keyinfotest"; using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly)) { using (DataTable tbl = reader.GetSchemaTable()) { if (tbl.Rows.Count != 2) throw new Exception("Wrong number of columns returned"); } } } finally { } cmd.CommandText = "DROP TABLE keyinfotest"; cmd.ExecuteNonQuery(); try { // Now test against non-integer primary key (unoptimized) subquery keyinfo fetch cmd.CommandText = "Create table keyinfotest (id char primary key, myuniquevalue integer unique not null, myvalue varchar(50))"; cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT MyValue FROM keyinfotest"; using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly)) { using (DataTable tbl = reader.GetSchemaTable()) { if (tbl.Rows.Count != 2) throw new Exception("Wrong number of columns returned"); } } cmd.CommandText = "Select * from keyinfotest"; using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly)) { using (DataTable tbl = reader.GetSchemaTable()) { if (tbl.Rows.Count != 3) throw new Exception("Wrong number of columns returned"); } } // Make sure commandbuilder can generate an update command with the correct parameter count using (DbDataAdapter adp = _fact.CreateDataAdapter()) using (DbCommandBuilder builder = _fact.CreateCommandBuilder()) { adp.SelectCommand = cmd; builder.DataAdapter = adp; builder.ConflictOption = ConflictOption.OverwriteChanges; using (DbCommand updatecmd = builder.GetUpdateCommand()) { if (updatecmd.Parameters.Count != 4) throw new Exception("Wrong number of parameters in update command!"); } } } finally { } } } catch (Exception e) { Console.WriteLine(e.Message); } } [Test] internal void LeakyCommands() { for (int n = 0; n < 100000; n++) { DbCommand cmd = _cnn.CreateCommand(); cmd.CommandText = "SELECT * FROM sqlite_master"; cmd.Prepare(); } CheckLocked(); } [Test(Sequence = 60)] internal void LockTest() { CheckSQLite(); using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "SELECT Field6 FROM TestCase WHERE Field6 IS NOT NULL"; byte[] b = new byte[4000]; using (DbDataReader rd = cmd.ExecuteReader()) { if (rd.Read() == false) throw new Exception("No data to read!"); rd.GetBytes(0, 0, b, 0, 4000); if (b[0] != 1) throw new Exception("Binary value non-match byte 0"); if (b[100] != 2) throw new Exception("Binary value non-match byte 100"); if (b[1000] != 3) throw new Exception("Binary value non-match byte 1000"); if (b[2000] != 4) throw new Exception("Binary value non-match byte 2000"); if (b[3000] != 5) throw new Exception("Binary value non-match byte 3000"); using (DbConnection clone = (DbConnection)((ICloneable)_cnn).Clone()) { if (clone.State != ConnectionState.Open) clone.Open(); using (DbCommand newcmd = clone.CreateCommand()) { newcmd.CommandText = "DELETE FROM TestCase WHERE Field6 IS NULL"; newcmd.CommandTimeout = 2; int cmdStart = Environment.TickCount; int cmdEnd; try { newcmd.ExecuteNonQuery(); // should fail because there's a reader on the database throw new ArgumentException("Should not have allowed an execute with an open reader"); // If we got here, the test failed } catch (Exception e) { if (e is ArgumentException) throw new Exception(e.Message); cmdEnd = Environment.TickCount; if (cmdEnd - cmdStart < 2000 || cmdEnd - cmdStart > 3000) throw new Exception("Gave up the lock too soon!"); // Didn't wait the right amount of time } } } } } } /// <summary> /// Execute multiple steps in a command and verify the results. Makes sure that commands after a select still /// get executed even if MoveNext() isn't called explicitly to move things along. /// </summary> [Test] internal void MultiStepReaderTest() { using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "CREATE TABLE stepreader (id int primary key);INSERT INTO stepreader values(1);SELECT * FROM stepreader;UPDATE stepreader set id = id + 1;"; using (DbDataReader reader = cmd.ExecuteReader()) { if (reader.Read() == false) throw new Exception("Failed to read from the table"); if (reader.GetInt32(0) != 1) throw new Exception(String.Format("Expected {0} got {1}", 1, reader.GetInt32(0))); } cmd.CommandText = "SELECT * FROM stepreader"; using (DbDataReader reader = cmd.ExecuteReader()) { if (reader.Read() == false) throw new Exception("Failed to read from the table"); if (reader.GetInt32(0) != 2) throw new Exception(String.Format("Expected {0} got {1}", 2, reader.GetInt32(0))); } } } internal class MTTest { internal DbConnection cnn; internal Exception e; internal System.Threading.Thread t; internal int value; } [Test(Sequence=11)] internal void MultithreadingTest() { using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "CREATE TABLE MultiThreadedTest(ID integer primary key, ThreadId integer, MyValue integer)"; cmd.ExecuteNonQuery(); } MTTest[] arr = new MTTest[8]; for (int n = 0; n < arr.Length; n++) { arr[n] = new MTTest(); arr[n].t = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(MultithreadedTestThread)); arr[n].t.IsBackground = true; arr[n].cnn = ((ICloneable)_cnn).Clone() as DbConnection; arr[n].t.Start(arr[n]); } System.Threading.Thread.CurrentThread.Join(8000); bool failed = false; Exception e = null; for (int n = 0; n < arr.Length; n++) { if (arr[n].t.Join(0) == false) { failed = true; arr[n].t.Abort(); } if (arr[n].e != null) e = arr[n].e; arr[n].cnn.Dispose(); } if (failed) throw new Exception("One or more threads deadlocked"); if (e != null) throw e; } internal void MultithreadedTestThread(object obj) { MTTest test = obj as MTTest; if (test.cnn.State != ConnectionState.Open) test.cnn.Open(); int start = Environment.TickCount; try { using (DbCommand cmd = test.cnn.CreateCommand()) { while (Environment.TickCount - start < 5000) { using (DbTransaction trans = test.cnn.BeginTransaction()) { cmd.CommandText = String.Format("SELECT * FROM MultiThreadedTest WHERE ThreadId = {0}", test.t.ManagedThreadId); using (DbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { test.value += Convert.ToInt32(reader[2]); } } cmd.CommandText = String.Format("INSERT INTO MultiThreadedTest(ThreadId, MyValue) VALUES({0}, {1})", test.t.ManagedThreadId, Environment.TickCount); cmd.ExecuteNonQuery(); trans.Commit(); } } } } catch (Exception e) { test.e = e; } } [Test] internal void ParameterizedInsert() { using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "INSERT INTO TestCase(Field1, Field2, [Fiëld3], [Fiæld4], Field5) VALUES(@p1,@p2,@p3,@p4,@p5)"; DbParameter Field1 = cmd.CreateParameter(); DbParameter Field2 = cmd.CreateParameter(); DbParameter Field3 = cmd.CreateParameter(); DbParameter Field4 = cmd.CreateParameter(); DbParameter Field5 = cmd.CreateParameter(); Field1.ParameterName = "@p1"; Field2.ParameterName = "@p2"; Field3.ParameterName = "@p3"; Field4.ParameterName = "@p4"; Field5.ParameterName = "@p5"; Field1.Value = 2; Field2.Value = 3.14159; Field3.Value = "Param Field3"; Field4.Value = "Field4 Par"; Field5.Value = DateTime.Now; cmd.Parameters.Add(Field1); cmd.Parameters.Add(Field2); cmd.Parameters.Add(Field3); cmd.Parameters.Add(Field4); cmd.Parameters.Add(Field5); cmd.ExecuteNonQuery(); } } [Test] internal void ParameterizedInsertMissingParams() { using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "INSERT INTO TestCase(Field1, Field2, [Fiëld3], [Fiæld4], Field5) VALUES(@p1,@p2,@p3,@p4,@p5)"; DbParameter Field1 = cmd.CreateParameter(); DbParameter Field2 = cmd.CreateParameter(); DbParameter Field3 = cmd.CreateParameter(); DbParameter Field4 = cmd.CreateParameter(); DbParameter Field5 = cmd.CreateParameter(); Field1.ParameterName = "@p1"; Field2.ParameterName = "@p2"; Field3.ParameterName = "@p3"; Field4.ParameterName = "@p4"; Field5.ParameterName = "@p5"; Field1.DbType = System.Data.DbType.Int32; Field1.Value = 2; Field2.Value = 3.14159; Field3.Value = "Field3 Param"; Field4.Value = "Field4 Par"; Field5.Value = DateTime.Now; cmd.Parameters.Add(Field1); cmd.Parameters.Add(Field2); cmd.Parameters.Add(Field3); cmd.Parameters.Add(Field4); // Assertion here, not enough parameters try { cmd.ExecuteNonQuery(); throw new Exception("Executed with a missing parameter"); } catch (Exception) // Expected { } } } /// <summary> /// Call Prepare() on a multi-statement command text where the second command depends on the existence of the first. /// </summary> [Test] internal void PrepareTest() { using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "CREATE TABLE nonexistent(id int primary key);SELECT id FROM nonexistent UNION SELECT 1"; cmd.Prepare(); object ob = cmd.ExecuteScalar(); if (ob == null || ob == DBNull.Value) throw new Exception("Multiple statements may not be supported"); if (Convert.ToInt32(ob) != 1) throw new Exception(String.Format("Expected {0} got {1}", 1, ob)); } } /// <summary> /// Checks to make sure transactions are rolled back before a connection goes back onto the pool /// </summary> [Test] internal void PoolingWithStealthTransactionTest() { object value; if (_cnnstring.TryGetValue("Pooling", out value) == false) throw new Exception("Pooling not present in connection string"); if ((bool)value == false) throw new InconclusiveException("Pooling not enabled in the connection string"); for (int n = 0; n < 100; n++) { using (DbConnection newcnn = ((ICloneable)_cnn).Clone() as DbConnection) { if (newcnn.State != ConnectionState.Open) newcnn.Open(); using (DbCommand cmd = newcnn.CreateCommand()) { cmd.CommandText = "BEGIN IMMEDIATE"; cmd.ExecuteNonQuery(); cmd.CommandText = "CREATE TABLE PoolTest(ID int primary key)"; cmd.ExecuteNonQuery(); } } } } /// <summary> /// Checks to make sure transactions are rolled back before a connection goes back onto the pool /// </summary> [Test] internal void PoolingWithTransactionTest() { object value; if (_cnnstring.TryGetValue("Pooling", out value) == false) throw new Exception("Pooling not present in connection string"); if ((bool)value == false) throw new InconclusiveException("Pooling not enabled in the connection string"); for (int n = 0; n < 100; n++) { using (DbConnection newcnn = ((ICloneable)_cnn).Clone() as DbConnection) { if (newcnn.State != ConnectionState.Open) newcnn.Open(); DbTransaction trans = newcnn.BeginTransaction(); using (DbCommand cmd = newcnn.CreateCommand()) { cmd.CommandText = "CREATE TABLE PoolTest(ID int primary key)"; cmd.ExecuteNonQuery(); } } } } /// <summary> /// Open a reader and then attempt to write to test the writer's command timeout property /// SQLite doesn't allow a write when a reader is active. /// *** NOTE AS OF 3.3.8 this test no longer blocks because SQLite now allows you to update table(s) /// while a reader is active on the same connection. Therefore the timeout test is invalid /// </summary> internal void TimeoutTest() { CheckSQLite(); using (DbCommand cmdRead = _cnn.CreateCommand()) { cmdRead.CommandText = "SELECT ID FROM TestCase"; using (DbDataReader rd = cmdRead.ExecuteReader()) { using (DbCommand cmdwrite = _cnn.CreateCommand()) { cmdwrite.CommandText = "UPDATE [KeyInfoTest] SET [ID] = [ID]"; cmdwrite.CommandTimeout = 5; int dwtick = Environment.TickCount; try { cmdwrite.ExecuteNonQuery(); } catch (Exception) { dwtick = (Environment.TickCount - dwtick) / 1000; if (dwtick < 5 || dwtick > 6) throw new Exception("Timeout didn't wait long enough!"); return; } throw new Exception("Operation should have failed but completed successfully"); } } } } [Test(Sequence = 41)] internal void TransactionScopeTest() { using (TransactionScope scope = new TransactionScope()) { using (DbConnection cnn2 = ((ICloneable)_cnn).Clone() as DbConnection) { if (cnn2.State != ConnectionState.Open) cnn2.Open(); using (DbCommand cmd = cnn2.CreateCommand()) { // Created a table inside the transaction scope cmd.CommandText = "CREATE TABLE VolatileTable (ID INTEGER PRIMARY KEY, MyValue VARCHAR(50))"; cmd.ExecuteNonQuery(); using (DbCommand cmd2 = cnn2.CreateCommand()) { using (cmd2.Transaction = cnn2.BeginTransaction()) { // Inserting a value inside the table, inside a transaction which is inside the transaction scope cmd2.CommandText = "INSERT INTO VolatileTable (ID, MyValue) VALUES(1, 'Hello')"; cmd2.ExecuteNonQuery(); cmd2.Transaction.Commit(); } } } // Connection is disposed before the transactionscope leaves, thereby forcing the connection to stay open } // Exit the transactionscope without committing it, causing a rollback of both the create table and the insert } // Verify that the table does not exist using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "SELECT COUNT(*) FROM VolatileTable"; try { object o = cmd.ExecuteScalar(); cmd.CommandText = "DROP TABLE VolatileTable"; cmd.ExecuteNonQuery(); throw new InvalidOperationException("Transaction failed! The table exists!"); } catch(Exception e) { if (e is InvalidOperationException) throw new Exception(e.Message); return; // Succeeded, the table should not have existed } } } /// <summary> /// Causes the user-defined aggregate to be iterated through /// </summary> /// <returns></returns> [Test] internal string UserAggregate() { CheckSQLite(); StringBuilder builder = new StringBuilder(); using (DbCommand cmd = _cnn.CreateCommand()) { int dtStart; int n = 0; int nCount; cmd.CommandText = "SELECT MyCount(*) FROM TestCase"; nCount = 0; dtStart = Environment.TickCount; while (Environment.TickCount - dtStart < 1000) { n = Convert.ToInt32(cmd.ExecuteScalar()); nCount++; } if (n != 120003) throw new Exception("Unexpected count"); builder.Append(String.Format("UserAggregate executed {0} times in 1 second.", nCount)); } return builder.ToString(); } /// <summary> /// Causes the user-defined collation sequence to be iterated through /// </summary> [Test] internal void UserCollation() { CheckSQLite(); using (DbCommand cmd = _cnn.CreateCommand()) { // Using a default collating sequence in descending order, "Param Field3" will appear at the top // and "Field3" will be next, followed by a NULL. Our user-defined collating sequence will // deliberately place them out of order so Field3 is first. cmd.CommandText = "SELECT [Fiëld3] FROM TestCase ORDER BY [Fiëld3] COLLATE MYSEQUENCE DESC"; string s = (string)cmd.ExecuteScalar(); if (s != "Fiëld3") throw new Exception("MySequence didn't sort properly"); } } /// <summary> /// Causes the user-defined function to be called /// </summary> /// <returns></returns> [Test] internal string UserFunction() { CheckSQLite(); StringBuilder builder = new StringBuilder(); using (DbCommand cmd = _cnn.CreateCommand()) { int nTimes; int dtStart; nTimes = 0; cmd.CommandText = "SELECT Foo('ee','foo')"; dtStart = Environment.TickCount; while (Environment.TickCount - dtStart < 1000) { cmd.ExecuteNonQuery(); nTimes++; } builder.AppendLine(String.Format("User (text) command executed {0} times in 1 second.", nTimes)); nTimes = 0; cmd.CommandText = "SELECT Foo(10,11)"; dtStart = Environment.TickCount; while (Environment.TickCount - dtStart < 1000) { cmd.ExecuteNonQuery(); nTimes++; } builder.AppendLine(String.Format("UserFunction command executed {0} times in 1 second.", nTimes)); nTimes = 0; cmd.CommandText = "SELECT ABS(1)"; dtStart = Environment.TickCount; while (Environment.TickCount - dtStart < 1000) { cmd.ExecuteNonQuery(); nTimes++; } builder.AppendLine(String.Format("Intrinsic command executed {0} times in 1 second.", nTimes)); nTimes = 0; cmd.CommandText = "SELECT lower('FOO')"; dtStart = Environment.TickCount; while (Environment.TickCount - dtStart < 1000) { cmd.ExecuteNonQuery(); nTimes++; } builder.AppendLine(String.Format("Intrin (txt) command executed {0} times in 1 second.", nTimes)); nTimes = 0; cmd.CommandText = "SELECT 1"; dtStart = Environment.TickCount; while (Environment.TickCount - dtStart < 1000) { cmd.ExecuteNonQuery(); nTimes++; } builder.Append(String.Format("Raw Value command executed {0} times in 1 second.", nTimes)); } return builder.ToString(); } [Test(Sequence = 42)] internal void VerifyBinaryData() { BinaryInsert(); using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "SELECT Field6 FROM TestCase WHERE Field6 IS NOT NULL"; byte[] b = new byte[4000]; using (DbDataReader rd = cmd.ExecuteReader()) { if (rd.Read() == false) throw new Exception("No data to read!"); rd.GetBytes(0, 0, b, 0, 4000); if (b[0] != 1) throw new Exception("Binary value non-match byte 0"); if (b[100] != 2) throw new Exception("Binary value non-match byte 100"); if (b[1000] != 3) throw new Exception("Binary value non-match byte 1000"); if (b[2000] != 4) throw new Exception("Binary value non-match byte 2000"); if (b[3000] != 5) throw new Exception("Binary value non-match byte 3000"); } } } [Test(Sequence = 30)] internal void VerifyInsert() { using (DbCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "SELECT Field1, Field2, [Fiëld3], [Fiæld4], Field5 FROM TestCase"; cmd.Prepare(); using (DbDataReader rd = cmd.ExecuteReader()) { if (rd.Read()) { long Field1 = rd.GetInt64(0); double Field2 = rd.GetDouble(1); string Field3 = rd.GetString(2); string Field4 = rd.GetString(3).TrimEnd(); DateTime Field5 = rd.GetDateTime(4); if (Field1 != 1) throw new Exception(String.Format("Field1 {0} did not match {1}", Field1, 1)); if (Field2 != 3.14159) throw new Exception(String.Format("Field2 {0} did not match {1}", Field2, 3.14159)); if (Field3 != "Fiëld3") throw new Exception(String.Format("Field3 {0} did not match {1}", Field3, "Fiëld3")); if (Field4 != "Fiæld4") throw new Exception(String.Format("Field4 {0} did not match {1}", Field4, "Fiæld4")); if (Field5.CompareTo(DateTime.Parse("2005-01-01 13:49:00")) != 0) throw new Exception(String.Format("Field5 {0} did not match {1}", Field4, DateTime.Parse("2005-01-01 13:49:00"))); if (rd.GetName(0) != "Field1") throw new Exception("Non-Match column name Field1"); if (rd.GetName(1) != "Field2") throw new Exception("Non-Match column name Field2"); if (rd.GetName(2) != "Fiëld3") throw new Exception("Non-Match column name Field3"); if (rd.GetName(3) != "Fiæld4") throw new Exception("Non-Match column name Field4"); if (rd.GetName(4) != "Field5") throw new Exception("Non-Match column name Field5"); } else throw new Exception("No data in table"); } } } } /// <summary> /// Scalar user-defined function. In this example, the same class is declared twice with /// different function names to demonstrate how to use alias names for user-defined functions. /// </summary> [SQLiteFunction(Name = "Foo", Arguments = 2, FuncType = FunctionType.Scalar)] [SQLiteFunction(Name = "TestFunc", Arguments = 2, FuncType = FunctionType.Scalar)] class TestFunc : SQLiteFunction { public override object Invoke(object[] args) { if (args[0].GetType() != typeof(int)) return args[0]; int Param1 = Convert.ToInt32(args[0]); // First parameter int Param2 = Convert.ToInt32(args[1]); // Second parameter return Param1 + Param2; } } [SQLiteFunction(Name = "CASETEST", Arguments = 2, FuncType = FunctionType.Scalar)] class CaseTestFunc : SQLiteFunctionEx { public override object Invoke(object[] args) { CollationSequence seq = GetCollationSequence(); return seq.Compare(args[0].ToString(), args[1].ToString()); } } /// <summary> /// Aggregate user-defined function. Arguments = -1 means any number of arguments is acceptable /// </summary> [SQLiteFunction(Name = "MyCount", Arguments = -1, FuncType = FunctionType.Aggregate)] class MyCount : SQLiteFunction { |
︙ | ︙ | |||
67 68 69 70 71 72 73 | /// User-defined collating sequence. /// </summary> [SQLiteFunction(Name = "MYSEQUENCE", FuncType = FunctionType.Collation)] class MySequence : SQLiteFunction { public override int Compare(string param1, string param2) { | | | | | > | > | | < < | < < | < < | < < | < < < < > | < < > > | < < < < > < < > | < < > | < < > | < | > | < | > > | < < < | | < | > | < < | | | > | < < | < < | | | | | > | > > < | | | > > > > | < < < < < < < < < < < < < > | | < < < < < | | < < < | | > | < < < < < | < > > < < < < < < > | | < | > > > | | | < < > | < < < < > > | < < < > > | < < < | | < < < > | < > | < < < > > > | | < < > > > > | | < < | > > | | < < < < < < < | | < < < < < < < < | < < < < > > > > | | | | < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1607 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 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 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 | /// User-defined collating sequence. /// </summary> [SQLiteFunction(Name = "MYSEQUENCE", FuncType = FunctionType.Collation)] class MySequence : SQLiteFunction { public override int Compare(string param1, string param2) { // Make sure the string "Fiëld3" is sorted out of order if (param1 == "Fiëld3") return 1; if (param2 == "Fiëld3") return -1; return String.Compare(param1, param2, true); } } [AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)] public sealed class TestAttribute : Attribute, IComparable<TestAttribute> { private static int _start = 65535; private int _sequence; public TestAttribute() { _sequence = _start; _start++; } public int Sequence { get { return _sequence; } set { _sequence = value; } } #region IComparable<TestAttribute> Members public int CompareTo(TestAttribute other) { return _sequence.CompareTo(other._sequence); } #endregion } internal enum TestResultEnum { Succeeded = 0, Failed = 1, Inconclusive = 2, } internal class InconclusiveException : Exception { internal InconclusiveException() : base() { } internal InconclusiveException(string message) : base(message) { } } internal class TestEventArgs : EventArgs { public readonly string TestName; public readonly TestResultEnum Result; public readonly Exception Exception; public readonly string Message; public readonly int Duration; internal TestEventArgs(string testName, TestResultEnum success, int duration, Exception e, string message) { TestName = testName; Result = success; Exception = e; Message = message; Duration = duration; } } delegate void TestCompletedEvent(object sender, TestEventArgs args); delegate void TestStartingEvent(object sender, TestEventArgs args); internal abstract class TestCaseBase { protected DbProviderFactory _fact; protected DbConnection _cnn = null; protected DbConnectionStringBuilder _cnnstring; public event TestCompletedEvent OnTestFinished; public event TestStartingEvent OnTestStarting; public event EventHandler OnAllTestsDone; protected TestCaseBase(DbProviderFactory factory, string connectionString) { _fact = factory; _cnn = _fact.CreateConnection(); _cnn.ConnectionString = connectionString; _cnnstring = _fact.CreateConnectionStringBuilder(); _cnnstring.ConnectionString = connectionString; _cnn.Open(); } internal void Run() { SortedList<TestAttribute, System.Reflection.MethodInfo> items = new SortedList<TestAttribute, System.Reflection.MethodInfo>(); foreach (System.Reflection.MethodInfo mi in GetType().GetMethods(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod)) { object[] att = mi.GetCustomAttributes(typeof(TestAttribute), false); if (att.Length == 1) { items.Add((TestAttribute)att[0], mi); } } foreach (KeyValuePair<TestAttribute, System.Reflection.MethodInfo> pair in items) { if (OnTestStarting != null) OnTestStarting(this, new TestEventArgs(pair.Value.Name, TestResultEnum.Inconclusive, 0, null, null)); int start = Environment.TickCount; try { object obj = pair.Value.Invoke(this, null); int duration = Environment.TickCount - start; if (OnTestFinished != null) OnTestFinished(this, new TestEventArgs(pair.Value.Name, TestResultEnum.Succeeded, duration, null, (obj is string) ? (string)obj : String.Empty)); } catch (Exception e) { int duration = Environment.TickCount - start; Exception inner = e.InnerException; if (OnTestFinished != null) { if (inner is InconclusiveException) { OnTestFinished(this, new TestEventArgs(pair.Value.Name, TestResultEnum.Inconclusive, duration, null, inner.Message)); } else { OnTestFinished(this, new TestEventArgs(pair.Value.Name, TestResultEnum.Failed, duration, inner, null)); } } } } if (OnAllTestsDone != null) OnAllTestsDone(this, EventArgs.Empty); } } } |
Added test/TestCasesDialog.Designer.cs.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | namespace test { partial class TestCasesDialog { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.Windows.Forms.Label label1; System.Windows.Forms.Label label2; System.Windows.Forms.Button closeButton; System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); this._provider = new System.Windows.Forms.ComboBox(); this._connectionString = new System.Windows.Forms.ComboBox(); this._grid = new System.Windows.Forms.DataGridView(); this.runButton = new System.Windows.Forms.Button(); this.Test = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Result = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Time = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Information = new System.Windows.Forms.DataGridViewTextBoxColumn(); label1 = new System.Windows.Forms.Label(); label2 = new System.Windows.Forms.Label(); closeButton = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this._grid)).BeginInit(); this.SuspendLayout(); // // label1 // label1.AutoSize = true; label1.Location = new System.Drawing.Point(14, 16); label1.Name = "label1"; label1.Size = new System.Drawing.Size(46, 13); label1.TabIndex = 0; label1.Text = "&Provider"; // // label2 // label2.AutoSize = true; label2.Location = new System.Drawing.Point(250, 16); label2.Name = "label2"; label2.Size = new System.Drawing.Size(91, 13); label2.TabIndex = 2; label2.Text = "Connection &String"; // // closeButton // closeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; closeButton.Location = new System.Drawing.Point(534, 482); closeButton.Name = "closeButton"; closeButton.Size = new System.Drawing.Size(75, 23); closeButton.TabIndex = 5; closeButton.Text = "&Close"; closeButton.UseVisualStyleBackColor = true; closeButton.Click += new System.EventHandler(this.closeButton_Click); // // _provider // this._provider.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this._provider.FormattingEnabled = true; this._provider.Location = new System.Drawing.Point(66, 13); this._provider.Name = "_provider"; this._provider.Size = new System.Drawing.Size(178, 21); this._provider.TabIndex = 1; // // _connectionString // this._connectionString.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this._connectionString.FormattingEnabled = true; this._connectionString.Location = new System.Drawing.Point(347, 13); this._connectionString.Name = "_connectionString"; this._connectionString.Size = new System.Drawing.Size(262, 21); this._connectionString.TabIndex = 3; // // _grid // this._grid.AllowUserToAddRows = false; this._grid.AllowUserToDeleteRows = false; this._grid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this._grid.BackgroundColor = System.Drawing.SystemColors.Window; this._grid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this._grid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Test, this.Result, this.Time, this.Information}); this._grid.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this._grid.Location = new System.Drawing.Point(12, 41); this._grid.Name = "_grid"; this._grid.ReadOnly = true; this._grid.RowHeadersVisible = false; this._grid.Size = new System.Drawing.Size(597, 435); this._grid.TabIndex = 4; // // runButton // this.runButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.runButton.Location = new System.Drawing.Point(453, 482); this.runButton.Name = "runButton"; this.runButton.Size = new System.Drawing.Size(75, 23); this.runButton.TabIndex = 6; this.runButton.Text = "&Run"; this.runButton.UseVisualStyleBackColor = true; this.runButton.Click += new System.EventHandler(this.runButton_Click); // // Test // this.Test.Frozen = true; this.Test.HeaderText = "Test"; this.Test.Name = "Test"; this.Test.ReadOnly = true; this.Test.Width = 150; // // Result // this.Result.Frozen = true; this.Result.HeaderText = "Result"; this.Result.Name = "Result"; this.Result.ReadOnly = true; this.Result.Resizable = System.Windows.Forms.DataGridViewTriState.True; this.Result.Width = 150; // // Time // dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; this.Time.DefaultCellStyle = dataGridViewCellStyle3; this.Time.HeaderText = "Time (ms)"; this.Time.Name = "Time"; this.Time.ReadOnly = true; // // Information // this.Information.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.Information.DefaultCellStyle = dataGridViewCellStyle4; this.Information.HeaderText = "Information"; this.Information.Name = "Information"; this.Information.ReadOnly = true; // // TestCasesDialog // this.AcceptButton = this.runButton; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = closeButton; this.ClientSize = new System.Drawing.Size(621, 517); this.Controls.Add(this.runButton); this.Controls.Add(closeButton); this.Controls.Add(this._grid); this.Controls.Add(this._connectionString); this.Controls.Add(label2); this.Controls.Add(this._provider); this.Controls.Add(label1); this.Name = "TestCasesDialog"; this.Text = "ADO.NET Provider Test"; ((System.ComponentModel.ISupportInitialize)(this._grid)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.ComboBox _provider; private System.Windows.Forms.ComboBox _connectionString; private System.Windows.Forms.DataGridView _grid; private System.Windows.Forms.Button runButton; private System.Windows.Forms.DataGridViewTextBoxColumn Test; private System.Windows.Forms.DataGridViewTextBoxColumn Result; private System.Windows.Forms.DataGridViewTextBoxColumn Time; private System.Windows.Forms.DataGridViewTextBoxColumn Information; } } |
Added test/TestCasesDialog.cs.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.Common; namespace test { public partial class TestCasesDialog : Form { private TestCases _test; public TestCasesDialog() { InitializeComponent(); using (DataTable tbl = DbProviderFactories.GetFactoryClasses()) { foreach (DataRow row in tbl.Rows) { string prov = row[2].ToString(); if (prov.IndexOf("SQLite", 0, StringComparison.OrdinalIgnoreCase) != -1 //|| prov.IndexOf("SqlClient", 0, StringComparison.OrdinalIgnoreCase) != -1 ) _provider.Items.Add(prov); if (prov == "System.Data.SQLite") _provider.SelectedItem = prov; } } _connectionString.Text = "Data Source=Test.db3;Pooling=true;FailIfMissing=false"; } private void runButton_Click(object sender, EventArgs e) { DbProviderFactory factory = DbProviderFactories.GetFactory(_provider.SelectedItem.ToString()); _test = new TestCases(factory, _connectionString.Text); _test.OnTestStarting += new TestStartingEvent(_test_OnTestStarting); _test.OnTestFinished += new TestCompletedEvent(_test_OnTestFinished); _test.OnAllTestsDone += new EventHandler(_test_OnAllTestsDone); _grid.Rows.Clear(); runButton.Enabled = false; System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(_threadFunc)); t.IsBackground = true; t.Start(); } void _test_OnAllTestsDone(object sender, EventArgs e) { if (InvokeRequired) Invoke(new EventHandler(_test_OnAllTestsDone), sender, e); else runButton.Enabled = true; } void _threadFunc() { _test.Run(); } void _test_OnTestFinished(object sender, TestEventArgs args) { if (InvokeRequired) Invoke(new TestCompletedEvent(_test_OnTestFinished), sender, args); else { _grid.Rows[_grid.Rows.Count - 1].SetValues(args.TestName, args.Result, args.Duration, (args.Exception == null) ? args.Message : args.Exception.Message); if (args.Result == TestResultEnum.Failed) { _grid.Rows[_grid.Rows.Count - 1].Cells[1].Style.BackColor = Color.Red; } else if (args.Result == TestResultEnum.Inconclusive) { _grid.Rows[_grid.Rows.Count - 1].Cells[1].Style.BackColor = Color.LightBlue; } _grid.Rows[_grid.Rows.Count - 1].Height = _grid.Rows[_grid.Rows.Count - 1].GetPreferredHeight(_grid.Rows.Count - 1, DataGridViewAutoSizeRowMode.AllCells, true); } } void _test_OnTestStarting(object sender, TestEventArgs args) { if (InvokeRequired) Invoke(new TestStartingEvent(_test_OnTestStarting), sender, args); else { _grid.Rows.Add(args.TestName, "Starting", null, null); _grid.FirstDisplayedScrollingRowIndex = _grid.Rows.Count - 1; } } private void closeButton_Click(object sender, EventArgs e) { Close(); } } } |
Added test/TestCasesDialog.resx.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | <?xml version="1.0" encoding="utf-8"?> <root> <!-- Microsoft ResX Schema Version 2.0 The primary goals of this format is to allow a simple XML format that is mostly human readable. The generation and parsing of the various data types are done through the TypeConverter classes associated with the data types. Example: ... ado.net/XML headers & schema ... <resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="version">2.0</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <value>[base64 mime encoded serialized .NET Framework object]</value> </data> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <comment>This is a comment</comment> </data> There are any number of "resheader" rows that contain simple name/value pairs. Each data row contains a name, and value. The row also contains a type or mimetype. Type corresponds to a .NET class that support text/value conversion through the TypeConverter architecture. Classes that don't support this are serialized and stored with the mimetype set. The mimetype is used for serialized objects, and tells the ResXResourceReader how to depersist the object. This is currently not extensible. For a given mimetype the value must be set accordingly: Note - application/x-microsoft.net.object.binary.base64 is the format that the ResXResourceWriter will generate, however the reader can read any of the formats listed below. mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Soap.SoapFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.bytearray.base64 value : The object must be serialized into a byte array : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="metadata"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="assembly"> <xsd:complexType> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>2.0</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> </metadata> <metadata name="label2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> </metadata> <metadata name="closeButton.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> </metadata> <metadata name="Test.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </metadata> <metadata name="Result.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </metadata> <metadata name="Time.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </metadata> <metadata name="Information.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </metadata> </root> |
Changes to test/test.csproj.
︙ | ︙ | |||
55 56 57 58 59 60 61 | </PropertyGroup> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>9.0.30428</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{E27B1B1E-19C0-45E8-AA74-B6E1C041A130}</ProjectGuid> | | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | </PropertyGroup> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>9.0.30428</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{E27B1B1E-19C0-45E8-AA74-B6E1C041A130}</ProjectGuid> <OutputType>WinExe</OutputType> <RootNamespace>test</RootNamespace> <AssemblyName>test</AssemblyName> <WarningLevel>4</WarningLevel> <IsWebBootstrapper>true</IsWebBootstrapper> <PublishUrl>http://localhost/test</PublishUrl> <Install>true</Install> <InstallFrom>Web</InstallFrom> |
︙ | ︙ | |||
77 78 79 80 81 82 83 84 85 86 87 88 89 90 | <ApplicationVersion>1.0.0.*</ApplicationVersion> <BootstrapperEnabled>true</BootstrapperEnabled> <FileUpgradeFlags> </FileUpgradeFlags> <OldToolsVersion>2.0</OldToolsVersion> <UpgradeBackupLocation> </UpgradeBackupLocation> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>..\bin\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> | > > | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | <ApplicationVersion>1.0.0.*</ApplicationVersion> <BootstrapperEnabled>true</BootstrapperEnabled> <FileUpgradeFlags> </FileUpgradeFlags> <OldToolsVersion>2.0</OldToolsVersion> <UpgradeBackupLocation> </UpgradeBackupLocation> <StartupObject> </StartupObject> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>..\bin\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> |
︙ | ︙ | |||
110 111 112 113 114 115 116 | <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression> <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile> <UseVSHostingProcess>false</UseVSHostingProcess> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Data" /> | | > > > > > > > > > > > > > | > > > > > > | 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 | <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression> <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile> <UseVSHostingProcess>false</UseVSHostingProcess> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Data.SQLite, Version=1.0.55.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86"> <SpecificVersion>False</SpecificVersion> <Private>False</Private> </Reference> <Reference Include="System.Drawing" /> <Reference Include="System.Transactions" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <None Include="app.config" /> <Compile Include="Program.cs" /> <Compile Include="AssemblyInfo.cs" /> <Compile Include="Properties\Resources.Designer.cs"> <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> <DependentUpon>Resources.resx</DependentUpon> </Compile> <Compile Include="TestCases.cs" /> <Compile Include="TestCasesDialog.cs"> <SubType>Form</SubType> </Compile> <Compile Include="TestCasesDialog.Designer.cs"> <DependentUpon>TestCasesDialog.cs</DependentUpon> </Compile> </ItemGroup> <ItemGroup> <BootstrapperFile Include="Microsoft.Net.Framework.2.0"> <InProject>False</InProject> <ProductName>.NET Framework 2.0</ProductName> <Install>true</Install> </BootstrapperFile> </ItemGroup> <ItemGroup> <BootstrapperPackage Include="Microsoft.Net.Framework.2.0"> <InProject>False</InProject> <ProductName>.NET Framework 2.0 Beta</ProductName> <Install>true</Install> </BootstrapperPackage> </ItemGroup> <ItemGroup> <EmbeddedResource Include="Properties\Resources.resx"> <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> <EmbeddedResource Include="TestCasesDialog.resx"> <DependentUpon>TestCasesDialog.cs</DependentUpon> </EmbeddedResource> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> </Project> |
Changes to testlinq/App.Config.
1 2 3 | <?xml version="1.0" encoding="utf-8"?> <configuration> <connectionStrings> | | > | 1 2 3 4 5 6 | <?xml version="1.0" encoding="utf-8"?> <configuration> <connectionStrings> <add name="northwindEntities" connectionString="metadata=res://*/NorthwindModel.csdl|res://*/NorthwindModel.ssdl|res://*/NorthwindModel.msl;provider=System.Data.SQLite;provider connection string="data source=c:\src\northwind.db"" providerName="System.Data.EntityClient" /> </connectionStrings> </configuration> |
Changes to testlinq/NorthwindModel.Designer.cs.
1 2 3 | //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. | | | | | | | | | | | | | | | | | | | | | | | | | | < < < < < < < < < < < | 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 | //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:2.0.50727.3051 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ [assembly: global::System.Data.Objects.DataClasses.EdmSchemaAttribute()] [assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("northwindModel", "FK_Products_CategoryID_CategoryID", "Categories", global::System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(testlinq.Categories), "Products", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(testlinq.Products))] [assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("northwindModel", "FK_Orders_CustomerID_CustomerID", "Customers", global::System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(testlinq.Customers), "Orders", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(testlinq.Orders))] [assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("northwindModel", "FK_Employees_ReportsTo_EmployeeID", "Employees", global::System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(testlinq.Employees), "Employees1", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(testlinq.Employees))] [assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("northwindModel", "FK_Orders_EmployeeID_EmployeeID", "Employees", global::System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(testlinq.Employees), "Orders", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(testlinq.Orders))] [assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("northwindModel", "FK_Order_Details_OrderID_OrderID", "Orders", global::System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(testlinq.Orders), "Order_Details", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(testlinq.Order_Details))] [assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("northwindModel", "FK_Order_Details_ProductID_ProductID", "Products", global::System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(testlinq.Products), "Order_Details", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(testlinq.Order_Details))] [assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("northwindModel", "FK_Orders_ShipVia_ShipperID", "Shippers", global::System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(testlinq.Shippers), "Orders", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(testlinq.Orders))] [assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("northwindModel", "FK_Products_SupplierID_SupplierID", "Suppliers", global::System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(testlinq.Suppliers), "Products", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(testlinq.Products))] [assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("northwindModel", "FK_Territories_RegionID_RegionID", "Region", global::System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(testlinq.Region), "Territories", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(testlinq.Territories))] [assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("northwindModel", "CustomerCustomerDemo", "Customers", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(testlinq.Customers), "CustomerDemographics", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(testlinq.CustomerDemographics))] [assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("northwindModel", "EmployeeTerritories", "Employees", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(testlinq.Employees), "Territories", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(testlinq.Territories))] // Original file name: // Generation date: 8/3/2008 3:16:52 AM namespace testlinq { /// <summary> /// There are no comments for northwindEntities in the schema. /// </summary> public partial class northwindEntities : global::System.Data.Objects.ObjectContext { /// <summary> /// Initializes a new northwindEntities object using the connection string found in the 'northwindEntities' section of the application configuration file. /// </summary> public northwindEntities() : base("name=northwindEntities", "northwindEntities") { this.OnContextCreated(); } /// <summary> /// Initialize a new northwindEntities object. /// </summary> public northwindEntities(string connectionString) : base(connectionString, "northwindEntities") { this.OnContextCreated(); } /// <summary> /// Initialize a new northwindEntities object. /// </summary> public northwindEntities(global::System.Data.EntityClient.EntityConnection connection) : base(connection, "northwindEntities") { this.OnContextCreated(); } partial void OnContextCreated(); /// <summary> /// There are no comments for Categories in the schema. /// </summary> public global::System.Data.Objects.ObjectQuery<Categories> Categories { get { if ((this._Categories == null)) { this._Categories = base.CreateQuery<Categories>("[Categories]"); } return this._Categories; } } private global::System.Data.Objects.ObjectQuery<Categories> _Categories; /// <summary> /// There are no comments for CustomerDemographics in the schema. /// </summary> public global::System.Data.Objects.ObjectQuery<CustomerDemographics> CustomerDemographics { get { if ((this._CustomerDemographics == null)) { this._CustomerDemographics = base.CreateQuery<CustomerDemographics>("[CustomerDemographics]"); } return this._CustomerDemographics; } } private global::System.Data.Objects.ObjectQuery<CustomerDemographics> _CustomerDemographics; /// <summary> /// There are no comments for Customers in the schema. /// </summary> public global::System.Data.Objects.ObjectQuery<Customers> Customers { get { if ((this._Customers == null)) { this._Customers = base.CreateQuery<Customers>("[Customers]"); } return this._Customers; } } private global::System.Data.Objects.ObjectQuery<Customers> _Customers; /// <summary> /// There are no comments for Employees in the schema. /// </summary> public global::System.Data.Objects.ObjectQuery<Employees> Employees { get { if ((this._Employees == null)) { this._Employees = base.CreateQuery<Employees>("[Employees]"); } return this._Employees; } } private global::System.Data.Objects.ObjectQuery<Employees> _Employees; /// <summary> /// There are no comments for Order_Details in the schema. /// </summary> public global::System.Data.Objects.ObjectQuery<Order_Details> Order_Details { get { if ((this._Order_Details == null)) { this._Order_Details = base.CreateQuery<Order_Details>("[Order_Details]"); } return this._Order_Details; } } private global::System.Data.Objects.ObjectQuery<Order_Details> _Order_Details; /// <summary> /// There are no comments for Orders in the schema. /// </summary> public global::System.Data.Objects.ObjectQuery<Orders> Orders { get { if ((this._Orders == null)) { this._Orders = base.CreateQuery<Orders>("[Orders]"); } return this._Orders; } } private global::System.Data.Objects.ObjectQuery<Orders> _Orders; /// <summary> /// There are no comments for Products in the schema. /// </summary> public global::System.Data.Objects.ObjectQuery<Products> Products { get { if ((this._Products == null)) { this._Products = base.CreateQuery<Products>("[Products]"); } return this._Products; } } private global::System.Data.Objects.ObjectQuery<Products> _Products; /// <summary> /// There are no comments for Region in the schema. /// </summary> public global::System.Data.Objects.ObjectQuery<Region> Region { get { if ((this._Region == null)) { this._Region = base.CreateQuery<Region>("[Region]"); } return this._Region; } } private global::System.Data.Objects.ObjectQuery<Region> _Region; /// <summary> /// There are no comments for Shippers in the schema. /// </summary> public global::System.Data.Objects.ObjectQuery<Shippers> Shippers { get { if ((this._Shippers == null)) { this._Shippers = base.CreateQuery<Shippers>("[Shippers]"); } return this._Shippers; } } private global::System.Data.Objects.ObjectQuery<Shippers> _Shippers; /// <summary> /// There are no comments for Suppliers in the schema. /// </summary> public global::System.Data.Objects.ObjectQuery<Suppliers> Suppliers { get { if ((this._Suppliers == null)) { this._Suppliers = base.CreateQuery<Suppliers>("[Suppliers]"); } return this._Suppliers; } } private global::System.Data.Objects.ObjectQuery<Suppliers> _Suppliers; /// <summary> /// There are no comments for Territories in the schema. /// </summary> public global::System.Data.Objects.ObjectQuery<Territories> Territories { get { if ((this._Territories == null)) { this._Territories = base.CreateQuery<Territories>("[Territories]"); |
︙ | ︙ | |||
307 308 309 310 311 312 313 | /// </summary> public void AddToTerritories(Territories territories) { base.AddObject("Territories", territories); } } /// <summary> | | | | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | /// </summary> public void AddToTerritories(Territories territories) { base.AddObject("Territories", territories); } } /// <summary> /// There are no comments for northwindModel.Categories in the schema. /// </summary> /// <KeyProperties> /// CategoryID /// </KeyProperties> [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="northwindModel", Name="Categories")] [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] [global::System.Serializable()] public partial class Categories : global::System.Data.Objects.DataClasses.EntityObject { /// <summary> /// Create a new Categories object. /// </summary> |
︙ | ︙ | |||
424 425 426 427 428 429 430 | } private byte[] _Picture; partial void OnPictureChanging(byte[] value); partial void OnPictureChanged(); /// <summary> /// There are no comments for Products in the schema. /// </summary> | | < | | | | | 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 | } private byte[] _Picture; partial void OnPictureChanging(byte[] value); partial void OnPictureChanged(); /// <summary> /// There are no comments for Products in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Products_CategoryID_CategoryID", "Products")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityCollection<Products> Products { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Products>("northwindModel.FK_Products_CategoryID_CategoryID", "Products"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Products>("northwindModel.FK_Products_CategoryID_CategoryID", "Products", value); } } } } /// <summary> /// There are no comments for northwindModel.CustomerDemographics in the schema. /// </summary> /// <KeyProperties> /// CustomerTypeID /// </KeyProperties> [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="northwindModel", Name="CustomerDemographics")] [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] [global::System.Serializable()] public partial class CustomerDemographics : global::System.Data.Objects.DataClasses.EntityObject { /// <summary> /// Create a new CustomerDemographics object. /// </summary> |
︙ | ︙ | |||
514 515 516 517 518 519 520 | } private string _CustomerDesc; partial void OnCustomerDescChanging(string value); partial void OnCustomerDescChanged(); /// <summary> /// There are no comments for Customers in the schema. /// </summary> | | < | | | | | 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 | } private string _CustomerDesc; partial void OnCustomerDescChanging(string value); partial void OnCustomerDescChanged(); /// <summary> /// There are no comments for Customers in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "CustomerCustomerDemo", "Customers")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityCollection<Customers> Customers { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Customers>("northwindModel.CustomerCustomerDemo", "Customers"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Customers>("northwindModel.CustomerCustomerDemo", "Customers", value); } } } } /// <summary> /// There are no comments for northwindModel.Customers in the schema. /// </summary> /// <KeyProperties> /// CustomerID /// </KeyProperties> [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="northwindModel", Name="Customers")] [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] [global::System.Serializable()] public partial class Customers : global::System.Data.Objects.DataClasses.EntityObject { /// <summary> /// Create a new Customers object. /// </summary> |
︙ | ︙ | |||
813 814 815 816 817 818 819 | } private string _Fax; partial void OnFaxChanging(string value); partial void OnFaxChanged(); /// <summary> /// There are no comments for Orders in the schema. /// </summary> | | < | | | < | | | | | 800 801 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 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | } private string _Fax; partial void OnFaxChanging(string value); partial void OnFaxChanged(); /// <summary> /// There are no comments for Orders in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Orders_CustomerID_CustomerID", "Orders")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityCollection<Orders> Orders { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Orders>("northwindModel.FK_Orders_CustomerID_CustomerID", "Orders"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Orders>("northwindModel.FK_Orders_CustomerID_CustomerID", "Orders", value); } } } /// <summary> /// There are no comments for CustomerDemographics in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "CustomerCustomerDemo", "CustomerDemographics")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityCollection<CustomerDemographics> CustomerDemographics { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<CustomerDemographics>("northwindModel.CustomerCustomerDemo", "CustomerDemographics"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<CustomerDemographics>("northwindModel.CustomerCustomerDemo", "CustomerDemographics", value); } } } } /// <summary> /// There are no comments for northwindModel.Employees in the schema. /// </summary> /// <KeyProperties> /// EmployeeID /// </KeyProperties> [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="northwindModel", Name="Employees")] [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] [global::System.Serializable()] public partial class Employees : global::System.Data.Objects.DataClasses.EntityObject { /// <summary> /// Create a new Employees object. /// </summary> |
︙ | ︙ | |||
1274 1275 1276 1277 1278 1279 1280 | } private string _PhotoPath; partial void OnPhotoPathChanging(string value); partial void OnPhotoPathChanged(); /// <summary> /// There are no comments for Employees1 in the schema. /// </summary> | | < | | | < | | < > | | | < | | | < | | | | | 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 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 | } private string _PhotoPath; partial void OnPhotoPathChanging(string value); partial void OnPhotoPathChanged(); /// <summary> /// There are no comments for Employees1 in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Employees_ReportsTo_EmployeeID", "Employees1")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityCollection<Employees> Employees1 { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Employees>("northwindModel.FK_Employees_ReportsTo_EmployeeID", "Employees1"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Employees>("northwindModel.FK_Employees_ReportsTo_EmployeeID", "Employees1", value); } } } /// <summary> /// There are no comments for Employees2 in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Employees_ReportsTo_EmployeeID", "Employees")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public Employees Employees2 { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Employees>("northwindModel.FK_Employees_ReportsTo_EmployeeID", "Employees").Value; } set { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Employees>("northwindModel.FK_Employees_ReportsTo_EmployeeID", "Employees").Value = value; } } /// <summary> /// There are no comments for Employees2 in the schema. /// </summary> [global::System.ComponentModel.BrowsableAttribute(false)] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityReference<Employees> Employees2Reference { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Employees>("northwindModel.FK_Employees_ReportsTo_EmployeeID", "Employees"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Employees>("northwindModel.FK_Employees_ReportsTo_EmployeeID", "Employees", value); } } } /// <summary> /// There are no comments for Orders in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Orders_EmployeeID_EmployeeID", "Orders")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityCollection<Orders> Orders { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Orders>("northwindModel.FK_Orders_EmployeeID_EmployeeID", "Orders"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Orders>("northwindModel.FK_Orders_EmployeeID_EmployeeID", "Orders", value); } } } /// <summary> /// There are no comments for Territories in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "EmployeeTerritories", "Territories")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityCollection<Territories> Territories { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Territories>("northwindModel.EmployeeTerritories", "Territories"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Territories>("northwindModel.EmployeeTerritories", "Territories", value); } } } } /// <summary> /// There are no comments for northwindModel.Order_Details in the schema. /// </summary> /// <KeyProperties> /// OrderID /// ProductID /// </KeyProperties> [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="northwindModel", Name="Order_Details")] [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] [global::System.Serializable()] public partial class Order_Details : global::System.Data.Objects.DataClasses.EntityObject { /// <summary> /// Create a new Order_Details object. /// </summary> |
︙ | ︙ | |||
1524 1525 1526 1527 1528 1529 1530 | } private float _Discount; partial void OnDiscountChanging(float value); partial void OnDiscountChanged(); /// <summary> /// There are no comments for Orders in the schema. /// </summary> | | < | | < > | | | < | | < > | | | | | 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 | } private float _Discount; partial void OnDiscountChanging(float value); partial void OnDiscountChanged(); /// <summary> /// There are no comments for Orders in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Order_Details_OrderID_OrderID", "Orders")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public Orders Orders { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Orders>("northwindModel.FK_Order_Details_OrderID_OrderID", "Orders").Value; } set { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Orders>("northwindModel.FK_Order_Details_OrderID_OrderID", "Orders").Value = value; } } /// <summary> /// There are no comments for Orders in the schema. /// </summary> [global::System.ComponentModel.BrowsableAttribute(false)] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityReference<Orders> OrdersReference { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Orders>("northwindModel.FK_Order_Details_OrderID_OrderID", "Orders"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Orders>("northwindModel.FK_Order_Details_OrderID_OrderID", "Orders", value); } } } /// <summary> /// There are no comments for Products in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Order_Details_ProductID_ProductID", "Products")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public Products Products { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Products>("northwindModel.FK_Order_Details_ProductID_ProductID", "Products").Value; } set { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Products>("northwindModel.FK_Order_Details_ProductID_ProductID", "Products").Value = value; } } /// <summary> /// There are no comments for Products in the schema. /// </summary> [global::System.ComponentModel.BrowsableAttribute(false)] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityReference<Products> ProductsReference { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Products>("northwindModel.FK_Order_Details_ProductID_ProductID", "Products"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Products>("northwindModel.FK_Order_Details_ProductID_ProductID", "Products", value); } } } } /// <summary> /// There are no comments for northwindModel.Orders in the schema. /// </summary> /// <KeyProperties> /// OrderID /// </KeyProperties> [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="northwindModel", Name="Orders")] [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] [global::System.Serializable()] public partial class Orders : global::System.Data.Objects.DataClasses.EntityObject { /// <summary> /// Create a new Orders object. /// </summary> |
︙ | ︙ | |||
1875 1876 1877 1878 1879 1880 1881 | } private string _ShipCountry; partial void OnShipCountryChanging(string value); partial void OnShipCountryChanged(); /// <summary> /// There are no comments for Customers in the schema. /// </summary> | | < | | < > | | > > > > > > > > > > > > > > > > > > < < < < < < < < < < < < < < < < < < < | | | < | | | < | | < > | | | | | 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 | } private string _ShipCountry; partial void OnShipCountryChanging(string value); partial void OnShipCountryChanged(); /// <summary> /// There are no comments for Customers in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Orders_CustomerID_CustomerID", "Customers")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public Customers Customers { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Customers>("northwindModel.FK_Orders_CustomerID_CustomerID", "Customers").Value; } set { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Customers>("northwindModel.FK_Orders_CustomerID_CustomerID", "Customers").Value = value; } } /// <summary> /// There are no comments for Customers in the schema. /// </summary> [global::System.ComponentModel.BrowsableAttribute(false)] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityReference<Customers> CustomersReference { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Customers>("northwindModel.FK_Orders_CustomerID_CustomerID", "Customers"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Customers>("northwindModel.FK_Orders_CustomerID_CustomerID", "Customers", value); } } } /// <summary> /// There are no comments for Employees in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Orders_EmployeeID_EmployeeID", "Employees")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public Employees Employees { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Employees>("northwindModel.FK_Orders_EmployeeID_EmployeeID", "Employees").Value; } set { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Employees>("northwindModel.FK_Orders_EmployeeID_EmployeeID", "Employees").Value = value; } } /// <summary> /// There are no comments for Employees in the schema. /// </summary> [global::System.ComponentModel.BrowsableAttribute(false)] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityReference<Employees> EmployeesReference { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Employees>("northwindModel.FK_Orders_EmployeeID_EmployeeID", "Employees"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Employees>("northwindModel.FK_Orders_EmployeeID_EmployeeID", "Employees", value); } } } /// <summary> /// There are no comments for Order_Details in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Order_Details_OrderID_OrderID", "Order_Details")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityCollection<Order_Details> Order_Details { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Order_Details>("northwindModel.FK_Order_Details_OrderID_OrderID", "Order_Details"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Order_Details>("northwindModel.FK_Order_Details_OrderID_OrderID", "Order_Details", value); } } } /// <summary> /// There are no comments for Shippers in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Orders_ShipVia_ShipperID", "Shippers")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public Shippers Shippers { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Shippers>("northwindModel.FK_Orders_ShipVia_ShipperID", "Shippers").Value; } set { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Shippers>("northwindModel.FK_Orders_ShipVia_ShipperID", "Shippers").Value = value; } } /// <summary> /// There are no comments for Shippers in the schema. /// </summary> [global::System.ComponentModel.BrowsableAttribute(false)] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityReference<Shippers> ShippersReference { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Shippers>("northwindModel.FK_Orders_ShipVia_ShipperID", "Shippers"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Shippers>("northwindModel.FK_Orders_ShipVia_ShipperID", "Shippers", value); } } } } /// <summary> /// There are no comments for northwindModel.Products in the schema. /// </summary> /// <KeyProperties> /// ProductID /// </KeyProperties> [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="northwindModel", Name="Products")] [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] [global::System.Serializable()] public partial class Products : global::System.Data.Objects.DataClasses.EntityObject { /// <summary> /// Create a new Products object. /// </summary> |
︙ | ︙ | |||
2221 2222 2223 2224 2225 2226 2227 | } private bool _Discontinued; partial void OnDiscontinuedChanging(bool value); partial void OnDiscontinuedChanged(); /// <summary> /// There are no comments for Categories in the schema. /// </summary> | | < | | < > | | | < | | | < | | < > | | | | | 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 | } private bool _Discontinued; partial void OnDiscontinuedChanging(bool value); partial void OnDiscontinuedChanged(); /// <summary> /// There are no comments for Categories in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Products_CategoryID_CategoryID", "Categories")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public Categories Categories { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Categories>("northwindModel.FK_Products_CategoryID_CategoryID", "Categories").Value; } set { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Categories>("northwindModel.FK_Products_CategoryID_CategoryID", "Categories").Value = value; } } /// <summary> /// There are no comments for Categories in the schema. /// </summary> [global::System.ComponentModel.BrowsableAttribute(false)] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityReference<Categories> CategoriesReference { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Categories>("northwindModel.FK_Products_CategoryID_CategoryID", "Categories"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Categories>("northwindModel.FK_Products_CategoryID_CategoryID", "Categories", value); } } } /// <summary> /// There are no comments for Order_Details in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Order_Details_ProductID_ProductID", "Order_Details")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityCollection<Order_Details> Order_Details { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Order_Details>("northwindModel.FK_Order_Details_ProductID_ProductID", "Order_Details"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Order_Details>("northwindModel.FK_Order_Details_ProductID_ProductID", "Order_Details", value); } } } /// <summary> /// There are no comments for Suppliers in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Products_SupplierID_SupplierID", "Suppliers")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public Suppliers Suppliers { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Suppliers>("northwindModel.FK_Products_SupplierID_SupplierID", "Suppliers").Value; } set { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Suppliers>("northwindModel.FK_Products_SupplierID_SupplierID", "Suppliers").Value = value; } } /// <summary> /// There are no comments for Suppliers in the schema. /// </summary> [global::System.ComponentModel.BrowsableAttribute(false)] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityReference<Suppliers> SuppliersReference { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Suppliers>("northwindModel.FK_Products_SupplierID_SupplierID", "Suppliers"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Suppliers>("northwindModel.FK_Products_SupplierID_SupplierID", "Suppliers", value); } } } } /// <summary> /// There are no comments for northwindModel.Region in the schema. /// </summary> /// <KeyProperties> /// RegionID /// </KeyProperties> [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="northwindModel", Name="Region")] [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] [global::System.Serializable()] public partial class Region : global::System.Data.Objects.DataClasses.EntityObject { /// <summary> /// Create a new Region object. /// </summary> |
︙ | ︙ | |||
2389 2390 2391 2392 2393 2394 2395 | } private string _RegionDescription; partial void OnRegionDescriptionChanging(string value); partial void OnRegionDescriptionChanged(); /// <summary> /// There are no comments for Territories in the schema. /// </summary> | | < | | | | | 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 | } private string _RegionDescription; partial void OnRegionDescriptionChanging(string value); partial void OnRegionDescriptionChanged(); /// <summary> /// There are no comments for Territories in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Territories_RegionID_RegionID", "Territories")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityCollection<Territories> Territories { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Territories>("northwindModel.FK_Territories_RegionID_RegionID", "Territories"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Territories>("northwindModel.FK_Territories_RegionID_RegionID", "Territories", value); } } } } /// <summary> /// There are no comments for northwindModel.Shippers in the schema. /// </summary> /// <KeyProperties> /// ShipperID /// </KeyProperties> [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="northwindModel", Name="Shippers")] [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] [global::System.Serializable()] public partial class Shippers : global::System.Data.Objects.DataClasses.EntityObject { /// <summary> /// Create a new Shippers object. /// </summary> |
︙ | ︙ | |||
2504 2505 2506 2507 2508 2509 2510 | } private string _Phone; partial void OnPhoneChanging(string value); partial void OnPhoneChanged(); /// <summary> /// There are no comments for Orders in the schema. /// </summary> | | < | | | | | 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 | } private string _Phone; partial void OnPhoneChanging(string value); partial void OnPhoneChanged(); /// <summary> /// There are no comments for Orders in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Orders_ShipVia_ShipperID", "Orders")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityCollection<Orders> Orders { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Orders>("northwindModel.FK_Orders_ShipVia_ShipperID", "Orders"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Orders>("northwindModel.FK_Orders_ShipVia_ShipperID", "Orders", value); } } } } /// <summary> /// There are no comments for northwindModel.Suppliers in the schema. /// </summary> /// <KeyProperties> /// SupplierID /// </KeyProperties> [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="northwindModel", Name="Suppliers")] [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] [global::System.Serializable()] public partial class Suppliers : global::System.Data.Objects.DataClasses.EntityObject { /// <summary> /// Create a new Suppliers object. /// </summary> |
︙ | ︙ | |||
2826 2827 2828 2829 2830 2831 2832 | } private string _HomePage; partial void OnHomePageChanging(string value); partial void OnHomePageChanged(); /// <summary> /// There are no comments for Products in the schema. /// </summary> | | < | | | | | 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 | } private string _HomePage; partial void OnHomePageChanging(string value); partial void OnHomePageChanged(); /// <summary> /// There are no comments for Products in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Products_SupplierID_SupplierID", "Products")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityCollection<Products> Products { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Products>("northwindModel.FK_Products_SupplierID_SupplierID", "Products"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Products>("northwindModel.FK_Products_SupplierID_SupplierID", "Products", value); } } } } /// <summary> /// There are no comments for northwindModel.Territories in the schema. /// </summary> /// <KeyProperties> /// TerritoryID /// </KeyProperties> [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="northwindModel", Name="Territories")] [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] [global::System.Serializable()] public partial class Territories : global::System.Data.Objects.DataClasses.EntityObject { /// <summary> /// Create a new Territories object. /// </summary> |
︙ | ︙ | |||
2918 2919 2920 2921 2922 2923 2924 | } private string _TerritoryDescription; partial void OnTerritoryDescriptionChanging(string value); partial void OnTerritoryDescriptionChanged(); /// <summary> /// There are no comments for Region in the schema. /// </summary> | | < | | < > | | | < | | | 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 | } private string _TerritoryDescription; partial void OnTerritoryDescriptionChanging(string value); partial void OnTerritoryDescriptionChanged(); /// <summary> /// There are no comments for Region in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "FK_Territories_RegionID_RegionID", "Region")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public Region Region { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Region>("northwindModel.FK_Territories_RegionID_RegionID", "Region").Value; } set { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Region>("northwindModel.FK_Territories_RegionID_RegionID", "Region").Value = value; } } /// <summary> /// There are no comments for Region in the schema. /// </summary> [global::System.ComponentModel.BrowsableAttribute(false)] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityReference<Region> RegionReference { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Region>("northwindModel.FK_Territories_RegionID_RegionID", "Region"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Region>("northwindModel.FK_Territories_RegionID_RegionID", "Region", value); } } } /// <summary> /// There are no comments for Employees in the schema. /// </summary> [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("northwindModel", "EmployeeTerritories", "Employees")] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public global::System.Data.Objects.DataClasses.EntityCollection<Employees> Employees { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Employees>("northwindModel.EmployeeTerritories", "Employees"); } set { if ((value != null)) { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Employees>("northwindModel.EmployeeTerritories", "Employees", value); } } } } } |
Changes to testlinq/NorthwindModel.edmx.
1 2 3 4 5 | <?xml version="1.0" encoding="utf-8"?> <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"> <edmx:Runtime> <!-- SSDL content --> <edmx:StorageModels> | > | | | | | | < | > | | | | | | | | | > > > > | | < < < < | | | | | | | | | 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 | <?xml version="1.0" encoding="utf-8"?> <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"> <!-- EF Runtime content --> <edmx:Runtime> <!-- SSDL content --> <edmx:StorageModels> <Schema Namespace="northwindModel.Store" Alias="Self" Provider="System.Data.SQLite" ProviderManifestToken="ISO8601" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl"> <EntityContainer Name="northwindModelStoreContainer"> <EntitySet Name="Categories" EntityType="northwindModel.Store.Categories" store:Type="Tables" /> <EntitySet Name="CustomerCustomerDemo" EntityType="northwindModel.Store.CustomerCustomerDemo" store:Type="Tables" /> <EntitySet Name="CustomerDemographics" EntityType="northwindModel.Store.CustomerDemographics" store:Type="Tables" /> <EntitySet Name="Customers" EntityType="northwindModel.Store.Customers" store:Type="Tables" /> <EntitySet Name="Employees" EntityType="northwindModel.Store.Employees" store:Type="Tables" /> <EntitySet Name="EmployeeTerritories" EntityType="northwindModel.Store.EmployeeTerritories" store:Type="Tables" /> <EntitySet Name="Order Details" EntityType="northwindModel.Store.Order Details" store:Type="Tables" /> <EntitySet Name="Orders" EntityType="northwindModel.Store.Orders" store:Type="Tables" /> <EntitySet Name="Products" EntityType="northwindModel.Store.Products" store:Type="Tables" /> <EntitySet Name="Region" EntityType="northwindModel.Store.Region" store:Type="Tables" /> <EntitySet Name="Shippers" EntityType="northwindModel.Store.Shippers" store:Type="Tables" /> <EntitySet Name="Suppliers" EntityType="northwindModel.Store.Suppliers" store:Type="Tables" /> <EntitySet Name="Territories" EntityType="northwindModel.Store.Territories" store:Type="Tables" /> <AssociationSet Name="FK_CustomerCustomerDemo_CustomerID_CustomerID" Association="northwindModel.Store.FK_CustomerCustomerDemo_CustomerID_CustomerID"> <End Role="Customers" EntitySet="Customers" /> <End Role="CustomerCustomerDemo" EntitySet="CustomerCustomerDemo" /> </AssociationSet> <AssociationSet Name="FK_CustomerCustomerDemo_CustomerTypeID_CustomerTypeId" Association="northwindModel.Store.FK_CustomerCustomerDemo_CustomerTypeID_CustomerTypeId"> <End Role="CustomerDemographics" EntitySet="CustomerDemographics" /> <End Role="CustomerCustomerDemo" EntitySet="CustomerCustomerDemo" /> </AssociationSet> <AssociationSet Name="FK_Employees_ReportsTo_EmployeeID" Association="northwindModel.Store.FK_Employees_ReportsTo_EmployeeID"> <End Role="Employees" EntitySet="Employees" /> <End Role="Employees1" EntitySet="Employees" /> </AssociationSet> <AssociationSet Name="FK_EmployeeTerritories_EmployeeID_EmployeeID" Association="northwindModel.Store.FK_EmployeeTerritories_EmployeeID_EmployeeID"> <End Role="Employees" EntitySet="Employees" /> <End Role="EmployeeTerritories" EntitySet="EmployeeTerritories" /> </AssociationSet> <AssociationSet Name="FK_EmployeeTerritories_TerritoryID_TerritoryID" Association="northwindModel.Store.FK_EmployeeTerritories_TerritoryID_TerritoryID"> <End Role="Territories" EntitySet="Territories" /> <End Role="EmployeeTerritories" EntitySet="EmployeeTerritories" /> </AssociationSet> <AssociationSet Name="FK_Order Details_OrderID_OrderID" Association="northwindModel.Store.FK_Order Details_OrderID_OrderID"> <End Role="Orders" EntitySet="Orders" /> <End Role="Order Details" EntitySet="Order Details" /> </AssociationSet> <AssociationSet Name="FK_Order Details_ProductID_ProductID" Association="northwindModel.Store.FK_Order Details_ProductID_ProductID"> <End Role="Products" EntitySet="Products" /> <End Role="Order Details" EntitySet="Order Details" /> </AssociationSet> <AssociationSet Name="FK_Orders_CustomerID_CustomerID" Association="northwindModel.Store.FK_Orders_CustomerID_CustomerID"> <End Role="Customers" EntitySet="Customers" /> <End Role="Orders" EntitySet="Orders" /> </AssociationSet> <AssociationSet Name="FK_Orders_EmployeeID_EmployeeID" Association="northwindModel.Store.FK_Orders_EmployeeID_EmployeeID"> <End Role="Employees" EntitySet="Employees" /> <End Role="Orders" EntitySet="Orders" /> </AssociationSet> <AssociationSet Name="FK_Orders_ShipVia_ShipperID" Association="northwindModel.Store.FK_Orders_ShipVia_ShipperID"> <End Role="Shippers" EntitySet="Shippers" /> <End Role="Orders" EntitySet="Orders" /> </AssociationSet> <AssociationSet Name="FK_Products_CategoryID_CategoryID" Association="northwindModel.Store.FK_Products_CategoryID_CategoryID"> <End Role="Categories" EntitySet="Categories" /> <End Role="Products" EntitySet="Products" /> </AssociationSet> <AssociationSet Name="FK_Products_SupplierID_SupplierID" Association="northwindModel.Store.FK_Products_SupplierID_SupplierID"> <End Role="Suppliers" EntitySet="Suppliers" /> <End Role="Products" EntitySet="Products" /> </AssociationSet> <AssociationSet Name="FK_Territories_RegionID_RegionID" Association="northwindModel.Store.FK_Territories_RegionID_RegionID"> <End Role="Region" EntitySet="Region" /> <End Role="Territories" EntitySet="Territories" /> </AssociationSet> </EntityContainer> <EntityType Name="Categories"> <Key> <PropertyRef Name="CategoryID" /> |
︙ | ︙ | |||
107 108 109 110 111 112 113 | <Property Name="City" Type="nvarchar" MaxLength="15" /> <Property Name="Region" Type="nvarchar" MaxLength="15" /> <Property Name="PostalCode" Type="nvarchar" MaxLength="10" /> <Property Name="Country" Type="nvarchar" MaxLength="15" /> <Property Name="Phone" Type="nvarchar" MaxLength="24" /> <Property Name="Fax" Type="nvarchar" MaxLength="24" /> </EntityType> | < < < < < < < < | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | <Property Name="City" Type="nvarchar" MaxLength="15" /> <Property Name="Region" Type="nvarchar" MaxLength="15" /> <Property Name="PostalCode" Type="nvarchar" MaxLength="10" /> <Property Name="Country" Type="nvarchar" MaxLength="15" /> <Property Name="Phone" Type="nvarchar" MaxLength="24" /> <Property Name="Fax" Type="nvarchar" MaxLength="24" /> </EntityType> <EntityType Name="Employees"> <Key> <PropertyRef Name="EmployeeID" /> </Key> <Property Name="EmployeeID" Type="integer" Nullable="false" StoreGeneratedPattern="Identity" /> <Property Name="LastName" Type="nvarchar" Nullable="false" MaxLength="20" /> <Property Name="FirstName" Type="nvarchar" Nullable="false" MaxLength="10" /> |
︙ | ︙ | |||
138 139 140 141 142 143 144 145 146 147 148 149 150 151 | <Property Name="HomePhone" Type="nvarchar" MaxLength="24" /> <Property Name="Extension" Type="nvarchar" MaxLength="4" /> <Property Name="Photo" Type="blob" /> <Property Name="Notes" Type="nvarchar" /> <Property Name="ReportsTo" Type="integer" /> <Property Name="PhotoPath" Type="nvarchar" MaxLength="255" /> </EntityType> <EntityType Name="Order Details"> <Key> <PropertyRef Name="OrderID" /> <PropertyRef Name="ProductID" /> </Key> <Property Name="OrderID" Type="integer" Nullable="false" StoreGeneratedPattern="Identity" /> <Property Name="ProductID" Type="integer" Nullable="false" StoreGeneratedPattern="Identity" /> | > > > > > > > > | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | <Property Name="HomePhone" Type="nvarchar" MaxLength="24" /> <Property Name="Extension" Type="nvarchar" MaxLength="4" /> <Property Name="Photo" Type="blob" /> <Property Name="Notes" Type="nvarchar" /> <Property Name="ReportsTo" Type="integer" /> <Property Name="PhotoPath" Type="nvarchar" MaxLength="255" /> </EntityType> <EntityType Name="EmployeeTerritories"> <Key> <PropertyRef Name="EmployeeID" /> <PropertyRef Name="TerritoryID" /> </Key> <Property Name="EmployeeID" Type="integer" Nullable="false" StoreGeneratedPattern="Identity" /> <Property Name="TerritoryID" Type="nvarchar" Nullable="false" MaxLength="20" StoreGeneratedPattern="Identity" /> </EntityType> <EntityType Name="Order Details"> <Key> <PropertyRef Name="OrderID" /> <PropertyRef Name="ProductID" /> </Key> <Property Name="OrderID" Type="integer" Nullable="false" StoreGeneratedPattern="Identity" /> <Property Name="ProductID" Type="integer" Nullable="false" StoreGeneratedPattern="Identity" /> |
︙ | ︙ | |||
224 225 226 227 228 229 230 | <PropertyRef Name="TerritoryID" /> </Key> <Property Name="TerritoryID" Type="nvarchar" Nullable="false" MaxLength="20" StoreGeneratedPattern="Identity" /> <Property Name="TerritoryDescription" Type="nvarchar" Nullable="false" MaxLength="50" /> <Property Name="RegionID" Type="integer" Nullable="false" /> </EntityType> <Association Name="FK_CustomerCustomerDemo_CustomerID_CustomerID"> | | | | | > > > > > > > > > > > > | | | | < < < < < < < < < < < < | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | <PropertyRef Name="TerritoryID" /> </Key> <Property Name="TerritoryID" Type="nvarchar" Nullable="false" MaxLength="20" StoreGeneratedPattern="Identity" /> <Property Name="TerritoryDescription" Type="nvarchar" Nullable="false" MaxLength="50" /> <Property Name="RegionID" Type="integer" Nullable="false" /> </EntityType> <Association Name="FK_CustomerCustomerDemo_CustomerID_CustomerID"> <End Role="Customers" Type="northwindModel.Store.Customers" Multiplicity="1" /> <End Role="CustomerCustomerDemo" Type="northwindModel.Store.CustomerCustomerDemo" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="Customers"> <PropertyRef Name="CustomerID" /> </Principal> <Dependent Role="CustomerCustomerDemo"> <PropertyRef Name="CustomerID" /> </Dependent> </ReferentialConstraint> </Association> <Association Name="FK_CustomerCustomerDemo_CustomerTypeID_CustomerTypeId"> <End Role="CustomerDemographics" Type="northwindModel.Store.CustomerDemographics" Multiplicity="1" /> <End Role="CustomerCustomerDemo" Type="northwindModel.Store.CustomerCustomerDemo" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="CustomerDemographics"> <PropertyRef Name="CustomerTypeID" /> </Principal> <Dependent Role="CustomerCustomerDemo"> <PropertyRef Name="CustomerTypeID" /> </Dependent> </ReferentialConstraint> </Association> <Association Name="FK_Employees_ReportsTo_EmployeeID"> <End Role="Employees" Type="northwindModel.Store.Employees" Multiplicity="0..1" /> <End Role="Employees1" Type="northwindModel.Store.Employees" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="Employees"> <PropertyRef Name="EmployeeID" /> </Principal> <Dependent Role="Employees1"> <PropertyRef Name="ReportsTo" /> </Dependent> </ReferentialConstraint> </Association> <Association Name="FK_EmployeeTerritories_EmployeeID_EmployeeID"> <End Role="Employees" Type="northwindModel.Store.Employees" Multiplicity="1" /> <End Role="EmployeeTerritories" Type="northwindModel.Store.EmployeeTerritories" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="Employees"> <PropertyRef Name="EmployeeID" /> </Principal> <Dependent Role="EmployeeTerritories"> <PropertyRef Name="EmployeeID" /> </Dependent> </ReferentialConstraint> </Association> <Association Name="FK_EmployeeTerritories_TerritoryID_TerritoryID"> <End Role="Territories" Type="northwindModel.Store.Territories" Multiplicity="1" /> <End Role="EmployeeTerritories" Type="northwindModel.Store.EmployeeTerritories" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="Territories"> <PropertyRef Name="TerritoryID" /> </Principal> <Dependent Role="EmployeeTerritories"> <PropertyRef Name="TerritoryID" /> </Dependent> </ReferentialConstraint> </Association> <Association Name="FK_Order Details_OrderID_OrderID"> <End Role="Orders" Type="northwindModel.Store.Orders" Multiplicity="1" /> <End Role="Order Details" Type="northwindModel.Store.Order Details" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="Orders"> <PropertyRef Name="OrderID" /> </Principal> <Dependent Role="Order Details"> <PropertyRef Name="OrderID" /> </Dependent> </ReferentialConstraint> </Association> <Association Name="FK_Order Details_ProductID_ProductID"> <End Role="Products" Type="northwindModel.Store.Products" Multiplicity="1" /> <End Role="Order Details" Type="northwindModel.Store.Order Details" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="Products"> <PropertyRef Name="ProductID" /> </Principal> <Dependent Role="Order Details"> <PropertyRef Name="ProductID" /> </Dependent> </ReferentialConstraint> </Association> <Association Name="FK_Orders_CustomerID_CustomerID"> <End Role="Customers" Type="northwindModel.Store.Customers" Multiplicity="0..1" /> <End Role="Orders" Type="northwindModel.Store.Orders" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="Customers"> <PropertyRef Name="CustomerID" /> </Principal> <Dependent Role="Orders"> <PropertyRef Name="CustomerID" /> </Dependent> </ReferentialConstraint> </Association> <Association Name="FK_Orders_EmployeeID_EmployeeID"> <End Role="Employees" Type="northwindModel.Store.Employees" Multiplicity="0..1" /> <End Role="Orders" Type="northwindModel.Store.Orders" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="Employees"> <PropertyRef Name="EmployeeID" /> </Principal> <Dependent Role="Orders"> <PropertyRef Name="EmployeeID" /> </Dependent> </ReferentialConstraint> </Association> <Association Name="FK_Orders_ShipVia_ShipperID"> <End Role="Shippers" Type="northwindModel.Store.Shippers" Multiplicity="0..1" /> <End Role="Orders" Type="northwindModel.Store.Orders" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="Shippers"> <PropertyRef Name="ShipperID" /> </Principal> <Dependent Role="Orders"> <PropertyRef Name="ShipVia" /> </Dependent> </ReferentialConstraint> </Association> <Association Name="FK_Products_CategoryID_CategoryID"> <End Role="Categories" Type="northwindModel.Store.Categories" Multiplicity="0..1" /> <End Role="Products" Type="northwindModel.Store.Products" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="Categories"> <PropertyRef Name="CategoryID" /> </Principal> <Dependent Role="Products"> <PropertyRef Name="CategoryID" /> </Dependent> </ReferentialConstraint> </Association> <Association Name="FK_Products_SupplierID_SupplierID"> <End Role="Suppliers" Type="northwindModel.Store.Suppliers" Multiplicity="0..1" /> <End Role="Products" Type="northwindModel.Store.Products" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="Suppliers"> <PropertyRef Name="SupplierID" /> </Principal> <Dependent Role="Products"> <PropertyRef Name="SupplierID" /> </Dependent> </ReferentialConstraint> </Association> <Association Name="FK_Territories_RegionID_RegionID"> <End Role="Region" Type="northwindModel.Store.Region" Multiplicity="1" /> <End Role="Territories" Type="northwindModel.Store.Territories" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="Region"> <PropertyRef Name="RegionID" /> </Principal> <Dependent Role="Territories"> <PropertyRef Name="RegionID" /> </Dependent> </ReferentialConstraint> </Association> </Schema></edmx:StorageModels> <!-- CSDL content --> <edmx:ConceptualModels> <Schema Namespace="northwindModel" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm"> <EntityContainer Name="northwindEntities"> <EntitySet Name="Categories" EntityType="northwindModel.Categories" /> <EntitySet Name="CustomerDemographics" EntityType="northwindModel.CustomerDemographics" /> <EntitySet Name="Customers" EntityType="northwindModel.Customers" /> <EntitySet Name="Employees" EntityType="northwindModel.Employees" /> <EntitySet Name="Order_Details" EntityType="northwindModel.Order_Details" /> <EntitySet Name="Orders" EntityType="northwindModel.Orders" /> <EntitySet Name="Products" EntityType="northwindModel.Products" /> <EntitySet Name="Region" EntityType="northwindModel.Region" /> <EntitySet Name="Shippers" EntityType="northwindModel.Shippers" /> <EntitySet Name="Suppliers" EntityType="northwindModel.Suppliers" /> <EntitySet Name="Territories" EntityType="northwindModel.Territories" /> <AssociationSet Name="FK_Products_CategoryID_CategoryID" Association="northwindModel.FK_Products_CategoryID_CategoryID"> <End Role="Categories" EntitySet="Categories" /> <End Role="Products" EntitySet="Products" /> </AssociationSet> <AssociationSet Name="FK_Orders_CustomerID_CustomerID" Association="northwindModel.FK_Orders_CustomerID_CustomerID"> <End Role="Customers" EntitySet="Customers" /> <End Role="Orders" EntitySet="Orders" /> </AssociationSet> <AssociationSet Name="FK_Employees_ReportsTo_EmployeeID" Association="northwindModel.FK_Employees_ReportsTo_EmployeeID"> <End Role="Employees" EntitySet="Employees" /> <End Role="Employees1" EntitySet="Employees" /> </AssociationSet> <AssociationSet Name="FK_Orders_EmployeeID_EmployeeID" Association="northwindModel.FK_Orders_EmployeeID_EmployeeID"> <End Role="Employees" EntitySet="Employees" /> <End Role="Orders" EntitySet="Orders" /> </AssociationSet> <AssociationSet Name="FK_Order_Details_OrderID_OrderID" Association="northwindModel.FK_Order_Details_OrderID_OrderID"> <End Role="Orders" EntitySet="Orders" /> <End Role="Order_Details" EntitySet="Order_Details" /> </AssociationSet> <AssociationSet Name="FK_Order_Details_ProductID_ProductID" Association="northwindModel.FK_Order_Details_ProductID_ProductID"> <End Role="Products" EntitySet="Products" /> <End Role="Order_Details" EntitySet="Order_Details" /> </AssociationSet> <AssociationSet Name="FK_Orders_ShipVia_ShipperID" Association="northwindModel.FK_Orders_ShipVia_ShipperID"> <End Role="Shippers" EntitySet="Shippers" /> <End Role="Orders" EntitySet="Orders" /> </AssociationSet> <AssociationSet Name="FK_Products_SupplierID_SupplierID" Association="northwindModel.FK_Products_SupplierID_SupplierID"> <End Role="Suppliers" EntitySet="Suppliers" /> <End Role="Products" EntitySet="Products" /> </AssociationSet> <AssociationSet Name="FK_Territories_RegionID_RegionID" Association="northwindModel.FK_Territories_RegionID_RegionID"> <End Role="Region" EntitySet="Region" /> <End Role="Territories" EntitySet="Territories" /> </AssociationSet> <AssociationSet Name="CustomerCustomerDemo" Association="northwindModel.CustomerCustomerDemo"> <End Role="Customers" EntitySet="Customers" /> <End Role="CustomerDemographics" EntitySet="CustomerDemographics" /> </AssociationSet> <AssociationSet Name="EmployeeTerritories" Association="northwindModel.EmployeeTerritories"> <End Role="Employees" EntitySet="Employees" /> <End Role="Territories" EntitySet="Territories" /> </AssociationSet> </EntityContainer> <EntityType Name="Categories"> <Key> <PropertyRef Name="CategoryID" /> </Key> <Property Name="CategoryID" Type="Int64" Nullable="false" /> <Property Name="CategoryName" Type="String" Nullable="false" MaxLength="15" Unicode="true" FixedLength="false" /> <Property Name="Description" Type="String" MaxLength="2147483647" Unicode="true" FixedLength="false" /> <Property Name="Picture" Type="Binary" MaxLength="2147483647" FixedLength="false" /> <NavigationProperty Name="Products" Relationship="northwindModel.FK_Products_CategoryID_CategoryID" FromRole="Categories" ToRole="Products" /> </EntityType> <EntityType Name="CustomerDemographics"> <Key> <PropertyRef Name="CustomerTypeID" /> </Key> <Property Name="CustomerTypeID" Type="String" Nullable="false" MaxLength="10" Unicode="true" FixedLength="false" /> <Property Name="CustomerDesc" Type="String" MaxLength="2147483647" Unicode="true" FixedLength="false" /> <NavigationProperty Name="Customers" Relationship="northwindModel.CustomerCustomerDemo" FromRole="CustomerDemographics" ToRole="Customers" /> </EntityType> <EntityType Name="Customers"> <Key> <PropertyRef Name="CustomerID" /> </Key> <Property Name="CustomerID" Type="String" Nullable="false" MaxLength="5" Unicode="true" FixedLength="false" /> <Property Name="CompanyName" Type="String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" /> <Property Name="ContactName" Type="String" MaxLength="30" Unicode="true" FixedLength="false" /> <Property Name="ContactTitle" Type="String" MaxLength="30" Unicode="true" FixedLength="false" /> <Property Name="Address" Type="String" MaxLength="60" Unicode="true" FixedLength="false" /> <Property Name="City" Type="String" MaxLength="15" Unicode="true" FixedLength="false" /> <Property Name="Region" Type="String" MaxLength="15" Unicode="true" FixedLength="false" /> <Property Name="PostalCode" Type="String" MaxLength="10" Unicode="true" FixedLength="false" /> <Property Name="Country" Type="String" MaxLength="15" Unicode="true" FixedLength="false" /> <Property Name="Phone" Type="String" MaxLength="24" Unicode="true" FixedLength="false" /> <Property Name="Fax" Type="String" MaxLength="24" Unicode="true" FixedLength="false" /> <NavigationProperty Name="Orders" Relationship="northwindModel.FK_Orders_CustomerID_CustomerID" FromRole="Customers" ToRole="Orders" /> <NavigationProperty Name="CustomerDemographics" Relationship="northwindModel.CustomerCustomerDemo" FromRole="Customers" ToRole="CustomerDemographics" /> </EntityType> <EntityType Name="Employees"> <Key> <PropertyRef Name="EmployeeID" /> </Key> <Property Name="EmployeeID" Type="Int64" Nullable="false" /> <Property Name="LastName" Type="String" Nullable="false" MaxLength="20" Unicode="true" FixedLength="false" /> |
︙ | ︙ | |||
498 499 500 501 502 503 504 | <Property Name="PostalCode" Type="String" MaxLength="10" Unicode="true" FixedLength="false" /> <Property Name="Country" Type="String" MaxLength="15" Unicode="true" FixedLength="false" /> <Property Name="HomePhone" Type="String" MaxLength="24" Unicode="true" FixedLength="false" /> <Property Name="Extension" Type="String" MaxLength="4" Unicode="true" FixedLength="false" /> <Property Name="Photo" Type="Binary" MaxLength="2147483647" FixedLength="false" /> <Property Name="Notes" Type="String" MaxLength="2147483647" Unicode="true" FixedLength="false" /> <Property Name="PhotoPath" Type="String" MaxLength="255" Unicode="true" FixedLength="false" /> | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | <Property Name="PostalCode" Type="String" MaxLength="10" Unicode="true" FixedLength="false" /> <Property Name="Country" Type="String" MaxLength="15" Unicode="true" FixedLength="false" /> <Property Name="HomePhone" Type="String" MaxLength="24" Unicode="true" FixedLength="false" /> <Property Name="Extension" Type="String" MaxLength="4" Unicode="true" FixedLength="false" /> <Property Name="Photo" Type="Binary" MaxLength="2147483647" FixedLength="false" /> <Property Name="Notes" Type="String" MaxLength="2147483647" Unicode="true" FixedLength="false" /> <Property Name="PhotoPath" Type="String" MaxLength="255" Unicode="true" FixedLength="false" /> <NavigationProperty Name="Employees1" Relationship="northwindModel.FK_Employees_ReportsTo_EmployeeID" FromRole="Employees" ToRole="Employees1" /> <NavigationProperty Name="Employees2" Relationship="northwindModel.FK_Employees_ReportsTo_EmployeeID" FromRole="Employees1" ToRole="Employees" /> <NavigationProperty Name="Orders" Relationship="northwindModel.FK_Orders_EmployeeID_EmployeeID" FromRole="Employees" ToRole="Orders" /> <NavigationProperty Name="Territories" Relationship="northwindModel.EmployeeTerritories" FromRole="Employees" ToRole="Territories" /> </EntityType> <EntityType Name="Order_Details"> <Key> <PropertyRef Name="OrderID" /> <PropertyRef Name="ProductID" /> </Key> <Property Name="OrderID" Type="Int64" Nullable="false" /> <Property Name="ProductID" Type="Int64" Nullable="false" /> <Property Name="UnitPrice" Type="Decimal" Nullable="false" Precision="53" Scale="0" /> <Property Name="Quantity" Type="Int16" Nullable="false" /> <Property Name="Discount" Type="Single" Nullable="false" /> <NavigationProperty Name="Orders" Relationship="northwindModel.FK_Order_Details_OrderID_OrderID" FromRole="Order_Details" ToRole="Orders" /> <NavigationProperty Name="Products" Relationship="northwindModel.FK_Order_Details_ProductID_ProductID" FromRole="Order_Details" ToRole="Products" /> </EntityType> <EntityType Name="Orders"> <Key> <PropertyRef Name="OrderID" /> </Key> <Property Name="OrderID" Type="Int64" Nullable="false" /> <Property Name="OrderDate" Type="DateTime" /> <Property Name="RequiredDate" Type="DateTime" /> <Property Name="ShippedDate" Type="DateTime" /> <Property Name="Freight" Type="Decimal" Precision="53" Scale="0" /> <Property Name="ShipName" Type="String" MaxLength="40" Unicode="true" FixedLength="false" /> <Property Name="ShipAddress" Type="String" MaxLength="60" Unicode="true" FixedLength="false" /> <Property Name="ShipCity" Type="String" MaxLength="15" Unicode="true" FixedLength="false" /> <Property Name="ShipRegion" Type="String" MaxLength="15" Unicode="true" FixedLength="false" /> <Property Name="ShipPostalCode" Type="String" MaxLength="10" Unicode="true" FixedLength="false" /> <Property Name="ShipCountry" Type="String" MaxLength="15" Unicode="true" FixedLength="false" /> <NavigationProperty Name="Customers" Relationship="northwindModel.FK_Orders_CustomerID_CustomerID" FromRole="Orders" ToRole="Customers" /> <NavigationProperty Name="Employees" Relationship="northwindModel.FK_Orders_EmployeeID_EmployeeID" FromRole="Orders" ToRole="Employees" /> <NavigationProperty Name="Order_Details" Relationship="northwindModel.FK_Order_Details_OrderID_OrderID" FromRole="Orders" ToRole="Order_Details" /> <NavigationProperty Name="Shippers" Relationship="northwindModel.FK_Orders_ShipVia_ShipperID" FromRole="Orders" ToRole="Shippers" /> </EntityType> <EntityType Name="Products"> <Key> <PropertyRef Name="ProductID" /> </Key> <Property Name="ProductID" Type="Int64" Nullable="false" /> <Property Name="ProductName" Type="String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" /> <Property Name="QuantityPerUnit" Type="String" MaxLength="20" Unicode="true" FixedLength="false" /> <Property Name="UnitPrice" Type="Decimal" Precision="53" Scale="0" /> <Property Name="UnitsInStock" Type="Int16" /> <Property Name="UnitsOnOrder" Type="Int16" /> <Property Name="ReorderLevel" Type="Int16" /> <Property Name="Discontinued" Type="Boolean" Nullable="false" /> <NavigationProperty Name="Categories" Relationship="northwindModel.FK_Products_CategoryID_CategoryID" FromRole="Products" ToRole="Categories" /> <NavigationProperty Name="Order_Details" Relationship="northwindModel.FK_Order_Details_ProductID_ProductID" FromRole="Products" ToRole="Order_Details" /> <NavigationProperty Name="Suppliers" Relationship="northwindModel.FK_Products_SupplierID_SupplierID" FromRole="Products" ToRole="Suppliers" /> </EntityType> <EntityType Name="Region"> <Key> <PropertyRef Name="RegionID" /> </Key> <Property Name="RegionID" Type="Int64" Nullable="false" /> <Property Name="RegionDescription" Type="String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="false" /> <NavigationProperty Name="Territories" Relationship="northwindModel.FK_Territories_RegionID_RegionID" FromRole="Region" ToRole="Territories" /> </EntityType> <EntityType Name="Shippers"> <Key> <PropertyRef Name="ShipperID" /> </Key> <Property Name="ShipperID" Type="Int64" Nullable="false" /> <Property Name="CompanyName" Type="String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" /> <Property Name="Phone" Type="String" MaxLength="24" Unicode="true" FixedLength="false" /> <NavigationProperty Name="Orders" Relationship="northwindModel.FK_Orders_ShipVia_ShipperID" FromRole="Shippers" ToRole="Orders" /> </EntityType> <EntityType Name="Suppliers"> <Key> <PropertyRef Name="SupplierID" /> </Key> <Property Name="SupplierID" Type="Int64" Nullable="false" /> <Property Name="CompanyName" Type="String" Nullable="false" MaxLength="40" Unicode="true" FixedLength="false" /> <Property Name="ContactName" Type="String" MaxLength="30" Unicode="true" FixedLength="false" /> <Property Name="ContactTitle" Type="String" MaxLength="30" Unicode="true" FixedLength="false" /> <Property Name="Address" Type="String" MaxLength="60" Unicode="true" FixedLength="false" /> <Property Name="City" Type="String" MaxLength="15" Unicode="true" FixedLength="false" /> <Property Name="Region" Type="String" MaxLength="15" Unicode="true" FixedLength="false" /> <Property Name="PostalCode" Type="String" MaxLength="10" Unicode="true" FixedLength="false" /> <Property Name="Country" Type="String" MaxLength="15" Unicode="true" FixedLength="false" /> <Property Name="Phone" Type="String" MaxLength="24" Unicode="true" FixedLength="false" /> <Property Name="Fax" Type="String" MaxLength="24" Unicode="true" FixedLength="false" /> <Property Name="HomePage" Type="String" MaxLength="2147483647" Unicode="true" FixedLength="false" /> <NavigationProperty Name="Products" Relationship="northwindModel.FK_Products_SupplierID_SupplierID" FromRole="Suppliers" ToRole="Products" /> </EntityType> <EntityType Name="Territories"> <Key> <PropertyRef Name="TerritoryID" /> </Key> <Property Name="TerritoryID" Type="String" Nullable="false" MaxLength="20" Unicode="true" FixedLength="false" /> <Property Name="TerritoryDescription" Type="String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="false" /> <NavigationProperty Name="Region" Relationship="northwindModel.FK_Territories_RegionID_RegionID" FromRole="Territories" ToRole="Region" /> <NavigationProperty Name="Employees" Relationship="northwindModel.EmployeeTerritories" FromRole="Territories" ToRole="Employees" /> </EntityType> <Association Name="FK_Products_CategoryID_CategoryID"> <End Role="Categories" Type="northwindModel.Categories" Multiplicity="0..1" /> <End Role="Products" Type="northwindModel.Products" Multiplicity="*" /> </Association> <Association Name="FK_Orders_CustomerID_CustomerID"> <End Role="Customers" Type="northwindModel.Customers" Multiplicity="0..1" /> <End Role="Orders" Type="northwindModel.Orders" Multiplicity="*" /> </Association> <Association Name="FK_Employees_ReportsTo_EmployeeID"> <End Role="Employees" Type="northwindModel.Employees" Multiplicity="0..1" /> <End Role="Employees1" Type="northwindModel.Employees" Multiplicity="*" /> </Association> <Association Name="FK_Orders_EmployeeID_EmployeeID"> <End Role="Employees" Type="northwindModel.Employees" Multiplicity="0..1" /> <End Role="Orders" Type="northwindModel.Orders" Multiplicity="*" /> </Association> <Association Name="FK_Order_Details_OrderID_OrderID"> <End Role="Orders" Type="northwindModel.Orders" Multiplicity="1" /> <End Role="Order_Details" Type="northwindModel.Order_Details" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="Orders"> <PropertyRef Name="OrderID" /> </Principal> <Dependent Role="Order_Details"> <PropertyRef Name="OrderID" /> </Dependent> </ReferentialConstraint> </Association> <Association Name="FK_Order_Details_ProductID_ProductID"> <End Role="Products" Type="northwindModel.Products" Multiplicity="1" /> <End Role="Order_Details" Type="northwindModel.Order_Details" Multiplicity="*" /> <ReferentialConstraint> <Principal Role="Products"> <PropertyRef Name="ProductID" /> </Principal> <Dependent Role="Order_Details"> <PropertyRef Name="ProductID" /> </Dependent> </ReferentialConstraint> </Association> <Association Name="FK_Orders_ShipVia_ShipperID"> <End Role="Shippers" Type="northwindModel.Shippers" Multiplicity="0..1" /> <End Role="Orders" Type="northwindModel.Orders" Multiplicity="*" /> </Association> <Association Name="FK_Products_SupplierID_SupplierID"> <End Role="Suppliers" Type="northwindModel.Suppliers" Multiplicity="0..1" /> <End Role="Products" Type="northwindModel.Products" Multiplicity="*" /> </Association> <Association Name="FK_Territories_RegionID_RegionID"> <End Role="Region" Type="northwindModel.Region" Multiplicity="1" /> <End Role="Territories" Type="northwindModel.Territories" Multiplicity="*" /> </Association> <Association Name="CustomerCustomerDemo"> <End Role="Customers" Type="northwindModel.Customers" Multiplicity="*" /> <End Role="CustomerDemographics" Type="northwindModel.CustomerDemographics" Multiplicity="*" /> </Association> <Association Name="EmployeeTerritories"> <End Role="Employees" Type="northwindModel.Employees" Multiplicity="*" /> <End Role="Territories" Type="northwindModel.Territories" Multiplicity="*" /> </Association> </Schema> </edmx:ConceptualModels> <!-- C-S mapping content --> <edmx:Mappings> <Mapping Space="C-S" xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS"> <EntityContainerMapping StorageEntityContainer="northwindModelStoreContainer" CdmEntityContainer="northwindEntities"> <EntitySetMapping Name="Categories"> <EntityTypeMapping TypeName="IsTypeOf(northwindModel.Categories)"> <MappingFragment StoreEntitySet="Categories"> <ScalarProperty Name="CategoryID" ColumnName="CategoryID" /> <ScalarProperty Name="CategoryName" ColumnName="CategoryName" /> <ScalarProperty Name="Description" ColumnName="Description" /> <ScalarProperty Name="Picture" ColumnName="Picture" /> </MappingFragment> </EntityTypeMapping> </EntitySetMapping> <EntitySetMapping Name="CustomerDemographics"> <EntityTypeMapping TypeName="IsTypeOf(northwindModel.CustomerDemographics)"> <MappingFragment StoreEntitySet="CustomerDemographics"> <ScalarProperty Name="CustomerTypeID" ColumnName="CustomerTypeID" /> <ScalarProperty Name="CustomerDesc" ColumnName="CustomerDesc" /> </MappingFragment> </EntityTypeMapping> </EntitySetMapping> <EntitySetMapping Name="Customers"> <EntityTypeMapping TypeName="IsTypeOf(northwindModel.Customers)"> <MappingFragment StoreEntitySet="Customers"> <ScalarProperty Name="CustomerID" ColumnName="CustomerID" /> <ScalarProperty Name="CompanyName" ColumnName="CompanyName" /> <ScalarProperty Name="ContactName" ColumnName="ContactName" /> <ScalarProperty Name="ContactTitle" ColumnName="ContactTitle" /> <ScalarProperty Name="Address" ColumnName="Address" /> <ScalarProperty Name="City" ColumnName="City" /> <ScalarProperty Name="Region" ColumnName="Region" /> <ScalarProperty Name="PostalCode" ColumnName="PostalCode" /> <ScalarProperty Name="Country" ColumnName="Country" /> <ScalarProperty Name="Phone" ColumnName="Phone" /> <ScalarProperty Name="Fax" ColumnName="Fax" /> </MappingFragment> </EntityTypeMapping> </EntitySetMapping> <EntitySetMapping Name="Employees"> <EntityTypeMapping TypeName="IsTypeOf(northwindModel.Employees)"> <MappingFragment StoreEntitySet="Employees"> <ScalarProperty Name="EmployeeID" ColumnName="EmployeeID" /> <ScalarProperty Name="LastName" ColumnName="LastName" /> <ScalarProperty Name="FirstName" ColumnName="FirstName" /> <ScalarProperty Name="Title" ColumnName="Title" /> <ScalarProperty Name="TitleOfCourtesy" ColumnName="TitleOfCourtesy" /> <ScalarProperty Name="BirthDate" ColumnName="BirthDate" /> |
︙ | ︙ | |||
721 722 723 724 725 726 727 | <ScalarProperty Name="Photo" ColumnName="Photo" /> <ScalarProperty Name="Notes" ColumnName="Notes" /> <ScalarProperty Name="PhotoPath" ColumnName="PhotoPath" /> </MappingFragment> </EntityTypeMapping> </EntitySetMapping> <EntitySetMapping Name="Order_Details"> | | | | | | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 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 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 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 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 | <ScalarProperty Name="Photo" ColumnName="Photo" /> <ScalarProperty Name="Notes" ColumnName="Notes" /> <ScalarProperty Name="PhotoPath" ColumnName="PhotoPath" /> </MappingFragment> </EntityTypeMapping> </EntitySetMapping> <EntitySetMapping Name="Order_Details"> <EntityTypeMapping TypeName="IsTypeOf(northwindModel.Order_Details)"> <MappingFragment StoreEntitySet="Order Details"> <ScalarProperty Name="OrderID" ColumnName="OrderID" /> <ScalarProperty Name="ProductID" ColumnName="ProductID" /> <ScalarProperty Name="UnitPrice" ColumnName="UnitPrice" /> <ScalarProperty Name="Quantity" ColumnName="Quantity" /> <ScalarProperty Name="Discount" ColumnName="Discount" /> </MappingFragment> </EntityTypeMapping> </EntitySetMapping> <EntitySetMapping Name="Orders"> <EntityTypeMapping TypeName="IsTypeOf(northwindModel.Orders)"> <MappingFragment StoreEntitySet="Orders"> <ScalarProperty Name="OrderID" ColumnName="OrderID" /> <ScalarProperty Name="OrderDate" ColumnName="OrderDate" /> <ScalarProperty Name="RequiredDate" ColumnName="RequiredDate" /> <ScalarProperty Name="ShippedDate" ColumnName="ShippedDate" /> <ScalarProperty Name="Freight" ColumnName="Freight" /> <ScalarProperty Name="ShipName" ColumnName="ShipName" /> <ScalarProperty Name="ShipAddress" ColumnName="ShipAddress" /> <ScalarProperty Name="ShipCity" ColumnName="ShipCity" /> <ScalarProperty Name="ShipRegion" ColumnName="ShipRegion" /> <ScalarProperty Name="ShipPostalCode" ColumnName="ShipPostalCode" /> <ScalarProperty Name="ShipCountry" ColumnName="ShipCountry" /> </MappingFragment> </EntityTypeMapping> </EntitySetMapping> <EntitySetMapping Name="Products"> <EntityTypeMapping TypeName="IsTypeOf(northwindModel.Products)"> <MappingFragment StoreEntitySet="Products"> <ScalarProperty Name="ProductID" ColumnName="ProductID" /> <ScalarProperty Name="ProductName" ColumnName="ProductName" /> <ScalarProperty Name="QuantityPerUnit" ColumnName="QuantityPerUnit" /> <ScalarProperty Name="UnitPrice" ColumnName="UnitPrice" /> <ScalarProperty Name="UnitsInStock" ColumnName="UnitsInStock" /> <ScalarProperty Name="UnitsOnOrder" ColumnName="UnitsOnOrder" /> <ScalarProperty Name="ReorderLevel" ColumnName="ReorderLevel" /> <ScalarProperty Name="Discontinued" ColumnName="Discontinued" /> </MappingFragment> </EntityTypeMapping> </EntitySetMapping> <EntitySetMapping Name="Region"> <EntityTypeMapping TypeName="IsTypeOf(northwindModel.Region)"> <MappingFragment StoreEntitySet="Region"> <ScalarProperty Name="RegionID" ColumnName="RegionID" /> <ScalarProperty Name="RegionDescription" ColumnName="RegionDescription" /> </MappingFragment> </EntityTypeMapping> </EntitySetMapping> <EntitySetMapping Name="Shippers"> <EntityTypeMapping TypeName="IsTypeOf(northwindModel.Shippers)"> <MappingFragment StoreEntitySet="Shippers"> <ScalarProperty Name="ShipperID" ColumnName="ShipperID" /> <ScalarProperty Name="CompanyName" ColumnName="CompanyName" /> <ScalarProperty Name="Phone" ColumnName="Phone" /> </MappingFragment> </EntityTypeMapping> </EntitySetMapping> <EntitySetMapping Name="Suppliers"> <EntityTypeMapping TypeName="IsTypeOf(northwindModel.Suppliers)"> <MappingFragment StoreEntitySet="Suppliers"> <ScalarProperty Name="SupplierID" ColumnName="SupplierID" /> <ScalarProperty Name="CompanyName" ColumnName="CompanyName" /> <ScalarProperty Name="ContactName" ColumnName="ContactName" /> <ScalarProperty Name="ContactTitle" ColumnName="ContactTitle" /> <ScalarProperty Name="Address" ColumnName="Address" /> <ScalarProperty Name="City" ColumnName="City" /> <ScalarProperty Name="Region" ColumnName="Region" /> <ScalarProperty Name="PostalCode" ColumnName="PostalCode" /> <ScalarProperty Name="Country" ColumnName="Country" /> <ScalarProperty Name="Phone" ColumnName="Phone" /> <ScalarProperty Name="Fax" ColumnName="Fax" /> <ScalarProperty Name="HomePage" ColumnName="HomePage" /> </MappingFragment> </EntityTypeMapping> </EntitySetMapping> <EntitySetMapping Name="Territories"> <EntityTypeMapping TypeName="IsTypeOf(northwindModel.Territories)"> <MappingFragment StoreEntitySet="Territories"> <ScalarProperty Name="TerritoryID" ColumnName="TerritoryID" /> <ScalarProperty Name="TerritoryDescription" ColumnName="TerritoryDescription" /> </MappingFragment> </EntityTypeMapping> </EntitySetMapping> <AssociationSetMapping Name="FK_Products_CategoryID_CategoryID" TypeName="northwindModel.FK_Products_CategoryID_CategoryID" StoreEntitySet="Products"> <EndProperty Name="Categories"> <ScalarProperty Name="CategoryID" ColumnName="CategoryID" /> </EndProperty> <EndProperty Name="Products"> <ScalarProperty Name="ProductID" ColumnName="ProductID" /> </EndProperty> <Condition ColumnName="CategoryID" IsNull="false" /> </AssociationSetMapping> <AssociationSetMapping Name="FK_Orders_CustomerID_CustomerID" TypeName="northwindModel.FK_Orders_CustomerID_CustomerID" StoreEntitySet="Orders"> <EndProperty Name="Customers"> <ScalarProperty Name="CustomerID" ColumnName="CustomerID" /> </EndProperty> <EndProperty Name="Orders"> <ScalarProperty Name="OrderID" ColumnName="OrderID" /> </EndProperty> <Condition ColumnName="CustomerID" IsNull="false" /> </AssociationSetMapping> <AssociationSetMapping Name="FK_Employees_ReportsTo_EmployeeID" TypeName="northwindModel.FK_Employees_ReportsTo_EmployeeID" StoreEntitySet="Employees"> <EndProperty Name="Employees"> <ScalarProperty Name="EmployeeID" ColumnName="ReportsTo" /> </EndProperty> <EndProperty Name="Employees1"> <ScalarProperty Name="EmployeeID" ColumnName="EmployeeID" /> </EndProperty> <Condition ColumnName="ReportsTo" IsNull="false" /> </AssociationSetMapping> <AssociationSetMapping Name="FK_Orders_EmployeeID_EmployeeID" TypeName="northwindModel.FK_Orders_EmployeeID_EmployeeID" StoreEntitySet="Orders"> <EndProperty Name="Employees"> <ScalarProperty Name="EmployeeID" ColumnName="EmployeeID" /> </EndProperty> <EndProperty Name="Orders"> <ScalarProperty Name="OrderID" ColumnName="OrderID" /> </EndProperty> <Condition ColumnName="EmployeeID" IsNull="false" /> </AssociationSetMapping> <AssociationSetMapping Name="FK_Order_Details_OrderID_OrderID" TypeName="northwindModel.FK_Order_Details_OrderID_OrderID" StoreEntitySet="Order Details"> <EndProperty Name="Orders"> <ScalarProperty Name="OrderID" ColumnName="OrderID" /> </EndProperty> <EndProperty Name="Order_Details"> <ScalarProperty Name="OrderID" ColumnName="OrderID" /> <ScalarProperty Name="ProductID" ColumnName="ProductID" /> </EndProperty> </AssociationSetMapping> <AssociationSetMapping Name="FK_Order_Details_ProductID_ProductID" TypeName="northwindModel.FK_Order_Details_ProductID_ProductID" StoreEntitySet="Order Details"> <EndProperty Name="Products"> <ScalarProperty Name="ProductID" ColumnName="ProductID" /> </EndProperty> <EndProperty Name="Order_Details"> <ScalarProperty Name="OrderID" ColumnName="OrderID" /> <ScalarProperty Name="ProductID" ColumnName="ProductID" /> </EndProperty> </AssociationSetMapping> <AssociationSetMapping Name="FK_Orders_ShipVia_ShipperID" TypeName="northwindModel.FK_Orders_ShipVia_ShipperID" StoreEntitySet="Orders"> <EndProperty Name="Shippers"> <ScalarProperty Name="ShipperID" ColumnName="ShipVia" /> </EndProperty> <EndProperty Name="Orders"> <ScalarProperty Name="OrderID" ColumnName="OrderID" /> </EndProperty> <Condition ColumnName="ShipVia" IsNull="false" /> </AssociationSetMapping> <AssociationSetMapping Name="FK_Products_SupplierID_SupplierID" TypeName="northwindModel.FK_Products_SupplierID_SupplierID" StoreEntitySet="Products"> <EndProperty Name="Suppliers"> <ScalarProperty Name="SupplierID" ColumnName="SupplierID" /> </EndProperty> <EndProperty Name="Products"> <ScalarProperty Name="ProductID" ColumnName="ProductID" /> </EndProperty> <Condition ColumnName="SupplierID" IsNull="false" /> </AssociationSetMapping> <AssociationSetMapping Name="FK_Territories_RegionID_RegionID" TypeName="northwindModel.FK_Territories_RegionID_RegionID" StoreEntitySet="Territories"> <EndProperty Name="Region"> <ScalarProperty Name="RegionID" ColumnName="RegionID" /> </EndProperty> <EndProperty Name="Territories"> <ScalarProperty Name="TerritoryID" ColumnName="TerritoryID" /> </EndProperty> </AssociationSetMapping> <AssociationSetMapping Name="CustomerCustomerDemo" TypeName="northwindModel.CustomerCustomerDemo" StoreEntitySet="CustomerCustomerDemo"> <EndProperty Name="Customers"> <ScalarProperty Name="CustomerID" ColumnName="CustomerID" /> </EndProperty> <EndProperty Name="CustomerDemographics"> <ScalarProperty Name="CustomerTypeID" ColumnName="CustomerTypeID" /> </EndProperty> </AssociationSetMapping> <AssociationSetMapping Name="EmployeeTerritories" TypeName="northwindModel.EmployeeTerritories" StoreEntitySet="EmployeeTerritories"> <EndProperty Name="Employees"> <ScalarProperty Name="EmployeeID" ColumnName="EmployeeID" /> </EndProperty> <EndProperty Name="Territories"> <ScalarProperty Name="TerritoryID" ColumnName="TerritoryID" /> </EndProperty> </AssociationSetMapping> </EntityContainerMapping> </Mapping> </edmx:Mappings> </edmx:Runtime> <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) --> <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2007/06/edmx"> <edmx:Connection> <DesignerInfoPropertySet> <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" /> </DesignerInfoPropertySet> </edmx:Connection> <edmx:Options> <DesignerInfoPropertySet> <DesignerProperty Name="ValidateOnBuild" Value="true" /> </DesignerInfoPropertySet> </edmx:Options> <!-- Diagram content (shape and connector positions) --> <edmx:Diagrams> <Diagram Name="NorthwindModel"> <EntityTypeShape EntityType="northwindModel.Categories" Width="1.5" PointX="3.75" PointY="16.125" Height="1.9802864583333317" IsExpanded="true" /> <EntityTypeShape EntityType="northwindModel.CustomerDemographics" Width="1.5" PointX="3" PointY="3.5" Height="1.5956835937499996" IsExpanded="true" /> <EntityTypeShape EntityType="northwindModel.Customers" Width="1.5" PointX="0.75" PointY="2.5" Height="3.5186979166666656" IsExpanded="true" /> <EntityTypeShape EntityType="northwindModel.Employees" Width="1.5" PointX="3.75" PointY="9.375" Height="5.057109375" IsExpanded="true" /> <EntityTypeShape EntityType="northwindModel.Order_Details" Width="1.5" PointX="8.25" PointY="3.125" Height="2.3648893229166656" IsExpanded="true" /> <EntityTypeShape EntityType="northwindModel.Orders" Width="1.5" PointX="6" PointY="2.25" Height="3.9033007812499996" IsExpanded="true" /> <EntityTypeShape EntityType="northwindModel.Products" Width="1.5" PointX="6" PointY="17.75" Height="3.1340950520833317" IsExpanded="true" /> <EntityTypeShape EntityType="northwindModel.Region" Width="1.5" PointX="5.75" PointY="8" Height="1.5956835937499996" IsExpanded="true" /> <EntityTypeShape EntityType="northwindModel.Shippers" Width="1.5" PointX="3.75" PointY="6.75" Height="1.7879850260416674" IsExpanded="true" /> <EntityTypeShape EntityType="northwindModel.Suppliers" Width="1.5" PointX="3.75" PointY="18.875" Height="3.5186979166666674" IsExpanded="true" /> <EntityTypeShape EntityType="northwindModel.Territories" Width="1.5" PointX="8" PointY="10.25" Height="1.7879850260416674" IsExpanded="true" /> <AssociationConnector Association="northwindModel.FK_Products_CategoryID_CategoryID" ManuallyRouted="false"> <ConnectorPoint PointX="5.25" PointY="17.927643229166666" /> <ConnectorPoint PointX="6" PointY="17.927643229166666" /></AssociationConnector> <AssociationConnector Association="northwindModel.FK_Orders_CustomerID_CustomerID" ManuallyRouted="false"> <ConnectorPoint PointX="2.25" PointY="2.96875" /> <ConnectorPoint PointX="6" PointY="2.96875" /></AssociationConnector> <AssociationConnector Association="northwindModel.FK_Employees_ReportsTo_EmployeeID" ManuallyRouted="false"> <ConnectorPoint PointX="4.2819230769230767" PointY="14.432109375" /> <ConnectorPoint PointX="4.2819230769230767" PointY="14.682109375" /> <ConnectorPoint PointX="4.7284615384615378" PointY="14.682109375" /> <ConnectorPoint PointX="4.7284615384615378" PointY="14.432109375" /></AssociationConnector> <AssociationConnector Association="northwindModel.FK_Orders_EmployeeID_EmployeeID" ManuallyRouted="false"> <ConnectorPoint PointX="5.25" PointY="12.045146484375" /> <ConnectorPoint PointX="7.40625" PointY="12.045146484375" /> <ConnectorPoint PointX="7.40625" PointY="6.15330078125" /></AssociationConnector> <AssociationConnector Association="northwindModel.FK_Order_Details_OrderID_OrderID" ManuallyRouted="false"> <ConnectorPoint PointX="7.5" PointY="4.3074446614583328" /> <ConnectorPoint PointX="8.25" PointY="4.3074446614583328" /></AssociationConnector> <AssociationConnector Association="northwindModel.FK_Order_Details_ProductID_ProductID" ManuallyRouted="false"> <ConnectorPoint PointX="7.5" PointY="19.317047526041666" /> <ConnectorPoint PointX="9.65625" PointY="19.317047526041666" /> <ConnectorPoint PointX="9.65625" PointY="5.4898893229166656" /></AssociationConnector> <AssociationConnector Association="northwindModel.FK_Orders_ShipVia_ShipperID" ManuallyRouted="false"> <ConnectorPoint PointX="5.25" PointY="7.34375" /> <ConnectorPoint PointX="7.3749975" PointY="7.34375" /> <ConnectorPoint PointX="7.3749975" PointY="6.15330078125" /></AssociationConnector> <AssociationConnector Association="northwindModel.FK_Products_SupplierID_SupplierID" ManuallyRouted="false"> <ConnectorPoint PointX="5.25" PointY="19.879547526041666" /> <ConnectorPoint PointX="6" PointY="19.879547526041666" /></AssociationConnector> <AssociationConnector Association="northwindModel.FK_Territories_RegionID_RegionID" ManuallyRouted="false"> <ConnectorPoint PointX="7.25" PointY="8.797841796875" /> <ConnectorPoint PointX="7.322916666666667" PointY="8.797841796875" /> <ConnectorPoint PointX="7.489583333333333" PointY="8.797841796875" /> <ConnectorPoint PointX="8.75" PointY="8.797841796875" /> <ConnectorPoint PointX="8.75" PointY="10.25" /></AssociationConnector> <AssociationConnector Association="northwindModel.CustomerCustomerDemo" ManuallyRouted="false"> <ConnectorPoint PointX="2.25" PointY="4.297841796875" /> <ConnectorPoint PointX="3" PointY="4.297841796875" /></AssociationConnector> <AssociationConnector Association="northwindModel.EmployeeTerritories" ManuallyRouted="false"> <ConnectorPoint PointX="5.25" PointY="11.143992513020834" /> <ConnectorPoint PointX="7.322916666666667" PointY="11.143992513020834" /> <ConnectorPoint PointX="7.489583333333333" PointY="11.143992513020834" /> <ConnectorPoint PointX="8" PointY="11.143992513020834" /></AssociationConnector></Diagram></edmx:Diagrams> </edmx:Designer> </edmx:Edmx> |
Changes to testlinq/Program.cs.
1 2 3 4 | using System; using System.Collections.Generic; using System.Linq; using System.Text; | | > > > > > | > | > > > > | 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 | using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.Objects; namespace testlinq { class Program { static void Main(string[] args) { using (northwindEntities db = new northwindEntities()) { { string entitySQL = "SELECT VALUE o FROM Orders AS o WHERE SQLite.DatePart('yyyy', o.OrderDate) = 1997;"; ObjectQuery<Orders> query = db.CreateQuery<Orders>(entitySQL); foreach (Orders o in query) { Console.WriteLine(o.ShipPostalCode); } } { var query = from c in db.Customers where c.City == "London" orderby c.CompanyName select c; foreach (Customers c in query) |
︙ | ︙ | |||
47 48 49 50 51 52 53 54 55 56 57 58 59 60 | c.Description = "My modified description"; db.SaveChanges(); db.DeleteObject(c); db.SaveChanges(); } // This query fails due to a SQLite core issue. Currently pending review by Dr. Hipp //{ // var query = from p in db.Products // where p.Order_Details.Count(od => od.Orders.Customers.Country == p.Suppliers.Country) > 2 // select p; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | c.Description = "My modified description"; db.SaveChanges(); db.DeleteObject(c); db.SaveChanges(); } { var query = db.Customers.Where(cust => cust.Country == "Denmark") .SelectMany(cust => cust.Orders.Where(o => o.Freight > 5)); foreach (Orders c in query) { Console.WriteLine(c.Freight); } } { var query = from c in db.Customers where c.Orders.Any(o => o.OrderDate.HasValue == true && o.OrderDate.Value.Year == 1997) select c; foreach (Customers c in query) { Console.WriteLine(c.CompanyName); } } { string entitySQL = "SELECT VALUE o FROM Orders AS o WHERE o.Customers.Country <> 'UK' AND o.Customers.Country <> 'Mexico' AND Year(o.OrderDate) = 1997;"; ObjectQuery<Orders> query = db.CreateQuery<Orders>(entitySQL); foreach (Orders o in query) { Console.WriteLine(o.ShipPostalCode); } } { string entitySQL = "SELECT VALUE o FROM Orders AS o WHERE NewGuid() <> NewGuid();"; ObjectQuery<Orders> query = db.CreateQuery<Orders>(entitySQL); foreach (Orders o in query) { Console.WriteLine(o.ShipPostalCode); } } // This query fails due to a SQLite core issue. Currently pending review by Dr. Hipp //{ // var query = from p in db.Products // where p.Order_Details.Count(od => od.Orders.Customers.Country == p.Suppliers.Country) > 2 // select p; |
︙ | ︙ |
Changes to testlinq/northwind.db.
cannot compute difference between binary files
Changes to testlinq/testlinq.csproj.
1 2 3 4 5 | <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | | > | 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 | <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>9.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{9D3CF7A6-092A-4B05-B0E4-BEF6944525B3}</ProjectGuid> <OutputType>Exe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>testlinq</RootNamespace> <AssemblyName>testlinq</AssemblyName> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <PlatformTarget>x86</PlatformTarget> <UseVSHostingProcess>false</UseVSHostingProcess> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> |
︙ | ︙ |
Changes to tools/install/InstallDesigner.cs.
︙ | ︙ | |||
148 149 150 151 152 153 154 155 156 157 158 159 160 161 | { using (subkey = parent.OpenSubKey(String.Format("{0}\\{1}", subkeyname, version))) { ListViewItem item = new ListViewItem(itemName); item.Tag = new string[] { subkeyname, version }; using (RegistryKey subsubkey = subkey.OpenSubKey("DataProviders")) { if (subsubkey == null) throw new ArgumentException("Edition not installed"); } using (RegistryKey subsubkey = subkey.OpenSubKey(String.Format("DataProviders\\{0}", (isChecked == null) ? lookFor.ToString("B") : ((Guid)isChecked).ToString("B")))) | > > > > > > > > > > > | 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 | { using (subkey = parent.OpenSubKey(String.Format("{0}\\{1}", subkeyname, version))) { ListViewItem item = new ListViewItem(itemName); item.Tag = new string[] { subkeyname, version }; // Verify this edition has been installed and its not a fluke that the key exists string dir = (string)subkey.GetValue("InstallDir"); using (RegistryKey subsubkey = subkey.OpenSubKey("Packages")) { if (subsubkey == null) throw new ArgumentException("Edition not installed"); if (subsubkey.SubKeyCount < 5) throw new ArgumentException("Edition not installed"); } using (RegistryKey subsubkey = subkey.OpenSubKey("DataProviders")) { if (subsubkey == null) throw new ArgumentException("Edition not installed"); } using (RegistryKey subsubkey = subkey.OpenSubKey(String.Format("DataProviders\\{0}", (isChecked == null) ? lookFor.ToString("B") : ((Guid)isChecked).ToString("B")))) |
︙ | ︙ | |||
652 653 654 655 656 657 658 659 660 661 662 663 664 665 | subkey.SetValue("CodeBase", Path.GetFullPath("SQLite.Designer.DLL")); subkey.SetValue("ID", 400); subkey.SetValue("InprocServer32", "mscoree.dll"); subkey.SetValue("CompanyName", "Black Castle Software, LLC"); subkey.SetValue("MinEdition", "standard"); subkey.SetValue("ProductName", "SQLite Data Provider"); subkey.SetValue("ProductVersion", "1.0"); } } using (RegistryKey key = Registry.LocalMachine.OpenSubKey(String.Format("Software\\Microsoft\\{0}\\{1}\\Menus", keyname, version), true)) { key.SetValue("{DCBE6C8D-0E57-4099-A183-98FF74C64D9C}", ", 1000, 2"); } | > > > > | 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 | subkey.SetValue("CodeBase", Path.GetFullPath("SQLite.Designer.DLL")); subkey.SetValue("ID", 400); subkey.SetValue("InprocServer32", "mscoree.dll"); subkey.SetValue("CompanyName", "Black Castle Software, LLC"); subkey.SetValue("MinEdition", "standard"); subkey.SetValue("ProductName", "SQLite Data Provider"); subkey.SetValue("ProductVersion", "1.0"); using (RegistryKey toolboxKey = subkey.CreateSubKey("Toolbox")) { toolboxKey.SetValue("Default Items", 3); } } } using (RegistryKey key = Registry.LocalMachine.OpenSubKey(String.Format("Software\\Microsoft\\{0}\\{1}\\Menus", keyname, version), true)) { key.SetValue("{DCBE6C8D-0E57-4099-A183-98FF74C64D9C}", ", 1000, 2"); } |
︙ | ︙ |
Changes to tools/install/Resources/System.Data.SQLite.dll.
cannot compute difference between binary files
Changes to tools/setup/exe/setup/setup.rc.
︙ | ︙ | |||
53 54 55 56 57 58 59 | ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO | | | | 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 | ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION 1,0,55,0 PRODUCTVERSION 1,0,0,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "Comments", "http://sqlite.phxsoftware.com" VALUE "FileDescription", "SQLite ADO.NET 2.0 Setup" VALUE "FileVersion", "1.0.55.0" VALUE "InternalName", "setup" VALUE "LegalCopyright", "Released to the public domain" VALUE "OriginalFilename", "setup.exe" VALUE "ProductName", "System.Data.SQLite" VALUE "ProductVersion", "1.0" END END |
︙ | ︙ |
Changes to tools/setup/sqlite_setup.suo.
cannot compute difference between binary files
Changes to tools/setup/sqlite_setup.vdproj.
︙ | ︙ | |||
11 12 13 14 15 16 17 | "SccLocalPath" = "8:" "SccAuxPath" = "8:" "SccProvider" = "8:" "Hierarchy" { "Entry" { | < < < < < < | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | "SccLocalPath" = "8:" "SccAuxPath" = "8:" "SccProvider" = "8:" "Hierarchy" { "Entry" { "MsmKey" = "8:_055B2BCD025C40A08F3B155843F41702" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_17D200EF10AB73D2A0E2D26B279AF28F" |
︙ | ︙ | |||
148 149 150 151 152 153 154 155 156 157 158 159 160 161 | "Entry" { "MsmKey" = "8:_A1873A8DC29649A4BAF00E155CDCB8BF" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_A7448E608040319F6C5E12637881B1F6" "OwnerKey" = "8:_CD3CE5CDAB13405EA6EAAADC95F88D2E" "MsmSig" = "8:_UNDEFINED" } "Entry" { | > > > > > > | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | "Entry" { "MsmKey" = "8:_A1873A8DC29649A4BAF00E155CDCB8BF" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_A18DBDB7776215EAD9A52C96F8CA1E91" "OwnerKey" = "8:_40F352185F3B41A485F42BFC64BF9162" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_A7448E608040319F6C5E12637881B1F6" "OwnerKey" = "8:_CD3CE5CDAB13405EA6EAAADC95F88D2E" "MsmSig" = "8:_UNDEFINED" } "Entry" { |
︙ | ︙ | |||
257 258 259 260 261 262 263 | { "MsmKey" = "8:_E6DB5A9B08AC4645A19C948BBFDD0348" "OwnerKey" = "8:_244D4945EA335F5E4E54085BFD020CC1" "MsmSig" = "8:_UNDEFINED" } "Entry" { | | < < < < < < | 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | { "MsmKey" = "8:_E6DB5A9B08AC4645A19C948BBFDD0348" "OwnerKey" = "8:_244D4945EA335F5E4E54085BFD020CC1" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_F320FBAE871DA320178BEEA242900CC7" "OwnerKey" = "8:_2C7EDFF06B61482393D94E3A63D90113" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" "OwnerKey" = "8:_B29C75F5F4D24817846DCEF9951068E1" |
︙ | ︙ | |||
324 325 326 327 328 329 330 | "MsmKey" = "8:_UNDEFINED" "OwnerKey" = "8:_40F352185F3B41A485F42BFC64BF9162" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" | | | 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | "MsmKey" = "8:_UNDEFINED" "OwnerKey" = "8:_40F352185F3B41A485F42BFC64BF9162" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" "OwnerKey" = "8:_A18DBDB7776215EAD9A52C96F8CA1E91" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" "OwnerKey" = "8:_40DFF08BA903482D807E715A041CA8B1" "MsmSig" = "8:_UNDEFINED" |
︙ | ︙ | |||
348 349 350 351 352 353 354 | "MsmKey" = "8:_UNDEFINED" "OwnerKey" = "8:_2C7EDFF06B61482393D94E3A63D90113" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" | | | | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | "MsmKey" = "8:_UNDEFINED" "OwnerKey" = "8:_2C7EDFF06B61482393D94E3A63D90113" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" "OwnerKey" = "8:_F320FBAE871DA320178BEEA242900CC7" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" "OwnerKey" = "8:_29B62FDE3E56411381A6E8B358CBB0F5" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" "OwnerKey" = "8:_244D4945EA335F5E4E54085BFD020CC1" "MsmSig" = "8:_UNDEFINED" |
︙ | ︙ | |||
499 500 501 502 503 504 505 | "AllowLaterVersions" = "11:TRUE" "InstallUrl" = "8:http://go.microsoft.com/fwlink/?LinkId=9832" } } } "File" { | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | "AllowLaterVersions" = "11:TRUE" "InstallUrl" = "8:http://go.microsoft.com/fwlink/?LinkId=9832" } } } "File" { "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_055B2BCD025C40A08F3B155843F41702" { "SourcePath" = "8:..\\..\\bin\\test.exe.config" "TargetName" = "8:test.exe.config" "Tag" = "8:" "Folder" = "8:_30C77BF2E6E84D01ADE5FB8BA2F81504" "Condition" = "8:" |
︙ | ︙ | |||
698 699 700 701 702 703 704 | "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_2C7EDFF06B61482393D94E3A63D90113" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" | | | 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_2C7EDFF06B61482393D94E3A63D90113" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" "AssemblyAsmDisplayName" = "8:test, Version=1.0.0.25019, Culture=neutral, processorArchitecture=x86" "ScatterAssemblies" { "_2C7EDFF06B61482393D94E3A63D90113" { "Name" = "8:test.exe" "Attributes" = "3:512" } |
︙ | ︙ | |||
811 812 813 814 815 816 817 | "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_40DFF08BA903482D807E715A041CA8B1" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" | | | 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 | "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_40DFF08BA903482D807E715A041CA8B1" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" "AssemblyAsmDisplayName" = "8:install, Version=1.0.0.18790, Culture=neutral, processorArchitecture=x86" "ScatterAssemblies" { "_40DFF08BA903482D807E715A041CA8B1" { "Name" = "8:install.exe" "Attributes" = "3:512" } |
︙ | ︙ | |||
842 843 844 845 846 847 848 | "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_40F352185F3B41A485F42BFC64BF9162" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" | | | 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_40F352185F3B41A485F42BFC64BF9162" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" "AssemblyAsmDisplayName" = "8:testce, Version=1.0.0.18356, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_40F352185F3B41A485F42BFC64BF9162" { "Name" = "8:testce.exe" "Attributes" = "3:512" } |
︙ | ︙ | |||
990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | "Permanent" = "11:FALSE" "SharedLegacy" = "11:FALSE" "PackageAs" = "3:1" "Register" = "3:1" "Exclude" = "11:FALSE" "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_A7448E608040319F6C5E12637881B1F6" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:TRUE" "AssemblyAsmDisplayName" = "8:Microsoft.VisualStudio.Shell, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" "ScatterAssemblies" | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 953 954 955 956 957 958 959 960 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 | "Permanent" = "11:FALSE" "SharedLegacy" = "11:FALSE" "PackageAs" = "3:1" "Register" = "3:1" "Exclude" = "11:FALSE" "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_A18DBDB7776215EAD9A52C96F8CA1E91" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" "AssemblyAsmDisplayName" = "8:System.Data.SQLite, Version=1.0.55.0, Culture=neutral, PublicKeyToken=1fdb50b1b62b4c84, processorArchitecture=x86" "ScatterAssemblies" { "_A18DBDB7776215EAD9A52C96F8CA1E91" { "Name" = "8:System.Data.SQLite.DLL" "Attributes" = "3:512" } } "SourcePath" = "8:System.Data.SQLite.DLL" "TargetName" = "8:" "Tag" = "8:" "Folder" = "8:_10C8E86E2EEF451BB40F774C35C5466F" "Condition" = "8:" "Transitive" = "11:FALSE" "Vital" = "11:TRUE" "ReadOnly" = "11:FALSE" "Hidden" = "11:FALSE" "System" = "11:FALSE" "Permanent" = "11:FALSE" "SharedLegacy" = "11:FALSE" "PackageAs" = "3:1" "Register" = "3:1" "Exclude" = "11:FALSE" "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_A7448E608040319F6C5E12637881B1F6" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:TRUE" "AssemblyAsmDisplayName" = "8:Microsoft.VisualStudio.Shell, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" "ScatterAssemblies" |
︙ | ︙ | |||
1148 1149 1150 1151 1152 1153 1154 | "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_CD3CE5CDAB13405EA6EAAADC95F88D2E" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" | | | 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 | "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_CD3CE5CDAB13405EA6EAAADC95F88D2E" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" "AssemblyAsmDisplayName" = "8:SQLite.Designer, Version=1.0.35.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86" "ScatterAssemblies" { "_CD3CE5CDAB13405EA6EAAADC95F88D2E" { "Name" = "8:SQLite.Designer.dll" "Attributes" = "3:512" } |
︙ | ︙ | |||
1277 1278 1279 1280 1281 1282 1283 | "SharedLegacy" = "11:FALSE" "PackageAs" = "3:1" "Register" = "3:1" "Exclude" = "11:TRUE" "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } | | | | | | | | | 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 | "SharedLegacy" = "11:FALSE" "PackageAs" = "3:1" "Register" = "3:1" "Exclude" = "11:TRUE" "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_F320FBAE871DA320178BEEA242900CC7" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" "AssemblyAsmDisplayName" = "8:System.Data.SQLite, Version=1.0.55.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86" "ScatterAssemblies" { "_F320FBAE871DA320178BEEA242900CC7" { "Name" = "8:System.Data.SQLite.DLL" "Attributes" = "3:512" } } "SourcePath" = "8:System.Data.SQLite.DLL" "TargetName" = "8:" "Tag" = "8:" "Folder" = "8:_30C77BF2E6E84D01ADE5FB8BA2F81504" "Condition" = "8:" "Transitive" = "11:FALSE" "Vital" = "11:TRUE" "ReadOnly" = "11:FALSE" "Hidden" = "11:FALSE" "System" = "11:FALSE" "Permanent" = "11:FALSE" |
︙ | ︙ | |||
1441 1442 1443 1444 1445 1446 1447 | "LangId" = "3:1033" "RequiresElevation" = "11:FALSE" } "Product" { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:SQLite ADO.NET 2.0 Provider" | | | | | 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 | "LangId" = "3:1033" "RequiresElevation" = "11:FALSE" } "Product" { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:SQLite ADO.NET 2.0 Provider" "ProductCode" = "8:{F223E3D2-98AC-4558-B660-D51BFF47C274}" "PackageCode" = "8:{3A3FFC71-54CB-472C-88A8-1E430A710E46}" "UpgradeCode" = "8:{78329A82-AFB1-453B-AF00-D46AC911DA89}" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:TRUE" "ProductVersion" = "8:1.055.0" "Manufacturer" = "8:Phoenix Software Solutions, LLC" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:http://sqlite.phxsoftware.com" "Title" = "8:SQLite ADO.NET 2.0 Provider" "Subject" = "8:" "ARPCONTACT" = "8:Phoenix Software Solutions, LLC" "Keywords" = "8:" |
︙ | ︙ |