0000: 2f 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a /***************
0010: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0020: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0030: 2a 2a 2a 2a 2a 2a 2a 2a 2a 0d 0a 20 2a 20 41 44 *********.. * AD
0040: 4f 2e 4e 45 54 20 32 2e 30 20 44 61 74 61 20 50 O.NET 2.0 Data P
0050: 72 6f 76 69 64 65 72 20 66 6f 72 20 53 51 4c 69 rovider for SQLi
0060: 74 65 20 56 65 72 73 69 6f 6e 20 33 2e 58 0d 0a te Version 3.X..
0070: 20 2a 20 57 72 69 74 74 65 6e 20 62 79 20 52 6f * Written by Ro
0080: 62 65 72 74 20 53 69 6d 70 73 6f 6e 20 28 72 6f bert Simpson (ro
0090: 62 65 72 74 40 62 6c 61 63 6b 63 61 73 74 6c 65 bert@blackcastle
00a0: 73 6f 66 74 2e 63 6f 6d 29 0d 0a 20 2a 0d 0a 20 soft.com).. *..
00b0: 2a 20 52 65 6c 65 61 73 65 64 20 74 6f 20 74 68 * Released to th
00c0: 65 20 70 75 62 6c 69 63 20 64 6f 6d 61 69 6e 2c e public domain,
00d0: 20 75 73 65 20 61 74 20 79 6f 75 72 20 6f 77 6e use at your own
00e0: 20 72 69 73 6b 21 0d 0a 20 2a 2a 2a 2a 2a 2a 2a risk!.. *******
00f0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0100: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0110: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0120: 2a 2f 0d 0a 0d 0a 6e 61 6d 65 73 70 61 63 65 20 */....namespace
0130: 53 79 73 74 65 6d 2e 44 61 74 61 2e 53 51 4c 69 System.Data.SQLi
0140: 74 65 0d 0a 7b 0d 0a 20 20 75 73 69 6e 67 20 53 te..{.. using S
0150: 79 73 74 65 6d 3b 0d 0a 20 20 75 73 69 6e 67 20 ystem;.. using
0160: 53 79 73 74 65 6d 2e 43 6f 6c 6c 65 63 74 69 6f System.Collectio
0170: 6e 73 2e 47 65 6e 65 72 69 63 3b 0d 0a 0d 0a 23 ns.Generic;....#
0180: 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 43 54 5f if !NET_COMPACT_
0190: 32 30 20 26 26 20 28 54 52 41 43 45 5f 43 4f 4e 20 && (TRACE_CON
01a0: 4e 45 43 54 49 4f 4e 20 7c 7c 20 54 52 41 43 45 NECTION || TRACE
01b0: 5f 53 54 41 54 45 4d 45 4e 54 29 0d 0a 20 20 75 _STATEMENT).. u
01c0: 73 69 6e 67 20 53 79 73 74 65 6d 2e 44 69 61 67 sing System.Diag
01d0: 6e 6f 73 74 69 63 73 3b 0d 0a 23 65 6e 64 69 66 nostics;..#endif
01e0: 0d 0a 0d 0a 20 20 75 73 69 6e 67 20 53 79 73 74 .... using Syst
01f0: 65 6d 2e 47 6c 6f 62 61 6c 69 7a 61 74 69 6f 6e em.Globalization
0200: 3b 0d 0a 20 20 75 73 69 6e 67 20 53 79 73 74 65 ;.. using Syste
0210: 6d 2e 52 75 6e 74 69 6d 65 2e 49 6e 74 65 72 6f m.Runtime.Intero
0220: 70 53 65 72 76 69 63 65 73 3b 0d 0a 20 20 75 73 pServices;.. us
0230: 69 6e 67 20 53 79 73 74 65 6d 2e 54 65 78 74 3b ing System.Text;
0240: 0d 0a 20 20 75 73 69 6e 67 20 53 79 73 74 65 6d .. using System
0250: 2e 54 68 72 65 61 64 69 6e 67 3b 0d 0a 0d 0a 20 .Threading;....
0260: 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
0270: 20 20 2f 2f 2f 20 54 68 69 73 20 69 73 20 74 68 /// This is th
0280: 65 20 6d 65 74 68 6f 64 20 73 69 67 6e 61 74 75 e method signatu
0290: 72 65 20 66 6f 72 20 74 68 65 20 53 51 4c 69 74 re for the SQLit
02a0: 65 20 63 6f 72 65 20 6c 69 62 72 61 72 79 20 6c e core library l
02b0: 6f 67 67 69 6e 67 20 63 61 6c 6c 62 61 63 6b 0d ogging callback.
02c0: 0a 20 20 2f 2f 2f 20 66 75 6e 63 74 69 6f 6e 20 . /// function
02d0: 66 6f 72 20 75 73 65 20 77 69 74 68 20 73 71 6c for use with sql
02e0: 69 74 65 33 5f 6c 6f 67 28 29 20 61 6e 64 20 74 ite3_log() and t
02f0: 68 65 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 he SQLITE_CONFIG
0300: 5f 4c 4f 47 2e 0d 0a 20 20 2f 2f 2f 0d 0a 20 20 _LOG... ///..
0310: 2f 2f 2f 20 57 41 52 4e 49 4e 47 3a 20 54 68 69 /// WARNING: Thi
0320: 73 20 64 65 6c 65 67 61 74 65 20 69 73 20 75 73 s delegate is us
0330: 65 64 20 6d 6f 72 65 2d 6f 72 2d 6c 65 73 73 20 ed more-or-less
0340: 64 69 72 65 63 74 6c 79 20 62 79 20 6e 61 74 69 directly by nati
0350: 76 65 20 63 6f 64 65 2c 20 64 6f 0d 0a 20 20 2f ve code, do.. /
0360: 2f 2f 20 20 20 20 20 20 20 20 20 20 6e 6f 74 20 // not
0370: 6d 6f 64 69 66 79 20 69 74 73 20 74 79 70 65 20 modify its type
0380: 73 69 67 6e 61 74 75 72 65 2e 0d 0a 20 20 2f 2f signature... //
0390: 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 / </summary>..
03a0: 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d /// <param name=
03b0: 22 70 55 73 65 72 44 61 74 61 22 3e 0d 0a 20 20 "pUserData">..
03c0: 2f 2f 2f 20 54 68 65 20 65 78 74 72 61 20 64 61 /// The extra da
03d0: 74 61 20 61 73 73 6f 63 69 61 74 65 64 20 77 69 ta associated wi
03e0: 74 68 20 74 68 69 73 20 6d 65 73 73 61 67 65 2c th this message,
03f0: 20 69 66 20 61 6e 79 2e 0d 0a 20 20 2f 2f 2f 20 if any... ///
0400: 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 2f 2f 2f 20 </param>.. ///
0410: 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 65 72 72 <param name="err
0420: 6f 72 43 6f 64 65 22 3e 0d 0a 20 20 2f 2f 2f 20 orCode">.. ///
0430: 54 68 65 20 65 72 72 6f 72 20 63 6f 64 65 20 61 The error code a
0440: 73 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 74 ssociated with t
0450: 68 69 73 20 6d 65 73 73 61 67 65 2e 0d 0a 20 20 his message...
0460: 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 /// </param>..
0470: 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d /// <param name=
0480: 22 70 4d 65 73 73 61 67 65 22 3e 0d 0a 20 20 2f "pMessage">.. /
0490: 2f 2f 20 54 68 65 20 6d 65 73 73 61 67 65 20 73 // The message s
04a0: 74 72 69 6e 67 20 74 6f 20 62 65 20 6c 6f 67 67 tring to be logg
04b0: 65 64 2e 0d 0a 20 20 2f 2f 2f 20 3c 2f 70 61 72 ed... /// </par
04c0: 61 6d 3e 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f am>..#if !PLATFO
04d0: 52 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 RM_COMPACTFRAMEW
04e0: 4f 52 4b 0d 0a 20 20 5b 55 6e 6d 61 6e 61 67 65 ORK.. [Unmanage
04f0: 64 46 75 6e 63 74 69 6f 6e 50 6f 69 6e 74 65 72 dFunctionPointer
0500: 28 43 61 6c 6c 69 6e 67 43 6f 6e 76 65 6e 74 69 (CallingConventi
0510: 6f 6e 2e 43 64 65 63 6c 29 5d 0d 0a 23 65 6e 64 on.Cdecl)]..#end
0520: 69 66 0d 0a 20 20 69 6e 74 65 72 6e 61 6c 20 64 if.. internal d
0530: 65 6c 65 67 61 74 65 20 76 6f 69 64 20 53 51 4c elegate void SQL
0540: 69 74 65 4c 6f 67 43 61 6c 6c 62 61 63 6b 28 49 iteLogCallback(I
0550: 6e 74 50 74 72 20 70 55 73 65 72 44 61 74 61 2c ntPtr pUserData,
0560: 20 69 6e 74 20 65 72 72 6f 72 43 6f 64 65 2c 20 int errorCode,
0570: 49 6e 74 50 74 72 20 70 4d 65 73 73 61 67 65 29 IntPtr pMessage)
0580: 3b 0d 0a 0d 0a 20 20 2f 2f 2f 20 3c 73 75 6d 6d ;.... /// <summ
0590: 61 72 79 3e 0d 0a 20 20 2f 2f 2f 20 54 68 69 73 ary>.. /// This
05a0: 20 63 6c 61 73 73 20 69 6d 70 6c 65 6d 65 6e 74 class implement
05b0: 73 20 53 51 4c 69 74 65 42 61 73 65 20 63 6f 6d s SQLiteBase com
05c0: 70 6c 65 74 65 6c 79 2c 20 61 6e 64 20 69 73 20 pletely, and is
05d0: 74 68 65 20 67 75 74 73 20 6f 66 20 74 68 65 20 the guts of the
05e0: 63 6f 64 65 20 74 68 61 74 20 69 6e 74 65 72 6f code that intero
05f0: 70 27 73 20 53 51 4c 69 74 65 20 77 69 74 68 20 p's SQLite with
0600: 2e 4e 45 54 0d 0a 20 20 2f 2f 2f 20 3c 2f 73 75 .NET.. /// </su
0610: 6d 6d 61 72 79 3e 0d 0a 20 20 69 6e 74 65 72 6e mmary>.. intern
0620: 61 6c 20 63 6c 61 73 73 20 53 51 4c 69 74 65 33 al class SQLite3
0630: 20 3a 20 53 51 4c 69 74 65 42 61 73 65 0d 0a 20 : SQLiteBase..
0640: 20 7b 0d 0a 20 20 20 20 70 72 69 76 61 74 65 20 {.. private
0650: 73 74 61 74 69 63 20 6f 62 6a 65 63 74 20 73 79 static object sy
0660: 6e 63 52 6f 6f 74 20 3d 20 6e 65 77 20 6f 62 6a ncRoot = new obj
0670: 65 63 74 28 29 3b 0d 0a 0d 0a 20 20 20 20 2f 2f ect();.... //
0680: 0d 0a 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 54 .. // NOTE: T
0690: 68 69 73 20 69 73 20 74 68 65 20 70 75 62 6c 69 his is the publi
06a0: 63 20 6b 65 79 20 66 6f 72 20 74 68 65 20 53 79 c key for the Sy
06b0: 73 74 65 6d 2e 44 61 74 61 2e 53 51 4c 69 74 65 stem.Data.SQLite
06c0: 20 61 73 73 65 6d 62 6c 79 2e 20 20 49 66 20 79 assembly. If y
06d0: 6f 75 20 63 68 61 6e 67 65 20 74 68 65 0d 0a 20 ou change the..
06e0: 20 20 20 2f 2f 20 20 20 20 20 20 20 53 4e 4b 20 // SNK
06f0: 66 69 6c 65 2c 20 79 6f 75 20 77 69 6c 6c 20 6e file, you will n
0700: 65 65 64 20 74 6f 20 63 68 61 6e 67 65 20 74 68 eed to change th
0710: 69 73 20 61 73 20 77 65 6c 6c 2e 0d 0a 20 20 20 is as well...
0720: 20 2f 2f 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 //.. interna
0730: 6c 20 63 6f 6e 73 74 20 73 74 72 69 6e 67 20 50 l const string P
0740: 75 62 6c 69 63 4b 65 79 20 3d 0d 0a 20 20 20 20 ublicKey =..
0750: 20 20 20 20 22 30 30 32 34 30 30 30 30 30 34 38 "00240000048
0760: 30 30 30 30 30 39 34 30 30 30 30 30 30 30 36 30 0000094000000060
0770: 32 30 30 30 30 30 30 32 34 30 30 30 30 35 32 35 2000000240000525
0780: 33 34 31 33 31 30 30 30 34 30 30 30 30 30 31 30 3413100040000010
0790: 30 30 31 30 30 30 35 61 32 38 38 64 65 35 36 38 0010005a288de568
07a0: 37 63 34 65 31 22 20 2b 0d 0a 20 20 20 20 20 20 7c4e1" +..
07b0: 20 20 22 62 36 32 31 64 64 66 66 35 64 38 34 34 "b621ddff5d844
07c0: 37 32 37 34 31 38 39 35 36 39 39 37 66 34 37 35 727418956997f475
07d0: 65 62 38 32 39 34 32 39 65 34 31 31 61 66 66 33 eb829429e411aff3
07e0: 65 39 33 66 39 37 62 37 30 64 65 36 39 38 62 39 e93f97b70de698b9
07f0: 37 32 36 34 30 39 32 35 62 64 64 34 34 32 38 30 72640925bdd44280
0800: 64 66 30 22 20 2b 0d 0a 20 20 20 20 20 20 20 20 df0" +..
0810: 22 61 32 35 61 38 34 33 32 36 36 39 37 33 37 30 "a25a84326697370
0820: 34 31 33 37 63 62 62 30 65 37 34 34 31 63 31 66 4137cbb0e7441c1f
0830: 65 37 63 61 65 34 65 32 34 34 30 61 65 39 31 61 e7cae4e2440ae91a
0840: 62 38 63 64 65 33 39 33 33 66 65 62 63 62 31 61 b8cde3933febcb1a
0850: 63 34 38 64 64 33 33 62 34 30 65 31 33 63 34 32 c48dd33b40e13c42
0860: 31 22 20 2b 0d 0a 20 20 20 20 20 20 20 20 22 64 1" +.. "d
0870: 38 32 31 35 63 31 38 61 34 33 34 39 61 34 33 36 8215c18a4349a436
0880: 64 64 34 39 39 65 33 63 33 38 35 63 63 36 38 33 dd499e3c385cc683
0890: 30 31 35 66 38 38 36 66 36 63 31 30 62 64 39 30 015f886f6c10bd90
08a0: 31 31 35 65 62 32 62 64 36 31 62 36 37 37 35 30 115eb2bd61b67750
08b0: 38 33 39 65 33 61 31 39 39 34 31 64 63 39 63 22 839e3a19941dc9c"
08c0: 3b 0d 0a 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f ;....#if !PLATFO
08d0: 52 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 RM_COMPACTFRAMEW
08e0: 4f 52 4b 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 ORK.. interna
08f0: 6c 20 63 6f 6e 73 74 20 73 74 72 69 6e 67 20 44 l const string D
0900: 65 73 69 67 6e 65 72 56 65 72 73 69 6f 6e 20 3d esignerVersion =
0910: 20 22 31 2e 30 2e 31 30 30 2e 30 22 3b 0d 0a 23 "1.0.100.0";..#
0920: 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 2f 2f 2f endif.... ///
0930: 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 <summary>..
0940: 2f 2f 2f 20 54 68 65 20 6f 70 61 71 75 65 20 70 /// The opaque p
0950: 6f 69 6e 74 65 72 20 72 65 74 75 72 6e 65 64 20 ointer returned
0960: 74 6f 20 75 73 20 62 79 20 74 68 65 20 73 71 6c to us by the sql
0970: 69 74 65 20 70 72 6f 76 69 64 65 72 0d 0a 20 20 ite provider..
0980: 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e /// </summary>
0990: 0d 0a 20 20 20 20 70 72 6f 74 65 63 74 65 64 20 .. protected
09a0: 69 6e 74 65 72 6e 61 6c 20 53 51 4c 69 74 65 43 internal SQLiteC
09b0: 6f 6e 6e 65 63 74 69 6f 6e 48 61 6e 64 6c 65 20 onnectionHandle
09c0: 5f 73 71 6c 3b 0d 0a 20 20 20 20 70 72 6f 74 65 _sql;.. prote
09d0: 63 74 65 64 20 73 74 72 69 6e 67 20 5f 66 69 6c cted string _fil
09e0: 65 4e 61 6d 65 3b 0d 0a 20 20 20 20 70 72 6f 74 eName;.. prot
09f0: 65 63 74 65 64 20 53 51 4c 69 74 65 43 6f 6e 6e ected SQLiteConn
0a00: 65 63 74 69 6f 6e 46 6c 61 67 73 20 5f 66 6c 61 ectionFlags _fla
0a10: 67 73 3b 0d 0a 20 20 20 20 70 72 6f 74 65 63 74 gs;.. protect
0a20: 65 64 20 62 6f 6f 6c 20 5f 75 73 65 50 6f 6f 6c ed bool _usePool
0a30: 3b 0d 0a 20 20 20 20 70 72 6f 74 65 63 74 65 64 ;.. protected
0a40: 20 69 6e 74 20 5f 70 6f 6f 6c 56 65 72 73 69 6f int _poolVersio
0a50: 6e 3b 0d 0a 20 20 20 20 70 72 69 76 61 74 65 20 n;.. private
0a60: 69 6e 74 20 5f 63 61 6e 63 65 6c 43 6f 75 6e 74 int _cancelCount
0a70: 3b 0d 0a 0d 0a 23 69 66 20 28 4e 45 54 5f 33 35 ;....#if (NET_35
0a80: 20 7c 7c 20 4e 45 54 5f 34 30 20 7c 7c 20 4e 45 || NET_40 || NE
0a90: 54 5f 34 35 20 7c 7c 20 4e 45 54 5f 34 35 31 20 T_45 || NET_451
0aa0: 7c 7c 20 4e 45 54 5f 34 35 32 20 7c 7c 20 4e 45 || NET_452 || NE
0ab0: 54 5f 34 36 20 7c 7c 20 4e 45 54 5f 34 36 31 29 T_46 || NET_461)
0ac0: 20 26 26 20 21 50 4c 41 54 46 4f 52 4d 5f 43 4f && !PLATFORM_CO
0ad0: 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 4b 0d 0a MPACTFRAMEWORK..
0ae0: 20 20 20 20 70 72 69 76 61 74 65 20 62 6f 6f 6c private bool
0af0: 20 5f 62 75 69 6c 64 69 6e 67 53 63 68 65 6d 61 _buildingSchema
0b00: 3b 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 ;..#endif....
0b10: 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
0b20: 20 20 20 20 2f 2f 2f 20 54 68 65 20 75 73 65 72 /// The user
0b30: 2d 64 65 66 69 6e 65 64 20 66 75 6e 63 74 69 6f -defined functio
0b40: 6e 73 20 72 65 67 69 73 74 65 72 65 64 20 6f 6e ns registered on
0b50: 20 74 68 69 73 20 63 6f 6e 6e 65 63 74 69 6f 6e this connection
0b60: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d .. /// </summ
0b70: 61 72 79 3e 0d 0a 20 20 20 20 70 72 6f 74 65 63 ary>.. protec
0b80: 74 65 64 20 44 69 63 74 69 6f 6e 61 72 79 3c 53 ted Dictionary<S
0b90: 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 QLiteFunctionAtt
0ba0: 72 69 62 75 74 65 2c 20 53 51 4c 69 74 65 46 75 ribute, SQLiteFu
0bb0: 6e 63 74 69 6f 6e 3e 20 5f 66 75 6e 63 74 69 6f nction> _functio
0bc0: 6e 73 3b 0d 0a 0d 0a 23 69 66 20 49 4e 54 45 52 ns;....#if INTER
0bd0: 4f 50 5f 56 49 52 54 55 41 4c 5f 54 41 42 4c 45 OP_VIRTUAL_TABLE
0be0: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 .. /// <summa
0bf0: 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 69 ry>.. /// Thi
0c00: 73 20 69 73 20 74 68 65 20 6e 61 6d 65 20 6f 66 s is the name of
0c10: 20 74 68 65 20 6e 61 74 69 76 65 20 6c 69 62 72 the native libr
0c20: 61 72 79 20 66 69 6c 65 20 74 68 61 74 20 63 6f ary file that co
0c30: 6e 74 61 69 6e 73 20 74 68 65 0d 0a 20 20 20 20 ntains the..
0c40: 2f 2f 2f 20 22 76 74 73 68 69 6d 22 20 65 78 74 /// "vtshim" ext
0c50: 65 6e 73 69 6f 6e 20 5b 77 72 61 70 70 65 72 5d ension [wrapper]
0c60: 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d ... /// </sum
0c70: 6d 61 72 79 3e 0d 0a 20 20 20 20 70 72 6f 74 65 mary>.. prote
0c80: 63 74 65 64 20 73 74 72 69 6e 67 20 5f 73 68 69 cted string _shi
0c90: 6d 45 78 74 65 6e 73 69 6f 6e 46 69 6c 65 4e 61 mExtensionFileNa
0ca0: 6d 65 20 3d 0d 0a 20 20 20 20 20 20 20 20 55 6e me =.. Un
0cb0: 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
0cc0: 73 2e 47 65 74 4e 61 74 69 76 65 4c 69 62 72 61 s.GetNativeLibra
0cd0: 72 79 46 69 6c 65 4e 61 6d 65 4f 6e 6c 79 28 29 ryFileNameOnly()
0ce0: 3b 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 ;.... /// <su
0cf0: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
0d00: 54 68 69 73 20 69 73 20 74 68 65 20 6e 61 6d 65 This is the name
0d10: 20 6f 66 20 74 68 65 20 6e 61 74 69 76 65 20 65 of the native e
0d20: 6e 74 72 79 20 70 6f 69 6e 74 20 66 6f 72 20 74 ntry point for t
0d30: 68 65 20 22 76 74 73 68 69 6d 22 0d 0a 20 20 20 he "vtshim"..
0d40: 20 2f 2f 2f 20 65 78 74 65 6e 73 69 6f 6e 20 5b /// extension [
0d50: 77 72 61 70 70 65 72 5d 2e 0d 0a 20 20 20 20 2f wrapper]... /
0d60: 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 // </summary>..
0d70: 20 20 20 70 72 6f 74 65 63 74 65 64 20 73 74 72 protected str
0d80: 69 6e 67 20 5f 73 68 69 6d 45 78 74 65 6e 73 69 ing _shimExtensi
0d90: 6f 6e 50 72 6f 63 4e 61 6d 65 20 3d 20 22 73 71 onProcName = "sq
0da0: 6c 69 74 65 33 5f 76 74 73 68 69 6d 5f 69 6e 69 lite3_vtshim_ini
0db0: 74 22 3b 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c t";.... /// <
0dc0: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
0dd0: 2f 20 54 68 65 20 6d 6f 64 75 6c 65 73 20 63 72 / The modules cr
0de0: 65 61 74 65 64 20 75 73 69 6e 67 20 74 68 69 73 eated using this
0df0: 20 63 6f 6e 6e 65 63 74 69 6f 6e 2e 0d 0a 20 20 connection...
0e00: 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e /// </summary>
0e10: 0d 0a 20 20 20 20 70 72 6f 74 65 63 74 65 64 20 .. protected
0e20: 44 69 63 74 69 6f 6e 61 72 79 3c 73 74 72 69 6e Dictionary<strin
0e30: 67 2c 20 53 51 4c 69 74 65 4d 6f 64 75 6c 65 3e g, SQLiteModule>
0e40: 20 5f 6d 6f 64 75 6c 65 73 3b 0d 0a 23 65 6e 64 _modules;..#end
0e50: 69 66 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f if.... //////
0e60: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
0e70: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
0e80: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
0e90: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
0ea0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
0eb0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 /////////....
0ec0: 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
0ed0: 20 20 20 20 2f 2f 2f 20 43 6f 6e 73 74 72 75 63 /// Construc
0ee0: 74 73 20 74 68 65 20 6f 62 6a 65 63 74 20 75 73 ts the object us
0ef0: 65 64 20 74 6f 20 69 6e 74 65 72 61 63 74 20 77 ed to interact w
0f00: 69 74 68 20 74 68 65 20 53 51 4c 69 74 65 20 63 ith the SQLite c
0f10: 6f 72 65 20 6c 69 62 72 61 72 79 0d 0a 20 20 20 ore library..
0f20: 20 2f 2f 2f 20 75 73 69 6e 67 20 74 68 65 20 55 /// using the U
0f30: 54 46 2d 38 20 74 65 78 74 20 65 6e 63 6f 64 69 TF-8 text encodi
0f40: 6e 67 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 ng... /// </s
0f50: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
0f60: 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 66 6d <param name="fm
0f70: 74 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 t">.. /// The
0f80: 20 44 61 74 65 54 69 6d 65 20 66 6f 72 6d 61 74 DateTime format
0f90: 20 74 6f 20 62 65 20 75 73 65 64 20 77 68 65 6e to be used when
0fa0: 20 63 6f 6e 76 65 72 74 69 6e 67 20 73 74 72 69 converting stri
0fb0: 6e 67 20 76 61 6c 75 65 73 20 74 6f 20 61 0d 0a ng values to a..
0fc0: 20 20 20 20 2f 2f 2f 20 44 61 74 65 54 69 6d 65 /// DateTime
0fd0: 20 61 6e 64 20 62 69 6e 64 69 6e 67 20 44 61 74 and binding Dat
0fe0: 65 54 69 6d 65 20 70 61 72 61 6d 65 74 65 72 73 eTime parameters
0ff0: 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 ... /// </par
1000: 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 am>.. /// <pa
1010: 72 61 6d 20 6e 61 6d 65 3d 22 6b 69 6e 64 22 3e ram name="kind">
1020: 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 3c 73 .. /// The <s
1030: 65 65 20 63 72 65 66 3d 22 44 61 74 65 54 69 6d ee cref="DateTim
1040: 65 4b 69 6e 64 22 20 2f 3e 20 74 6f 20 62 65 20 eKind" /> to be
1050: 75 73 65 64 20 77 68 65 6e 20 63 72 65 61 74 69 used when creati
1060: 6e 67 20 44 61 74 65 54 69 6d 65 0d 0a 20 20 20 ng DateTime..
1070: 20 2f 2f 2f 20 76 61 6c 75 65 73 2e 0d 0a 20 20 /// values...
1080: 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a /// </param>..
1090: 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e /// <param n
10a0: 61 6d 65 3d 22 66 6d 74 53 74 72 69 6e 67 22 3e ame="fmtString">
10b0: 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 66 6f .. /// The fo
10c0: 72 6d 61 74 20 73 74 72 69 6e 67 20 74 6f 20 62 rmat string to b
10d0: 65 20 75 73 65 64 20 77 68 65 6e 20 70 61 72 73 e used when pars
10e0: 69 6e 67 20 61 6e 64 20 66 6f 72 6d 61 74 74 69 ing and formatti
10f0: 6e 67 20 44 61 74 65 54 69 6d 65 0d 0a 20 20 20 ng DateTime..
1100: 20 2f 2f 2f 20 76 61 6c 75 65 73 2e 0d 0a 20 20 /// values...
1110: 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a /// </param>..
1120: 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e /// <param n
1130: 61 6d 65 3d 22 64 62 22 3e 0d 0a 20 20 20 20 2f ame="db">.. /
1140: 2f 2f 20 54 68 65 20 6e 61 74 69 76 65 20 68 61 // The native ha
1150: 6e 64 6c 65 20 74 6f 20 62 65 20 61 73 73 6f 63 ndle to be assoc
1160: 69 61 74 65 64 20 77 69 74 68 20 74 68 65 20 64 iated with the d
1170: 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 atabase connecti
1180: 6f 6e 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 on... /// </p
1190: 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c aram>.. /// <
11a0: 70 61 72 61 6d 20 6e 61 6d 65 3d 22 66 69 6c 65 param name="file
11b0: 4e 61 6d 65 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 Name">.. ///
11c0: 54 68 65 20 66 75 6c 6c 79 20 71 75 61 6c 69 66 The fully qualif
11d0: 69 65 64 20 66 69 6c 65 20 6e 61 6d 65 20 61 73 ied file name as
11e0: 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 3c 70 sociated with <p
11f0: 61 72 61 6d 72 65 66 20 6e 61 6d 65 3d 22 64 62 aramref name="db
1200: 20 22 2f 3e 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c "/>... /// <
1210: 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f /param>.. ///
1220: 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 6f 77 <param name="ow
1230: 6e 48 61 6e 64 6c 65 22 3e 0d 0a 20 20 20 20 2f nHandle">.. /
1240: 2f 2f 20 4e 6f 6e 2d 7a 65 72 6f 20 69 66 20 74 // Non-zero if t
1250: 68 65 20 6e 65 77 6c 79 20 63 72 65 61 74 65 64 he newly created
1260: 20 6f 62 6a 65 63 74 20 69 6e 73 74 61 6e 63 65 object instance
1270: 20 77 69 6c 6c 20 6e 65 65 64 20 74 6f 20 64 69 will need to di
1280: 73 70 6f 73 65 0d 0a 20 20 20 20 2f 2f 2f 20 6f spose.. /// o
1290: 66 20 3c 70 61 72 61 6d 72 65 66 20 6e 61 6d 65 f <paramref name
12a0: 3d 22 64 62 22 20 2f 3e 20 77 68 65 6e 20 69 74 ="db" /> when it
12b0: 20 69 73 20 6e 6f 20 6c 6f 6e 67 65 72 20 6e 65 is no longer ne
12c0: 65 64 65 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c eded... /// <
12d0: 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 69 6e 74 /param>.. int
12e0: 65 72 6e 61 6c 20 53 51 4c 69 74 65 33 28 0d 0a ernal SQLite3(..
12f0: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 44 61 SQLiteDa
1300: 74 65 46 6f 72 6d 61 74 73 20 66 6d 74 2c 0d 0a teFormats fmt,..
1310: 20 20 20 20 20 20 20 20 44 61 74 65 54 69 6d 65 DateTime
1320: 4b 69 6e 64 20 6b 69 6e 64 2c 0d 0a 20 20 20 20 Kind kind,..
1330: 20 20 20 20 73 74 72 69 6e 67 20 66 6d 74 53 74 string fmtSt
1340: 72 69 6e 67 2c 0d 0a 20 20 20 20 20 20 20 20 49 ring,.. I
1350: 6e 74 50 74 72 20 64 62 2c 0d 0a 20 20 20 20 20 ntPtr db,..
1360: 20 20 20 73 74 72 69 6e 67 20 66 69 6c 65 4e 61 string fileNa
1370: 6d 65 2c 0d 0a 20 20 20 20 20 20 20 20 62 6f 6f me,.. boo
1380: 6c 20 6f 77 6e 48 61 6e 64 6c 65 0d 0a 20 20 20 l ownHandle..
1390: 20 20 20 20 20 29 0d 0a 20 20 20 20 20 20 3a 20 ).. :
13a0: 62 61 73 65 28 66 6d 74 2c 20 6b 69 6e 64 2c 20 base(fmt, kind,
13b0: 66 6d 74 53 74 72 69 6e 67 29 0d 0a 20 20 20 20 fmtString)..
13c0: 7b 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 64 {.. if (d
13d0: 62 20 21 3d 20 49 6e 74 50 74 72 2e 5a 65 72 6f b != IntPtr.Zero
13e0: 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 ).. {..
13f0: 20 20 20 20 20 20 20 20 20 20 5f 73 71 6c 20 3d _sql =
1400: 20 6e 65 77 20 53 51 4c 69 74 65 43 6f 6e 6e 65 new SQLiteConne
1410: 63 74 69 6f 6e 48 61 6e 64 6c 65 28 64 62 2c 20 ctionHandle(db,
1420: 6f 77 6e 48 61 6e 64 6c 65 29 3b 0d 0a 20 20 20 ownHandle);..
1430: 20 20 20 20 20 20 20 20 20 5f 66 69 6c 65 4e 61 _fileNa
1440: 6d 65 20 3d 20 66 69 6c 65 4e 61 6d 65 3b 0d 0a me = fileName;..
1450: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 53 51 .. SQ
1460: 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 2e 4f LiteConnection.O
1470: 6e 43 68 61 6e 67 65 64 28 6e 75 6c 6c 2c 20 6e nChanged(null, n
1480: 65 77 20 43 6f 6e 6e 65 63 74 69 6f 6e 45 76 65 ew ConnectionEve
1490: 6e 74 41 72 67 73 28 0d 0a 20 20 20 20 20 20 20 ntArgs(..
14a0: 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 43 SQLiteC
14b0: 6f 6e 6e 65 63 74 69 6f 6e 45 76 65 6e 74 54 79 onnectionEventTy
14c0: 70 65 2e 4e 65 77 43 72 69 74 69 63 61 6c 48 61 pe.NewCriticalHa
14d0: 6e 64 6c 65 2c 20 6e 75 6c 6c 2c 0d 0a 20 20 20 ndle, null,..
14e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 6e 75 6c nul
14f0: 6c 2c 20 6e 75 6c 6c 2c 20 6e 75 6c 6c 2c 20 5f l, null, null, _
1500: 73 71 6c 2c 20 66 69 6c 65 4e 61 6d 65 2c 20 6e sql, fileName, n
1510: 65 77 20 6f 62 6a 65 63 74 5b 5d 20 7b 0d 0a 20 ew object[] {..
1520: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 t
1530: 79 70 65 6f 66 28 53 51 4c 69 74 65 33 29 2c 20 ypeof(SQLite3),
1540: 66 6d 74 2c 20 6b 69 6e 64 2c 20 66 6d 74 53 74 fmt, kind, fmtSt
1550: 72 69 6e 67 2c 20 64 62 2c 20 66 69 6c 65 4e 61 ring, db, fileNa
1560: 6d 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 me,..
1570: 20 20 20 20 20 6f 77 6e 48 61 6e 64 6c 65 20 7d ownHandle }
1580: 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a ));.. }..
1590: 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f }.... ///
15a0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
15b0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
15c0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
15d0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
15e0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
15f0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a ////////////....
1600: 20 20 20 20 23 72 65 67 69 6f 6e 20 49 44 69 73 #region IDis
1610: 70 6f 73 61 62 6c 65 20 22 50 61 74 74 65 72 6e posable "Pattern
1620: 22 20 4d 65 6d 62 65 72 73 0d 0a 20 20 20 20 70 " Members.. p
1630: 72 69 76 61 74 65 20 62 6f 6f 6c 20 64 69 73 70 rivate bool disp
1640: 6f 73 65 64 3b 0d 0a 20 20 20 20 70 72 69 76 61 osed;.. priva
1650: 74 65 20 76 6f 69 64 20 43 68 65 63 6b 44 69 73 te void CheckDis
1660: 70 6f 73 65 64 28 29 20 2f 2a 20 74 68 72 6f 77 posed() /* throw
1670: 20 2a 2f 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 */.. {..#if
1680: 54 48 52 4f 57 5f 4f 4e 5f 44 49 53 50 4f 53 45 THROW_ON_DISPOSE
1690: 44 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 64 D.. if (d
16a0: 69 73 70 6f 73 65 64 29 0d 0a 20 20 20 20 20 20 isposed)..
16b0: 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 throw new
16c0: 4f 62 6a 65 63 74 44 69 73 70 6f 73 65 64 45 78 ObjectDisposedEx
16d0: 63 65 70 74 69 6f 6e 28 74 79 70 65 6f 66 28 53 ception(typeof(S
16e0: 51 4c 69 74 65 33 29 2e 4e 61 6d 65 29 3b 0d 0a QLite3).Name);..
16f0: 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d 0a 0d #endif.. }...
1700: 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f . ///////////
1710: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1720: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1730: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1740: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1750: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1760: 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 70 72 6f 74 ////.... prot
1770: 65 63 74 65 64 20 6f 76 65 72 72 69 64 65 20 76 ected override v
1780: 6f 69 64 20 44 69 73 70 6f 73 65 28 62 6f 6f 6c oid Dispose(bool
1790: 20 64 69 73 70 6f 73 69 6e 67 29 0d 0a 20 20 20 disposing)..
17a0: 20 7b 0d 0a 20 20 20 20 20 20 20 20 74 72 79 0d {.. try.
17b0: 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 . {..
17c0: 20 20 20 20 20 20 20 20 69 66 20 28 21 64 69 73 if (!dis
17d0: 70 6f 73 65 64 29 0d 0a 20 20 20 20 20 20 20 20 posed)..
17e0: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
17f0: 20 20 20 20 20 20 20 2f 2f 69 66 20 28 64 69 73 //if (dis
1800: 70 6f 73 69 6e 67 29 0d 0a 20 20 20 20 20 20 20 posing)..
1810: 20 20 20 20 20 20 20 20 20 2f 2f 7b 0d 0a 20 20 //{..
1820: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f //
1830: 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////
1840: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1850: 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 20 20 20 20 20 20 ////////..
1860: 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 //
1870: 2f 2f 20 64 69 73 70 6f 73 65 20 6d 61 6e 61 67 // dispose manag
1880: 65 64 20 72 65 73 6f 75 72 63 65 73 20 68 65 72 ed resources her
1890: 65 2e 2e 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 e.....
18a0: 20 20 20 20 20 20 2f 2f 20 20 20 20 2f 2f 2f 2f // ////
18b0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
18c0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
18d0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
18e0: 20 20 2f 2f 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 //}....
18f0: 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 2f 2f 2f ///////
1900: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1910: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d ///////////////.
1920: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
1930: 20 2f 2f 20 72 65 6c 65 61 73 65 20 75 6e 6d 61 // release unma
1940: 6e 61 67 65 64 20 72 65 73 6f 75 72 63 65 73 20 naged resources
1950: 68 65 72 65 2e 2e 2e 0d 0a 20 20 20 20 20 20 20 here.....
1960: 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 2f 2f 2f ///////
1970: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1980: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d ///////////////.
1990: 0a 0d 0a 23 69 66 20 49 4e 54 45 52 4f 50 5f 56 ...#if INTEROP_V
19a0: 49 52 54 55 41 4c 5f 54 41 42 4c 45 0d 0a 20 20 IRTUAL_TABLE..
19b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 69 Di
19c0: 73 70 6f 73 65 4d 6f 64 75 6c 65 73 28 29 3b 0d sposeModules();.
19d0: 0a 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 .#endif....
19e0: 20 20 20 20 20 20 20 20 20 20 20 43 6c 6f 73 65 Close
19f0: 28 66 61 6c 73 65 29 3b 20 2f 2a 20 44 69 73 70 (false); /* Disp
1a00: 6f 73 69 6e 67 2c 20 63 61 6e 6e 6f 74 20 74 68 osing, cannot th
1a10: 72 6f 77 2e 20 2a 2f 0d 0a 20 20 20 20 20 20 20 row. */..
1a20: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
1a30: 7d 0d 0a 20 20 20 20 20 20 20 20 66 69 6e 61 6c }.. final
1a40: 6c 79 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 ly.. {..
1a50: 20 20 20 20 20 20 20 20 20 20 20 62 61 73 65 2e base.
1a60: 44 69 73 70 6f 73 65 28 64 69 73 70 6f 73 69 6e Dispose(disposin
1a70: 67 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 g);....
1a80: 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 20 //..
1a90: 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 45 76 65 72 // NOTE: Ever
1aa0: 79 74 68 69 6e 67 20 73 68 6f 75 6c 64 20 62 65 ything should be
1ab0: 20 66 75 6c 6c 79 20 64 69 73 70 6f 73 65 64 20 fully disposed
1ac0: 61 74 20 74 68 69 73 20 70 6f 69 6e 74 2e 0d 0a at this point...
1ad0: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 0d 0a //..
1ae0: 20 20 20 20 20 20 20 20 20 20 20 20 64 69 73 70 disp
1af0: 6f 73 65 64 20 3d 20 74 72 75 65 3b 0d 0a 20 20 osed = true;..
1b00: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a }.. }..
1b10: 20 20 20 20 23 65 6e 64 72 65 67 69 6f 6e 0d 0a #endregion..
1b20: 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f .. //////////
1b30: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b40: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b50: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b60: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b70: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b80: 2f 2f 2f 2f 2f 0d 0a 0d 0a 23 69 66 20 49 4e 54 /////....#if INT
1b90: 45 52 4f 50 5f 56 49 52 54 55 41 4c 5f 54 41 42 EROP_VIRTUAL_TAB
1ba0: 4c 45 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d LE.. /// <sum
1bb0: 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 mary>.. /// T
1bc0: 68 69 73 20 6d 65 74 68 6f 64 20 61 74 74 65 6d his method attem
1bd0: 70 74 73 20 74 6f 20 64 69 73 70 6f 73 65 20 6f pts to dispose o
1be0: 66 20 61 6c 6c 20 74 68 65 20 3c 73 65 65 20 63 f all the <see c
1bf0: 72 65 66 3d 22 53 51 4c 69 74 65 4d 6f 64 75 6c ref="SQLiteModul
1c00: 65 22 20 2f 3e 20 64 65 72 69 76 65 64 0d 0a 20 e" /> derived..
1c10: 20 20 20 2f 2f 2f 20 6f 62 6a 65 63 74 20 69 6e /// object in
1c20: 73 74 61 6e 63 65 73 20 63 75 72 72 65 6e 74 6c stances currentl
1c30: 79 20 61 73 73 6f 63 69 61 74 65 64 20 77 69 74 y associated wit
1c40: 68 20 74 68 65 20 6e 61 74 69 76 65 20 64 61 74 h the native dat
1c50: 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e abase connection
1c60: 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d ... /// </sum
1c70: 6d 61 72 79 3e 0d 0a 20 20 20 20 70 72 69 76 61 mary>.. priva
1c80: 74 65 20 76 6f 69 64 20 44 69 73 70 6f 73 65 4d te void DisposeM
1c90: 6f 64 75 6c 65 73 28 29 0d 0a 20 20 20 20 7b 0d odules().. {.
1ca0: 0a 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 . //..
1cb0: 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 49 66 // NOTE: If
1cc0: 20 61 6e 79 20 6d 6f 64 75 6c 65 73 20 77 65 72 any modules wer
1cd0: 65 20 63 72 65 61 74 65 64 2c 20 61 74 74 65 6d e created, attem
1ce0: 70 74 20 74 6f 20 64 69 73 70 6f 73 65 20 6f 66 pt to dispose of
1cf0: 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 .. //
1d00: 20 20 20 74 68 65 6d 20 6e 6f 77 2e 20 20 54 68 them now. Th
1d10: 69 73 20 63 6f 64 65 20 69 73 20 64 65 73 69 67 is code is desig
1d20: 6e 65 64 20 74 6f 20 61 76 6f 69 64 20 74 68 72 ned to avoid thr
1d30: 6f 77 69 6e 67 0d 0a 20 20 20 20 20 20 20 20 2f owing.. /
1d40: 2f 20 20 20 20 20 20 20 65 78 63 65 70 74 69 6f / exceptio
1d50: 6e 73 20 75 6e 6c 65 73 73 20 74 68 65 20 44 69 ns unless the Di
1d60: 73 70 6f 73 65 20 6d 65 74 68 6f 64 20 6f 66 20 spose method of
1d70: 74 68 65 20 6d 6f 64 75 6c 65 0d 0a 20 20 20 20 the module..
1d80: 20 20 20 20 2f 2f 20 20 20 20 20 20 20 69 74 73 // its
1d90: 65 6c 66 20 74 68 72 6f 77 73 20 61 6e 20 65 78 elf throws an ex
1da0: 63 65 70 74 69 6f 6e 2e 0d 0a 20 20 20 20 20 20 ception...
1db0: 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 69 66 //.. if
1dc0: 20 28 5f 6d 6f 64 75 6c 65 73 20 21 3d 20 6e 75 (_modules != nu
1dd0: 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a ll).. {..
1de0: 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 65 fore
1df0: 61 63 68 20 28 4b 65 79 56 61 6c 75 65 50 61 69 ach (KeyValuePai
1e00: 72 3c 73 74 72 69 6e 67 2c 20 53 51 4c 69 74 65 r<string, SQLite
1e10: 4d 6f 64 75 6c 65 3e 20 70 61 69 72 20 69 6e 20 Module> pair in
1e20: 5f 6d 6f 64 75 6c 65 73 29 0d 0a 20 20 20 20 20 _modules)..
1e30: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
1e40: 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 SQLite
1e50: 4d 6f 64 75 6c 65 20 6d 6f 64 75 6c 65 20 3d 20 Module module =
1e60: 70 61 69 72 2e 56 61 6c 75 65 3b 0d 0a 0d 0a 20 pair.Value;....
1e70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 i
1e80: 66 20 28 6d 6f 64 75 6c 65 20 3d 3d 20 6e 75 6c f (module == nul
1e90: 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 l)..
1ea0: 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 continue
1eb0: 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ;....
1ec0: 20 20 20 20 20 6d 6f 64 75 6c 65 2e 44 69 73 70 module.Disp
1ed0: 6f 73 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 ose();..
1ee0: 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 }....
1ef0: 20 20 20 20 20 5f 6d 6f 64 75 6c 65 73 2e 43 6c _modules.Cl
1f00: 65 61 72 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 ear();..
1f10: 7d 0d 0a 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 }.. }..#endif
1f20: 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f .... ////////
1f30: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1f40: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1f50: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1f60: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1f70: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1f80: 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 2f ///////.... /
1f90: 2f 20 49 74 20 69 73 6e 27 74 20 6e 65 63 65 73 / It isn't neces
1fa0: 73 61 72 79 20 74 6f 20 63 6c 65 61 6e 75 70 20 sary to cleanup
1fb0: 61 6e 79 20 66 75 6e 63 74 69 6f 6e 73 20 77 65 any functions we
1fc0: 27 76 65 20 72 65 67 69 73 74 65 72 65 64 2e 20 've registered.
1fd0: 20 49 66 20 74 68 65 20 63 6f 6e 6e 65 63 74 69 If the connecti
1fe0: 6f 6e 0d 0a 20 20 20 20 2f 2f 20 67 6f 65 73 20 on.. // goes
1ff0: 74 6f 20 74 68 65 20 70 6f 6f 6c 20 61 6e 64 20 to the pool and
2000: 69 73 20 72 65 73 75 72 72 65 63 74 65 64 20 6c is resurrected l
2010: 61 74 65 72 2c 20 72 65 2d 72 65 67 69 73 74 65 ater, re-registe
2020: 72 65 64 20 66 75 6e 63 74 69 6f 6e 73 20 77 69 red functions wi
2030: 6c 6c 20 6f 76 65 72 77 72 69 74 65 20 74 68 65 ll overwrite the
2040: 0d 0a 20 20 20 20 2f 2f 20 70 72 65 76 69 6f 75 .. // previou
2050: 73 20 66 75 6e 63 74 69 6f 6e 73 2e 20 20 54 68 s functions. Th
2060: 65 20 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e e SQLiteFunction
2070: 43 6f 6f 6b 69 65 48 61 6e 64 6c 65 20 77 69 6c CookieHandle wil
2080: 6c 20 74 61 6b 65 20 63 61 72 65 20 6f 66 20 66 l take care of f
2090: 72 65 65 69 6e 67 20 75 6e 6d 61 6e 61 67 65 64 reeing unmanaged
20a0: 0d 0a 20 20 20 20 2f 2f 20 72 65 73 6f 75 72 63 .. // resourc
20b0: 65 73 20 62 65 6c 6f 6e 67 69 6e 67 20 74 6f 20 es belonging to
20c0: 74 68 65 20 70 72 65 76 69 6f 75 73 6c 79 2d 72 the previously-r
20d0: 65 67 69 73 74 65 72 65 64 20 66 75 6e 63 74 69 egistered functi
20e0: 6f 6e 73 2e 0d 0a 20 20 20 20 69 6e 74 65 72 6e ons... intern
20f0: 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f 69 64 al override void
2100: 20 43 6c 6f 73 65 28 62 6f 6f 6c 20 63 61 6e 54 Close(bool canT
2110: 68 72 6f 77 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 hrow).. {..
2120: 20 20 20 20 69 66 20 28 5f 73 71 6c 20 21 3d 20 if (_sql !=
2130: 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 7b 0d 0a null).. {..
2140: 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 5f if (!_
2150: 73 71 6c 2e 4f 77 6e 48 61 6e 64 6c 65 29 0d 0a sql.OwnHandle)..
2160: 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
2170: 20 20 20 20 20 20 20 20 20 20 20 5f 73 71 6c 20 _sql
2180: 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 = null;..
2190: 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a return;..
21a0: 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 }....
21b0: 20 20 20 20 20 20 20 20 20 62 6f 6f 6c 20 75 6e bool un
21c0: 62 69 6e 64 46 75 6e 63 74 69 6f 6e 73 20 3d 20 bindFunctions =
21d0: 28 28 5f 66 6c 61 67 73 20 26 20 53 51 4c 69 74 ((_flags & SQLit
21e0: 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 eConnectionFlags
21f0: 2e 55 6e 62 69 6e 64 46 75 6e 63 74 69 6f 6e 73 .UnbindFunctions
2200: 4f 6e 43 6c 6f 73 65 29 0d 0a 20 20 20 20 20 20 OnClose)..
2210: 20 20 20 20 20 20 20 20 20 20 3d 3d 20 53 51 4c == SQL
2220: 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 iteConnectionFla
2230: 67 73 2e 55 6e 62 69 6e 64 46 75 6e 63 74 69 6f gs.UnbindFunctio
2240: 6e 73 4f 6e 43 6c 6f 73 65 29 3b 0d 0a 0d 0a 20 nsOnClose);....
2250: 20 20 20 20 20 20 20 20 20 69 66 20 28 5f 75 73 if (_us
2260: 65 50 6f 6f 6c 29 0d 0a 20 20 20 20 20 20 20 20 ePool)..
2270: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
2280: 20 20 20 69 66 20 28 53 51 4c 69 74 65 42 61 73 if (SQLiteBas
2290: 65 2e 52 65 73 65 74 43 6f 6e 6e 65 63 74 69 6f e.ResetConnectio
22a0: 6e 28 5f 73 71 6c 2c 20 5f 73 71 6c 2c 20 63 61 n(_sql, _sql, ca
22b0: 6e 54 68 72 6f 77 29 29 0d 0a 20 20 20 20 20 20 nThrow))..
22c0: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
22d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 if
22e0: 28 75 6e 62 69 6e 64 46 75 6e 63 74 69 6f 6e 73 (unbindFunctions
22f0: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )..
2300: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
2310: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 if
2320: 20 28 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e (SQLiteFunction
2330: 2e 55 6e 62 69 6e 64 41 6c 6c 46 75 6e 63 74 69 .UnbindAllFuncti
2340: 6f 6e 73 28 74 68 69 73 2c 20 5f 66 6c 61 67 73 ons(this, _flags
2350: 2c 20 66 61 6c 73 65 29 29 0d 0a 20 20 20 20 20 , false))..
2360: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2370: 20 7b 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d {..#if !NET_COM
2380: 50 41 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 PACT_20 && TRACE
2390: 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 _CONNECTION..
23a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
23b0: 20 20 20 20 20 20 20 54 72 61 63 65 2e 57 72 69 Trace.Wri
23c0: 74 65 4c 69 6e 65 28 55 6e 73 61 66 65 4e 61 74 teLine(UnsafeNat
23d0: 69 76 65 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e iveMethods.Strin
23e0: 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 gFormat(..
23f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2400: 20 20 20 20 20 20 20 20 43 75 6c 74 75 72 65 49 CultureI
2410: 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c 74 75 nfo.CurrentCultu
2420: 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 re,..
2430: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2440: 20 20 20 22 55 6e 62 69 6e 64 46 75 6e 63 74 69 "UnbindFuncti
2450: 6f 6e 73 20 28 50 6f 6f 6c 29 20 53 75 63 63 65 ons (Pool) Succe
2460: 73 73 3a 20 7b 30 7d 22 2c 0d 0a 20 20 20 20 20 ss: {0}",..
2470: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2480: 20 20 20 20 20 20 20 20 20 48 61 6e 64 6c 65 54 HandleT
2490: 6f 53 74 72 69 6e 67 28 29 29 29 3b 0d 0a 23 65 oString()));..#e
24a0: 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 ndif..
24b0: 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 }..
24c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
24d0: 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 else..
24e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
24f0: 20 7b 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d {..#if !NET_COM
2500: 50 41 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 PACT_20 && TRACE
2510: 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 _CONNECTION..
2520: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2530: 20 20 20 20 20 20 20 54 72 61 63 65 2e 57 72 69 Trace.Wri
2540: 74 65 4c 69 6e 65 28 55 6e 73 61 66 65 4e 61 74 teLine(UnsafeNat
2550: 69 76 65 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e iveMethods.Strin
2560: 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 gFormat(..
2570: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2580: 20 20 20 20 20 20 20 20 43 75 6c 74 75 72 65 49 CultureI
2590: 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c 74 75 nfo.CurrentCultu
25a0: 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 re,..
25b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
25c0: 20 20 20 22 55 6e 62 69 6e 64 46 75 6e 63 74 69 "UnbindFuncti
25d0: 6f 6e 73 20 28 50 6f 6f 6c 29 20 46 61 69 6c 75 ons (Pool) Failu
25e0: 72 65 3a 20 7b 30 7d 22 2c 0d 0a 20 20 20 20 20 re: {0}",..
25f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2600: 20 20 20 20 20 20 20 20 20 48 61 6e 64 6c 65 54 HandleT
2610: 6f 53 74 72 69 6e 67 28 29 29 29 3b 0d 0a 23 65 oString()));..#e
2620: 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 ndif..
2630: 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 }..
2640: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2650: 20 7d 0d 0a 0d 0a 23 69 66 20 49 4e 54 45 52 4f }....#if INTERO
2660: 50 5f 56 49 52 54 55 41 4c 5f 54 41 42 4c 45 0d P_VIRTUAL_TABLE.
2670: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
2680: 20 20 20 44 69 73 70 6f 73 65 4d 6f 64 75 6c 65 DisposeModule
2690: 73 28 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a s();..#endif....
26a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
26b0: 20 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 SQLiteConnecti
26c0: 6f 6e 50 6f 6f 6c 2e 41 64 64 28 5f 66 69 6c 65 onPool.Add(_file
26d0: 4e 61 6d 65 2c 20 5f 73 71 6c 2c 20 5f 70 6f 6f Name, _sql, _poo
26e0: 6c 56 65 72 73 69 6f 6e 29 3b 0d 0a 0d 0a 20 20 lVersion);....
26f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2700: 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e SQLiteConnection
2710: 2e 4f 6e 43 68 61 6e 67 65 64 28 6e 75 6c 6c 2c .OnChanged(null,
2720: 20 6e 65 77 20 43 6f 6e 6e 65 63 74 69 6f 6e 45 new ConnectionE
2730: 76 65 6e 74 41 72 67 73 28 0d 0a 20 20 20 20 20 ventArgs(..
2740: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2750: 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f SQLiteConnectio
2760: 6e 45 76 65 6e 74 54 79 70 65 2e 43 6c 6f 73 65 nEventType.Close
2770: 64 54 6f 50 6f 6f 6c 2c 20 6e 75 6c 6c 2c 20 6e dToPool, null, n
2780: 75 6c 6c 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 ull,..
2790: 20 20 20 20 20 20 20 20 20 20 20 20 6e 75 6c 6c null
27a0: 2c 20 6e 75 6c 6c 2c 20 5f 73 71 6c 2c 20 5f 66 , null, _sql, _f
27b0: 69 6c 65 4e 61 6d 65 2c 20 6e 65 77 20 6f 62 6a ileName, new obj
27c0: 65 63 74 5b 5d 20 7b 0d 0a 20 20 20 20 20 20 20 ect[] {..
27d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 t
27e0: 79 70 65 6f 66 28 53 51 4c 69 74 65 33 29 2c 20 ypeof(SQLite3),
27f0: 63 61 6e 54 68 72 6f 77 2c 20 5f 66 69 6c 65 4e canThrow, _fileN
2800: 61 6d 65 2c 20 5f 70 6f 6f 6c 56 65 72 73 69 6f ame, _poolVersio
2810: 6e 20 7d 29 29 3b 0d 0a 0d 0a 23 69 66 20 21 4e n }));....#if !N
2820: 45 54 5f 43 4f 4d 50 41 43 54 5f 32 30 20 26 26 ET_COMPACT_20 &&
2830: 20 54 52 41 43 45 5f 43 4f 4e 4e 45 43 54 49 4f TRACE_CONNECTIO
2840: 4e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 N..
2850: 20 20 20 20 20 54 72 61 63 65 2e 57 72 69 74 65 Trace.Write
2860: 4c 69 6e 65 28 55 6e 73 61 66 65 4e 61 74 69 76 Line(UnsafeNativ
2870: 65 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 eMethods.StringF
2880: 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 ormat(..
2890: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 43 75 Cu
28a0: 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e ltureInfo.Curren
28b0: 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 tCulture,..
28c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
28d0: 20 22 43 6c 6f 73 65 20 28 50 6f 6f 6c 29 20 53 "Close (Pool) S
28e0: 75 63 63 65 73 73 3a 20 7b 30 7d 22 2c 0d 0a 20 uccess: {0}",..
28f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2900: 20 20 20 20 20 48 61 6e 64 6c 65 54 6f 53 74 72 HandleToStr
2910: 69 6e 67 28 29 29 29 3b 0d 0a 23 65 6e 64 69 66 ing()));..#endif
2920: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
2930: 7d 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 }..#if !NET_COMP
2940: 41 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f ACT_20 && TRACE_
2950: 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 CONNECTION..
2960: 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a else..
2970: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d {.
2980: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
2990: 20 20 20 54 72 61 63 65 2e 57 72 69 74 65 4c 69 Trace.WriteLi
29a0: 6e 65 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d ne(UnsafeNativeM
29b0: 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 ethods.StringFor
29c0: 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 mat(..
29d0: 20 20 20 20 20 20 20 20 20 20 20 20 43 75 6c 74 Cult
29e0: 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 ureInfo.CurrentC
29f0: 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 ulture,..
2a00: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 "
2a10: 43 6c 6f 73 65 20 28 50 6f 6f 6c 29 20 46 61 69 Close (Pool) Fai
2a20: 6c 75 72 65 3a 20 7b 30 7d 22 2c 0d 0a 20 20 20 lure: {0}",..
2a30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2a40: 20 20 20 48 61 6e 64 6c 65 54 6f 53 74 72 69 6e HandleToStrin
2a50: 67 28 29 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 g()));..
2a60: 20 20 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d }..#endif.
2a70: 0a 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 . }..
2a80: 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 else..
2a90: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
2aa0: 20 20 20 20 20 20 20 20 20 69 66 20 28 75 6e 62 if (unb
2ab0: 69 6e 64 46 75 6e 63 74 69 6f 6e 73 29 0d 0a 20 indFunctions)..
2ac0: 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a {..
2ad0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2ae0: 20 20 69 66 20 28 53 51 4c 69 74 65 46 75 6e 63 if (SQLiteFunc
2af0: 74 69 6f 6e 2e 55 6e 62 69 6e 64 41 6c 6c 46 75 tion.UnbindAllFu
2b00: 6e 63 74 69 6f 6e 73 28 74 68 69 73 2c 20 5f 66 nctions(this, _f
2b10: 6c 61 67 73 2c 20 66 61 6c 73 65 29 29 0d 0a 20 lags, false))..
2b20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2b30: 20 7b 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d {..#if !NET_COM
2b40: 50 41 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 PACT_20 && TRACE
2b50: 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 _CONNECTION..
2b60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2b70: 20 20 20 54 72 61 63 65 2e 57 72 69 74 65 4c 69 Trace.WriteLi
2b80: 6e 65 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d ne(UnsafeNativeM
2b90: 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 ethods.StringFor
2ba0: 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 mat(..
2bb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2bc0: 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 CultureInfo.Curr
2bd0: 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 entCulture,..
2be0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2bf0: 20 20 20 20 20 20 20 22 55 6e 62 69 6e 64 46 75 "UnbindFu
2c00: 6e 63 74 69 6f 6e 73 20 53 75 63 63 65 73 73 3a nctions Success:
2c10: 20 7b 30 7d 22 2c 0d 0a 20 20 20 20 20 20 20 20 {0}",..
2c20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2c30: 20 20 48 61 6e 64 6c 65 54 6f 53 74 72 69 6e 67 HandleToString
2c40: 28 29 29 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 ()));..#endif..
2c50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2c60: 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 }..
2c70: 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 else..
2c80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d {.
2c90: 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 43 .#if !NET_COMPAC
2ca0: 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f 43 4f T_20 && TRACE_CO
2cb0: 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 20 20 NNECTION..
2cc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2cd0: 54 72 61 63 65 2e 57 72 69 74 65 4c 69 6e 65 28 Trace.WriteLine(
2ce0: 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
2cf0: 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d 61 74 ods.StringFormat
2d00: 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 (..
2d10: 20 20 20 20 20 20 20 20 20 20 20 20 20 43 75 6c Cul
2d20: 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 tureInfo.Current
2d30: 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 Culture,..
2d40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2d50: 20 20 20 20 22 55 6e 62 69 6e 64 46 75 6e 63 74 "UnbindFunct
2d60: 69 6f 6e 73 20 46 61 69 6c 75 72 65 3a 20 7b 30 ions Failure: {0
2d70: 7d 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 }",..
2d80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 48 H
2d90: 61 6e 64 6c 65 54 6f 53 74 72 69 6e 67 28 29 29 andleToString())
2da0: 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 );..#endif..
2db0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d }.
2dc0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d . }
2dd0: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ....
2de0: 20 20 5f 73 71 6c 2e 44 69 73 70 6f 73 65 28 29 _sql.Dispose()
2df0: 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 7d 0d 0a ;.. }..
2e00: 20 20 20 20 20 20 20 20 20 20 5f 73 71 6c 20 3d _sql =
2e10: 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 7d 0d null;.. }.
2e20: 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f . }.... //
2e30: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2e40: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2e50: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2e60: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2e70: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2e80: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d /////////////...
2e90: 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 43 .#if !NET_COMPAC
2ea0: 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f 43 4f T_20 && TRACE_CO
2eb0: 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 70 72 NNECTION.. pr
2ec0: 6f 74 65 63 74 65 64 20 73 74 72 69 6e 67 20 48 otected string H
2ed0: 61 6e 64 6c 65 54 6f 53 74 72 69 6e 67 28 29 0d andleToString().
2ee0: 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 . {..
2ef0: 69 66 20 28 5f 73 71 6c 20 3d 3d 20 6e 75 6c 6c if (_sql == null
2f00: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 ).. r
2f10: 65 74 75 72 6e 20 22 3c 6e 75 6c 6c 3e 22 3b 0d eturn "<null>";.
2f20: 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 ... retur
2f30: 6e 20 5f 73 71 6c 2e 54 6f 53 74 72 69 6e 67 28 n _sql.ToString(
2f40: 29 3b 0d 0a 20 20 20 20 7d 0d 0a 23 65 6e 64 69 );.. }..#endi
2f50: 66 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f f.... ///////
2f60: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2f70: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2f80: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2f90: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2fa0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2fb0: 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 ////////....
2fc0: 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 /// <summary>..
2fd0: 20 20 20 2f 2f 2f 20 52 65 74 75 72 6e 73 20 74 /// Returns t
2fe0: 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 74 69 6d he number of tim
2ff0: 65 73 20 74 68 65 20 3c 73 65 65 20 63 72 65 66 es the <see cref
3000: 3d 22 43 61 6e 63 65 6c 22 20 2f 3e 20 6d 65 74 ="Cancel" /> met
3010: 68 6f 64 20 68 61 73 20 62 65 65 6e 0d 0a 20 20 hod has been..
3020: 20 20 2f 2f 2f 20 63 61 6c 6c 65 64 2e 0d 0a 20 /// called...
3030: 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 /// </summary
3040: 3e 0d 0a 20 20 20 20 70 72 69 76 61 74 65 20 69 >.. private i
3050: 6e 74 20 47 65 74 43 61 6e 63 65 6c 43 6f 75 6e nt GetCancelCoun
3060: 74 28 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 t().. {..
3070: 20 20 20 20 72 65 74 75 72 6e 20 49 6e 74 65 72 return Inter
3080: 6c 6f 63 6b 65 64 2e 43 6f 6d 70 61 72 65 45 78 locked.CompareEx
3090: 63 68 61 6e 67 65 28 72 65 66 20 5f 63 61 6e 63 change(ref _canc
30a0: 65 6c 43 6f 75 6e 74 2c 20 30 2c 20 30 29 3b 0d elCount, 0, 0);.
30b0: 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f . }.... //
30c0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
30d0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
30e0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
30f0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3100: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3110: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d /////////////...
3120: 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 . /// <summar
3130: 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 69 73 y>.. /// This
3140: 20 6d 65 74 68 6f 64 20 64 65 74 65 72 6d 69 6e method determin
3150: 65 73 20 77 68 65 74 68 65 72 20 6f 72 20 6e 6f es whether or no
3160: 74 20 61 20 3c 73 65 65 20 63 72 65 66 3d 22 53 t a <see cref="S
3170: 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 22 20 QLiteException"
3180: 2f 3e 0d 0a 20 20 20 20 2f 2f 2f 20 77 69 74 68 />.. /// with
3190: 20 61 20 72 65 74 75 72 6e 20 63 6f 64 65 20 6f a return code o
31a0: 66 20 3c 73 65 65 20 63 72 65 66 3d 22 53 51 4c f <see cref="SQL
31b0: 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 49 6e 74 iteErrorCode.Int
31c0: 65 72 72 75 70 74 22 20 2f 3e 20 73 68 6f 75 6c errupt" /> shoul
31d0: 64 0d 0a 20 20 20 20 2f 2f 2f 20 62 65 20 74 68 d.. /// be th
31e0: 72 6f 77 6e 20 61 66 74 65 72 20 6d 61 6b 69 6e rown after makin
31f0: 67 20 61 20 63 61 6c 6c 20 69 6e 74 6f 20 74 68 g a call into th
3200: 65 20 53 51 4c 69 74 65 20 63 6f 72 65 20 6c 69 e SQLite core li
3210: 62 72 61 72 79 2e 0d 0a 20 20 20 20 2f 2f 2f 20 brary... ///
3220: 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 </summary>..
3230: 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 0d 0a 20 /// <returns>..
3240: 20 20 20 2f 2f 2f 20 4e 6f 6e 2d 7a 65 72 6f 20 /// Non-zero
3250: 69 66 20 61 20 3c 73 65 65 20 63 72 65 66 3d 22 if a <see cref="
3260: 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 22 SQLiteException"
3270: 20 2f 3e 20 74 6f 20 62 65 20 74 68 72 6f 77 6e /> to be thrown
3280: 2e 20 20 54 68 69 73 20 6d 65 74 68 6f 64 0d 0a . This method..
3290: 20 20 20 20 2f 2f 2f 20 77 69 6c 6c 20 6f 6e 6c /// will onl
32a0: 79 20 72 65 74 75 72 6e 20 6e 6f 6e 2d 7a 65 72 y return non-zer
32b0: 6f 20 69 66 20 74 68 65 20 3c 73 65 65 20 63 72 o if the <see cr
32c0: 65 66 3d 22 43 61 6e 63 65 6c 22 20 2f 3e 20 6d ef="Cancel" /> m
32d0: 65 74 68 6f 64 20 77 61 73 20 63 61 6c 6c 65 64 ethod was called
32e0: 0d 0a 20 20 20 20 2f 2f 2f 20 6f 6e 65 20 6f 72 .. /// one or
32f0: 20 6d 6f 72 65 20 74 69 6d 65 73 20 64 75 72 69 more times duri
3300: 6e 67 20 61 20 63 61 6c 6c 20 69 6e 74 6f 20 74 ng a call into t
3310: 68 65 20 53 51 4c 69 74 65 20 63 6f 72 65 20 6c he SQLite core l
3320: 69 62 72 61 72 79 20 28 65 2e 67 2e 20 77 68 65 ibrary (e.g. whe
3330: 6e 0d 0a 20 20 20 20 2f 2f 2f 20 74 68 65 20 73 n.. /// the s
3340: 71 6c 69 74 65 33 5f 70 72 65 70 61 72 65 2a 28 qlite3_prepare*(
3350: 29 20 6f 72 20 73 71 6c 69 74 65 33 5f 73 74 65 ) or sqlite3_ste
3360: 70 28 29 20 41 50 49 73 20 61 72 65 20 75 73 65 p() APIs are use
3370: 64 29 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 72 d)... /// </r
3380: 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 70 72 69 eturns>.. pri
3390: 76 61 74 65 20 62 6f 6f 6c 20 53 68 6f 75 6c 64 vate bool Should
33a0: 54 68 72 6f 77 46 6f 72 43 61 6e 63 65 6c 28 29 ThrowForCancel()
33b0: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
33c0: 20 72 65 74 75 72 6e 20 47 65 74 43 61 6e 63 65 return GetCance
33d0: 6c 43 6f 75 6e 74 28 29 20 3e 20 30 3b 0d 0a 20 lCount() > 0;..
33e0: 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 2f }.... ////
33f0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3400: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3410: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3420: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3430: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3440: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 ///////////....
3450: 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
3460: 0d 0a 20 20 20 20 2f 2f 2f 20 52 65 73 65 74 73 .. /// Resets
3470: 20 74 68 65 20 76 61 6c 75 65 20 6f 66 20 74 68 the value of th
3480: 65 20 3c 73 65 65 20 63 72 65 66 3d 22 5f 63 61 e <see cref="_ca
3490: 6e 63 65 6c 43 6f 75 6e 74 22 20 2f 3e 20 66 69 ncelCount" /> fi
34a0: 65 6c 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f eld... /// </
34b0: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 70 72 summary>.. pr
34c0: 69 76 61 74 65 20 69 6e 74 20 52 65 73 65 74 43 ivate int ResetC
34d0: 61 6e 63 65 6c 43 6f 75 6e 74 28 29 0d 0a 20 20 ancelCount()..
34e0: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 72 65 74 {.. ret
34f0: 75 72 6e 20 49 6e 74 65 72 6c 6f 63 6b 65 64 2e urn Interlocked.
3500: 43 6f 6d 70 61 72 65 45 78 63 68 61 6e 67 65 28 CompareExchange(
3510: 72 65 66 20 5f 63 61 6e 63 65 6c 43 6f 75 6e 74 ref _cancelCount
3520: 2c 20 30 2c 20 5f 63 61 6e 63 65 6c 43 6f 75 6e , 0, _cancelCoun
3530: 74 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 t);.. }....
3540: 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f //////////////
3550: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3560: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3570: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3580: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3590: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
35a0: 2f 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 /.... /// <su
35b0: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
35c0: 41 74 74 65 6d 70 74 73 20 74 6f 20 69 6e 74 65 Attempts to inte
35d0: 72 72 75 70 74 20 74 68 65 20 71 75 65 72 79 20 rrupt the query
35e0: 63 75 72 72 65 6e 74 6c 79 20 65 78 65 63 75 74 currently execut
35f0: 69 6e 67 20 6f 6e 20 74 68 65 20 61 73 73 6f 63 ing on the assoc
3600: 69 61 74 65 64 0d 0a 20 20 20 20 2f 2f 2f 20 6e iated.. /// n
3610: 61 74 69 76 65 20 64 61 74 61 62 61 73 65 20 63 ative database c
3620: 6f 6e 6e 65 63 74 69 6f 6e 2e 0d 0a 20 20 20 20 onnection...
3630: 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a /// </summary>..
3640: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
3650: 72 72 69 64 65 20 76 6f 69 64 20 43 61 6e 63 65 rride void Cance
3660: 6c 28 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 l().. {..
3670: 20 20 74 72 79 0d 0a 20 20 20 20 20 20 7b 0d 0a try.. {..
3680: 20 20 20 20 20 20 20 20 2f 2f 20 64 6f 20 6e 6f // do no
3690: 74 68 69 6e 67 2e 0d 0a 20 20 20 20 20 20 7d 0d thing... }.
36a0: 0a 20 20 20 20 20 20 66 69 6e 61 6c 6c 79 20 2f . finally /
36b0: 2a 20 4e 4f 54 45 3a 20 54 68 72 65 61 64 2e 41 * NOTE: Thread.A
36c0: 62 6f 72 74 28 29 20 70 72 6f 74 65 63 74 69 6f bort() protectio
36d0: 6e 2e 20 2a 2f 0d 0a 20 20 20 20 20 20 7b 0d 0a n. */.. {..
36e0: 20 20 20 20 20 20 20 20 49 6e 74 65 72 6c 6f 63 Interloc
36f0: 6b 65 64 2e 49 6e 63 72 65 6d 65 6e 74 28 72 65 ked.Increment(re
3700: 66 20 5f 63 61 6e 63 65 6c 43 6f 75 6e 74 29 3b f _cancelCount);
3710: 0d 0a 20 20 20 20 20 20 20 20 55 6e 73 61 66 65 .. Unsafe
3720: 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
3730: 6c 69 74 65 33 5f 69 6e 74 65 72 72 75 70 74 28 lite3_interrupt(
3740: 5f 73 71 6c 29 3b 0d 0a 20 20 20 20 20 20 7d 0d _sql);.. }.
3750: 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f . }.... //
3760: 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 / <summary>..
3770: 20 2f 2f 2f 20 54 68 69 73 20 66 75 6e 63 74 69 /// This functi
3780: 6f 6e 20 62 69 6e 64 73 20 61 20 75 73 65 72 2d on binds a user-
3790: 64 65 66 69 6e 65 64 20 66 75 6e 63 74 69 6f 6e defined function
37a0: 20 74 6f 20 74 68 65 20 63 6f 6e 6e 65 63 74 69 to the connecti
37b0: 6f 6e 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 on... /// </s
37c0: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
37d0: 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 66 75 <param name="fu
37e0: 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 65 22 nctionAttribute"
37f0: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 3c >.. /// The <
3800: 73 65 65 20 63 72 65 66 3d 22 53 51 4c 69 74 65 see cref="SQLite
3810: 46 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 FunctionAttribut
3820: 65 22 2f 3e 20 6f 62 6a 65 63 74 20 69 6e 73 74 e"/> object inst
3830: 61 6e 63 65 20 63 6f 6e 74 61 69 6e 69 6e 67 0d ance containing.
3840: 0a 20 20 20 20 2f 2f 2f 20 74 68 65 20 6d 65 74 . /// the met
3850: 61 64 61 74 61 20 66 6f 72 20 74 68 65 20 66 75 adata for the fu
3860: 6e 63 74 69 6f 6e 20 74 6f 20 62 65 20 62 6f 75 nction to be bou
3870: 6e 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 nd... /// </p
3880: 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c aram>.. /// <
3890: 70 61 72 61 6d 20 6e 61 6d 65 3d 22 66 75 6e 63 param name="func
38a0: 74 69 6f 6e 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 tion">.. ///
38b0: 54 68 65 20 3c 73 65 65 20 63 72 65 66 3d 22 53 The <see cref="S
38c0: 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 22 2f 3e QLiteFunction"/>
38d0: 20 6f 62 6a 65 63 74 20 69 6e 73 74 61 6e 63 65 object instance
38e0: 20 74 68 61 74 20 69 6d 70 6c 65 6d 65 6e 74 73 that implements
38f0: 20 74 68 65 0d 0a 20 20 20 20 2f 2f 2f 20 66 75 the.. /// fu
3900: 6e 63 74 69 6f 6e 20 74 6f 20 62 65 20 62 6f 75 nction to be bou
3910: 6e 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 nd... /// </p
3920: 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c aram>.. /// <
3930: 70 61 72 61 6d 20 6e 61 6d 65 3d 22 66 6c 61 67 param name="flag
3940: 73 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 s">.. /// The
3950: 20 66 6c 61 67 73 20 61 73 73 6f 63 69 61 74 65 flags associate
3960: 64 20 77 69 74 68 20 74 68 65 20 70 61 72 65 6e d with the paren
3970: 74 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 6f 62 6a t connection obj
3980: 65 63 74 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ect... /// </
3990: 70 61 72 61 6d 3e 0d 0a 20 20 20 20 69 6e 74 65 param>.. inte
39a0: 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f rnal override vo
39b0: 69 64 20 42 69 6e 64 46 75 6e 63 74 69 6f 6e 28 id BindFunction(
39c0: 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 .. SQLite
39d0: 46 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 FunctionAttribut
39e0: 65 20 66 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 e functionAttrib
39f0: 75 74 65 2c 0d 0a 20 20 20 20 20 20 20 20 53 51 ute,.. SQ
3a00: 4c 69 74 65 46 75 6e 63 74 69 6f 6e 20 66 75 6e LiteFunction fun
3a10: 63 74 69 6f 6e 2c 0d 0a 20 20 20 20 20 20 20 20 ction,..
3a20: 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e SQLiteConnection
3a30: 46 6c 61 67 73 20 66 6c 61 67 73 0d 0a 20 20 20 Flags flags..
3a40: 20 20 20 20 20 29 0d 0a 20 20 20 20 7b 0d 0a 20 ).. {..
3a50: 20 20 20 20 20 20 20 69 66 20 28 66 75 6e 63 74 if (funct
3a60: 69 6f 6e 41 74 74 72 69 62 75 74 65 20 3d 3d 20 ionAttribute ==
3a70: 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 null)..
3a80: 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 throw new Arg
3a90: 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 umentNullExcepti
3aa0: 6f 6e 28 22 66 75 6e 63 74 69 6f 6e 41 74 74 72 on("functionAttr
3ab0: 69 62 75 74 65 22 29 3b 0d 0a 0d 0a 20 20 20 20 ibute");....
3ac0: 20 20 20 20 69 66 20 28 66 75 6e 63 74 69 6f 6e if (function
3ad0: 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 == null)..
3ae0: 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 throw new
3af0: 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 ArgumentNullExc
3b00: 65 70 74 69 6f 6e 28 22 66 75 6e 63 74 69 6f 6e eption("function
3b10: 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 ");.... S
3b20: 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 2e 42 69 QLiteFunction.Bi
3b30: 6e 64 46 75 6e 63 74 69 6f 6e 28 74 68 69 73 2c ndFunction(this,
3b40: 20 66 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 functionAttribu
3b50: 74 65 2c 20 66 75 6e 63 74 69 6f 6e 2c 20 66 6c te, function, fl
3b60: 61 67 73 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 ags);....
3b70: 20 69 66 20 28 5f 66 75 6e 63 74 69 6f 6e 73 20 if (_functions
3b80: 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 == null)..
3b90: 20 20 20 20 20 20 5f 66 75 6e 63 74 69 6f 6e 73 _functions
3ba0: 20 3d 20 6e 65 77 20 44 69 63 74 69 6f 6e 61 72 = new Dictionar
3bb0: 79 3c 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e y<SQLiteFunction
3bc0: 41 74 74 72 69 62 75 74 65 2c 20 53 51 4c 69 74 Attribute, SQLit
3bd0: 65 46 75 6e 63 74 69 6f 6e 3e 28 29 3b 0d 0a 0d eFunction>();...
3be0: 0a 20 20 20 20 20 20 20 20 5f 66 75 6e 63 74 69 . _functi
3bf0: 6f 6e 73 5b 66 75 6e 63 74 69 6f 6e 41 74 74 72 ons[functionAttr
3c00: 69 62 75 74 65 5d 20 3d 20 66 75 6e 63 74 69 6f ibute] = functio
3c10: 6e 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 n;.. }....
3c20: 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
3c30: 20 20 20 20 2f 2f 2f 20 54 68 69 73 20 66 75 6e /// This fun
3c40: 63 74 69 6f 6e 20 62 69 6e 64 73 20 61 20 75 73 ction binds a us
3c50: 65 72 2d 64 65 66 69 6e 65 64 20 66 75 6e 63 74 er-defined funct
3c60: 69 6f 6e 20 74 6f 20 74 68 65 20 63 6f 6e 6e 65 ion to the conne
3c70: 63 74 69 6f 6e 2e 0d 0a 20 20 20 20 2f 2f 2f 20 ction... ///
3c80: 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 </summary>..
3c90: 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d /// <param name=
3ca0: 22 66 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 "functionAttribu
3cb0: 74 65 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 te">.. /// Th
3cc0: 65 20 3c 73 65 65 20 63 72 65 66 3d 22 53 51 4c e <see cref="SQL
3cd0: 69 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 72 69 iteFunctionAttri
3ce0: 62 75 74 65 22 2f 3e 20 6f 62 6a 65 63 74 20 69 bute"/> object i
3cf0: 6e 73 74 61 6e 63 65 20 63 6f 6e 74 61 69 6e 69 nstance containi
3d00: 6e 67 0d 0a 20 20 20 20 2f 2f 2f 20 74 68 65 20 ng.. /// the
3d10: 6d 65 74 61 64 61 74 61 20 66 6f 72 20 74 68 65 metadata for the
3d20: 20 66 75 6e 63 74 69 6f 6e 20 74 6f 20 62 65 20 function to be
3d30: 75 6e 62 6f 75 6e 64 2e 0d 0a 20 20 20 20 2f 2f unbound... //
3d40: 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 / </param>..
3d50: 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d /// <param name=
3d60: 22 66 6c 61 67 73 22 3e 0d 0a 20 20 20 20 2f 2f "flags">.. //
3d70: 2f 20 54 68 65 20 66 6c 61 67 73 20 61 73 73 6f / The flags asso
3d80: 63 69 61 74 65 64 20 77 69 74 68 20 74 68 65 20 ciated with the
3d90: 70 61 72 65 6e 74 20 63 6f 6e 6e 65 63 74 69 6f parent connectio
3da0: 6e 20 6f 62 6a 65 63 74 2e 0d 0a 20 20 20 20 2f n object... /
3db0: 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 // </param>..
3dc0: 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 4e 6f /// <returns>No
3dd0: 6e 2d 7a 65 72 6f 20 69 66 20 74 68 65 20 66 75 n-zero if the fu
3de0: 6e 63 74 69 6f 6e 20 77 61 73 20 75 6e 62 6f 75 nction was unbou
3df0: 6e 64 20 61 6e 64 20 72 65 6d 6f 76 65 64 2e 3c nd and removed.<
3e00: 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 69 /returns>.. i
3e10: 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
3e20: 20 62 6f 6f 6c 20 55 6e 62 69 6e 64 46 75 6e 63 bool UnbindFunc
3e30: 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 20 53 tion(.. S
3e40: 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 QLiteFunctionAtt
3e50: 72 69 62 75 74 65 20 66 75 6e 63 74 69 6f 6e 41 ribute functionA
3e60: 74 74 72 69 62 75 74 65 2c 0d 0a 20 20 20 20 20 ttribute,..
3e70: 20 20 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 SQLiteConnect
3e80: 69 6f 6e 46 6c 61 67 73 20 66 6c 61 67 73 0d 0a ionFlags flags..
3e90: 20 20 20 20 20 20 20 20 29 0d 0a 20 20 20 20 7b ).. {
3ea0: 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 66 75 .. if (fu
3eb0: 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 65 20 nctionAttribute
3ec0: 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 == null)..
3ed0: 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 throw new
3ee0: 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 ArgumentNullExce
3ef0: 70 74 69 6f 6e 28 22 66 75 6e 63 74 69 6f 6e 41 ption("functionA
3f00: 74 74 72 69 62 75 74 65 22 29 3b 0d 0a 0d 0a 20 ttribute");....
3f10: 20 20 20 20 20 20 20 69 66 20 28 5f 66 75 6e 63 if (_func
3f20: 74 69 6f 6e 73 20 3d 3d 20 6e 75 6c 6c 29 0d 0a tions == null)..
3f30: 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 retu
3f40: 72 6e 20 66 61 6c 73 65 3b 0d 0a 0d 0a 20 20 20 rn false;....
3f50: 20 20 20 20 20 53 51 4c 69 74 65 46 75 6e 63 74 SQLiteFunct
3f60: 69 6f 6e 20 66 75 6e 63 74 69 6f 6e 3b 0d 0a 0d ion function;...
3f70: 0a 20 20 20 20 20 20 20 20 69 66 20 28 5f 66 75 . if (_fu
3f80: 6e 63 74 69 6f 6e 73 2e 54 72 79 47 65 74 56 61 nctions.TryGetVa
3f90: 6c 75 65 28 66 75 6e 63 74 69 6f 6e 41 74 74 72 lue(functionAttr
3fa0: 69 62 75 74 65 2c 20 6f 75 74 20 66 75 6e 63 74 ibute, out funct
3fb0: 69 6f 6e 29 29 0d 0a 20 20 20 20 20 20 20 20 7b ion)).. {
3fc0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 .. if
3fd0: 20 28 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e (SQLiteFunction
3fe0: 2e 55 6e 62 69 6e 64 46 75 6e 63 74 69 6f 6e 28 .UnbindFunction(
3ff0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
4000: 20 20 20 20 20 20 74 68 69 73 2c 20 66 75 6e 63 this, func
4010: 74 69 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 66 tionAttribute, f
4020: 75 6e 63 74 69 6f 6e 2c 20 66 6c 61 67 73 29 20 unction, flags)
4030: 26 26 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 &&..
4040: 20 20 20 20 5f 66 75 6e 63 74 69 6f 6e 73 2e 52 _functions.R
4050: 65 6d 6f 76 65 28 66 75 6e 63 74 69 6f 6e 41 74 emove(functionAt
4060: 74 72 69 62 75 74 65 29 29 0d 0a 20 20 20 20 20 tribute))..
4070: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
4080: 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e return
4090: 20 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 true;..
40a0: 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d }.. }
40b0: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 .... retu
40c0: 72 6e 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 7d rn false;.. }
40d0: 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
40e0: 20 6f 76 65 72 72 69 64 65 20 73 74 72 69 6e 67 override string
40f0: 20 56 65 72 73 69 6f 6e 0d 0a 20 20 20 20 7b 0d Version.. {.
4100: 0a 20 20 20 20 20 20 67 65 74 0d 0a 20 20 20 20 . get..
4110: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 72 65 74 {.. ret
4120: 75 72 6e 20 53 51 4c 69 74 65 56 65 72 73 69 6f urn SQLiteVersio
4130: 6e 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 n;.. }..
4140: 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e }.... intern
4150: 61 6c 20 6f 76 65 72 72 69 64 65 20 69 6e 74 20 al override int
4160: 56 65 72 73 69 6f 6e 4e 75 6d 62 65 72 0d 0a 20 VersionNumber..
4170: 20 20 20 7b 0d 0a 20 20 20 20 20 20 67 65 74 0d {.. get.
4180: 0a 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 . {..
4190: 20 20 72 65 74 75 72 6e 20 53 51 4c 69 74 65 56 return SQLiteV
41a0: 65 72 73 69 6f 6e 4e 75 6d 62 65 72 3b 0d 0a 20 ersionNumber;..
41b0: 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d }.. }...
41c0: 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 73 74 . internal st
41d0: 61 74 69 63 20 73 74 72 69 6e 67 20 44 65 66 69 atic string Defi
41e0: 6e 65 43 6f 6e 73 74 61 6e 74 73 0d 0a 20 20 20 neConstants..
41f0: 20 7b 0d 0a 20 20 20 20 20 20 20 20 67 65 74 0d {.. get.
4200: 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 . {..
4210: 20 20 20 20 20 20 20 20 53 74 72 69 6e 67 42 75 StringBu
4220: 69 6c 64 65 72 20 72 65 73 75 6c 74 20 3d 20 6e ilder result = n
4230: 65 77 20 53 74 72 69 6e 67 42 75 69 6c 64 65 72 ew StringBuilder
4240: 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ();..
4250: 20 49 4c 69 73 74 3c 73 74 72 69 6e 67 3e 20 6c IList<string> l
4260: 69 73 74 20 3d 20 53 51 4c 69 74 65 44 65 66 69 ist = SQLiteDefi
4270: 6e 65 43 6f 6e 73 74 61 6e 74 73 2e 4f 70 74 69 neConstants.Opti
4280: 6f 6e 4c 69 73 74 3b 0d 0a 0d 0a 20 20 20 20 20 onList;....
4290: 20 20 20 20 20 20 20 69 66 20 28 6c 69 73 74 20 if (list
42a0: 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 != null)..
42b0: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
42c0: 20 20 20 20 20 20 20 20 20 66 6f 72 65 61 63 68 foreach
42d0: 20 28 73 74 72 69 6e 67 20 65 6c 65 6d 65 6e 74 (string element
42e0: 20 69 6e 20 6c 69 73 74 29 0d 0a 20 20 20 20 20 in list)..
42f0: 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 {..
4300: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4310: 20 20 69 66 20 28 65 6c 65 6d 65 6e 74 20 3d 3d if (element ==
4320: 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 null)..
4330: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4340: 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 continue;....
4350: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4360: 20 69 66 20 28 72 65 73 75 6c 74 2e 4c 65 6e 67 if (result.Leng
4370: 74 68 20 3e 20 30 29 0d 0a 20 20 20 20 20 20 20 th > 0)..
4380: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4390: 20 72 65 73 75 6c 74 2e 41 70 70 65 6e 64 28 27 result.Append('
43a0: 20 27 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ');....
43b0: 20 20 20 20 20 20 20 20 20 20 20 20 72 65 73 75 resu
43c0: 6c 74 2e 41 70 70 65 6e 64 28 65 6c 65 6d 65 6e lt.Append(elemen
43d0: 74 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 t);..
43e0: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
43f0: 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 }....
4400: 20 20 20 20 20 72 65 74 75 72 6e 20 72 65 73 75 return resu
4410: 6c 74 2e 54 6f 53 74 72 69 6e 67 28 29 3b 0d 0a lt.ToString();..
4420: 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d }.. }
4430: 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
4440: 20 73 74 61 74 69 63 20 73 74 72 69 6e 67 20 53 static string S
4450: 51 4c 69 74 65 56 65 72 73 69 6f 6e 0d 0a 20 20 QLiteVersion..
4460: 20 20 7b 0d 0a 20 20 20 20 20 20 67 65 74 0d 0a {.. get..
4470: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
4480: 20 72 65 74 75 72 6e 20 55 54 46 38 54 6f 53 74 return UTF8ToSt
4490: 72 69 6e 67 28 55 6e 73 61 66 65 4e 61 74 69 76 ring(UnsafeNativ
44a0: 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
44b0: 5f 6c 69 62 76 65 72 73 69 6f 6e 28 29 2c 20 2d _libversion(), -
44c0: 31 29 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 1);.. }..
44d0: 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 }.... inter
44e0: 6e 61 6c 20 73 74 61 74 69 63 20 69 6e 74 20 53 nal static int S
44f0: 51 4c 69 74 65 56 65 72 73 69 6f 6e 4e 75 6d 62 QLiteVersionNumb
4500: 65 72 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 er.. {..
4510: 20 67 65 74 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 get.. {..
4520: 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 6e return Un
4530: 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
4540: 73 2e 73 71 6c 69 74 65 33 5f 6c 69 62 76 65 72 s.sqlite3_libver
4550: 73 69 6f 6e 5f 6e 75 6d 62 65 72 28 29 3b 0d 0a sion_number();..
4560: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a }.. }..
4570: 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 73 .. internal s
4580: 74 61 74 69 63 20 73 74 72 69 6e 67 20 53 51 4c tatic string SQL
4590: 69 74 65 53 6f 75 72 63 65 49 64 0d 0a 20 20 20 iteSourceId..
45a0: 20 7b 0d 0a 20 20 20 20 20 20 67 65 74 0d 0a 20 {.. get..
45b0: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
45c0: 72 65 74 75 72 6e 20 55 54 46 38 54 6f 53 74 72 return UTF8ToStr
45d0: 69 6e 67 28 55 6e 73 61 66 65 4e 61 74 69 76 65 ing(UnsafeNative
45e0: 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
45f0: 73 6f 75 72 63 65 69 64 28 29 2c 20 2d 31 29 3b sourceid(), -1);
4600: 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d .. }.. }
4610: 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
4620: 20 73 74 61 74 69 63 20 73 74 72 69 6e 67 20 53 static string S
4630: 51 4c 69 74 65 43 6f 6d 70 69 6c 65 4f 70 74 69 QLiteCompileOpti
4640: 6f 6e 73 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 ons.. {..
4650: 20 20 20 20 67 65 74 0d 0a 20 20 20 20 20 20 20 get..
4660: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
4670: 53 74 72 69 6e 67 42 75 69 6c 64 65 72 20 72 65 StringBuilder re
4680: 73 75 6c 74 20 3d 20 6e 65 77 20 53 74 72 69 6e sult = new Strin
4690: 67 42 75 69 6c 64 65 72 28 29 3b 0d 0a 20 20 20 gBuilder();..
46a0: 20 20 20 20 20 20 20 20 20 69 6e 74 20 69 6e 64 int ind
46b0: 65 78 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 20 ex = 0;..
46c0: 20 20 20 20 20 49 6e 74 50 74 72 20 7a 56 61 6c IntPtr zVal
46d0: 75 65 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 ue = UnsafeNativ
46e0: 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
46f0: 5f 63 6f 6d 70 69 6c 65 6f 70 74 69 6f 6e 5f 67 _compileoption_g
4700: 65 74 28 69 6e 64 65 78 2b 2b 29 3b 0d 0a 0d 0a et(index++);....
4710: 20 20 20 20 20 20 20 20 20 20 20 20 77 68 69 6c whil
4720: 65 20 28 7a 56 61 6c 75 65 20 21 3d 20 49 6e 74 e (zValue != Int
4730: 50 74 72 2e 5a 65 72 6f 29 0d 0a 20 20 20 20 20 Ptr.Zero)..
4740: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
4750: 20 20 20 20 20 20 20 20 20 20 69 66 20 28 72 65 if (re
4760: 73 75 6c 74 2e 4c 65 6e 67 74 68 20 3e 20 30 29 sult.Length > 0)
4770: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
4780: 20 20 20 20 20 20 72 65 73 75 6c 74 2e 41 70 70 result.App
4790: 65 6e 64 28 27 20 27 29 3b 0d 0a 0d 0a 20 20 20 end(' ');....
47a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 73 res
47b0: 75 6c 74 2e 41 70 70 65 6e 64 28 55 54 46 38 54 ult.Append(UTF8T
47c0: 6f 53 74 72 69 6e 67 28 7a 56 61 6c 75 65 2c 20 oString(zValue,
47d0: 2d 31 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 -1));..
47e0: 20 20 20 20 20 20 20 7a 56 61 6c 75 65 20 3d 20 zValue =
47f0: 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
4800: 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6d 70 ods.sqlite3_comp
4810: 69 6c 65 6f 70 74 69 6f 6e 5f 67 65 74 28 69 6e ileoption_get(in
4820: 64 65 78 2b 2b 29 3b 0d 0a 20 20 20 20 20 20 20 dex++);..
4830: 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 }....
4840: 20 20 20 20 20 20 72 65 74 75 72 6e 20 72 65 73 return res
4850: 75 6c 74 2e 54 6f 53 74 72 69 6e 67 28 29 3b 0d ult.ToString();.
4860: 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 . }..
4870: 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 }.... interna
4880: 6c 20 73 74 61 74 69 63 20 73 74 72 69 6e 67 20 l static string
4890: 49 6e 74 65 72 6f 70 56 65 72 73 69 6f 6e 0d 0a InteropVersion..
48a0: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 67 {.. g
48b0: 65 74 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 23 et.. {..#
48c0: 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 if !SQLITE_STAND
48d0: 41 52 44 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ARD..
48e0: 20 72 65 74 75 72 6e 20 55 54 46 38 54 6f 53 74 return UTF8ToSt
48f0: 72 69 6e 67 28 55 6e 73 61 66 65 4e 61 74 69 76 ring(UnsafeNativ
4900: 65 4d 65 74 68 6f 64 73 2e 69 6e 74 65 72 6f 70 eMethods.interop
4910: 5f 6c 69 62 76 65 72 73 69 6f 6e 28 29 2c 20 2d _libversion(), -
4920: 31 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 1);..#else..
4930: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 6e return n
4940: 75 6c 6c 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 ull;..#endif..
4950: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a }.. }..
4960: 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 73 .. internal s
4970: 74 61 74 69 63 20 73 74 72 69 6e 67 20 49 6e 74 tatic string Int
4980: 65 72 6f 70 53 6f 75 72 63 65 49 64 0d 0a 20 20 eropSourceId..
4990: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 67 65 74 {.. get
49a0: 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 23 69 66 .. {..#if
49b0: 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 !SQLITE_STANDAR
49c0: 44 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 D.. r
49d0: 65 74 75 72 6e 20 55 54 46 38 54 6f 53 74 72 69 eturn UTF8ToStri
49e0: 6e 67 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d ng(UnsafeNativeM
49f0: 65 74 68 6f 64 73 2e 69 6e 74 65 72 6f 70 5f 73 ethods.interop_s
4a00: 6f 75 72 63 65 69 64 28 29 2c 20 2d 31 29 3b 0d ourceid(), -1);.
4a10: 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 .#else..
4a20: 20 20 20 20 72 65 74 75 72 6e 20 6e 75 6c 6c 3b return null;
4a30: 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 ..#endif..
4a40: 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 }.. }....
4a50: 20 20 69 6e 74 65 72 6e 61 6c 20 73 74 61 74 69 internal stati
4a60: 63 20 73 74 72 69 6e 67 20 49 6e 74 65 72 6f 70 c string Interop
4a70: 43 6f 6d 70 69 6c 65 4f 70 74 69 6f 6e 73 0d 0a CompileOptions..
4a80: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 67 {.. g
4a90: 65 74 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 23 et.. {..#
4aa0: 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 if !SQLITE_STAND
4ab0: 41 52 44 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ARD..
4ac0: 20 53 74 72 69 6e 67 42 75 69 6c 64 65 72 20 72 StringBuilder r
4ad0: 65 73 75 6c 74 20 3d 20 6e 65 77 20 53 74 72 69 esult = new Stri
4ae0: 6e 67 42 75 69 6c 64 65 72 28 29 3b 0d 0a 20 20 ngBuilder();..
4af0: 20 20 20 20 20 20 20 20 20 20 69 6e 74 20 69 6e int in
4b00: 64 65 78 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 dex = 0;..
4b10: 20 20 20 20 20 20 49 6e 74 50 74 72 20 7a 56 61 IntPtr zVa
4b20: 6c 75 65 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 lue = UnsafeNati
4b30: 76 65 4d 65 74 68 6f 64 73 2e 69 6e 74 65 72 6f veMethods.intero
4b40: 70 5f 63 6f 6d 70 69 6c 65 6f 70 74 69 6f 6e 5f p_compileoption_
4b50: 67 65 74 28 69 6e 64 65 78 2b 2b 29 3b 0d 0a 0d get(index++);...
4b60: 0a 20 20 20 20 20 20 20 20 20 20 20 20 77 68 69 . whi
4b70: 6c 65 20 28 7a 56 61 6c 75 65 20 21 3d 20 49 6e le (zValue != In
4b80: 74 50 74 72 2e 5a 65 72 6f 29 0d 0a 20 20 20 20 tPtr.Zero)..
4b90: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
4ba0: 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 72 if (r
4bb0: 65 73 75 6c 74 2e 4c 65 6e 67 74 68 20 3e 20 30 esult.Length > 0
4bc0: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )..
4bd0: 20 20 20 20 20 20 20 72 65 73 75 6c 74 2e 41 70 result.Ap
4be0: 70 65 6e 64 28 27 20 27 29 3b 0d 0a 0d 0a 20 20 pend(' ');....
4bf0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 re
4c00: 73 75 6c 74 2e 41 70 70 65 6e 64 28 55 54 46 38 sult.Append(UTF8
4c10: 54 6f 53 74 72 69 6e 67 28 7a 56 61 6c 75 65 2c ToString(zValue,
4c20: 20 2d 31 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 -1));..
4c30: 20 20 20 20 20 20 20 20 7a 56 61 6c 75 65 20 3d zValue =
4c40: 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
4c50: 68 6f 64 73 2e 69 6e 74 65 72 6f 70 5f 63 6f 6d hods.interop_com
4c60: 70 69 6c 65 6f 70 74 69 6f 6e 5f 67 65 74 28 69 pileoption_get(i
4c70: 6e 64 65 78 2b 2b 29 3b 0d 0a 20 20 20 20 20 20 ndex++);..
4c80: 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 }....
4c90: 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 72 65 return re
4ca0: 73 75 6c 74 2e 54 6f 53 74 72 69 6e 67 28 29 3b sult.ToString();
4cb0: 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 ..#else..
4cc0: 20 20 20 20 20 72 65 74 75 72 6e 20 6e 75 6c 6c return null
4cd0: 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 ;..#endif..
4ce0: 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 }.. }....
4cf0: 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 internal over
4d00: 72 69 64 65 20 62 6f 6f 6c 20 41 75 74 6f 43 6f ride bool AutoCo
4d10: 6d 6d 69 74 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 mmit.. {..
4d20: 20 20 20 67 65 74 0d 0a 20 20 20 20 20 20 7b 0d get.. {.
4d30: 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 . return
4d40: 49 73 41 75 74 6f 63 6f 6d 6d 69 74 28 5f 73 71 IsAutocommit(_sq
4d50: 6c 2c 20 5f 73 71 6c 29 3b 0d 0a 20 20 20 20 20 l, _sql);..
4d60: 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 }.. }....
4d70: 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 internal overri
4d80: 64 65 20 6c 6f 6e 67 20 4c 61 73 74 49 6e 73 65 de long LastInse
4d90: 72 74 52 6f 77 49 64 0d 0a 20 20 20 20 7b 0d 0a rtRowId.. {..
4da0: 20 20 20 20 20 20 67 65 74 0d 0a 20 20 20 20 20 get..
4db0: 20 7b 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 {..#if !PLATFOR
4dc0: 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f M_COMPACTFRAMEWO
4dd0: 52 4b 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 RK.. retu
4de0: 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d rn UnsafeNativeM
4df0: 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 6c ethods.sqlite3_l
4e00: 61 73 74 5f 69 6e 73 65 72 74 5f 72 6f 77 69 64 ast_insert_rowid
4e10: 28 5f 73 71 6c 29 3b 0d 0a 23 65 6c 69 66 20 21 (_sql);..#elif !
4e20: 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d SQLITE_STANDARD.
4e30: 0a 20 20 20 20 20 20 20 20 6c 6f 6e 67 20 72 6f . long ro
4e40: 77 49 64 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 wId = 0;..
4e50: 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 UnsafeNativeMe
4e60: 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 6c 61 thods.sqlite3_la
4e70: 73 74 5f 69 6e 73 65 72 74 5f 72 6f 77 69 64 5f st_insert_rowid_
4e80: 69 6e 74 65 72 6f 70 28 5f 73 71 6c 2c 20 72 65 interop(_sql, re
4e90: 66 20 72 6f 77 49 64 29 3b 0d 0a 20 20 20 20 20 f rowId);..
4ea0: 20 20 20 72 65 74 75 72 6e 20 72 6f 77 49 64 3b return rowId;
4eb0: 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 ..#else..
4ec0: 20 74 68 72 6f 77 20 6e 65 77 20 4e 6f 74 49 6d throw new NotIm
4ed0: 70 6c 65 6d 65 6e 74 65 64 45 78 63 65 70 74 69 plementedExcepti
4ee0: 6f 6e 28 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 on();..#endif..
4ef0: 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d }.. }...
4f00: 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
4f10: 65 72 72 69 64 65 20 69 6e 74 20 43 68 61 6e 67 erride int Chang
4f20: 65 73 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 es.. {..
4f30: 20 67 65 74 0d 0a 20 20 20 20 20 20 7b 0d 0a 23 get.. {..#
4f40: 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 if !SQLITE_STAND
4f50: 41 52 44 0d 0a 20 20 20 20 20 20 20 20 72 65 74 ARD.. ret
4f60: 75 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 urn UnsafeNative
4f70: 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
4f80: 63 68 61 6e 67 65 73 5f 69 6e 74 65 72 6f 70 28 changes_interop(
4f90: 5f 73 71 6c 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 _sql);..#else..
4fa0: 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 6e return Un
4fb0: 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
4fc0: 73 2e 73 71 6c 69 74 65 33 5f 63 68 61 6e 67 65 s.sqlite3_change
4fd0: 73 28 5f 73 71 6c 29 3b 0d 0a 23 65 6e 64 69 66 s(_sql);..#endif
4fe0: 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d .. }.. }
4ff0: 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
5000: 20 6f 76 65 72 72 69 64 65 20 6c 6f 6e 67 20 4d override long M
5010: 65 6d 6f 72 79 55 73 65 64 0d 0a 20 20 20 20 7b emoryUsed.. {
5020: 0d 0a 20 20 20 20 20 20 20 20 67 65 74 0d 0a 20 .. get..
5030: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
5040: 20 20 20 20 20 20 72 65 74 75 72 6e 20 53 74 61 return Sta
5050: 74 69 63 4d 65 6d 6f 72 79 55 73 65 64 3b 0d 0a ticMemoryUsed;..
5060: 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d }.. }
5070: 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
5080: 20 73 74 61 74 69 63 20 6c 6f 6e 67 20 53 74 61 static long Sta
5090: 74 69 63 4d 65 6d 6f 72 79 55 73 65 64 0d 0a 20 ticMemoryUsed..
50a0: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 67 65 {.. ge
50b0: 74 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 23 69 t.. {..#i
50c0: 66 20 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 f !PLATFORM_COMP
50d0: 41 43 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 ACTFRAMEWORK..
50e0: 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e return
50f0: 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
5100: 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 6d 65 6d hods.sqlite3_mem
5110: 6f 72 79 5f 75 73 65 64 28 29 3b 0d 0a 23 65 6c ory_used();..#el
5120: 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 if !SQLITE_STAND
5130: 41 52 44 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ARD..
5140: 20 6c 6f 6e 67 20 62 79 74 65 73 20 3d 20 30 3b long bytes = 0;
5150: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 55 6e .. Un
5160: 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
5170: 73 2e 73 71 6c 69 74 65 33 5f 6d 65 6d 6f 72 79 s.sqlite3_memory
5180: 5f 75 73 65 64 5f 69 6e 74 65 72 6f 70 28 72 65 _used_interop(re
5190: 66 20 62 79 74 65 73 29 3b 0d 0a 20 20 20 20 20 f bytes);..
51a0: 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 62 79 return by
51b0: 74 65 73 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 tes;..#else..
51c0: 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e throw n
51d0: 65 77 20 4e 6f 74 49 6d 70 6c 65 6d 65 6e 74 65 ew NotImplemente
51e0: 64 45 78 63 65 70 74 69 6f 6e 28 29 3b 0d 0a 23 dException();..#
51f0: 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 7d endif.. }
5200: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
5210: 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
5220: 20 6c 6f 6e 67 20 4d 65 6d 6f 72 79 48 69 67 68 long MemoryHigh
5230: 77 61 74 65 72 0d 0a 20 20 20 20 7b 0d 0a 20 20 water.. {..
5240: 20 20 20 20 20 20 67 65 74 0d 0a 20 20 20 20 20 get..
5250: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
5260: 20 20 72 65 74 75 72 6e 20 53 74 61 74 69 63 4d return StaticM
5270: 65 6d 6f 72 79 48 69 67 68 77 61 74 65 72 3b 0d emoryHighwater;.
5280: 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 . }..
5290: 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 }.... interna
52a0: 6c 20 73 74 61 74 69 63 20 6c 6f 6e 67 20 53 74 l static long St
52b0: 61 74 69 63 4d 65 6d 6f 72 79 48 69 67 68 77 61 aticMemoryHighwa
52c0: 74 65 72 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 ter.. {..
52d0: 20 20 20 20 67 65 74 0d 0a 20 20 20 20 20 20 20 get..
52e0: 20 7b 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 {..#if !PLATFOR
52f0: 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f M_COMPACTFRAMEWO
5300: 52 4b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 RK..
5310: 72 65 74 75 72 6e 20 55 6e 73 61 66 65 4e 61 74 return UnsafeNat
5320: 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 iveMethods.sqlit
5330: 65 33 5f 6d 65 6d 6f 72 79 5f 68 69 67 68 77 61 e3_memory_highwa
5340: 74 65 72 28 30 29 3b 0d 0a 23 65 6c 69 66 20 21 ter(0);..#elif !
5350: 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d SQLITE_STANDARD.
5360: 0a 20 20 20 20 20 20 20 20 20 20 20 20 6c 6f 6e . lon
5370: 67 20 62 79 74 65 73 20 3d 20 30 3b 0d 0a 20 20 g bytes = 0;..
5380: 20 20 20 20 20 20 20 20 20 20 55 6e 73 61 66 65 Unsafe
5390: 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
53a0: 6c 69 74 65 33 5f 6d 65 6d 6f 72 79 5f 68 69 67 lite3_memory_hig
53b0: 68 77 61 74 65 72 5f 69 6e 74 65 72 6f 70 28 30 hwater_interop(0
53c0: 2c 20 72 65 66 20 62 79 74 65 73 29 3b 0d 0a 20 , ref bytes);..
53d0: 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 retur
53e0: 6e 20 62 79 74 65 73 3b 0d 0a 23 65 6c 73 65 0d n bytes;..#else.
53f0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 . thr
5400: 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 6d ow new NotImplem
5410: 65 6e 74 65 64 45 78 63 65 70 74 69 6f 6e 28 29 entedException()
5420: 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 ;..#endif..
5430: 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 }.. }....
5440: 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
5450: 0d 0a 20 20 20 20 2f 2f 2f 20 52 65 74 75 72 6e .. /// Return
5460: 73 20 6e 6f 6e 2d 7a 65 72 6f 20 69 66 20 74 68 s non-zero if th
5470: 65 20 75 6e 64 65 72 6c 79 69 6e 67 20 6e 61 74 e underlying nat
5480: 69 76 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 68 ive connection h
5490: 61 6e 64 6c 65 20 69 73 20 6f 77 6e 65 64 0d 0a andle is owned..
54a0: 20 20 20 20 2f 2f 2f 20 62 79 20 74 68 69 73 20 /// by this
54b0: 69 6e 73 74 61 6e 63 65 2e 0d 0a 20 20 20 20 2f instance... /
54c0: 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 // </summary>..
54d0: 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 internal over
54e0: 72 69 64 65 20 62 6f 6f 6c 20 4f 77 6e 48 61 6e ride bool OwnHan
54f0: 64 6c 65 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 dle.. {..
5500: 20 20 20 20 67 65 74 0d 0a 20 20 20 20 20 20 20 get..
5510: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
5520: 69 66 20 28 5f 73 71 6c 20 3d 3d 20 6e 75 6c 6c if (_sql == null
5530: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )..
5540: 20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c throw new SQL
5550: 69 74 65 45 78 63 65 70 74 69 6f 6e 28 22 6e 6f iteException("no
5560: 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 68 61 6e 64 connection hand
5570: 6c 65 20 61 76 61 69 6c 61 62 6c 65 22 29 3b 0d le available");.
5580: 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 ... r
5590: 65 74 75 72 6e 20 5f 73 71 6c 2e 4f 77 6e 48 61 eturn _sql.OwnHa
55a0: 6e 64 6c 65 3b 0d 0a 20 20 20 20 20 20 20 20 7d ndle;.. }
55b0: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f .. }.... /
55c0: 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 // <summary>..
55d0: 20 20 2f 2f 2f 20 52 65 74 75 72 6e 73 20 74 68 /// Returns th
55e0: 65 20 6c 6f 67 69 63 61 6c 20 6c 69 73 74 20 6f e logical list o
55f0: 66 20 66 75 6e 63 74 69 6f 6e 73 20 61 73 73 6f f functions asso
5600: 63 69 61 74 65 64 20 77 69 74 68 20 74 68 69 73 ciated with this
5610: 20 63 6f 6e 6e 65 63 74 69 6f 6e 2e 0d 0a 20 20 connection...
5620: 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e /// </summary>
5630: 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
5640: 76 65 72 72 69 64 65 20 49 44 69 63 74 69 6f 6e verride IDiction
5650: 61 72 79 3c 53 51 4c 69 74 65 46 75 6e 63 74 69 ary<SQLiteFuncti
5660: 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 53 51 4c onAttribute, SQL
5670: 69 74 65 46 75 6e 63 74 69 6f 6e 3e 20 46 75 6e iteFunction> Fun
5680: 63 74 69 6f 6e 73 0d 0a 20 20 20 20 7b 0d 0a 20 ctions.. {..
5690: 20 20 20 20 20 20 20 67 65 74 20 7b 20 72 65 74 get { ret
56a0: 75 72 6e 20 5f 66 75 6e 63 74 69 6f 6e 73 3b 20 urn _functions;
56b0: 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 }.. }....
56c0: 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 internal overrid
56d0: 65 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 e SQLiteErrorCod
56e0: 65 20 53 65 74 4d 65 6d 6f 72 79 53 74 61 74 75 e SetMemoryStatu
56f0: 73 28 62 6f 6f 6c 20 76 61 6c 75 65 29 0d 0a 20 s(bool value)..
5700: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 72 65 {.. re
5710: 74 75 72 6e 20 53 74 61 74 69 63 53 65 74 4d 65 turn StaticSetMe
5720: 6d 6f 72 79 53 74 61 74 75 73 28 76 61 6c 75 65 moryStatus(value
5730: 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 );.. }....
5740: 20 69 6e 74 65 72 6e 61 6c 20 73 74 61 74 69 63 internal static
5750: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
5760: 20 53 74 61 74 69 63 53 65 74 4d 65 6d 6f 72 79 StaticSetMemory
5770: 53 74 61 74 75 73 28 62 6f 6f 6c 20 76 61 6c 75 Status(bool valu
5780: 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 e).. {..
5790: 20 20 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f SQLiteErrorCo
57a0: 64 65 20 72 63 20 3d 20 55 6e 73 61 66 65 4e 61 de rc = UnsafeNa
57b0: 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 tiveMethods.sqli
57c0: 74 65 33 5f 63 6f 6e 66 69 67 5f 69 6e 74 28 0d te3_config_int(.
57d0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 53 51 4c . SQL
57e0: 69 74 65 43 6f 6e 66 69 67 4f 70 73 45 6e 75 6d iteConfigOpsEnum
57f0: 2e 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 4d .SQLITE_CONFIG_M
5800: 45 4d 53 54 41 54 55 53 2c 20 76 61 6c 75 65 20 EMSTATUS, value
5810: 3f 20 31 20 3a 20 30 29 3b 0d 0a 0d 0a 20 20 20 ? 1 : 0);....
5820: 20 20 20 20 20 72 65 74 75 72 6e 20 72 63 3b 0d return rc;.
5830: 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f . }.... //
5840: 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 / <summary>..
5850: 20 2f 2f 2f 20 41 74 74 65 6d 70 74 73 20 74 6f /// Attempts to
5860: 20 66 72 65 65 20 61 73 20 6d 75 63 68 20 68 65 free as much he
5870: 61 70 20 6d 65 6d 6f 72 79 20 61 73 20 70 6f 73 ap memory as pos
5880: 73 69 62 6c 65 20 66 6f 72 20 74 68 65 20 64 61 sible for the da
5890: 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f tabase connectio
58a0: 6e 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 n... /// </su
58b0: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
58c0: 3c 72 65 74 75 72 6e 73 3e 41 20 73 74 61 6e 64 <returns>A stand
58d0: 61 72 64 20 53 51 4c 69 74 65 20 72 65 74 75 72 ard SQLite retur
58e0: 6e 20 63 6f 64 65 20 28 69 2e 65 2e 20 7a 65 72 n code (i.e. zer
58f0: 6f 20 66 6f 72 20 73 75 63 63 65 73 73 20 61 6e o for success an
5900: 64 20 6e 6f 6e 2d 7a 65 72 6f 20 66 6f 72 20 66 d non-zero for f
5910: 61 69 6c 75 72 65 29 2e 3c 2f 72 65 74 75 72 6e ailure).</return
5920: 73 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c s>.. internal
5930: 20 6f 76 65 72 72 69 64 65 20 53 51 4c 69 74 65 override SQLite
5940: 45 72 72 6f 72 43 6f 64 65 20 52 65 6c 65 61 73 ErrorCode Releas
5950: 65 4d 65 6d 6f 72 79 28 29 0d 0a 20 20 20 20 7b eMemory().. {
5960: 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 .. SQLite
5970: 45 72 72 6f 72 43 6f 64 65 20 72 63 20 3d 20 55 ErrorCode rc = U
5980: 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
5990: 64 73 2e 73 71 6c 69 74 65 33 5f 64 62 5f 72 65 ds.sqlite3_db_re
59a0: 6c 65 61 73 65 5f 6d 65 6d 6f 72 79 28 5f 73 71 lease_memory(_sq
59b0: 6c 29 3b 0d 0a 20 20 20 20 20 20 20 20 72 65 74 l);.. ret
59c0: 75 72 6e 20 72 63 3b 0d 0a 20 20 20 20 7d 0d 0a urn rc;.. }..
59d0: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 .. /// <summa
59e0: 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 41 74 74 ry>.. /// Att
59f0: 65 6d 70 74 73 20 74 6f 20 66 72 65 65 20 4e 20 empts to free N
5a00: 62 79 74 65 73 20 6f 66 20 68 65 61 70 20 6d 65 bytes of heap me
5a10: 6d 6f 72 79 20 62 79 20 64 65 61 6c 6c 6f 63 61 mory by dealloca
5a20: 74 69 6e 67 20 6e 6f 6e 2d 65 73 73 65 6e 74 69 ting non-essenti
5a30: 61 6c 20 6d 65 6d 6f 72 79 0d 0a 20 20 20 20 2f al memory.. /
5a40: 2f 2f 20 61 6c 6c 6f 63 61 74 69 6f 6e 73 20 68 // allocations h
5a50: 65 6c 64 20 62 79 20 74 68 65 20 64 61 74 61 62 eld by the datab
5a60: 61 73 65 20 6c 69 62 72 61 72 79 2e 20 4d 65 6d ase library. Mem
5a70: 6f 72 79 20 75 73 65 64 20 74 6f 20 63 61 63 68 ory used to cach
5a80: 65 20 64 61 74 61 62 61 73 65 20 70 61 67 65 73 e database pages
5a90: 0d 0a 20 20 20 20 2f 2f 2f 20 74 6f 20 69 6d 70 .. /// to imp
5aa0: 72 6f 76 65 20 70 65 72 66 6f 72 6d 61 6e 63 65 rove performance
5ab0: 20 69 73 20 61 6e 20 65 78 61 6d 70 6c 65 20 6f is an example o
5ac0: 66 20 6e 6f 6e 2d 65 73 73 65 6e 74 69 61 6c 20 f non-essential
5ad0: 6d 65 6d 6f 72 79 2e 20 20 54 68 69 73 20 69 73 memory. This is
5ae0: 20 61 20 6e 6f 2d 6f 70 0d 0a 20 20 20 20 2f 2f a no-op.. //
5af0: 2f 20 72 65 74 75 72 6e 69 6e 67 20 7a 65 72 6f / returning zero
5b00: 20 69 66 20 74 68 65 20 53 51 4c 69 74 65 20 63 if the SQLite c
5b10: 6f 72 65 20 6c 69 62 72 61 72 79 20 77 61 73 20 ore library was
5b20: 6e 6f 74 20 63 6f 6d 70 69 6c 65 64 20 77 69 74 not compiled wit
5b30: 68 20 74 68 65 20 63 6f 6d 70 69 6c 65 2d 74 69 h the compile-ti
5b40: 6d 65 0d 0a 20 20 20 20 2f 2f 2f 20 6f 70 74 69 me.. /// opti
5b50: 6f 6e 20 53 51 4c 49 54 45 5f 45 4e 41 42 4c 45 on SQLITE_ENABLE
5b60: 5f 4d 45 4d 4f 52 59 5f 4d 41 4e 41 47 45 4d 45 _MEMORY_MANAGEME
5b70: 4e 54 2e 20 20 4f 70 74 69 6f 6e 61 6c 6c 79 2c NT. Optionally,
5b80: 20 61 74 74 65 6d 70 74 73 20 74 6f 20 72 65 73 attempts to res
5b90: 65 74 20 61 6e 64 2f 6f 72 0d 0a 20 20 20 20 2f et and/or.. /
5ba0: 2f 2f 20 63 6f 6d 70 61 63 74 20 74 68 65 20 57 // compact the W
5bb0: 69 6e 33 32 20 6e 61 74 69 76 65 20 68 65 61 70 in32 native heap
5bc0: 2c 20 69 66 20 61 70 70 6c 69 63 61 62 6c 65 2e , if applicable.
5bd0: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d .. /// </summ
5be0: 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 ary>.. /// <p
5bf0: 61 72 61 6d 20 6e 61 6d 65 3d 22 6e 42 79 74 65 aram name="nByte
5c00: 73 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 s">.. /// The
5c10: 20 72 65 71 75 65 73 74 65 64 20 6e 75 6d 62 65 requested numbe
5c20: 72 20 6f 66 20 62 79 74 65 73 20 74 6f 20 66 72 r of bytes to fr
5c30: 65 65 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 ee... /// </p
5c40: 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c aram>.. /// <
5c50: 70 61 72 61 6d 20 6e 61 6d 65 3d 22 72 65 73 65 param name="rese
5c60: 74 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 4e 6f 6e t">.. /// Non
5c70: 2d 7a 65 72 6f 20 74 6f 20 61 74 74 65 6d 70 74 -zero to attempt
5c80: 20 61 20 68 65 61 70 20 72 65 73 65 74 2e 0d 0a a heap reset...
5c90: 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e /// </param>
5ca0: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d .. /// <param
5cb0: 20 6e 61 6d 65 3d 22 63 6f 6d 70 61 63 74 22 3e name="compact">
5cc0: 0d 0a 20 20 20 20 2f 2f 2f 20 4e 6f 6e 2d 7a 65 .. /// Non-ze
5cd0: 72 6f 20 74 6f 20 61 74 74 65 6d 70 74 20 68 65 ro to attempt he
5ce0: 61 70 20 63 6f 6d 70 61 63 74 69 6f 6e 2e 0d 0a ap compaction...
5cf0: 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e /// </param>
5d00: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d .. /// <param
5d10: 20 6e 61 6d 65 3d 22 6e 46 72 65 65 22 3e 0d 0a name="nFree">..
5d20: 20 20 20 20 2f 2f 2f 20 54 68 65 20 6e 75 6d 62 /// The numb
5d30: 65 72 20 6f 66 20 62 79 74 65 73 20 61 63 74 75 er of bytes actu
5d40: 61 6c 6c 79 20 66 72 65 65 64 2e 20 20 54 68 69 ally freed. Thi
5d50: 73 20 76 61 6c 75 65 20 6d 61 79 20 62 65 20 7a s value may be z
5d60: 65 72 6f 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ero... /// </
5d70: 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 param>.. ///
5d80: 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 72 65 73 <param name="res
5d90: 65 74 4f 6b 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 etOk">.. ///
5da0: 54 68 69 73 20 76 61 6c 75 65 20 77 69 6c 6c 20 This value will
5db0: 62 65 20 6e 6f 6e 2d 7a 65 72 6f 20 69 66 20 74 be non-zero if t
5dc0: 68 65 20 68 65 61 70 20 72 65 73 65 74 20 77 61 he heap reset wa
5dd0: 73 20 73 75 63 63 65 73 73 66 75 6c 2e 0d 0a 20 s successful...
5de0: 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d /// </param>.
5df0: 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 . /// <param
5e00: 6e 61 6d 65 3d 22 6e 4c 61 72 67 65 73 74 22 3e name="nLargest">
5e10: 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 73 69 .. /// The si
5e20: 7a 65 20 6f 66 20 74 68 65 20 6c 61 72 67 65 73 ze of the larges
5e30: 74 20 63 6f 6d 6d 69 74 74 65 64 20 66 72 65 65 t committed free
5e40: 20 62 6c 6f 63 6b 20 69 6e 20 74 68 65 20 68 65 block in the he
5e50: 61 70 2c 20 69 6e 20 62 79 74 65 73 2e 0d 0a 20 ap, in bytes...
5e60: 20 20 20 2f 2f 2f 20 54 68 69 73 20 76 61 6c 75 /// This valu
5e70: 65 20 77 69 6c 6c 20 62 65 20 7a 65 72 6f 20 75 e will be zero u
5e80: 6e 6c 65 73 73 20 68 65 61 70 20 63 6f 6d 70 61 nless heap compa
5e90: 63 74 69 6f 6e 20 69 73 20 65 6e 61 62 6c 65 64 ction is enabled
5ea0: 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 ... /// </par
5eb0: 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 am>.. /// <re
5ec0: 74 75 72 6e 73 3e 0d 0a 20 20 20 20 2f 2f 2f 20 turns>.. ///
5ed0: 41 20 73 74 61 6e 64 61 72 64 20 53 51 4c 69 74 A standard SQLit
5ee0: 65 20 72 65 74 75 72 6e 20 63 6f 64 65 20 28 69 e return code (i
5ef0: 2e 65 2e 20 7a 65 72 6f 20 66 6f 72 20 73 75 63 .e. zero for suc
5f00: 63 65 73 73 20 61 6e 64 20 6e 6f 6e 2d 7a 65 72 cess and non-zer
5f10: 6f 0d 0a 20 20 20 20 2f 2f 2f 20 66 6f 72 20 66 o.. /// for f
5f20: 61 69 6c 75 72 65 29 2e 0d 0a 20 20 20 20 2f 2f ailure)... //
5f30: 2f 20 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 / </returns>..
5f40: 20 20 69 6e 74 65 72 6e 61 6c 20 73 74 61 74 69 internal stati
5f50: 63 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 c SQLiteErrorCod
5f60: 65 20 53 74 61 74 69 63 52 65 6c 65 61 73 65 4d e StaticReleaseM
5f70: 65 6d 6f 72 79 28 0d 0a 20 20 20 20 20 20 20 20 emory(..
5f80: 69 6e 74 20 6e 42 79 74 65 73 2c 0d 0a 20 20 20 int nBytes,..
5f90: 20 20 20 20 20 62 6f 6f 6c 20 72 65 73 65 74 2c bool reset,
5fa0: 0d 0a 20 20 20 20 20 20 20 20 62 6f 6f 6c 20 63 .. bool c
5fb0: 6f 6d 70 61 63 74 2c 0d 0a 20 20 20 20 20 20 20 ompact,..
5fc0: 20 72 65 66 20 69 6e 74 20 6e 46 72 65 65 2c 0d ref int nFree,.
5fd0: 0a 20 20 20 20 20 20 20 20 72 65 66 20 62 6f 6f . ref boo
5fe0: 6c 20 72 65 73 65 74 4f 6b 2c 0d 0a 20 20 20 20 l resetOk,..
5ff0: 20 20 20 20 72 65 66 20 75 69 6e 74 20 6e 4c 61 ref uint nLa
6000: 72 67 65 73 74 0d 0a 20 20 20 20 20 20 20 20 29 rgest.. )
6010: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
6020: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
6030: 20 72 63 20 3d 20 53 51 4c 69 74 65 45 72 72 6f rc = SQLiteErro
6040: 72 43 6f 64 65 2e 4f 6b 3b 0d 0a 0d 0a 20 20 20 rCode.Ok;....
6050: 20 20 20 20 20 69 6e 74 20 6e 46 72 65 65 4c 6f int nFreeLo
6060: 63 61 6c 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 cal = UnsafeNati
6070: 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
6080: 33 5f 72 65 6c 65 61 73 65 5f 6d 65 6d 6f 72 79 3_release_memory
6090: 28 6e 42 79 74 65 73 29 3b 0d 0a 20 20 20 20 20 (nBytes);..
60a0: 20 20 20 75 69 6e 74 20 6e 4c 61 72 67 65 73 74 uint nLargest
60b0: 4c 6f 63 61 6c 20 3d 20 30 3b 0d 0a 20 20 20 20 Local = 0;..
60c0: 20 20 20 20 62 6f 6f 6c 20 72 65 73 65 74 4f 6b bool resetOk
60d0: 4c 6f 63 61 6c 20 3d 20 66 61 6c 73 65 3b 0d 0a Local = false;..
60e0: 0d 0a 23 69 66 20 21 44 45 42 55 47 20 26 26 20 ..#if !DEBUG &&
60f0: 57 49 4e 44 4f 57 53 20 2f 2f 20 4e 4f 54 45 3a WINDOWS // NOTE:
6100: 20 53 68 6f 75 6c 64 20 62 65 20 22 57 49 4e 33 Should be "WIN3
6110: 32 48 45 41 50 20 26 26 20 21 4d 45 4d 44 45 42 2HEAP && !MEMDEB
6120: 55 47 20 26 26 20 57 49 4e 44 4f 57 53 22 0d 0a UG && WINDOWS"..
6130: 20 20 20 20 20 20 20 20 69 66 20 28 28 72 63 20 if ((rc
6140: 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f == SQLiteErrorCo
6150: 64 65 2e 4f 6b 29 20 26 26 20 72 65 73 65 74 29 de.Ok) && reset)
6160: 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 .. {..
6170: 20 20 20 20 20 20 20 20 20 72 63 20 3d 20 55 6e rc = Un
6180: 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
6190: 73 2e 73 71 6c 69 74 65 33 5f 77 69 6e 33 32 5f s.sqlite3_win32_
61a0: 72 65 73 65 74 5f 68 65 61 70 28 29 3b 0d 0a 0d reset_heap();...
61b0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 . if
61c0: 28 72 63 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 (rc == SQLiteErr
61d0: 6f 72 43 6f 64 65 2e 4f 6b 29 0d 0a 20 20 20 20 orCode.Ok)..
61e0: 20 20 20 20 20 20 20 20 20 20 20 20 72 65 73 65 rese
61f0: 74 4f 6b 4c 6f 63 61 6c 20 3d 20 74 72 75 65 3b tOkLocal = true;
6200: 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 .. }....
6210: 20 20 20 20 20 20 20 69 66 20 28 28 72 63 20 3d if ((rc =
6220: 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 = SQLiteErrorCod
6230: 65 2e 4f 6b 29 20 26 26 20 63 6f 6d 70 61 63 74 e.Ok) && compact
6240: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 ).. r
6250: 63 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 c = UnsafeNative
6260: 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
6270: 77 69 6e 33 32 5f 63 6f 6d 70 61 63 74 5f 68 65 win32_compact_he
6280: 61 70 28 72 65 66 20 6e 4c 61 72 67 65 73 74 4c ap(ref nLargestL
6290: 6f 63 61 6c 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 ocal);..#else..
62a0: 20 20 20 20 20 20 20 69 66 20 28 72 65 73 65 74 if (reset
62b0: 20 7c 7c 20 63 6f 6d 70 61 63 74 29 0d 0a 20 20 || compact)..
62c0: 20 20 20 20 20 20 20 20 20 20 72 63 20 3d 20 53 rc = S
62d0: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4e QLiteErrorCode.N
62e0: 6f 74 46 6f 75 6e 64 3b 0d 0a 23 65 6e 64 69 66 otFound;..#endif
62f0: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 6e 46 72 65 .... nFre
6300: 65 20 3d 20 6e 46 72 65 65 4c 6f 63 61 6c 3b 0d e = nFreeLocal;.
6310: 0a 20 20 20 20 20 20 20 20 6e 4c 61 72 67 65 73 . nLarges
6320: 74 20 3d 20 6e 4c 61 72 67 65 73 74 4c 6f 63 61 t = nLargestLoca
6330: 6c 3b 0d 0a 20 20 20 20 20 20 20 20 72 65 73 65 l;.. rese
6340: 74 4f 6b 20 3d 20 72 65 73 65 74 4f 6b 4c 6f 63 tOk = resetOkLoc
6350: 61 6c 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 72 al;.... r
6360: 65 74 75 72 6e 20 72 63 3b 0d 0a 20 20 20 20 7d eturn rc;.. }
6370: 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d .... /// <sum
6380: 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 53 mary>.. /// S
6390: 68 75 74 64 6f 77 6e 20 74 68 65 20 53 51 4c 69 hutdown the SQLi
63a0: 74 65 20 65 6e 67 69 6e 65 20 73 6f 20 74 68 61 te engine so tha
63b0: 74 20 69 74 20 63 61 6e 20 62 65 20 72 65 73 74 t it can be rest
63c0: 61 72 74 65 64 20 77 69 74 68 20 64 69 66 66 65 arted with diffe
63d0: 72 65 6e 74 0d 0a 20 20 20 20 2f 2f 2f 20 63 6f rent.. /// co
63e0: 6e 66 69 67 75 72 61 74 69 6f 6e 20 6f 70 74 69 nfiguration opti
63f0: 6f 6e 73 2e 20 20 57 65 20 64 65 70 65 6e 64 20 ons. We depend
6400: 6f 6e 20 61 75 74 6f 20 69 6e 69 74 69 61 6c 69 on auto initiali
6410: 7a 61 74 69 6f 6e 20 74 6f 20 72 65 63 6f 76 65 zation to recove
6420: 72 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 r... /// </su
6430: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
6440: 3c 72 65 74 75 72 6e 73 3e 52 65 74 75 72 6e 73 <returns>Returns
6450: 20 61 20 73 74 61 6e 64 61 72 64 20 53 51 4c 69 a standard SQLi
6460: 74 65 20 72 65 73 75 6c 74 20 63 6f 64 65 2e 3c te result code.<
6470: 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 69 /returns>.. i
6480: 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
6490: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
64a0: 20 53 68 75 74 64 6f 77 6e 28 29 0d 0a 20 20 20 Shutdown()..
64b0: 20 7b 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 {.. retu
64c0: 72 6e 20 53 74 61 74 69 63 53 68 75 74 64 6f 77 rn StaticShutdow
64d0: 6e 28 66 61 6c 73 65 29 3b 0d 0a 20 20 20 20 7d n(false);.. }
64e0: 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d .... /// <sum
64f0: 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 53 mary>.. /// S
6500: 68 75 74 64 6f 77 6e 20 74 68 65 20 53 51 4c 69 hutdown the SQLi
6510: 74 65 20 65 6e 67 69 6e 65 20 73 6f 20 74 68 61 te engine so tha
6520: 74 20 69 74 20 63 61 6e 20 62 65 20 72 65 73 74 t it can be rest
6530: 61 72 74 65 64 20 77 69 74 68 20 64 69 66 66 65 arted with diffe
6540: 72 65 6e 74 0d 0a 20 20 20 20 2f 2f 2f 20 63 6f rent.. /// co
6550: 6e 66 69 67 75 72 61 74 69 6f 6e 20 6f 70 74 69 nfiguration opti
6560: 6f 6e 73 2e 20 20 57 65 20 64 65 70 65 6e 64 20 ons. We depend
6570: 6f 6e 20 61 75 74 6f 20 69 6e 69 74 69 61 6c 69 on auto initiali
6580: 7a 61 74 69 6f 6e 20 74 6f 20 72 65 63 6f 76 65 zation to recove
6590: 72 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 r... /// </su
65a0: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
65b0: 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 64 69 72 <param name="dir
65c0: 65 63 74 6f 72 69 65 73 22 3e 0d 0a 20 20 20 20 ectories">..
65d0: 2f 2f 2f 20 4e 6f 6e 2d 7a 65 72 6f 20 74 6f 20 /// Non-zero to
65e0: 72 65 73 65 74 20 74 68 65 20 64 61 74 61 62 61 reset the databa
65f0: 73 65 20 61 6e 64 20 74 65 6d 70 6f 72 61 72 79 se and temporary
6600: 20 64 69 72 65 63 74 6f 72 69 65 73 20 74 6f 20 directories to
6610: 74 68 65 69 72 0d 0a 20 20 20 20 2f 2f 2f 20 64 their.. /// d
6620: 65 66 61 75 6c 74 20 76 61 6c 75 65 73 2c 20 77 efault values, w
6630: 68 69 63 68 20 73 68 6f 75 6c 64 20 62 65 20 6e hich should be n
6640: 75 6c 6c 20 66 6f 72 20 62 6f 74 68 2e 20 20 54 ull for both. T
6650: 68 69 73 20 70 61 72 61 6d 65 74 65 72 20 68 61 his parameter ha
6660: 73 20 6e 6f 0d 0a 20 20 20 20 2f 2f 2f 20 65 66 s no.. /// ef
6670: 66 65 63 74 20 6f 6e 20 6e 6f 6e 2d 57 69 6e 64 fect on non-Wind
6680: 6f 77 73 20 6f 70 65 72 61 74 69 6e 67 20 73 79 ows operating sy
6690: 73 74 65 6d 73 2e 0d 0a 20 20 20 20 2f 2f 2f 20 stems... ///
66a0: 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f </param>.. //
66b0: 2f 20 3c 72 65 74 75 72 6e 73 3e 52 65 74 75 72 / <returns>Retur
66c0: 6e 73 20 61 20 73 74 61 6e 64 61 72 64 20 53 51 ns a standard SQ
66d0: 4c 69 74 65 20 72 65 73 75 6c 74 20 63 6f 64 65 Lite result code
66e0: 2e 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 .</returns>..
66f0: 20 69 6e 74 65 72 6e 61 6c 20 73 74 61 74 69 63 internal static
6700: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
6710: 20 53 74 61 74 69 63 53 68 75 74 64 6f 77 6e 28 StaticShutdown(
6720: 0d 0a 20 20 20 20 20 20 20 20 62 6f 6f 6c 20 64 .. bool d
6730: 69 72 65 63 74 6f 72 69 65 73 0d 0a 20 20 20 20 irectories..
6740: 20 20 20 20 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 ).. {..
6750: 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 6f SQLiteErro
6760: 72 43 6f 64 65 20 72 63 20 3d 20 53 51 4c 69 74 rCode rc = SQLit
6770: 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 3b 0d 0a eErrorCode.Ok;..
6780: 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 64 69 .. if (di
6790: 72 65 63 74 6f 72 69 65 73 29 0d 0a 20 20 20 20 rectories)..
67a0: 20 20 20 20 7b 0d 0a 23 69 66 20 57 49 4e 44 4f {..#if WINDO
67b0: 57 53 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 WS..
67c0: 69 66 20 28 72 63 20 3d 3d 20 53 51 4c 69 74 65 if (rc == SQLite
67d0: 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 0d 0a 20 ErrorCode.Ok)..
67e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 r
67f0: 63 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 c = UnsafeNative
6800: 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
6810: 77 69 6e 33 32 5f 73 65 74 5f 64 69 72 65 63 74 win32_set_direct
6820: 6f 72 79 28 31 2c 20 6e 75 6c 6c 29 3b 0d 0a 0d ory(1, null);...
6830: 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 . if
6840: 28 72 63 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 (rc == SQLiteErr
6850: 6f 72 43 6f 64 65 2e 4f 6b 29 0d 0a 20 20 20 20 orCode.Ok)..
6860: 20 20 20 20 20 20 20 20 20 20 20 20 72 63 20 3d rc =
6870: 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
6880: 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 77 69 6e hods.sqlite3_win
6890: 33 32 5f 73 65 74 5f 64 69 72 65 63 74 6f 72 79 32_set_directory
68a0: 28 32 2c 20 6e 75 6c 6c 29 3b 0d 0a 23 65 6c 73 (2, null);..#els
68b0: 65 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 e..#if !NET_COMP
68c0: 41 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f ACT_20 && TRACE_
68d0: 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 CONNECTION..
68e0: 20 20 20 20 20 20 20 20 54 72 61 63 65 2e 57 72 Trace.Wr
68f0: 69 74 65 4c 69 6e 65 28 0d 0a 20 20 20 20 20 20 iteLine(..
6900: 20 20 20 20 20 20 20 20 20 20 22 53 68 75 74 64 "Shutd
6910: 6f 77 6e 3a 20 43 61 6e 6e 6f 74 20 72 65 73 65 own: Cannot rese
6920: 74 20 64 69 72 65 63 74 6f 72 69 65 73 20 6f 6e t directories on
6930: 20 74 68 69 73 20 70 6c 61 74 66 6f 72 6d 2e 22 this platform."
6940: 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 23 65 6e 64 );..#endif..#end
6950: 69 66 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d if.. }...
6960: 0a 20 20 20 20 20 20 20 20 69 66 20 28 72 63 20 . if (rc
6970: 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f == SQLiteErrorCo
6980: 64 65 2e 4f 6b 29 0d 0a 20 20 20 20 20 20 20 20 de.Ok)..
6990: 20 20 20 20 72 63 20 3d 20 55 6e 73 61 66 65 4e rc = UnsafeN
69a0: 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c ativeMethods.sql
69b0: 69 74 65 33 5f 73 68 75 74 64 6f 77 6e 28 29 3b ite3_shutdown();
69c0: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 .... retu
69d0: 72 6e 20 72 63 3b 0d 0a 20 20 20 20 7d 0d 0a 0d rn rc;.. }...
69e0: 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 . /// <summar
69f0: 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 44 65 74 65 y>.. /// Dete
6a00: 72 6d 69 6e 65 73 20 69 66 20 74 68 65 20 61 73 rmines if the as
6a10: 73 6f 63 69 61 74 65 64 20 6e 61 74 69 76 65 20 sociated native
6a20: 63 6f 6e 6e 65 63 74 69 6f 6e 20 68 61 6e 64 6c connection handl
6a30: 65 20 69 73 20 6f 70 65 6e 2e 0d 0a 20 20 20 20 e is open...
6a40: 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a /// </summary>..
6a50: 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 /// <returns
6a60: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 4e 6f 6e 2d 7a >.. /// Non-z
6a70: 65 72 6f 20 69 66 20 74 68 65 20 61 73 73 6f 63 ero if the assoc
6a80: 69 61 74 65 64 20 6e 61 74 69 76 65 20 63 6f 6e iated native con
6a90: 6e 65 63 74 69 6f 6e 20 68 61 6e 64 6c 65 20 69 nection handle i
6aa0: 73 20 6f 70 65 6e 2e 0d 0a 20 20 20 20 2f 2f 2f s open... ///
6ab0: 20 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 </returns>..
6ac0: 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 internal overri
6ad0: 64 65 20 62 6f 6f 6c 20 49 73 4f 70 65 6e 28 29 de bool IsOpen()
6ae0: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
6af0: 20 72 65 74 75 72 6e 20 28 5f 73 71 6c 20 21 3d return (_sql !=
6b00: 20 6e 75 6c 6c 29 20 26 26 20 21 5f 73 71 6c 2e null) && !_sql.
6b10: 49 73 49 6e 76 61 6c 69 64 20 26 26 20 21 5f 73 IsInvalid && !_s
6b20: 71 6c 2e 49 73 43 6c 6f 73 65 64 3b 0d 0a 20 20 ql.IsClosed;..
6b30: 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c }.... /// <
6b40: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
6b50: 2f 20 52 65 74 75 72 6e 73 20 74 68 65 20 66 75 / Returns the fu
6b60: 6c 6c 79 20 71 75 61 6c 69 66 69 65 64 20 70 61 lly qualified pa
6b70: 74 68 20 61 6e 64 20 66 69 6c 65 20 6e 61 6d 65 th and file name
6b80: 20 66 6f 72 20 74 68 65 20 63 75 72 72 65 6e 74 for the current
6b90: 6c 79 20 6f 70 65 6e 0d 0a 20 20 20 20 2f 2f 2f ly open.. ///
6ba0: 20 64 61 74 61 62 61 73 65 2c 20 69 66 20 61 6e database, if an
6bb0: 79 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 y... /// </su
6bc0: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
6bd0: 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 64 62 4e <param name="dbN
6be0: 61 6d 65 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 ame">.. /// T
6bf0: 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 61 he name of the a
6c00: 74 74 61 63 68 65 64 20 64 61 74 61 62 61 73 65 ttached database
6c10: 20 74 6f 20 71 75 65 72 79 2e 0d 0a 20 20 20 20 to query...
6c20: 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 /// </param>..
6c30: 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 0d /// <returns>.
6c40: 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 66 75 6c . /// The ful
6c50: 6c 79 20 71 75 61 6c 69 66 69 65 64 20 70 61 74 ly qualified pat
6c60: 68 20 61 6e 64 20 66 69 6c 65 20 6e 61 6d 65 20 h and file name
6c70: 66 6f 72 20 74 68 65 20 63 75 72 72 65 6e 74 6c for the currentl
6c80: 79 20 6f 70 65 6e 20 64 61 74 61 62 61 73 65 2c y open database,
6c90: 0d 0a 20 20 20 20 2f 2f 2f 20 69 66 20 61 6e 79 .. /// if any
6ca0: 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 72 65 74 ... /// </ret
6cb0: 75 72 6e 73 3e 0d 0a 20 20 20 20 69 6e 74 65 72 urns>.. inter
6cc0: 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 73 74 72 nal override str
6cd0: 69 6e 67 20 47 65 74 46 69 6c 65 4e 61 6d 65 28 ing GetFileName(
6ce0: 73 74 72 69 6e 67 20 64 62 4e 61 6d 65 29 0d 0a string dbName)..
6cf0: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 69 {.. i
6d00: 66 20 28 5f 73 71 6c 20 3d 3d 20 6e 75 6c 6c 29 f (_sql == null)
6d10: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 .. re
6d20: 74 75 72 6e 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 20 turn null;....
6d30: 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 54 46 return UTF
6d40: 38 54 6f 53 74 72 69 6e 67 28 55 6e 73 61 66 65 8ToString(Unsafe
6d50: 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
6d60: 6c 69 74 65 33 5f 64 62 5f 66 69 6c 65 6e 61 6d lite3_db_filenam
6d70: 65 5f 62 79 74 65 73 28 0d 0a 20 20 20 20 20 20 e_bytes(..
6d80: 20 20 20 20 20 20 5f 73 71 6c 2c 20 54 6f 55 54 _sql, ToUT
6d90: 46 38 28 64 62 4e 61 6d 65 29 29 2c 20 2d 31 29 F8(dbName)), -1)
6da0: 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 ;.. }....
6db0: 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 internal overrid
6dc0: 65 20 76 6f 69 64 20 4f 70 65 6e 28 73 74 72 69 e void Open(stri
6dd0: 6e 67 20 73 74 72 46 69 6c 65 6e 61 6d 65 2c 20 ng strFilename,
6de0: 73 74 72 69 6e 67 20 76 66 73 4e 61 6d 65 2c 20 string vfsName,
6df0: 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e SQLiteConnection
6e00: 46 6c 61 67 73 20 63 6f 6e 6e 65 63 74 69 6f 6e Flags connection
6e10: 46 6c 61 67 73 2c 20 53 51 4c 69 74 65 4f 70 65 Flags, SQLiteOpe
6e20: 6e 46 6c 61 67 73 45 6e 75 6d 20 6f 70 65 6e 46 nFlagsEnum openF
6e30: 6c 61 67 73 2c 20 69 6e 74 20 6d 61 78 50 6f 6f lags, int maxPoo
6e40: 6c 53 69 7a 65 2c 20 62 6f 6f 6c 20 75 73 65 50 lSize, bool useP
6e50: 6f 6f 6c 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 ool).. {..
6e60: 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 2f 2f 20 //.. //
6e70: 4e 4f 54 45 3a 20 49 66 20 74 68 65 20 64 61 74 NOTE: If the dat
6e80: 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e abase connection
6e90: 20 69 73 20 63 75 72 72 65 6e 74 6c 79 20 6f 70 is currently op
6ea0: 65 6e 2c 20 61 74 74 65 6d 70 74 20 74 6f 0d 0a en, attempt to..
6eb0: 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 63 // c
6ec0: 6c 6f 73 65 20 69 74 20 6e 6f 77 2e 20 20 54 68 lose it now. Th
6ed0: 69 73 20 6d 75 73 74 20 62 65 20 64 6f 6e 65 20 is must be done
6ee0: 62 65 63 61 75 73 65 20 74 68 65 20 66 69 6c 65 because the file
6ef0: 20 6e 61 6d 65 20 6f 72 0d 0a 20 20 20 20 20 20 name or..
6f00: 2f 2f 20 20 20 20 20 20 20 6f 74 68 65 72 20 70 // other p
6f10: 61 72 61 6d 65 74 65 72 73 20 74 68 61 74 20 6d arameters that m
6f20: 61 79 20 69 6d 70 61 63 74 20 74 68 65 20 75 6e ay impact the un
6f30: 64 65 72 6c 79 69 6e 67 20 64 61 74 61 62 61 73 derlying databas
6f40: 65 0d 0a 20 20 20 20 20 20 2f 2f 20 20 20 20 20 e.. //
6f50: 20 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 6d 61 79 connection may
6f60: 20 68 61 76 65 20 63 68 61 6e 67 65 64 2e 0d 0a have changed...
6f70: 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 //..
6f80: 69 66 20 28 5f 73 71 6c 20 21 3d 20 6e 75 6c 6c if (_sql != null
6f90: 29 20 43 6c 6f 73 65 28 74 72 75 65 29 3b 0d 0a ) Close(true);..
6fa0: 0d 0a 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 .. //..
6fb0: 20 20 2f 2f 20 4e 4f 54 45 3a 20 49 66 20 74 68 // NOTE: If th
6fc0: 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 77 61 73 e connection was
6fd0: 20 6e 6f 74 20 63 6c 6f 73 65 64 20 73 75 63 63 not closed succ
6fe0: 65 73 73 66 75 6c 6c 79 2c 20 74 68 72 6f 77 20 essfully, throw
6ff0: 61 6e 0d 0a 20 20 20 20 20 20 2f 2f 20 20 20 20 an.. //
7000: 20 20 20 65 78 63 65 70 74 69 6f 6e 20 6e 6f 77 exception now
7010: 2e 0d 0a 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 ... //..
7020: 20 20 20 69 66 20 28 5f 73 71 6c 20 21 3d 20 6e if (_sql != n
7030: 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 ull)..
7040: 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 throw new SQLite
7050: 45 78 63 65 70 74 69 6f 6e 28 22 63 6f 6e 6e 65 Exception("conne
7060: 63 74 69 6f 6e 20 68 61 6e 64 6c 65 20 69 73 20 ction handle is
7070: 73 74 69 6c 6c 20 61 63 74 69 76 65 22 29 3b 0d still active");.
7080: 0a 0d 0a 20 20 20 20 20 20 5f 75 73 65 50 6f 6f ... _usePoo
7090: 6c 20 3d 20 75 73 65 50 6f 6f 6c 3b 0d 0a 20 20 l = usePool;..
70a0: 20 20 20 20 5f 66 69 6c 65 4e 61 6d 65 20 3d 20 _fileName =
70b0: 73 74 72 46 69 6c 65 6e 61 6d 65 3b 0d 0a 20 20 strFilename;..
70c0: 20 20 20 20 5f 66 6c 61 67 73 20 3d 20 63 6f 6e _flags = con
70d0: 6e 65 63 74 69 6f 6e 46 6c 61 67 73 3b 0d 0a 0d nectionFlags;...
70e0: 0a 20 20 20 20 20 20 69 66 20 28 75 73 65 50 6f . if (usePo
70f0: 6f 6c 29 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 20 ol).. {..
7100: 20 20 20 20 20 20 5f 73 71 6c 20 3d 20 53 51 4c _sql = SQL
7110: 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 50 6f 6f iteConnectionPoo
7120: 6c 2e 52 65 6d 6f 76 65 28 73 74 72 46 69 6c 65 l.Remove(strFile
7130: 6e 61 6d 65 2c 20 6d 61 78 50 6f 6f 6c 53 69 7a name, maxPoolSiz
7140: 65 2c 20 6f 75 74 20 5f 70 6f 6f 6c 56 65 72 73 e, out _poolVers
7150: 69 6f 6e 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 ion);....
7160: 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f SQLiteConnectio
7170: 6e 2e 4f 6e 43 68 61 6e 67 65 64 28 6e 75 6c 6c n.OnChanged(null
7180: 2c 20 6e 65 77 20 43 6f 6e 6e 65 63 74 69 6f 6e , new Connection
7190: 45 76 65 6e 74 41 72 67 73 28 0d 0a 20 20 20 20 EventArgs(..
71a0: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 43 6f SQLiteCo
71b0: 6e 6e 65 63 74 69 6f 6e 45 76 65 6e 74 54 79 70 nnectionEventTyp
71c0: 65 2e 4f 70 65 6e 65 64 46 72 6f 6d 50 6f 6f 6c e.OpenedFromPool
71d0: 2c 20 6e 75 6c 6c 2c 20 6e 75 6c 6c 2c 0d 0a 20 , null, null,..
71e0: 20 20 20 20 20 20 20 20 20 20 20 6e 75 6c 6c 2c null,
71f0: 20 6e 75 6c 6c 2c 20 5f 73 71 6c 2c 20 73 74 72 null, _sql, str
7200: 46 69 6c 65 6e 61 6d 65 2c 20 6e 65 77 20 6f 62 Filename, new ob
7210: 6a 65 63 74 5b 5d 20 7b 0d 0a 20 20 20 20 20 20 ject[] {..
7220: 20 20 20 20 20 20 74 79 70 65 6f 66 28 53 51 4c typeof(SQL
7230: 69 74 65 33 29 2c 20 73 74 72 46 69 6c 65 6e 61 ite3), strFilena
7240: 6d 65 2c 20 76 66 73 4e 61 6d 65 2c 20 63 6f 6e me, vfsName, con
7250: 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2c 0d 0a 20 nectionFlags,..
7260: 20 20 20 20 20 20 20 20 20 20 20 6f 70 65 6e 46 openF
7270: 6c 61 67 73 2c 20 6d 61 78 50 6f 6f 6c 53 69 7a lags, maxPoolSiz
7280: 65 2c 20 75 73 65 50 6f 6f 6c 2c 20 5f 70 6f 6f e, usePool, _poo
7290: 6c 56 65 72 73 69 6f 6e 20 7d 29 29 3b 0d 0a 0d lVersion }));...
72a0: 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 43 .#if !NET_COMPAC
72b0: 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f 43 4f T_20 && TRACE_CO
72c0: 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 20 20 NNECTION..
72d0: 20 20 54 72 61 63 65 2e 57 72 69 74 65 4c 69 6e Trace.WriteLin
72e0: 65 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 e(UnsafeNativeMe
72f0: 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d thods.StringForm
7300: 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 at(..
7310: 20 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 CultureInfo.Cur
7320: 72 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 rentCulture,..
7330: 20 20 20 20 20 20 20 20 20 20 22 4f 70 65 6e 20 "Open
7340: 28 50 6f 6f 6c 29 3a 20 7b 30 7d 22 2c 20 48 61 (Pool): {0}", Ha
7350: 6e 64 6c 65 54 6f 53 74 72 69 6e 67 28 29 29 29 ndleToString()))
7360: 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 ;..#endif..
7370: 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 69 66 20 28 }.... if (
7380: 5f 73 71 6c 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 _sql == null)..
7390: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
73a0: 74 72 79 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a try.. {..
73b0: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 64 // d
73c0: 6f 20 6e 6f 74 68 69 6e 67 2e 0d 0a 20 20 20 20 o nothing...
73d0: 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 66 }.. f
73e0: 69 6e 61 6c 6c 79 20 2f 2a 20 4e 4f 54 45 3a 20 inally /* NOTE:
73f0: 54 68 72 65 61 64 2e 41 62 6f 72 74 28 29 20 70 Thread.Abort() p
7400: 72 6f 74 65 63 74 69 6f 6e 2e 20 2a 2f 0d 0a 20 rotection. */..
7410: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
7420: 20 20 20 20 49 6e 74 50 74 72 20 64 62 20 3d 20 IntPtr db =
7430: 49 6e 74 50 74 72 2e 5a 65 72 6f 3b 0d 0a 20 20 IntPtr.Zero;..
7440: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 SQLiteEr
7450: 72 6f 72 43 6f 64 65 20 6e 3b 0d 0a 0d 0a 23 69 rorCode n;....#i
7460: 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 f !SQLITE_STANDA
7470: 52 44 0d 0a 20 20 20 20 20 20 20 20 20 20 69 6e RD.. in
7480: 74 20 65 78 74 46 75 6e 63 73 20 3d 20 28 28 63 t extFuncs = ((c
7490: 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 20 26 onnectionFlags &
74a0: 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f SQLiteConnectio
74b0: 6e 46 6c 61 67 73 2e 4e 6f 45 78 74 65 6e 73 69 nFlags.NoExtensi
74c0: 6f 6e 46 75 6e 63 74 69 6f 6e 73 29 20 21 3d 20 onFunctions) !=
74d0: 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e SQLiteConnection
74e0: 46 6c 61 67 73 2e 4e 6f 45 78 74 65 6e 73 69 6f Flags.NoExtensio
74f0: 6e 46 75 6e 63 74 69 6f 6e 73 29 20 3f 20 31 20 nFunctions) ? 1
7500: 3a 20 30 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 : 0;....
7510: 20 20 69 66 20 28 65 78 74 46 75 6e 63 73 20 21 if (extFuncs !
7520: 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 = 0)..
7530: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6e {.. n
7540: 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d = UnsafeNativeM
7550: 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 6f ethods.sqlite3_o
7560: 70 65 6e 5f 69 6e 74 65 72 6f 70 28 54 6f 55 54 pen_interop(ToUT
7570: 46 38 28 73 74 72 46 69 6c 65 6e 61 6d 65 29 2c F8(strFilename),
7580: 20 54 6f 55 54 46 38 28 76 66 73 4e 61 6d 65 29 ToUTF8(vfsName)
7590: 2c 20 6f 70 65 6e 46 6c 61 67 73 2c 20 65 78 74 , openFlags, ext
75a0: 46 75 6e 63 73 2c 20 72 65 66 20 64 62 29 3b 0d Funcs, ref db);.
75b0: 0a 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 . }..
75c0: 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 23 65 else..#e
75d0: 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 ndif..
75e0: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6e {.. n
75f0: 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d = UnsafeNativeM
7600: 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 6f ethods.sqlite3_o
7610: 70 65 6e 5f 76 32 28 54 6f 55 54 46 38 28 73 74 pen_v2(ToUTF8(st
7620: 72 46 69 6c 65 6e 61 6d 65 29 2c 20 72 65 66 20 rFilename), ref
7630: 64 62 2c 20 6f 70 65 6e 46 6c 61 67 73 2c 20 54 db, openFlags, T
7640: 6f 55 54 46 38 28 76 66 73 4e 61 6d 65 29 29 3b oUTF8(vfsName));
7650: 0d 0a 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d .. }...
7660: 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 43 .#if !NET_COMPAC
7670: 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f 43 4f T_20 && TRACE_CO
7680: 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 20 20 NNECTION..
7690: 20 20 20 20 54 72 61 63 65 2e 57 72 69 74 65 4c Trace.WriteL
76a0: 69 6e 65 28 55 6e 73 61 66 65 4e 61 74 69 76 65 ine(UnsafeNative
76b0: 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f Methods.StringFo
76c0: 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 rmat(..
76d0: 20 20 20 20 20 43 75 6c 74 75 72 65 49 6e 66 6f CultureInfo
76e0: 2e 43 75 72 72 65 6e 74 43 75 6c 74 75 72 65 2c .CurrentCulture,
76f0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
7700: 22 4f 70 65 6e 3a 20 7b 30 7d 22 2c 20 64 62 29 "Open: {0}", db)
7710: 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 );..#endif....
7720: 20 20 20 20 20 20 20 20 69 66 20 28 6e 20 21 3d if (n !=
7730: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
7740: 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 77 20 53 .Ok) throw new S
7750: 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 6e QLiteException(n
7760: 2c 20 6e 75 6c 6c 29 3b 0d 0a 20 20 20 20 20 20 , null);..
7770: 20 20 20 20 5f 73 71 6c 20 3d 20 6e 65 77 20 53 _sql = new S
7780: 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 48 QLiteConnectionH
7790: 61 6e 64 6c 65 28 64 62 2c 20 74 72 75 65 29 3b andle(db, true);
77a0: 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 .. }..
77b0: 20 20 20 20 20 6c 6f 63 6b 20 28 5f 73 71 6c 29 lock (_sql)
77c0: 20 7b 20 2f 2a 20 48 41 43 4b 3a 20 46 6f 72 63 { /* HACK: Forc
77d0: 65 20 74 68 65 20 53 79 6e 63 42 6c 6f 63 6b 20 e the SyncBlock
77e0: 74 6f 20 62 65 20 22 63 72 65 61 74 65 64 22 20 to be "created"
77f0: 6e 6f 77 2e 20 2a 2f 20 7d 0d 0a 0d 0a 20 20 20 now. */ }....
7800: 20 20 20 20 20 53 51 4c 69 74 65 43 6f 6e 6e 65 SQLiteConne
7810: 63 74 69 6f 6e 2e 4f 6e 43 68 61 6e 67 65 64 28 ction.OnChanged(
7820: 6e 75 6c 6c 2c 20 6e 65 77 20 43 6f 6e 6e 65 63 null, new Connec
7830: 74 69 6f 6e 45 76 65 6e 74 41 72 67 73 28 0d 0a tionEventArgs(..
7840: 20 20 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 SQLi
7850: 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 45 76 65 6e teConnectionEven
7860: 74 54 79 70 65 2e 4e 65 77 43 72 69 74 69 63 61 tType.NewCritica
7870: 6c 48 61 6e 64 6c 65 2c 20 6e 75 6c 6c 2c 0d 0a lHandle, null,..
7880: 20 20 20 20 20 20 20 20 20 20 20 20 6e 75 6c 6c null
7890: 2c 20 6e 75 6c 6c 2c 20 6e 75 6c 6c 2c 20 5f 73 , null, null, _s
78a0: 71 6c 2c 20 73 74 72 46 69 6c 65 6e 61 6d 65 2c ql, strFilename,
78b0: 20 6e 65 77 20 6f 62 6a 65 63 74 5b 5d 20 7b 0d new object[] {.
78c0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 74 79 70 . typ
78d0: 65 6f 66 28 53 51 4c 69 74 65 33 29 2c 20 73 74 eof(SQLite3), st
78e0: 72 46 69 6c 65 6e 61 6d 65 2c 20 76 66 73 4e 61 rFilename, vfsNa
78f0: 6d 65 2c 20 63 6f 6e 6e 65 63 74 69 6f 6e 46 6c me, connectionFl
7900: 61 67 73 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 ags,..
7910: 20 20 6f 70 65 6e 46 6c 61 67 73 2c 20 6d 61 78 openFlags, max
7920: 50 6f 6f 6c 53 69 7a 65 2c 20 75 73 65 50 6f 6f PoolSize, usePoo
7930: 6c 20 7d 29 29 3b 0d 0a 20 20 20 20 20 20 7d 0d l }));.. }.
7940: 0a 0d 0a 20 20 20 20 20 20 2f 2f 20 42 69 6e 64 ... // Bind
7950: 20 66 75 6e 63 74 69 6f 6e 73 20 74 6f 20 74 68 functions to th
7960: 69 73 20 63 6f 6e 6e 65 63 74 69 6f 6e 2e 20 20 is connection.
7970: 49 66 20 61 6e 79 20 70 72 65 76 69 6f 75 73 20 If any previous
7980: 66 75 6e 63 74 69 6f 6e 73 20 6f 66 20 74 68 65 functions of the
7990: 20 73 61 6d 65 20 6e 61 6d 65 0d 0a 20 20 20 20 same name..
79a0: 20 20 2f 2f 20 77 65 72 65 20 61 6c 72 65 61 64 // were alread
79b0: 79 20 62 6f 75 6e 64 2c 20 74 68 65 6e 20 74 68 y bound, then th
79c0: 65 20 6e 65 77 20 62 69 6e 64 69 6e 67 73 20 72 e new bindings r
79d0: 65 70 6c 61 63 65 20 74 68 65 20 6f 6c 64 2e 0d eplace the old..
79e0: 0a 20 20 20 20 20 20 69 66 20 28 28 63 6f 6e 6e . if ((conn
79f0: 65 63 74 69 6f 6e 46 6c 61 67 73 20 26 20 53 51 ectionFlags & SQ
7a00: 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c LiteConnectionFl
7a10: 61 67 73 2e 4e 6f 42 69 6e 64 46 75 6e 63 74 69 ags.NoBindFuncti
7a20: 6f 6e 73 29 20 21 3d 20 53 51 4c 69 74 65 43 6f ons) != SQLiteCo
7a30: 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e 4e 6f nnectionFlags.No
7a40: 42 69 6e 64 46 75 6e 63 74 69 6f 6e 73 29 0d 0a BindFunctions)..
7a50: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
7a60: 20 20 20 69 66 20 28 5f 66 75 6e 63 74 69 6f 6e if (_function
7a70: 73 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 s == null)..
7a80: 20 20 20 20 20 20 20 20 20 20 5f 66 75 6e 63 74 _funct
7a90: 69 6f 6e 73 20 3d 20 6e 65 77 20 44 69 63 74 69 ions = new Dicti
7aa0: 6f 6e 61 72 79 3c 53 51 4c 69 74 65 46 75 6e 63 onary<SQLiteFunc
7ab0: 74 69 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 53 tionAttribute, S
7ac0: 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 3e 28 29 QLiteFunction>()
7ad0: 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 66 ;.... f
7ae0: 6f 72 65 61 63 68 20 28 4b 65 79 56 61 6c 75 65 oreach (KeyValue
7af0: 50 61 69 72 3c 53 51 4c 69 74 65 46 75 6e 63 74 Pair<SQLiteFunct
7b00: 69 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 53 51 ionAttribute, SQ
7b10: 4c 69 74 65 46 75 6e 63 74 69 6f 6e 3e 20 70 61 LiteFunction> pa
7b20: 69 72 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ir..
7b30: 20 20 20 20 20 20 69 6e 20 53 51 4c 69 74 65 46 in SQLiteF
7b40: 75 6e 63 74 69 6f 6e 2e 42 69 6e 64 46 75 6e 63 unction.BindFunc
7b50: 74 69 6f 6e 73 28 74 68 69 73 2c 20 63 6f 6e 6e tions(this, conn
7b60: 65 63 74 69 6f 6e 46 6c 61 67 73 29 29 0d 0a 20 ectionFlags))..
7b70: 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 {..
7b80: 20 20 20 20 20 20 20 20 20 20 5f 66 75 6e 63 74 _funct
7b90: 69 6f 6e 73 5b 70 61 69 72 2e 4b 65 79 5d 20 3d ions[pair.Key] =
7ba0: 20 70 61 69 72 2e 56 61 6c 75 65 3b 0d 0a 20 20 pair.Value;..
7bb0: 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
7bc0: 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 53 65 74 54 }.... SetT
7bd0: 69 6d 65 6f 75 74 28 30 29 3b 0d 0a 20 20 20 20 imeout(0);..
7be0: 20 20 47 43 2e 4b 65 65 70 41 6c 69 76 65 28 5f GC.KeepAlive(_
7bf0: 73 71 6c 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a sql);.. }....
7c00: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
7c10: 72 72 69 64 65 20 76 6f 69 64 20 43 6c 65 61 72 rride void Clear
7c20: 50 6f 6f 6c 28 29 0d 0a 20 20 20 20 7b 0d 0a 20 Pool().. {..
7c30: 20 20 20 20 20 53 51 4c 69 74 65 43 6f 6e 6e 65 SQLiteConne
7c40: 63 74 69 6f 6e 50 6f 6f 6c 2e 43 6c 65 61 72 50 ctionPool.ClearP
7c50: 6f 6f 6c 28 5f 66 69 6c 65 4e 61 6d 65 29 3b 0d ool(_fileName);.
7c60: 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
7c70: 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
7c80: 69 6e 74 20 43 6f 75 6e 74 50 6f 6f 6c 28 29 0d int CountPool().
7c90: 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 . {..
7ca0: 44 69 63 74 69 6f 6e 61 72 79 3c 73 74 72 69 6e Dictionary<strin
7cb0: 67 2c 20 69 6e 74 3e 20 63 6f 75 6e 74 73 20 3d g, int> counts =
7cc0: 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 null;..
7cd0: 69 6e 74 20 6f 70 65 6e 43 6f 75 6e 74 20 3d 20 int openCount =
7ce0: 30 3b 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 20 0;.. int
7cf0: 63 6c 6f 73 65 43 6f 75 6e 74 20 3d 20 30 3b 0d closeCount = 0;.
7d00: 0a 20 20 20 20 20 20 20 20 69 6e 74 20 74 6f 74 . int tot
7d10: 61 6c 43 6f 75 6e 74 20 3d 20 30 3b 0d 0a 0d 0a alCount = 0;....
7d20: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 43 6f SQLiteCo
7d30: 6e 6e 65 63 74 69 6f 6e 50 6f 6f 6c 2e 47 65 74 nnectionPool.Get
7d40: 43 6f 75 6e 74 73 28 5f 66 69 6c 65 4e 61 6d 65 Counts(_fileName
7d50: 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 ,.. r
7d60: 65 66 20 63 6f 75 6e 74 73 2c 20 72 65 66 20 6f ef counts, ref o
7d70: 70 65 6e 43 6f 75 6e 74 2c 20 72 65 66 20 63 6c penCount, ref cl
7d80: 6f 73 65 43 6f 75 6e 74 2c 0d 0a 20 20 20 20 20 oseCount,..
7d90: 20 20 20 20 20 20 20 72 65 66 20 74 6f 74 61 6c ref total
7da0: 43 6f 75 6e 74 29 3b 0d 0a 0d 0a 20 20 20 20 20 Count);....
7db0: 20 20 20 72 65 74 75 72 6e 20 74 6f 74 61 6c 43 return totalC
7dc0: 6f 75 6e 74 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a ount;.. }....
7dd0: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
7de0: 72 72 69 64 65 20 76 6f 69 64 20 53 65 74 54 69 rride void SetTi
7df0: 6d 65 6f 75 74 28 69 6e 74 20 6e 54 69 6d 65 6f meout(int nTimeo
7e00: 75 74 4d 53 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 utMS).. {..
7e10: 20 20 20 20 49 6e 74 50 74 72 20 64 62 20 3d 20 IntPtr db =
7e20: 5f 73 71 6c 3b 0d 0a 20 20 20 20 20 20 69 66 20 _sql;.. if
7e30: 28 64 62 20 3d 3d 20 49 6e 74 50 74 72 2e 5a 65 (db == IntPtr.Ze
7e40: 72 6f 29 20 74 68 72 6f 77 20 6e 65 77 20 53 51 ro) throw new SQ
7e50: 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 22 6e LiteException("n
7e60: 6f 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 68 61 6e o connection han
7e70: 64 6c 65 20 61 76 61 69 6c 61 62 6c 65 22 29 3b dle available");
7e80: 0d 0a 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 .. SQLiteEr
7e90: 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 rorCode n = Unsa
7ea0: 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
7eb0: 73 71 6c 69 74 65 33 5f 62 75 73 79 5f 74 69 6d sqlite3_busy_tim
7ec0: 65 6f 75 74 28 64 62 2c 20 6e 54 69 6d 65 6f 75 eout(db, nTimeou
7ed0: 74 4d 53 29 3b 0d 0a 20 20 20 20 20 20 69 66 20 tMS);.. if
7ee0: 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f (n != SQLiteErro
7ef0: 72 43 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 20 rCode.Ok) throw
7f00: 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 new SQLiteExcept
7f10: 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 ion(n, GetLastEr
7f20: 72 6f 72 28 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a ror());.. }..
7f30: 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
7f40: 76 65 72 72 69 64 65 20 62 6f 6f 6c 20 53 74 65 verride bool Ste
7f50: 70 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e p(SQLiteStatemen
7f60: 74 20 73 74 6d 74 29 0d 0a 20 20 20 20 7b 0d 0a t stmt).. {..
7f70: 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 6f SQLiteErro
7f80: 72 43 6f 64 65 20 6e 3b 0d 0a 20 20 20 20 20 20 rCode n;..
7f90: 52 61 6e 64 6f 6d 20 72 6e 64 20 3d 20 6e 75 6c Random rnd = nul
7fa0: 6c 3b 0d 0a 20 20 20 20 20 20 75 69 6e 74 20 73 l;.. uint s
7fb0: 74 61 72 74 74 69 63 6b 20 3d 20 28 75 69 6e 74 tarttick = (uint
7fc0: 29 45 6e 76 69 72 6f 6e 6d 65 6e 74 2e 54 69 63 )Environment.Tic
7fd0: 6b 43 6f 75 6e 74 3b 0d 0a 20 20 20 20 20 20 75 kCount;.. u
7fe0: 69 6e 74 20 74 69 6d 65 6f 75 74 20 3d 20 28 75 int timeout = (u
7ff0: 69 6e 74 29 28 73 74 6d 74 2e 5f 63 6f 6d 6d 61 int)(stmt._comma
8000: 6e 64 2e 5f 63 6f 6d 6d 61 6e 64 54 69 6d 65 6f nd._commandTimeo
8010: 75 74 20 2a 20 31 30 30 30 29 3b 0d 0a 0d 0a 20 ut * 1000);....
8020: 20 20 20 20 20 52 65 73 65 74 43 61 6e 63 65 6c ResetCancel
8030: 43 6f 75 6e 74 28 29 3b 0d 0a 0d 0a 20 20 20 20 Count();....
8040: 20 20 77 68 69 6c 65 20 28 74 72 75 65 29 0d 0a while (true)..
8050: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
8060: 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 7b 0d try.. {.
8070: 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 . //
8080: 64 6f 20 6e 6f 74 68 69 6e 67 2e 0d 0a 20 20 20 do nothing...
8090: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
80a0: 66 69 6e 61 6c 6c 79 20 2f 2a 20 4e 4f 54 45 3a finally /* NOTE:
80b0: 20 54 68 72 65 61 64 2e 41 62 6f 72 74 28 29 20 Thread.Abort()
80c0: 70 72 6f 74 65 63 74 69 6f 6e 2e 20 2a 2f 0d 0a protection. */..
80d0: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
80e0: 20 20 20 20 20 6e 20 3d 20 55 6e 73 61 66 65 4e n = UnsafeN
80f0: 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c ativeMethods.sql
8100: 69 74 65 33 5f 73 74 65 70 28 73 74 6d 74 2e 5f ite3_step(stmt._
8110: 73 71 6c 69 74 65 5f 73 74 6d 74 29 3b 0d 0a 20 sqlite_stmt);..
8120: 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 }....
8130: 20 20 20 20 69 66 20 28 53 68 6f 75 6c 64 54 68 if (ShouldTh
8140: 72 6f 77 46 6f 72 43 61 6e 63 65 6c 28 29 29 0d rowForCancel()).
8150: 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 . {..
8160: 20 20 20 20 20 20 20 20 69 66 20 28 28 6e 20 3d if ((n =
8170: 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 = SQLiteErrorCod
8180: 65 2e 4f 6b 29 20 7c 7c 0d 0a 20 20 20 20 20 20 e.Ok) ||..
8190: 20 20 20 20 20 20 20 20 20 20 28 6e 20 3d 3d 20 (n ==
81a0: 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e SQLiteErrorCode.
81b0: 52 6f 77 29 20 7c 7c 0d 0a 20 20 20 20 20 20 20 Row) ||..
81c0: 20 20 20 20 20 20 20 20 20 28 6e 20 3d 3d 20 53 (n == S
81d0: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 44 QLiteErrorCode.D
81e0: 6f 6e 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 one))..
81f0: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
8200: 20 20 20 20 20 20 6e 20 3d 20 53 51 4c 69 74 65 n = SQLite
8210: 45 72 72 6f 72 43 6f 64 65 2e 49 6e 74 65 72 72 ErrorCode.Interr
8220: 75 70 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 upt;..
8230: 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 }....
8240: 20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c throw new SQL
8250: 69 74 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 iteException(n,
8260: 6e 75 6c 6c 29 3b 0d 0a 20 20 20 20 20 20 20 20 null);..
8270: 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 }.... if
8280: 28 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f (n == SQLiteErro
8290: 72 43 6f 64 65 2e 49 6e 74 65 72 72 75 70 74 29 rCode.Interrupt)
82a0: 20 72 65 74 75 72 6e 20 66 61 6c 73 65 3b 0d 0a return false;..
82b0: 20 20 20 20 20 20 20 20 69 66 20 28 6e 20 3d 3d if (n ==
82c0: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
82d0: 2e 52 6f 77 29 20 72 65 74 75 72 6e 20 74 72 75 .Row) return tru
82e0: 65 3b 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 e;.. if (
82f0: 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 n == SQLiteError
8300: 43 6f 64 65 2e 44 6f 6e 65 29 20 72 65 74 75 72 Code.Done) retur
8310: 6e 20 66 61 6c 73 65 3b 0d 0a 0d 0a 20 20 20 20 n false;....
8320: 20 20 20 20 69 66 20 28 6e 20 21 3d 20 53 51 4c if (n != SQL
8330: 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 iteErrorCode.Ok)
8340: 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 .. {..
8350: 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 SQLiteErr
8360: 6f 72 43 6f 64 65 20 72 3b 0d 0a 0d 0a 20 20 20 orCode r;....
8370: 20 20 20 20 20 20 20 2f 2f 20 41 6e 20 65 72 72 // An err
8380: 6f 72 20 6f 63 63 75 72 72 65 64 2c 20 61 74 74 or occurred, att
8390: 65 6d 70 74 20 74 6f 20 72 65 73 65 74 20 74 68 empt to reset th
83a0: 65 20 73 74 61 74 65 6d 65 6e 74 2e 20 20 49 66 e statement. If
83b0: 20 74 68 65 20 72 65 73 65 74 20 77 6f 72 6b 65 the reset worke
83c0: 64 20 62 65 63 61 75 73 65 20 74 68 65 0d 0a 20 d because the..
83d0: 20 20 20 20 20 20 20 20 20 2f 2f 20 73 63 68 65 // sche
83e0: 6d 61 20 68 61 73 20 63 68 61 6e 67 65 64 2c 20 ma has changed,
83f0: 72 65 2d 74 72 79 20 74 68 65 20 73 74 65 70 20 re-try the step
8400: 61 67 61 69 6e 2e 20 20 49 66 20 69 74 20 65 72 again. If it er
8410: 72 6f 72 65 64 20 6f 75 72 20 62 65 63 61 75 73 rored our becaus
8420: 65 20 74 68 65 20 64 61 74 61 62 61 73 65 0d 0a e the database..
8430: 20 20 20 20 20 20 20 20 20 20 2f 2f 20 69 73 20 // is
8440: 6c 6f 63 6b 65 64 2c 20 74 68 65 6e 20 6b 65 65 locked, then kee
8450: 70 20 72 65 74 72 79 69 6e 67 20 75 6e 74 69 6c p retrying until
8460: 20 74 68 65 20 63 6f 6d 6d 61 6e 64 20 74 69 6d the command tim
8470: 65 6f 75 74 20 6f 63 63 75 72 73 2e 0d 0a 20 20 eout occurs...
8480: 20 20 20 20 20 20 20 20 72 20 3d 20 52 65 73 65 r = Rese
8490: 74 28 73 74 6d 74 29 3b 0d 0a 0d 0a 20 20 20 20 t(stmt);....
84a0: 20 20 20 20 20 20 69 66 20 28 72 20 3d 3d 20 53 if (r == S
84b0: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f QLiteErrorCode.O
84c0: 6b 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 k)..
84d0: 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 throw new SQLite
84e0: 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 Exception(n, Get
84f0: 4c 61 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a 0d LastError());...
8500: 0a 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 20 . else
8510: 69 66 20 28 28 72 20 3d 3d 20 53 51 4c 69 74 65 if ((r == SQLite
8520: 45 72 72 6f 72 43 6f 64 65 2e 4c 6f 63 6b 65 64 ErrorCode.Locked
8530: 20 7c 7c 20 72 20 3d 3d 20 53 51 4c 69 74 65 45 || r == SQLiteE
8540: 72 72 6f 72 43 6f 64 65 2e 42 75 73 79 29 20 26 rrorCode.Busy) &
8550: 26 20 73 74 6d 74 2e 5f 63 6f 6d 6d 61 6e 64 20 & stmt._command
8560: 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 != null)..
8570: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
8580: 20 20 20 2f 2f 20 4b 65 65 70 20 74 72 79 69 6e // Keep tryin
8590: 67 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 g.. i
85a0: 66 20 28 72 6e 64 20 3d 3d 20 6e 75 6c 6c 29 20 f (rnd == null)
85b0: 2f 2f 20 46 69 72 73 74 20 74 69 6d 65 20 77 65 // First time we
85c0: 27 76 65 20 65 6e 63 6f 75 6e 74 65 72 65 64 20 've encountered
85d0: 74 68 65 20 6c 6f 63 6b 0d 0a 20 20 20 20 20 20 the lock..
85e0: 20 20 20 20 20 20 20 20 72 6e 64 20 3d 20 6e 65 rnd = ne
85f0: 77 20 52 61 6e 64 6f 6d 28 29 3b 0d 0a 0d 0a 20 w Random();....
8600: 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 66 // If
8610: 20 77 65 27 76 65 20 65 78 63 65 65 64 65 64 20 we've exceeded
8620: 74 68 65 20 63 6f 6d 6d 61 6e 64 27 73 20 74 69 the command's ti
8630: 6d 65 6f 75 74 2c 20 67 69 76 65 20 75 70 20 61 meout, give up a
8640: 6e 64 20 74 68 72 6f 77 20 61 6e 20 65 72 72 6f nd throw an erro
8650: 72 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 r.. i
8660: 66 20 28 28 75 69 6e 74 29 45 6e 76 69 72 6f 6e f ((uint)Environ
8670: 6d 65 6e 74 2e 54 69 63 6b 43 6f 75 6e 74 20 2d ment.TickCount -
8680: 20 73 74 61 72 74 74 69 63 6b 20 3e 20 74 69 6d starttick > tim
8690: 65 6f 75 74 29 0d 0a 20 20 20 20 20 20 20 20 20 eout)..
86a0: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
86b0: 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 51 throw new SQ
86c0: 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 72 2c LiteException(r,
86d0: 20 47 65 74 4c 61 73 74 45 72 72 6f 72 28 29 29 GetLastError())
86e0: 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d ;.. }
86f0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 6c .. el
8700: 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 se..
8710: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 {..
8720: 20 2f 2f 20 4f 74 68 65 72 77 69 73 65 20 73 6c // Otherwise sl
8730: 65 65 70 20 66 6f 72 20 61 20 72 61 6e 64 6f 6d eep for a random
8740: 20 61 6d 6f 75 6e 74 20 6f 66 20 74 69 6d 65 20 amount of time
8750: 75 70 20 74 6f 20 31 35 30 6d 73 0d 0a 20 20 20 up to 150ms..
8760: 20 20 20 20 20 20 20 20 20 20 20 53 79 73 74 65 Syste
8770: 6d 2e 54 68 72 65 61 64 69 6e 67 2e 54 68 72 65 m.Threading.Thre
8780: 61 64 2e 53 6c 65 65 70 28 72 6e 64 2e 4e 65 78 ad.Sleep(rnd.Nex
8790: 74 28 31 2c 20 31 35 30 29 29 3b 0d 0a 20 20 20 t(1, 150));..
87a0: 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 }..
87b0: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
87c0: 20 7d 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 }.. }..
87d0: 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 }.... /// <s
87e0: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
87f0: 20 48 61 73 20 74 68 65 20 73 71 6c 69 74 65 33 Has the sqlite3
8800: 5f 65 72 72 73 74 72 28 29 20 63 6f 72 65 20 6c _errstr() core l
8810: 69 62 72 61 72 79 20 41 50 49 20 62 65 65 6e 20 ibrary API been
8820: 63 68 65 63 6b 65 64 20 66 6f 72 20 79 65 74 3f checked for yet?
8830: 0d 0a 20 20 20 20 2f 2f 2f 20 49 66 20 73 6f 2c .. /// If so,
8840: 20 69 73 20 69 74 20 70 72 65 73 65 6e 74 3f 0d is it present?.
8850: 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 . /// </summa
8860: 72 79 3e 0d 0a 20 20 20 20 70 72 69 76 61 74 65 ry>.. private
8870: 20 73 74 61 74 69 63 20 62 6f 6f 6c 3f 20 68 61 static bool? ha
8880: 76 65 5f 65 72 72 73 74 72 20 3d 20 6e 75 6c 6c ve_errstr = null
8890: 3b 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 ;.... /// <su
88a0: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
88b0: 52 65 74 75 72 6e 73 20 74 68 65 20 65 72 72 6f Returns the erro
88c0: 72 20 6d 65 73 73 61 67 65 20 66 6f 72 20 74 68 r message for th
88d0: 65 20 73 70 65 63 69 66 69 65 64 20 53 51 4c 69 e specified SQLi
88e0: 74 65 20 72 65 74 75 72 6e 20 63 6f 64 65 20 75 te return code u
88f0: 73 69 6e 67 0d 0a 20 20 20 20 2f 2f 2f 20 74 68 sing.. /// th
8900: 65 20 73 71 6c 69 74 65 33 5f 65 72 72 73 74 72 e sqlite3_errstr
8910: 28 29 20 66 75 6e 63 74 69 6f 6e 2c 20 66 61 6c () function, fal
8920: 6c 69 6e 67 20 62 61 63 6b 20 74 6f 20 74 68 65 ling back to the
8930: 20 69 6e 74 65 72 6e 61 6c 20 6c 6f 6f 6b 75 70 internal lookup
8940: 0d 0a 20 20 20 20 2f 2f 2f 20 74 61 62 6c 65 20 .. /// table
8950: 69 66 20 6e 65 63 65 73 73 61 72 79 2e 0d 0a 20 if necessary...
8960: 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 /// </summary
8970: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 >.. /// <para
8980: 6d 20 6e 61 6d 65 3d 22 72 63 22 3e 54 68 65 20 m name="rc">The
8990: 53 51 4c 69 74 65 20 72 65 74 75 72 6e 20 63 6f SQLite return co
89a0: 64 65 2e 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 de.</param>..
89b0: 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 54 68 /// <returns>Th
89c0: 65 20 65 72 72 6f 72 20 6d 65 73 73 61 67 65 20 e error message
89d0: 6f 72 20 6e 75 6c 6c 20 69 66 20 69 74 20 63 61 or null if it ca
89e0: 6e 6e 6f 74 20 62 65 20 66 6f 75 6e 64 2e 3c 2f nnot be found.</
89f0: 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 69 6e returns>.. in
8a00: 74 65 72 6e 61 6c 20 73 74 61 74 69 63 20 73 74 ternal static st
8a10: 72 69 6e 67 20 47 65 74 45 72 72 6f 72 53 74 72 ring GetErrorStr
8a20: 69 6e 67 28 53 51 4c 69 74 65 45 72 72 6f 72 43 ing(SQLiteErrorC
8a30: 6f 64 65 20 72 63 29 0d 0a 20 20 20 20 7b 0d 0a ode rc).. {..
8a40: 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 try..
8a50: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
8a60: 20 20 20 20 69 66 20 28 68 61 76 65 5f 65 72 72 if (have_err
8a70: 73 74 72 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 str == null)..
8a80: 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
8a90: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 6e 74 int
8aa0: 20 76 65 72 73 69 6f 6e 4e 75 6d 62 65 72 20 3d versionNumber =
8ab0: 20 53 51 4c 69 74 65 56 65 72 73 69 6f 6e 4e 75 SQLiteVersionNu
8ac0: 6d 62 65 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 mber;..
8ad0: 20 20 20 20 20 20 20 68 61 76 65 5f 65 72 72 73 have_errs
8ae0: 74 72 20 3d 20 28 76 65 72 73 69 6f 6e 4e 75 6d tr = (versionNum
8af0: 62 65 72 20 3e 3d 20 33 30 30 37 30 31 35 29 3b ber >= 3007015);
8b00: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d .. }.
8b10: 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 ... i
8b20: 66 20 28 28 62 6f 6f 6c 29 68 61 76 65 5f 65 72 f ((bool)have_er
8b30: 72 73 74 72 29 0d 0a 20 20 20 20 20 20 20 20 20 rstr)..
8b40: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
8b50: 20 20 20 20 20 20 49 6e 74 50 74 72 20 70 74 72 IntPtr ptr
8b60: 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d = UnsafeNativeM
8b70: 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 65 ethods.sqlite3_e
8b80: 72 72 73 74 72 28 72 63 29 3b 0d 0a 0d 0a 20 20 rrstr(rc);....
8b90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 if
8ba0: 20 28 70 74 72 20 21 3d 20 49 6e 74 50 74 72 2e (ptr != IntPtr.
8bb0: 5a 65 72 6f 29 0d 0a 20 20 20 20 20 20 20 20 20 Zero)..
8bc0: 20 20 20 20 20 20 20 7b 0d 0a 23 69 66 20 21 50 {..#if !P
8bd0: 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 LATFORM_COMPACTF
8be0: 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 20 20 RAMEWORK..
8bf0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 re
8c00: 74 75 72 6e 20 4d 61 72 73 68 61 6c 2e 50 74 72 turn Marshal.Ptr
8c10: 54 6f 53 74 72 69 6e 67 41 6e 73 69 28 70 74 72 ToStringAnsi(ptr
8c20: 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 );..#else..
8c30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 r
8c40: 65 74 75 72 6e 20 55 54 46 38 54 6f 53 74 72 69 eturn UTF8ToStri
8c50: 6e 67 28 70 74 72 2c 20 2d 31 29 3b 0d 0a 23 65 ng(ptr, -1);..#e
8c60: 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 ndif..
8c70: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
8c80: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
8c90: 7d 0d 0a 20 20 20 20 20 20 20 20 63 61 74 63 68 }.. catch
8ca0: 20 28 45 6e 74 72 79 50 6f 69 6e 74 4e 6f 74 46 (EntryPointNotF
8cb0: 6f 75 6e 64 45 78 63 65 70 74 69 6f 6e 29 0d 0a oundException)..
8cc0: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
8cd0: 20 20 20 20 20 20 20 2f 2f 20 64 6f 20 6e 6f 74 // do not
8ce0: 68 69 6e 67 2e 0d 0a 20 20 20 20 20 20 20 20 7d hing... }
8cf0: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 .... retu
8d00: 72 6e 20 46 61 6c 6c 62 61 63 6b 47 65 74 45 72 rn FallbackGetEr
8d10: 72 6f 72 53 74 72 69 6e 67 28 72 63 29 3b 0d 0a rorString(rc);..
8d20: 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f }.... ///
8d30: 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 <summary>..
8d40: 2f 2f 2f 20 48 61 73 20 74 68 65 20 73 71 6c 69 /// Has the sqli
8d50: 74 65 33 5f 73 74 6d 74 5f 72 65 61 64 6f 6e 6c te3_stmt_readonl
8d60: 79 28 29 20 63 6f 72 65 20 6c 69 62 72 61 72 79 y() core library
8d70: 20 41 50 49 20 62 65 65 6e 20 63 68 65 63 6b 65 API been checke
8d80: 64 20 66 6f 72 20 79 65 74 3f 0d 0a 20 20 20 20 d for yet?..
8d90: 2f 2f 2f 20 49 66 20 73 6f 2c 20 69 73 20 69 74 /// If so, is it
8da0: 20 70 72 65 73 65 6e 74 3f 0d 0a 20 20 20 20 2f present?.. /
8db0: 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 // </summary>..
8dc0: 20 20 20 70 72 69 76 61 74 65 20 73 74 61 74 69 private stati
8dd0: 63 20 62 6f 6f 6c 3f 20 68 61 76 65 5f 73 74 6d c bool? have_stm
8de0: 74 5f 72 65 61 64 6f 6e 6c 79 20 3d 20 6e 75 6c t_readonly = nul
8df0: 6c 3b 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 l;.... /// <s
8e00: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
8e10: 20 52 65 74 75 72 6e 73 20 6e 6f 6e 2d 7a 65 72 Returns non-zer
8e20: 6f 20 69 66 20 74 68 65 20 73 70 65 63 69 66 69 o if the specifi
8e30: 65 64 20 73 74 61 74 65 6d 65 6e 74 20 69 73 20 ed statement is
8e40: 72 65 61 64 2d 6f 6e 6c 79 20 69 6e 20 6e 61 74 read-only in nat
8e50: 75 72 65 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ure... /// </
8e60: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
8e70: 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 73 / <param name="s
8e80: 74 6d 74 22 3e 54 68 65 20 73 74 61 74 65 6d 65 tmt">The stateme
8e90: 6e 74 20 74 6f 20 63 68 65 63 6b 2e 3c 2f 70 61 nt to check.</pa
8ea0: 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 ram>.. /// <r
8eb0: 65 74 75 72 6e 73 3e 54 72 75 65 20 69 66 20 74 eturns>True if t
8ec0: 68 65 20 6f 75 74 65 72 20 71 75 65 72 79 20 69 he outer query i
8ed0: 73 20 72 65 61 64 2d 6f 6e 6c 79 2e 3c 2f 72 65 s read-only.</re
8ee0: 74 75 72 6e 73 3e 0d 0a 20 20 20 20 69 6e 74 65 turns>.. inte
8ef0: 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 62 6f rnal override bo
8f00: 6f 6c 20 49 73 52 65 61 64 4f 6e 6c 79 28 0d 0a ol IsReadOnly(..
8f10: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 53 74 SQLiteSt
8f20: 61 74 65 6d 65 6e 74 20 73 74 6d 74 0d 0a 20 20 atement stmt..
8f30: 20 20 20 20 20 20 29 0d 0a 20 20 20 20 7b 0d 0a ).. {..
8f40: 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 try..
8f50: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
8f60: 20 20 20 20 69 66 20 28 68 61 76 65 5f 73 74 6d if (have_stm
8f70: 74 5f 72 65 61 64 6f 6e 6c 79 20 3d 3d 20 6e 75 t_readonly == nu
8f80: 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ll)..
8f90: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
8fa0: 20 20 20 20 69 6e 74 20 76 65 72 73 69 6f 6e 4e int versionN
8fb0: 75 6d 62 65 72 20 3d 20 53 51 4c 69 74 65 56 65 umber = SQLiteVe
8fc0: 72 73 69 6f 6e 4e 75 6d 62 65 72 3b 0d 0a 20 20 rsionNumber;..
8fd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 68 61 ha
8fe0: 76 65 5f 73 74 6d 74 5f 72 65 61 64 6f 6e 6c 79 ve_stmt_readonly
8ff0: 20 3d 20 28 76 65 72 73 69 6f 6e 4e 75 6d 62 65 = (versionNumbe
9000: 72 20 3e 3d 20 33 30 30 37 30 30 34 29 3b 0d 0a r >= 3007004);..
9010: 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d }...
9020: 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 . if
9030: 28 28 62 6f 6f 6c 29 68 61 76 65 5f 73 74 6d 74 ((bool)have_stmt
9040: 5f 72 65 61 64 6f 6e 6c 79 29 0d 0a 20 20 20 20 _readonly)..
9050: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
9060: 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 retur
9070: 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 n UnsafeNativeMe
9080: 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 73 74 thods.sqlite3_st
9090: 6d 74 5f 72 65 61 64 6f 6e 6c 79 28 0d 0a 20 20 mt_readonly(..
90a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
90b0: 20 20 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 stmt._sqlite_s
90c0: 74 6d 74 29 20 21 3d 20 30 3b 0d 0a 20 20 20 20 tmt) != 0;..
90d0: 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
90e0: 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 63 61 }.. ca
90f0: 74 63 68 20 28 45 6e 74 72 79 50 6f 69 6e 74 4e tch (EntryPointN
9100: 6f 74 46 6f 75 6e 64 45 78 63 65 70 74 69 6f 6e otFoundException
9110: 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 ).. {..
9120: 20 20 20 20 20 20 20 20 20 20 2f 2f 20 64 6f 20 // do
9130: 6e 6f 74 68 69 6e 67 2e 0d 0a 20 20 20 20 20 20 nothing...
9140: 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 72 }.... r
9150: 65 74 75 72 6e 20 66 61 6c 73 65 3b 20 2f 2a 20 eturn false; /*
9160: 4e 4f 54 45 3a 20 55 6e 6b 6e 6f 77 6e 2c 20 61 NOTE: Unknown, a
9170: 73 73 75 6d 65 20 66 61 6c 73 65 2e 20 2a 2f 0d ssume false. */.
9180: 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
9190: 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
91a0: 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 SQLiteErrorCode
91b0: 52 65 73 65 74 28 53 51 4c 69 74 65 53 74 61 74 Reset(SQLiteStat
91c0: 65 6d 65 6e 74 20 73 74 6d 74 29 0d 0a 20 20 20 ement stmt)..
91d0: 20 7b 0d 0a 20 20 20 20 20 20 53 51 4c 69 74 65 {.. SQLite
91e0: 45 72 72 6f 72 43 6f 64 65 20 6e 3b 0d 0a 0d 0a ErrorCode n;....
91f0: 23 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e #if !SQLITE_STAN
9200: 44 41 52 44 0d 0a 20 20 20 20 20 20 6e 20 3d 20 DARD.. n =
9210: 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
9220: 6f 64 73 2e 73 71 6c 69 74 65 33 5f 72 65 73 65 ods.sqlite3_rese
9230: 74 5f 69 6e 74 65 72 6f 70 28 73 74 6d 74 2e 5f t_interop(stmt._
9240: 73 71 6c 69 74 65 5f 73 74 6d 74 29 3b 0d 0a 23 sqlite_stmt);..#
9250: 65 6c 73 65 0d 0a 20 20 20 20 20 20 6e 20 3d 20 else.. n =
9260: 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
9270: 6f 64 73 2e 73 71 6c 69 74 65 33 5f 72 65 73 65 ods.sqlite3_rese
9280: 74 28 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 t(stmt._sqlite_s
9290: 74 6d 74 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 0d tmt);..#endif...
92a0: 0a 20 20 20 20 20 20 2f 2f 20 49 66 20 74 68 65 . // If the
92b0: 20 73 63 68 65 6d 61 20 63 68 61 6e 67 65 64 2c schema changed,
92c0: 20 74 72 79 20 61 6e 64 20 72 65 2d 70 72 65 70 try and re-prep
92d0: 61 72 65 20 69 74 0d 0a 20 20 20 20 20 20 69 66 are it.. if
92e0: 20 28 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 (n == SQLiteErr
92f0: 6f 72 43 6f 64 65 2e 53 63 68 65 6d 61 29 0d 0a orCode.Schema)..
9300: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
9310: 20 2f 2f 20 52 65 63 72 65 61 74 65 20 61 20 64 // Recreate a d
9320: 75 6d 6d 79 20 73 74 61 74 65 6d 65 6e 74 0d 0a ummy statement..
9330: 20 20 20 20 20 20 20 20 73 74 72 69 6e 67 20 73 string s
9340: 74 72 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 tr = null;..
9350: 20 20 20 20 75 73 69 6e 67 20 28 53 51 4c 69 74 using (SQLit
9360: 65 53 74 61 74 65 6d 65 6e 74 20 74 6d 70 20 3d eStatement tmp =
9370: 20 50 72 65 70 61 72 65 28 6e 75 6c 6c 2c 20 73 Prepare(null, s
9380: 74 6d 74 2e 5f 73 71 6c 53 74 61 74 65 6d 65 6e tmt._sqlStatemen
9390: 74 2c 20 6e 75 6c 6c 2c 20 28 75 69 6e 74 29 28 t, null, (uint)(
93a0: 73 74 6d 74 2e 5f 63 6f 6d 6d 61 6e 64 2e 5f 63 stmt._command._c
93b0: 6f 6d 6d 61 6e 64 54 69 6d 65 6f 75 74 20 2a 20 ommandTimeout *
93c0: 31 30 30 30 29 2c 20 72 65 66 20 73 74 72 29 29 1000), ref str))
93d0: 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 .. {..
93e0: 20 20 20 20 20 20 20 2f 2f 20 46 69 6e 61 6c 69 // Finali
93f0: 7a 65 20 74 68 65 20 65 78 69 73 74 69 6e 67 20 ze the existing
9400: 73 74 61 74 65 6d 65 6e 74 0d 0a 20 20 20 20 20 statement..
9410: 20 20 20 20 20 73 74 6d 74 2e 5f 73 71 6c 69 74 stmt._sqlit
9420: 65 5f 73 74 6d 74 2e 44 69 73 70 6f 73 65 28 29 e_stmt.Dispose()
9430: 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 2f 2f 20 ;.. //
9440: 52 65 61 73 73 69 67 6e 20 61 20 6e 65 77 20 73 Reassign a new s
9450: 74 61 74 65 6d 65 6e 74 20 70 6f 69 6e 74 65 72 tatement pointer
9460: 20 74 6f 20 74 68 65 20 6f 6c 64 20 73 74 61 74 to the old stat
9470: 65 6d 65 6e 74 20 61 6e 64 20 63 6c 65 61 72 20 ement and clear
9480: 74 68 65 20 74 65 6d 70 6f 72 61 72 79 20 6f 6e the temporary on
9490: 65 0d 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 e.. if
94a0: 28 74 6d 70 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 (tmp != null)..
94b0: 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 {..
94c0: 20 20 20 20 20 20 20 20 73 74 6d 74 2e 5f 73 71 stmt._sq
94d0: 6c 69 74 65 5f 73 74 6d 74 20 3d 20 74 6d 70 2e lite_stmt = tmp.
94e0: 5f 73 71 6c 69 74 65 5f 73 74 6d 74 3b 0d 0a 20 _sqlite_stmt;..
94f0: 20 20 20 20 20 20 20 20 20 20 20 74 6d 70 2e 5f tmp._
9500: 73 71 6c 69 74 65 5f 73 74 6d 74 20 3d 20 6e 75 sqlite_stmt = nu
9510: 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 7d ll;.. }
9520: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 2f 2f .... //
9530: 20 52 65 61 70 70 6c 79 20 70 61 72 61 6d 65 74 Reapply paramet
9540: 65 72 73 0d 0a 20 20 20 20 20 20 20 20 20 20 73 ers.. s
9550: 74 6d 74 2e 42 69 6e 64 50 61 72 61 6d 65 74 65 tmt.BindParamete
9560: 72 73 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d rs();.. }
9570: 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e .. return
9580: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
9590: 2e 55 6e 6b 6e 6f 77 6e 3b 20 2f 2f 20 52 65 73 .Unknown; // Res
95a0: 65 74 20 77 61 73 20 4f 4b 2c 20 77 69 74 68 20 et was OK, with
95b0: 73 63 68 65 6d 61 20 63 68 61 6e 67 65 0d 0a 20 schema change..
95c0: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 65 6c }.. el
95d0: 73 65 20 69 66 20 28 6e 20 3d 3d 20 53 51 4c 69 se if (n == SQLi
95e0: 74 65 45 72 72 6f 72 43 6f 64 65 2e 4c 6f 63 6b teErrorCode.Lock
95f0: 65 64 20 7c 7c 20 6e 20 3d 3d 20 53 51 4c 69 74 ed || n == SQLit
9600: 65 45 72 72 6f 72 43 6f 64 65 2e 42 75 73 79 29 eErrorCode.Busy)
9610: 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e .. return
9620: 20 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 69 66 20 n;.... if
9630: 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f (n != SQLiteErro
9640: 72 43 6f 64 65 2e 4f 6b 29 0d 0a 20 20 20 20 20 rCode.Ok)..
9650: 20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c throw new SQL
9660: 69 74 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 iteException(n,
9670: 47 65 74 4c 61 73 74 45 72 72 6f 72 28 29 29 3b GetLastError());
9680: 0d 0a 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e .... return
9690: 20 6e 3b 20 2f 2f 20 57 65 20 72 65 73 65 74 20 n; // We reset
96a0: 4f 4b 2c 20 6e 6f 20 73 63 68 65 6d 61 20 63 68 OK, no schema ch
96b0: 61 6e 67 65 73 0d 0a 20 20 20 20 7d 0d 0a 0d 0a anges.. }....
96c0: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
96d0: 72 72 69 64 65 20 73 74 72 69 6e 67 20 47 65 74 rride string Get
96e0: 4c 61 73 74 45 72 72 6f 72 28 29 0d 0a 20 20 20 LastError()..
96f0: 20 7b 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 {.. retu
9700: 72 6e 20 47 65 74 4c 61 73 74 45 72 72 6f 72 28 rn GetLastError(
9710: 6e 75 6c 6c 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d null);.. }...
9720: 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
9730: 65 72 72 69 64 65 20 73 74 72 69 6e 67 20 47 65 erride string Ge
9740: 74 4c 61 73 74 45 72 72 6f 72 28 73 74 72 69 6e tLastError(strin
9750: 67 20 64 65 66 56 61 6c 75 65 29 0d 0a 20 20 20 g defValue)..
9760: 20 7b 0d 0a 20 20 20 20 20 20 20 20 73 74 72 69 {.. stri
9770: 6e 67 20 72 65 73 75 6c 74 20 3d 20 53 51 4c 69 ng result = SQLi
9780: 74 65 42 61 73 65 2e 47 65 74 4c 61 73 74 45 72 teBase.GetLastEr
9790: 72 6f 72 28 5f 73 71 6c 2c 20 5f 73 71 6c 29 3b ror(_sql, _sql);
97a0: 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 53 74 .. if (St
97b0: 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 ring.IsNullOrEmp
97c0: 74 79 28 72 65 73 75 6c 74 29 29 20 72 65 73 75 ty(result)) resu
97d0: 6c 74 20 3d 20 64 65 66 56 61 6c 75 65 3b 0d 0a lt = defValue;..
97e0: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 72 return r
97f0: 65 73 75 6c 74 3b 0d 0a 20 20 20 20 7d 0d 0a 0d esult;.. }...
9800: 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f . ///////////
9810: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9820: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9830: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9840: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9850: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9860: 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 23 72 65 67 ////.... #reg
9870: 69 6f 6e 20 51 75 65 72 79 20 44 69 61 67 6e 6f ion Query Diagno
9880: 73 74 69 63 73 20 53 75 70 70 6f 72 74 0d 0a 23 stics Support..#
9890: 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d if !PLATFORM_COM
98a0: 50 41 43 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 PACTFRAMEWORK..
98b0: 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
98c0: 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 69 73 20 66 .. /// This f
98d0: 69 65 6c 64 20 69 73 20 75 73 65 64 20 74 6f 20 ield is used to
98e0: 6b 65 65 70 20 74 72 61 63 6b 20 6f 66 20 77 68 keep track of wh
98f0: 65 74 68 65 72 20 6f 72 20 6e 6f 74 20 74 68 65 ether or not the
9900: 0d 0a 20 20 20 20 2f 2f 2f 20 22 53 51 4c 69 74 .. /// "SQLit
9910: 65 5f 46 6f 72 63 65 4c 6f 67 50 72 65 70 61 72 e_ForceLogPrepar
9920: 65 22 20 65 6e 76 69 72 6f 6e 6d 65 6e 74 20 76 e" environment v
9930: 61 72 69 61 62 6c 65 20 68 61 73 20 62 65 65 6e ariable has been
9940: 20 71 75 65 72 69 65 64 2e 20 20 49 66 20 73 6f queried. If so
9950: 2c 0d 0a 20 20 20 20 2f 2f 2f 20 69 74 20 77 69 ,.. /// it wi
9960: 6c 6c 20 6f 6e 6c 79 20 62 65 20 6e 6f 6e 2d 7a ll only be non-z
9970: 65 72 6f 20 69 66 20 74 68 65 20 65 6e 76 69 72 ero if the envir
9980: 6f 6e 6d 65 6e 74 20 76 61 72 69 61 62 6c 65 20 onment variable
9990: 77 61 73 20 70 72 65 73 65 6e 74 2e 0d 0a 20 20 was present...
99a0: 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e /// </summary>
99b0: 0d 0a 20 20 20 20 70 72 69 76 61 74 65 20 73 74 .. private st
99c0: 61 74 69 63 20 62 6f 6f 6c 3f 20 66 6f 72 63 65 atic bool? force
99d0: 4c 6f 67 50 72 65 70 61 72 65 20 3d 20 6e 75 6c LogPrepare = nul
99e0: 6c 3b 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f l;.... //////
99f0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9a00: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9a10: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9a20: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9a30: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9a40: 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 /////////....
9a50: 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
9a60: 20 20 20 20 2f 2f 2f 20 44 65 74 65 72 6d 69 6e /// Determin
9a70: 65 73 20 69 66 20 61 6c 6c 20 63 61 6c 6c 73 20 es if all calls
9a80: 74 6f 20 70 72 65 70 61 72 65 20 61 20 53 51 4c to prepare a SQL
9a90: 20 71 75 65 72 79 20 77 69 6c 6c 20 62 65 20 6c query will be l
9aa0: 6f 67 67 65 64 2c 0d 0a 20 20 20 20 2f 2f 2f 20 ogged,.. ///
9ab0: 72 65 67 61 72 64 6c 65 73 73 20 6f 66 20 74 68 regardless of th
9ac0: 65 20 66 6c 61 67 73 20 66 6f 72 20 74 68 65 20 e flags for the
9ad0: 61 73 73 6f 63 69 61 74 65 64 20 63 6f 6e 6e 65 associated conne
9ae0: 63 74 69 6f 6e 2e 0d 0a 20 20 20 20 2f 2f 2f 20 ction... ///
9af0: 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 </summary>..
9b00: 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 0d 0a 20 /// <returns>..
9b10: 20 20 20 2f 2f 2f 20 4e 6f 6e 2d 7a 65 72 6f 20 /// Non-zero
9b20: 74 6f 20 6c 6f 67 20 61 6c 6c 20 63 61 6c 6c 73 to log all calls
9b30: 20 74 6f 20 70 72 65 70 61 72 65 20 61 20 53 51 to prepare a SQ
9b40: 4c 20 71 75 65 72 79 2e 0d 0a 20 20 20 20 2f 2f L query... //
9b50: 2f 20 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 / </returns>..
9b60: 20 20 70 72 69 76 61 74 65 20 73 74 61 74 69 63 private static
9b70: 20 62 6f 6f 6c 20 46 6f 72 63 65 4c 6f 67 50 72 bool ForceLogPr
9b80: 65 70 61 72 65 28 29 0d 0a 20 20 20 20 7b 0d 0a epare().. {..
9b90: 20 20 20 20 20 20 20 20 6c 6f 63 6b 20 28 73 79 lock (sy
9ba0: 6e 63 52 6f 6f 74 29 0d 0a 20 20 20 20 20 20 20 ncRoot)..
9bb0: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
9bc0: 69 66 20 28 66 6f 72 63 65 4c 6f 67 50 72 65 70 if (forceLogPrep
9bd0: 61 72 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 are == null)..
9be0: 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
9bf0: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 if
9c00: 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 (UnsafeNativeMet
9c10: 68 6f 64 73 2e 47 65 74 53 65 74 74 69 6e 67 56 hods.GetSettingV
9c20: 61 6c 75 65 28 0d 0a 20 20 20 20 20 20 20 20 20 alue(..
9c30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 "
9c40: 53 51 4c 69 74 65 5f 46 6f 72 63 65 4c 6f 67 50 SQLite_ForceLogP
9c50: 72 65 70 61 72 65 22 2c 20 6e 75 6c 6c 29 20 21 repare", null) !
9c60: 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 = null)..
9c70: 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 {..
9c80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
9c90: 66 6f 72 63 65 4c 6f 67 50 72 65 70 61 72 65 20 forceLogPrepare
9ca0: 3d 20 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 = true;..
9cb0: 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 }..
9cc0: 20 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 else
9cd0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
9ce0: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
9cf0: 20 20 20 20 20 20 20 20 20 66 6f 72 63 65 4c 6f forceLo
9d00: 67 50 72 65 70 61 72 65 20 3d 20 66 61 6c 73 65 gPrepare = false
9d10: 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ;..
9d20: 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 }..
9d30: 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 }....
9d40: 20 20 20 72 65 74 75 72 6e 20 28 62 6f 6f 6c 29 return (bool)
9d50: 66 6f 72 63 65 4c 6f 67 50 72 65 70 61 72 65 3b forceLogPrepare;
9d60: 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 .. }..
9d70: 20 7d 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 }..#endif..
9d80: 23 65 6e 64 72 65 67 69 6f 6e 0d 0a 0d 0a 20 20 #endregion....
9d90: 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f //////////////
9da0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9db0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9dc0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9dd0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9de0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
9df0: 2f 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 /.... interna
9e00: 6c 20 6f 76 65 72 72 69 64 65 20 53 51 4c 69 74 l override SQLit
9e10: 65 53 74 61 74 65 6d 65 6e 74 20 50 72 65 70 61 eStatement Prepa
9e20: 72 65 28 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 re(SQLiteConnect
9e30: 69 6f 6e 20 63 6e 6e 2c 20 73 74 72 69 6e 67 20 ion cnn, string
9e40: 73 74 72 53 71 6c 2c 20 53 51 4c 69 74 65 53 74 strSql, SQLiteSt
9e50: 61 74 65 6d 65 6e 74 20 70 72 65 76 69 6f 75 73 atement previous
9e60: 2c 20 75 69 6e 74 20 74 69 6d 65 6f 75 74 4d 53 , uint timeoutMS
9e70: 2c 20 72 65 66 20 73 74 72 69 6e 67 20 73 74 72 , ref string str
9e80: 52 65 6d 61 69 6e 29 0d 0a 20 20 20 20 7b 0d 0a Remain).. {..
9e90: 20 20 20 20 20 20 69 66 20 28 21 53 74 72 69 6e if (!Strin
9ea0: 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 g.IsNullOrEmpty(
9eb0: 73 74 72 53 71 6c 29 29 20 73 74 72 53 71 6c 20 strSql)) strSql
9ec0: 3d 20 73 74 72 53 71 6c 2e 54 72 69 6d 28 29 3b = strSql.Trim();
9ed0: 0d 0a 20 20 20 20 20 20 69 66 20 28 21 53 74 72 .. if (!Str
9ee0: 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 ing.IsNullOrEmpt
9ef0: 79 28 73 74 72 53 71 6c 29 29 0d 0a 20 20 20 20 y(strSql))..
9f00: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 2f 2f 0d {.. //.
9f10: 0a 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 . // NOTE
9f20: 3a 20 53 51 4c 69 74 65 20 64 6f 65 73 20 6e 6f : SQLite does no
9f30: 74 20 73 75 70 70 6f 72 74 20 74 68 65 20 63 6f t support the co
9f40: 6e 63 65 70 74 20 6f 66 20 73 65 70 61 72 61 74 ncept of separat
9f50: 65 20 73 63 68 65 6d 61 73 0d 0a 20 20 20 20 20 e schemas..
9f60: 20 20 20 2f 2f 20 20 20 20 20 20 20 69 6e 20 6f // in o
9f70: 6e 65 20 64 61 74 61 62 61 73 65 3b 20 74 68 65 ne database; the
9f80: 72 65 66 6f 72 65 2c 20 72 65 6d 6f 76 65 20 74 refore, remove t
9f90: 68 65 20 62 61 73 65 20 73 63 68 65 6d 61 20 6e he base schema n
9fa0: 61 6d 65 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 ame.. //
9fb0: 20 20 20 20 20 20 75 73 65 64 20 74 6f 20 73 6d used to sm
9fc0: 6f 6f 74 68 20 69 6e 74 65 67 72 61 74 69 6f 6e ooth integration
9fd0: 20 77 69 74 68 20 74 68 65 20 62 61 73 65 20 2e with the base .
9fe0: 4e 45 54 20 46 72 61 6d 65 77 6f 72 6b 0d 0a 20 NET Framework..
9ff0: 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 //
a000: 64 61 74 61 20 63 6c 61 73 73 65 73 2e 0d 0a 20 data classes...
a010: 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 //..
a020: 20 20 20 73 74 72 69 6e 67 20 62 61 73 65 53 63 string baseSc
a030: 68 65 6d 61 4e 61 6d 65 20 3d 20 28 63 6e 6e 20 hemaName = (cnn
a040: 21 3d 20 6e 75 6c 6c 29 20 3f 20 63 6e 6e 2e 5f != null) ? cnn._
a050: 62 61 73 65 53 63 68 65 6d 61 4e 61 6d 65 20 3a baseSchemaName :
a060: 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 20 20 20 20 20 null;....
a070: 20 20 69 66 20 28 21 53 74 72 69 6e 67 2e 49 73 if (!String.Is
a080: 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 62 61 73 65 NullOrEmpty(base
a090: 53 63 68 65 6d 61 4e 61 6d 65 29 29 0d 0a 20 20 SchemaName))..
a0a0: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
a0b0: 20 20 20 73 74 72 53 71 6c 20 3d 20 73 74 72 53 strSql = strS
a0c0: 71 6c 2e 52 65 70 6c 61 63 65 28 0d 0a 20 20 20 ql.Replace(..
a0d0: 20 20 20 20 20 20 20 20 20 20 20 55 6e 73 61 66 Unsaf
a0e0: 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 53 eNativeMethods.S
a0f0: 74 72 69 6e 67 46 6f 72 6d 61 74 28 43 75 6c 74 tringFormat(Cult
a100: 75 72 65 49 6e 66 6f 2e 49 6e 76 61 72 69 61 6e ureInfo.Invarian
a110: 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 tCulture,..
a120: 20 20 20 20 20 20 20 20 20 22 5b 7b 30 7d 5d 2e "[{0}].
a130: 22 2c 20 62 61 73 65 53 63 68 65 6d 61 4e 61 6d ", baseSchemaNam
a140: 65 29 2c 20 53 74 72 69 6e 67 2e 45 6d 70 74 79 e), String.Empty
a150: 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 );....
a160: 73 74 72 53 71 6c 20 3d 20 73 74 72 53 71 6c 2e strSql = strSql.
a170: 52 65 70 6c 61 63 65 28 0d 0a 20 20 20 20 20 20 Replace(..
a180: 20 20 20 20 20 20 20 20 55 6e 73 61 66 65 4e 61 UnsafeNa
a190: 74 69 76 65 4d 65 74 68 6f 64 73 2e 53 74 72 69 tiveMethods.Stri
a1a0: 6e 67 46 6f 72 6d 61 74 28 43 75 6c 74 75 72 65 ngFormat(Culture
a1b0: 49 6e 66 6f 2e 49 6e 76 61 72 69 61 6e 74 43 75 Info.InvariantCu
a1c0: 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 lture,..
a1d0: 20 20 20 20 20 20 22 7b 30 7d 2e 22 2c 20 62 61 "{0}.", ba
a1e0: 73 65 53 63 68 65 6d 61 4e 61 6d 65 29 2c 20 53 seSchemaName), S
a1f0: 74 72 69 6e 67 2e 45 6d 70 74 79 29 3b 0d 0a 20 tring.Empty);..
a200: 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 }..
a210: 7d 0d 0a 0d 0a 20 20 20 20 20 20 53 51 4c 69 74 }.... SQLit
a220: 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 eConnectionFlags
a230: 20 66 6c 61 67 73 20 3d 0d 0a 20 20 20 20 20 20 flags =..
a240: 20 20 20 20 28 63 6e 6e 20 21 3d 20 6e 75 6c 6c (cnn != null
a250: 29 20 3f 20 63 6e 6e 2e 46 6c 61 67 73 20 3a 20 ) ? cnn.Flags :
a260: 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e SQLiteConnection
a270: 46 6c 61 67 73 2e 44 65 66 61 75 6c 74 3b 0d 0a Flags.Default;..
a280: 0d 0a 20 20 20 20 20 20 69 66 20 28 0d 0a 23 69 .. if (..#i
a290: 66 20 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 f !PLATFORM_COMP
a2a0: 41 43 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 ACTFRAMEWORK..
a2b0: 20 20 20 20 20 20 20 20 46 6f 72 63 65 4c 6f 67 ForceLog
a2c0: 50 72 65 70 61 72 65 28 29 20 7c 7c 0d 0a 23 65 Prepare() ||..#e
a2d0: 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 ndif..
a2e0: 28 28 66 6c 61 67 73 20 26 20 53 51 4c 69 74 65 ((flags & SQLite
a2f0: 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e ConnectionFlags.
a300: 4c 6f 67 50 72 65 70 61 72 65 29 20 3d 3d 20 53 LogPrepare) == S
a310: 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 QLiteConnectionF
a320: 6c 61 67 73 2e 4c 6f 67 50 72 65 70 61 72 65 29 lags.LogPrepare)
a330: 29 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 ).. {..
a340: 20 20 20 20 20 20 69 66 20 28 28 73 74 72 53 71 if ((strSq
a350: 6c 20 3d 3d 20 6e 75 6c 6c 29 20 7c 7c 20 28 73 l == null) || (s
a360: 74 72 53 71 6c 2e 4c 65 6e 67 74 68 20 3d 3d 20 trSql.Length ==
a370: 30 29 20 7c 7c 20 28 73 74 72 53 71 6c 2e 54 72 0) || (strSql.Tr
a380: 69 6d 28 29 2e 4c 65 6e 67 74 68 20 3d 3d 20 30 im().Length == 0
a390: 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ))..
a3a0: 20 20 53 51 4c 69 74 65 4c 6f 67 2e 4c 6f 67 4d SQLiteLog.LogM
a3b0: 65 73 73 61 67 65 28 22 50 72 65 70 61 72 69 6e essage("Preparin
a3c0: 67 20 7b 3c 6e 6f 74 68 69 6e 67 3e 7d 2e 2e 2e g {<nothing>}...
a3d0: 22 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 65 ");.. e
a3e0: 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 lse..
a3f0: 20 20 20 53 51 4c 69 74 65 4c 6f 67 2e 4c 6f 67 SQLiteLog.Log
a400: 4d 65 73 73 61 67 65 28 55 6e 73 61 66 65 4e 61 Message(UnsafeNa
a410: 74 69 76 65 4d 65 74 68 6f 64 73 2e 53 74 72 69 tiveMethods.Stri
a420: 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 ngFormat(..
a430: 20 20 20 20 20 20 20 20 20 20 20 20 20 43 75 6c Cul
a440: 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 tureInfo.Current
a450: 43 75 6c 74 75 72 65 2c 20 22 50 72 65 70 61 72 Culture, "Prepar
a460: 69 6e 67 20 7b 7b 7b 30 7d 7d 7d 2e 2e 2e 22 2c ing {{{0}}}...",
a470: 20 73 74 72 53 71 6c 29 29 3b 0d 0a 20 20 20 20 strSql));..
a480: 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 49 6e 74 }.... Int
a490: 50 74 72 20 73 74 6d 74 20 3d 20 49 6e 74 50 74 Ptr stmt = IntPt
a4a0: 72 2e 5a 65 72 6f 3b 0d 0a 20 20 20 20 20 20 49 r.Zero;.. I
a4b0: 6e 74 50 74 72 20 70 74 72 20 3d 20 49 6e 74 50 ntPtr ptr = IntP
a4c0: 74 72 2e 5a 65 72 6f 3b 0d 0a 20 20 20 20 20 20 tr.Zero;..
a4d0: 69 6e 74 20 6c 65 6e 20 3d 20 30 3b 0d 0a 20 20 int len = 0;..
a4e0: 20 20 20 20 53 51 4c 69 74 65 45 72 72 6f 72 43 SQLiteErrorC
a4f0: 6f 64 65 20 6e 20 3d 20 53 51 4c 69 74 65 45 72 ode n = SQLiteEr
a500: 72 6f 72 43 6f 64 65 2e 53 63 68 65 6d 61 3b 0d rorCode.Schema;.
a510: 0a 20 20 20 20 20 20 69 6e 74 20 72 65 74 72 69 . int retri
a520: 65 73 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 69 es = 0;.. i
a530: 6e 74 20 6d 61 78 69 6d 75 6d 52 65 74 72 69 65 nt maximumRetrie
a540: 73 20 3d 20 28 63 6e 6e 20 21 3d 20 6e 75 6c 6c s = (cnn != null
a550: 29 20 3f 20 63 6e 6e 2e 5f 70 72 65 70 61 72 65 ) ? cnn._prepare
a560: 52 65 74 72 69 65 73 20 3a 20 53 51 4c 69 74 65 Retries : SQLite
a570: 43 6f 6e 6e 65 63 74 69 6f 6e 2e 44 65 66 61 75 Connection.Defau
a580: 6c 74 50 72 65 70 61 72 65 52 65 74 72 69 65 73 ltPrepareRetries
a590: 3b 0d 0a 20 20 20 20 20 20 62 79 74 65 5b 5d 20 ;.. byte[]
a5a0: 62 20 3d 20 54 6f 55 54 46 38 28 73 74 72 53 71 b = ToUTF8(strSq
a5b0: 6c 29 3b 0d 0a 20 20 20 20 20 20 73 74 72 69 6e l);.. strin
a5c0: 67 20 74 79 70 65 64 65 66 73 20 3d 20 6e 75 6c g typedefs = nul
a5d0: 6c 3b 0d 0a 20 20 20 20 20 20 53 51 4c 69 74 65 l;.. SQLite
a5e0: 53 74 61 74 65 6d 65 6e 74 20 63 6d 64 20 3d 20 Statement cmd =
a5f0: 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 52 61 6e null;.. Ran
a600: 64 6f 6d 20 72 6e 64 20 3d 20 6e 75 6c 6c 3b 0d dom rnd = null;.
a610: 0a 20 20 20 20 20 20 75 69 6e 74 20 73 74 61 72 . uint star
a620: 74 74 69 63 6b 20 3d 20 28 75 69 6e 74 29 45 6e ttick = (uint)En
a630: 76 69 72 6f 6e 6d 65 6e 74 2e 54 69 63 6b 43 6f vironment.TickCo
a640: 75 6e 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 52 65 unt;.... Re
a650: 73 65 74 43 61 6e 63 65 6c 43 6f 75 6e 74 28 29 setCancelCount()
a660: 3b 0d 0a 0d 0a 20 20 20 20 20 20 47 43 48 61 6e ;.... GCHan
a670: 64 6c 65 20 68 61 6e 64 6c 65 20 3d 20 47 43 48 dle handle = GCH
a680: 61 6e 64 6c 65 2e 41 6c 6c 6f 63 28 62 2c 20 47 andle.Alloc(b, G
a690: 43 48 61 6e 64 6c 65 54 79 70 65 2e 50 69 6e 6e CHandleType.Pinn
a6a0: 65 64 29 3b 0d 0a 20 20 20 20 20 20 49 6e 74 50 ed);.. IntP
a6b0: 74 72 20 70 73 71 6c 20 3d 20 68 61 6e 64 6c 65 tr psql = handle
a6c0: 2e 41 64 64 72 4f 66 50 69 6e 6e 65 64 4f 62 6a .AddrOfPinnedObj
a6d0: 65 63 74 28 29 3b 0d 0a 20 20 20 20 20 20 53 51 ect();.. SQ
a6e0: 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 48 61 6e LiteStatementHan
a6f0: 64 6c 65 20 73 74 61 74 65 6d 65 6e 74 48 61 6e dle statementHan
a700: 64 6c 65 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 dle = null;..
a710: 20 20 20 74 72 79 0d 0a 20 20 20 20 20 20 7b 0d try.. {.
a720: 0a 20 20 20 20 20 20 20 20 77 68 69 6c 65 20 28 . while (
a730: 28 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f (n == SQLiteErro
a740: 72 43 6f 64 65 2e 53 63 68 65 6d 61 20 7c 7c 20 rCode.Schema ||
a750: 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 n == SQLiteError
a760: 43 6f 64 65 2e 4c 6f 63 6b 65 64 20 7c 7c 20 6e Code.Locked || n
a770: 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 == SQLiteErrorC
a780: 6f 64 65 2e 42 75 73 79 29 20 26 26 20 72 65 74 ode.Busy) && ret
a790: 72 69 65 73 20 3c 20 6d 61 78 69 6d 75 6d 52 65 ries < maximumRe
a7a0: 74 72 69 65 73 29 0d 0a 20 20 20 20 20 20 20 20 tries)..
a7b0: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 74 72 79 {.. try
a7c0: 0d 0a 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 .. {..
a7d0: 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 64 6f // do
a7e0: 20 6e 6f 74 68 69 6e 67 2e 0d 0a 20 20 20 20 20 nothing...
a7f0: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
a800: 20 20 66 69 6e 61 6c 6c 79 20 2f 2a 20 4e 4f 54 finally /* NOT
a810: 45 3a 20 54 68 72 65 61 64 2e 41 62 6f 72 74 28 E: Thread.Abort(
a820: 29 20 70 72 6f 74 65 63 74 69 6f 6e 2e 20 2a 2f ) protection. */
a830: 0d 0a 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 .. {..
a840: 20 20 20 20 20 20 20 20 20 20 20 73 74 6d 74 20 stmt
a850: 3d 20 49 6e 74 50 74 72 2e 5a 65 72 6f 3b 0d 0a = IntPtr.Zero;..
a860: 20 20 20 20 20 20 20 20 20 20 20 20 70 74 72 20 ptr
a870: 3d 20 49 6e 74 50 74 72 2e 5a 65 72 6f 3b 0d 0a = IntPtr.Zero;..
a880: 0d 0a 23 69 66 20 21 53 51 4c 49 54 45 5f 53 54 ..#if !SQLITE_ST
a890: 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 20 20 ANDARD..
a8a0: 20 20 20 20 6c 65 6e 20 3d 20 30 3b 0d 0a 20 20 len = 0;..
a8b0: 20 20 20 20 20 20 20 20 20 20 6e 20 3d 20 55 6e n = Un
a8c0: 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
a8d0: 73 2e 73 71 6c 69 74 65 33 5f 70 72 65 70 61 72 s.sqlite3_prepar
a8e0: 65 5f 69 6e 74 65 72 6f 70 28 5f 73 71 6c 2c 20 e_interop(_sql,
a8f0: 70 73 71 6c 2c 20 62 2e 4c 65 6e 67 74 68 20 2d psql, b.Length -
a900: 20 31 2c 20 72 65 66 20 73 74 6d 74 2c 20 72 65 1, ref stmt, re
a910: 66 20 70 74 72 2c 20 72 65 66 20 6c 65 6e 29 3b f ptr, ref len);
a920: 0d 0a 23 65 6c 73 65 0d 0a 23 69 66 20 55 53 45 ..#else..#if USE
a930: 5f 50 52 45 50 41 52 45 5f 56 32 0d 0a 20 20 20 _PREPARE_V2..
a940: 20 20 20 20 20 20 20 20 20 6e 20 3d 20 55 6e 73 n = Uns
a950: 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
a960: 2e 73 71 6c 69 74 65 33 5f 70 72 65 70 61 72 65 .sqlite3_prepare
a970: 5f 76 32 28 5f 73 71 6c 2c 20 70 73 71 6c 2c 20 _v2(_sql, psql,
a980: 62 2e 4c 65 6e 67 74 68 20 2d 20 31 2c 20 72 65 b.Length - 1, re
a990: 66 20 73 74 6d 74 2c 20 72 65 66 20 70 74 72 29 f stmt, ref ptr)
a9a0: 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 ;..#else..
a9b0: 20 20 20 20 20 20 6e 20 3d 20 55 6e 73 61 66 65 n = Unsafe
a9c0: 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
a9d0: 6c 69 74 65 33 5f 70 72 65 70 61 72 65 28 5f 73 lite3_prepare(_s
a9e0: 71 6c 2c 20 70 73 71 6c 2c 20 62 2e 4c 65 6e 67 ql, psql, b.Leng
a9f0: 74 68 20 2d 20 31 2c 20 72 65 66 20 73 74 6d 74 th - 1, ref stmt
aa00: 2c 20 72 65 66 20 70 74 72 29 3b 0d 0a 23 65 6e , ref ptr);..#en
aa10: 64 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 20 dif..
aa20: 20 6c 65 6e 20 3d 20 2d 31 3b 0d 0a 23 65 6e 64 len = -1;..#end
aa30: 69 66 0d 0a 0d 0a 23 69 66 20 21 4e 45 54 5f 43 if....#if !NET_C
aa40: 4f 4d 50 41 43 54 5f 32 30 20 26 26 20 54 52 41 OMPACT_20 && TRA
aa50: 43 45 5f 53 54 41 54 45 4d 45 4e 54 0d 0a 20 20 CE_STATEMENT..
aa60: 20 20 20 20 20 20 20 20 20 20 54 72 61 63 65 2e Trace.
aa70: 57 72 69 74 65 4c 69 6e 65 28 55 6e 73 61 66 65 WriteLine(Unsafe
aa80: 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 53 74 NativeMethods.St
aa90: 72 69 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 ringFormat(..
aaa0: 20 20 20 20 20 20 20 20 20 20 20 20 20 43 75 6c Cul
aab0: 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 tureInfo.Current
aac0: 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 Culture,..
aad0: 20 20 20 20 20 20 20 20 20 20 22 50 72 65 70 61 "Prepa
aae0: 72 65 20 28 7b 30 7d 29 3a 20 7b 31 7d 22 2c 20 re ({0}): {1}",
aaf0: 6e 2c 20 73 74 6d 74 29 29 3b 0d 0a 23 65 6e 64 n, stmt));..#end
ab00: 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 if....
ab10: 20 20 69 66 20 28 28 6e 20 3d 3d 20 53 51 4c 69 if ((n == SQLi
ab20: 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 teErrorCode.Ok)
ab30: 26 26 20 28 73 74 6d 74 20 21 3d 20 49 6e 74 50 && (stmt != IntP
ab40: 74 72 2e 5a 65 72 6f 29 29 0d 0a 20 20 20 20 20 tr.Zero))..
ab50: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
ab60: 20 20 20 20 20 20 20 20 69 66 20 28 73 74 61 74 if (stat
ab70: 65 6d 65 6e 74 48 61 6e 64 6c 65 20 21 3d 20 6e ementHandle != n
ab80: 75 6c 6c 29 20 73 74 61 74 65 6d 65 6e 74 48 61 ull) statementHa
ab90: 6e 64 6c 65 2e 44 69 73 70 6f 73 65 28 29 3b 0d ndle.Dispose();.
aba0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 . s
abb0: 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 3d tatementHandle =
abc0: 20 6e 65 77 20 53 51 4c 69 74 65 53 74 61 74 65 new SQLiteState
abd0: 6d 65 6e 74 48 61 6e 64 6c 65 28 5f 73 71 6c 2c mentHandle(_sql,
abe0: 20 73 74 6d 74 29 3b 0d 0a 20 20 20 20 20 20 20 stmt);..
abf0: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
ac00: 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 }....
ac10: 20 69 66 20 28 73 74 61 74 65 6d 65 6e 74 48 61 if (statementHa
ac20: 6e 64 6c 65 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 ndle != null)..
ac30: 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 {..
ac40: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 43 6f SQLiteCo
ac50: 6e 6e 65 63 74 69 6f 6e 2e 4f 6e 43 68 61 6e 67 nnection.OnChang
ac60: 65 64 28 6e 75 6c 6c 2c 20 6e 65 77 20 43 6f 6e ed(null, new Con
ac70: 6e 65 63 74 69 6f 6e 45 76 65 6e 74 41 72 67 73 nectionEventArgs
ac80: 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 (..
ac90: 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f SQLiteConnectio
aca0: 6e 45 76 65 6e 74 54 79 70 65 2e 4e 65 77 43 72 nEventType.NewCr
acb0: 69 74 69 63 61 6c 48 61 6e 64 6c 65 2c 20 6e 75 iticalHandle, nu
acc0: 6c 6c 2c 20 6e 75 6c 6c 2c 0d 0a 20 20 20 20 20 ll, null,..
acd0: 20 20 20 20 20 20 20 20 20 6e 75 6c 6c 2c 20 6e null, n
ace0: 75 6c 6c 2c 20 73 74 61 74 65 6d 65 6e 74 48 61 ull, statementHa
acf0: 6e 64 6c 65 2c 20 73 74 72 53 71 6c 2c 20 6e 65 ndle, strSql, ne
ad00: 77 20 6f 62 6a 65 63 74 5b 5d 20 7b 0d 0a 20 20 w object[] {..
ad10: 20 20 20 20 20 20 20 20 20 20 20 20 74 79 70 65 type
ad20: 6f 66 28 53 51 4c 69 74 65 33 29 2c 20 63 6e 6e of(SQLite3), cnn
ad30: 2c 20 73 74 72 53 71 6c 2c 20 70 72 65 76 69 6f , strSql, previo
ad40: 75 73 2c 20 74 69 6d 65 6f 75 74 4d 53 20 7d 29 us, timeoutMS })
ad50: 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 7d 0d );.. }.
ad60: 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 ... if
ad70: 28 53 68 6f 75 6c 64 54 68 72 6f 77 46 6f 72 43 (ShouldThrowForC
ad80: 61 6e 63 65 6c 28 29 29 0d 0a 20 20 20 20 20 20 ancel())..
ad90: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
ada0: 20 20 20 20 20 69 66 20 28 28 6e 20 3d 3d 20 53 if ((n == S
adb0: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f QLiteErrorCode.O
adc0: 6b 29 20 7c 7c 0d 0a 20 20 20 20 20 20 20 20 20 k) ||..
add0: 20 20 20 20 20 20 20 20 20 28 6e 20 3d 3d 20 53 (n == S
ade0: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 52 QLiteErrorCode.R
adf0: 6f 77 29 20 7c 7c 0d 0a 20 20 20 20 20 20 20 20 ow) ||..
ae00: 20 20 20 20 20 20 20 20 20 20 28 6e 20 3d 3d 20 (n ==
ae10: 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e SQLiteErrorCode.
ae20: 44 6f 6e 65 29 29 0d 0a 20 20 20 20 20 20 20 20 Done))..
ae30: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
ae40: 20 20 20 20 20 20 20 20 20 20 20 6e 20 3d 20 53 n = S
ae50: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 49 QLiteErrorCode.I
ae60: 6e 74 65 72 72 75 70 74 3b 0d 0a 20 20 20 20 20 nterrupt;..
ae70: 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 }....
ae80: 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f thro
ae90: 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 w new SQLiteExce
aea0: 70 74 69 6f 6e 28 6e 2c 20 6e 75 6c 6c 29 3b 0d ption(n, null);.
aeb0: 0a 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a . }....
aec0: 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6e 20 if (n
aed0: 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f == SQLiteErrorCo
aee0: 64 65 2e 49 6e 74 65 72 72 75 70 74 29 0d 0a 20 de.Interrupt)..
aef0: 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b break
af00: 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 65 6c 73 ;.. els
af10: 65 20 69 66 20 28 6e 20 3d 3d 20 53 51 4c 69 74 e if (n == SQLit
af20: 65 45 72 72 6f 72 43 6f 64 65 2e 53 63 68 65 6d eErrorCode.Schem
af30: 61 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 a)..
af40: 72 65 74 72 69 65 73 2b 2b 3b 0d 0a 20 20 20 20 retries++;..
af50: 20 20 20 20 20 20 65 6c 73 65 20 69 66 20 28 6e else if (n
af60: 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 == SQLiteErrorC
af70: 6f 64 65 2e 45 72 72 6f 72 29 0d 0a 20 20 20 20 ode.Error)..
af80: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
af90: 20 20 20 20 20 69 66 20 28 53 74 72 69 6e 67 2e if (String.
afa0: 43 6f 6d 70 61 72 65 28 47 65 74 4c 61 73 74 45 Compare(GetLastE
afb0: 72 72 6f 72 28 29 2c 20 22 6e 65 61 72 20 5c 22 rror(), "near \"
afc0: 54 59 50 45 53 5c 22 3a 20 73 79 6e 74 61 78 20 TYPES\": syntax
afd0: 65 72 72 6f 72 22 2c 20 53 74 72 69 6e 67 43 6f error", StringCo
afe0: 6d 70 61 72 69 73 6f 6e 2e 4f 72 64 69 6e 61 6c mparison.Ordinal
aff0: 49 67 6e 6f 72 65 43 61 73 65 29 20 3d 3d 20 30 IgnoreCase) == 0
b000: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b ).. {
b010: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
b020: 69 6e 74 20 70 6f 73 20 3d 20 73 74 72 53 71 6c int pos = strSql
b030: 2e 49 6e 64 65 78 4f 66 28 27 3b 27 29 3b 0d 0a .IndexOf(';');..
b040: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 if
b050: 20 28 70 6f 73 20 3d 3d 20 2d 31 29 20 70 6f 73 (pos == -1) pos
b060: 20 3d 20 73 74 72 53 71 6c 2e 4c 65 6e 67 74 68 = strSql.Length
b070: 20 2d 20 31 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 - 1;....
b080: 20 20 20 20 20 20 20 74 79 70 65 64 65 66 73 20 typedefs
b090: 3d 20 73 74 72 53 71 6c 2e 53 75 62 73 74 72 69 = strSql.Substri
b0a0: 6e 67 28 30 2c 20 70 6f 73 20 2b 20 31 29 3b 0d ng(0, pos + 1);.
b0b0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 . s
b0c0: 74 72 53 71 6c 20 3d 20 73 74 72 53 71 6c 2e 53 trSql = strSql.S
b0d0: 75 62 73 74 72 69 6e 67 28 70 6f 73 20 2b 20 31 ubstring(pos + 1
b0e0: 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 );....
b0f0: 20 20 20 20 73 74 72 52 65 6d 61 69 6e 20 3d 20 strRemain =
b100: 53 74 72 69 6e 67 2e 45 6d 70 74 79 3b 0d 0a 0d String.Empty;...
b110: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 77 . w
b120: 68 69 6c 65 20 28 63 6d 64 20 3d 3d 20 6e 75 6c hile (cmd == nul
b130: 6c 20 26 26 20 73 74 72 53 71 6c 2e 4c 65 6e 67 l && strSql.Leng
b140: 74 68 20 3e 20 30 29 0d 0a 20 20 20 20 20 20 20 th > 0)..
b150: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
b160: 20 20 20 20 20 20 20 20 20 20 63 6d 64 20 3d 20 cmd =
b170: 50 72 65 70 61 72 65 28 63 6e 6e 2c 20 73 74 72 Prepare(cnn, str
b180: 53 71 6c 2c 20 70 72 65 76 69 6f 75 73 2c 20 74 Sql, previous, t
b190: 69 6d 65 6f 75 74 4d 53 2c 20 72 65 66 20 73 74 imeoutMS, ref st
b1a0: 72 52 65 6d 61 69 6e 29 3b 0d 0a 20 20 20 20 20 rRemain);..
b1b0: 20 20 20 20 20 20 20 20 20 20 20 73 74 72 53 71 strSq
b1c0: 6c 20 3d 20 73 74 72 52 65 6d 61 69 6e 3b 0d 0a l = strRemain;..
b1d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d }.
b1e0: 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ...
b1f0: 20 69 66 20 28 63 6d 64 20 21 3d 20 6e 75 6c 6c if (cmd != null
b200: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )..
b210: 20 20 20 63 6d 64 2e 53 65 74 54 79 70 65 73 28 cmd.SetTypes(
b220: 74 79 70 65 64 65 66 73 29 3b 0d 0a 0d 0a 20 20 typedefs);....
b230: 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 retu
b240: 72 6e 20 63 6d 64 3b 0d 0a 20 20 20 20 20 20 20 rn cmd;..
b250: 20 20 20 20 20 7d 0d 0a 23 69 66 20 28 4e 45 54 }..#if (NET
b260: 5f 33 35 20 7c 7c 20 4e 45 54 5f 34 30 20 7c 7c _35 || NET_40 ||
b270: 20 4e 45 54 5f 34 35 20 7c 7c 20 4e 45 54 5f 34 NET_45 || NET_4
b280: 35 31 20 7c 7c 20 4e 45 54 5f 34 35 32 20 7c 7c 51 || NET_452 ||
b290: 20 4e 45 54 5f 34 36 20 7c 7c 20 4e 45 54 5f 34 NET_46 || NET_4
b2a0: 36 31 29 20 26 26 20 21 50 4c 41 54 46 4f 52 4d 61) && !PLATFORM
b2b0: 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 _COMPACTFRAMEWOR
b2c0: 4b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 K.. e
b2d0: 6c 73 65 20 69 66 20 28 5f 62 75 69 6c 64 69 6e lse if (_buildin
b2e0: 67 53 63 68 65 6d 61 20 3d 3d 20 66 61 6c 73 65 gSchema == false
b2f0: 20 26 26 20 53 74 72 69 6e 67 2e 43 6f 6d 70 61 && String.Compa
b300: 72 65 28 47 65 74 4c 61 73 74 45 72 72 6f 72 28 re(GetLastError(
b310: 29 2c 20 30 2c 20 22 6e 6f 20 73 75 63 68 20 74 ), 0, "no such t
b320: 61 62 6c 65 3a 20 54 45 4d 50 2e 53 43 48 45 4d able: TEMP.SCHEM
b330: 41 22 2c 20 30 2c 20 32 36 2c 20 53 74 72 69 6e A", 0, 26, Strin
b340: 67 43 6f 6d 70 61 72 69 73 6f 6e 2e 4f 72 64 69 gComparison.Ordi
b350: 6e 61 6c 49 67 6e 6f 72 65 43 61 73 65 29 20 3d nalIgnoreCase) =
b360: 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 = 0)..
b370: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
b380: 20 20 20 73 74 72 52 65 6d 61 69 6e 20 3d 20 53 strRemain = S
b390: 74 72 69 6e 67 2e 45 6d 70 74 79 3b 0d 0a 20 20 tring.Empty;..
b3a0: 20 20 20 20 20 20 20 20 20 20 20 20 5f 62 75 69 _bui
b3b0: 6c 64 69 6e 67 53 63 68 65 6d 61 20 3d 20 74 72 ldingSchema = tr
b3c0: 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ue;..
b3d0: 20 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 try..
b3e0: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
b3f0: 20 20 20 20 20 20 20 20 20 49 53 51 4c 69 74 65 ISQLite
b400: 53 63 68 65 6d 61 45 78 74 65 6e 73 69 6f 6e 73 SchemaExtensions
b410: 20 65 78 74 20 3d 20 28 28 49 53 65 72 76 69 63 ext = ((IServic
b420: 65 50 72 6f 76 69 64 65 72 29 53 51 4c 69 74 65 eProvider)SQLite
b430: 46 61 63 74 6f 72 79 2e 49 6e 73 74 61 6e 63 65 Factory.Instance
b440: 29 2e 47 65 74 53 65 72 76 69 63 65 28 74 79 70 ).GetService(typ
b450: 65 6f 66 28 49 53 51 4c 69 74 65 53 63 68 65 6d eof(ISQLiteSchem
b460: 61 45 78 74 65 6e 73 69 6f 6e 73 29 29 20 61 73 aExtensions)) as
b470: 20 49 53 51 4c 69 74 65 53 63 68 65 6d 61 45 78 ISQLiteSchemaEx
b480: 74 65 6e 73 69 6f 6e 73 3b 0d 0a 0d 0a 20 20 20 tensions;....
b490: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 if
b4a0: 28 65 78 74 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 (ext != null)..
b4b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
b4c0: 20 65 78 74 2e 42 75 69 6c 64 54 65 6d 70 53 63 ext.BuildTempSc
b4d0: 68 65 6d 61 28 63 6e 6e 29 3b 0d 0a 0d 0a 20 20 hema(cnn);....
b4e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 77 68 wh
b4f0: 69 6c 65 20 28 63 6d 64 20 3d 3d 20 6e 75 6c 6c ile (cmd == null
b500: 20 26 26 20 73 74 72 53 71 6c 2e 4c 65 6e 67 74 && strSql.Lengt
b510: 68 20 3e 20 30 29 0d 0a 20 20 20 20 20 20 20 20 h > 0)..
b520: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
b530: 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6d 64 cmd
b540: 20 3d 20 50 72 65 70 61 72 65 28 63 6e 6e 2c 20 = Prepare(cnn,
b550: 73 74 72 53 71 6c 2c 20 70 72 65 76 69 6f 75 73 strSql, previous
b560: 2c 20 74 69 6d 65 6f 75 74 4d 53 2c 20 72 65 66 , timeoutMS, ref
b570: 20 73 74 72 52 65 6d 61 69 6e 29 3b 0d 0a 20 20 strRemain);..
b580: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
b590: 73 74 72 53 71 6c 20 3d 20 73 74 72 52 65 6d 61 strSql = strRema
b5a0: 69 6e 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 in;..
b5b0: 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 }....
b5c0: 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e return
b5d0: 20 63 6d 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 cmd;..
b5e0: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
b5f0: 20 20 20 20 20 20 66 69 6e 61 6c 6c 79 0d 0a 20 finally..
b600: 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a {..
b610: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
b620: 5f 62 75 69 6c 64 69 6e 67 53 63 68 65 6d 61 20 _buildingSchema
b630: 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 = false;..
b640: 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
b650: 20 20 20 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 }..#endif
b660: 0d 0a 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 .. }..
b670: 20 20 20 20 20 20 20 20 20 65 6c 73 65 20 69 66 else if
b680: 20 28 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 (n == SQLiteErr
b690: 6f 72 43 6f 64 65 2e 4c 6f 63 6b 65 64 20 7c 7c orCode.Locked ||
b6a0: 20 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f n == SQLiteErro
b6b0: 72 43 6f 64 65 2e 42 75 73 79 29 20 2f 2f 20 4c rCode.Busy) // L
b6c0: 6f 63 6b 65 64 20 2d 2d 20 64 65 6c 61 79 20 61 ocked -- delay a
b6d0: 20 73 6d 61 6c 6c 20 61 6d 6f 75 6e 74 20 62 65 small amount be
b6e0: 66 6f 72 65 20 72 65 74 72 79 69 6e 67 0d 0a 20 fore retrying..
b6f0: 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 {..
b700: 20 20 20 20 20 20 20 20 2f 2f 20 4b 65 65 70 20 // Keep
b710: 74 72 79 69 6e 67 0d 0a 20 20 20 20 20 20 20 20 trying..
b720: 20 20 20 20 69 66 20 28 72 6e 64 20 3d 3d 20 6e if (rnd == n
b730: 75 6c 6c 29 20 2f 2f 20 46 69 72 73 74 20 74 69 ull) // First ti
b740: 6d 65 20 77 65 27 76 65 20 65 6e 63 6f 75 6e 74 me we've encount
b750: 65 72 65 64 20 74 68 65 20 6c 6f 63 6b 0d 0a 20 ered the lock..
b760: 20 20 20 20 20 20 20 20 20 20 20 20 20 72 6e 64 rnd
b770: 20 3d 20 6e 65 77 20 52 61 6e 64 6f 6d 28 29 3b = new Random();
b780: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ....
b790: 2f 2f 20 49 66 20 77 65 27 76 65 20 65 78 63 65 // If we've exce
b7a0: 65 64 65 64 20 74 68 65 20 63 6f 6d 6d 61 6e 64 eded the command
b7b0: 27 73 20 74 69 6d 65 6f 75 74 2c 20 67 69 76 65 's timeout, give
b7c0: 20 75 70 20 61 6e 64 20 74 68 72 6f 77 20 61 6e up and throw an
b7d0: 20 65 72 72 6f 72 0d 0a 20 20 20 20 20 20 20 20 error..
b7e0: 20 20 20 20 69 66 20 28 28 75 69 6e 74 29 45 6e if ((uint)En
b7f0: 76 69 72 6f 6e 6d 65 6e 74 2e 54 69 63 6b 43 6f vironment.TickCo
b800: 75 6e 74 20 2d 20 73 74 61 72 74 74 69 63 6b 20 unt - starttick
b810: 3e 20 74 69 6d 65 6f 75 74 4d 53 29 0d 0a 20 20 > timeoutMS)..
b820: 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
b830: 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 throw
b840: 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 new SQLiteExcep
b850: 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 tion(n, GetLastE
b860: 72 72 6f 72 28 29 29 3b 0d 0a 20 20 20 20 20 20 rror());..
b870: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
b880: 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 else..
b890: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
b8a0: 20 20 20 20 20 20 20 20 2f 2f 20 4f 74 68 65 72 // Other
b8b0: 77 69 73 65 20 73 6c 65 65 70 20 66 6f 72 20 61 wise sleep for a
b8c0: 20 72 61 6e 64 6f 6d 20 61 6d 6f 75 6e 74 20 6f random amount o
b8d0: 66 20 74 69 6d 65 20 75 70 20 74 6f 20 31 35 30 f time up to 150
b8e0: 6d 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ms..
b8f0: 20 20 53 79 73 74 65 6d 2e 54 68 72 65 61 64 69 System.Threadi
b900: 6e 67 2e 54 68 72 65 61 64 2e 53 6c 65 65 70 28 ng.Thread.Sleep(
b910: 72 6e 64 2e 4e 65 78 74 28 31 2c 20 31 35 30 29 rnd.Next(1, 150)
b920: 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 );..
b930: 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 7d 0d 0a }.. }..
b940: 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 }....
b950: 20 20 20 20 20 69 66 20 28 53 68 6f 75 6c 64 54 if (ShouldT
b960: 68 72 6f 77 46 6f 72 43 61 6e 63 65 6c 28 29 29 hrowForCancel())
b970: 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 .. {..
b980: 20 20 20 20 20 20 20 20 20 69 66 20 28 28 6e 20 if ((n
b990: 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f == SQLiteErrorCo
b9a0: 64 65 2e 4f 6b 29 20 7c 7c 0d 0a 20 20 20 20 20 de.Ok) ||..
b9b0: 20 20 20 20 20 20 20 20 20 20 20 28 6e 20 3d 3d (n ==
b9c0: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
b9d0: 2e 52 6f 77 29 20 7c 7c 0d 0a 20 20 20 20 20 20 .Row) ||..
b9e0: 20 20 20 20 20 20 20 20 20 20 28 6e 20 3d 3d 20 (n ==
b9f0: 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e SQLiteErrorCode.
ba00: 44 6f 6e 65 29 29 0d 0a 20 20 20 20 20 20 20 20 Done))..
ba10: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
ba20: 20 20 20 20 20 20 20 6e 20 3d 20 53 51 4c 69 74 n = SQLit
ba30: 65 45 72 72 6f 72 43 6f 64 65 2e 49 6e 74 65 72 eErrorCode.Inter
ba40: 72 75 70 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 rupt;..
ba50: 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 }....
ba60: 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 51 throw new SQ
ba70: 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c LiteException(n,
ba80: 20 6e 75 6c 6c 29 3b 0d 0a 20 20 20 20 20 20 20 null);..
ba90: 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 }.... if
baa0: 20 28 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 (n == SQLiteErr
bab0: 6f 72 43 6f 64 65 2e 49 6e 74 65 72 72 75 70 74 orCode.Interrupt
bac0: 29 20 72 65 74 75 72 6e 20 6e 75 6c 6c 3b 0d 0a ) return null;..
bad0: 20 20 20 20 20 20 20 20 69 66 20 28 6e 20 21 3d if (n !=
bae0: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
baf0: 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 77 20 53 .Ok) throw new S
bb00: 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 6e QLiteException(n
bb10: 2c 20 47 65 74 4c 61 73 74 45 72 72 6f 72 28 29 , GetLastError()
bb20: 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 73 74 );.... st
bb30: 72 52 65 6d 61 69 6e 20 3d 20 55 54 46 38 54 6f rRemain = UTF8To
bb40: 53 74 72 69 6e 67 28 70 74 72 2c 20 6c 65 6e 29 String(ptr, len)
bb50: 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 ;.... if
bb60: 28 73 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c 65 (statementHandle
bb70: 20 21 3d 20 6e 75 6c 6c 29 20 63 6d 64 20 3d 20 != null) cmd =
bb80: 6e 65 77 20 53 51 4c 69 74 65 53 74 61 74 65 6d new SQLiteStatem
bb90: 65 6e 74 28 74 68 69 73 2c 20 66 6c 61 67 73 2c ent(this, flags,
bba0: 20 73 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c 65 statementHandle
bbb0: 2c 20 73 74 72 53 71 6c 2e 53 75 62 73 74 72 69 , strSql.Substri
bbc0: 6e 67 28 30 2c 20 73 74 72 53 71 6c 2e 4c 65 6e ng(0, strSql.Len
bbd0: 67 74 68 20 2d 20 73 74 72 52 65 6d 61 69 6e 2e gth - strRemain.
bbe0: 4c 65 6e 67 74 68 29 2c 20 70 72 65 76 69 6f 75 Length), previou
bbf0: 73 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 72 s);.... r
bc00: 65 74 75 72 6e 20 63 6d 64 3b 0d 0a 20 20 20 20 eturn cmd;..
bc10: 20 20 7d 0d 0a 20 20 20 20 20 20 66 69 6e 61 6c }.. final
bc20: 6c 79 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 20 20 ly.. {..
bc30: 20 20 20 20 20 68 61 6e 64 6c 65 2e 46 72 65 65 handle.Free
bc40: 28 29 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 ();.. }..
bc50: 20 20 7d 0d 0a 0d 0a 20 20 20 20 70 72 6f 74 65 }.... prote
bc60: 63 74 65 64 20 73 74 61 74 69 63 20 76 6f 69 64 cted static void
bc70: 20 4c 6f 67 42 69 6e 64 28 53 51 4c 69 74 65 53 LogBind(SQLiteS
bc80: 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 68 tatementHandle h
bc90: 61 6e 64 6c 65 2c 20 69 6e 74 20 69 6e 64 65 78 andle, int index
bca0: 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
bcb0: 20 20 49 6e 74 50 74 72 20 68 61 6e 64 6c 65 49 IntPtr handleI
bcc0: 6e 74 50 74 72 20 3d 20 68 61 6e 64 6c 65 3b 0d ntPtr = handle;.
bcd0: 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 ... SQLit
bce0: 65 4c 6f 67 2e 4c 6f 67 4d 65 73 73 61 67 65 28 eLog.LogMessage(
bcf0: 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
bd00: 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d 61 74 ods.StringFormat
bd10: 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 43 (.. C
bd20: 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 ultureInfo.Curre
bd30: 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 ntCulture,..
bd40: 20 20 20 20 20 20 20 20 22 42 69 6e 64 69 6e 67 "Binding
bd50: 20 73 74 61 74 65 6d 65 6e 74 20 7b 30 7d 20 70 statement {0} p
bd60: 61 72 61 6d 74 65 72 20 23 7b 31 7d 20 61 73 20 aramter #{1} as
bd70: 4e 55 4c 4c 2e 2e 2e 22 2c 0d 0a 20 20 20 20 20 NULL...",..
bd80: 20 20 20 20 20 20 20 68 61 6e 64 6c 65 49 6e 74 handleInt
bd90: 50 74 72 2c 20 69 6e 64 65 78 29 29 3b 0d 0a 20 Ptr, index));..
bda0: 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 70 72 6f 74 }.... prot
bdb0: 65 63 74 65 64 20 73 74 61 74 69 63 20 76 6f 69 ected static voi
bdc0: 64 20 4c 6f 67 42 69 6e 64 28 53 51 4c 69 74 65 d LogBind(SQLite
bdd0: 53 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 StatementHandle
bde0: 68 61 6e 64 6c 65 2c 20 69 6e 74 20 69 6e 64 65 handle, int inde
bdf0: 78 2c 20 56 61 6c 75 65 54 79 70 65 20 76 61 6c x, ValueType val
be00: 75 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 ue).. {..
be10: 20 20 20 20 49 6e 74 50 74 72 20 68 61 6e 64 6c IntPtr handl
be20: 65 49 6e 74 50 74 72 20 3d 20 68 61 6e 64 6c 65 eIntPtr = handle
be30: 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 4c ;.... SQL
be40: 69 74 65 4c 6f 67 2e 4c 6f 67 4d 65 73 73 61 67 iteLog.LogMessag
be50: 65 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 e(UnsafeNativeMe
be60: 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d thods.StringForm
be70: 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 at(..
be80: 20 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 CultureInfo.Cur
be90: 72 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 rentCulture,..
bea0: 20 20 20 20 20 20 20 20 20 20 22 42 69 6e 64 69 "Bindi
beb0: 6e 67 20 73 74 61 74 65 6d 65 6e 74 20 7b 30 7d ng statement {0}
bec0: 20 70 61 72 61 6d 74 65 72 20 23 7b 31 7d 20 61 paramter #{1} a
bed0: 73 20 74 79 70 65 20 7b 32 7d 20 77 69 74 68 20 s type {2} with
bee0: 76 61 6c 75 65 20 7b 7b 7b 33 7d 7d 7d 2e 2e 2e value {{{3}}}...
bef0: 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ",..
bf00: 68 61 6e 64 6c 65 49 6e 74 50 74 72 2c 20 69 6e handleIntPtr, in
bf10: 64 65 78 2c 20 76 61 6c 75 65 2e 47 65 74 54 79 dex, value.GetTy
bf20: 70 65 28 29 2c 20 76 61 6c 75 65 29 29 3b 0d 0a pe(), value));..
bf30: 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 70 72 69 }.... pri
bf40: 76 61 74 65 20 73 74 61 74 69 63 20 73 74 72 69 vate static stri
bf50: 6e 67 20 46 6f 72 6d 61 74 44 61 74 65 54 69 6d ng FormatDateTim
bf60: 65 28 44 61 74 65 54 69 6d 65 20 76 61 6c 75 65 e(DateTime value
bf70: 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
bf80: 20 20 53 74 72 69 6e 67 42 75 69 6c 64 65 72 20 StringBuilder
bf90: 72 65 73 75 6c 74 20 3d 20 6e 65 77 20 53 74 72 result = new Str
bfa0: 69 6e 67 42 75 69 6c 64 65 72 28 29 3b 0d 0a 0d ingBuilder();...
bfb0: 0a 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 2e . result.
bfc0: 41 70 70 65 6e 64 28 76 61 6c 75 65 2e 54 6f 53 Append(value.ToS
bfd0: 74 72 69 6e 67 28 22 79 79 79 79 2d 4d 4d 2d 64 tring("yyyy-MM-d
bfe0: 64 54 48 48 3a 6d 6d 3a 73 73 2e 46 46 46 46 46 dTHH:mm:ss.FFFFF
bff0: 46 46 4b 22 29 29 3b 0d 0a 20 20 20 20 20 20 20 FFK"));..
c000: 20 72 65 73 75 6c 74 2e 41 70 70 65 6e 64 28 27 result.Append('
c010: 20 27 29 3b 0d 0a 20 20 20 20 20 20 20 20 72 65 ');.. re
c020: 73 75 6c 74 2e 41 70 70 65 6e 64 28 76 61 6c 75 sult.Append(valu
c030: 65 2e 4b 69 6e 64 29 3b 0d 0a 20 20 20 20 20 20 e.Kind);..
c040: 20 20 72 65 73 75 6c 74 2e 41 70 70 65 6e 64 28 result.Append(
c050: 27 20 27 29 3b 0d 0a 20 20 20 20 20 20 20 20 72 ' ');.. r
c060: 65 73 75 6c 74 2e 41 70 70 65 6e 64 28 76 61 6c esult.Append(val
c070: 75 65 2e 54 69 63 6b 73 29 3b 0d 0a 0d 0a 20 20 ue.Ticks);....
c080: 20 20 20 20 20 20 72 65 74 75 72 6e 20 72 65 73 return res
c090: 75 6c 74 2e 54 6f 53 74 72 69 6e 67 28 29 3b 0d ult.ToString();.
c0a0: 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 70 72 . }.... pr
c0b0: 6f 74 65 63 74 65 64 20 73 74 61 74 69 63 20 76 otected static v
c0c0: 6f 69 64 20 4c 6f 67 42 69 6e 64 28 53 51 4c 69 oid LogBind(SQLi
c0d0: 74 65 53 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c teStatementHandl
c0e0: 65 20 68 61 6e 64 6c 65 2c 20 69 6e 74 20 69 6e e handle, int in
c0f0: 64 65 78 2c 20 44 61 74 65 54 69 6d 65 20 76 61 dex, DateTime va
c100: 6c 75 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 lue).. {..
c110: 20 20 20 20 20 49 6e 74 50 74 72 20 68 61 6e 64 IntPtr hand
c120: 6c 65 49 6e 74 50 74 72 20 3d 20 68 61 6e 64 6c leIntPtr = handl
c130: 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 e;.... SQ
c140: 4c 69 74 65 4c 6f 67 2e 4c 6f 67 4d 65 73 73 61 LiteLog.LogMessa
c150: 67 65 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d ge(UnsafeNativeM
c160: 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 ethods.StringFor
c170: 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 mat(..
c180: 20 20 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 CultureInfo.Cu
c190: 72 72 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 rrentCulture,..
c1a0: 20 20 20 20 20 20 20 20 20 20 20 22 42 69 6e 64 "Bind
c1b0: 69 6e 67 20 73 74 61 74 65 6d 65 6e 74 20 7b 30 ing statement {0
c1c0: 7d 20 70 61 72 61 6d 74 65 72 20 23 7b 31 7d 20 } paramter #{1}
c1d0: 61 73 20 74 79 70 65 20 7b 32 7d 20 77 69 74 68 as type {2} with
c1e0: 20 76 61 6c 75 65 20 7b 7b 7b 33 7d 7d 7d 2e 2e value {{{3}}}..
c1f0: 2e 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 .",..
c200: 20 68 61 6e 64 6c 65 49 6e 74 50 74 72 2c 20 69 handleIntPtr, i
c210: 6e 64 65 78 2c 20 74 79 70 65 6f 66 28 44 61 74 ndex, typeof(Dat
c220: 65 54 69 6d 65 29 2c 20 46 6f 72 6d 61 74 44 61 eTime), FormatDa
c230: 74 65 54 69 6d 65 28 76 61 6c 75 65 29 29 29 3b teTime(value)));
c240: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 70 .. }.... p
c250: 72 6f 74 65 63 74 65 64 20 73 74 61 74 69 63 20 rotected static
c260: 76 6f 69 64 20 4c 6f 67 42 69 6e 64 28 53 51 4c void LogBind(SQL
c270: 69 74 65 53 74 61 74 65 6d 65 6e 74 48 61 6e 64 iteStatementHand
c280: 6c 65 20 68 61 6e 64 6c 65 2c 20 69 6e 74 20 69 le handle, int i
c290: 6e 64 65 78 2c 20 73 74 72 69 6e 67 20 76 61 6c ndex, string val
c2a0: 75 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 ue).. {..
c2b0: 20 20 20 20 49 6e 74 50 74 72 20 68 61 6e 64 6c IntPtr handl
c2c0: 65 49 6e 74 50 74 72 20 3d 20 68 61 6e 64 6c 65 eIntPtr = handle
c2d0: 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 4c ;.... SQL
c2e0: 69 74 65 4c 6f 67 2e 4c 6f 67 4d 65 73 73 61 67 iteLog.LogMessag
c2f0: 65 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 e(UnsafeNativeMe
c300: 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d thods.StringForm
c310: 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 at(..
c320: 20 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 CultureInfo.Cur
c330: 72 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 rentCulture,..
c340: 20 20 20 20 20 20 20 20 20 20 22 42 69 6e 64 69 "Bindi
c350: 6e 67 20 73 74 61 74 65 6d 65 6e 74 20 7b 30 7d ng statement {0}
c360: 20 70 61 72 61 6d 74 65 72 20 23 7b 31 7d 20 61 paramter #{1} a
c370: 73 20 74 79 70 65 20 7b 32 7d 20 77 69 74 68 20 s type {2} with
c380: 76 61 6c 75 65 20 7b 7b 7b 33 7d 7d 7d 2e 2e 2e value {{{3}}}...
c390: 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ",..
c3a0: 68 61 6e 64 6c 65 49 6e 74 50 74 72 2c 20 69 6e handleIntPtr, in
c3b0: 64 65 78 2c 20 74 79 70 65 6f 66 28 53 74 72 69 dex, typeof(Stri
c3c0: 6e 67 29 2c 20 28 76 61 6c 75 65 20 21 3d 20 6e ng), (value != n
c3d0: 75 6c 6c 29 20 3f 20 76 61 6c 75 65 20 3a 20 22 ull) ? value : "
c3e0: 3c 6e 75 6c 6c 3e 22 29 29 3b 0d 0a 20 20 20 20 <null>"));..
c3f0: 7d 0d 0a 0d 0a 20 20 20 20 70 72 69 76 61 74 65 }.... private
c400: 20 73 74 61 74 69 63 20 73 74 72 69 6e 67 20 54 static string T
c410: 6f 48 65 78 61 64 65 63 69 6d 61 6c 53 74 72 69 oHexadecimalStri
c420: 6e 67 28 0d 0a 20 20 20 20 20 20 20 20 62 79 74 ng(.. byt
c430: 65 5b 5d 20 61 72 72 61 79 0d 0a 20 20 20 20 20 e[] array..
c440: 20 20 20 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 ).. {..
c450: 20 20 20 20 20 69 66 20 28 61 72 72 61 79 20 3d if (array =
c460: 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 = null)..
c470: 20 20 20 20 20 72 65 74 75 72 6e 20 6e 75 6c 6c return null
c480: 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 74 72 ;.... Str
c490: 69 6e 67 42 75 69 6c 64 65 72 20 72 65 73 75 6c ingBuilder resul
c4a0: 74 20 3d 20 6e 65 77 20 53 74 72 69 6e 67 42 75 t = new StringBu
c4b0: 69 6c 64 65 72 28 61 72 72 61 79 2e 4c 65 6e 67 ilder(array.Leng
c4c0: 74 68 20 2a 20 32 29 3b 0d 0a 0d 0a 20 20 20 20 th * 2);....
c4d0: 20 20 20 20 69 6e 74 20 6c 65 6e 67 74 68 20 3d int length =
c4e0: 20 61 72 72 61 79 2e 4c 65 6e 67 74 68 3b 0d 0a array.Length;..
c4f0: 0d 0a 20 20 20 20 20 20 20 20 66 6f 72 20 28 69 .. for (i
c500: 6e 74 20 69 6e 64 65 78 20 3d 20 30 3b 20 69 6e nt index = 0; in
c510: 64 65 78 20 3c 20 6c 65 6e 67 74 68 3b 20 69 6e dex < length; in
c520: 64 65 78 2b 2b 29 0d 0a 20 20 20 20 20 20 20 20 dex++)..
c530: 20 20 20 20 72 65 73 75 6c 74 2e 41 70 70 65 6e result.Appen
c540: 64 28 61 72 72 61 79 5b 69 6e 64 65 78 5d 2e 54 d(array[index].T
c550: 6f 53 74 72 69 6e 67 28 22 78 32 22 29 29 3b 0d oString("x2"));.
c560: 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 ... retur
c570: 6e 20 72 65 73 75 6c 74 2e 54 6f 53 74 72 69 6e n result.ToStrin
c580: 67 28 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 g();.. }....
c590: 20 20 20 70 72 6f 74 65 63 74 65 64 20 73 74 61 protected sta
c5a0: 74 69 63 20 76 6f 69 64 20 4c 6f 67 42 69 6e 64 tic void LogBind
c5b0: 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 (SQLiteStatement
c5c0: 48 61 6e 64 6c 65 20 68 61 6e 64 6c 65 2c 20 69 Handle handle, i
c5d0: 6e 74 20 69 6e 64 65 78 2c 20 62 79 74 65 5b 5d nt index, byte[]
c5e0: 20 76 61 6c 75 65 29 0d 0a 20 20 20 20 7b 0d 0a value).. {..
c5f0: 20 20 20 20 20 20 20 20 49 6e 74 50 74 72 20 68 IntPtr h
c600: 61 6e 64 6c 65 49 6e 74 50 74 72 20 3d 20 68 61 andleIntPtr = ha
c610: 6e 64 6c 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 ndle;....
c620: 20 53 51 4c 69 74 65 4c 6f 67 2e 4c 6f 67 4d 65 SQLiteLog.LogMe
c630: 73 73 61 67 65 28 55 6e 73 61 66 65 4e 61 74 69 ssage(UnsafeNati
c640: 76 65 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 veMethods.String
c650: 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 Format(..
c660: 20 20 20 20 20 43 75 6c 74 75 72 65 49 6e 66 6f CultureInfo
c670: 2e 43 75 72 72 65 6e 74 43 75 6c 74 75 72 65 2c .CurrentCulture,
c680: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 22 42 .. "B
c690: 69 6e 64 69 6e 67 20 73 74 61 74 65 6d 65 6e 74 inding statement
c6a0: 20 7b 30 7d 20 70 61 72 61 6d 74 65 72 20 23 7b {0} paramter #{
c6b0: 31 7d 20 61 73 20 74 79 70 65 20 7b 32 7d 20 77 1} as type {2} w
c6c0: 69 74 68 20 76 61 6c 75 65 20 7b 7b 7b 33 7d 7d ith value {{{3}}
c6d0: 7d 2e 2e 2e 22 2c 0d 0a 20 20 20 20 20 20 20 20 }...",..
c6e0: 20 20 20 20 68 61 6e 64 6c 65 49 6e 74 50 74 72 handleIntPtr
c6f0: 2c 20 69 6e 64 65 78 2c 20 74 79 70 65 6f 66 28 , index, typeof(
c700: 42 79 74 65 5b 5d 29 2c 20 28 76 61 6c 75 65 20 Byte[]), (value
c710: 21 3d 20 6e 75 6c 6c 29 20 3f 20 54 6f 48 65 78 != null) ? ToHex
c720: 61 64 65 63 69 6d 61 6c 53 74 72 69 6e 67 28 76 adecimalString(v
c730: 61 6c 75 65 29 20 3a 20 22 3c 6e 75 6c 6c 3e 22 alue) : "<null>"
c740: 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 ));.. }....
c750: 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 internal overr
c760: 69 64 65 20 76 6f 69 64 20 42 69 6e 64 5f 44 6f ide void Bind_Do
c770: 75 62 6c 65 28 53 51 4c 69 74 65 53 74 61 74 65 uble(SQLiteState
c780: 6d 65 6e 74 20 73 74 6d 74 2c 20 53 51 4c 69 74 ment stmt, SQLit
c790: 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 eConnectionFlags
c7a0: 20 66 6c 61 67 73 2c 20 69 6e 74 20 69 6e 64 65 flags, int inde
c7b0: 78 2c 20 64 6f 75 62 6c 65 20 76 61 6c 75 65 29 x, double value)
c7c0: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
c7d0: 20 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 SQLiteStatement
c7e0: 48 61 6e 64 6c 65 20 68 61 6e 64 6c 65 20 3d 20 Handle handle =
c7f0: 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d stmt._sqlite_stm
c800: 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 t;.... if
c810: 20 28 28 66 6c 61 67 73 20 26 20 53 51 4c 69 74 ((flags & SQLit
c820: 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 eConnectionFlags
c830: 2e 4c 6f 67 42 69 6e 64 29 20 3d 3d 20 53 51 4c .LogBind) == SQL
c840: 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 iteConnectionFla
c850: 67 73 2e 4c 6f 67 42 69 6e 64 29 0d 0a 20 20 20 gs.LogBind)..
c860: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
c870: 20 20 20 20 4c 6f 67 42 69 6e 64 28 68 61 6e 64 LogBind(hand
c880: 6c 65 2c 20 69 6e 64 65 78 2c 20 76 61 6c 75 65 le, index, value
c890: 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d );.. }...
c8a0: 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f 43 .#if !PLATFORM_C
c8b0: 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 4b 0d OMPACTFRAMEWORK.
c8c0: 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 . SQLiteE
c8d0: 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 rrorCode n = Uns
c8e0: 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
c8f0: 2e 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 64 6f .sqlite3_bind_do
c900: 75 62 6c 65 28 68 61 6e 64 6c 65 2c 20 69 6e 64 uble(handle, ind
c910: 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 20 20 ex, value);..
c920: 20 20 20 20 20 69 66 20 28 6e 20 21 3d 20 53 51 if (n != SQ
c930: 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b LiteErrorCode.Ok
c940: 29 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 ) throw new SQLi
c950: 74 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 teException(n, G
c960: 65 74 4c 61 73 74 45 72 72 6f 72 28 29 29 3b 0d etLastError());.
c970: 0a 23 65 6c 69 66 20 21 53 51 4c 49 54 45 5f 53 .#elif !SQLITE_S
c980: 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 20 TANDARD..
c990: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
c9a0: 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 n = UnsafeNativ
c9b0: 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
c9c0: 5f 62 69 6e 64 5f 64 6f 75 62 6c 65 5f 69 6e 74 _bind_double_int
c9d0: 65 72 6f 70 28 68 61 6e 64 6c 65 2c 20 69 6e 64 erop(handle, ind
c9e0: 65 78 2c 20 72 65 66 20 76 61 6c 75 65 29 3b 0d ex, ref value);.
c9f0: 0a 20 20 20 20 20 20 20 20 69 66 20 28 6e 20 21 . if (n !
ca00: 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 = SQLiteErrorCod
ca10: 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 77 20 e.Ok) throw new
ca20: 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 SQLiteException(
ca30: 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f 72 28 n, GetLastError(
ca40: 29 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 ));..#else..
ca50: 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 4e 6f throw new No
ca60: 74 49 6d 70 6c 65 6d 65 6e 74 65 64 45 78 63 65 tImplementedExce
ca70: 70 74 69 6f 6e 28 29 3b 0d 0a 23 65 6e 64 69 66 ption();..#endif
ca80: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
ca90: 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
caa0: 20 76 6f 69 64 20 42 69 6e 64 5f 49 6e 74 33 32 void Bind_Int32
cab0: 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 (SQLiteStatement
cac0: 20 73 74 6d 74 2c 20 53 51 4c 69 74 65 43 6f 6e stmt, SQLiteCon
cad0: 6e 65 63 74 69 6f 6e 46 6c 61 67 73 20 66 6c 61 nectionFlags fla
cae0: 67 73 2c 20 69 6e 74 20 69 6e 64 65 78 2c 20 69 gs, int index, i
caf0: 6e 74 20 76 61 6c 75 65 29 0d 0a 20 20 20 20 7b nt value).. {
cb00: 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 .. SQLite
cb10: 53 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 StatementHandle
cb20: 68 61 6e 64 6c 65 20 3d 20 73 74 6d 74 2e 5f 73 handle = stmt._s
cb30: 71 6c 69 74 65 5f 73 74 6d 74 3b 0d 0a 0d 0a 20 qlite_stmt;....
cb40: 20 20 20 20 20 20 20 69 66 20 28 28 66 6c 61 67 if ((flag
cb50: 73 20 26 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 s & SQLiteConnec
cb60: 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f 67 42 69 6e tionFlags.LogBin
cb70: 64 29 20 3d 3d 20 53 51 4c 69 74 65 43 6f 6e 6e d) == SQLiteConn
cb80: 65 63 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f 67 42 ectionFlags.LogB
cb90: 69 6e 64 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d ind).. {.
cba0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 4c 6f 67 . Log
cbb0: 42 69 6e 64 28 68 61 6e 64 6c 65 2c 20 69 6e 64 Bind(handle, ind
cbc0: 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 20 20 ex, value);..
cbd0: 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 }....
cbe0: 20 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 SQLiteErrorCod
cbf0: 65 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 e n = UnsafeNati
cc00: 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
cc10: 33 5f 62 69 6e 64 5f 69 6e 74 28 68 61 6e 64 6c 3_bind_int(handl
cc20: 65 2c 20 69 6e 64 65 78 2c 20 76 61 6c 75 65 29 e, index, value)
cc30: 3b 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 6e ;.. if (n
cc40: 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 != SQLiteErrorC
cc50: 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 ode.Ok) throw ne
cc60: 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f w SQLiteExceptio
cc70: 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f n(n, GetLastErro
cc80: 72 28 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a r());.. }....
cc90: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
cca0: 72 72 69 64 65 20 76 6f 69 64 20 42 69 6e 64 5f rride void Bind_
ccb0: 55 49 6e 74 33 32 28 53 51 4c 69 74 65 53 74 61 UInt32(SQLiteSta
ccc0: 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 53 51 4c tement stmt, SQL
ccd0: 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 iteConnectionFla
cce0: 67 73 20 66 6c 61 67 73 2c 20 69 6e 74 20 69 6e gs flags, int in
ccf0: 64 65 78 2c 20 75 69 6e 74 20 76 61 6c 75 65 29 dex, uint value)
cd00: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
cd10: 20 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 SQLiteStatement
cd20: 48 61 6e 64 6c 65 20 68 61 6e 64 6c 65 20 3d 20 Handle handle =
cd30: 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d stmt._sqlite_stm
cd40: 74 3b 0d 0a 0d 0a 23 69 66 20 21 50 4c 41 54 46 t;....#if !PLATF
cd50: 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 ORM_COMPACTFRAME
cd60: 57 4f 52 4b 0d 0a 20 20 20 20 20 20 20 20 69 66 WORK.. if
cd70: 20 28 28 66 6c 61 67 73 20 26 20 53 51 4c 69 74 ((flags & SQLit
cd80: 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 eConnectionFlags
cd90: 2e 4c 6f 67 42 69 6e 64 29 20 3d 3d 20 53 51 4c .LogBind) == SQL
cda0: 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 iteConnectionFla
cdb0: 67 73 2e 4c 6f 67 42 69 6e 64 29 0d 0a 20 20 20 gs.LogBind)..
cdc0: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
cdd0: 20 20 20 20 4c 6f 67 42 69 6e 64 28 68 61 6e 64 LogBind(hand
cde0: 6c 65 2c 20 69 6e 64 65 78 2c 20 76 61 6c 75 65 le, index, value
cdf0: 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 23 );.. }..#
ce00: 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 endif....
ce10: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
ce20: 20 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 n;.... i
ce30: 66 20 28 28 66 6c 61 67 73 20 26 20 53 51 4c 69 f ((flags & SQLi
ce40: 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 teConnectionFlag
ce50: 73 2e 42 69 6e 64 55 49 6e 74 33 32 41 73 49 6e s.BindUInt32AsIn
ce60: 74 36 34 29 20 3d 3d 20 53 51 4c 69 74 65 43 6f t64) == SQLiteCo
ce70: 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e 42 69 nnectionFlags.Bi
ce80: 6e 64 55 49 6e 74 33 32 41 73 49 6e 74 36 34 29 ndUInt32AsInt64)
ce90: 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 .. {..
cea0: 20 20 20 20 20 20 20 20 20 6c 6f 6e 67 20 76 61 long va
ceb0: 6c 75 65 32 20 3d 20 76 61 6c 75 65 3b 0d 0a 0d lue2 = value;...
cec0: 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f 43 .#if !PLATFORM_C
ced0: 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 4b 0d OMPACTFRAMEWORK.
cee0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 6e 20 3d . n =
cef0: 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
cf00: 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 62 69 6e hods.sqlite3_bin
cf10: 64 5f 69 6e 74 36 34 28 68 61 6e 64 6c 65 2c 20 d_int64(handle,
cf20: 69 6e 64 65 78 2c 20 76 61 6c 75 65 32 29 3b 0d index, value2);.
cf30: 0a 23 65 6c 69 66 20 21 53 51 4c 49 54 45 5f 53 .#elif !SQLITE_S
cf40: 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 20 TANDARD..
cf50: 20 20 20 20 20 6e 20 3d 20 55 6e 73 61 66 65 4e n = UnsafeN
cf60: 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c ativeMethods.sql
cf70: 69 74 65 33 5f 62 69 6e 64 5f 69 6e 74 36 34 5f ite3_bind_int64_
cf80: 69 6e 74 65 72 6f 70 28 68 61 6e 64 6c 65 2c 20 interop(handle,
cf90: 69 6e 64 65 78 2c 20 72 65 66 20 76 61 6c 75 65 index, ref value
cfa0: 32 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 2);..#else..
cfb0: 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 throw ne
cfc0: 77 20 4e 6f 74 49 6d 70 6c 65 6d 65 6e 74 65 64 w NotImplemented
cfd0: 45 78 63 65 70 74 69 6f 6e 28 29 3b 0d 0a 23 65 Exception();..#e
cfe0: 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 7d 0d ndif.. }.
cff0: 0a 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 . else..
d000: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
d010: 20 20 20 20 20 20 6e 20 3d 20 55 6e 73 61 66 65 n = Unsafe
d020: 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
d030: 6c 69 74 65 33 5f 62 69 6e 64 5f 75 69 6e 74 28 lite3_bind_uint(
d040: 68 61 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 76 handle, index, v
d050: 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 alue);..
d060: 7d 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 6e }.. if (n
d070: 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 != SQLiteErrorC
d080: 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 ode.Ok) throw ne
d090: 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f w SQLiteExceptio
d0a0: 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f n(n, GetLastErro
d0b0: 72 28 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a r());.. }....
d0c0: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
d0d0: 72 72 69 64 65 20 76 6f 69 64 20 42 69 6e 64 5f rride void Bind_
d0e0: 49 6e 74 36 34 28 53 51 4c 69 74 65 53 74 61 74 Int64(SQLiteStat
d0f0: 65 6d 65 6e 74 20 73 74 6d 74 2c 20 53 51 4c 69 ement stmt, SQLi
d100: 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 teConnectionFlag
d110: 73 20 66 6c 61 67 73 2c 20 69 6e 74 20 69 6e 64 s flags, int ind
d120: 65 78 2c 20 6c 6f 6e 67 20 76 61 6c 75 65 29 0d ex, long value).
d130: 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 . {..
d140: 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 48 SQLiteStatementH
d150: 61 6e 64 6c 65 20 68 61 6e 64 6c 65 20 3d 20 73 andle handle = s
d160: 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 tmt._sqlite_stmt
d170: 3b 0d 0a 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f ;....#if !PLATFO
d180: 52 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 RM_COMPACTFRAMEW
d190: 4f 52 4b 0d 0a 20 20 20 20 20 20 20 20 69 66 20 ORK.. if
d1a0: 28 28 66 6c 61 67 73 20 26 20 53 51 4c 69 74 65 ((flags & SQLite
d1b0: 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e ConnectionFlags.
d1c0: 4c 6f 67 42 69 6e 64 29 20 3d 3d 20 53 51 4c 69 LogBind) == SQLi
d1d0: 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 teConnectionFlag
d1e0: 73 2e 4c 6f 67 42 69 6e 64 29 0d 0a 20 20 20 20 s.LogBind)..
d1f0: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
d200: 20 20 20 4c 6f 67 42 69 6e 64 28 68 61 6e 64 6c LogBind(handl
d210: 65 2c 20 69 6e 64 65 78 2c 20 76 61 6c 75 65 29 e, index, value)
d220: 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a ;.. }....
d230: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 SQLiteEr
d240: 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 rorCode n = Unsa
d250: 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
d260: 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 69 6e 74 sqlite3_bind_int
d270: 36 34 28 68 61 6e 64 6c 65 2c 20 69 6e 64 65 78 64(handle, index
d280: 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 , value);..
d290: 20 20 20 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 if (n != SQLi
d2a0: 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 teErrorCode.Ok)
d2b0: 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 throw new SQLite
d2c0: 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 Exception(n, Get
d2d0: 4c 61 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a 23 LastError());..#
d2e0: 65 6c 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 elif !SQLITE_STA
d2f0: 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 20 20 53 NDARD.. S
d300: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 6e QLiteErrorCode n
d310: 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d = UnsafeNativeM
d320: 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 62 ethods.sqlite3_b
d330: 69 6e 64 5f 69 6e 74 36 34 5f 69 6e 74 65 72 6f ind_int64_intero
d340: 70 28 68 61 6e 64 6c 65 2c 20 69 6e 64 65 78 2c p(handle, index,
d350: 20 72 65 66 20 76 61 6c 75 65 29 3b 0d 0a 20 20 ref value);..
d360: 20 20 20 20 20 20 69 66 20 28 6e 20 21 3d 20 53 if (n != S
d370: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f QLiteErrorCode.O
d380: 6b 29 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c k) throw new SQL
d390: 69 74 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 iteException(n,
d3a0: 47 65 74 4c 61 73 74 45 72 72 6f 72 28 29 29 3b GetLastError());
d3b0: 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 ..#else..
d3c0: 20 74 68 72 6f 77 20 6e 65 77 20 4e 6f 74 49 6d throw new NotIm
d3d0: 70 6c 65 6d 65 6e 74 65 64 45 78 63 65 70 74 69 plementedExcepti
d3e0: 6f 6e 28 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 on();..#endif..
d3f0: 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 }.... inte
d400: 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f rnal override vo
d410: 69 64 20 42 69 6e 64 5f 55 49 6e 74 36 34 28 53 id Bind_UInt64(S
d420: 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 QLiteStatement s
d430: 74 6d 74 2c 20 53 51 4c 69 74 65 43 6f 6e 6e 65 tmt, SQLiteConne
d440: 63 74 69 6f 6e 46 6c 61 67 73 20 66 6c 61 67 73 ctionFlags flags
d450: 2c 20 69 6e 74 20 69 6e 64 65 78 2c 20 75 6c 6f , int index, ulo
d460: 6e 67 20 76 61 6c 75 65 29 0d 0a 20 20 20 20 7b ng value).. {
d470: 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 .. SQLite
d480: 53 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 StatementHandle
d490: 68 61 6e 64 6c 65 20 3d 20 73 74 6d 74 2e 5f 73 handle = stmt._s
d4a0: 71 6c 69 74 65 5f 73 74 6d 74 3b 0d 0a 0d 0a 23 qlite_stmt;....#
d4b0: 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d if !PLATFORM_COM
d4c0: 50 41 43 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 PACTFRAMEWORK..
d4d0: 20 20 20 20 20 20 20 69 66 20 28 28 66 6c 61 67 if ((flag
d4e0: 73 20 26 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 s & SQLiteConnec
d4f0: 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f 67 42 69 6e tionFlags.LogBin
d500: 64 29 20 3d 3d 20 53 51 4c 69 74 65 43 6f 6e 6e d) == SQLiteConn
d510: 65 63 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f 67 42 ectionFlags.LogB
d520: 69 6e 64 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d ind).. {.
d530: 0a 20 20 20 20 20 20 20 20 20 20 20 20 4c 6f 67 . Log
d540: 42 69 6e 64 28 68 61 6e 64 6c 65 2c 20 69 6e 64 Bind(handle, ind
d550: 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 20 20 ex, value);..
d560: 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 }....
d570: 20 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 SQLiteErrorCod
d580: 65 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 e n = UnsafeNati
d590: 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
d5a0: 33 5f 62 69 6e 64 5f 75 69 6e 74 36 34 28 68 61 3_bind_uint64(ha
d5b0: 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 76 61 6c ndle, index, val
d5c0: 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 69 66 ue);.. if
d5d0: 20 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 72 (n != SQLiteErr
d5e0: 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 orCode.Ok) throw
d5f0: 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 new SQLiteExcep
d600: 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 tion(n, GetLastE
d610: 72 72 6f 72 28 29 29 3b 0d 0a 23 65 6c 69 66 20 rror());..#elif
d620: 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 !SQLITE_STANDARD
d630: 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 .. SQLite
d640: 45 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e ErrorCode n = Un
d650: 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
d660: 73 2e 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 75 s.sqlite3_bind_u
d670: 69 6e 74 36 34 5f 69 6e 74 65 72 6f 70 28 68 61 int64_interop(ha
d680: 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 72 65 66 ndle, index, ref
d690: 20 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 value);..
d6a0: 20 20 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 if (n != SQLit
d6b0: 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 eErrorCode.Ok) t
d6c0: 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 hrow new SQLiteE
d6d0: 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c xception(n, GetL
d6e0: 61 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a 23 65 astError());..#e
d6f0: 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 74 68 72 lse.. thr
d700: 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 6d ow new NotImplem
d710: 65 6e 74 65 64 45 78 63 65 70 74 69 6f 6e 28 29 entedException()
d720: 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d ;..#endif.. }
d730: 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
d740: 20 6f 76 65 72 72 69 64 65 20 76 6f 69 64 20 42 override void B
d750: 69 6e 64 5f 54 65 78 74 28 53 51 4c 69 74 65 53 ind_Text(SQLiteS
d760: 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 53 tatement stmt, S
d770: 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 QLiteConnectionF
d780: 6c 61 67 73 20 66 6c 61 67 73 2c 20 69 6e 74 20 lags flags, int
d790: 69 6e 64 65 78 2c 20 73 74 72 69 6e 67 20 76 61 index, string va
d7a0: 6c 75 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 lue).. {..
d7b0: 20 20 20 20 20 53 51 4c 69 74 65 53 74 61 74 65 SQLiteState
d7c0: 6d 65 6e 74 48 61 6e 64 6c 65 20 68 61 6e 64 6c mentHandle handl
d7d0: 65 20 3d 20 73 74 6d 74 2e 5f 73 71 6c 69 74 65 e = stmt._sqlite
d7e0: 5f 73 74 6d 74 3b 0d 0a 0d 0a 23 69 66 20 21 50 _stmt;....#if !P
d7f0: 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 LATFORM_COMPACTF
d800: 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 20 20 RAMEWORK..
d810: 20 20 69 66 20 28 28 66 6c 61 67 73 20 26 20 53 if ((flags & S
d820: 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 QLiteConnectionF
d830: 6c 61 67 73 2e 4c 6f 67 42 69 6e 64 29 20 3d 3d lags.LogBind) ==
d840: 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f SQLiteConnectio
d850: 6e 46 6c 61 67 73 2e 4c 6f 67 42 69 6e 64 29 0d nFlags.LogBind).
d860: 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 . {..
d870: 20 20 20 20 20 20 20 20 4c 6f 67 42 69 6e 64 28 LogBind(
d880: 68 61 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 76 handle, index, v
d890: 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 alue);..
d8a0: 7d 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 }..#endif....
d8b0: 20 20 20 20 20 62 79 74 65 5b 5d 20 62 20 3d 20 byte[] b =
d8c0: 54 6f 55 54 46 38 28 76 61 6c 75 65 29 3b 0d 0a ToUTF8(value);..
d8d0: 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f ..#if !PLATFORM_
d8e0: 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 4b COMPACTFRAMEWORK
d8f0: 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 28 66 .. if ((f
d900: 6c 61 67 73 20 26 20 53 51 4c 69 74 65 43 6f 6e lags & SQLiteCon
d910: 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f 67 nectionFlags.Log
d920: 42 69 6e 64 29 20 3d 3d 20 53 51 4c 69 74 65 43 Bind) == SQLiteC
d930: 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e 4c onnectionFlags.L
d940: 6f 67 42 69 6e 64 29 0d 0a 20 20 20 20 20 20 20 ogBind)..
d950: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
d960: 4c 6f 67 42 69 6e 64 28 68 61 6e 64 6c 65 2c 20 LogBind(handle,
d970: 69 6e 64 65 78 2c 20 62 29 3b 0d 0a 20 20 20 20 index, b);..
d980: 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d 0a 0d }..#endif...
d990: 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 . SQLiteE
d9a0: 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 rrorCode n = Uns
d9b0: 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
d9c0: 2e 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 74 65 .sqlite3_bind_te
d9d0: 78 74 28 68 61 6e 64 6c 65 2c 20 69 6e 64 65 78 xt(handle, index
d9e0: 2c 20 62 2c 20 62 2e 4c 65 6e 67 74 68 20 2d 20 , b, b.Length -
d9f0: 31 2c 20 28 49 6e 74 50 74 72 29 28 2d 31 29 29 1, (IntPtr)(-1))
da00: 3b 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 6e ;.. if (n
da10: 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 != SQLiteErrorC
da20: 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 ode.Ok) throw ne
da30: 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f w SQLiteExceptio
da40: 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f n(n, GetLastErro
da50: 72 28 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a r());.. }....
da60: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
da70: 72 72 69 64 65 20 76 6f 69 64 20 42 69 6e 64 5f rride void Bind_
da80: 44 61 74 65 54 69 6d 65 28 53 51 4c 69 74 65 53 DateTime(SQLiteS
da90: 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 53 tatement stmt, S
daa0: 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 QLiteConnectionF
dab0: 6c 61 67 73 20 66 6c 61 67 73 2c 20 69 6e 74 20 lags flags, int
dac0: 69 6e 64 65 78 2c 20 44 61 74 65 54 69 6d 65 20 index, DateTime
dad0: 64 74 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 dt).. {..
dae0: 20 20 20 20 53 51 4c 69 74 65 53 74 61 74 65 6d SQLiteStatem
daf0: 65 6e 74 48 61 6e 64 6c 65 20 68 61 6e 64 6c 65 entHandle handle
db00: 20 3d 20 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f = stmt._sqlite_
db10: 73 74 6d 74 3b 0d 0a 0d 0a 23 69 66 20 21 50 4c stmt;....#if !PL
db20: 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 52 ATFORM_COMPACTFR
db30: 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 20 20 20 AMEWORK..
db40: 20 69 66 20 28 28 66 6c 61 67 73 20 26 20 53 51 if ((flags & SQ
db50: 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c LiteConnectionFl
db60: 61 67 73 2e 4c 6f 67 42 69 6e 64 29 20 3d 3d 20 ags.LogBind) ==
db70: 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e SQLiteConnection
db80: 46 6c 61 67 73 2e 4c 6f 67 42 69 6e 64 29 0d 0a Flags.LogBind)..
db90: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
dba0: 20 20 20 20 20 20 20 4c 6f 67 42 69 6e 64 28 68 LogBind(h
dbb0: 61 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 64 74 andle, index, dt
dbc0: 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 23 );.. }..#
dbd0: 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 endif....
dbe0: 20 69 66 20 28 28 66 6c 61 67 73 20 26 20 53 51 if ((flags & SQ
dbf0: 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c LiteConnectionFl
dc00: 61 67 73 2e 42 69 6e 64 44 61 74 65 54 69 6d 65 ags.BindDateTime
dc10: 57 69 74 68 4b 69 6e 64 29 20 3d 3d 20 53 51 4c WithKind) == SQL
dc20: 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 iteConnectionFla
dc30: 67 73 2e 42 69 6e 64 44 61 74 65 54 69 6d 65 57 gs.BindDateTimeW
dc40: 69 74 68 4b 69 6e 64 29 0d 0a 20 20 20 20 20 20 ithKind)..
dc50: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
dc60: 20 69 66 20 28 28 5f 64 61 74 65 74 69 6d 65 4b if ((_datetimeK
dc70: 69 6e 64 20 21 3d 20 44 61 74 65 54 69 6d 65 4b ind != DateTimeK
dc80: 69 6e 64 2e 55 6e 73 70 65 63 69 66 69 65 64 29 ind.Unspecified)
dc90: 20 26 26 0d 0a 20 20 20 20 20 20 20 20 20 20 20 &&..
dca0: 20 20 20 20 20 28 64 74 2e 4b 69 6e 64 20 21 3d (dt.Kind !=
dcb0: 20 44 61 74 65 54 69 6d 65 4b 69 6e 64 2e 55 6e DateTimeKind.Un
dcc0: 73 70 65 63 69 66 69 65 64 29 20 26 26 0d 0a 20 specified) &&..
dcd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 (
dce0: 64 74 2e 4b 69 6e 64 20 21 3d 20 5f 64 61 74 65 dt.Kind != _date
dcf0: 74 69 6d 65 4b 69 6e 64 29 29 0d 0a 20 20 20 20 timeKind))..
dd00: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
dd10: 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 5f if (_
dd20: 64 61 74 65 74 69 6d 65 4b 69 6e 64 20 3d 3d 20 datetimeKind ==
dd30: 44 61 74 65 54 69 6d 65 4b 69 6e 64 2e 55 74 63 DateTimeKind.Utc
dd40: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )..
dd50: 20 20 20 20 20 20 20 64 74 20 3d 20 64 74 2e 54 dt = dt.T
dd60: 6f 55 6e 69 76 65 72 73 61 6c 54 69 6d 65 28 29 oUniversalTime()
dd70: 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ;..
dd80: 20 20 20 65 6c 73 65 20 69 66 20 28 5f 64 61 74 else if (_dat
dd90: 65 74 69 6d 65 4b 69 6e 64 20 3d 3d 20 44 61 74 etimeKind == Dat
dda0: 65 54 69 6d 65 4b 69 6e 64 2e 4c 6f 63 61 6c 29 eTimeKind.Local)
ddb0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
ddc0: 20 20 20 20 20 20 64 74 20 3d 20 64 74 2e 54 6f dt = dt.To
ddd0: 4c 6f 63 61 6c 54 69 6d 65 28 29 3b 0d 0a 20 20 LocalTime();..
dde0: 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 }..
ddf0: 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 }....
de00: 20 20 73 77 69 74 63 68 20 28 5f 64 61 74 65 74 switch (_datet
de10: 69 6d 65 46 6f 72 6d 61 74 29 0d 0a 20 20 20 20 imeFormat)..
de20: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
de30: 20 20 20 63 61 73 65 20 53 51 4c 69 74 65 44 61 case SQLiteDa
de40: 74 65 46 6f 72 6d 61 74 73 2e 54 69 63 6b 73 3a teFormats.Ticks:
de50: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
de60: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
de70: 20 20 20 20 20 20 20 20 20 6c 6f 6e 67 20 76 61 long va
de80: 6c 75 65 20 3d 20 64 74 2e 54 69 63 6b 73 3b 0d lue = dt.Ticks;.
de90: 0a 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 4d ...#if !PLATFORM
dea0: 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 _COMPACTFRAMEWOR
deb0: 4b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 K..
dec0: 20 20 20 20 20 20 20 69 66 20 28 28 66 6c 61 67 if ((flag
ded0: 73 20 26 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 s & SQLiteConnec
dee0: 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f 67 42 69 6e tionFlags.LogBin
def0: 64 29 20 3d 3d 20 53 51 4c 69 74 65 43 6f 6e 6e d) == SQLiteConn
df00: 65 63 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f 67 42 ectionFlags.LogB
df10: 69 6e 64 29 0d 0a 20 20 20 20 20 20 20 20 20 20 ind)..
df20: 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
df30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
df40: 20 20 20 20 20 4c 6f 67 42 69 6e 64 28 68 61 6e LogBind(han
df50: 64 6c 65 2c 20 69 6e 64 65 78 2c 20 76 61 6c 75 dle, index, valu
df60: 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 e);..
df70: 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 }....
df80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
df90: 20 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 SQLiteErrorCod
dfa0: 65 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 e n = UnsafeNati
dfb0: 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
dfc0: 33 5f 62 69 6e 64 5f 69 6e 74 36 34 28 68 61 6e 3_bind_int64(han
dfd0: 64 6c 65 2c 20 69 6e 64 65 78 2c 20 76 61 6c 75 dle, index, valu
dfe0: 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 e);..
dff0: 20 20 20 20 20 20 20 20 20 69 66 20 28 6e 20 21 if (n !
e000: 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 = SQLiteErrorCod
e010: 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 77 20 e.Ok) throw new
e020: 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 SQLiteException(
e030: 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f 72 28 n, GetLastError(
e040: 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ));..
e050: 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d break;.
e060: 0a 23 65 6c 69 66 20 21 53 51 4c 49 54 45 5f 53 .#elif !SQLITE_S
e070: 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 20 TANDARD..
e080: 20 20 20 20 20 20 20 20 20 20 20 20 20 53 51 4c SQL
e090: 69 74 65 45 72 72 6f 72 43 6f 64 65 20 6e 20 3d iteErrorCode n =
e0a0: 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
e0b0: 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 62 69 6e hods.sqlite3_bin
e0c0: 64 5f 69 6e 74 36 34 5f 69 6e 74 65 72 6f 70 28 d_int64_interop(
e0d0: 68 61 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 72 handle, index, r
e0e0: 65 66 20 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 ef value);..
e0f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e100: 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 if (n != SQLiteE
e110: 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 68 72 rrorCode.Ok) thr
e120: 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 ow new SQLiteExc
e130: 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 eption(n, GetLas
e140: 74 45 72 72 6f 72 28 29 29 3b 0d 0a 20 20 20 20 tError());..
e150: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e160: 62 72 65 61 6b 3b 0d 0a 23 65 6c 73 65 0d 0a 20 break;..#else..
e170: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e180: 20 20 20 74 68 72 6f 77 20 6e 65 77 20 4e 6f 74 throw new Not
e190: 49 6d 70 6c 65 6d 65 6e 74 65 64 45 78 63 65 70 ImplementedExcep
e1a0: 74 69 6f 6e 28 29 3b 0d 0a 23 65 6e 64 69 66 0d tion();..#endif.
e1b0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
e1c0: 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 }..
e1d0: 63 61 73 65 20 53 51 4c 69 74 65 44 61 74 65 46 case SQLiteDateF
e1e0: 6f 72 6d 61 74 73 2e 4a 75 6c 69 61 6e 44 61 79 ormats.JulianDay
e1f0: 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 :..
e200: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
e210: 20 20 20 20 20 20 20 20 20 20 64 6f 75 62 6c 65 double
e220: 20 76 61 6c 75 65 20 3d 20 54 6f 4a 75 6c 69 61 value = ToJulia
e230: 6e 44 61 79 28 64 74 29 3b 0d 0a 0d 0a 23 69 66 nDay(dt);....#if
e240: 20 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 !PLATFORM_COMPA
e250: 43 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 CTFRAMEWORK..
e260: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e270: 20 69 66 20 28 28 66 6c 61 67 73 20 26 20 53 51 if ((flags & SQ
e280: 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c LiteConnectionFl
e290: 61 67 73 2e 4c 6f 67 42 69 6e 64 29 20 3d 3d 20 ags.LogBind) ==
e2a0: 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e SQLiteConnection
e2b0: 46 6c 61 67 73 2e 4c 6f 67 42 69 6e 64 29 0d 0a Flags.LogBind)..
e2c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e2d0: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
e2e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 4c L
e2f0: 6f 67 42 69 6e 64 28 68 61 6e 64 6c 65 2c 20 69 ogBind(handle, i
e300: 6e 64 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 ndex, value);..
e310: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e320: 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 }....
e330: 20 20 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 SQLi
e340: 74 65 45 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 teErrorCode n =
e350: 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
e360: 6f 64 73 2e 73 71 6c 69 74 65 33 5f 62 69 6e 64 ods.sqlite3_bind
e370: 5f 64 6f 75 62 6c 65 28 68 61 6e 64 6c 65 2c 20 _double(handle,
e380: 69 6e 64 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a index, value);..
e390: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e3a0: 20 20 20 20 69 66 20 28 6e 20 21 3d 20 53 51 4c if (n != SQL
e3b0: 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 iteErrorCode.Ok)
e3c0: 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 throw new SQLit
e3d0: 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 eException(n, Ge
e3e0: 74 4c 61 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a tLastError());..
e3f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e400: 20 20 20 20 62 72 65 61 6b 3b 0d 0a 23 65 6c 69 break;..#eli
e410: 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 f !SQLITE_STANDA
e420: 52 44 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 RD..
e430: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 SQLiteEr
e440: 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 rorCode n = Unsa
e450: 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
e460: 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 64 6f 75 sqlite3_bind_dou
e470: 62 6c 65 5f 69 6e 74 65 72 6f 70 28 68 61 6e 64 ble_interop(hand
e480: 6c 65 2c 20 69 6e 64 65 78 2c 20 72 65 66 20 76 le, index, ref v
e490: 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 alue);..
e4a0: 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 if (
e4b0: 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 n != SQLiteError
e4c0: 43 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e Code.Ok) throw n
e4d0: 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 ew SQLiteExcepti
e4e0: 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 on(n, GetLastErr
e4f0: 6f 72 28 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 or());..
e500: 20 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 brea
e510: 6b 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 k;..#else..
e520: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 t
e530: 68 72 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c hrow new NotImpl
e540: 65 6d 65 6e 74 65 64 45 78 63 65 70 74 69 6f 6e ementedException
e550: 28 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 ();..#endif..
e560: 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a }..
e570: 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 case
e580: 20 53 51 4c 69 74 65 44 61 74 65 46 6f 72 6d 61 SQLiteDateForma
e590: 74 73 2e 55 6e 69 78 45 70 6f 63 68 3a 0d 0a 20 ts.UnixEpoch:..
e5a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b {
e5b0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
e5c0: 20 20 20 20 20 20 6c 6f 6e 67 20 76 61 6c 75 65 long value
e5d0: 20 3d 20 43 6f 6e 76 65 72 74 2e 54 6f 49 6e 74 = Convert.ToInt
e5e0: 36 34 28 64 74 2e 53 75 62 74 72 61 63 74 28 55 64(dt.Subtract(U
e5f0: 6e 69 78 45 70 6f 63 68 29 2e 54 6f 74 61 6c 53 nixEpoch).TotalS
e600: 65 63 6f 6e 64 73 29 3b 0d 0a 0d 0a 23 69 66 20 econds);....#if
e610: 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 !PLATFORM_COMPAC
e620: 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 TFRAMEWORK..
e630: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e640: 69 66 20 28 28 66 6c 61 67 73 20 26 20 53 51 4c if ((flags & SQL
e650: 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 iteConnectionFla
e660: 67 73 2e 4c 6f 67 42 69 6e 64 29 20 3d 3d 20 53 gs.LogBind) == S
e670: 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 QLiteConnectionF
e680: 6c 61 67 73 2e 4c 6f 67 42 69 6e 64 29 0d 0a 20 lags.LogBind)..
e690: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e6a0: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
e6b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 4c 6f Lo
e6c0: 67 42 69 6e 64 28 68 61 6e 64 6c 65 2c 20 69 6e gBind(handle, in
e6d0: 64 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 20 dex, value);..
e6e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e6f0: 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 }....
e700: 20 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 SQLit
e710: 65 45 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 eErrorCode n = U
e720: 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
e730: 64 73 2e 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f ds.sqlite3_bind_
e740: 69 6e 74 36 34 28 68 61 6e 64 6c 65 2c 20 69 6e int64(handle, in
e750: 64 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 20 dex, value);..
e760: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e770: 20 20 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 if (n != SQLit
e780: 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 eErrorCode.Ok) t
e790: 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 hrow new SQLiteE
e7a0: 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c xception(n, GetL
e7b0: 61 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a 20 20 astError());..
e7c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e7d0: 20 20 62 72 65 61 6b 3b 0d 0a 23 65 6c 69 66 20 break;..#elif
e7e0: 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 !SQLITE_STANDARD
e7f0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
e800: 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 6f SQLiteErro
e810: 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 66 65 rCode n = Unsafe
e820: 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
e830: 6c 69 74 65 33 5f 62 69 6e 64 5f 69 6e 74 36 34 lite3_bind_int64
e840: 5f 69 6e 74 65 72 6f 70 28 68 61 6e 64 6c 65 2c _interop(handle,
e850: 20 69 6e 64 65 78 2c 20 72 65 66 20 76 61 6c 75 index, ref valu
e860: 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 e);..
e870: 20 20 20 20 20 20 20 20 20 69 66 20 28 6e 20 21 if (n !
e880: 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 = SQLiteErrorCod
e890: 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 77 20 e.Ok) throw new
e8a0: 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 SQLiteException(
e8b0: 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f 72 28 n, GetLastError(
e8c0: 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ));..
e8d0: 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d break;.
e8e0: 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 .#else..
e8f0: 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f thro
e900: 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 6d 65 w new NotImpleme
e910: 6e 74 65 64 45 78 63 65 70 74 69 6f 6e 28 29 3b ntedException();
e920: 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 ..#endif..
e930: 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 }..
e940: 20 20 20 20 20 20 20 20 20 64 65 66 61 75 6c 74 default
e950: 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 :..
e960: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
e970: 20 20 20 20 20 20 20 20 20 20 62 79 74 65 5b 5d byte[]
e980: 20 62 20 3d 20 54 6f 55 54 46 38 28 64 74 29 3b b = ToUTF8(dt);
e990: 0d 0a 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 ....#if !PLATFOR
e9a0: 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f M_COMPACTFRAMEWO
e9b0: 52 4b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 RK..
e9c0: 20 20 20 20 20 20 20 20 69 66 20 28 28 66 6c 61 if ((fla
e9d0: 67 73 20 26 20 53 51 4c 69 74 65 43 6f 6e 6e 65 gs & SQLiteConne
e9e0: 63 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f 67 42 69 ctionFlags.LogBi
e9f0: 6e 64 29 20 3d 3d 20 53 51 4c 69 74 65 43 6f 6e nd) == SQLiteCon
ea00: 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f 67 nectionFlags.Log
ea10: 42 69 6e 64 29 0d 0a 20 20 20 20 20 20 20 20 20 Bind)..
ea20: 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 {..
ea30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
ea40: 20 20 20 20 20 20 4c 6f 67 42 69 6e 64 28 68 61 LogBind(ha
ea50: 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 62 29 3b ndle, index, b);
ea60: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
ea70: 20 20 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d }..#endif.
ea80: 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ...
ea90: 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 SQLiteErr
eaa0: 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 66 orCode n = Unsaf
eab0: 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
eac0: 71 6c 69 74 65 33 5f 62 69 6e 64 5f 74 65 78 74 qlite3_bind_text
ead0: 28 68 61 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 (handle, index,
eae0: 62 2c 20 62 2e 4c 65 6e 67 74 68 20 2d 20 31 2c b, b.Length - 1,
eaf0: 20 28 49 6e 74 50 74 72 29 28 2d 31 29 29 3b 0d (IntPtr)(-1));.
eb00: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
eb10: 20 20 20 20 20 69 66 20 28 6e 20 21 3d 20 53 51 if (n != SQ
eb20: 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b LiteErrorCode.Ok
eb30: 29 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 ) throw new SQLi
eb40: 74 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 teException(n, G
eb50: 65 74 4c 61 73 74 45 72 72 6f 72 28 29 29 3b 0d etLastError());.
eb60: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
eb70: 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 break;..
eb80: 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a }..
eb90: 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d }.. }
eba0: 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
ebb0: 20 6f 76 65 72 72 69 64 65 20 76 6f 69 64 20 42 override void B
ebc0: 69 6e 64 5f 42 6c 6f 62 28 53 51 4c 69 74 65 53 ind_Blob(SQLiteS
ebd0: 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 53 tatement stmt, S
ebe0: 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 QLiteConnectionF
ebf0: 6c 61 67 73 20 66 6c 61 67 73 2c 20 69 6e 74 20 lags flags, int
ec00: 69 6e 64 65 78 2c 20 62 79 74 65 5b 5d 20 62 6c index, byte[] bl
ec10: 6f 62 44 61 74 61 29 0d 0a 20 20 20 20 7b 0d 0a obData).. {..
ec20: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 53 74 SQLiteSt
ec30: 61 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 68 61 atementHandle ha
ec40: 6e 64 6c 65 20 3d 20 73 74 6d 74 2e 5f 73 71 6c ndle = stmt._sql
ec50: 69 74 65 5f 73 74 6d 74 3b 0d 0a 0d 0a 23 69 66 ite_stmt;....#if
ec60: 20 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 !PLATFORM_COMPA
ec70: 43 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 CTFRAMEWORK..
ec80: 20 20 20 20 20 69 66 20 28 28 66 6c 61 67 73 20 if ((flags
ec90: 26 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 & SQLiteConnecti
eca0: 6f 6e 46 6c 61 67 73 2e 4c 6f 67 42 69 6e 64 29 onFlags.LogBind)
ecb0: 20 3d 3d 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 == SQLiteConnec
ecc0: 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f 67 42 69 6e tionFlags.LogBin
ecd0: 64 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 d).. {..
ece0: 20 20 20 20 20 20 20 20 20 20 20 4c 6f 67 42 69 LogBi
ecf0: 6e 64 28 68 61 6e 64 6c 65 2c 20 69 6e 64 65 78 nd(handle, index
ed00: 2c 20 62 6c 6f 62 44 61 74 61 29 3b 0d 0a 20 20 , blobData);..
ed10: 20 20 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d }..#endif.
ed20: 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 ... SQLit
ed30: 65 45 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 eErrorCode n = U
ed40: 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
ed50: 64 73 2e 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f ds.sqlite3_bind_
ed60: 62 6c 6f 62 28 68 61 6e 64 6c 65 2c 20 69 6e 64 blob(handle, ind
ed70: 65 78 2c 20 62 6c 6f 62 44 61 74 61 2c 20 62 6c ex, blobData, bl
ed80: 6f 62 44 61 74 61 2e 4c 65 6e 67 74 68 2c 20 28 obData.Length, (
ed90: 49 6e 74 50 74 72 29 28 2d 31 29 29 3b 0d 0a 20 IntPtr)(-1));..
eda0: 20 20 20 20 20 20 20 69 66 20 28 6e 20 21 3d 20 if (n !=
edb0: 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e SQLiteErrorCode.
edc0: 4f 6b 29 20 74 68 72 6f 77 20 6e 65 77 20 53 51 Ok) throw new SQ
edd0: 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c LiteException(n,
ede0: 20 47 65 74 4c 61 73 74 45 72 72 6f 72 28 29 29 GetLastError())
edf0: 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 ;.. }....
ee00: 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 internal overrid
ee10: 65 20 76 6f 69 64 20 42 69 6e 64 5f 4e 75 6c 6c e void Bind_Null
ee20: 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 (SQLiteStatement
ee30: 20 73 74 6d 74 2c 20 53 51 4c 69 74 65 43 6f 6e stmt, SQLiteCon
ee40: 6e 65 63 74 69 6f 6e 46 6c 61 67 73 20 66 6c 61 nectionFlags fla
ee50: 67 73 2c 20 69 6e 74 20 69 6e 64 65 78 29 0d 0a gs, int index)..
ee60: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 53 {.. S
ee70: 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 48 61 QLiteStatementHa
ee80: 6e 64 6c 65 20 68 61 6e 64 6c 65 20 3d 20 73 74 ndle handle = st
ee90: 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 3b mt._sqlite_stmt;
eea0: 0d 0a 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 ....#if !PLATFOR
eeb0: 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f M_COMPACTFRAMEWO
eec0: 52 4b 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 RK.. if (
eed0: 28 66 6c 61 67 73 20 26 20 53 51 4c 69 74 65 43 (flags & SQLiteC
eee0: 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e 4c onnectionFlags.L
eef0: 6f 67 42 69 6e 64 29 20 3d 3d 20 53 51 4c 69 74 ogBind) == SQLit
ef00: 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 eConnectionFlags
ef10: 2e 4c 6f 67 42 69 6e 64 29 0d 0a 20 20 20 20 20 .LogBind)..
ef20: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
ef30: 20 20 4c 6f 67 42 69 6e 64 28 68 61 6e 64 6c 65 LogBind(handle
ef40: 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 , index);..
ef50: 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a }..#endif....
ef60: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 SQLiteEr
ef70: 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 rorCode n = Unsa
ef80: 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
ef90: 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 6e 75 6c sqlite3_bind_nul
efa0: 6c 28 68 61 6e 64 6c 65 2c 20 69 6e 64 65 78 29 l(handle, index)
efb0: 3b 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 6e ;.. if (n
efc0: 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 != SQLiteErrorC
efd0: 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 ode.Ok) throw ne
efe0: 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f w SQLiteExceptio
eff0: 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f n(n, GetLastErro
f000: 72 28 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a r());.. }....
f010: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
f020: 72 72 69 64 65 20 69 6e 74 20 42 69 6e 64 5f 50 rride int Bind_P
f030: 61 72 61 6d 43 6f 75 6e 74 28 53 51 4c 69 74 65 aramCount(SQLite
f040: 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 Statement stmt,
f050: 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e SQLiteConnection
f060: 46 6c 61 67 73 20 66 6c 61 67 73 29 0d 0a 20 20 Flags flags)..
f070: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 53 51 4c {.. SQL
f080: 69 74 65 53 74 61 74 65 6d 65 6e 74 48 61 6e 64 iteStatementHand
f090: 6c 65 20 68 61 6e 64 6c 65 20 3d 20 73 74 6d 74 le handle = stmt
f0a0: 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 3b 0d 0a ._sqlite_stmt;..
f0b0: 20 20 20 20 20 20 20 20 69 6e 74 20 76 61 6c 75 int valu
f0c0: 65 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 e = UnsafeNative
f0d0: 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
f0e0: 62 69 6e 64 5f 70 61 72 61 6d 65 74 65 72 5f 63 bind_parameter_c
f0f0: 6f 75 6e 74 28 68 61 6e 64 6c 65 29 3b 0d 0a 0d ount(handle);...
f100: 0a 20 20 20 20 20 20 20 20 69 66 20 28 28 66 6c . if ((fl
f110: 61 67 73 20 26 20 53 51 4c 69 74 65 43 6f 6e 6e ags & SQLiteConn
f120: 65 63 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f 67 42 ectionFlags.LogB
f130: 69 6e 64 29 20 3d 3d 20 53 51 4c 69 74 65 43 6f ind) == SQLiteCo
f140: 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f nnectionFlags.Lo
f150: 67 42 69 6e 64 29 0d 0a 20 20 20 20 20 20 20 20 gBind)..
f160: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 {.. I
f170: 6e 74 50 74 72 20 68 61 6e 64 6c 65 49 6e 74 50 ntPtr handleIntP
f180: 74 72 20 3d 20 68 61 6e 64 6c 65 3b 0d 0a 0d 0a tr = handle;....
f190: 20 20 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 SQLi
f1a0: 74 65 4c 6f 67 2e 4c 6f 67 4d 65 73 73 61 67 65 teLog.LogMessage
f1b0: 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 (UnsafeNativeMet
f1c0: 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d 61 hods.StringForma
f1d0: 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 t(..
f1e0: 20 20 20 20 43 75 6c 74 75 72 65 49 6e 66 6f 2e CultureInfo.
f1f0: 43 75 72 72 65 6e 74 43 75 6c 74 75 72 65 2c 0d CurrentCulture,.
f200: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
f210: 20 22 53 74 61 74 65 6d 65 6e 74 20 7b 30 7d 20 "Statement {0}
f220: 70 61 72 61 6d 74 65 72 20 63 6f 75 6e 74 20 69 paramter count i
f230: 73 20 7b 31 7d 2e 22 2c 0d 0a 20 20 20 20 20 20 s {1}.",..
f240: 20 20 20 20 20 20 20 20 20 20 68 61 6e 64 6c 65 handle
f250: 49 6e 74 50 74 72 2c 20 76 61 6c 75 65 29 29 3b IntPtr, value));
f260: 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 .. }....
f270: 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 76 61 return va
f280: 6c 75 65 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 lue;.. }....
f290: 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 internal over
f2a0: 72 69 64 65 20 73 74 72 69 6e 67 20 42 69 6e 64 ride string Bind
f2b0: 5f 50 61 72 61 6d 4e 61 6d 65 28 53 51 4c 69 74 _ParamName(SQLit
f2c0: 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c eStatement stmt,
f2d0: 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f SQLiteConnectio
f2e0: 6e 46 6c 61 67 73 20 66 6c 61 67 73 2c 20 69 6e nFlags flags, in
f2f0: 74 20 69 6e 64 65 78 29 0d 0a 20 20 20 20 7b 0d t index).. {.
f300: 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 53 . SQLiteS
f310: 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 68 tatementHandle h
f320: 61 6e 64 6c 65 20 3d 20 73 74 6d 74 2e 5f 73 71 andle = stmt._sq
f330: 6c 69 74 65 5f 73 74 6d 74 3b 0d 0a 20 20 20 20 lite_stmt;..
f340: 20 20 20 20 73 74 72 69 6e 67 20 6e 61 6d 65 3b string name;
f350: 0d 0a 0d 0a 23 69 66 20 21 53 51 4c 49 54 45 5f ....#if !SQLITE_
f360: 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 STANDARD..
f370: 20 20 69 6e 74 20 6c 65 6e 20 3d 20 30 3b 0d 0a int len = 0;..
f380: 20 20 20 20 20 20 20 20 6e 61 6d 65 20 3d 20 55 name = U
f390: 54 46 38 54 6f 53 74 72 69 6e 67 28 55 6e 73 61 TF8ToString(Unsa
f3a0: 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
f3b0: 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 70 61 72 sqlite3_bind_par
f3c0: 61 6d 65 74 65 72 5f 6e 61 6d 65 5f 69 6e 74 65 ameter_name_inte
f3d0: 72 6f 70 28 68 61 6e 64 6c 65 2c 20 69 6e 64 65 rop(handle, inde
f3e0: 78 2c 20 72 65 66 20 6c 65 6e 29 2c 20 6c 65 6e x, ref len), len
f3f0: 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 );..#else..
f400: 20 20 20 6e 61 6d 65 20 3d 20 55 54 46 38 54 6f name = UTF8To
f410: 53 74 72 69 6e 67 28 55 6e 73 61 66 65 4e 61 74 String(UnsafeNat
f420: 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 iveMethods.sqlit
f430: 65 33 5f 62 69 6e 64 5f 70 61 72 61 6d 65 74 65 e3_bind_paramete
f440: 72 5f 6e 61 6d 65 28 68 61 6e 64 6c 65 2c 20 69 r_name(handle, i
f450: 6e 64 65 78 29 2c 20 2d 31 29 3b 0d 0a 23 65 6e ndex), -1);..#en
f460: 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 dif.... i
f470: 66 20 28 28 66 6c 61 67 73 20 26 20 53 51 4c 69 f ((flags & SQLi
f480: 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 teConnectionFlag
f490: 73 2e 4c 6f 67 42 69 6e 64 29 20 3d 3d 20 53 51 s.LogBind) == SQ
f4a0: 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c LiteConnectionFl
f4b0: 61 67 73 2e 4c 6f 67 42 69 6e 64 29 0d 0a 20 20 ags.LogBind)..
f4c0: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
f4d0: 20 20 20 20 20 49 6e 74 50 74 72 20 68 61 6e 64 IntPtr hand
f4e0: 6c 65 49 6e 74 50 74 72 20 3d 20 68 61 6e 64 6c leIntPtr = handl
f4f0: 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 e;....
f500: 20 20 53 51 4c 69 74 65 4c 6f 67 2e 4c 6f 67 4d SQLiteLog.LogM
f510: 65 73 73 61 67 65 28 55 6e 73 61 66 65 4e 61 74 essage(UnsafeNat
f520: 69 76 65 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e iveMethods.Strin
f530: 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 gFormat(..
f540: 20 20 20 20 20 20 20 20 20 20 43 75 6c 74 75 72 Cultur
f550: 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c eInfo.CurrentCul
f560: 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 ture,..
f570: 20 20 20 20 20 20 20 22 53 74 61 74 65 6d 65 6e "Statemen
f580: 74 20 7b 30 7d 20 70 61 72 61 6d 74 65 72 20 23 t {0} paramter #
f590: 7b 31 7d 20 6e 61 6d 65 20 69 73 20 7b 7b 7b 32 {1} name is {{{2
f5a0: 7d 7d 7d 2e 22 2c 0d 0a 20 20 20 20 20 20 20 20 }}}.",..
f5b0: 20 20 20 20 20 20 20 20 68 61 6e 64 6c 65 49 6e handleIn
f5c0: 74 50 74 72 2c 20 69 6e 64 65 78 2c 20 6e 61 6d tPtr, index, nam
f5d0: 65 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d e));.. }.
f5e0: 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 ... retur
f5f0: 6e 20 6e 61 6d 65 3b 0d 0a 20 20 20 20 7d 0d 0a n name;.. }..
f600: 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
f610: 76 65 72 72 69 64 65 20 69 6e 74 20 42 69 6e 64 verride int Bind
f620: 5f 50 61 72 61 6d 49 6e 64 65 78 28 53 51 4c 69 _ParamIndex(SQLi
f630: 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 teStatement stmt
f640: 2c 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 , SQLiteConnecti
f650: 6f 6e 46 6c 61 67 73 20 66 6c 61 67 73 2c 20 73 onFlags flags, s
f660: 74 72 69 6e 67 20 70 61 72 61 6d 4e 61 6d 65 29 tring paramName)
f670: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
f680: 20 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 SQLiteStatement
f690: 48 61 6e 64 6c 65 20 68 61 6e 64 6c 65 20 3d 20 Handle handle =
f6a0: 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d stmt._sqlite_stm
f6b0: 74 3b 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 20 t;.. int
f6c0: 69 6e 64 65 78 20 3d 20 55 6e 73 61 66 65 4e 61 index = UnsafeNa
f6d0: 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 tiveMethods.sqli
f6e0: 74 65 33 5f 62 69 6e 64 5f 70 61 72 61 6d 65 74 te3_bind_paramet
f6f0: 65 72 5f 69 6e 64 65 78 28 68 61 6e 64 6c 65 2c er_index(handle,
f700: 20 54 6f 55 54 46 38 28 70 61 72 61 6d 4e 61 6d ToUTF8(paramNam
f710: 65 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 e));....
f720: 69 66 20 28 28 66 6c 61 67 73 20 26 20 53 51 4c if ((flags & SQL
f730: 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 iteConnectionFla
f740: 67 73 2e 4c 6f 67 42 69 6e 64 29 20 3d 3d 20 53 gs.LogBind) == S
f750: 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 QLiteConnectionF
f760: 6c 61 67 73 2e 4c 6f 67 42 69 6e 64 29 0d 0a 20 lags.LogBind)..
f770: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
f780: 20 20 20 20 20 20 49 6e 74 50 74 72 20 68 61 6e IntPtr han
f790: 64 6c 65 49 6e 74 50 74 72 20 3d 20 68 61 6e 64 dleIntPtr = hand
f7a0: 6c 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 le;....
f7b0: 20 20 20 53 51 4c 69 74 65 4c 6f 67 2e 4c 6f 67 SQLiteLog.Log
f7c0: 4d 65 73 73 61 67 65 28 55 6e 73 61 66 65 4e 61 Message(UnsafeNa
f7d0: 74 69 76 65 4d 65 74 68 6f 64 73 2e 53 74 72 69 tiveMethods.Stri
f7e0: 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 ngFormat(..
f7f0: 20 20 20 20 20 20 20 20 20 20 20 43 75 6c 74 75 Cultu
f800: 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 reInfo.CurrentCu
f810: 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 lture,..
f820: 20 20 20 20 20 20 20 20 22 53 74 61 74 65 6d 65 "Stateme
f830: 6e 74 20 7b 30 7d 20 70 61 72 61 6d 74 65 72 20 nt {0} paramter
f840: 69 6e 64 65 78 20 6f 66 20 6e 61 6d 65 20 7b 7b index of name {{
f850: 7b 31 7d 7d 7d 20 69 73 20 23 7b 32 7d 2e 22 2c {1}}} is #{2}.",
f860: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
f870: 20 20 68 61 6e 64 6c 65 49 6e 74 50 74 72 2c 20 handleIntPtr,
f880: 70 61 72 61 6d 4e 61 6d 65 2c 20 69 6e 64 65 78 paramName, index
f890: 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a ));.. }..
f8a0: 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e .. return
f8b0: 20 69 6e 64 65 78 3b 0d 0a 20 20 20 20 7d 0d 0a index;.. }..
f8c0: 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
f8d0: 76 65 72 72 69 64 65 20 69 6e 74 20 43 6f 6c 75 verride int Colu
f8e0: 6d 6e 43 6f 75 6e 74 28 53 51 4c 69 74 65 53 74 mnCount(SQLiteSt
f8f0: 61 74 65 6d 65 6e 74 20 73 74 6d 74 29 0d 0a 20 atement stmt)..
f900: 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 65 74 75 {.. retu
f910: 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d rn UnsafeNativeM
f920: 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 ethods.sqlite3_c
f930: 6f 6c 75 6d 6e 5f 63 6f 75 6e 74 28 73 74 6d 74 olumn_count(stmt
f940: 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 29 3b 0d ._sqlite_stmt);.
f950: 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
f960: 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
f970: 73 74 72 69 6e 67 20 43 6f 6c 75 6d 6e 4e 61 6d string ColumnNam
f980: 65 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e e(SQLiteStatemen
f990: 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 t stmt, int inde
f9a0: 78 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 21 x).. {..#if !
f9b0: 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d SQLITE_STANDARD.
f9c0: 0a 20 20 20 20 20 20 69 6e 74 20 6c 65 6e 20 3d . int len =
f9d0: 20 30 3b 0d 0a 20 20 20 20 20 20 49 6e 74 50 74 0;.. IntPt
f9e0: 72 20 70 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 r p = UnsafeNati
f9f0: 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
fa00: 33 5f 63 6f 6c 75 6d 6e 5f 6e 61 6d 65 5f 69 6e 3_column_name_in
fa10: 74 65 72 6f 70 28 73 74 6d 74 2e 5f 73 71 6c 69 terop(stmt._sqli
fa20: 74 65 5f 73 74 6d 74 2c 20 69 6e 64 65 78 2c 20 te_stmt, index,
fa30: 72 65 66 20 6c 65 6e 29 3b 0d 0a 23 65 6c 73 65 ref len);..#else
fa40: 0d 0a 20 20 20 20 20 20 49 6e 74 50 74 72 20 70 .. IntPtr p
fa50: 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d = UnsafeNativeM
fa60: 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 ethods.sqlite3_c
fa70: 6f 6c 75 6d 6e 5f 6e 61 6d 65 28 73 74 6d 74 2e olumn_name(stmt.
fa80: 5f 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 6e _sqlite_stmt, in
fa90: 64 65 78 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 dex);..#endif..
faa0: 20 20 20 20 20 69 66 20 28 70 20 3d 3d 20 49 6e if (p == In
fab0: 74 50 74 72 2e 5a 65 72 6f 29 0d 0a 20 20 20 20 tPtr.Zero)..
fac0: 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 51 throw new SQ
fad0: 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 53 51 LiteException(SQ
fae0: 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4e 6f LiteErrorCode.No
faf0: 4d 65 6d 2c 20 47 65 74 4c 61 73 74 45 72 72 6f Mem, GetLastErro
fb00: 72 28 29 29 3b 0d 0a 23 69 66 20 21 53 51 4c 49 r());..#if !SQLI
fb10: 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 TE_STANDARD..
fb20: 20 20 20 72 65 74 75 72 6e 20 55 54 46 38 54 6f return UTF8To
fb30: 53 74 72 69 6e 67 28 70 2c 20 6c 65 6e 29 3b 0d String(p, len);.
fb40: 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 72 65 .#else.. re
fb50: 74 75 72 6e 20 55 54 46 38 54 6f 53 74 72 69 6e turn UTF8ToStrin
fb60: 67 28 70 2c 20 2d 31 29 3b 0d 0a 23 65 6e 64 69 g(p, -1);..#endi
fb70: 66 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 f.. }....
fb80: 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 internal overrid
fb90: 65 20 54 79 70 65 41 66 66 69 6e 69 74 79 20 43 e TypeAffinity C
fba0: 6f 6c 75 6d 6e 41 66 66 69 6e 69 74 79 28 53 51 olumnAffinity(SQ
fbb0: 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 LiteStatement st
fbc0: 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 29 0d 0a mt, int index)..
fbd0: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 65 74 {.. ret
fbe0: 75 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 urn UnsafeNative
fbf0: 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
fc00: 63 6f 6c 75 6d 6e 5f 74 79 70 65 28 73 74 6d 74 column_type(stmt
fc10: 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 ._sqlite_stmt, i
fc20: 6e 64 65 78 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d ndex);.. }...
fc30: 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
fc40: 65 72 72 69 64 65 20 73 74 72 69 6e 67 20 43 6f erride string Co
fc50: 6c 75 6d 6e 54 79 70 65 28 53 51 4c 69 74 65 53 lumnType(SQLiteS
fc60: 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 tatement stmt, i
fc70: 6e 74 20 69 6e 64 65 78 2c 20 72 65 66 20 54 79 nt index, ref Ty
fc80: 70 65 41 66 66 69 6e 69 74 79 20 6e 41 66 66 69 peAffinity nAffi
fc90: 6e 69 74 79 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 nity).. {..
fca0: 20 20 20 20 20 20 69 6e 74 20 6c 65 6e 3b 0d 0a int len;..
fcb0: 23 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e #if !SQLITE_STAN
fcc0: 44 41 52 44 0d 0a 20 20 20 20 20 20 20 20 6c 65 DARD.. le
fcd0: 6e 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 20 20 n = 0;..
fce0: 49 6e 74 50 74 72 20 70 20 3d 20 55 6e 73 61 66 IntPtr p = Unsaf
fcf0: 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
fd00: 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 64 65 qlite3_column_de
fd10: 63 6c 74 79 70 65 5f 69 6e 74 65 72 6f 70 28 73 cltype_interop(s
fd20: 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 tmt._sqlite_stmt
fd30: 2c 20 69 6e 64 65 78 2c 20 72 65 66 20 6c 65 6e , index, ref len
fd40: 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 );..#else..
fd50: 20 20 20 6c 65 6e 20 3d 20 2d 31 3b 0d 0a 20 20 len = -1;..
fd60: 20 20 20 20 20 20 49 6e 74 50 74 72 20 70 20 3d IntPtr p =
fd70: 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
fd80: 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c hods.sqlite3_col
fd90: 75 6d 6e 5f 64 65 63 6c 74 79 70 65 28 73 74 6d umn_decltype(stm
fda0: 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 t._sqlite_stmt,
fdb0: 69 6e 64 65 78 29 3b 0d 0a 23 65 6e 64 69 66 0d index);..#endif.
fdc0: 0a 20 20 20 20 20 20 20 20 6e 41 66 66 69 6e 69 . nAffini
fdd0: 74 79 20 3d 20 43 6f 6c 75 6d 6e 41 66 66 69 6e ty = ColumnAffin
fde0: 69 74 79 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 ity(stmt, index)
fdf0: 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 ;.... if
fe00: 28 28 70 20 21 3d 20 49 6e 74 50 74 72 2e 5a 65 ((p != IntPtr.Ze
fe10: 72 6f 29 20 26 26 20 28 28 6c 65 6e 20 3e 20 30 ro) && ((len > 0
fe20: 29 20 7c 7c 20 28 6c 65 6e 20 3d 3d 20 2d 31 29 ) || (len == -1)
fe30: 29 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 )).. {..
fe40: 20 20 20 20 20 20 20 20 20 20 20 73 74 72 69 6e strin
fe50: 67 20 64 65 63 6c 54 79 70 65 20 3d 20 55 54 46 g declType = UTF
fe60: 38 54 6f 53 74 72 69 6e 67 28 70 2c 20 6c 65 6e 8ToString(p, len
fe70: 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 );....
fe80: 20 20 69 66 20 28 21 53 74 72 69 6e 67 2e 49 73 if (!String.Is
fe90: 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 64 65 63 6c NullOrEmpty(decl
fea0: 54 79 70 65 29 29 0d 0a 20 20 20 20 20 20 20 20 Type))..
feb0: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 64 return d
fec0: 65 63 6c 54 79 70 65 3b 0d 0a 20 20 20 20 20 20 eclType;..
fed0: 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 73 }.... s
fee0: 74 72 69 6e 67 5b 5d 20 61 72 20 3d 20 73 74 6d tring[] ar = stm
fef0: 74 2e 54 79 70 65 44 65 66 69 6e 69 74 69 6f 6e t.TypeDefinition
ff00: 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 s;.... if
ff10: 20 28 61 72 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 (ar != null)..
ff20: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
ff30: 20 20 20 20 20 20 69 66 20 28 69 6e 64 65 78 20 if (index
ff40: 3c 20 61 72 2e 4c 65 6e 67 74 68 20 26 26 20 61 < ar.Length && a
ff50: 72 5b 69 6e 64 65 78 5d 20 21 3d 20 6e 75 6c 6c r[index] != null
ff60: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )..
ff70: 20 20 20 72 65 74 75 72 6e 20 61 72 5b 69 6e 64 return ar[ind
ff80: 65 78 5d 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d ex];.. }.
ff90: 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 ... retur
ffa0: 6e 20 53 74 72 69 6e 67 2e 45 6d 70 74 79 3b 0d n String.Empty;.
ffb0: 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
ffc0: 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
ffd0: 69 6e 74 20 43 6f 6c 75 6d 6e 49 6e 64 65 78 28 int ColumnIndex(
ffe0: 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 SQLiteStatement
fff0: 73 74 6d 74 2c 20 73 74 72 69 6e 67 20 63 6f 6c stmt, string col
10000 75 6d 6e 4e 61 6d 65 29 0d 0a 20 20 20 20 7b 0d umnName).. {.
10010 0a 20 20 20 20 20 20 69 6e 74 20 78 20 3d 20 43 . int x = C
10020 6f 6c 75 6d 6e 43 6f 75 6e 74 28 73 74 6d 74 29 olumnCount(stmt)
10030 3b 0d 0a 0d 0a 20 20 20 20 20 20 66 6f 72 20 28 ;.... for (
10040 69 6e 74 20 6e 20 3d 20 30 3b 20 6e 20 3c 20 78 int n = 0; n < x
10050 3b 20 6e 2b 2b 29 0d 0a 20 20 20 20 20 20 7b 0d ; n++).. {.
10060 0a 20 20 20 20 20 20 20 20 69 66 20 28 53 74 72 . if (Str
10070 69 6e 67 2e 43 6f 6d 70 61 72 65 28 63 6f 6c 75 ing.Compare(colu
10080 6d 6e 4e 61 6d 65 2c 20 43 6f 6c 75 6d 6e 4e 61 mnName, ColumnNa
10090 6d 65 28 73 74 6d 74 2c 20 6e 29 2c 20 53 74 72 me(stmt, n), Str
100a0 69 6e 67 43 6f 6d 70 61 72 69 73 6f 6e 2e 4f 72 ingComparison.Or
100b0 64 69 6e 61 6c 49 67 6e 6f 72 65 43 61 73 65 29 dinalIgnoreCase)
100c0 20 3d 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 == 0)..
100d0 20 20 72 65 74 75 72 6e 20 6e 3b 0d 0a 20 20 20 return n;..
100e0 20 20 20 7d 0d 0a 20 20 20 20 20 20 72 65 74 75 }.. retu
100f0 72 6e 20 2d 31 3b 0d 0a 20 20 20 20 7d 0d 0a 0d rn -1;.. }...
10100 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
10110 65 72 72 69 64 65 20 73 74 72 69 6e 67 20 43 6f erride string Co
10120 6c 75 6d 6e 4f 72 69 67 69 6e 61 6c 4e 61 6d 65 lumnOriginalName
10130 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 (SQLiteStatement
10140 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 stmt, int index
10150 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 21 53 ).. {..#if !S
10160 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a QLITE_STANDARD..
10170 20 20 20 20 20 20 69 6e 74 20 6c 65 6e 20 3d 20 int len =
10180 30 3b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 0;.. return
10190 20 55 54 46 38 54 6f 53 74 72 69 6e 67 28 55 6e UTF8ToString(Un
101a0 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
101b0 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e s.sqlite3_column
101c0 5f 6f 72 69 67 69 6e 5f 6e 61 6d 65 5f 69 6e 74 _origin_name_int
101d0 65 72 6f 70 28 73 74 6d 74 2e 5f 73 71 6c 69 74 erop(stmt._sqlit
101e0 65 5f 73 74 6d 74 2c 20 69 6e 64 65 78 2c 20 72 e_stmt, index, r
101f0 65 66 20 6c 65 6e 29 2c 20 6c 65 6e 29 3b 0d 0a ef len), len);..
10200 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 72 65 74 #else.. ret
10210 75 72 6e 20 55 54 46 38 54 6f 53 74 72 69 6e 67 urn UTF8ToString
10220 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 (UnsafeNativeMet
10230 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c hods.sqlite3_col
10240 75 6d 6e 5f 6f 72 69 67 69 6e 5f 6e 61 6d 65 28 umn_origin_name(
10250 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d stmt._sqlite_stm
10260 74 2c 20 69 6e 64 65 78 29 2c 20 2d 31 29 3b 0d t, index), -1);.
10270 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d 0a .#endif.. }..
10280 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
10290 76 65 72 72 69 64 65 20 73 74 72 69 6e 67 20 43 verride string C
102a0 6f 6c 75 6d 6e 44 61 74 61 62 61 73 65 4e 61 6d olumnDatabaseNam
102b0 65 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e e(SQLiteStatemen
102c0 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 t stmt, int inde
102d0 78 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 21 x).. {..#if !
102e0 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d SQLITE_STANDARD.
102f0 0a 20 20 20 20 20 20 69 6e 74 20 6c 65 6e 20 3d . int len =
10300 20 30 3b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 0;.. retur
10310 6e 20 55 54 46 38 54 6f 53 74 72 69 6e 67 28 55 n UTF8ToString(U
10320 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
10330 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d ds.sqlite3_colum
10340 6e 5f 64 61 74 61 62 61 73 65 5f 6e 61 6d 65 5f n_database_name_
10350 69 6e 74 65 72 6f 70 28 73 74 6d 74 2e 5f 73 71 interop(stmt._sq
10360 6c 69 74 65 5f 73 74 6d 74 2c 20 69 6e 64 65 78 lite_stmt, index
10370 2c 20 72 65 66 20 6c 65 6e 29 2c 20 6c 65 6e 29 , ref len), len)
10380 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 ;..#else..
10390 72 65 74 75 72 6e 20 55 54 46 38 54 6f 53 74 72 return UTF8ToStr
103a0 69 6e 67 28 55 6e 73 61 66 65 4e 61 74 69 76 65 ing(UnsafeNative
103b0 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
103c0 63 6f 6c 75 6d 6e 5f 64 61 74 61 62 61 73 65 5f column_database_
103d0 6e 61 6d 65 28 73 74 6d 74 2e 5f 73 71 6c 69 74 name(stmt._sqlit
103e0 65 5f 73 74 6d 74 2c 20 69 6e 64 65 78 29 2c 20 e_stmt, index),
103f0 2d 31 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 -1);..#endif..
10400 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 }.... inter
10410 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 73 74 72 nal override str
10420 69 6e 67 20 43 6f 6c 75 6d 6e 54 61 62 6c 65 4e ing ColumnTableN
10430 61 6d 65 28 53 51 4c 69 74 65 53 74 61 74 65 6d ame(SQLiteStatem
10440 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e ent stmt, int in
10450 64 65 78 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 dex).. {..#if
10460 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 !SQLITE_STANDAR
10470 44 0d 0a 20 20 20 20 20 20 69 6e 74 20 6c 65 6e D.. int len
10480 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 72 65 74 = 0;.. ret
10490 75 72 6e 20 55 54 46 38 54 6f 53 74 72 69 6e 67 urn UTF8ToString
104a0 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 (UnsafeNativeMet
104b0 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c hods.sqlite3_col
104c0 75 6d 6e 5f 74 61 62 6c 65 5f 6e 61 6d 65 5f 69 umn_table_name_i
104d0 6e 74 65 72 6f 70 28 73 74 6d 74 2e 5f 73 71 6c nterop(stmt._sql
104e0 69 74 65 5f 73 74 6d 74 2c 20 69 6e 64 65 78 2c ite_stmt, index,
104f0 20 72 65 66 20 6c 65 6e 29 2c 20 6c 65 6e 29 3b ref len), len);
10500 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 72 ..#else.. r
10510 65 74 75 72 6e 20 55 54 46 38 54 6f 53 74 72 69 eturn UTF8ToStri
10520 6e 67 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d ng(UnsafeNativeM
10530 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 ethods.sqlite3_c
10540 6f 6c 75 6d 6e 5f 74 61 62 6c 65 5f 6e 61 6d 65 olumn_table_name
10550 28 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 (stmt._sqlite_st
10560 6d 74 2c 20 69 6e 64 65 78 29 2c 20 2d 31 29 3b mt, index), -1);
10570 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d ..#endif.. }.
10580 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
10590 6f 76 65 72 72 69 64 65 20 76 6f 69 64 20 43 6f override void Co
105a0 6c 75 6d 6e 4d 65 74 61 44 61 74 61 28 73 74 72 lumnMetaData(str
105b0 69 6e 67 20 64 61 74 61 42 61 73 65 2c 20 73 74 ing dataBase, st
105c0 72 69 6e 67 20 74 61 62 6c 65 2c 20 73 74 72 69 ring table, stri
105d0 6e 67 20 63 6f 6c 75 6d 6e 2c 20 72 65 66 20 73 ng column, ref s
105e0 74 72 69 6e 67 20 64 61 74 61 54 79 70 65 2c 20 tring dataType,
105f0 72 65 66 20 73 74 72 69 6e 67 20 63 6f 6c 6c 61 ref string colla
10600 74 65 53 65 71 75 65 6e 63 65 2c 20 72 65 66 20 teSequence, ref
10610 62 6f 6f 6c 20 6e 6f 74 4e 75 6c 6c 2c 20 72 65 bool notNull, re
10620 66 20 62 6f 6f 6c 20 70 72 69 6d 61 72 79 4b 65 f bool primaryKe
10630 79 2c 20 72 65 66 20 62 6f 6f 6c 20 61 75 74 6f y, ref bool auto
10640 49 6e 63 72 65 6d 65 6e 74 29 0d 0a 20 20 20 20 Increment)..
10650 7b 0d 0a 20 20 20 20 20 20 49 6e 74 50 74 72 20 {.. IntPtr
10660 64 61 74 61 54 79 70 65 50 74 72 20 3d 20 49 6e dataTypePtr = In
10670 74 50 74 72 2e 5a 65 72 6f 3b 0d 0a 20 20 20 20 tPtr.Zero;..
10680 20 20 49 6e 74 50 74 72 20 63 6f 6c 6c 53 65 71 IntPtr collSeq
10690 50 74 72 20 3d 20 49 6e 74 50 74 72 2e 5a 65 72 Ptr = IntPtr.Zer
106a0 6f 3b 0d 0a 20 20 20 20 20 20 69 6e 74 20 6e 6e o;.. int nn
106b0 6f 74 4e 75 6c 6c 20 3d 20 30 3b 0d 0a 20 20 20 otNull = 0;..
106c0 20 20 20 69 6e 74 20 6e 70 72 69 6d 61 72 79 4b int nprimaryK
106d0 65 79 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 69 ey = 0;.. i
106e0 6e 74 20 6e 61 75 74 6f 49 6e 63 20 3d 20 30 3b nt nautoInc = 0;
106f0 0d 0a 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 .. SQLiteEr
10700 72 6f 72 43 6f 64 65 20 6e 3b 0d 0a 20 20 20 20 rorCode n;..
10710 20 20 69 6e 74 20 64 74 4c 65 6e 3b 0d 0a 20 20 int dtLen;..
10720 20 20 20 20 69 6e 74 20 63 73 4c 65 6e 3b 0d 0a int csLen;..
10730 0d 0a 23 69 66 20 21 53 51 4c 49 54 45 5f 53 54 ..#if !SQLITE_ST
10740 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 64 74 ANDARD.. dt
10750 4c 65 6e 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 Len = 0;..
10760 63 73 4c 65 6e 20 3d 20 30 3b 0d 0a 20 20 20 20 csLen = 0;..
10770 20 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 n = UnsafeNati
10780 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
10790 33 5f 74 61 62 6c 65 5f 63 6f 6c 75 6d 6e 5f 6d 3_table_column_m
107a0 65 74 61 64 61 74 61 5f 69 6e 74 65 72 6f 70 28 etadata_interop(
107b0 5f 73 71 6c 2c 20 54 6f 55 54 46 38 28 64 61 74 _sql, ToUTF8(dat
107c0 61 42 61 73 65 29 2c 20 54 6f 55 54 46 38 28 74 aBase), ToUTF8(t
107d0 61 62 6c 65 29 2c 20 54 6f 55 54 46 38 28 63 6f able), ToUTF8(co
107e0 6c 75 6d 6e 29 2c 20 72 65 66 20 64 61 74 61 54 lumn), ref dataT
107f0 79 70 65 50 74 72 2c 20 72 65 66 20 63 6f 6c 6c ypePtr, ref coll
10800 53 65 71 50 74 72 2c 20 72 65 66 20 6e 6e 6f 74 SeqPtr, ref nnot
10810 4e 75 6c 6c 2c 20 72 65 66 20 6e 70 72 69 6d 61 Null, ref nprima
10820 72 79 4b 65 79 2c 20 72 65 66 20 6e 61 75 74 6f ryKey, ref nauto
10830 49 6e 63 2c 20 72 65 66 20 64 74 4c 65 6e 2c 20 Inc, ref dtLen,
10840 72 65 66 20 63 73 4c 65 6e 29 3b 0d 0a 23 65 6c ref csLen);..#el
10850 73 65 0d 0a 20 20 20 20 20 20 64 74 4c 65 6e 20 se.. dtLen
10860 3d 20 2d 31 3b 0d 0a 20 20 20 20 20 20 63 73 4c = -1;.. csL
10870 65 6e 20 3d 20 2d 31 3b 0d 0a 0d 0a 20 20 20 20 en = -1;....
10880 20 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 n = UnsafeNati
10890 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
108a0 33 5f 74 61 62 6c 65 5f 63 6f 6c 75 6d 6e 5f 6d 3_table_column_m
108b0 65 74 61 64 61 74 61 28 5f 73 71 6c 2c 20 54 6f etadata(_sql, To
108c0 55 54 46 38 28 64 61 74 61 42 61 73 65 29 2c 20 UTF8(dataBase),
108d0 54 6f 55 54 46 38 28 74 61 62 6c 65 29 2c 20 54 ToUTF8(table), T
108e0 6f 55 54 46 38 28 63 6f 6c 75 6d 6e 29 2c 20 72 oUTF8(column), r
108f0 65 66 20 64 61 74 61 54 79 70 65 50 74 72 2c 20 ef dataTypePtr,
10900 72 65 66 20 63 6f 6c 6c 53 65 71 50 74 72 2c 20 ref collSeqPtr,
10910 72 65 66 20 6e 6e 6f 74 4e 75 6c 6c 2c 20 72 65 ref nnotNull, re
10920 66 20 6e 70 72 69 6d 61 72 79 4b 65 79 2c 20 72 f nprimaryKey, r
10930 65 66 20 6e 61 75 74 6f 49 6e 63 29 3b 0d 0a 23 ef nautoInc);..#
10940 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 69 66 20 endif.. if
10950 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f (n != SQLiteErro
10960 72 43 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 20 rCode.Ok) throw
10970 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 new SQLiteExcept
10980 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 ion(n, GetLastEr
10990 72 6f 72 28 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 ror());....
109a0 20 64 61 74 61 54 79 70 65 20 3d 20 55 54 46 38 dataType = UTF8
109b0 54 6f 53 74 72 69 6e 67 28 64 61 74 61 54 79 70 ToString(dataTyp
109c0 65 50 74 72 2c 20 64 74 4c 65 6e 29 3b 0d 0a 20 ePtr, dtLen);..
109d0 20 20 20 20 20 63 6f 6c 6c 61 74 65 53 65 71 75 collateSequ
109e0 65 6e 63 65 20 3d 20 55 54 46 38 54 6f 53 74 72 ence = UTF8ToStr
109f0 69 6e 67 28 63 6f 6c 6c 53 65 71 50 74 72 2c 20 ing(collSeqPtr,
10a00 63 73 4c 65 6e 29 3b 0d 0a 0d 0a 20 20 20 20 20 csLen);....
10a10 20 6e 6f 74 4e 75 6c 6c 20 3d 20 28 6e 6e 6f 74 notNull = (nnot
10a20 4e 75 6c 6c 20 3d 3d 20 31 29 3b 0d 0a 20 20 20 Null == 1);..
10a30 20 20 20 70 72 69 6d 61 72 79 4b 65 79 20 3d 20 primaryKey =
10a40 28 6e 70 72 69 6d 61 72 79 4b 65 79 20 3d 3d 20 (nprimaryKey ==
10a50 31 29 3b 0d 0a 20 20 20 20 20 20 61 75 74 6f 49 1);.. autoI
10a60 6e 63 72 65 6d 65 6e 74 20 3d 20 28 6e 61 75 74 ncrement = (naut
10a70 6f 49 6e 63 20 3d 3d 20 31 29 3b 0d 0a 20 20 20 oInc == 1);..
10a80 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e }.... intern
10a90 61 6c 20 6f 76 65 72 72 69 64 65 20 6f 62 6a 65 al override obje
10aa0 63 74 20 47 65 74 4f 62 6a 65 63 74 28 53 51 4c ct GetObject(SQL
10ab0 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d iteStatement stm
10ac0 74 2c 20 69 6e 74 20 69 6e 64 65 78 29 0d 0a 20 t, int index)..
10ad0 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 73 77 {.. sw
10ae0 69 74 63 68 20 28 43 6f 6c 75 6d 6e 41 66 66 69 itch (ColumnAffi
10af0 6e 69 74 79 28 73 74 6d 74 2c 20 69 6e 64 65 78 nity(stmt, index
10b00 29 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 )).. {..
10b10 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 case
10b20 54 79 70 65 41 66 66 69 6e 69 74 79 2e 49 6e 74 TypeAffinity.Int
10b30 36 34 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 64:..
10b40 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
10b50 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 retu
10b60 72 6e 20 47 65 74 49 6e 74 36 34 28 73 74 6d 74 rn GetInt64(stmt
10b70 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 , index);..
10b80 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 }..
10b90 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 54 case T
10ba0 79 70 65 41 66 66 69 6e 69 74 79 2e 44 6f 75 62 ypeAffinity.Doub
10bb0 6c 65 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 le:..
10bc0 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
10bd0 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 retu
10be0 72 6e 20 47 65 74 44 6f 75 62 6c 65 28 73 74 6d rn GetDouble(stm
10bf0 74 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 t, index);..
10c00 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 }..
10c10 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 case
10c20 54 79 70 65 41 66 66 69 6e 69 74 79 2e 54 65 78 TypeAffinity.Tex
10c30 74 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 t:..
10c40 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
10c50 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 retur
10c60 6e 20 47 65 74 54 65 78 74 28 73 74 6d 74 2c 20 n GetText(stmt,
10c70 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 index);..
10c80 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 }..
10c90 20 20 20 20 20 20 20 20 63 61 73 65 20 54 79 70 case Typ
10ca0 65 41 66 66 69 6e 69 74 79 2e 42 6c 6f 62 3a 0d eAffinity.Blob:.
10cb0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
10cc0 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
10cd0 20 20 20 20 20 20 20 20 6c 6f 6e 67 20 73 69 7a long siz
10ce0 65 20 3d 20 47 65 74 42 79 74 65 73 28 73 74 6d e = GetBytes(stm
10cf0 74 2c 20 69 6e 64 65 78 2c 20 30 2c 20 6e 75 6c t, index, 0, nul
10d00 6c 2c 20 30 2c 20 30 29 3b 0d 0a 0d 0a 20 20 20 l, 0, 0);....
10d10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
10d20 20 69 66 20 28 28 73 69 7a 65 20 3e 20 30 29 20 if ((size > 0)
10d30 26 26 20 28 73 69 7a 65 20 3c 3d 20 69 6e 74 2e && (size <= int.
10d40 4d 61 78 56 61 6c 75 65 29 29 0d 0a 20 20 20 20 MaxValue))..
10d50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
10d60 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 {..
10d70 20 20 20 20 20 20 20 20 20 20 20 62 79 74 65 5b byte[
10d80 5d 20 62 79 74 65 73 20 3d 20 6e 65 77 20 62 79 ] bytes = new by
10d90 74 65 5b 28 69 6e 74 29 73 69 7a 65 5d 3b 0d 0a te[(int)size];..
10da0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
10db0 20 20 20 20 20 20 20 20 20 20 47 65 74 42 79 74 GetByt
10dc0 65 73 28 73 74 6d 74 2c 20 69 6e 64 65 78 2c 20 es(stmt, index,
10dd0 30 2c 20 62 79 74 65 73 2c 20 30 2c 20 28 69 6e 0, bytes, 0, (in
10de0 74 29 73 69 7a 65 29 3b 0d 0a 0d 0a 20 20 20 20 t)size);....
10df0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
10e00 20 20 20 20 72 65 74 75 72 6e 20 62 79 74 65 73 return bytes
10e10 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ;..
10e20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 }..
10e30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 72 br
10e40 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 eak;..
10e50 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
10e60 20 20 20 20 20 63 61 73 65 20 54 79 70 65 41 66 case TypeAf
10e70 66 69 6e 69 74 79 2e 4e 75 6c 6c 3a 0d 0a 20 20 finity.Null:..
10e80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d {.
10e90 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
10ea0 20 20 20 20 20 72 65 74 75 72 6e 20 44 42 4e 75 return DBNu
10eb0 6c 6c 2e 56 61 6c 75 65 3b 0d 0a 20 20 20 20 20 ll.Value;..
10ec0 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 }..
10ed0 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 }....
10ee0 20 20 20 74 68 72 6f 77 20 6e 65 77 20 4e 6f 74 throw new Not
10ef0 49 6d 70 6c 65 6d 65 6e 74 65 64 45 78 63 65 70 ImplementedExcep
10f00 74 69 6f 6e 28 29 3b 0d 0a 20 20 20 20 7d 0d 0a tion();.. }..
10f10 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
10f20 76 65 72 72 69 64 65 20 64 6f 75 62 6c 65 20 47 verride double G
10f30 65 74 44 6f 75 62 6c 65 28 53 51 4c 69 74 65 53 etDouble(SQLiteS
10f40 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 tatement stmt, i
10f50 6e 74 20 69 6e 64 65 78 29 0d 0a 20 20 20 20 7b nt index).. {
10f60 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f ..#if !PLATFORM_
10f70 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 4b COMPACTFRAMEWORK
10f80 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 .. return U
10f90 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
10fa0 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d ds.sqlite3_colum
10fb0 6e 5f 64 6f 75 62 6c 65 28 73 74 6d 74 2e 5f 73 n_double(stmt._s
10fc0 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 6e 64 65 qlite_stmt, inde
10fd0 78 29 3b 0d 0a 23 65 6c 69 66 20 21 53 51 4c 49 x);..#elif !SQLI
10fe0 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 TE_STANDARD..
10ff0 20 20 20 64 6f 75 62 6c 65 20 76 61 6c 75 65 20 double value
11000 3d 20 30 2e 30 3b 0d 0a 20 20 20 20 20 20 55 6e = 0.0;.. Un
11010 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
11020 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e s.sqlite3_column
11030 5f 64 6f 75 62 6c 65 5f 69 6e 74 65 72 6f 70 28 _double_interop(
11040 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d stmt._sqlite_stm
11050 74 2c 20 69 6e 64 65 78 2c 20 72 65 66 20 76 61 t, index, ref va
11060 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 72 65 74 lue);.. ret
11070 75 72 6e 20 76 61 6c 75 65 3b 0d 0a 23 65 6c 73 urn value;..#els
11080 65 0d 0a 20 20 20 20 20 20 74 68 72 6f 77 20 6e e.. throw n
11090 65 77 20 4e 6f 74 49 6d 70 6c 65 6d 65 6e 74 65 ew NotImplemente
110a0 64 45 78 63 65 70 74 69 6f 6e 28 29 3b 0d 0a 23 dException();..#
110b0 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d 0a 0d 0a endif.. }....
110c0 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
110d0 72 72 69 64 65 20 62 6f 6f 6c 20 47 65 74 42 6f rride bool GetBo
110e0 6f 6c 65 61 6e 28 53 51 4c 69 74 65 53 74 61 74 olean(SQLiteStat
110f0 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 ement stmt, int
11100 69 6e 64 65 78 29 0d 0a 20 20 20 20 7b 0d 0a 20 index).. {..
11110 20 20 20 20 20 72 65 74 75 72 6e 20 54 6f 42 6f return ToBo
11120 6f 6c 65 61 6e 28 47 65 74 4f 62 6a 65 63 74 28 olean(GetObject(
11130 73 74 6d 74 2c 20 69 6e 64 65 78 29 2c 20 43 75 stmt, index), Cu
11140 6c 74 75 72 65 49 6e 66 6f 2e 49 6e 76 61 72 69 ltureInfo.Invari
11150 61 6e 74 43 75 6c 74 75 72 65 2c 20 66 61 6c 73 antCulture, fals
11160 65 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 e);.. }....
11170 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 internal overr
11180 69 64 65 20 73 62 79 74 65 20 47 65 74 53 42 79 ide sbyte GetSBy
11190 74 65 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 te(SQLiteStateme
111a0 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 nt stmt, int ind
111b0 65 78 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 ex).. {..
111c0 20 20 72 65 74 75 72 6e 20 75 6e 63 68 65 63 6b return uncheck
111d0 65 64 28 28 73 62 79 74 65 29 28 47 65 74 49 6e ed((sbyte)(GetIn
111e0 74 33 32 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 t32(stmt, index)
111f0 20 26 20 62 79 74 65 2e 4d 61 78 56 61 6c 75 65 & byte.MaxValue
11200 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 ));.. }....
11210 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 internal overr
11220 69 64 65 20 62 79 74 65 20 47 65 74 42 79 74 65 ide byte GetByte
11230 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 (SQLiteStatement
11240 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 stmt, int index
11250 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
11260 72 65 74 75 72 6e 20 75 6e 63 68 65 63 6b 65 64 return unchecked
11270 28 28 62 79 74 65 29 28 47 65 74 49 6e 74 33 32 ((byte)(GetInt32
11280 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 20 26 20 (stmt, index) &
11290 62 79 74 65 2e 4d 61 78 56 61 6c 75 65 29 29 3b byte.MaxValue));
112a0 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
112b0 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
112c0 20 73 68 6f 72 74 20 47 65 74 49 6e 74 31 36 28 short GetInt16(
112d0 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 SQLiteStatement
112e0 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 29 stmt, int index)
112f0 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 .. {.. r
11300 65 74 75 72 6e 20 75 6e 63 68 65 63 6b 65 64 28 eturn unchecked(
11310 28 73 68 6f 72 74 29 28 47 65 74 49 6e 74 33 32 (short)(GetInt32
11320 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 20 26 20 (stmt, index) &
11330 75 73 68 6f 72 74 2e 4d 61 78 56 61 6c 75 65 29 ushort.MaxValue)
11340 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 );.. }....
11350 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 internal overri
11360 64 65 20 75 73 68 6f 72 74 20 47 65 74 55 49 6e de ushort GetUIn
11370 74 31 36 28 53 51 4c 69 74 65 53 74 61 74 65 6d t16(SQLiteStatem
11380 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e ent stmt, int in
11390 64 65 78 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 dex).. {..
113a0 20 20 20 72 65 74 75 72 6e 20 75 6e 63 68 65 63 return unchec
113b0 6b 65 64 28 28 75 73 68 6f 72 74 29 28 47 65 74 ked((ushort)(Get
113c0 49 6e 74 33 32 28 73 74 6d 74 2c 20 69 6e 64 65 Int32(stmt, inde
113d0 78 29 20 26 20 75 73 68 6f 72 74 2e 4d 61 78 56 x) & ushort.MaxV
113e0 61 6c 75 65 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a alue));.. }..
113f0 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
11400 76 65 72 72 69 64 65 20 69 6e 74 20 47 65 74 49 verride int GetI
11410 6e 74 33 32 28 53 51 4c 69 74 65 53 74 61 74 65 nt32(SQLiteState
11420 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 ment stmt, int i
11430 6e 64 65 78 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 ndex).. {..
11440 20 20 20 20 72 65 74 75 72 6e 20 55 6e 73 61 66 return Unsaf
11450 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
11460 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 69 6e qlite3_column_in
11470 74 28 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 t(stmt._sqlite_s
11480 74 6d 74 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 20 tmt, index);..
11490 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 }.... inter
114a0 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 75 69 6e nal override uin
114b0 74 20 47 65 74 55 49 6e 74 33 32 28 53 51 4c 69 t GetUInt32(SQLi
114c0 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 teStatement stmt
114d0 2c 20 69 6e 74 20 69 6e 64 65 78 29 0d 0a 20 20 , int index)..
114e0 20 20 7b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 {.. retur
114f0 6e 20 75 6e 63 68 65 63 6b 65 64 28 28 75 69 6e n unchecked((uin
11500 74 29 47 65 74 49 6e 74 33 32 28 73 74 6d 74 2c t)GetInt32(stmt,
11510 20 69 6e 64 65 78 29 29 3b 0d 0a 20 20 20 20 7d index));.. }
11520 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
11530 20 6f 76 65 72 72 69 64 65 20 6c 6f 6e 67 20 47 override long G
11540 65 74 49 6e 74 36 34 28 53 51 4c 69 74 65 53 74 etInt64(SQLiteSt
11550 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e atement stmt, in
11560 74 20 69 6e 64 65 78 29 0d 0a 20 20 20 20 7b 0d t index).. {.
11570 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f 43 .#if !PLATFORM_C
11580 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 4b 0d OMPACTFRAMEWORK.
11590 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 6e . return Un
115a0 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
115b0 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e s.sqlite3_column
115c0 5f 69 6e 74 36 34 28 73 74 6d 74 2e 5f 73 71 6c _int64(stmt._sql
115d0 69 74 65 5f 73 74 6d 74 2c 20 69 6e 64 65 78 29 ite_stmt, index)
115e0 3b 0d 0a 23 65 6c 69 66 20 21 53 51 4c 49 54 45 ;..#elif !SQLITE
115f0 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 _STANDARD..
11600 20 6c 6f 6e 67 20 76 61 6c 75 65 20 3d 20 30 3b long value = 0;
11610 0d 0a 20 20 20 20 20 20 55 6e 73 61 66 65 4e 61 .. UnsafeNa
11620 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 tiveMethods.sqli
11630 74 65 33 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 36 34 te3_column_int64
11640 5f 69 6e 74 65 72 6f 70 28 73 74 6d 74 2e 5f 73 _interop(stmt._s
11650 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 6e 64 65 qlite_stmt, inde
11660 78 2c 20 72 65 66 20 76 61 6c 75 65 29 3b 0d 0a x, ref value);..
11670 20 20 20 20 20 20 72 65 74 75 72 6e 20 76 61 6c return val
11680 75 65 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 ue;..#else..
11690 20 20 74 68 72 6f 77 20 6e 65 77 20 4e 6f 74 49 throw new NotI
116a0 6d 70 6c 65 6d 65 6e 74 65 64 45 78 63 65 70 74 mplementedExcept
116b0 69 6f 6e 28 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a ion();..#endif..
116c0 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 }.... int
116d0 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 75 ernal override u
116e0 6c 6f 6e 67 20 47 65 74 55 49 6e 74 36 34 28 53 long GetUInt64(S
116f0 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 QLiteStatement s
11700 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 29 0d tmt, int index).
11710 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 65 . {.. re
11720 74 75 72 6e 20 75 6e 63 68 65 63 6b 65 64 28 28 turn unchecked((
11730 75 6c 6f 6e 67 29 47 65 74 49 6e 74 36 34 28 73 ulong)GetInt64(s
11740 74 6d 74 2c 20 69 6e 64 65 78 29 29 3b 0d 0a 20 tmt, index));..
11750 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 }.... inte
11760 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 73 74 rnal override st
11770 72 69 6e 67 20 47 65 74 54 65 78 74 28 53 51 4c ring GetText(SQL
11780 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d iteStatement stm
11790 74 2c 20 69 6e 74 20 69 6e 64 65 78 29 0d 0a 20 t, int index)..
117a0 20 20 20 7b 0d 0a 23 69 66 20 21 53 51 4c 49 54 {..#if !SQLIT
117b0 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 E_STANDARD..
117c0 20 20 69 6e 74 20 6c 65 6e 20 3d 20 30 3b 0d 0a int len = 0;..
117d0 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 54 46 return UTF
117e0 38 54 6f 53 74 72 69 6e 67 28 55 6e 73 61 66 65 8ToString(Unsafe
117f0 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
11800 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 74 65 78 lite3_column_tex
11810 74 5f 69 6e 74 65 72 6f 70 28 73 74 6d 74 2e 5f t_interop(stmt._
11820 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 6e 64 sqlite_stmt, ind
11830 65 78 2c 20 72 65 66 20 6c 65 6e 29 2c 20 6c 65 ex, ref len), le
11840 6e 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 n);..#else..
11850 20 20 72 65 74 75 72 6e 20 55 54 46 38 54 6f 53 return UTF8ToS
11860 74 72 69 6e 67 28 55 6e 73 61 66 65 4e 61 74 69 tring(UnsafeNati
11870 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
11880 33 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 73 74 3_column_text(st
11890 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 2c mt._sqlite_stmt,
118a0 20 69 6e 64 65 78 29 2c 0d 0a 20 20 20 20 20 20 index),..
118b0 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 UnsafeNativeMe
118c0 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f thods.sqlite3_co
118d0 6c 75 6d 6e 5f 62 79 74 65 73 28 73 74 6d 74 2e lumn_bytes(stmt.
118e0 5f 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 6e _sqlite_stmt, in
118f0 64 65 78 29 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a dex));..#endif..
11900 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 }.... int
11910 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 44 ernal override D
11920 61 74 65 54 69 6d 65 20 47 65 74 44 61 74 65 54 ateTime GetDateT
11930 69 6d 65 28 53 51 4c 69 74 65 53 74 61 74 65 6d ime(SQLiteStatem
11940 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e ent stmt, int in
11950 64 65 78 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 dex).. {..
11960 20 20 20 69 66 20 28 5f 64 61 74 65 74 69 6d 65 if (_datetime
11970 46 6f 72 6d 61 74 20 3d 3d 20 53 51 4c 69 74 65 Format == SQLite
11980 44 61 74 65 46 6f 72 6d 61 74 73 2e 54 69 63 6b DateFormats.Tick
11990 73 29 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 s).. retu
119a0 72 6e 20 54 69 63 6b 73 54 6f 44 61 74 65 54 69 rn TicksToDateTi
119b0 6d 65 28 47 65 74 49 6e 74 36 34 28 73 74 6d 74 me(GetInt64(stmt
119c0 2c 20 69 6e 64 65 78 29 2c 20 5f 64 61 74 65 74 , index), _datet
119d0 69 6d 65 4b 69 6e 64 29 3b 0d 0a 20 20 20 20 20 imeKind);..
119e0 20 65 6c 73 65 20 69 66 20 28 5f 64 61 74 65 74 else if (_datet
119f0 69 6d 65 46 6f 72 6d 61 74 20 3d 3d 20 53 51 4c imeFormat == SQL
11a00 69 74 65 44 61 74 65 46 6f 72 6d 61 74 73 2e 4a iteDateFormats.J
11a10 75 6c 69 61 6e 44 61 79 29 0d 0a 20 20 20 20 20 ulianDay)..
11a20 20 20 20 72 65 74 75 72 6e 20 54 6f 44 61 74 65 return ToDate
11a30 54 69 6d 65 28 47 65 74 44 6f 75 62 6c 65 28 73 Time(GetDouble(s
11a40 74 6d 74 2c 20 69 6e 64 65 78 29 2c 20 5f 64 61 tmt, index), _da
11a50 74 65 74 69 6d 65 4b 69 6e 64 29 3b 0d 0a 20 20 tetimeKind);..
11a60 20 20 20 20 65 6c 73 65 20 69 66 20 28 5f 64 61 else if (_da
11a70 74 65 74 69 6d 65 46 6f 72 6d 61 74 20 3d 3d 20 tetimeFormat ==
11a80 53 51 4c 69 74 65 44 61 74 65 46 6f 72 6d 61 74 SQLiteDateFormat
11a90 73 2e 55 6e 69 78 45 70 6f 63 68 29 0d 0a 20 20 s.UnixEpoch)..
11aa0 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 6e 69 return Uni
11ab0 78 45 70 6f 63 68 54 6f 44 61 74 65 54 69 6d 65 xEpochToDateTime
11ac0 28 47 65 74 49 6e 74 36 34 28 73 74 6d 74 2c 20 (GetInt64(stmt,
11ad0 69 6e 64 65 78 29 2c 20 5f 64 61 74 65 74 69 6d index), _datetim
11ae0 65 4b 69 6e 64 29 3b 0d 0a 0d 0a 23 69 66 20 21 eKind);....#if !
11af0 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d SQLITE_STANDARD.
11b00 0a 20 20 20 20 20 20 69 6e 74 20 6c 65 6e 20 3d . int len =
11b10 20 30 3b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 0;.. retur
11b20 6e 20 54 6f 44 61 74 65 54 69 6d 65 28 55 6e 73 n ToDateTime(Uns
11b30 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
11b40 2e 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f .sqlite3_column_
11b50 74 65 78 74 5f 69 6e 74 65 72 6f 70 28 73 74 6d text_interop(stm
11b60 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 t._sqlite_stmt,
11b70 69 6e 64 65 78 2c 20 72 65 66 20 6c 65 6e 29 2c index, ref len),
11b80 20 6c 65 6e 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 len);..#else..
11b90 20 20 20 20 20 72 65 74 75 72 6e 20 54 6f 44 61 return ToDa
11ba0 74 65 54 69 6d 65 28 55 6e 73 61 66 65 4e 61 74 teTime(UnsafeNat
11bb0 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 iveMethods.sqlit
11bc0 65 33 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 73 e3_column_text(s
11bd0 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 tmt._sqlite_stmt
11be0 2c 20 69 6e 64 65 78 29 2c 0d 0a 20 20 20 20 20 , index),..
11bf0 20 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d UnsafeNativeM
11c00 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 ethods.sqlite3_c
11c10 6f 6c 75 6d 6e 5f 62 79 74 65 73 28 73 74 6d 74 olumn_bytes(stmt
11c20 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 ._sqlite_stmt, i
11c30 6e 64 65 78 29 29 3b 0d 0a 23 65 6e 64 69 66 0d ndex));..#endif.
11c40 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
11c50 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
11c60 6c 6f 6e 67 20 47 65 74 42 79 74 65 73 28 53 51 long GetBytes(SQ
11c70 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 LiteStatement st
11c80 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 2c 20 69 mt, int index, i
11c90 6e 74 20 6e 44 61 74 61 4f 66 66 73 65 74 2c 20 nt nDataOffset,
11ca0 62 79 74 65 5b 5d 20 62 44 65 73 74 2c 20 69 6e byte[] bDest, in
11cb0 74 20 6e 53 74 61 72 74 2c 20 69 6e 74 20 6e 4c t nStart, int nL
11cc0 65 6e 67 74 68 29 0d 0a 20 20 20 20 7b 0d 0a 20 ength).. {..
11cd0 20 20 20 20 20 69 6e 74 20 6e 6c 65 6e 20 3d 20 int nlen =
11ce0 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
11cf0 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c 75 ods.sqlite3_colu
11d00 6d 6e 5f 62 79 74 65 73 28 73 74 6d 74 2e 5f 73 mn_bytes(stmt._s
11d10 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 6e 64 65 qlite_stmt, inde
11d20 78 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 2f 2f 20 x);.... //
11d30 49 66 20 6e 6f 20 64 65 73 74 69 6e 61 74 69 6f If no destinatio
11d40 6e 20 62 75 66 66 65 72 2c 20 72 65 74 75 72 6e n buffer, return
11d50 20 74 68 65 20 73 69 7a 65 20 6e 65 65 64 65 64 the size needed
11d60 2e 0d 0a 20 20 20 20 20 20 69 66 20 28 62 44 65 ... if (bDe
11d70 73 74 20 3d 3d 20 6e 75 6c 6c 29 20 72 65 74 75 st == null) retu
11d80 72 6e 20 6e 6c 65 6e 3b 0d 0a 0d 0a 20 20 20 20 rn nlen;....
11d90 20 20 69 6e 74 20 6e 43 6f 70 69 65 64 20 3d 20 int nCopied =
11da0 6e 4c 65 6e 67 74 68 3b 0d 0a 0d 0a 20 20 20 20 nLength;....
11db0 20 20 69 66 20 28 6e 43 6f 70 69 65 64 20 2b 20 if (nCopied +
11dc0 6e 53 74 61 72 74 20 3e 20 62 44 65 73 74 2e 4c nStart > bDest.L
11dd0 65 6e 67 74 68 29 20 6e 43 6f 70 69 65 64 20 3d ength) nCopied =
11de0 20 62 44 65 73 74 2e 4c 65 6e 67 74 68 20 2d 20 bDest.Length -
11df0 6e 53 74 61 72 74 3b 0d 0a 20 20 20 20 20 20 69 nStart;.. i
11e00 66 20 28 6e 43 6f 70 69 65 64 20 2b 20 6e 44 61 f (nCopied + nDa
11e10 74 61 4f 66 66 73 65 74 20 3e 20 6e 6c 65 6e 29 taOffset > nlen)
11e20 20 6e 43 6f 70 69 65 64 20 3d 20 6e 6c 65 6e 20 nCopied = nlen
11e30 2d 20 6e 44 61 74 61 4f 66 66 73 65 74 3b 0d 0a - nDataOffset;..
11e40 0d 0a 20 20 20 20 20 20 69 66 20 28 6e 43 6f 70 .. if (nCop
11e50 69 65 64 20 3e 20 30 29 0d 0a 20 20 20 20 20 20 ied > 0)..
11e60 7b 0d 0a 20 20 20 20 20 20 20 20 49 6e 74 50 74 {.. IntPt
11e70 72 20 70 74 72 20 3d 20 55 6e 73 61 66 65 4e 61 r ptr = UnsafeNa
11e80 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 tiveMethods.sqli
11e90 74 65 33 5f 63 6f 6c 75 6d 6e 5f 62 6c 6f 62 28 te3_column_blob(
11ea0 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d stmt._sqlite_stm
11eb0 74 2c 20 69 6e 64 65 78 29 3b 0d 0a 0d 0a 20 20 t, index);....
11ec0 20 20 20 20 20 20 4d 61 72 73 68 61 6c 2e 43 6f Marshal.Co
11ed0 70 79 28 28 49 6e 74 50 74 72 29 28 70 74 72 2e py((IntPtr)(ptr.
11ee0 54 6f 49 6e 74 36 34 28 29 20 2b 20 6e 44 61 74 ToInt64() + nDat
11ef0 61 4f 66 66 73 65 74 29 2c 20 62 44 65 73 74 2c aOffset), bDest,
11f00 20 6e 53 74 61 72 74 2c 20 6e 43 6f 70 69 65 64 nStart, nCopied
11f10 29 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 );.. }..
11f20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 7b else.. {
11f30 0d 0a 20 20 20 20 20 20 20 20 6e 43 6f 70 69 65 .. nCopie
11f40 64 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 7d 0d d = 0;.. }.
11f50 0a 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 ... return
11f60 6e 43 6f 70 69 65 64 3b 0d 0a 20 20 20 20 7d 0d nCopied;.. }.
11f70 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
11f80 6f 76 65 72 72 69 64 65 20 6c 6f 6e 67 20 47 65 override long Ge
11f90 74 43 68 61 72 73 28 53 51 4c 69 74 65 53 74 61 tChars(SQLiteSta
11fa0 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 tement stmt, int
11fb0 20 69 6e 64 65 78 2c 20 69 6e 74 20 6e 44 61 74 index, int nDat
11fc0 61 4f 66 66 73 65 74 2c 20 63 68 61 72 5b 5d 20 aOffset, char[]
11fd0 62 44 65 73 74 2c 20 69 6e 74 20 6e 53 74 61 72 bDest, int nStar
11fe0 74 2c 20 69 6e 74 20 6e 4c 65 6e 67 74 68 29 0d t, int nLength).
11ff0 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 69 6e . {.. in
12000 74 20 6e 6c 65 6e 3b 0d 0a 20 20 20 20 20 20 69 t nlen;.. i
12010 6e 74 20 6e 43 6f 70 69 65 64 20 3d 20 6e 4c 65 nt nCopied = nLe
12020 6e 67 74 68 3b 0d 0a 0d 0a 20 20 20 20 20 20 73 ngth;.... s
12030 74 72 69 6e 67 20 73 74 72 20 3d 20 47 65 74 54 tring str = GetT
12040 65 78 74 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 ext(stmt, index)
12050 3b 0d 0a 20 20 20 20 20 20 6e 6c 65 6e 20 3d 20 ;.. nlen =
12060 73 74 72 2e 4c 65 6e 67 74 68 3b 0d 0a 0d 0a 20 str.Length;....
12070 20 20 20 20 20 69 66 20 28 62 44 65 73 74 20 3d if (bDest =
12080 3d 20 6e 75 6c 6c 29 20 72 65 74 75 72 6e 20 6e = null) return n
12090 6c 65 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 69 66 len;.... if
120a0 20 28 6e 43 6f 70 69 65 64 20 2b 20 6e 53 74 61 (nCopied + nSta
120b0 72 74 20 3e 20 62 44 65 73 74 2e 4c 65 6e 67 74 rt > bDest.Lengt
120c0 68 29 20 6e 43 6f 70 69 65 64 20 3d 20 62 44 65 h) nCopied = bDe
120d0 73 74 2e 4c 65 6e 67 74 68 20 2d 20 6e 53 74 61 st.Length - nSta
120e0 72 74 3b 0d 0a 20 20 20 20 20 20 69 66 20 28 6e rt;.. if (n
120f0 43 6f 70 69 65 64 20 2b 20 6e 44 61 74 61 4f 66 Copied + nDataOf
12100 66 73 65 74 20 3e 20 6e 6c 65 6e 29 20 6e 43 6f fset > nlen) nCo
12110 70 69 65 64 20 3d 20 6e 6c 65 6e 20 2d 20 6e 44 pied = nlen - nD
12120 61 74 61 4f 66 66 73 65 74 3b 0d 0a 0d 0a 20 20 ataOffset;....
12130 20 20 20 20 69 66 20 28 6e 43 6f 70 69 65 64 20 if (nCopied
12140 3e 20 30 29 0d 0a 20 20 20 20 20 20 20 20 73 74 > 0).. st
12150 72 2e 43 6f 70 79 54 6f 28 6e 44 61 74 61 4f 66 r.CopyTo(nDataOf
12160 66 73 65 74 2c 20 62 44 65 73 74 2c 20 6e 53 74 fset, bDest, nSt
12170 61 72 74 2c 20 6e 43 6f 70 69 65 64 29 3b 0d 0a art, nCopied);..
12180 20 20 20 20 20 20 65 6c 73 65 20 6e 43 6f 70 69 else nCopi
12190 65 64 20 3d 20 30 3b 0d 0a 0d 0a 20 20 20 20 20 ed = 0;....
121a0 20 72 65 74 75 72 6e 20 6e 43 6f 70 69 65 64 3b return nCopied;
121b0 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
121c0 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
121d0 20 62 6f 6f 6c 20 49 73 4e 75 6c 6c 28 53 51 4c bool IsNull(SQL
121e0 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d iteStatement stm
121f0 74 2c 20 69 6e 74 20 69 6e 64 65 78 29 0d 0a 20 t, int index)..
12200 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 65 74 75 {.. retu
12210 72 6e 20 28 43 6f 6c 75 6d 6e 41 66 66 69 6e 69 rn (ColumnAffini
12220 74 79 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 20 ty(stmt, index)
12230 3d 3d 20 54 79 70 65 41 66 66 69 6e 69 74 79 2e == TypeAffinity.
12240 4e 75 6c 6c 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d Null);.. }...
12250 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
12260 65 72 72 69 64 65 20 69 6e 74 20 41 67 67 72 65 erride int Aggre
12270 67 61 74 65 43 6f 75 6e 74 28 49 6e 74 50 74 72 gateCount(IntPtr
12280 20 63 6f 6e 74 65 78 74 29 0d 0a 20 20 20 20 7b context).. {
12290 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 .. return U
122a0 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
122b0 64 73 2e 73 71 6c 69 74 65 33 5f 61 67 67 72 65 ds.sqlite3_aggre
122c0 67 61 74 65 5f 63 6f 75 6e 74 28 63 6f 6e 74 65 gate_count(conte
122d0 78 74 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 xt);.. }....
122e0 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 internal over
122f0 72 69 64 65 20 53 51 4c 69 74 65 45 72 72 6f 72 ride SQLiteError
12300 43 6f 64 65 20 43 72 65 61 74 65 46 75 6e 63 74 Code CreateFunct
12310 69 6f 6e 28 73 74 72 69 6e 67 20 73 74 72 46 75 ion(string strFu
12320 6e 63 74 69 6f 6e 2c 20 69 6e 74 20 6e 41 72 67 nction, int nArg
12330 73 2c 20 62 6f 6f 6c 20 6e 65 65 64 43 6f 6c 6c s, bool needColl
12340 53 65 71 2c 20 53 51 4c 69 74 65 43 61 6c 6c 62 Seq, SQLiteCallb
12350 61 63 6b 20 66 75 6e 63 2c 20 53 51 4c 69 74 65 ack func, SQLite
12360 43 61 6c 6c 62 61 63 6b 20 66 75 6e 63 73 74 65 Callback funcste
12370 70 2c 20 53 51 4c 69 74 65 46 69 6e 61 6c 43 61 p, SQLiteFinalCa
12380 6c 6c 62 61 63 6b 20 66 75 6e 63 66 69 6e 61 6c llback funcfinal
12390 2c 20 62 6f 6f 6c 20 63 61 6e 54 68 72 6f 77 29 , bool canThrow)
123a0 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 53 .. {.. S
123b0 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 6e QLiteErrorCode n
123c0 3b 0d 0a 0d 0a 23 69 66 20 21 53 51 4c 49 54 45 ;....#if !SQLITE
123d0 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 _STANDARD..
123e0 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 n = UnsafeNativ
123f0 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
12400 5f 63 72 65 61 74 65 5f 66 75 6e 63 74 69 6f 6e _create_function
12410 5f 69 6e 74 65 72 6f 70 28 5f 73 71 6c 2c 20 54 _interop(_sql, T
12420 6f 55 54 46 38 28 73 74 72 46 75 6e 63 74 69 6f oUTF8(strFunctio
12430 6e 29 2c 20 6e 41 72 67 73 2c 20 34 2c 20 49 6e n), nArgs, 4, In
12440 74 50 74 72 2e 5a 65 72 6f 2c 20 66 75 6e 63 2c tPtr.Zero, func,
12450 20 66 75 6e 63 73 74 65 70 2c 20 66 75 6e 63 66 funcstep, funcf
12460 69 6e 61 6c 2c 20 28 6e 65 65 64 43 6f 6c 6c 53 inal, (needCollS
12470 65 71 20 3d 3d 20 74 72 75 65 29 20 3f 20 31 20 eq == true) ? 1
12480 3a 20 30 29 3b 0d 0a 20 20 20 20 20 20 69 66 20 : 0);.. if
12490 28 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f (n == SQLiteErro
124a0 72 43 6f 64 65 2e 4f 6b 29 20 6e 20 3d 20 55 6e rCode.Ok) n = Un
124b0 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
124c0 73 2e 73 71 6c 69 74 65 33 5f 63 72 65 61 74 65 s.sqlite3_create
124d0 5f 66 75 6e 63 74 69 6f 6e 5f 69 6e 74 65 72 6f _function_intero
124e0 70 28 5f 73 71 6c 2c 20 54 6f 55 54 46 38 28 73 p(_sql, ToUTF8(s
124f0 74 72 46 75 6e 63 74 69 6f 6e 29 2c 20 6e 41 72 trFunction), nAr
12500 67 73 2c 20 31 2c 20 49 6e 74 50 74 72 2e 5a 65 gs, 1, IntPtr.Ze
12510 72 6f 2c 20 66 75 6e 63 2c 20 66 75 6e 63 73 74 ro, func, funcst
12520 65 70 2c 20 66 75 6e 63 66 69 6e 61 6c 2c 20 28 ep, funcfinal, (
12530 6e 65 65 64 43 6f 6c 6c 53 65 71 20 3d 3d 20 74 needCollSeq == t
12540 72 75 65 29 20 3f 20 31 20 3a 20 30 29 3b 0d 0a rue) ? 1 : 0);..
12550 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 6e 20 3d #else.. n =
12560 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
12570 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 72 65 hods.sqlite3_cre
12580 61 74 65 5f 66 75 6e 63 74 69 6f 6e 28 5f 73 71 ate_function(_sq
12590 6c 2c 20 54 6f 55 54 46 38 28 73 74 72 46 75 6e l, ToUTF8(strFun
125a0 63 74 69 6f 6e 29 2c 20 6e 41 72 67 73 2c 20 34 ction), nArgs, 4
125b0 2c 20 49 6e 74 50 74 72 2e 5a 65 72 6f 2c 20 66 , IntPtr.Zero, f
125c0 75 6e 63 2c 20 66 75 6e 63 73 74 65 70 2c 20 66 unc, funcstep, f
125d0 75 6e 63 66 69 6e 61 6c 29 3b 0d 0a 20 20 20 20 uncfinal);..
125e0 20 20 69 66 20 28 6e 20 3d 3d 20 53 51 4c 69 74 if (n == SQLit
125f0 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 6e eErrorCode.Ok) n
12600 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d = UnsafeNativeM
12610 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 ethods.sqlite3_c
12620 72 65 61 74 65 5f 66 75 6e 63 74 69 6f 6e 28 5f reate_function(_
12630 73 71 6c 2c 20 54 6f 55 54 46 38 28 73 74 72 46 sql, ToUTF8(strF
12640 75 6e 63 74 69 6f 6e 29 2c 20 6e 41 72 67 73 2c unction), nArgs,
12650 20 31 2c 20 49 6e 74 50 74 72 2e 5a 65 72 6f 2c 1, IntPtr.Zero,
12660 20 66 75 6e 63 2c 20 66 75 6e 63 73 74 65 70 2c func, funcstep,
12670 20 66 75 6e 63 66 69 6e 61 6c 29 3b 0d 0a 23 65 funcfinal);..#e
12680 6e 64 69 66 0d 0a 20 20 20 20 20 20 69 66 20 28 ndif.. if (
12690 63 61 6e 54 68 72 6f 77 20 26 26 20 28 6e 20 21 canThrow && (n !
126a0 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 = SQLiteErrorCod
126b0 65 2e 4f 6b 29 29 20 74 68 72 6f 77 20 6e 65 77 e.Ok)) throw new
126c0 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e SQLiteException
126d0 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f 72 (n, GetLastError
126e0 28 29 29 3b 0d 0a 20 20 20 20 20 20 72 65 74 75 ());.. retu
126f0 72 6e 20 6e 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a rn n;.. }....
12700 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
12710 72 72 69 64 65 20 53 51 4c 69 74 65 45 72 72 6f rride SQLiteErro
12720 72 43 6f 64 65 20 43 72 65 61 74 65 43 6f 6c 6c rCode CreateColl
12730 61 74 69 6f 6e 28 73 74 72 69 6e 67 20 73 74 72 ation(string str
12740 43 6f 6c 6c 61 74 69 6f 6e 2c 20 53 51 4c 69 74 Collation, SQLit
12750 65 43 6f 6c 6c 61 74 69 6f 6e 20 66 75 6e 63 2c eCollation func,
12760 20 53 51 4c 69 74 65 43 6f 6c 6c 61 74 69 6f 6e SQLiteCollation
12770 20 66 75 6e 63 31 36 2c 20 62 6f 6f 6c 20 63 61 func16, bool ca
12780 6e 54 68 72 6f 77 29 0d 0a 20 20 20 20 7b 0d 0a nThrow).. {..
12790 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 6f SQLiteErro
127a0 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 66 65 rCode n = Unsafe
127b0 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
127c0 6c 69 74 65 33 5f 63 72 65 61 74 65 5f 63 6f 6c lite3_create_col
127d0 6c 61 74 69 6f 6e 28 5f 73 71 6c 2c 20 54 6f 55 lation(_sql, ToU
127e0 54 46 38 28 73 74 72 43 6f 6c 6c 61 74 69 6f 6e TF8(strCollation
127f0 29 2c 20 32 2c 20 49 6e 74 50 74 72 2e 5a 65 72 ), 2, IntPtr.Zer
12800 6f 2c 20 66 75 6e 63 31 36 29 3b 0d 0a 20 20 20 o, func16);..
12810 20 20 20 69 66 20 28 6e 20 3d 3d 20 53 51 4c 69 if (n == SQLi
12820 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 teErrorCode.Ok)
12830 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 n = UnsafeNative
12840 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
12850 63 72 65 61 74 65 5f 63 6f 6c 6c 61 74 69 6f 6e create_collation
12860 28 5f 73 71 6c 2c 20 54 6f 55 54 46 38 28 73 74 (_sql, ToUTF8(st
12870 72 43 6f 6c 6c 61 74 69 6f 6e 29 2c 20 31 2c 20 rCollation), 1,
12880 49 6e 74 50 74 72 2e 5a 65 72 6f 2c 20 66 75 6e IntPtr.Zero, fun
12890 63 29 3b 0d 0a 20 20 20 20 20 20 69 66 20 28 63 c);.. if (c
128a0 61 6e 54 68 72 6f 77 20 26 26 20 28 6e 20 21 3d anThrow && (n !=
128b0 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
128c0 2e 4f 6b 29 29 20 74 68 72 6f 77 20 6e 65 77 20 .Ok)) throw new
128d0 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 SQLiteException(
128e0 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f 72 28 n, GetLastError(
128f0 29 29 3b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 ));.. retur
12900 6e 20 6e 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 n n;.. }....
12910 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 internal over
12920 72 69 64 65 20 69 6e 74 20 43 6f 6e 74 65 78 74 ride int Context
12930 43 6f 6c 6c 61 74 65 43 6f 6d 70 61 72 65 28 43 CollateCompare(C
12940 6f 6c 6c 61 74 69 6f 6e 45 6e 63 6f 64 69 6e 67 ollationEncoding
12950 45 6e 75 6d 20 65 6e 63 2c 20 49 6e 74 50 74 72 Enum enc, IntPtr
12960 20 63 6f 6e 74 65 78 74 2c 20 73 74 72 69 6e 67 context, string
12970 20 73 31 2c 20 73 74 72 69 6e 67 20 73 32 29 0d s1, string s2).
12980 0a 20 20 20 20 7b 0d 0a 23 69 66 20 21 53 51 4c . {..#if !SQL
12990 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 ITE_STANDARD..
129a0 20 20 20 20 62 79 74 65 5b 5d 20 62 31 3b 0d 0a byte[] b1;..
129b0 20 20 20 20 20 20 62 79 74 65 5b 5d 20 62 32 3b byte[] b2;
129c0 0d 0a 20 20 20 20 20 20 53 79 73 74 65 6d 2e 54 .. System.T
129d0 65 78 74 2e 45 6e 63 6f 64 69 6e 67 20 63 6f 6e ext.Encoding con
129e0 76 65 72 74 65 72 20 3d 20 6e 75 6c 6c 3b 0d 0a verter = null;..
129f0 0d 0a 20 20 20 20 20 20 73 77 69 74 63 68 20 28 .. switch (
12a00 65 6e 63 29 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 enc).. {..
12a10 20 20 20 20 20 20 20 63 61 73 65 20 43 6f 6c 6c case Coll
12a20 61 74 69 6f 6e 45 6e 63 6f 64 69 6e 67 45 6e 75 ationEncodingEnu
12a30 6d 2e 55 54 46 38 3a 0d 0a 20 20 20 20 20 20 20 m.UTF8:..
12a40 20 20 20 63 6f 6e 76 65 72 74 65 72 20 3d 20 53 converter = S
12a50 79 73 74 65 6d 2e 54 65 78 74 2e 45 6e 63 6f 64 ystem.Text.Encod
12a60 69 6e 67 2e 55 54 46 38 3b 0d 0a 20 20 20 20 20 ing.UTF8;..
12a70 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 break;..
12a80 20 20 20 20 20 63 61 73 65 20 43 6f 6c 6c 61 74 case Collat
12a90 69 6f 6e 45 6e 63 6f 64 69 6e 67 45 6e 75 6d 2e ionEncodingEnum.
12aa0 55 54 46 31 36 4c 45 3a 0d 0a 20 20 20 20 20 20 UTF16LE:..
12ab0 20 20 20 20 63 6f 6e 76 65 72 74 65 72 20 3d 20 converter =
12ac0 53 79 73 74 65 6d 2e 54 65 78 74 2e 45 6e 63 6f System.Text.Enco
12ad0 64 69 6e 67 2e 55 6e 69 63 6f 64 65 3b 0d 0a 20 ding.Unicode;..
12ae0 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d break;.
12af0 0a 20 20 20 20 20 20 20 20 63 61 73 65 20 43 6f . case Co
12b00 6c 6c 61 74 69 6f 6e 45 6e 63 6f 64 69 6e 67 45 llationEncodingE
12b10 6e 75 6d 2e 55 54 46 31 36 42 45 3a 0d 0a 20 20 num.UTF16BE:..
12b20 20 20 20 20 20 20 20 20 63 6f 6e 76 65 72 74 65 converte
12b30 72 20 3d 20 53 79 73 74 65 6d 2e 54 65 78 74 2e r = System.Text.
12b40 45 6e 63 6f 64 69 6e 67 2e 42 69 67 45 6e 64 69 Encoding.BigEndi
12b50 61 6e 55 6e 69 63 6f 64 65 3b 0d 0a 20 20 20 20 anUnicode;..
12b60 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 break;..
12b70 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 62 }.... b
12b80 31 20 3d 20 63 6f 6e 76 65 72 74 65 72 2e 47 65 1 = converter.Ge
12b90 74 42 79 74 65 73 28 73 31 29 3b 0d 0a 20 20 20 tBytes(s1);..
12ba0 20 20 20 62 32 20 3d 20 63 6f 6e 76 65 72 74 65 b2 = converte
12bb0 72 2e 47 65 74 42 79 74 65 73 28 73 32 29 3b 0d r.GetBytes(s2);.
12bc0 0a 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 ... return
12bd0 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
12be0 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6e 74 ods.sqlite3_cont
12bf0 65 78 74 5f 63 6f 6c 6c 63 6f 6d 70 61 72 65 5f ext_collcompare_
12c00 69 6e 74 65 72 6f 70 28 63 6f 6e 74 65 78 74 2c interop(context,
12c10 20 62 31 2c 20 62 31 2e 4c 65 6e 67 74 68 2c 20 b1, b1.Length,
12c20 62 32 2c 20 62 32 2e 4c 65 6e 67 74 68 29 3b 0d b2, b2.Length);.
12c30 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 74 68 .#else.. th
12c40 72 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 row new NotImple
12c50 6d 65 6e 74 65 64 45 78 63 65 70 74 69 6f 6e 28 mentedException(
12c60 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 );..#endif..
12c70 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 }.... interna
12c80 6c 20 6f 76 65 72 72 69 64 65 20 69 6e 74 20 43 l override int C
12c90 6f 6e 74 65 78 74 43 6f 6c 6c 61 74 65 43 6f 6d ontextCollateCom
12ca0 70 61 72 65 28 43 6f 6c 6c 61 74 69 6f 6e 45 6e pare(CollationEn
12cb0 63 6f 64 69 6e 67 45 6e 75 6d 20 65 6e 63 2c 20 codingEnum enc,
12cc0 49 6e 74 50 74 72 20 63 6f 6e 74 65 78 74 2c 20 IntPtr context,
12cd0 63 68 61 72 5b 5d 20 63 31 2c 20 63 68 61 72 5b char[] c1, char[
12ce0 5d 20 63 32 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 ] c2).. {..#i
12cf0 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 f !SQLITE_STANDA
12d00 52 44 0d 0a 20 20 20 20 20 20 62 79 74 65 5b 5d RD.. byte[]
12d10 20 62 31 3b 0d 0a 20 20 20 20 20 20 62 79 74 65 b1;.. byte
12d20 5b 5d 20 62 32 3b 0d 0a 20 20 20 20 20 20 53 79 [] b2;.. Sy
12d30 73 74 65 6d 2e 54 65 78 74 2e 45 6e 63 6f 64 69 stem.Text.Encodi
12d40 6e 67 20 63 6f 6e 76 65 72 74 65 72 20 3d 20 6e ng converter = n
12d50 75 6c 6c 3b 0d 0a 0d 0a 20 20 20 20 20 20 73 77 ull;.... sw
12d60 69 74 63 68 20 28 65 6e 63 29 0d 0a 20 20 20 20 itch (enc)..
12d70 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 63 61 73 {.. cas
12d80 65 20 43 6f 6c 6c 61 74 69 6f 6e 45 6e 63 6f 64 e CollationEncod
12d90 69 6e 67 45 6e 75 6d 2e 55 54 46 38 3a 0d 0a 20 ingEnum.UTF8:..
12da0 20 20 20 20 20 20 20 20 20 63 6f 6e 76 65 72 74 convert
12db0 65 72 20 3d 20 53 79 73 74 65 6d 2e 54 65 78 74 er = System.Text
12dc0 2e 45 6e 63 6f 64 69 6e 67 2e 55 54 46 38 3b 0d .Encoding.UTF8;.
12dd0 0a 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b . break
12de0 3b 0d 0a 20 20 20 20 20 20 20 20 63 61 73 65 20 ;.. case
12df0 43 6f 6c 6c 61 74 69 6f 6e 45 6e 63 6f 64 69 6e CollationEncodin
12e00 67 45 6e 75 6d 2e 55 54 46 31 36 4c 45 3a 0d 0a gEnum.UTF16LE:..
12e10 20 20 20 20 20 20 20 20 20 20 63 6f 6e 76 65 72 conver
12e20 74 65 72 20 3d 20 53 79 73 74 65 6d 2e 54 65 78 ter = System.Tex
12e30 74 2e 45 6e 63 6f 64 69 6e 67 2e 55 6e 69 63 6f t.Encoding.Unico
12e40 64 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 62 de;.. b
12e50 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 63 reak;.. c
12e60 61 73 65 20 43 6f 6c 6c 61 74 69 6f 6e 45 6e 63 ase CollationEnc
12e70 6f 64 69 6e 67 45 6e 75 6d 2e 55 54 46 31 36 42 odingEnum.UTF16B
12e80 45 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 63 6f E:.. co
12e90 6e 76 65 72 74 65 72 20 3d 20 53 79 73 74 65 6d nverter = System
12ea0 2e 54 65 78 74 2e 45 6e 63 6f 64 69 6e 67 2e 42 .Text.Encoding.B
12eb0 69 67 45 6e 64 69 61 6e 55 6e 69 63 6f 64 65 3b igEndianUnicode;
12ec0 0d 0a 20 20 20 20 20 20 20 20 20 20 62 72 65 61 .. brea
12ed0 6b 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 k;.. }....
12ee0 20 20 20 20 20 62 31 20 3d 20 63 6f 6e 76 65 72 b1 = conver
12ef0 74 65 72 2e 47 65 74 42 79 74 65 73 28 63 31 29 ter.GetBytes(c1)
12f00 3b 0d 0a 20 20 20 20 20 20 62 32 20 3d 20 63 6f ;.. b2 = co
12f10 6e 76 65 72 74 65 72 2e 47 65 74 42 79 74 65 73 nverter.GetBytes
12f20 28 63 32 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 72 (c2);.... r
12f30 65 74 75 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 eturn UnsafeNati
12f40 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
12f50 33 5f 63 6f 6e 74 65 78 74 5f 63 6f 6c 6c 63 6f 3_context_collco
12f60 6d 70 61 72 65 5f 69 6e 74 65 72 6f 70 28 63 6f mpare_interop(co
12f70 6e 74 65 78 74 2c 20 62 31 2c 20 62 31 2e 4c 65 ntext, b1, b1.Le
12f80 6e 67 74 68 2c 20 62 32 2c 20 62 32 2e 4c 65 6e ngth, b2, b2.Len
12f90 67 74 68 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 gth);..#else..
12fa0 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 4e 6f throw new No
12fb0 74 49 6d 70 6c 65 6d 65 6e 74 65 64 45 78 63 65 tImplementedExce
12fc0 70 74 69 6f 6e 28 29 3b 0d 0a 23 65 6e 64 69 66 ption();..#endif
12fd0 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
12fe0 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
12ff0 20 43 6f 6c 6c 61 74 69 6f 6e 53 65 71 75 65 6e CollationSequen
13000 63 65 20 47 65 74 43 6f 6c 6c 61 74 69 6f 6e 53 ce GetCollationS
13010 65 71 75 65 6e 63 65 28 53 51 4c 69 74 65 46 75 equence(SQLiteFu
13020 6e 63 74 69 6f 6e 20 66 75 6e 63 2c 20 49 6e 74 nction func, Int
13030 50 74 72 20 63 6f 6e 74 65 78 74 29 0d 0a 20 20 Ptr context)..
13040 20 20 7b 0d 0a 23 69 66 20 21 53 51 4c 49 54 45 {..#if !SQLITE
13050 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 _STANDARD..
13060 20 43 6f 6c 6c 61 74 69 6f 6e 53 65 71 75 65 6e CollationSequen
13070 63 65 20 73 65 71 20 3d 20 6e 65 77 20 43 6f 6c ce seq = new Col
13080 6c 61 74 69 6f 6e 53 65 71 75 65 6e 63 65 28 29 lationSequence()
13090 3b 0d 0a 20 20 20 20 20 20 69 6e 74 20 6c 65 6e ;.. int len
130a0 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 69 6e 74 = 0;.. int
130b0 20 74 79 70 65 20 3d 20 30 3b 0d 0a 20 20 20 20 type = 0;..
130c0 20 20 69 6e 74 20 65 6e 63 20 3d 20 30 3b 0d 0a int enc = 0;..
130d0 20 20 20 20 20 20 49 6e 74 50 74 72 20 70 20 3d IntPtr p =
130e0 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
130f0 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6e hods.sqlite3_con
13100 74 65 78 74 5f 63 6f 6c 6c 73 65 71 5f 69 6e 74 text_collseq_int
13110 65 72 6f 70 28 63 6f 6e 74 65 78 74 2c 20 72 65 erop(context, re
13120 66 20 74 79 70 65 2c 20 72 65 66 20 65 6e 63 2c f type, ref enc,
13130 20 72 65 66 20 6c 65 6e 29 3b 0d 0a 0d 0a 20 20 ref len);....
13140 20 20 20 20 69 66 20 28 70 20 21 3d 20 6e 75 6c if (p != nul
13150 6c 29 20 73 65 71 2e 4e 61 6d 65 20 3d 20 55 54 l) seq.Name = UT
13160 46 38 54 6f 53 74 72 69 6e 67 28 70 2c 20 6c 65 F8ToString(p, le
13170 6e 29 3b 0d 0a 20 20 20 20 20 20 73 65 71 2e 54 n);.. seq.T
13180 79 70 65 20 3d 20 28 43 6f 6c 6c 61 74 69 6f 6e ype = (Collation
13190 54 79 70 65 45 6e 75 6d 29 74 79 70 65 3b 0d 0a TypeEnum)type;..
131a0 20 20 20 20 20 20 73 65 71 2e 5f 66 75 6e 63 20 seq._func
131b0 3d 20 66 75 6e 63 3b 0d 0a 20 20 20 20 20 20 73 = func;.. s
131c0 65 71 2e 45 6e 63 6f 64 69 6e 67 20 3d 20 28 43 eq.Encoding = (C
131d0 6f 6c 6c 61 74 69 6f 6e 45 6e 63 6f 64 69 6e 67 ollationEncoding
131e0 45 6e 75 6d 29 65 6e 63 3b 0d 0a 0d 0a 20 20 20 Enum)enc;....
131f0 20 20 20 72 65 74 75 72 6e 20 73 65 71 3b 0d 0a return seq;..
13200 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 74 68 72 #else.. thr
13210 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 6d ow new NotImplem
13220 65 6e 74 65 64 45 78 63 65 70 74 69 6f 6e 28 29 entedException()
13230 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d ;..#endif.. }
13240 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
13250 20 6f 76 65 72 72 69 64 65 20 6c 6f 6e 67 20 47 override long G
13260 65 74 50 61 72 61 6d 56 61 6c 75 65 42 79 74 65 etParamValueByte
13270 73 28 49 6e 74 50 74 72 20 70 2c 20 69 6e 74 20 s(IntPtr p, int
13280 6e 44 61 74 61 4f 66 66 73 65 74 2c 20 62 79 74 nDataOffset, byt
13290 65 5b 5d 20 62 44 65 73 74 2c 20 69 6e 74 20 6e e[] bDest, int n
132a0 53 74 61 72 74 2c 20 69 6e 74 20 6e 4c 65 6e 67 Start, int nLeng
132b0 74 68 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 th).. {..
132c0 20 20 69 6e 74 20 6e 6c 65 6e 20 3d 20 55 6e 73 int nlen = Uns
132d0 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
132e0 2e 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 62 .sqlite3_value_b
132f0 79 74 65 73 28 70 29 3b 0d 0a 0d 0a 20 20 20 20 ytes(p);....
13300 20 20 2f 2f 20 49 66 20 6e 6f 20 64 65 73 74 69 // If no desti
13310 6e 61 74 69 6f 6e 20 62 75 66 66 65 72 2c 20 72 nation buffer, r
13320 65 74 75 72 6e 20 74 68 65 20 73 69 7a 65 20 6e eturn the size n
13330 65 65 64 65 64 2e 0d 0a 20 20 20 20 20 20 69 66 eeded... if
13340 20 28 62 44 65 73 74 20 3d 3d 20 6e 75 6c 6c 29 (bDest == null)
13350 20 72 65 74 75 72 6e 20 6e 6c 65 6e 3b 0d 0a 0d return nlen;...
13360 0a 20 20 20 20 20 20 69 6e 74 20 6e 43 6f 70 69 . int nCopi
13370 65 64 20 3d 20 6e 4c 65 6e 67 74 68 3b 0d 0a 0d ed = nLength;...
13380 0a 20 20 20 20 20 20 69 66 20 28 6e 43 6f 70 69 . if (nCopi
13390 65 64 20 2b 20 6e 53 74 61 72 74 20 3e 20 62 44 ed + nStart > bD
133a0 65 73 74 2e 4c 65 6e 67 74 68 29 20 6e 43 6f 70 est.Length) nCop
133b0 69 65 64 20 3d 20 62 44 65 73 74 2e 4c 65 6e 67 ied = bDest.Leng
133c0 74 68 20 2d 20 6e 53 74 61 72 74 3b 0d 0a 20 20 th - nStart;..
133d0 20 20 20 20 69 66 20 28 6e 43 6f 70 69 65 64 20 if (nCopied
133e0 2b 20 6e 44 61 74 61 4f 66 66 73 65 74 20 3e 20 + nDataOffset >
133f0 6e 6c 65 6e 29 20 6e 43 6f 70 69 65 64 20 3d 20 nlen) nCopied =
13400 6e 6c 65 6e 20 2d 20 6e 44 61 74 61 4f 66 66 73 nlen - nDataOffs
13410 65 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 69 66 20 et;.... if
13420 28 6e 43 6f 70 69 65 64 20 3e 20 30 29 0d 0a 20 (nCopied > 0)..
13430 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
13440 49 6e 74 50 74 72 20 70 74 72 20 3d 20 55 6e 73 IntPtr ptr = Uns
13450 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
13460 2e 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 62 .sqlite3_value_b
13470 6c 6f 62 28 70 29 3b 0d 0a 0d 0a 20 20 20 20 20 lob(p);....
13480 20 20 20 4d 61 72 73 68 61 6c 2e 43 6f 70 79 28 Marshal.Copy(
13490 28 49 6e 74 50 74 72 29 28 70 74 72 2e 54 6f 49 (IntPtr)(ptr.ToI
134a0 6e 74 36 34 28 29 20 2b 20 6e 44 61 74 61 4f 66 nt64() + nDataOf
134b0 66 73 65 74 29 2c 20 62 44 65 73 74 2c 20 6e 53 fset), bDest, nS
134c0 74 61 72 74 2c 20 6e 43 6f 70 69 65 64 29 3b 0d tart, nCopied);.
134d0 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 . }..
134e0 65 6c 73 65 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 else.. {..
134f0 20 20 20 20 20 20 20 6e 43 6f 70 69 65 64 20 3d nCopied =
13500 20 30 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 0d 0a 0;.. }....
13510 20 20 20 20 20 20 72 65 74 75 72 6e 20 6e 43 6f return nCo
13520 70 69 65 64 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a pied;.. }....
13530 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
13540 72 72 69 64 65 20 64 6f 75 62 6c 65 20 47 65 74 rride double Get
13550 50 61 72 61 6d 56 61 6c 75 65 44 6f 75 62 6c 65 ParamValueDouble
13560 28 49 6e 74 50 74 72 20 70 74 72 29 0d 0a 20 20 (IntPtr ptr)..
13570 20 20 7b 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f {..#if !PLATFO
13580 52 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 RM_COMPACTFRAMEW
13590 4f 52 4b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 ORK.. retur
135a0 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 n UnsafeNativeMe
135b0 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 76 61 thods.sqlite3_va
135c0 6c 75 65 5f 64 6f 75 62 6c 65 28 70 74 72 29 3b lue_double(ptr);
135d0 0d 0a 23 65 6c 69 66 20 21 53 51 4c 49 54 45 5f ..#elif !SQLITE_
135e0 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 STANDARD..
135f0 64 6f 75 62 6c 65 20 76 61 6c 75 65 20 3d 20 30 double value = 0
13600 2e 30 3b 0d 0a 20 20 20 20 20 20 55 6e 73 61 66 .0;.. Unsaf
13610 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
13620 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 64 6f 75 qlite3_value_dou
13630 62 6c 65 5f 69 6e 74 65 72 6f 70 28 70 74 72 2c ble_interop(ptr,
13640 20 72 65 66 20 76 61 6c 75 65 29 3b 0d 0a 20 20 ref value);..
13650 20 20 20 20 72 65 74 75 72 6e 20 76 61 6c 75 65 return value
13660 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 ;..#else..
13670 74 68 72 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 throw new NotImp
13680 6c 65 6d 65 6e 74 65 64 45 78 63 65 70 74 69 6f lementedExceptio
13690 6e 28 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 n();..#endif..
136a0 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 }.... inter
136b0 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 69 6e 74 nal override int
136c0 20 47 65 74 50 61 72 61 6d 56 61 6c 75 65 49 6e GetParamValueIn
136d0 74 33 32 28 49 6e 74 50 74 72 20 70 74 72 29 0d t32(IntPtr ptr).
136e0 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 65 . {.. re
136f0 74 75 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 turn UnsafeNativ
13700 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
13710 5f 76 61 6c 75 65 5f 69 6e 74 28 70 74 72 29 3b _value_int(ptr);
13720 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
13730 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
13740 20 6c 6f 6e 67 20 47 65 74 50 61 72 61 6d 56 61 long GetParamVa
13750 6c 75 65 49 6e 74 36 34 28 49 6e 74 50 74 72 20 lueInt64(IntPtr
13760 70 74 72 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 ptr).. {..#if
13770 20 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 !PLATFORM_COMPA
13780 43 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 CTFRAMEWORK..
13790 20 20 20 72 65 74 75 72 6e 20 55 6e 73 61 66 65 return Unsafe
137a0 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
137b0 6c 69 74 65 33 5f 76 61 6c 75 65 5f 69 6e 74 36 lite3_value_int6
137c0 34 28 70 74 72 29 3b 0d 0a 23 65 6c 69 66 20 21 4(ptr);..#elif !
137d0 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d SQLITE_STANDARD.
137e0 0a 20 20 20 20 20 20 49 6e 74 36 34 20 76 61 6c . Int64 val
137f0 75 65 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 55 ue = 0;.. U
13800 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
13810 64 73 2e 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 ds.sqlite3_value
13820 5f 69 6e 74 36 34 5f 69 6e 74 65 72 6f 70 28 70 _int64_interop(p
13830 74 72 2c 20 72 65 66 20 76 61 6c 75 65 29 3b 0d tr, ref value);.
13840 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 76 61 . return va
13850 6c 75 65 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 lue;..#else..
13860 20 20 20 74 68 72 6f 77 20 6e 65 77 20 4e 6f 74 throw new Not
13870 49 6d 70 6c 65 6d 65 6e 74 65 64 45 78 63 65 70 ImplementedExcep
13880 74 69 6f 6e 28 29 3b 0d 0a 23 65 6e 64 69 66 0d tion();..#endif.
13890 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
138a0 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
138b0 73 74 72 69 6e 67 20 47 65 74 50 61 72 61 6d 56 string GetParamV
138c0 61 6c 75 65 54 65 78 74 28 49 6e 74 50 74 72 20 alueText(IntPtr
138d0 70 74 72 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 ptr).. {..#if
138e0 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 !SQLITE_STANDAR
138f0 44 0d 0a 20 20 20 20 20 20 69 6e 74 20 6c 65 6e D.. int len
13900 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 72 65 74 = 0;.. ret
13910 75 72 6e 20 55 54 46 38 54 6f 53 74 72 69 6e 67 urn UTF8ToString
13920 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 (UnsafeNativeMet
13930 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 76 61 6c hods.sqlite3_val
13940 75 65 5f 74 65 78 74 5f 69 6e 74 65 72 6f 70 28 ue_text_interop(
13950 70 74 72 2c 20 72 65 66 20 6c 65 6e 29 2c 20 6c ptr, ref len), l
13960 65 6e 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 en);..#else..
13970 20 20 20 72 65 74 75 72 6e 20 55 54 46 38 54 6f return UTF8To
13980 53 74 72 69 6e 67 28 55 6e 73 61 66 65 4e 61 74 String(UnsafeNat
13990 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 iveMethods.sqlit
139a0 65 33 5f 76 61 6c 75 65 5f 74 65 78 74 28 70 74 e3_value_text(pt
139b0 72 29 2c 0d 0a 20 20 20 20 20 20 20 20 55 6e 73 r),.. Uns
139c0 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
139d0 2e 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 62 .sqlite3_value_b
139e0 79 74 65 73 28 70 74 72 29 29 3b 0d 0a 23 65 6e ytes(ptr));..#en
139f0 64 69 66 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 dif.. }....
13a00 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 internal overr
13a10 69 64 65 20 54 79 70 65 41 66 66 69 6e 69 74 79 ide TypeAffinity
13a20 20 47 65 74 50 61 72 61 6d 56 61 6c 75 65 54 79 GetParamValueTy
13a30 70 65 28 49 6e 74 50 74 72 20 70 74 72 29 0d 0a pe(IntPtr ptr)..
13a40 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 65 74 {.. ret
13a50 75 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 urn UnsafeNative
13a60 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
13a70 76 61 6c 75 65 5f 74 79 70 65 28 70 74 72 29 3b value_type(ptr);
13a80 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
13a90 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
13aa0 20 76 6f 69 64 20 52 65 74 75 72 6e 42 6c 6f 62 void ReturnBlob
13ab0 28 49 6e 74 50 74 72 20 63 6f 6e 74 65 78 74 2c (IntPtr context,
13ac0 20 62 79 74 65 5b 5d 20 76 61 6c 75 65 29 0d 0a byte[] value)..
13ad0 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 55 6e 73 {.. Uns
13ae0 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
13af0 2e 73 71 6c 69 74 65 33 5f 72 65 73 75 6c 74 5f .sqlite3_result_
13b00 62 6c 6f 62 28 63 6f 6e 74 65 78 74 2c 20 76 61 blob(context, va
13b10 6c 75 65 2c 20 76 61 6c 75 65 2e 4c 65 6e 67 74 lue, value.Lengt
13b20 68 2c 20 28 49 6e 74 50 74 72 29 28 2d 31 29 29 h, (IntPtr)(-1))
13b30 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 ;.. }....
13b40 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 internal overrid
13b50 65 20 76 6f 69 64 20 52 65 74 75 72 6e 44 6f 75 e void ReturnDou
13b60 62 6c 65 28 49 6e 74 50 74 72 20 63 6f 6e 74 65 ble(IntPtr conte
13b70 78 74 2c 20 64 6f 75 62 6c 65 20 76 61 6c 75 65 xt, double value
13b80 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 21 50 ).. {..#if !P
13b90 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 LATFORM_COMPACTF
13ba0 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 20 20 RAMEWORK..
13bb0 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
13bc0 6f 64 73 2e 73 71 6c 69 74 65 33 5f 72 65 73 75 ods.sqlite3_resu
13bd0 6c 74 5f 64 6f 75 62 6c 65 28 63 6f 6e 74 65 78 lt_double(contex
13be0 74 2c 20 76 61 6c 75 65 29 3b 0d 0a 23 65 6c 69 t, value);..#eli
13bf0 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 f !SQLITE_STANDA
13c00 52 44 0d 0a 20 20 20 20 20 20 55 6e 73 61 66 65 RD.. Unsafe
13c10 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
13c20 6c 69 74 65 33 5f 72 65 73 75 6c 74 5f 64 6f 75 lite3_result_dou
13c30 62 6c 65 5f 69 6e 74 65 72 6f 70 28 63 6f 6e 74 ble_interop(cont
13c40 65 78 74 2c 20 72 65 66 20 76 61 6c 75 65 29 3b ext, ref value);
13c50 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 74 ..#else.. t
13c60 68 72 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c hrow new NotImpl
13c70 65 6d 65 6e 74 65 64 45 78 63 65 70 74 69 6f 6e ementedException
13c80 28 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 ();..#endif..
13c90 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e }.... intern
13ca0 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f 69 64 al override void
13cb0 20 52 65 74 75 72 6e 45 72 72 6f 72 28 49 6e 74 ReturnError(Int
13cc0 50 74 72 20 63 6f 6e 74 65 78 74 2c 20 73 74 72 Ptr context, str
13cd0 69 6e 67 20 76 61 6c 75 65 29 0d 0a 20 20 20 20 ing value)..
13ce0 7b 0d 0a 20 20 20 20 20 20 55 6e 73 61 66 65 4e {.. UnsafeN
13cf0 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c ativeMethods.sql
13d00 69 74 65 33 5f 72 65 73 75 6c 74 5f 65 72 72 6f ite3_result_erro
13d10 72 28 63 6f 6e 74 65 78 74 2c 20 54 6f 55 54 46 r(context, ToUTF
13d20 38 28 76 61 6c 75 65 29 2c 20 76 61 6c 75 65 2e 8(value), value.
13d30 4c 65 6e 67 74 68 29 3b 0d 0a 20 20 20 20 7d 0d Length);.. }.
13d40 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
13d50 6f 76 65 72 72 69 64 65 20 76 6f 69 64 20 52 65 override void Re
13d60 74 75 72 6e 49 6e 74 33 32 28 49 6e 74 50 74 72 turnInt32(IntPtr
13d70 20 63 6f 6e 74 65 78 74 2c 20 69 6e 74 20 76 61 context, int va
13d80 6c 75 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 lue).. {..
13d90 20 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d UnsafeNativeM
13da0 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 72 ethods.sqlite3_r
13db0 65 73 75 6c 74 5f 69 6e 74 28 63 6f 6e 74 65 78 esult_int(contex
13dc0 74 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 t, value);..
13dd0 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 }.... interna
13de0 6c 20 6f 76 65 72 72 69 64 65 20 76 6f 69 64 20 l override void
13df0 52 65 74 75 72 6e 49 6e 74 36 34 28 49 6e 74 50 ReturnInt64(IntP
13e00 74 72 20 63 6f 6e 74 65 78 74 2c 20 6c 6f 6e 67 tr context, long
13e10 20 76 61 6c 75 65 29 0d 0a 20 20 20 20 7b 0d 0a value).. {..
13e20 23 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f 43 4f #if !PLATFORM_CO
13e30 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 4b 0d 0a MPACTFRAMEWORK..
13e40 20 20 20 20 20 20 55 6e 73 61 66 65 4e 61 74 69 UnsafeNati
13e50 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
13e60 33 5f 72 65 73 75 6c 74 5f 69 6e 74 36 34 28 63 3_result_int64(c
13e70 6f 6e 74 65 78 74 2c 20 76 61 6c 75 65 29 3b 0d ontext, value);.
13e80 0a 23 65 6c 69 66 20 21 53 51 4c 49 54 45 5f 53 .#elif !SQLITE_S
13e90 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 55 TANDARD.. U
13ea0 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
13eb0 64 73 2e 73 71 6c 69 74 65 33 5f 72 65 73 75 6c ds.sqlite3_resul
13ec0 74 5f 69 6e 74 36 34 5f 69 6e 74 65 72 6f 70 28 t_int64_interop(
13ed0 63 6f 6e 74 65 78 74 2c 20 72 65 66 20 76 61 6c context, ref val
13ee0 75 65 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 ue);..#else..
13ef0 20 20 20 74 68 72 6f 77 20 6e 65 77 20 4e 6f 74 throw new Not
13f00 49 6d 70 6c 65 6d 65 6e 74 65 64 45 78 63 65 70 ImplementedExcep
13f10 74 69 6f 6e 28 29 3b 0d 0a 23 65 6e 64 69 66 0d tion();..#endif.
13f20 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
13f30 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
13f40 76 6f 69 64 20 52 65 74 75 72 6e 4e 75 6c 6c 28 void ReturnNull(
13f50 49 6e 74 50 74 72 20 63 6f 6e 74 65 78 74 29 0d IntPtr context).
13f60 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 55 6e . {.. Un
13f70 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
13f80 73 2e 73 71 6c 69 74 65 33 5f 72 65 73 75 6c 74 s.sqlite3_result
13f90 5f 6e 75 6c 6c 28 63 6f 6e 74 65 78 74 29 3b 0d _null(context);.
13fa0 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
13fb0 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
13fc0 76 6f 69 64 20 52 65 74 75 72 6e 54 65 78 74 28 void ReturnText(
13fd0 49 6e 74 50 74 72 20 63 6f 6e 74 65 78 74 2c 20 IntPtr context,
13fe0 73 74 72 69 6e 67 20 76 61 6c 75 65 29 0d 0a 20 string value)..
13ff0 20 20 20 7b 0d 0a 20 20 20 20 20 20 62 79 74 65 {.. byte
14000 5b 5d 20 62 20 3d 20 54 6f 55 54 46 38 28 76 61 [] b = ToUTF8(va
14010 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 55 6e 73 lue);.. Uns
14020 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
14030 2e 73 71 6c 69 74 65 33 5f 72 65 73 75 6c 74 5f .sqlite3_result_
14040 74 65 78 74 28 63 6f 6e 74 65 78 74 2c 20 54 6f text(context, To
14050 55 54 46 38 28 76 61 6c 75 65 29 2c 20 62 2e 4c UTF8(value), b.L
14060 65 6e 67 74 68 20 2d 20 31 2c 20 28 49 6e 74 50 ength - 1, (IntP
14070 74 72 29 28 2d 31 29 29 3b 0d 0a 20 20 20 20 7d tr)(-1));.. }
14080 0d 0a 0d 0a 23 69 66 20 49 4e 54 45 52 4f 50 5f ....#if INTEROP_
14090 56 49 52 54 55 41 4c 5f 54 41 42 4c 45 0d 0a 20 VIRTUAL_TABLE..
140a0 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
140b0 0d 0a 20 20 20 20 2f 2f 2f 20 43 61 6c 6c 73 20 .. /// Calls
140c0 74 68 65 20 6e 61 74 69 76 65 20 53 51 4c 69 74 the native SQLit
140d0 65 20 63 6f 72 65 20 6c 69 62 72 61 72 79 20 69 e core library i
140e0 6e 20 6f 72 64 65 72 20 74 6f 20 63 72 65 61 74 n order to creat
140f0 65 20 61 20 64 69 73 70 6f 73 61 62 6c 65 0d 0a e a disposable..
14100 20 20 20 20 2f 2f 2f 20 6d 6f 64 75 6c 65 20 63 /// module c
14110 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 20 69 6d ontaining the im
14120 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 6f 66 20 plementation of
14130 61 20 76 69 72 74 75 61 6c 20 74 61 62 6c 65 2e a virtual table.
14140 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d .. /// </summ
14150 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 ary>.. /// <p
14160 61 72 61 6d 20 6e 61 6d 65 3d 22 6d 6f 64 75 6c aram name="modul
14170 65 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 e">.. /// The
14180 20 6d 6f 64 75 6c 65 20 6f 62 6a 65 63 74 20 74 module object t
14190 6f 20 62 65 20 75 73 65 64 20 77 68 65 6e 20 63 o be used when c
141a0 72 65 61 74 69 6e 67 20 74 68 65 20 6e 61 74 69 reating the nati
141b0 76 65 20 64 69 73 70 6f 73 61 62 6c 65 20 6d 6f ve disposable mo
141c0 64 75 6c 65 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c dule... /// <
141d0 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f /param>.. ///
141e0 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 66 6c <param name="fl
141f0 61 67 73 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 ags">.. /// T
14200 68 65 20 66 6c 61 67 73 20 66 6f 72 20 74 68 65 he flags for the
14210 20 61 73 73 6f 63 69 61 74 65 64 20 3c 73 65 65 associated <see
14220 20 63 72 65 66 3d 22 53 51 4c 69 74 65 43 6f 6e cref="SQLiteCon
14230 6e 65 63 74 69 6f 6e 22 20 2f 3e 20 6f 62 6a 65 nection" /> obje
14240 63 74 20 69 6e 73 74 61 6e 63 65 2e 0d 0a 20 20 ct instance...
14250 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a /// </param>..
14260 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
14270 72 72 69 64 65 20 76 6f 69 64 20 43 72 65 61 74 rride void Creat
14280 65 4d 6f 64 75 6c 65 28 53 51 4c 69 74 65 4d 6f eModule(SQLiteMo
14290 64 75 6c 65 20 6d 6f 64 75 6c 65 2c 20 53 51 4c dule module, SQL
142a0 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 iteConnectionFla
142b0 67 73 20 66 6c 61 67 73 29 0d 0a 20 20 20 20 7b gs flags).. {
142c0 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 6d 6f .. if (mo
142d0 64 75 6c 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 dule == null)..
142e0 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 throw
142f0 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c new ArgumentNul
14300 6c 45 78 63 65 70 74 69 6f 6e 28 22 6d 6f 64 75 lException("modu
14310 6c 65 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 le");....
14320 20 69 66 20 28 28 66 6c 61 67 73 20 26 20 53 51 if ((flags & SQ
14330 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c LiteConnectionFl
14340 61 67 73 2e 4e 6f 4c 6f 67 4d 6f 64 75 6c 65 29 ags.NoLogModule)
14350 20 21 3d 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 != SQLiteConnec
14360 74 69 6f 6e 46 6c 61 67 73 2e 4e 6f 4c 6f 67 4d tionFlags.NoLogM
14370 6f 64 75 6c 65 29 0d 0a 20 20 20 20 20 20 20 20 odule)..
14380 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d {.. m
14390 6f 64 75 6c 65 2e 4c 6f 67 45 72 72 6f 72 73 20 odule.LogErrors
143a0 3d 20 28 28 66 6c 61 67 73 20 26 20 53 51 4c 69 = ((flags & SQLi
143b0 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 teConnectionFlag
143c0 73 2e 4c 6f 67 4d 6f 64 75 6c 65 45 72 72 6f 72 s.LogModuleError
143d0 29 20 3d 3d 20 53 51 4c 69 74 65 43 6f 6e 6e 65 ) == SQLiteConne
143e0 63 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f 67 4d 6f ctionFlags.LogMo
143f0 64 75 6c 65 45 72 72 6f 72 29 3b 0d 0a 20 20 20 duleError);..
14400 20 20 20 20 20 20 20 20 20 6d 6f 64 75 6c 65 2e module.
14410 4c 6f 67 45 78 63 65 70 74 69 6f 6e 73 20 3d 20 LogExceptions =
14420 28 28 66 6c 61 67 73 20 26 20 53 51 4c 69 74 65 ((flags & SQLite
14430 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e ConnectionFlags.
14440 4c 6f 67 4d 6f 64 75 6c 65 45 78 63 65 70 74 69 LogModuleExcepti
14450 6f 6e 29 20 3d 3d 20 53 51 4c 69 74 65 43 6f 6e on) == SQLiteCon
14460 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e 4c 6f 67 nectionFlags.Log
14470 4d 6f 64 75 6c 65 45 78 63 65 70 74 69 6f 6e 29 ModuleException)
14480 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a ;.. }....
14490 20 20 20 20 20 20 20 20 69 66 20 28 5f 73 71 6c if (_sql
144a0 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 == null)..
144b0 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 throw new
144c0 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e SQLiteException
144d0 28 22 63 6f 6e 6e 65 63 74 69 6f 6e 20 68 61 73 ("connection has
144e0 20 61 6e 20 69 6e 76 61 6c 69 64 20 68 61 6e 64 an invalid hand
144f0 6c 65 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 le");....
14500 20 69 66 20 28 5f 73 68 69 6d 45 78 74 65 6e 73 if (_shimExtens
14510 69 6f 6e 46 69 6c 65 4e 61 6d 65 20 3d 3d 20 6e ionFileName == n
14520 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 ull)..
14530 20 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 throw new SQLi
14540 74 65 45 78 63 65 70 74 69 6f 6e 28 22 74 68 65 teException("the
14550 20 66 69 6c 65 20 6e 61 6d 65 20 66 6f 72 20 74 file name for t
14560 68 65 20 5c 22 76 74 73 68 69 6d 5c 22 20 65 78 he \"vtshim\" ex
14570 74 65 6e 73 69 6f 6e 20 69 73 20 75 6e 6b 6e 6f tension is unkno
14580 77 6e 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 wn");....
14590 20 69 66 20 28 5f 73 68 69 6d 45 78 74 65 6e 73 if (_shimExtens
145a0 69 6f 6e 50 72 6f 63 4e 61 6d 65 20 3d 3d 20 6e ionProcName == n
145b0 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 ull)..
145c0 20 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 throw new SQLi
145d0 74 65 45 78 63 65 70 74 69 6f 6e 28 22 74 68 65 teException("the
145e0 20 65 6e 74 72 79 20 70 6f 69 6e 74 20 66 6f 72 entry point for
145f0 20 74 68 65 20 5c 22 76 74 73 68 69 6d 5c 22 20 the \"vtshim\"
14600 65 78 74 65 6e 73 69 6f 6e 20 69 73 20 75 6e 6b extension is unk
14610 6e 6f 77 6e 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 nown");....
14620 20 20 20 53 65 74 4c 6f 61 64 45 78 74 65 6e 73 SetLoadExtens
14630 69 6f 6e 28 74 72 75 65 29 3b 0d 0a 20 20 20 20 ion(true);..
14640 20 20 20 20 4c 6f 61 64 45 78 74 65 6e 73 69 6f LoadExtensio
14650 6e 28 5f 73 68 69 6d 45 78 74 65 6e 73 69 6f 6e n(_shimExtension
14660 46 69 6c 65 4e 61 6d 65 2c 20 5f 73 68 69 6d 45 FileName, _shimE
14670 78 74 65 6e 73 69 6f 6e 50 72 6f 63 4e 61 6d 65 xtensionProcName
14680 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 );.... if
14690 20 28 6d 6f 64 75 6c 65 2e 43 72 65 61 74 65 44 (module.CreateD
146a0 69 73 70 6f 73 61 62 6c 65 4d 6f 64 75 6c 65 28 isposableModule(
146b0 5f 73 71 6c 29 29 0d 0a 20 20 20 20 20 20 20 20 _sql))..
146c0 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 {.. i
146d0 66 20 28 5f 6d 6f 64 75 6c 65 73 20 3d 3d 20 6e f (_modules == n
146e0 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 ull)..
146f0 20 20 20 20 20 20 5f 6d 6f 64 75 6c 65 73 20 3d _modules =
14700 20 6e 65 77 20 44 69 63 74 69 6f 6e 61 72 79 3c new Dictionary<
14710 73 74 72 69 6e 67 2c 20 53 51 4c 69 74 65 4d 6f string, SQLiteMo
14720 64 75 6c 65 3e 28 29 3b 0d 0a 0d 0a 20 20 20 20 dule>();....
14730 20 20 20 20 20 20 20 20 5f 6d 6f 64 75 6c 65 73 _modules
14740 2e 41 64 64 28 6d 6f 64 75 6c 65 2e 4e 61 6d 65 .Add(module.Name
14750 2c 20 6d 6f 64 75 6c 65 29 3b 0d 0a 0d 0a 20 20 , module);....
14760 20 20 20 20 20 20 20 20 20 20 69 66 20 28 5f 75 if (_u
14770 73 65 50 6f 6f 6c 29 0d 0a 20 20 20 20 20 20 20 sePool)..
14780 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
14790 20 20 20 20 20 20 20 20 5f 75 73 65 50 6f 6f 6c _usePool
147a0 20 3d 20 66 61 6c 73 65 3b 0d 0a 0d 0a 23 69 66 = false;....#if
147b0 20 21 4e 45 54 5f 43 4f 4d 50 41 43 54 5f 32 30 !NET_COMPACT_20
147c0 20 26 26 20 54 52 41 43 45 5f 43 4f 4e 4e 45 43 && TRACE_CONNEC
147d0 54 49 4f 4e 0d 0a 20 20 20 20 20 20 20 20 20 20 TION..
147e0 20 20 20 20 20 20 54 72 61 63 65 2e 57 72 69 74 Trace.Writ
147f0 65 4c 69 6e 65 28 55 6e 73 61 66 65 4e 61 74 69 eLine(UnsafeNati
14800 76 65 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 veMethods.String
14810 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 Format(..
14820 20 20 20 20 20 20 20 20 20 20 20 20 20 43 75 6c Cul
14830 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 tureInfo.Current
14840 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 Culture,..
14850 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 43 "C
14860 72 65 61 74 65 4d 6f 64 75 6c 65 20 28 50 6f 6f reateModule (Poo
14870 6c 29 20 44 69 73 61 62 6c 65 64 3a 20 7b 30 7d l) Disabled: {0}
14880 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ",..
14890 20 20 20 20 20 20 20 20 48 61 6e 64 6c 65 54 6f HandleTo
148a0 53 74 72 69 6e 67 28 29 29 29 3b 0d 0a 23 65 6e String()));..#en
148b0 64 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 20 dif..
148c0 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 }.. }..
148d0 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 else..
148e0 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
148f0 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 51 throw new SQ
14900 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 47 65 LiteException(Ge
14910 74 4c 61 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a tLastError());..
14920 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d }.. }
14930 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d .... /// <sum
14940 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 43 mary>.. /// C
14950 61 6c 6c 73 20 74 68 65 20 6e 61 74 69 76 65 20 alls the native
14960 53 51 4c 69 74 65 20 63 6f 72 65 20 6c 69 62 72 SQLite core libr
14970 61 72 79 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 ary in order to
14980 63 6c 65 61 6e 75 70 20 74 68 65 20 72 65 73 6f cleanup the reso
14990 75 72 63 65 73 0d 0a 20 20 20 20 2f 2f 2f 20 61 urces.. /// a
149a0 73 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 61 ssociated with a
149b0 20 6d 6f 64 75 6c 65 20 63 6f 6e 74 61 69 6e 69 module containi
149c0 6e 67 20 74 68 65 20 69 6d 70 6c 65 6d 65 6e 74 ng the implement
149d0 61 74 69 6f 6e 20 6f 66 20 61 20 76 69 72 74 75 ation of a virtu
149e0 61 6c 20 74 61 62 6c 65 2e 0d 0a 20 20 20 20 2f al table... /
149f0 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 // </summary>..
14a00 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 /// <param na
14a10 6d 65 3d 22 6d 6f 64 75 6c 65 22 3e 0d 0a 20 20 me="module">..
14a20 20 20 2f 2f 2f 20 54 68 65 20 6d 6f 64 75 6c 65 /// The module
14a30 20 6f 62 6a 65 63 74 20 70 72 65 76 69 6f 75 73 object previous
14a40 6c 79 20 70 61 73 73 65 64 20 74 6f 20 74 68 65 ly passed to the
14a50 20 3c 73 65 65 20 63 72 65 66 3d 22 43 72 65 61 <see cref="Crea
14a60 74 65 4d 6f 64 75 6c 65 22 20 2f 3e 0d 0a 20 20 teModule" />..
14a70 20 20 2f 2f 2f 20 6d 65 74 68 6f 64 2e 0d 0a 20 /// method...
14a80 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d /// </param>.
14a90 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 . /// <param
14aa0 6e 61 6d 65 3d 22 66 6c 61 67 73 22 3e 0d 0a 20 name="flags">..
14ab0 20 20 20 2f 2f 2f 20 54 68 65 20 66 6c 61 67 73 /// The flags
14ac0 20 66 6f 72 20 74 68 65 20 61 73 73 6f 63 69 61 for the associa
14ad0 74 65 64 20 3c 73 65 65 20 63 72 65 66 3d 22 53 ted <see cref="S
14ae0 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 22 QLiteConnection"
14af0 20 2f 3e 20 6f 62 6a 65 63 74 20 69 6e 73 74 61 /> object insta
14b00 6e 63 65 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f nce... /// </
14b10 70 61 72 61 6d 3e 0d 0a 20 20 20 20 69 6e 74 65 param>.. inte
14b20 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f rnal override vo
14b30 69 64 20 44 69 73 70 6f 73 65 4d 6f 64 75 6c 65 id DisposeModule
14b40 28 53 51 4c 69 74 65 4d 6f 64 75 6c 65 20 6d 6f (SQLiteModule mo
14b50 64 75 6c 65 2c 20 53 51 4c 69 74 65 43 6f 6e 6e dule, SQLiteConn
14b60 65 63 74 69 6f 6e 46 6c 61 67 73 20 66 6c 61 67 ectionFlags flag
14b70 73 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 s).. {..
14b80 20 20 20 69 66 20 28 6d 6f 64 75 6c 65 20 3d 3d if (module ==
14b90 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 null)..
14ba0 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 throw new Ar
14bb0 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 gumentNullExcept
14bc0 69 6f 6e 28 22 6d 6f 64 75 6c 65 22 29 3b 0d 0a ion("module");..
14bd0 0d 0a 20 20 20 20 20 20 20 20 6d 6f 64 75 6c 65 .. module
14be0 2e 44 69 73 70 6f 73 65 28 29 3b 0d 0a 20 20 20 .Dispose();..
14bf0 20 7d 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 }..#endif....
14c00 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 internal overr
14c10 69 64 65 20 49 6e 74 50 74 72 20 41 67 67 72 65 ide IntPtr Aggre
14c20 67 61 74 65 43 6f 6e 74 65 78 74 28 49 6e 74 50 gateContext(IntP
14c30 74 72 20 63 6f 6e 74 65 78 74 29 0d 0a 20 20 20 tr context)..
14c40 20 7b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e {.. return
14c50 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
14c60 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 61 67 67 hods.sqlite3_agg
14c70 72 65 67 61 74 65 5f 63 6f 6e 74 65 78 74 28 63 regate_context(c
14c80 6f 6e 74 65 78 74 2c 20 31 29 3b 0d 0a 20 20 20 ontext, 1);..
14c90 20 7d 0d 0a 0d 0a 23 69 66 20 49 4e 54 45 52 4f }....#if INTERO
14ca0 50 5f 56 49 52 54 55 41 4c 5f 54 41 42 4c 45 0d P_VIRTUAL_TABLE.
14cb0 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 . /// <summar
14cc0 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 43 61 6c 6c y>.. /// Call
14cd0 73 20 74 68 65 20 6e 61 74 69 76 65 20 53 51 4c s the native SQL
14ce0 69 74 65 20 63 6f 72 65 20 6c 69 62 72 61 72 79 ite core library
14cf0 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 64 65 63 in order to dec
14d00 6c 61 72 65 20 61 20 76 69 72 74 75 61 6c 20 74 lare a virtual t
14d10 61 62 6c 65 0d 0a 20 20 20 20 2f 2f 2f 20 69 6e able.. /// in
14d20 20 72 65 73 70 6f 6e 73 65 20 74 6f 20 61 20 63 response to a c
14d30 61 6c 6c 20 69 6e 74 6f 20 74 68 65 20 3c 73 65 all into the <se
14d40 65 20 63 72 65 66 3d 22 49 53 51 4c 69 74 65 4e e cref="ISQLiteN
14d50 61 74 69 76 65 4d 6f 64 75 6c 65 2e 78 43 72 65 ativeModule.xCre
14d60 61 74 65 22 20 2f 3e 0d 0a 20 20 20 20 2f 2f 2f ate" />.. ///
14d70 20 6f 72 20 3c 73 65 65 20 63 72 65 66 3d 22 49 or <see cref="I
14d80 53 51 4c 69 74 65 4e 61 74 69 76 65 4d 6f 64 75 SQLiteNativeModu
14d90 6c 65 2e 78 43 6f 6e 6e 65 63 74 22 20 2f 3e 20 le.xConnect" />
14da0 76 69 72 74 75 61 6c 20 74 61 62 6c 65 20 6d 65 virtual table me
14db0 74 68 6f 64 73 2e 0d 0a 20 20 20 20 2f 2f 2f 20 thods... ///
14dc0 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 </summary>..
14dd0 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d /// <param name=
14de0 22 6d 6f 64 75 6c 65 22 3e 0d 0a 20 20 20 20 2f "module">.. /
14df0 2f 2f 20 54 68 65 20 76 69 72 74 75 61 6c 20 74 // The virtual t
14e00 61 62 6c 65 20 6d 6f 64 75 6c 65 20 74 68 61 74 able module that
14e10 20 69 73 20 74 6f 20 62 65 20 72 65 73 70 6f 6e is to be respon
14e20 73 69 62 6c 65 20 66 6f 72 20 74 68 65 20 76 69 sible for the vi
14e30 72 74 75 61 6c 20 74 61 62 6c 65 0d 0a 20 20 20 rtual table..
14e40 20 2f 2f 2f 20 62 65 69 6e 67 20 64 65 63 6c 61 /// being decla
14e50 72 65 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f red... /// </
14e60 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 param>.. ///
14e70 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 73 74 72 <param name="str
14e80 53 71 6c 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 Sql">.. /// T
14e90 68 65 20 73 74 72 69 6e 67 20 63 6f 6e 74 61 69 he string contai
14ea0 6e 69 6e 67 20 74 68 65 20 53 51 4c 20 73 74 61 ning the SQL sta
14eb0 74 65 6d 65 6e 74 20 64 65 73 63 72 69 62 69 6e tement describin
14ec0 67 20 74 68 65 20 76 69 72 74 75 61 6c 20 74 61 g the virtual ta
14ed0 62 6c 65 20 74 6f 0d 0a 20 20 20 20 2f 2f 2f 20 ble to.. ///
14ee0 62 65 20 64 65 63 6c 61 72 65 64 2e 0d 0a 20 20 be declared...
14ef0 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a /// </param>..
14f00 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e /// <param n
14f10 61 6d 65 3d 22 65 72 72 6f 72 22 3e 0d 0a 20 20 ame="error">..
14f20 20 20 2f 2f 2f 20 55 70 6f 6e 20 73 75 63 63 65 /// Upon succe
14f30 73 73 2c 20 74 68 65 20 63 6f 6e 74 65 6e 74 73 ss, the contents
14f40 20 6f 66 20 74 68 69 73 20 70 61 72 61 6d 65 74 of this paramet
14f50 65 72 20 61 72 65 20 75 6e 64 65 66 69 6e 65 64 er are undefined
14f60 2e 20 20 55 70 6f 6e 20 66 61 69 6c 75 72 65 2c . Upon failure,
14f70 0d 0a 20 20 20 20 2f 2f 2f 20 69 74 20 73 68 6f .. /// it sho
14f80 75 6c 64 20 63 6f 6e 74 61 69 6e 20 61 6e 20 61 uld contain an a
14f90 70 70 72 6f 70 72 69 61 74 65 20 65 72 72 6f 72 ppropriate error
14fa0 20 6d 65 73 73 61 67 65 2e 0d 0a 20 20 20 20 2f message... /
14fb0 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 // </param>..
14fc0 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 0d 0a /// <returns>..
14fd0 20 20 20 20 2f 2f 2f 20 41 20 73 74 61 6e 64 61 /// A standa
14fe0 72 64 20 53 51 4c 69 74 65 20 72 65 74 75 72 6e rd SQLite return
14ff0 20 63 6f 64 65 2e 0d 0a 20 20 20 20 2f 2f 2f 20 code... ///
15000 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 </returns>..
15010 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 internal overrid
15020 65 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 e SQLiteErrorCod
15030 65 20 44 65 63 6c 61 72 65 56 69 72 74 75 61 6c e DeclareVirtual
15040 54 61 62 6c 65 28 0d 0a 20 20 20 20 20 20 20 20 Table(..
15050 53 51 4c 69 74 65 4d 6f 64 75 6c 65 20 6d 6f 64 SQLiteModule mod
15060 75 6c 65 2c 0d 0a 20 20 20 20 20 20 20 20 73 74 ule,.. st
15070 72 69 6e 67 20 73 74 72 53 71 6c 2c 0d 0a 20 20 ring strSql,..
15080 20 20 20 20 20 20 72 65 66 20 73 74 72 69 6e 67 ref string
15090 20 65 72 72 6f 72 0d 0a 20 20 20 20 20 20 20 20 error..
150a0 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
150b0 20 20 69 66 20 28 5f 73 71 6c 20 3d 3d 20 6e 75 if (_sql == nu
150c0 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a ll).. {..
150d0 20 20 20 20 20 20 20 20 20 20 20 20 65 72 72 6f erro
150e0 72 20 3d 20 22 63 6f 6e 6e 65 63 74 69 6f 6e 20 r = "connection
150f0 68 61 73 20 61 6e 20 69 6e 76 61 6c 69 64 20 68 has an invalid h
15100 61 6e 64 6c 65 22 3b 0d 0a 20 20 20 20 20 20 20 andle";..
15110 20 20 20 20 20 72 65 74 75 72 6e 20 53 51 4c 69 return SQLi
15120 74 65 45 72 72 6f 72 43 6f 64 65 2e 45 72 72 6f teErrorCode.Erro
15130 72 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d r;.. }...
15140 0a 20 20 20 20 20 20 20 20 49 6e 74 50 74 72 20 . IntPtr
15150 70 53 71 6c 20 3d 20 49 6e 74 50 74 72 2e 5a 65 pSql = IntPtr.Ze
15160 72 6f 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 74 ro;.... t
15170 72 79 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 ry.. {..
15180 20 20 20 20 20 20 20 20 20 20 20 70 53 71 6c 20 pSql
15190 3d 20 53 51 4c 69 74 65 53 74 72 69 6e 67 2e 55 = SQLiteString.U
151a0 74 66 38 49 6e 74 50 74 72 46 72 6f 6d 53 74 72 tf8IntPtrFromStr
151b0 69 6e 67 28 73 74 72 53 71 6c 29 3b 0d 0a 0d 0a ing(strSql);....
151c0 20 20 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 SQLi
151d0 74 65 45 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 teErrorCode n =
151e0 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
151f0 6f 64 73 2e 73 71 6c 69 74 65 33 5f 64 65 63 6c ods.sqlite3_decl
15200 61 72 65 5f 76 74 61 62 28 0d 0a 20 20 20 20 20 are_vtab(..
15210 20 20 20 20 20 20 20 20 20 20 20 5f 73 71 6c 2c _sql,
15220 20 70 53 71 6c 29 3b 0d 0a 0d 0a 20 20 20 20 20 pSql);....
15230 20 20 20 20 20 20 20 69 66 20 28 28 6e 20 3d 3d if ((n ==
15240 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
15250 2e 4f 6b 29 20 26 26 20 28 6d 6f 64 75 6c 65 20 .Ok) && (module
15260 21 3d 20 6e 75 6c 6c 29 29 0d 0a 20 20 20 20 20 != null))..
15270 20 20 20 20 20 20 20 20 20 20 20 6d 6f 64 75 6c modul
15280 65 2e 44 65 63 6c 61 72 65 64 20 3d 20 74 72 75 e.Declared = tru
15290 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 e;....
152a0 20 20 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 if (n != SQLit
152b0 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 65 eErrorCode.Ok) e
152c0 72 72 6f 72 20 3d 20 47 65 74 4c 61 73 74 45 72 rror = GetLastEr
152d0 72 6f 72 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 ror();....
152e0 20 20 20 20 20 20 72 65 74 75 72 6e 20 6e 3b 0d return n;.
152f0 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 . }..
15300 20 20 20 20 66 69 6e 61 6c 6c 79 0d 0a 20 20 20 finally..
15310 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
15320 20 20 20 20 69 66 20 28 70 53 71 6c 20 21 3d 20 if (pSql !=
15330 49 6e 74 50 74 72 2e 5a 65 72 6f 29 0d 0a 20 20 IntPtr.Zero)..
15340 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
15350 20 20 20 20 20 20 20 20 20 20 20 20 20 53 51 4c SQL
15360 69 74 65 4d 65 6d 6f 72 79 2e 46 72 65 65 28 70 iteMemory.Free(p
15370 53 71 6c 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 Sql);..
15380 20 20 20 20 20 20 20 70 53 71 6c 20 3d 20 49 6e pSql = In
15390 74 50 74 72 2e 5a 65 72 6f 3b 0d 0a 20 20 20 20 tPtr.Zero;..
153a0 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
153b0 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 }.. }....
153c0 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
153d0 0d 0a 20 20 20 20 2f 2f 2f 20 43 61 6c 6c 73 20 .. /// Calls
153e0 74 68 65 20 6e 61 74 69 76 65 20 53 51 4c 69 74 the native SQLit
153f0 65 20 63 6f 72 65 20 6c 69 62 72 61 72 79 20 69 e core library i
15400 6e 20 6f 72 64 65 72 20 74 6f 20 64 65 63 6c 61 n order to decla
15410 72 65 20 61 20 76 69 72 74 75 61 6c 20 74 61 62 re a virtual tab
15420 6c 65 0d 0a 20 20 20 20 2f 2f 2f 20 66 75 6e 63 le.. /// func
15430 74 69 6f 6e 20 69 6e 20 72 65 73 70 6f 6e 73 65 tion in response
15440 20 74 6f 20 61 20 63 61 6c 6c 20 69 6e 74 6f 20 to a call into
15450 74 68 65 20 3c 73 65 65 20 63 72 65 66 3d 22 49 the <see cref="I
15460 53 51 4c 69 74 65 4e 61 74 69 76 65 4d 6f 64 75 SQLiteNativeModu
15470 6c 65 2e 78 43 72 65 61 74 65 22 20 2f 3e 0d 0a le.xCreate" />..
15480 20 20 20 20 2f 2f 2f 20 6f 72 20 3c 73 65 65 20 /// or <see
15490 63 72 65 66 3d 22 49 53 51 4c 69 74 65 4e 61 74 cref="ISQLiteNat
154a0 69 76 65 4d 6f 64 75 6c 65 2e 78 43 6f 6e 6e 65 iveModule.xConne
154b0 63 74 22 20 2f 3e 20 76 69 72 74 75 61 6c 20 74 ct" /> virtual t
154c0 61 62 6c 65 20 6d 65 74 68 6f 64 73 2e 0d 0a 20 able methods...
154d0 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 /// </summary
154e0 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 >.. /// <para
154f0 6d 20 6e 61 6d 65 3d 22 6d 6f 64 75 6c 65 22 3e m name="module">
15500 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 76 69 .. /// The vi
15510 72 74 75 61 6c 20 74 61 62 6c 65 20 6d 6f 64 75 rtual table modu
15520 6c 65 20 74 68 61 74 20 69 73 20 74 6f 20 62 65 le that is to be
15530 20 72 65 73 70 6f 6e 73 69 62 6c 65 20 66 6f 72 responsible for
15540 20 74 68 65 20 76 69 72 74 75 61 6c 20 74 61 62 the virtual tab
15550 6c 65 0d 0a 20 20 20 20 2f 2f 2f 20 66 75 6e 63 le.. /// func
15560 74 69 6f 6e 20 62 65 69 6e 67 20 64 65 63 6c 61 tion being decla
15570 72 65 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f red... /// </
15580 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 param>.. ///
15590 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 61 72 67 <param name="arg
155a0 75 6d 65 6e 74 43 6f 75 6e 74 22 3e 0d 0a 20 20 umentCount">..
155b0 20 20 2f 2f 2f 20 54 68 65 20 6e 75 6d 62 65 72 /// The number
155c0 20 6f 66 20 61 72 67 75 6d 65 6e 74 73 20 74 6f of arguments to
155d0 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 20 62 65 the function be
155e0 69 6e 67 20 64 65 63 6c 61 72 65 64 2e 0d 0a 20 ing declared...
155f0 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d /// </param>.
15600 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 . /// <param
15610 6e 61 6d 65 3d 22 6e 61 6d 65 22 3e 0d 0a 20 20 name="name">..
15620 20 20 2f 2f 2f 20 54 68 65 20 6e 61 6d 65 20 6f /// The name o
15630 66 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 20 62 f the function b
15640 65 69 6e 67 20 64 65 63 6c 61 72 65 64 2e 0d 0a eing declared...
15650 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e /// </param>
15660 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d .. /// <param
15670 20 6e 61 6d 65 3d 22 65 72 72 6f 72 22 3e 0d 0a name="error">..
15680 20 20 20 20 2f 2f 2f 20 55 70 6f 6e 20 73 75 63 /// Upon suc
15690 63 65 73 73 2c 20 74 68 65 20 63 6f 6e 74 65 6e cess, the conten
156a0 74 73 20 6f 66 20 74 68 69 73 20 70 61 72 61 6d ts of this param
156b0 65 74 65 72 20 61 72 65 20 75 6e 64 65 66 69 6e eter are undefin
156c0 65 64 2e 20 20 55 70 6f 6e 20 66 61 69 6c 75 72 ed. Upon failur
156d0 65 2c 0d 0a 20 20 20 20 2f 2f 2f 20 69 74 20 73 e,.. /// it s
156e0 68 6f 75 6c 64 20 63 6f 6e 74 61 69 6e 20 61 6e hould contain an
156f0 20 61 70 70 72 6f 70 72 69 61 74 65 20 65 72 72 appropriate err
15700 6f 72 20 6d 65 73 73 61 67 65 2e 0d 0a 20 20 20 or message...
15710 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 /// </param>..
15720 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e /// <returns>
15730 0d 0a 20 20 20 20 2f 2f 2f 20 41 20 73 74 61 6e .. /// A stan
15740 64 61 72 64 20 53 51 4c 69 74 65 20 72 65 74 75 dard SQLite retu
15750 72 6e 20 63 6f 64 65 2e 0d 0a 20 20 20 20 2f 2f rn code... //
15760 2f 20 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 / </returns>..
15770 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 internal overr
15780 69 64 65 20 53 51 4c 69 74 65 45 72 72 6f 72 43 ide SQLiteErrorC
15790 6f 64 65 20 44 65 63 6c 61 72 65 56 69 72 74 75 ode DeclareVirtu
157a0 61 6c 46 75 6e 63 74 69 6f 6e 28 0d 0a 20 20 20 alFunction(..
157b0 20 20 20 20 20 53 51 4c 69 74 65 4d 6f 64 75 6c SQLiteModul
157c0 65 20 6d 6f 64 75 6c 65 2c 0d 0a 20 20 20 20 20 e module,..
157d0 20 20 20 69 6e 74 20 61 72 67 75 6d 65 6e 74 43 int argumentC
157e0 6f 75 6e 74 2c 0d 0a 20 20 20 20 20 20 20 20 73 ount,.. s
157f0 74 72 69 6e 67 20 6e 61 6d 65 2c 0d 0a 20 20 20 tring name,..
15800 20 20 20 20 20 72 65 66 20 73 74 72 69 6e 67 20 ref string
15810 65 72 72 6f 72 0d 0a 20 20 20 20 20 20 20 20 29 error.. )
15820 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
15830 20 69 66 20 28 5f 73 71 6c 20 3d 3d 20 6e 75 6c if (_sql == nul
15840 6c 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 l).. {..
15850 20 20 20 20 20 20 20 20 20 20 20 65 72 72 6f 72 error
15860 20 3d 20 22 63 6f 6e 6e 65 63 74 69 6f 6e 20 68 = "connection h
15870 61 73 20 61 6e 20 69 6e 76 61 6c 69 64 20 68 61 as an invalid ha
15880 6e 64 6c 65 22 3b 0d 0a 20 20 20 20 20 20 20 20 ndle";..
15890 20 20 20 20 72 65 74 75 72 6e 20 53 51 4c 69 74 return SQLit
158a0 65 45 72 72 6f 72 43 6f 64 65 2e 45 72 72 6f 72 eErrorCode.Error
158b0 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a ;.. }....
158c0 20 20 20 20 20 20 20 20 49 6e 74 50 74 72 20 70 IntPtr p
158d0 4e 61 6d 65 20 3d 20 49 6e 74 50 74 72 2e 5a 65 Name = IntPtr.Ze
158e0 72 6f 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 74 ro;.... t
158f0 72 79 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 ry.. {..
15900 20 20 20 20 20 20 20 20 20 20 20 70 4e 61 6d 65 pName
15910 20 3d 20 53 51 4c 69 74 65 53 74 72 69 6e 67 2e = SQLiteString.
15920 55 74 66 38 49 6e 74 50 74 72 46 72 6f 6d 53 74 Utf8IntPtrFromSt
15930 72 69 6e 67 28 6e 61 6d 65 29 3b 0d 0a 0d 0a 20 ring(name);....
15940 20 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 SQLit
15950 65 45 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 eErrorCode n = U
15960 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
15970 64 73 2e 73 71 6c 69 74 65 33 5f 6f 76 65 72 6c ds.sqlite3_overl
15980 6f 61 64 5f 66 75 6e 63 74 69 6f 6e 28 0d 0a 20 oad_function(..
15990 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5f _
159a0 73 71 6c 2c 20 70 4e 61 6d 65 2c 20 61 72 67 75 sql, pName, argu
159b0 6d 65 6e 74 43 6f 75 6e 74 29 3b 0d 0a 0d 0a 20 mentCount);....
159c0 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6e if (n
159d0 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 != SQLiteErrorC
159e0 6f 64 65 2e 4f 6b 29 20 65 72 72 6f 72 20 3d 20 ode.Ok) error =
159f0 47 65 74 4c 61 73 74 45 72 72 6f 72 28 29 3b 0d GetLastError();.
15a00 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 ... r
15a10 65 74 75 72 6e 20 6e 3b 0d 0a 20 20 20 20 20 20 eturn n;..
15a20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 66 69 6e }.. fin
15a30 61 6c 6c 79 0d 0a 20 20 20 20 20 20 20 20 7b 0d ally.. {.
15a40 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 . if
15a50 28 70 4e 61 6d 65 20 21 3d 20 49 6e 74 50 74 72 (pName != IntPtr
15a60 2e 5a 65 72 6f 29 0d 0a 20 20 20 20 20 20 20 20 .Zero)..
15a70 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
15a80 20 20 20 20 20 20 20 53 51 4c 69 74 65 4d 65 6d SQLiteMem
15a90 6f 72 79 2e 46 72 65 65 28 70 4e 61 6d 65 29 3b ory.Free(pName);
15aa0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
15ab0 20 20 70 4e 61 6d 65 20 3d 20 49 6e 74 50 74 72 pName = IntPtr
15ac0 2e 5a 65 72 6f 3b 0d 0a 20 20 20 20 20 20 20 20 .Zero;..
15ad0 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d }.. }
15ae0 0d 0a 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d .. }..#endif.
15af0 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d ... /// <summ
15b00 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 45 6e ary>.. /// En
15b10 61 62 6c 65 73 20 6f 72 20 64 69 73 61 62 6c 65 ables or disable
15b20 64 20 65 78 74 65 6e 73 69 6f 6e 20 6c 6f 61 64 d extension load
15b30 69 6e 67 20 62 79 20 53 51 4c 69 74 65 2e 0d 0a ing by SQLite...
15b40 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 /// </summar
15b50 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 y>.. /// <par
15b60 61 6d 20 6e 61 6d 65 3d 22 62 4f 6e 4f 66 66 22 am name="bOnOff"
15b70 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 72 75 65 20 >.. /// True
15b80 74 6f 20 65 6e 61 62 6c 65 20 6c 6f 61 64 69 6e to enable loadin
15b90 67 20 6f 66 20 65 78 74 65 6e 73 69 6f 6e 73 2c g of extensions,
15ba0 20 66 61 6c 73 65 20 74 6f 20 64 69 73 61 62 6c false to disabl
15bb0 65 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 e... /// </pa
15bc0 72 61 6d 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e ram>.. intern
15bd0 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f 69 64 al override void
15be0 20 53 65 74 4c 6f 61 64 45 78 74 65 6e 73 69 6f SetLoadExtensio
15bf0 6e 28 62 6f 6f 6c 20 62 4f 6e 4f 66 66 29 0d 0a n(bool bOnOff)..
15c00 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 53 {.. S
15c10 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 6e QLiteErrorCode n
15c20 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d = UnsafeNativeM
15c30 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 65 ethods.sqlite3_e
15c40 6e 61 62 6c 65 5f 6c 6f 61 64 5f 65 78 74 65 6e nable_load_exten
15c50 73 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 20 20 sion(..
15c60 20 20 20 5f 73 71 6c 2c 20 28 62 4f 6e 4f 66 66 _sql, (bOnOff
15c70 20 3f 20 2d 31 20 3a 20 30 29 29 3b 0d 0a 0d 0a ? -1 : 0));....
15c80 20 20 20 20 20 20 20 20 69 66 20 28 6e 20 21 3d if (n !=
15c90 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
15ca0 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 77 20 53 .Ok) throw new S
15cb0 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 6e QLiteException(n
15cc0 2c 20 47 65 74 4c 61 73 74 45 72 72 6f 72 28 29 , GetLastError()
15cd0 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 );.. }....
15ce0 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
15cf0 20 20 20 20 2f 2f 2f 20 4c 6f 61 64 73 20 61 20 /// Loads a
15d00 53 51 4c 69 74 65 20 65 78 74 65 6e 73 69 6f 6e SQLite extension
15d10 20 6c 69 62 72 61 72 79 20 66 72 6f 6d 20 74 68 library from th
15d20 65 20 6e 61 6d 65 64 20 66 69 6c 65 2e 0d 0a 20 e named file...
15d30 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 /// </summary
15d40 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 >.. /// <para
15d50 6d 20 6e 61 6d 65 3d 22 66 69 6c 65 4e 61 6d 65 m name="fileName
15d60 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 ">.. /// The
15d70 6e 61 6d 65 20 6f 66 20 74 68 65 20 64 79 6e 61 name of the dyna
15d80 6d 69 63 20 6c 69 6e 6b 20 6c 69 62 72 61 72 79 mic link library
15d90 20 66 69 6c 65 20 63 6f 6e 74 61 69 6e 69 6e 67 file containing
15da0 20 74 68 65 20 65 78 74 65 6e 73 69 6f 6e 2e 0d the extension..
15db0 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d . /// </param
15dc0 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 >.. /// <para
15dd0 6d 20 6e 61 6d 65 3d 22 70 72 6f 63 4e 61 6d 65 m name="procName
15de0 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 ">.. /// The
15df0 6e 61 6d 65 20 6f 66 20 74 68 65 20 65 78 70 6f name of the expo
15e00 72 74 65 64 20 66 75 6e 63 74 69 6f 6e 20 75 73 rted function us
15e10 65 64 20 74 6f 20 69 6e 69 74 69 61 6c 69 7a 65 ed to initialize
15e20 20 74 68 65 20 65 78 74 65 6e 73 69 6f 6e 2e 0d the extension..
15e30 0a 20 20 20 20 2f 2f 2f 20 49 66 20 6e 75 6c 6c . /// If null
15e40 2c 20 74 68 65 20 64 65 66 61 75 6c 74 20 22 73 , the default "s
15e50 71 6c 69 74 65 33 5f 65 78 74 65 6e 73 69 6f 6e qlite3_extension
15e60 5f 69 6e 69 74 22 20 77 69 6c 6c 20 62 65 20 75 _init" will be u
15e70 73 65 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f sed... /// </
15e80 70 61 72 61 6d 3e 0d 0a 20 20 20 20 69 6e 74 65 param>.. inte
15e90 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f rnal override vo
15ea0 69 64 20 4c 6f 61 64 45 78 74 65 6e 73 69 6f 6e id LoadExtension
15eb0 28 73 74 72 69 6e 67 20 66 69 6c 65 4e 61 6d 65 (string fileName
15ec0 2c 20 73 74 72 69 6e 67 20 70 72 6f 63 4e 61 6d , string procNam
15ed0 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 e).. {..
15ee0 20 20 20 69 66 20 28 66 69 6c 65 4e 61 6d 65 20 if (fileName
15ef0 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 == null)..
15f00 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 throw new
15f10 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 ArgumentNullExce
15f20 70 74 69 6f 6e 28 22 66 69 6c 65 4e 61 6d 65 22 ption("fileName"
15f30 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 49 6e );.... In
15f40 74 50 74 72 20 70 45 72 72 6f 72 20 3d 20 49 6e tPtr pError = In
15f50 74 50 74 72 2e 5a 65 72 6f 3b 0d 0a 0d 0a 20 20 tPtr.Zero;....
15f60 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 20 20 try..
15f70 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
15f80 20 20 62 79 74 65 5b 5d 20 75 74 66 38 46 69 6c byte[] utf8Fil
15f90 65 4e 61 6d 65 20 3d 20 55 54 46 38 45 6e 63 6f eName = UTF8Enco
15fa0 64 69 6e 67 2e 55 54 46 38 2e 47 65 74 42 79 74 ding.UTF8.GetByt
15fb0 65 73 28 66 69 6c 65 4e 61 6d 65 20 2b 20 27 5c es(fileName + '\
15fc0 30 27 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 0');..
15fd0 20 20 62 79 74 65 5b 5d 20 75 74 66 38 50 72 6f byte[] utf8Pro
15fe0 63 4e 61 6d 65 20 3d 20 6e 75 6c 6c 3b 0d 0a 0d cName = null;...
15ff0 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 . if
16000 28 70 72 6f 63 4e 61 6d 65 20 21 3d 20 6e 75 6c (procName != nul
16010 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 l)..
16020 20 20 20 20 75 74 66 38 50 72 6f 63 4e 61 6d 65 utf8ProcName
16030 20 3d 20 55 54 46 38 45 6e 63 6f 64 69 6e 67 2e = UTF8Encoding.
16040 55 54 46 38 2e 47 65 74 42 79 74 65 73 28 70 72 UTF8.GetBytes(pr
16050 6f 63 4e 61 6d 65 20 2b 20 27 5c 30 27 29 3b 0d ocName + '\0');.
16060 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 53 ... S
16070 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 6e QLiteErrorCode n
16080 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d = UnsafeNativeM
16090 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 6c ethods.sqlite3_l
160a0 6f 61 64 5f 65 78 74 65 6e 73 69 6f 6e 28 0d 0a oad_extension(..
160b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
160c0 5f 73 71 6c 2c 20 75 74 66 38 46 69 6c 65 4e 61 _sql, utf8FileNa
160d0 6d 65 2c 20 75 74 66 38 50 72 6f 63 4e 61 6d 65 me, utf8ProcName
160e0 2c 20 72 65 66 20 70 45 72 72 6f 72 29 3b 0d 0a , ref pError);..
160f0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 .. if
16100 20 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 72 (n != SQLiteErr
16110 6f 72 43 6f 64 65 2e 4f 6b 29 0d 0a 20 20 20 20 orCode.Ok)..
16120 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f thro
16130 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 w new SQLiteExce
16140 70 74 69 6f 6e 28 6e 2c 20 55 54 46 38 54 6f 53 ption(n, UTF8ToS
16150 74 72 69 6e 67 28 70 45 72 72 6f 72 2c 20 2d 31 tring(pError, -1
16160 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a ));.. }..
16170 20 20 20 20 20 20 20 20 66 69 6e 61 6c 6c 79 0d finally.
16180 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 . {..
16190 20 20 20 20 20 20 20 20 69 66 20 28 70 45 72 72 if (pErr
161a0 6f 72 20 21 3d 20 49 6e 74 50 74 72 2e 5a 65 72 or != IntPtr.Zer
161b0 6f 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 o)..
161c0 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 {..
161d0 20 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d UnsafeNativeM
161e0 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 66 ethods.sqlite3_f
161f0 72 65 65 28 70 45 72 72 6f 72 29 3b 0d 0a 20 20 ree(pError);..
16200 20 20 20 20 20 20 20 20 20 20 20 20 20 20 70 45 pE
16210 72 72 6f 72 20 3d 20 49 6e 74 50 74 72 2e 5a 65 rror = IntPtr.Ze
16220 72 6f 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ro;..
16230 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 }.. }..
16240 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 }.... ///
16250 45 6e 61 62 6c 65 73 20 6f 72 20 64 69 73 61 62 Enables or disab
16260 6c 65 64 20 65 78 74 65 6e 64 65 64 20 72 65 73 led extended res
16270 75 6c 74 20 63 6f 64 65 73 20 72 65 74 75 72 6e ult codes return
16280 65 64 20 62 79 20 53 51 4c 69 74 65 0d 0a 20 20 ed by SQLite..
16290 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 internal overr
162a0 69 64 65 20 76 6f 69 64 20 53 65 74 45 78 74 65 ide void SetExte
162b0 6e 64 65 64 52 65 73 75 6c 74 43 6f 64 65 73 28 ndedResultCodes(
162c0 62 6f 6f 6c 20 62 4f 6e 4f 66 66 29 0d 0a 20 20 bool bOnOff)..
162d0 20 20 7b 0d 0a 20 20 20 20 20 20 53 51 4c 69 74 {.. SQLit
162e0 65 45 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 eErrorCode n = U
162f0 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
16300 64 73 2e 73 71 6c 69 74 65 33 5f 65 78 74 65 6e ds.sqlite3_exten
16310 64 65 64 5f 72 65 73 75 6c 74 5f 63 6f 64 65 73 ded_result_codes
16320 28 0d 0a 20 20 20 20 20 20 20 20 20 20 5f 73 71 (.. _sq
16330 6c 2c 20 28 62 4f 6e 4f 66 66 20 3f 20 2d 31 20 l, (bOnOff ? -1
16340 3a 20 30 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 : 0));....
16350 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 if (n != SQLiteE
16360 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 68 72 rrorCode.Ok) thr
16370 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 ow new SQLiteExc
16380 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 eption(n, GetLas
16390 74 45 72 72 6f 72 28 29 29 3b 0d 0a 20 20 20 20 tError());..
163a0 7d 0d 0a 20 20 20 20 2f 2f 2f 20 47 65 74 73 20 }.. /// Gets
163b0 74 68 65 20 6c 61 73 74 20 53 51 4c 69 74 65 20 the last SQLite
163c0 65 72 72 6f 72 20 63 6f 64 65 0d 0a 20 20 20 20 error code..
163d0 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 internal overrid
163e0 65 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 e SQLiteErrorCod
163f0 65 20 52 65 73 75 6c 74 43 6f 64 65 28 29 0d 0a e ResultCode()..
16400 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 65 74 {.. ret
16410 75 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 urn UnsafeNative
16420 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
16430 65 72 72 63 6f 64 65 28 5f 73 71 6c 29 3b 0d 0a errcode(_sql);..
16440 20 20 20 20 7d 0d 0a 20 20 20 20 2f 2f 2f 20 47 }.. /// G
16450 65 74 73 20 74 68 65 20 6c 61 73 74 20 53 51 4c ets the last SQL
16460 69 74 65 20 65 78 74 65 6e 64 65 64 20 65 72 72 ite extended err
16470 6f 72 20 63 6f 64 65 0d 0a 20 20 20 20 69 6e 74 or code.. int
16480 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 53 ernal override S
16490 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 45 QLiteErrorCode E
164a0 78 74 65 6e 64 65 64 52 65 73 75 6c 74 43 6f 64 xtendedResultCod
164b0 65 28 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 e().. {..
164c0 20 20 72 65 74 75 72 6e 20 55 6e 73 61 66 65 4e return UnsafeN
164d0 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c ativeMethods.sql
164e0 69 74 65 33 5f 65 78 74 65 6e 64 65 64 5f 65 72 ite3_extended_er
164f0 72 63 6f 64 65 28 5f 73 71 6c 29 3b 0d 0a 20 20 rcode(_sql);..
16500 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 41 }.... /// A
16510 64 64 20 61 20 6c 6f 67 20 6d 65 73 73 61 67 65 dd a log message
16520 20 76 69 61 20 74 68 65 20 53 51 4c 69 74 65 20 via the SQLite
16530 73 71 6c 69 74 65 33 5f 6c 6f 67 20 69 6e 74 65 sqlite3_log inte
16540 72 66 61 63 65 2e 0d 0a 20 20 20 20 69 6e 74 65 rface... inte
16550 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f rnal override vo
16560 69 64 20 4c 6f 67 4d 65 73 73 61 67 65 28 53 51 id LogMessage(SQ
16570 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 69 45 LiteErrorCode iE
16580 72 72 43 6f 64 65 2c 20 73 74 72 69 6e 67 20 7a rrCode, string z
16590 4d 65 73 73 61 67 65 29 0d 0a 20 20 20 20 7b 0d Message).. {.
165a0 0a 20 20 20 20 20 20 53 74 61 74 69 63 4c 6f 67 . StaticLog
165b0 4d 65 73 73 61 67 65 28 69 45 72 72 43 6f 64 65 Message(iErrCode
165c0 2c 20 7a 4d 65 73 73 61 67 65 29 3b 0d 0a 20 20 , zMessage);..
165d0 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 41 }.... /// A
165e0 64 64 20 61 20 6c 6f 67 20 6d 65 73 73 61 67 65 dd a log message
165f0 20 76 69 61 20 74 68 65 20 53 51 4c 69 74 65 20 via the SQLite
16600 73 71 6c 69 74 65 33 5f 6c 6f 67 20 69 6e 74 65 sqlite3_log inte
16610 72 66 61 63 65 2e 0d 0a 20 20 20 20 69 6e 74 65 rface... inte
16620 72 6e 61 6c 20 73 74 61 74 69 63 20 76 6f 69 64 rnal static void
16630 20 53 74 61 74 69 63 4c 6f 67 4d 65 73 73 61 67 StaticLogMessag
16640 65 28 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 e(SQLiteErrorCod
16650 65 20 69 45 72 72 43 6f 64 65 2c 20 73 74 72 69 e iErrCode, stri
16660 6e 67 20 7a 4d 65 73 73 61 67 65 29 0d 0a 20 20 ng zMessage)..
16670 20 20 7b 0d 0a 20 20 20 20 20 20 55 6e 73 61 66 {.. Unsaf
16680 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
16690 71 6c 69 74 65 33 5f 6c 6f 67 28 69 45 72 72 43 qlite3_log(iErrC
166a0 6f 64 65 2c 20 54 6f 55 54 46 38 28 7a 4d 65 73 ode, ToUTF8(zMes
166b0 73 61 67 65 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a sage));.. }..
166c0 0d 0a 23 69 66 20 49 4e 54 45 52 4f 50 5f 43 4f ..#if INTEROP_CO
166d0 44 45 43 20 7c 7c 20 49 4e 54 45 52 4f 50 5f 49 DEC || INTEROP_I
166e0 4e 43 4c 55 44 45 5f 53 45 45 0d 0a 20 20 20 20 NCLUDE_SEE..
166f0 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 internal overrid
16700 65 20 76 6f 69 64 20 53 65 74 50 61 73 73 77 6f e void SetPasswo
16710 72 64 28 62 79 74 65 5b 5d 20 70 61 73 73 77 6f rd(byte[] passwo
16720 72 64 42 79 74 65 73 29 0d 0a 20 20 20 20 7b 0d rdBytes).. {.
16730 0a 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 . SQLiteErr
16740 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 66 orCode n = Unsaf
16750 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
16760 71 6c 69 74 65 33 5f 6b 65 79 28 5f 73 71 6c 2c qlite3_key(_sql,
16770 20 70 61 73 73 77 6f 72 64 42 79 74 65 73 2c 20 passwordBytes,
16780 70 61 73 73 77 6f 72 64 42 79 74 65 73 2e 4c 65 passwordBytes.Le
16790 6e 67 74 68 29 3b 0d 0a 20 20 20 20 20 20 69 66 ngth);.. if
167a0 20 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 72 (n != SQLiteErr
167b0 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 orCode.Ok) throw
167c0 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 new SQLiteExcep
167d0 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 tion(n, GetLastE
167e0 72 72 6f 72 28 29 29 3b 0d 0a 0d 0a 20 20 20 20 rror());....
167f0 20 20 69 66 20 28 5f 75 73 65 50 6f 6f 6c 29 0d if (_usePool).
16800 0a 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 . {..
16810 20 20 5f 75 73 65 50 6f 6f 6c 20 3d 20 66 61 6c _usePool = fal
16820 73 65 3b 0d 0a 0d 0a 23 69 66 20 21 4e 45 54 5f se;....#if !NET_
16830 43 4f 4d 50 41 43 54 5f 32 30 20 26 26 20 54 52 COMPACT_20 && TR
16840 41 43 45 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a ACE_CONNECTION..
16850 20 20 20 20 20 20 20 20 54 72 61 63 65 2e 57 72 Trace.Wr
16860 69 74 65 4c 69 6e 65 28 55 6e 73 61 66 65 4e 61 iteLine(UnsafeNa
16870 74 69 76 65 4d 65 74 68 6f 64 73 2e 53 74 72 69 tiveMethods.Stri
16880 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 ngFormat(..
16890 20 20 20 20 20 43 75 6c 74 75 72 65 49 6e 66 6f CultureInfo
168a0 2e 43 75 72 72 65 6e 74 43 75 6c 74 75 72 65 2c .CurrentCulture,
168b0 0d 0a 20 20 20 20 20 20 20 20 20 20 22 53 65 74 .. "Set
168c0 50 61 73 73 77 6f 72 64 20 28 50 6f 6f 6c 29 20 Password (Pool)
168d0 44 69 73 61 62 6c 65 64 3a 20 7b 30 7d 22 2c 0d Disabled: {0}",.
168e0 0a 20 20 20 20 20 20 20 20 20 20 48 61 6e 64 6c . Handl
168f0 65 54 6f 53 74 72 69 6e 67 28 29 29 29 3b 0d 0a eToString()));..
16900 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 7d 0d #endif.. }.
16910 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
16920 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
16930 76 6f 69 64 20 43 68 61 6e 67 65 50 61 73 73 77 void ChangePassw
16940 6f 72 64 28 62 79 74 65 5b 5d 20 6e 65 77 50 61 ord(byte[] newPa
16950 73 73 77 6f 72 64 42 79 74 65 73 29 0d 0a 20 20 sswordBytes)..
16960 20 20 7b 0d 0a 20 20 20 20 20 20 53 51 4c 69 74 {.. SQLit
16970 65 45 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 eErrorCode n = U
16980 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
16990 64 73 2e 73 71 6c 69 74 65 33 5f 72 65 6b 65 79 ds.sqlite3_rekey
169a0 28 5f 73 71 6c 2c 20 6e 65 77 50 61 73 73 77 6f (_sql, newPasswo
169b0 72 64 42 79 74 65 73 2c 20 28 6e 65 77 50 61 73 rdBytes, (newPas
169c0 73 77 6f 72 64 42 79 74 65 73 20 3d 3d 20 6e 75 swordBytes == nu
169d0 6c 6c 29 20 3f 20 30 20 3a 20 6e 65 77 50 61 73 ll) ? 0 : newPas
169e0 73 77 6f 72 64 42 79 74 65 73 2e 4c 65 6e 67 74 swordBytes.Lengt
169f0 68 29 3b 0d 0a 20 20 20 20 20 20 69 66 20 28 6e h);.. if (n
16a00 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 != SQLiteErrorC
16a10 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 ode.Ok) throw ne
16a20 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f w SQLiteExceptio
16a30 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f n(n, GetLastErro
16a40 72 28 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 69 r());.... i
16a50 66 20 28 5f 75 73 65 50 6f 6f 6c 29 0d 0a 20 20 f (_usePool)..
16a60 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 5f {.. _
16a70 75 73 65 50 6f 6f 6c 20 3d 20 66 61 6c 73 65 3b usePool = false;
16a80 0d 0a 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d ....#if !NET_COM
16a90 50 41 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 PACT_20 && TRACE
16aa0 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 _CONNECTION..
16ab0 20 20 20 20 20 54 72 61 63 65 2e 57 72 69 74 65 Trace.Write
16ac0 4c 69 6e 65 28 55 6e 73 61 66 65 4e 61 74 69 76 Line(UnsafeNativ
16ad0 65 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 eMethods.StringF
16ae0 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 ormat(..
16af0 20 20 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 CultureInfo.Cu
16b00 72 72 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 rrentCulture,..
16b10 20 20 20 20 20 20 20 20 20 22 43 68 61 6e 67 65 "Change
16b20 50 61 73 73 77 6f 72 64 20 28 50 6f 6f 6c 29 20 Password (Pool)
16b30 44 69 73 61 62 6c 65 64 3a 20 7b 30 7d 22 2c 0d Disabled: {0}",.
16b40 0a 20 20 20 20 20 20 20 20 20 20 48 61 6e 64 6c . Handl
16b50 65 54 6f 53 74 72 69 6e 67 28 29 29 29 3b 0d 0a eToString()));..
16b60 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 7d 0d #endif.. }.
16b70 0a 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d 0a . }..#endif..
16b80 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
16b90 76 65 72 72 69 64 65 20 76 6f 69 64 20 53 65 74 verride void Set
16ba0 50 72 6f 67 72 65 73 73 48 6f 6f 6b 28 69 6e 74 ProgressHook(int
16bb0 20 6e 4f 70 73 2c 20 53 51 4c 69 74 65 50 72 6f nOps, SQLitePro
16bc0 67 72 65 73 73 43 61 6c 6c 62 61 63 6b 20 66 75 gressCallback fu
16bd0 6e 63 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 nc).. {..
16be0 20 20 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 UnsafeNative
16bf0 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
16c00 70 72 6f 67 72 65 73 73 5f 68 61 6e 64 6c 65 72 progress_handler
16c10 28 5f 73 71 6c 2c 20 6e 4f 70 73 2c 20 66 75 6e (_sql, nOps, fun
16c20 63 2c 20 49 6e 74 50 74 72 2e 5a 65 72 6f 29 3b c, IntPtr.Zero);
16c30 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
16c40 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
16c50 20 76 6f 69 64 20 53 65 74 41 75 74 68 6f 72 69 void SetAuthori
16c60 7a 65 72 48 6f 6f 6b 28 53 51 4c 69 74 65 41 75 zerHook(SQLiteAu
16c70 74 68 6f 72 69 7a 65 72 43 61 6c 6c 62 61 63 6b thorizerCallback
16c80 20 66 75 6e 63 29 0d 0a 20 20 20 20 7b 0d 0a 20 func).. {..
16c90 20 20 20 20 20 55 6e 73 61 66 65 4e 61 74 69 76 UnsafeNativ
16ca0 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
16cb0 5f 73 65 74 5f 61 75 74 68 6f 72 69 7a 65 72 28 _set_authorizer(
16cc0 5f 73 71 6c 2c 20 66 75 6e 63 2c 20 49 6e 74 50 _sql, func, IntP
16cd0 74 72 2e 5a 65 72 6f 29 3b 0d 0a 20 20 20 20 7d tr.Zero);.. }
16ce0 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
16cf0 20 6f 76 65 72 72 69 64 65 20 76 6f 69 64 20 53 override void S
16d00 65 74 55 70 64 61 74 65 48 6f 6f 6b 28 53 51 4c etUpdateHook(SQL
16d10 69 74 65 55 70 64 61 74 65 43 61 6c 6c 62 61 63 iteUpdateCallbac
16d20 6b 20 66 75 6e 63 29 0d 0a 20 20 20 20 7b 0d 0a k func).. {..
16d30 20 20 20 20 20 20 55 6e 73 61 66 65 4e 61 74 69 UnsafeNati
16d40 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
16d50 33 5f 75 70 64 61 74 65 5f 68 6f 6f 6b 28 5f 73 3_update_hook(_s
16d60 71 6c 2c 20 66 75 6e 63 2c 20 49 6e 74 50 74 72 ql, func, IntPtr
16d70 2e 5a 65 72 6f 29 3b 0d 0a 20 20 20 20 7d 0d 0a .Zero);.. }..
16d80 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
16d90 76 65 72 72 69 64 65 20 76 6f 69 64 20 53 65 74 verride void Set
16da0 43 6f 6d 6d 69 74 48 6f 6f 6b 28 53 51 4c 69 74 CommitHook(SQLit
16db0 65 43 6f 6d 6d 69 74 43 61 6c 6c 62 61 63 6b 20 eCommitCallback
16dc0 66 75 6e 63 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 func).. {..
16dd0 20 20 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 UnsafeNative
16de0 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
16df0 63 6f 6d 6d 69 74 5f 68 6f 6f 6b 28 5f 73 71 6c commit_hook(_sql
16e00 2c 20 66 75 6e 63 2c 20 49 6e 74 50 74 72 2e 5a , func, IntPtr.Z
16e10 65 72 6f 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a ero);.. }....
16e20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
16e30 72 72 69 64 65 20 76 6f 69 64 20 53 65 74 54 72 rride void SetTr
16e40 61 63 65 43 61 6c 6c 62 61 63 6b 28 53 51 4c 69 aceCallback(SQLi
16e50 74 65 54 72 61 63 65 43 61 6c 6c 62 61 63 6b 20 teTraceCallback
16e60 66 75 6e 63 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 func).. {..
16e70 20 20 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 UnsafeNative
16e80 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
16e90 74 72 61 63 65 28 5f 73 71 6c 2c 20 66 75 6e 63 trace(_sql, func
16ea0 2c 20 49 6e 74 50 74 72 2e 5a 65 72 6f 29 3b 0d , IntPtr.Zero);.
16eb0 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
16ec0 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
16ed0 76 6f 69 64 20 53 65 74 52 6f 6c 6c 62 61 63 6b void SetRollback
16ee0 48 6f 6f 6b 28 53 51 4c 69 74 65 52 6f 6c 6c 62 Hook(SQLiteRollb
16ef0 61 63 6b 43 61 6c 6c 62 61 63 6b 20 66 75 6e 63 ackCallback func
16f00 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
16f10 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
16f20 6f 64 73 2e 73 71 6c 69 74 65 33 5f 72 6f 6c 6c ods.sqlite3_roll
16f30 62 61 63 6b 5f 68 6f 6f 6b 28 5f 73 71 6c 2c 20 back_hook(_sql,
16f40 66 75 6e 63 2c 20 49 6e 74 50 74 72 2e 5a 65 72 func, IntPtr.Zer
16f50 6f 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 o);.. }....
16f60 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d /// <summary>.
16f70 0a 20 20 20 20 2f 2f 2f 20 41 6c 6c 6f 77 73 20 . /// Allows
16f80 74 68 65 20 73 65 74 74 69 6e 67 20 6f 66 20 61 the setting of a
16f90 20 6c 6f 67 67 69 6e 67 20 63 61 6c 6c 62 61 63 logging callbac
16fa0 6b 20 69 6e 76 6f 6b 65 64 20 62 79 20 53 51 4c k invoked by SQL
16fb0 69 74 65 20 77 68 65 6e 20 61 0d 0a 20 20 20 20 ite when a..
16fc0 2f 2f 2f 20 6c 6f 67 20 65 76 65 6e 74 20 6f 63 /// log event oc
16fd0 63 75 72 73 2e 20 20 4f 6e 6c 79 20 6f 6e 65 20 curs. Only one
16fe0 63 61 6c 6c 62 61 63 6b 20 6d 61 79 20 62 65 20 callback may be
16ff0 73 65 74 2e 20 20 49 66 20 4e 55 4c 4c 20 69 73 set. If NULL is
17000 20 70 61 73 73 65 64 2c 0d 0a 20 20 20 20 2f 2f passed,.. //
17010 2f 20 74 68 65 20 6c 6f 67 67 69 6e 67 20 63 61 / the logging ca
17020 6c 6c 62 61 63 6b 20 69 73 20 75 6e 72 65 67 69 llback is unregi
17030 73 74 65 72 65 64 2e 0d 0a 20 20 20 20 2f 2f 2f stered... ///
17040 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 </summary>..
17050 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 /// <param name
17060 3d 22 66 75 6e 63 22 3e 54 68 65 20 63 61 6c 6c ="func">The call
17070 62 61 63 6b 20 66 75 6e 63 74 69 6f 6e 20 74 6f back function to
17080 20 69 6e 76 6f 6b 65 2e 3c 2f 70 61 72 61 6d 3e invoke.</param>
17090 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 .. /// <retur
170a0 6e 73 3e 52 65 74 75 72 6e 73 20 61 20 72 65 73 ns>Returns a res
170b0 75 6c 74 20 63 6f 64 65 3c 2f 72 65 74 75 72 6e ult code</return
170c0 73 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c s>.. internal
170d0 20 6f 76 65 72 72 69 64 65 20 53 51 4c 69 74 65 override SQLite
170e0 45 72 72 6f 72 43 6f 64 65 20 53 65 74 4c 6f 67 ErrorCode SetLog
170f0 43 61 6c 6c 62 61 63 6b 28 53 51 4c 69 74 65 4c Callback(SQLiteL
17100 6f 67 43 61 6c 6c 62 61 63 6b 20 66 75 6e 63 29 ogCallback func)
17110 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
17120 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
17130 20 72 63 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 rc = UnsafeNati
17140 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
17150 33 5f 63 6f 6e 66 69 67 5f 6c 6f 67 28 0d 0a 20 3_config_log(..
17160 20 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 SQLit
17170 65 43 6f 6e 66 69 67 4f 70 73 45 6e 75 6d 2e 53 eConfigOpsEnum.S
17180 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 4c 4f 47 QLITE_CONFIG_LOG
17190 2c 20 66 75 6e 63 2c 20 49 6e 74 50 74 72 2e 5a , func, IntPtr.Z
171a0 65 72 6f 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 ero);....
171b0 20 72 65 74 75 72 6e 20 72 63 3b 0d 0a 20 20 20 return rc;..
171c0 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f }.... //////
171d0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
171e0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
171f0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
17200 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
17210 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
17220 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 /////////....
17230 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
17240 20 20 20 20 2f 2f 2f 20 43 72 65 61 74 65 73 20 /// Creates
17250 61 20 6e 65 77 20 53 51 4c 69 74 65 20 62 61 63 a new SQLite bac
17260 6b 75 70 20 6f 62 6a 65 63 74 20 62 61 73 65 64 kup object based
17270 20 6f 6e 20 74 68 65 20 70 72 6f 76 69 64 65 64 on the provided
17280 20 64 65 73 74 69 6e 61 74 69 6f 6e 0d 0a 20 20 destination..
17290 20 20 2f 2f 2f 20 64 61 74 61 62 61 73 65 20 63 /// database c
172a0 6f 6e 6e 65 63 74 69 6f 6e 2e 20 20 54 68 65 20 onnection. The
172b0 73 6f 75 72 63 65 20 64 61 74 61 62 61 73 65 20 source database
172c0 63 6f 6e 6e 65 63 74 69 6f 6e 20 69 73 20 74 68 connection is th
172d0 65 20 6f 6e 65 0d 0a 20 20 20 20 2f 2f 2f 20 61 e one.. /// a
172e0 73 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 74 ssociated with t
172f0 68 69 73 20 6f 62 6a 65 63 74 2e 20 20 54 68 65 his object. The
17300 20 73 6f 75 72 63 65 20 61 6e 64 20 64 65 73 74 source and dest
17310 69 6e 61 74 69 6f 6e 20 64 61 74 61 62 61 73 65 ination database
17320 0d 0a 20 20 20 20 2f 2f 2f 20 63 6f 6e 6e 65 63 .. /// connec
17330 74 69 6f 6e 73 20 63 61 6e 6e 6f 74 20 62 65 20 tions cannot be
17340 74 68 65 20 73 61 6d 65 2e 0d 0a 20 20 20 20 2f the same... /
17350 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 // </summary>..
17360 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 /// <param na
17370 6d 65 3d 22 64 65 73 74 43 6e 6e 22 3e 54 68 65 me="destCnn">The
17380 20 64 65 73 74 69 6e 61 74 69 6f 6e 20 64 61 74 destination dat
17390 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e abase connection
173a0 2e 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f .</param>.. /
173b0 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 // <param name="
173c0 64 65 73 74 4e 61 6d 65 22 3e 54 68 65 20 64 65 destName">The de
173d0 73 74 69 6e 61 74 69 6f 6e 20 64 61 74 61 62 61 stination databa
173e0 73 65 20 6e 61 6d 65 2e 3c 2f 70 61 72 61 6d 3e se name.</param>
173f0 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d .. /// <param
17400 20 6e 61 6d 65 3d 22 73 6f 75 72 63 65 4e 61 6d name="sourceNam
17410 65 22 3e 54 68 65 20 73 6f 75 72 63 65 20 64 61 e">The source da
17420 74 61 62 61 73 65 20 6e 61 6d 65 2e 3c 2f 70 61 tabase name.</pa
17430 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 ram>.. /// <r
17440 65 74 75 72 6e 73 3e 54 68 65 20 6e 65 77 6c 79 eturns>The newly
17450 20 63 72 65 61 74 65 64 20 62 61 63 6b 75 70 20 created backup
17460 6f 62 6a 65 63 74 2e 3c 2f 72 65 74 75 72 6e 73 object.</returns
17470 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 >.. internal
17480 6f 76 65 72 72 69 64 65 20 53 51 4c 69 74 65 42 override SQLiteB
17490 61 63 6b 75 70 20 49 6e 69 74 69 61 6c 69 7a 65 ackup Initialize
174a0 42 61 63 6b 75 70 28 0d 0a 20 20 20 20 20 20 20 Backup(..
174b0 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f SQLiteConnectio
174c0 6e 20 64 65 73 74 43 6e 6e 2c 0d 0a 20 20 20 20 n destCnn,..
174d0 20 20 20 20 73 74 72 69 6e 67 20 64 65 73 74 4e string destN
174e0 61 6d 65 2c 0d 0a 20 20 20 20 20 20 20 20 73 74 ame,.. st
174f0 72 69 6e 67 20 73 6f 75 72 63 65 4e 61 6d 65 0d ring sourceName.
17500 0a 20 20 20 20 20 20 20 20 29 0d 0a 20 20 20 20 . )..
17510 7b 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 64 {.. if (d
17520 65 73 74 43 6e 6e 20 3d 3d 20 6e 75 6c 6c 29 0d estCnn == null).
17530 0a 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 . thr
17540 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e ow new ArgumentN
17550 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 22 64 65 ullException("de
17560 73 74 43 6e 6e 22 29 3b 0d 0a 0d 0a 20 20 20 20 stCnn");....
17570 20 20 20 20 69 66 20 28 64 65 73 74 4e 61 6d 65 if (destName
17580 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 == null)..
17590 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 throw new
175a0 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 ArgumentNullExc
175b0 65 70 74 69 6f 6e 28 22 64 65 73 74 4e 61 6d 65 eption("destName
175c0 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 ");.... i
175d0 66 20 28 73 6f 75 72 63 65 4e 61 6d 65 20 3d 3d f (sourceName ==
175e0 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 null)..
175f0 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 throw new Ar
17600 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 gumentNullExcept
17610 69 6f 6e 28 22 73 6f 75 72 63 65 4e 61 6d 65 22 ion("sourceName"
17620 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 );.... SQ
17630 4c 69 74 65 33 20 64 65 73 74 53 71 6c 69 74 65 Lite3 destSqlite
17640 33 20 3d 20 64 65 73 74 43 6e 6e 2e 5f 73 71 6c 3 = destCnn._sql
17650 20 61 73 20 53 51 4c 69 74 65 33 3b 0d 0a 0d 0a as SQLite3;....
17660 20 20 20 20 20 20 20 20 69 66 20 28 64 65 73 74 if (dest
17670 53 71 6c 69 74 65 33 20 3d 3d 20 6e 75 6c 6c 29 Sqlite3 == null)
17680 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 74 68 .. th
17690 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 row new Argument
176a0 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 20 20 20 Exception(..
176b0 20 20 20 20 20 20 20 20 20 20 20 20 22 44 65 73 "Des
176c0 74 69 6e 61 74 69 6f 6e 20 63 6f 6e 6e 65 63 74 tination connect
176d0 69 6f 6e 20 68 61 73 20 6e 6f 20 77 72 61 70 70 ion has no wrapp
176e0 65 72 2e 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 er.",..
176f0 20 20 20 20 20 20 20 22 64 65 73 74 43 6e 6e 22 "destCnn"
17700 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 );.... SQ
17710 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 48 61 LiteConnectionHa
17720 6e 64 6c 65 20 64 65 73 74 48 61 6e 64 6c 65 20 ndle destHandle
17730 3d 20 64 65 73 74 53 71 6c 69 74 65 33 2e 5f 73 = destSqlite3._s
17740 71 6c 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 ql;.... i
17750 66 20 28 64 65 73 74 48 61 6e 64 6c 65 20 3d 3d f (destHandle ==
17760 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 null)..
17770 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 throw new Ar
17780 67 75 6d 65 6e 74 45 78 63 65 70 74 69 6f 6e 28 gumentException(
17790 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
177a0 20 20 22 44 65 73 74 69 6e 61 74 69 6f 6e 20 63 "Destination c
177b0 6f 6e 6e 65 63 74 69 6f 6e 20 68 61 73 20 61 6e onnection has an
177c0 20 69 6e 76 61 6c 69 64 20 68 61 6e 64 6c 65 2e invalid handle.
177d0 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ",..
177e0 20 20 20 20 22 64 65 73 74 43 6e 6e 22 29 3b 0d "destCnn");.
177f0 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 ... SQLit
17800 65 43 6f 6e 6e 65 63 74 69 6f 6e 48 61 6e 64 6c eConnectionHandl
17810 65 20 73 6f 75 72 63 65 48 61 6e 64 6c 65 20 3d e sourceHandle =
17820 20 5f 73 71 6c 3b 0d 0a 0d 0a 20 20 20 20 20 20 _sql;....
17830 20 20 69 66 20 28 73 6f 75 72 63 65 48 61 6e 64 if (sourceHand
17840 6c 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 le == null)..
17850 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e throw n
17860 65 77 20 49 6e 76 61 6c 69 64 4f 70 65 72 61 74 ew InvalidOperat
17870 69 6f 6e 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 ionException(..
17880 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 "
17890 53 6f 75 72 63 65 20 63 6f 6e 6e 65 63 74 69 6f Source connectio
178a0 6e 20 68 61 73 20 61 6e 20 69 6e 76 61 6c 69 64 n has an invalid
178b0 20 68 61 6e 64 6c 65 2e 22 29 3b 0d 0a 0d 0a 20 handle.");....
178c0 20 20 20 20 20 20 20 62 79 74 65 5b 5d 20 7a 44 byte[] zD
178d0 65 73 74 4e 61 6d 65 20 3d 20 54 6f 55 54 46 38 estName = ToUTF8
178e0 28 64 65 73 74 4e 61 6d 65 29 3b 0d 0a 20 20 20 (destName);..
178f0 20 20 20 20 20 62 79 74 65 5b 5d 20 7a 53 6f 75 byte[] zSou
17900 72 63 65 4e 61 6d 65 20 3d 20 54 6f 55 54 46 38 rceName = ToUTF8
17910 28 73 6f 75 72 63 65 4e 61 6d 65 29 3b 0d 0a 0d (sourceName);...
17920 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 42 . SQLiteB
17930 61 63 6b 75 70 48 61 6e 64 6c 65 20 62 61 63 6b ackupHandle back
17940 75 70 48 61 6e 64 6c 65 20 3d 20 6e 75 6c 6c 3b upHandle = null;
17950 0d 0a 0d 0a 20 20 20 20 20 20 20 20 74 72 79 0d .... try.
17960 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 . {..
17970 20 20 20 20 20 20 20 20 2f 2f 20 64 6f 20 6e 6f // do no
17980 74 68 69 6e 67 2e 0d 0a 20 20 20 20 20 20 20 20 thing...
17990 7d 0d 0a 20 20 20 20 20 20 20 20 66 69 6e 61 6c }.. final
179a0 6c 79 20 2f 2a 20 4e 4f 54 45 3a 20 54 68 72 65 ly /* NOTE: Thre
179b0 61 64 2e 41 62 6f 72 74 28 29 20 70 72 6f 74 65 ad.Abort() prote
179c0 63 74 69 6f 6e 2e 20 2a 2f 0d 0a 20 20 20 20 20 ction. */..
179d0 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
179e0 20 20 49 6e 74 50 74 72 20 62 61 63 6b 75 70 20 IntPtr backup
179f0 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 = UnsafeNativeMe
17a00 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 62 61 thods.sqlite3_ba
17a10 63 6b 75 70 5f 69 6e 69 74 28 0d 0a 20 20 20 20 ckup_init(..
17a20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 73 74 dest
17a30 48 61 6e 64 6c 65 2c 20 7a 44 65 73 74 4e 61 6d Handle, zDestNam
17a40 65 2c 20 73 6f 75 72 63 65 48 61 6e 64 6c 65 2c e, sourceHandle,
17a50 20 7a 53 6f 75 72 63 65 4e 61 6d 65 29 3b 0d 0a zSourceName);..
17a60 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 .. if
17a70 20 28 62 61 63 6b 75 70 20 3d 3d 20 49 6e 74 50 (backup == IntP
17a80 74 72 2e 5a 65 72 6f 29 0d 0a 20 20 20 20 20 20 tr.Zero)..
17a90 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
17aa0 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 SQLiteE
17ab0 72 72 6f 72 43 6f 64 65 20 72 65 73 75 6c 74 43 rrorCode resultC
17ac0 6f 64 65 20 3d 20 52 65 73 75 6c 74 43 6f 64 65 ode = ResultCode
17ad0 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 ();....
17ae0 20 20 20 20 20 20 20 69 66 20 28 72 65 73 75 6c if (resul
17af0 74 43 6f 64 65 20 21 3d 20 53 51 4c 69 74 65 45 tCode != SQLiteE
17b00 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 0d 0a 20 20 rrorCode.Ok)..
17b10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17b20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 throw new SQLi
17b30 74 65 45 78 63 65 70 74 69 6f 6e 28 72 65 73 75 teException(resu
17b40 6c 74 43 6f 64 65 2c 20 47 65 74 4c 61 73 74 45 ltCode, GetLastE
17b50 72 72 6f 72 28 29 29 3b 0d 0a 20 20 20 20 20 20 rror());..
17b60 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a else..
17b70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17b80 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 51 throw new SQ
17b90 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 22 66 LiteException("f
17ba0 61 69 6c 65 64 20 74 6f 20 69 6e 69 74 69 61 6c ailed to initial
17bb0 69 7a 65 20 62 61 63 6b 75 70 22 29 3b 0d 0a 20 ize backup");..
17bc0 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a }....
17bd0 20 20 20 20 20 20 20 20 20 20 20 20 62 61 63 6b back
17be0 75 70 48 61 6e 64 6c 65 20 3d 20 6e 65 77 20 53 upHandle = new S
17bf0 51 4c 69 74 65 42 61 63 6b 75 70 48 61 6e 64 6c QLiteBackupHandl
17c00 65 28 64 65 73 74 48 61 6e 64 6c 65 2c 20 62 61 e(destHandle, ba
17c10 63 6b 75 70 29 3b 0d 0a 20 20 20 20 20 20 20 20 ckup);..
17c20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 4c }.... SQL
17c30 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 2e 4f 6e iteConnection.On
17c40 43 68 61 6e 67 65 64 28 6e 75 6c 6c 2c 20 6e 65 Changed(null, ne
17c50 77 20 43 6f 6e 6e 65 63 74 69 6f 6e 45 76 65 6e w ConnectionEven
17c60 74 41 72 67 73 28 0d 0a 20 20 20 20 20 20 20 20 tArgs(..
17c70 20 20 20 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 SQLiteConnec
17c80 74 69 6f 6e 45 76 65 6e 74 54 79 70 65 2e 4e 65 tionEventType.Ne
17c90 77 43 72 69 74 69 63 61 6c 48 61 6e 64 6c 65 2c wCriticalHandle,
17ca0 20 6e 75 6c 6c 2c 0d 0a 20 20 20 20 20 20 20 20 null,..
17cb0 20 20 20 20 6e 75 6c 6c 2c 20 6e 75 6c 6c 2c 20 null, null,
17cc0 6e 75 6c 6c 2c 20 62 61 63 6b 75 70 48 61 6e 64 null, backupHand
17cd0 6c 65 2c 20 6e 75 6c 6c 2c 20 6e 65 77 20 6f 62 le, null, new ob
17ce0 6a 65 63 74 5b 5d 20 7b 0d 0a 20 20 20 20 20 20 ject[] {..
17cf0 20 20 20 20 20 20 74 79 70 65 6f 66 28 53 51 4c typeof(SQL
17d00 69 74 65 33 29 2c 20 64 65 73 74 43 6e 6e 2c 20 ite3), destCnn,
17d10 64 65 73 74 4e 61 6d 65 2c 20 73 6f 75 72 63 65 destName, source
17d20 4e 61 6d 65 20 7d 29 29 3b 0d 0a 0d 0a 20 20 20 Name }));....
17d30 20 20 20 20 20 72 65 74 75 72 6e 20 6e 65 77 20 return new
17d40 53 51 4c 69 74 65 42 61 63 6b 75 70 28 0d 0a 20 SQLiteBackup(..
17d50 20 20 20 20 20 20 20 20 20 20 20 74 68 69 73 2c this,
17d60 20 62 61 63 6b 75 70 48 61 6e 64 6c 65 2c 20 64 backupHandle, d
17d70 65 73 74 48 61 6e 64 6c 65 2c 20 7a 44 65 73 74 estHandle, zDest
17d80 4e 61 6d 65 2c 20 73 6f 75 72 63 65 48 61 6e 64 Name, sourceHand
17d90 6c 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 le,..
17da0 20 7a 53 6f 75 72 63 65 4e 61 6d 65 29 3b 0d 0a zSourceName);..
17db0 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f }.... ///
17dc0 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 <summary>..
17dd0 2f 2f 2f 20 43 6f 70 69 65 73 20 75 70 20 74 6f /// Copies up to
17de0 20 4e 20 70 61 67 65 73 20 66 72 6f 6d 20 74 68 N pages from th
17df0 65 20 73 6f 75 72 63 65 20 64 61 74 61 62 61 73 e source databas
17e00 65 20 74 6f 20 74 68 65 20 64 65 73 74 69 6e 61 e to the destina
17e10 74 69 6f 6e 0d 0a 20 20 20 20 2f 2f 2f 20 64 61 tion.. /// da
17e20 74 61 62 61 73 65 20 61 73 73 6f 63 69 61 74 65 tabase associate
17e30 64 20 77 69 74 68 20 74 68 65 20 73 70 65 63 69 d with the speci
17e40 66 69 65 64 20 62 61 63 6b 75 70 20 6f 62 6a 65 fied backup obje
17e50 63 74 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 ct... /// </s
17e60 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
17e70 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 62 61 <param name="ba
17e80 63 6b 75 70 22 3e 54 68 65 20 62 61 63 6b 75 70 ckup">The backup
17e90 20 6f 62 6a 65 63 74 20 74 6f 20 75 73 65 2e 3c object to use.<
17ea0 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f /param>.. ///
17eb0 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 6e 50 <param name="nP
17ec0 61 67 65 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 age">.. /// T
17ed0 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 70 61 67 he number of pag
17ee0 65 73 20 74 6f 20 63 6f 70 79 2c 20 6e 65 67 61 es to copy, nega
17ef0 74 69 76 65 20 74 6f 20 63 6f 70 79 20 61 6c 6c tive to copy all
17f00 20 72 65 6d 61 69 6e 69 6e 67 20 70 61 67 65 73 remaining pages
17f10 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 ... /// </par
17f20 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 am>.. /// <pa
17f30 72 61 6d 20 6e 61 6d 65 3d 22 72 65 74 72 79 22 ram name="retry"
17f40 3e 0d 0a 20 20 20 20 2f 2f 2f 20 53 65 74 20 74 >.. /// Set t
17f50 6f 20 74 72 75 65 20 69 66 20 74 68 65 20 6f 70 o true if the op
17f60 65 72 61 74 69 6f 6e 20 6e 65 65 64 73 20 74 6f eration needs to
17f70 20 62 65 20 72 65 74 72 69 65 64 20 64 75 65 20 be retried due
17f80 74 6f 20 64 61 74 61 62 61 73 65 0d 0a 20 20 20 to database..
17f90 20 2f 2f 2f 20 6c 6f 63 6b 69 6e 67 20 69 73 73 /// locking iss
17fa0 75 65 73 3b 20 6f 74 68 65 72 77 69 73 65 2c 20 ues; otherwise,
17fb0 73 65 74 20 74 6f 20 66 61 6c 73 65 2e 0d 0a 20 set to false...
17fc0 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d /// </param>.
17fd0 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e . /// <return
17fe0 73 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 72 75 65 s>.. /// True
17ff0 20 69 66 20 74 68 65 72 65 20 61 72 65 20 6d 6f if there are mo
18000 72 65 20 70 61 67 65 73 20 74 6f 20 62 65 20 63 re pages to be c
18010 6f 70 69 65 64 2c 20 66 61 6c 73 65 20 6f 74 68 opied, false oth
18020 65 72 77 69 73 65 2e 0d 0a 20 20 20 20 2f 2f 2f erwise... ///
18030 20 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 </returns>..
18040 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 internal overri
18050 64 65 20 62 6f 6f 6c 20 53 74 65 70 42 61 63 6b de bool StepBack
18060 75 70 28 0d 0a 20 20 20 20 20 20 20 20 53 51 4c up(.. SQL
18070 69 74 65 42 61 63 6b 75 70 20 62 61 63 6b 75 70 iteBackup backup
18080 2c 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 20 6e ,.. int n
18090 50 61 67 65 2c 0d 0a 20 20 20 20 20 20 20 20 72 Page,.. r
180a0 65 66 20 62 6f 6f 6c 20 72 65 74 72 79 0d 0a 20 ef bool retry..
180b0 20 20 20 20 20 20 20 29 0d 0a 20 20 20 20 7b 0d ).. {.
180c0 0a 20 20 20 20 20 20 20 20 72 65 74 72 79 20 3d . retry =
180d0 20 66 61 6c 73 65 3b 0d 0a 0d 0a 20 20 20 20 20 false;....
180e0 20 20 20 69 66 20 28 62 61 63 6b 75 70 20 3d 3d if (backup ==
180f0 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 null)..
18100 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 throw new Ar
18110 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 gumentNullExcept
18120 69 6f 6e 28 22 62 61 63 6b 75 70 22 29 3b 0d 0a ion("backup");..
18130 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 .. SQLite
18140 42 61 63 6b 75 70 48 61 6e 64 6c 65 20 68 61 6e BackupHandle han
18150 64 6c 65 20 3d 20 62 61 63 6b 75 70 2e 5f 73 71 dle = backup._sq
18160 6c 69 74 65 5f 62 61 63 6b 75 70 3b 0d 0a 0d 0a lite_backup;....
18170 20 20 20 20 20 20 20 20 69 66 20 28 68 61 6e 64 if (hand
18180 6c 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 le == null)..
18190 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e throw n
181a0 65 77 20 49 6e 76 61 6c 69 64 4f 70 65 72 61 74 ew InvalidOperat
181b0 69 6f 6e 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 ionException(..
181c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 "
181d0 42 61 63 6b 75 70 20 6f 62 6a 65 63 74 20 68 61 Backup object ha
181e0 73 20 61 6e 20 69 6e 76 61 6c 69 64 20 68 61 6e s an invalid han
181f0 64 6c 65 2e 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 dle.");....
18200 20 20 20 49 6e 74 50 74 72 20 68 61 6e 64 6c 65 IntPtr handle
18210 50 74 72 20 3d 20 68 61 6e 64 6c 65 3b 0d 0a 0d Ptr = handle;...
18220 0a 20 20 20 20 20 20 20 20 69 66 20 28 68 61 6e . if (han
18230 64 6c 65 50 74 72 20 3d 3d 20 49 6e 74 50 74 72 dlePtr == IntPtr
18240 2e 5a 65 72 6f 29 0d 0a 20 20 20 20 20 20 20 20 .Zero)..
18250 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 49 6e throw new In
18260 76 61 6c 69 64 4f 70 65 72 61 74 69 6f 6e 45 78 validOperationEx
18270 63 65 70 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 ception(..
18280 20 20 20 20 20 20 20 20 20 20 22 42 61 63 6b 75 "Backu
18290 70 20 6f 62 6a 65 63 74 20 68 61 73 20 61 6e 20 p object has an
182a0 69 6e 76 61 6c 69 64 20 68 61 6e 64 6c 65 20 70 invalid handle p
182b0 6f 69 6e 74 65 72 2e 22 29 3b 0d 0a 0d 0a 20 20 ointer.");....
182c0 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 6f SQLiteErro
182d0 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 66 65 rCode n = Unsafe
182e0 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
182f0 6c 69 74 65 33 5f 62 61 63 6b 75 70 5f 73 74 65 lite3_backup_ste
18300 70 28 68 61 6e 64 6c 65 50 74 72 2c 20 6e 50 61 p(handlePtr, nPa
18310 67 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 62 61 ge);.. ba
18320 63 6b 75 70 2e 5f 73 74 65 70 52 65 73 75 6c 74 ckup._stepResult
18330 20 3d 20 6e 3b 20 2f 2a 20 4e 4f 54 45 3a 20 53 = n; /* NOTE: S
18340 61 76 65 20 66 6f 72 20 75 73 65 20 62 79 20 46 ave for use by F
18350 69 6e 69 73 68 42 61 63 6b 75 70 2e 20 2a 2f 0d inishBackup. */.
18360 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 6e ... if (n
18370 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 == SQLiteErrorC
18380 6f 64 65 2e 4f 6b 29 0d 0a 20 20 20 20 20 20 20 ode.Ok)..
18390 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
183a0 72 65 74 75 72 6e 20 74 72 75 65 3b 0d 0a 20 20 return true;..
183b0 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
183c0 20 65 6c 73 65 20 69 66 20 28 6e 20 3d 3d 20 53 else if (n == S
183d0 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 42 QLiteErrorCode.B
183e0 75 73 79 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d usy).. {.
183f0 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 . ret
18400 72 79 20 3d 20 74 72 75 65 3b 0d 0a 20 20 20 20 ry = true;..
18410 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 74 return t
18420 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d rue;.. }.
18430 0a 20 20 20 20 20 20 20 20 65 6c 73 65 20 69 66 . else if
18440 20 28 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 (n == SQLiteErr
18450 6f 72 43 6f 64 65 2e 4c 6f 63 6b 65 64 29 0d 0a orCode.Locked)..
18460 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
18470 20 20 20 20 20 20 20 72 65 74 72 79 20 3d 20 74 retry = t
18480 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 rue;..
18490 20 20 72 65 74 75 72 6e 20 74 72 75 65 3b 0d 0a return true;..
184a0 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
184b0 20 20 20 65 6c 73 65 20 69 66 20 28 6e 20 3d 3d else if (n ==
184c0 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
184d0 2e 44 6f 6e 65 29 0d 0a 20 20 20 20 20 20 20 20 .Done)..
184e0 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 {.. r
184f0 65 74 75 72 6e 20 66 61 6c 73 65 3b 0d 0a 20 20 eturn false;..
18500 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
18510 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 7b else.. {
18520 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 74 68 .. th
18530 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 row new SQLiteEx
18540 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 ception(n, GetLa
18550 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a 20 20 20 stError());..
18560 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d }.. }...
18570 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 . /// <summar
18580 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 52 65 74 75 y>.. /// Retu
18590 72 6e 73 20 74 68 65 20 6e 75 6d 62 65 72 20 6f rns the number o
185a0 66 20 70 61 67 65 73 20 72 65 6d 61 69 6e 69 6e f pages remainin
185b0 67 20 74 6f 20 62 65 20 63 6f 70 69 65 64 20 66 g to be copied f
185c0 72 6f 6d 20 74 68 65 20 73 6f 75 72 63 65 0d 0a rom the source..
185d0 20 20 20 20 2f 2f 2f 20 64 61 74 61 62 61 73 65 /// database
185e0 20 74 6f 20 74 68 65 20 64 65 73 74 69 6e 61 74 to the destinat
185f0 69 6f 6e 20 64 61 74 61 62 61 73 65 20 61 73 73 ion database ass
18600 6f 63 69 61 74 65 64 20 77 69 74 68 20 74 68 65 ociated with the
18610 20 73 70 65 63 69 66 69 65 64 0d 0a 20 20 20 20 specified..
18620 2f 2f 2f 20 62 61 63 6b 75 70 20 6f 62 6a 65 63 /// backup objec
18630 74 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 t... /// </su
18640 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
18650 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 62 61 63 <param name="bac
18660 6b 75 70 22 3e 54 68 65 20 62 61 63 6b 75 70 20 kup">The backup
18670 6f 62 6a 65 63 74 20 74 6f 20 63 68 65 63 6b 2e object to check.
18680 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f </param>.. //
18690 2f 20 3c 72 65 74 75 72 6e 73 3e 54 68 65 20 6e / <returns>The n
186a0 75 6d 62 65 72 20 6f 66 20 70 61 67 65 73 20 72 umber of pages r
186b0 65 6d 61 69 6e 69 6e 67 20 74 6f 20 62 65 20 63 emaining to be c
186c0 6f 70 69 65 64 2e 3c 2f 72 65 74 75 72 6e 73 3e opied.</returns>
186d0 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
186e0 76 65 72 72 69 64 65 20 69 6e 74 20 52 65 6d 61 verride int Rema
186f0 69 6e 69 6e 67 42 61 63 6b 75 70 28 0d 0a 20 20 iningBackup(..
18700 20 20 20 20 20 20 53 51 4c 69 74 65 42 61 63 6b SQLiteBack
18710 75 70 20 62 61 63 6b 75 70 0d 0a 20 20 20 20 20 up backup..
18720 20 20 20 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 ).. {..
18730 20 20 20 20 20 69 66 20 28 62 61 63 6b 75 70 20 if (backup
18740 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 == null)..
18750 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 throw new
18760 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 ArgumentNullExce
18770 70 74 69 6f 6e 28 22 62 61 63 6b 75 70 22 29 3b ption("backup");
18780 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 .... SQLi
18790 74 65 42 61 63 6b 75 70 48 61 6e 64 6c 65 20 68 teBackupHandle h
187a0 61 6e 64 6c 65 20 3d 20 62 61 63 6b 75 70 2e 5f andle = backup._
187b0 73 71 6c 69 74 65 5f 62 61 63 6b 75 70 3b 0d 0a sqlite_backup;..
187c0 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 68 61 .. if (ha
187d0 6e 64 6c 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 ndle == null)..
187e0 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 throw
187f0 20 6e 65 77 20 49 6e 76 61 6c 69 64 4f 70 65 72 new InvalidOper
18800 61 74 69 6f 6e 45 78 63 65 70 74 69 6f 6e 28 0d ationException(.
18810 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
18820 20 22 42 61 63 6b 75 70 20 6f 62 6a 65 63 74 20 "Backup object
18830 68 61 73 20 61 6e 20 69 6e 76 61 6c 69 64 20 68 has an invalid h
18840 61 6e 64 6c 65 2e 22 29 3b 0d 0a 0d 0a 20 20 20 andle.");....
18850 20 20 20 20 20 49 6e 74 50 74 72 20 68 61 6e 64 IntPtr hand
18860 6c 65 50 74 72 20 3d 20 68 61 6e 64 6c 65 3b 0d lePtr = handle;.
18870 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 68 ... if (h
18880 61 6e 64 6c 65 50 74 72 20 3d 3d 20 49 6e 74 50 andlePtr == IntP
18890 74 72 2e 5a 65 72 6f 29 0d 0a 20 20 20 20 20 20 tr.Zero)..
188a0 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 throw new
188b0 49 6e 76 61 6c 69 64 4f 70 65 72 61 74 69 6f 6e InvalidOperation
188c0 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 20 20 20 Exception(..
188d0 20 20 20 20 20 20 20 20 20 20 20 20 22 42 61 63 "Bac
188e0 6b 75 70 20 6f 62 6a 65 63 74 20 68 61 73 20 61 kup object has a
188f0 6e 20 69 6e 76 61 6c 69 64 20 68 61 6e 64 6c 65 n invalid handle
18900 20 70 6f 69 6e 74 65 72 2e 22 29 3b 0d 0a 0d 0a pointer.");....
18910 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 return U
18920 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
18930 64 73 2e 73 71 6c 69 74 65 33 5f 62 61 63 6b 75 ds.sqlite3_backu
18940 70 5f 72 65 6d 61 69 6e 69 6e 67 28 68 61 6e 64 p_remaining(hand
18950 6c 65 50 74 72 29 3b 0d 0a 20 20 20 20 7d 0d 0a lePtr);.. }..
18960 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 .. /// <summa
18970 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 52 65 74 ry>.. /// Ret
18980 75 72 6e 73 20 74 68 65 20 74 6f 74 61 6c 20 6e urns the total n
18990 75 6d 62 65 72 20 6f 66 20 70 61 67 65 73 20 69 umber of pages i
189a0 6e 20 74 68 65 20 73 6f 75 72 63 65 20 64 61 74 n the source dat
189b0 61 62 61 73 65 20 61 73 73 6f 63 69 61 74 65 64 abase associated
189c0 0d 0a 20 20 20 20 2f 2f 2f 20 77 69 74 68 20 74 .. /// with t
189d0 68 65 20 73 70 65 63 69 66 69 65 64 20 62 61 63 he specified bac
189e0 6b 75 70 20 6f 62 6a 65 63 74 2e 0d 0a 20 20 20 kup object...
189f0 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d /// </summary>.
18a00 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 . /// <param
18a10 6e 61 6d 65 3d 22 62 61 63 6b 75 70 22 3e 54 68 name="backup">Th
18a20 65 20 62 61 63 6b 75 70 20 6f 62 6a 65 63 74 20 e backup object
18a30 74 6f 20 63 68 65 63 6b 2e 3c 2f 70 61 72 61 6d to check.</param
18a40 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 >.. /// <retu
18a50 72 6e 73 3e 54 68 65 20 74 6f 74 61 6c 20 6e 75 rns>The total nu
18a60 6d 62 65 72 20 6f 66 20 70 61 67 65 73 20 69 6e mber of pages in
18a70 20 74 68 65 20 73 6f 75 72 63 65 20 64 61 74 61 the source data
18a80 62 61 73 65 2e 3c 2f 72 65 74 75 72 6e 73 3e 0d base.</returns>.
18a90 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
18aa0 65 72 72 69 64 65 20 69 6e 74 20 50 61 67 65 43 erride int PageC
18ab0 6f 75 6e 74 42 61 63 6b 75 70 28 0d 0a 20 20 20 ountBackup(..
18ac0 20 20 20 20 20 53 51 4c 69 74 65 42 61 63 6b 75 SQLiteBacku
18ad0 70 20 62 61 63 6b 75 70 0d 0a 20 20 20 20 20 20 p backup..
18ae0 20 20 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 ).. {..
18af0 20 20 20 20 69 66 20 28 62 61 63 6b 75 70 20 3d if (backup =
18b00 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 = null)..
18b10 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 throw new A
18b20 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 rgumentNullExcep
18b30 74 69 6f 6e 28 22 62 61 63 6b 75 70 22 29 3b 0d tion("backup");.
18b40 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 ... SQLit
18b50 65 42 61 63 6b 75 70 48 61 6e 64 6c 65 20 68 61 eBackupHandle ha
18b60 6e 64 6c 65 20 3d 20 62 61 63 6b 75 70 2e 5f 73 ndle = backup._s
18b70 71 6c 69 74 65 5f 62 61 63 6b 75 70 3b 0d 0a 0d qlite_backup;...
18b80 0a 20 20 20 20 20 20 20 20 69 66 20 28 68 61 6e . if (han
18b90 64 6c 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 dle == null)..
18ba0 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 throw
18bb0 6e 65 77 20 49 6e 76 61 6c 69 64 4f 70 65 72 61 new InvalidOpera
18bc0 74 69 6f 6e 45 78 63 65 70 74 69 6f 6e 28 0d 0a tionException(..
18bd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
18be0 22 42 61 63 6b 75 70 20 6f 62 6a 65 63 74 20 68 "Backup object h
18bf0 61 73 20 61 6e 20 69 6e 76 61 6c 69 64 20 68 61 as an invalid ha
18c00 6e 64 6c 65 2e 22 29 3b 0d 0a 0d 0a 20 20 20 20 ndle.");....
18c10 20 20 20 20 49 6e 74 50 74 72 20 68 61 6e 64 6c IntPtr handl
18c20 65 50 74 72 20 3d 20 68 61 6e 64 6c 65 3b 0d 0a ePtr = handle;..
18c30 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 68 61 .. if (ha
18c40 6e 64 6c 65 50 74 72 20 3d 3d 20 49 6e 74 50 74 ndlePtr == IntPt
18c50 72 2e 5a 65 72 6f 29 0d 0a 20 20 20 20 20 20 20 r.Zero)..
18c60 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 49 throw new I
18c70 6e 76 61 6c 69 64 4f 70 65 72 61 74 69 6f 6e 45 nvalidOperationE
18c80 78 63 65 70 74 69 6f 6e 28 0d 0a 20 20 20 20 20 xception(..
18c90 20 20 20 20 20 20 20 20 20 20 20 22 42 61 63 6b "Back
18ca0 75 70 20 6f 62 6a 65 63 74 20 68 61 73 20 61 6e up object has an
18cb0 20 69 6e 76 61 6c 69 64 20 68 61 6e 64 6c 65 20 invalid handle
18cc0 70 6f 69 6e 74 65 72 2e 22 29 3b 0d 0a 0d 0a 20 pointer.");....
18cd0 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 6e return Un
18ce0 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
18cf0 73 2e 73 71 6c 69 74 65 33 5f 62 61 63 6b 75 70 s.sqlite3_backup
18d00 5f 70 61 67 65 63 6f 75 6e 74 28 68 61 6e 64 6c _pagecount(handl
18d10 65 50 74 72 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d ePtr);.. }...
18d20 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 . /// <summar
18d30 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 44 65 73 74 y>.. /// Dest
18d40 72 6f 79 73 20 74 68 65 20 62 61 63 6b 75 70 20 roys the backup
18d50 6f 62 6a 65 63 74 2c 20 72 6f 6c 6c 69 6e 67 20 object, rolling
18d60 62 61 63 6b 20 61 6e 79 20 62 61 63 6b 75 70 20 back any backup
18d70 74 68 61 74 20 6d 61 79 20 62 65 20 69 6e 0d 0a that may be in..
18d80 20 20 20 20 2f 2f 2f 20 70 72 6f 67 65 73 73 2e /// progess.
18d90 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d .. /// </summ
18da0 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 ary>.. /// <p
18db0 61 72 61 6d 20 6e 61 6d 65 3d 22 62 61 63 6b 75 aram name="backu
18dc0 70 22 3e 54 68 65 20 62 61 63 6b 75 70 20 6f 62 p">The backup ob
18dd0 6a 65 63 74 20 74 6f 20 64 65 73 74 72 6f 79 2e ject to destroy.
18de0 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 69 6e </param>.. in
18df0 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
18e00 76 6f 69 64 20 46 69 6e 69 73 68 42 61 63 6b 75 void FinishBacku
18e10 70 28 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 p(.. SQLi
18e20 74 65 42 61 63 6b 75 70 20 62 61 63 6b 75 70 0d teBackup backup.
18e30 0a 20 20 20 20 20 20 20 20 29 0d 0a 20 20 20 20 . )..
18e40 7b 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 62 {.. if (b
18e50 61 63 6b 75 70 20 3d 3d 20 6e 75 6c 6c 29 0d 0a ackup == null)..
18e60 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f thro
18e70 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 w new ArgumentNu
18e80 6c 6c 45 78 63 65 70 74 69 6f 6e 28 22 62 61 63 llException("bac
18e90 6b 75 70 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 kup");....
18ea0 20 20 53 51 4c 69 74 65 42 61 63 6b 75 70 48 61 SQLiteBackupHa
18eb0 6e 64 6c 65 20 68 61 6e 64 6c 65 20 3d 20 62 61 ndle handle = ba
18ec0 63 6b 75 70 2e 5f 73 71 6c 69 74 65 5f 62 61 63 ckup._sqlite_bac
18ed0 6b 75 70 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 kup;....
18ee0 69 66 20 28 68 61 6e 64 6c 65 20 3d 3d 20 6e 75 if (handle == nu
18ef0 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ll)..
18f00 20 74 68 72 6f 77 20 6e 65 77 20 49 6e 76 61 6c throw new Inval
18f10 69 64 4f 70 65 72 61 74 69 6f 6e 45 78 63 65 70 idOperationExcep
18f20 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 20 20 tion(..
18f30 20 20 20 20 20 20 20 22 42 61 63 6b 75 70 20 6f "Backup o
18f40 62 6a 65 63 74 20 68 61 73 20 61 6e 20 69 6e 76 bject has an inv
18f50 61 6c 69 64 20 68 61 6e 64 6c 65 2e 22 29 3b 0d alid handle.");.
18f60 0a 0d 0a 20 20 20 20 20 20 20 20 49 6e 74 50 74 ... IntPt
18f70 72 20 68 61 6e 64 6c 65 50 74 72 20 3d 20 68 61 r handlePtr = ha
18f80 6e 64 6c 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 ndle;....
18f90 20 69 66 20 28 68 61 6e 64 6c 65 50 74 72 20 3d if (handlePtr =
18fa0 3d 20 49 6e 74 50 74 72 2e 5a 65 72 6f 29 0d 0a = IntPtr.Zero)..
18fb0 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f thro
18fc0 77 20 6e 65 77 20 49 6e 76 61 6c 69 64 4f 70 65 w new InvalidOpe
18fd0 72 61 74 69 6f 6e 45 78 63 65 70 74 69 6f 6e 28 rationException(
18fe0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
18ff0 20 20 22 42 61 63 6b 75 70 20 6f 62 6a 65 63 74 "Backup object
19000 20 68 61 73 20 61 6e 20 69 6e 76 61 6c 69 64 20 has an invalid
19010 68 61 6e 64 6c 65 20 70 6f 69 6e 74 65 72 2e 22 handle pointer."
19020 29 3b 0d 0a 0d 0a 23 69 66 20 21 53 51 4c 49 54 );....#if !SQLIT
19030 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 E_STANDARD..
19040 20 20 20 20 53 51 4c 69 74 65 45 72 72 6f 72 43 SQLiteErrorC
19050 6f 64 65 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 ode n = UnsafeNa
19060 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 tiveMethods.sqli
19070 74 65 33 5f 62 61 63 6b 75 70 5f 66 69 6e 69 73 te3_backup_finis
19080 68 5f 69 6e 74 65 72 6f 70 28 68 61 6e 64 6c 65 h_interop(handle
19090 50 74 72 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 Ptr);..#else..
190a0 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 6f SQLiteErro
190b0 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 66 65 rCode n = Unsafe
190c0 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
190d0 6c 69 74 65 33 5f 62 61 63 6b 75 70 5f 66 69 6e lite3_backup_fin
190e0 69 73 68 28 68 61 6e 64 6c 65 50 74 72 29 3b 0d ish(handlePtr);.
190f0 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 .#endif..
19100 20 68 61 6e 64 6c 65 2e 53 65 74 48 61 6e 64 6c handle.SetHandl
19110 65 41 73 49 6e 76 61 6c 69 64 28 29 3b 0d 0a 0d eAsInvalid();...
19120 0a 23 69 66 20 43 4f 55 4e 54 5f 48 41 4e 44 4c .#if COUNT_HANDL
19130 45 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 28 E.. if ((
19140 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 n == SQLiteError
19150 43 6f 64 65 2e 4f 6b 29 20 7c 7c 20 28 6e 20 3d Code.Ok) || (n =
19160 3d 20 62 61 63 6b 75 70 2e 5f 73 74 65 70 52 65 = backup._stepRe
19170 73 75 6c 74 29 29 20 68 61 6e 64 6c 65 2e 57 61 sult)) handle.Wa
19180 73 52 65 6c 65 61 73 65 64 4f 6b 28 29 3b 0d 0a sReleasedOk();..
19190 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 #endif....
191a0 20 20 69 66 20 28 28 6e 20 21 3d 20 53 51 4c 69 if ((n != SQLi
191b0 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 teErrorCode.Ok)
191c0 26 26 20 28 6e 20 21 3d 20 62 61 63 6b 75 70 2e && (n != backup.
191d0 5f 73 74 65 70 52 65 73 75 6c 74 29 29 0d 0a 20 _stepResult))..
191e0 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 throw
191f0 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 new SQLiteExcep
19200 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 tion(n, GetLastE
19210 72 72 6f 72 28 29 29 3b 0d 0a 20 20 20 20 7d 0d rror());.. }.
19220 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f ... /////////
19230 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
19240 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
19250 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
19260 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
19270 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
19280 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 2f 2f //////.... //
19290 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 / <summary>..
192a0 20 2f 2f 2f 20 44 65 74 65 72 6d 69 6e 65 73 20 /// Determines
192b0 69 66 20 74 68 65 20 53 51 4c 69 74 65 20 63 6f if the SQLite co
192c0 72 65 20 6c 69 62 72 61 72 79 20 68 61 73 20 62 re library has b
192d0 65 65 6e 20 69 6e 69 74 69 61 6c 69 7a 65 64 20 een initialized
192e0 66 6f 72 20 74 68 65 0d 0a 20 20 20 20 2f 2f 2f for the.. ///
192f0 20 63 75 72 72 65 6e 74 20 70 72 6f 63 65 73 73 current process
19300 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d ... /// </sum
19310 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c mary>.. /// <
19320 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 2f 2f returns>.. //
19330 2f 20 41 20 62 6f 6f 6c 65 61 6e 20 69 6e 64 69 / A boolean indi
19340 63 61 74 69 6e 67 20 77 68 65 74 68 65 72 20 6f cating whether o
19350 72 20 6e 6f 74 20 74 68 65 20 53 51 4c 69 74 65 r not the SQLite
19360 20 63 6f 72 65 20 6c 69 62 72 61 72 79 20 68 61 core library ha
19370 73 20 62 65 65 6e 0d 0a 20 20 20 20 2f 2f 2f 20 s been.. ///
19380 69 6e 69 74 69 61 6c 69 7a 65 64 20 66 6f 72 20 initialized for
19390 74 68 65 20 63 75 72 72 65 6e 74 20 70 72 6f 63 the current proc
193a0 65 73 73 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ess... /// </
193b0 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 69 6e returns>.. in
193c0 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
193d0 62 6f 6f 6c 20 49 73 49 6e 69 74 69 61 6c 69 7a bool IsInitializ
193e0 65 64 28 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 ed().. {..
193f0 20 20 20 20 20 72 65 74 75 72 6e 20 53 74 61 74 return Stat
19400 69 63 49 73 49 6e 69 74 69 61 6c 69 7a 65 64 28 icIsInitialized(
19410 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 );.. }....
19420 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
19430 20 20 20 20 2f 2f 2f 20 44 65 74 65 72 6d 69 6e /// Determin
19440 65 73 20 69 66 20 74 68 65 20 53 51 4c 69 74 65 es if the SQLite
19450 20 63 6f 72 65 20 6c 69 62 72 61 72 79 20 68 61 core library ha
19460 73 20 62 65 65 6e 20 69 6e 69 74 69 61 6c 69 7a s been initializ
19470 65 64 20 66 6f 72 20 74 68 65 0d 0a 20 20 20 20 ed for the..
19480 2f 2f 2f 20 63 75 72 72 65 6e 74 20 70 72 6f 63 /// current proc
19490 65 73 73 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ess... /// </
194a0 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
194b0 2f 20 3c 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 / <returns>..
194c0 20 2f 2f 2f 20 41 20 62 6f 6f 6c 65 61 6e 20 69 /// A boolean i
194d0 6e 64 69 63 61 74 69 6e 67 20 77 68 65 74 68 65 ndicating whethe
194e0 72 20 6f 72 20 6e 6f 74 20 74 68 65 20 53 51 4c r or not the SQL
194f0 69 74 65 20 63 6f 72 65 20 6c 69 62 72 61 72 79 ite core library
19500 20 68 61 73 20 62 65 65 6e 0d 0a 20 20 20 20 2f has been.. /
19510 2f 2f 20 69 6e 69 74 69 61 6c 69 7a 65 64 20 66 // initialized f
19520 6f 72 20 74 68 65 20 63 75 72 72 65 6e 74 20 70 or the current p
19530 72 6f 63 65 73 73 2e 0d 0a 20 20 20 20 2f 2f 2f rocess... ///
19540 20 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 </returns>..
19550 20 69 6e 74 65 72 6e 61 6c 20 73 74 61 74 69 63 internal static
19560 20 62 6f 6f 6c 20 53 74 61 74 69 63 49 73 49 6e bool StaticIsIn
19570 69 74 69 61 6c 69 7a 65 64 28 29 0d 0a 20 20 20 itialized()..
19580 20 7b 0d 0a 20 20 20 20 20 20 20 20 2f 2f 0d 0a {.. //..
19590 20 20 20 20 20 20 20 20 2f 2f 20 42 55 47 46 49 // BUGFI
195a0 58 3a 20 50 72 65 76 65 6e 74 20 72 61 63 65 73 X: Prevent races
195b0 20 77 69 74 68 20 6f 74 68 65 72 20 74 68 72 65 with other thre
195c0 61 64 73 20 66 6f 72 20 74 68 69 73 20 65 6e 74 ads for this ent
195d0 69 72 65 20 62 6c 6f 63 6b 2c 20 64 75 65 0d 0a ire block, due..
195e0 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 //
195f0 20 20 20 74 6f 20 74 68 65 20 74 72 79 2f 66 69 to the try/fi
19600 6e 61 6c 6c 79 20 73 65 6d 61 6e 74 69 63 73 2e nally semantics.
19610 20 20 53 65 65 20 74 69 63 6b 65 74 20 5b 37 32 See ticket [72
19620 39 30 35 63 39 61 37 37 5d 2e 0d 0a 20 20 20 20 905c9a77]...
19630 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 //..
19640 6c 6f 63 6b 20 28 73 79 6e 63 52 6f 6f 74 29 0d lock (syncRoot).
19650 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 . {..
19660 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 //..
19670 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a // NOTE:
19680 20 53 61 76 65 20 74 68 65 20 73 74 61 74 65 20 Save the state
19690 6f 66 20 74 68 65 20 6c 6f 67 67 69 6e 67 20 63 of the logging c
196a0 6c 61 73 73 20 61 6e 64 20 74 68 65 6e 20 72 65 lass and then re
196b0 73 74 6f 72 65 20 69 74 0d 0a 20 20 20 20 20 20 store it..
196c0 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 61 // a
196d0 66 74 65 72 20 77 65 20 61 72 65 20 64 6f 6e 65 fter we are done
196e0 20 74 6f 20 61 76 6f 69 64 20 6c 6f 67 67 69 6e to avoid loggin
196f0 67 20 74 6f 6f 20 6d 61 6e 79 20 66 61 6c 73 65 g too many false
19700 20 65 72 72 6f 72 73 2e 0d 0a 20 20 20 20 20 20 errors...
19710 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 //..
19720 20 20 20 20 20 20 62 6f 6f 6c 20 73 61 76 65 64 bool saved
19730 45 6e 61 62 6c 65 64 20 3d 20 53 51 4c 69 74 65 Enabled = SQLite
19740 4c 6f 67 2e 45 6e 61 62 6c 65 64 3b 0d 0a 20 20 Log.Enabled;..
19750 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 SQLite
19760 4c 6f 67 2e 45 6e 61 62 6c 65 64 20 3d 20 66 61 Log.Enabled = fa
19770 6c 73 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 lse;....
19780 20 20 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 try..
19790 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
197a0 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 //..
197b0 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e // N
197c0 4f 54 45 3a 20 54 68 69 73 20 6d 65 74 68 6f 64 OTE: This method
197d0 20 5b 61 62 5d 75 73 65 73 20 74 68 65 20 66 61 [ab]uses the fa
197e0 63 74 20 74 68 61 74 20 53 51 4c 69 74 65 20 77 ct that SQLite w
197f0 69 6c 6c 20 61 6c 77 61 79 73 0d 0a 20 20 20 20 ill always..
19800 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 //
19810 20 20 20 20 20 72 65 74 75 72 6e 20 53 51 4c 49 return SQLI
19820 54 45 5f 45 52 52 4f 52 20 66 6f 72 20 61 6e 79 TE_ERROR for any
19830 20 75 6e 6b 6e 6f 77 6e 20 63 6f 6e 66 69 67 75 unknown configu
19840 72 61 74 69 6f 6e 20 6f 70 74 69 6f 6e 0d 0a 20 ration option..
19850 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f /
19860 2f 20 20 20 20 20 20 20 2a 75 6e 6c 65 73 73 2a / *unless*
19870 20 74 68 65 20 53 51 4c 69 74 65 20 6c 69 62 72 the SQLite libr
19880 61 72 79 20 68 61 73 20 61 6c 72 65 61 64 79 20 ary has already
19890 62 65 65 6e 20 69 6e 69 74 69 61 6c 69 7a 65 64 been initialized
198a0 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ...
198b0 20 20 20 2f 2f 20 20 20 20 20 20 20 49 6e 20 74 // In t
198c0 68 61 74 20 63 61 73 65 20 69 74 20 77 69 6c 6c hat case it will
198d0 20 61 6c 77 61 79 73 20 72 65 74 75 72 6e 20 53 always return S
198e0 51 4c 49 54 45 5f 4d 49 53 55 53 45 2e 0d 0a 20 QLITE_MISUSE...
198f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f /
19900 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 /..
19910 20 20 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f SQLiteErrorCo
19920 64 65 20 72 63 20 3d 20 55 6e 73 61 66 65 4e 61 de rc = UnsafeNa
19930 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 tiveMethods.sqli
19940 74 65 33 5f 63 6f 6e 66 69 67 5f 6e 6f 6e 65 28 te3_config_none(
19950 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
19960 20 20 20 20 20 20 53 51 4c 69 74 65 43 6f 6e 66 SQLiteConf
19970 69 67 4f 70 73 45 6e 75 6d 2e 53 51 4c 49 54 45 igOpsEnum.SQLITE
19980 5f 43 4f 4e 46 49 47 5f 4e 4f 4e 45 29 3b 0d 0a _CONFIG_NONE);..
19990 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
199a0 20 20 72 65 74 75 72 6e 20 28 72 63 20 3d 3d 20 return (rc ==
199b0 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e SQLiteErrorCode.
199c0 4d 69 73 75 73 65 29 3b 0d 0a 20 20 20 20 20 20 Misuse);..
199d0 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
199e0 20 20 20 20 20 66 69 6e 61 6c 6c 79 0d 0a 20 20 finally..
199f0 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
19a00 20 20 20 20 20 20 20 20 20 20 20 20 20 53 51 4c SQL
19a10 69 74 65 4c 6f 67 2e 45 6e 61 62 6c 65 64 20 3d iteLog.Enabled =
19a20 20 73 61 76 65 64 45 6e 61 62 6c 65 64 3b 0d 0a savedEnabled;..
19a30 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 }..
19a40 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d }.. }.
19a50 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d ... /// <summ
19a60 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 48 65 ary>.. /// He
19a70 6c 70 65 72 20 66 75 6e 63 74 69 6f 6e 20 74 6f lper function to
19a80 20 72 65 74 72 69 65 76 65 20 61 20 63 6f 6c 75 retrieve a colu
19a90 6d 6e 20 6f 66 20 64 61 74 61 20 66 72 6f 6d 20 mn of data from
19aa0 61 6e 20 61 63 74 69 76 65 20 73 74 61 74 65 6d an active statem
19ab0 65 6e 74 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ent... /// </
19ac0 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
19ad0 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 73 / <param name="s
19ae0 74 6d 74 22 3e 54 68 65 20 73 74 61 74 65 6d 65 tmt">The stateme
19af0 6e 74 20 62 65 69 6e 67 20 73 74 65 70 28 29 27 nt being step()'
19b00 64 20 74 68 72 6f 75 67 68 3c 2f 70 61 72 61 6d d through</param
19b10 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 >.. /// <para
19b20 6d 20 6e 61 6d 65 3d 22 66 6c 61 67 73 22 3e 54 m name="flags">T
19b30 68 65 20 66 6c 61 67 73 20 61 73 73 6f 63 69 61 he flags associa
19b40 74 65 64 20 77 69 74 68 20 74 68 65 20 63 6f 6e ted with the con
19b50 6e 65 63 74 69 6f 6e 2e 3c 2f 70 61 72 61 6d 3e nection.</param>
19b60 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d .. /// <param
19b70 20 6e 61 6d 65 3d 22 69 6e 64 65 78 22 3e 54 68 name="index">Th
19b80 65 20 63 6f 6c 75 6d 6e 20 69 6e 64 65 78 20 74 e column index t
19b90 6f 20 72 65 74 72 69 65 76 65 3c 2f 70 61 72 61 o retrieve</para
19ba0 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 m>.. /// <par
19bb0 61 6d 20 6e 61 6d 65 3d 22 74 79 70 22 3e 54 68 am name="typ">Th
19bc0 65 20 74 79 70 65 20 6f 66 20 64 61 74 61 20 63 e type of data c
19bd0 6f 6e 74 61 69 6e 65 64 20 69 6e 20 74 68 65 20 ontained in the
19be0 63 6f 6c 75 6d 6e 2e 20 20 49 66 20 55 6e 69 6e column. If Unin
19bf0 69 74 69 61 6c 69 7a 65 64 2c 20 74 68 69 73 20 itialized, this
19c00 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 72 65 function will re
19c10 74 72 69 65 76 65 20 74 68 65 20 64 61 74 61 74 trieve the datat
19c20 79 70 65 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 2e ype information.
19c30 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f </param>.. //
19c40 2f 20 3c 72 65 74 75 72 6e 73 3e 52 65 74 75 72 / <returns>Retur
19c50 6e 73 20 74 68 65 20 64 61 74 61 20 69 6e 20 74 ns the data in t
19c60 68 65 20 63 6f 6c 75 6d 6e 3c 2f 72 65 74 75 72 he column</retur
19c70 6e 73 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 ns>.. interna
19c80 6c 20 6f 76 65 72 72 69 64 65 20 6f 62 6a 65 63 l override objec
19c90 74 20 47 65 74 56 61 6c 75 65 28 53 51 4c 69 74 t GetValue(SQLit
19ca0 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c eStatement stmt,
19cb0 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f SQLiteConnectio
19cc0 6e 46 6c 61 67 73 20 66 6c 61 67 73 2c 20 69 6e nFlags flags, in
19cd0 74 20 69 6e 64 65 78 2c 20 53 51 4c 69 74 65 54 t index, SQLiteT
19ce0 79 70 65 20 74 79 70 29 0d 0a 20 20 20 20 7b 0d ype typ).. {.
19cf0 0a 20 20 20 20 20 20 54 79 70 65 41 66 66 69 6e . TypeAffin
19d00 69 74 79 20 61 66 66 20 3d 20 74 79 70 2e 41 66 ity aff = typ.Af
19d10 66 69 6e 69 74 79 3b 0d 0a 20 20 20 20 20 20 69 finity;.. i
19d20 66 20 28 61 66 66 20 3d 3d 20 54 79 70 65 41 66 f (aff == TypeAf
19d30 66 69 6e 69 74 79 2e 4e 75 6c 6c 29 20 72 65 74 finity.Null) ret
19d40 75 72 6e 20 44 42 4e 75 6c 6c 2e 56 61 6c 75 65 urn DBNull.Value
19d50 3b 0d 0a 20 20 20 20 20 20 54 79 70 65 20 74 20 ;.. Type t
19d60 3d 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 20 20 20 20 = null;....
19d70 20 69 66 20 28 74 79 70 2e 54 79 70 65 20 21 3d if (typ.Type !=
19d80 20 44 62 54 79 70 65 2e 4f 62 6a 65 63 74 29 0d DbType.Object).
19d90 0a 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 . {..
19da0 20 20 74 20 3d 20 53 51 4c 69 74 65 43 6f 6e 76 t = SQLiteConv
19db0 65 72 74 2e 53 51 4c 69 74 65 54 79 70 65 54 6f ert.SQLiteTypeTo
19dc0 54 79 70 65 28 74 79 70 29 3b 0d 0a 20 20 20 20 Type(typ);..
19dd0 20 20 20 20 61 66 66 20 3d 20 54 79 70 65 54 6f aff = TypeTo
19de0 41 66 66 69 6e 69 74 79 28 74 29 3b 0d 0a 20 20 Affinity(t);..
19df0 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 69 }.... i
19e00 66 20 28 28 66 6c 61 67 73 20 26 20 53 51 4c 69 f ((flags & SQLi
19e10 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 teConnectionFlag
19e20 73 2e 47 65 74 41 6c 6c 41 73 54 65 78 74 29 20 s.GetAllAsText)
19e30 3d 3d 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 == SQLiteConnect
19e40 69 6f 6e 46 6c 61 67 73 2e 47 65 74 41 6c 6c 41 ionFlags.GetAllA
19e50 73 54 65 78 74 29 0d 0a 20 20 20 20 20 20 20 20 sText)..
19e60 20 20 72 65 74 75 72 6e 20 47 65 74 54 65 78 74 return GetText
19e70 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 3b 0d 0a (stmt, index);..
19e80 0d 0a 20 20 20 20 20 20 73 77 69 74 63 68 20 28 .. switch (
19e90 61 66 66 29 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 aff).. {..
19ea0 20 20 20 20 20 20 20 63 61 73 65 20 54 79 70 65 case Type
19eb0 41 66 66 69 6e 69 74 79 2e 42 6c 6f 62 3a 0d 0a Affinity.Blob:..
19ec0 20 20 20 20 20 20 20 20 20 20 69 66 20 28 74 79 if (ty
19ed0 70 2e 54 79 70 65 20 3d 3d 20 44 62 54 79 70 65 p.Type == DbType
19ee0 2e 47 75 69 64 20 26 26 20 74 79 70 2e 41 66 66 .Guid && typ.Aff
19ef0 69 6e 69 74 79 20 3d 3d 20 54 79 70 65 41 66 66 inity == TypeAff
19f00 69 6e 69 74 79 2e 54 65 78 74 29 0d 0a 20 20 20 inity.Text)..
19f10 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 return
19f20 6e 65 77 20 47 75 69 64 28 47 65 74 54 65 78 74 new Guid(GetText
19f30 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 29 3b 0d (stmt, index));.
19f40 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 69 6e 74 ... int
19f50 20 6e 20 3d 20 28 69 6e 74 29 47 65 74 42 79 74 n = (int)GetByt
19f60 65 73 28 73 74 6d 74 2c 20 69 6e 64 65 78 2c 20 es(stmt, index,
19f70 30 2c 20 6e 75 6c 6c 2c 20 30 2c 20 30 29 3b 0d 0, null, 0, 0);.
19f80 0a 20 20 20 20 20 20 20 20 20 20 62 79 74 65 5b . byte[
19f90 5d 20 62 20 3d 20 6e 65 77 20 62 79 74 65 5b 6e ] b = new byte[n
19fa0 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 47 65 ];.. Ge
19fb0 74 42 79 74 65 73 28 73 74 6d 74 2c 20 69 6e 64 tBytes(stmt, ind
19fc0 65 78 2c 20 30 2c 20 62 2c 20 30 2c 20 6e 29 3b ex, 0, b, 0, n);
19fd0 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 69 66 .... if
19fe0 20 28 74 79 70 2e 54 79 70 65 20 3d 3d 20 44 62 (typ.Type == Db
19ff0 54 79 70 65 2e 47 75 69 64 20 26 26 20 6e 20 3d Type.Guid && n =
1a000 3d 20 31 36 29 0d 0a 20 20 20 20 20 20 20 20 20 = 16)..
1a010 20 20 20 72 65 74 75 72 6e 20 6e 65 77 20 47 75 return new Gu
1a020 69 64 28 62 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 id(b);....
1a030 20 20 20 20 72 65 74 75 72 6e 20 62 3b 0d 0a 20 return b;..
1a040 20 20 20 20 20 20 20 63 61 73 65 20 54 79 70 65 case Type
1a050 41 66 66 69 6e 69 74 79 2e 44 61 74 65 54 69 6d Affinity.DateTim
1a060 65 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 72 65 e:.. re
1a070 74 75 72 6e 20 47 65 74 44 61 74 65 54 69 6d 65 turn GetDateTime
1a080 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 3b 0d 0a (stmt, index);..
1a090 20 20 20 20 20 20 20 20 63 61 73 65 20 54 79 70 case Typ
1a0a0 65 41 66 66 69 6e 69 74 79 2e 44 6f 75 62 6c 65 eAffinity.Double
1a0b0 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 :.. if
1a0c0 28 74 20 3d 3d 20 6e 75 6c 6c 29 20 72 65 74 75 (t == null) retu
1a0d0 72 6e 20 47 65 74 44 6f 75 62 6c 65 28 73 74 6d rn GetDouble(stm
1a0e0 74 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 t, index);..
1a0f0 20 20 20 20 20 20 72 65 74 75 72 6e 20 43 6f 6e return Con
1a100 76 65 72 74 2e 43 68 61 6e 67 65 54 79 70 65 28 vert.ChangeType(
1a110 47 65 74 44 6f 75 62 6c 65 28 73 74 6d 74 2c 20 GetDouble(stmt,
1a120 69 6e 64 65 78 29 2c 20 74 2c 20 6e 75 6c 6c 29 index), t, null)
1a130 3b 0d 0a 20 20 20 20 20 20 20 20 63 61 73 65 20 ;.. case
1a140 54 79 70 65 41 66 66 69 6e 69 74 79 2e 49 6e 74 TypeAffinity.Int
1a150 36 34 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 69 64:.. i
1a160 66 20 28 74 20 3d 3d 20 6e 75 6c 6c 29 20 72 65 f (t == null) re
1a170 74 75 72 6e 20 47 65 74 49 6e 74 36 34 28 73 74 turn GetInt64(st
1a180 6d 74 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 20 20 mt, index);..
1a190 20 20 20 20 20 20 20 69 66 20 28 74 20 3d 3d 20 if (t ==
1a1a0 74 79 70 65 6f 66 28 42 6f 6f 6c 65 61 6e 29 29 typeof(Boolean))
1a1b0 20 72 65 74 75 72 6e 20 47 65 74 42 6f 6f 6c 65 return GetBoole
1a1c0 61 6e 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 3b an(stmt, index);
1a1d0 0d 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 28 .. if (
1a1e0 74 20 3d 3d 20 74 79 70 65 6f 66 28 53 42 79 74 t == typeof(SByt
1a1f0 65 29 29 20 72 65 74 75 72 6e 20 47 65 74 53 42 e)) return GetSB
1a200 79 74 65 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 yte(stmt, index)
1a210 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 ;.. if
1a220 28 74 20 3d 3d 20 74 79 70 65 6f 66 28 42 79 74 (t == typeof(Byt
1a230 65 29 29 20 72 65 74 75 72 6e 20 47 65 74 42 79 e)) return GetBy
1a240 74 65 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 3b te(stmt, index);
1a250 0d 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 28 .. if (
1a260 74 20 3d 3d 20 74 79 70 65 6f 66 28 49 6e 74 31 t == typeof(Int1
1a270 36 29 29 20 72 65 74 75 72 6e 20 47 65 74 49 6e 6)) return GetIn
1a280 74 31 36 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 t16(stmt, index)
1a290 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 ;.. if
1a2a0 28 74 20 3d 3d 20 74 79 70 65 6f 66 28 55 49 6e (t == typeof(UIn
1a2b0 74 31 36 29 29 20 72 65 74 75 72 6e 20 47 65 74 t16)) return Get
1a2c0 55 49 6e 74 31 36 28 73 74 6d 74 2c 20 69 6e 64 UInt16(stmt, ind
1a2d0 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 ex);..
1a2e0 69 66 20 28 74 20 3d 3d 20 74 79 70 65 6f 66 28 if (t == typeof(
1a2f0 49 6e 74 33 32 29 29 20 72 65 74 75 72 6e 20 47 Int32)) return G
1a300 65 74 49 6e 74 33 32 28 73 74 6d 74 2c 20 69 6e etInt32(stmt, in
1a310 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 dex);..
1a320 20 69 66 20 28 74 20 3d 3d 20 74 79 70 65 6f 66 if (t == typeof
1a330 28 55 49 6e 74 33 32 29 29 20 72 65 74 75 72 6e (UInt32)) return
1a340 20 47 65 74 55 49 6e 74 33 32 28 73 74 6d 74 2c GetUInt32(stmt,
1a350 20 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 index);..
1a360 20 20 20 20 69 66 20 28 74 20 3d 3d 20 74 79 70 if (t == typ
1a370 65 6f 66 28 49 6e 74 36 34 29 29 20 72 65 74 75 eof(Int64)) retu
1a380 72 6e 20 47 65 74 49 6e 74 36 34 28 73 74 6d 74 rn GetInt64(stmt
1a390 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 , index);..
1a3a0 20 20 20 20 20 69 66 20 28 74 20 3d 3d 20 74 79 if (t == ty
1a3b0 70 65 6f 66 28 55 49 6e 74 36 34 29 29 20 72 65 peof(UInt64)) re
1a3c0 74 75 72 6e 20 47 65 74 55 49 6e 74 36 34 28 73 turn GetUInt64(s
1a3d0 74 6d 74 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 20 tmt, index);..
1a3e0 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 43 return C
1a3f0 6f 6e 76 65 72 74 2e 43 68 61 6e 67 65 54 79 70 onvert.ChangeTyp
1a400 65 28 47 65 74 49 6e 74 36 34 28 73 74 6d 74 2c e(GetInt64(stmt,
1a410 20 69 6e 64 65 78 29 2c 20 74 2c 20 6e 75 6c 6c index), t, null
1a420 29 3b 0d 0a 20 20 20 20 20 20 20 20 64 65 66 61 );.. defa
1a430 75 6c 74 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 ult:..
1a440 72 65 74 75 72 6e 20 47 65 74 54 65 78 74 28 73 return GetText(s
1a450 74 6d 74 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 20 tmt, index);..
1a460 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a }.. }....
1a470 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
1a480 72 72 69 64 65 20 69 6e 74 20 47 65 74 43 75 72 rride int GetCur
1a490 73 6f 72 46 6f 72 54 61 62 6c 65 28 53 51 4c 69 sorForTable(SQLi
1a4a0 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 teStatement stmt
1a4b0 2c 20 69 6e 74 20 64 62 2c 20 69 6e 74 20 72 6f , int db, int ro
1a4c0 6f 74 50 61 67 65 29 0d 0a 20 20 20 20 7b 0d 0a otPage).. {..
1a4d0 23 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e #if !SQLITE_STAN
1a4e0 44 41 52 44 0d 0a 20 20 20 20 20 20 72 65 74 75 DARD.. retu
1a4f0 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d rn UnsafeNativeM
1a500 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 74 ethods.sqlite3_t
1a510 61 62 6c 65 5f 63 75 72 73 6f 72 5f 69 6e 74 65 able_cursor_inte
1a520 72 6f 70 28 73 74 6d 74 2e 5f 73 71 6c 69 74 65 rop(stmt._sqlite
1a530 5f 73 74 6d 74 2c 20 64 62 2c 20 72 6f 6f 74 50 _stmt, db, rootP
1a540 61 67 65 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 age);..#else..
1a550 20 20 20 20 72 65 74 75 72 6e 20 2d 31 3b 0d 0a return -1;..
1a560 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d 0a 0d #endif.. }...
1a570 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
1a580 65 72 72 69 64 65 20 6c 6f 6e 67 20 47 65 74 52 erride long GetR
1a590 6f 77 49 64 46 6f 72 43 75 72 73 6f 72 28 53 51 owIdForCursor(SQ
1a5a0 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 LiteStatement st
1a5b0 6d 74 2c 20 69 6e 74 20 63 75 72 73 6f 72 29 0d mt, int cursor).
1a5c0 0a 20 20 20 20 7b 0d 0a 23 69 66 20 21 53 51 4c . {..#if !SQL
1a5d0 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 ITE_STANDARD..
1a5e0 20 20 20 20 6c 6f 6e 67 20 72 6f 77 69 64 20 3d long rowid =
1a5f0 20 30 3b 0d 0a 20 20 20 20 20 20 53 51 4c 69 74 0;.. SQLit
1a600 65 45 72 72 6f 72 43 6f 64 65 20 72 63 20 3d 20 eErrorCode rc =
1a610 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
1a620 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 75 72 73 ods.sqlite3_curs
1a630 6f 72 5f 72 6f 77 69 64 5f 69 6e 74 65 72 6f 70 or_rowid_interop
1a640 28 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 (stmt._sqlite_st
1a650 6d 74 2c 20 63 75 72 73 6f 72 2c 20 72 65 66 20 mt, cursor, ref
1a660 72 6f 77 69 64 29 3b 0d 0a 20 20 20 20 20 20 69 rowid);.. i
1a670 66 20 28 72 63 20 3d 3d 20 53 51 4c 69 74 65 45 f (rc == SQLiteE
1a680 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 72 65 74 rrorCode.Ok) ret
1a690 75 72 6e 20 72 6f 77 69 64 3b 0d 0a 0d 0a 20 20 urn rowid;....
1a6a0 20 20 20 20 72 65 74 75 72 6e 20 30 3b 0d 0a 23 return 0;..#
1a6b0 65 6c 73 65 0d 0a 20 20 20 20 20 20 72 65 74 75 else.. retu
1a6c0 72 6e 20 30 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 rn 0;..#endif..
1a6d0 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 }.... inte
1a6e0 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f rnal override vo
1a6f0 69 64 20 47 65 74 49 6e 64 65 78 43 6f 6c 75 6d id GetIndexColum
1a700 6e 45 78 74 65 6e 64 65 64 49 6e 66 6f 28 73 74 nExtendedInfo(st
1a710 72 69 6e 67 20 64 61 74 61 62 61 73 65 2c 20 73 ring database, s
1a720 74 72 69 6e 67 20 69 6e 64 65 78 2c 20 73 74 72 tring index, str
1a730 69 6e 67 20 63 6f 6c 75 6d 6e 2c 20 72 65 66 20 ing column, ref
1a740 69 6e 74 20 73 6f 72 74 4d 6f 64 65 2c 20 72 65 int sortMode, re
1a750 66 20 69 6e 74 20 6f 6e 45 72 72 6f 72 2c 20 72 f int onError, r
1a760 65 66 20 73 74 72 69 6e 67 20 63 6f 6c 6c 61 74 ef string collat
1a770 69 6f 6e 53 65 71 75 65 6e 63 65 29 0d 0a 20 20 ionSequence)..
1a780 20 20 7b 0d 0a 23 69 66 20 21 53 51 4c 49 54 45 {..#if !SQLITE
1a790 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 _STANDARD..
1a7a0 20 49 6e 74 50 74 72 20 63 6f 6c 6c 20 3d 20 49 IntPtr coll = I
1a7b0 6e 74 50 74 72 2e 5a 65 72 6f 3b 0d 0a 20 20 20 ntPtr.Zero;..
1a7c0 20 20 20 69 6e 74 20 63 6f 6c 6c 6c 65 6e 20 3d int colllen =
1a7d0 20 30 3b 0d 0a 20 20 20 20 20 20 53 51 4c 69 74 0;.. SQLit
1a7e0 65 45 72 72 6f 72 43 6f 64 65 20 72 63 3b 0d 0a eErrorCode rc;..
1a7f0 0d 0a 20 20 20 20 20 20 72 63 20 3d 20 55 6e 73 .. rc = Uns
1a800 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
1a810 2e 73 71 6c 69 74 65 33 5f 69 6e 64 65 78 5f 63 .sqlite3_index_c
1a820 6f 6c 75 6d 6e 5f 69 6e 66 6f 5f 69 6e 74 65 72 olumn_info_inter
1a830 6f 70 28 5f 73 71 6c 2c 20 54 6f 55 54 46 38 28 op(_sql, ToUTF8(
1a840 64 61 74 61 62 61 73 65 29 2c 20 54 6f 55 54 46 database), ToUTF
1a850 38 28 69 6e 64 65 78 29 2c 20 54 6f 55 54 46 38 8(index), ToUTF8
1a860 28 63 6f 6c 75 6d 6e 29 2c 20 72 65 66 20 73 6f (column), ref so
1a870 72 74 4d 6f 64 65 2c 20 72 65 66 20 6f 6e 45 72 rtMode, ref onEr
1a880 72 6f 72 2c 20 72 65 66 20 63 6f 6c 6c 2c 20 72 ror, ref coll, r
1a890 65 66 20 63 6f 6c 6c 6c 65 6e 29 3b 0d 0a 20 20 ef colllen);..
1a8a0 20 20 20 20 69 66 20 28 72 63 20 21 3d 20 53 51 if (rc != SQ
1a8b0 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b LiteErrorCode.Ok
1a8c0 29 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 ) throw new SQLi
1a8d0 74 65 45 78 63 65 70 74 69 6f 6e 28 72 63 2c 20 teException(rc,
1a8e0 6e 75 6c 6c 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 null);....
1a8f0 63 6f 6c 6c 61 74 69 6f 6e 53 65 71 75 65 6e 63 collationSequenc
1a900 65 20 3d 20 55 54 46 38 54 6f 53 74 72 69 6e 67 e = UTF8ToString
1a910 28 63 6f 6c 6c 2c 20 63 6f 6c 6c 6c 65 6e 29 3b (coll, colllen);
1a920 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 73 ..#else.. s
1a930 6f 72 74 4d 6f 64 65 20 3d 20 30 3b 0d 0a 20 20 ortMode = 0;..
1a940 20 20 20 20 6f 6e 45 72 72 6f 72 20 3d 20 32 3b onError = 2;
1a950 0d 0a 20 20 20 20 20 20 63 6f 6c 6c 61 74 69 6f .. collatio
1a960 6e 53 65 71 75 65 6e 63 65 20 3d 20 22 42 49 4e nSequence = "BIN
1a970 41 52 59 22 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 ARY";..#endif..
1a980 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 }.... inte
1a990 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 53 51 rnal override SQ
1a9a0 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 46 69 LiteErrorCode Fi
1a9b0 6c 65 43 6f 6e 74 72 6f 6c 28 73 74 72 69 6e 67 leControl(string
1a9c0 20 7a 44 62 4e 61 6d 65 2c 20 69 6e 74 20 6f 70 zDbName, int op
1a9d0 2c 20 49 6e 74 50 74 72 20 70 41 72 67 29 0d 0a , IntPtr pArg)..
1a9e0 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 65 74 {.. ret
1a9f0 75 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 urn UnsafeNative
1aa00 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
1aa10 66 69 6c 65 5f 63 6f 6e 74 72 6f 6c 28 5f 73 71 file_control(_sq
1aa20 6c 2c 20 28 7a 44 62 4e 61 6d 65 20 21 3d 20 6e l, (zDbName != n
1aa30 75 6c 6c 29 20 3f 20 54 6f 55 54 46 38 28 7a 44 ull) ? ToUTF8(zD
1aa40 62 4e 61 6d 65 29 20 3a 20 6e 75 6c 6c 2c 20 6f bName) : null, o
1aa50 70 2c 20 70 41 72 67 29 3b 0d 0a 20 20 20 20 7d p, pArg);.. }
1aa60 0d 0a 20 20 7d 0d 0a 7d 0d 0a .. }..}..