Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix xCreate and xConnect delegate signatures. Finish marshalling of the sqlite3_index_info structure. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | virtualTables |
Files: | files | file ages | folders |
SHA1: |
7461bf423f2ef22d8ec30acd20d9912d |
User & Date: | mistachkin 2013-06-18 20:39:06.918 |
Context
2013-06-18
| ||
21:15 | Move marshalling utility methods into the internal SQLiteMarshal class. check-in: 89613e2645 user: mistachkin tags: virtualTables | |
20:39 | Fix xCreate and xConnect delegate signatures. Finish marshalling of the sqlite3_index_info structure. check-in: 7461bf423f user: mistachkin tags: virtualTables | |
06:12 | Fix compilation errors for the .NET Compact Framework build. check-in: e64388aacd user: mistachkin tags: virtualTables | |
Changes
Changes to System.Data.SQLite/SQLiteModuleBase.cs.
︙ | ︙ | |||
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// /* [Flags()] */ public enum SQLiteIndexConstraintOp : byte { EqualTo = 2, GreaterThan = 4, LessThanOrEqualTo = 8, LessThan = 16, GreaterThanOrEqualTo = 32, Match = 64 } /////////////////////////////////////////////////////////////////////////// public sealed class SQLiteIndexConstraint { | > > > > > | > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > | > > | | | | | > > > > | > > > > > | 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 | } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndexConstraintOp Enumeration /* [Flags()] */ public enum SQLiteIndexConstraintOp : byte { EqualTo = 2, GreaterThan = 4, LessThanOrEqualTo = 8, LessThan = 16, GreaterThanOrEqualTo = 32, Match = 64 } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndexConstraint Class public sealed class SQLiteIndexConstraint { #region Internal Constructors internal SQLiteIndexConstraint( UnsafeNativeMethods.sqlite3_index_constraint constraint ) : this(constraint.iColumn, constraint.op, constraint.usable, constraint.iTermOffset) { // do nothing. } #endregion ////////////////////////////////////////////////////////////////////// #region Private Constructors private SQLiteIndexConstraint( int iColumn, SQLiteIndexConstraintOp op, byte usable, int iTermOffset ) { this.iColumn = iColumn; this.op = op; this.usable = usable; this.iTermOffset = iTermOffset; } #endregion ////////////////////////////////////////////////////////////////////// #region Public Fields public int iColumn; ////////////////////////////////////////////////////////////////////// public SQLiteIndexConstraintOp op; ////////////////////////////////////////////////////////////////////// public byte usable; ////////////////////////////////////////////////////////////////////// public int iTermOffset; #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndexOrderBy Class public sealed class SQLiteIndexOrderBy { #region Internal Constructors internal SQLiteIndexOrderBy( UnsafeNativeMethods.sqlite3_index_orderby orderBy ) : this(orderBy.iColumn, orderBy.desc) { // do nothing. } #endregion ////////////////////////////////////////////////////////////////////// #region Private Constructors private SQLiteIndexOrderBy( int iColumn, byte desc ) { this.iColumn = iColumn; this.desc = desc; } #endregion ////////////////////////////////////////////////////////////////////// #region Public Fields public int iColumn; /* Column number */ ////////////////////////////////////////////////////////////////////// public byte desc; /* True for DESC. False for ASC. */ #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndexConstraintUsage Class public sealed class SQLiteIndexConstraintUsage { #region Internal Constructors internal SQLiteIndexConstraintUsage( UnsafeNativeMethods.sqlite3_index_constraint_usage constraintUsage ) : this(constraintUsage.argvIndex, constraintUsage.omit) { // do nothing. } #endregion ////////////////////////////////////////////////////////////////////// #region Private Constructors private SQLiteIndexConstraintUsage( int argvIndex, byte omit ) { this.argvIndex = argvIndex; this.omit = omit; } #endregion /////////////////////////////////////////////////////////////////////// #region Public Fields public int argvIndex; /////////////////////////////////////////////////////////////////////// public byte omit; #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndexInputs Class public sealed class SQLiteIndexInputs { #region Internal Constructors internal SQLiteIndexInputs(int nConstraint, int nOrderBy) { constraints = new SQLiteIndexConstraint[nConstraint]; orderBys = new SQLiteIndexOrderBy[nOrderBy]; } #endregion /////////////////////////////////////////////////////////////////////// #region Public Properties private SQLiteIndexConstraint[] constraints; public SQLiteIndexConstraint[] Constraints { get { return constraints; } } /////////////////////////////////////////////////////////////////////// private SQLiteIndexOrderBy[] orderBys; public SQLiteIndexOrderBy[] OrderBys { get { return orderBys; } } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndexOutputs Class public sealed class SQLiteIndexOutputs { #region Internal Constructors internal SQLiteIndexOutputs(int nConstraint) { constraintUsages = new SQLiteIndexConstraintUsage[nConstraint]; } #endregion /////////////////////////////////////////////////////////////////////// #region Public Properties private SQLiteIndexConstraintUsage[] constraintUsages; public SQLiteIndexConstraintUsage[] ConstraintUsages { get { return constraintUsages; } } /////////////////////////////////////////////////////////////////////// private int idxNum; public int IdxNum { get { return idxNum; } set { idxNum = value; } } /////////////////////////////////////////////////////////////////////// private string idxStr; public string IdxStr { get { return idxStr; } set { idxStr = value; } } /////////////////////////////////////////////////////////////////////// private int needToFreeIdxStr; public int NeedToFreeIdxStr { get { return needToFreeIdxStr; } set { needToFreeIdxStr = value; } } /////////////////////////////////////////////////////////////////////// private int orderByConsumed; public int OrderByConsumed { get { return orderByConsumed; } set { orderByConsumed = value; } } /////////////////////////////////////////////////////////////////////// private double estimatedCost; public double EstimatedCost { get { return estimatedCost; } set { estimatedCost = value; } } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndex Class public sealed class SQLiteIndex { #region Internal Constructors internal SQLiteIndex(int nConstraint, int nOrderBy) { inputs = new SQLiteIndexInputs(nConstraint, nOrderBy); outputs = new SQLiteIndexOutputs(nConstraint); } #endregion /////////////////////////////////////////////////////////////////////// #region Public Properties private SQLiteIndexInputs inputs; public SQLiteIndexInputs Inputs { get { return inputs; } } /////////////////////////////////////////////////////////////////////// private SQLiteIndexOutputs outputs; public SQLiteIndexOutputs Outputs { get { return outputs; } } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteVirtualTableCursor Class public class SQLiteVirtualTableCursor : ISQLiteNativeHandle { #region Public Constructors public SQLiteVirtualTableCursor( IntPtr nativeHandle ) { |
︙ | ︙ | |||
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | private IntPtr nativeHandle; public IntPtr NativeHandle { get { return nativeHandle; } } #endregion } /////////////////////////////////////////////////////////////////////////// public interface ISQLiteNativeHandle { IntPtr NativeHandle { get; } } /////////////////////////////////////////////////////////////////////////// public interface ISQLiteNativeModule { | > > > > > > > > > > > > | > | > > > > > > > | > > | > > > > > > | > > > > > > | > > > > | > > > > > > | > > > > > | > > > > > > > > > | > > > > > | > > > > > > > > > > | > > | > > > > > > | > > > > > > > > | | > > > > | | > | > | | | > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > | > > > > > > > > | > > > > > > > > > > > | > > > > > | > > > > > | > > > > > > > > | | > > > > > > > > > > | > > > > > > > | > > > > > > | > > > > > > > > > > > > > > > > > > | > > > > > > > > | > > > > > | > > > > > | > > > > > | > > > > > | > | 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 | private IntPtr nativeHandle; public IntPtr NativeHandle { get { return nativeHandle; } } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region ISQLiteNativeHandle Interface public interface ISQLiteNativeHandle { IntPtr NativeHandle { get; } } #endregion /////////////////////////////////////////////////////////////////////////// #region ISQLiteNativeModule Interface public interface ISQLiteNativeModule { SQLiteErrorCode xCreate( IntPtr pDb, IntPtr pAux, int argc, IntPtr[] argv, ref IntPtr pVtab, ref IntPtr pError ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xConnect( IntPtr pDb, IntPtr pAux, int argc, IntPtr[] argv, ref IntPtr pVtab, ref IntPtr pError ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xBestIndex( IntPtr pVtab, IntPtr pIndex ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xDisconnect( IntPtr pVtab ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xDestroy( IntPtr pVtab ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xOpen( IntPtr pVtab, ref IntPtr pCursor ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xClose( IntPtr pCursor ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xFilter( IntPtr pCursor, int idxNum, IntPtr idxStr, int argc, IntPtr[] argv ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xNext( IntPtr pCursor ); /////////////////////////////////////////////////////////////////////// bool xEof( IntPtr pCursor ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xColumn( IntPtr pCursor, IntPtr pContext, int index ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xRowId( IntPtr pCursor, ref long rowId ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xUpdate( IntPtr pVtab, int nData, IntPtr apData, ref long rowId ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xBegin( IntPtr pVtab ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xSync( IntPtr pVtab ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xCommit( IntPtr pVtab ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xRollback( IntPtr pVtab ); /////////////////////////////////////////////////////////////////////// bool xFindFunction( IntPtr pVtab, int nArg, IntPtr zName, ref SQLiteCallback callback, ref IntPtr pClientData ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xRename( IntPtr pVtab, IntPtr zNew ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xSavepoint( IntPtr pVtab, int iSavepoint ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xRelease( IntPtr pVtab, int iSavepoint ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode xRollbackTo( IntPtr pVtab, int iSavepoint ); } #endregion /////////////////////////////////////////////////////////////////////////// #region ISQLiteManagedModule Interface public interface ISQLiteManagedModule { bool Declared { get; } /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Create( SQLiteConnection connection, /* in */ IntPtr pClientData, /* in */ string[] argv, /* in */ ref string error /* out */ ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Connect( SQLiteConnection connection, /* in */ IntPtr pClientData, /* in */ string[] argv, /* in */ ref string error /* out */ ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode BestIndex( SQLiteIndex index /* in, out */ ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Disconnect(); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Destroy(); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Open( ref SQLiteVirtualTableCursor cursor /* out */ ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Close( SQLiteVirtualTableCursor cursor /* in */ ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Filter( SQLiteVirtualTableCursor cursor, /* in */ int idxNum, /* in */ string idxStr, /* in */ SQLiteValue[] argv /* in */ ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Next( SQLiteVirtualTableCursor cursor /* in */ ); /////////////////////////////////////////////////////////////////////// bool Eof( SQLiteVirtualTableCursor cursor /* in */ ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Column( SQLiteVirtualTableCursor cursor, /* in */ SQLiteContext context, /* in */ int index /* in */ ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode RowId( SQLiteVirtualTableCursor cursor, /* in */ ref long rowId /* out */ ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Update( SQLiteValue[] values, /* in */ ref long rowId /* in, out */ ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Begin(); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Sync(); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Commit(); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Rollback(); /////////////////////////////////////////////////////////////////////// bool FindFunction( int nArg, /* in */ string zName, /* in */ ref SQLiteFunction function, /* out */ ref IntPtr pClientData /* out */ ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Rename( string zNew /* in */ ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Savepoint( int iSavepoint /* in */ ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode Release( int iSavepoint /* in */ ); /////////////////////////////////////////////////////////////////////// SQLiteErrorCode RollbackTo( int iSavepoint /* in */ ); } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteModuleBase Class public abstract class SQLiteModuleBase : ISQLiteManagedModule, ISQLiteNativeModule, IDisposable { #region Private Constants private static readonly Encoding Utf8Encoding = Encoding.UTF8; #endregion /////////////////////////////////////////////////////////////////////// #region Private Methods private UnsafeNativeMethods.sqlite3_module CreateNativeModule() { UnsafeNativeMethods.sqlite3_module module = |
︙ | ︙ | |||
557 558 559 560 561 562 563 | return module; } private static int ThirtyBits = 0x3fffffff; /////////////////////////////////////////////////////////////////////// | < < | 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 | return module; } private static int ThirtyBits = 0x3fffffff; /////////////////////////////////////////////////////////////////////// private static IntPtr IntPtrForOffset( IntPtr pointer, int offset ) { return new IntPtr(pointer.ToInt64() + offset); } /////////////////////////////////////////////////////////////////////// private static int MarshalReadInt32( IntPtr pointer, int offset ) |
︙ | ︙ | |||
892 893 894 895 896 897 898 | result[index] = new SQLiteValue(values[index]); return result; } /////////////////////////////////////////////////////////////////////// | | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > | | > > > > > > | > > > > > | > | < | > | > > > > > > > | 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 | result[index] = new SQLiteValue(values[index]); return result; } /////////////////////////////////////////////////////////////////////// private static void IndexToIntPtr( SQLiteIndex index, IntPtr pIndex ) { if ((index == null) || (index.Inputs == null) || (index.Inputs.Constraints == null) || (index.Inputs.OrderBys == null) || (index.Outputs == null) || (index.Outputs.ConstraintUsages == null)) { return; } if (pIndex == IntPtr.Zero) return; int offset = 0; int nConstraint = MarshalReadInt32(pIndex, offset); if (nConstraint != index.Inputs.Constraints.Length) return; if (nConstraint != index.Outputs.ConstraintUsages.Length) return; offset += sizeof(int); IntPtr pConstraint = MarshalReadIntPtr(pIndex, offset); offset += IntPtr.Size; int nOrderBy = MarshalReadInt32(pIndex, offset); index = new SQLiteIndex(nConstraint, nOrderBy); offset += sizeof(int); IntPtr pOrderBy = MarshalReadIntPtr(pIndex, offset); offset += IntPtr.Size; IntPtr pConstraintUsage = MarshalReadIntPtr(pIndex, offset); int sizeOfConstraintType = Marshal.SizeOf(typeof( UnsafeNativeMethods.sqlite3_index_constraint)); for (int iConstraint = 0; iConstraint < nConstraint; iConstraint++) { UnsafeNativeMethods.sqlite3_index_constraint constraint = new UnsafeNativeMethods.sqlite3_index_constraint( index.Inputs.Constraints[iConstraint]); Marshal.StructureToPtr( constraint, IntPtrForOffset(pConstraint, iConstraint * sizeOfConstraintType), false); index.Inputs.Constraints[iConstraint] = new SQLiteIndexConstraint(constraint); } int sizeOfOrderByType = Marshal.SizeOf(typeof( UnsafeNativeMethods.sqlite3_index_orderby)); for (int iOrderBy = 0; iOrderBy < nOrderBy; iOrderBy++) { UnsafeNativeMethods.sqlite3_index_orderby orderBy = new UnsafeNativeMethods.sqlite3_index_orderby( index.Inputs.OrderBys[iOrderBy]); Marshal.StructureToPtr( orderBy, IntPtrForOffset(pOrderBy, iOrderBy * sizeOfOrderByType), false); index.Inputs.OrderBys[iOrderBy] = new SQLiteIndexOrderBy(orderBy); } int sizeOfConstraintUsageType = Marshal.SizeOf(typeof( UnsafeNativeMethods.sqlite3_index_constraint_usage)); for (int iConstraint = 0; iConstraint < nConstraint; iConstraint++) { UnsafeNativeMethods.sqlite3_index_constraint_usage constraintUsage = new UnsafeNativeMethods.sqlite3_index_constraint_usage( index.Outputs.ConstraintUsages[iConstraint]); Marshal.StructureToPtr( constraintUsage, IntPtrForOffset(pConstraintUsage, iConstraint * sizeOfConstraintUsageType), false); index.Outputs.ConstraintUsages[iConstraint] = new SQLiteIndexConstraintUsage(constraintUsage); } } /////////////////////////////////////////////////////////////////////// private static void IndexFromIntPtr( IntPtr pIndex, ref SQLiteIndex index ) { if (pIndex == IntPtr.Zero) return; int offset = 0; int nConstraint = MarshalReadInt32(pIndex, offset); offset += sizeof(int); IntPtr pConstraint = MarshalReadIntPtr(pIndex, offset); offset += IntPtr.Size; int nOrderBy = MarshalReadInt32(pIndex, offset); index = new SQLiteIndex(nConstraint, nOrderBy); offset += sizeof(int); IntPtr pOrderBy = MarshalReadIntPtr(pIndex, offset); offset += IntPtr.Size; IntPtr pConstraintUsage = MarshalReadIntPtr(pIndex, offset); offset += IntPtr.Size; index.Outputs.IdxNum = MarshalReadInt32(pIndex, offset); offset += sizeof(int); index.Outputs.IdxStr = StringFromUtf8IntPtr(IntPtrForOffset( pIndex, offset)); offset += IntPtr.Size; index.Outputs.NeedToFreeIdxStr = MarshalReadInt32(pIndex, offset); offset += sizeof(int); index.Outputs.OrderByConsumed = MarshalReadInt32(pIndex, offset); offset += sizeof(int); index.Outputs.EstimatedCost = MarshalReadDouble(pIndex, offset); int sizeOfConstraintType = Marshal.SizeOf(typeof( UnsafeNativeMethods.sqlite3_index_constraint)); for (int iConstraint = 0; iConstraint < nConstraint; iConstraint++) { UnsafeNativeMethods.sqlite3_index_constraint constraint = new UnsafeNativeMethods.sqlite3_index_constraint(); Marshal.PtrToStructure(IntPtrForOffset(pConstraint, iConstraint * sizeOfConstraintType), constraint); index.Inputs.Constraints[iConstraint] = new SQLiteIndexConstraint(constraint); } int sizeOfOrderByType = Marshal.SizeOf(typeof( UnsafeNativeMethods.sqlite3_index_orderby)); for (int iOrderBy = 0; iOrderBy < nOrderBy; iOrderBy++) { UnsafeNativeMethods.sqlite3_index_orderby orderBy = new UnsafeNativeMethods.sqlite3_index_orderby(); Marshal.PtrToStructure(IntPtrForOffset(pOrderBy, iOrderBy * sizeOfOrderByType), orderBy); index.Inputs.OrderBys[iOrderBy] = new SQLiteIndexOrderBy(orderBy); } int sizeOfConstraintUsageType = Marshal.SizeOf(typeof( UnsafeNativeMethods.sqlite3_index_constraint_usage)); for (int iConstraint = 0; iConstraint < nConstraint; iConstraint++) { UnsafeNativeMethods.sqlite3_index_constraint_usage constraintUsage = new UnsafeNativeMethods.sqlite3_index_constraint_usage(); Marshal.PtrToStructure(IntPtrForOffset(pConstraintUsage, iConstraint * sizeOfConstraintUsageType), constraintUsage); index.Outputs.ConstraintUsages[iConstraint] = new SQLiteIndexConstraintUsage(constraintUsage); } } #endregion /////////////////////////////////////////////////////////////////////// #region Public Constructors public SQLiteModuleBase() |
︙ | ︙ | |||
1099 1100 1101 1102 1103 1104 1105 | /////////////////////////////////////////////////////////////////////// #region ISQLiteNativeModule Members public SQLiteErrorCode xCreate( IntPtr pDb, IntPtr pAux, int argc, | | | 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 | /////////////////////////////////////////////////////////////////////// #region ISQLiteNativeModule Members public SQLiteErrorCode xCreate( IntPtr pDb, IntPtr pAux, int argc, IntPtr[] argv, ref IntPtr pVtab, ref IntPtr pError ) { try { using (SQLiteConnection connection = new SQLiteConnection( |
︙ | ︙ | |||
1138 1139 1140 1141 1142 1143 1144 | /////////////////////////////////////////////////////////////////////// public SQLiteErrorCode xConnect( IntPtr pDb, IntPtr pAux, int argc, | | | 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 | /////////////////////////////////////////////////////////////////////// public SQLiteErrorCode xConnect( IntPtr pDb, IntPtr pAux, int argc, IntPtr[] argv, ref IntPtr pVtab, ref IntPtr pError ) { try { using (SQLiteConnection connection = new SQLiteConnection( |
︙ | ︙ | |||
1180 1181 1182 1183 1184 1185 1186 | public SQLiteErrorCode xBestIndex( IntPtr pVtab, IntPtr pIndex ) { try { | | | < | > | 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 | public SQLiteErrorCode xBestIndex( IntPtr pVtab, IntPtr pIndex ) { try { SQLiteIndex index = null; IndexFromIntPtr(pIndex, ref index); if (BestIndex(index) == SQLiteErrorCode.Ok) { IndexToIntPtr(index, pIndex); return SQLiteErrorCode.Ok; } } catch (Exception e) /* NOTE: Must catch ALL. */ { SetTableError(pVtab, e.ToString()); } |
︙ | ︙ | |||
1890 1891 1892 1893 1894 1895 1896 1897 | #region Destructor ~SQLiteModuleBase() { Dispose(false); } #endregion } } | > | 2433 2434 2435 2436 2437 2438 2439 2440 2441 | #region Destructor ~SQLiteModuleBase() { Dispose(false); } #endregion } #endregion } |
Changes to System.Data.SQLite/UnsafeNativeMethods.cs.
︙ | ︙ | |||
1624 1625 1626 1627 1628 1629 1630 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif public delegate SQLiteErrorCode xCreate( IntPtr pDb, IntPtr pAux, int argc, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] | | | | 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 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif public delegate SQLiteErrorCode xCreate( IntPtr pDb, IntPtr pAux, int argc, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] IntPtr[] argv, ref IntPtr pVtab, ref IntPtr pError ); /////////////////////////////////////////////////////////////////////////// #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif public delegate SQLiteErrorCode xConnect( IntPtr pDb, IntPtr pAux, int argc, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] IntPtr[] argv, ref IntPtr pVtab, ref IntPtr pError ); /////////////////////////////////////////////////////////////////////////// #if !PLATFORM_COMPACTFRAMEWORK |
︙ | ︙ | |||
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 | } /////////////////////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] internal struct sqlite3_index_constraint { public int iColumn; public SQLiteIndexConstraintOp op; public byte usable; public int iTermOffset; } /////////////////////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] internal struct sqlite3_index_orderby { public int iColumn; /* Column number */ public byte desc; /* True for DESC. False for ASC. */ } /////////////////////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] internal struct sqlite3_index_constraint_usage { public int argvIndex; /* if >0, constraint is part of argv to xFilter */ public byte omit; /* Do not code a test for this constraint */ } /////////////////////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] internal struct sqlite3_index_info { /* Inputs */ public int nConstraint; /* Number of entries in aConstraint */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < | < | < | | 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 | } /////////////////////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] internal struct sqlite3_index_constraint { public sqlite3_index_constraint( SQLiteIndexConstraint constraint ) : this() { if (constraint != null) { iColumn = constraint.iColumn; op = constraint.op; usable = constraint.usable; iTermOffset = constraint.iTermOffset; } } /////////////////////////////////////////////////////////////////////// public int iColumn; public SQLiteIndexConstraintOp op; public byte usable; public int iTermOffset; } /////////////////////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] internal struct sqlite3_index_orderby { public sqlite3_index_orderby( SQLiteIndexOrderBy orderBy ) : this() { if (orderBy != null) { iColumn = orderBy.iColumn; desc = orderBy.desc; } } /////////////////////////////////////////////////////////////////////// public int iColumn; /* Column number */ public byte desc; /* True for DESC. False for ASC. */ } /////////////////////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] internal struct sqlite3_index_constraint_usage { public sqlite3_index_constraint_usage( SQLiteIndexConstraintUsage constraintUsage ) : this() { if (constraintUsage != null) { argvIndex = constraintUsage.argvIndex; omit = constraintUsage.omit; } } /////////////////////////////////////////////////////////////////////// public int argvIndex; /* if >0, constraint is part of argv to xFilter */ public byte omit; /* Do not code a test for this constraint */ } /////////////////////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] internal struct sqlite3_index_info { /* Inputs */ public int nConstraint; /* Number of entries in aConstraint */ public IntPtr aConstraint; public int nOrderBy; public IntPtr aOrderBy; /* Outputs */ public IntPtr aConstraintUsage; public int idxNum; /* Number used to identify the index */ public string idxStr; /* String, possibly obtained from sqlite3_malloc */ public int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ public int orderByConsumed; /* True if output is already ordered */ public double estimatedCost; /* Estimated cost of using this index */ } #endregion |
︙ | ︙ |