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: 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 / <summary>..
0690: 20 2f 2f 2f 20 54 68 69 73 20 66 69 65 6c 64 20 /// This field
06a0: 69 73 20 75 73 65 64 20 74 6f 20 72 65 66 65 72 is used to refer
06b0: 20 74 6f 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 to memory alloc
06c0: 61 74 65 64 20 66 6f 72 20 74 68 65 0d 0a 20 20 ated for the..
06d0: 20 20 2f 2f 2f 20 53 51 4c 49 54 45 5f 44 42 43 /// SQLITE_DBC
06e0: 4f 4e 46 49 47 5f 4d 41 49 4e 44 42 4e 41 4d 45 ONFIG_MAINDBNAME
06f0: 20 76 61 6c 75 65 20 75 73 65 64 20 77 69 74 68 value used with
0700: 20 74 68 65 20 6e 61 74 69 76 65 0d 0a 20 20 20 the native..
0710: 20 2f 2f 2f 20 22 73 71 6c 69 74 65 33 5f 64 62 /// "sqlite3_db
0720: 5f 63 6f 6e 66 69 67 22 20 41 50 49 2e 20 20 49 _config" API. I
0730: 66 20 61 6c 6c 6f 63 61 74 65 64 2c 20 74 68 65 f allocated, the
0740: 20 61 73 73 6f 63 69 61 74 65 64 0d 0a 20 20 20 associated..
0750: 20 2f 2f 2f 20 6d 65 6d 65 6f 72 79 20 77 69 6c /// memeory wil
0760: 6c 20 62 65 20 66 72 65 65 64 20 77 68 65 6e 20 l be freed when
0770: 74 68 65 20 75 6e 64 65 72 6c 79 69 6e 67 20 63 the underlying c
0780: 6f 6e 6e 65 63 74 69 6f 6e 20 69 73 0d 0a 20 20 onnection is..
0790: 20 20 2f 2f 2f 20 63 6c 6f 73 65 64 2e 0d 0a 20 /// closed...
07a0: 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 /// </summary
07b0: 3e 0d 0a 20 20 20 20 70 72 69 76 61 74 65 20 49 >.. private I
07c0: 6e 74 50 74 72 20 64 62 4e 61 6d 65 20 3d 20 49 ntPtr dbName = I
07d0: 6e 74 50 74 72 2e 5a 65 72 6f 3b 0d 0a 0d 0a 20 ntPtr.Zero;....
07e0: 20 20 20 2f 2f 0d 0a 20 20 20 20 2f 2f 20 4e 4f //.. // NO
07f0: 54 45 3a 20 54 68 69 73 20 69 73 20 74 68 65 20 TE: This is the
0800: 70 75 62 6c 69 63 20 6b 65 79 20 66 6f 72 20 74 public key for t
0810: 68 65 20 53 79 73 74 65 6d 2e 44 61 74 61 2e 53 he System.Data.S
0820: 51 4c 69 74 65 20 61 73 73 65 6d 62 6c 79 2e 20 QLite assembly.
0830: 20 49 66 20 79 6f 75 20 63 68 61 6e 67 65 20 74 If you change t
0840: 68 65 0d 0a 20 20 20 20 2f 2f 20 20 20 20 20 20 he.. //
0850: 20 53 4e 4b 20 66 69 6c 65 2c 20 79 6f 75 20 77 SNK file, you w
0860: 69 6c 6c 20 6e 65 65 64 20 74 6f 20 63 68 61 6e ill need to chan
0870: 67 65 20 74 68 69 73 20 61 73 20 77 65 6c 6c 2e ge this as well.
0880: 0d 0a 20 20 20 20 2f 2f 0d 0a 20 20 20 20 69 6e .. //.. in
0890: 74 65 72 6e 61 6c 20 63 6f 6e 73 74 20 73 74 72 ternal const str
08a0: 69 6e 67 20 50 75 62 6c 69 63 4b 65 79 20 3d 0d ing PublicKey =.
08b0: 0a 20 20 20 20 20 20 20 20 22 30 30 32 34 30 30 . "002400
08c0: 30 30 30 34 38 30 30 30 30 30 39 34 30 30 30 30 0004800000940000
08d0: 30 30 30 36 30 32 30 30 30 30 30 30 32 34 30 30 0006020000002400
08e0: 30 30 35 32 35 33 34 31 33 31 30 30 30 34 30 30 0052534131000400
08f0: 30 30 30 31 30 30 30 31 30 30 30 35 61 32 38 38 000100010005a288
0900: 64 65 35 36 38 37 63 34 65 31 22 20 2b 0d 0a 20 de5687c4e1" +..
0910: 20 20 20 20 20 20 20 22 62 36 32 31 64 64 66 66 "b621ddff
0920: 35 64 38 34 34 37 32 37 34 31 38 39 35 36 39 39 5d84472741895699
0930: 37 66 34 37 35 65 62 38 32 39 34 32 39 65 34 31 7f475eb829429e41
0940: 31 61 66 66 33 65 39 33 66 39 37 62 37 30 64 65 1aff3e93f97b70de
0950: 36 39 38 62 39 37 32 36 34 30 39 32 35 62 64 64 698b972640925bdd
0960: 34 34 32 38 30 64 66 30 22 20 2b 0d 0a 20 20 20 44280df0" +..
0970: 20 20 20 20 20 22 61 32 35 61 38 34 33 32 36 36 "a25a843266
0980: 39 37 33 37 30 34 31 33 37 63 62 62 30 65 37 34 973704137cbb0e74
0990: 34 31 63 31 66 65 37 63 61 65 34 65 32 34 34 30 41c1fe7cae4e2440
09a0: 61 65 39 31 61 62 38 63 64 65 33 39 33 33 66 65 ae91ab8cde3933fe
09b0: 62 63 62 31 61 63 34 38 64 64 33 33 62 34 30 65 bcb1ac48dd33b40e
09c0: 31 33 63 34 32 31 22 20 2b 0d 0a 20 20 20 20 20 13c421" +..
09d0: 20 20 20 22 64 38 32 31 35 63 31 38 61 34 33 34 "d8215c18a434
09e0: 39 61 34 33 36 64 64 34 39 39 65 33 63 33 38 35 9a436dd499e3c385
09f0: 63 63 36 38 33 30 31 35 66 38 38 36 66 36 63 31 cc683015f886f6c1
0a00: 30 62 64 39 30 31 31 35 65 62 32 62 64 36 31 62 0bd90115eb2bd61b
0a10: 36 37 37 35 30 38 33 39 65 33 61 31 39 39 34 31 67750839e3a19941
0a20: 64 63 39 63 22 3b 0d 0a 0d 0a 23 69 66 20 21 50 dc9c";....#if !P
0a30: 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 LATFORM_COMPACTF
0a40: 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 69 6e RAMEWORK.. in
0a50: 74 65 72 6e 61 6c 20 63 6f 6e 73 74 20 73 74 72 ternal const str
0a60: 69 6e 67 20 44 65 73 69 67 6e 65 72 56 65 72 73 ing DesignerVers
0a70: 69 6f 6e 20 3d 20 22 31 2e 30 2e 31 30 38 2e 30 ion = "1.0.108.0
0a80: 22 3b 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 ";..#endif....
0a90: 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d /// <summary>.
0aa0: 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 6f 70 61 . /// The opa
0ab0: 71 75 65 20 70 6f 69 6e 74 65 72 20 72 65 74 75 que pointer retu
0ac0: 72 6e 65 64 20 74 6f 20 75 73 20 62 79 20 74 68 rned to us by th
0ad0: 65 20 73 71 6c 69 74 65 20 70 72 6f 76 69 64 65 e sqlite provide
0ae0: 72 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d r.. /// </sum
0af0: 6d 61 72 79 3e 0d 0a 20 20 20 20 70 72 6f 74 65 mary>.. prote
0b00: 63 74 65 64 20 69 6e 74 65 72 6e 61 6c 20 53 51 cted internal SQ
0b10: 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 48 61 LiteConnectionHa
0b20: 6e 64 6c 65 20 5f 73 71 6c 3b 0d 0a 20 20 20 20 ndle _sql;..
0b30: 70 72 6f 74 65 63 74 65 64 20 73 74 72 69 6e 67 protected string
0b40: 20 5f 66 69 6c 65 4e 61 6d 65 3b 0d 0a 20 20 20 _fileName;..
0b50: 20 70 72 6f 74 65 63 74 65 64 20 53 51 4c 69 74 protected SQLit
0b60: 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 eConnectionFlags
0b70: 20 5f 66 6c 61 67 73 3b 0d 0a 20 20 20 20 70 72 _flags;.. pr
0b80: 69 76 61 74 65 20 62 6f 6f 6c 20 5f 73 65 74 4c ivate bool _setL
0b90: 6f 67 43 61 6c 6c 62 61 63 6b 3b 0d 0a 20 20 20 ogCallback;..
0ba0: 20 70 72 6f 74 65 63 74 65 64 20 62 6f 6f 6c 20 protected bool
0bb0: 5f 75 73 65 50 6f 6f 6c 3b 0d 0a 20 20 20 20 70 _usePool;.. p
0bc0: 72 6f 74 65 63 74 65 64 20 69 6e 74 20 5f 70 6f rotected int _po
0bd0: 6f 6c 56 65 72 73 69 6f 6e 3b 0d 0a 20 20 20 20 olVersion;..
0be0: 70 72 69 76 61 74 65 20 69 6e 74 20 5f 63 61 6e private int _can
0bf0: 63 65 6c 43 6f 75 6e 74 3b 0d 0a 0d 0a 23 69 66 celCount;....#if
0c00: 20 28 4e 45 54 5f 33 35 20 7c 7c 20 4e 45 54 5f (NET_35 || NET_
0c10: 34 30 20 7c 7c 20 4e 45 54 5f 34 35 20 7c 7c 20 40 || NET_45 ||
0c20: 4e 45 54 5f 34 35 31 20 7c 7c 20 4e 45 54 5f 34 NET_451 || NET_4
0c30: 35 32 20 7c 7c 20 4e 45 54 5f 34 36 20 7c 7c 20 52 || NET_46 ||
0c40: 4e 45 54 5f 34 36 31 20 7c 7c 20 4e 45 54 5f 34 NET_461 || NET_4
0c50: 36 32 20 7c 7c 20 4e 45 54 5f 34 37 20 7c 7c 20 62 || NET_47 ||
0c60: 4e 45 54 5f 34 37 31 29 20 26 26 20 21 50 4c 41 NET_471) && !PLA
0c70: 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 52 41 TFORM_COMPACTFRA
0c80: 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 70 72 69 76 MEWORK.. priv
0c90: 61 74 65 20 62 6f 6f 6c 20 5f 62 75 69 6c 64 69 ate bool _buildi
0ca0: 6e 67 53 63 68 65 6d 61 3b 0d 0a 23 65 6e 64 69 ngSchema;..#endi
0cb0: 66 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 f.... /// <su
0cc0: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
0cd0: 54 68 65 20 75 73 65 72 2d 64 65 66 69 6e 65 64 The user-defined
0ce0: 20 66 75 6e 63 74 69 6f 6e 73 20 72 65 67 69 73 functions regis
0cf0: 74 65 72 65 64 20 6f 6e 20 74 68 69 73 20 63 6f tered on this co
0d00: 6e 6e 65 63 74 69 6f 6e 0d 0a 20 20 20 20 2f 2f nnection.. //
0d10: 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 / </summary>..
0d20: 20 20 70 72 6f 74 65 63 74 65 64 20 44 69 63 74 protected Dict
0d30: 69 6f 6e 61 72 79 3c 53 51 4c 69 74 65 46 75 6e ionary<SQLiteFun
0d40: 63 74 69 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 ctionAttribute,
0d50: 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 3e 20 SQLiteFunction>
0d60: 5f 66 75 6e 63 74 69 6f 6e 73 3b 0d 0a 0d 0a 23 _functions;....#
0d70: 69 66 20 49 4e 54 45 52 4f 50 5f 56 49 52 54 55 if INTEROP_VIRTU
0d80: 41 4c 5f 54 41 42 4c 45 0d 0a 20 20 20 20 2f 2f AL_TABLE.. //
0d90: 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 / <summary>..
0da0: 20 2f 2f 2f 20 54 68 69 73 20 69 73 20 74 68 65 /// This is the
0db0: 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 6e 61 74 name of the nat
0dc0: 69 76 65 20 6c 69 62 72 61 72 79 20 66 69 6c 65 ive library file
0dd0: 20 74 68 61 74 20 63 6f 6e 74 61 69 6e 73 20 74 that contains t
0de0: 68 65 0d 0a 20 20 20 20 2f 2f 2f 20 22 76 74 73 he.. /// "vts
0df0: 68 69 6d 22 20 65 78 74 65 6e 73 69 6f 6e 20 5b him" extension [
0e00: 77 72 61 70 70 65 72 5d 2e 0d 0a 20 20 20 20 2f wrapper]... /
0e10: 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 // </summary>..
0e20: 20 20 20 70 72 6f 74 65 63 74 65 64 20 73 74 72 protected str
0e30: 69 6e 67 20 5f 73 68 69 6d 45 78 74 65 6e 73 69 ing _shimExtensi
0e40: 6f 6e 46 69 6c 65 4e 61 6d 65 20 3d 20 6e 75 6c onFileName = nul
0e50: 6c 3b 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 l;.... /// <s
0e60: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
0e70: 20 54 68 69 73 20 69 73 20 74 68 65 20 66 6c 61 This is the fla
0e80: 67 20 69 6e 64 69 63 61 74 65 20 77 68 65 74 68 g indicate wheth
0e90: 65 72 20 74 68 65 20 6e 61 74 69 76 65 20 6c 69 er the native li
0ea0: 62 72 61 72 79 20 66 69 6c 65 20 74 68 61 74 0d brary file that.
0eb0: 0a 20 20 20 20 2f 2f 2f 20 63 6f 6e 74 61 69 6e . /// contain
0ec0: 73 20 74 68 65 20 22 76 74 73 68 69 6d 22 20 65 s the "vtshim" e
0ed0: 78 74 65 6e 73 69 6f 6e 20 6d 75 73 74 20 62 65 xtension must be
0ee0: 20 64 79 6e 61 6d 69 63 61 6c 6c 79 20 6c 6f 61 dynamically loa
0ef0: 64 65 64 20 62 79 0d 0a 20 20 20 20 2f 2f 2f 20 ded by.. ///
0f00: 74 68 69 73 20 63 6c 61 73 73 20 70 72 69 6f 72 this class prior
0f10: 20 74 6f 20 75 73 65 2e 0d 0a 20 20 20 20 2f 2f to use... //
0f20: 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 / </summary>..
0f30: 20 20 70 72 6f 74 65 63 74 65 64 20 62 6f 6f 6c protected bool
0f40: 3f 20 5f 73 68 69 6d 49 73 4c 6f 61 64 4e 65 65 ? _shimIsLoadNee
0f50: 64 65 64 20 3d 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 ded = null;....
0f60: 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
0f70: 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 69 73 20 69 .. /// This i
0f80: 73 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 s the name of th
0f90: 65 20 6e 61 74 69 76 65 20 65 6e 74 72 79 20 70 e native entry p
0fa0: 6f 69 6e 74 20 66 6f 72 20 74 68 65 20 22 76 74 oint for the "vt
0fb0: 73 68 69 6d 22 0d 0a 20 20 20 20 2f 2f 2f 20 65 shim".. /// e
0fc0: 78 74 65 6e 73 69 6f 6e 20 5b 77 72 61 70 70 65 xtension [wrappe
0fd0: 72 5d 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 r]... /// </s
0fe0: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 70 72 6f ummary>.. pro
0ff0: 74 65 63 74 65 64 20 73 74 72 69 6e 67 20 5f 73 tected string _s
1000: 68 69 6d 45 78 74 65 6e 73 69 6f 6e 50 72 6f 63 himExtensionProc
1010: 4e 61 6d 65 20 3d 20 22 73 71 6c 69 74 65 33 5f Name = "sqlite3_
1020: 76 74 73 68 69 6d 5f 69 6e 69 74 22 3b 0d 0a 0d vtshim_init";...
1030: 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 . /// <summar
1040: 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 y>.. /// The
1050: 6d 6f 64 75 6c 65 73 20 63 72 65 61 74 65 64 20 modules created
1060: 75 73 69 6e 67 20 74 68 69 73 20 63 6f 6e 6e 65 using this conne
1070: 63 74 69 6f 6e 2e 0d 0a 20 20 20 20 2f 2f 2f 20 ction... ///
1080: 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 </summary>..
1090: 70 72 6f 74 65 63 74 65 64 20 44 69 63 74 69 6f protected Dictio
10a0: 6e 61 72 79 3c 73 74 72 69 6e 67 2c 20 53 51 4c nary<string, SQL
10b0: 69 74 65 4d 6f 64 75 6c 65 3e 20 5f 6d 6f 64 75 iteModule> _modu
10c0: 6c 65 73 3b 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a les;..#endif....
10d0: 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////
10e0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
10f0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1100: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1110: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1120: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1130: 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c ///.... /// <
1140: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
1150: 2f 20 43 6f 6e 73 74 72 75 63 74 73 20 74 68 65 / Constructs the
1160: 20 6f 62 6a 65 63 74 20 75 73 65 64 20 74 6f 20 object used to
1170: 69 6e 74 65 72 61 63 74 20 77 69 74 68 20 74 68 interact with th
1180: 65 20 53 51 4c 69 74 65 20 63 6f 72 65 20 6c 69 e SQLite core li
1190: 62 72 61 72 79 0d 0a 20 20 20 20 2f 2f 2f 20 75 brary.. /// u
11a0: 73 69 6e 67 20 74 68 65 20 55 54 46 2d 38 20 74 sing the UTF-8 t
11b0: 65 78 74 20 65 6e 63 6f 64 69 6e 67 2e 0d 0a 20 ext encoding...
11c0: 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 /// </summary
11d0: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 >.. /// <para
11e0: 6d 20 6e 61 6d 65 3d 22 66 6d 74 22 3e 0d 0a 20 m name="fmt">..
11f0: 20 20 20 2f 2f 2f 20 54 68 65 20 44 61 74 65 54 /// The DateT
1200: 69 6d 65 20 66 6f 72 6d 61 74 20 74 6f 20 62 65 ime format to be
1210: 20 75 73 65 64 20 77 68 65 6e 20 63 6f 6e 76 65 used when conve
1220: 72 74 69 6e 67 20 73 74 72 69 6e 67 20 76 61 6c rting string val
1230: 75 65 73 20 74 6f 20 61 0d 0a 20 20 20 20 2f 2f ues to a.. //
1240: 2f 20 44 61 74 65 54 69 6d 65 20 61 6e 64 20 62 / DateTime and b
1250: 69 6e 64 69 6e 67 20 44 61 74 65 54 69 6d 65 20 inding DateTime
1260: 70 61 72 61 6d 65 74 65 72 73 2e 0d 0a 20 20 20 parameters...
1270: 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 /// </param>..
1280: 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 /// <param na
1290: 6d 65 3d 22 6b 69 6e 64 22 3e 0d 0a 20 20 20 20 me="kind">..
12a0: 2f 2f 2f 20 54 68 65 20 3c 73 65 65 20 63 72 65 /// The <see cre
12b0: 66 3d 22 44 61 74 65 54 69 6d 65 4b 69 6e 64 22 f="DateTimeKind"
12c0: 20 2f 3e 20 74 6f 20 62 65 20 75 73 65 64 20 77 /> to be used w
12d0: 68 65 6e 20 63 72 65 61 74 69 6e 67 20 44 61 74 hen creating Dat
12e0: 65 54 69 6d 65 0d 0a 20 20 20 20 2f 2f 2f 20 76 eTime.. /// v
12f0: 61 6c 75 65 73 2e 0d 0a 20 20 20 20 2f 2f 2f 20 alues... ///
1300: 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f </param>.. //
1310: 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 66 / <param name="f
1320: 6d 74 53 74 72 69 6e 67 22 3e 0d 0a 20 20 20 20 mtString">..
1330: 2f 2f 2f 20 54 68 65 20 66 6f 72 6d 61 74 20 73 /// The format s
1340: 74 72 69 6e 67 20 74 6f 20 62 65 20 75 73 65 64 tring to be used
1350: 20 77 68 65 6e 20 70 61 72 73 69 6e 67 20 61 6e when parsing an
1360: 64 20 66 6f 72 6d 61 74 74 69 6e 67 20 44 61 74 d formatting Dat
1370: 65 54 69 6d 65 0d 0a 20 20 20 20 2f 2f 2f 20 76 eTime.. /// v
1380: 61 6c 75 65 73 2e 0d 0a 20 20 20 20 2f 2f 2f 20 alues... ///
1390: 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f </param>.. //
13a0: 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 64 / <param name="d
13b0: 62 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 b">.. /// The
13c0: 20 6e 61 74 69 76 65 20 68 61 6e 64 6c 65 20 74 native handle t
13d0: 6f 20 62 65 20 61 73 73 6f 63 69 61 74 65 64 20 o be associated
13e0: 77 69 74 68 20 74 68 65 20 64 61 74 61 62 61 73 with the databas
13f0: 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 2e 0d 0a 20 e connection...
1400: 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d /// </param>.
1410: 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 . /// <param
1420: 6e 61 6d 65 3d 22 66 69 6c 65 4e 61 6d 65 22 3e name="fileName">
1430: 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 66 75 .. /// The fu
1440: 6c 6c 79 20 71 75 61 6c 69 66 69 65 64 20 66 69 lly qualified fi
1450: 6c 65 20 6e 61 6d 65 20 61 73 73 6f 63 69 61 74 le name associat
1460: 65 64 20 77 69 74 68 20 3c 70 61 72 61 6d 72 65 ed with <paramre
1470: 66 20 6e 61 6d 65 3d 22 64 62 20 22 2f 3e 2e 0d f name="db "/>..
1480: 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d . /// </param
1490: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 >.. /// <para
14a0: 6d 20 6e 61 6d 65 3d 22 6f 77 6e 48 61 6e 64 6c m name="ownHandl
14b0: 65 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 4e 6f 6e e">.. /// Non
14c0: 2d 7a 65 72 6f 20 69 66 20 74 68 65 20 6e 65 77 -zero if the new
14d0: 6c 79 20 63 72 65 61 74 65 64 20 6f 62 6a 65 63 ly created objec
14e0: 74 20 69 6e 73 74 61 6e 63 65 20 77 69 6c 6c 20 t instance will
14f0: 6e 65 65 64 20 74 6f 20 64 69 73 70 6f 73 65 0d need to dispose.
1500: 0a 20 20 20 20 2f 2f 2f 20 6f 66 20 3c 70 61 72 . /// of <par
1510: 61 6d 72 65 66 20 6e 61 6d 65 3d 22 64 62 22 20 amref name="db"
1520: 2f 3e 20 77 68 65 6e 20 69 74 20 69 73 20 6e 6f /> when it is no
1530: 20 6c 6f 6e 67 65 72 20 6e 65 65 64 65 64 2e 0d longer needed..
1540: 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d . /// </param
1550: 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 >.. internal
1560: 53 51 4c 69 74 65 33 28 0d 0a 20 20 20 20 20 20 SQLite3(..
1570: 20 20 53 51 4c 69 74 65 44 61 74 65 46 6f 72 6d SQLiteDateForm
1580: 61 74 73 20 66 6d 74 2c 0d 0a 20 20 20 20 20 20 ats fmt,..
1590: 20 20 44 61 74 65 54 69 6d 65 4b 69 6e 64 20 6b DateTimeKind k
15a0: 69 6e 64 2c 0d 0a 20 20 20 20 20 20 20 20 73 74 ind,.. st
15b0: 72 69 6e 67 20 66 6d 74 53 74 72 69 6e 67 2c 0d ring fmtString,.
15c0: 0a 20 20 20 20 20 20 20 20 49 6e 74 50 74 72 20 . IntPtr
15d0: 64 62 2c 0d 0a 20 20 20 20 20 20 20 20 73 74 72 db,.. str
15e0: 69 6e 67 20 66 69 6c 65 4e 61 6d 65 2c 0d 0a 20 ing fileName,..
15f0: 20 20 20 20 20 20 20 62 6f 6f 6c 20 6f 77 6e 48 bool ownH
1600: 61 6e 64 6c 65 0d 0a 20 20 20 20 20 20 20 20 29 andle.. )
1610: 0d 0a 20 20 20 20 20 20 3a 20 62 61 73 65 28 66 .. : base(f
1620: 6d 74 2c 20 6b 69 6e 64 2c 20 66 6d 74 53 74 72 mt, kind, fmtStr
1630: 69 6e 67 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 ing).. {..
1640: 20 20 20 20 20 69 66 20 28 64 62 20 21 3d 20 49 if (db != I
1650: 6e 74 50 74 72 2e 5a 65 72 6f 29 0d 0a 20 20 20 ntPtr.Zero)..
1660: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
1670: 20 20 20 20 5f 73 71 6c 20 3d 20 6e 65 77 20 53 _sql = new S
1680: 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 48 QLiteConnectionH
1690: 61 6e 64 6c 65 28 64 62 2c 20 6f 77 6e 48 61 6e andle(db, ownHan
16a0: 64 6c 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 dle);..
16b0: 20 20 20 5f 66 69 6c 65 4e 61 6d 65 20 3d 20 66 _fileName = f
16c0: 69 6c 65 4e 61 6d 65 3b 0d 0a 0d 0a 20 20 20 20 ileName;....
16d0: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 43 6f SQLiteCo
16e0: 6e 6e 65 63 74 69 6f 6e 2e 4f 6e 43 68 61 6e 67 nnection.OnChang
16f0: 65 64 28 6e 75 6c 6c 2c 20 6e 65 77 20 43 6f 6e ed(null, new Con
1700: 6e 65 63 74 69 6f 6e 45 76 65 6e 74 41 72 67 73 nectionEventArgs
1710: 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 (..
1720: 20 20 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 SQLiteConnect
1730: 69 6f 6e 45 76 65 6e 74 54 79 70 65 2e 4e 65 77 ionEventType.New
1740: 43 72 69 74 69 63 61 6c 48 61 6e 64 6c 65 2c 20 CriticalHandle,
1750: 6e 75 6c 6c 2c 0d 0a 20 20 20 20 20 20 20 20 20 null,..
1760: 20 20 20 20 20 20 20 6e 75 6c 6c 2c 20 6e 75 6c null, nul
1770: 6c 2c 20 6e 75 6c 6c 2c 20 5f 73 71 6c 2c 20 66 l, null, _sql, f
1780: 69 6c 65 4e 61 6d 65 2c 20 6e 65 77 20 6f 62 6a ileName, new obj
1790: 65 63 74 5b 5d 20 7b 0d 0a 20 20 20 20 20 20 20 ect[] {..
17a0: 20 20 20 20 20 20 20 20 20 74 79 70 65 6f 66 28 typeof(
17b0: 53 51 4c 69 74 65 33 29 2c 20 66 6d 74 2c 20 6b SQLite3), fmt, k
17c0: 69 6e 64 2c 20 66 6d 74 53 74 72 69 6e 67 2c 20 ind, fmtString,
17d0: 64 62 2c 20 66 69 6c 65 4e 61 6d 65 2c 0d 0a 20 db, fileName,..
17e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f o
17f0: 77 6e 48 61 6e 64 6c 65 20 7d 29 29 3b 0d 0a 20 wnHandle }));..
1800: 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d }.. }.
1810: 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f ... /////////
1820: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1830: 2f 2f 2f 2f 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 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1860: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1870: 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 23 72 //////.... #r
1880: 65 67 69 6f 6e 20 49 44 69 73 70 6f 73 61 62 6c egion IDisposabl
1890: 65 20 22 50 61 74 74 65 72 6e 22 20 4d 65 6d 62 e "Pattern" Memb
18a0: 65 72 73 0d 0a 20 20 20 20 70 72 69 76 61 74 65 ers.. private
18b0: 20 62 6f 6f 6c 20 64 69 73 70 6f 73 65 64 3b 0d bool disposed;.
18c0: 0a 20 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 . private voi
18d0: 64 20 43 68 65 63 6b 44 69 73 70 6f 73 65 64 28 d CheckDisposed(
18e0: 29 20 2f 2a 20 74 68 72 6f 77 20 2a 2f 0d 0a 20 ) /* throw */..
18f0: 20 20 20 7b 0d 0a 23 69 66 20 54 48 52 4f 57 5f {..#if THROW_
1900: 4f 4e 5f 44 49 53 50 4f 53 45 44 0d 0a 20 20 20 ON_DISPOSED..
1910: 20 20 20 20 20 69 66 20 28 64 69 73 70 6f 73 65 if (dispose
1920: 64 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 d)..
1930: 74 68 72 6f 77 20 6e 65 77 20 4f 62 6a 65 63 74 throw new Object
1940: 44 69 73 70 6f 73 65 64 45 78 63 65 70 74 69 6f DisposedExceptio
1950: 6e 28 74 79 70 65 6f 66 28 53 51 4c 69 74 65 33 n(typeof(SQLite3
1960: 29 2e 4e 61 6d 65 29 3b 0d 0a 23 65 6e 64 69 66 ).Name);..#endif
1970: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f .. }.... /
1980: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1990: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
19a0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
19b0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
19c0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
19d0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a //////////////..
19e0: 0d 0a 20 20 20 20 70 72 6f 74 65 63 74 65 64 20 .. protected
19f0: 6f 76 65 72 72 69 64 65 20 76 6f 69 64 20 44 69 override void Di
1a00: 73 70 6f 73 65 28 62 6f 6f 6c 20 64 69 73 70 6f spose(bool dispo
1a10: 73 69 6e 67 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 sing).. {..
1a20: 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 20 20 try..
1a30: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
1a40: 20 20 69 66 20 28 21 64 69 73 70 6f 73 65 64 29 if (!disposed)
1a50: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d .. {.
1a60: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
1a70: 20 2f 2f 69 66 20 28 64 69 73 70 6f 73 69 6e 67 //if (disposing
1a80: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )..
1a90: 20 20 20 2f 2f 7b 0d 0a 20 20 20 20 20 20 20 20 //{..
1aa0: 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 2f 2f // //
1ab0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1ac0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1ad0: 2f 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 //..
1ae0: 20 20 20 20 2f 2f 20 20 20 20 2f 2f 20 64 69 73 // // dis
1af0: 70 6f 73 65 20 6d 61 6e 61 67 65 64 20 72 65 73 pose managed res
1b00: 6f 75 72 63 65 73 20 68 65 72 65 2e 2e 2e 0d 0a ources here.....
1b10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1b20: 2f 2f 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 0d 0a 20 20 20 20 //////////..
1b50: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 7d 0d //}.
1b60: 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ...
1b70: 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f /////////////
1b80: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b90: 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 20 20 20 20 20 /////////..
1ba0: 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 72 65 // re
1bb0: 6c 65 61 73 65 20 75 6e 6d 61 6e 61 67 65 64 20 lease unmanaged
1bc0: 72 65 73 6f 75 72 63 65 73 20 68 65 72 65 2e 2e resources here..
1bd0: 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ...
1be0: 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f /////////////
1bf0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1c00: 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 23 69 66 /////////....#if
1c10: 20 49 4e 54 45 52 4f 50 5f 56 49 52 54 55 41 4c INTEROP_VIRTUAL
1c20: 5f 54 41 42 4c 45 0d 0a 20 20 20 20 20 20 20 20 _TABLE..
1c30: 20 20 20 20 20 20 20 20 44 69 73 70 6f 73 65 4d DisposeM
1c40: 6f 64 75 6c 65 73 28 29 3b 0d 0a 23 65 6e 64 69 odules();..#endi
1c50: 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 f....
1c60: 20 20 20 20 20 43 6c 6f 73 65 28 74 72 75 65 29 Close(true)
1c70: 3b 20 2f 2a 20 44 69 73 70 6f 73 69 6e 67 2c 20 ; /* Disposing,
1c80: 63 61 6e 6e 6f 74 20 74 68 72 6f 77 2e 20 2a 2f cannot throw. */
1c90: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d .. }.
1ca0: 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 . }..
1cb0: 20 20 20 20 66 69 6e 61 6c 6c 79 0d 0a 20 20 20 finally..
1cc0: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
1cd0: 20 20 20 20 62 61 73 65 2e 44 69 73 70 6f 73 65 base.Dispose
1ce0: 28 64 69 73 70 6f 73 69 6e 67 29 3b 0d 0a 0d 0a (disposing);....
1cf0: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 0d 0a //..
1d00: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e // N
1d10: 4f 54 45 3a 20 45 76 65 72 79 74 68 69 6e 67 20 OTE: Everything
1d20: 73 68 6f 75 6c 64 20 62 65 20 66 75 6c 6c 79 20 should be fully
1d30: 64 69 73 70 6f 73 65 64 20 61 74 20 74 68 69 73 disposed at this
1d40: 20 70 6f 69 6e 74 2e 0d 0a 20 20 20 20 20 20 20 point...
1d50: 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 //..
1d60: 20 20 20 20 20 64 69 73 70 6f 73 65 64 20 3d 20 disposed =
1d70: 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 7d true;.. }
1d80: 0d 0a 20 20 20 20 7d 0d 0a 20 20 20 20 23 65 6e .. }.. #en
1d90: 64 72 65 67 69 6f 6e 0d 0a 0d 0a 20 20 20 20 2f dregion.... /
1da0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1db0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1dc0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1dd0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1de0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1df0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a //////////////..
1e00: 0d 0a 23 69 66 20 44 45 42 55 47 0d 0a 20 20 20 ..#if DEBUG..
1e10: 20 70 75 62 6c 69 63 20 6f 76 65 72 72 69 64 65 public override
1e20: 20 73 74 72 69 6e 67 20 54 6f 53 74 72 69 6e 67 string ToString
1e30: 28 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 ().. {..
1e40: 20 20 20 72 65 74 75 72 6e 20 48 65 6c 70 65 72 return Helper
1e50: 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f Methods.StringFo
1e60: 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 rmat(..
1e70: 20 20 20 43 75 6c 74 75 72 65 49 6e 66 6f 2e 49 CultureInfo.I
1e80: 6e 76 61 72 69 61 6e 74 43 75 6c 74 75 72 65 2c nvariantCulture,
1e90: 20 22 66 69 6c 65 4e 61 6d 65 20 3d 20 7b 30 7d "fileName = {0}
1ea0: 2c 20 66 6c 61 67 73 20 3d 20 7b 31 7d 22 2c 0d , flags = {1}",.
1eb0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 5f 66 69 . _fi
1ec0: 6c 65 4e 61 6d 65 2c 20 5f 66 6c 61 67 73 29 3b leName, _flags);
1ed0: 0d 0a 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d .. }..#endif.
1ee0: 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f ... /////////
1ef0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1f00: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1f10: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1f20: 2f 2f 2f 2f 2f 2f 2f 2f 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 0d 0a 0d 0a 23 69 66 20 49 4e //////....#if IN
1f50: 54 45 52 4f 50 5f 56 49 52 54 55 41 4c 5f 54 41 TEROP_VIRTUAL_TA
1f60: 42 4c 45 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 BLE.. /// <su
1f70: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
1f80: 54 68 69 73 20 6d 65 74 68 6f 64 20 61 74 74 65 This method atte
1f90: 6d 70 74 73 20 74 6f 20 64 69 73 70 6f 73 65 20 mpts to dispose
1fa0: 6f 66 20 61 6c 6c 20 74 68 65 20 3c 73 65 65 20 of all the <see
1fb0: 63 72 65 66 3d 22 53 51 4c 69 74 65 4d 6f 64 75 cref="SQLiteModu
1fc0: 6c 65 22 20 2f 3e 20 64 65 72 69 76 65 64 0d 0a le" /> derived..
1fd0: 20 20 20 20 2f 2f 2f 20 6f 62 6a 65 63 74 20 69 /// object i
1fe0: 6e 73 74 61 6e 63 65 73 20 63 75 72 72 65 6e 74 nstances current
1ff0: 6c 79 20 61 73 73 6f 63 69 61 74 65 64 20 77 69 ly associated wi
2000: 74 68 20 74 68 65 20 6e 61 74 69 76 65 20 64 61 th the native da
2010: 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f tabase connectio
2020: 6e 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 n... /// </su
2030: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 70 72 69 76 mmary>.. priv
2040: 61 74 65 20 76 6f 69 64 20 44 69 73 70 6f 73 65 ate void Dispose
2050: 4d 6f 64 75 6c 65 73 28 29 0d 0a 20 20 20 20 7b Modules().. {
2060: 0d 0a 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 .. //..
2070: 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 49 // NOTE: I
2080: 66 20 61 6e 79 20 6d 6f 64 75 6c 65 73 20 77 65 f any modules we
2090: 72 65 20 63 72 65 61 74 65 64 2c 20 61 74 74 65 re created, atte
20a0: 6d 70 74 20 74 6f 20 64 69 73 70 6f 73 65 20 6f mpt to dispose o
20b0: 66 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 20 f.. //
20c0: 20 20 20 20 74 68 65 6d 20 6e 6f 77 2e 20 20 54 them now. T
20d0: 68 69 73 20 63 6f 64 65 20 69 73 20 64 65 73 69 his code is desi
20e0: 67 6e 65 64 20 74 6f 20 61 76 6f 69 64 20 74 68 gned to avoid th
20f0: 72 6f 77 69 6e 67 0d 0a 20 20 20 20 20 20 20 20 rowing..
2100: 2f 2f 20 20 20 20 20 20 20 65 78 63 65 70 74 69 // excepti
2110: 6f 6e 73 20 75 6e 6c 65 73 73 20 74 68 65 20 44 ons unless the D
2120: 69 73 70 6f 73 65 20 6d 65 74 68 6f 64 20 6f 66 ispose method of
2130: 20 74 68 65 20 6d 6f 64 75 6c 65 0d 0a 20 20 20 the module..
2140: 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 69 74 // it
2150: 73 65 6c 66 20 74 68 72 6f 77 73 20 61 6e 20 65 self throws an e
2160: 78 63 65 70 74 69 6f 6e 2e 0d 0a 20 20 20 20 20 xception...
2170: 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 69 //.. i
2180: 66 20 28 5f 6d 6f 64 75 6c 65 73 20 21 3d 20 6e f (_modules != n
2190: 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d ull).. {.
21a0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 . for
21b0: 65 61 63 68 20 28 4b 65 79 56 61 6c 75 65 50 61 each (KeyValuePa
21c0: 69 72 3c 73 74 72 69 6e 67 2c 20 53 51 4c 69 74 ir<string, SQLit
21d0: 65 4d 6f 64 75 6c 65 3e 20 70 61 69 72 20 69 6e eModule> pair in
21e0: 20 5f 6d 6f 64 75 6c 65 73 29 0d 0a 20 20 20 20 _modules)..
21f0: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
2200: 20 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 SQLit
2210: 65 4d 6f 64 75 6c 65 20 6d 6f 64 75 6c 65 20 3d eModule module =
2220: 20 70 61 69 72 2e 56 61 6c 75 65 3b 0d 0a 0d 0a pair.Value;....
2230: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2240: 69 66 20 28 6d 6f 64 75 6c 65 20 3d 3d 20 6e 75 if (module == nu
2250: 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ll)..
2260: 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 continu
2270: 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 e;....
2280: 20 20 20 20 20 20 6d 6f 64 75 6c 65 2e 44 69 73 module.Dis
2290: 70 6f 73 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 pose();..
22a0: 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 }....
22b0: 20 20 20 20 20 20 5f 6d 6f 64 75 6c 65 73 2e 43 _modules.C
22c0: 6c 65 61 72 28 29 3b 0d 0a 20 20 20 20 20 20 20 lear();..
22d0: 20 7d 0d 0a 20 20 20 20 7d 0d 0a 23 65 6e 64 69 }.. }..#endi
22e0: 66 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f f.... ///////
22f0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2300: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2310: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2320: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2330: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
2340: 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 ////////....
2350: 2f 2f 20 49 74 20 69 73 6e 27 74 20 6e 65 63 65 // It isn't nece
2360: 73 73 61 72 79 20 74 6f 20 63 6c 65 61 6e 75 70 ssary to cleanup
2370: 20 61 6e 79 20 66 75 6e 63 74 69 6f 6e 73 20 77 any functions w
2380: 65 27 76 65 20 72 65 67 69 73 74 65 72 65 64 2e e've registered.
2390: 20 20 49 66 20 74 68 65 20 63 6f 6e 6e 65 63 74 If the connect
23a0: 69 6f 6e 0d 0a 20 20 20 20 2f 2f 20 67 6f 65 73 ion.. // goes
23b0: 20 74 6f 20 74 68 65 20 70 6f 6f 6c 20 61 6e 64 to the pool and
23c0: 20 69 73 20 72 65 73 75 72 72 65 63 74 65 64 20 is resurrected
23d0: 6c 61 74 65 72 2c 20 72 65 2d 72 65 67 69 73 74 later, re-regist
23e0: 65 72 65 64 20 66 75 6e 63 74 69 6f 6e 73 20 77 ered functions w
23f0: 69 6c 6c 20 6f 76 65 72 77 72 69 74 65 20 74 68 ill overwrite th
2400: 65 0d 0a 20 20 20 20 2f 2f 20 70 72 65 76 69 6f e.. // previo
2410: 75 73 20 66 75 6e 63 74 69 6f 6e 73 2e 20 20 54 us functions. T
2420: 68 65 20 53 51 4c 69 74 65 46 75 6e 63 74 69 6f he SQLiteFunctio
2430: 6e 43 6f 6f 6b 69 65 48 61 6e 64 6c 65 20 77 69 nCookieHandle wi
2440: 6c 6c 20 74 61 6b 65 20 63 61 72 65 20 6f 66 20 ll take care of
2450: 66 72 65 65 69 6e 67 20 75 6e 6d 61 6e 61 67 65 freeing unmanage
2460: 64 0d 0a 20 20 20 20 2f 2f 20 72 65 73 6f 75 72 d.. // resour
2470: 63 65 73 20 62 65 6c 6f 6e 67 69 6e 67 20 74 6f ces belonging to
2480: 20 74 68 65 20 70 72 65 76 69 6f 75 73 6c 79 2d the previously-
2490: 72 65 67 69 73 74 65 72 65 64 20 66 75 6e 63 74 registered funct
24a0: 69 6f 6e 73 2e 0d 0a 20 20 20 20 69 6e 74 65 72 ions... inter
24b0: 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f 69 nal override voi
24c0: 64 20 43 6c 6f 73 65 28 62 6f 6f 6c 20 64 69 73 d Close(bool dis
24d0: 70 6f 73 69 6e 67 29 0d 0a 20 20 20 20 7b 0d 0a posing).. {..
24e0: 20 20 20 20 20 20 69 66 20 28 5f 73 71 6c 20 21 if (_sql !
24f0: 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 7b = null).. {
2500: 0d 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 28 .. if (
2510: 21 5f 73 71 6c 2e 4f 77 6e 48 61 6e 64 6c 65 29 !_sql.OwnHandle)
2520: 0d 0a 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 .. {..
2530: 20 20 20 20 20 20 20 20 20 20 20 20 20 5f 73 71 _sq
2540: 6c 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 l = null;..
2550: 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b return;
2560: 0d 0a 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d .. }...
2570: 0a 20 20 20 20 20 20 20 20 20 20 62 6f 6f 6c 20 . bool
2580: 75 6e 62 69 6e 64 46 75 6e 63 74 69 6f 6e 73 20 unbindFunctions
2590: 3d 20 28 28 5f 66 6c 61 67 73 20 26 20 53 51 4c = ((_flags & SQL
25a0: 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 iteConnectionFla
25b0: 67 73 2e 55 6e 62 69 6e 64 46 75 6e 63 74 69 6f gs.UnbindFunctio
25c0: 6e 73 4f 6e 43 6c 6f 73 65 29 0d 0a 20 20 20 20 nsOnClose)..
25d0: 20 20 20 20 20 20 20 20 20 20 20 20 3d 3d 20 53 == S
25e0: 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 QLiteConnectionF
25f0: 6c 61 67 73 2e 55 6e 62 69 6e 64 46 75 6e 63 74 lags.UnbindFunct
2600: 69 6f 6e 73 4f 6e 43 6c 6f 73 65 29 3b 0d 0a 0d ionsOnClose);...
2610: 0a 20 20 20 20 20 20 72 65 74 72 79 3a 0d 0a 0d . retry:...
2620: 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 28 5f . if (_
2630: 75 73 65 50 6f 6f 6c 29 0d 0a 20 20 20 20 20 20 usePool)..
2640: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
2650: 20 20 20 20 20 69 66 20 28 53 51 4c 69 74 65 42 if (SQLiteB
2660: 61 73 65 2e 52 65 73 65 74 43 6f 6e 6e 65 63 74 ase.ResetConnect
2670: 69 6f 6e 28 5f 73 71 6c 2c 20 5f 73 71 6c 2c 20 ion(_sql, _sql,
2680: 21 64 69 73 70 6f 73 69 6e 67 29 20 26 26 0d 0a !disposing) &&..
2690: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
26a0: 20 20 55 6e 68 6f 6f 6b 4e 61 74 69 76 65 43 61 UnhookNativeCa
26b0: 6c 6c 62 61 63 6b 73 28 74 72 75 65 2c 20 21 64 llbacks(true, !d
26c0: 69 73 70 6f 73 69 6e 67 29 29 0d 0a 20 20 20 20 isposing))..
26d0: 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
26e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 i
26f0: 66 20 28 75 6e 62 69 6e 64 46 75 6e 63 74 69 6f f (unbindFunctio
2700: 6e 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ns)..
2710: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
2720: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2730: 69 66 20 28 53 51 4c 69 74 65 46 75 6e 63 74 69 if (SQLiteFuncti
2740: 6f 6e 2e 55 6e 62 69 6e 64 41 6c 6c 46 75 6e 63 on.UnbindAllFunc
2750: 74 69 6f 6e 73 28 74 68 69 73 2c 20 5f 66 6c 61 tions(this, _fla
2760: 67 73 2c 20 66 61 6c 73 65 29 29 0d 0a 20 20 20 gs, false))..
2770: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2780: 20 20 20 7b 0d 0a 23 69 66 20 21 4e 45 54 5f 43 {..#if !NET_C
2790: 4f 4d 50 41 43 54 5f 32 30 20 26 26 20 54 52 41 OMPACT_20 && TRA
27a0: 43 45 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 CE_CONNECTION..
27b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
27c0: 20 20 20 20 20 20 20 20 20 54 72 61 63 65 2e 57 Trace.W
27d0: 72 69 74 65 4c 69 6e 65 28 48 65 6c 70 65 72 4d riteLine(HelperM
27e0: 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 ethods.StringFor
27f0: 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 mat(..
2800: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2810: 20 20 20 20 43 75 6c 74 75 72 65 49 6e 66 6f 2e CultureInfo.
2820: 43 75 72 72 65 6e 74 43 75 6c 74 75 72 65 2c 0d CurrentCulture,.
2830: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
2840: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 "
2850: 55 6e 62 69 6e 64 46 75 6e 63 74 69 6f 6e 73 20 UnbindFunctions
2860: 28 50 6f 6f 6c 29 20 53 75 63 63 65 73 73 3a 20 (Pool) Success:
2870: 7b 30 7d 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 {0}",..
2880: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2890: 20 20 20 20 20 48 61 6e 64 6c 65 54 6f 53 74 72 HandleToStr
28a0: 69 6e 67 28 29 29 29 3b 0d 0a 23 65 6e 64 69 66 ing()));..#endif
28b0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
28c0: 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
28d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
28e0: 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 else..
28f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a {..
2900: 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 43 54 #if !NET_COMPACT
2910: 5f 32 30 20 26 26 20 54 52 41 43 45 5f 43 4f 4e _20 && TRACE_CON
2920: 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 20 20 20 NECTION..
2930: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2940: 20 20 20 54 72 61 63 65 2e 57 72 69 74 65 4c 69 Trace.WriteLi
2950: 6e 65 28 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 ne(HelperMethods
2960: 2e 53 74 72 69 6e 67 46 6f 72 6d 61 74 28 0d 0a .StringFormat(..
2970: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2980: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 43 75 Cu
2990: 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e ltureInfo.Curren
29a0: 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 tCulture,..
29b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
29c0: 20 20 20 20 20 20 20 20 20 22 55 6e 62 69 6e 64 "Unbind
29d0: 46 75 6e 63 74 69 6f 6e 73 20 28 50 6f 6f 6c 29 Functions (Pool)
29e0: 20 46 61 69 6c 75 72 65 3a 20 7b 30 7d 22 2c 0d Failure: {0}",.
29f0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
2a00: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 48 H
2a10: 61 6e 64 6c 65 54 6f 53 74 72 69 6e 67 28 29 29 andleToString())
2a20: 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 );..#endif..
2a30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2a40: 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 }..
2a50: 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 23 69 66 20 }....#if
2a60: 49 4e 54 45 52 4f 50 5f 56 49 52 54 55 41 4c 5f INTEROP_VIRTUAL_
2a70: 54 41 42 4c 45 0d 0a 20 20 20 20 20 20 20 20 20 TABLE..
2a80: 20 20 20 20 20 20 20 20 20 44 69 73 70 6f 73 65 Dispose
2a90: 4d 6f 64 75 6c 65 73 28 29 3b 0d 0a 23 65 6e 64 Modules();..#end
2aa0: 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 if....
2ab0: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 43 6f SQLiteCo
2ac0: 6e 6e 65 63 74 69 6f 6e 50 6f 6f 6c 2e 41 64 64 nnectionPool.Add
2ad0: 28 5f 66 69 6c 65 4e 61 6d 65 2c 20 5f 73 71 6c (_fileName, _sql
2ae0: 2c 20 5f 70 6f 6f 6c 56 65 72 73 69 6f 6e 29 3b , _poolVersion);
2af0: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ....
2b00: 20 20 20 20 20 20 53 51 4c 69 74 65 43 6f 6e 6e SQLiteConn
2b10: 65 63 74 69 6f 6e 2e 4f 6e 43 68 61 6e 67 65 64 ection.OnChanged
2b20: 28 6e 75 6c 6c 2c 20 6e 65 77 20 43 6f 6e 6e 65 (null, new Conne
2b30: 63 74 69 6f 6e 45 76 65 6e 74 41 72 67 73 28 0d ctionEventArgs(.
2b40: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
2b50: 20 20 20 20 20 20 20 53 51 4c 69 74 65 43 6f 6e SQLiteCon
2b60: 6e 65 63 74 69 6f 6e 45 76 65 6e 74 54 79 70 65 nectionEventType
2b70: 2e 43 6c 6f 73 65 64 54 6f 50 6f 6f 6c 2c 20 6e .ClosedToPool, n
2b80: 75 6c 6c 2c 20 6e 75 6c 6c 2c 0d 0a 20 20 20 20 ull, null,..
2b90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2ba0: 20 20 6e 75 6c 6c 2c 20 6e 75 6c 6c 2c 20 5f 73 null, null, _s
2bb0: 71 6c 2c 20 5f 66 69 6c 65 4e 61 6d 65 2c 20 6e ql, _fileName, n
2bc0: 65 77 20 6f 62 6a 65 63 74 5b 5d 20 7b 0d 0a 20 ew object[] {..
2bd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2be0: 20 20 20 20 20 74 79 70 65 6f 66 28 53 51 4c 69 typeof(SQLi
2bf0: 74 65 33 29 2c 20 21 64 69 73 70 6f 73 69 6e 67 te3), !disposing
2c00: 2c 20 5f 66 69 6c 65 4e 61 6d 65 2c 20 5f 70 6f , _fileName, _po
2c10: 6f 6c 56 65 72 73 69 6f 6e 20 7d 29 29 3b 0d 0a olVersion }));..
2c20: 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 ..#if !NET_COMPA
2c30: 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f 43 CT_20 && TRACE_C
2c40: 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 20 ONNECTION..
2c50: 20 20 20 20 20 20 20 20 20 20 20 20 20 54 72 61 Tra
2c60: 63 65 2e 57 72 69 74 65 4c 69 6e 65 28 48 65 6c ce.WriteLine(Hel
2c70: 70 65 72 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e perMethods.Strin
2c80: 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 gFormat(..
2c90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2ca0: 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 CultureInfo.Curr
2cb0: 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 entCulture,..
2cc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2cd0: 20 20 20 22 43 6c 6f 73 65 20 28 50 6f 6f 6c 29 "Close (Pool)
2ce0: 20 53 75 63 63 65 73 73 3a 20 7b 30 7d 22 2c 0d Success: {0}",.
2cf0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
2d00: 20 20 20 20 20 20 20 48 61 6e 64 6c 65 54 6f 53 HandleToS
2d10: 74 72 69 6e 67 28 29 29 29 3b 0d 0a 23 65 6e 64 tring()));..#end
2d20: 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 if..
2d30: 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 }..
2d40: 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 else..
2d50: 20 20 20 20 20 20 20 7b 0d 0a 23 69 66 20 21 4e {..#if !N
2d60: 45 54 5f 43 4f 4d 50 41 43 54 5f 32 30 20 26 26 ET_COMPACT_20 &&
2d70: 20 54 52 41 43 45 5f 43 4f 4e 4e 45 43 54 49 4f TRACE_CONNECTIO
2d80: 4e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 N..
2d90: 20 20 20 20 20 54 72 61 63 65 2e 57 72 69 74 65 Trace.Write
2da0: 4c 69 6e 65 28 48 65 6c 70 65 72 4d 65 74 68 6f Line(HelperMetho
2db0: 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d 61 74 28 ds.StringFormat(
2dc0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
2dd0: 20 20 20 20 20 20 20 20 43 75 6c 74 75 72 65 49 CultureI
2de0: 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c 74 75 nfo.CurrentCultu
2df0: 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 re,..
2e00: 20 20 20 20 20 20 20 20 20 20 20 22 43 6c 6f 73 "Clos
2e10: 65 20 28 50 6f 6f 6c 29 20 46 61 69 6c 75 72 65 e (Pool) Failure
2e20: 3a 20 7b 30 7d 22 2c 0d 0a 20 20 20 20 20 20 20 : {0}",..
2e30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 48 H
2e40: 61 6e 64 6c 65 54 6f 53 74 72 69 6e 67 28 29 29 andleToString())
2e50: 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 );..#endif....
2e60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2e70: 2f 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 //..
2e80: 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 54 // NOTE: T
2e90: 68 69 73 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 63 his connection c
2ea0: 61 6e 6e 6f 74 20 62 65 20 61 64 64 65 64 20 74 annot be added t
2eb0: 6f 20 74 68 65 20 70 6f 6f 6c 3b 0d 0a 20 20 20 o the pool;..
2ec0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f /
2ed0: 2f 20 20 20 20 20 20 20 74 68 65 72 65 66 6f 72 / therefor
2ee0: 65 2c 20 6a 75 73 74 20 75 73 65 20 74 68 65 20 e, just use the
2ef0: 6e 6f 72 6d 61 6c 20 64 69 73 70 6f 73 61 6c 0d normal disposal.
2f00: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
2f10: 20 20 20 2f 2f 20 20 20 20 20 20 20 70 72 6f 63 // proc
2f20: 65 64 75 72 65 20 6f 6e 20 69 74 2e 0d 0a 20 20 edure on it...
2f30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2f40: 2f 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 //..
2f50: 20 20 20 20 20 20 5f 75 73 65 50 6f 6f 6c 20 3d _usePool =
2f60: 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 20 false;..
2f70: 20 20 20 20 20 20 20 20 20 20 20 67 6f 74 6f 20 goto
2f80: 72 65 74 72 79 3b 0d 0a 20 20 20 20 20 20 20 20 retry;..
2f90: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
2fa0: 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 }..
2fb0: 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 else..
2fc0: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 {..
2fd0: 20 2f 2a 20 49 47 4e 4f 52 45 44 20 2a 2f 0d 0a /* IGNORED */..
2fe0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 55 6e Un
2ff0: 68 6f 6f 6b 4e 61 74 69 76 65 43 61 6c 6c 62 61 hookNativeCallba
3000: 63 6b 73 28 64 69 73 70 6f 73 69 6e 67 2c 20 21 cks(disposing, !
3010: 64 69 73 70 6f 73 69 6e 67 29 3b 0d 0a 0d 0a 20 disposing);....
3020: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 if
3030: 28 75 6e 62 69 6e 64 46 75 6e 63 74 69 6f 6e 73 (unbindFunctions
3040: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )..
3050: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
3060: 20 20 20 20 20 20 69 66 20 28 53 51 4c 69 74 65 if (SQLite
3070: 46 75 6e 63 74 69 6f 6e 2e 55 6e 62 69 6e 64 41 Function.UnbindA
3080: 6c 6c 46 75 6e 63 74 69 6f 6e 73 28 74 68 69 73 llFunctions(this
3090: 2c 20 5f 66 6c 61 67 73 2c 20 66 61 6c 73 65 29 , _flags, false)
30a0: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )..
30b0: 20 20 20 20 20 7b 0d 0a 23 69 66 20 21 4e 45 54 {..#if !NET
30c0: 5f 43 4f 4d 50 41 43 54 5f 32 30 20 26 26 20 54 _COMPACT_20 && T
30d0: 52 41 43 45 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d RACE_CONNECTION.
30e0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
30f0: 20 20 20 20 20 20 20 54 72 61 63 65 2e 57 72 69 Trace.Wri
3100: 74 65 4c 69 6e 65 28 48 65 6c 70 65 72 4d 65 74 teLine(HelperMet
3110: 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d 61 hods.StringForma
3120: 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 t(..
3130: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 43 75 Cu
3140: 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e ltureInfo.Curren
3150: 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 tCulture,..
3160: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3170: 20 20 20 20 20 22 55 6e 62 69 6e 64 46 75 6e 63 "UnbindFunc
3180: 74 69 6f 6e 73 20 53 75 63 63 65 73 73 3a 20 7b tions Success: {
3190: 30 7d 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 0}",..
31a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
31b0: 48 61 6e 64 6c 65 54 6f 53 74 72 69 6e 67 28 29 HandleToString()
31c0: 29 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 ));..#endif..
31d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d }
31e0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
31f0: 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 else..
3200: 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 23 {..#
3210: 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 43 54 5f if !NET_COMPACT_
3220: 32 30 20 26 26 20 54 52 41 43 45 5f 43 4f 4e 4e 20 && TRACE_CONN
3230: 45 43 54 49 4f 4e 0d 0a 20 20 20 20 20 20 20 20 ECTION..
3240: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 54 72 Tr
3250: 61 63 65 2e 57 72 69 74 65 4c 69 6e 65 28 48 65 ace.WriteLine(He
3260: 6c 70 65 72 4d 65 74 68 6f 64 73 2e 53 74 72 69 lperMethods.Stri
3270: 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 ngFormat(..
3280: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3290: 20 20 20 20 20 43 75 6c 74 75 72 65 49 6e 66 6f CultureInfo
32a0: 2e 43 75 72 72 65 6e 74 43 75 6c 74 75 72 65 2c .CurrentCulture,
32b0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
32c0: 20 20 20 20 20 20 20 20 20 20 20 20 22 55 6e 62 "Unb
32d0: 69 6e 64 46 75 6e 63 74 69 6f 6e 73 20 46 61 69 indFunctions Fai
32e0: 6c 75 72 65 3a 20 7b 30 7d 22 2c 0d 0a 20 20 20 lure: {0}",..
32f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3300: 20 20 20 20 20 20 20 48 61 6e 64 6c 65 54 6f 53 HandleToS
3310: 74 72 69 6e 67 28 29 29 29 3b 0d 0a 23 65 6e 64 tring()));..#end
3320: 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 if..
3330: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
3340: 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 }....
3350: 20 20 20 20 20 20 20 20 20 20 5f 73 71 6c 2e 44 _sql.D
3360: 69 73 70 6f 73 65 28 29 3b 0d 0a 0d 0a 20 20 20 ispose();....
3370: 20 20 20 20 20 20 20 20 20 20 20 46 72 65 65 44 FreeD
3380: 62 4e 61 6d 65 28 21 64 69 73 70 6f 73 69 6e 67 bName(!disposing
3390: 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 7d 0d );.. }.
33a0: 0a 20 20 20 20 20 20 20 20 20 20 5f 73 71 6c 20 . _sql
33b0: 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 7d = null;.. }
33c0: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f .. }.... /
33d0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
33e0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 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 0d 0a //////////////..
3430: 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 ..#if !NET_COMPA
3440: 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f 43 CT_20 && TRACE_C
3450: 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 70 ONNECTION.. p
3460: 72 6f 74 65 63 74 65 64 20 73 74 72 69 6e 67 20 rotected string
3470: 48 61 6e 64 6c 65 54 6f 53 74 72 69 6e 67 28 29 HandleToString()
3480: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
3490: 20 69 66 20 28 5f 73 71 6c 20 3d 3d 20 6e 75 6c if (_sql == nul
34a0: 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 l)..
34b0: 72 65 74 75 72 6e 20 22 3c 6e 75 6c 6c 3e 22 3b return "<null>";
34c0: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 .... retu
34d0: 72 6e 20 5f 73 71 6c 2e 54 6f 53 74 72 69 6e 67 rn _sql.ToString
34e0: 28 29 3b 0d 0a 20 20 20 20 7d 0d 0a 23 65 6e 64 ();.. }..#end
34f0: 69 66 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f if.... //////
3500: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3510: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3520: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3530: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3540: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3550: 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 /////////....
3560: 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
3570: 20 20 20 20 2f 2f 2f 20 52 65 74 75 72 6e 73 20 /// Returns
3580: 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 74 69 the number of ti
3590: 6d 65 73 20 74 68 65 20 3c 73 65 65 20 63 72 65 mes the <see cre
35a0: 66 3d 22 43 61 6e 63 65 6c 22 20 2f 3e 20 6d 65 f="Cancel" /> me
35b0: 74 68 6f 64 20 68 61 73 20 62 65 65 6e 0d 0a 20 thod has been..
35c0: 20 20 20 2f 2f 2f 20 63 61 6c 6c 65 64 2e 0d 0a /// called...
35d0: 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 /// </summar
35e0: 79 3e 0d 0a 20 20 20 20 70 72 69 76 61 74 65 20 y>.. private
35f0: 69 6e 74 20 47 65 74 43 61 6e 63 65 6c 43 6f 75 int GetCancelCou
3600: 6e 74 28 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 nt().. {..
3610: 20 20 20 20 20 72 65 74 75 72 6e 20 49 6e 74 65 return Inte
3620: 72 6c 6f 63 6b 65 64 2e 43 6f 6d 70 61 72 65 45 rlocked.CompareE
3630: 78 63 68 61 6e 67 65 28 72 65 66 20 5f 63 61 6e xchange(ref _can
3640: 63 65 6c 43 6f 75 6e 74 2c 20 30 2c 20 30 29 3b celCount, 0, 0);
3650: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f .. }.... /
3660: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3670: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3680: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3690: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
36a0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
36b0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a //////////////..
36c0: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 .. /// <summa
36d0: 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 69 ry>.. /// Thi
36e0: 73 20 6d 65 74 68 6f 64 20 64 65 74 65 72 6d 69 s method determi
36f0: 6e 65 73 20 77 68 65 74 68 65 72 20 6f 72 20 6e nes whether or n
3700: 6f 74 20 61 20 3c 73 65 65 20 63 72 65 66 3d 22 ot a <see cref="
3710: 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 22 SQLiteException"
3720: 20 2f 3e 0d 0a 20 20 20 20 2f 2f 2f 20 77 69 74 />.. /// wit
3730: 68 20 61 20 72 65 74 75 72 6e 20 63 6f 64 65 20 h a return code
3740: 6f 66 20 3c 73 65 65 20 63 72 65 66 3d 22 53 51 of <see cref="SQ
3750: 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 49 6e LiteErrorCode.In
3760: 74 65 72 72 75 70 74 22 20 2f 3e 20 73 68 6f 75 terrupt" /> shou
3770: 6c 64 0d 0a 20 20 20 20 2f 2f 2f 20 62 65 20 74 ld.. /// be t
3780: 68 72 6f 77 6e 20 61 66 74 65 72 20 6d 61 6b 69 hrown after maki
3790: 6e 67 20 61 20 63 61 6c 6c 20 69 6e 74 6f 20 74 ng a call into t
37a0: 68 65 20 53 51 4c 69 74 65 20 63 6f 72 65 20 6c he SQLite core l
37b0: 69 62 72 61 72 79 2e 0d 0a 20 20 20 20 2f 2f 2f ibrary... ///
37c0: 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 </summary>..
37d0: 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 0d 0a /// <returns>..
37e0: 20 20 20 20 2f 2f 2f 20 4e 6f 6e 2d 7a 65 72 6f /// Non-zero
37f0: 20 69 66 20 61 20 3c 73 65 65 20 63 72 65 66 3d if a <see cref=
3800: 22 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e "SQLiteException
3810: 22 20 2f 3e 20 74 6f 20 62 65 20 74 68 72 6f 77 " /> to be throw
3820: 6e 2e 20 20 54 68 69 73 20 6d 65 74 68 6f 64 0d n. This method.
3830: 0a 20 20 20 20 2f 2f 2f 20 77 69 6c 6c 20 6f 6e . /// will on
3840: 6c 79 20 72 65 74 75 72 6e 20 6e 6f 6e 2d 7a 65 ly return non-ze
3850: 72 6f 20 69 66 20 74 68 65 20 3c 73 65 65 20 63 ro if the <see c
3860: 72 65 66 3d 22 43 61 6e 63 65 6c 22 20 2f 3e 20 ref="Cancel" />
3870: 6d 65 74 68 6f 64 20 77 61 73 20 63 61 6c 6c 65 method was calle
3880: 64 0d 0a 20 20 20 20 2f 2f 2f 20 6f 6e 65 20 6f d.. /// one o
3890: 72 20 6d 6f 72 65 20 74 69 6d 65 73 20 64 75 72 r more times dur
38a0: 69 6e 67 20 61 20 63 61 6c 6c 20 69 6e 74 6f 20 ing a call into
38b0: 74 68 65 20 53 51 4c 69 74 65 20 63 6f 72 65 20 the SQLite core
38c0: 6c 69 62 72 61 72 79 20 28 65 2e 67 2e 20 77 68 library (e.g. wh
38d0: 65 6e 0d 0a 20 20 20 20 2f 2f 2f 20 74 68 65 20 en.. /// the
38e0: 73 71 6c 69 74 65 33 5f 70 72 65 70 61 72 65 2a sqlite3_prepare*
38f0: 28 29 20 6f 72 20 73 71 6c 69 74 65 33 5f 73 74 () or sqlite3_st
3900: 65 70 28 29 20 41 50 49 73 20 61 72 65 20 75 73 ep() APIs are us
3910: 65 64 29 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ed)... /// </
3920: 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 70 72 returns>.. pr
3930: 69 76 61 74 65 20 62 6f 6f 6c 20 53 68 6f 75 6c ivate bool Shoul
3940: 64 54 68 72 6f 77 46 6f 72 43 61 6e 63 65 6c 28 dThrowForCancel(
3950: 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
3960: 20 20 72 65 74 75 72 6e 20 47 65 74 43 61 6e 63 return GetCanc
3970: 65 6c 43 6f 75 6e 74 28 29 20 3e 20 30 3b 0d 0a elCount() > 0;..
3980: 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f }.... ///
3990: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
39a0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
39b0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
39c0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
39d0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
39e0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a ////////////....
39f0: 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 /// <summary
3a00: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 52 65 73 65 74 >.. /// Reset
3a10: 73 20 74 68 65 20 76 61 6c 75 65 20 6f 66 20 74 s the value of t
3a20: 68 65 20 3c 73 65 65 20 63 72 65 66 3d 22 5f 63 he <see cref="_c
3a30: 61 6e 63 65 6c 43 6f 75 6e 74 22 20 2f 3e 20 66 ancelCount" /> f
3a40: 69 65 6c 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c ield... /// <
3a50: 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 70 /summary>.. p
3a60: 72 69 76 61 74 65 20 69 6e 74 20 52 65 73 65 74 rivate int Reset
3a70: 43 61 6e 63 65 6c 43 6f 75 6e 74 28 29 0d 0a 20 CancelCount()..
3a80: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 72 65 {.. re
3a90: 74 75 72 6e 20 49 6e 74 65 72 6c 6f 63 6b 65 64 turn Interlocked
3aa0: 2e 43 6f 6d 70 61 72 65 45 78 63 68 61 6e 67 65 .CompareExchange
3ab0: 28 72 65 66 20 5f 63 61 6e 63 65 6c 43 6f 75 6e (ref _cancelCoun
3ac0: 74 2c 20 30 2c 20 5f 63 61 6e 63 65 6c 43 6f 75 t, 0, _cancelCou
3ad0: 6e 74 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 nt);.. }....
3ae0: 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f /////////////
3af0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3b00: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3b10: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3b20: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3b30: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
3b40: 2f 2f 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 //.... /// <s
3b50: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
3b60: 20 41 74 74 65 6d 70 74 73 20 74 6f 20 69 6e 74 Attempts to int
3b70: 65 72 72 75 70 74 20 74 68 65 20 71 75 65 72 79 errupt the query
3b80: 20 63 75 72 72 65 6e 74 6c 79 20 65 78 65 63 75 currently execu
3b90: 74 69 6e 67 20 6f 6e 20 74 68 65 20 61 73 73 6f ting on the asso
3ba0: 63 69 61 74 65 64 0d 0a 20 20 20 20 2f 2f 2f 20 ciated.. ///
3bb0: 6e 61 74 69 76 65 20 64 61 74 61 62 61 73 65 20 native database
3bc0: 63 6f 6e 6e 65 63 74 69 6f 6e 2e 0d 0a 20 20 20 connection...
3bd0: 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d /// </summary>.
3be0: 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
3bf0: 65 72 72 69 64 65 20 76 6f 69 64 20 43 61 6e 63 erride void Canc
3c00: 65 6c 28 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 el().. {..
3c10: 20 20 20 74 72 79 0d 0a 20 20 20 20 20 20 7b 0d try.. {.
3c20: 0a 20 20 20 20 20 20 20 20 2f 2f 20 64 6f 20 6e . // do n
3c30: 6f 74 68 69 6e 67 2e 0d 0a 20 20 20 20 20 20 7d othing... }
3c40: 0d 0a 20 20 20 20 20 20 66 69 6e 61 6c 6c 79 20 .. finally
3c50: 2f 2a 20 4e 4f 54 45 3a 20 54 68 72 65 61 64 2e /* NOTE: Thread.
3c60: 41 62 6f 72 74 28 29 20 70 72 6f 74 65 63 74 69 Abort() protecti
3c70: 6f 6e 2e 20 2a 2f 0d 0a 20 20 20 20 20 20 7b 0d on. */.. {.
3c80: 0a 20 20 20 20 20 20 20 20 49 6e 74 65 72 6c 6f . Interlo
3c90: 63 6b 65 64 2e 49 6e 63 72 65 6d 65 6e 74 28 72 cked.Increment(r
3ca0: 65 66 20 5f 63 61 6e 63 65 6c 43 6f 75 6e 74 29 ef _cancelCount)
3cb0: 3b 0d 0a 20 20 20 20 20 20 20 20 55 6e 73 61 66 ;.. Unsaf
3cc0: 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
3cd0: 71 6c 69 74 65 33 5f 69 6e 74 65 72 72 75 70 74 qlite3_interrupt
3ce0: 28 5f 73 71 6c 29 3b 0d 0a 20 20 20 20 20 20 7d (_sql);.. }
3cf0: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f .. }.... /
3d00: 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 // <summary>..
3d10: 20 20 2f 2f 2f 20 54 68 69 73 20 66 75 6e 63 74 /// This funct
3d20: 69 6f 6e 20 62 69 6e 64 73 20 61 20 75 73 65 72 ion binds a user
3d30: 2d 64 65 66 69 6e 65 64 20 66 75 6e 63 74 69 6f -defined functio
3d40: 6e 20 74 6f 20 74 68 65 20 63 6f 6e 6e 65 63 74 n to the connect
3d50: 69 6f 6e 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ion... /// </
3d60: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
3d70: 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 66 / <param name="f
3d80: 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 65 unctionAttribute
3d90: 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 ">.. /// The
3da0: 3c 73 65 65 20 63 72 65 66 3d 22 53 51 4c 69 74 <see cref="SQLit
3db0: 65 46 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 eFunctionAttribu
3dc0: 74 65 22 2f 3e 20 6f 62 6a 65 63 74 20 69 6e 73 te"/> object ins
3dd0: 74 61 6e 63 65 20 63 6f 6e 74 61 69 6e 69 6e 67 tance containing
3de0: 0d 0a 20 20 20 20 2f 2f 2f 20 74 68 65 20 6d 65 .. /// the me
3df0: 74 61 64 61 74 61 20 66 6f 72 20 74 68 65 20 66 tadata for the f
3e00: 75 6e 63 74 69 6f 6e 20 74 6f 20 62 65 20 62 6f unction to be bo
3e10: 75 6e 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f und... /// </
3e20: 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 param>.. ///
3e30: 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 66 75 6e <param name="fun
3e40: 63 74 69 6f 6e 22 3e 0d 0a 20 20 20 20 2f 2f 2f ction">.. ///
3e50: 20 54 68 65 20 3c 73 65 65 20 63 72 65 66 3d 22 The <see cref="
3e60: 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 22 2f SQLiteFunction"/
3e70: 3e 20 6f 62 6a 65 63 74 20 69 6e 73 74 61 6e 63 > object instanc
3e80: 65 20 74 68 61 74 20 69 6d 70 6c 65 6d 65 6e 74 e that implement
3e90: 73 20 74 68 65 0d 0a 20 20 20 20 2f 2f 2f 20 66 s the.. /// f
3ea0: 75 6e 63 74 69 6f 6e 20 74 6f 20 62 65 20 62 6f unction to be bo
3eb0: 75 6e 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f und... /// </
3ec0: 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 param>.. ///
3ed0: 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 66 6c 61 <param name="fla
3ee0: 67 73 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 gs">.. /// Th
3ef0: 65 20 66 6c 61 67 73 20 61 73 73 6f 63 69 61 74 e flags associat
3f00: 65 64 20 77 69 74 68 20 74 68 65 20 70 61 72 65 ed with the pare
3f10: 6e 74 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 6f 62 nt connection ob
3f20: 6a 65 63 74 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c ject... /// <
3f30: 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 69 6e 74 /param>.. int
3f40: 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 ernal override v
3f50: 6f 69 64 20 42 69 6e 64 46 75 6e 63 74 69 6f 6e oid BindFunction
3f60: 28 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 (.. SQLit
3f70: 65 46 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 eFunctionAttribu
3f80: 74 65 20 66 75 6e 63 74 69 6f 6e 41 74 74 72 69 te functionAttri
3f90: 62 75 74 65 2c 0d 0a 20 20 20 20 20 20 20 20 53 bute,.. S
3fa0: 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 20 66 75 QLiteFunction fu
3fb0: 6e 63 74 69 6f 6e 2c 0d 0a 20 20 20 20 20 20 20 nction,..
3fc0: 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f SQLiteConnectio
3fd0: 6e 46 6c 61 67 73 20 66 6c 61 67 73 0d 0a 20 20 nFlags flags..
3fe0: 20 20 20 20 20 20 29 0d 0a 20 20 20 20 7b 0d 0a ).. {..
3ff0: 20 20 20 20 20 20 20 20 69 66 20 28 66 75 6e 63 if (func
4000: 74 69 6f 6e 41 74 74 72 69 62 75 74 65 20 3d 3d tionAttribute ==
4010: 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 null)..
4020: 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 throw new Ar
4030: 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 gumentNullExcept
4040: 69 6f 6e 28 22 66 75 6e 63 74 69 6f 6e 41 74 74 ion("functionAtt
4050: 72 69 62 75 74 65 22 29 3b 0d 0a 0d 0a 20 20 20 ribute");....
4060: 20 20 20 20 20 69 66 20 28 66 75 6e 63 74 69 6f if (functio
4070: 6e 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 n == null)..
4080: 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 throw ne
4090: 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 w ArgumentNullEx
40a0: 63 65 70 74 69 6f 6e 28 22 66 75 6e 63 74 69 6f ception("functio
40b0: 6e 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 n");....
40c0: 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 2e 42 SQLiteFunction.B
40d0: 69 6e 64 46 75 6e 63 74 69 6f 6e 28 74 68 69 73 indFunction(this
40e0: 2c 20 66 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 , functionAttrib
40f0: 75 74 65 2c 20 66 75 6e 63 74 69 6f 6e 2c 20 66 ute, function, f
4100: 6c 61 67 73 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 lags);....
4110: 20 20 69 66 20 28 5f 66 75 6e 63 74 69 6f 6e 73 if (_functions
4120: 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 == null)..
4130: 20 20 20 20 20 20 20 5f 66 75 6e 63 74 69 6f 6e _function
4140: 73 20 3d 20 6e 65 77 20 44 69 63 74 69 6f 6e 61 s = new Dictiona
4150: 72 79 3c 53 51 4c 69 74 65 46 75 6e 63 74 69 6f ry<SQLiteFunctio
4160: 6e 41 74 74 72 69 62 75 74 65 2c 20 53 51 4c 69 nAttribute, SQLi
4170: 74 65 46 75 6e 63 74 69 6f 6e 3e 28 29 3b 0d 0a teFunction>();..
4180: 0d 0a 20 20 20 20 20 20 20 20 5f 66 75 6e 63 74 .. _funct
4190: 69 6f 6e 73 5b 66 75 6e 63 74 69 6f 6e 41 74 74 ions[functionAtt
41a0: 72 69 62 75 74 65 5d 20 3d 20 66 75 6e 63 74 69 ribute] = functi
41b0: 6f 6e 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 on;.. }....
41c0: 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d /// <summary>.
41d0: 0a 20 20 20 20 2f 2f 2f 20 54 68 69 73 20 66 75 . /// This fu
41e0: 6e 63 74 69 6f 6e 20 62 69 6e 64 73 20 61 20 75 nction binds a u
41f0: 73 65 72 2d 64 65 66 69 6e 65 64 20 66 75 6e 63 ser-defined func
4200: 74 69 6f 6e 20 74 6f 20 74 68 65 20 63 6f 6e 6e tion to the conn
4210: 65 63 74 69 6f 6e 2e 0d 0a 20 20 20 20 2f 2f 2f ection... ///
4220: 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 </summary>..
4230: 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 /// <param name
4240: 3d 22 66 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 ="functionAttrib
4250: 75 74 65 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 ute">.. /// T
4260: 68 65 20 3c 73 65 65 20 63 72 65 66 3d 22 53 51 he <see cref="SQ
4270: 4c 69 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 72 LiteFunctionAttr
4280: 69 62 75 74 65 22 2f 3e 20 6f 62 6a 65 63 74 20 ibute"/> object
4290: 69 6e 73 74 61 6e 63 65 20 63 6f 6e 74 61 69 6e instance contain
42a0: 69 6e 67 0d 0a 20 20 20 20 2f 2f 2f 20 74 68 65 ing.. /// the
42b0: 20 6d 65 74 61 64 61 74 61 20 66 6f 72 20 74 68 metadata for th
42c0: 65 20 66 75 6e 63 74 69 6f 6e 20 74 6f 20 62 65 e function to be
42d0: 20 75 6e 62 6f 75 6e 64 2e 0d 0a 20 20 20 20 2f unbound... /
42e0: 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 // </param>..
42f0: 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 /// <param name
4300: 3d 22 66 6c 61 67 73 22 3e 0d 0a 20 20 20 20 2f ="flags">.. /
4310: 2f 2f 20 54 68 65 20 66 6c 61 67 73 20 61 73 73 // The flags ass
4320: 6f 63 69 61 74 65 64 20 77 69 74 68 20 74 68 65 ociated with the
4330: 20 70 61 72 65 6e 74 20 63 6f 6e 6e 65 63 74 69 parent connecti
4340: 6f 6e 20 6f 62 6a 65 63 74 2e 0d 0a 20 20 20 20 on object...
4350: 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 /// </param>..
4360: 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 4e /// <returns>N
4370: 6f 6e 2d 7a 65 72 6f 20 69 66 20 74 68 65 20 66 on-zero if the f
4380: 75 6e 63 74 69 6f 6e 20 77 61 73 20 75 6e 62 6f unction was unbo
4390: 75 6e 64 20 61 6e 64 20 72 65 6d 6f 76 65 64 2e und and removed.
43a0: 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 </returns>..
43b0: 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 internal overrid
43c0: 65 20 62 6f 6f 6c 20 55 6e 62 69 6e 64 46 75 6e e bool UnbindFun
43d0: 63 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 20 ction(..
43e0: 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 41 74 SQLiteFunctionAt
43f0: 74 72 69 62 75 74 65 20 66 75 6e 63 74 69 6f 6e tribute function
4400: 41 74 74 72 69 62 75 74 65 2c 0d 0a 20 20 20 20 Attribute,..
4410: 20 20 20 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 SQLiteConnec
4420: 74 69 6f 6e 46 6c 61 67 73 20 66 6c 61 67 73 0d tionFlags flags.
4430: 0a 20 20 20 20 20 20 20 20 29 0d 0a 20 20 20 20 . )..
4440: 7b 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 66 {.. if (f
4450: 75 6e 63 74 69 6f 6e 41 74 74 72 69 62 75 74 65 unctionAttribute
4460: 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 == null)..
4470: 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 throw new
4480: 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 ArgumentNullExc
4490: 65 70 74 69 6f 6e 28 22 66 75 6e 63 74 69 6f 6e eption("function
44a0: 41 74 74 72 69 62 75 74 65 22 29 3b 0d 0a 0d 0a Attribute");....
44b0: 20 20 20 20 20 20 20 20 69 66 20 28 5f 66 75 6e if (_fun
44c0: 63 74 69 6f 6e 73 20 3d 3d 20 6e 75 6c 6c 29 0d ctions == null).
44d0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 . ret
44e0: 75 72 6e 20 66 61 6c 73 65 3b 0d 0a 0d 0a 20 20 urn false;....
44f0: 20 20 20 20 20 20 53 51 4c 69 74 65 46 75 6e 63 SQLiteFunc
4500: 74 69 6f 6e 20 66 75 6e 63 74 69 6f 6e 3b 0d 0a tion function;..
4510: 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 5f 66 .. if (_f
4520: 75 6e 63 74 69 6f 6e 73 2e 54 72 79 47 65 74 56 unctions.TryGetV
4530: 61 6c 75 65 28 66 75 6e 63 74 69 6f 6e 41 74 74 alue(functionAtt
4540: 72 69 62 75 74 65 2c 20 6f 75 74 20 66 75 6e 63 ribute, out func
4550: 74 69 6f 6e 29 29 0d 0a 20 20 20 20 20 20 20 20 tion))..
4560: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 {.. i
4570: 66 20 28 53 51 4c 69 74 65 46 75 6e 63 74 69 6f f (SQLiteFunctio
4580: 6e 2e 55 6e 62 69 6e 64 46 75 6e 63 74 69 6f 6e n.UnbindFunction
4590: 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 (..
45a0: 20 20 20 20 20 20 20 74 68 69 73 2c 20 66 75 6e this, fun
45b0: 63 74 69 6f 6e 41 74 74 72 69 62 75 74 65 2c 20 ctionAttribute,
45c0: 66 75 6e 63 74 69 6f 6e 2c 20 66 6c 61 67 73 29 function, flags)
45d0: 20 26 26 0d 0a 20 20 20 20 20 20 20 20 20 20 20 &&..
45e0: 20 20 20 20 20 5f 66 75 6e 63 74 69 6f 6e 73 2e _functions.
45f0: 52 65 6d 6f 76 65 28 66 75 6e 63 74 69 6f 6e 41 Remove(functionA
4600: 74 74 72 69 62 75 74 65 29 29 0d 0a 20 20 20 20 ttribute))..
4610: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
4620: 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 retur
4630: 6e 20 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 n true;..
4640: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
4650: 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 }.... ret
4660: 75 72 6e 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 urn false;..
4670: 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 }.... interna
4680: 6c 20 6f 76 65 72 72 69 64 65 20 73 74 72 69 6e l override strin
4690: 67 20 56 65 72 73 69 6f 6e 0d 0a 20 20 20 20 7b g Version.. {
46a0: 0d 0a 20 20 20 20 20 20 67 65 74 0d 0a 20 20 20 .. get..
46b0: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 72 65 {.. re
46c0: 74 75 72 6e 20 53 51 4c 69 74 65 56 65 72 73 69 turn SQLiteVersi
46d0: 6f 6e 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 on;.. }..
46e0: 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 }.... inter
46f0: 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 69 6e 74 nal override int
4700: 20 56 65 72 73 69 6f 6e 4e 75 6d 62 65 72 0d 0a VersionNumber..
4710: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 67 65 74 {.. get
4720: 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 .. {..
4730: 20 20 20 72 65 74 75 72 6e 20 53 51 4c 69 74 65 return SQLite
4740: 56 65 72 73 69 6f 6e 4e 75 6d 62 65 72 3b 0d 0a VersionNumber;..
4750: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a }.. }..
4760: 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 73 .. internal s
4770: 74 61 74 69 63 20 73 74 72 69 6e 67 20 44 65 66 tatic string Def
4780: 69 6e 65 43 6f 6e 73 74 61 6e 74 73 0d 0a 20 20 ineConstants..
4790: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 67 65 74 {.. get
47a0: 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 .. {..
47b0: 20 20 20 20 20 20 20 20 20 53 74 72 69 6e 67 42 StringB
47c0: 75 69 6c 64 65 72 20 72 65 73 75 6c 74 20 3d 20 uilder result =
47d0: 6e 65 77 20 53 74 72 69 6e 67 42 75 69 6c 64 65 new StringBuilde
47e0: 72 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 r();..
47f0: 20 20 49 4c 69 73 74 3c 73 74 72 69 6e 67 3e 20 IList<string>
4800: 6c 69 73 74 20 3d 20 53 51 4c 69 74 65 44 65 66 list = SQLiteDef
4810: 69 6e 65 43 6f 6e 73 74 61 6e 74 73 2e 4f 70 74 ineConstants.Opt
4820: 69 6f 6e 4c 69 73 74 3b 0d 0a 0d 0a 20 20 20 20 ionList;....
4830: 20 20 20 20 20 20 20 20 69 66 20 28 6c 69 73 74 if (list
4840: 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 != null)..
4850: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
4860: 20 20 20 20 20 20 20 20 20 20 66 6f 72 65 61 63 foreac
4870: 68 20 28 73 74 72 69 6e 67 20 65 6c 65 6d 65 6e h (string elemen
4880: 74 20 69 6e 20 6c 69 73 74 29 0d 0a 20 20 20 20 t in list)..
4890: 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 {..
48a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
48b0: 20 20 20 69 66 20 28 65 6c 65 6d 65 6e 74 20 3d if (element =
48c0: 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 = null)..
48d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
48e0: 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 continue;....
48f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4900: 20 20 69 66 20 28 72 65 73 75 6c 74 2e 4c 65 6e if (result.Len
4910: 67 74 68 20 3e 20 30 29 0d 0a 20 20 20 20 20 20 gth > 0)..
4920: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4930: 20 20 72 65 73 75 6c 74 2e 41 70 70 65 6e 64 28 result.Append(
4940: 27 20 27 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 ' ');....
4950: 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 73 res
4960: 75 6c 74 2e 41 70 70 65 6e 64 28 65 6c 65 6d 65 ult.Append(eleme
4970: 6e 74 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 nt);..
4980: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
4990: 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 }....
49a0: 20 20 20 20 20 20 72 65 74 75 72 6e 20 72 65 73 return res
49b0: 75 6c 74 2e 54 6f 53 74 72 69 6e 67 28 29 3b 0d ult.ToString();.
49c0: 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 . }..
49d0: 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 }.... interna
49e0: 6c 20 73 74 61 74 69 63 20 73 74 72 69 6e 67 20 l static string
49f0: 53 51 4c 69 74 65 56 65 72 73 69 6f 6e 0d 0a 20 SQLiteVersion..
4a00: 20 20 20 7b 0d 0a 20 20 20 20 20 20 67 65 74 0d {.. get.
4a10: 0a 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 . {..
4a20: 20 20 72 65 74 75 72 6e 20 55 54 46 38 54 6f 53 return UTF8ToS
4a30: 74 72 69 6e 67 28 55 6e 73 61 66 65 4e 61 74 69 tring(UnsafeNati
4a40: 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
4a50: 33 5f 6c 69 62 76 65 72 73 69 6f 6e 28 29 2c 20 3_libversion(),
4a60: 2d 31 29 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 -1);.. }..
4a70: 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 }.... inte
4a80: 72 6e 61 6c 20 73 74 61 74 69 63 20 69 6e 74 20 rnal static int
4a90: 53 51 4c 69 74 65 56 65 72 73 69 6f 6e 4e 75 6d SQLiteVersionNum
4aa0: 62 65 72 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 ber.. {..
4ab0: 20 20 67 65 74 0d 0a 20 20 20 20 20 20 7b 0d 0a get.. {..
4ac0: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 return U
4ad0: 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
4ae0: 64 73 2e 73 71 6c 69 74 65 33 5f 6c 69 62 76 65 ds.sqlite3_libve
4af0: 72 73 69 6f 6e 5f 6e 75 6d 62 65 72 28 29 3b 0d rsion_number();.
4b00: 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d . }.. }.
4b10: 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
4b20: 73 74 61 74 69 63 20 73 74 72 69 6e 67 20 53 51 static string SQ
4b30: 4c 69 74 65 53 6f 75 72 63 65 49 64 0d 0a 20 20 LiteSourceId..
4b40: 20 20 7b 0d 0a 20 20 20 20 20 20 67 65 74 0d 0a {.. get..
4b50: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
4b60: 20 72 65 74 75 72 6e 20 55 54 46 38 54 6f 53 74 return UTF8ToSt
4b70: 72 69 6e 67 28 55 6e 73 61 66 65 4e 61 74 69 76 ring(UnsafeNativ
4b80: 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
4b90: 5f 73 6f 75 72 63 65 69 64 28 29 2c 20 2d 31 29 _sourceid(), -1)
4ba0: 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 ;.. }..
4bb0: 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 }.... interna
4bc0: 6c 20 73 74 61 74 69 63 20 73 74 72 69 6e 67 20 l static string
4bd0: 53 51 4c 69 74 65 43 6f 6d 70 69 6c 65 4f 70 74 SQLiteCompileOpt
4be0: 69 6f 6e 73 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 ions.. {..
4bf0: 20 20 20 20 20 67 65 74 0d 0a 20 20 20 20 20 20 get..
4c00: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
4c10: 20 53 74 72 69 6e 67 42 75 69 6c 64 65 72 20 72 StringBuilder r
4c20: 65 73 75 6c 74 20 3d 20 6e 65 77 20 53 74 72 69 esult = new Stri
4c30: 6e 67 42 75 69 6c 64 65 72 28 29 3b 0d 0a 20 20 ngBuilder();..
4c40: 20 20 20 20 20 20 20 20 20 20 69 6e 74 20 69 6e int in
4c50: 64 65 78 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 dex = 0;..
4c60: 20 20 20 20 20 20 49 6e 74 50 74 72 20 7a 56 61 IntPtr zVa
4c70: 6c 75 65 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 lue = UnsafeNati
4c80: 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
4c90: 33 5f 63 6f 6d 70 69 6c 65 6f 70 74 69 6f 6e 5f 3_compileoption_
4ca0: 67 65 74 28 69 6e 64 65 78 2b 2b 29 3b 0d 0a 0d get(index++);...
4cb0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 77 68 69 . whi
4cc0: 6c 65 20 28 7a 56 61 6c 75 65 20 21 3d 20 49 6e le (zValue != In
4cd0: 74 50 74 72 2e 5a 65 72 6f 29 0d 0a 20 20 20 20 tPtr.Zero)..
4ce0: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
4cf0: 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 72 if (r
4d00: 65 73 75 6c 74 2e 4c 65 6e 67 74 68 20 3e 20 30 esult.Length > 0
4d10: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )..
4d20: 20 20 20 20 20 20 20 72 65 73 75 6c 74 2e 41 70 result.Ap
4d30: 70 65 6e 64 28 27 20 27 29 3b 0d 0a 0d 0a 20 20 pend(' ');....
4d40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 re
4d50: 73 75 6c 74 2e 41 70 70 65 6e 64 28 55 54 46 38 sult.Append(UTF8
4d60: 54 6f 53 74 72 69 6e 67 28 7a 56 61 6c 75 65 2c ToString(zValue,
4d70: 20 2d 31 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 -1));..
4d80: 20 20 20 20 20 20 20 20 7a 56 61 6c 75 65 20 3d zValue =
4d90: 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
4da0: 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6d hods.sqlite3_com
4db0: 70 69 6c 65 6f 70 74 69 6f 6e 5f 67 65 74 28 69 pileoption_get(i
4dc0: 6e 64 65 78 2b 2b 29 3b 0d 0a 20 20 20 20 20 20 ndex++);..
4dd0: 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 }....
4de0: 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 72 65 return re
4df0: 73 75 6c 74 2e 54 6f 53 74 72 69 6e 67 28 29 3b sult.ToString();
4e00: 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 .. }..
4e10: 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e }.... intern
4e20: 61 6c 20 73 74 61 74 69 63 20 73 74 72 69 6e 67 al static string
4e30: 20 49 6e 74 65 72 6f 70 56 65 72 73 69 6f 6e 0d InteropVersion.
4e40: 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 . {..
4e50: 67 65 74 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a get.. {..
4e60: 23 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e #if !SQLITE_STAN
4e70: 44 41 52 44 0d 0a 20 20 20 20 20 20 20 20 20 20 DARD..
4e80: 20 20 72 65 74 75 72 6e 20 55 54 46 38 54 6f 53 return UTF8ToS
4e90: 74 72 69 6e 67 28 55 6e 73 61 66 65 4e 61 74 69 tring(UnsafeNati
4ea0: 76 65 4d 65 74 68 6f 64 73 2e 69 6e 74 65 72 6f veMethods.intero
4eb0: 70 5f 6c 69 62 76 65 72 73 69 6f 6e 28 29 2c 20 p_libversion(),
4ec0: 2d 31 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 -1);..#else..
4ed0: 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 return
4ee0: 6e 75 6c 6c 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 null;..#endif..
4ef0: 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d }.. }.
4f00: 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
4f10: 73 74 61 74 69 63 20 73 74 72 69 6e 67 20 49 6e static string In
4f20: 74 65 72 6f 70 53 6f 75 72 63 65 49 64 0d 0a 20 teropSourceId..
4f30: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 67 65 {.. ge
4f40: 74 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 23 69 t.. {..#i
4f50: 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 f !SQLITE_STANDA
4f60: 52 44 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 RD..
4f70: 72 65 74 75 72 6e 20 55 54 46 38 54 6f 53 74 72 return UTF8ToStr
4f80: 69 6e 67 28 55 6e 73 61 66 65 4e 61 74 69 76 65 ing(UnsafeNative
4f90: 4d 65 74 68 6f 64 73 2e 69 6e 74 65 72 6f 70 5f Methods.interop_
4fa0: 73 6f 75 72 63 65 69 64 28 29 2c 20 2d 31 29 3b sourceid(), -1);
4fb0: 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 ..#else..
4fc0: 20 20 20 20 20 72 65 74 75 72 6e 20 6e 75 6c 6c return null
4fd0: 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 ;..#endif..
4fe0: 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 }.. }....
4ff0: 20 20 20 69 6e 74 65 72 6e 61 6c 20 73 74 61 74 internal stat
5000: 69 63 20 73 74 72 69 6e 67 20 49 6e 74 65 72 6f ic string Intero
5010: 70 43 6f 6d 70 69 6c 65 4f 70 74 69 6f 6e 73 0d pCompileOptions.
5020: 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 . {..
5030: 67 65 74 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a get.. {..
5040: 23 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e #if !SQLITE_STAN
5050: 44 41 52 44 0d 0a 20 20 20 20 20 20 20 20 20 20 DARD..
5060: 20 20 53 74 72 69 6e 67 42 75 69 6c 64 65 72 20 StringBuilder
5070: 72 65 73 75 6c 74 20 3d 20 6e 65 77 20 53 74 72 result = new Str
5080: 69 6e 67 42 75 69 6c 64 65 72 28 29 3b 0d 0a 20 ingBuilder();..
5090: 20 20 20 20 20 20 20 20 20 20 20 69 6e 74 20 69 int i
50a0: 6e 64 65 78 20 3d 20 30 3b 0d 0a 20 20 20 20 20 ndex = 0;..
50b0: 20 20 20 20 20 20 20 49 6e 74 50 74 72 20 7a 56 IntPtr zV
50c0: 61 6c 75 65 20 3d 20 55 6e 73 61 66 65 4e 61 74 alue = UnsafeNat
50d0: 69 76 65 4d 65 74 68 6f 64 73 2e 69 6e 74 65 72 iveMethods.inter
50e0: 6f 70 5f 63 6f 6d 70 69 6c 65 6f 70 74 69 6f 6e op_compileoption
50f0: 5f 67 65 74 28 69 6e 64 65 78 2b 2b 29 3b 0d 0a _get(index++);..
5100: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 77 68 .. wh
5110: 69 6c 65 20 28 7a 56 61 6c 75 65 20 21 3d 20 49 ile (zValue != I
5120: 6e 74 50 74 72 2e 5a 65 72 6f 29 0d 0a 20 20 20 ntPtr.Zero)..
5130: 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 {..
5140: 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 if (
5150: 72 65 73 75 6c 74 2e 4c 65 6e 67 74 68 20 3e 20 result.Length >
5160: 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 0)..
5170: 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 2e 41 result.A
5180: 70 70 65 6e 64 28 27 20 27 29 3b 0d 0a 0d 0a 20 ppend(' ');....
5190: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 r
51a0: 65 73 75 6c 74 2e 41 70 70 65 6e 64 28 55 54 46 esult.Append(UTF
51b0: 38 54 6f 53 74 72 69 6e 67 28 7a 56 61 6c 75 65 8ToString(zValue
51c0: 2c 20 2d 31 29 29 3b 0d 0a 20 20 20 20 20 20 20 , -1));..
51d0: 20 20 20 20 20 20 20 20 20 7a 56 61 6c 75 65 20 zValue
51e0: 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 = UnsafeNativeMe
51f0: 74 68 6f 64 73 2e 69 6e 74 65 72 6f 70 5f 63 6f thods.interop_co
5200: 6d 70 69 6c 65 6f 70 74 69 6f 6e 5f 67 65 74 28 mpileoption_get(
5210: 69 6e 64 65 78 2b 2b 29 3b 0d 0a 20 20 20 20 20 index++);..
5220: 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 }....
5230: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 72 return r
5240: 65 73 75 6c 74 2e 54 6f 53 74 72 69 6e 67 28 29 esult.ToString()
5250: 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 ;..#else..
5260: 20 20 20 20 20 20 72 65 74 75 72 6e 20 6e 75 6c return nul
5270: 6c 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 l;..#endif..
5280: 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a }.. }....
5290: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
52a0: 72 72 69 64 65 20 62 6f 6f 6c 20 41 75 74 6f 43 rride bool AutoC
52b0: 6f 6d 6d 69 74 0d 0a 20 20 20 20 7b 0d 0a 20 20 ommit.. {..
52c0: 20 20 20 20 67 65 74 0d 0a 20 20 20 20 20 20 7b get.. {
52d0: 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e .. return
52e0: 20 49 73 41 75 74 6f 63 6f 6d 6d 69 74 28 5f 73 IsAutocommit(_s
52f0: 71 6c 2c 20 5f 73 71 6c 29 3b 0d 0a 20 20 20 20 ql, _sql);..
5300: 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 }.. }....
5310: 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 internal overr
5320: 69 64 65 20 62 6f 6f 6c 20 49 73 52 65 61 64 4f ide bool IsReadO
5330: 6e 6c 79 28 0d 0a 20 20 20 20 20 20 20 20 73 74 nly(.. st
5340: 72 69 6e 67 20 6e 61 6d 65 0d 0a 20 20 20 20 20 ring name..
5350: 20 20 20 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 ).. {..
5360: 20 20 20 20 20 49 6e 74 50 74 72 20 70 44 62 4e IntPtr pDbN
5370: 61 6d 65 20 3d 20 49 6e 74 50 74 72 2e 5a 65 72 ame = IntPtr.Zer
5380: 6f 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 74 72 o;.... tr
5390: 79 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 y.. {..
53a0: 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6e 61 if (na
53b0: 6d 65 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 me != null)..
53c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 70 44 62 pDb
53d0: 4e 61 6d 65 20 3d 20 53 51 4c 69 74 65 53 74 72 Name = SQLiteStr
53e0: 69 6e 67 2e 55 74 66 38 49 6e 74 50 74 72 46 72 ing.Utf8IntPtrFr
53f0: 6f 6d 53 74 72 69 6e 67 28 6e 61 6d 65 29 3b 0d omString(name);.
5400: 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 ... i
5410: 6e 74 20 72 65 73 75 6c 74 20 3d 20 55 6e 73 61 nt result = Unsa
5420: 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
5430: 73 71 6c 69 74 65 33 5f 64 62 5f 72 65 61 64 6f sqlite3_db_reado
5440: 6e 6c 79 28 0d 0a 20 20 20 20 20 20 20 20 20 20 nly(..
5450: 20 20 20 20 20 20 5f 73 71 6c 2c 20 70 44 62 4e _sql, pDbN
5460: 61 6d 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 ame);....
5470: 20 20 20 20 20 69 66 20 28 72 65 73 75 6c 74 20 if (result
5480: 3d 3d 20 2d 31 29 20 2f 2a 20 64 61 74 61 62 61 == -1) /* databa
5490: 73 65 20 6e 6f 74 20 66 6f 75 6e 64 20 2a 2f 0d se not found */.
54a0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a . {..
54b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
54c0: 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 throw new SQLite
54d0: 45 78 63 65 70 74 69 6f 6e 28 48 65 6c 70 65 72 Exception(Helper
54e0: 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f Methods.StringFo
54f0: 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 rmat(..
5500: 20 20 20 20 20 20 20 20 20 20 20 43 75 6c 74 75 Cultu
5510: 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 reInfo.CurrentCu
5520: 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 lture,..
5530: 20 20 20 20 20 20 20 20 20 20 20 20 22 64 61 74 "dat
5540: 61 62 61 73 65 20 5c 22 7b 30 7d 5c 22 20 6e 6f abase \"{0}\" no
5550: 74 20 66 6f 75 6e 64 22 2c 20 6e 61 6d 65 29 29 t found", name))
5560: 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d ;.. }
5570: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ....
5580: 72 65 74 75 72 6e 20 72 65 73 75 6c 74 20 3d 3d return result ==
5590: 20 30 20 3f 20 66 61 6c 73 65 20 3a 20 74 72 75 0 ? false : tru
55a0: 65 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 e;.. }..
55b0: 20 20 20 20 20 20 20 66 69 6e 61 6c 6c 79 0d 0a finally..
55c0: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
55d0: 20 20 20 20 20 20 20 69 66 20 28 70 44 62 4e 61 if (pDbNa
55e0: 6d 65 20 21 3d 20 49 6e 74 50 74 72 2e 5a 65 72 me != IntPtr.Zer
55f0: 6f 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 o)..
5600: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 {..
5610: 20 20 20 53 51 4c 69 74 65 4d 65 6d 6f 72 79 2e SQLiteMemory.
5620: 46 72 65 65 28 70 44 62 4e 61 6d 65 29 3b 0d 0a Free(pDbName);..
5630: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5640: 70 44 62 4e 61 6d 65 20 3d 20 49 6e 74 50 74 72 pDbName = IntPtr
5650: 2e 5a 65 72 6f 3b 0d 0a 20 20 20 20 20 20 20 20 .Zero;..
5660: 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d }.. }
5670: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
5680: 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
5690: 20 6c 6f 6e 67 20 4c 61 73 74 49 6e 73 65 72 74 long LastInsert
56a0: 52 6f 77 49 64 0d 0a 20 20 20 20 7b 0d 0a 20 20 RowId.. {..
56b0: 20 20 20 20 67 65 74 0d 0a 20 20 20 20 20 20 7b get.. {
56c0: 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f ..#if !PLATFORM_
56d0: 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 4b COMPACTFRAMEWORK
56e0: 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e .. return
56f0: 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
5700: 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 6c 61 73 hods.sqlite3_las
5710: 74 5f 69 6e 73 65 72 74 5f 72 6f 77 69 64 28 5f t_insert_rowid(_
5720: 73 71 6c 29 3b 0d 0a 23 65 6c 69 66 20 21 53 51 sql);..#elif !SQ
5730: 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 LITE_STANDARD..
5740: 20 20 20 20 20 20 20 6c 6f 6e 67 20 72 6f 77 49 long rowI
5750: 64 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 20 20 d = 0;..
5760: 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
5770: 6f 64 73 2e 73 71 6c 69 74 65 33 5f 6c 61 73 74 ods.sqlite3_last
5780: 5f 69 6e 73 65 72 74 5f 72 6f 77 69 64 5f 69 6e _insert_rowid_in
5790: 74 65 72 6f 70 28 5f 73 71 6c 2c 20 72 65 66 20 terop(_sql, ref
57a0: 72 6f 77 49 64 29 3b 0d 0a 20 20 20 20 20 20 20 rowId);..
57b0: 20 72 65 74 75 72 6e 20 72 6f 77 49 64 3b 0d 0a return rowId;..
57c0: 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 74 #else.. t
57d0: 68 72 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c hrow new NotImpl
57e0: 65 6d 65 6e 74 65 64 45 78 63 65 70 74 69 6f 6e ementedException
57f0: 28 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 ();..#endif..
5800: 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 }.. }....
5810: 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 internal over
5820: 72 69 64 65 20 69 6e 74 20 43 68 61 6e 67 65 73 ride int Changes
5830: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 67 .. {.. g
5840: 65 74 0d 0a 20 20 20 20 20 20 7b 0d 0a 23 69 66 et.. {..#if
5850: 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 !SQLITE_STANDAR
5860: 44 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 D.. retur
5870: 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 n UnsafeNativeMe
5880: 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 68 thods.sqlite3_ch
5890: 61 6e 67 65 73 5f 69 6e 74 65 72 6f 70 28 5f 73 anges_interop(_s
58a0: 71 6c 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 ql);..#else..
58b0: 20 20 20 20 20 72 65 74 75 72 6e 20 55 6e 73 61 return Unsa
58c0: 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
58d0: 73 71 6c 69 74 65 33 5f 63 68 61 6e 67 65 73 28 sqlite3_changes(
58e0: 5f 73 71 6c 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a _sql);..#endif..
58f0: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a }.. }..
5900: 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
5910: 76 65 72 72 69 64 65 20 6c 6f 6e 67 20 4d 65 6d verride long Mem
5920: 6f 72 79 55 73 65 64 0d 0a 20 20 20 20 7b 0d 0a oryUsed.. {..
5930: 20 20 20 20 20 20 20 20 67 65 74 0d 0a 20 20 20 get..
5940: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
5950: 20 20 20 20 72 65 74 75 72 6e 20 53 74 61 74 69 return Stati
5960: 63 4d 65 6d 6f 72 79 55 73 65 64 3b 0d 0a 20 20 cMemoryUsed;..
5970: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a }.. }..
5980: 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 73 .. internal s
5990: 74 61 74 69 63 20 6c 6f 6e 67 20 53 74 61 74 69 tatic long Stati
59a0: 63 4d 65 6d 6f 72 79 55 73 65 64 0d 0a 20 20 20 cMemoryUsed..
59b0: 20 7b 0d 0a 20 20 20 20 20 20 20 20 67 65 74 0d {.. get.
59c0: 0a 20 20 20 20 20 20 20 20 7b 0d 0a 23 69 66 20 . {..#if
59d0: 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 !PLATFORM_COMPAC
59e0: 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 TFRAMEWORK..
59f0: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 return U
5a00: 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
5a10: 64 73 2e 73 71 6c 69 74 65 33 5f 6d 65 6d 6f 72 ds.sqlite3_memor
5a20: 79 5f 75 73 65 64 28 29 3b 0d 0a 23 65 6c 69 66 y_used();..#elif
5a30: 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 !SQLITE_STANDAR
5a40: 44 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6c D.. l
5a50: 6f 6e 67 20 62 79 74 65 73 20 3d 20 30 3b 0d 0a ong bytes = 0;..
5a60: 20 20 20 20 20 20 20 20 20 20 20 20 55 6e 73 61 Unsa
5a70: 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
5a80: 73 71 6c 69 74 65 33 5f 6d 65 6d 6f 72 79 5f 75 sqlite3_memory_u
5a90: 73 65 64 5f 69 6e 74 65 72 6f 70 28 72 65 66 20 sed_interop(ref
5aa0: 62 79 74 65 73 29 3b 0d 0a 20 20 20 20 20 20 20 bytes);..
5ab0: 20 20 20 20 20 72 65 74 75 72 6e 20 62 79 74 65 return byte
5ac0: 73 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 s;..#else..
5ad0: 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 throw new
5ae0: 20 4e 6f 74 49 6d 70 6c 65 6d 65 6e 74 65 64 45 NotImplementedE
5af0: 78 63 65 70 74 69 6f 6e 28 29 3b 0d 0a 23 65 6e xception();..#en
5b00: 64 69 66 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a dif.. }..
5b10: 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 }.... int
5b20: 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 6c ernal override l
5b30: 6f 6e 67 20 4d 65 6d 6f 72 79 48 69 67 68 77 61 ong MemoryHighwa
5b40: 74 65 72 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 ter.. {..
5b50: 20 20 20 20 67 65 74 0d 0a 20 20 20 20 20 20 20 get..
5b60: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
5b70: 72 65 74 75 72 6e 20 53 74 61 74 69 63 4d 65 6d return StaticMem
5b80: 6f 72 79 48 69 67 68 77 61 74 65 72 3b 0d 0a 20 oryHighwater;..
5b90: 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d }.. }.
5ba0: 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
5bb0: 73 74 61 74 69 63 20 6c 6f 6e 67 20 53 74 61 74 static long Stat
5bc0: 69 63 4d 65 6d 6f 72 79 48 69 67 68 77 61 74 65 icMemoryHighwate
5bd0: 72 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 r.. {..
5be0: 20 20 67 65 74 0d 0a 20 20 20 20 20 20 20 20 7b get.. {
5bf0: 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f ..#if !PLATFORM_
5c00: 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 4b COMPACTFRAMEWORK
5c10: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 .. re
5c20: 74 75 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 turn UnsafeNativ
5c30: 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
5c40: 5f 6d 65 6d 6f 72 79 5f 68 69 67 68 77 61 74 65 _memory_highwate
5c50: 72 28 30 29 3b 0d 0a 23 65 6c 69 66 20 21 53 51 r(0);..#elif !SQ
5c60: 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 LITE_STANDARD..
5c70: 20 20 20 20 20 20 20 20 20 20 20 6c 6f 6e 67 20 long
5c80: 62 79 74 65 73 20 3d 20 30 3b 0d 0a 20 20 20 20 bytes = 0;..
5c90: 20 20 20 20 20 20 20 20 55 6e 73 61 66 65 4e 61 UnsafeNa
5ca0: 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 tiveMethods.sqli
5cb0: 74 65 33 5f 6d 65 6d 6f 72 79 5f 68 69 67 68 77 te3_memory_highw
5cc0: 61 74 65 72 5f 69 6e 74 65 72 6f 70 28 30 2c 20 ater_interop(0,
5cd0: 72 65 66 20 62 79 74 65 73 29 3b 0d 0a 20 20 20 ref bytes);..
5ce0: 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 return
5cf0: 62 79 74 65 73 3b 0d 0a 23 65 6c 73 65 0d 0a 20 bytes;..#else..
5d00: 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 throw
5d10: 20 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 6d 65 6e new NotImplemen
5d20: 74 65 64 45 78 63 65 70 74 69 6f 6e 28 29 3b 0d tedException();.
5d30: 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 .#endif..
5d40: 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 }.. }....
5d50: 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
5d60: 20 20 20 20 2f 2f 2f 20 52 65 74 75 72 6e 73 20 /// Returns
5d70: 6e 6f 6e 2d 7a 65 72 6f 20 69 66 20 74 68 65 20 non-zero if the
5d80: 75 6e 64 65 72 6c 79 69 6e 67 20 6e 61 74 69 76 underlying nativ
5d90: 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 68 61 6e e connection han
5da0: 64 6c 65 20 69 73 20 6f 77 6e 65 64 0d 0a 20 20 dle is owned..
5db0: 20 20 2f 2f 2f 20 62 79 20 74 68 69 73 20 69 6e /// by this in
5dc0: 73 74 61 6e 63 65 2e 0d 0a 20 20 20 20 2f 2f 2f stance... ///
5dd0: 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 </summary>..
5de0: 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 internal overri
5df0: 64 65 20 62 6f 6f 6c 20 4f 77 6e 48 61 6e 64 6c de bool OwnHandl
5e00: 65 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 e.. {..
5e10: 20 20 67 65 74 0d 0a 20 20 20 20 20 20 20 20 7b get.. {
5e20: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 .. if
5e30: 20 28 5f 73 71 6c 20 3d 3d 20 6e 75 6c 6c 29 0d (_sql == null).
5e40: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
5e50: 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 throw new SQLit
5e60: 65 45 78 63 65 70 74 69 6f 6e 28 22 6e 6f 20 63 eException("no c
5e70: 6f 6e 6e 65 63 74 69 6f 6e 20 68 61 6e 64 6c 65 onnection handle
5e80: 20 61 76 61 69 6c 61 62 6c 65 22 29 3b 0d 0a 0d available");...
5e90: 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 . ret
5ea0: 75 72 6e 20 5f 73 71 6c 2e 4f 77 6e 48 61 6e 64 urn _sql.OwnHand
5eb0: 6c 65 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a le;.. }..
5ec0: 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f }.... ///
5ed0: 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 <summary>..
5ee0: 2f 2f 2f 20 52 65 74 75 72 6e 73 20 74 68 65 20 /// Returns the
5ef0: 6c 6f 67 69 63 61 6c 20 6c 69 73 74 20 6f 66 20 logical list of
5f00: 66 75 6e 63 74 69 6f 6e 73 20 61 73 73 6f 63 69 functions associ
5f10: 61 74 65 64 20 77 69 74 68 20 74 68 69 73 20 63 ated with this c
5f20: 6f 6e 6e 65 63 74 69 6f 6e 2e 0d 0a 20 20 20 20 onnection...
5f30: 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a /// </summary>..
5f40: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
5f50: 72 72 69 64 65 20 49 44 69 63 74 69 6f 6e 61 72 rride IDictionar
5f60: 79 3c 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e y<SQLiteFunction
5f70: 41 74 74 72 69 62 75 74 65 2c 20 53 51 4c 69 74 Attribute, SQLit
5f80: 65 46 75 6e 63 74 69 6f 6e 3e 20 46 75 6e 63 74 eFunction> Funct
5f90: 69 6f 6e 73 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 ions.. {..
5fa0: 20 20 20 20 20 67 65 74 20 7b 20 72 65 74 75 72 get { retur
5fb0: 6e 20 5f 66 75 6e 63 74 69 6f 6e 73 3b 20 7d 0d n _functions; }.
5fc0: 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
5fd0: 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
5fe0: 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 SQLiteErrorCode
5ff0: 53 65 74 4d 65 6d 6f 72 79 53 74 61 74 75 73 28 SetMemoryStatus(
6000: 62 6f 6f 6c 20 76 61 6c 75 65 29 0d 0a 20 20 20 bool value)..
6010: 20 7b 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 {.. retu
6020: 72 6e 20 53 74 61 74 69 63 53 65 74 4d 65 6d 6f rn StaticSetMemo
6030: 72 79 53 74 61 74 75 73 28 76 61 6c 75 65 29 3b ryStatus(value);
6040: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
6050: 6e 74 65 72 6e 61 6c 20 73 74 61 74 69 63 20 53 nternal static S
6060: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 53 QLiteErrorCode S
6070: 74 61 74 69 63 53 65 74 4d 65 6d 6f 72 79 53 74 taticSetMemorySt
6080: 61 74 75 73 28 62 6f 6f 6c 20 76 61 6c 75 65 29 atus(bool value)
6090: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
60a0: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
60b0: 20 72 63 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 rc = UnsafeNati
60c0: 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
60d0: 33 5f 63 6f 6e 66 69 67 5f 69 6e 74 28 0d 0a 20 3_config_int(..
60e0: 20 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 SQLit
60f0: 65 43 6f 6e 66 69 67 4f 70 73 45 6e 75 6d 2e 53 eConfigOpsEnum.S
6100: 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 4d 45 4d QLITE_CONFIG_MEM
6110: 53 54 41 54 55 53 2c 20 76 61 6c 75 65 20 3f 20 STATUS, value ?
6120: 31 20 3a 20 30 29 3b 0d 0a 0d 0a 20 20 20 20 20 1 : 0);....
6130: 20 20 20 72 65 74 75 72 6e 20 72 63 3b 0d 0a 20 return rc;..
6140: 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 }.... ///
6150: 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f <summary>.. /
6160: 2f 2f 20 41 74 74 65 6d 70 74 73 20 74 6f 20 66 // Attempts to f
6170: 72 65 65 20 61 73 20 6d 75 63 68 20 68 65 61 70 ree as much heap
6180: 20 6d 65 6d 6f 72 79 20 61 73 20 70 6f 73 73 69 memory as possi
6190: 62 6c 65 20 66 6f 72 20 74 68 65 20 64 61 74 61 ble for the data
61a0: 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 2e base connection.
61b0: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d .. /// </summ
61c0: 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 ary>.. /// <r
61d0: 65 74 75 72 6e 73 3e 41 20 73 74 61 6e 64 61 72 eturns>A standar
61e0: 64 20 53 51 4c 69 74 65 20 72 65 74 75 72 6e 20 d SQLite return
61f0: 63 6f 64 65 20 28 69 2e 65 2e 20 7a 65 72 6f 20 code (i.e. zero
6200: 66 6f 72 20 73 75 63 63 65 73 73 20 61 6e 64 20 for success and
6210: 6e 6f 6e 2d 7a 65 72 6f 20 66 6f 72 20 66 61 69 non-zero for fai
6220: 6c 75 72 65 29 2e 3c 2f 72 65 74 75 72 6e 73 3e lure).</returns>
6230: 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
6240: 76 65 72 72 69 64 65 20 53 51 4c 69 74 65 45 72 verride SQLiteEr
6250: 72 6f 72 43 6f 64 65 20 52 65 6c 65 61 73 65 4d rorCode ReleaseM
6260: 65 6d 6f 72 79 28 29 0d 0a 20 20 20 20 7b 0d 0a emory().. {..
6270: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 SQLiteEr
6280: 72 6f 72 43 6f 64 65 20 72 63 20 3d 20 55 6e 73 rorCode rc = Uns
6290: 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
62a0: 2e 73 71 6c 69 74 65 33 5f 64 62 5f 72 65 6c 65 .sqlite3_db_rele
62b0: 61 73 65 5f 6d 65 6d 6f 72 79 28 5f 73 71 6c 29 ase_memory(_sql)
62c0: 3b 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 ;.. retur
62d0: 6e 20 72 63 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a n rc;.. }....
62e0: 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 /// <summary
62f0: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 41 74 74 65 6d >.. /// Attem
6300: 70 74 73 20 74 6f 20 66 72 65 65 20 4e 20 62 79 pts to free N by
6310: 74 65 73 20 6f 66 20 68 65 61 70 20 6d 65 6d 6f tes of heap memo
6320: 72 79 20 62 79 20 64 65 61 6c 6c 6f 63 61 74 69 ry by deallocati
6330: 6e 67 20 6e 6f 6e 2d 65 73 73 65 6e 74 69 61 6c ng non-essential
6340: 20 6d 65 6d 6f 72 79 0d 0a 20 20 20 20 2f 2f 2f memory.. ///
6350: 20 61 6c 6c 6f 63 61 74 69 6f 6e 73 20 68 65 6c allocations hel
6360: 64 20 62 79 20 74 68 65 20 64 61 74 61 62 61 73 d by the databas
6370: 65 20 6c 69 62 72 61 72 79 2e 20 4d 65 6d 6f 72 e library. Memor
6380: 79 20 75 73 65 64 20 74 6f 20 63 61 63 68 65 20 y used to cache
6390: 64 61 74 61 62 61 73 65 20 70 61 67 65 73 0d 0a database pages..
63a0: 20 20 20 20 2f 2f 2f 20 74 6f 20 69 6d 70 72 6f /// to impro
63b0: 76 65 20 70 65 72 66 6f 72 6d 61 6e 63 65 20 69 ve performance i
63c0: 73 20 61 6e 20 65 78 61 6d 70 6c 65 20 6f 66 20 s an example of
63d0: 6e 6f 6e 2d 65 73 73 65 6e 74 69 61 6c 20 6d 65 non-essential me
63e0: 6d 6f 72 79 2e 20 20 54 68 69 73 20 69 73 20 61 mory. This is a
63f0: 20 6e 6f 2d 6f 70 0d 0a 20 20 20 20 2f 2f 2f 20 no-op.. ///
6400: 72 65 74 75 72 6e 69 6e 67 20 7a 65 72 6f 20 69 returning zero i
6410: 66 20 74 68 65 20 53 51 4c 69 74 65 20 63 6f 72 f the SQLite cor
6420: 65 20 6c 69 62 72 61 72 79 20 77 61 73 20 6e 6f e library was no
6430: 74 20 63 6f 6d 70 69 6c 65 64 20 77 69 74 68 20 t compiled with
6440: 74 68 65 20 63 6f 6d 70 69 6c 65 2d 74 69 6d 65 the compile-time
6450: 0d 0a 20 20 20 20 2f 2f 2f 20 6f 70 74 69 6f 6e .. /// option
6460: 20 53 51 4c 49 54 45 5f 45 4e 41 42 4c 45 5f 4d SQLITE_ENABLE_M
6470: 45 4d 4f 52 59 5f 4d 41 4e 41 47 45 4d 45 4e 54 EMORY_MANAGEMENT
6480: 2e 20 20 4f 70 74 69 6f 6e 61 6c 6c 79 2c 20 61 . Optionally, a
6490: 74 74 65 6d 70 74 73 20 74 6f 20 72 65 73 65 74 ttempts to reset
64a0: 20 61 6e 64 2f 6f 72 0d 0a 20 20 20 20 2f 2f 2f and/or.. ///
64b0: 20 63 6f 6d 70 61 63 74 20 74 68 65 20 57 69 6e compact the Win
64c0: 33 32 20 6e 61 74 69 76 65 20 68 65 61 70 2c 20 32 native heap,
64d0: 69 66 20 61 70 70 6c 69 63 61 62 6c 65 2e 0d 0a if applicable...
64e0: 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 /// </summar
64f0: 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 y>.. /// <par
6500: 61 6d 20 6e 61 6d 65 3d 22 6e 42 79 74 65 73 22 am name="nBytes"
6510: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 72 >.. /// The r
6520: 65 71 75 65 73 74 65 64 20 6e 75 6d 62 65 72 20 equested number
6530: 6f 66 20 62 79 74 65 73 20 74 6f 20 66 72 65 65 of bytes to free
6540: 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 ... /// </par
6550: 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 am>.. /// <pa
6560: 72 61 6d 20 6e 61 6d 65 3d 22 72 65 73 65 74 22 ram name="reset"
6570: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 4e 6f 6e 2d 7a >.. /// Non-z
6580: 65 72 6f 20 74 6f 20 61 74 74 65 6d 70 74 20 61 ero to attempt a
6590: 20 68 65 61 70 20 72 65 73 65 74 2e 0d 0a 20 20 heap reset...
65a0: 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a /// </param>..
65b0: 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e /// <param n
65c0: 61 6d 65 3d 22 63 6f 6d 70 61 63 74 22 3e 0d 0a ame="compact">..
65d0: 20 20 20 20 2f 2f 2f 20 4e 6f 6e 2d 7a 65 72 6f /// Non-zero
65e0: 20 74 6f 20 61 74 74 65 6d 70 74 20 68 65 61 70 to attempt heap
65f0: 20 63 6f 6d 70 61 63 74 69 6f 6e 2e 0d 0a 20 20 compaction...
6600: 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a /// </param>..
6610: 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e /// <param n
6620: 61 6d 65 3d 22 6e 46 72 65 65 22 3e 0d 0a 20 20 ame="nFree">..
6630: 20 20 2f 2f 2f 20 54 68 65 20 6e 75 6d 62 65 72 /// The number
6640: 20 6f 66 20 62 79 74 65 73 20 61 63 74 75 61 6c of bytes actual
6650: 6c 79 20 66 72 65 65 64 2e 20 20 54 68 69 73 20 ly freed. This
6660: 76 61 6c 75 65 20 6d 61 79 20 62 65 20 7a 65 72 value may be zer
6670: 6f 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 o... /// </pa
6680: 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 ram>.. /// <p
6690: 61 72 61 6d 20 6e 61 6d 65 3d 22 72 65 73 65 74 aram name="reset
66a0: 4f 6b 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 Ok">.. /// Th
66b0: 69 73 20 76 61 6c 75 65 20 77 69 6c 6c 20 62 65 is value will be
66c0: 20 6e 6f 6e 2d 7a 65 72 6f 20 69 66 20 74 68 65 non-zero if the
66d0: 20 68 65 61 70 20 72 65 73 65 74 20 77 61 73 20 heap reset was
66e0: 73 75 63 63 65 73 73 66 75 6c 2e 0d 0a 20 20 20 successful...
66f0: 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 /// </param>..
6700: 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 /// <param na
6710: 6d 65 3d 22 6e 4c 61 72 67 65 73 74 22 3e 0d 0a me="nLargest">..
6720: 20 20 20 20 2f 2f 2f 20 54 68 65 20 73 69 7a 65 /// The size
6730: 20 6f 66 20 74 68 65 20 6c 61 72 67 65 73 74 20 of the largest
6740: 63 6f 6d 6d 69 74 74 65 64 20 66 72 65 65 20 62 committed free b
6750: 6c 6f 63 6b 20 69 6e 20 74 68 65 20 68 65 61 70 lock in the heap
6760: 2c 20 69 6e 20 62 79 74 65 73 2e 0d 0a 20 20 20 , in bytes...
6770: 20 2f 2f 2f 20 54 68 69 73 20 76 61 6c 75 65 20 /// This value
6780: 77 69 6c 6c 20 62 65 20 7a 65 72 6f 20 75 6e 6c will be zero unl
6790: 65 73 73 20 68 65 61 70 20 63 6f 6d 70 61 63 74 ess heap compact
67a0: 69 6f 6e 20 69 73 20 65 6e 61 62 6c 65 64 2e 0d ion is enabled..
67b0: 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d . /// </param
67c0: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 >.. /// <retu
67d0: 72 6e 73 3e 0d 0a 20 20 20 20 2f 2f 2f 20 41 20 rns>.. /// A
67e0: 73 74 61 6e 64 61 72 64 20 53 51 4c 69 74 65 20 standard SQLite
67f0: 72 65 74 75 72 6e 20 63 6f 64 65 20 28 69 2e 65 return code (i.e
6800: 2e 20 7a 65 72 6f 20 66 6f 72 20 73 75 63 63 65 . zero for succe
6810: 73 73 20 61 6e 64 20 6e 6f 6e 2d 7a 65 72 6f 0d ss and non-zero.
6820: 0a 20 20 20 20 2f 2f 2f 20 66 6f 72 20 66 61 69 . /// for fai
6830: 6c 75 72 65 29 2e 0d 0a 20 20 20 20 2f 2f 2f 20 lure)... ///
6840: 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 </returns>..
6850: 69 6e 74 65 72 6e 61 6c 20 73 74 61 74 69 63 20 internal static
6860: 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 SQLiteErrorCode
6870: 53 74 61 74 69 63 52 65 6c 65 61 73 65 4d 65 6d StaticReleaseMem
6880: 6f 72 79 28 0d 0a 20 20 20 20 20 20 20 20 69 6e ory(.. in
6890: 74 20 6e 42 79 74 65 73 2c 0d 0a 20 20 20 20 20 t nBytes,..
68a0: 20 20 20 62 6f 6f 6c 20 72 65 73 65 74 2c 0d 0a bool reset,..
68b0: 20 20 20 20 20 20 20 20 62 6f 6f 6c 20 63 6f 6d bool com
68c0: 70 61 63 74 2c 0d 0a 20 20 20 20 20 20 20 20 72 pact,.. r
68d0: 65 66 20 69 6e 74 20 6e 46 72 65 65 2c 0d 0a 20 ef int nFree,..
68e0: 20 20 20 20 20 20 20 72 65 66 20 62 6f 6f 6c 20 ref bool
68f0: 72 65 73 65 74 4f 6b 2c 0d 0a 20 20 20 20 20 20 resetOk,..
6900: 20 20 72 65 66 20 75 69 6e 74 20 6e 4c 61 72 67 ref uint nLarg
6910: 65 73 74 0d 0a 20 20 20 20 20 20 20 20 29 0d 0a est.. )..
6920: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 53 {.. S
6930: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 72 QLiteErrorCode r
6940: 63 20 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 c = SQLiteErrorC
6950: 6f 64 65 2e 4f 6b 3b 0d 0a 0d 0a 20 20 20 20 20 ode.Ok;....
6960: 20 20 20 69 6e 74 20 6e 46 72 65 65 4c 6f 63 61 int nFreeLoca
6970: 6c 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 l = UnsafeNative
6980: 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
6990: 72 65 6c 65 61 73 65 5f 6d 65 6d 6f 72 79 28 6e release_memory(n
69a0: 42 79 74 65 73 29 3b 0d 0a 20 20 20 20 20 20 20 Bytes);..
69b0: 20 75 69 6e 74 20 6e 4c 61 72 67 65 73 74 4c 6f uint nLargestLo
69c0: 63 61 6c 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 cal = 0;..
69d0: 20 20 62 6f 6f 6c 20 72 65 73 65 74 4f 6b 4c 6f bool resetOkLo
69e0: 63 61 6c 20 3d 20 66 61 6c 73 65 3b 0d 0a 0d 0a cal = false;....
69f0: 23 69 66 20 21 44 45 42 55 47 20 26 26 20 57 49 #if !DEBUG && WI
6a00: 4e 44 4f 57 53 20 2f 2f 20 4e 4f 54 45 3a 20 53 NDOWS // NOTE: S
6a10: 68 6f 75 6c 64 20 62 65 20 22 57 49 4e 33 32 48 hould be "WIN32H
6a20: 45 41 50 20 26 26 20 21 4d 45 4d 44 45 42 55 47 EAP && !MEMDEBUG
6a30: 20 26 26 20 57 49 4e 44 4f 57 53 22 0d 0a 20 20 && WINDOWS"..
6a40: 20 20 20 20 20 20 69 66 20 28 48 65 6c 70 65 72 if (Helper
6a50: 4d 65 74 68 6f 64 73 2e 49 73 57 69 6e 64 6f 77 Methods.IsWindow
6a60: 73 28 29 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d s()).. {.
6a70: 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 . if
6a80: 28 28 72 63 20 3d 3d 20 53 51 4c 69 74 65 45 72 ((rc == SQLiteEr
6a90: 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 26 26 20 72 rorCode.Ok) && r
6aa0: 65 73 65 74 29 0d 0a 20 20 20 20 20 20 20 20 20 eset)..
6ab0: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
6ac0: 20 20 20 20 20 20 72 63 20 3d 20 55 6e 73 61 66 rc = Unsaf
6ad0: 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
6ae0: 71 6c 69 74 65 33 5f 77 69 6e 33 32 5f 72 65 73 qlite3_win32_res
6af0: 65 74 5f 68 65 61 70 28 29 3b 0d 0a 0d 0a 20 20 et_heap();....
6b00: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 if
6b10: 20 28 72 63 20 3d 3d 20 53 51 4c 69 74 65 45 72 (rc == SQLiteEr
6b20: 72 6f 72 43 6f 64 65 2e 4f 6b 29 0d 0a 20 20 20 rorCode.Ok)..
6b30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
6b40: 20 72 65 73 65 74 4f 6b 4c 6f 63 61 6c 20 3d 20 resetOkLocal =
6b50: 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 true;..
6b60: 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 }....
6b70: 20 20 20 20 69 66 20 28 28 72 63 20 3d 3d 20 53 if ((rc == S
6b80: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f QLiteErrorCode.O
6b90: 6b 29 20 26 26 20 63 6f 6d 70 61 63 74 29 0d 0a k) && compact)..
6ba0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
6bb0: 72 63 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 rc = UnsafeNativ
6bc0: 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
6bd0: 5f 77 69 6e 33 32 5f 63 6f 6d 70 61 63 74 5f 68 _win32_compact_h
6be0: 65 61 70 28 72 65 66 20 6e 4c 61 72 67 65 73 74 eap(ref nLargest
6bf0: 4c 6f 63 61 6c 29 3b 0d 0a 20 20 20 20 20 20 20 Local);..
6c00: 20 7d 0d 0a 20 20 20 20 20 20 20 20 65 6c 73 65 }.. else
6c10: 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 ..#endif..
6c20: 20 20 69 66 20 28 72 65 73 65 74 20 7c 7c 20 63 if (reset || c
6c30: 6f 6d 70 61 63 74 29 0d 0a 20 20 20 20 20 20 20 ompact)..
6c40: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
6c50: 72 63 20 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 rc = SQLiteError
6c60: 43 6f 64 65 2e 4e 6f 74 46 6f 75 6e 64 3b 0d 0a Code.NotFound;..
6c70: 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 }....
6c80: 20 20 20 20 20 6e 46 72 65 65 20 3d 20 6e 46 72 nFree = nFr
6c90: 65 65 4c 6f 63 61 6c 3b 0d 0a 20 20 20 20 20 20 eeLocal;..
6ca0: 20 20 6e 4c 61 72 67 65 73 74 20 3d 20 6e 4c 61 nLargest = nLa
6cb0: 72 67 65 73 74 4c 6f 63 61 6c 3b 0d 0a 20 20 20 rgestLocal;..
6cc0: 20 20 20 20 20 72 65 73 65 74 4f 6b 20 3d 20 72 resetOk = r
6cd0: 65 73 65 74 4f 6b 4c 6f 63 61 6c 3b 0d 0a 0d 0a esetOkLocal;....
6ce0: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 72 return r
6cf0: 63 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 c;.. }....
6d00: 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
6d10: 20 20 20 20 2f 2f 2f 20 53 68 75 74 64 6f 77 6e /// Shutdown
6d20: 20 74 68 65 20 53 51 4c 69 74 65 20 65 6e 67 69 the SQLite engi
6d30: 6e 65 20 73 6f 20 74 68 61 74 20 69 74 20 63 61 ne so that it ca
6d40: 6e 20 62 65 20 72 65 73 74 61 72 74 65 64 20 77 n be restarted w
6d50: 69 74 68 20 64 69 66 66 65 72 65 6e 74 0d 0a 20 ith different..
6d60: 20 20 20 2f 2f 2f 20 63 6f 6e 66 69 67 75 72 61 /// configura
6d70: 74 69 6f 6e 20 6f 70 74 69 6f 6e 73 2e 20 20 57 tion options. W
6d80: 65 20 64 65 70 65 6e 64 20 6f 6e 20 61 75 74 6f e depend on auto
6d90: 20 69 6e 69 74 69 61 6c 69 7a 61 74 69 6f 6e 20 initialization
6da0: 74 6f 20 72 65 63 6f 76 65 72 2e 0d 0a 20 20 20 to recover...
6db0: 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d /// </summary>.
6dc0: 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e . /// <return
6dd0: 73 3e 52 65 74 75 72 6e 73 20 61 20 73 74 61 6e s>Returns a stan
6de0: 64 61 72 64 20 53 51 4c 69 74 65 20 72 65 73 75 dard SQLite resu
6df0: 6c 74 20 63 6f 64 65 2e 3c 2f 72 65 74 75 72 6e lt code.</return
6e00: 73 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c s>.. internal
6e10: 20 6f 76 65 72 72 69 64 65 20 53 51 4c 69 74 65 override SQLite
6e20: 45 72 72 6f 72 43 6f 64 65 20 53 68 75 74 64 6f ErrorCode Shutdo
6e30: 77 6e 28 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 wn().. {..
6e40: 20 20 20 20 20 72 65 74 75 72 6e 20 53 74 61 74 return Stat
6e50: 69 63 53 68 75 74 64 6f 77 6e 28 66 61 6c 73 65 icShutdown(false
6e60: 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 );.. }....
6e70: 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a /// <summary>..
6e80: 20 20 20 20 2f 2f 2f 20 53 68 75 74 64 6f 77 6e /// Shutdown
6e90: 20 74 68 65 20 53 51 4c 69 74 65 20 65 6e 67 69 the SQLite engi
6ea0: 6e 65 20 73 6f 20 74 68 61 74 20 69 74 20 63 61 ne so that it ca
6eb0: 6e 20 62 65 20 72 65 73 74 61 72 74 65 64 20 77 n be restarted w
6ec0: 69 74 68 20 64 69 66 66 65 72 65 6e 74 0d 0a 20 ith different..
6ed0: 20 20 20 2f 2f 2f 20 63 6f 6e 66 69 67 75 72 61 /// configura
6ee0: 74 69 6f 6e 20 6f 70 74 69 6f 6e 73 2e 20 20 57 tion options. W
6ef0: 65 20 64 65 70 65 6e 64 20 6f 6e 20 61 75 74 6f e depend on auto
6f00: 20 69 6e 69 74 69 61 6c 69 7a 61 74 69 6f 6e 20 initialization
6f10: 74 6f 20 72 65 63 6f 76 65 72 2e 0d 0a 20 20 20 to recover...
6f20: 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d /// </summary>.
6f30: 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 . /// <param
6f40: 6e 61 6d 65 3d 22 64 69 72 65 63 74 6f 72 69 65 name="directorie
6f50: 73 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 4e 6f 6e s">.. /// Non
6f60: 2d 7a 65 72 6f 20 74 6f 20 72 65 73 65 74 20 74 -zero to reset t
6f70: 68 65 20 64 61 74 61 62 61 73 65 20 61 6e 64 20 he database and
6f80: 74 65 6d 70 6f 72 61 72 79 20 64 69 72 65 63 74 temporary direct
6f90: 6f 72 69 65 73 20 74 6f 20 74 68 65 69 72 0d 0a ories to their..
6fa0: 20 20 20 20 2f 2f 2f 20 64 65 66 61 75 6c 74 20 /// default
6fb0: 76 61 6c 75 65 73 2c 20 77 68 69 63 68 20 73 68 values, which sh
6fc0: 6f 75 6c 64 20 62 65 20 6e 75 6c 6c 20 66 6f 72 ould be null for
6fd0: 20 62 6f 74 68 2e 20 20 54 68 69 73 20 70 61 72 both. This par
6fe0: 61 6d 65 74 65 72 20 68 61 73 20 6e 6f 0d 0a 20 ameter has no..
6ff0: 20 20 20 2f 2f 2f 20 65 66 66 65 63 74 20 6f 6e /// effect on
7000: 20 6e 6f 6e 2d 57 69 6e 64 6f 77 73 20 6f 70 65 non-Windows ope
7010: 72 61 74 69 6e 67 20 73 79 73 74 65 6d 73 2e 0d rating systems..
7020: 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d . /// </param
7030: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 >.. /// <retu
7040: 72 6e 73 3e 52 65 74 75 72 6e 73 20 61 20 73 74 rns>Returns a st
7050: 61 6e 64 61 72 64 20 53 51 4c 69 74 65 20 72 65 andard SQLite re
7060: 73 75 6c 74 20 63 6f 64 65 2e 3c 2f 72 65 74 75 sult code.</retu
7070: 72 6e 73 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e rns>.. intern
7080: 61 6c 20 73 74 61 74 69 63 20 53 51 4c 69 74 65 al static SQLite
7090: 45 72 72 6f 72 43 6f 64 65 20 53 74 61 74 69 63 ErrorCode Static
70a0: 53 68 75 74 64 6f 77 6e 28 0d 0a 20 20 20 20 20 Shutdown(..
70b0: 20 20 20 62 6f 6f 6c 20 64 69 72 65 63 74 6f 72 bool director
70c0: 69 65 73 0d 0a 20 20 20 20 20 20 20 20 29 0d 0a ies.. )..
70d0: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 53 {.. S
70e0: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 72 QLiteErrorCode r
70f0: 63 20 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 c = SQLiteErrorC
7100: 6f 64 65 2e 4f 6b 3b 0d 0a 0d 0a 20 20 20 20 20 ode.Ok;....
7110: 20 20 20 69 66 20 28 64 69 72 65 63 74 6f 72 69 if (directori
7120: 65 73 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a es).. {..
7130: 23 69 66 20 57 49 4e 44 4f 57 53 0d 0a 20 20 20 #if WINDOWS..
7140: 20 20 20 20 20 20 20 20 20 69 66 20 28 48 65 6c if (Hel
7150: 70 65 72 4d 65 74 68 6f 64 73 2e 49 73 57 69 6e perMethods.IsWin
7160: 64 6f 77 73 28 29 29 0d 0a 20 20 20 20 20 20 20 dows())..
7170: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
7180: 20 20 20 20 20 20 20 20 69 66 20 28 72 63 20 3d if (rc =
7190: 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 = SQLiteErrorCod
71a0: 65 2e 4f 6b 29 0d 0a 20 20 20 20 20 20 20 20 20 e.Ok)..
71b0: 20 20 20 20 20 20 20 20 20 20 20 72 63 20 3d 20 rc =
71c0: 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
71d0: 6f 64 73 2e 73 71 6c 69 74 65 33 5f 77 69 6e 33 ods.sqlite3_win3
71e0: 32 5f 73 65 74 5f 64 69 72 65 63 74 6f 72 79 28 2_set_directory(
71f0: 31 2c 20 6e 75 6c 6c 29 3b 0d 0a 0d 0a 20 20 20 1, null);....
7200: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 if
7210: 28 72 63 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 (rc == SQLiteErr
7220: 6f 72 43 6f 64 65 2e 4f 6b 29 0d 0a 20 20 20 20 orCode.Ok)..
7230: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
7240: 72 63 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 rc = UnsafeNativ
7250: 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
7260: 5f 77 69 6e 33 32 5f 73 65 74 5f 64 69 72 65 63 _win32_set_direc
7270: 74 6f 72 79 28 32 2c 20 6e 75 6c 6c 29 3b 0d 0a tory(2, null);..
7280: 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 }..
7290: 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 0d else.
72a0: 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 .#endif..
72b0: 20 20 20 20 20 7b 0d 0a 23 69 66 20 21 4e 45 54 {..#if !NET
72c0: 5f 43 4f 4d 50 41 43 54 5f 32 30 20 26 26 20 54 _COMPACT_20 && T
72d0: 52 41 43 45 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d RACE_CONNECTION.
72e0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
72f0: 20 54 72 61 63 65 2e 57 72 69 74 65 4c 69 6e 65 Trace.WriteLine
7300: 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 (..
7310: 20 20 20 20 20 20 20 22 53 68 75 74 64 6f 77 6e "Shutdown
7320: 3a 20 43 61 6e 6e 6f 74 20 72 65 73 65 74 20 64 : Cannot reset d
7330: 69 72 65 63 74 6f 72 69 65 73 20 6f 6e 20 74 68 irectories on th
7340: 69 73 20 70 6c 61 74 66 6f 72 6d 2e 22 29 3b 0d is platform.");.
7350: 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 .#endif..
7360: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
7370: 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 }.... if
7380: 28 72 63 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 (rc == SQLiteErr
7390: 6f 72 43 6f 64 65 2e 4f 6b 29 0d 0a 20 20 20 20 orCode.Ok)..
73a0: 20 20 20 20 20 20 20 20 72 63 20 3d 20 55 6e 73 rc = Uns
73b0: 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
73c0: 2e 73 71 6c 69 74 65 33 5f 73 68 75 74 64 6f 77 .sqlite3_shutdow
73d0: 6e 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 n();....
73e0: 72 65 74 75 72 6e 20 72 63 3b 0d 0a 20 20 20 20 return rc;..
73f0: 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 }.... /// <su
7400: 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
7410: 44 65 74 65 72 6d 69 6e 65 73 20 69 66 20 74 68 Determines if th
7420: 65 20 61 73 73 6f 63 69 61 74 65 64 20 6e 61 74 e associated nat
7430: 69 76 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 68 ive connection h
7440: 61 6e 64 6c 65 20 69 73 20 6f 70 65 6e 2e 0d 0a andle is open...
7450: 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 /// </summar
7460: 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 74 y>.. /// <ret
7470: 75 72 6e 73 3e 0d 0a 20 20 20 20 2f 2f 2f 20 4e urns>.. /// N
7480: 6f 6e 2d 7a 65 72 6f 20 69 66 20 74 68 65 20 61 on-zero if the a
7490: 73 73 6f 63 69 61 74 65 64 20 6e 61 74 69 76 65 ssociated native
74a0: 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 68 61 6e 64 connection hand
74b0: 6c 65 20 69 73 20 6f 70 65 6e 2e 0d 0a 20 20 20 le is open...
74c0: 20 2f 2f 2f 20 3c 2f 72 65 74 75 72 6e 73 3e 0d /// </returns>.
74d0: 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
74e0: 65 72 72 69 64 65 20 62 6f 6f 6c 20 49 73 4f 70 erride bool IsOp
74f0: 65 6e 28 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 en().. {..
7500: 20 20 20 20 20 72 65 74 75 72 6e 20 28 5f 73 71 return (_sq
7510: 6c 20 21 3d 20 6e 75 6c 6c 29 20 26 26 20 21 5f l != null) && !_
7520: 73 71 6c 2e 49 73 49 6e 76 61 6c 69 64 20 26 26 sql.IsInvalid &&
7530: 20 21 5f 73 71 6c 2e 49 73 43 6c 6f 73 65 64 3b !_sql.IsClosed;
7540: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f .. }.... /
7550: 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 // <summary>..
7560: 20 20 2f 2f 2f 20 52 65 74 75 72 6e 73 20 74 68 /// Returns th
7570: 65 20 66 75 6c 6c 79 20 71 75 61 6c 69 66 69 65 e fully qualifie
7580: 64 20 70 61 74 68 20 61 6e 64 20 66 69 6c 65 20 d path and file
7590: 6e 61 6d 65 20 66 6f 72 20 74 68 65 20 63 75 72 name for the cur
75a0: 72 65 6e 74 6c 79 20 6f 70 65 6e 0d 0a 20 20 20 rently open..
75b0: 20 2f 2f 2f 20 64 61 74 61 62 61 73 65 2c 20 69 /// database, i
75c0: 66 20 61 6e 79 2e 0d 0a 20 20 20 20 2f 2f 2f 20 f any... ///
75d0: 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 </summary>..
75e0: 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d /// <param name=
75f0: 22 64 62 4e 61 6d 65 22 3e 0d 0a 20 20 20 20 2f "dbName">.. /
7600: 2f 2f 20 54 68 65 20 6e 61 6d 65 20 6f 66 20 74 // The name of t
7610: 68 65 20 61 74 74 61 63 68 65 64 20 64 61 74 61 he attached data
7620: 62 61 73 65 20 74 6f 20 71 75 65 72 79 2e 0d 0a base to query...
7630: 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e /// </param>
7640: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 .. /// <retur
7650: 6e 73 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 ns>.. /// The
7660: 20 66 75 6c 6c 79 20 71 75 61 6c 69 66 69 65 64 fully qualified
7670: 20 70 61 74 68 20 61 6e 64 20 66 69 6c 65 20 6e path and file n
7680: 61 6d 65 20 66 6f 72 20 74 68 65 20 63 75 72 72 ame for the curr
7690: 65 6e 74 6c 79 20 6f 70 65 6e 20 64 61 74 61 62 ently open datab
76a0: 61 73 65 2c 0d 0a 20 20 20 20 2f 2f 2f 20 69 66 ase,.. /// if
76b0: 20 61 6e 79 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c any... /// <
76c0: 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 69 /returns>.. i
76d0: 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
76e0: 20 73 74 72 69 6e 67 20 47 65 74 46 69 6c 65 4e string GetFileN
76f0: 61 6d 65 28 73 74 72 69 6e 67 20 64 62 4e 61 6d ame(string dbNam
7700: 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 e).. {..
7710: 20 20 20 69 66 20 28 5f 73 71 6c 20 3d 3d 20 6e if (_sql == n
7720: 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 ull)..
7730: 20 20 72 65 74 75 72 6e 20 6e 75 6c 6c 3b 0d 0a return null;..
7740: 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e .. return
7750: 20 55 54 46 38 54 6f 53 74 72 69 6e 67 28 55 6e UTF8ToString(Un
7760: 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
7770: 73 2e 73 71 6c 69 74 65 33 5f 64 62 5f 66 69 6c s.sqlite3_db_fil
7780: 65 6e 61 6d 65 5f 62 79 74 65 73 28 0d 0a 20 20 ename_bytes(..
7790: 20 20 20 20 20 20 20 20 20 20 5f 73 71 6c 2c 20 _sql,
77a0: 54 6f 55 54 46 38 28 64 62 4e 61 6d 65 29 29 2c ToUTF8(dbName)),
77b0: 20 2d 31 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a -1);.. }....
77c0: 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
77d0: 72 72 69 64 65 20 76 6f 69 64 20 4f 70 65 6e 28 rride void Open(
77e0: 73 74 72 69 6e 67 20 73 74 72 46 69 6c 65 6e 61 string strFilena
77f0: 6d 65 2c 20 73 74 72 69 6e 67 20 76 66 73 4e 61 me, string vfsNa
7800: 6d 65 2c 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 me, SQLiteConnec
7810: 74 69 6f 6e 46 6c 61 67 73 20 63 6f 6e 6e 65 63 tionFlags connec
7820: 74 69 6f 6e 46 6c 61 67 73 2c 20 53 51 4c 69 74 tionFlags, SQLit
7830: 65 4f 70 65 6e 46 6c 61 67 73 45 6e 75 6d 20 6f eOpenFlagsEnum o
7840: 70 65 6e 46 6c 61 67 73 2c 20 69 6e 74 20 6d 61 penFlags, int ma
7850: 78 50 6f 6f 6c 53 69 7a 65 2c 20 62 6f 6f 6c 20 xPoolSize, bool
7860: 75 73 65 50 6f 6f 6c 29 0d 0a 20 20 20 20 7b 0d usePool).. {.
7870: 0a 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 . //..
7880: 20 2f 2f 20 4e 4f 54 45 3a 20 49 66 20 74 68 65 // NOTE: If the
7890: 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 database connec
78a0: 74 69 6f 6e 20 69 73 20 63 75 72 72 65 6e 74 6c tion is currentl
78b0: 79 20 6f 70 65 6e 2c 20 61 74 74 65 6d 70 74 20 y open, attempt
78c0: 74 6f 0d 0a 20 20 20 20 20 20 2f 2f 20 20 20 20 to.. //
78d0: 20 20 20 63 6c 6f 73 65 20 69 74 20 6e 6f 77 2e close it now.
78e0: 20 20 54 68 69 73 20 6d 75 73 74 20 62 65 20 64 This must be d
78f0: 6f 6e 65 20 62 65 63 61 75 73 65 20 74 68 65 20 one because the
7900: 66 69 6c 65 20 6e 61 6d 65 20 6f 72 0d 0a 20 20 file name or..
7910: 20 20 20 20 2f 2f 20 20 20 20 20 20 20 6f 74 68 // oth
7920: 65 72 20 70 61 72 61 6d 65 74 65 72 73 20 74 68 er parameters th
7930: 61 74 20 6d 61 79 20 69 6d 70 61 63 74 20 74 68 at may impact th
7940: 65 20 75 6e 64 65 72 6c 79 69 6e 67 20 64 61 74 e underlying dat
7950: 61 62 61 73 65 0d 0a 20 20 20 20 20 20 2f 2f 20 abase.. //
7960: 20 20 20 20 20 20 63 6f 6e 6e 65 63 74 69 6f 6e connection
7970: 20 6d 61 79 20 68 61 76 65 20 63 68 61 6e 67 65 may have change
7980: 64 2e 0d 0a 20 20 20 20 20 20 2f 2f 0d 0a 20 20 d... //..
7990: 20 20 20 20 69 66 20 28 5f 73 71 6c 20 21 3d 20 if (_sql !=
79a0: 6e 75 6c 6c 29 20 43 6c 6f 73 65 28 66 61 6c 73 null) Close(fals
79b0: 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 2f 2f 0d e);.... //.
79c0: 0a 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 . // NOTE:
79d0: 49 66 20 74 68 65 20 63 6f 6e 6e 65 63 74 69 6f If the connectio
79e0: 6e 20 77 61 73 20 6e 6f 74 20 63 6c 6f 73 65 64 n was not closed
79f0: 20 73 75 63 63 65 73 73 66 75 6c 6c 79 2c 20 74 successfully, t
7a00: 68 72 6f 77 20 61 6e 0d 0a 20 20 20 20 20 20 2f hrow an.. /
7a10: 2f 20 20 20 20 20 20 20 65 78 63 65 70 74 69 6f / exceptio
7a20: 6e 20 6e 6f 77 2e 0d 0a 20 20 20 20 20 20 2f 2f n now... //
7a30: 0d 0a 20 20 20 20 20 20 69 66 20 28 5f 73 71 6c .. if (_sql
7a40: 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 != null)..
7a50: 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 throw new S
7a60: 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 22 QLiteException("
7a70: 63 6f 6e 6e 65 63 74 69 6f 6e 20 68 61 6e 64 6c connection handl
7a80: 65 20 69 73 20 73 74 69 6c 6c 20 61 63 74 69 76 e is still activ
7a90: 65 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 5f 75 e");.... _u
7aa0: 73 65 50 6f 6f 6c 20 3d 20 75 73 65 50 6f 6f 6c sePool = usePool
7ab0: 3b 0d 0a 20 20 20 20 20 20 5f 66 69 6c 65 4e 61 ;.. _fileNa
7ac0: 6d 65 20 3d 20 73 74 72 46 69 6c 65 6e 61 6d 65 me = strFilename
7ad0: 3b 0d 0a 20 20 20 20 20 20 5f 66 6c 61 67 73 20 ;.. _flags
7ae0: 3d 20 63 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 = connectionFlag
7af0: 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 69 66 20 28 s;.... if (
7b00: 75 73 65 50 6f 6f 6c 29 0d 0a 20 20 20 20 20 20 usePool)..
7b10: 7b 0d 0a 20 20 20 20 20 20 20 20 5f 73 71 6c 20 {.. _sql
7b20: 3d 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 = SQLiteConnecti
7b30: 6f 6e 50 6f 6f 6c 2e 52 65 6d 6f 76 65 28 73 74 onPool.Remove(st
7b40: 72 46 69 6c 65 6e 61 6d 65 2c 20 6d 61 78 50 6f rFilename, maxPo
7b50: 6f 6c 53 69 7a 65 2c 20 6f 75 74 20 5f 70 6f 6f olSize, out _poo
7b60: 6c 56 65 72 73 69 6f 6e 29 3b 0d 0a 0d 0a 20 20 lVersion);....
7b70: 20 20 20 20 20 20 53 51 4c 69 74 65 43 6f 6e 6e SQLiteConn
7b80: 65 63 74 69 6f 6e 2e 4f 6e 43 68 61 6e 67 65 64 ection.OnChanged
7b90: 28 6e 75 6c 6c 2c 20 6e 65 77 20 43 6f 6e 6e 65 (null, new Conne
7ba0: 63 74 69 6f 6e 45 76 65 6e 74 41 72 67 73 28 0d ctionEventArgs(.
7bb0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 53 51 4c . SQL
7bc0: 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 45 76 65 iteConnectionEve
7bd0: 6e 74 54 79 70 65 2e 4f 70 65 6e 65 64 46 72 6f ntType.OpenedFro
7be0: 6d 50 6f 6f 6c 2c 20 6e 75 6c 6c 2c 20 6e 75 6c mPool, null, nul
7bf0: 6c 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 l,..
7c00: 6e 75 6c 6c 2c 20 6e 75 6c 6c 2c 20 5f 73 71 6c null, null, _sql
7c10: 2c 20 73 74 72 46 69 6c 65 6e 61 6d 65 2c 20 6e , strFilename, n
7c20: 65 77 20 6f 62 6a 65 63 74 5b 5d 20 7b 0d 0a 20 ew object[] {..
7c30: 20 20 20 20 20 20 20 20 20 20 20 74 79 70 65 6f typeo
7c40: 66 28 53 51 4c 69 74 65 33 29 2c 20 73 74 72 46 f(SQLite3), strF
7c50: 69 6c 65 6e 61 6d 65 2c 20 76 66 73 4e 61 6d 65 ilename, vfsName
7c60: 2c 20 63 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 , connectionFlag
7c70: 73 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 s,..
7c80: 6f 70 65 6e 46 6c 61 67 73 2c 20 6d 61 78 50 6f openFlags, maxPo
7c90: 6f 6c 53 69 7a 65 2c 20 75 73 65 50 6f 6f 6c 2c olSize, usePool,
7ca0: 20 5f 70 6f 6f 6c 56 65 72 73 69 6f 6e 20 7d 29 _poolVersion })
7cb0: 29 3b 0d 0a 0d 0a 23 69 66 20 21 4e 45 54 5f 43 );....#if !NET_C
7cc0: 4f 4d 50 41 43 54 5f 32 30 20 26 26 20 54 52 41 OMPACT_20 && TRA
7cd0: 43 45 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 CE_CONNECTION..
7ce0: 20 20 20 20 20 20 20 54 72 61 63 65 2e 57 72 69 Trace.Wri
7cf0: 74 65 4c 69 6e 65 28 48 65 6c 70 65 72 4d 65 74 teLine(HelperMet
7d00: 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d 61 hods.StringForma
7d10: 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 t(..
7d20: 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 CultureInfo.Curr
7d30: 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 entCulture,..
7d40: 20 20 20 20 20 20 20 20 20 22 4f 70 65 6e 20 28 "Open (
7d50: 50 6f 6f 6c 29 3a 20 7b 30 7d 22 2c 20 48 61 6e Pool): {0}", Han
7d60: 64 6c 65 54 6f 53 74 72 69 6e 67 28 29 29 29 3b dleToString()));
7d70: 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 ..#endif..
7d80: 7d 0d 0a 0d 0a 20 20 20 20 20 20 69 66 20 28 5f }.... if (_
7d90: 73 71 6c 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 sql == null)..
7da0: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 74 {.. t
7db0: 72 79 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 ry.. {..
7dc0: 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 64 6f // do
7dd0: 20 6e 6f 74 68 69 6e 67 2e 0d 0a 20 20 20 20 20 nothing...
7de0: 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 66 69 }.. fi
7df0: 6e 61 6c 6c 79 20 2f 2a 20 4e 4f 54 45 3a 20 54 nally /* NOTE: T
7e00: 68 72 65 61 64 2e 41 62 6f 72 74 28 29 20 70 72 hread.Abort() pr
7e10: 6f 74 65 63 74 69 6f 6e 2e 20 2a 2f 0d 0a 20 20 otection. */..
7e20: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
7e30: 20 20 20 49 6e 74 50 74 72 20 64 62 20 3d 20 49 IntPtr db = I
7e40: 6e 74 50 74 72 2e 5a 65 72 6f 3b 0d 0a 20 20 20 ntPtr.Zero;..
7e50: 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 SQLiteErr
7e60: 6f 72 43 6f 64 65 20 6e 3b 0d 0a 0d 0a 23 69 66 orCode n;....#if
7e70: 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 !SQLITE_STANDAR
7e80: 44 0d 0a 20 20 20 20 20 20 20 20 20 20 69 6e 74 D.. int
7e90: 20 65 78 74 46 75 6e 63 73 20 3d 20 28 28 63 6f extFuncs = ((co
7ea0: 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 20 26 20 nnectionFlags &
7eb0: 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e SQLiteConnection
7ec0: 46 6c 61 67 73 2e 4e 6f 45 78 74 65 6e 73 69 6f Flags.NoExtensio
7ed0: 6e 46 75 6e 63 74 69 6f 6e 73 29 20 21 3d 20 53 nFunctions) != S
7ee0: 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 QLiteConnectionF
7ef0: 6c 61 67 73 2e 4e 6f 45 78 74 65 6e 73 69 6f 6e lags.NoExtension
7f00: 46 75 6e 63 74 69 6f 6e 73 29 20 3f 20 31 20 3a Functions) ? 1 :
7f10: 20 30 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 0;....
7f20: 20 69 66 20 28 65 78 74 46 75 6e 63 73 20 21 3d if (extFuncs !=
7f30: 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 7b 0).. {
7f40: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6e 20 .. n
7f50: 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 = UnsafeNativeMe
7f60: 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 6f 70 thods.sqlite3_op
7f70: 65 6e 5f 69 6e 74 65 72 6f 70 28 54 6f 55 54 46 en_interop(ToUTF
7f80: 38 28 73 74 72 46 69 6c 65 6e 61 6d 65 29 2c 20 8(strFilename),
7f90: 54 6f 55 54 46 38 28 76 66 73 4e 61 6d 65 29 2c ToUTF8(vfsName),
7fa0: 20 6f 70 65 6e 46 6c 61 67 73 2c 20 65 78 74 46 openFlags, extF
7fb0: 75 6e 63 73 2c 20 72 65 66 20 64 62 29 3b 0d 0a uncs, ref db);..
7fc0: 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 }..
7fd0: 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 23 65 6e else..#en
7fe0: 64 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 7b dif.. {
7ff0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6e 20 .. n
8000: 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 = UnsafeNativeMe
8010: 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 6f 70 thods.sqlite3_op
8020: 65 6e 5f 76 32 28 54 6f 55 54 46 38 28 73 74 72 en_v2(ToUTF8(str
8030: 46 69 6c 65 6e 61 6d 65 29 2c 20 72 65 66 20 64 Filename), ref d
8040: 62 2c 20 6f 70 65 6e 46 6c 61 67 73 2c 20 54 6f b, openFlags, To
8050: 55 54 46 38 28 76 66 73 4e 61 6d 65 29 29 3b 0d UTF8(vfsName));.
8060: 0a 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a . }....
8070: 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 43 54 #if !NET_COMPACT
8080: 5f 32 30 20 26 26 20 54 52 41 43 45 5f 43 4f 4e _20 && TRACE_CON
8090: 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 20 20 20 NECTION..
80a0: 20 20 20 54 72 61 63 65 2e 57 72 69 74 65 4c 69 Trace.WriteLi
80b0: 6e 65 28 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 ne(HelperMethods
80c0: 2e 53 74 72 69 6e 67 46 6f 72 6d 61 74 28 0d 0a .StringFormat(..
80d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 43 75 Cu
80e0: 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e ltureInfo.Curren
80f0: 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 tCulture,..
8100: 20 20 20 20 20 20 20 20 20 22 4f 70 65 6e 3a 20 "Open:
8110: 7b 30 7d 22 2c 20 64 62 29 29 3b 0d 0a 23 65 6e {0}", db));..#en
8120: 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 dif....
8130: 20 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 65 if (n != SQLite
8140: 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 68 ErrorCode.Ok) th
8150: 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 row new SQLiteEx
8160: 63 65 70 74 69 6f 6e 28 6e 2c 20 6e 75 6c 6c 29 ception(n, null)
8170: 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 5f 73 71 ;.. _sq
8180: 6c 20 3d 20 6e 65 77 20 53 51 4c 69 74 65 43 6f l = new SQLiteCo
8190: 6e 6e 65 63 74 69 6f 6e 48 61 6e 64 6c 65 28 64 nnectionHandle(d
81a0: 62 2c 20 74 72 75 65 29 3b 0d 0a 20 20 20 20 20 b, true);..
81b0: 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 6c 6f }.. lo
81c0: 63 6b 20 28 5f 73 71 6c 29 20 7b 20 2f 2a 20 48 ck (_sql) { /* H
81d0: 41 43 4b 3a 20 46 6f 72 63 65 20 74 68 65 20 53 ACK: Force the S
81e0: 79 6e 63 42 6c 6f 63 6b 20 74 6f 20 62 65 20 22 yncBlock to be "
81f0: 63 72 65 61 74 65 64 22 20 6e 6f 77 2e 20 2a 2f created" now. */
8200: 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 }.... SQ
8210: 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 2e 4f LiteConnection.O
8220: 6e 43 68 61 6e 67 65 64 28 6e 75 6c 6c 2c 20 6e nChanged(null, n
8230: 65 77 20 43 6f 6e 6e 65 63 74 69 6f 6e 45 76 65 ew ConnectionEve
8240: 6e 74 41 72 67 73 28 0d 0a 20 20 20 20 20 20 20 ntArgs(..
8250: 20 20 20 20 20 53 51 4c 69 74 65 43 6f 6e 6e 65 SQLiteConne
8260: 63 74 69 6f 6e 45 76 65 6e 74 54 79 70 65 2e 4e ctionEventType.N
8270: 65 77 43 72 69 74 69 63 61 6c 48 61 6e 64 6c 65 ewCriticalHandle
8280: 2c 20 6e 75 6c 6c 2c 0d 0a 20 20 20 20 20 20 20 , null,..
8290: 20 20 20 20 20 6e 75 6c 6c 2c 20 6e 75 6c 6c 2c null, null,
82a0: 20 6e 75 6c 6c 2c 20 5f 73 71 6c 2c 20 73 74 72 null, _sql, str
82b0: 46 69 6c 65 6e 61 6d 65 2c 20 6e 65 77 20 6f 62 Filename, new ob
82c0: 6a 65 63 74 5b 5d 20 7b 0d 0a 20 20 20 20 20 20 ject[] {..
82d0: 20 20 20 20 20 20 74 79 70 65 6f 66 28 53 51 4c typeof(SQL
82e0: 69 74 65 33 29 2c 20 73 74 72 46 69 6c 65 6e 61 ite3), strFilena
82f0: 6d 65 2c 20 76 66 73 4e 61 6d 65 2c 20 63 6f 6e me, vfsName, con
8300: 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2c 0d 0a 20 nectionFlags,..
8310: 20 20 20 20 20 20 20 20 20 20 20 6f 70 65 6e 46 openF
8320: 6c 61 67 73 2c 20 6d 61 78 50 6f 6f 6c 53 69 7a lags, maxPoolSiz
8330: 65 2c 20 75 73 65 50 6f 6f 6c 20 7d 29 29 3b 0d e, usePool }));.
8340: 0a 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 . }....
8350: 20 20 2f 2f 20 42 69 6e 64 20 66 75 6e 63 74 69 // Bind functi
8360: 6f 6e 73 20 74 6f 20 74 68 69 73 20 63 6f 6e 6e ons to this conn
8370: 65 63 74 69 6f 6e 2e 20 20 49 66 20 61 6e 79 20 ection. If any
8380: 70 72 65 76 69 6f 75 73 20 66 75 6e 63 74 69 6f previous functio
8390: 6e 73 20 6f 66 20 74 68 65 20 73 61 6d 65 20 6e ns of the same n
83a0: 61 6d 65 0d 0a 20 20 20 20 20 20 2f 2f 20 77 65 ame.. // we
83b0: 72 65 20 61 6c 72 65 61 64 79 20 62 6f 75 6e 64 re already bound
83c0: 2c 20 74 68 65 6e 20 74 68 65 20 6e 65 77 20 62 , then the new b
83d0: 69 6e 64 69 6e 67 73 20 72 65 70 6c 61 63 65 20 indings replace
83e0: 74 68 65 20 6f 6c 64 2e 0d 0a 20 20 20 20 20 20 the old...
83f0: 69 66 20 28 28 63 6f 6e 6e 65 63 74 69 6f 6e 46 if ((connectionF
8400: 6c 61 67 73 20 26 20 53 51 4c 69 74 65 43 6f 6e lags & SQLiteCon
8410: 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e 4e 6f 42 nectionFlags.NoB
8420: 69 6e 64 46 75 6e 63 74 69 6f 6e 73 29 20 21 3d indFunctions) !=
8430: 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f SQLiteConnectio
8440: 6e 46 6c 61 67 73 2e 4e 6f 42 69 6e 64 46 75 6e nFlags.NoBindFun
8450: 63 74 69 6f 6e 73 29 0d 0a 20 20 20 20 20 20 7b ctions).. {
8460: 0d 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 28 .. if (
8470: 5f 66 75 6e 63 74 69 6f 6e 73 20 3d 3d 20 6e 75 _functions == nu
8480: 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ll)..
8490: 20 20 20 5f 66 75 6e 63 74 69 6f 6e 73 20 3d 20 _functions =
84a0: 6e 65 77 20 44 69 63 74 69 6f 6e 61 72 79 3c 53 new Dictionary<S
84b0: 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 QLiteFunctionAtt
84c0: 72 69 62 75 74 65 2c 20 53 51 4c 69 74 65 46 75 ribute, SQLiteFu
84d0: 6e 63 74 69 6f 6e 3e 28 29 3b 0d 0a 0d 0a 20 20 nction>();....
84e0: 20 20 20 20 20 20 20 20 66 6f 72 65 61 63 68 20 foreach
84f0: 28 4b 65 79 56 61 6c 75 65 50 61 69 72 3c 53 51 (KeyValuePair<SQ
8500: 4c 69 74 65 46 75 6e 63 74 69 6f 6e 41 74 74 72 LiteFunctionAttr
8510: 69 62 75 74 65 2c 20 53 51 4c 69 74 65 46 75 6e ibute, SQLiteFun
8520: 63 74 69 6f 6e 3e 20 70 61 69 72 0d 0a 20 20 20 ction> pair..
8530: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 i
8540: 6e 20 53 51 4c 69 74 65 46 75 6e 63 74 69 6f 6e n SQLiteFunction
8550: 2e 42 69 6e 64 46 75 6e 63 74 69 6f 6e 73 28 74 .BindFunctions(t
8560: 68 69 73 2c 20 63 6f 6e 6e 65 63 74 69 6f 6e 46 his, connectionF
8570: 6c 61 67 73 29 29 0d 0a 20 20 20 20 20 20 20 20 lags))..
8580: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
8590: 20 20 20 5f 66 75 6e 63 74 69 6f 6e 73 5b 70 61 _functions[pa
85a0: 69 72 2e 4b 65 79 5d 20 3d 20 70 61 69 72 2e 56 ir.Key] = pair.V
85b0: 61 6c 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 alue;..
85c0: 20 7d 0d 0a 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 }.. }....
85d0: 20 20 20 20 20 53 65 74 54 69 6d 65 6f 75 74 28 SetTimeout(
85e0: 30 29 3b 0d 0a 20 20 20 20 20 20 47 43 2e 4b 65 0);.. GC.Ke
85f0: 65 70 41 6c 69 76 65 28 5f 73 71 6c 29 3b 0d 0a epAlive(_sql);..
8600: 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 }.... int
8610: 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 ernal override v
8620: 6f 69 64 20 43 6c 65 61 72 50 6f 6f 6c 28 29 0d oid ClearPool().
8630: 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 53 51 . {.. SQ
8640: 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 50 6f LiteConnectionPo
8650: 6f 6c 2e 43 6c 65 61 72 50 6f 6f 6c 28 5f 66 69 ol.ClearPool(_fi
8660: 6c 65 4e 61 6d 65 29 3b 0d 0a 20 20 20 20 7d 0d leName);.. }.
8670: 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
8680: 6f 76 65 72 72 69 64 65 20 69 6e 74 20 43 6f 75 override int Cou
8690: 6e 74 50 6f 6f 6c 28 29 0d 0a 20 20 20 20 7b 0d ntPool().. {.
86a0: 0a 20 20 20 20 20 20 20 20 44 69 63 74 69 6f 6e . Diction
86b0: 61 72 79 3c 73 74 72 69 6e 67 2c 20 69 6e 74 3e ary<string, int>
86c0: 20 63 6f 75 6e 74 73 20 3d 20 6e 75 6c 6c 3b 0d counts = null;.
86d0: 0a 20 20 20 20 20 20 20 20 69 6e 74 20 6f 70 65 . int ope
86e0: 6e 43 6f 75 6e 74 20 3d 20 30 3b 0d 0a 20 20 20 nCount = 0;..
86f0: 20 20 20 20 20 69 6e 74 20 63 6c 6f 73 65 43 6f int closeCo
8700: 75 6e 74 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 unt = 0;..
8710: 20 20 69 6e 74 20 74 6f 74 61 6c 43 6f 75 6e 74 int totalCount
8720: 20 3d 20 30 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 = 0;....
8730: 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f SQLiteConnectio
8740: 6e 50 6f 6f 6c 2e 47 65 74 43 6f 75 6e 74 73 28 nPool.GetCounts(
8750: 5f 66 69 6c 65 4e 61 6d 65 2c 0d 0a 20 20 20 20 _fileName,..
8760: 20 20 20 20 20 20 20 20 72 65 66 20 63 6f 75 6e ref coun
8770: 74 73 2c 20 72 65 66 20 6f 70 65 6e 43 6f 75 6e ts, ref openCoun
8780: 74 2c 20 72 65 66 20 63 6c 6f 73 65 43 6f 75 6e t, ref closeCoun
8790: 74 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 t,..
87a0: 72 65 66 20 74 6f 74 61 6c 43 6f 75 6e 74 29 3b ref totalCount);
87b0: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 .... retu
87c0: 72 6e 20 74 6f 74 61 6c 43 6f 75 6e 74 3b 0d 0a rn totalCount;..
87d0: 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 }.... int
87e0: 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 ernal override v
87f0: 6f 69 64 20 53 65 74 54 69 6d 65 6f 75 74 28 69 oid SetTimeout(i
8800: 6e 74 20 6e 54 69 6d 65 6f 75 74 4d 53 29 0d 0a nt nTimeoutMS)..
8810: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 49 6e 74 {.. Int
8820: 50 74 72 20 64 62 20 3d 20 5f 73 71 6c 3b 0d 0a Ptr db = _sql;..
8830: 20 20 20 20 20 20 69 66 20 28 64 62 20 3d 3d 20 if (db ==
8840: 49 6e 74 50 74 72 2e 5a 65 72 6f 29 20 74 68 72 IntPtr.Zero) thr
8850: 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 ow new SQLiteExc
8860: 65 70 74 69 6f 6e 28 22 6e 6f 20 63 6f 6e 6e 65 eption("no conne
8870: 63 74 69 6f 6e 20 68 61 6e 64 6c 65 20 61 76 61 ction handle ava
8880: 69 6c 61 62 6c 65 22 29 3b 0d 0a 20 20 20 20 20 ilable");..
8890: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
88a0: 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 n = UnsafeNativ
88b0: 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
88c0: 5f 62 75 73 79 5f 74 69 6d 65 6f 75 74 28 64 62 _busy_timeout(db
88d0: 2c 20 6e 54 69 6d 65 6f 75 74 4d 53 29 3b 0d 0a , nTimeoutMS);..
88e0: 20 20 20 20 20 20 69 66 20 28 6e 20 21 3d 20 53 if (n != S
88f0: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f QLiteErrorCode.O
8900: 6b 29 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c k) throw new SQL
8910: 69 74 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 iteException(n,
8920: 47 65 74 4c 61 73 74 45 72 72 6f 72 28 29 29 3b GetLastError());
8930: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
8940: 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
8950: 20 62 6f 6f 6c 20 53 74 65 70 28 53 51 4c 69 74 bool Step(SQLit
8960: 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 29 eStatement stmt)
8970: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 53 .. {.. S
8980: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 6e QLiteErrorCode n
8990: 3b 0d 0a 20 20 20 20 20 20 52 61 6e 64 6f 6d 20 ;.. Random
89a0: 72 6e 64 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 rnd = null;..
89b0: 20 20 20 75 69 6e 74 20 73 74 61 72 74 74 69 63 uint starttic
89c0: 6b 20 3d 20 28 75 69 6e 74 29 45 6e 76 69 72 6f k = (uint)Enviro
89d0: 6e 6d 65 6e 74 2e 54 69 63 6b 43 6f 75 6e 74 3b nment.TickCount;
89e0: 0d 0a 20 20 20 20 20 20 75 69 6e 74 20 74 69 6d .. uint tim
89f0: 65 6f 75 74 20 3d 20 28 75 69 6e 74 29 28 73 74 eout = (uint)(st
8a00: 6d 74 2e 5f 63 6f 6d 6d 61 6e 64 2e 5f 63 6f 6d mt._command._com
8a10: 6d 61 6e 64 54 69 6d 65 6f 75 74 20 2a 20 31 30 mandTimeout * 10
8a20: 30 30 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 52 65 00);.... Re
8a30: 73 65 74 43 61 6e 63 65 6c 43 6f 75 6e 74 28 29 setCancelCount()
8a40: 3b 0d 0a 0d 0a 20 20 20 20 20 20 77 68 69 6c 65 ;.... while
8a50: 20 28 74 72 75 65 29 0d 0a 20 20 20 20 20 20 7b (true).. {
8a60: 0d 0a 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 .. try..
8a70: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
8a80: 20 20 20 20 20 20 2f 2f 20 64 6f 20 6e 6f 74 68 // do noth
8a90: 69 6e 67 2e 0d 0a 20 20 20 20 20 20 20 20 7d 0d ing... }.
8aa0: 0a 20 20 20 20 20 20 20 20 66 69 6e 61 6c 6c 79 . finally
8ab0: 20 2f 2a 20 4e 4f 54 45 3a 20 54 68 72 65 61 64 /* NOTE: Thread
8ac0: 2e 41 62 6f 72 74 28 29 20 70 72 6f 74 65 63 74 .Abort() protect
8ad0: 69 6f 6e 2e 20 2a 2f 0d 0a 20 20 20 20 20 20 20 ion. */..
8ae0: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 6e 20 {.. n
8af0: 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 = UnsafeNativeMe
8b00: 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 73 74 thods.sqlite3_st
8b10: 65 70 28 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f ep(stmt._sqlite_
8b20: 73 74 6d 74 29 3b 0d 0a 20 20 20 20 20 20 20 20 stmt);..
8b30: 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 }.... if
8b40: 28 53 68 6f 75 6c 64 54 68 72 6f 77 46 6f 72 43 (ShouldThrowForC
8b50: 61 6e 63 65 6c 28 29 29 0d 0a 20 20 20 20 20 20 ancel())..
8b60: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
8b70: 20 69 66 20 28 28 6e 20 3d 3d 20 53 51 4c 69 74 if ((n == SQLit
8b80: 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 7c eErrorCode.Ok) |
8b90: 7c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |..
8ba0: 20 20 20 28 6e 20 3d 3d 20 53 51 4c 69 74 65 45 (n == SQLiteE
8bb0: 72 72 6f 72 43 6f 64 65 2e 52 6f 77 29 20 7c 7c rrorCode.Row) ||
8bc0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
8bd0: 20 20 28 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 (n == SQLiteEr
8be0: 72 6f 72 43 6f 64 65 2e 44 6f 6e 65 29 29 0d 0a rorCode.Done))..
8bf0: 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 {..
8c00: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6e n
8c10: 20 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f = SQLiteErrorCo
8c20: 64 65 2e 49 6e 74 65 72 72 75 70 74 3b 0d 0a 20 de.Interrupt;..
8c30: 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a }....
8c40: 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f thro
8c50: 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 w new SQLiteExce
8c60: 70 74 69 6f 6e 28 6e 2c 20 6e 75 6c 6c 29 3b 0d ption(n, null);.
8c70: 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 . }....
8c80: 20 20 20 20 20 20 69 66 20 28 6e 20 3d 3d 20 53 if (n == S
8c90: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 49 QLiteErrorCode.I
8ca0: 6e 74 65 72 72 75 70 74 29 20 72 65 74 75 72 6e nterrupt) return
8cb0: 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 20 false;..
8cc0: 20 69 66 20 28 6e 20 3d 3d 20 53 51 4c 69 74 65 if (n == SQLite
8cd0: 45 72 72 6f 72 43 6f 64 65 2e 52 6f 77 29 20 72 ErrorCode.Row) r
8ce0: 65 74 75 72 6e 20 74 72 75 65 3b 0d 0a 20 20 20 eturn true;..
8cf0: 20 20 20 20 20 69 66 20 28 6e 20 3d 3d 20 53 51 if (n == SQ
8d00: 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 44 6f LiteErrorCode.Do
8d10: 6e 65 29 20 72 65 74 75 72 6e 20 66 61 6c 73 65 ne) return false
8d20: 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 ;.... if
8d30: 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f (n != SQLiteErro
8d40: 72 43 6f 64 65 2e 4f 6b 29 0d 0a 20 20 20 20 20 rCode.Ok)..
8d50: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
8d60: 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 SQLiteErrorCode
8d70: 72 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 r;....
8d80: 2f 2f 20 41 6e 20 65 72 72 6f 72 20 6f 63 63 75 // An error occu
8d90: 72 72 65 64 2c 20 61 74 74 65 6d 70 74 20 74 6f rred, attempt to
8da0: 20 72 65 73 65 74 20 74 68 65 20 73 74 61 74 65 reset the state
8db0: 6d 65 6e 74 2e 20 20 49 66 20 74 68 65 20 72 65 ment. If the re
8dc0: 73 65 74 20 77 6f 72 6b 65 64 20 62 65 63 61 75 set worked becau
8dd0: 73 65 20 74 68 65 0d 0a 20 20 20 20 20 20 20 20 se the..
8de0: 20 20 2f 2f 20 73 63 68 65 6d 61 20 68 61 73 20 // schema has
8df0: 63 68 61 6e 67 65 64 2c 20 72 65 2d 74 72 79 20 changed, re-try
8e00: 74 68 65 20 73 74 65 70 20 61 67 61 69 6e 2e 20 the step again.
8e10: 20 49 66 20 69 74 20 65 72 72 6f 72 65 64 20 6f If it errored o
8e20: 75 72 20 62 65 63 61 75 73 65 20 74 68 65 20 64 ur because the d
8e30: 61 74 61 62 61 73 65 0d 0a 20 20 20 20 20 20 20 atabase..
8e40: 20 20 20 2f 2f 20 69 73 20 6c 6f 63 6b 65 64 2c // is locked,
8e50: 20 74 68 65 6e 20 6b 65 65 70 20 72 65 74 72 79 then keep retry
8e60: 69 6e 67 20 75 6e 74 69 6c 20 74 68 65 20 63 6f ing until the co
8e70: 6d 6d 61 6e 64 20 74 69 6d 65 6f 75 74 20 6f 63 mmand timeout oc
8e80: 63 75 72 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 curs...
8e90: 20 72 20 3d 20 52 65 73 65 74 28 73 74 6d 74 29 r = Reset(stmt)
8ea0: 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 69 ;.... i
8eb0: 66 20 28 72 20 3d 3d 20 53 51 4c 69 74 65 45 72 f (r == SQLiteEr
8ec0: 72 6f 72 43 6f 64 65 2e 4f 6b 29 0d 0a 20 20 20 rorCode.Ok)..
8ed0: 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e throw n
8ee0: 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 ew SQLiteExcepti
8ef0: 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 on(n, GetLastErr
8f00: 6f 72 28 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 or());....
8f10: 20 20 20 20 65 6c 73 65 20 69 66 20 28 28 72 20 else if ((r
8f20: 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f == SQLiteErrorCo
8f30: 64 65 2e 4c 6f 63 6b 65 64 20 7c 7c 20 72 20 3d de.Locked || r =
8f40: 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 = SQLiteErrorCod
8f50: 65 2e 42 75 73 79 29 20 26 26 20 73 74 6d 74 2e e.Busy) && stmt.
8f60: 5f 63 6f 6d 6d 61 6e 64 20 21 3d 20 6e 75 6c 6c _command != null
8f70: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 7b 0d 0a ).. {..
8f80: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4b // K
8f90: 65 65 70 20 74 72 79 69 6e 67 0d 0a 20 20 20 20 eep trying..
8fa0: 20 20 20 20 20 20 20 20 69 66 20 28 72 6e 64 20 if (rnd
8fb0: 3d 3d 20 6e 75 6c 6c 29 20 2f 2f 20 46 69 72 73 == null) // Firs
8fc0: 74 20 74 69 6d 65 20 77 65 27 76 65 20 65 6e 63 t time we've enc
8fd0: 6f 75 6e 74 65 72 65 64 20 74 68 65 20 6c 6f 63 ountered the loc
8fe0: 6b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 k..
8ff0: 20 72 6e 64 20 3d 20 6e 65 77 20 52 61 6e 64 6f rnd = new Rando
9000: 6d 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 m();....
9010: 20 20 20 20 2f 2f 20 49 66 20 77 65 27 76 65 20 // If we've
9020: 65 78 63 65 65 64 65 64 20 74 68 65 20 63 6f 6d exceeded the com
9030: 6d 61 6e 64 27 73 20 74 69 6d 65 6f 75 74 2c 20 mand's timeout,
9040: 67 69 76 65 20 75 70 20 61 6e 64 20 74 68 72 6f give up and thro
9050: 77 20 61 6e 20 65 72 72 6f 72 0d 0a 20 20 20 20 w an error..
9060: 20 20 20 20 20 20 20 20 69 66 20 28 28 75 69 6e if ((uin
9070: 74 29 45 6e 76 69 72 6f 6e 6d 65 6e 74 2e 54 69 t)Environment.Ti
9080: 63 6b 43 6f 75 6e 74 20 2d 20 73 74 61 72 74 74 ckCount - startt
9090: 69 63 6b 20 3e 20 74 69 6d 65 6f 75 74 29 0d 0a ick > timeout)..
90a0: 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 {..
90b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 thr
90c0: 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 ow new SQLiteExc
90d0: 65 70 74 69 6f 6e 28 72 2c 20 47 65 74 4c 61 73 eption(r, GetLas
90e0: 74 45 72 72 6f 72 28 29 29 3b 0d 0a 20 20 20 20 tError());..
90f0: 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
9100: 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 else..
9110: 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 {..
9120: 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4f 74 68 // Oth
9130: 65 72 77 69 73 65 20 73 6c 65 65 70 20 66 6f 72 erwise sleep for
9140: 20 61 20 72 61 6e 64 6f 6d 20 61 6d 6f 75 6e 74 a random amount
9150: 20 6f 66 20 74 69 6d 65 20 75 70 20 74 6f 20 31 of time up to 1
9160: 35 30 6d 73 0d 0a 20 20 20 20 20 20 20 20 20 20 50ms..
9170: 20 20 20 20 53 79 73 74 65 6d 2e 54 68 72 65 61 System.Threa
9180: 64 69 6e 67 2e 54 68 72 65 61 64 2e 53 6c 65 65 ding.Thread.Slee
9190: 70 28 72 6e 64 2e 4e 65 78 74 28 31 2c 20 31 35 p(rnd.Next(1, 15
91a0: 30 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 0));..
91b0: 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 7d }.. }
91c0: 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 .. }..
91d0: 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 }.. }....
91e0: 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
91f0: 0d 0a 20 20 20 20 2f 2f 2f 20 48 61 73 20 74 68 .. /// Has th
9200: 65 20 73 71 6c 69 74 65 33 5f 65 72 72 73 74 72 e sqlite3_errstr
9210: 28 29 20 63 6f 72 65 20 6c 69 62 72 61 72 79 20 () core library
9220: 41 50 49 20 62 65 65 6e 20 63 68 65 63 6b 65 64 API been checked
9230: 20 66 6f 72 20 79 65 74 3f 0d 0a 20 20 20 20 2f for yet?.. /
9240: 2f 2f 20 49 66 20 73 6f 2c 20 69 73 20 69 74 20 // If so, is it
9250: 70 72 65 73 65 6e 74 3f 0d 0a 20 20 20 20 2f 2f present?.. //
9260: 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 / </summary>..
9270: 20 20 70 72 69 76 61 74 65 20 73 74 61 74 69 63 private static
9280: 20 62 6f 6f 6c 3f 20 68 61 76 65 5f 65 72 72 73 bool? have_errs
9290: 74 72 20 3d 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 20 tr = null;....
92a0: 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d /// <summary>.
92b0: 0a 20 20 20 20 2f 2f 2f 20 52 65 74 75 72 6e 73 . /// Returns
92c0: 20 74 68 65 20 65 72 72 6f 72 20 6d 65 73 73 61 the error messa
92d0: 67 65 20 66 6f 72 20 74 68 65 20 73 70 65 63 69 ge for the speci
92e0: 66 69 65 64 20 53 51 4c 69 74 65 20 72 65 74 75 fied SQLite retu
92f0: 72 6e 20 63 6f 64 65 20 75 73 69 6e 67 0d 0a 20 rn code using..
9300: 20 20 20 2f 2f 2f 20 74 68 65 20 73 71 6c 69 74 /// the sqlit
9310: 65 33 5f 65 72 72 73 74 72 28 29 20 66 75 6e 63 e3_errstr() func
9320: 74 69 6f 6e 2c 20 66 61 6c 6c 69 6e 67 20 62 61 tion, falling ba
9330: 63 6b 20 74 6f 20 74 68 65 20 69 6e 74 65 72 6e ck to the intern
9340: 61 6c 20 6c 6f 6f 6b 75 70 0d 0a 20 20 20 20 2f al lookup.. /
9350: 2f 2f 20 74 61 62 6c 65 20 69 66 20 6e 65 63 65 // table if nece
9360: 73 73 61 72 79 2e 0d 0a 20 20 20 20 2f 2f 2f 0d ssary... ///.
9370: 0a 20 20 20 20 2f 2f 2f 20 57 41 52 4e 49 4e 47 . /// WARNING
9380: 3a 20 44 6f 20 6e 6f 74 20 72 65 6d 6f 76 65 20 : Do not remove
9390: 74 68 69 73 20 6d 65 74 68 6f 64 2c 20 69 74 20 this method, it
93a0: 69 73 20 75 73 65 64 20 76 69 61 20 72 65 66 6c is used via refl
93b0: 65 63 74 69 6f 6e 2e 0d 0a 20 20 20 20 2f 2f 2f ection... ///
93c0: 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 </summary>..
93d0: 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 /// <param name
93e0: 3d 22 72 63 22 3e 54 68 65 20 53 51 4c 69 74 65 ="rc">The SQLite
93f0: 20 72 65 74 75 72 6e 20 63 6f 64 65 2e 3c 2f 70 return code.</p
9400: 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c aram>.. /// <
9410: 72 65 74 75 72 6e 73 3e 54 68 65 20 65 72 72 6f returns>The erro
9420: 72 20 6d 65 73 73 61 67 65 20 6f 72 20 6e 75 6c r message or nul
9430: 6c 20 69 66 20 69 74 20 63 61 6e 6e 6f 74 20 62 l if it cannot b
9440: 65 20 66 6f 75 6e 64 2e 3c 2f 72 65 74 75 72 6e e found.</return
9450: 73 3e 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c s>.. internal
9460: 20 73 74 61 74 69 63 20 73 74 72 69 6e 67 20 47 static string G
9470: 65 74 45 72 72 6f 72 53 74 72 69 6e 67 28 53 51 etErrorString(SQ
9480: 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 72 63 LiteErrorCode rc
9490: 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
94a0: 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 7b try.. {
94b0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 .. if
94c0: 20 28 68 61 76 65 5f 65 72 72 73 74 72 20 3d 3d (have_errstr ==
94d0: 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 null)..
94e0: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
94f0: 20 20 20 20 20 20 20 69 6e 74 20 76 65 72 73 69 int versi
9500: 6f 6e 4e 75 6d 62 65 72 20 3d 20 53 51 4c 69 74 onNumber = SQLit
9510: 65 56 65 72 73 69 6f 6e 4e 75 6d 62 65 72 3b 0d eVersionNumber;.
9520: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
9530: 20 68 61 76 65 5f 65 72 72 73 74 72 20 3d 20 28 have_errstr = (
9540: 76 65 72 73 69 6f 6e 4e 75 6d 62 65 72 20 3e 3d versionNumber >=
9550: 20 33 30 30 37 30 31 35 29 3b 0d 0a 20 20 20 20 3007015);..
9560: 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 }....
9570: 20 20 20 20 20 20 20 20 20 69 66 20 28 28 62 6f if ((bo
9580: 6f 6c 29 68 61 76 65 5f 65 72 72 73 74 72 29 0d ol)have_errstr).
9590: 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a . {..
95a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
95b0: 49 6e 74 50 74 72 20 70 74 72 20 3d 20 55 6e 73 IntPtr ptr = Uns
95c0: 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
95d0: 2e 73 71 6c 69 74 65 33 5f 65 72 72 73 74 72 28 .sqlite3_errstr(
95e0: 72 63 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 rc);....
95f0: 20 20 20 20 20 20 20 20 69 66 20 28 70 74 72 20 if (ptr
9600: 21 3d 20 49 6e 74 50 74 72 2e 5a 65 72 6f 29 0d != IntPtr.Zero).
9610: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
9620: 20 7b 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 {..#if !PLATFOR
9630: 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f M_COMPACTFRAMEWO
9640: 52 4b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 RK..
9650: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 4d return M
9660: 61 72 73 68 61 6c 2e 50 74 72 54 6f 53 74 72 69 arshal.PtrToStri
9670: 6e 67 41 6e 73 69 28 70 74 72 29 3b 0d 0a 23 65 ngAnsi(ptr);..#e
9680: 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 lse..
9690: 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 return
96a0: 55 54 46 38 54 6f 53 74 72 69 6e 67 28 70 74 72 UTF8ToString(ptr
96b0: 2c 20 2d 31 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a , -1);..#endif..
96c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
96d0: 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d }.. }
96e0: 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 .. }..
96f0: 20 20 20 20 20 63 61 74 63 68 20 28 45 6e 74 72 catch (Entr
9700: 79 50 6f 69 6e 74 4e 6f 74 46 6f 75 6e 64 45 78 yPointNotFoundEx
9710: 63 65 70 74 69 6f 6e 29 0d 0a 20 20 20 20 20 20 ception)..
9720: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
9730: 20 2f 2f 20 64 6f 20 6e 6f 74 68 69 6e 67 2e 0d // do nothing..
9740: 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 . }....
9750: 20 20 20 20 20 20 72 65 74 75 72 6e 20 46 61 6c return Fal
9760: 6c 62 61 63 6b 47 65 74 45 72 72 6f 72 53 74 72 lbackGetErrorStr
9770: 69 6e 67 28 72 63 29 3b 0d 0a 20 20 20 20 7d 0d ing(rc);.. }.
9780: 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d ... /// <summ
9790: 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 48 61 ary>.. /// Ha
97a0: 73 20 74 68 65 20 73 71 6c 69 74 65 33 5f 73 74 s the sqlite3_st
97b0: 6d 74 5f 72 65 61 64 6f 6e 6c 79 28 29 20 63 6f mt_readonly() co
97c0: 72 65 20 6c 69 62 72 61 72 79 20 41 50 49 20 62 re library API b
97d0: 65 65 6e 20 63 68 65 63 6b 65 64 20 66 6f 72 20 een checked for
97e0: 79 65 74 3f 0d 0a 20 20 20 20 2f 2f 2f 20 49 66 yet?.. /// If
97f0: 20 73 6f 2c 20 69 73 20 69 74 20 70 72 65 73 65 so, is it prese
9800: 6e 74 3f 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 nt?.. /// </s
9810: 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 70 72 69 ummary>.. pri
9820: 76 61 74 65 20 73 74 61 74 69 63 20 62 6f 6f 6c vate static bool
9830: 3f 20 68 61 76 65 5f 73 74 6d 74 5f 72 65 61 64 ? have_stmt_read
9840: 6f 6e 6c 79 20 3d 20 6e 75 6c 6c 3b 0d 0a 0d 0a only = null;....
9850: 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 /// <summary
9860: 3e 0d 0a 20 20 20 20 2f 2f 2f 20 52 65 74 75 72 >.. /// Retur
9870: 6e 73 20 6e 6f 6e 2d 7a 65 72 6f 20 69 66 20 74 ns non-zero if t
9880: 68 65 20 73 70 65 63 69 66 69 65 64 20 73 74 61 he specified sta
9890: 74 65 6d 65 6e 74 20 69 73 20 72 65 61 64 2d 6f tement is read-o
98a0: 6e 6c 79 20 69 6e 20 6e 61 74 75 72 65 2e 0d 0a nly in nature...
98b0: 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 /// </summar
98c0: 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 y>.. /// <par
98d0: 61 6d 20 6e 61 6d 65 3d 22 73 74 6d 74 22 3e 54 am name="stmt">T
98e0: 68 65 20 73 74 61 74 65 6d 65 6e 74 20 74 6f 20 he statement to
98f0: 63 68 65 63 6b 2e 3c 2f 70 61 72 61 6d 3e 0d 0a check.</param>..
9900: 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 /// <returns
9910: 3e 54 72 75 65 20 69 66 20 74 68 65 20 6f 75 74 >True if the out
9920: 65 72 20 71 75 65 72 79 20 69 73 20 72 65 61 64 er query is read
9930: 2d 6f 6e 6c 79 2e 3c 2f 72 65 74 75 72 6e 73 3e -only.</returns>
9940: 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
9950: 76 65 72 72 69 64 65 20 62 6f 6f 6c 20 49 73 52 verride bool IsR
9960: 65 61 64 4f 6e 6c 79 28 0d 0a 20 20 20 20 20 20 eadOnly(..
9970: 20 20 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e SQLiteStatemen
9980: 74 20 73 74 6d 74 0d 0a 20 20 20 20 20 20 20 20 t stmt..
9990: 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
99a0: 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 7b try.. {
99b0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 .. if
99c0: 20 28 68 61 76 65 5f 73 74 6d 74 5f 72 65 61 64 (have_stmt_read
99d0: 6f 6e 6c 79 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 only == null)..
99e0: 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 {..
99f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 6e in
9a00: 74 20 76 65 72 73 69 6f 6e 4e 75 6d 62 65 72 20 t versionNumber
9a10: 3d 20 53 51 4c 69 74 65 56 65 72 73 69 6f 6e 4e = SQLiteVersionN
9a20: 75 6d 62 65 72 3b 0d 0a 20 20 20 20 20 20 20 20 umber;..
9a30: 20 20 20 20 20 20 20 20 68 61 76 65 5f 73 74 6d have_stm
9a40: 74 5f 72 65 61 64 6f 6e 6c 79 20 3d 20 28 76 65 t_readonly = (ve
9a50: 72 73 69 6f 6e 4e 75 6d 62 65 72 20 3e 3d 20 33 rsionNumber >= 3
9a60: 30 30 37 30 30 34 29 3b 0d 0a 20 20 20 20 20 20 007004);..
9a70: 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 }....
9a80: 20 20 20 20 20 20 20 69 66 20 28 28 62 6f 6f 6c if ((bool
9a90: 29 68 61 76 65 5f 73 74 6d 74 5f 72 65 61 64 6f )have_stmt_reado
9aa0: 6e 6c 79 29 0d 0a 20 20 20 20 20 20 20 20 20 20 nly)..
9ab0: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
9ac0: 20 20 20 20 20 72 65 74 75 72 6e 20 55 6e 73 61 return Unsa
9ad0: 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
9ae0: 73 71 6c 69 74 65 33 5f 73 74 6d 74 5f 72 65 61 sqlite3_stmt_rea
9af0: 64 6f 6e 6c 79 28 0d 0a 20 20 20 20 20 20 20 20 donly(..
9b00: 20 20 20 20 20 20 20 20 20 20 20 20 73 74 6d 74 stmt
9b10: 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 29 20 21 ._sqlite_stmt) !
9b20: 3d 20 30 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 = 0;..
9b30: 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a }.. }..
9b40: 20 20 20 20 20 20 20 20 63 61 74 63 68 20 28 45 catch (E
9b50: 6e 74 72 79 50 6f 69 6e 74 4e 6f 74 46 6f 75 6e ntryPointNotFoun
9b60: 64 45 78 63 65 70 74 69 6f 6e 29 0d 0a 20 20 20 dException)..
9b70: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
9b80: 20 20 20 20 2f 2f 20 64 6f 20 6e 6f 74 68 69 6e // do nothin
9b90: 67 2e 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d g... }...
9ba0: 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 . return
9bb0: 66 61 6c 73 65 3b 20 2f 2a 20 4e 4f 54 45 3a 20 false; /* NOTE:
9bc0: 55 6e 6b 6e 6f 77 6e 2c 20 61 73 73 75 6d 65 20 Unknown, assume
9bd0: 66 61 6c 73 65 2e 20 2a 2f 0d 0a 20 20 20 20 7d false. */.. }
9be0: 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
9bf0: 20 6f 76 65 72 72 69 64 65 20 53 51 4c 69 74 65 override SQLite
9c00: 45 72 72 6f 72 43 6f 64 65 20 52 65 73 65 74 28 ErrorCode Reset(
9c10: 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 SQLiteStatement
9c20: 73 74 6d 74 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 stmt).. {..
9c30: 20 20 20 20 53 51 4c 69 74 65 45 72 72 6f 72 43 SQLiteErrorC
9c40: 6f 64 65 20 6e 3b 0d 0a 0d 0a 23 69 66 20 21 53 ode n;....#if !S
9c50: 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a QLITE_STANDARD..
9c60: 20 20 20 20 20 20 6e 20 3d 20 55 6e 73 61 66 65 n = Unsafe
9c70: 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
9c80: 6c 69 74 65 33 5f 72 65 73 65 74 5f 69 6e 74 65 lite3_reset_inte
9c90: 72 6f 70 28 73 74 6d 74 2e 5f 73 71 6c 69 74 65 rop(stmt._sqlite
9ca0: 5f 73 74 6d 74 29 3b 0d 0a 23 65 6c 73 65 0d 0a _stmt);..#else..
9cb0: 20 20 20 20 20 20 6e 20 3d 20 55 6e 73 61 66 65 n = Unsafe
9cc0: 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
9cd0: 6c 69 74 65 33 5f 72 65 73 65 74 28 73 74 6d 74 lite3_reset(stmt
9ce0: 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 29 3b 0d ._sqlite_stmt);.
9cf0: 0a 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 .#endif....
9d00: 20 2f 2f 20 49 66 20 74 68 65 20 73 63 68 65 6d // If the schem
9d10: 61 20 63 68 61 6e 67 65 64 2c 20 74 72 79 20 61 a changed, try a
9d20: 6e 64 20 72 65 2d 70 72 65 70 61 72 65 20 69 74 nd re-prepare it
9d30: 0d 0a 20 20 20 20 20 20 69 66 20 28 6e 20 3d 3d .. if (n ==
9d40: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
9d50: 2e 53 63 68 65 6d 61 29 0d 0a 20 20 20 20 20 20 .Schema)..
9d60: 7b 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 52 65 {.. // Re
9d70: 63 72 65 61 74 65 20 61 20 64 75 6d 6d 79 20 73 create a dummy s
9d80: 74 61 74 65 6d 65 6e 74 0d 0a 20 20 20 20 20 20 tatement..
9d90: 20 20 73 74 72 69 6e 67 20 73 74 72 20 3d 20 6e string str = n
9da0: 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 75 73 ull;.. us
9db0: 69 6e 67 20 28 53 51 4c 69 74 65 53 74 61 74 65 ing (SQLiteState
9dc0: 6d 65 6e 74 20 74 6d 70 20 3d 20 50 72 65 70 61 ment tmp = Prepa
9dd0: 72 65 28 6e 75 6c 6c 2c 20 73 74 6d 74 2e 5f 73 re(null, stmt._s
9de0: 71 6c 53 74 61 74 65 6d 65 6e 74 2c 20 6e 75 6c qlStatement, nul
9df0: 6c 2c 20 28 75 69 6e 74 29 28 73 74 6d 74 2e 5f l, (uint)(stmt._
9e00: 63 6f 6d 6d 61 6e 64 2e 5f 63 6f 6d 6d 61 6e 64 command._command
9e10: 54 69 6d 65 6f 75 74 20 2a 20 31 30 30 30 29 2c Timeout * 1000),
9e20: 20 72 65 66 20 73 74 72 29 29 0d 0a 20 20 20 20 ref str))..
9e30: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
9e40: 20 2f 2f 20 46 69 6e 61 6c 69 7a 65 20 74 68 65 // Finalize the
9e50: 20 65 78 69 73 74 69 6e 67 20 73 74 61 74 65 6d existing statem
9e60: 65 6e 74 0d 0a 20 20 20 20 20 20 20 20 20 20 73 ent.. s
9e70: 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 tmt._sqlite_stmt
9e80: 2e 44 69 73 70 6f 73 65 28 29 3b 0d 0a 20 20 20 .Dispose();..
9e90: 20 20 20 20 20 20 20 2f 2f 20 52 65 61 73 73 69 // Reassi
9ea0: 67 6e 20 61 20 6e 65 77 20 73 74 61 74 65 6d 65 gn a new stateme
9eb0: 6e 74 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 nt pointer to th
9ec0: 65 20 6f 6c 64 20 73 74 61 74 65 6d 65 6e 74 20 e old statement
9ed0: 61 6e 64 20 63 6c 65 61 72 20 74 68 65 20 74 65 and clear the te
9ee0: 6d 70 6f 72 61 72 79 20 6f 6e 65 0d 0a 20 20 20 mporary one..
9ef0: 20 20 20 20 20 20 20 69 66 20 28 74 6d 70 20 21 if (tmp !
9f00: 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 = null)..
9f10: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
9f20: 20 20 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 stmt._sqlite_s
9f30: 74 6d 74 20 3d 20 74 6d 70 2e 5f 73 71 6c 69 74 tmt = tmp._sqlit
9f40: 65 5f 73 74 6d 74 3b 0d 0a 20 20 20 20 20 20 20 e_stmt;..
9f50: 20 20 20 20 20 74 6d 70 2e 5f 73 71 6c 69 74 65 tmp._sqlite
9f60: 5f 73 74 6d 74 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 _stmt = null;..
9f70: 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 }....
9f80: 20 20 20 20 20 20 20 20 2f 2f 20 52 65 61 70 70 // Reapp
9f90: 6c 79 20 70 61 72 61 6d 65 74 65 72 73 0d 0a 20 ly parameters..
9fa0: 20 20 20 20 20 20 20 20 20 73 74 6d 74 2e 42 69 stmt.Bi
9fb0: 6e 64 50 61 72 61 6d 65 74 65 72 73 28 29 3b 0d ndParameters();.
9fc0: 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 . }..
9fd0: 20 20 20 20 72 65 74 75 72 6e 20 53 51 4c 69 74 return SQLit
9fe0: 65 45 72 72 6f 72 43 6f 64 65 2e 55 6e 6b 6e 6f eErrorCode.Unkno
9ff0: 77 6e 3b 20 2f 2f 20 52 65 73 65 74 20 77 61 73 wn; // Reset was
a000: 20 4f 4b 2c 20 77 69 74 68 20 73 63 68 65 6d 61 OK, with schema
a010: 20 63 68 61 6e 67 65 0d 0a 20 20 20 20 20 20 7d change.. }
a020: 0d 0a 20 20 20 20 20 20 65 6c 73 65 20 69 66 20 .. else if
a030: 28 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f (n == SQLiteErro
a040: 72 43 6f 64 65 2e 4c 6f 63 6b 65 64 20 7c 7c 20 rCode.Locked ||
a050: 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 n == SQLiteError
a060: 43 6f 64 65 2e 42 75 73 79 29 0d 0a 20 20 20 20 Code.Busy)..
a070: 20 20 20 20 72 65 74 75 72 6e 20 6e 3b 0d 0a 0d return n;...
a080: 0a 20 20 20 20 20 20 69 66 20 28 6e 20 21 3d 20 . if (n !=
a090: 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e SQLiteErrorCode.
a0a0: 4f 6b 29 0d 0a 20 20 20 20 20 20 20 20 74 68 72 Ok).. thr
a0b0: 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 ow new SQLiteExc
a0c0: 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 eption(n, GetLas
a0d0: 74 45 72 72 6f 72 28 29 29 3b 0d 0a 0d 0a 20 20 tError());....
a0e0: 20 20 20 20 72 65 74 75 72 6e 20 6e 3b 20 2f 2f return n; //
a0f0: 20 57 65 20 72 65 73 65 74 20 4f 4b 2c 20 6e 6f We reset OK, no
a100: 20 73 63 68 65 6d 61 20 63 68 61 6e 67 65 73 0d schema changes.
a110: 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
a120: 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
a130: 73 74 72 69 6e 67 20 47 65 74 4c 61 73 74 45 72 string GetLastEr
a140: 72 6f 72 28 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 ror().. {..
a150: 20 20 20 20 20 20 72 65 74 75 72 6e 20 47 65 74 return Get
a160: 4c 61 73 74 45 72 72 6f 72 28 6e 75 6c 6c 29 3b LastError(null);
a170: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
a180: 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
a190: 20 73 74 72 69 6e 67 20 47 65 74 4c 61 73 74 45 string GetLastE
a1a0: 72 72 6f 72 28 73 74 72 69 6e 67 20 64 65 66 56 rror(string defV
a1b0: 61 6c 75 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 alue).. {..
a1c0: 20 20 20 20 20 20 73 74 72 69 6e 67 20 72 65 73 string res
a1d0: 75 6c 74 20 3d 20 53 51 4c 69 74 65 42 61 73 65 ult = SQLiteBase
a1e0: 2e 47 65 74 4c 61 73 74 45 72 72 6f 72 28 5f 73 .GetLastError(_s
a1f0: 71 6c 2c 20 5f 73 71 6c 29 3b 0d 0a 20 20 20 20 ql, _sql);..
a200: 20 20 20 20 69 66 20 28 53 74 72 69 6e 67 2e 49 if (String.I
a210: 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 72 65 73 sNullOrEmpty(res
a220: 75 6c 74 29 29 20 72 65 73 75 6c 74 20 3d 20 64 ult)) result = d
a230: 65 66 56 61 6c 75 65 3b 0d 0a 20 20 20 20 20 20 efValue;..
a240: 20 20 72 65 74 75 72 6e 20 72 65 73 75 6c 74 3b return result;
a250: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f .. }.... /
a260: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a270: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a280: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a290: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a2a0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a2b0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a //////////////..
a2c0: 0d 0a 20 20 20 20 23 72 65 67 69 6f 6e 20 51 75 .. #region Qu
a2d0: 65 72 79 20 44 69 61 67 6e 6f 73 74 69 63 73 20 ery Diagnostics
a2e0: 53 75 70 70 6f 72 74 0d 0a 23 69 66 20 21 50 4c Support..#if !PL
a2f0: 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 52 ATFORM_COMPACTFR
a300: 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 2f 2f 2f AMEWORK.. ///
a310: 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 <summary>..
a320: 2f 2f 2f 20 54 68 69 73 20 66 69 65 6c 64 20 69 /// This field i
a330: 73 20 75 73 65 64 20 74 6f 20 6b 65 65 70 20 74 s used to keep t
a340: 72 61 63 6b 20 6f 66 20 77 68 65 74 68 65 72 20 rack of whether
a350: 6f 72 20 6e 6f 74 20 74 68 65 0d 0a 20 20 20 20 or not the..
a360: 2f 2f 2f 20 22 53 51 4c 69 74 65 5f 46 6f 72 63 /// "SQLite_Forc
a370: 65 4c 6f 67 50 72 65 70 61 72 65 22 20 65 6e 76 eLogPrepare" env
a380: 69 72 6f 6e 6d 65 6e 74 20 76 61 72 69 61 62 6c ironment variabl
a390: 65 20 68 61 73 20 62 65 65 6e 20 71 75 65 72 69 e has been queri
a3a0: 65 64 2e 20 20 49 66 20 73 6f 2c 0d 0a 20 20 20 ed. If so,..
a3b0: 20 2f 2f 2f 20 69 74 20 77 69 6c 6c 20 6f 6e 6c /// it will onl
a3c0: 79 20 62 65 20 6e 6f 6e 2d 7a 65 72 6f 20 69 66 y be non-zero if
a3d0: 20 74 68 65 20 65 6e 76 69 72 6f 6e 6d 65 6e 74 the environment
a3e0: 20 76 61 72 69 61 62 6c 65 20 77 61 73 20 70 72 variable was pr
a3f0: 65 73 65 6e 74 2e 0d 0a 20 20 20 20 2f 2f 2f 20 esent... ///
a400: 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 </summary>..
a410: 70 72 69 76 61 74 65 20 73 74 61 74 69 63 20 62 private static b
a420: 6f 6f 6c 3f 20 66 6f 72 63 65 4c 6f 67 50 72 65 ool? forceLogPre
a430: 70 61 72 65 20 3d 20 6e 75 6c 6c 3b 0d 0a 0d 0a pare = null;....
a440: 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////
a450: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a460: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a470: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a480: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a490: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a4a0: 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c ///.... /// <
a4b0: 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
a4c0: 2f 20 44 65 74 65 72 6d 69 6e 65 73 20 69 66 20 / Determines if
a4d0: 61 6c 6c 20 63 61 6c 6c 73 20 74 6f 20 70 72 65 all calls to pre
a4e0: 70 61 72 65 20 61 20 53 51 4c 20 71 75 65 72 79 pare a SQL query
a4f0: 20 77 69 6c 6c 20 62 65 20 6c 6f 67 67 65 64 2c will be logged,
a500: 0d 0a 20 20 20 20 2f 2f 2f 20 72 65 67 61 72 64 .. /// regard
a510: 6c 65 73 73 20 6f 66 20 74 68 65 20 66 6c 61 67 less of the flag
a520: 73 20 66 6f 72 20 74 68 65 20 61 73 73 6f 63 69 s for the associ
a530: 61 74 65 64 20 63 6f 6e 6e 65 63 74 69 6f 6e 2e ated connection.
a540: 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d .. /// </summ
a550: 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 ary>.. /// <r
a560: 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 2f 2f 2f eturns>.. ///
a570: 20 4e 6f 6e 2d 7a 65 72 6f 20 74 6f 20 6c 6f 67 Non-zero to log
a580: 20 61 6c 6c 20 63 61 6c 6c 73 20 74 6f 20 70 72 all calls to pr
a590: 65 70 61 72 65 20 61 20 53 51 4c 20 71 75 65 72 epare a SQL quer
a5a0: 79 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 72 65 y... /// </re
a5b0: 74 75 72 6e 73 3e 0d 0a 20 20 20 20 70 72 69 76 turns>.. priv
a5c0: 61 74 65 20 73 74 61 74 69 63 20 62 6f 6f 6c 20 ate static bool
a5d0: 46 6f 72 63 65 4c 6f 67 50 72 65 70 61 72 65 28 ForceLogPrepare(
a5e0: 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
a5f0: 20 20 6c 6f 63 6b 20 28 73 79 6e 63 52 6f 6f 74 lock (syncRoot
a600: 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 ).. {..
a610: 20 20 20 20 20 20 20 20 20 20 69 66 20 28 66 6f if (fo
a620: 72 63 65 4c 6f 67 50 72 65 70 61 72 65 20 3d 3d rceLogPrepare ==
a630: 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 null)..
a640: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
a650: 20 20 20 20 20 20 20 69 66 20 28 55 6e 73 61 66 if (Unsaf
a660: 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 47 eNativeMethods.G
a670: 65 74 53 65 74 74 69 6e 67 56 61 6c 75 65 28 0d etSettingValue(.
a680: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
a690: 20 20 20 20 20 20 20 20 20 22 53 51 4c 69 74 65 "SQLite
a6a0: 5f 46 6f 72 63 65 4c 6f 67 50 72 65 70 61 72 65 _ForceLogPrepare
a6b0: 22 2c 20 6e 75 6c 6c 29 20 21 3d 20 6e 75 6c 6c ", null) != null
a6c0: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )..
a6d0: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
a6e0: 20 20 20 20 20 20 20 20 20 20 66 6f 72 63 65 4c forceL
a6f0: 6f 67 50 72 65 70 61 72 65 20 3d 20 74 72 75 65 ogPrepare = true
a700: 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ;..
a710: 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 }..
a720: 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 else..
a730: 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 {..
a740: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
a750: 20 20 20 66 6f 72 63 65 4c 6f 67 50 72 65 70 61 forceLogPrepa
a760: 72 65 20 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 re = false;..
a770: 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a }..
a780: 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d }...
a790: 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 . ret
a7a0: 75 72 6e 20 28 62 6f 6f 6c 29 66 6f 72 63 65 4c urn (bool)forceL
a7b0: 6f 67 50 72 65 70 61 72 65 3b 0d 0a 20 20 20 20 ogPrepare;..
a7c0: 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 23 65 }.. }..#e
a7d0: 6e 64 69 66 0d 0a 20 20 20 20 23 65 6e 64 72 65 ndif.. #endre
a7e0: 67 69 6f 6e 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 2f gion.... ////
a7f0: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a800: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a810: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a820: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a830: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
a840: 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 ///////////....
a850: 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 internal over
a860: 72 69 64 65 20 53 51 4c 69 74 65 53 74 61 74 65 ride SQLiteState
a870: 6d 65 6e 74 20 50 72 65 70 61 72 65 28 53 51 4c ment Prepare(SQL
a880: 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 20 63 6e iteConnection cn
a890: 6e 2c 20 73 74 72 69 6e 67 20 73 74 72 53 71 6c n, string strSql
a8a0: 2c 20 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e , SQLiteStatemen
a8b0: 74 20 70 72 65 76 69 6f 75 73 2c 20 75 69 6e 74 t previous, uint
a8c0: 20 74 69 6d 65 6f 75 74 4d 53 2c 20 72 65 66 20 timeoutMS, ref
a8d0: 73 74 72 69 6e 67 20 73 74 72 52 65 6d 61 69 6e string strRemain
a8e0: 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
a8f0: 69 66 20 28 21 53 74 72 69 6e 67 2e 49 73 4e 75 if (!String.IsNu
a900: 6c 6c 4f 72 45 6d 70 74 79 28 73 74 72 53 71 6c llOrEmpty(strSql
a910: 29 29 20 73 74 72 53 71 6c 20 3d 20 73 74 72 53 )) strSql = strS
a920: 71 6c 2e 54 72 69 6d 28 29 3b 0d 0a 20 20 20 20 ql.Trim();..
a930: 20 20 69 66 20 28 21 53 74 72 69 6e 67 2e 49 73 if (!String.Is
a940: 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 73 74 72 53 NullOrEmpty(strS
a950: 71 6c 29 29 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 ql)).. {..
a960: 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 //..
a970: 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 53 51 4c 69 // NOTE: SQLi
a980: 74 65 20 64 6f 65 73 20 6e 6f 74 20 73 75 70 70 te does not supp
a990: 6f 72 74 20 74 68 65 20 63 6f 6e 63 65 70 74 20 ort the concept
a9a0: 6f 66 20 73 65 70 61 72 61 74 65 20 73 63 68 65 of separate sche
a9b0: 6d 61 73 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 mas.. //
a9c0: 20 20 20 20 20 20 69 6e 20 6f 6e 65 20 64 61 74 in one dat
a9d0: 61 62 61 73 65 3b 20 74 68 65 72 65 66 6f 72 65 abase; therefore
a9e0: 2c 20 72 65 6d 6f 76 65 20 74 68 65 20 62 61 73 , remove the bas
a9f0: 65 20 73 63 68 65 6d 61 20 6e 61 6d 65 0d 0a 20 e schema name..
aa00: 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 //
aa10: 75 73 65 64 20 74 6f 20 73 6d 6f 6f 74 68 20 69 used to smooth i
aa20: 6e 74 65 67 72 61 74 69 6f 6e 20 77 69 74 68 20 ntegration with
aa30: 74 68 65 20 62 61 73 65 20 2e 4e 45 54 20 46 72 the base .NET Fr
aa40: 61 6d 65 77 6f 72 6b 0d 0a 20 20 20 20 20 20 20 amework..
aa50: 20 2f 2f 20 20 20 20 20 20 20 64 61 74 61 20 63 // data c
aa60: 6c 61 73 73 65 73 2e 0d 0a 20 20 20 20 20 20 20 lasses...
aa70: 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 73 74 72 //.. str
aa80: 69 6e 67 20 62 61 73 65 53 63 68 65 6d 61 4e 61 ing baseSchemaNa
aa90: 6d 65 20 3d 20 28 63 6e 6e 20 21 3d 20 6e 75 6c me = (cnn != nul
aaa0: 6c 29 20 3f 20 63 6e 6e 2e 5f 62 61 73 65 53 63 l) ? cnn._baseSc
aab0: 68 65 6d 61 4e 61 6d 65 20 3a 20 6e 75 6c 6c 3b hemaName : null;
aac0: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 .... if (
aad0: 21 53 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 !String.IsNullOr
aae0: 45 6d 70 74 79 28 62 61 73 65 53 63 68 65 6d 61 Empty(baseSchema
aaf0: 4e 61 6d 65 29 29 0d 0a 20 20 20 20 20 20 20 20 Name))..
ab00: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 73 74 72 {.. str
ab10: 53 71 6c 20 3d 20 73 74 72 53 71 6c 2e 52 65 70 Sql = strSql.Rep
ab20: 6c 61 63 65 28 0d 0a 20 20 20 20 20 20 20 20 20 lace(..
ab30: 20 20 20 20 20 48 65 6c 70 65 72 4d 65 74 68 6f HelperMetho
ab40: 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d 61 74 28 ds.StringFormat(
ab50: 43 75 6c 74 75 72 65 49 6e 66 6f 2e 49 6e 76 61 CultureInfo.Inva
ab60: 72 69 61 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 riantCulture,..
ab70: 20 20 20 20 20 20 20 20 20 20 20 20 20 22 5b 7b "[{
ab80: 30 7d 5d 2e 22 2c 20 62 61 73 65 53 63 68 65 6d 0}].", baseSchem
ab90: 61 4e 61 6d 65 29 2c 20 53 74 72 69 6e 67 2e 45 aName), String.E
aba0: 6d 70 74 79 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 mpty);....
abb0: 20 20 20 20 73 74 72 53 71 6c 20 3d 20 73 74 72 strSql = str
abc0: 53 71 6c 2e 52 65 70 6c 61 63 65 28 0d 0a 20 20 Sql.Replace(..
abd0: 20 20 20 20 20 20 20 20 20 20 20 20 48 65 6c 70 Help
abe0: 65 72 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 erMethods.String
abf0: 46 6f 72 6d 61 74 28 43 75 6c 74 75 72 65 49 6e Format(CultureIn
ac00: 66 6f 2e 49 6e 76 61 72 69 61 6e 74 43 75 6c 74 fo.InvariantCult
ac10: 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 ure,..
ac20: 20 20 20 20 22 7b 30 7d 2e 22 2c 20 62 61 73 65 "{0}.", base
ac30: 53 63 68 65 6d 61 4e 61 6d 65 29 2c 20 53 74 72 SchemaName), Str
ac40: 69 6e 67 2e 45 6d 70 74 79 29 3b 0d 0a 20 20 20 ing.Empty);..
ac50: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 7d 0d }.. }.
ac60: 0a 0d 0a 20 20 20 20 20 20 53 51 4c 69 74 65 43 ... SQLiteC
ac70: 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 20 66 onnectionFlags f
ac80: 6c 61 67 73 20 3d 0d 0a 20 20 20 20 20 20 20 20 lags =..
ac90: 20 20 28 63 6e 6e 20 21 3d 20 6e 75 6c 6c 29 20 (cnn != null)
aca0: 3f 20 63 6e 6e 2e 46 6c 61 67 73 20 3a 20 53 51 ? cnn.Flags : SQ
acb0: 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c LiteConnectionFl
acc0: 61 67 73 2e 44 65 66 61 75 6c 74 3b 0d 0a 0d 0a ags.Default;....
acd0: 20 20 20 20 20 20 69 66 20 28 0d 0a 23 69 66 20 if (..#if
ace0: 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 !PLATFORM_COMPAC
acf0: 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 TFRAMEWORK..
ad00: 20 20 20 20 20 20 46 6f 72 63 65 4c 6f 67 50 72 ForceLogPr
ad10: 65 70 61 72 65 28 29 20 7c 7c 0d 0a 23 65 6e 64 epare() ||..#end
ad20: 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 48 65 if.. He
ad30: 6c 70 65 72 4d 65 74 68 6f 64 73 2e 4c 6f 67 50 lperMethods.LogP
ad40: 72 65 70 61 72 65 28 66 6c 61 67 73 29 29 0d 0a repare(flags))..
ad50: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
ad60: 20 20 20 69 66 20 28 28 73 74 72 53 71 6c 20 3d if ((strSql =
ad70: 3d 20 6e 75 6c 6c 29 20 7c 7c 20 28 73 74 72 53 = null) || (strS
ad80: 71 6c 2e 4c 65 6e 67 74 68 20 3d 3d 20 30 29 20 ql.Length == 0)
ad90: 7c 7c 20 28 73 74 72 53 71 6c 2e 54 72 69 6d 28 || (strSql.Trim(
ada0: 29 2e 4c 65 6e 67 74 68 20 3d 3d 20 30 29 29 0d ).Length == 0)).
adb0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 53 . S
adc0: 51 4c 69 74 65 4c 6f 67 2e 4c 6f 67 4d 65 73 73 QLiteLog.LogMess
add0: 61 67 65 28 22 50 72 65 70 61 72 69 6e 67 20 7b age("Preparing {
ade0: 3c 6e 6f 74 68 69 6e 67 3e 7d 2e 2e 2e 22 29 3b <nothing>}...");
adf0: 0d 0a 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 .. else
ae00: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
ae10: 53 51 4c 69 74 65 4c 6f 67 2e 4c 6f 67 4d 65 73 SQLiteLog.LogMes
ae20: 73 61 67 65 28 48 65 6c 70 65 72 4d 65 74 68 6f sage(HelperMetho
ae30: 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d 61 74 28 ds.StringFormat(
ae40: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
ae50: 20 20 20 20 43 75 6c 74 75 72 65 49 6e 66 6f 2e CultureInfo.
ae60: 43 75 72 72 65 6e 74 43 75 6c 74 75 72 65 2c 20 CurrentCulture,
ae70: 22 50 72 65 70 61 72 69 6e 67 20 7b 7b 7b 30 7d "Preparing {{{0}
ae80: 7d 7d 2e 2e 2e 22 2c 20 73 74 72 53 71 6c 29 29 }}...", strSql))
ae90: 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 ;.. }....
aea0: 20 20 20 20 49 6e 74 50 74 72 20 73 74 6d 74 20 IntPtr stmt
aeb0: 3d 20 49 6e 74 50 74 72 2e 5a 65 72 6f 3b 0d 0a = IntPtr.Zero;..
aec0: 20 20 20 20 20 20 49 6e 74 50 74 72 20 70 74 72 IntPtr ptr
aed0: 20 3d 20 49 6e 74 50 74 72 2e 5a 65 72 6f 3b 0d = IntPtr.Zero;.
aee0: 0a 20 20 20 20 20 20 69 6e 74 20 6c 65 6e 20 3d . int len =
aef0: 20 30 3b 0d 0a 20 20 20 20 20 20 53 51 4c 69 74 0;.. SQLit
af00: 65 45 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 53 eErrorCode n = S
af10: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 53 QLiteErrorCode.S
af20: 63 68 65 6d 61 3b 0d 0a 20 20 20 20 20 20 69 6e chema;.. in
af30: 74 20 72 65 74 72 69 65 73 20 3d 20 30 3b 0d 0a t retries = 0;..
af40: 20 20 20 20 20 20 69 6e 74 20 6d 61 78 69 6d 75 int maximu
af50: 6d 52 65 74 72 69 65 73 20 3d 20 28 63 6e 6e 20 mRetries = (cnn
af60: 21 3d 20 6e 75 6c 6c 29 20 3f 20 63 6e 6e 2e 5f != null) ? cnn._
af70: 70 72 65 70 61 72 65 52 65 74 72 69 65 73 20 3a prepareRetries :
af80: 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f SQLiteConnectio
af90: 6e 2e 44 65 66 61 75 6c 74 50 72 65 70 61 72 65 n.DefaultPrepare
afa0: 52 65 74 72 69 65 73 3b 0d 0a 20 20 20 20 20 20 Retries;..
afb0: 62 79 74 65 5b 5d 20 62 20 3d 20 54 6f 55 54 46 byte[] b = ToUTF
afc0: 38 28 73 74 72 53 71 6c 29 3b 0d 0a 20 20 20 20 8(strSql);..
afd0: 20 20 73 74 72 69 6e 67 20 74 79 70 65 64 65 66 string typedef
afe0: 73 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 s = null;..
aff0: 20 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 SQLiteStatement
b000: 20 63 6d 64 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 cmd = null;..
b010: 20 20 20 20 52 61 6e 64 6f 6d 20 72 6e 64 20 3d Random rnd =
b020: 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 75 69 null;.. ui
b030: 6e 74 20 73 74 61 72 74 74 69 63 6b 20 3d 20 28 nt starttick = (
b040: 75 69 6e 74 29 45 6e 76 69 72 6f 6e 6d 65 6e 74 uint)Environment
b050: 2e 54 69 63 6b 43 6f 75 6e 74 3b 0d 0a 0d 0a 20 .TickCount;....
b060: 20 20 20 20 20 52 65 73 65 74 43 61 6e 63 65 6c ResetCancel
b070: 43 6f 75 6e 74 28 29 3b 0d 0a 0d 0a 20 20 20 20 Count();....
b080: 20 20 47 43 48 61 6e 64 6c 65 20 68 61 6e 64 6c GCHandle handl
b090: 65 20 3d 20 47 43 48 61 6e 64 6c 65 2e 41 6c 6c e = GCHandle.All
b0a0: 6f 63 28 62 2c 20 47 43 48 61 6e 64 6c 65 54 79 oc(b, GCHandleTy
b0b0: 70 65 2e 50 69 6e 6e 65 64 29 3b 0d 0a 20 20 20 pe.Pinned);..
b0c0: 20 20 20 49 6e 74 50 74 72 20 70 73 71 6c 20 3d IntPtr psql =
b0d0: 20 68 61 6e 64 6c 65 2e 41 64 64 72 4f 66 50 69 handle.AddrOfPi
b0e0: 6e 6e 65 64 4f 62 6a 65 63 74 28 29 3b 0d 0a 20 nnedObject();..
b0f0: 20 20 20 20 20 53 51 4c 69 74 65 53 74 61 74 65 SQLiteState
b100: 6d 65 6e 74 48 61 6e 64 6c 65 20 73 74 61 74 65 mentHandle state
b110: 6d 65 6e 74 48 61 6e 64 6c 65 20 3d 20 6e 75 6c mentHandle = nul
b120: 6c 3b 0d 0a 20 20 20 20 20 20 74 72 79 0d 0a 20 l;.. try..
b130: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
b140: 77 68 69 6c 65 20 28 28 6e 20 3d 3d 20 53 51 4c while ((n == SQL
b150: 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 53 63 68 iteErrorCode.Sch
b160: 65 6d 61 20 7c 7c 20 6e 20 3d 3d 20 53 51 4c 69 ema || n == SQLi
b170: 74 65 45 72 72 6f 72 43 6f 64 65 2e 4c 6f 63 6b teErrorCode.Lock
b180: 65 64 20 7c 7c 20 6e 20 3d 3d 20 53 51 4c 69 74 ed || n == SQLit
b190: 65 45 72 72 6f 72 43 6f 64 65 2e 42 75 73 79 29 eErrorCode.Busy)
b1a0: 20 26 26 20 72 65 74 72 69 65 73 20 3c 20 6d 61 && retries < ma
b1b0: 78 69 6d 75 6d 52 65 74 72 69 65 73 29 0d 0a 20 ximumRetries)..
b1c0: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
b1d0: 20 20 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 try..
b1e0: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
b1f0: 20 20 2f 2f 20 64 6f 20 6e 6f 74 68 69 6e 67 2e // do nothing.
b200: 0d 0a 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 .. }..
b210: 20 20 20 20 20 20 20 20 20 66 69 6e 61 6c 6c 79 finally
b220: 20 2f 2a 20 4e 4f 54 45 3a 20 54 68 72 65 61 64 /* NOTE: Thread
b230: 2e 41 62 6f 72 74 28 29 20 70 72 6f 74 65 63 74 .Abort() protect
b240: 69 6f 6e 2e 20 2a 2f 0d 0a 20 20 20 20 20 20 20 ion. */..
b250: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
b260: 20 20 73 74 6d 74 20 3d 20 49 6e 74 50 74 72 2e stmt = IntPtr.
b270: 5a 65 72 6f 3b 0d 0a 20 20 20 20 20 20 20 20 20 Zero;..
b280: 20 20 20 70 74 72 20 3d 20 49 6e 74 50 74 72 2e ptr = IntPtr.
b290: 5a 65 72 6f 3b 0d 0a 0d 0a 23 69 66 20 21 53 51 Zero;....#if !SQ
b2a0: 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 LITE_STANDARD..
b2b0: 20 20 20 20 20 20 20 20 20 20 20 6c 65 6e 20 3d len =
b2c0: 20 30 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 0;..
b2d0: 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 n = UnsafeNativ
b2e0: 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
b2f0: 5f 70 72 65 70 61 72 65 5f 69 6e 74 65 72 6f 70 _prepare_interop
b300: 28 5f 73 71 6c 2c 20 70 73 71 6c 2c 20 62 2e 4c (_sql, psql, b.L
b310: 65 6e 67 74 68 20 2d 20 31 2c 20 72 65 66 20 73 ength - 1, ref s
b320: 74 6d 74 2c 20 72 65 66 20 70 74 72 2c 20 72 65 tmt, ref ptr, re
b330: 66 20 6c 65 6e 29 3b 0d 0a 23 65 6c 73 65 0d 0a f len);..#else..
b340: 23 69 66 20 55 53 45 5f 50 52 45 50 41 52 45 5f #if USE_PREPARE_
b350: 56 32 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 V2..
b360: 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 n = UnsafeNative
b370: 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
b380: 70 72 65 70 61 72 65 5f 76 32 28 5f 73 71 6c 2c prepare_v2(_sql,
b390: 20 70 73 71 6c 2c 20 62 2e 4c 65 6e 67 74 68 20 psql, b.Length
b3a0: 2d 20 31 2c 20 72 65 66 20 73 74 6d 74 2c 20 72 - 1, ref stmt, r
b3b0: 65 66 20 70 74 72 29 3b 0d 0a 23 65 6c 73 65 0d ef ptr);..#else.
b3c0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 6e 20 3d . n =
b3d0: 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
b3e0: 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 70 72 65 hods.sqlite3_pre
b3f0: 70 61 72 65 28 5f 73 71 6c 2c 20 70 73 71 6c 2c pare(_sql, psql,
b400: 20 62 2e 4c 65 6e 67 74 68 20 2d 20 31 2c 20 72 b.Length - 1, r
b410: 65 66 20 73 74 6d 74 2c 20 72 65 66 20 70 74 72 ef stmt, ref ptr
b420: 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 );..#endif..
b430: 20 20 20 20 20 20 20 20 6c 65 6e 20 3d 20 2d 31 len = -1
b440: 3b 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 23 69 66 ;..#endif....#if
b450: 20 21 4e 45 54 5f 43 4f 4d 50 41 43 54 5f 32 30 !NET_COMPACT_20
b460: 20 26 26 20 54 52 41 43 45 5f 53 54 41 54 45 4d && TRACE_STATEM
b470: 45 4e 54 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ENT..
b480: 20 54 72 61 63 65 2e 57 72 69 74 65 4c 69 6e 65 Trace.WriteLine
b490: 28 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e 53 (HelperMethods.S
b4a0: 74 72 69 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 tringFormat(..
b4b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 43 75 Cu
b4c0: 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e ltureInfo.Curren
b4d0: 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 tCulture,..
b4e0: 20 20 20 20 20 20 20 20 20 20 20 22 50 72 65 70 "Prep
b4f0: 61 72 65 20 28 7b 30 7d 29 3a 20 7b 31 7d 22 2c are ({0}): {1}",
b500: 20 6e 2c 20 73 74 6d 74 29 29 3b 0d 0a 23 65 6e n, stmt));..#en
b510: 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 dif....
b520: 20 20 20 69 66 20 28 28 6e 20 3d 3d 20 53 51 4c if ((n == SQL
b530: 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 iteErrorCode.Ok)
b540: 20 26 26 20 28 73 74 6d 74 20 21 3d 20 49 6e 74 && (stmt != Int
b550: 50 74 72 2e 5a 65 72 6f 29 29 0d 0a 20 20 20 20 Ptr.Zero))..
b560: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
b570: 20 20 20 20 20 20 20 20 20 69 66 20 28 73 74 61 if (sta
b580: 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 21 3d 20 tementHandle !=
b590: 6e 75 6c 6c 29 20 73 74 61 74 65 6d 65 6e 74 48 null) statementH
b5a0: 61 6e 64 6c 65 2e 44 69 73 70 6f 73 65 28 29 3b andle.Dispose();
b5b0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
b5c0: 73 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 statementHandle
b5d0: 3d 20 6e 65 77 20 53 51 4c 69 74 65 53 74 61 74 = new SQLiteStat
b5e0: 65 6d 65 6e 74 48 61 6e 64 6c 65 28 5f 73 71 6c ementHandle(_sql
b5f0: 2c 20 73 74 6d 74 29 3b 0d 0a 20 20 20 20 20 20 , stmt);..
b600: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
b610: 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 }....
b620: 20 20 69 66 20 28 73 74 61 74 65 6d 65 6e 74 48 if (statementH
b630: 61 6e 64 6c 65 20 21 3d 20 6e 75 6c 6c 29 0d 0a andle != null)..
b640: 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
b650: 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 43 SQLiteC
b660: 6f 6e 6e 65 63 74 69 6f 6e 2e 4f 6e 43 68 61 6e onnection.OnChan
b670: 67 65 64 28 6e 75 6c 6c 2c 20 6e 65 77 20 43 6f ged(null, new Co
b680: 6e 6e 65 63 74 69 6f 6e 45 76 65 6e 74 41 72 67 nnectionEventArg
b690: 73 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 s(..
b6a0: 20 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 SQLiteConnecti
b6b0: 6f 6e 45 76 65 6e 74 54 79 70 65 2e 4e 65 77 43 onEventType.NewC
b6c0: 72 69 74 69 63 61 6c 48 61 6e 64 6c 65 2c 20 6e riticalHandle, n
b6d0: 75 6c 6c 2c 20 6e 75 6c 6c 2c 0d 0a 20 20 20 20 ull, null,..
b6e0: 20 20 20 20 20 20 20 20 20 20 6e 75 6c 6c 2c 20 null,
b6f0: 6e 75 6c 6c 2c 20 73 74 61 74 65 6d 65 6e 74 48 null, statementH
b700: 61 6e 64 6c 65 2c 20 73 74 72 53 71 6c 2c 20 6e andle, strSql, n
b710: 65 77 20 6f 62 6a 65 63 74 5b 5d 20 7b 0d 0a 20 ew object[] {..
b720: 20 20 20 20 20 20 20 20 20 20 20 20 20 74 79 70 typ
b730: 65 6f 66 28 53 51 4c 69 74 65 33 29 2c 20 63 6e eof(SQLite3), cn
b740: 6e 2c 20 73 74 72 53 71 6c 2c 20 70 72 65 76 69 n, strSql, previ
b750: 6f 75 73 2c 20 74 69 6d 65 6f 75 74 4d 53 20 7d ous, timeoutMS }
b760: 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 7d ));.. }
b770: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 69 66 .... if
b780: 20 28 53 68 6f 75 6c 64 54 68 72 6f 77 46 6f 72 (ShouldThrowFor
b790: 43 61 6e 63 65 6c 28 29 29 0d 0a 20 20 20 20 20 Cancel())..
b7a0: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
b7b0: 20 20 20 20 20 20 69 66 20 28 28 6e 20 3d 3d 20 if ((n ==
b7c0: 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e SQLiteErrorCode.
b7d0: 4f 6b 29 20 7c 7c 0d 0a 20 20 20 20 20 20 20 20 Ok) ||..
b7e0: 20 20 20 20 20 20 20 20 20 20 28 6e 20 3d 3d 20 (n ==
b7f0: 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e SQLiteErrorCode.
b800: 52 6f 77 29 20 7c 7c 0d 0a 20 20 20 20 20 20 20 Row) ||..
b810: 20 20 20 20 20 20 20 20 20 20 20 28 6e 20 3d 3d (n ==
b820: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
b830: 2e 44 6f 6e 65 29 29 0d 0a 20 20 20 20 20 20 20 .Done))..
b840: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
b850: 20 20 20 20 20 20 20 20 20 20 20 20 6e 20 3d 20 n =
b860: 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e SQLiteErrorCode.
b870: 49 6e 74 65 72 72 75 70 74 3b 0d 0a 20 20 20 20 Interrupt;..
b880: 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 }....
b890: 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 thr
b8a0: 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 ow new SQLiteExc
b8b0: 65 70 74 69 6f 6e 28 6e 2c 20 6e 75 6c 6c 29 3b eption(n, null);
b8c0: 0d 0a 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d .. }...
b8d0: 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6e . if (n
b8e0: 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 == SQLiteErrorC
b8f0: 6f 64 65 2e 49 6e 74 65 72 72 75 70 74 29 0d 0a ode.Interrupt)..
b900: 20 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 brea
b910: 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 65 6c k;.. el
b920: 73 65 20 69 66 20 28 6e 20 3d 3d 20 53 51 4c 69 se if (n == SQLi
b930: 74 65 45 72 72 6f 72 43 6f 64 65 2e 53 63 68 65 teErrorCode.Sche
b940: 6d 61 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ma)..
b950: 20 72 65 74 72 69 65 73 2b 2b 3b 0d 0a 20 20 20 retries++;..
b960: 20 20 20 20 20 20 20 65 6c 73 65 20 69 66 20 28 else if (
b970: 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 n == SQLiteError
b980: 43 6f 64 65 2e 45 72 72 6f 72 29 0d 0a 20 20 20 Code.Error)..
b990: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
b9a0: 20 20 20 20 20 20 69 66 20 28 53 74 72 69 6e 67 if (String
b9b0: 2e 43 6f 6d 70 61 72 65 28 47 65 74 4c 61 73 74 .Compare(GetLast
b9c0: 45 72 72 6f 72 28 29 2c 20 22 6e 65 61 72 20 5c Error(), "near \
b9d0: 22 54 59 50 45 53 5c 22 3a 20 73 79 6e 74 61 78 "TYPES\": syntax
b9e0: 20 65 72 72 6f 72 22 2c 20 53 74 72 69 6e 67 43 error", StringC
b9f0: 6f 6d 70 61 72 69 73 6f 6e 2e 4f 72 64 69 6e 61 omparison.Ordina
ba00: 6c 49 67 6e 6f 72 65 43 61 73 65 29 20 3d 3d 20 lIgnoreCase) ==
ba10: 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 0)..
ba20: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 {..
ba30: 20 69 6e 74 20 70 6f 73 20 3d 20 73 74 72 53 71 int pos = strSq
ba40: 6c 2e 49 6e 64 65 78 4f 66 28 27 3b 27 29 3b 0d l.IndexOf(';');.
ba50: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 . i
ba60: 66 20 28 70 6f 73 20 3d 3d 20 2d 31 29 20 70 6f f (pos == -1) po
ba70: 73 20 3d 20 73 74 72 53 71 6c 2e 4c 65 6e 67 74 s = strSql.Lengt
ba80: 68 20 2d 20 31 3b 0d 0a 0d 0a 20 20 20 20 20 20 h - 1;....
ba90: 20 20 20 20 20 20 20 20 74 79 70 65 64 65 66 73 typedefs
baa0: 20 3d 20 73 74 72 53 71 6c 2e 53 75 62 73 74 72 = strSql.Substr
bab0: 69 6e 67 28 30 2c 20 70 6f 73 20 2b 20 31 29 3b ing(0, pos + 1);
bac0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
bad0: 73 74 72 53 71 6c 20 3d 20 73 74 72 53 71 6c 2e strSql = strSql.
bae0: 53 75 62 73 74 72 69 6e 67 28 70 6f 73 20 2b 20 Substring(pos +
baf0: 31 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 1);....
bb00: 20 20 20 20 20 73 74 72 52 65 6d 61 69 6e 20 3d strRemain =
bb10: 20 53 74 72 69 6e 67 2e 45 6d 70 74 79 3b 0d 0a String.Empty;..
bb20: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
bb30: 77 68 69 6c 65 20 28 63 6d 64 20 3d 3d 20 6e 75 while (cmd == nu
bb40: 6c 6c 20 26 26 20 73 74 72 53 71 6c 2e 4c 65 6e ll && strSql.Len
bb50: 67 74 68 20 3e 20 30 29 0d 0a 20 20 20 20 20 20 gth > 0)..
bb60: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
bb70: 20 20 20 20 20 20 20 20 20 20 20 63 6d 64 20 3d cmd =
bb80: 20 50 72 65 70 61 72 65 28 63 6e 6e 2c 20 73 74 Prepare(cnn, st
bb90: 72 53 71 6c 2c 20 70 72 65 76 69 6f 75 73 2c 20 rSql, previous,
bba0: 74 69 6d 65 6f 75 74 4d 53 2c 20 72 65 66 20 73 timeoutMS, ref s
bbb0: 74 72 52 65 6d 61 69 6e 29 3b 0d 0a 20 20 20 20 trRemain);..
bbc0: 20 20 20 20 20 20 20 20 20 20 20 20 73 74 72 53 strS
bbd0: 71 6c 20 3d 20 73 74 72 52 65 6d 61 69 6e 3b 0d ql = strRemain;.
bbe0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d . }
bbf0: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ....
bc00: 20 20 69 66 20 28 63 6d 64 20 21 3d 20 6e 75 6c if (cmd != nul
bc10: 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 l)..
bc20: 20 20 20 20 63 6d 64 2e 53 65 74 54 79 70 65 73 cmd.SetTypes
bc30: 28 74 79 70 65 64 65 66 73 29 3b 0d 0a 0d 0a 20 (typedefs);....
bc40: 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 ret
bc50: 75 72 6e 20 63 6d 64 3b 0d 0a 20 20 20 20 20 20 urn cmd;..
bc60: 20 20 20 20 20 20 7d 0d 0a 23 69 66 20 28 4e 45 }..#if (NE
bc70: 54 5f 33 35 20 7c 7c 20 4e 45 54 5f 34 30 20 7c T_35 || NET_40 |
bc80: 7c 20 4e 45 54 5f 34 35 20 7c 7c 20 4e 45 54 5f | NET_45 || NET_
bc90: 34 35 31 20 7c 7c 20 4e 45 54 5f 34 35 32 20 7c 451 || NET_452 |
bca0: 7c 20 4e 45 54 5f 34 36 20 7c 7c 20 4e 45 54 5f | NET_46 || NET_
bcb0: 34 36 31 20 7c 7c 20 4e 45 54 5f 34 36 32 20 7c 461 || NET_462 |
bcc0: 7c 20 4e 45 54 5f 34 37 20 7c 7c 20 4e 45 54 5f | NET_47 || NET_
bcd0: 34 37 31 29 20 26 26 20 21 50 4c 41 54 46 4f 52 471) && !PLATFOR
bce0: 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f M_COMPACTFRAMEWO
bcf0: 52 4b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 RK..
bd00: 65 6c 73 65 20 69 66 20 28 5f 62 75 69 6c 64 69 else if (_buildi
bd10: 6e 67 53 63 68 65 6d 61 20 3d 3d 20 66 61 6c 73 ngSchema == fals
bd20: 65 20 26 26 20 53 74 72 69 6e 67 2e 43 6f 6d 70 e && String.Comp
bd30: 61 72 65 28 47 65 74 4c 61 73 74 45 72 72 6f 72 are(GetLastError
bd40: 28 29 2c 20 30 2c 20 22 6e 6f 20 73 75 63 68 20 (), 0, "no such
bd50: 74 61 62 6c 65 3a 20 54 45 4d 50 2e 53 43 48 45 table: TEMP.SCHE
bd60: 4d 41 22 2c 20 30 2c 20 32 36 2c 20 53 74 72 69 MA", 0, 26, Stri
bd70: 6e 67 43 6f 6d 70 61 72 69 73 6f 6e 2e 4f 72 64 ngComparison.Ord
bd80: 69 6e 61 6c 49 67 6e 6f 72 65 43 61 73 65 29 20 inalIgnoreCase)
bd90: 3d 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 == 0)..
bda0: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
bdb0: 20 20 20 20 73 74 72 52 65 6d 61 69 6e 20 3d 20 strRemain =
bdc0: 53 74 72 69 6e 67 2e 45 6d 70 74 79 3b 0d 0a 20 String.Empty;..
bdd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 5f 62 75 _bu
bde0: 69 6c 64 69 6e 67 53 63 68 65 6d 61 20 3d 20 74 ildingSchema = t
bdf0: 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 rue;..
be00: 20 20 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 try..
be10: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
be20: 20 20 20 20 20 20 20 20 20 20 49 53 51 4c 69 74 ISQLit
be30: 65 53 63 68 65 6d 61 45 78 74 65 6e 73 69 6f 6e eSchemaExtension
be40: 73 20 65 78 74 20 3d 20 28 28 49 53 65 72 76 69 s ext = ((IServi
be50: 63 65 50 72 6f 76 69 64 65 72 29 53 51 4c 69 74 ceProvider)SQLit
be60: 65 46 61 63 74 6f 72 79 2e 49 6e 73 74 61 6e 63 eFactory.Instanc
be70: 65 29 2e 47 65 74 53 65 72 76 69 63 65 28 74 79 e).GetService(ty
be80: 70 65 6f 66 28 49 53 51 4c 69 74 65 53 63 68 65 peof(ISQLiteSche
be90: 6d 61 45 78 74 65 6e 73 69 6f 6e 73 29 29 20 61 maExtensions)) a
bea0: 73 20 49 53 51 4c 69 74 65 53 63 68 65 6d 61 45 s ISQLiteSchemaE
beb0: 78 74 65 6e 73 69 6f 6e 73 3b 0d 0a 0d 0a 20 20 xtensions;....
bec0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 if
bed0: 20 28 65 78 74 20 21 3d 20 6e 75 6c 6c 29 0d 0a (ext != null)..
bee0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
bef0: 20 20 65 78 74 2e 42 75 69 6c 64 54 65 6d 70 53 ext.BuildTempS
bf00: 63 68 65 6d 61 28 63 6e 6e 29 3b 0d 0a 0d 0a 20 chema(cnn);....
bf10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 77 w
bf20: 68 69 6c 65 20 28 63 6d 64 20 3d 3d 20 6e 75 6c hile (cmd == nul
bf30: 6c 20 26 26 20 73 74 72 53 71 6c 2e 4c 65 6e 67 l && strSql.Leng
bf40: 74 68 20 3e 20 30 29 0d 0a 20 20 20 20 20 20 20 th > 0)..
bf50: 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 {..
bf60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6d cm
bf70: 64 20 3d 20 50 72 65 70 61 72 65 28 63 6e 6e 2c d = Prepare(cnn,
bf80: 20 73 74 72 53 71 6c 2c 20 70 72 65 76 69 6f 75 strSql, previou
bf90: 73 2c 20 74 69 6d 65 6f 75 74 4d 53 2c 20 72 65 s, timeoutMS, re
bfa0: 66 20 73 74 72 52 65 6d 61 69 6e 29 3b 0d 0a 20 f strRemain);..
bfb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
bfc0: 20 73 74 72 53 71 6c 20 3d 20 73 74 72 52 65 6d strSql = strRem
bfd0: 61 69 6e 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 ain;..
bfe0: 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 }....
bff0: 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 retur
c000: 6e 20 63 6d 64 3b 0d 0a 20 20 20 20 20 20 20 20 n cmd;..
c010: 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 }..
c020: 20 20 20 20 20 20 20 66 69 6e 61 6c 6c 79 0d 0a finally..
c030: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d {.
c040: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
c050: 20 5f 62 75 69 6c 64 69 6e 67 53 63 68 65 6d 61 _buildingSchema
c060: 20 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 = false;..
c070: 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 }..
c080: 20 20 20 20 20 20 20 20 7d 0d 0a 23 65 6e 64 69 }..#endi
c090: 66 0d 0a 20 20 20 20 20 20 20 20 20 20 7d 0d 0a f.. }..
c0a0: 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 20 69 else i
c0b0: 66 20 28 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 f (n == SQLiteEr
c0c0: 72 6f 72 43 6f 64 65 2e 4c 6f 63 6b 65 64 20 7c rorCode.Locked |
c0d0: 7c 20 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 | n == SQLiteErr
c0e0: 6f 72 43 6f 64 65 2e 42 75 73 79 29 20 2f 2f 20 orCode.Busy) //
c0f0: 4c 6f 63 6b 65 64 20 2d 2d 20 64 65 6c 61 79 20 Locked -- delay
c100: 61 20 73 6d 61 6c 6c 20 61 6d 6f 75 6e 74 20 62 a small amount b
c110: 65 66 6f 72 65 20 72 65 74 72 79 69 6e 67 0d 0a efore retrying..
c120: 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
c130: 20 20 20 20 20 20 20 20 20 2f 2f 20 4b 65 65 70 // Keep
c140: 20 74 72 79 69 6e 67 0d 0a 20 20 20 20 20 20 20 trying..
c150: 20 20 20 20 20 69 66 20 28 72 6e 64 20 3d 3d 20 if (rnd ==
c160: 6e 75 6c 6c 29 20 2f 2f 20 46 69 72 73 74 20 74 null) // First t
c170: 69 6d 65 20 77 65 27 76 65 20 65 6e 63 6f 75 6e ime we've encoun
c180: 74 65 72 65 64 20 74 68 65 20 6c 6f 63 6b 0d 0a tered the lock..
c190: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 6e rn
c1a0: 64 20 3d 20 6e 65 77 20 52 61 6e 64 6f 6d 28 29 d = new Random()
c1b0: 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ;....
c1c0: 20 2f 2f 20 49 66 20 77 65 27 76 65 20 65 78 63 // If we've exc
c1d0: 65 65 64 65 64 20 74 68 65 20 63 6f 6d 6d 61 6e eeded the comman
c1e0: 64 27 73 20 74 69 6d 65 6f 75 74 2c 20 67 69 76 d's timeout, giv
c1f0: 65 20 75 70 20 61 6e 64 20 74 68 72 6f 77 20 61 e up and throw a
c200: 6e 20 65 72 72 6f 72 0d 0a 20 20 20 20 20 20 20 n error..
c210: 20 20 20 20 20 69 66 20 28 28 75 69 6e 74 29 45 if ((uint)E
c220: 6e 76 69 72 6f 6e 6d 65 6e 74 2e 54 69 63 6b 43 nvironment.TickC
c230: 6f 75 6e 74 20 2d 20 73 74 61 72 74 74 69 63 6b ount - starttick
c240: 20 3e 20 74 69 6d 65 6f 75 74 4d 53 29 0d 0a 20 > timeoutMS)..
c250: 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 {..
c260: 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f thro
c270: 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 w new SQLiteExce
c280: 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 ption(n, GetLast
c290: 45 72 72 6f 72 28 29 29 3b 0d 0a 20 20 20 20 20 Error());..
c2a0: 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 }..
c2b0: 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 else..
c2c0: 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
c2d0: 20 20 20 20 20 20 20 20 20 2f 2f 20 4f 74 68 65 // Othe
c2e0: 72 77 69 73 65 20 73 6c 65 65 70 20 66 6f 72 20 rwise sleep for
c2f0: 61 20 72 61 6e 64 6f 6d 20 61 6d 6f 75 6e 74 20 a random amount
c300: 6f 66 20 74 69 6d 65 20 75 70 20 74 6f 20 31 35 of time up to 15
c310: 30 6d 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 0ms..
c320: 20 20 20 53 79 73 74 65 6d 2e 54 68 72 65 61 64 System.Thread
c330: 69 6e 67 2e 54 68 72 65 61 64 2e 53 6c 65 65 70 ing.Thread.Sleep
c340: 28 72 6e 64 2e 4e 65 78 74 28 31 2c 20 31 35 30 (rnd.Next(1, 150
c350: 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ));..
c360: 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 7d 0d }.. }.
c370: 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 . }....
c380: 20 20 20 20 20 20 69 66 20 28 53 68 6f 75 6c 64 if (Should
c390: 54 68 72 6f 77 46 6f 72 43 61 6e 63 65 6c 28 29 ThrowForCancel()
c3a0: 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 ).. {..
c3b0: 20 20 20 20 20 20 20 20 20 20 69 66 20 28 28 6e if ((n
c3c0: 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 == SQLiteErrorC
c3d0: 6f 64 65 2e 4f 6b 29 20 7c 7c 0d 0a 20 20 20 20 ode.Ok) ||..
c3e0: 20 20 20 20 20 20 20 20 20 20 20 20 28 6e 20 3d (n =
c3f0: 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 = SQLiteErrorCod
c400: 65 2e 52 6f 77 29 20 7c 7c 0d 0a 20 20 20 20 20 e.Row) ||..
c410: 20 20 20 20 20 20 20 20 20 20 20 28 6e 20 3d 3d (n ==
c420: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
c430: 2e 44 6f 6e 65 29 29 0d 0a 20 20 20 20 20 20 20 .Done))..
c440: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
c450: 20 20 20 20 20 20 20 20 6e 20 3d 20 53 51 4c 69 n = SQLi
c460: 74 65 45 72 72 6f 72 43 6f 64 65 2e 49 6e 74 65 teErrorCode.Inte
c470: 72 72 75 70 74 3b 0d 0a 20 20 20 20 20 20 20 20 rrupt;..
c480: 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 }....
c490: 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 throw new S
c4a0: 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 6e QLiteException(n
c4b0: 2c 20 6e 75 6c 6c 29 3b 0d 0a 20 20 20 20 20 20 , null);..
c4c0: 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 }.... i
c4d0: 66 20 28 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 f (n == SQLiteEr
c4e0: 72 6f 72 43 6f 64 65 2e 49 6e 74 65 72 72 75 70 rorCode.Interrup
c4f0: 74 29 20 72 65 74 75 72 6e 20 6e 75 6c 6c 3b 0d t) return null;.
c500: 0a 20 20 20 20 20 20 20 20 69 66 20 28 6e 20 21 . if (n !
c510: 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 = SQLiteErrorCod
c520: 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 77 20 e.Ok) throw new
c530: 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 SQLiteException(
c540: 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f 72 28 n, GetLastError(
c550: 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 73 ));.... s
c560: 74 72 52 65 6d 61 69 6e 20 3d 20 55 54 46 38 54 trRemain = UTF8T
c570: 6f 53 74 72 69 6e 67 28 70 74 72 2c 20 6c 65 6e oString(ptr, len
c580: 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 );.... if
c590: 20 28 73 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c (statementHandl
c5a0: 65 20 21 3d 20 6e 75 6c 6c 29 20 63 6d 64 20 3d e != null) cmd =
c5b0: 20 6e 65 77 20 53 51 4c 69 74 65 53 74 61 74 65 new SQLiteState
c5c0: 6d 65 6e 74 28 74 68 69 73 2c 20 66 6c 61 67 73 ment(this, flags
c5d0: 2c 20 73 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c , statementHandl
c5e0: 65 2c 20 73 74 72 53 71 6c 2e 53 75 62 73 74 72 e, strSql.Substr
c5f0: 69 6e 67 28 30 2c 20 73 74 72 53 71 6c 2e 4c 65 ing(0, strSql.Le
c600: 6e 67 74 68 20 2d 20 73 74 72 52 65 6d 61 69 6e ngth - strRemain
c610: 2e 4c 65 6e 67 74 68 29 2c 20 70 72 65 76 69 6f .Length), previo
c620: 75 73 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 us);....
c630: 72 65 74 75 72 6e 20 63 6d 64 3b 0d 0a 20 20 20 return cmd;..
c640: 20 20 20 7d 0d 0a 20 20 20 20 20 20 66 69 6e 61 }.. fina
c650: 6c 6c 79 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 20 lly.. {..
c660: 20 20 20 20 20 20 68 61 6e 64 6c 65 2e 46 72 65 handle.Fre
c670: 65 28 29 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 e();.. }..
c680: 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 70 72 6f 74 }.... prot
c690: 65 63 74 65 64 20 73 74 61 74 69 63 20 76 6f 69 ected static voi
c6a0: 64 20 4c 6f 67 42 69 6e 64 28 53 51 4c 69 74 65 d LogBind(SQLite
c6b0: 53 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 StatementHandle
c6c0: 68 61 6e 64 6c 65 2c 20 69 6e 74 20 69 6e 64 65 handle, int inde
c6d0: 78 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 x).. {..
c6e0: 20 20 20 49 6e 74 50 74 72 20 68 61 6e 64 6c 65 IntPtr handle
c6f0: 49 6e 74 50 74 72 20 3d 20 68 61 6e 64 6c 65 3b IntPtr = handle;
c700: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 .... SQLi
c710: 74 65 4c 6f 67 2e 4c 6f 67 4d 65 73 73 61 67 65 teLog.LogMessage
c720: 28 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e 53 (HelperMethods.S
c730: 74 72 69 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 tringFormat(..
c740: 20 20 20 20 20 20 20 20 20 20 43 75 6c 74 75 72 Cultur
c750: 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c eInfo.CurrentCul
c760: 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 ture,..
c770: 20 20 20 22 42 69 6e 64 69 6e 67 20 73 74 61 74 "Binding stat
c780: 65 6d 65 6e 74 20 7b 30 7d 20 70 61 72 61 6d 74 ement {0} paramt
c790: 65 72 20 23 7b 31 7d 20 61 73 20 4e 55 4c 4c 2e er #{1} as NULL.
c7a0: 2e 2e 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 ..",..
c7b0: 20 20 68 61 6e 64 6c 65 49 6e 74 50 74 72 2c 20 handleIntPtr,
c7c0: 69 6e 64 65 78 29 29 3b 0d 0a 20 20 20 20 7d 0d index));.. }.
c7d0: 0a 0d 0a 20 20 20 20 70 72 6f 74 65 63 74 65 64 ... protected
c7e0: 20 73 74 61 74 69 63 20 76 6f 69 64 20 4c 6f 67 static void Log
c7f0: 42 69 6e 64 28 53 51 4c 69 74 65 53 74 61 74 65 Bind(SQLiteState
c800: 6d 65 6e 74 48 61 6e 64 6c 65 20 68 61 6e 64 6c mentHandle handl
c810: 65 2c 20 69 6e 74 20 69 6e 64 65 78 2c 20 56 61 e, int index, Va
c820: 6c 75 65 54 79 70 65 20 76 61 6c 75 65 29 0d 0a lueType value)..
c830: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 49 {.. I
c840: 6e 74 50 74 72 20 68 61 6e 64 6c 65 49 6e 74 50 ntPtr handleIntP
c850: 74 72 20 3d 20 68 61 6e 64 6c 65 3b 0d 0a 0d 0a tr = handle;....
c860: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 4c 6f SQLiteLo
c870: 67 2e 4c 6f 67 4d 65 73 73 61 67 65 28 48 65 6c g.LogMessage(Hel
c880: 70 65 72 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e perMethods.Strin
c890: 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 gFormat(..
c8a0: 20 20 20 20 20 20 43 75 6c 74 75 72 65 49 6e 66 CultureInf
c8b0: 6f 2e 43 75 72 72 65 6e 74 43 75 6c 74 75 72 65 o.CurrentCulture
c8c0: 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 22 ,.. "
c8d0: 42 69 6e 64 69 6e 67 20 73 74 61 74 65 6d 65 6e Binding statemen
c8e0: 74 20 7b 30 7d 20 70 61 72 61 6d 74 65 72 20 23 t {0} paramter #
c8f0: 7b 31 7d 20 61 73 20 74 79 70 65 20 7b 32 7d 20 {1} as type {2}
c900: 77 69 74 68 20 76 61 6c 75 65 20 7b 7b 7b 33 7d with value {{{3}
c910: 7d 7d 2e 2e 2e 22 2c 0d 0a 20 20 20 20 20 20 20 }}...",..
c920: 20 20 20 20 20 68 61 6e 64 6c 65 49 6e 74 50 74 handleIntPt
c930: 72 2c 20 69 6e 64 65 78 2c 20 76 61 6c 75 65 2e r, index, value.
c940: 47 65 74 54 79 70 65 28 29 2c 20 76 61 6c 75 65 GetType(), value
c950: 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 ));.. }....
c960: 20 20 70 72 69 76 61 74 65 20 73 74 61 74 69 63 private static
c970: 20 73 74 72 69 6e 67 20 46 6f 72 6d 61 74 44 61 string FormatDa
c980: 74 65 54 69 6d 65 28 44 61 74 65 54 69 6d 65 20 teTime(DateTime
c990: 76 61 6c 75 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 value).. {..
c9a0: 20 20 20 20 20 20 20 53 74 72 69 6e 67 42 75 69 StringBui
c9b0: 6c 64 65 72 20 72 65 73 75 6c 74 20 3d 20 6e 65 lder result = ne
c9c0: 77 20 53 74 72 69 6e 67 42 75 69 6c 64 65 72 28 w StringBuilder(
c9d0: 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 );.... re
c9e0: 73 75 6c 74 2e 41 70 70 65 6e 64 28 76 61 6c 75 sult.Append(valu
c9f0: 65 2e 54 6f 53 74 72 69 6e 67 28 22 79 79 79 79 e.ToString("yyyy
ca00: 2d 4d 4d 2d 64 64 54 48 48 3a 6d 6d 3a 73 73 2e -MM-ddTHH:mm:ss.
ca10: 46 46 46 46 46 46 46 4b 22 29 29 3b 0d 0a 20 20 FFFFFFFK"));..
ca20: 20 20 20 20 20 20 72 65 73 75 6c 74 2e 41 70 70 result.App
ca30: 65 6e 64 28 27 20 27 29 3b 0d 0a 20 20 20 20 20 end(' ');..
ca40: 20 20 20 72 65 73 75 6c 74 2e 41 70 70 65 6e 64 result.Append
ca50: 28 76 61 6c 75 65 2e 4b 69 6e 64 29 3b 0d 0a 20 (value.Kind);..
ca60: 20 20 20 20 20 20 20 72 65 73 75 6c 74 2e 41 70 result.Ap
ca70: 70 65 6e 64 28 27 20 27 29 3b 0d 0a 20 20 20 20 pend(' ');..
ca80: 20 20 20 20 72 65 73 75 6c 74 2e 41 70 70 65 6e result.Appen
ca90: 64 28 76 61 6c 75 65 2e 54 69 63 6b 73 29 3b 0d d(value.Ticks);.
caa0: 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 ... retur
cab0: 6e 20 72 65 73 75 6c 74 2e 54 6f 53 74 72 69 6e n result.ToStrin
cac0: 67 28 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 g();.. }....
cad0: 20 20 20 70 72 6f 74 65 63 74 65 64 20 73 74 61 protected sta
cae0: 74 69 63 20 76 6f 69 64 20 4c 6f 67 42 69 6e 64 tic void LogBind
caf0: 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 (SQLiteStatement
cb00: 48 61 6e 64 6c 65 20 68 61 6e 64 6c 65 2c 20 69 Handle handle, i
cb10: 6e 74 20 69 6e 64 65 78 2c 20 44 61 74 65 54 69 nt index, DateTi
cb20: 6d 65 20 76 61 6c 75 65 29 0d 0a 20 20 20 20 7b me value).. {
cb30: 0d 0a 20 20 20 20 20 20 20 20 49 6e 74 50 74 72 .. IntPtr
cb40: 20 68 61 6e 64 6c 65 49 6e 74 50 74 72 20 3d 20 handleIntPtr =
cb50: 68 61 6e 64 6c 65 3b 0d 0a 0d 0a 20 20 20 20 20 handle;....
cb60: 20 20 20 53 51 4c 69 74 65 4c 6f 67 2e 4c 6f 67 SQLiteLog.Log
cb70: 4d 65 73 73 61 67 65 28 48 65 6c 70 65 72 4d 65 Message(HelperMe
cb80: 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d thods.StringForm
cb90: 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 at(..
cba0: 20 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 CultureInfo.Cur
cbb0: 72 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 rentCulture,..
cbc0: 20 20 20 20 20 20 20 20 20 20 22 42 69 6e 64 69 "Bindi
cbd0: 6e 67 20 73 74 61 74 65 6d 65 6e 74 20 7b 30 7d ng statement {0}
cbe0: 20 70 61 72 61 6d 74 65 72 20 23 7b 31 7d 20 61 paramter #{1} a
cbf0: 73 20 74 79 70 65 20 7b 32 7d 20 77 69 74 68 20 s type {2} with
cc00: 76 61 6c 75 65 20 7b 7b 7b 33 7d 7d 7d 2e 2e 2e value {{{3}}}...
cc10: 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ",..
cc20: 68 61 6e 64 6c 65 49 6e 74 50 74 72 2c 20 69 6e handleIntPtr, in
cc30: 64 65 78 2c 20 74 79 70 65 6f 66 28 44 61 74 65 dex, typeof(Date
cc40: 54 69 6d 65 29 2c 20 46 6f 72 6d 61 74 44 61 74 Time), FormatDat
cc50: 65 54 69 6d 65 28 76 61 6c 75 65 29 29 29 3b 0d eTime(value)));.
cc60: 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 70 72 . }.... pr
cc70: 6f 74 65 63 74 65 64 20 73 74 61 74 69 63 20 76 otected static v
cc80: 6f 69 64 20 4c 6f 67 42 69 6e 64 28 53 51 4c 69 oid LogBind(SQLi
cc90: 74 65 53 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c teStatementHandl
cca0: 65 20 68 61 6e 64 6c 65 2c 20 69 6e 74 20 69 6e e handle, int in
ccb0: 64 65 78 2c 20 73 74 72 69 6e 67 20 76 61 6c 75 dex, string valu
ccc0: 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 e).. {..
ccd0: 20 20 20 49 6e 74 50 74 72 20 68 61 6e 64 6c 65 IntPtr handle
cce0: 49 6e 74 50 74 72 20 3d 20 68 61 6e 64 6c 65 3b IntPtr = handle;
ccf0: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 .... SQLi
cd00: 74 65 4c 6f 67 2e 4c 6f 67 4d 65 73 73 61 67 65 teLog.LogMessage
cd10: 28 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e 53 (HelperMethods.S
cd20: 74 72 69 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 tringFormat(..
cd30: 20 20 20 20 20 20 20 20 20 20 43 75 6c 74 75 72 Cultur
cd40: 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c eInfo.CurrentCul
cd50: 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 ture,..
cd60: 20 20 20 22 42 69 6e 64 69 6e 67 20 73 74 61 74 "Binding stat
cd70: 65 6d 65 6e 74 20 7b 30 7d 20 70 61 72 61 6d 74 ement {0} paramt
cd80: 65 72 20 23 7b 31 7d 20 61 73 20 74 79 70 65 20 er #{1} as type
cd90: 7b 32 7d 20 77 69 74 68 20 76 61 6c 75 65 20 7b {2} with value {
cda0: 7b 7b 33 7d 7d 7d 2e 2e 2e 22 2c 0d 0a 20 20 20 {{3}}}...",..
cdb0: 20 20 20 20 20 20 20 20 20 68 61 6e 64 6c 65 49 handleI
cdc0: 6e 74 50 74 72 2c 20 69 6e 64 65 78 2c 20 74 79 ntPtr, index, ty
cdd0: 70 65 6f 66 28 53 74 72 69 6e 67 29 2c 20 28 76 peof(String), (v
cde0: 61 6c 75 65 20 21 3d 20 6e 75 6c 6c 29 20 3f 20 alue != null) ?
cdf0: 76 61 6c 75 65 20 3a 20 22 3c 6e 75 6c 6c 3e 22 value : "<null>"
ce00: 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 ));.. }....
ce10: 20 20 70 72 69 76 61 74 65 20 73 74 61 74 69 63 private static
ce20: 20 73 74 72 69 6e 67 20 54 6f 48 65 78 61 64 65 string ToHexade
ce30: 63 69 6d 61 6c 53 74 72 69 6e 67 28 0d 0a 20 20 cimalString(..
ce40: 20 20 20 20 20 20 62 79 74 65 5b 5d 20 61 72 72 byte[] arr
ce50: 61 79 0d 0a 20 20 20 20 20 20 20 20 29 0d 0a 20 ay.. )..
ce60: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 69 66 {.. if
ce70: 20 28 61 72 72 61 79 20 3d 3d 20 6e 75 6c 6c 29 (array == null)
ce80: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 .. re
ce90: 74 75 72 6e 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 20 turn null;....
cea0: 20 20 20 20 20 20 53 74 72 69 6e 67 42 75 69 6c StringBuil
ceb0: 64 65 72 20 72 65 73 75 6c 74 20 3d 20 6e 65 77 der result = new
cec0: 20 53 74 72 69 6e 67 42 75 69 6c 64 65 72 28 61 StringBuilder(a
ced0: 72 72 61 79 2e 4c 65 6e 67 74 68 20 2a 20 32 29 rray.Length * 2)
cee0: 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 ;.... int
cef0: 20 6c 65 6e 67 74 68 20 3d 20 61 72 72 61 79 2e length = array.
cf00: 4c 65 6e 67 74 68 3b 0d 0a 0d 0a 20 20 20 20 20 Length;....
cf10: 20 20 20 66 6f 72 20 28 69 6e 74 20 69 6e 64 65 for (int inde
cf20: 78 20 3d 20 30 3b 20 69 6e 64 65 78 20 3c 20 6c x = 0; index < l
cf30: 65 6e 67 74 68 3b 20 69 6e 64 65 78 2b 2b 29 0d ength; index++).
cf40: 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 73 . res
cf50: 75 6c 74 2e 41 70 70 65 6e 64 28 61 72 72 61 79 ult.Append(array
cf60: 5b 69 6e 64 65 78 5d 2e 54 6f 53 74 72 69 6e 67 [index].ToString
cf70: 28 22 78 32 22 29 29 3b 0d 0a 0d 0a 20 20 20 20 ("x2"));....
cf80: 20 20 20 20 72 65 74 75 72 6e 20 72 65 73 75 6c return resul
cf90: 74 2e 54 6f 53 74 72 69 6e 67 28 29 3b 0d 0a 20 t.ToString();..
cfa0: 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 70 72 6f 74 }.... prot
cfb0: 65 63 74 65 64 20 73 74 61 74 69 63 20 76 6f 69 ected static voi
cfc0: 64 20 4c 6f 67 42 69 6e 64 28 53 51 4c 69 74 65 d LogBind(SQLite
cfd0: 53 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 StatementHandle
cfe0: 68 61 6e 64 6c 65 2c 20 69 6e 74 20 69 6e 64 65 handle, int inde
cff0: 78 2c 20 62 79 74 65 5b 5d 20 76 61 6c 75 65 29 x, byte[] value)
d000: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
d010: 20 49 6e 74 50 74 72 20 68 61 6e 64 6c 65 49 6e IntPtr handleIn
d020: 74 50 74 72 20 3d 20 68 61 6e 64 6c 65 3b 0d 0a tPtr = handle;..
d030: 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 .. SQLite
d040: 4c 6f 67 2e 4c 6f 67 4d 65 73 73 61 67 65 28 48 Log.LogMessage(H
d050: 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e 53 74 72 elperMethods.Str
d060: 69 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 ingFormat(..
d070: 20 20 20 20 20 20 20 20 43 75 6c 74 75 72 65 49 CultureI
d080: 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c 74 75 nfo.CurrentCultu
d090: 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 re,..
d0a0: 20 22 42 69 6e 64 69 6e 67 20 73 74 61 74 65 6d "Binding statem
d0b0: 65 6e 74 20 7b 30 7d 20 70 61 72 61 6d 74 65 72 ent {0} paramter
d0c0: 20 23 7b 31 7d 20 61 73 20 74 79 70 65 20 7b 32 #{1} as type {2
d0d0: 7d 20 77 69 74 68 20 76 61 6c 75 65 20 7b 7b 7b } with value {{{
d0e0: 33 7d 7d 7d 2e 2e 2e 22 2c 0d 0a 20 20 20 20 20 3}}}...",..
d0f0: 20 20 20 20 20 20 20 68 61 6e 64 6c 65 49 6e 74 handleInt
d100: 50 74 72 2c 20 69 6e 64 65 78 2c 20 74 79 70 65 Ptr, index, type
d110: 6f 66 28 42 79 74 65 5b 5d 29 2c 20 28 76 61 6c of(Byte[]), (val
d120: 75 65 20 21 3d 20 6e 75 6c 6c 29 20 3f 20 54 6f ue != null) ? To
d130: 48 65 78 61 64 65 63 69 6d 61 6c 53 74 72 69 6e HexadecimalStrin
d140: 67 28 76 61 6c 75 65 29 20 3a 20 22 3c 6e 75 6c g(value) : "<nul
d150: 6c 3e 22 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d l>"));.. }...
d160: 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
d170: 65 72 72 69 64 65 20 76 6f 69 64 20 42 69 6e 64 erride void Bind
d180: 5f 44 6f 75 62 6c 65 28 53 51 4c 69 74 65 53 74 _Double(SQLiteSt
d190: 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 53 51 atement stmt, SQ
d1a0: 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c LiteConnectionFl
d1b0: 61 67 73 20 66 6c 61 67 73 2c 20 69 6e 74 20 69 ags flags, int i
d1c0: 6e 64 65 78 2c 20 64 6f 75 62 6c 65 20 76 61 6c ndex, double val
d1d0: 75 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 ue).. {..
d1e0: 20 20 20 20 53 51 4c 69 74 65 53 74 61 74 65 6d SQLiteStatem
d1f0: 65 6e 74 48 61 6e 64 6c 65 20 68 61 6e 64 6c 65 entHandle handle
d200: 20 3d 20 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f = stmt._sqlite_
d210: 73 74 6d 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 stmt;....
d220: 20 69 66 20 28 48 65 6c 70 65 72 4d 65 74 68 6f if (HelperMetho
d230: 64 73 2e 4c 6f 67 42 69 6e 64 28 66 6c 61 67 73 ds.LogBind(flags
d240: 29 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 )).. {..
d250: 20 20 20 20 20 20 20 20 20 20 20 4c 6f 67 42 69 LogBi
d260: 6e 64 28 68 61 6e 64 6c 65 2c 20 69 6e 64 65 78 nd(handle, index
d270: 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 , value);..
d280: 20 20 20 7d 0d 0a 0d 0a 23 69 66 20 21 50 4c 41 }....#if !PLA
d290: 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 52 41 TFORM_COMPACTFRA
d2a0: 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 20 20 20 20 MEWORK..
d2b0: 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 SQLiteErrorCode
d2c0: 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 n = UnsafeNative
d2d0: 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
d2e0: 62 69 6e 64 5f 64 6f 75 62 6c 65 28 68 61 6e 64 bind_double(hand
d2f0: 6c 65 2c 20 69 6e 64 65 78 2c 20 76 61 6c 75 65 le, index, value
d300: 29 3b 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 );.. if (
d310: 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 n != SQLiteError
d320: 43 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e Code.Ok) throw n
d330: 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 ew SQLiteExcepti
d340: 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 on(n, GetLastErr
d350: 6f 72 28 29 29 3b 0d 0a 23 65 6c 69 66 20 21 53 or());..#elif !S
d360: 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a QLITE_STANDARD..
d370: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 SQLiteEr
d380: 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 rorCode n = Unsa
d390: 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
d3a0: 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 64 6f 75 sqlite3_bind_dou
d3b0: 62 6c 65 5f 69 6e 74 65 72 6f 70 28 68 61 6e 64 ble_interop(hand
d3c0: 6c 65 2c 20 69 6e 64 65 78 2c 20 72 65 66 20 76 le, index, ref v
d3d0: 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 alue);..
d3e0: 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 if (n != SQLiteE
d3f0: 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 68 72 rrorCode.Ok) thr
d400: 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 ow new SQLiteExc
d410: 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 eption(n, GetLas
d420: 74 45 72 72 6f 72 28 29 29 3b 0d 0a 23 65 6c 73 tError());..#els
d430: 65 0d 0a 20 20 20 20 20 20 20 20 74 68 72 6f 77 e.. throw
d440: 20 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 6d 65 6e new NotImplemen
d450: 74 65 64 45 78 63 65 70 74 69 6f 6e 28 29 3b 0d tedException();.
d460: 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d 0a .#endif.. }..
d470: 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
d480: 76 65 72 72 69 64 65 20 76 6f 69 64 20 42 69 6e verride void Bin
d490: 64 5f 49 6e 74 33 32 28 53 51 4c 69 74 65 53 74 d_Int32(SQLiteSt
d4a0: 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 53 51 atement stmt, SQ
d4b0: 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c LiteConnectionFl
d4c0: 61 67 73 20 66 6c 61 67 73 2c 20 69 6e 74 20 69 ags flags, int i
d4d0: 6e 64 65 78 2c 20 69 6e 74 20 76 61 6c 75 65 29 ndex, int value)
d4e0: 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
d4f0: 20 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 SQLiteStatement
d500: 48 61 6e 64 6c 65 20 68 61 6e 64 6c 65 20 3d 20 Handle handle =
d510: 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d stmt._sqlite_stm
d520: 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 t;.... if
d530: 20 28 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e (HelperMethods.
d540: 4c 6f 67 42 69 6e 64 28 66 6c 61 67 73 29 29 0d LogBind(flags)).
d550: 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 . {..
d560: 20 20 20 20 20 20 20 20 4c 6f 67 42 69 6e 64 28 LogBind(
d570: 68 61 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 76 handle, index, v
d580: 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 alue);..
d590: 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 4c }.... SQL
d5a0: 69 74 65 45 72 72 6f 72 43 6f 64 65 20 6e 20 3d iteErrorCode n =
d5b0: 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
d5c0: 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 62 69 6e hods.sqlite3_bin
d5d0: 64 5f 69 6e 74 28 68 61 6e 64 6c 65 2c 20 69 6e d_int(handle, in
d5e0: 64 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 20 dex, value);..
d5f0: 20 20 20 20 20 20 69 66 20 28 6e 20 21 3d 20 53 if (n != S
d600: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f QLiteErrorCode.O
d610: 6b 29 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c k) throw new SQL
d620: 69 74 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 iteException(n,
d630: 47 65 74 4c 61 73 74 45 72 72 6f 72 28 29 29 3b GetLastError());
d640: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
d650: 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
d660: 20 76 6f 69 64 20 42 69 6e 64 5f 55 49 6e 74 33 void Bind_UInt3
d670: 32 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 2(SQLiteStatemen
d680: 74 20 73 74 6d 74 2c 20 53 51 4c 69 74 65 43 6f t stmt, SQLiteCo
d690: 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 20 66 6c nnectionFlags fl
d6a0: 61 67 73 2c 20 69 6e 74 20 69 6e 64 65 78 2c 20 ags, int index,
d6b0: 75 69 6e 74 20 76 61 6c 75 65 29 0d 0a 20 20 20 uint value)..
d6c0: 20 7b 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 {.. SQLi
d6d0: 74 65 53 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c teStatementHandl
d6e0: 65 20 68 61 6e 64 6c 65 20 3d 20 73 74 6d 74 2e e handle = stmt.
d6f0: 5f 73 71 6c 69 74 65 5f 73 74 6d 74 3b 0d 0a 0d _sqlite_stmt;...
d700: 0a 20 20 20 20 20 20 20 20 69 66 20 28 48 65 6c . if (Hel
d710: 70 65 72 4d 65 74 68 6f 64 73 2e 4c 6f 67 42 69 perMethods.LogBi
d720: 6e 64 28 66 6c 61 67 73 29 29 0d 0a 20 20 20 20 nd(flags))..
d730: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
d740: 20 20 20 4c 6f 67 42 69 6e 64 28 68 61 6e 64 6c LogBind(handl
d750: 65 2c 20 69 6e 64 65 78 2c 20 76 61 6c 75 65 29 e, index, value)
d760: 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a ;.. }....
d770: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 SQLiteEr
d780: 72 6f 72 43 6f 64 65 20 6e 3b 0d 0a 0d 0a 20 20 rorCode n;....
d790: 20 20 20 20 20 20 69 66 20 28 28 66 6c 61 67 73 if ((flags
d7a0: 20 26 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 & SQLiteConnect
d7b0: 69 6f 6e 46 6c 61 67 73 2e 42 69 6e 64 55 49 6e ionFlags.BindUIn
d7c0: 74 33 32 41 73 49 6e 74 36 34 29 20 3d 3d 20 53 t32AsInt64) == S
d7d0: 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 QLiteConnectionF
d7e0: 6c 61 67 73 2e 42 69 6e 64 55 49 6e 74 33 32 41 lags.BindUInt32A
d7f0: 73 49 6e 74 36 34 29 0d 0a 20 20 20 20 20 20 20 sInt64)..
d800: 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
d810: 6c 6f 6e 67 20 76 61 6c 75 65 32 20 3d 20 76 61 long value2 = va
d820: 6c 75 65 3b 0d 0a 0d 0a 23 69 66 20 21 50 4c 41 lue;....#if !PLA
d830: 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 52 41 TFORM_COMPACTFRA
d840: 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 20 20 20 20 MEWORK..
d850: 20 20 20 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 n = UnsafeNa
d860: 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 tiveMethods.sqli
d870: 74 65 33 5f 62 69 6e 64 5f 69 6e 74 36 34 28 68 te3_bind_int64(h
d880: 61 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 76 61 andle, index, va
d890: 6c 75 65 32 29 3b 0d 0a 23 65 6c 69 66 20 21 53 lue2);..#elif !S
d8a0: 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a QLITE_STANDARD..
d8b0: 20 20 20 20 20 20 20 20 20 20 20 20 6e 20 3d 20 n =
d8c0: 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
d8d0: 6f 64 73 2e 73 71 6c 69 74 65 33 5f 62 69 6e 64 ods.sqlite3_bind
d8e0: 5f 69 6e 74 36 34 5f 69 6e 74 65 72 6f 70 28 68 _int64_interop(h
d8f0: 61 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 72 65 andle, index, re
d900: 66 20 76 61 6c 75 65 32 29 3b 0d 0a 23 65 6c 73 f value2);..#els
d910: 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 74 e.. t
d920: 68 72 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c hrow new NotImpl
d930: 65 6d 65 6e 74 65 64 45 78 63 65 70 74 69 6f 6e ementedException
d940: 28 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 ();..#endif..
d950: 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
d960: 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 7b 0d else.. {.
d970: 0a 20 20 20 20 20 20 20 20 20 20 20 20 6e 20 3d . n =
d980: 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
d990: 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 62 69 6e hods.sqlite3_bin
d9a0: 64 5f 75 69 6e 74 28 68 61 6e 64 6c 65 2c 20 69 d_uint(handle, i
d9b0: 6e 64 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 ndex, value);..
d9c0: 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 }..
d9d0: 20 20 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 if (n != SQLit
d9e0: 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 eErrorCode.Ok) t
d9f0: 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 hrow new SQLiteE
da00: 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c xception(n, GetL
da10: 61 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a 20 20 astError());..
da20: 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 }.... inter
da30: 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f 69 nal override voi
da40: 64 20 42 69 6e 64 5f 49 6e 74 36 34 28 53 51 4c d Bind_Int64(SQL
da50: 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d iteStatement stm
da60: 74 2c 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 t, SQLiteConnect
da70: 69 6f 6e 46 6c 61 67 73 20 66 6c 61 67 73 2c 20 ionFlags flags,
da80: 69 6e 74 20 69 6e 64 65 78 2c 20 6c 6f 6e 67 20 int index, long
da90: 76 61 6c 75 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 value).. {..
daa0: 20 20 20 20 20 20 20 53 51 4c 69 74 65 53 74 61 SQLiteSta
dab0: 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 68 61 6e tementHandle han
dac0: 64 6c 65 20 3d 20 73 74 6d 74 2e 5f 73 71 6c 69 dle = stmt._sqli
dad0: 74 65 5f 73 74 6d 74 3b 0d 0a 0d 0a 20 20 20 20 te_stmt;....
dae0: 20 20 20 20 69 66 20 28 48 65 6c 70 65 72 4d 65 if (HelperMe
daf0: 74 68 6f 64 73 2e 4c 6f 67 42 69 6e 64 28 66 6c thods.LogBind(fl
db00: 61 67 73 29 29 0d 0a 20 20 20 20 20 20 20 20 7b ags)).. {
db10: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 4c 6f .. Lo
db20: 67 42 69 6e 64 28 68 61 6e 64 6c 65 2c 20 69 6e gBind(handle, in
db30: 64 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 20 dex, value);..
db40: 20 20 20 20 20 20 7d 0d 0a 0d 0a 23 69 66 20 21 }....#if !
db50: 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 PLATFORM_COMPACT
db60: 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 20 FRAMEWORK..
db70: 20 20 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f SQLiteErrorCo
db80: 64 65 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 de n = UnsafeNat
db90: 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 iveMethods.sqlit
dba0: 65 33 5f 62 69 6e 64 5f 69 6e 74 36 34 28 68 61 e3_bind_int64(ha
dbb0: 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 76 61 6c ndle, index, val
dbc0: 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 69 66 ue);.. if
dbd0: 20 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 72 (n != SQLiteErr
dbe0: 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 orCode.Ok) throw
dbf0: 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 new SQLiteExcep
dc00: 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 tion(n, GetLastE
dc10: 72 72 6f 72 28 29 29 3b 0d 0a 23 65 6c 69 66 20 rror());..#elif
dc20: 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 !SQLITE_STANDARD
dc30: 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 .. SQLite
dc40: 45 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e ErrorCode n = Un
dc50: 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
dc60: 73 2e 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 69 s.sqlite3_bind_i
dc70: 6e 74 36 34 5f 69 6e 74 65 72 6f 70 28 68 61 6e nt64_interop(han
dc80: 64 6c 65 2c 20 69 6e 64 65 78 2c 20 72 65 66 20 dle, index, ref
dc90: 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 value);..
dca0: 20 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 65 if (n != SQLite
dcb0: 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 68 ErrorCode.Ok) th
dcc0: 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 row new SQLiteEx
dcd0: 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 ception(n, GetLa
dce0: 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a 23 65 6c stError());..#el
dcf0: 73 65 0d 0a 20 20 20 20 20 20 20 20 74 68 72 6f se.. thro
dd00: 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 6d 65 w new NotImpleme
dd10: 6e 74 65 64 45 78 63 65 70 74 69 6f 6e 28 29 3b ntedException();
dd20: 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d ..#endif.. }.
dd30: 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
dd40: 6f 76 65 72 72 69 64 65 20 76 6f 69 64 20 42 69 override void Bi
dd50: 6e 64 5f 55 49 6e 74 36 34 28 53 51 4c 69 74 65 nd_UInt64(SQLite
dd60: 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 Statement stmt,
dd70: 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e SQLiteConnection
dd80: 46 6c 61 67 73 20 66 6c 61 67 73 2c 20 69 6e 74 Flags flags, int
dd90: 20 69 6e 64 65 78 2c 20 75 6c 6f 6e 67 20 76 61 index, ulong va
dda0: 6c 75 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 lue).. {..
ddb0: 20 20 20 20 20 53 51 4c 69 74 65 53 74 61 74 65 SQLiteState
ddc0: 6d 65 6e 74 48 61 6e 64 6c 65 20 68 61 6e 64 6c mentHandle handl
ddd0: 65 20 3d 20 73 74 6d 74 2e 5f 73 71 6c 69 74 65 e = stmt._sqlite
dde0: 5f 73 74 6d 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 _stmt;....
ddf0: 20 20 69 66 20 28 48 65 6c 70 65 72 4d 65 74 68 if (HelperMeth
de00: 6f 64 73 2e 4c 6f 67 42 69 6e 64 28 66 6c 61 67 ods.LogBind(flag
de10: 73 29 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a s)).. {..
de20: 20 20 20 20 20 20 20 20 20 20 20 20 4c 6f 67 42 LogB
de30: 69 6e 64 28 68 61 6e 64 6c 65 2c 20 69 6e 64 65 ind(handle, inde
de40: 78 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 x, value);..
de50: 20 20 20 20 7d 0d 0a 0d 0a 23 69 66 20 21 50 4c }....#if !PL
de60: 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 52 ATFORM_COMPACTFR
de70: 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 20 20 20 AMEWORK..
de80: 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
de90: 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 n = UnsafeNativ
dea0: 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
deb0: 5f 62 69 6e 64 5f 75 69 6e 74 36 34 28 68 61 6e _bind_uint64(han
dec0: 64 6c 65 2c 20 69 6e 64 65 78 2c 20 76 61 6c 75 dle, index, valu
ded0: 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 69 66 20 e);.. if
dee0: 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f (n != SQLiteErro
def0: 72 43 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 20 rCode.Ok) throw
df00: 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 new SQLiteExcept
df10: 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 ion(n, GetLastEr
df20: 72 6f 72 28 29 29 3b 0d 0a 23 65 6c 69 66 20 21 ror());..#elif !
df30: 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d SQLITE_STANDARD.
df40: 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 . SQLiteE
df50: 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 rrorCode n = Uns
df60: 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
df70: 2e 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 75 69 .sqlite3_bind_ui
df80: 6e 74 36 34 5f 69 6e 74 65 72 6f 70 28 68 61 6e nt64_interop(han
df90: 64 6c 65 2c 20 69 6e 64 65 78 2c 20 72 65 66 20 dle, index, ref
dfa0: 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 value);..
dfb0: 20 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 65 if (n != SQLite
dfc0: 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 68 ErrorCode.Ok) th
dfd0: 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 row new SQLiteEx
dfe0: 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 ception(n, GetLa
dff0: 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a 23 65 6c stError());..#el
e000: 73 65 0d 0a 20 20 20 20 20 20 20 20 74 68 72 6f se.. thro
e010: 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 6d 65 w new NotImpleme
e020: 6e 74 65 64 45 78 63 65 70 74 69 6f 6e 28 29 3b ntedException();
e030: 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d ..#endif.. }.
e040: 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
e050: 6f 76 65 72 72 69 64 65 20 76 6f 69 64 20 42 69 override void Bi
e060: 6e 64 5f 42 6f 6f 6c 65 61 6e 28 53 51 4c 69 74 nd_Boolean(SQLit
e070: 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c eStatement stmt,
e080: 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f SQLiteConnectio
e090: 6e 46 6c 61 67 73 20 66 6c 61 67 73 2c 20 69 6e nFlags flags, in
e0a0: 74 20 69 6e 64 65 78 2c 20 62 6f 6f 6c 20 76 61 t index, bool va
e0b0: 6c 75 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 lue).. {..
e0c0: 20 20 20 20 20 53 51 4c 69 74 65 53 74 61 74 65 SQLiteState
e0d0: 6d 65 6e 74 48 61 6e 64 6c 65 20 68 61 6e 64 6c mentHandle handl
e0e0: 65 20 3d 20 73 74 6d 74 2e 5f 73 71 6c 69 74 65 e = stmt._sqlite
e0f0: 5f 73 74 6d 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 _stmt;....
e100: 20 20 69 66 20 28 48 65 6c 70 65 72 4d 65 74 68 if (HelperMeth
e110: 6f 64 73 2e 4c 6f 67 42 69 6e 64 28 66 6c 61 67 ods.LogBind(flag
e120: 73 29 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a s)).. {..
e130: 20 20 20 20 20 20 20 20 20 20 20 20 4c 6f 67 42 LogB
e140: 69 6e 64 28 68 61 6e 64 6c 65 2c 20 69 6e 64 65 ind(handle, inde
e150: 78 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 x, value);..
e160: 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 }....
e170: 20 69 6e 74 20 76 61 6c 75 65 32 20 3d 20 76 61 int value2 = va
e180: 6c 75 65 20 3f 20 31 20 3a 20 30 3b 0d 0a 0d 0a lue ? 1 : 0;....
e190: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 SQLiteEr
e1a0: 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 rorCode n = Unsa
e1b0: 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
e1c0: 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 69 6e 74 sqlite3_bind_int
e1d0: 28 68 61 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 (handle, index,
e1e0: 76 61 6c 75 65 32 29 3b 0d 0a 20 20 20 20 20 20 value2);..
e1f0: 20 20 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 if (n != SQLit
e200: 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 eErrorCode.Ok) t
e210: 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 hrow new SQLiteE
e220: 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c xception(n, GetL
e230: 61 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a 20 20 astError());..
e240: 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 }.... inter
e250: 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f 69 nal override voi
e260: 64 20 42 69 6e 64 5f 54 65 78 74 28 53 51 4c 69 d Bind_Text(SQLi
e270: 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 teStatement stmt
e280: 2c 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 , SQLiteConnecti
e290: 6f 6e 46 6c 61 67 73 20 66 6c 61 67 73 2c 20 69 onFlags flags, i
e2a0: 6e 74 20 69 6e 64 65 78 2c 20 73 74 72 69 6e 67 nt index, string
e2b0: 20 76 61 6c 75 65 29 0d 0a 20 20 20 20 7b 0d 0a value).. {..
e2c0: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 53 74 SQLiteSt
e2d0: 61 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 68 61 atementHandle ha
e2e0: 6e 64 6c 65 20 3d 20 73 74 6d 74 2e 5f 73 71 6c ndle = stmt._sql
e2f0: 69 74 65 5f 73 74 6d 74 3b 0d 0a 0d 0a 20 20 20 ite_stmt;....
e300: 20 20 20 20 20 69 66 20 28 48 65 6c 70 65 72 4d if (HelperM
e310: 65 74 68 6f 64 73 2e 4c 6f 67 42 69 6e 64 28 66 ethods.LogBind(f
e320: 6c 61 67 73 29 29 0d 0a 20 20 20 20 20 20 20 20 lags))..
e330: 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 4c {.. L
e340: 6f 67 42 69 6e 64 28 68 61 6e 64 6c 65 2c 20 69 ogBind(handle, i
e350: 6e 64 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 ndex, value);..
e360: 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 }....
e370: 20 20 20 20 62 79 74 65 5b 5d 20 62 20 3d 20 54 byte[] b = T
e380: 6f 55 54 46 38 28 76 61 6c 75 65 29 3b 0d 0a 0d oUTF8(value);...
e390: 0a 20 20 20 20 20 20 20 20 69 66 20 28 48 65 6c . if (Hel
e3a0: 70 65 72 4d 65 74 68 6f 64 73 2e 4c 6f 67 42 69 perMethods.LogBi
e3b0: 6e 64 28 66 6c 61 67 73 29 29 0d 0a 20 20 20 20 nd(flags))..
e3c0: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
e3d0: 20 20 20 4c 6f 67 42 69 6e 64 28 68 61 6e 64 6c LogBind(handl
e3e0: 65 2c 20 69 6e 64 65 78 2c 20 62 29 3b 0d 0a 20 e, index, b);..
e3f0: 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 }....
e400: 20 20 20 20 53 51 4c 69 74 65 45 72 72 6f 72 43 SQLiteErrorC
e410: 6f 64 65 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 ode n = UnsafeNa
e420: 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 tiveMethods.sqli
e430: 74 65 33 5f 62 69 6e 64 5f 74 65 78 74 28 68 61 te3_bind_text(ha
e440: 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 62 2c 20 ndle, index, b,
e450: 62 2e 4c 65 6e 67 74 68 20 2d 20 31 2c 20 28 49 b.Length - 1, (I
e460: 6e 74 50 74 72 29 28 2d 31 29 29 3b 0d 0a 20 20 ntPtr)(-1));..
e470: 20 20 20 20 20 20 69 66 20 28 6e 20 21 3d 20 53 if (n != S
e480: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f QLiteErrorCode.O
e490: 6b 29 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c k) throw new SQL
e4a0: 69 74 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 iteException(n,
e4b0: 47 65 74 4c 61 73 74 45 72 72 6f 72 28 29 29 3b GetLastError());
e4c0: 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
e4d0: 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
e4e0: 20 76 6f 69 64 20 42 69 6e 64 5f 44 61 74 65 54 void Bind_DateT
e4f0: 69 6d 65 28 53 51 4c 69 74 65 53 74 61 74 65 6d ime(SQLiteStatem
e500: 65 6e 74 20 73 74 6d 74 2c 20 53 51 4c 69 74 65 ent stmt, SQLite
e510: 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 20 ConnectionFlags
e520: 66 6c 61 67 73 2c 20 69 6e 74 20 69 6e 64 65 78 flags, int index
e530: 2c 20 44 61 74 65 54 69 6d 65 20 64 74 29 0d 0a , DateTime dt)..
e540: 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 53 {.. S
e550: 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 48 61 QLiteStatementHa
e560: 6e 64 6c 65 20 68 61 6e 64 6c 65 20 3d 20 73 74 ndle handle = st
e570: 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 3b mt._sqlite_stmt;
e580: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 .... if (
e590: 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e 4c 6f HelperMethods.Lo
e5a0: 67 42 69 6e 64 28 66 6c 61 67 73 29 29 0d 0a 20 gBind(flags))..
e5b0: 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
e5c0: 20 20 20 20 20 20 4c 6f 67 42 69 6e 64 28 68 61 LogBind(ha
e5d0: 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 64 74 29 ndle, index, dt)
e5e0: 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a ;.. }....
e5f0: 20 20 20 20 20 20 20 20 69 66 20 28 28 66 6c 61 if ((fla
e600: 67 73 20 26 20 53 51 4c 69 74 65 43 6f 6e 6e 65 gs & SQLiteConne
e610: 63 74 69 6f 6e 46 6c 61 67 73 2e 42 69 6e 64 44 ctionFlags.BindD
e620: 61 74 65 54 69 6d 65 57 69 74 68 4b 69 6e 64 29 ateTimeWithKind)
e630: 20 3d 3d 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 == SQLiteConnec
e640: 74 69 6f 6e 46 6c 61 67 73 2e 42 69 6e 64 44 61 tionFlags.BindDa
e650: 74 65 54 69 6d 65 57 69 74 68 4b 69 6e 64 29 0d teTimeWithKind).
e660: 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 . {..
e670: 20 20 20 20 20 20 20 20 69 66 20 28 28 5f 64 61 if ((_da
e680: 74 65 74 69 6d 65 4b 69 6e 64 20 21 3d 20 44 61 tetimeKind != Da
e690: 74 65 54 69 6d 65 4b 69 6e 64 2e 55 6e 73 70 65 teTimeKind.Unspe
e6a0: 63 69 66 69 65 64 29 20 26 26 0d 0a 20 20 20 20 cified) &&..
e6b0: 20 20 20 20 20 20 20 20 20 20 20 20 28 64 74 2e (dt.
e6c0: 4b 69 6e 64 20 21 3d 20 44 61 74 65 54 69 6d 65 Kind != DateTime
e6d0: 4b 69 6e 64 2e 55 6e 73 70 65 63 69 66 69 65 64 Kind.Unspecified
e6e0: 29 20 26 26 0d 0a 20 20 20 20 20 20 20 20 20 20 ) &&..
e6f0: 20 20 20 20 20 20 28 64 74 2e 4b 69 6e 64 20 21 (dt.Kind !
e700: 3d 20 5f 64 61 74 65 74 69 6d 65 4b 69 6e 64 29 = _datetimeKind)
e710: 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b ).. {
e720: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
e730: 20 20 69 66 20 28 5f 64 61 74 65 74 69 6d 65 4b if (_datetimeK
e740: 69 6e 64 20 3d 3d 20 44 61 74 65 54 69 6d 65 4b ind == DateTimeK
e750: 69 6e 64 2e 55 74 63 29 0d 0a 20 20 20 20 20 20 ind.Utc)..
e760: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 74 dt
e770: 20 3d 20 64 74 2e 54 6f 55 6e 69 76 65 72 73 61 = dt.ToUniversa
e780: 6c 54 69 6d 65 28 29 3b 0d 0a 20 20 20 20 20 20 lTime();..
e790: 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 20 69 else i
e7a0: 66 20 28 5f 64 61 74 65 74 69 6d 65 4b 69 6e 64 f (_datetimeKind
e7b0: 20 3d 3d 20 44 61 74 65 54 69 6d 65 4b 69 6e 64 == DateTimeKind
e7c0: 2e 4c 6f 63 61 6c 29 0d 0a 20 20 20 20 20 20 20 .Local)..
e7d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 64 74 20 dt
e7e0: 3d 20 64 74 2e 54 6f 4c 6f 63 61 6c 54 69 6d 65 = dt.ToLocalTime
e7f0: 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ();..
e800: 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d }.. }...
e810: 0a 20 20 20 20 20 20 20 20 73 77 69 74 63 68 20 . switch
e820: 28 5f 64 61 74 65 74 69 6d 65 46 6f 72 6d 61 74 (_datetimeFormat
e830: 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 ).. {..
e840: 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 53 case S
e850: 51 4c 69 74 65 44 61 74 65 46 6f 72 6d 61 74 73 QLiteDateFormats
e860: 2e 54 69 63 6b 73 3a 0d 0a 20 20 20 20 20 20 20 .Ticks:..
e870: 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 {..
e880: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e890: 6c 6f 6e 67 20 76 61 6c 75 65 20 3d 20 64 74 2e long value = dt.
e8a0: 54 69 63 6b 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 Ticks;....
e8b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 if
e8c0: 20 28 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e (HelperMethods.
e8d0: 4c 6f 67 42 69 6e 64 28 66 6c 61 67 73 29 29 0d LogBind(flags)).
e8e0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
e8f0: 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
e900: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e910: 4c 6f 67 42 69 6e 64 28 68 61 6e 64 6c 65 2c 20 LogBind(handle,
e920: 69 6e 64 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a index, value);..
e930: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e940: 20 20 20 20 7d 0d 0a 0d 0a 23 69 66 20 21 50 4c }....#if !PL
e950: 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 52 ATFORM_COMPACTFR
e960: 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 20 20 20 AMEWORK..
e970: 20 20 20 20 20 20 20 20 20 20 20 20 20 53 51 4c SQL
e980: 69 74 65 45 72 72 6f 72 43 6f 64 65 20 6e 20 3d iteErrorCode n =
e990: 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
e9a0: 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 62 69 6e hods.sqlite3_bin
e9b0: 64 5f 69 6e 74 36 34 28 68 61 6e 64 6c 65 2c 20 d_int64(handle,
e9c0: 69 6e 64 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a index, value);..
e9d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
e9e0: 20 20 20 20 69 66 20 28 6e 20 21 3d 20 53 51 4c if (n != SQL
e9f0: 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 iteErrorCode.Ok)
ea00: 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 throw new SQLit
ea10: 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 eException(n, Ge
ea20: 74 4c 61 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a tLastError());..
ea30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
ea40: 20 20 20 20 62 72 65 61 6b 3b 0d 0a 23 65 6c 69 break;..#eli
ea50: 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 f !SQLITE_STANDA
ea60: 52 44 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 RD..
ea70: 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 SQLiteEr
ea80: 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 rorCode n = Unsa
ea90: 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
eaa0: 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 69 6e 74 sqlite3_bind_int
eab0: 36 34 5f 69 6e 74 65 72 6f 70 28 68 61 6e 64 6c 64_interop(handl
eac0: 65 2c 20 69 6e 64 65 78 2c 20 72 65 66 20 76 61 e, index, ref va
ead0: 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 lue);..
eae0: 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6e if (n
eaf0: 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 != SQLiteErrorC
eb00: 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 ode.Ok) throw ne
eb10: 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f w SQLiteExceptio
eb20: 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f n(n, GetLastErro
eb30: 72 28 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 r());..
eb40: 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b break
eb50: 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 ;..#else..
eb60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 th
eb70: 72 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 row new NotImple
eb80: 6d 65 6e 74 65 64 45 78 63 65 70 74 69 6f 6e 28 mentedException(
eb90: 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 );..#endif..
eba0: 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 }..
ebb0: 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 case
ebc0: 53 51 4c 69 74 65 44 61 74 65 46 6f 72 6d 61 74 SQLiteDateFormat
ebd0: 73 2e 4a 75 6c 69 61 6e 44 61 79 3a 0d 0a 20 20 s.JulianDay:..
ebe0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d {.
ebf0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
ec00: 20 20 20 20 20 64 6f 75 62 6c 65 20 76 61 6c 75 double valu
ec10: 65 20 3d 20 54 6f 4a 75 6c 69 61 6e 44 61 79 28 e = ToJulianDay(
ec20: 64 74 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 dt);....
ec30: 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 if (
ec40: 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e 4c 6f HelperMethods.Lo
ec50: 67 42 69 6e 64 28 66 6c 61 67 73 29 29 0d 0a 20 gBind(flags))..
ec60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
ec70: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
ec80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 4c 6f Lo
ec90: 67 42 69 6e 64 28 68 61 6e 64 6c 65 2c 20 69 6e gBind(handle, in
eca0: 64 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 20 dex, value);..
ecb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
ecc0: 20 20 7d 0d 0a 0d 0a 23 69 66 20 21 50 4c 41 54 }....#if !PLAT
ecd0: 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d FORM_COMPACTFRAM
ece0: 45 57 4f 52 4b 0d 0a 20 20 20 20 20 20 20 20 20 EWORK..
ecf0: 20 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 SQLit
ed00: 65 45 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 eErrorCode n = U
ed10: 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
ed20: 64 73 2e 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f ds.sqlite3_bind_
ed30: 64 6f 75 62 6c 65 28 68 61 6e 64 6c 65 2c 20 69 double(handle, i
ed40: 6e 64 65 78 2c 20 76 61 6c 75 65 29 3b 0d 0a 20 ndex, value);..
ed50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
ed60: 20 20 20 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 if (n != SQLi
ed70: 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 teErrorCode.Ok)
ed80: 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 throw new SQLite
ed90: 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 Exception(n, Get
eda0: 4c 61 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a 20 LastError());..
edb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
edc0: 20 20 20 62 72 65 61 6b 3b 0d 0a 23 65 6c 69 66 break;..#elif
edd0: 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 !SQLITE_STANDAR
ede0: 44 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 D..
edf0: 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 SQLiteErr
ee00: 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 66 orCode n = Unsaf
ee10: 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
ee20: 71 6c 69 74 65 33 5f 62 69 6e 64 5f 64 6f 75 62 qlite3_bind_doub
ee30: 6c 65 5f 69 6e 74 65 72 6f 70 28 68 61 6e 64 6c le_interop(handl
ee40: 65 2c 20 69 6e 64 65 78 2c 20 72 65 66 20 76 61 e, index, ref va
ee50: 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 lue);..
ee60: 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6e if (n
ee70: 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 != SQLiteErrorC
ee80: 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 ode.Ok) throw ne
ee90: 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f w SQLiteExceptio
eea0: 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f n(n, GetLastErro
eeb0: 72 28 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 r());..
eec0: 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b break
eed0: 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 ;..#else..
eee0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 th
eef0: 72 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 row new NotImple
ef00: 6d 65 6e 74 65 64 45 78 63 65 70 74 69 6f 6e 28 mentedException(
ef10: 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 );..#endif..
ef20: 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 }..
ef30: 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 case
ef40: 53 51 4c 69 74 65 44 61 74 65 46 6f 72 6d 61 74 SQLiteDateFormat
ef50: 73 2e 55 6e 69 78 45 70 6f 63 68 3a 0d 0a 20 20 s.UnixEpoch:..
ef60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d {.
ef70: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
ef80: 20 20 20 20 20 6c 6f 6e 67 20 76 61 6c 75 65 20 long value
ef90: 3d 20 43 6f 6e 76 65 72 74 2e 54 6f 49 6e 74 36 = Convert.ToInt6
efa0: 34 28 64 74 2e 53 75 62 74 72 61 63 74 28 55 6e 4(dt.Subtract(Un
efb0: 69 78 45 70 6f 63 68 29 2e 54 6f 74 61 6c 53 65 ixEpoch).TotalSe
efc0: 63 6f 6e 64 73 29 3b 0d 0a 0d 0a 20 20 20 20 20 conds);....
efd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 i
efe0: 66 20 28 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 f (HelperMethods
eff0: 2e 4c 6f 67 42 69 6e 64 28 66 6c 61 67 73 29 29 .LogBind(flags))
f000: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
f010: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
f020: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
f030: 20 4c 6f 67 42 69 6e 64 28 68 61 6e 64 6c 65 2c LogBind(handle,
f040: 20 69 6e 64 65 78 2c 20 76 61 6c 75 65 29 3b 0d index, value);.
f050: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
f060: 20 20 20 20 20 7d 0d 0a 0d 0a 23 69 66 20 21 50 }....#if !P
f070: 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 LATFORM_COMPACTF
f080: 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 20 20 RAMEWORK..
f090: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 53 51 SQ
f0a0: 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 6e 20 LiteErrorCode n
f0b0: 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 = UnsafeNativeMe
f0c0: 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 62 69 thods.sqlite3_bi
f0d0: 6e 64 5f 69 6e 74 36 34 28 68 61 6e 64 6c 65 2c nd_int64(handle,
f0e0: 20 69 6e 64 65 78 2c 20 76 61 6c 75 65 29 3b 0d index, value);.
f0f0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
f100: 20 20 20 20 20 69 66 20 28 6e 20 21 3d 20 53 51 if (n != SQ
f110: 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b LiteErrorCode.Ok
f120: 29 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 ) throw new SQLi
f130: 74 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 teException(n, G
f140: 65 74 4c 61 73 74 45 72 72 6f 72 28 29 29 3b 0d etLastError());.
f150: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
f160: 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 23 65 6c break;..#el
f170: 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 if !SQLITE_STAND
f180: 41 52 44 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ARD..
f190: 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 SQLiteE
f1a0: 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 rrorCode n = Uns
f1b0: 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
f1c0: 2e 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 69 6e .sqlite3_bind_in
f1d0: 74 36 34 5f 69 6e 74 65 72 6f 70 28 68 61 6e 64 t64_interop(hand
f1e0: 6c 65 2c 20 69 6e 64 65 78 2c 20 72 65 66 20 76 le, index, ref v
f1f0: 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 alue);..
f200: 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 if (
f210: 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 n != SQLiteError
f220: 43 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e Code.Ok) throw n
f230: 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 ew SQLiteExcepti
f240: 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 on(n, GetLastErr
f250: 6f 72 28 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 or());..
f260: 20 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 brea
f270: 6b 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 k;..#else..
f280: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 t
f290: 68 72 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c hrow new NotImpl
f2a0: 65 6d 65 6e 74 65 64 45 78 63 65 70 74 69 6f 6e ementedException
f2b0: 28 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 ();..#endif..
f2c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a }..
f2d0: 20 20 20 20 20 20 20 20 20 20 20 20 64 65 66 61 defa
f2e0: 75 6c 74 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 ult:..
f2f0: 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
f300: 20 20 20 20 20 20 20 20 20 20 20 20 20 62 79 74 byt
f310: 65 5b 5d 20 62 20 3d 20 54 6f 55 54 46 38 28 64 e[] b = ToUTF8(d
f320: 74 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 t);....
f330: 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 48 if (H
f340: 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e 4c 6f 67 elperMethods.Log
f350: 42 69 6e 64 28 66 6c 61 67 73 29 29 0d 0a 20 20 Bind(flags))..
f360: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
f370: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
f380: 20 20 20 20 20 20 20 20 20 20 20 20 20 4c 6f 67 Log
f390: 42 69 6e 64 28 68 61 6e 64 6c 65 2c 20 69 6e 64 Bind(handle, ind
f3a0: 65 78 2c 20 62 29 3b 0d 0a 20 20 20 20 20 20 20 ex, b);..
f3b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a }..
f3c0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
f3d0: 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 6f SQLiteErro
f3e0: 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 66 65 rCode n = Unsafe
f3f0: 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
f400: 6c 69 74 65 33 5f 62 69 6e 64 5f 74 65 78 74 28 lite3_bind_text(
f410: 68 61 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 62 handle, index, b
f420: 2c 20 62 2e 4c 65 6e 67 74 68 20 2d 20 31 2c 20 , b.Length - 1,
f430: 28 49 6e 74 50 74 72 29 28 2d 31 29 29 3b 0d 0a (IntPtr)(-1));..
f440: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
f450: 20 20 20 20 69 66 20 28 6e 20 21 3d 20 53 51 4c if (n != SQL
f460: 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 iteErrorCode.Ok)
f470: 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 throw new SQLit
f480: 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 eException(n, Ge
f490: 74 4c 61 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a tLastError());..
f4a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
f4b0: 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 break;..
f4c0: 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 }..
f4d0: 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d }.. }.
f4e0: 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
f4f0: 6f 76 65 72 72 69 64 65 20 76 6f 69 64 20 42 69 override void Bi
f500: 6e 64 5f 42 6c 6f 62 28 53 51 4c 69 74 65 53 74 nd_Blob(SQLiteSt
f510: 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 53 51 atement stmt, SQ
f520: 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c LiteConnectionFl
f530: 61 67 73 20 66 6c 61 67 73 2c 20 69 6e 74 20 69 ags flags, int i
f540: 6e 64 65 78 2c 20 62 79 74 65 5b 5d 20 62 6c 6f ndex, byte[] blo
f550: 62 44 61 74 61 29 0d 0a 20 20 20 20 7b 0d 0a 20 bData).. {..
f560: 20 20 20 20 20 20 20 53 51 4c 69 74 65 53 74 61 SQLiteSta
f570: 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 68 61 6e tementHandle han
f580: 64 6c 65 20 3d 20 73 74 6d 74 2e 5f 73 71 6c 69 dle = stmt._sqli
f590: 74 65 5f 73 74 6d 74 3b 0d 0a 0d 0a 20 20 20 20 te_stmt;....
f5a0: 20 20 20 20 69 66 20 28 48 65 6c 70 65 72 4d 65 if (HelperMe
f5b0: 74 68 6f 64 73 2e 4c 6f 67 42 69 6e 64 28 66 6c thods.LogBind(fl
f5c0: 61 67 73 29 29 0d 0a 20 20 20 20 20 20 20 20 7b ags)).. {
f5d0: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 4c 6f .. Lo
f5e0: 67 42 69 6e 64 28 68 61 6e 64 6c 65 2c 20 69 6e gBind(handle, in
f5f0: 64 65 78 2c 20 62 6c 6f 62 44 61 74 61 29 3b 0d dex, blobData);.
f600: 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 . }....
f610: 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 6f SQLiteErro
f620: 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 66 65 rCode n = Unsafe
f630: 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
f640: 6c 69 74 65 33 5f 62 69 6e 64 5f 62 6c 6f 62 28 lite3_bind_blob(
f650: 68 61 6e 64 6c 65 2c 20 69 6e 64 65 78 2c 20 62 handle, index, b
f660: 6c 6f 62 44 61 74 61 2c 20 62 6c 6f 62 44 61 74 lobData, blobDat
f670: 61 2e 4c 65 6e 67 74 68 2c 20 28 49 6e 74 50 74 a.Length, (IntPt
f680: 72 29 28 2d 31 29 29 3b 0d 0a 20 20 20 20 20 20 r)(-1));..
f690: 20 20 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 if (n != SQLit
f6a0: 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 eErrorCode.Ok) t
f6b0: 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 hrow new SQLiteE
f6c0: 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c xception(n, GetL
f6d0: 61 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a 20 20 astError());..
f6e0: 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 }.... inter
f6f0: 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f 69 nal override voi
f700: 64 20 42 69 6e 64 5f 4e 75 6c 6c 28 53 51 4c 69 d Bind_Null(SQLi
f710: 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 teStatement stmt
f720: 2c 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 , SQLiteConnecti
f730: 6f 6e 46 6c 61 67 73 20 66 6c 61 67 73 2c 20 69 onFlags flags, i
f740: 6e 74 20 69 6e 64 65 78 29 0d 0a 20 20 20 20 7b nt index).. {
f750: 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 .. SQLite
f760: 53 74 61 74 65 6d 65 6e 74 48 61 6e 64 6c 65 20 StatementHandle
f770: 68 61 6e 64 6c 65 20 3d 20 73 74 6d 74 2e 5f 73 handle = stmt._s
f780: 71 6c 69 74 65 5f 73 74 6d 74 3b 0d 0a 0d 0a 20 qlite_stmt;....
f790: 20 20 20 20 20 20 20 69 66 20 28 48 65 6c 70 65 if (Helpe
f7a0: 72 4d 65 74 68 6f 64 73 2e 4c 6f 67 42 69 6e 64 rMethods.LogBind
f7b0: 28 66 6c 61 67 73 29 29 0d 0a 20 20 20 20 20 20 (flags))..
f7c0: 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
f7d0: 20 4c 6f 67 42 69 6e 64 28 68 61 6e 64 6c 65 2c LogBind(handle,
f7e0: 20 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 index);..
f7f0: 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 }.... S
f800: 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 6e QLiteErrorCode n
f810: 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d = UnsafeNativeM
f820: 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 62 ethods.sqlite3_b
f830: 69 6e 64 5f 6e 75 6c 6c 28 68 61 6e 64 6c 65 2c ind_null(handle,
f840: 20 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 index);..
f850: 20 20 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 if (n != SQLit
f860: 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 eErrorCode.Ok) t
f870: 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 hrow new SQLiteE
f880: 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c xception(n, GetL
f890: 61 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a 20 20 astError());..
f8a0: 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 }.... inter
f8b0: 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 69 6e 74 nal override int
f8c0: 20 42 69 6e 64 5f 50 61 72 61 6d 43 6f 75 6e 74 Bind_ParamCount
f8d0: 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 (SQLiteStatement
f8e0: 20 73 74 6d 74 2c 20 53 51 4c 69 74 65 43 6f 6e stmt, SQLiteCon
f8f0: 6e 65 63 74 69 6f 6e 46 6c 61 67 73 20 66 6c 61 nectionFlags fla
f900: 67 73 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 gs).. {..
f910: 20 20 20 20 53 51 4c 69 74 65 53 74 61 74 65 6d SQLiteStatem
f920: 65 6e 74 48 61 6e 64 6c 65 20 68 61 6e 64 6c 65 entHandle handle
f930: 20 3d 20 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f = stmt._sqlite_
f940: 73 74 6d 74 3b 0d 0a 20 20 20 20 20 20 20 20 69 stmt;.. i
f950: 6e 74 20 76 61 6c 75 65 20 3d 20 55 6e 73 61 66 nt value = Unsaf
f960: 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
f970: 71 6c 69 74 65 33 5f 62 69 6e 64 5f 70 61 72 61 qlite3_bind_para
f980: 6d 65 74 65 72 5f 63 6f 75 6e 74 28 68 61 6e 64 meter_count(hand
f990: 6c 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 le);....
f9a0: 69 66 20 28 48 65 6c 70 65 72 4d 65 74 68 6f 64 if (HelperMethod
f9b0: 73 2e 4c 6f 67 42 69 6e 64 28 66 6c 61 67 73 29 s.LogBind(flags)
f9c0: 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 ).. {..
f9d0: 20 20 20 20 20 20 20 20 20 20 49 6e 74 50 74 72 IntPtr
f9e0: 20 68 61 6e 64 6c 65 49 6e 74 50 74 72 20 3d 20 handleIntPtr =
f9f0: 68 61 6e 64 6c 65 3b 0d 0a 0d 0a 20 20 20 20 20 handle;....
fa00: 20 20 20 20 20 20 20 53 51 4c 69 74 65 4c 6f 67 SQLiteLog
fa10: 2e 4c 6f 67 4d 65 73 73 61 67 65 28 48 65 6c 70 .LogMessage(Help
fa20: 65 72 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 erMethods.String
fa30: 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 Format(..
fa40: 20 20 20 20 20 20 20 20 20 43 75 6c 74 75 72 65 Culture
fa50: 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c 74 Info.CurrentCult
fa60: 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 ure,..
fa70: 20 20 20 20 20 20 22 53 74 61 74 65 6d 65 6e 74 "Statement
fa80: 20 7b 30 7d 20 70 61 72 61 6d 74 65 72 20 63 6f {0} paramter co
fa90: 75 6e 74 20 69 73 20 7b 31 7d 2e 22 2c 0d 0a 20 unt is {1}.",..
faa0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 68 h
fab0: 61 6e 64 6c 65 49 6e 74 50 74 72 2c 20 76 61 6c andleIntPtr, val
fac0: 75 65 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d ue));.. }
fad0: 0d 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 .... retu
fae0: 72 6e 20 76 61 6c 75 65 3b 0d 0a 20 20 20 20 7d rn value;.. }
faf0: 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
fb00: 20 6f 76 65 72 72 69 64 65 20 73 74 72 69 6e 67 override string
fb10: 20 42 69 6e 64 5f 50 61 72 61 6d 4e 61 6d 65 28 Bind_ParamName(
fb20: 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 SQLiteStatement
fb30: 73 74 6d 74 2c 20 53 51 4c 69 74 65 43 6f 6e 6e stmt, SQLiteConn
fb40: 65 63 74 69 6f 6e 46 6c 61 67 73 20 66 6c 61 67 ectionFlags flag
fb50: 73 2c 20 69 6e 74 20 69 6e 64 65 78 29 0d 0a 20 s, int index)..
fb60: 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 53 51 {.. SQ
fb70: 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 48 61 6e LiteStatementHan
fb80: 64 6c 65 20 68 61 6e 64 6c 65 20 3d 20 73 74 6d dle handle = stm
fb90: 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 3b 0d t._sqlite_stmt;.
fba0: 0a 20 20 20 20 20 20 20 20 73 74 72 69 6e 67 20 . string
fbb0: 6e 61 6d 65 3b 0d 0a 0d 0a 23 69 66 20 21 53 51 name;....#if !SQ
fbc0: 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 LITE_STANDARD..
fbd0: 20 20 20 20 20 20 20 69 6e 74 20 6c 65 6e 20 3d int len =
fbe0: 20 30 3b 0d 0a 20 20 20 20 20 20 20 20 6e 61 6d 0;.. nam
fbf0: 65 20 3d 20 55 54 46 38 54 6f 53 74 72 69 6e 67 e = UTF8ToString
fc00: 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 (UnsafeNativeMet
fc10: 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 62 69 6e hods.sqlite3_bin
fc20: 64 5f 70 61 72 61 6d 65 74 65 72 5f 6e 61 6d 65 d_parameter_name
fc30: 5f 69 6e 74 65 72 6f 70 28 68 61 6e 64 6c 65 2c _interop(handle,
fc40: 20 69 6e 64 65 78 2c 20 72 65 66 20 6c 65 6e 29 index, ref len)
fc50: 2c 20 6c 65 6e 29 3b 0d 0a 23 65 6c 73 65 0d 0a , len);..#else..
fc60: 20 20 20 20 20 20 20 20 6e 61 6d 65 20 3d 20 55 name = U
fc70: 54 46 38 54 6f 53 74 72 69 6e 67 28 55 6e 73 61 TF8ToString(Unsa
fc80: 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
fc90: 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 70 61 72 sqlite3_bind_par
fca0: 61 6d 65 74 65 72 5f 6e 61 6d 65 28 68 61 6e 64 ameter_name(hand
fcb0: 6c 65 2c 20 69 6e 64 65 78 29 2c 20 2d 31 29 3b le, index), -1);
fcc0: 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 ..#endif....
fcd0: 20 20 20 20 69 66 20 28 48 65 6c 70 65 72 4d 65 if (HelperMe
fce0: 74 68 6f 64 73 2e 4c 6f 67 42 69 6e 64 28 66 6c thods.LogBind(fl
fcf0: 61 67 73 29 29 0d 0a 20 20 20 20 20 20 20 20 7b ags)).. {
fd00: 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e .. In
fd10: 74 50 74 72 20 68 61 6e 64 6c 65 49 6e 74 50 74 tPtr handleIntPt
fd20: 72 20 3d 20 68 61 6e 64 6c 65 3b 0d 0a 0d 0a 20 r = handle;....
fd30: 20 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 SQLit
fd40: 65 4c 6f 67 2e 4c 6f 67 4d 65 73 73 61 67 65 28 eLog.LogMessage(
fd50: 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e 53 74 HelperMethods.St
fd60: 72 69 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 ringFormat(..
fd70: 20 20 20 20 20 20 20 20 20 20 20 20 20 43 75 6c Cul
fd80: 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 tureInfo.Current
fd90: 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 Culture,..
fda0: 20 20 20 20 20 20 20 20 20 20 22 53 74 61 74 65 "State
fdb0: 6d 65 6e 74 20 7b 30 7d 20 70 61 72 61 6d 74 65 ment {0} paramte
fdc0: 72 20 23 7b 31 7d 20 6e 61 6d 65 20 69 73 20 7b r #{1} name is {
fdd0: 7b 7b 32 7d 7d 7d 2e 22 2c 0d 0a 20 20 20 20 20 {{2}}}.",..
fde0: 20 20 20 20 20 20 20 20 20 20 20 68 61 6e 64 6c handl
fdf0: 65 49 6e 74 50 74 72 2c 20 69 6e 64 65 78 2c 20 eIntPtr, index,
fe00: 6e 61 6d 65 29 29 3b 0d 0a 20 20 20 20 20 20 20 name));..
fe10: 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 }.... re
fe20: 74 75 72 6e 20 6e 61 6d 65 3b 0d 0a 20 20 20 20 turn name;..
fe30: 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 }.... interna
fe40: 6c 20 6f 76 65 72 72 69 64 65 20 69 6e 74 20 42 l override int B
fe50: 69 6e 64 5f 50 61 72 61 6d 49 6e 64 65 78 28 53 ind_ParamIndex(S
fe60: 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 QLiteStatement s
fe70: 74 6d 74 2c 20 53 51 4c 69 74 65 43 6f 6e 6e 65 tmt, SQLiteConne
fe80: 63 74 69 6f 6e 46 6c 61 67 73 20 66 6c 61 67 73 ctionFlags flags
fe90: 2c 20 73 74 72 69 6e 67 20 70 61 72 61 6d 4e 61 , string paramNa
fea0: 6d 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 me).. {..
feb0: 20 20 20 20 53 51 4c 69 74 65 53 74 61 74 65 6d SQLiteStatem
fec0: 65 6e 74 48 61 6e 64 6c 65 20 68 61 6e 64 6c 65 entHandle handle
fed0: 20 3d 20 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f = stmt._sqlite_
fee0: 73 74 6d 74 3b 0d 0a 20 20 20 20 20 20 20 20 69 stmt;.. i
fef0: 6e 74 20 69 6e 64 65 78 20 3d 20 55 6e 73 61 66 nt index = Unsaf
ff00: 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
ff10: 71 6c 69 74 65 33 5f 62 69 6e 64 5f 70 61 72 61 qlite3_bind_para
ff20: 6d 65 74 65 72 5f 69 6e 64 65 78 28 68 61 6e 64 meter_index(hand
ff30: 6c 65 2c 20 54 6f 55 54 46 38 28 70 61 72 61 6d le, ToUTF8(param
ff40: 4e 61 6d 65 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 Name));....
ff50: 20 20 20 69 66 20 28 48 65 6c 70 65 72 4d 65 74 if (HelperMet
ff60: 68 6f 64 73 2e 4c 6f 67 42 69 6e 64 28 66 6c 61 hods.LogBind(fla
ff70: 67 73 29 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d gs)).. {.
ff80: 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 74 . Int
ff90: 50 74 72 20 68 61 6e 64 6c 65 49 6e 74 50 74 72 Ptr handleIntPtr
ffa0: 20 3d 20 68 61 6e 64 6c 65 3b 0d 0a 0d 0a 20 20 = handle;....
ffb0: 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 SQLite
ffc0: 4c 6f 67 2e 4c 6f 67 4d 65 73 73 61 67 65 28 48 Log.LogMessage(H
ffd0: 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e 53 74 72 elperMethods.Str
ffe0: 69 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 ingFormat(..
fff0: 20 20 20 20 20 20 20 20 20 20 20 20 43 75 6c 74 Cult
10000 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 ureInfo.CurrentC
10010 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 ulture,..
10020 20 20 20 20 20 20 20 20 20 22 53 74 61 74 65 6d "Statem
10030 65 6e 74 20 7b 30 7d 20 70 61 72 61 6d 74 65 72 ent {0} paramter
10040 20 69 6e 64 65 78 20 6f 66 20 6e 61 6d 65 20 7b index of name {
10050 7b 7b 31 7d 7d 7d 20 69 73 20 23 7b 32 7d 2e 22 {{1}}} is #{2}."
10060 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ,..
10070 20 20 20 68 61 6e 64 6c 65 49 6e 74 50 74 72 2c handleIntPtr,
10080 20 70 61 72 61 6d 4e 61 6d 65 2c 20 69 6e 64 65 paramName, inde
10090 78 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d x));.. }.
100a0 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 ... retur
100b0 6e 20 69 6e 64 65 78 3b 0d 0a 20 20 20 20 7d 0d n index;.. }.
100c0 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
100d0 6f 76 65 72 72 69 64 65 20 69 6e 74 20 43 6f 6c override int Col
100e0 75 6d 6e 43 6f 75 6e 74 28 53 51 4c 69 74 65 53 umnCount(SQLiteS
100f0 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 29 0d 0a tatement stmt)..
10100 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 65 74 {.. ret
10110 75 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 urn UnsafeNative
10120 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
10130 63 6f 6c 75 6d 6e 5f 63 6f 75 6e 74 28 73 74 6d column_count(stm
10140 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 29 3b t._sqlite_stmt);
10150 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
10160 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
10170 20 73 74 72 69 6e 67 20 43 6f 6c 75 6d 6e 4e 61 string ColumnNa
10180 6d 65 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 me(SQLiteStateme
10190 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 nt stmt, int ind
101a0 65 78 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 ex).. {..#if
101b0 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 !SQLITE_STANDARD
101c0 0d 0a 20 20 20 20 20 20 69 6e 74 20 6c 65 6e 20 .. int len
101d0 3d 20 30 3b 0d 0a 20 20 20 20 20 20 49 6e 74 50 = 0;.. IntP
101e0 74 72 20 70 20 3d 20 55 6e 73 61 66 65 4e 61 74 tr p = UnsafeNat
101f0 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 iveMethods.sqlit
10200 65 33 5f 63 6f 6c 75 6d 6e 5f 6e 61 6d 65 5f 69 e3_column_name_i
10210 6e 74 65 72 6f 70 28 73 74 6d 74 2e 5f 73 71 6c nterop(stmt._sql
10220 69 74 65 5f 73 74 6d 74 2c 20 69 6e 64 65 78 2c ite_stmt, index,
10230 20 72 65 66 20 6c 65 6e 29 3b 0d 0a 23 65 6c 73 ref len);..#els
10240 65 0d 0a 20 20 20 20 20 20 49 6e 74 50 74 72 20 e.. IntPtr
10250 70 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 p = UnsafeNative
10260 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
10270 63 6f 6c 75 6d 6e 5f 6e 61 6d 65 28 73 74 6d 74 column_name(stmt
10280 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 ._sqlite_stmt, i
10290 6e 64 65 78 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a ndex);..#endif..
102a0 20 20 20 20 20 20 69 66 20 28 70 20 3d 3d 20 49 if (p == I
102b0 6e 74 50 74 72 2e 5a 65 72 6f 29 0d 0a 20 20 20 ntPtr.Zero)..
102c0 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 throw new S
102d0 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 53 QLiteException(S
102e0 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4e QLiteErrorCode.N
102f0 6f 4d 65 6d 2c 20 47 65 74 4c 61 73 74 45 72 72 oMem, GetLastErr
10300 6f 72 28 29 29 3b 0d 0a 23 69 66 20 21 53 51 4c or());..#if !SQL
10310 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 ITE_STANDARD..
10320 20 20 20 20 72 65 74 75 72 6e 20 55 54 46 38 54 return UTF8T
10330 6f 53 74 72 69 6e 67 28 70 2c 20 6c 65 6e 29 3b oString(p, len);
10340 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 72 ..#else.. r
10350 65 74 75 72 6e 20 55 54 46 38 54 6f 53 74 72 69 eturn UTF8ToStri
10360 6e 67 28 70 2c 20 2d 31 29 3b 0d 0a 23 65 6e 64 ng(p, -1);..#end
10370 69 66 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 if.. }....
10380 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 internal overri
10390 64 65 20 54 79 70 65 41 66 66 69 6e 69 74 79 20 de TypeAffinity
103a0 43 6f 6c 75 6d 6e 41 66 66 69 6e 69 74 79 28 53 ColumnAffinity(S
103b0 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 QLiteStatement s
103c0 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 29 0d tmt, int index).
103d0 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 65 . {.. re
103e0 74 75 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 turn UnsafeNativ
103f0 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
10400 5f 63 6f 6c 75 6d 6e 5f 74 79 70 65 28 73 74 6d _column_type(stm
10410 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 t._sqlite_stmt,
10420 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 7d 0d 0a index);.. }..
10430 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
10440 76 65 72 72 69 64 65 20 73 74 72 69 6e 67 20 43 verride string C
10450 6f 6c 75 6d 6e 54 79 70 65 28 53 51 4c 69 74 65 olumnType(SQLite
10460 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 Statement stmt,
10470 69 6e 74 20 69 6e 64 65 78 2c 20 72 65 66 20 54 int index, ref T
10480 79 70 65 41 66 66 69 6e 69 74 79 20 6e 41 66 66 ypeAffinity nAff
10490 69 6e 69 74 79 29 0d 0a 20 20 20 20 7b 0d 0a 20 inity).. {..
104a0 20 20 20 20 20 20 20 69 6e 74 20 6c 65 6e 3b 0d int len;.
104b0 0a 23 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 .#if !SQLITE_STA
104c0 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 20 20 6c NDARD.. l
104d0 65 6e 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 20 en = 0;..
104e0 20 49 6e 74 50 74 72 20 70 20 3d 20 55 6e 73 61 IntPtr p = Unsa
104f0 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
10500 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 64 sqlite3_column_d
10510 65 63 6c 74 79 70 65 5f 69 6e 74 65 72 6f 70 28 ecltype_interop(
10520 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d stmt._sqlite_stm
10530 74 2c 20 69 6e 64 65 78 2c 20 72 65 66 20 6c 65 t, index, ref le
10540 6e 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 n);..#else..
10550 20 20 20 20 6c 65 6e 20 3d 20 2d 31 3b 0d 0a 20 len = -1;..
10560 20 20 20 20 20 20 20 49 6e 74 50 74 72 20 70 20 IntPtr p
10570 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 = UnsafeNativeMe
10580 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f thods.sqlite3_co
10590 6c 75 6d 6e 5f 64 65 63 6c 74 79 70 65 28 73 74 lumn_decltype(st
105a0 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 2c mt._sqlite_stmt,
105b0 20 69 6e 64 65 78 29 3b 0d 0a 23 65 6e 64 69 66 index);..#endif
105c0 0d 0a 20 20 20 20 20 20 20 20 6e 41 66 66 69 6e .. nAffin
105d0 69 74 79 20 3d 20 43 6f 6c 75 6d 6e 41 66 66 69 ity = ColumnAffi
105e0 6e 69 74 79 28 73 74 6d 74 2c 20 69 6e 64 65 78 nity(stmt, index
105f0 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 );.... if
10600 20 28 28 70 20 21 3d 20 49 6e 74 50 74 72 2e 5a ((p != IntPtr.Z
10610 65 72 6f 29 20 26 26 20 28 28 6c 65 6e 20 3e 20 ero) && ((len >
10620 30 29 20 7c 7c 20 28 6c 65 6e 20 3d 3d 20 2d 31 0) || (len == -1
10630 29 29 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a ))).. {..
10640 20 20 20 20 20 20 20 20 20 20 20 20 73 74 72 69 stri
10650 6e 67 20 64 65 63 6c 54 79 70 65 20 3d 20 55 54 ng declType = UT
10660 46 38 54 6f 53 74 72 69 6e 67 28 70 2c 20 6c 65 F8ToString(p, le
10670 6e 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 n);....
10680 20 20 20 69 66 20 28 21 53 74 72 69 6e 67 2e 49 if (!String.I
10690 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 64 65 63 sNullOrEmpty(dec
106a0 6c 54 79 70 65 29 29 0d 0a 20 20 20 20 20 20 20 lType))..
106b0 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 return
106c0 64 65 63 6c 54 79 70 65 3b 0d 0a 20 20 20 20 20 declType;..
106d0 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 }....
106e0 73 74 72 69 6e 67 5b 5d 20 61 72 20 3d 20 73 74 string[] ar = st
106f0 6d 74 2e 54 79 70 65 44 65 66 69 6e 69 74 69 6f mt.TypeDefinitio
10700 6e 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 ns;.... i
10710 66 20 28 61 72 20 21 3d 20 6e 75 6c 6c 29 0d 0a f (ar != null)..
10720 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
10730 20 20 20 20 20 20 20 69 66 20 28 69 6e 64 65 78 if (index
10740 20 3c 20 61 72 2e 4c 65 6e 67 74 68 20 26 26 20 < ar.Length &&
10750 61 72 5b 69 6e 64 65 78 5d 20 21 3d 20 6e 75 6c ar[index] != nul
10760 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 l)..
10770 20 20 20 20 72 65 74 75 72 6e 20 61 72 5b 69 6e return ar[in
10780 64 65 78 5d 3b 0d 0a 20 20 20 20 20 20 20 20 7d dex];.. }
10790 0d 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 .... retu
107a0 72 6e 20 53 74 72 69 6e 67 2e 45 6d 70 74 79 3b rn String.Empty;
107b0 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
107c0 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
107d0 20 69 6e 74 20 43 6f 6c 75 6d 6e 49 6e 64 65 78 int ColumnIndex
107e0 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 (SQLiteStatement
107f0 20 73 74 6d 74 2c 20 73 74 72 69 6e 67 20 63 6f stmt, string co
10800 6c 75 6d 6e 4e 61 6d 65 29 0d 0a 20 20 20 20 7b lumnName).. {
10810 0d 0a 20 20 20 20 20 20 69 6e 74 20 78 20 3d 20 .. int x =
10820 43 6f 6c 75 6d 6e 43 6f 75 6e 74 28 73 74 6d 74 ColumnCount(stmt
10830 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 66 6f 72 20 );.... for
10840 28 69 6e 74 20 6e 20 3d 20 30 3b 20 6e 20 3c 20 (int n = 0; n <
10850 78 3b 20 6e 2b 2b 29 0d 0a 20 20 20 20 20 20 7b x; n++).. {
10860 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 53 74 .. if (St
10870 72 69 6e 67 2e 43 6f 6d 70 61 72 65 28 63 6f 6c ring.Compare(col
10880 75 6d 6e 4e 61 6d 65 2c 20 43 6f 6c 75 6d 6e 4e umnName, ColumnN
10890 61 6d 65 28 73 74 6d 74 2c 20 6e 29 2c 20 53 74 ame(stmt, n), St
108a0 72 69 6e 67 43 6f 6d 70 61 72 69 73 6f 6e 2e 4f ringComparison.O
108b0 72 64 69 6e 61 6c 49 67 6e 6f 72 65 43 61 73 65 rdinalIgnoreCase
108c0 29 20 3d 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 ) == 0)..
108d0 20 20 20 72 65 74 75 72 6e 20 6e 3b 0d 0a 20 20 return n;..
108e0 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 72 65 74 }.. ret
108f0 75 72 6e 20 2d 31 3b 0d 0a 20 20 20 20 7d 0d 0a urn -1;.. }..
10900 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
10910 76 65 72 72 69 64 65 20 73 74 72 69 6e 67 20 43 verride string C
10920 6f 6c 75 6d 6e 4f 72 69 67 69 6e 61 6c 4e 61 6d olumnOriginalNam
10930 65 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e e(SQLiteStatemen
10940 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 t stmt, int inde
10950 78 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 21 x).. {..#if !
10960 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d SQLITE_STANDARD.
10970 0a 20 20 20 20 20 20 69 6e 74 20 6c 65 6e 20 3d . int len =
10980 20 30 3b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 0;.. retur
10990 6e 20 55 54 46 38 54 6f 53 74 72 69 6e 67 28 55 n UTF8ToString(U
109a0 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
109b0 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d ds.sqlite3_colum
109c0 6e 5f 6f 72 69 67 69 6e 5f 6e 61 6d 65 5f 69 6e n_origin_name_in
109d0 74 65 72 6f 70 28 73 74 6d 74 2e 5f 73 71 6c 69 terop(stmt._sqli
109e0 74 65 5f 73 74 6d 74 2c 20 69 6e 64 65 78 2c 20 te_stmt, index,
109f0 72 65 66 20 6c 65 6e 29 2c 20 6c 65 6e 29 3b 0d ref len), len);.
10a00 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 72 65 .#else.. re
10a10 74 75 72 6e 20 55 54 46 38 54 6f 53 74 72 69 6e turn UTF8ToStrin
10a20 67 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 g(UnsafeNativeMe
10a30 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f thods.sqlite3_co
10a40 6c 75 6d 6e 5f 6f 72 69 67 69 6e 5f 6e 61 6d 65 lumn_origin_name
10a50 28 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 (stmt._sqlite_st
10a60 6d 74 2c 20 69 6e 64 65 78 29 2c 20 2d 31 29 3b mt, index), -1);
10a70 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d ..#endif.. }.
10a80 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
10a90 6f 76 65 72 72 69 64 65 20 73 74 72 69 6e 67 20 override string
10aa0 43 6f 6c 75 6d 6e 44 61 74 61 62 61 73 65 4e 61 ColumnDatabaseNa
10ab0 6d 65 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 me(SQLiteStateme
10ac0 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 nt stmt, int ind
10ad0 65 78 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 ex).. {..#if
10ae0 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 !SQLITE_STANDARD
10af0 0d 0a 20 20 20 20 20 20 69 6e 74 20 6c 65 6e 20 .. int len
10b00 3d 20 30 3b 0d 0a 20 20 20 20 20 20 72 65 74 75 = 0;.. retu
10b10 72 6e 20 55 54 46 38 54 6f 53 74 72 69 6e 67 28 rn UTF8ToString(
10b20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
10b30 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c 75 ods.sqlite3_colu
10b40 6d 6e 5f 64 61 74 61 62 61 73 65 5f 6e 61 6d 65 mn_database_name
10b50 5f 69 6e 74 65 72 6f 70 28 73 74 6d 74 2e 5f 73 _interop(stmt._s
10b60 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 6e 64 65 qlite_stmt, inde
10b70 78 2c 20 72 65 66 20 6c 65 6e 29 2c 20 6c 65 6e x, ref len), len
10b80 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 );..#else..
10b90 20 72 65 74 75 72 6e 20 55 54 46 38 54 6f 53 74 return UTF8ToSt
10ba0 72 69 6e 67 28 55 6e 73 61 66 65 4e 61 74 69 76 ring(UnsafeNativ
10bb0 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
10bc0 5f 63 6f 6c 75 6d 6e 5f 64 61 74 61 62 61 73 65 _column_database
10bd0 5f 6e 61 6d 65 28 73 74 6d 74 2e 5f 73 71 6c 69 _name(stmt._sqli
10be0 74 65 5f 73 74 6d 74 2c 20 69 6e 64 65 78 29 2c te_stmt, index),
10bf0 20 2d 31 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 -1);..#endif..
10c00 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 }.... inte
10c10 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 73 74 rnal override st
10c20 72 69 6e 67 20 43 6f 6c 75 6d 6e 54 61 62 6c 65 ring ColumnTable
10c30 4e 61 6d 65 28 53 51 4c 69 74 65 53 74 61 74 65 Name(SQLiteState
10c40 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 ment stmt, int i
10c50 6e 64 65 78 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 ndex).. {..#i
10c60 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 f !SQLITE_STANDA
10c70 52 44 0d 0a 20 20 20 20 20 20 69 6e 74 20 6c 65 RD.. int le
10c80 6e 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 72 65 n = 0;.. re
10c90 74 75 72 6e 20 55 54 46 38 54 6f 53 74 72 69 6e turn UTF8ToStrin
10ca0 67 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 g(UnsafeNativeMe
10cb0 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f thods.sqlite3_co
10cc0 6c 75 6d 6e 5f 74 61 62 6c 65 5f 6e 61 6d 65 5f lumn_table_name_
10cd0 69 6e 74 65 72 6f 70 28 73 74 6d 74 2e 5f 73 71 interop(stmt._sq
10ce0 6c 69 74 65 5f 73 74 6d 74 2c 20 69 6e 64 65 78 lite_stmt, index
10cf0 2c 20 72 65 66 20 6c 65 6e 29 2c 20 6c 65 6e 29 , ref len), len)
10d00 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 ;..#else..
10d10 72 65 74 75 72 6e 20 55 54 46 38 54 6f 53 74 72 return UTF8ToStr
10d20 69 6e 67 28 55 6e 73 61 66 65 4e 61 74 69 76 65 ing(UnsafeNative
10d30 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
10d40 63 6f 6c 75 6d 6e 5f 74 61 62 6c 65 5f 6e 61 6d column_table_nam
10d50 65 28 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 e(stmt._sqlite_s
10d60 74 6d 74 2c 20 69 6e 64 65 78 29 2c 20 2d 31 29 tmt, index), -1)
10d70 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d ;..#endif.. }
10d80 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
10d90 20 6f 76 65 72 72 69 64 65 20 76 6f 69 64 20 43 override void C
10da0 6f 6c 75 6d 6e 4d 65 74 61 44 61 74 61 28 73 74 olumnMetaData(st
10db0 72 69 6e 67 20 64 61 74 61 42 61 73 65 2c 20 73 ring dataBase, s
10dc0 74 72 69 6e 67 20 74 61 62 6c 65 2c 20 73 74 72 tring table, str
10dd0 69 6e 67 20 63 6f 6c 75 6d 6e 2c 20 72 65 66 20 ing column, ref
10de0 73 74 72 69 6e 67 20 64 61 74 61 54 79 70 65 2c string dataType,
10df0 20 72 65 66 20 73 74 72 69 6e 67 20 63 6f 6c 6c ref string coll
10e00 61 74 65 53 65 71 75 65 6e 63 65 2c 20 72 65 66 ateSequence, ref
10e10 20 62 6f 6f 6c 20 6e 6f 74 4e 75 6c 6c 2c 20 72 bool notNull, r
10e20 65 66 20 62 6f 6f 6c 20 70 72 69 6d 61 72 79 4b ef bool primaryK
10e30 65 79 2c 20 72 65 66 20 62 6f 6f 6c 20 61 75 74 ey, ref bool aut
10e40 6f 49 6e 63 72 65 6d 65 6e 74 29 0d 0a 20 20 20 oIncrement)..
10e50 20 7b 0d 0a 20 20 20 20 20 20 49 6e 74 50 74 72 {.. IntPtr
10e60 20 64 61 74 61 54 79 70 65 50 74 72 20 3d 20 49 dataTypePtr = I
10e70 6e 74 50 74 72 2e 5a 65 72 6f 3b 0d 0a 20 20 20 ntPtr.Zero;..
10e80 20 20 20 49 6e 74 50 74 72 20 63 6f 6c 6c 53 65 IntPtr collSe
10e90 71 50 74 72 20 3d 20 49 6e 74 50 74 72 2e 5a 65 qPtr = IntPtr.Ze
10ea0 72 6f 3b 0d 0a 20 20 20 20 20 20 69 6e 74 20 6e ro;.. int n
10eb0 6e 6f 74 4e 75 6c 6c 20 3d 20 30 3b 0d 0a 20 20 notNull = 0;..
10ec0 20 20 20 20 69 6e 74 20 6e 70 72 69 6d 61 72 79 int nprimary
10ed0 4b 65 79 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 Key = 0;..
10ee0 69 6e 74 20 6e 61 75 74 6f 49 6e 63 20 3d 20 30 int nautoInc = 0
10ef0 3b 0d 0a 20 20 20 20 20 20 53 51 4c 69 74 65 45 ;.. SQLiteE
10f00 72 72 6f 72 43 6f 64 65 20 6e 3b 0d 0a 20 20 20 rrorCode n;..
10f10 20 20 20 69 6e 74 20 64 74 4c 65 6e 3b 0d 0a 20 int dtLen;..
10f20 20 20 20 20 20 69 6e 74 20 63 73 4c 65 6e 3b 0d int csLen;.
10f30 0a 0d 0a 23 69 66 20 21 53 51 4c 49 54 45 5f 53 ...#if !SQLITE_S
10f40 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 64 TANDARD.. d
10f50 74 4c 65 6e 20 3d 20 30 3b 0d 0a 20 20 20 20 20 tLen = 0;..
10f60 20 63 73 4c 65 6e 20 3d 20 30 3b 0d 0a 20 20 20 csLen = 0;..
10f70 20 20 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 n = UnsafeNat
10f80 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 iveMethods.sqlit
10f90 65 33 5f 74 61 62 6c 65 5f 63 6f 6c 75 6d 6e 5f e3_table_column_
10fa0 6d 65 74 61 64 61 74 61 5f 69 6e 74 65 72 6f 70 metadata_interop
10fb0 28 5f 73 71 6c 2c 20 54 6f 55 54 46 38 28 64 61 (_sql, ToUTF8(da
10fc0 74 61 42 61 73 65 29 2c 20 54 6f 55 54 46 38 28 taBase), ToUTF8(
10fd0 74 61 62 6c 65 29 2c 20 54 6f 55 54 46 38 28 63 table), ToUTF8(c
10fe0 6f 6c 75 6d 6e 29 2c 20 72 65 66 20 64 61 74 61 olumn), ref data
10ff0 54 79 70 65 50 74 72 2c 20 72 65 66 20 63 6f 6c TypePtr, ref col
11000 6c 53 65 71 50 74 72 2c 20 72 65 66 20 6e 6e 6f lSeqPtr, ref nno
11010 74 4e 75 6c 6c 2c 20 72 65 66 20 6e 70 72 69 6d tNull, ref nprim
11020 61 72 79 4b 65 79 2c 20 72 65 66 20 6e 61 75 74 aryKey, ref naut
11030 6f 49 6e 63 2c 20 72 65 66 20 64 74 4c 65 6e 2c oInc, ref dtLen,
11040 20 72 65 66 20 63 73 4c 65 6e 29 3b 0d 0a 23 65 ref csLen);..#e
11050 6c 73 65 0d 0a 20 20 20 20 20 20 64 74 4c 65 6e lse.. dtLen
11060 20 3d 20 2d 31 3b 0d 0a 20 20 20 20 20 20 63 73 = -1;.. cs
11070 4c 65 6e 20 3d 20 2d 31 3b 0d 0a 0d 0a 20 20 20 Len = -1;....
11080 20 20 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 n = UnsafeNat
11090 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 iveMethods.sqlit
110a0 65 33 5f 74 61 62 6c 65 5f 63 6f 6c 75 6d 6e 5f e3_table_column_
110b0 6d 65 74 61 64 61 74 61 28 5f 73 71 6c 2c 20 54 metadata(_sql, T
110c0 6f 55 54 46 38 28 64 61 74 61 42 61 73 65 29 2c oUTF8(dataBase),
110d0 20 54 6f 55 54 46 38 28 74 61 62 6c 65 29 2c 20 ToUTF8(table),
110e0 54 6f 55 54 46 38 28 63 6f 6c 75 6d 6e 29 2c 20 ToUTF8(column),
110f0 72 65 66 20 64 61 74 61 54 79 70 65 50 74 72 2c ref dataTypePtr,
11100 20 72 65 66 20 63 6f 6c 6c 53 65 71 50 74 72 2c ref collSeqPtr,
11110 20 72 65 66 20 6e 6e 6f 74 4e 75 6c 6c 2c 20 72 ref nnotNull, r
11120 65 66 20 6e 70 72 69 6d 61 72 79 4b 65 79 2c 20 ef nprimaryKey,
11130 72 65 66 20 6e 61 75 74 6f 49 6e 63 29 3b 0d 0a ref nautoInc);..
11140 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 69 66 #endif.. if
11150 20 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 72 (n != SQLiteErr
11160 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 68 72 6f 77 orCode.Ok) throw
11170 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 new SQLiteExcep
11180 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 tion(n, GetLastE
11190 72 72 6f 72 28 29 29 3b 0d 0a 0d 0a 20 20 20 20 rror());....
111a0 20 20 64 61 74 61 54 79 70 65 20 3d 20 55 54 46 dataType = UTF
111b0 38 54 6f 53 74 72 69 6e 67 28 64 61 74 61 54 79 8ToString(dataTy
111c0 70 65 50 74 72 2c 20 64 74 4c 65 6e 29 3b 0d 0a pePtr, dtLen);..
111d0 20 20 20 20 20 20 63 6f 6c 6c 61 74 65 53 65 71 collateSeq
111e0 75 65 6e 63 65 20 3d 20 55 54 46 38 54 6f 53 74 uence = UTF8ToSt
111f0 72 69 6e 67 28 63 6f 6c 6c 53 65 71 50 74 72 2c ring(collSeqPtr,
11200 20 63 73 4c 65 6e 29 3b 0d 0a 0d 0a 20 20 20 20 csLen);....
11210 20 20 6e 6f 74 4e 75 6c 6c 20 3d 20 28 6e 6e 6f notNull = (nno
11220 74 4e 75 6c 6c 20 3d 3d 20 31 29 3b 0d 0a 20 20 tNull == 1);..
11230 20 20 20 20 70 72 69 6d 61 72 79 4b 65 79 20 3d primaryKey =
11240 20 28 6e 70 72 69 6d 61 72 79 4b 65 79 20 3d 3d (nprimaryKey ==
11250 20 31 29 3b 0d 0a 20 20 20 20 20 20 61 75 74 6f 1);.. auto
11260 49 6e 63 72 65 6d 65 6e 74 20 3d 20 28 6e 61 75 Increment = (nau
11270 74 6f 49 6e 63 20 3d 3d 20 31 29 3b 0d 0a 20 20 toInc == 1);..
11280 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 }.... inter
11290 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 6f 62 6a nal override obj
112a0 65 63 74 20 47 65 74 4f 62 6a 65 63 74 28 53 51 ect GetObject(SQ
112b0 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 LiteStatement st
112c0 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 29 0d 0a mt, int index)..
112d0 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 73 {.. s
112e0 77 69 74 63 68 20 28 43 6f 6c 75 6d 6e 41 66 66 witch (ColumnAff
112f0 69 6e 69 74 79 28 73 74 6d 74 2c 20 69 6e 64 65 inity(stmt, inde
11300 78 29 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a x)).. {..
11310 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 case
11320 20 54 79 70 65 41 66 66 69 6e 69 74 79 2e 49 6e TypeAffinity.In
11330 74 36 34 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 t64:..
11340 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
11350 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 ret
11360 75 72 6e 20 47 65 74 49 6e 74 36 34 28 73 74 6d urn GetInt64(stm
11370 74 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 t, index);..
11380 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 }..
11390 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 case
113a0 54 79 70 65 41 66 66 69 6e 69 74 79 2e 44 6f 75 TypeAffinity.Dou
113b0 62 6c 65 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 ble:..
113c0 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
113d0 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 ret
113e0 75 72 6e 20 47 65 74 44 6f 75 62 6c 65 28 73 74 urn GetDouble(st
113f0 6d 74 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 20 20 mt, index);..
11400 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a }..
11410 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 case
11420 20 54 79 70 65 41 66 66 69 6e 69 74 79 2e 54 65 TypeAffinity.Te
11430 78 74 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 xt:..
11440 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
11450 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 retu
11460 72 6e 20 47 65 74 54 65 78 74 28 73 74 6d 74 2c rn GetText(stmt,
11470 20 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 index);..
11480 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 }..
11490 20 20 20 20 20 20 20 20 20 63 61 73 65 20 54 79 case Ty
114a0 70 65 41 66 66 69 6e 69 74 79 2e 42 6c 6f 62 3a peAffinity.Blob:
114b0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
114c0 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
114d0 20 20 20 20 20 20 20 20 20 6c 6f 6e 67 20 73 69 long si
114e0 7a 65 20 3d 20 47 65 74 42 79 74 65 73 28 73 74 ze = GetBytes(st
114f0 6d 74 2c 20 69 6e 64 65 78 2c 20 30 2c 20 6e 75 mt, index, 0, nu
11500 6c 6c 2c 20 30 2c 20 30 29 3b 0d 0a 0d 0a 20 20 ll, 0, 0);....
11510 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
11520 20 20 69 66 20 28 28 73 69 7a 65 20 3e 20 30 29 if ((size > 0)
11530 20 26 26 20 28 73 69 7a 65 20 3c 3d 20 69 6e 74 && (size <= int
11540 2e 4d 61 78 56 61 6c 75 65 29 29 0d 0a 20 20 20 .MaxValue))..
11550 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
11560 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
11570 20 20 20 20 20 20 20 20 20 20 20 20 62 79 74 65 byte
11580 5b 5d 20 62 79 74 65 73 20 3d 20 6e 65 77 20 62 [] bytes = new b
11590 79 74 65 5b 28 69 6e 74 29 73 69 7a 65 5d 3b 0d yte[(int)size];.
115a0 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ...
115b0 20 20 20 20 20 20 20 20 20 20 20 47 65 74 42 79 GetBy
115c0 74 65 73 28 73 74 6d 74 2c 20 69 6e 64 65 78 2c tes(stmt, index,
115d0 20 30 2c 20 62 79 74 65 73 2c 20 30 2c 20 28 69 0, bytes, 0, (i
115e0 6e 74 29 73 69 7a 65 29 3b 0d 0a 0d 0a 20 20 20 nt)size);....
115f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
11600 20 20 20 20 20 72 65 74 75 72 6e 20 62 79 74 65 return byte
11610 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 s;..
11620 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
11630 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 b
11640 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 reak;..
11650 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 }..
11660 20 20 20 20 20 20 63 61 73 65 20 54 79 70 65 41 case TypeA
11670 66 66 69 6e 69 74 79 2e 4e 75 6c 6c 3a 0d 0a 20 ffinity.Null:..
11680 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b {
11690 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
116a0 20 20 20 20 20 20 72 65 74 75 72 6e 20 44 42 4e return DBN
116b0 75 6c 6c 2e 56 61 6c 75 65 3b 0d 0a 20 20 20 20 ull.Value;..
116c0 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 }..
116d0 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 }....
116e0 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 4e 6f throw new No
116f0 74 49 6d 70 6c 65 6d 65 6e 74 65 64 45 78 63 65 tImplementedExce
11700 70 74 69 6f 6e 28 29 3b 0d 0a 20 20 20 20 7d 0d ption();.. }.
11710 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
11720 6f 76 65 72 72 69 64 65 20 64 6f 75 62 6c 65 20 override double
11730 47 65 74 44 6f 75 62 6c 65 28 53 51 4c 69 74 65 GetDouble(SQLite
11740 53 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 Statement stmt,
11750 69 6e 74 20 69 6e 64 65 78 29 0d 0a 20 20 20 20 int index)..
11760 7b 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 4d {..#if !PLATFORM
11770 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 _COMPACTFRAMEWOR
11780 4b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 K.. return
11790 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
117a0 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c 75 ods.sqlite3_colu
117b0 6d 6e 5f 64 6f 75 62 6c 65 28 73 74 6d 74 2e 5f mn_double(stmt._
117c0 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 6e 64 sqlite_stmt, ind
117d0 65 78 29 3b 0d 0a 23 65 6c 69 66 20 21 53 51 4c ex);..#elif !SQL
117e0 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 ITE_STANDARD..
117f0 20 20 20 20 64 6f 75 62 6c 65 20 76 61 6c 75 65 double value
11800 20 3d 20 30 2e 30 3b 0d 0a 20 20 20 20 20 20 55 = 0.0;.. U
11810 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
11820 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d ds.sqlite3_colum
11830 6e 5f 64 6f 75 62 6c 65 5f 69 6e 74 65 72 6f 70 n_double_interop
11840 28 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 (stmt._sqlite_st
11850 6d 74 2c 20 69 6e 64 65 78 2c 20 72 65 66 20 76 mt, index, ref v
11860 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 72 65 alue);.. re
11870 74 75 72 6e 20 76 61 6c 75 65 3b 0d 0a 23 65 6c turn value;..#el
11880 73 65 0d 0a 20 20 20 20 20 20 74 68 72 6f 77 20 se.. throw
11890 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 6d 65 6e 74 new NotImplement
118a0 65 64 45 78 63 65 70 74 69 6f 6e 28 29 3b 0d 0a edException();..
118b0 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d 0a 0d #endif.. }...
118c0 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
118d0 65 72 72 69 64 65 20 62 6f 6f 6c 20 47 65 74 42 erride bool GetB
118e0 6f 6f 6c 65 61 6e 28 53 51 4c 69 74 65 53 74 61 oolean(SQLiteSta
118f0 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 tement stmt, int
11900 20 69 6e 64 65 78 29 0d 0a 20 20 20 20 7b 0d 0a index).. {..
11910 20 20 20 20 20 20 72 65 74 75 72 6e 20 54 6f 42 return ToB
11920 6f 6f 6c 65 61 6e 28 47 65 74 4f 62 6a 65 63 74 oolean(GetObject
11930 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 2c 20 43 (stmt, index), C
11940 75 6c 74 75 72 65 49 6e 66 6f 2e 49 6e 76 61 72 ultureInfo.Invar
11950 69 61 6e 74 43 75 6c 74 75 72 65 2c 20 66 61 6c iantCulture, fal
11960 73 65 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 se);.. }....
11970 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 internal over
11980 72 69 64 65 20 73 62 79 74 65 20 47 65 74 53 42 ride sbyte GetSB
11990 79 74 65 28 53 51 4c 69 74 65 53 74 61 74 65 6d yte(SQLiteStatem
119a0 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e ent stmt, int in
119b0 64 65 78 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 dex).. {..
119c0 20 20 20 72 65 74 75 72 6e 20 75 6e 63 68 65 63 return unchec
119d0 6b 65 64 28 28 73 62 79 74 65 29 28 47 65 74 49 ked((sbyte)(GetI
119e0 6e 74 33 32 28 73 74 6d 74 2c 20 69 6e 64 65 78 nt32(stmt, index
119f0 29 20 26 20 62 79 74 65 2e 4d 61 78 56 61 6c 75 ) & byte.MaxValu
11a00 65 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 e));.. }....
11a10 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 internal over
11a20 72 69 64 65 20 62 79 74 65 20 47 65 74 42 79 74 ride byte GetByt
11a30 65 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e e(SQLiteStatemen
11a40 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 t stmt, int inde
11a50 78 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 x).. {..
11a60 20 72 65 74 75 72 6e 20 75 6e 63 68 65 63 6b 65 return unchecke
11a70 64 28 28 62 79 74 65 29 28 47 65 74 49 6e 74 33 d((byte)(GetInt3
11a80 32 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 20 26 2(stmt, index) &
11a90 20 62 79 74 65 2e 4d 61 78 56 61 6c 75 65 29 29 byte.MaxValue))
11aa0 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 ;.. }....
11ab0 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 internal overrid
11ac0 65 20 73 68 6f 72 74 20 47 65 74 49 6e 74 31 36 e short GetInt16
11ad0 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 (SQLiteStatement
11ae0 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 stmt, int index
11af0 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
11b00 72 65 74 75 72 6e 20 75 6e 63 68 65 63 6b 65 64 return unchecked
11b10 28 28 73 68 6f 72 74 29 28 47 65 74 49 6e 74 33 ((short)(GetInt3
11b20 32 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 20 26 2(stmt, index) &
11b30 20 75 73 68 6f 72 74 2e 4d 61 78 56 61 6c 75 65 ushort.MaxValue
11b40 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 ));.. }....
11b50 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 internal overr
11b60 69 64 65 20 75 73 68 6f 72 74 20 47 65 74 55 49 ide ushort GetUI
11b70 6e 74 31 36 28 53 51 4c 69 74 65 53 74 61 74 65 nt16(SQLiteState
11b80 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 ment stmt, int i
11b90 6e 64 65 78 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 ndex).. {..
11ba0 20 20 20 20 72 65 74 75 72 6e 20 75 6e 63 68 65 return unche
11bb0 63 6b 65 64 28 28 75 73 68 6f 72 74 29 28 47 65 cked((ushort)(Ge
11bc0 74 49 6e 74 33 32 28 73 74 6d 74 2c 20 69 6e 64 tInt32(stmt, ind
11bd0 65 78 29 20 26 20 75 73 68 6f 72 74 2e 4d 61 78 ex) & ushort.Max
11be0 56 61 6c 75 65 29 29 3b 0d 0a 20 20 20 20 7d 0d Value));.. }.
11bf0 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
11c00 6f 76 65 72 72 69 64 65 20 69 6e 74 20 47 65 74 override int Get
11c10 49 6e 74 33 32 28 53 51 4c 69 74 65 53 74 61 74 Int32(SQLiteStat
11c20 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 ement stmt, int
11c30 69 6e 64 65 78 29 0d 0a 20 20 20 20 7b 0d 0a 20 index).. {..
11c40 20 20 20 20 20 72 65 74 75 72 6e 20 55 6e 73 61 return Unsa
11c50 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
11c60 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 69 sqlite3_column_i
11c70 6e 74 28 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f nt(stmt._sqlite_
11c80 73 74 6d 74 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 stmt, index);..
11c90 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 }.... inte
11ca0 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 75 69 rnal override ui
11cb0 6e 74 20 47 65 74 55 49 6e 74 33 32 28 53 51 4c nt GetUInt32(SQL
11cc0 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 6d iteStatement stm
11cd0 74 2c 20 69 6e 74 20 69 6e 64 65 78 29 0d 0a 20 t, int index)..
11ce0 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 65 74 75 {.. retu
11cf0 72 6e 20 75 6e 63 68 65 63 6b 65 64 28 28 75 69 rn unchecked((ui
11d00 6e 74 29 47 65 74 49 6e 74 33 32 28 73 74 6d 74 nt)GetInt32(stmt
11d10 2c 20 69 6e 64 65 78 29 29 3b 0d 0a 20 20 20 20 , index));..
11d20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 }.... interna
11d30 6c 20 6f 76 65 72 72 69 64 65 20 6c 6f 6e 67 20 l override long
11d40 47 65 74 49 6e 74 36 34 28 53 51 4c 69 74 65 53 GetInt64(SQLiteS
11d50 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 tatement stmt, i
11d60 6e 74 20 69 6e 64 65 78 29 0d 0a 20 20 20 20 7b nt index).. {
11d70 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f ..#if !PLATFORM_
11d80 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 4b COMPACTFRAMEWORK
11d90 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 .. return U
11da0 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
11db0 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d ds.sqlite3_colum
11dc0 6e 5f 69 6e 74 36 34 28 73 74 6d 74 2e 5f 73 71 n_int64(stmt._sq
11dd0 6c 69 74 65 5f 73 74 6d 74 2c 20 69 6e 64 65 78 lite_stmt, index
11de0 29 3b 0d 0a 23 65 6c 69 66 20 21 53 51 4c 49 54 );..#elif !SQLIT
11df0 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 E_STANDARD..
11e00 20 20 6c 6f 6e 67 20 76 61 6c 75 65 20 3d 20 30 long value = 0
11e10 3b 0d 0a 20 20 20 20 20 20 55 6e 73 61 66 65 4e ;.. UnsafeN
11e20 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c ativeMethods.sql
11e30 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 36 ite3_column_int6
11e40 34 5f 69 6e 74 65 72 6f 70 28 73 74 6d 74 2e 5f 4_interop(stmt._
11e50 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 6e 64 sqlite_stmt, ind
11e60 65 78 2c 20 72 65 66 20 76 61 6c 75 65 29 3b 0d ex, ref value);.
11e70 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 76 61 . return va
11e80 6c 75 65 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 lue;..#else..
11e90 20 20 20 74 68 72 6f 77 20 6e 65 77 20 4e 6f 74 throw new Not
11ea0 49 6d 70 6c 65 6d 65 6e 74 65 64 45 78 63 65 70 ImplementedExcep
11eb0 74 69 6f 6e 28 29 3b 0d 0a 23 65 6e 64 69 66 0d tion();..#endif.
11ec0 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
11ed0 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
11ee0 75 6c 6f 6e 67 20 47 65 74 55 49 6e 74 36 34 28 ulong GetUInt64(
11ef0 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 SQLiteStatement
11f00 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 29 stmt, int index)
11f10 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 .. {.. r
11f20 65 74 75 72 6e 20 75 6e 63 68 65 63 6b 65 64 28 eturn unchecked(
11f30 28 75 6c 6f 6e 67 29 47 65 74 49 6e 74 36 34 28 (ulong)GetInt64(
11f40 73 74 6d 74 2c 20 69 6e 64 65 78 29 29 3b 0d 0a stmt, index));..
11f50 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 }.... int
11f60 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 73 ernal override s
11f70 74 72 69 6e 67 20 47 65 74 54 65 78 74 28 53 51 tring GetText(SQ
11f80 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 74 LiteStatement st
11f90 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 29 0d 0a mt, int index)..
11fa0 20 20 20 20 7b 0d 0a 23 69 66 20 21 53 51 4c 49 {..#if !SQLI
11fb0 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 TE_STANDARD..
11fc0 20 20 20 69 6e 74 20 6c 65 6e 20 3d 20 30 3b 0d int len = 0;.
11fd0 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 54 . return UT
11fe0 46 38 54 6f 53 74 72 69 6e 67 28 55 6e 73 61 66 F8ToString(Unsaf
11ff0 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
12000 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 74 65 qlite3_column_te
12010 78 74 5f 69 6e 74 65 72 6f 70 28 73 74 6d 74 2e xt_interop(stmt.
12020 5f 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 6e _sqlite_stmt, in
12030 64 65 78 2c 20 72 65 66 20 6c 65 6e 29 2c 20 6c dex, ref len), l
12040 65 6e 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 en);..#else..
12050 20 20 20 72 65 74 75 72 6e 20 55 54 46 38 54 6f return UTF8To
12060 53 74 72 69 6e 67 28 55 6e 73 61 66 65 4e 61 74 String(UnsafeNat
12070 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 iveMethods.sqlit
12080 65 33 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 73 e3_column_text(s
12090 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 tmt._sqlite_stmt
120a0 2c 20 69 6e 64 65 78 29 2c 0d 0a 20 20 20 20 20 , index),..
120b0 20 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d UnsafeNativeM
120c0 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 ethods.sqlite3_c
120d0 6f 6c 75 6d 6e 5f 62 79 74 65 73 28 73 74 6d 74 olumn_bytes(stmt
120e0 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 ._sqlite_stmt, i
120f0 6e 64 65 78 29 29 3b 0d 0a 23 65 6e 64 69 66 0d ndex));..#endif.
12100 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
12110 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
12120 44 61 74 65 54 69 6d 65 20 47 65 74 44 61 74 65 DateTime GetDate
12130 54 69 6d 65 28 53 51 4c 69 74 65 53 74 61 74 65 Time(SQLiteState
12140 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 ment stmt, int i
12150 6e 64 65 78 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 ndex).. {..
12160 20 20 20 20 69 66 20 28 5f 64 61 74 65 74 69 6d if (_datetim
12170 65 46 6f 72 6d 61 74 20 3d 3d 20 53 51 4c 69 74 eFormat == SQLit
12180 65 44 61 74 65 46 6f 72 6d 61 74 73 2e 54 69 63 eDateFormats.Tic
12190 6b 73 29 0d 0a 20 20 20 20 20 20 20 20 72 65 74 ks).. ret
121a0 75 72 6e 20 54 69 63 6b 73 54 6f 44 61 74 65 54 urn TicksToDateT
121b0 69 6d 65 28 47 65 74 49 6e 74 36 34 28 73 74 6d ime(GetInt64(stm
121c0 74 2c 20 69 6e 64 65 78 29 2c 20 5f 64 61 74 65 t, index), _date
121d0 74 69 6d 65 4b 69 6e 64 29 3b 0d 0a 20 20 20 20 timeKind);..
121e0 20 20 65 6c 73 65 20 69 66 20 28 5f 64 61 74 65 else if (_date
121f0 74 69 6d 65 46 6f 72 6d 61 74 20 3d 3d 20 53 51 timeFormat == SQ
12200 4c 69 74 65 44 61 74 65 46 6f 72 6d 61 74 73 2e LiteDateFormats.
12210 4a 75 6c 69 61 6e 44 61 79 29 0d 0a 20 20 20 20 JulianDay)..
12220 20 20 20 20 72 65 74 75 72 6e 20 54 6f 44 61 74 return ToDat
12230 65 54 69 6d 65 28 47 65 74 44 6f 75 62 6c 65 28 eTime(GetDouble(
12240 73 74 6d 74 2c 20 69 6e 64 65 78 29 2c 20 5f 64 stmt, index), _d
12250 61 74 65 74 69 6d 65 4b 69 6e 64 29 3b 0d 0a 20 atetimeKind);..
12260 20 20 20 20 20 65 6c 73 65 20 69 66 20 28 5f 64 else if (_d
12270 61 74 65 74 69 6d 65 46 6f 72 6d 61 74 20 3d 3d atetimeFormat ==
12280 20 53 51 4c 69 74 65 44 61 74 65 46 6f 72 6d 61 SQLiteDateForma
12290 74 73 2e 55 6e 69 78 45 70 6f 63 68 29 0d 0a 20 ts.UnixEpoch)..
122a0 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 6e return Un
122b0 69 78 45 70 6f 63 68 54 6f 44 61 74 65 54 69 6d ixEpochToDateTim
122c0 65 28 47 65 74 49 6e 74 36 34 28 73 74 6d 74 2c e(GetInt64(stmt,
122d0 20 69 6e 64 65 78 29 2c 20 5f 64 61 74 65 74 69 index), _dateti
122e0 6d 65 4b 69 6e 64 29 3b 0d 0a 0d 0a 23 69 66 20 meKind);....#if
122f0 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 !SQLITE_STANDARD
12300 0d 0a 20 20 20 20 20 20 69 6e 74 20 6c 65 6e 20 .. int len
12310 3d 20 30 3b 0d 0a 20 20 20 20 20 20 72 65 74 75 = 0;.. retu
12320 72 6e 20 54 6f 44 61 74 65 54 69 6d 65 28 55 6e rn ToDateTime(Un
12330 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
12340 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e s.sqlite3_column
12350 5f 74 65 78 74 5f 69 6e 74 65 72 6f 70 28 73 74 _text_interop(st
12360 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 2c mt._sqlite_stmt,
12370 20 69 6e 64 65 78 2c 20 72 65 66 20 6c 65 6e 29 index, ref len)
12380 2c 20 6c 65 6e 29 3b 0d 0a 23 65 6c 73 65 0d 0a , len);..#else..
12390 20 20 20 20 20 20 72 65 74 75 72 6e 20 54 6f 44 return ToD
123a0 61 74 65 54 69 6d 65 28 55 6e 73 61 66 65 4e 61 ateTime(UnsafeNa
123b0 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 tiveMethods.sqli
123c0 74 65 33 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 te3_column_text(
123d0 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d stmt._sqlite_stm
123e0 74 2c 20 69 6e 64 65 78 29 2c 0d 0a 20 20 20 20 t, index),..
123f0 20 20 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 UnsafeNative
12400 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
12410 63 6f 6c 75 6d 6e 5f 62 79 74 65 73 28 73 74 6d column_bytes(stm
12420 74 2e 5f 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 t._sqlite_stmt,
12430 69 6e 64 65 78 29 29 3b 0d 0a 23 65 6e 64 69 66 index));..#endif
12440 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
12450 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
12460 20 6c 6f 6e 67 20 47 65 74 42 79 74 65 73 28 53 long GetBytes(S
12470 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 73 QLiteStatement s
12480 74 6d 74 2c 20 69 6e 74 20 69 6e 64 65 78 2c 20 tmt, int index,
12490 69 6e 74 20 6e 44 61 74 61 4f 66 66 73 65 74 2c int nDataOffset,
124a0 20 62 79 74 65 5b 5d 20 62 44 65 73 74 2c 20 69 byte[] bDest, i
124b0 6e 74 20 6e 53 74 61 72 74 2c 20 69 6e 74 20 6e nt nStart, int n
124c0 4c 65 6e 67 74 68 29 0d 0a 20 20 20 20 7b 0d 0a Length).. {..
124d0 20 20 20 20 20 20 69 6e 74 20 6e 6c 65 6e 20 3d int nlen =
124e0 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
124f0 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f 6c hods.sqlite3_col
12500 75 6d 6e 5f 62 79 74 65 73 28 73 74 6d 74 2e 5f umn_bytes(stmt._
12510 73 71 6c 69 74 65 5f 73 74 6d 74 2c 20 69 6e 64 sqlite_stmt, ind
12520 65 78 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 2f 2f ex);.... //
12530 20 49 66 20 6e 6f 20 64 65 73 74 69 6e 61 74 69 If no destinati
12540 6f 6e 20 62 75 66 66 65 72 2c 20 72 65 74 75 72 on buffer, retur
12550 6e 20 74 68 65 20 73 69 7a 65 20 6e 65 65 64 65 n the size neede
12560 64 2e 0d 0a 20 20 20 20 20 20 69 66 20 28 62 44 d... if (bD
12570 65 73 74 20 3d 3d 20 6e 75 6c 6c 29 20 72 65 74 est == null) ret
12580 75 72 6e 20 6e 6c 65 6e 3b 0d 0a 0d 0a 20 20 20 urn nlen;....
12590 20 20 20 69 6e 74 20 6e 43 6f 70 69 65 64 20 3d int nCopied =
125a0 20 6e 4c 65 6e 67 74 68 3b 0d 0a 0d 0a 20 20 20 nLength;....
125b0 20 20 20 69 66 20 28 6e 43 6f 70 69 65 64 20 2b if (nCopied +
125c0 20 6e 53 74 61 72 74 20 3e 20 62 44 65 73 74 2e nStart > bDest.
125d0 4c 65 6e 67 74 68 29 20 6e 43 6f 70 69 65 64 20 Length) nCopied
125e0 3d 20 62 44 65 73 74 2e 4c 65 6e 67 74 68 20 2d = bDest.Length -
125f0 20 6e 53 74 61 72 74 3b 0d 0a 20 20 20 20 20 20 nStart;..
12600 69 66 20 28 6e 43 6f 70 69 65 64 20 2b 20 6e 44 if (nCopied + nD
12610 61 74 61 4f 66 66 73 65 74 20 3e 20 6e 6c 65 6e ataOffset > nlen
12620 29 20 6e 43 6f 70 69 65 64 20 3d 20 6e 6c 65 6e ) nCopied = nlen
12630 20 2d 20 6e 44 61 74 61 4f 66 66 73 65 74 3b 0d - nDataOffset;.
12640 0a 0d 0a 20 20 20 20 20 20 69 66 20 28 6e 43 6f ... if (nCo
12650 70 69 65 64 20 3e 20 30 29 0d 0a 20 20 20 20 20 pied > 0)..
12660 20 7b 0d 0a 20 20 20 20 20 20 20 20 49 6e 74 50 {.. IntP
12670 74 72 20 70 74 72 20 3d 20 55 6e 73 61 66 65 4e tr ptr = UnsafeN
12680 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c ativeMethods.sql
12690 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 62 6c 6f 62 ite3_column_blob
126a0 28 73 74 6d 74 2e 5f 73 71 6c 69 74 65 5f 73 74 (stmt._sqlite_st
126b0 6d 74 2c 20 69 6e 64 65 78 29 3b 0d 0a 0d 0a 20 mt, index);....
126c0 20 20 20 20 20 20 20 4d 61 72 73 68 61 6c 2e 43 Marshal.C
126d0 6f 70 79 28 28 49 6e 74 50 74 72 29 28 70 74 72 opy((IntPtr)(ptr
126e0 2e 54 6f 49 6e 74 36 34 28 29 20 2b 20 6e 44 61 .ToInt64() + nDa
126f0 74 61 4f 66 66 73 65 74 29 2c 20 62 44 65 73 74 taOffset), bDest
12700 2c 20 6e 53 74 61 72 74 2c 20 6e 43 6f 70 69 65 , nStart, nCopie
12710 64 29 3b 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 d);.. }..
12720 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 else..
12730 7b 0d 0a 20 20 20 20 20 20 20 20 6e 43 6f 70 69 {.. nCopi
12740 65 64 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 7d ed = 0;.. }
12750 0d 0a 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e .... return
12760 20 6e 43 6f 70 69 65 64 3b 0d 0a 20 20 20 20 7d nCopied;.. }
12770 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
12780 20 6f 76 65 72 72 69 64 65 20 63 68 61 72 20 47 override char G
12790 65 74 43 68 61 72 28 53 51 4c 69 74 65 53 74 61 etChar(SQLiteSta
127a0 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 6e 74 tement stmt, int
127b0 20 69 6e 64 65 78 29 0d 0a 20 20 20 20 7b 0d 0a index).. {..
127c0 20 20 20 20 20 20 72 65 74 75 72 6e 20 43 6f 6e return Con
127d0 76 65 72 74 2e 54 6f 43 68 61 72 28 47 65 74 55 vert.ToChar(GetU
127e0 49 6e 74 31 36 28 73 74 6d 74 2c 20 69 6e 64 65 Int16(stmt, inde
127f0 78 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 x));.. }....
12800 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 internal over
12810 72 69 64 65 20 6c 6f 6e 67 20 47 65 74 43 68 61 ride long GetCha
12820 72 73 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 rs(SQLiteStateme
12830 6e 74 20 73 74 6d 74 2c 20 69 6e 74 20 69 6e 64 nt stmt, int ind
12840 65 78 2c 20 69 6e 74 20 6e 44 61 74 61 4f 66 66 ex, int nDataOff
12850 73 65 74 2c 20 63 68 61 72 5b 5d 20 62 44 65 73 set, char[] bDes
12860 74 2c 20 69 6e 74 20 6e 53 74 61 72 74 2c 20 69 t, int nStart, i
12870 6e 74 20 6e 4c 65 6e 67 74 68 29 0d 0a 20 20 20 nt nLength)..
12880 20 7b 0d 0a 20 20 20 20 20 20 69 6e 74 20 6e 6c {.. int nl
12890 65 6e 3b 0d 0a 20 20 20 20 20 20 69 6e 74 20 6e en;.. int n
128a0 43 6f 70 69 65 64 20 3d 20 6e 4c 65 6e 67 74 68 Copied = nLength
128b0 3b 0d 0a 0d 0a 20 20 20 20 20 20 73 74 72 69 6e ;.... strin
128c0 67 20 73 74 72 20 3d 20 47 65 74 54 65 78 74 28 g str = GetText(
128d0 73 74 6d 74 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 stmt, index);..
128e0 20 20 20 20 20 6e 6c 65 6e 20 3d 20 73 74 72 2e nlen = str.
128f0 4c 65 6e 67 74 68 3b 0d 0a 0d 0a 20 20 20 20 20 Length;....
12900 20 69 66 20 28 62 44 65 73 74 20 3d 3d 20 6e 75 if (bDest == nu
12910 6c 6c 29 20 72 65 74 75 72 6e 20 6e 6c 65 6e 3b ll) return nlen;
12920 0d 0a 0d 0a 20 20 20 20 20 20 69 66 20 28 6e 43 .... if (nC
12930 6f 70 69 65 64 20 2b 20 6e 53 74 61 72 74 20 3e opied + nStart >
12940 20 62 44 65 73 74 2e 4c 65 6e 67 74 68 29 20 6e bDest.Length) n
12950 43 6f 70 69 65 64 20 3d 20 62 44 65 73 74 2e 4c Copied = bDest.L
12960 65 6e 67 74 68 20 2d 20 6e 53 74 61 72 74 3b 0d ength - nStart;.
12970 0a 20 20 20 20 20 20 69 66 20 28 6e 43 6f 70 69 . if (nCopi
12980 65 64 20 2b 20 6e 44 61 74 61 4f 66 66 73 65 74 ed + nDataOffset
12990 20 3e 20 6e 6c 65 6e 29 20 6e 43 6f 70 69 65 64 > nlen) nCopied
129a0 20 3d 20 6e 6c 65 6e 20 2d 20 6e 44 61 74 61 4f = nlen - nDataO
129b0 66 66 73 65 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 ffset;....
129c0 69 66 20 28 6e 43 6f 70 69 65 64 20 3e 20 30 29 if (nCopied > 0)
129d0 0d 0a 20 20 20 20 20 20 20 20 73 74 72 2e 43 6f .. str.Co
129e0 70 79 54 6f 28 6e 44 61 74 61 4f 66 66 73 65 74 pyTo(nDataOffset
129f0 2c 20 62 44 65 73 74 2c 20 6e 53 74 61 72 74 2c , bDest, nStart,
12a00 20 6e 43 6f 70 69 65 64 29 3b 0d 0a 20 20 20 20 nCopied);..
12a10 20 20 65 6c 73 65 20 6e 43 6f 70 69 65 64 20 3d else nCopied =
12a20 20 30 3b 0d 0a 0d 0a 20 20 20 20 20 20 72 65 74 0;.... ret
12a30 75 72 6e 20 6e 43 6f 70 69 65 64 3b 0d 0a 20 20 urn nCopied;..
12a40 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 }.... inter
12a50 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 62 6f 6f nal override boo
12a60 6c 20 49 73 4e 75 6c 6c 28 53 51 4c 69 74 65 53 l IsNull(SQLiteS
12a70 74 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 69 tatement stmt, i
12a80 6e 74 20 69 6e 64 65 78 29 0d 0a 20 20 20 20 7b nt index).. {
12a90 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 28 .. return (
12aa0 43 6f 6c 75 6d 6e 41 66 66 69 6e 69 74 79 28 73 ColumnAffinity(s
12ab0 74 6d 74 2c 20 69 6e 64 65 78 29 20 3d 3d 20 54 tmt, index) == T
12ac0 79 70 65 41 66 66 69 6e 69 74 79 2e 4e 75 6c 6c ypeAffinity.Null
12ad0 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 );.. }....
12ae0 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 internal overri
12af0 64 65 20 69 6e 74 20 41 67 67 72 65 67 61 74 65 de int Aggregate
12b00 43 6f 75 6e 74 28 49 6e 74 50 74 72 20 63 6f 6e Count(IntPtr con
12b10 74 65 78 74 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 text).. {..
12b20 20 20 20 20 72 65 74 75 72 6e 20 55 6e 73 61 66 return Unsaf
12b30 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
12b40 71 6c 69 74 65 33 5f 61 67 67 72 65 67 61 74 65 qlite3_aggregate
12b50 5f 63 6f 75 6e 74 28 63 6f 6e 74 65 78 74 29 3b _count(context);
12b60 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
12b70 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
12b80 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
12b90 20 43 72 65 61 74 65 46 75 6e 63 74 69 6f 6e 28 CreateFunction(
12ba0 73 74 72 69 6e 67 20 73 74 72 46 75 6e 63 74 69 string strFuncti
12bb0 6f 6e 2c 20 69 6e 74 20 6e 41 72 67 73 2c 20 62 on, int nArgs, b
12bc0 6f 6f 6c 20 6e 65 65 64 43 6f 6c 6c 53 65 71 2c ool needCollSeq,
12bd0 20 53 51 4c 69 74 65 43 61 6c 6c 62 61 63 6b 20 SQLiteCallback
12be0 66 75 6e 63 2c 20 53 51 4c 69 74 65 43 61 6c 6c func, SQLiteCall
12bf0 62 61 63 6b 20 66 75 6e 63 73 74 65 70 2c 20 53 back funcstep, S
12c00 51 4c 69 74 65 46 69 6e 61 6c 43 61 6c 6c 62 61 QLiteFinalCallba
12c10 63 6b 20 66 75 6e 63 66 69 6e 61 6c 2c 20 62 6f ck funcfinal, bo
12c20 6f 6c 20 63 61 6e 54 68 72 6f 77 29 0d 0a 20 20 ol canThrow)..
12c30 20 20 7b 0d 0a 20 20 20 20 20 20 53 51 4c 69 74 {.. SQLit
12c40 65 45 72 72 6f 72 43 6f 64 65 20 6e 3b 0d 0a 0d eErrorCode n;...
12c50 0a 23 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 .#if !SQLITE_STA
12c60 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 6e 20 3d NDARD.. n =
12c70 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
12c80 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 72 65 hods.sqlite3_cre
12c90 61 74 65 5f 66 75 6e 63 74 69 6f 6e 5f 69 6e 74 ate_function_int
12ca0 65 72 6f 70 28 5f 73 71 6c 2c 20 54 6f 55 54 46 erop(_sql, ToUTF
12cb0 38 28 73 74 72 46 75 6e 63 74 69 6f 6e 29 2c 20 8(strFunction),
12cc0 6e 41 72 67 73 2c 20 34 2c 20 49 6e 74 50 74 72 nArgs, 4, IntPtr
12cd0 2e 5a 65 72 6f 2c 20 66 75 6e 63 2c 20 66 75 6e .Zero, func, fun
12ce0 63 73 74 65 70 2c 20 66 75 6e 63 66 69 6e 61 6c cstep, funcfinal
12cf0 2c 20 28 6e 65 65 64 43 6f 6c 6c 53 65 71 20 3d , (needCollSeq =
12d00 3d 20 74 72 75 65 29 20 3f 20 31 20 3a 20 30 29 = true) ? 1 : 0)
12d10 3b 0d 0a 20 20 20 20 20 20 69 66 20 28 6e 20 3d ;.. if (n =
12d20 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 = SQLiteErrorCod
12d30 65 2e 4f 6b 29 20 6e 20 3d 20 55 6e 73 61 66 65 e.Ok) n = Unsafe
12d40 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
12d50 6c 69 74 65 33 5f 63 72 65 61 74 65 5f 66 75 6e lite3_create_fun
12d60 63 74 69 6f 6e 5f 69 6e 74 65 72 6f 70 28 5f 73 ction_interop(_s
12d70 71 6c 2c 20 54 6f 55 54 46 38 28 73 74 72 46 75 ql, ToUTF8(strFu
12d80 6e 63 74 69 6f 6e 29 2c 20 6e 41 72 67 73 2c 20 nction), nArgs,
12d90 31 2c 20 49 6e 74 50 74 72 2e 5a 65 72 6f 2c 20 1, IntPtr.Zero,
12da0 66 75 6e 63 2c 20 66 75 6e 63 73 74 65 70 2c 20 func, funcstep,
12db0 66 75 6e 63 66 69 6e 61 6c 2c 20 28 6e 65 65 64 funcfinal, (need
12dc0 43 6f 6c 6c 53 65 71 20 3d 3d 20 74 72 75 65 29 CollSeq == true)
12dd0 20 3f 20 31 20 3a 20 30 29 3b 0d 0a 23 65 6c 73 ? 1 : 0);..#els
12de0 65 0d 0a 20 20 20 20 20 20 6e 20 3d 20 55 6e 73 e.. n = Uns
12df0 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
12e00 2e 73 71 6c 69 74 65 33 5f 63 72 65 61 74 65 5f .sqlite3_create_
12e10 66 75 6e 63 74 69 6f 6e 28 5f 73 71 6c 2c 20 54 function(_sql, T
12e20 6f 55 54 46 38 28 73 74 72 46 75 6e 63 74 69 6f oUTF8(strFunctio
12e30 6e 29 2c 20 6e 41 72 67 73 2c 20 34 2c 20 49 6e n), nArgs, 4, In
12e40 74 50 74 72 2e 5a 65 72 6f 2c 20 66 75 6e 63 2c tPtr.Zero, func,
12e50 20 66 75 6e 63 73 74 65 70 2c 20 66 75 6e 63 66 funcstep, funcf
12e60 69 6e 61 6c 29 3b 0d 0a 20 20 20 20 20 20 69 66 inal);.. if
12e70 20 28 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 (n == SQLiteErr
12e80 6f 72 43 6f 64 65 2e 4f 6b 29 20 6e 20 3d 20 55 orCode.Ok) n = U
12e90 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
12ea0 64 73 2e 73 71 6c 69 74 65 33 5f 63 72 65 61 74 ds.sqlite3_creat
12eb0 65 5f 66 75 6e 63 74 69 6f 6e 28 5f 73 71 6c 2c e_function(_sql,
12ec0 20 54 6f 55 54 46 38 28 73 74 72 46 75 6e 63 74 ToUTF8(strFunct
12ed0 69 6f 6e 29 2c 20 6e 41 72 67 73 2c 20 31 2c 20 ion), nArgs, 1,
12ee0 49 6e 74 50 74 72 2e 5a 65 72 6f 2c 20 66 75 6e IntPtr.Zero, fun
12ef0 63 2c 20 66 75 6e 63 73 74 65 70 2c 20 66 75 6e c, funcstep, fun
12f00 63 66 69 6e 61 6c 29 3b 0d 0a 23 65 6e 64 69 66 cfinal);..#endif
12f10 0d 0a 20 20 20 20 20 20 69 66 20 28 63 61 6e 54 .. if (canT
12f20 68 72 6f 77 20 26 26 20 28 6e 20 21 3d 20 53 51 hrow && (n != SQ
12f30 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b LiteErrorCode.Ok
12f40 29 29 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c )) throw new SQL
12f50 69 74 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 iteException(n,
12f60 47 65 74 4c 61 73 74 45 72 72 6f 72 28 29 29 3b GetLastError());
12f70 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 6e .. return n
12f80 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 ;.. }....
12f90 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 internal overrid
12fa0 65 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 e SQLiteErrorCod
12fb0 65 20 43 72 65 61 74 65 43 6f 6c 6c 61 74 69 6f e CreateCollatio
12fc0 6e 28 73 74 72 69 6e 67 20 73 74 72 43 6f 6c 6c n(string strColl
12fd0 61 74 69 6f 6e 2c 20 53 51 4c 69 74 65 43 6f 6c ation, SQLiteCol
12fe0 6c 61 74 69 6f 6e 20 66 75 6e 63 2c 20 53 51 4c lation func, SQL
12ff0 69 74 65 43 6f 6c 6c 61 74 69 6f 6e 20 66 75 6e iteCollation fun
13000 63 31 36 2c 20 62 6f 6f 6c 20 63 61 6e 54 68 72 c16, bool canThr
13010 6f 77 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 ow).. {..
13020 20 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 SQLiteErrorCod
13030 65 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 e n = UnsafeNati
13040 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
13050 33 5f 63 72 65 61 74 65 5f 63 6f 6c 6c 61 74 69 3_create_collati
13060 6f 6e 28 5f 73 71 6c 2c 20 54 6f 55 54 46 38 28 on(_sql, ToUTF8(
13070 73 74 72 43 6f 6c 6c 61 74 69 6f 6e 29 2c 20 32 strCollation), 2
13080 2c 20 49 6e 74 50 74 72 2e 5a 65 72 6f 2c 20 66 , IntPtr.Zero, f
13090 75 6e 63 31 36 29 3b 0d 0a 20 20 20 20 20 20 69 unc16);.. i
130a0 66 20 28 6e 20 3d 3d 20 53 51 4c 69 74 65 45 72 f (n == SQLiteEr
130b0 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 6e 20 3d 20 rorCode.Ok) n =
130c0 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
130d0 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 72 65 61 ods.sqlite3_crea
130e0 74 65 5f 63 6f 6c 6c 61 74 69 6f 6e 28 5f 73 71 te_collation(_sq
130f0 6c 2c 20 54 6f 55 54 46 38 28 73 74 72 43 6f 6c l, ToUTF8(strCol
13100 6c 61 74 69 6f 6e 29 2c 20 31 2c 20 49 6e 74 50 lation), 1, IntP
13110 74 72 2e 5a 65 72 6f 2c 20 66 75 6e 63 29 3b 0d tr.Zero, func);.
13120 0a 20 20 20 20 20 20 69 66 20 28 63 61 6e 54 68 . if (canTh
13130 72 6f 77 20 26 26 20 28 6e 20 21 3d 20 53 51 4c row && (n != SQL
13140 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 iteErrorCode.Ok)
13150 29 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 ) throw new SQLi
13160 74 65 45 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 teException(n, G
13170 65 74 4c 61 73 74 45 72 72 6f 72 28 29 29 3b 0d etLastError());.
13180 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 6e 3b . return n;
13190 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 .. }.... i
131a0 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
131b0 20 69 6e 74 20 43 6f 6e 74 65 78 74 43 6f 6c 6c int ContextColl
131c0 61 74 65 43 6f 6d 70 61 72 65 28 43 6f 6c 6c 61 ateCompare(Colla
131d0 74 69 6f 6e 45 6e 63 6f 64 69 6e 67 45 6e 75 6d tionEncodingEnum
131e0 20 65 6e 63 2c 20 49 6e 74 50 74 72 20 63 6f 6e enc, IntPtr con
131f0 74 65 78 74 2c 20 73 74 72 69 6e 67 20 73 31 2c text, string s1,
13200 20 73 74 72 69 6e 67 20 73 32 29 0d 0a 20 20 20 string s2)..
13210 20 7b 0d 0a 23 69 66 20 21 53 51 4c 49 54 45 5f {..#if !SQLITE_
13220 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 STANDARD..
13230 62 79 74 65 5b 5d 20 62 31 3b 0d 0a 20 20 20 20 byte[] b1;..
13240 20 20 62 79 74 65 5b 5d 20 62 32 3b 0d 0a 20 20 byte[] b2;..
13250 20 20 20 20 53 79 73 74 65 6d 2e 54 65 78 74 2e System.Text.
13260 45 6e 63 6f 64 69 6e 67 20 63 6f 6e 76 65 72 74 Encoding convert
13270 65 72 20 3d 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 20 er = null;....
13280 20 20 20 20 73 77 69 74 63 68 20 28 65 6e 63 29 switch (enc)
13290 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 .. {..
132a0 20 20 20 63 61 73 65 20 43 6f 6c 6c 61 74 69 6f case Collatio
132b0 6e 45 6e 63 6f 64 69 6e 67 45 6e 75 6d 2e 55 54 nEncodingEnum.UT
132c0 46 38 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 63 F8:.. c
132d0 6f 6e 76 65 72 74 65 72 20 3d 20 53 79 73 74 65 onverter = Syste
132e0 6d 2e 54 65 78 74 2e 45 6e 63 6f 64 69 6e 67 2e m.Text.Encoding.
132f0 55 54 46 38 3b 0d 0a 20 20 20 20 20 20 20 20 20 UTF8;..
13300 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 break;..
13310 20 63 61 73 65 20 43 6f 6c 6c 61 74 69 6f 6e 45 case CollationE
13320 6e 63 6f 64 69 6e 67 45 6e 75 6d 2e 55 54 46 31 ncodingEnum.UTF1
13330 36 4c 45 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 6LE:..
13340 63 6f 6e 76 65 72 74 65 72 20 3d 20 53 79 73 74 converter = Syst
13350 65 6d 2e 54 65 78 74 2e 45 6e 63 6f 64 69 6e 67 em.Text.Encoding
13360 2e 55 6e 69 63 6f 64 65 3b 0d 0a 20 20 20 20 20 .Unicode;..
13370 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 break;..
13380 20 20 20 20 20 63 61 73 65 20 43 6f 6c 6c 61 74 case Collat
13390 69 6f 6e 45 6e 63 6f 64 69 6e 67 45 6e 75 6d 2e ionEncodingEnum.
133a0 55 54 46 31 36 42 45 3a 0d 0a 20 20 20 20 20 20 UTF16BE:..
133b0 20 20 20 20 63 6f 6e 76 65 72 74 65 72 20 3d 20 converter =
133c0 53 79 73 74 65 6d 2e 54 65 78 74 2e 45 6e 63 6f System.Text.Enco
133d0 64 69 6e 67 2e 42 69 67 45 6e 64 69 61 6e 55 6e ding.BigEndianUn
133e0 69 63 6f 64 65 3b 0d 0a 20 20 20 20 20 20 20 20 icode;..
133f0 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 break;..
13400 7d 0d 0a 0d 0a 20 20 20 20 20 20 62 31 20 3d 20 }.... b1 =
13410 63 6f 6e 76 65 72 74 65 72 2e 47 65 74 42 79 74 converter.GetByt
13420 65 73 28 73 31 29 3b 0d 0a 20 20 20 20 20 20 62 es(s1);.. b
13430 32 20 3d 20 63 6f 6e 76 65 72 74 65 72 2e 47 65 2 = converter.Ge
13440 74 42 79 74 65 73 28 73 32 29 3b 0d 0a 0d 0a 20 tBytes(s2);....
13450 20 20 20 20 20 72 65 74 75 72 6e 20 55 6e 73 61 return Unsa
13460 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
13470 73 71 6c 69 74 65 33 5f 63 6f 6e 74 65 78 74 5f sqlite3_context_
13480 63 6f 6c 6c 63 6f 6d 70 61 72 65 5f 69 6e 74 65 collcompare_inte
13490 72 6f 70 28 63 6f 6e 74 65 78 74 2c 20 62 31 2c rop(context, b1,
134a0 20 62 31 2e 4c 65 6e 67 74 68 2c 20 62 32 2c 20 b1.Length, b2,
134b0 62 32 2e 4c 65 6e 67 74 68 29 3b 0d 0a 23 65 6c b2.Length);..#el
134c0 73 65 0d 0a 20 20 20 20 20 20 74 68 72 6f 77 20 se.. throw
134d0 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 6d 65 6e 74 new NotImplement
134e0 65 64 45 78 63 65 70 74 69 6f 6e 28 29 3b 0d 0a edException();..
134f0 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d 0a 0d #endif.. }...
13500 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
13510 65 72 72 69 64 65 20 69 6e 74 20 43 6f 6e 74 65 erride int Conte
13520 78 74 43 6f 6c 6c 61 74 65 43 6f 6d 70 61 72 65 xtCollateCompare
13530 28 43 6f 6c 6c 61 74 69 6f 6e 45 6e 63 6f 64 69 (CollationEncodi
13540 6e 67 45 6e 75 6d 20 65 6e 63 2c 20 49 6e 74 50 ngEnum enc, IntP
13550 74 72 20 63 6f 6e 74 65 78 74 2c 20 63 68 61 72 tr context, char
13560 5b 5d 20 63 31 2c 20 63 68 61 72 5b 5d 20 63 32 [] c1, char[] c2
13570 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 21 53 ).. {..#if !S
13580 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a QLITE_STANDARD..
13590 20 20 20 20 20 20 62 79 74 65 5b 5d 20 62 31 3b byte[] b1;
135a0 0d 0a 20 20 20 20 20 20 62 79 74 65 5b 5d 20 62 .. byte[] b
135b0 32 3b 0d 0a 20 20 20 20 20 20 53 79 73 74 65 6d 2;.. System
135c0 2e 54 65 78 74 2e 45 6e 63 6f 64 69 6e 67 20 63 .Text.Encoding c
135d0 6f 6e 76 65 72 74 65 72 20 3d 20 6e 75 6c 6c 3b onverter = null;
135e0 0d 0a 0d 0a 20 20 20 20 20 20 73 77 69 74 63 68 .... switch
135f0 20 28 65 6e 63 29 0d 0a 20 20 20 20 20 20 7b 0d (enc).. {.
13600 0a 20 20 20 20 20 20 20 20 63 61 73 65 20 43 6f . case Co
13610 6c 6c 61 74 69 6f 6e 45 6e 63 6f 64 69 6e 67 45 llationEncodingE
13620 6e 75 6d 2e 55 54 46 38 3a 0d 0a 20 20 20 20 20 num.UTF8:..
13630 20 20 20 20 20 63 6f 6e 76 65 72 74 65 72 20 3d converter =
13640 20 53 79 73 74 65 6d 2e 54 65 78 74 2e 45 6e 63 System.Text.Enc
13650 6f 64 69 6e 67 2e 55 54 46 38 3b 0d 0a 20 20 20 oding.UTF8;..
13660 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 break;..
13670 20 20 20 20 20 20 20 63 61 73 65 20 43 6f 6c 6c case Coll
13680 61 74 69 6f 6e 45 6e 63 6f 64 69 6e 67 45 6e 75 ationEncodingEnu
13690 6d 2e 55 54 46 31 36 4c 45 3a 0d 0a 20 20 20 20 m.UTF16LE:..
136a0 20 20 20 20 20 20 63 6f 6e 76 65 72 74 65 72 20 converter
136b0 3d 20 53 79 73 74 65 6d 2e 54 65 78 74 2e 45 6e = System.Text.En
136c0 63 6f 64 69 6e 67 2e 55 6e 69 63 6f 64 65 3b 0d coding.Unicode;.
136d0 0a 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b . break
136e0 3b 0d 0a 20 20 20 20 20 20 20 20 63 61 73 65 20 ;.. case
136f0 43 6f 6c 6c 61 74 69 6f 6e 45 6e 63 6f 64 69 6e CollationEncodin
13700 67 45 6e 75 6d 2e 55 54 46 31 36 42 45 3a 0d 0a gEnum.UTF16BE:..
13710 20 20 20 20 20 20 20 20 20 20 63 6f 6e 76 65 72 conver
13720 74 65 72 20 3d 20 53 79 73 74 65 6d 2e 54 65 78 ter = System.Tex
13730 74 2e 45 6e 63 6f 64 69 6e 67 2e 42 69 67 45 6e t.Encoding.BigEn
13740 64 69 61 6e 55 6e 69 63 6f 64 65 3b 0d 0a 20 20 dianUnicode;..
13750 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a break;..
13760 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 }....
13770 20 62 31 20 3d 20 63 6f 6e 76 65 72 74 65 72 2e b1 = converter.
13780 47 65 74 42 79 74 65 73 28 63 31 29 3b 0d 0a 20 GetBytes(c1);..
13790 20 20 20 20 20 62 32 20 3d 20 63 6f 6e 76 65 72 b2 = conver
137a0 74 65 72 2e 47 65 74 42 79 74 65 73 28 63 32 29 ter.GetBytes(c2)
137b0 3b 0d 0a 0d 0a 20 20 20 20 20 20 72 65 74 75 72 ;.... retur
137c0 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 n UnsafeNativeMe
137d0 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f thods.sqlite3_co
137e0 6e 74 65 78 74 5f 63 6f 6c 6c 63 6f 6d 70 61 72 ntext_collcompar
137f0 65 5f 69 6e 74 65 72 6f 70 28 63 6f 6e 74 65 78 e_interop(contex
13800 74 2c 20 62 31 2c 20 62 31 2e 4c 65 6e 67 74 68 t, b1, b1.Length
13810 2c 20 62 32 2c 20 62 32 2e 4c 65 6e 67 74 68 29 , b2, b2.Length)
13820 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 ;..#else..
13830 74 68 72 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 throw new NotImp
13840 6c 65 6d 65 6e 74 65 64 45 78 63 65 70 74 69 6f lementedExceptio
13850 6e 28 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 n();..#endif..
13860 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 }.... inter
13870 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 43 6f 6c nal override Col
13880 6c 61 74 69 6f 6e 53 65 71 75 65 6e 63 65 20 47 lationSequence G
13890 65 74 43 6f 6c 6c 61 74 69 6f 6e 53 65 71 75 65 etCollationSeque
138a0 6e 63 65 28 53 51 4c 69 74 65 46 75 6e 63 74 69 nce(SQLiteFuncti
138b0 6f 6e 20 66 75 6e 63 2c 20 49 6e 74 50 74 72 20 on func, IntPtr
138c0 63 6f 6e 74 65 78 74 29 0d 0a 20 20 20 20 7b 0d context).. {.
138d0 0a 23 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 .#if !SQLITE_STA
138e0 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 43 6f 6c NDARD.. Col
138f0 6c 61 74 69 6f 6e 53 65 71 75 65 6e 63 65 20 73 lationSequence s
13900 65 71 20 3d 20 6e 65 77 20 43 6f 6c 6c 61 74 69 eq = new Collati
13910 6f 6e 53 65 71 75 65 6e 63 65 28 29 3b 0d 0a 20 onSequence();..
13920 20 20 20 20 20 69 6e 74 20 6c 65 6e 20 3d 20 30 int len = 0
13930 3b 0d 0a 20 20 20 20 20 20 69 6e 74 20 74 79 70 ;.. int typ
13940 65 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 69 6e e = 0;.. in
13950 74 20 65 6e 63 20 3d 20 30 3b 0d 0a 20 20 20 20 t enc = 0;..
13960 20 20 49 6e 74 50 74 72 20 70 20 3d 20 55 6e 73 IntPtr p = Uns
13970 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
13980 2e 73 71 6c 69 74 65 33 5f 63 6f 6e 74 65 78 74 .sqlite3_context
13990 5f 63 6f 6c 6c 73 65 71 5f 69 6e 74 65 72 6f 70 _collseq_interop
139a0 28 63 6f 6e 74 65 78 74 2c 20 72 65 66 20 74 79 (context, ref ty
139b0 70 65 2c 20 72 65 66 20 65 6e 63 2c 20 72 65 66 pe, ref enc, ref
139c0 20 6c 65 6e 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 len);....
139d0 69 66 20 28 70 20 21 3d 20 6e 75 6c 6c 29 20 73 if (p != null) s
139e0 65 71 2e 4e 61 6d 65 20 3d 20 55 54 46 38 54 6f eq.Name = UTF8To
139f0 53 74 72 69 6e 67 28 70 2c 20 6c 65 6e 29 3b 0d String(p, len);.
13a00 0a 20 20 20 20 20 20 73 65 71 2e 54 79 70 65 20 . seq.Type
13a10 3d 20 28 43 6f 6c 6c 61 74 69 6f 6e 54 79 70 65 = (CollationType
13a20 45 6e 75 6d 29 74 79 70 65 3b 0d 0a 20 20 20 20 Enum)type;..
13a30 20 20 73 65 71 2e 5f 66 75 6e 63 20 3d 20 66 75 seq._func = fu
13a40 6e 63 3b 0d 0a 20 20 20 20 20 20 73 65 71 2e 45 nc;.. seq.E
13a50 6e 63 6f 64 69 6e 67 20 3d 20 28 43 6f 6c 6c 61 ncoding = (Colla
13a60 74 69 6f 6e 45 6e 63 6f 64 69 6e 67 45 6e 75 6d tionEncodingEnum
13a70 29 65 6e 63 3b 0d 0a 0d 0a 20 20 20 20 20 20 72 )enc;.... r
13a80 65 74 75 72 6e 20 73 65 71 3b 0d 0a 23 65 6c 73 eturn seq;..#els
13a90 65 0d 0a 20 20 20 20 20 20 74 68 72 6f 77 20 6e e.. throw n
13aa0 65 77 20 4e 6f 74 49 6d 70 6c 65 6d 65 6e 74 65 ew NotImplemente
13ab0 64 45 78 63 65 70 74 69 6f 6e 28 29 3b 0d 0a 23 dException();..#
13ac0 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d 0a 0d 0a endif.. }....
13ad0 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
13ae0 72 72 69 64 65 20 6c 6f 6e 67 20 47 65 74 50 61 rride long GetPa
13af0 72 61 6d 56 61 6c 75 65 42 79 74 65 73 28 49 6e ramValueBytes(In
13b00 74 50 74 72 20 70 2c 20 69 6e 74 20 6e 44 61 74 tPtr p, int nDat
13b10 61 4f 66 66 73 65 74 2c 20 62 79 74 65 5b 5d 20 aOffset, byte[]
13b20 62 44 65 73 74 2c 20 69 6e 74 20 6e 53 74 61 72 bDest, int nStar
13b30 74 2c 20 69 6e 74 20 6e 4c 65 6e 67 74 68 29 0d t, int nLength).
13b40 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 69 6e . {.. in
13b50 74 20 6e 6c 65 6e 20 3d 20 55 6e 73 61 66 65 4e t nlen = UnsafeN
13b60 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c ativeMethods.sql
13b70 69 74 65 33 5f 76 61 6c 75 65 5f 62 79 74 65 73 ite3_value_bytes
13b80 28 70 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 2f 2f (p);.... //
13b90 20 49 66 20 6e 6f 20 64 65 73 74 69 6e 61 74 69 If no destinati
13ba0 6f 6e 20 62 75 66 66 65 72 2c 20 72 65 74 75 72 on buffer, retur
13bb0 6e 20 74 68 65 20 73 69 7a 65 20 6e 65 65 64 65 n the size neede
13bc0 64 2e 0d 0a 20 20 20 20 20 20 69 66 20 28 62 44 d... if (bD
13bd0 65 73 74 20 3d 3d 20 6e 75 6c 6c 29 20 72 65 74 est == null) ret
13be0 75 72 6e 20 6e 6c 65 6e 3b 0d 0a 0d 0a 20 20 20 urn nlen;....
13bf0 20 20 20 69 6e 74 20 6e 43 6f 70 69 65 64 20 3d int nCopied =
13c00 20 6e 4c 65 6e 67 74 68 3b 0d 0a 0d 0a 20 20 20 nLength;....
13c10 20 20 20 69 66 20 28 6e 43 6f 70 69 65 64 20 2b if (nCopied +
13c20 20 6e 53 74 61 72 74 20 3e 20 62 44 65 73 74 2e nStart > bDest.
13c30 4c 65 6e 67 74 68 29 20 6e 43 6f 70 69 65 64 20 Length) nCopied
13c40 3d 20 62 44 65 73 74 2e 4c 65 6e 67 74 68 20 2d = bDest.Length -
13c50 20 6e 53 74 61 72 74 3b 0d 0a 20 20 20 20 20 20 nStart;..
13c60 69 66 20 28 6e 43 6f 70 69 65 64 20 2b 20 6e 44 if (nCopied + nD
13c70 61 74 61 4f 66 66 73 65 74 20 3e 20 6e 6c 65 6e ataOffset > nlen
13c80 29 20 6e 43 6f 70 69 65 64 20 3d 20 6e 6c 65 6e ) nCopied = nlen
13c90 20 2d 20 6e 44 61 74 61 4f 66 66 73 65 74 3b 0d - nDataOffset;.
13ca0 0a 0d 0a 20 20 20 20 20 20 69 66 20 28 6e 43 6f ... if (nCo
13cb0 70 69 65 64 20 3e 20 30 29 0d 0a 20 20 20 20 20 pied > 0)..
13cc0 20 7b 0d 0a 20 20 20 20 20 20 20 20 49 6e 74 50 {.. IntP
13cd0 74 72 20 70 74 72 20 3d 20 55 6e 73 61 66 65 4e tr ptr = UnsafeN
13ce0 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c ativeMethods.sql
13cf0 69 74 65 33 5f 76 61 6c 75 65 5f 62 6c 6f 62 28 ite3_value_blob(
13d00 70 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 4d p);.... M
13d10 61 72 73 68 61 6c 2e 43 6f 70 79 28 28 49 6e 74 arshal.Copy((Int
13d20 50 74 72 29 28 70 74 72 2e 54 6f 49 6e 74 36 34 Ptr)(ptr.ToInt64
13d30 28 29 20 2b 20 6e 44 61 74 61 4f 66 66 73 65 74 () + nDataOffset
13d40 29 2c 20 62 44 65 73 74 2c 20 6e 53 74 61 72 74 ), bDest, nStart
13d50 2c 20 6e 43 6f 70 69 65 64 29 3b 0d 0a 20 20 20 , nCopied);..
13d60 20 20 20 7d 0d 0a 20 20 20 20 20 20 65 6c 73 65 }.. else
13d70 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 .. {..
13d80 20 20 20 6e 43 6f 70 69 65 64 20 3d 20 30 3b 0d nCopied = 0;.
13d90 0a 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 . }....
13da0 20 20 72 65 74 75 72 6e 20 6e 43 6f 70 69 65 64 return nCopied
13db0 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 ;.. }....
13dc0 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 internal overrid
13dd0 65 20 64 6f 75 62 6c 65 20 47 65 74 50 61 72 61 e double GetPara
13de0 6d 56 61 6c 75 65 44 6f 75 62 6c 65 28 49 6e 74 mValueDouble(Int
13df0 50 74 72 20 70 74 72 29 0d 0a 20 20 20 20 7b 0d Ptr ptr).. {.
13e00 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f 43 .#if !PLATFORM_C
13e10 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 4b 0d OMPACTFRAMEWORK.
13e20 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 6e . return Un
13e30 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
13e40 73 2e 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f s.sqlite3_value_
13e50 64 6f 75 62 6c 65 28 70 74 72 29 3b 0d 0a 23 65 double(ptr);..#e
13e60 6c 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e lif !SQLITE_STAN
13e70 44 41 52 44 0d 0a 20 20 20 20 20 20 64 6f 75 62 DARD.. doub
13e80 6c 65 20 76 61 6c 75 65 20 3d 20 30 2e 30 3b 0d le value = 0.0;.
13e90 0a 20 20 20 20 20 20 55 6e 73 61 66 65 4e 61 74 . UnsafeNat
13ea0 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 iveMethods.sqlit
13eb0 65 33 5f 76 61 6c 75 65 5f 64 6f 75 62 6c 65 5f e3_value_double_
13ec0 69 6e 74 65 72 6f 70 28 70 74 72 2c 20 72 65 66 interop(ptr, ref
13ed0 20 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 value);..
13ee0 72 65 74 75 72 6e 20 76 61 6c 75 65 3b 0d 0a 23 return value;..#
13ef0 65 6c 73 65 0d 0a 20 20 20 20 20 20 74 68 72 6f else.. thro
13f00 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 6d 65 w new NotImpleme
13f10 6e 74 65 64 45 78 63 65 70 74 69 6f 6e 28 29 3b ntedException();
13f20 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d ..#endif.. }.
13f30 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 ... internal
13f40 6f 76 65 72 72 69 64 65 20 69 6e 74 20 47 65 74 override int Get
13f50 50 61 72 61 6d 56 61 6c 75 65 49 6e 74 33 32 28 ParamValueInt32(
13f60 49 6e 74 50 74 72 20 70 74 72 29 0d 0a 20 20 20 IntPtr ptr)..
13f70 20 7b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e {.. return
13f80 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
13f90 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 76 61 6c hods.sqlite3_val
13fa0 75 65 5f 69 6e 74 28 70 74 72 29 3b 0d 0a 20 20 ue_int(ptr);..
13fb0 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 }.... inter
13fc0 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 6c 6f 6e nal override lon
13fd0 67 20 47 65 74 50 61 72 61 6d 56 61 6c 75 65 49 g GetParamValueI
13fe0 6e 74 36 34 28 49 6e 74 50 74 72 20 70 74 72 29 nt64(IntPtr ptr)
13ff0 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 21 50 4c .. {..#if !PL
14000 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 52 ATFORM_COMPACTFR
14010 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 20 20 72 AMEWORK.. r
14020 65 74 75 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 eturn UnsafeNati
14030 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
14040 33 5f 76 61 6c 75 65 5f 69 6e 74 36 34 28 70 74 3_value_int64(pt
14050 72 29 3b 0d 0a 23 65 6c 69 66 20 21 53 51 4c 49 r);..#elif !SQLI
14060 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 TE_STANDARD..
14070 20 20 20 49 6e 74 36 34 20 76 61 6c 75 65 20 3d Int64 value =
14080 20 30 3b 0d 0a 20 20 20 20 20 20 55 6e 73 61 66 0;.. Unsaf
14090 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
140a0 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 69 6e 74 qlite3_value_int
140b0 36 34 5f 69 6e 74 65 72 6f 70 28 70 74 72 2c 20 64_interop(ptr,
140c0 72 65 66 20 76 61 6c 75 65 29 3b 0d 0a 20 20 20 ref value);..
140d0 20 20 20 72 65 74 75 72 6e 20 76 61 6c 75 65 3b return value;
140e0 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 74 ..#else.. t
140f0 68 72 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c hrow new NotImpl
14100 65 6d 65 6e 74 65 64 45 78 63 65 70 74 69 6f 6e ementedException
14110 28 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 ();..#endif..
14120 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e }.... intern
14130 61 6c 20 6f 76 65 72 72 69 64 65 20 73 74 72 69 al override stri
14140 6e 67 20 47 65 74 50 61 72 61 6d 56 61 6c 75 65 ng GetParamValue
14150 54 65 78 74 28 49 6e 74 50 74 72 20 70 74 72 29 Text(IntPtr ptr)
14160 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 21 53 51 .. {..#if !SQ
14170 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 LITE_STANDARD..
14180 20 20 20 20 20 69 6e 74 20 6c 65 6e 20 3d 20 30 int len = 0
14190 3b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 ;.. return
141a0 55 54 46 38 54 6f 53 74 72 69 6e 67 28 55 6e 73 UTF8ToString(Uns
141b0 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
141c0 2e 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 74 .sqlite3_value_t
141d0 65 78 74 5f 69 6e 74 65 72 6f 70 28 70 74 72 2c ext_interop(ptr,
141e0 20 72 65 66 20 6c 65 6e 29 2c 20 6c 65 6e 29 3b ref len), len);
141f0 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 72 ..#else.. r
14200 65 74 75 72 6e 20 55 54 46 38 54 6f 53 74 72 69 eturn UTF8ToStri
14210 6e 67 28 55 6e 73 61 66 65 4e 61 74 69 76 65 4d ng(UnsafeNativeM
14220 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 76 ethods.sqlite3_v
14230 61 6c 75 65 5f 74 65 78 74 28 70 74 72 29 2c 0d alue_text(ptr),.
14240 0a 20 20 20 20 20 20 20 20 55 6e 73 61 66 65 4e . UnsafeN
14250 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c ativeMethods.sql
14260 69 74 65 33 5f 76 61 6c 75 65 5f 62 79 74 65 73 ite3_value_bytes
14270 28 70 74 72 29 29 3b 0d 0a 23 65 6e 64 69 66 0d (ptr));..#endif.
14280 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e . }.... in
14290 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
142a0 54 79 70 65 41 66 66 69 6e 69 74 79 20 47 65 74 TypeAffinity Get
142b0 50 61 72 61 6d 56 61 6c 75 65 54 79 70 65 28 49 ParamValueType(I
142c0 6e 74 50 74 72 20 70 74 72 29 0d 0a 20 20 20 20 ntPtr ptr)..
142d0 7b 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 {.. return
142e0 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 UnsafeNativeMeth
142f0 6f 64 73 2e 73 71 6c 69 74 65 33 5f 76 61 6c 75 ods.sqlite3_valu
14300 65 5f 74 79 70 65 28 70 74 72 29 3b 0d 0a 20 20 e_type(ptr);..
14310 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 }.... inter
14320 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f 69 nal override voi
14330 64 20 52 65 74 75 72 6e 42 6c 6f 62 28 49 6e 74 d ReturnBlob(Int
14340 50 74 72 20 63 6f 6e 74 65 78 74 2c 20 62 79 74 Ptr context, byt
14350 65 5b 5d 20 76 61 6c 75 65 29 0d 0a 20 20 20 20 e[] value)..
14360 7b 0d 0a 20 20 20 20 20 20 55 6e 73 61 66 65 4e {.. UnsafeN
14370 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c ativeMethods.sql
14380 69 74 65 33 5f 72 65 73 75 6c 74 5f 62 6c 6f 62 ite3_result_blob
14390 28 63 6f 6e 74 65 78 74 2c 20 76 61 6c 75 65 2c (context, value,
143a0 20 76 61 6c 75 65 2e 4c 65 6e 67 74 68 2c 20 28 value.Length, (
143b0 49 6e 74 50 74 72 29 28 2d 31 29 29 3b 0d 0a 20 IntPtr)(-1));..
143c0 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 }.... inte
143d0 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f rnal override vo
143e0 69 64 20 52 65 74 75 72 6e 44 6f 75 62 6c 65 28 id ReturnDouble(
143f0 49 6e 74 50 74 72 20 63 6f 6e 74 65 78 74 2c 20 IntPtr context,
14400 64 6f 75 62 6c 65 20 76 61 6c 75 65 29 0d 0a 20 double value)..
14410 20 20 20 7b 0d 0a 23 69 66 20 21 50 4c 41 54 46 {..#if !PLATF
14420 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 ORM_COMPACTFRAME
14430 57 4f 52 4b 0d 0a 20 20 20 20 20 20 55 6e 73 61 WORK.. Unsa
14440 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
14450 73 71 6c 69 74 65 33 5f 72 65 73 75 6c 74 5f 64 sqlite3_result_d
14460 6f 75 62 6c 65 28 63 6f 6e 74 65 78 74 2c 20 76 ouble(context, v
14470 61 6c 75 65 29 3b 0d 0a 23 65 6c 69 66 20 21 53 alue);..#elif !S
14480 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a QLITE_STANDARD..
14490 20 20 20 20 20 20 55 6e 73 61 66 65 4e 61 74 69 UnsafeNati
144a0 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 veMethods.sqlite
144b0 33 5f 72 65 73 75 6c 74 5f 64 6f 75 62 6c 65 5f 3_result_double_
144c0 69 6e 74 65 72 6f 70 28 63 6f 6e 74 65 78 74 2c interop(context,
144d0 20 72 65 66 20 76 61 6c 75 65 29 3b 0d 0a 23 65 ref value);..#e
144e0 6c 73 65 0d 0a 20 20 20 20 20 20 74 68 72 6f 77 lse.. throw
144f0 20 6e 65 77 20 4e 6f 74 49 6d 70 6c 65 6d 65 6e new NotImplemen
14500 74 65 64 45 78 63 65 70 74 69 6f 6e 28 29 3b 0d tedException();.
14510 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 7d 0d 0a .#endif.. }..
14520 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
14530 76 65 72 72 69 64 65 20 76 6f 69 64 20 52 65 74 verride void Ret
14540 75 72 6e 45 72 72 6f 72 28 49 6e 74 50 74 72 20 urnError(IntPtr
14550 63 6f 6e 74 65 78 74 2c 20 73 74 72 69 6e 67 20 context, string
14560 76 61 6c 75 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 value).. {..
14570 20 20 20 20 20 55 6e 73 61 66 65 4e 61 74 69 76 UnsafeNativ
14580 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
14590 5f 72 65 73 75 6c 74 5f 65 72 72 6f 72 28 63 6f _result_error(co
145a0 6e 74 65 78 74 2c 20 54 6f 55 54 46 38 28 76 61 ntext, ToUTF8(va
145b0 6c 75 65 29 2c 20 76 61 6c 75 65 2e 4c 65 6e 67 lue), value.Leng
145c0 74 68 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 th);.. }....
145d0 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 internal over
145e0 72 69 64 65 20 76 6f 69 64 20 52 65 74 75 72 6e ride void Return
145f0 49 6e 74 33 32 28 49 6e 74 50 74 72 20 63 6f 6e Int32(IntPtr con
14600 74 65 78 74 2c 20 69 6e 74 20 76 61 6c 75 65 29 text, int value)
14610 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 55 .. {.. U
14620 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
14630 64 73 2e 73 71 6c 69 74 65 33 5f 72 65 73 75 6c ds.sqlite3_resul
14640 74 5f 69 6e 74 28 63 6f 6e 74 65 78 74 2c 20 76 t_int(context, v
14650 61 6c 75 65 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d alue);.. }...
14660 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
14670 65 72 72 69 64 65 20 76 6f 69 64 20 52 65 74 75 erride void Retu
14680 72 6e 49 6e 74 36 34 28 49 6e 74 50 74 72 20 63 rnInt64(IntPtr c
14690 6f 6e 74 65 78 74 2c 20 6c 6f 6e 67 20 76 61 6c ontext, long val
146a0 75 65 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 ue).. {..#if
146b0 21 50 4c 41 54 46 4f 52 4d 5f 43 4f 4d 50 41 43 !PLATFORM_COMPAC
146c0 54 46 52 41 4d 45 57 4f 52 4b 0d 0a 20 20 20 20 TFRAMEWORK..
146d0 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 UnsafeNativeMe
146e0 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 72 65 thods.sqlite3_re
146f0 73 75 6c 74 5f 69 6e 74 36 34 28 63 6f 6e 74 65 sult_int64(conte
14700 78 74 2c 20 76 61 6c 75 65 29 3b 0d 0a 23 65 6c xt, value);..#el
14710 69 66 20 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 if !SQLITE_STAND
14720 41 52 44 0d 0a 20 20 20 20 20 20 55 6e 73 61 66 ARD.. Unsaf
14730 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
14740 71 6c 69 74 65 33 5f 72 65 73 75 6c 74 5f 69 6e qlite3_result_in
14750 74 36 34 5f 69 6e 74 65 72 6f 70 28 63 6f 6e 74 t64_interop(cont
14760 65 78 74 2c 20 72 65 66 20 76 61 6c 75 65 29 3b ext, ref value);
14770 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 74 ..#else.. t
14780 68 72 6f 77 20 6e 65 77 20 4e 6f 74 49 6d 70 6c hrow new NotImpl
14790 65 6d 65 6e 74 65 64 45 78 63 65 70 74 69 6f 6e ementedException
147a0 28 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 ();..#endif..
147b0 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e }.... intern
147c0 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f 69 64 al override void
147d0 20 52 65 74 75 72 6e 4e 75 6c 6c 28 49 6e 74 50 ReturnNull(IntP
147e0 74 72 20 63 6f 6e 74 65 78 74 29 0d 0a 20 20 20 tr context)..
147f0 20 7b 0d 0a 20 20 20 20 20 20 55 6e 73 61 66 65 {.. Unsafe
14800 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 NativeMethods.sq
14810 6c 69 74 65 33 5f 72 65 73 75 6c 74 5f 6e 75 6c lite3_result_nul
14820 6c 28 63 6f 6e 74 65 78 74 29 3b 0d 0a 20 20 20 l(context);..
14830 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e }.... intern
14840 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f 69 64 al override void
14850 20 52 65 74 75 72 6e 54 65 78 74 28 49 6e 74 50 ReturnText(IntP
14860 74 72 20 63 6f 6e 74 65 78 74 2c 20 73 74 72 69 tr context, stri
14870 6e 67 20 76 61 6c 75 65 29 0d 0a 20 20 20 20 7b ng value).. {
14880 0d 0a 20 20 20 20 20 20 62 79 74 65 5b 5d 20 62 .. byte[] b
14890 20 3d 20 54 6f 55 54 46 38 28 76 61 6c 75 65 29 = ToUTF8(value)
148a0 3b 0d 0a 20 20 20 20 20 20 55 6e 73 61 66 65 4e ;.. UnsafeN
148b0 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c ativeMethods.sql
148c0 69 74 65 33 5f 72 65 73 75 6c 74 5f 74 65 78 74 ite3_result_text
148d0 28 63 6f 6e 74 65 78 74 2c 20 54 6f 55 54 46 38 (context, ToUTF8
148e0 28 76 61 6c 75 65 29 2c 20 62 2e 4c 65 6e 67 74 (value), b.Lengt
148f0 68 20 2d 20 31 2c 20 28 49 6e 74 50 74 72 29 28 h - 1, (IntPtr)(
14900 2d 31 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a -1));.. }....
14910 23 69 66 20 49 4e 54 45 52 4f 50 5f 56 49 52 54 #if INTEROP_VIRT
14920 55 41 4c 5f 54 41 42 4c 45 0d 0a 20 20 20 20 2f UAL_TABLE.. /
14930 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 // <summary>..
14940 20 20 2f 2f 2f 20 44 65 74 65 72 6d 69 6e 65 73 /// Determines
14950 20 74 68 65 20 66 69 6c 65 20 6e 61 6d 65 20 6f the file name o
14960 66 20 74 68 65 20 6e 61 74 69 76 65 20 6c 69 62 f the native lib
14970 72 61 72 79 20 63 6f 6e 74 61 69 6e 69 6e 67 20 rary containing
14980 74 68 65 20 6e 61 74 69 76 65 0d 0a 20 20 20 20 the native..
14990 2f 2f 2f 20 22 76 74 73 68 69 6d 22 20 65 78 74 /// "vtshim" ext
149a0 65 6e 73 69 6f 6e 20 2d 41 4e 44 2d 20 77 68 65 ension -AND- whe
149b0 74 68 65 72 20 69 74 20 73 68 6f 75 6c 64 20 62 ther it should b
149c0 65 20 64 79 6e 61 6d 69 63 61 6c 6c 79 20 6c 6f e dynamically lo
149d0 61 64 65 64 20 62 79 0d 0a 20 20 20 20 2f 2f 2f aded by.. ///
149e0 20 74 68 69 73 20 63 6c 61 73 73 2e 0d 0a 20 20 this class...
149f0 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e /// </summary>
14a00 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d .. /// <param
14a10 20 6e 61 6d 65 3d 22 69 73 4c 6f 61 64 4e 65 65 name="isLoadNee
14a20 64 65 64 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 ded">.. /// T
14a30 68 69 73 20 6f 75 74 70 75 74 20 70 61 72 61 6d his output param
14a40 65 74 65 72 20 77 69 6c 6c 20 62 65 20 73 65 74 eter will be set
14a50 20 74 6f 20 6e 6f 6e 2d 7a 65 72 6f 20 69 66 20 to non-zero if
14a60 74 68 65 20 72 65 74 75 72 6e 65 64 20 6e 61 74 the returned nat
14a70 69 76 65 0d 0a 20 20 20 20 2f 2f 2f 20 6c 69 62 ive.. /// lib
14a80 72 61 72 79 20 66 69 6c 65 20 6e 61 6d 65 20 73 rary file name s
14a90 68 6f 75 6c 64 20 62 65 20 64 79 6e 61 6d 69 63 hould be dynamic
14aa0 61 6c 6c 79 20 6c 6f 61 64 65 64 20 70 72 69 6f ally loaded prio
14ab0 72 20 74 6f 20 61 74 74 65 6d 70 74 69 6e 67 0d r to attempting.
14ac0 0a 20 20 20 20 2f 2f 2f 20 74 68 65 20 63 72 65 . /// the cre
14ad0 61 74 69 6f 6e 20 6f 66 20 6e 61 74 69 76 65 20 ation of native
14ae0 64 69 73 70 6f 73 61 62 6c 65 20 65 78 74 65 6e disposable exten
14af0 73 69 6f 6e 20 6d 6f 64 75 6c 65 73 2e 0d 0a 20 sion modules...
14b00 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d /// </param>.
14b10 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e . /// <return
14b20 73 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 s>.. /// The
14b30 66 69 6c 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 file name of the
14b40 20 6e 61 74 69 76 65 20 6c 69 62 72 61 72 79 20 native library
14b50 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 20 6e containing the n
14b60 61 74 69 76 65 20 22 76 74 73 68 69 6d 22 0d 0a ative "vtshim"..
14b70 20 20 20 20 2f 2f 2f 20 65 78 74 65 6e 73 69 6f /// extensio
14b80 6e 20 2d 4f 52 2d 20 6e 75 6c 6c 20 69 66 20 69 n -OR- null if i
14b90 74 20 63 61 6e 6e 6f 74 20 62 65 20 64 65 74 65 t cannot be dete
14ba0 72 6d 69 6e 65 64 2e 0d 0a 20 20 20 20 2f 2f 2f rmined... ///
14bb0 20 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 </returns>..
14bc0 20 70 72 69 76 61 74 65 20 73 74 72 69 6e 67 20 private string
14bd0 47 65 74 53 68 69 6d 45 78 74 65 6e 73 69 6f 6e GetShimExtension
14be0 46 69 6c 65 4e 61 6d 65 28 0d 0a 20 20 20 20 20 FileName(..
14bf0 20 20 20 72 65 66 20 62 6f 6f 6c 20 69 73 4c 6f ref bool isLo
14c00 61 64 4e 65 65 64 65 64 20 2f 2a 20 6f 75 74 20 adNeeded /* out
14c10 2a 2f 0d 0a 20 20 20 20 20 20 20 20 29 0d 0a 20 */.. )..
14c20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 69 66 {.. if
14c30 20 28 5f 73 68 69 6d 49 73 4c 6f 61 64 4e 65 65 (_shimIsLoadNee
14c40 64 65 64 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 ded != null)..
14c50 20 20 20 20 20 20 20 20 20 20 69 73 4c 6f 61 64 isLoad
14c60 4e 65 65 64 65 64 20 3d 20 28 62 6f 6f 6c 29 5f Needed = (bool)_
14c70 73 68 69 6d 49 73 4c 6f 61 64 4e 65 65 64 65 64 shimIsLoadNeeded
14c80 3b 0d 0a 20 20 20 20 20 20 20 20 65 6c 73 65 0d ;.. else.
14c90 0a 23 69 66 20 53 51 4c 49 54 45 5f 53 54 41 4e .#if SQLITE_STAN
14ca0 44 41 52 44 20 7c 7c 20 55 53 45 5f 49 4e 54 45 DARD || USE_INTE
14cb0 52 4f 50 5f 44 4c 4c 20 7c 7c 20 50 4c 41 54 46 ROP_DLL || PLATF
14cc0 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 ORM_COMPACTFRAME
14cd0 57 4f 52 4b 0d 0a 20 20 20 20 20 20 20 20 20 20 WORK..
14ce0 20 20 69 73 4c 6f 61 64 4e 65 65 64 65 64 20 3d isLoadNeeded =
14cf0 20 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e 49 HelperMethods.I
14d00 73 57 69 6e 64 6f 77 73 28 29 3b 20 2f 2a 20 43 sWindows(); /* C
14d10 4f 4d 50 41 54 20 2a 2f 0d 0a 23 65 6c 73 65 0d OMPAT */..#else.
14d20 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 73 4c . isL
14d30 6f 61 64 4e 65 65 64 65 64 20 3d 20 66 61 6c 73 oadNeeded = fals
14d40 65 3b 20 2f 2a 20 6d 69 78 65 64 2d 6d 6f 64 65 e; /* mixed-mode
14d50 20 61 73 73 65 6d 62 6c 79 20 2a 2f 0d 0a 23 65 assembly */..#e
14d60 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ndif....
14d70 73 74 72 69 6e 67 20 66 69 6c 65 4e 61 6d 65 20 string fileName
14d80 3d 20 5f 73 68 69 6d 45 78 74 65 6e 73 69 6f 6e = _shimExtension
14d90 46 69 6c 65 4e 61 6d 65 3b 0d 0a 0d 0a 20 20 20 FileName;....
14da0 20 20 20 20 20 69 66 20 28 66 69 6c 65 4e 61 6d if (fileNam
14db0 65 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 e != null)..
14dc0 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 66 return f
14dd0 69 6c 65 4e 61 6d 65 3b 0d 0a 0d 0a 23 69 66 20 ileName;....#if
14de0 28 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 (SQLITE_STANDARD
14df0 20 7c 7c 20 55 53 45 5f 49 4e 54 45 52 4f 50 5f || USE_INTEROP_
14e00 44 4c 4c 20 7c 7c 20 50 4c 41 54 46 4f 52 4d 5f DLL || PLATFORM_
14e10 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 4b COMPACTFRAMEWORK
14e20 29 20 26 26 20 50 52 45 4c 4f 41 44 5f 4e 41 54 ) && PRELOAD_NAT
14e30 49 56 45 5f 4c 49 42 52 41 52 59 0d 0a 20 20 20 IVE_LIBRARY..
14e40 20 20 20 20 20 72 65 74 75 72 6e 20 55 6e 73 61 return Unsa
14e50 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
14e60 47 65 74 4e 61 74 69 76 65 4c 69 62 72 61 72 79 GetNativeLibrary
14e70 46 69 6c 65 4e 61 6d 65 4f 6e 6c 79 28 29 3b 20 FileNameOnly();
14e80 2f 2a 20 43 4f 4d 50 41 54 20 2a 2f 0d 0a 23 65 /* COMPAT */..#e
14e90 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 72 65 74 lse.. ret
14ea0 75 72 6e 20 6e 75 6c 6c 3b 0d 0a 23 65 6e 64 69 urn null;..#endi
14eb0 66 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 f.. }....
14ec0 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 /// <summary>..
14ed0 20 20 20 2f 2f 2f 20 43 61 6c 6c 73 20 74 68 65 /// Calls the
14ee0 20 6e 61 74 69 76 65 20 53 51 4c 69 74 65 20 63 native SQLite c
14ef0 6f 72 65 20 6c 69 62 72 61 72 79 20 69 6e 20 6f ore library in o
14f00 72 64 65 72 20 74 6f 20 63 72 65 61 74 65 20 61 rder to create a
14f10 20 64 69 73 70 6f 73 61 62 6c 65 0d 0a 20 20 20 disposable..
14f20 20 2f 2f 2f 20 6d 6f 64 75 6c 65 20 63 6f 6e 74 /// module cont
14f30 61 69 6e 69 6e 67 20 74 68 65 20 69 6d 70 6c 65 aining the imple
14f40 6d 65 6e 74 61 74 69 6f 6e 20 6f 66 20 61 20 76 mentation of a v
14f50 69 72 74 75 61 6c 20 74 61 62 6c 65 2e 0d 0a 20 irtual table...
14f60 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 /// </summary
14f70 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 >.. /// <para
14f80 6d 20 6e 61 6d 65 3d 22 6d 6f 64 75 6c 65 22 3e m name="module">
14f90 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 6d 6f .. /// The mo
14fa0 64 75 6c 65 20 6f 62 6a 65 63 74 20 74 6f 20 62 dule object to b
14fb0 65 20 75 73 65 64 20 77 68 65 6e 20 63 72 65 61 e used when crea
14fc0 74 69 6e 67 20 74 68 65 20 6e 61 74 69 76 65 20 ting the native
14fd0 64 69 73 70 6f 73 61 62 6c 65 20 6d 6f 64 75 6c disposable modul
14fe0 65 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 e... /// </pa
14ff0 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 ram>.. /// <p
15000 61 72 61 6d 20 6e 61 6d 65 3d 22 66 6c 61 67 73 aram name="flags
15010 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 ">.. /// The
15020 66 6c 61 67 73 20 66 6f 72 20 74 68 65 20 61 73 flags for the as
15030 73 6f 63 69 61 74 65 64 20 3c 73 65 65 20 63 72 sociated <see cr
15040 65 66 3d 22 53 51 4c 69 74 65 43 6f 6e 6e 65 63 ef="SQLiteConnec
15050 74 69 6f 6e 22 20 2f 3e 20 6f 62 6a 65 63 74 20 tion" /> object
15060 69 6e 73 74 61 6e 63 65 2e 0d 0a 20 20 20 20 2f instance... /
15070 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 // </param>..
15080 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 internal overri
15090 64 65 20 76 6f 69 64 20 43 72 65 61 74 65 4d 6f de void CreateMo
150a0 64 75 6c 65 28 53 51 4c 69 74 65 4d 6f 64 75 6c dule(SQLiteModul
150b0 65 20 6d 6f 64 75 6c 65 2c 20 53 51 4c 69 74 65 e module, SQLite
150c0 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 20 ConnectionFlags
150d0 66 6c 61 67 73 29 0d 0a 20 20 20 20 7b 0d 0a 20 flags).. {..
150e0 20 20 20 20 20 20 20 69 66 20 28 6d 6f 64 75 6c if (modul
150f0 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 e == null)..
15100 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 throw ne
15110 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 w ArgumentNullEx
15120 63 65 70 74 69 6f 6e 28 22 6d 6f 64 75 6c 65 22 ception("module"
15130 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 );.... if
15140 20 28 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e (HelperMethods.
15150 4e 6f 4c 6f 67 4d 6f 64 75 6c 65 28 66 6c 61 67 NoLogModule(flag
15160 73 29 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a s)).. {..
15170 20 20 20 20 20 20 20 20 20 20 20 20 6d 6f 64 75 modu
15180 6c 65 2e 4c 6f 67 45 72 72 6f 72 73 20 3d 20 48 le.LogErrors = H
15190 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e 4c 6f 67 elperMethods.Log
151a0 4d 6f 64 75 6c 65 45 72 72 6f 72 28 66 6c 61 67 ModuleError(flag
151b0 73 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 s);..
151c0 20 6d 6f 64 75 6c 65 2e 4c 6f 67 45 78 63 65 70 module.LogExcep
151d0 74 69 6f 6e 73 20 3d 20 48 65 6c 70 65 72 4d 65 tions = HelperMe
151e0 74 68 6f 64 73 2e 4c 6f 67 4d 6f 64 75 6c 65 45 thods.LogModuleE
151f0 78 63 65 70 74 69 6f 6e 28 66 6c 61 67 73 29 3b xception(flags);
15200 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 .. }....
15210 20 20 20 20 20 20 20 69 66 20 28 5f 73 71 6c 20 if (_sql
15220 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 == null)..
15230 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 throw new
15240 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 SQLiteException(
15250 22 63 6f 6e 6e 65 63 74 69 6f 6e 20 68 61 73 20 "connection has
15260 61 6e 20 69 6e 76 61 6c 69 64 20 68 61 6e 64 6c an invalid handl
15270 65 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 e");....
15280 62 6f 6f 6c 20 69 73 4c 6f 61 64 4e 65 65 64 65 bool isLoadNeede
15290 64 20 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 d = false;..
152a0 20 20 20 20 73 74 72 69 6e 67 20 66 69 6c 65 4e string fileN
152b0 61 6d 65 20 3d 20 47 65 74 53 68 69 6d 45 78 74 ame = GetShimExt
152c0 65 6e 73 69 6f 6e 46 69 6c 65 4e 61 6d 65 28 72 ensionFileName(r
152d0 65 66 20 69 73 4c 6f 61 64 4e 65 65 64 65 64 29 ef isLoadNeeded)
152e0 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 ;.... if
152f0 28 69 73 4c 6f 61 64 4e 65 65 64 65 64 29 0d 0a (isLoadNeeded)..
15300 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
15310 20 20 20 20 20 20 20 69 66 20 28 66 69 6c 65 4e if (fileN
15320 61 6d 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 ame == null)..
15330 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 th
15340 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 row new SQLiteEx
15350 63 65 70 74 69 6f 6e 28 22 74 68 65 20 66 69 6c ception("the fil
15360 65 20 6e 61 6d 65 20 66 6f 72 20 74 68 65 20 5c e name for the \
15370 22 76 74 73 68 69 6d 5c 22 20 65 78 74 65 6e 73 "vtshim\" extens
15380 69 6f 6e 20 69 73 20 75 6e 6b 6e 6f 77 6e 22 29 ion is unknown")
15390 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ;....
153a0 20 69 66 20 28 5f 73 68 69 6d 45 78 74 65 6e 73 if (_shimExtens
153b0 69 6f 6e 50 72 6f 63 4e 61 6d 65 20 3d 3d 20 6e ionProcName == n
153c0 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 ull)..
153d0 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 throw new
153e0 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 SQLiteException(
153f0 22 74 68 65 20 65 6e 74 72 79 20 70 6f 69 6e 74 "the entry point
15400 20 66 6f 72 20 74 68 65 20 5c 22 76 74 73 68 69 for the \"vtshi
15410 6d 5c 22 20 65 78 74 65 6e 73 69 6f 6e 20 69 73 m\" extension is
15420 20 75 6e 6b 6e 6f 77 6e 22 29 3b 0d 0a 0d 0a 20 unknown");....
15430 20 20 20 20 20 20 20 20 20 20 20 53 65 74 4c 6f SetLo
15440 61 64 45 78 74 65 6e 73 69 6f 6e 28 74 72 75 65 adExtension(true
15450 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 );..
15460 4c 6f 61 64 45 78 74 65 6e 73 69 6f 6e 28 66 69 LoadExtension(fi
15470 6c 65 4e 61 6d 65 2c 20 5f 73 68 69 6d 45 78 74 leName, _shimExt
15480 65 6e 73 69 6f 6e 50 72 6f 63 4e 61 6d 65 29 3b ensionProcName);
15490 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 .. }....
154a0 20 20 20 20 20 20 20 69 66 20 28 6d 6f 64 75 6c if (modul
154b0 65 2e 43 72 65 61 74 65 44 69 73 70 6f 73 61 62 e.CreateDisposab
154c0 6c 65 4d 6f 64 75 6c 65 28 5f 73 71 6c 29 29 0d leModule(_sql)).
154d0 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 . {..
154e0 20 20 20 20 20 20 20 20 69 66 20 28 5f 6d 6f 64 if (_mod
154f0 75 6c 65 73 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 ules == null)..
15500 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5f _
15510 6d 6f 64 75 6c 65 73 20 3d 20 6e 65 77 20 44 69 modules = new Di
15520 63 74 69 6f 6e 61 72 79 3c 73 74 72 69 6e 67 2c ctionary<string,
15530 20 53 51 4c 69 74 65 4d 6f 64 75 6c 65 3e 28 29 SQLiteModule>()
15540 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ;....
15550 20 5f 6d 6f 64 75 6c 65 73 2e 41 64 64 28 6d 6f _modules.Add(mo
15560 64 75 6c 65 2e 4e 61 6d 65 2c 20 6d 6f 64 75 6c dule.Name, modul
15570 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 e);....
15580 20 20 20 69 66 20 28 5f 75 73 65 50 6f 6f 6c 29 if (_usePool)
15590 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d .. {.
155a0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
155b0 20 5f 75 73 65 50 6f 6f 6c 20 3d 20 66 61 6c 73 _usePool = fals
155c0 65 3b 0d 0a 0d 0a 23 69 66 20 21 4e 45 54 5f 43 e;....#if !NET_C
155d0 4f 4d 50 41 43 54 5f 32 30 20 26 26 20 54 52 41 OMPACT_20 && TRA
155e0 43 45 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 CE_CONNECTION..
155f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 54 T
15600 72 61 63 65 2e 57 72 69 74 65 4c 69 6e 65 28 48 race.WriteLine(H
15610 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e 53 74 72 elperMethods.Str
15620 69 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 ingFormat(..
15630 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
15640 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 CultureInfo.Curr
15650 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 entCulture,..
15660 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
15670 20 22 43 72 65 61 74 65 4d 6f 64 75 6c 65 20 28 "CreateModule (
15680 50 6f 6f 6c 29 20 44 69 73 61 62 6c 65 64 3a 20 Pool) Disabled:
15690 7b 30 7d 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 {0}",..
156a0 20 20 20 20 20 20 20 20 20 20 20 48 61 6e 64 6c Handl
156b0 65 54 6f 53 74 72 69 6e 67 28 29 29 29 3b 0d 0a eToString()));..
156c0 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 #endif..
156d0 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d }.. }
156e0 0d 0a 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a .. else..
156f0 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
15700 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 throw new
15710 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e SQLiteException
15720 28 47 65 74 4c 61 73 74 45 72 72 6f 72 28 29 29 (GetLastError())
15730 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 ;.. }..
15740 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c }.... /// <
15750 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
15760 2f 20 43 61 6c 6c 73 20 74 68 65 20 6e 61 74 69 / Calls the nati
15770 76 65 20 53 51 4c 69 74 65 20 63 6f 72 65 20 6c ve SQLite core l
15780 69 62 72 61 72 79 20 69 6e 20 6f 72 64 65 72 20 ibrary in order
15790 74 6f 20 63 6c 65 61 6e 75 70 20 74 68 65 20 72 to cleanup the r
157a0 65 73 6f 75 72 63 65 73 0d 0a 20 20 20 20 2f 2f esources.. //
157b0 2f 20 61 73 73 6f 63 69 61 74 65 64 20 77 69 74 / associated wit
157c0 68 20 61 20 6d 6f 64 75 6c 65 20 63 6f 6e 74 61 h a module conta
157d0 69 6e 69 6e 67 20 74 68 65 20 69 6d 70 6c 65 6d ining the implem
157e0 65 6e 74 61 74 69 6f 6e 20 6f 66 20 61 20 76 69 entation of a vi
157f0 72 74 75 61 6c 20 74 61 62 6c 65 2e 0d 0a 20 20 rtual table...
15800 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e /// </summary>
15810 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d .. /// <param
15820 20 6e 61 6d 65 3d 22 6d 6f 64 75 6c 65 22 3e 0d name="module">.
15830 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 6d 6f 64 . /// The mod
15840 75 6c 65 20 6f 62 6a 65 63 74 20 70 72 65 76 69 ule object previ
15850 6f 75 73 6c 79 20 70 61 73 73 65 64 20 74 6f 20 ously passed to
15860 74 68 65 20 3c 73 65 65 20 63 72 65 66 3d 22 43 the <see cref="C
15870 72 65 61 74 65 4d 6f 64 75 6c 65 22 20 2f 3e 0d reateModule" />.
15880 0a 20 20 20 20 2f 2f 2f 20 6d 65 74 68 6f 64 2e . /// method.
15890 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 .. /// </para
158a0 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 m>.. /// <par
158b0 61 6d 20 6e 61 6d 65 3d 22 66 6c 61 67 73 22 3e am name="flags">
158c0 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 66 6c .. /// The fl
158d0 61 67 73 20 66 6f 72 20 74 68 65 20 61 73 73 6f ags for the asso
158e0 63 69 61 74 65 64 20 3c 73 65 65 20 63 72 65 66 ciated <see cref
158f0 3d 22 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 ="SQLiteConnecti
15900 6f 6e 22 20 2f 3e 20 6f 62 6a 65 63 74 20 69 6e on" /> object in
15910 73 74 61 6e 63 65 2e 0d 0a 20 20 20 20 2f 2f 2f stance... ///
15920 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 69 </param>.. i
15930 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 nternal override
15940 20 76 6f 69 64 20 44 69 73 70 6f 73 65 4d 6f 64 void DisposeMod
15950 75 6c 65 28 53 51 4c 69 74 65 4d 6f 64 75 6c 65 ule(SQLiteModule
15960 20 6d 6f 64 75 6c 65 2c 20 53 51 4c 69 74 65 43 module, SQLiteC
15970 6f 6e 6e 65 63 74 69 6f 6e 46 6c 61 67 73 20 66 onnectionFlags f
15980 6c 61 67 73 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 lags).. {..
15990 20 20 20 20 20 20 69 66 20 28 6d 6f 64 75 6c 65 if (module
159a0 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 == null)..
159b0 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 throw new
159c0 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 ArgumentNullExc
159d0 65 70 74 69 6f 6e 28 22 6d 6f 64 75 6c 65 22 29 eption("module")
159e0 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 6d 6f 64 ;.... mod
159f0 75 6c 65 2e 44 69 73 70 6f 73 65 28 29 3b 0d 0a ule.Dispose();..
15a00 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d 0a 0d }..#endif...
15a10 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
15a20 65 72 72 69 64 65 20 49 6e 74 50 74 72 20 41 67 erride IntPtr Ag
15a30 67 72 65 67 61 74 65 43 6f 6e 74 65 78 74 28 49 gregateContext(I
15a40 6e 74 50 74 72 20 63 6f 6e 74 65 78 74 29 0d 0a ntPtr context)..
15a50 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 65 74 {.. ret
15a60 75 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 urn UnsafeNative
15a70 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
15a80 61 67 67 72 65 67 61 74 65 5f 63 6f 6e 74 65 78 aggregate_contex
15a90 74 28 63 6f 6e 74 65 78 74 2c 20 31 29 3b 0d 0a t(context, 1);..
15aa0 20 20 20 20 7d 0d 0a 0d 0a 23 69 66 20 49 4e 54 }....#if INT
15ab0 45 52 4f 50 5f 56 49 52 54 55 41 4c 5f 54 41 42 EROP_VIRTUAL_TAB
15ac0 4c 45 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d LE.. /// <sum
15ad0 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 43 mary>.. /// C
15ae0 61 6c 6c 73 20 74 68 65 20 6e 61 74 69 76 65 20 alls the native
15af0 53 51 4c 69 74 65 20 63 6f 72 65 20 6c 69 62 72 SQLite core libr
15b00 61 72 79 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 ary in order to
15b10 64 65 63 6c 61 72 65 20 61 20 76 69 72 74 75 61 declare a virtua
15b20 6c 20 74 61 62 6c 65 0d 0a 20 20 20 20 2f 2f 2f l table.. ///
15b30 20 69 6e 20 72 65 73 70 6f 6e 73 65 20 74 6f 20 in response to
15b40 61 20 63 61 6c 6c 20 69 6e 74 6f 20 74 68 65 20 a call into the
15b50 3c 73 65 65 20 63 72 65 66 3d 22 49 53 51 4c 69 <see cref="ISQLi
15b60 74 65 4e 61 74 69 76 65 4d 6f 64 75 6c 65 2e 78 teNativeModule.x
15b70 43 72 65 61 74 65 22 20 2f 3e 0d 0a 20 20 20 20 Create" />..
15b80 2f 2f 2f 20 6f 72 20 3c 73 65 65 20 63 72 65 66 /// or <see cref
15b90 3d 22 49 53 51 4c 69 74 65 4e 61 74 69 76 65 4d ="ISQLiteNativeM
15ba0 6f 64 75 6c 65 2e 78 43 6f 6e 6e 65 63 74 22 20 odule.xConnect"
15bb0 2f 3e 20 76 69 72 74 75 61 6c 20 74 61 62 6c 65 /> virtual table
15bc0 20 6d 65 74 68 6f 64 73 2e 0d 0a 20 20 20 20 2f methods... /
15bd0 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 // </summary>..
15be0 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 /// <param na
15bf0 6d 65 3d 22 6d 6f 64 75 6c 65 22 3e 0d 0a 20 20 me="module">..
15c00 20 20 2f 2f 2f 20 54 68 65 20 76 69 72 74 75 61 /// The virtua
15c10 6c 20 74 61 62 6c 65 20 6d 6f 64 75 6c 65 20 74 l table module t
15c20 68 61 74 20 69 73 20 74 6f 20 62 65 20 72 65 73 hat is to be res
15c30 70 6f 6e 73 69 62 6c 65 20 66 6f 72 20 74 68 65 ponsible for the
15c40 20 76 69 72 74 75 61 6c 20 74 61 62 6c 65 0d 0a virtual table..
15c50 20 20 20 20 2f 2f 2f 20 62 65 69 6e 67 20 64 65 /// being de
15c60 63 6c 61 72 65 64 2e 0d 0a 20 20 20 20 2f 2f 2f clared... ///
15c70 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f </param>.. /
15c80 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 // <param name="
15c90 73 74 72 53 71 6c 22 3e 0d 0a 20 20 20 20 2f 2f strSql">.. //
15ca0 2f 20 54 68 65 20 73 74 72 69 6e 67 20 63 6f 6e / The string con
15cb0 74 61 69 6e 69 6e 67 20 74 68 65 20 53 51 4c 20 taining the SQL
15cc0 73 74 61 74 65 6d 65 6e 74 20 64 65 73 63 72 69 statement descri
15cd0 62 69 6e 67 20 74 68 65 20 76 69 72 74 75 61 6c bing the virtual
15ce0 20 74 61 62 6c 65 20 74 6f 0d 0a 20 20 20 20 2f table to.. /
15cf0 2f 2f 20 62 65 20 64 65 63 6c 61 72 65 64 2e 0d // be declared..
15d00 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d . /// </param
15d10 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 >.. /// <para
15d20 6d 20 6e 61 6d 65 3d 22 65 72 72 6f 72 22 3e 0d m name="error">.
15d30 0a 20 20 20 20 2f 2f 2f 20 55 70 6f 6e 20 73 75 . /// Upon su
15d40 63 63 65 73 73 2c 20 74 68 65 20 63 6f 6e 74 65 ccess, the conte
15d50 6e 74 73 20 6f 66 20 74 68 69 73 20 70 61 72 61 nts of this para
15d60 6d 65 74 65 72 20 61 72 65 20 75 6e 64 65 66 69 meter are undefi
15d70 6e 65 64 2e 20 20 55 70 6f 6e 20 66 61 69 6c 75 ned. Upon failu
15d80 72 65 2c 0d 0a 20 20 20 20 2f 2f 2f 20 69 74 20 re,.. /// it
15d90 73 68 6f 75 6c 64 20 63 6f 6e 74 61 69 6e 20 61 should contain a
15da0 6e 20 61 70 70 72 6f 70 72 69 61 74 65 20 65 72 n appropriate er
15db0 72 6f 72 20 6d 65 73 73 61 67 65 2e 0d 0a 20 20 ror message...
15dc0 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a /// </param>..
15dd0 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 /// <returns
15de0 3e 0d 0a 20 20 20 20 2f 2f 2f 20 41 20 73 74 61 >.. /// A sta
15df0 6e 64 61 72 64 20 53 51 4c 69 74 65 20 72 65 74 ndard SQLite ret
15e00 75 72 6e 20 63 6f 64 65 2e 0d 0a 20 20 20 20 2f urn code... /
15e10 2f 2f 20 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 // </returns>..
15e20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 internal over
15e30 72 69 64 65 20 53 51 4c 69 74 65 45 72 72 6f 72 ride SQLiteError
15e40 43 6f 64 65 20 44 65 63 6c 61 72 65 56 69 72 74 Code DeclareVirt
15e50 75 61 6c 54 61 62 6c 65 28 0d 0a 20 20 20 20 20 ualTable(..
15e60 20 20 20 53 51 4c 69 74 65 4d 6f 64 75 6c 65 20 SQLiteModule
15e70 6d 6f 64 75 6c 65 2c 0d 0a 20 20 20 20 20 20 20 module,..
15e80 20 73 74 72 69 6e 67 20 73 74 72 53 71 6c 2c 0d string strSql,.
15e90 0a 20 20 20 20 20 20 20 20 72 65 66 20 73 74 72 . ref str
15ea0 69 6e 67 20 65 72 72 6f 72 0d 0a 20 20 20 20 20 ing error..
15eb0 20 20 20 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 ).. {..
15ec0 20 20 20 20 20 69 66 20 28 5f 73 71 6c 20 3d 3d if (_sql ==
15ed0 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 null)..
15ee0 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 {.. e
15ef0 72 72 6f 72 20 3d 20 22 63 6f 6e 6e 65 63 74 69 rror = "connecti
15f00 6f 6e 20 68 61 73 20 61 6e 20 69 6e 76 61 6c 69 on has an invali
15f10 64 20 68 61 6e 64 6c 65 22 3b 0d 0a 20 20 20 20 d handle";..
15f20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 53 return S
15f30 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 45 QLiteErrorCode.E
15f40 72 72 6f 72 3b 0d 0a 20 20 20 20 20 20 20 20 7d rror;.. }
15f50 0d 0a 0d 0a 20 20 20 20 20 20 20 20 49 6e 74 50 .... IntP
15f60 74 72 20 70 53 71 6c 20 3d 20 49 6e 74 50 74 72 tr pSql = IntPtr
15f70 2e 5a 65 72 6f 3b 0d 0a 0d 0a 20 20 20 20 20 20 .Zero;....
15f80 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 7b try.. {
15f90 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 53 .. pS
15fa0 71 6c 20 3d 20 53 51 4c 69 74 65 53 74 72 69 6e ql = SQLiteStrin
15fb0 67 2e 55 74 66 38 49 6e 74 50 74 72 46 72 6f 6d g.Utf8IntPtrFrom
15fc0 53 74 72 69 6e 67 28 73 74 72 53 71 6c 29 3b 0d String(strSql);.
15fd0 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 53 ... S
15fe0 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 6e QLiteErrorCode n
15ff0 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d = UnsafeNativeM
16000 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 64 ethods.sqlite3_d
16010 65 63 6c 61 72 65 5f 76 74 61 62 28 0d 0a 20 20 eclare_vtab(..
16020 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5f 73 _s
16030 71 6c 2c 20 70 53 71 6c 29 3b 0d 0a 0d 0a 20 20 ql, pSql);....
16040 20 20 20 20 20 20 20 20 20 20 69 66 20 28 28 6e if ((n
16050 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 == SQLiteErrorC
16060 6f 64 65 2e 4f 6b 29 20 26 26 20 28 6d 6f 64 75 ode.Ok) && (modu
16070 6c 65 20 21 3d 20 6e 75 6c 6c 29 29 0d 0a 20 20 le != null))..
16080 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 6f mo
16090 64 75 6c 65 2e 44 65 63 6c 61 72 65 64 20 3d 20 dule.Declared =
160a0 74 72 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 true;....
160b0 20 20 20 20 20 69 66 20 28 6e 20 21 3d 20 53 51 if (n != SQ
160c0 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b LiteErrorCode.Ok
160d0 29 20 65 72 72 6f 72 20 3d 20 47 65 74 4c 61 73 ) error = GetLas
160e0 74 45 72 72 6f 72 28 29 3b 0d 0a 0d 0a 20 20 20 tError();....
160f0 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 return
16100 6e 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 n;.. }..
16110 20 20 20 20 20 20 20 66 69 6e 61 6c 6c 79 0d 0a finally..
16120 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
16130 20 20 20 20 20 20 20 69 66 20 28 70 53 71 6c 20 if (pSql
16140 21 3d 20 49 6e 74 50 74 72 2e 5a 65 72 6f 29 0d != IntPtr.Zero).
16150 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a . {..
16160 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
16170 53 51 4c 69 74 65 4d 65 6d 6f 72 79 2e 46 72 65 SQLiteMemory.Fre
16180 65 28 70 53 71 6c 29 3b 0d 0a 20 20 20 20 20 20 e(pSql);..
16190 20 20 20 20 20 20 20 20 20 20 70 53 71 6c 20 3d pSql =
161a0 20 49 6e 74 50 74 72 2e 5a 65 72 6f 3b 0d 0a 20 IntPtr.Zero;..
161b0 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 }..
161c0 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a }.. }..
161d0 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 .. /// <summa
161e0 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 43 61 6c ry>.. /// Cal
161f0 6c 73 20 74 68 65 20 6e 61 74 69 76 65 20 53 51 ls the native SQ
16200 4c 69 74 65 20 63 6f 72 65 20 6c 69 62 72 61 72 Lite core librar
16210 79 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 64 65 y in order to de
16220 63 6c 61 72 65 20 61 20 76 69 72 74 75 61 6c 20 clare a virtual
16230 74 61 62 6c 65 0d 0a 20 20 20 20 2f 2f 2f 20 66 table.. /// f
16240 75 6e 63 74 69 6f 6e 20 69 6e 20 72 65 73 70 6f unction in respo
16250 6e 73 65 20 74 6f 20 61 20 63 61 6c 6c 20 69 6e nse to a call in
16260 74 6f 20 74 68 65 20 3c 73 65 65 20 63 72 65 66 to the <see cref
16270 3d 22 49 53 51 4c 69 74 65 4e 61 74 69 76 65 4d ="ISQLiteNativeM
16280 6f 64 75 6c 65 2e 78 43 72 65 61 74 65 22 20 2f odule.xCreate" /
16290 3e 0d 0a 20 20 20 20 2f 2f 2f 20 6f 72 20 3c 73 >.. /// or <s
162a0 65 65 20 63 72 65 66 3d 22 49 53 51 4c 69 74 65 ee cref="ISQLite
162b0 4e 61 74 69 76 65 4d 6f 64 75 6c 65 2e 78 43 6f NativeModule.xCo
162c0 6e 6e 65 63 74 22 20 2f 3e 20 76 69 72 74 75 61 nnect" /> virtua
162d0 6c 20 74 61 62 6c 65 20 6d 65 74 68 6f 64 73 2e l table methods.
162e0 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d .. /// </summ
162f0 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 ary>.. /// <p
16300 61 72 61 6d 20 6e 61 6d 65 3d 22 6d 6f 64 75 6c aram name="modul
16310 65 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 e">.. /// The
16320 20 76 69 72 74 75 61 6c 20 74 61 62 6c 65 20 6d virtual table m
16330 6f 64 75 6c 65 20 74 68 61 74 20 69 73 20 74 6f odule that is to
16340 20 62 65 20 72 65 73 70 6f 6e 73 69 62 6c 65 20 be responsible
16350 66 6f 72 20 74 68 65 20 76 69 72 74 75 61 6c 20 for the virtual
16360 74 61 62 6c 65 0d 0a 20 20 20 20 2f 2f 2f 20 66 table.. /// f
16370 75 6e 63 74 69 6f 6e 20 62 65 69 6e 67 20 64 65 unction being de
16380 63 6c 61 72 65 64 2e 0d 0a 20 20 20 20 2f 2f 2f clared... ///
16390 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f </param>.. /
163a0 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 // <param name="
163b0 61 72 67 75 6d 65 6e 74 43 6f 75 6e 74 22 3e 0d argumentCount">.
163c0 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 6e 75 6d . /// The num
163d0 62 65 72 20 6f 66 20 61 72 67 75 6d 65 6e 74 73 ber of arguments
163e0 20 74 6f 20 74 68 65 20 66 75 6e 63 74 69 6f 6e to the function
163f0 20 62 65 69 6e 67 20 64 65 63 6c 61 72 65 64 2e being declared.
16400 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 .. /// </para
16410 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 m>.. /// <par
16420 61 6d 20 6e 61 6d 65 3d 22 6e 61 6d 65 22 3e 0d am name="name">.
16430 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 6e 61 6d . /// The nam
16440 65 20 6f 66 20 74 68 65 20 66 75 6e 63 74 69 6f e of the functio
16450 6e 20 62 65 69 6e 67 20 64 65 63 6c 61 72 65 64 n being declared
16460 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 ... /// </par
16470 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 am>.. /// <pa
16480 72 61 6d 20 6e 61 6d 65 3d 22 65 72 72 6f 72 22 ram name="error"
16490 3e 0d 0a 20 20 20 20 2f 2f 2f 20 55 70 6f 6e 20 >.. /// Upon
164a0 73 75 63 63 65 73 73 2c 20 74 68 65 20 63 6f 6e success, the con
164b0 74 65 6e 74 73 20 6f 66 20 74 68 69 73 20 70 61 tents of this pa
164c0 72 61 6d 65 74 65 72 20 61 72 65 20 75 6e 64 65 rameter are unde
164d0 66 69 6e 65 64 2e 20 20 55 70 6f 6e 20 66 61 69 fined. Upon fai
164e0 6c 75 72 65 2c 0d 0a 20 20 20 20 2f 2f 2f 20 69 lure,.. /// i
164f0 74 20 73 68 6f 75 6c 64 20 63 6f 6e 74 61 69 6e t should contain
16500 20 61 6e 20 61 70 70 72 6f 70 72 69 61 74 65 20 an appropriate
16510 65 72 72 6f 72 20 6d 65 73 73 61 67 65 2e 0d 0a error message...
16520 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e /// </param>
16530 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 .. /// <retur
16540 6e 73 3e 0d 0a 20 20 20 20 2f 2f 2f 20 41 20 73 ns>.. /// A s
16550 74 61 6e 64 61 72 64 20 53 51 4c 69 74 65 20 72 tandard SQLite r
16560 65 74 75 72 6e 20 63 6f 64 65 2e 0d 0a 20 20 20 eturn code...
16570 20 2f 2f 2f 20 3c 2f 72 65 74 75 72 6e 73 3e 0d /// </returns>.
16580 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 . internal ov
16590 65 72 72 69 64 65 20 53 51 4c 69 74 65 45 72 72 erride SQLiteErr
165a0 6f 72 43 6f 64 65 20 44 65 63 6c 61 72 65 56 69 orCode DeclareVi
165b0 72 74 75 61 6c 46 75 6e 63 74 69 6f 6e 28 0d 0a rtualFunction(..
165c0 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 4d 6f SQLiteMo
165d0 64 75 6c 65 20 6d 6f 64 75 6c 65 2c 0d 0a 20 20 dule module,..
165e0 20 20 20 20 20 20 69 6e 74 20 61 72 67 75 6d 65 int argume
165f0 6e 74 43 6f 75 6e 74 2c 0d 0a 20 20 20 20 20 20 ntCount,..
16600 20 20 73 74 72 69 6e 67 20 6e 61 6d 65 2c 0d 0a string name,..
16610 20 20 20 20 20 20 20 20 72 65 66 20 73 74 72 69 ref stri
16620 6e 67 20 65 72 72 6f 72 0d 0a 20 20 20 20 20 20 ng error..
16630 20 20 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 ).. {..
16640 20 20 20 20 69 66 20 28 5f 73 71 6c 20 3d 3d 20 if (_sql ==
16650 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 7b null).. {
16660 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 72 .. er
16670 72 6f 72 20 3d 20 22 63 6f 6e 6e 65 63 74 69 6f ror = "connectio
16680 6e 20 68 61 73 20 61 6e 20 69 6e 76 61 6c 69 64 n has an invalid
16690 20 68 61 6e 64 6c 65 22 3b 0d 0a 20 20 20 20 20 handle";..
166a0 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 53 51 return SQ
166b0 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 45 72 LiteErrorCode.Er
166c0 72 6f 72 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d ror;.. }.
166d0 0a 0d 0a 20 20 20 20 20 20 20 20 49 6e 74 50 74 ... IntPt
166e0 72 20 70 4e 61 6d 65 20 3d 20 49 6e 74 50 74 72 r pName = IntPtr
166f0 2e 5a 65 72 6f 3b 0d 0a 0d 0a 20 20 20 20 20 20 .Zero;....
16700 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 7b try.. {
16710 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 4e .. pN
16720 61 6d 65 20 3d 20 53 51 4c 69 74 65 53 74 72 69 ame = SQLiteStri
16730 6e 67 2e 55 74 66 38 49 6e 74 50 74 72 46 72 6f ng.Utf8IntPtrFro
16740 6d 53 74 72 69 6e 67 28 6e 61 6d 65 29 3b 0d 0a mString(name);..
16750 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 53 51 .. SQ
16760 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 6e 20 LiteErrorCode n
16770 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 = UnsafeNativeMe
16780 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 6f 76 thods.sqlite3_ov
16790 65 72 6c 6f 61 64 5f 66 75 6e 63 74 69 6f 6e 28 erload_function(
167a0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
167b0 20 20 5f 73 71 6c 2c 20 70 4e 61 6d 65 2c 20 61 _sql, pName, a
167c0 72 67 75 6d 65 6e 74 43 6f 75 6e 74 29 3b 0d 0a rgumentCount);..
167d0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 .. if
167e0 20 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 72 (n != SQLiteErr
167f0 6f 72 43 6f 64 65 2e 4f 6b 29 20 65 72 72 6f 72 orCode.Ok) error
16800 20 3d 20 47 65 74 4c 61 73 74 45 72 72 6f 72 28 = GetLastError(
16810 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 );....
16820 20 20 72 65 74 75 72 6e 20 6e 3b 0d 0a 20 20 20 return n;..
16830 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
16840 66 69 6e 61 6c 6c 79 0d 0a 20 20 20 20 20 20 20 finally..
16850 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
16860 69 66 20 28 70 4e 61 6d 65 20 21 3d 20 49 6e 74 if (pName != Int
16870 50 74 72 2e 5a 65 72 6f 29 0d 0a 20 20 20 20 20 Ptr.Zero)..
16880 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
16890 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 SQLite
168a0 4d 65 6d 6f 72 79 2e 46 72 65 65 28 70 4e 61 6d Memory.Free(pNam
168b0 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 e);..
168c0 20 20 20 20 20 70 4e 61 6d 65 20 3d 20 49 6e 74 pName = Int
168d0 50 74 72 2e 5a 65 72 6f 3b 0d 0a 20 20 20 20 20 Ptr.Zero;..
168e0 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 }..
168f0 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 23 65 6e 64 }.. }..#end
16900 69 66 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 if.... /// <s
16910 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
16920 20 42 75 69 6c 64 73 20 61 6e 20 65 72 72 6f 72 Builds an error
16930 20 6d 65 73 73 61 67 65 20 73 74 72 69 6e 67 20 message string
16940 66 72 61 67 6d 65 6e 74 20 63 6f 6e 74 61 69 6e fragment contain
16950 69 6e 67 20 74 68 65 0d 0a 20 20 20 20 2f 2f 2f ing the.. ///
16960 20 64 65 66 69 6e 65 64 20 76 61 6c 75 65 73 20 defined values
16970 6f 66 20 74 68 65 20 3c 73 65 65 20 63 72 65 66 of the <see cref
16980 3d 22 53 51 4c 69 74 65 43 6f 6e 66 69 67 44 62 ="SQLiteConfigDb
16990 4f 70 73 45 6e 75 6d 22 20 2f 3e 0d 0a 20 20 20 OpsEnum" />..
169a0 20 2f 2f 2f 20 65 6e 75 6d 65 72 61 74 69 6f 6e /// enumeration
169b0 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d ... /// </sum
169c0 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c mary>.. /// <
169d0 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 2f 2f returns>.. //
169e0 2f 20 54 68 65 20 62 75 69 6c 74 20 73 74 72 69 / The built stri
169f0 6e 67 20 66 72 61 67 6d 65 6e 74 2e 0d 0a 20 20 ng fragment...
16a00 20 20 2f 2f 2f 20 3c 2f 72 65 74 75 72 6e 73 3e /// </returns>
16a10 0d 0a 20 20 20 20 70 72 69 76 61 74 65 20 73 74 .. private st
16a20 61 74 69 63 20 73 74 72 69 6e 67 20 47 65 74 43 atic string GetC
16a30 6f 6e 66 69 67 44 62 4f 70 73 4e 61 6d 65 73 28 onfigDbOpsNames(
16a40 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
16a50 20 20 53 74 72 69 6e 67 42 75 69 6c 64 65 72 20 StringBuilder
16a60 62 75 69 6c 64 65 72 20 3d 20 6e 65 77 20 53 74 builder = new St
16a70 72 69 6e 67 42 75 69 6c 64 65 72 28 29 3b 0d 0a ringBuilder();..
16a80 0d 0a 23 69 66 20 21 50 4c 41 54 46 4f 52 4d 5f ..#if !PLATFORM_
16a90 43 4f 4d 50 41 43 54 46 52 41 4d 45 57 4f 52 4b COMPACTFRAMEWORK
16aa0 0d 0a 20 20 20 20 20 20 20 20 66 6f 72 65 61 63 .. foreac
16ab0 68 20 28 73 74 72 69 6e 67 20 6e 61 6d 65 20 69 h (string name i
16ac0 6e 20 45 6e 75 6d 2e 47 65 74 4e 61 6d 65 73 28 n Enum.GetNames(
16ad0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
16ae0 20 20 74 79 70 65 6f 66 28 53 51 4c 69 74 65 43 typeof(SQLiteC
16af0 6f 6e 66 69 67 44 62 4f 70 73 45 6e 75 6d 29 29 onfigDbOpsEnum))
16b00 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 ).. {..
16b10 20 20 20 20 20 20 20 20 20 20 69 66 20 28 53 74 if (St
16b20 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 ring.IsNullOrEmp
16b30 74 79 28 6e 61 6d 65 29 29 0d 0a 20 20 20 20 20 ty(name))..
16b40 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 conti
16b50 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 nue;....
16b60 20 20 20 20 69 66 20 28 62 75 69 6c 64 65 72 2e if (builder.
16b70 4c 65 6e 67 74 68 20 3e 20 30 29 0d 0a 20 20 20 Length > 0)..
16b80 20 20 20 20 20 20 20 20 20 20 20 20 20 62 75 69 bui
16b90 6c 64 65 72 2e 41 70 70 65 6e 64 28 22 2c 20 22 lder.Append(", "
16ba0 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 );....
16bb0 20 20 62 75 69 6c 64 65 72 2e 41 70 70 65 6e 64 builder.Append
16bc0 28 6e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 20 (name);..
16bd0 20 7d 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 }..#else..
16be0 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 2f //.. /
16bf0 2f 20 54 4f 44 4f 3a 20 55 70 64 61 74 65 20 74 / TODO: Update t
16c00 68 69 73 20 6c 69 73 74 20 69 66 20 74 68 65 20 his list if the
16c10 61 76 61 69 6c 61 62 6c 65 20 76 61 6c 75 65 73 available values
16c20 20 69 6e 20 74 68 65 0d 0a 20 20 20 20 20 20 20 in the..
16c30 20 2f 2f 20 20 20 20 20 20 20 22 53 51 4c 69 74 // "SQLit
16c40 65 43 6f 6e 66 69 67 44 62 4f 70 73 45 6e 75 6d eConfigDbOpsEnum
16c50 22 20 65 6e 75 6d 65 72 61 74 69 6f 6e 20 63 68 " enumeration ch
16c60 61 6e 67 65 2e 0d 0a 20 20 20 20 20 20 20 20 2f ange... /
16c70 2f 0d 0a 20 20 20 20 20 20 20 20 62 75 69 6c 64 /.. build
16c80 65 72 2e 41 70 70 65 6e 64 46 6f 72 6d 61 74 28 er.AppendFormat(
16c90 43 75 6c 74 75 72 65 49 6e 66 6f 2e 49 6e 76 61 CultureInfo.Inva
16ca0 72 69 61 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 riantCulture,..
16cb0 20 20 20 20 20 20 20 20 20 20 20 22 7b 30 7d 2c "{0},
16cc0 20 7b 31 7d 2c 20 7b 32 7d 2c 20 7b 33 7d 2c 20 {1}, {2}, {3},
16cd0 7b 34 7d 2c 20 7b 35 7d 2c 20 7b 36 7d 2c 20 7b {4}, {5}, {6}, {
16ce0 37 7d 2c 20 7b 38 7d 2c 20 7b 39 7d 22 2c 0d 0a 7}, {8}, {9}",..
16cf0 20 20 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 SQLi
16d00 74 65 43 6f 6e 66 69 67 44 62 4f 70 73 45 6e 75 teConfigDbOpsEnu
16d10 6d 2e 53 51 4c 49 54 45 5f 44 42 43 4f 4e 46 49 m.SQLITE_DBCONFI
16d20 47 5f 4e 4f 4e 45 2c 0d 0a 20 20 20 20 20 20 20 G_NONE,..
16d30 20 20 20 20 20 53 51 4c 69 74 65 43 6f 6e 66 69 SQLiteConfi
16d40 67 44 62 4f 70 73 45 6e 75 6d 2e 53 51 4c 49 54 gDbOpsEnum.SQLIT
16d50 45 5f 44 42 43 4f 4e 46 49 47 5f 4d 41 49 4e 44 E_DBCONFIG_MAIND
16d60 42 4e 41 4d 45 2c 0d 0a 20 20 20 20 20 20 20 20 BNAME,..
16d70 20 20 20 20 53 51 4c 69 74 65 43 6f 6e 66 69 67 SQLiteConfig
16d80 44 62 4f 70 73 45 6e 75 6d 2e 53 51 4c 49 54 45 DbOpsEnum.SQLITE
16d90 5f 44 42 43 4f 4e 46 49 47 5f 4c 4f 4f 4b 41 53 _DBCONFIG_LOOKAS
16da0 49 44 45 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 IDE,..
16db0 20 20 53 51 4c 69 74 65 43 6f 6e 66 69 67 44 62 SQLiteConfigDb
16dc0 4f 70 73 45 6e 75 6d 2e 53 51 4c 49 54 45 5f 44 OpsEnum.SQLITE_D
16dd0 42 43 4f 4e 46 49 47 5f 45 4e 41 42 4c 45 5f 46 BCONFIG_ENABLE_F
16de0 4b 45 59 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 KEY,..
16df0 20 20 53 51 4c 69 74 65 43 6f 6e 66 69 67 44 62 SQLiteConfigDb
16e00 4f 70 73 45 6e 75 6d 2e 53 51 4c 49 54 45 5f 44 OpsEnum.SQLITE_D
16e10 42 43 4f 4e 46 49 47 5f 45 4e 41 42 4c 45 5f 54 BCONFIG_ENABLE_T
16e20 52 49 47 47 45 52 2c 0d 0a 20 20 20 20 20 20 20 RIGGER,..
16e30 20 20 20 20 20 53 51 4c 69 74 65 43 6f 6e 66 69 SQLiteConfi
16e40 67 44 62 4f 70 73 45 6e 75 6d 2e 53 51 4c 49 54 gDbOpsEnum.SQLIT
16e50 45 5f 44 42 43 4f 4e 46 49 47 5f 45 4e 41 42 4c E_DBCONFIG_ENABL
16e60 45 5f 46 54 53 33 5f 54 4f 4b 45 4e 49 5a 45 52 E_FTS3_TOKENIZER
16e70 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 53 ,.. S
16e80 51 4c 69 74 65 43 6f 6e 66 69 67 44 62 4f 70 73 QLiteConfigDbOps
16e90 45 6e 75 6d 2e 53 51 4c 49 54 45 5f 44 42 43 4f Enum.SQLITE_DBCO
16ea0 4e 46 49 47 5f 45 4e 41 42 4c 45 5f 4c 4f 41 44 NFIG_ENABLE_LOAD
16eb0 5f 45 58 54 45 4e 53 49 4f 4e 2c 0d 0a 20 20 20 _EXTENSION,..
16ec0 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 43 SQLiteC
16ed0 6f 6e 66 69 67 44 62 4f 70 73 45 6e 75 6d 2e 53 onfigDbOpsEnum.S
16ee0 51 4c 49 54 45 5f 44 42 43 4f 4e 46 49 47 5f 4e QLITE_DBCONFIG_N
16ef0 4f 5f 43 4b 50 54 5f 4f 4e 5f 43 4c 4f 53 45 2c O_CKPT_ON_CLOSE,
16f00 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 53 51 .. SQ
16f10 4c 69 74 65 43 6f 6e 66 69 67 44 62 4f 70 73 45 LiteConfigDbOpsE
16f20 6e 75 6d 2e 53 51 4c 49 54 45 5f 44 42 43 4f 4e num.SQLITE_DBCON
16f30 46 49 47 5f 45 4e 41 42 4c 45 5f 51 50 53 47 2c FIG_ENABLE_QPSG,
16f40 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 53 51 .. SQ
16f50 4c 69 74 65 43 6f 6e 66 69 67 44 62 4f 70 73 45 LiteConfigDbOpsE
16f60 6e 75 6d 2e 53 51 4c 49 54 45 5f 44 42 43 4f 4e num.SQLITE_DBCON
16f70 46 49 47 5f 54 52 49 47 47 45 52 5f 45 51 50 29 FIG_TRIGGER_EQP)
16f80 3b 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 ;..#endif....
16f90 20 20 20 20 20 72 65 74 75 72 6e 20 62 75 69 6c return buil
16fa0 64 65 72 2e 54 6f 53 74 72 69 6e 67 28 29 3b 0d der.ToString();.
16fb0 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f . }.... //
16fc0 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 / <summary>..
16fd0 20 2f 2f 2f 20 43 68 61 6e 67 65 20 61 20 63 6f /// Change a co
16fe0 6e 66 69 67 75 72 61 74 69 6f 6e 20 6f 70 74 69 nfiguration opti
16ff0 6f 6e 20 76 61 6c 75 65 20 66 6f 72 20 74 68 65 on value for the
17000 20 64 61 74 61 62 61 73 65 2e 0d 0a 20 20 20 20 database...
17010 2f 2f 2f 20 63 6f 6e 6e 65 63 74 69 6f 6e 2e 0d /// connection..
17020 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 . /// </summa
17030 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 ry>.. /// <pa
17040 72 61 6d 20 6e 61 6d 65 3d 22 6f 70 74 69 6f 6e ram name="option
17050 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 ">.. /// The
17060 64 61 74 61 62 61 73 65 20 63 6f 6e 66 69 67 75 database configu
17070 72 61 74 69 6f 6e 20 6f 70 74 69 6f 6e 20 74 6f ration option to
17080 20 63 68 61 6e 67 65 2e 0d 0a 20 20 20 20 2f 2f change... //
17090 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 / </param>..
170a0 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d /// <param name=
170b0 22 76 61 6c 75 65 22 3e 0d 0a 20 20 20 20 2f 2f "value">.. //
170c0 2f 20 54 68 65 20 6e 65 77 20 76 61 6c 75 65 20 / The new value
170d0 66 6f 72 20 74 68 65 20 73 70 65 63 69 66 69 65 for the specifie
170e0 64 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 d configuration
170f0 6f 70 74 69 6f 6e 2e 0d 0a 20 20 20 20 2f 2f 2f option... ///
17100 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f </param>.. /
17110 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 0d 0a 20 20 // <returns>..
17120 20 20 2f 2f 2f 20 41 20 73 74 61 6e 64 61 72 64 /// A standard
17130 20 53 51 4c 69 74 65 20 72 65 74 75 72 6e 20 63 SQLite return c
17140 6f 64 65 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ode... /// </
17150 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 69 6e returns>.. in
17160 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
17170 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 SQLiteErrorCode
17180 53 65 74 43 6f 6e 66 69 67 75 72 61 74 69 6f 6e SetConfiguration
17190 4f 70 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 Option(..
171a0 20 53 51 4c 69 74 65 43 6f 6e 66 69 67 44 62 4f SQLiteConfigDbO
171b0 70 73 45 6e 75 6d 20 6f 70 74 69 6f 6e 2c 0d 0a psEnum option,..
171c0 20 20 20 20 20 20 20 20 6f 62 6a 65 63 74 20 76 object v
171d0 61 6c 75 65 0d 0a 20 20 20 20 20 20 20 20 29 0d alue.. ).
171e0 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 . {..
171f0 69 66 20 28 21 45 6e 75 6d 2e 49 73 44 65 66 69 if (!Enum.IsDefi
17200 6e 65 64 28 74 79 70 65 6f 66 28 53 51 4c 69 74 ned(typeof(SQLit
17210 65 43 6f 6e 66 69 67 44 62 4f 70 73 45 6e 75 6d eConfigDbOpsEnum
17220 29 2c 20 6f 70 74 69 6f 6e 29 29 0d 0a 20 20 20 ), option))..
17230 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
17240 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 51 throw new SQ
17250 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 48 65 LiteException(He
17260 6c 70 65 72 4d 65 74 68 6f 64 73 2e 53 74 72 69 lperMethods.Stri
17270 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 ngFormat(..
17280 20 20 20 20 20 20 20 20 20 20 20 43 75 6c 74 75 Cultu
17290 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 reInfo.CurrentCu
172a0 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 lture,..
172b0 20 20 20 20 20 20 20 20 22 75 6e 72 65 63 6f 67 "unrecog
172c0 6e 69 7a 65 64 20 63 6f 6e 66 69 67 75 72 61 74 nized configurat
172d0 69 6f 6e 20 6f 70 74 69 6f 6e 2c 20 6d 75 73 74 ion option, must
172e0 20 62 65 3a 20 7b 30 7d 22 2c 0d 0a 20 20 20 20 be: {0}",..
172f0 20 20 20 20 20 20 20 20 20 20 20 20 47 65 74 43 GetC
17300 6f 6e 66 69 67 44 62 4f 70 73 4e 61 6d 65 73 28 onfigDbOpsNames(
17310 29 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d )));.. }.
17320 0a 0d 0a 20 20 20 20 20 20 20 20 73 77 69 74 63 ... switc
17330 68 20 28 6f 70 74 69 6f 6e 29 0d 0a 20 20 20 20 h (option)..
17340 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
17350 20 20 20 63 61 73 65 20 53 51 4c 69 74 65 43 6f case SQLiteCo
17360 6e 66 69 67 44 62 4f 70 73 45 6e 75 6d 2e 53 51 nfigDbOpsEnum.SQ
17370 4c 49 54 45 5f 44 42 43 4f 4e 46 49 47 5f 4e 4f LITE_DBCONFIG_NO
17380 4e 45 3a 20 2f 2f 20 6e 69 6c 0d 0a 20 20 20 20 NE: // nil..
17390 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 {..
173a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
173b0 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 20 //..
173c0 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f // NO
173d0 54 45 3a 20 44 6f 20 6e 6f 74 68 69 6e 67 2c 20 TE: Do nothing,
173e0 72 65 74 75 72 6e 20 73 75 63 63 65 73 73 2e 0d return success..
173f0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
17400 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 //..
17410 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 ret
17420 75 72 6e 20 53 51 4c 69 74 65 45 72 72 6f 72 43 urn SQLiteErrorC
17430 6f 64 65 2e 4f 6b 3b 0d 0a 20 20 20 20 20 20 20 ode.Ok;..
17440 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 }..
17450 20 20 20 20 20 20 20 20 63 61 73 65 20 53 51 4c case SQL
17460 69 74 65 43 6f 6e 66 69 67 44 62 4f 70 73 45 6e iteConfigDbOpsEn
17470 75 6d 2e 53 51 4c 49 54 45 5f 44 42 43 4f 4e 46 um.SQLITE_DBCONF
17480 49 47 5f 4d 41 49 4e 44 42 4e 41 4d 45 3a 20 2f IG_MAINDBNAME: /
17490 2f 20 63 68 61 72 2a 0d 0a 20 20 20 20 20 20 20 / char*..
174a0 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 {..
174b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
174c0 69 66 20 28 76 61 6c 75 65 20 3d 3d 20 6e 75 6c if (value == nul
174d0 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 l)..
174e0 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f thro
174f0 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 w new ArgumentNu
17500 6c 6c 45 78 63 65 70 74 69 6f 6e 28 22 76 61 6c llException("val
17510 75 65 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 ue");....
17520 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 if
17530 28 21 28 76 61 6c 75 65 20 69 73 20 73 74 72 69 (!(value is stri
17540 6e 67 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 ng))..
17550 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
17560 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17570 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 throw new S
17580 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 48 QLiteException(H
17590 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e 53 74 72 elperMethods.Str
175a0 69 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 ingFormat(..
175b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
175c0 20 20 20 20 20 20 20 20 43 75 6c 74 75 72 65 49 CultureI
175d0 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c 74 75 nfo.CurrentCultu
175e0 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 re,..
175f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17600 20 22 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 "configuration
17610 76 61 6c 75 65 20 74 79 70 65 20 6d 69 73 6d 61 value type misma
17620 74 63 68 2c 20 6d 75 73 74 20 62 65 20 6f 66 20 tch, must be of
17630 74 79 70 65 20 7b 30 7d 22 2c 0d 0a 20 20 20 20 type {0}",..
17640 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17650 20 20 20 20 20 20 20 20 74 79 70 65 6f 66 28 73 typeof(s
17660 74 72 69 6e 67 29 29 29 3b 0d 0a 20 20 20 20 20 tring)));..
17670 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d }
17680 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ....
17690 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 SQLiteEr
176a0 72 6f 72 43 6f 64 65 20 72 63 20 3d 20 53 51 4c rorCode rc = SQL
176b0 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 45 72 72 iteErrorCode.Err
176c0 6f 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 or;..
176d0 20 20 20 20 20 20 20 20 20 49 6e 74 50 74 72 20 IntPtr
176e0 70 44 62 4e 61 6d 65 20 3d 20 49 6e 74 50 74 72 pDbName = IntPtr
176f0 2e 5a 65 72 6f 3b 0d 0a 0d 0a 20 20 20 20 20 20 .Zero;....
17700 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 72 tr
17710 79 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 y..
17720 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
17730 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17740 20 20 70 44 62 4e 61 6d 65 20 3d 20 53 51 4c 69 pDbName = SQLi
17750 74 65 53 74 72 69 6e 67 2e 55 74 66 38 49 6e 74 teString.Utf8Int
17760 50 74 72 46 72 6f 6d 53 74 72 69 6e 67 28 0d 0a PtrFromString(..
17770 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17780 20 20 20 20 20 20 20 20 20 20 20 20 28 73 74 72 (str
17790 69 6e 67 29 76 61 6c 75 65 29 3b 0d 0a 0d 0a 20 ing)value);....
177a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
177b0 20 20 20 20 20 20 20 69 66 20 28 70 44 62 4e 61 if (pDbNa
177c0 6d 65 20 3d 3d 20 49 6e 74 50 74 72 2e 5a 65 72 me == IntPtr.Zer
177d0 6f 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 o)..
177e0 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 {..
177f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17800 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 throw
17810 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 new SQLiteExcep
17820 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 20 20 tion(..
17830 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17840 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 SQLiteErr
17850 6f 72 43 6f 64 65 2e 4e 6f 4d 65 6d 2c 0d 0a 20 orCode.NoMem,..
17860 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17870 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 "
17880 63 61 6e 6e 6f 74 20 61 6c 6c 6f 63 61 74 65 20 cannot allocate
17890 64 61 74 61 62 61 73 65 20 6e 61 6d 65 22 29 3b database name");
178a0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
178b0 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 }....
178c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
178d0 20 20 20 20 20 20 20 72 63 20 3d 20 55 6e 73 61 rc = Unsa
178e0 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
178f0 73 71 6c 69 74 65 33 5f 64 62 5f 63 6f 6e 66 69 sqlite3_db_confi
17900 67 5f 63 68 61 72 70 74 72 28 0d 0a 20 20 20 20 g_charptr(..
17910 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17920 20 20 20 20 20 20 20 20 5f 73 71 6c 2c 20 6f 70 _sql, op
17930 74 69 6f 6e 2c 20 70 44 62 4e 61 6d 65 29 3b 0d tion, pDbName);.
17940 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ...
17950 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 72 if (r
17960 63 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 c == SQLiteError
17970 43 6f 64 65 2e 4f 6b 29 0d 0a 20 20 20 20 20 20 Code.Ok)..
17980 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17990 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
179a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
179b0 20 46 72 65 65 44 62 4e 61 6d 65 28 74 72 75 65 FreeDbName(true
179c0 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 );....
179d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
179e0 20 20 64 62 4e 61 6d 65 20 3d 20 70 44 62 4e 61 dbName = pDbNa
179f0 6d 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 me;..
17a00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17a10 20 70 44 62 4e 61 6d 65 20 3d 20 49 6e 74 50 74 pDbName = IntPt
17a20 72 2e 5a 65 72 6f 3b 0d 0a 20 20 20 20 20 20 20 r.Zero;..
17a30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17a40 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 }..
17a50 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
17a60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 f
17a70 69 6e 61 6c 6c 79 0d 0a 20 20 20 20 20 20 20 20 inally..
17a80 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 {..
17a90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17aa0 20 20 20 20 20 20 20 69 66 20 28 28 72 63 20 21 if ((rc !
17ab0 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 = SQLiteErrorCod
17ac0 65 2e 4f 6b 29 20 26 26 0d 0a 20 20 20 20 20 20 e.Ok) &&..
17ad0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17ae0 20 20 20 20 20 20 28 70 44 62 4e 61 6d 65 20 21 (pDbName !
17af0 3d 20 49 6e 74 50 74 72 2e 5a 65 72 6f 29 29 0d = IntPtr.Zero)).
17b00 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
17b10 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 {..
17b20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17b30 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 4d 65 SQLiteMe
17b40 6d 6f 72 79 2e 46 72 65 65 28 70 44 62 4e 61 6d mory.Free(pDbNam
17b50 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 e);..
17b60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17b70 20 70 44 62 4e 61 6d 65 20 3d 20 49 6e 74 50 74 pDbName = IntPt
17b80 72 2e 5a 65 72 6f 3b 0d 0a 20 20 20 20 20 20 20 r.Zero;..
17b90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17ba0 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 }..
17bb0 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 }....
17bc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17bd0 20 72 65 74 75 72 6e 20 72 63 3b 0d 0a 20 20 20 return rc;..
17be0 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a }..
17bf0 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 case
17c00 20 53 51 4c 69 74 65 43 6f 6e 66 69 67 44 62 4f SQLiteConfigDbO
17c10 70 73 45 6e 75 6d 2e 53 51 4c 49 54 45 5f 44 42 psEnum.SQLITE_DB
17c20 43 4f 4e 46 49 47 5f 4c 4f 4f 4b 41 53 49 44 45 CONFIG_LOOKASIDE
17c30 3a 20 2f 2f 20 76 6f 69 64 2a 20 69 6e 74 20 69 : // void* int i
17c40 6e 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 nt..
17c50 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
17c60 20 20 20 20 20 20 20 20 20 20 20 6f 62 6a 65 63 objec
17c70 74 5b 5d 20 61 72 72 61 79 20 3d 20 76 61 6c 75 t[] array = valu
17c80 65 20 61 73 20 6f 62 6a 65 63 74 5b 5d 3b 0d 0a e as object[];..
17c90 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
17ca0 20 20 20 20 20 20 69 66 20 28 61 72 72 61 79 20 if (array
17cb0 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 == null)..
17cc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d {.
17cd0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
17ce0 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e throw n
17cf0 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 ew SQLiteExcepti
17d00 6f 6e 28 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 on(HelperMethods
17d10 2e 53 74 72 69 6e 67 46 6f 72 6d 61 74 28 0d 0a .StringFormat(..
17d20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17d30 20 20 20 20 20 20 20 20 20 20 20 20 43 75 6c 74 Cult
17d40 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 ureInfo.CurrentC
17d50 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 ulture,..
17d60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17d70 20 20 20 20 20 22 63 6f 6e 66 69 67 75 72 61 74 "configurat
17d80 69 6f 6e 20 76 61 6c 75 65 20 74 79 70 65 20 6d ion value type m
17d90 69 73 6d 61 74 63 68 2c 20 6d 75 73 74 20 62 65 ismatch, must be
17da0 20 6f 66 20 74 79 70 65 20 7b 30 7d 22 2c 0d 0a of type {0}",..
17db0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17dc0 20 20 20 20 20 20 20 20 20 20 20 20 74 79 70 65 type
17dd0 6f 66 28 6f 62 6a 65 63 74 5b 5d 29 29 29 3b 0d of(object[])));.
17de0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
17df0 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 }....
17e00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 if
17e10 20 28 21 28 61 72 72 61 79 5b 30 5d 20 69 73 20 (!(array[0] is
17e20 49 6e 74 50 74 72 29 29 0d 0a 20 20 20 20 20 20 IntPtr))..
17e30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d {.
17e40 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
17e50 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e throw n
17e60 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 ew SQLiteExcepti
17e70 6f 6e 28 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 on(HelperMethods
17e80 2e 53 74 72 69 6e 67 46 6f 72 6d 61 74 28 0d 0a .StringFormat(..
17e90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17ea0 20 20 20 20 20 20 20 20 20 20 20 20 43 75 6c 74 Cult
17eb0 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 ureInfo.CurrentC
17ec0 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 ulture,..
17ed0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17ee0 20 20 20 20 20 22 63 6f 6e 66 69 67 75 72 61 74 "configurat
17ef0 69 6f 6e 20 65 6c 65 6d 65 6e 74 20 7a 65 72 6f ion element zero
17f00 20 28 30 29 20 74 79 70 65 20 6d 69 73 6d 61 74 (0) type mismat
17f10 63 68 2c 20 6d 75 73 74 20 62 65 20 6f 66 20 74 ch, must be of t
17f20 79 70 65 20 7b 30 7d 22 2c 0d 0a 20 20 20 20 20 ype {0}",..
17f30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17f40 20 20 20 20 20 20 20 74 79 70 65 6f 66 28 49 6e typeof(In
17f50 74 50 74 72 29 29 29 3b 0d 0a 20 20 20 20 20 20 tPtr)));..
17f60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d }.
17f70 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ...
17f80 20 20 20 20 20 20 20 69 66 20 28 21 28 61 72 72 if (!(arr
17f90 61 79 5b 31 5d 20 69 73 20 69 6e 74 29 29 0d 0a ay[1] is int))..
17fa0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
17fb0 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
17fc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 t
17fd0 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 hrow new SQLiteE
17fe0 78 63 65 70 74 69 6f 6e 28 48 65 6c 70 65 72 4d xception(HelperM
17ff0 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 ethods.StringFor
18000 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 mat(..
18010 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
18020 20 20 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 CultureInfo.Cu
18030 72 72 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 rrentCulture,..
18040 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
18050 20 20 20 20 20 20 20 20 20 20 20 22 63 6f 6e 66 "conf
18060 69 67 75 72 61 74 69 6f 6e 20 65 6c 65 6d 65 6e iguration elemen
18070 74 20 6f 6e 65 20 28 31 29 20 74 79 70 65 20 6d t one (1) type m
18080 69 73 6d 61 74 63 68 2c 20 6d 75 73 74 20 62 65 ismatch, must be
18090 20 6f 66 20 74 79 70 65 20 7b 30 7d 22 2c 0d 0a of type {0}",..
180a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
180b0 20 20 20 20 20 20 20 20 20 20 20 20 74 79 70 65 type
180c0 6f 66 28 69 6e 74 29 29 29 3b 0d 0a 20 20 20 20 of(int)));..
180d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
180e0 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 }....
180f0 20 20 20 20 20 20 20 20 20 69 66 20 28 21 28 61 if (!(a
18100 72 72 61 79 5b 32 5d 20 69 73 20 69 6e 74 29 29 rray[2] is int))
18110 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
18120 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
18130 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
18140 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 throw new SQLit
18150 65 45 78 63 65 70 74 69 6f 6e 28 48 65 6c 70 65 eException(Helpe
18160 72 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 rMethods.StringF
18170 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 ormat(..
18180 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
18190 20 20 20 20 43 75 6c 74 75 72 65 49 6e 66 6f 2e CultureInfo.
181a0 43 75 72 72 65 6e 74 43 75 6c 74 75 72 65 2c 0d CurrentCulture,.
181b0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
181c0 20 20 20 20 20 20 20 20 20 20 20 20 20 22 63 6f "co
181d0 6e 66 69 67 75 72 61 74 69 6f 6e 20 65 6c 65 6d nfiguration elem
181e0 65 6e 74 20 74 77 6f 20 28 32 29 20 74 79 70 65 ent two (2) type
181f0 20 6d 69 73 6d 61 74 63 68 2c 20 6d 75 73 74 20 mismatch, must
18200 62 65 20 6f 66 20 74 79 70 65 20 7b 30 7d 22 2c be of type {0}",
18210 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
18220 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 79 ty
18230 70 65 6f 66 28 69 6e 74 29 29 29 3b 0d 0a 20 20 peof(int)));..
18240 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
18250 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 }....
18260 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 retur
18270 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 n UnsafeNativeMe
18280 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 64 62 thods.sqlite3_db
18290 5f 63 6f 6e 66 69 67 5f 69 6e 74 70 74 72 5f 74 _config_intptr_t
182a0 77 6f 5f 69 6e 74 73 28 0d 0a 20 20 20 20 20 20 wo_ints(..
182b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
182c0 20 20 5f 73 71 6c 2c 20 6f 70 74 69 6f 6e 2c 20 _sql, option,
182d0 28 49 6e 74 50 74 72 29 61 72 72 61 79 5b 30 5d (IntPtr)array[0]
182e0 2c 20 28 69 6e 74 29 61 72 72 61 79 5b 31 5d 2c , (int)array[1],
182f0 20 28 69 6e 74 29 61 72 72 61 79 5b 32 5d 29 3b (int)array[2]);
18300 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
18310 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 }..
18320 20 63 61 73 65 20 53 51 4c 69 74 65 43 6f 6e 66 case SQLiteConf
18330 69 67 44 62 4f 70 73 45 6e 75 6d 2e 53 51 4c 49 igDbOpsEnum.SQLI
18340 54 45 5f 44 42 43 4f 4e 46 49 47 5f 45 4e 41 42 TE_DBCONFIG_ENAB
18350 4c 45 5f 46 4b 45 59 3a 20 2f 2f 20 69 6e 74 20 LE_FKEY: // int
18360 69 6e 74 2a 0d 0a 20 20 20 20 20 20 20 20 20 20 int*..
18370 20 20 63 61 73 65 20 53 51 4c 69 74 65 43 6f 6e case SQLiteCon
18380 66 69 67 44 62 4f 70 73 45 6e 75 6d 2e 53 51 4c figDbOpsEnum.SQL
18390 49 54 45 5f 44 42 43 4f 4e 46 49 47 5f 45 4e 41 ITE_DBCONFIG_ENA
183a0 42 4c 45 5f 54 52 49 47 47 45 52 3a 20 2f 2f 20 BLE_TRIGGER: //
183b0 69 6e 74 20 69 6e 74 2a 0d 0a 20 20 20 20 20 20 int int*..
183c0 20 20 20 20 20 20 63 61 73 65 20 53 51 4c 69 74 case SQLit
183d0 65 43 6f 6e 66 69 67 44 62 4f 70 73 45 6e 75 6d eConfigDbOpsEnum
183e0 2e 53 51 4c 49 54 45 5f 44 42 43 4f 4e 46 49 47 .SQLITE_DBCONFIG
183f0 5f 45 4e 41 42 4c 45 5f 46 54 53 33 5f 54 4f 4b _ENABLE_FTS3_TOK
18400 45 4e 49 5a 45 52 3a 20 2f 2f 20 69 6e 74 20 69 ENIZER: // int i
18410 6e 74 2a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 nt*..
18420 20 63 61 73 65 20 53 51 4c 69 74 65 43 6f 6e 66 case SQLiteConf
18430 69 67 44 62 4f 70 73 45 6e 75 6d 2e 53 51 4c 49 igDbOpsEnum.SQLI
18440 54 45 5f 44 42 43 4f 4e 46 49 47 5f 45 4e 41 42 TE_DBCONFIG_ENAB
18450 4c 45 5f 4c 4f 41 44 5f 45 58 54 45 4e 53 49 4f LE_LOAD_EXTENSIO
18460 4e 3a 20 2f 2f 20 69 6e 74 20 69 6e 74 2a 0d 0a N: // int int*..
18470 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 case
18480 20 53 51 4c 69 74 65 43 6f 6e 66 69 67 44 62 4f SQLiteConfigDbO
18490 70 73 45 6e 75 6d 2e 53 51 4c 49 54 45 5f 44 42 psEnum.SQLITE_DB
184a0 43 4f 4e 46 49 47 5f 4e 4f 5f 43 4b 50 54 5f 4f CONFIG_NO_CKPT_O
184b0 4e 5f 43 4c 4f 53 45 3a 20 2f 2f 20 69 6e 74 20 N_CLOSE: // int
184c0 69 6e 74 2a 0d 0a 20 20 20 20 20 20 20 20 20 20 int*..
184d0 20 20 63 61 73 65 20 53 51 4c 69 74 65 43 6f 6e case SQLiteCon
184e0 66 69 67 44 62 4f 70 73 45 6e 75 6d 2e 53 51 4c figDbOpsEnum.SQL
184f0 49 54 45 5f 44 42 43 4f 4e 46 49 47 5f 45 4e 41 ITE_DBCONFIG_ENA
18500 42 4c 45 5f 51 50 53 47 3a 20 2f 2f 20 69 6e 74 BLE_QPSG: // int
18510 20 69 6e 74 2a 0d 0a 20 20 20 20 20 20 20 20 20 int*..
18520 20 20 20 63 61 73 65 20 53 51 4c 69 74 65 43 6f case SQLiteCo
18530 6e 66 69 67 44 62 4f 70 73 45 6e 75 6d 2e 53 51 nfigDbOpsEnum.SQ
18540 4c 49 54 45 5f 44 42 43 4f 4e 46 49 47 5f 54 52 LITE_DBCONFIG_TR
18550 49 47 47 45 52 5f 45 51 50 3a 20 2f 2f 20 69 6e IGGER_EQP: // in
18560 74 20 69 6e 74 2a 0d 0a 20 20 20 20 20 20 20 20 t int*..
18570 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
18580 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 i
18590 66 20 28 21 28 76 61 6c 75 65 20 69 73 20 62 6f f (!(value is bo
185a0 6f 6c 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 ol))..
185b0 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
185c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
185d0 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 53 throw new S
185e0 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 48 QLiteException(H
185f0 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e 53 74 72 elperMethods.Str
18600 69 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 20 20 20 ingFormat(..
18610 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
18620 20 20 20 20 20 20 20 20 43 75 6c 74 75 72 65 49 CultureI
18630 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c 74 75 nfo.CurrentCultu
18640 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 re,..
18650 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
18660 20 22 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 "configuration
18670 76 61 6c 75 65 20 74 79 70 65 20 6d 69 73 6d 61 value type misma
18680 74 63 68 2c 20 6d 75 73 74 20 62 65 20 6f 66 20 tch, must be of
18690 74 79 70 65 20 7b 30 7d 22 2c 0d 0a 20 20 20 20 type {0}",..
186a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
186b0 20 20 20 20 20 20 20 20 74 79 70 65 6f 66 28 62 typeof(b
186c0 6f 6f 6c 29 29 29 3b 0d 0a 20 20 20 20 20 20 20 ool)));..
186d0 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a }..
186e0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
186f0 20 20 20 20 20 20 69 6e 74 20 72 65 73 75 6c 74 int result
18700 20 3d 20 30 3b 20 2f 2a 20 4e 4f 54 20 55 53 45 = 0; /* NOT USE
18710 44 20 2a 2f 0d 0a 0d 0a 20 20 20 20 20 20 20 20 D */....
18720 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 retu
18730 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d rn UnsafeNativeM
18740 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 64 ethods.sqlite3_d
18750 62 5f 63 6f 6e 66 69 67 5f 69 6e 74 5f 72 65 66 b_config_int_ref
18760 69 6e 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 int(..
18770 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5f 73 _s
18780 71 6c 2c 20 6f 70 74 69 6f 6e 2c 20 28 28 62 6f ql, option, ((bo
18790 6f 6c 29 76 61 6c 75 65 20 3f 20 31 20 3a 20 30 ol)value ? 1 : 0
187a0 29 2c 20 72 65 66 20 72 65 73 75 6c 74 29 3b 0d ), ref result);.
187b0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
187c0 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 }..
187d0 64 65 66 61 75 6c 74 3a 0d 0a 20 20 20 20 20 20 default:..
187e0 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
187f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
18800 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 throw new SQLit
18810 65 45 78 63 65 70 74 69 6f 6e 28 48 65 6c 70 65 eException(Helpe
18820 72 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 rMethods.StringF
18830 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 ormat(..
18840 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
18850 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 CultureInfo.Curr
18860 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 entCulture,..
18870 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
18880 20 20 20 20 20 22 75 6e 73 75 70 70 6f 72 74 65 "unsupporte
18890 64 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 d configuration
188a0 6f 70 74 69 6f 6e 20 7b 30 7d 22 2c 20 6f 70 74 option {0}", opt
188b0 69 6f 6e 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 ion));..
188c0 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
188d0 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 }.. }....
188e0 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
188f0 0d 0a 20 20 20 20 2f 2f 2f 20 45 6e 61 62 6c 65 .. /// Enable
18900 73 20 6f 72 20 64 69 73 61 62 6c 65 73 20 65 78 s or disables ex
18910 74 65 6e 73 69 6f 6e 20 6c 6f 61 64 69 6e 67 20 tension loading
18920 62 79 20 53 51 4c 69 74 65 2e 0d 0a 20 20 20 20 by SQLite...
18930 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a /// </summary>..
18940 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e /// <param n
18950 61 6d 65 3d 22 62 4f 6e 4f 66 66 22 3e 0d 0a 20 ame="bOnOff">..
18960 20 20 20 2f 2f 2f 20 54 72 75 65 20 74 6f 20 65 /// True to e
18970 6e 61 62 6c 65 20 6c 6f 61 64 69 6e 67 20 6f 66 nable loading of
18980 20 65 78 74 65 6e 73 69 6f 6e 73 2c 20 66 61 6c extensions, fal
18990 73 65 20 74 6f 20 64 69 73 61 62 6c 65 2e 0d 0a se to disable...
189a0 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e /// </param>
189b0 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
189c0 76 65 72 72 69 64 65 20 76 6f 69 64 20 53 65 74 verride void Set
189d0 4c 6f 61 64 45 78 74 65 6e 73 69 6f 6e 28 62 6f LoadExtension(bo
189e0 6f 6c 20 62 4f 6e 4f 66 66 29 0d 0a 20 20 20 20 ol bOnOff)..
189f0 7b 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 {.. SQLit
18a00 65 45 72 72 6f 72 43 6f 64 65 20 6e 3b 0d 0a 0d eErrorCode n;...
18a10 0a 20 20 20 20 20 20 20 20 69 66 20 28 53 51 4c . if (SQL
18a20 69 74 65 56 65 72 73 69 6f 6e 4e 75 6d 62 65 72 iteVersionNumber
18a30 20 3e 3d 20 33 30 31 33 30 30 30 29 0d 0a 20 20 >= 3013000)..
18a40 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
18a50 20 20 20 20 20 6e 20 3d 20 53 65 74 43 6f 6e 66 n = SetConf
18a60 69 67 75 72 61 74 69 6f 6e 4f 70 74 69 6f 6e 28 igurationOption(
18a70 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
18a80 20 20 53 51 4c 69 74 65 43 6f 6e 66 69 67 44 62 SQLiteConfigDb
18a90 4f 70 73 45 6e 75 6d 2e 53 51 4c 49 54 45 5f 44 OpsEnum.SQLITE_D
18aa0 42 43 4f 4e 46 49 47 5f 45 4e 41 42 4c 45 5f 4c BCONFIG_ENABLE_L
18ab0 4f 41 44 5f 45 58 54 45 4e 53 49 4f 4e 2c 0d 0a OAD_EXTENSION,..
18ac0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
18ad0 62 4f 6e 4f 66 66 29 3b 0d 0a 20 20 20 20 20 20 bOnOff);..
18ae0 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 65 6c 73 }.. els
18af0 65 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 e.. {..
18b00 20 20 20 20 20 20 20 20 20 20 6e 20 3d 20 55 6e n = Un
18b10 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
18b20 73 2e 73 71 6c 69 74 65 33 5f 65 6e 61 62 6c 65 s.sqlite3_enable
18b30 5f 6c 6f 61 64 5f 65 78 74 65 6e 73 69 6f 6e 28 _load_extension(
18b40 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
18b50 20 20 5f 73 71 6c 2c 20 28 62 4f 6e 4f 66 66 20 _sql, (bOnOff
18b60 3f 20 2d 31 20 3a 20 30 29 29 3b 0d 0a 20 20 20 ? -1 : 0));..
18b70 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 }....
18b80 20 20 69 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 if (n != SQLit
18b90 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 eErrorCode.Ok) t
18ba0 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 hrow new SQLiteE
18bb0 78 63 65 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c xception(n, GetL
18bc0 61 73 74 45 72 72 6f 72 28 29 29 3b 0d 0a 20 20 astError());..
18bd0 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c }.... /// <
18be0 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
18bf0 2f 20 4c 6f 61 64 73 20 61 20 53 51 4c 69 74 65 / Loads a SQLite
18c00 20 65 78 74 65 6e 73 69 6f 6e 20 6c 69 62 72 61 extension libra
18c10 72 79 20 66 72 6f 6d 20 74 68 65 20 6e 61 6d 65 ry from the name
18c20 64 20 66 69 6c 65 2e 0d 0a 20 20 20 20 2f 2f 2f d file... ///
18c30 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 </summary>..
18c40 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 /// <param name
18c50 3d 22 66 69 6c 65 4e 61 6d 65 22 3e 0d 0a 20 20 ="fileName">..
18c60 20 20 2f 2f 2f 20 54 68 65 20 6e 61 6d 65 20 6f /// The name o
18c70 66 20 74 68 65 20 64 79 6e 61 6d 69 63 20 6c 69 f the dynamic li
18c80 6e 6b 20 6c 69 62 72 61 72 79 20 66 69 6c 65 20 nk library file
18c90 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 20 65 containing the e
18ca0 78 74 65 6e 73 69 6f 6e 2e 0d 0a 20 20 20 20 2f xtension... /
18cb0 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 // </param>..
18cc0 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 /// <param name
18cd0 3d 22 70 72 6f 63 4e 61 6d 65 22 3e 0d 0a 20 20 ="procName">..
18ce0 20 20 2f 2f 2f 20 54 68 65 20 6e 61 6d 65 20 6f /// The name o
18cf0 66 20 74 68 65 20 65 78 70 6f 72 74 65 64 20 66 f the exported f
18d00 75 6e 63 74 69 6f 6e 20 75 73 65 64 20 74 6f 20 unction used to
18d10 69 6e 69 74 69 61 6c 69 7a 65 20 74 68 65 20 65 initialize the e
18d20 78 74 65 6e 73 69 6f 6e 2e 0d 0a 20 20 20 20 2f xtension... /
18d30 2f 2f 20 49 66 20 6e 75 6c 6c 2c 20 74 68 65 20 // If null, the
18d40 64 65 66 61 75 6c 74 20 22 73 71 6c 69 74 65 33 default "sqlite3
18d50 5f 65 78 74 65 6e 73 69 6f 6e 5f 69 6e 69 74 22 _extension_init"
18d60 20 77 69 6c 6c 20 62 65 20 75 73 65 64 2e 0d 0a will be used...
18d70 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e /// </param>
18d80 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
18d90 76 65 72 72 69 64 65 20 76 6f 69 64 20 4c 6f 61 verride void Loa
18da0 64 45 78 74 65 6e 73 69 6f 6e 28 73 74 72 69 6e dExtension(strin
18db0 67 20 66 69 6c 65 4e 61 6d 65 2c 20 73 74 72 69 g fileName, stri
18dc0 6e 67 20 70 72 6f 63 4e 61 6d 65 29 0d 0a 20 20 ng procName)..
18dd0 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 69 66 20 {.. if
18de0 28 66 69 6c 65 4e 61 6d 65 20 3d 3d 20 6e 75 6c (fileName == nul
18df0 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 l)..
18e00 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 throw new Argume
18e10 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 ntNullException(
18e20 22 66 69 6c 65 4e 61 6d 65 22 29 3b 0d 0a 0d 0a "fileName");....
18e30 20 20 20 20 20 20 20 20 49 6e 74 50 74 72 20 70 IntPtr p
18e40 45 72 72 6f 72 20 3d 20 49 6e 74 50 74 72 2e 5a Error = IntPtr.Z
18e50 65 72 6f 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ero;....
18e60 74 72 79 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a try.. {..
18e70 20 20 20 20 20 20 20 20 20 20 20 20 62 79 74 65 byte
18e80 5b 5d 20 75 74 66 38 46 69 6c 65 4e 61 6d 65 20 [] utf8FileName
18e90 3d 20 55 54 46 38 45 6e 63 6f 64 69 6e 67 2e 55 = UTF8Encoding.U
18ea0 54 46 38 2e 47 65 74 42 79 74 65 73 28 66 69 6c TF8.GetBytes(fil
18eb0 65 4e 61 6d 65 20 2b 20 27 5c 30 27 29 3b 0d 0a eName + '\0');..
18ec0 20 20 20 20 20 20 20 20 20 20 20 20 62 79 74 65 byte
18ed0 5b 5d 20 75 74 66 38 50 72 6f 63 4e 61 6d 65 20 [] utf8ProcName
18ee0 3d 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 20 20 20 20 = null;....
18ef0 20 20 20 20 20 20 20 69 66 20 28 70 72 6f 63 4e if (procN
18f00 61 6d 65 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 ame != null)..
18f10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 75 74 ut
18f20 66 38 50 72 6f 63 4e 61 6d 65 20 3d 20 55 54 46 f8ProcName = UTF
18f30 38 45 6e 63 6f 64 69 6e 67 2e 55 54 46 38 2e 47 8Encoding.UTF8.G
18f40 65 74 42 79 74 65 73 28 70 72 6f 63 4e 61 6d 65 etBytes(procName
18f50 20 2b 20 27 5c 30 27 29 3b 0d 0a 0d 0a 20 20 20 + '\0');....
18f60 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 SQLiteE
18f70 72 72 6f 72 43 6f 64 65 20 6e 20 3d 20 55 6e 73 rrorCode n = Uns
18f80 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
18f90 2e 73 71 6c 69 74 65 33 5f 6c 6f 61 64 5f 65 78 .sqlite3_load_ex
18fa0 74 65 6e 73 69 6f 6e 28 0d 0a 20 20 20 20 20 20 tension(..
18fb0 20 20 20 20 20 20 20 20 20 20 5f 73 71 6c 2c 20 _sql,
18fc0 75 74 66 38 46 69 6c 65 4e 61 6d 65 2c 20 75 74 utf8FileName, ut
18fd0 66 38 50 72 6f 63 4e 61 6d 65 2c 20 72 65 66 20 f8ProcName, ref
18fe0 70 45 72 72 6f 72 29 3b 0d 0a 0d 0a 20 20 20 20 pError);....
18ff0 20 20 20 20 20 20 20 20 69 66 20 28 6e 20 21 3d if (n !=
19000 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
19010 2e 4f 6b 29 0d 0a 20 20 20 20 20 20 20 20 20 20 .Ok)..
19020 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 throw new
19030 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 SQLiteException(
19040 6e 2c 20 55 54 46 38 54 6f 53 74 72 69 6e 67 28 n, UTF8ToString(
19050 70 45 72 72 6f 72 2c 20 2d 31 29 29 3b 0d 0a 20 pError, -1));..
19060 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 }..
19070 20 20 66 69 6e 61 6c 6c 79 0d 0a 20 20 20 20 20 finally..
19080 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
19090 20 20 69 66 20 28 70 45 72 72 6f 72 20 21 3d 20 if (pError !=
190a0 49 6e 74 50 74 72 2e 5a 65 72 6f 29 0d 0a 20 20 IntPtr.Zero)..
190b0 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
190c0 20 20 20 20 20 20 20 20 20 20 20 20 20 55 6e 73 Uns
190d0 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 afeNativeMethods
190e0 2e 73 71 6c 69 74 65 33 5f 66 72 65 65 28 70 45 .sqlite3_free(pE
190f0 72 72 6f 72 29 3b 0d 0a 20 20 20 20 20 20 20 20 rror);..
19100 20 20 20 20 20 20 20 20 70 45 72 72 6f 72 20 3d pError =
19110 20 49 6e 74 50 74 72 2e 5a 65 72 6f 3b 0d 0a 20 IntPtr.Zero;..
19120 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 }..
19130 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a }.. }..
19140 0d 0a 20 20 20 20 2f 2f 2f 20 45 6e 61 62 6c 65 .. /// Enable
19150 73 20 6f 72 20 64 69 73 61 62 6c 65 64 20 65 78 s or disabled ex
19160 74 65 6e 64 65 64 20 72 65 73 75 6c 74 20 63 6f tended result co
19170 64 65 73 20 72 65 74 75 72 6e 65 64 20 62 79 20 des returned by
19180 53 51 4c 69 74 65 0d 0a 20 20 20 20 69 6e 74 65 SQLite.. inte
19190 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f rnal override vo
191a0 69 64 20 53 65 74 45 78 74 65 6e 64 65 64 52 65 id SetExtendedRe
191b0 73 75 6c 74 43 6f 64 65 73 28 62 6f 6f 6c 20 62 sultCodes(bool b
191c0 4f 6e 4f 66 66 29 0d 0a 20 20 20 20 7b 0d 0a 20 OnOff).. {..
191d0 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 6f 72 SQLiteError
191e0 43 6f 64 65 20 6e 20 3d 20 55 6e 73 61 66 65 4e Code n = UnsafeN
191f0 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c ativeMethods.sql
19200 69 74 65 33 5f 65 78 74 65 6e 64 65 64 5f 72 65 ite3_extended_re
19210 73 75 6c 74 5f 63 6f 64 65 73 28 0d 0a 20 20 20 sult_codes(..
19220 20 20 20 20 20 20 20 5f 73 71 6c 2c 20 28 62 4f _sql, (bO
19230 6e 4f 66 66 20 3f 20 2d 31 20 3a 20 30 29 29 3b nOff ? -1 : 0));
19240 0d 0a 0d 0a 20 20 20 20 20 20 69 66 20 28 6e 20 .... if (n
19250 21 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f != SQLiteErrorCo
19260 64 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 77 de.Ok) throw new
19270 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e SQLiteException
19280 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f 72 (n, GetLastError
19290 28 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 20 20 20 ());.. }..
192a0 20 2f 2f 2f 20 47 65 74 73 20 74 68 65 20 6c 61 /// Gets the la
192b0 73 74 20 53 51 4c 69 74 65 20 65 72 72 6f 72 20 st SQLite error
192c0 63 6f 64 65 0d 0a 20 20 20 20 69 6e 74 65 72 6e code.. intern
192d0 61 6c 20 6f 76 65 72 72 69 64 65 20 53 51 4c 69 al override SQLi
192e0 74 65 45 72 72 6f 72 43 6f 64 65 20 52 65 73 75 teErrorCode Resu
192f0 6c 74 43 6f 64 65 28 29 0d 0a 20 20 20 20 7b 0d ltCode().. {.
19300 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 55 6e . return Un
19310 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 safeNativeMethod
19320 73 2e 73 71 6c 69 74 65 33 5f 65 72 72 63 6f 64 s.sqlite3_errcod
19330 65 28 5f 73 71 6c 29 3b 0d 0a 20 20 20 20 7d 0d e(_sql);.. }.
19340 0a 20 20 20 20 2f 2f 2f 20 47 65 74 73 20 74 68 . /// Gets th
19350 65 20 6c 61 73 74 20 53 51 4c 69 74 65 20 65 78 e last SQLite ex
19360 74 65 6e 64 65 64 20 65 72 72 6f 72 20 63 6f 64 tended error cod
19370 65 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 e.. internal
19380 6f 76 65 72 72 69 64 65 20 53 51 4c 69 74 65 45 override SQLiteE
19390 72 72 6f 72 43 6f 64 65 20 45 78 74 65 6e 64 65 rrorCode Extende
193a0 64 52 65 73 75 6c 74 43 6f 64 65 28 29 0d 0a 20 dResultCode()..
193b0 20 20 20 7b 0d 0a 20 20 20 20 20 20 72 65 74 75 {.. retu
193c0 72 6e 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d rn UnsafeNativeM
193d0 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 65 ethods.sqlite3_e
193e0 78 74 65 6e 64 65 64 5f 65 72 72 63 6f 64 65 28 xtended_errcode(
193f0 5f 73 71 6c 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d _sql);.. }...
19400 0a 20 20 20 20 2f 2f 2f 20 41 64 64 20 61 20 6c . /// Add a l
19410 6f 67 20 6d 65 73 73 61 67 65 20 76 69 61 20 74 og message via t
19420 68 65 20 53 51 4c 69 74 65 20 73 71 6c 69 74 65 he SQLite sqlite
19430 33 5f 6c 6f 67 20 69 6e 74 65 72 66 61 63 65 2e 3_log interface.
19440 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
19450 76 65 72 72 69 64 65 20 76 6f 69 64 20 4c 6f 67 verride void Log
19460 4d 65 73 73 61 67 65 28 53 51 4c 69 74 65 45 72 Message(SQLiteEr
19470 72 6f 72 43 6f 64 65 20 69 45 72 72 43 6f 64 65 rorCode iErrCode
19480 2c 20 73 74 72 69 6e 67 20 7a 4d 65 73 73 61 67 , string zMessag
19490 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 e).. {..
194a0 20 53 74 61 74 69 63 4c 6f 67 4d 65 73 73 61 67 StaticLogMessag
194b0 65 28 69 45 72 72 43 6f 64 65 2c 20 7a 4d 65 73 e(iErrCode, zMes
194c0 73 61 67 65 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d sage);.. }...
194d0 0a 20 20 20 20 2f 2f 2f 20 41 64 64 20 61 20 6c . /// Add a l
194e0 6f 67 20 6d 65 73 73 61 67 65 20 76 69 61 20 74 og message via t
194f0 68 65 20 53 51 4c 69 74 65 20 73 71 6c 69 74 65 he SQLite sqlite
19500 33 5f 6c 6f 67 20 69 6e 74 65 72 66 61 63 65 2e 3_log interface.
19510 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 73 .. internal s
19520 74 61 74 69 63 20 76 6f 69 64 20 53 74 61 74 69 tatic void Stati
19530 63 4c 6f 67 4d 65 73 73 61 67 65 28 53 51 4c 69 cLogMessage(SQLi
19540 74 65 45 72 72 6f 72 43 6f 64 65 20 69 45 72 72 teErrorCode iErr
19550 43 6f 64 65 2c 20 73 74 72 69 6e 67 20 7a 4d 65 Code, string zMe
19560 73 73 61 67 65 29 0d 0a 20 20 20 20 7b 0d 0a 20 ssage).. {..
19570 20 20 20 20 20 55 6e 73 61 66 65 4e 61 74 69 76 UnsafeNativ
19580 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
19590 5f 6c 6f 67 28 69 45 72 72 43 6f 64 65 2c 20 54 _log(iErrCode, T
195a0 6f 55 54 46 38 28 7a 4d 65 73 73 61 67 65 29 29 oUTF8(zMessage))
195b0 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 23 69 66 20 ;.. }....#if
195c0 49 4e 54 45 52 4f 50 5f 43 4f 44 45 43 20 7c 7c INTEROP_CODEC ||
195d0 20 49 4e 54 45 52 4f 50 5f 49 4e 43 4c 55 44 45 INTEROP_INCLUDE
195e0 5f 53 45 45 0d 0a 20 20 20 20 69 6e 74 65 72 6e _SEE.. intern
195f0 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f 69 64 al override void
19600 20 53 65 74 50 61 73 73 77 6f 72 64 28 62 79 74 SetPassword(byt
19610 65 5b 5d 20 70 61 73 73 77 6f 72 64 42 79 74 65 e[] passwordByte
19620 73 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 s).. {..
19630 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
19640 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 n = UnsafeNativ
19650 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
19660 5f 6b 65 79 28 5f 73 71 6c 2c 20 70 61 73 73 77 _key(_sql, passw
19670 6f 72 64 42 79 74 65 73 2c 20 70 61 73 73 77 6f ordBytes, passwo
19680 72 64 42 79 74 65 73 2e 4c 65 6e 67 74 68 29 3b rdBytes.Length);
19690 0d 0a 20 20 20 20 20 20 69 66 20 28 6e 20 21 3d .. if (n !=
196a0 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
196b0 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 77 20 53 .Ok) throw new S
196c0 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 6e QLiteException(n
196d0 2c 20 47 65 74 4c 61 73 74 45 72 72 6f 72 28 29 , GetLastError()
196e0 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 69 66 20 28 );.... if (
196f0 5f 75 73 65 50 6f 6f 6c 29 0d 0a 20 20 20 20 20 _usePool)..
19700 20 7b 0d 0a 20 20 20 20 20 20 20 20 5f 75 73 65 {.. _use
19710 50 6f 6f 6c 20 3d 20 66 61 6c 73 65 3b 0d 0a 0d Pool = false;...
19720 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 43 .#if !NET_COMPAC
19730 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f 43 4f T_20 && TRACE_CO
19740 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 20 20 NNECTION..
19750 20 20 54 72 61 63 65 2e 57 72 69 74 65 4c 69 6e Trace.WriteLin
19760 65 28 48 65 6c 70 65 72 4d 65 74 68 6f 64 73 2e e(HelperMethods.
19770 53 74 72 69 6e 67 46 6f 72 6d 61 74 28 0d 0a 20 StringFormat(..
19780 20 20 20 20 20 20 20 20 20 43 75 6c 74 75 72 65 Culture
19790 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c 74 Info.CurrentCult
197a0 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 ure,..
197b0 22 53 65 74 50 61 73 73 77 6f 72 64 20 28 50 6f "SetPassword (Po
197c0 6f 6c 29 20 44 69 73 61 62 6c 65 64 3a 20 7b 30 ol) Disabled: {0
197d0 7d 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 48 }",.. H
197e0 61 6e 64 6c 65 54 6f 53 74 72 69 6e 67 28 29 29 andleToString())
197f0 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 );..#endif..
19800 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 }.. }....
19810 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 internal overr
19820 69 64 65 20 76 6f 69 64 20 43 68 61 6e 67 65 50 ide void ChangeP
19830 61 73 73 77 6f 72 64 28 62 79 74 65 5b 5d 20 6e assword(byte[] n
19840 65 77 50 61 73 73 77 6f 72 64 42 79 74 65 73 29 ewPasswordBytes)
19850 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 53 .. {.. S
19860 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 6e QLiteErrorCode n
19870 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d = UnsafeNativeM
19880 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 72 ethods.sqlite3_r
19890 65 6b 65 79 28 5f 73 71 6c 2c 20 6e 65 77 50 61 ekey(_sql, newPa
198a0 73 73 77 6f 72 64 42 79 74 65 73 2c 20 28 6e 65 sswordBytes, (ne
198b0 77 50 61 73 73 77 6f 72 64 42 79 74 65 73 20 3d wPasswordBytes =
198c0 3d 20 6e 75 6c 6c 29 20 3f 20 30 20 3a 20 6e 65 = null) ? 0 : ne
198d0 77 50 61 73 73 77 6f 72 64 42 79 74 65 73 2e 4c wPasswordBytes.L
198e0 65 6e 67 74 68 29 3b 0d 0a 20 20 20 20 20 20 69 ength);.. i
198f0 66 20 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 72 f (n != SQLiteEr
19900 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 74 68 72 6f rorCode.Ok) thro
19910 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 w new SQLiteExce
19920 70 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 ption(n, GetLast
19930 45 72 72 6f 72 28 29 29 3b 0d 0a 0d 0a 20 20 20 Error());....
19940 20 20 20 69 66 20 28 5f 75 73 65 50 6f 6f 6c 29 if (_usePool)
19950 0d 0a 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 .. {..
19960 20 20 20 5f 75 73 65 50 6f 6f 6c 20 3d 20 66 61 _usePool = fa
19970 6c 73 65 3b 0d 0a 0d 0a 23 69 66 20 21 4e 45 54 lse;....#if !NET
19980 5f 43 4f 4d 50 41 43 54 5f 32 30 20 26 26 20 54 _COMPACT_20 && T
19990 52 41 43 45 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d RACE_CONNECTION.
199a0 0a 20 20 20 20 20 20 20 20 54 72 61 63 65 2e 57 . Trace.W
199b0 72 69 74 65 4c 69 6e 65 28 48 65 6c 70 65 72 4d riteLine(HelperM
199c0 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 ethods.StringFor
199d0 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 mat(..
199e0 43 75 6c 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 CultureInfo.Curr
199f0 65 6e 74 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 entCulture,..
19a00 20 20 20 20 20 20 20 22 43 68 61 6e 67 65 50 61 "ChangePa
19a10 73 73 77 6f 72 64 20 28 50 6f 6f 6c 29 20 44 69 ssword (Pool) Di
19a20 73 61 62 6c 65 64 3a 20 7b 30 7d 22 2c 0d 0a 20 sabled: {0}",..
19a30 20 20 20 20 20 20 20 20 20 48 61 6e 64 6c 65 54 HandleT
19a40 6f 53 74 72 69 6e 67 28 29 29 29 3b 0d 0a 23 65 oString()));..#e
19a50 6e 64 69 66 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 ndif.. }..
19a60 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a }..#endif....
19a70 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
19a80 72 72 69 64 65 20 76 6f 69 64 20 53 65 74 50 72 rride void SetPr
19a90 6f 67 72 65 73 73 48 6f 6f 6b 28 69 6e 74 20 6e ogressHook(int n
19aa0 4f 70 73 2c 20 53 51 4c 69 74 65 50 72 6f 67 72 Ops, SQLiteProgr
19ab0 65 73 73 43 61 6c 6c 62 61 63 6b 20 66 75 6e 63 essCallback func
19ac0 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
19ad0 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 UnsafeNativeMe
19ae0 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 70 72 thods.sqlite3_pr
19af0 6f 67 72 65 73 73 5f 68 61 6e 64 6c 65 72 28 5f ogress_handler(_
19b00 73 71 6c 2c 20 6e 4f 70 73 2c 20 66 75 6e 63 2c sql, nOps, func,
19b10 20 49 6e 74 50 74 72 2e 5a 65 72 6f 29 3b 0d 0a IntPtr.Zero);..
19b20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 }.... int
19b30 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 ernal override v
19b40 6f 69 64 20 53 65 74 41 75 74 68 6f 72 69 7a 65 oid SetAuthorize
19b50 72 48 6f 6f 6b 28 53 51 4c 69 74 65 41 75 74 68 rHook(SQLiteAuth
19b60 6f 72 69 7a 65 72 43 61 6c 6c 62 61 63 6b 20 66 orizerCallback f
19b70 75 6e 63 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 unc).. {..
19b80 20 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d UnsafeNativeM
19b90 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 73 ethods.sqlite3_s
19ba0 65 74 5f 61 75 74 68 6f 72 69 7a 65 72 28 5f 73 et_authorizer(_s
19bb0 71 6c 2c 20 66 75 6e 63 2c 20 49 6e 74 50 74 72 ql, func, IntPtr
19bc0 2e 5a 65 72 6f 29 3b 0d 0a 20 20 20 20 7d 0d 0a .Zero);.. }..
19bd0 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
19be0 76 65 72 72 69 64 65 20 76 6f 69 64 20 53 65 74 verride void Set
19bf0 55 70 64 61 74 65 48 6f 6f 6b 28 53 51 4c 69 74 UpdateHook(SQLit
19c00 65 55 70 64 61 74 65 43 61 6c 6c 62 61 63 6b 20 eUpdateCallback
19c10 66 75 6e 63 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 func).. {..
19c20 20 20 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 UnsafeNative
19c30 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
19c40 75 70 64 61 74 65 5f 68 6f 6f 6b 28 5f 73 71 6c update_hook(_sql
19c50 2c 20 66 75 6e 63 2c 20 49 6e 74 50 74 72 2e 5a , func, IntPtr.Z
19c60 65 72 6f 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a ero);.. }....
19c70 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
19c80 72 72 69 64 65 20 76 6f 69 64 20 53 65 74 43 6f rride void SetCo
19c90 6d 6d 69 74 48 6f 6f 6b 28 53 51 4c 69 74 65 43 mmitHook(SQLiteC
19ca0 6f 6d 6d 69 74 43 61 6c 6c 62 61 63 6b 20 66 75 ommitCallback fu
19cb0 6e 63 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 nc).. {..
19cc0 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 UnsafeNativeMe
19cd0 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f thods.sqlite3_co
19ce0 6d 6d 69 74 5f 68 6f 6f 6b 28 5f 73 71 6c 2c 20 mmit_hook(_sql,
19cf0 66 75 6e 63 2c 20 49 6e 74 50 74 72 2e 5a 65 72 func, IntPtr.Zer
19d00 6f 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 o);.. }....
19d10 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 internal overr
19d20 69 64 65 20 76 6f 69 64 20 53 65 74 54 72 61 63 ide void SetTrac
19d30 65 43 61 6c 6c 62 61 63 6b 28 53 51 4c 69 74 65 eCallback(SQLite
19d40 54 72 61 63 65 43 61 6c 6c 62 61 63 6b 20 66 75 TraceCallback fu
19d50 6e 63 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 nc).. {..
19d60 20 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 UnsafeNativeMe
19d70 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 74 72 thods.sqlite3_tr
19d80 61 63 65 28 5f 73 71 6c 2c 20 66 75 6e 63 2c 20 ace(_sql, func,
19d90 49 6e 74 50 74 72 2e 5a 65 72 6f 29 3b 0d 0a 20 IntPtr.Zero);..
19da0 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 }.... inte
19db0 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f rnal override vo
19dc0 69 64 20 53 65 74 54 72 61 63 65 43 61 6c 6c 62 id SetTraceCallb
19dd0 61 63 6b 32 28 53 51 4c 69 74 65 54 72 61 63 65 ack2(SQLiteTrace
19de0 46 6c 61 67 73 20 6d 61 73 6b 2c 20 53 51 4c 69 Flags mask, SQLi
19df0 74 65 54 72 61 63 65 43 61 6c 6c 62 61 63 6b 32 teTraceCallback2
19e00 20 66 75 6e 63 29 0d 0a 20 20 20 20 7b 0d 0a 20 func).. {..
19e10 20 20 20 20 20 20 20 55 6e 73 61 66 65 4e 61 74 UnsafeNat
19e20 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 iveMethods.sqlit
19e30 65 33 5f 74 72 61 63 65 5f 76 32 28 5f 73 71 6c e3_trace_v2(_sql
19e40 2c 20 6d 61 73 6b 2c 20 66 75 6e 63 2c 20 49 6e , mask, func, In
19e50 74 50 74 72 2e 5a 65 72 6f 29 3b 0d 0a 20 20 20 tPtr.Zero);..
19e60 20 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e }.... intern
19e70 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f 69 64 al override void
19e80 20 53 65 74 52 6f 6c 6c 62 61 63 6b 48 6f 6f 6b SetRollbackHook
19e90 28 53 51 4c 69 74 65 52 6f 6c 6c 62 61 63 6b 43 (SQLiteRollbackC
19ea0 61 6c 6c 62 61 63 6b 20 66 75 6e 63 29 0d 0a 20 allback func)..
19eb0 20 20 20 7b 0d 0a 20 20 20 20 20 20 55 6e 73 61 {.. Unsa
19ec0 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
19ed0 73 71 6c 69 74 65 33 5f 72 6f 6c 6c 62 61 63 6b sqlite3_rollback
19ee0 5f 68 6f 6f 6b 28 5f 73 71 6c 2c 20 66 75 6e 63 _hook(_sql, func
19ef0 2c 20 49 6e 74 50 74 72 2e 5a 65 72 6f 29 3b 0d , IntPtr.Zero);.
19f00 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f . }.... //
19f10 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 / <summary>..
19f20 20 2f 2f 2f 20 41 6c 6c 6f 77 73 20 74 68 65 20 /// Allows the
19f30 73 65 74 74 69 6e 67 20 6f 66 20 61 20 6c 6f 67 setting of a log
19f40 67 69 6e 67 20 63 61 6c 6c 62 61 63 6b 20 69 6e ging callback in
19f50 76 6f 6b 65 64 20 62 79 20 53 51 4c 69 74 65 20 voked by SQLite
19f60 77 68 65 6e 20 61 0d 0a 20 20 20 20 2f 2f 2f 20 when a.. ///
19f70 6c 6f 67 20 65 76 65 6e 74 20 6f 63 63 75 72 73 log event occurs
19f80 2e 20 20 4f 6e 6c 79 20 6f 6e 65 20 63 61 6c 6c . Only one call
19f90 62 61 63 6b 20 6d 61 79 20 62 65 20 73 65 74 2e back may be set.
19fa0 20 20 49 66 20 4e 55 4c 4c 20 69 73 20 70 61 73 If NULL is pas
19fb0 73 65 64 2c 0d 0a 20 20 20 20 2f 2f 2f 20 74 68 sed,.. /// th
19fc0 65 20 6c 6f 67 67 69 6e 67 20 63 61 6c 6c 62 61 e logging callba
19fd0 63 6b 20 69 73 20 75 6e 72 65 67 69 73 74 65 72 ck is unregister
19fe0 65 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 ed... /// </s
19ff0 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
1a000 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 66 75 <param name="fu
1a010 6e 63 22 3e 54 68 65 20 63 61 6c 6c 62 61 63 6b nc">The callback
1a020 20 66 75 6e 63 74 69 6f 6e 20 74 6f 20 69 6e 76 function to inv
1a030 6f 6b 65 2e 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 oke.</param>..
1a040 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 52 /// <returns>R
1a050 65 74 75 72 6e 73 20 61 20 72 65 73 75 6c 74 20 eturns a result
1a060 63 6f 64 65 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a code</returns>..
1a070 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
1a080 72 72 69 64 65 20 53 51 4c 69 74 65 45 72 72 6f rride SQLiteErro
1a090 72 43 6f 64 65 20 53 65 74 4c 6f 67 43 61 6c 6c rCode SetLogCall
1a0a0 62 61 63 6b 28 53 51 4c 69 74 65 4c 6f 67 43 61 back(SQLiteLogCa
1a0b0 6c 6c 62 61 63 6b 20 66 75 6e 63 29 0d 0a 20 20 llback func)..
1a0c0 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 53 51 4c {.. SQL
1a0d0 69 74 65 45 72 72 6f 72 43 6f 64 65 20 72 63 20 iteErrorCode rc
1a0e0 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 = UnsafeNativeMe
1a0f0 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 63 6f thods.sqlite3_co
1a100 6e 66 69 67 5f 6c 6f 67 28 0d 0a 20 20 20 20 20 nfig_log(..
1a110 20 20 20 20 20 20 20 53 51 4c 69 74 65 43 6f 6e SQLiteCon
1a120 66 69 67 4f 70 73 45 6e 75 6d 2e 53 51 4c 49 54 figOpsEnum.SQLIT
1a130 45 5f 43 4f 4e 46 49 47 5f 4c 4f 47 2c 20 66 75 E_CONFIG_LOG, fu
1a140 6e 63 2c 20 49 6e 74 50 74 72 2e 5a 65 72 6f 29 nc, IntPtr.Zero)
1a150 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 ;.... if
1a160 28 72 63 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 (rc == SQLiteErr
1a170 6f 72 43 6f 64 65 2e 4f 6b 29 0d 0a 20 20 20 20 orCode.Ok)..
1a180 20 20 20 20 20 20 20 20 5f 73 65 74 4c 6f 67 43 _setLogC
1a190 61 6c 6c 62 61 63 6b 20 3d 20 28 66 75 6e 63 20 allback = (func
1a1a0 21 3d 20 6e 75 6c 6c 29 3b 0d 0a 0d 0a 20 20 20 != null);....
1a1b0 20 20 20 20 20 72 65 74 75 72 6e 20 72 63 3b 0d return rc;.
1a1c0 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f . }.... //
1a1d0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1a1e0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1a1f0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1a200 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1a210 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1a220 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d /////////////...
1a230 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 . /// <summar
1a240 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 41 70 70 65 y>.. /// Appe
1a250 6e 64 73 20 61 6e 20 65 72 72 6f 72 20 6d 65 73 nds an error mes
1a260 73 61 67 65 20 61 6e 64 20 61 6e 20 61 70 70 72 sage and an appr
1a270 6f 70 72 69 61 74 65 20 6c 69 6e 65 2d 65 6e 64 opriate line-end
1a280 69 6e 67 20 74 6f 20 61 20 3c 73 65 65 20 63 72 ing to a <see cr
1a290 65 66 3d 22 53 74 72 69 6e 67 42 75 69 6c 64 65 ef="StringBuilde
1a2a0 72 22 20 2f 3e 0d 0a 20 20 20 20 2f 2f 2f 20 69 r" />.. /// i
1a2b0 6e 73 74 61 6e 63 65 2e 20 20 54 68 69 73 20 69 nstance. This i
1a2c0 73 20 75 73 65 66 75 6c 20 62 65 63 61 75 73 65 s useful because
1a2d0 20 74 68 65 20 2e 4e 45 54 20 43 6f 6d 70 61 63 the .NET Compac
1a2e0 74 20 46 72 61 6d 65 77 6f 72 6b 20 68 61 73 20 t Framework has
1a2f0 61 20 73 6c 69 67 68 74 6c 79 20 64 69 66 66 65 a slightly diffe
1a300 72 65 6e 74 20 73 65 74 0d 0a 20 20 20 20 2f 2f rent set.. //
1a310 2f 20 6f 66 20 73 75 70 70 6f 72 74 65 64 20 6d / of supported m
1a320 65 74 68 6f 64 73 20 66 6f 72 20 74 68 65 20 3c ethods for the <
1a330 73 65 65 20 63 72 65 66 3d 22 53 74 72 69 6e 67 see cref="String
1a340 42 75 69 6c 64 65 72 22 20 2f 3e 20 63 6c 61 73 Builder" /> clas
1a350 73 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 s... /// </su
1a360 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 mmary>.. ///
1a370 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 62 75 69 <param name="bui
1a380 6c 64 65 72 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 lder">.. ///
1a390 54 68 65 20 3c 73 65 65 20 63 72 65 66 3d 22 53 The <see cref="S
1a3a0 74 72 69 6e 67 42 75 69 6c 64 65 72 22 20 2f 3e tringBuilder" />
1a3b0 20 69 6e 73 74 61 6e 63 65 20 74 6f 20 61 70 70 instance to app
1a3c0 65 6e 64 20 74 6f 2e 0d 0a 20 20 20 20 2f 2f 2f end to... ///
1a3d0 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f </param>.. /
1a3e0 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 // <param name="
1a3f0 6d 65 73 73 61 67 65 22 3e 0d 0a 20 20 20 20 2f message">.. /
1a400 2f 2f 20 54 68 65 20 6d 65 73 73 61 67 65 20 74 // The message t
1a410 6f 20 61 70 70 65 6e 64 2e 20 20 49 74 20 77 69 o append. It wi
1a420 6c 6c 20 62 65 20 66 6f 6c 6c 6f 77 65 64 20 62 ll be followed b
1a430 79 20 61 6e 20 61 70 70 72 6f 70 72 69 61 74 65 y an appropriate
1a440 20 6c 69 6e 65 2d 65 6e 64 69 6e 67 2e 0d 0a 20 line-ending...
1a450 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d /// </param>.
1a460 0a 20 20 20 20 70 72 69 76 61 74 65 20 73 74 61 . private sta
1a470 74 69 63 20 76 6f 69 64 20 41 70 70 65 6e 64 45 tic void AppendE
1a480 72 72 6f 72 28 0d 0a 20 20 20 20 20 20 20 20 53 rror(.. S
1a490 74 72 69 6e 67 42 75 69 6c 64 65 72 20 62 75 69 tringBuilder bui
1a4a0 6c 64 65 72 2c 0d 0a 20 20 20 20 20 20 20 20 73 lder,.. s
1a4b0 74 72 69 6e 67 20 6d 65 73 73 61 67 65 0d 0a 20 tring message..
1a4c0 20 20 20 20 20 20 20 29 0d 0a 20 20 20 20 7b 0d ).. {.
1a4d0 0a 20 20 20 20 20 20 20 20 69 66 20 28 62 75 69 . if (bui
1a4e0 6c 64 65 72 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 lder == null)..
1a4f0 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 retur
1a500 6e 3b 0d 0a 0d 0a 23 69 66 20 21 50 4c 41 54 46 n;....#if !PLATF
1a510 4f 52 4d 5f 43 4f 4d 50 41 43 54 46 52 41 4d 45 ORM_COMPACTFRAME
1a520 57 4f 52 4b 0d 0a 20 20 20 20 20 20 20 20 62 75 WORK.. bu
1a530 69 6c 64 65 72 2e 41 70 70 65 6e 64 4c 69 6e 65 ilder.AppendLine
1a540 28 6d 65 73 73 61 67 65 29 3b 0d 0a 23 65 6c 73 (message);..#els
1a550 65 0d 0a 20 20 20 20 20 20 20 20 62 75 69 6c 64 e.. build
1a560 65 72 2e 41 70 70 65 6e 64 28 6d 65 73 73 61 67 er.Append(messag
1a570 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 62 75 69 e);.. bui
1a580 6c 64 65 72 2e 41 70 70 65 6e 64 28 22 5c 72 5c lder.Append("\r\
1a590 6e 22 29 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 n");..#endif..
1a5a0 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f }.... /////
1a5b0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1a5c0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1a5d0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1a5e0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1a5f0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1a600 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 //////////....
1a610 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d /// <summary>.
1a620 0a 20 20 20 20 2f 2f 2f 20 54 68 69 73 20 6d 65 . /// This me
1a630 74 68 6f 64 20 61 74 74 65 6d 70 74 73 20 74 6f thod attempts to
1a640 20 63 61 75 73 65 20 74 68 65 20 53 51 4c 69 74 cause the SQLit
1a650 65 20 6e 61 74 69 76 65 20 6c 69 62 72 61 72 79 e native library
1a660 20 74 6f 20 69 6e 76 61 6c 69 64 61 74 65 0d 0a to invalidate..
1a670 20 20 20 20 2f 2f 2f 20 69 74 73 20 66 75 6e 63 /// its func
1a680 74 69 6f 6e 20 70 6f 69 6e 74 65 72 73 20 74 68 tion pointers th
1a690 61 74 20 72 65 66 65 72 20 74 6f 20 74 68 69 73 at refer to this
1a6a0 20 69 6e 73 74 61 6e 63 65 2e 20 20 54 68 69 73 instance. This
1a6b0 20 69 73 20 6e 65 63 65 73 73 61 72 79 0d 0a 20 is necessary..
1a6c0 20 20 20 2f 2f 2f 20 74 6f 20 70 72 65 76 65 6e /// to preven
1a6d0 74 20 63 61 6c 6c 73 20 66 72 6f 6d 20 6e 61 74 t calls from nat
1a6e0 69 76 65 20 63 6f 64 65 20 69 6e 74 6f 20 64 65 ive code into de
1a6f0 6c 65 67 61 74 65 73 20 74 68 61 74 20 6d 61 79 legates that may
1a700 20 68 61 76 65 20 62 65 65 6e 0d 0a 20 20 20 20 have been..
1a710 2f 2f 2f 20 67 61 72 62 61 67 65 20 63 6f 6c 6c /// garbage coll
1a720 65 63 74 65 64 2e 20 20 4e 6f 72 6d 61 6c 6c 79 ected. Normally
1a730 2c 20 74 68 65 73 65 20 74 79 70 65 73 20 6f 66 , these types of
1a740 20 69 73 73 75 65 73 20 63 61 6e 20 6f 6e 6c 79 issues can only
1a750 20 61 72 69 73 65 20 66 6f 72 0d 0a 20 20 20 20 arise for..
1a760 2f 2f 2f 20 63 6f 6e 6e 65 63 74 69 6f 6e 73 20 /// connections
1a770 74 68 61 74 20 61 72 65 20 61 64 64 65 64 20 74 that are added t
1a780 6f 20 74 68 65 20 70 6f 6f 6c 3b 20 68 6f 77 76 o the pool; howv
1a790 65 72 2c 20 69 74 20 69 73 20 67 6f 6f 64 20 70 er, it is good p
1a7a0 72 61 63 74 69 63 65 20 74 6f 0d 0a 20 20 20 20 ractice to..
1a7b0 2f 2f 2f 20 75 6e 63 6f 6e 64 69 74 69 6f 6e 61 /// unconditiona
1a7c0 6c 6c 79 20 69 6e 76 61 6c 69 64 61 74 65 20 66 lly invalidate f
1a7d0 75 6e 63 74 69 6f 6e 20 70 6f 69 6e 74 65 72 73 unction pointers
1a7e0 20 74 68 61 74 20 6d 61 79 20 72 65 66 65 72 20 that may refer
1a7f0 74 6f 20 6f 62 6a 65 63 74 73 0d 0a 20 20 20 20 to objects..
1a800 2f 2f 2f 20 62 65 69 6e 67 20 64 69 73 70 6f 73 /// being dispos
1a810 65 64 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 ed... /// </s
1a820 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
1a830 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 69 6e <param name="in
1a840 63 6c 75 64 65 47 6c 6f 62 61 6c 22 3e 0d 0a 20 cludeGlobal">..
1a850 20 20 20 2f 2f 2f 20 4e 6f 6e 2d 7a 65 72 6f 20 /// Non-zero
1a860 74 6f 20 61 6c 73 6f 20 69 6e 76 61 6c 69 64 61 to also invalida
1a870 74 65 20 67 6c 6f 62 61 6c 20 66 75 6e 63 74 69 te global functi
1a880 6f 6e 20 70 6f 69 6e 74 65 72 73 20 28 69 2e 65 on pointers (i.e
1a890 2e 20 74 68 6f 73 65 20 74 68 61 74 0d 0a 20 20 . those that..
1a8a0 20 20 2f 2f 2f 20 61 72 65 20 6e 6f 74 20 64 69 /// are not di
1a8b0 72 65 63 74 6c 79 20 61 73 73 6f 63 69 61 74 65 rectly associate
1a8c0 64 20 77 69 74 68 20 74 68 69 73 20 63 6f 6e 6e d with this conn
1a8d0 65 63 74 69 6f 6e 20 6f 6e 20 74 68 65 20 6e 61 ection on the na
1a8e0 74 69 76 65 20 73 69 64 65 29 2e 0d 0a 20 20 20 tive side)...
1a8f0 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 /// </param>..
1a900 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 /// <param na
1a910 6d 65 3d 22 63 61 6e 54 68 72 6f 77 22 3e 0d 0a me="canThrow">..
1a920 20 20 20 20 2f 2f 2f 20 4e 6f 6e 2d 7a 65 72 6f /// Non-zero
1a930 20 69 66 20 74 68 69 73 20 6d 65 74 68 6f 64 20 if this method
1a940 69 73 20 62 65 69 6e 67 20 65 78 65 63 75 74 65 is being execute
1a950 64 20 77 69 74 68 69 6e 20 61 20 63 6f 6e 74 65 d within a conte
1a960 78 74 20 77 68 65 72 65 20 69 74 20 63 61 6e 0d xt where it can.
1a970 0a 20 20 20 20 2f 2f 2f 20 74 68 72 6f 77 20 61 . /// throw a
1a980 6e 20 65 78 63 65 70 74 69 6f 6e 20 69 6e 20 74 n exception in t
1a990 68 65 20 65 76 65 6e 74 20 6f 66 20 66 61 69 6c he event of fail
1a9a0 75 72 65 3b 20 6f 74 68 65 72 77 69 73 65 2c 20 ure; otherwise,
1a9b0 7a 65 72 6f 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c zero... /// <
1a9c0 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f /param>.. ///
1a9d0 20 3c 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 <returns>..
1a9e0 2f 2f 2f 20 4e 6f 6e 2d 7a 65 72 6f 20 69 66 20 /// Non-zero if
1a9f0 74 68 69 73 20 6d 65 74 68 6f 64 20 77 61 73 20 this method was
1aa00 73 75 63 63 65 73 73 66 75 6c 3b 20 6f 74 68 65 successful; othe
1aa10 72 77 69 73 65 2c 20 7a 65 72 6f 2e 0d 0a 20 20 rwise, zero...
1aa20 20 20 2f 2f 2f 20 3c 2f 72 65 74 75 72 6e 73 3e /// </returns>
1aa30 0d 0a 20 20 20 20 70 72 69 76 61 74 65 20 62 6f .. private bo
1aa40 6f 6c 20 55 6e 68 6f 6f 6b 4e 61 74 69 76 65 43 ol UnhookNativeC
1aa50 61 6c 6c 62 61 63 6b 73 28 0d 0a 20 20 20 20 20 allbacks(..
1aa60 20 20 20 62 6f 6f 6c 20 69 6e 63 6c 75 64 65 47 bool includeG
1aa70 6c 6f 62 61 6c 2c 0d 0a 20 20 20 20 20 20 20 20 lobal,..
1aa80 62 6f 6f 6c 20 63 61 6e 54 68 72 6f 77 0d 0a 20 bool canThrow..
1aa90 20 20 20 20 20 20 20 29 0d 0a 20 20 20 20 7b 0d ).. {.
1aaa0 0a 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 . //..
1aab0 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 49 6e // NOTE: In
1aac0 69 74 69 61 6c 6c 79 2c 20 74 68 69 73 20 6d 65 itially, this me
1aad0 74 68 6f 64 20 61 73 73 75 6d 65 73 20 73 75 63 thod assumes suc
1aae0 63 65 73 73 2e 20 20 54 68 65 6e 2c 20 69 66 20 cess. Then, if
1aaf0 61 6e 79 20 61 74 74 65 6d 70 74 0d 0a 20 20 20 any attempt..
1ab00 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 74 6f // to
1ab10 20 69 6e 76 61 6c 69 64 61 74 65 20 61 20 66 75 invalidate a fu
1ab20 6e 63 74 69 6f 6e 20 70 6f 69 6e 74 65 72 20 66 nction pointer f
1ab30 61 69 6c 73 2c 20 74 68 65 20 6f 76 65 72 61 6c ails, the overal
1ab40 6c 20 72 65 73 75 6c 74 20 69 73 0d 0a 20 20 20 l result is..
1ab50 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 73 65 // se
1ab60 74 20 74 6f 20 66 61 69 6c 75 72 65 2e 20 20 48 t to failure. H
1ab70 6f 77 65 76 65 72 2c 20 74 68 69 73 20 77 69 6c owever, this wil
1ab80 6c 20 6e 6f 74 20 70 72 65 76 65 6e 74 20 66 75 l not prevent fu
1ab90 72 74 68 65 72 0d 0a 20 20 20 20 20 20 20 20 2f rther.. /
1aba0 2f 20 20 20 20 20 20 20 61 74 74 65 6d 70 74 73 / attempts
1abb0 2c 20 69 66 20 61 6e 79 2c 20 74 6f 20 69 6e 76 , if any, to inv
1abc0 61 6c 69 64 61 74 65 20 73 75 62 73 65 71 75 65 alidate subseque
1abd0 6e 74 20 66 75 6e 63 74 69 6f 6e 20 70 6f 69 6e nt function poin
1abe0 74 65 72 73 2e 0d 0a 20 20 20 20 20 20 20 20 2f ters... /
1abf0 2f 0d 0a 20 20 20 20 20 20 20 20 62 6f 6f 6c 20 /.. bool
1ac00 72 65 73 75 6c 74 20 3d 20 74 72 75 65 3b 0d 0a result = true;..
1ac10 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 SQLiteEr
1ac20 72 6f 72 43 6f 64 65 20 72 63 20 3d 20 53 51 4c rorCode rc = SQL
1ac30 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 3b iteErrorCode.Ok;
1ac40 0d 0a 20 20 20 20 20 20 20 20 53 74 72 69 6e 67 .. String
1ac50 42 75 69 6c 64 65 72 20 62 75 69 6c 64 65 72 20 Builder builder
1ac60 3d 20 6e 65 77 20 53 74 72 69 6e 67 42 75 69 6c = new StringBuil
1ac70 64 65 72 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 der();....
1ac80 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f //////////////
1ac90 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1aca0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1acb0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1acc0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1acd0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d /////////////...
1ace0 0a 20 20 20 20 20 20 20 20 23 72 65 67 69 6f 6e . #region
1acf0 20 52 6f 6c 6c 62 61 63 6b 20 48 6f 6f 6b 20 28 Rollback Hook (
1ad00 50 65 72 2d 43 6f 6e 6e 65 63 74 69 6f 6e 29 0d Per-Connection).
1ad10 0a 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 . try..
1ad20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
1ad30 20 20 20 20 20 53 65 74 52 6f 6c 6c 62 61 63 6b SetRollback
1ad40 48 6f 6f 6b 28 6e 75 6c 6c 29 3b 20 2f 2a 20 74 Hook(null); /* t
1ad50 68 72 6f 77 20 2a 2f 0d 0a 20 20 20 20 20 20 20 hrow */..
1ad60 20 7d 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d }..#if !NET_COM
1ad70 50 41 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 PACT_20 && TRACE
1ad80 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 _CONNECTION..
1ad90 20 20 20 20 20 63 61 74 63 68 20 28 45 78 63 65 catch (Exce
1ada0 70 74 69 6f 6e 20 65 29 0d 0a 23 65 6c 73 65 0d ption e)..#else.
1adb0 0a 20 20 20 20 20 20 20 20 63 61 74 63 68 20 28 . catch (
1adc0 45 78 63 65 70 74 69 6f 6e 29 0d 0a 23 65 6e 64 Exception)..#end
1add0 69 66 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 23 if.. {..#
1ade0 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 43 54 5f if !NET_COMPACT_
1adf0 32 30 20 26 26 20 54 52 41 43 45 5f 43 4f 4e 4e 20 && TRACE_CONN
1ae00 45 43 54 49 4f 4e 0d 0a 20 20 20 20 20 20 20 20 ECTION..
1ae10 20 20 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 try..
1ae20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
1ae30 20 20 20 20 20 20 20 20 54 72 61 63 65 2e 57 72 Trace.Wr
1ae40 69 74 65 4c 69 6e 65 28 48 65 6c 70 65 72 4d 65 iteLine(HelperMe
1ae50 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d thods.StringForm
1ae60 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 at(..
1ae70 20 20 20 20 20 20 20 20 20 43 75 6c 74 75 72 65 Culture
1ae80 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c 74 Info.CurrentCult
1ae90 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 ure,..
1aea0 20 20 20 20 20 20 20 20 20 20 22 46 61 69 6c 65 "Faile
1aeb0 64 20 74 6f 20 75 6e 73 65 74 20 72 6f 6c 6c 62 d to unset rollb
1aec0 61 63 6b 20 68 6f 6f 6b 3a 20 7b 30 7d 22 2c 0d ack hook: {0}",.
1aed0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
1aee0 20 20 20 20 20 65 29 29 3b 20 2f 2a 20 74 68 72 e)); /* thr
1aef0 6f 77 20 2a 2f 0d 0a 20 20 20 20 20 20 20 20 20 ow */..
1af00 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 }..
1af10 20 20 63 61 74 63 68 0d 0a 20 20 20 20 20 20 20 catch..
1af20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
1af30 20 20 20 20 20 20 20 20 2f 2f 20 64 6f 20 6e 6f // do no
1af40 74 68 69 6e 67 2e 0d 0a 20 20 20 20 20 20 20 20 thing...
1af50 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d 0a 0d }..#endif...
1af60 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 70 70 . App
1af70 65 6e 64 45 72 72 6f 72 28 62 75 69 6c 64 65 72 endError(builder
1af80 2c 20 22 66 61 69 6c 65 64 20 74 6f 20 75 6e 73 , "failed to uns
1af90 65 74 20 72 6f 6c 6c 62 61 63 6b 20 68 6f 6f 6b et rollback hook
1afa0 22 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ");..
1afb0 20 72 63 20 3d 20 53 51 4c 69 74 65 45 72 72 6f rc = SQLiteErro
1afc0 72 43 6f 64 65 2e 45 72 72 6f 72 3b 0d 0a 0d 0a rCode.Error;....
1afd0 20 20 20 20 20 20 20 20 20 20 20 20 72 65 73 75 resu
1afe0 6c 74 20 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 lt = false;..
1aff0 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
1b000 23 65 6e 64 72 65 67 69 6f 6e 0d 0a 0d 0a 20 20 #endregion....
1b010 20 20 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f //////////
1b020 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b030 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b040 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b050 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b060 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b070 2f 0d 0a 0d 0a 20 20 20 20 20 20 20 20 23 72 65 /.... #re
1b080 67 69 6f 6e 20 54 72 61 63 65 20 43 61 6c 6c 62 gion Trace Callb
1b090 61 63 6b 20 28 50 65 72 2d 43 6f 6e 6e 65 63 74 ack (Per-Connect
1b0a0 69 6f 6e 29 0d 0a 20 20 20 20 20 20 20 20 74 72 ion).. tr
1b0b0 79 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 y.. {..
1b0c0 20 20 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 //..
1b0d0 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 // NOT
1b0e0 45 3a 20 57 68 65 6e 20 75 73 69 6e 67 20 76 65 E: When using ve
1b0f0 72 73 69 6f 6e 20 33 2e 31 34 20 28 6f 72 20 6c rsion 3.14 (or l
1b100 61 74 65 72 29 20 6f 66 20 74 68 65 20 53 51 4c ater) of the SQL
1b110 69 74 65 20 63 6f 72 65 0d 0a 20 20 20 20 20 20 ite core..
1b120 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 6c // l
1b130 69 62 72 61 72 79 2c 20 75 73 65 20 74 68 65 20 ibrary, use the
1b140 6e 65 77 65 72 20 73 71 6c 69 74 65 33 5f 74 72 newer sqlite3_tr
1b150 61 63 65 5f 76 32 28 29 20 41 50 49 20 69 6e 20 ace_v2() API in
1b160 6f 72 64 65 72 0d 0a 20 20 20 20 20 20 20 20 20 order..
1b170 20 20 20 2f 2f 20 20 20 20 20 20 20 74 6f 20 75 // to u
1b180 6e 68 6f 6f 6b 20 74 68 65 20 74 72 61 63 65 20 nhook the trace
1b190 63 61 6c 6c 62 61 63 6b 2c 20 6a 75 73 74 20 69 callback, just i
1b1a0 6e 20 63 61 73 65 20 74 68 65 20 6f 6c 64 65 72 n case the older
1b1b0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f .. //
1b1c0 20 20 20 20 20 20 20 41 50 49 20 69 73 20 6e 6f API is no
1b1d0 74 20 61 76 61 69 6c 61 62 6c 65 20 28 65 2e 67 t available (e.g
1b1e0 2e 20 53 51 4c 49 54 45 5f 4f 4d 49 54 5f 44 45 . SQLITE_OMIT_DE
1b1f0 50 52 45 43 41 54 45 44 29 2e 0d 0a 20 20 20 20 PRECATED)...
1b200 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 //..
1b210 20 20 20 20 20 20 20 20 69 66 20 28 55 6e 73 61 if (Unsa
1b220 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
1b230 73 71 6c 69 74 65 33 5f 6c 69 62 76 65 72 73 69 sqlite3_libversi
1b240 6f 6e 5f 6e 75 6d 62 65 72 28 29 20 3e 3d 20 33 on_number() >= 3
1b250 30 31 34 30 30 30 29 0d 0a 20 20 20 20 20 20 20 014000)..
1b260 20 20 20 20 20 20 20 20 20 53 65 74 54 72 61 63 SetTrac
1b270 65 43 61 6c 6c 62 61 63 6b 32 28 53 51 4c 69 74 eCallback2(SQLit
1b280 65 54 72 61 63 65 46 6c 61 67 73 2e 53 51 4c 49 eTraceFlags.SQLI
1b290 54 45 5f 54 52 41 43 45 5f 4e 4f 4e 45 2c 20 6e TE_TRACE_NONE, n
1b2a0 75 6c 6c 29 3b 20 2f 2a 20 74 68 72 6f 77 20 2a ull); /* throw *
1b2b0 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 /.. e
1b2c0 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 lse..
1b2d0 20 20 20 20 20 53 65 74 54 72 61 63 65 43 61 6c SetTraceCal
1b2e0 6c 62 61 63 6b 28 6e 75 6c 6c 29 3b 20 2f 2a 20 lback(null); /*
1b2f0 74 68 72 6f 77 20 2a 2f 0d 0a 20 20 20 20 20 20 throw */..
1b300 20 20 7d 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f }..#if !NET_CO
1b310 4d 50 41 43 54 5f 32 30 20 26 26 20 54 52 41 43 MPACT_20 && TRAC
1b320 45 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 E_CONNECTION..
1b330 20 20 20 20 20 20 63 61 74 63 68 20 28 45 78 63 catch (Exc
1b340 65 70 74 69 6f 6e 20 65 29 0d 0a 23 65 6c 73 65 eption e)..#else
1b350 0d 0a 20 20 20 20 20 20 20 20 63 61 74 63 68 20 .. catch
1b360 28 45 78 63 65 70 74 69 6f 6e 29 0d 0a 23 65 6e (Exception)..#en
1b370 64 69 66 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a dif.. {..
1b380 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 43 54 #if !NET_COMPACT
1b390 5f 32 30 20 26 26 20 54 52 41 43 45 5f 43 4f 4e _20 && TRACE_CON
1b3a0 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 20 20 20 NECTION..
1b3b0 20 20 20 20 20 74 72 79 0d 0a 20 20 20 20 20 20 try..
1b3c0 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
1b3d0 20 20 20 20 20 20 20 20 20 54 72 61 63 65 2e 57 Trace.W
1b3e0 72 69 74 65 4c 69 6e 65 28 48 65 6c 70 65 72 4d riteLine(HelperM
1b3f0 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 ethods.StringFor
1b400 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 mat(..
1b410 20 20 20 20 20 20 20 20 20 20 43 75 6c 74 75 72 Cultur
1b420 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c eInfo.CurrentCul
1b430 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 ture,..
1b440 20 20 20 20 20 20 20 20 20 20 20 22 46 61 69 6c "Fail
1b450 65 64 20 74 6f 20 75 6e 73 65 74 20 74 72 61 63 ed to unset trac
1b460 65 20 63 61 6c 6c 62 61 63 6b 3a 20 7b 30 7d 22 e callback: {0}"
1b470 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ,..
1b480 20 20 20 20 20 20 20 65 29 29 3b 20 2f 2a 20 74 e)); /* t
1b490 68 72 6f 77 20 2a 2f 0d 0a 20 20 20 20 20 20 20 hrow */..
1b4a0 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
1b4b0 20 20 20 20 63 61 74 63 68 0d 0a 20 20 20 20 20 catch..
1b4c0 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
1b4d0 20 20 20 20 20 20 20 20 20 20 2f 2f 20 64 6f 20 // do
1b4e0 6e 6f 74 68 69 6e 67 2e 0d 0a 20 20 20 20 20 20 nothing...
1b4f0 20 20 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d }..#endif.
1b500 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 ... A
1b510 70 70 65 6e 64 45 72 72 6f 72 28 62 75 69 6c 64 ppendError(build
1b520 65 72 2c 20 22 66 61 69 6c 65 64 20 74 6f 20 75 er, "failed to u
1b530 6e 73 65 74 20 74 72 61 63 65 20 63 61 6c 6c 62 nset trace callb
1b540 61 63 6b 22 29 3b 0d 0a 20 20 20 20 20 20 20 20 ack");..
1b550 20 20 20 20 72 63 20 3d 20 53 51 4c 69 74 65 45 rc = SQLiteE
1b560 72 72 6f 72 43 6f 64 65 2e 45 72 72 6f 72 3b 0d rrorCode.Error;.
1b570 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 ... r
1b580 65 73 75 6c 74 20 3d 20 66 61 6c 73 65 3b 0d 0a esult = false;..
1b590 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
1b5a0 20 20 20 23 65 6e 64 72 65 67 69 6f 6e 0d 0a 0d #endregion...
1b5b0 0a 20 20 20 20 20 20 20 20 2f 2f 2f 2f 2f 2f 2f . ///////
1b5c0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b5d0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b5e0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b5f0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b600 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b610 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ////....
1b620 23 72 65 67 69 6f 6e 20 43 6f 6d 6d 69 74 20 48 #region Commit H
1b630 6f 6f 6b 20 28 50 65 72 2d 43 6f 6e 6e 65 63 74 ook (Per-Connect
1b640 69 6f 6e 29 0d 0a 20 20 20 20 20 20 20 20 74 72 ion).. tr
1b650 79 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 y.. {..
1b660 20 20 20 20 20 20 20 20 20 20 53 65 74 43 6f 6d SetCom
1b670 6d 69 74 48 6f 6f 6b 28 6e 75 6c 6c 29 3b 20 2f mitHook(null); /
1b680 2a 20 74 68 72 6f 77 20 2a 2f 0d 0a 20 20 20 20 * throw */..
1b690 20 20 20 20 7d 0d 0a 23 69 66 20 21 4e 45 54 5f }..#if !NET_
1b6a0 43 4f 4d 50 41 43 54 5f 32 30 20 26 26 20 54 52 COMPACT_20 && TR
1b6b0 41 43 45 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a ACE_CONNECTION..
1b6c0 20 20 20 20 20 20 20 20 63 61 74 63 68 20 28 45 catch (E
1b6d0 78 63 65 70 74 69 6f 6e 20 65 29 0d 0a 23 65 6c xception e)..#el
1b6e0 73 65 0d 0a 20 20 20 20 20 20 20 20 63 61 74 63 se.. catc
1b6f0 68 20 28 45 78 63 65 70 74 69 6f 6e 29 0d 0a 23 h (Exception)..#
1b700 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 7b endif.. {
1b710 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 ..#if !NET_COMPA
1b720 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f 43 CT_20 && TRACE_C
1b730 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 20 ONNECTION..
1b740 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 20 try..
1b750 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
1b760 20 20 20 20 20 20 20 20 20 20 20 54 72 61 63 65 Trace
1b770 2e 57 72 69 74 65 4c 69 6e 65 28 48 65 6c 70 65 .WriteLine(Helpe
1b780 72 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 rMethods.StringF
1b790 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 ormat(..
1b7a0 20 20 20 20 20 20 20 20 20 20 20 20 43 75 6c 74 Cult
1b7b0 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 ureInfo.CurrentC
1b7c0 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 ulture,..
1b7d0 20 20 20 20 20 20 20 20 20 20 20 20 20 22 46 61 "Fa
1b7e0 69 6c 65 64 20 74 6f 20 75 6e 73 65 74 20 63 6f iled to unset co
1b7f0 6d 6d 69 74 20 68 6f 6f 6b 3a 20 7b 30 7d 22 2c mmit hook: {0}",
1b800 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
1b810 20 20 20 20 20 20 65 29 29 3b 20 2f 2a 20 74 68 e)); /* th
1b820 72 6f 77 20 2a 2f 0d 0a 20 20 20 20 20 20 20 20 row */..
1b830 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 }..
1b840 20 20 20 63 61 74 63 68 0d 0a 20 20 20 20 20 20 catch..
1b850 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
1b860 20 20 20 20 20 20 20 20 20 2f 2f 20 64 6f 20 6e // do n
1b870 6f 74 68 69 6e 67 2e 0d 0a 20 20 20 20 20 20 20 othing...
1b880 20 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d 0a }..#endif..
1b890 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 70 .. Ap
1b8a0 70 65 6e 64 45 72 72 6f 72 28 62 75 69 6c 64 65 pendError(builde
1b8b0 72 2c 20 22 66 61 69 6c 65 64 20 74 6f 20 75 6e r, "failed to un
1b8c0 73 65 74 20 63 6f 6d 6d 69 74 20 68 6f 6f 6b 22 set commit hook"
1b8d0 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 );..
1b8e0 72 63 20 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 rc = SQLiteError
1b8f0 43 6f 64 65 2e 45 72 72 6f 72 3b 0d 0a 0d 0a 20 Code.Error;....
1b900 20 20 20 20 20 20 20 20 20 20 20 72 65 73 75 6c resul
1b910 74 20 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 t = false;..
1b920 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 23 }.. #
1b930 65 6e 64 72 65 67 69 6f 6e 0d 0a 0d 0a 20 20 20 endregion....
1b940 20 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ///////////
1b950 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b960 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b970 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b980 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b990 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1b9a0 0d 0a 0d 0a 20 20 20 20 20 20 20 20 23 72 65 67 .... #reg
1b9b0 69 6f 6e 20 55 70 64 61 74 65 20 48 6f 6f 6b 20 ion Update Hook
1b9c0 28 50 65 72 2d 43 6f 6e 6e 65 63 74 69 6f 6e 29 (Per-Connection)
1b9d0 0d 0a 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 .. try..
1b9e0 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
1b9f0 20 20 20 20 20 20 53 65 74 55 70 64 61 74 65 48 SetUpdateH
1ba00 6f 6f 6b 28 6e 75 6c 6c 29 3b 20 2f 2a 20 74 68 ook(null); /* th
1ba10 72 6f 77 20 2a 2f 0d 0a 20 20 20 20 20 20 20 20 row */..
1ba20 7d 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 }..#if !NET_COMP
1ba30 41 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f ACT_20 && TRACE_
1ba40 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 CONNECTION..
1ba50 20 20 20 20 63 61 74 63 68 20 28 45 78 63 65 70 catch (Excep
1ba60 74 69 6f 6e 20 65 29 0d 0a 23 65 6c 73 65 0d 0a tion e)..#else..
1ba70 20 20 20 20 20 20 20 20 63 61 74 63 68 20 28 45 catch (E
1ba80 78 63 65 70 74 69 6f 6e 29 0d 0a 23 65 6e 64 69 xception)..#endi
1ba90 66 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 23 69 f.. {..#i
1baa0 66 20 21 4e 45 54 5f 43 4f 4d 50 41 43 54 5f 32 f !NET_COMPACT_2
1bab0 30 20 26 26 20 54 52 41 43 45 5f 43 4f 4e 4e 45 0 && TRACE_CONNE
1bac0 43 54 49 4f 4e 0d 0a 20 20 20 20 20 20 20 20 20 CTION..
1bad0 20 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 try..
1bae0 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
1baf0 20 20 20 20 20 20 20 54 72 61 63 65 2e 57 72 69 Trace.Wri
1bb00 74 65 4c 69 6e 65 28 48 65 6c 70 65 72 4d 65 74 teLine(HelperMet
1bb10 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d 61 hods.StringForma
1bb20 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 t(..
1bb30 20 20 20 20 20 20 20 20 43 75 6c 74 75 72 65 49 CultureI
1bb40 6e 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c 74 75 nfo.CurrentCultu
1bb50 72 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 re,..
1bb60 20 20 20 20 20 20 20 20 20 22 46 61 69 6c 65 64 "Failed
1bb70 20 74 6f 20 75 6e 73 65 74 20 75 70 64 61 74 65 to unset update
1bb80 20 68 6f 6f 6b 3a 20 7b 30 7d 22 2c 0d 0a 20 20 hook: {0}",..
1bb90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1bba0 20 20 65 29 29 3b 20 2f 2a 20 74 68 72 6f 77 20 e)); /* throw
1bbb0 2a 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 */..
1bbc0 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 63 }.. c
1bbd0 61 74 63 68 0d 0a 20 20 20 20 20 20 20 20 20 20 atch..
1bbe0 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
1bbf0 20 20 20 20 20 2f 2f 20 64 6f 20 6e 6f 74 68 69 // do nothi
1bc00 6e 67 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ng...
1bc10 20 7d 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 }..#endif....
1bc20 20 20 20 20 20 20 20 20 20 20 41 70 70 65 6e 64 Append
1bc30 45 72 72 6f 72 28 62 75 69 6c 64 65 72 2c 20 22 Error(builder, "
1bc40 66 61 69 6c 65 64 20 74 6f 20 75 6e 73 65 74 20 failed to unset
1bc50 75 70 64 61 74 65 20 68 6f 6f 6b 22 29 3b 0d 0a update hook");..
1bc60 20 20 20 20 20 20 20 20 20 20 20 20 72 63 20 3d rc =
1bc70 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
1bc80 2e 45 72 72 6f 72 3b 0d 0a 0d 0a 20 20 20 20 20 .Error;....
1bc90 20 20 20 20 20 20 20 72 65 73 75 6c 74 20 3d 20 result =
1bca0 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 20 20 false;..
1bcb0 7d 0d 0a 20 20 20 20 20 20 20 20 23 65 6e 64 72 }.. #endr
1bcc0 65 67 69 6f 6e 0d 0a 0d 0a 20 20 20 20 20 20 20 egion....
1bcd0 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ///////////////
1bce0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1bcf0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1bd00 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1bd10 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1bd20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a ////////////....
1bd30 20 20 20 20 20 20 20 20 23 72 65 67 69 6f 6e 20 #region
1bd40 41 75 74 68 6f 72 69 7a 65 72 20 48 6f 6f 6b 20 Authorizer Hook
1bd50 28 50 65 72 2d 43 6f 6e 6e 65 63 74 69 6f 6e 29 (Per-Connection)
1bd60 0d 0a 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 .. try..
1bd70 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
1bd80 20 20 20 20 20 20 53 65 74 41 75 74 68 6f 72 69 SetAuthori
1bd90 7a 65 72 48 6f 6f 6b 28 6e 75 6c 6c 29 3b 20 2f zerHook(null); /
1bda0 2a 20 74 68 72 6f 77 20 2a 2f 0d 0a 20 20 20 20 * throw */..
1bdb0 20 20 20 20 7d 0d 0a 23 69 66 20 21 4e 45 54 5f }..#if !NET_
1bdc0 43 4f 4d 50 41 43 54 5f 32 30 20 26 26 20 54 52 COMPACT_20 && TR
1bdd0 41 43 45 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a ACE_CONNECTION..
1bde0 20 20 20 20 20 20 20 20 63 61 74 63 68 20 28 45 catch (E
1bdf0 78 63 65 70 74 69 6f 6e 20 65 29 0d 0a 23 65 6c xception e)..#el
1be00 73 65 0d 0a 20 20 20 20 20 20 20 20 63 61 74 63 se.. catc
1be10 68 20 28 45 78 63 65 70 74 69 6f 6e 29 0d 0a 23 h (Exception)..#
1be20 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 7b endif.. {
1be30 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 ..#if !NET_COMPA
1be40 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f 43 CT_20 && TRACE_C
1be50 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 20 ONNECTION..
1be60 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 20 try..
1be70 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
1be80 20 20 20 20 20 20 20 20 20 20 20 54 72 61 63 65 Trace
1be90 2e 57 72 69 74 65 4c 69 6e 65 28 48 65 6c 70 65 .WriteLine(Helpe
1bea0 72 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 rMethods.StringF
1beb0 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 ormat(..
1bec0 20 20 20 20 20 20 20 20 20 20 20 20 43 75 6c 74 Cult
1bed0 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 ureInfo.CurrentC
1bee0 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 ulture,..
1bef0 20 20 20 20 20 20 20 20 20 20 20 20 20 22 46 61 "Fa
1bf00 69 6c 65 64 20 74 6f 20 75 6e 73 65 74 20 61 75 iled to unset au
1bf10 74 68 6f 72 69 7a 65 72 20 68 6f 6f 6b 3a 20 7b thorizer hook: {
1bf20 30 7d 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 0}",..
1bf30 20 20 20 20 20 20 20 20 20 20 65 29 29 3b 20 2f e)); /
1bf40 2a 20 74 68 72 6f 77 20 2a 2f 0d 0a 20 20 20 20 * throw */..
1bf50 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 }..
1bf60 20 20 20 20 20 20 20 63 61 74 63 68 0d 0a 20 20 catch..
1bf70 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 {..
1bf80 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 //
1bf90 64 6f 20 6e 6f 74 68 69 6e 67 2e 0d 0a 20 20 20 do nothing...
1bfa0 20 20 20 20 20 20 20 20 20 7d 0d 0a 23 65 6e 64 }..#end
1bfb0 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 if....
1bfc0 20 20 41 70 70 65 6e 64 45 72 72 6f 72 28 62 75 AppendError(bu
1bfd0 69 6c 64 65 72 2c 20 22 66 61 69 6c 65 64 20 74 ilder, "failed t
1bfe0 6f 20 75 6e 73 65 74 20 61 75 74 68 6f 72 69 7a o unset authoriz
1bff0 65 72 20 68 6f 6f 6b 22 29 3b 0d 0a 20 20 20 20 er hook");..
1c000 20 20 20 20 20 20 20 20 72 63 20 3d 20 53 51 4c rc = SQL
1c010 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 45 72 72 iteErrorCode.Err
1c020 6f 72 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 or;....
1c030 20 20 20 72 65 73 75 6c 74 20 3d 20 66 61 6c 73 result = fals
1c040 65 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 e;.. }..
1c050 20 20 20 20 20 20 20 23 65 6e 64 72 65 67 69 6f #endregio
1c060 6e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f n.... ///
1c070 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1c080 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1c090 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1c0a0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1c0b0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1c0c0 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 ////////....
1c0d0 20 20 20 20 23 72 65 67 69 6f 6e 20 50 72 6f 67 #region Prog
1c0e0 72 65 73 73 20 48 6f 6f 6b 20 28 50 65 72 2d 43 ress Hook (Per-C
1c0f0 6f 6e 6e 65 63 74 69 6f 6e 29 0d 0a 20 20 20 20 onnection)..
1c100 20 20 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 try..
1c110 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
1c120 53 65 74 50 72 6f 67 72 65 73 73 48 6f 6f 6b 28 SetProgressHook(
1c130 30 2c 20 6e 75 6c 6c 29 3b 20 2f 2a 20 74 68 72 0, null); /* thr
1c140 6f 77 20 2a 2f 0d 0a 20 20 20 20 20 20 20 20 7d ow */.. }
1c150 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 ..#if !NET_COMPA
1c160 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f 43 CT_20 && TRACE_C
1c170 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 20 ONNECTION..
1c180 20 20 20 63 61 74 63 68 20 28 45 78 63 65 70 74 catch (Except
1c190 69 6f 6e 20 65 29 0d 0a 23 65 6c 73 65 0d 0a 20 ion e)..#else..
1c1a0 20 20 20 20 20 20 20 63 61 74 63 68 20 28 45 78 catch (Ex
1c1b0 63 65 70 74 69 6f 6e 29 0d 0a 23 65 6e 64 69 66 ception)..#endif
1c1c0 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 23 69 66 .. {..#if
1c1d0 20 21 4e 45 54 5f 43 4f 4d 50 41 43 54 5f 32 30 !NET_COMPACT_20
1c1e0 20 26 26 20 54 52 41 43 45 5f 43 4f 4e 4e 45 43 && TRACE_CONNEC
1c1f0 54 49 4f 4e 0d 0a 20 20 20 20 20 20 20 20 20 20 TION..
1c200 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 20 try..
1c210 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
1c220 20 20 20 20 20 20 54 72 61 63 65 2e 57 72 69 74 Trace.Writ
1c230 65 4c 69 6e 65 28 48 65 6c 70 65 72 4d 65 74 68 eLine(HelperMeth
1c240 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d 61 74 ods.StringFormat
1c250 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 (..
1c260 20 20 20 20 20 20 20 43 75 6c 74 75 72 65 49 6e CultureIn
1c270 66 6f 2e 43 75 72 72 65 6e 74 43 75 6c 74 75 72 fo.CurrentCultur
1c280 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 e,..
1c290 20 20 20 20 20 20 20 20 22 46 61 69 6c 65 64 20 "Failed
1c2a0 74 6f 20 75 6e 73 65 74 20 70 72 6f 67 72 65 73 to unset progres
1c2b0 73 20 68 6f 6f 6b 3a 20 7b 30 7d 22 2c 0d 0a 20 s hook: {0}",..
1c2c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1c2d0 20 20 20 65 29 29 3b 20 2f 2a 20 74 68 72 6f 77 e)); /* throw
1c2e0 20 2a 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 */..
1c2f0 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 }..
1c300 63 61 74 63 68 0d 0a 20 20 20 20 20 20 20 20 20 catch..
1c310 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
1c320 20 20 20 20 20 20 2f 2f 20 64 6f 20 6e 6f 74 68 // do noth
1c330 69 6e 67 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 ing...
1c340 20 20 7d 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 20 }..#endif....
1c350 20 20 20 20 20 20 20 20 20 20 20 41 70 70 65 6e Appen
1c360 64 45 72 72 6f 72 28 62 75 69 6c 64 65 72 2c 20 dError(builder,
1c370 22 66 61 69 6c 65 64 20 74 6f 20 75 6e 73 65 74 "failed to unset
1c380 20 70 72 6f 67 72 65 73 73 20 68 6f 6f 6b 22 29 progress hook")
1c390 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 ;.. r
1c3a0 63 20 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 c = SQLiteErrorC
1c3b0 6f 64 65 2e 45 72 72 6f 72 3b 0d 0a 0d 0a 20 20 ode.Error;....
1c3c0 20 20 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 result
1c3d0 20 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 = false;..
1c3e0 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 23 65 }.. #e
1c3f0 6e 64 72 65 67 69 6f 6e 0d 0a 0d 0a 20 20 20 20 ndregion....
1c400 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////
1c410 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1c420 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1c430 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1c440 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1c450 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d ///////////////.
1c460 0a 0d 0a 20 20 20 20 20 20 20 20 23 72 65 67 69 ... #regi
1c470 6f 6e 20 4c 6f 67 20 43 61 6c 6c 62 61 63 6b 20 on Log Callback
1c480 28 47 6c 6f 62 61 6c 29 0d 0a 20 20 20 20 20 20 (Global)..
1c490 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 2f 2f //.. //
1c4a0 20 4e 4f 54 45 3a 20 57 65 20 68 61 76 65 20 74 NOTE: We have t
1c4b0 6f 20 62 65 20 63 61 72 65 66 75 6c 20 68 65 72 o be careful her
1c4c0 65 20 62 65 63 61 75 73 65 20 74 68 65 20 6c 6f e because the lo
1c4d0 67 20 63 61 6c 6c 62 61 63 6b 0d 0a 20 20 20 20 g callback..
1c4e0 20 20 20 20 2f 2f 20 20 20 20 20 20 20 69 73 20 // is
1c4f0 6e 6f 74 20 70 65 72 2d 63 6f 6e 6e 65 63 74 69 not per-connecti
1c500 6f 6e 20 6f 6e 20 74 68 65 20 6e 61 74 69 76 65 on on the native
1c510 20 73 69 64 65 2e 20 20 49 74 20 73 68 6f 75 6c side. It shoul
1c520 64 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 20 d.. //
1c530 20 20 20 20 6f 6e 6c 79 20 62 65 20 75 6e 73 65 only be unse
1c540 74 20 62 79 20 74 68 69 73 20 6d 65 74 68 6f 64 t by this method
1c550 20 69 66 20 74 68 69 73 20 69 6e 73 74 61 6e 63 if this instanc
1c560 65 20 77 61 73 0d 0a 20 20 20 20 20 20 20 20 2f e was.. /
1c570 2f 20 20 20 20 20 20 20 72 65 73 70 6f 6e 73 69 / responsi
1c580 62 6c 65 20 66 6f 72 20 73 65 74 74 69 6e 67 20 ble for setting
1c590 69 74 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 0d it... //.
1c5a0 0a 20 20 20 20 20 20 20 20 69 66 20 28 69 6e 63 . if (inc
1c5b0 6c 75 64 65 47 6c 6f 62 61 6c 20 26 26 20 5f 73 ludeGlobal && _s
1c5c0 65 74 4c 6f 67 43 61 6c 6c 62 61 63 6b 29 0d 0a etLogCallback)..
1c5d0 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
1c5e0 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 20 try..
1c5f0 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
1c600 20 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 SQLit
1c610 65 45 72 72 6f 72 43 6f 64 65 20 72 63 32 20 3d eErrorCode rc2 =
1c620 20 53 65 74 4c 6f 67 43 61 6c 6c 62 61 63 6b 28 SetLogCallback(
1c630 6e 75 6c 6c 29 3b 20 2f 2a 20 74 68 72 6f 77 20 null); /* throw
1c640 2a 2f 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 */....
1c650 20 20 20 20 20 20 69 66 20 28 72 63 32 20 21 3d if (rc2 !=
1c660 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
1c670 2e 4f 6b 29 0d 0a 20 20 20 20 20 20 20 20 20 20 .Ok)..
1c680 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
1c690 20 20 20 20 20 20 20 20 20 20 20 20 20 41 70 70 App
1c6a0 65 6e 64 45 72 72 6f 72 28 62 75 69 6c 64 65 72 endError(builder
1c6b0 2c 20 22 63 6f 75 6c 64 20 6e 6f 74 20 75 6e 73 , "could not uns
1c6c0 65 74 20 6c 6f 67 20 63 61 6c 6c 62 61 63 6b 22 et log callback"
1c6d0 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 );..
1c6e0 20 20 20 20 20 20 20 20 72 63 20 3d 20 72 63 32 rc = rc2
1c6f0 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ;....
1c700 20 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 20 result
1c710 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 = false;..
1c720 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 }..
1c730 20 20 20 20 20 20 20 20 20 7d 0d 0a 23 69 66 20 }..#if
1c740 21 4e 45 54 5f 43 4f 4d 50 41 43 54 5f 32 30 20 !NET_COMPACT_20
1c750 26 26 20 54 52 41 43 45 5f 43 4f 4e 4e 45 43 54 && TRACE_CONNECT
1c760 49 4f 4e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ION..
1c770 20 63 61 74 63 68 20 28 45 78 63 65 70 74 69 6f catch (Exceptio
1c780 6e 20 65 29 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 n e)..#else..
1c790 20 20 20 20 20 20 20 20 20 63 61 74 63 68 20 28 catch (
1c7a0 45 78 63 65 70 74 69 6f 6e 29 0d 0a 23 65 6e 64 Exception)..#end
1c7b0 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 if..
1c7c0 7b 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 {..#if !NET_COMP
1c7d0 41 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f ACT_20 && TRACE_
1c7e0 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 CONNECTION..
1c7f0 20 20 20 20 20 20 20 20 20 20 20 20 74 72 79 0d try.
1c800 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
1c810 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..
1c820 20 20 20 20 20 20 20 20 54 72 61 63 65 2e 57 72 Trace.Wr
1c830 69 74 65 4c 69 6e 65 28 48 65 6c 70 65 72 4d 65 iteLine(HelperMe
1c840 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 6f 72 6d thods.StringForm
1c850 61 74 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 at(..
1c860 20 20 20 20 20 20 20 20 20 20 20 20 20 43 75 6c Cul
1c870 74 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 tureInfo.Current
1c880 43 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 Culture,..
1c890 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1c8a0 20 20 22 46 61 69 6c 65 64 20 74 6f 20 75 6e 73 "Failed to uns
1c8b0 65 74 20 6c 6f 67 20 63 61 6c 6c 62 61 63 6b 3a et log callback:
1c8c0 20 7b 30 7d 22 2c 0d 0a 20 20 20 20 20 20 20 20 {0}",..
1c8d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1c8e0 65 29 29 3b 20 2f 2a 20 74 68 72 6f 77 20 2a 2f e)); /* throw */
1c8f0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..
1c900 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 }..
1c910 20 20 20 20 20 63 61 74 63 68 0d 0a 20 20 20 20 catch..
1c920 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 {..
1c930 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1c940 20 20 20 2f 2f 20 64 6f 20 6e 6f 74 68 69 6e 67 // do nothing
1c950 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ...
1c960 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a }..#endif....
1c970 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1c980 41 70 70 65 6e 64 45 72 72 6f 72 28 62 75 69 6c AppendError(buil
1c990 64 65 72 2c 20 22 66 61 69 6c 65 64 20 74 6f 20 der, "failed to
1c9a0 75 6e 73 65 74 20 6c 6f 67 20 63 61 6c 6c 62 61 unset log callba
1c9b0 63 6b 22 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 ck");..
1c9c0 20 20 20 20 20 20 20 72 63 20 3d 20 53 51 4c 69 rc = SQLi
1c9d0 74 65 45 72 72 6f 72 43 6f 64 65 2e 45 72 72 6f teErrorCode.Erro
1c9e0 72 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 r;....
1c9f0 20 20 20 20 20 20 72 65 73 75 6c 74 20 3d 20 66 result = f
1ca00 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 alse;..
1ca10 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d }.. }.
1ca20 0a 20 20 20 20 20 20 20 20 23 65 6e 64 72 65 67 . #endreg
1ca30 69 6f 6e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f ion.... /
1ca40 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1ca50 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1ca60 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1ca70 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1ca80 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1ca90 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 //////////....
1caa0 20 20 20 20 20 20 69 66 20 28 21 72 65 73 75 6c if (!resul
1cab0 74 20 26 26 20 63 61 6e 54 68 72 6f 77 29 0d 0a t && canThrow)..
1cac0 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f thro
1cad0 77 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 w new SQLiteExce
1cae0 70 74 69 6f 6e 28 72 63 2c 20 62 75 69 6c 64 65 ption(rc, builde
1caf0 72 2e 54 6f 53 74 72 69 6e 67 28 29 29 3b 0d 0a r.ToString());..
1cb00 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e .. return
1cb10 20 72 65 73 75 6c 74 3b 0d 0a 20 20 20 20 7d 0d result;.. }.
1cb20 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f ... /////////
1cb30 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1cb40 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1cb50 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1cb60 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1cb70 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1cb80 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 2f 2f //////.... //
1cb90 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 / <summary>..
1cba0 20 2f 2f 2f 20 54 68 69 73 20 6d 65 74 68 6f 64 /// This method
1cbb0 20 61 74 74 65 6d 70 74 73 20 74 6f 20 66 72 65 attempts to fre
1cbc0 65 20 74 68 65 20 63 61 63 68 65 64 20 64 61 74 e the cached dat
1cbd0 61 62 61 73 65 20 6e 61 6d 65 20 75 73 65 64 20 abase name used
1cbe0 77 69 74 68 20 74 68 65 0d 0a 20 20 20 20 2f 2f with the.. //
1cbf0 2f 20 3c 73 65 65 20 63 72 65 66 3d 22 53 65 74 / <see cref="Set
1cc00 43 6f 6e 66 69 67 75 72 61 74 69 6f 6e 4f 70 74 ConfigurationOpt
1cc10 69 6f 6e 22 20 2f 3e 20 6d 65 74 68 6f 64 2e 0d ion" /> method..
1cc20 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 . /// </summa
1cc30 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 ry>.. /// <pa
1cc40 72 61 6d 20 6e 61 6d 65 3d 22 63 61 6e 54 68 72 ram name="canThr
1cc50 6f 77 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 4e 6f ow">.. /// No
1cc60 6e 2d 7a 65 72 6f 20 69 66 20 74 68 69 73 20 6d n-zero if this m
1cc70 65 74 68 6f 64 20 69 73 20 62 65 69 6e 67 20 65 ethod is being e
1cc80 78 65 63 75 74 65 64 20 77 69 74 68 69 6e 20 61 xecuted within a
1cc90 20 63 6f 6e 74 65 78 74 20 77 68 65 72 65 20 69 context where i
1cca0 74 20 63 61 6e 0d 0a 20 20 20 20 2f 2f 2f 20 74 t can.. /// t
1ccb0 68 72 6f 77 20 61 6e 20 65 78 63 65 70 74 69 6f hrow an exceptio
1ccc0 6e 20 69 6e 20 74 68 65 20 65 76 65 6e 74 20 6f n in the event o
1ccd0 66 20 66 61 69 6c 75 72 65 3b 20 6f 74 68 65 72 f failure; other
1cce0 77 69 73 65 2c 20 7a 65 72 6f 2e 0d 0a 20 20 20 wise, zero...
1ccf0 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 /// </param>..
1cd00 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e /// <returns>
1cd10 0d 0a 20 20 20 20 2f 2f 2f 20 4e 6f 6e 2d 7a 65 .. /// Non-ze
1cd20 72 6f 20 69 66 20 74 68 69 73 20 6d 65 74 68 6f ro if this metho
1cd30 64 20 77 61 73 20 73 75 63 63 65 73 73 66 75 6c d was successful
1cd40 3b 20 6f 74 68 65 72 77 69 73 65 2c 20 7a 65 72 ; otherwise, zer
1cd50 6f 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 72 65 o... /// </re
1cd60 74 75 72 6e 73 3e 0d 0a 20 20 20 20 70 72 69 76 turns>.. priv
1cd70 61 74 65 20 62 6f 6f 6c 20 46 72 65 65 44 62 4e ate bool FreeDbN
1cd80 61 6d 65 28 0d 0a 20 20 20 20 20 20 20 20 62 6f ame(.. bo
1cd90 6f 6c 20 63 61 6e 54 68 72 6f 77 0d 0a 20 20 20 ol canThrow..
1cda0 20 20 20 20 20 29 0d 0a 20 20 20 20 7b 0d 0a 20 ).. {..
1cdb0 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 20 try..
1cdc0 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 {..
1cdd0 20 20 20 69 66 20 28 64 62 4e 61 6d 65 20 21 3d if (dbName !=
1cde0 20 49 6e 74 50 74 72 2e 5a 65 72 6f 29 0d 0a 20 IntPtr.Zero)..
1cdf0 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 {..
1ce00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 53 51 SQ
1ce10 4c 69 74 65 4d 65 6d 6f 72 79 2e 46 72 65 65 28 LiteMemory.Free(
1ce20 64 62 4e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 dbName);..
1ce30 20 20 20 20 20 20 20 20 20 20 64 62 4e 61 6d 65 dbName
1ce40 20 3d 20 49 6e 74 50 74 72 2e 5a 65 72 6f 3b 0d = IntPtr.Zero;.
1ce50 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a . }..
1ce60 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 .. re
1ce70 74 75 72 6e 20 74 72 75 65 3b 0d 0a 20 20 20 20 turn true;..
1ce80 20 20 20 20 7d 0d 0a 23 69 66 20 21 4e 45 54 5f }..#if !NET_
1ce90 43 4f 4d 50 41 43 54 5f 32 30 20 26 26 20 54 52 COMPACT_20 && TR
1cea0 41 43 45 5f 43 4f 4e 4e 45 43 54 49 4f 4e 0d 0a ACE_CONNECTION..
1ceb0 20 20 20 20 20 20 20 20 63 61 74 63 68 20 28 45 catch (E
1cec0 78 63 65 70 74 69 6f 6e 20 65 29 0d 0a 23 65 6c xception e)..#el
1ced0 73 65 0d 0a 20 20 20 20 20 20 20 20 63 61 74 63 se.. catc
1cee0 68 20 28 45 78 63 65 70 74 69 6f 6e 29 0d 0a 23 h (Exception)..#
1cef0 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 7b endif.. {
1cf00 0d 0a 23 69 66 20 21 4e 45 54 5f 43 4f 4d 50 41 ..#if !NET_COMPA
1cf10 43 54 5f 32 30 20 26 26 20 54 52 41 43 45 5f 43 CT_20 && TRACE_C
1cf20 4f 4e 4e 45 43 54 49 4f 4e 0d 0a 20 20 20 20 20 ONNECTION..
1cf30 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 20 try..
1cf40 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 {..
1cf50 20 20 20 20 20 20 20 20 20 20 20 54 72 61 63 65 Trace
1cf60 2e 57 72 69 74 65 4c 69 6e 65 28 48 65 6c 70 65 .WriteLine(Helpe
1cf70 72 4d 65 74 68 6f 64 73 2e 53 74 72 69 6e 67 46 rMethods.StringF
1cf80 6f 72 6d 61 74 28 0d 0a 20 20 20 20 20 20 20 20 ormat(..
1cf90 20 20 20 20 20 20 20 20 20 20 20 20 43 75 6c 74 Cult
1cfa0 75 72 65 49 6e 66 6f 2e 43 75 72 72 65 6e 74 43 ureInfo.CurrentC
1cfb0 75 6c 74 75 72 65 2c 0d 0a 20 20 20 20 20 20 20 ulture,..
1cfc0 20 20 20 20 20 20 20 20 20 20 20 20 20 22 46 61 "Fa
1cfd0 69 6c 65 64 20 74 6f 20 66 72 65 65 20 64 61 74 iled to free dat
1cfe0 61 62 61 73 65 20 6e 61 6d 65 3a 20 7b 30 7d 22 abase name: {0}"
1cff0 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ,..
1d000 20 20 20 20 20 20 20 65 29 29 3b 20 2f 2a 20 74 e)); /* t
1d010 68 72 6f 77 20 2a 2f 0d 0a 20 20 20 20 20 20 20 hrow */..
1d020 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
1d030 20 20 20 20 63 61 74 63 68 0d 0a 20 20 20 20 20 catch..
1d040 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
1d050 20 20 20 20 20 20 20 20 20 20 2f 2f 20 64 6f 20 // do
1d060 6e 6f 74 68 69 6e 67 2e 0d 0a 20 20 20 20 20 20 nothing...
1d070 20 20 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d }..#endif.
1d080 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 ... i
1d090 66 20 28 63 61 6e 54 68 72 6f 77 29 0d 0a 20 20 f (canThrow)..
1d0a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 th
1d0b0 72 6f 77 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d row;.. }.
1d0c0 0a 0d 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 ... retur
1d0d0 6e 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 7d 0d n false;.. }.
1d0e0 0a 0d 0a 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f ... /////////
1d0f0 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1d100 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1d110 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1d120 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1d130 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1d140 2f 2f 2f 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 2f 2f //////.... //
1d150 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 / <summary>..
1d160 20 2f 2f 2f 20 43 72 65 61 74 65 73 20 61 20 6e /// Creates a n
1d170 65 77 20 53 51 4c 69 74 65 20 62 61 63 6b 75 70 ew SQLite backup
1d180 20 6f 62 6a 65 63 74 20 62 61 73 65 64 20 6f 6e object based on
1d190 20 74 68 65 20 70 72 6f 76 69 64 65 64 20 64 65 the provided de
1d1a0 73 74 69 6e 61 74 69 6f 6e 0d 0a 20 20 20 20 2f stination.. /
1d1b0 2f 2f 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e // database conn
1d1c0 65 63 74 69 6f 6e 2e 20 20 54 68 65 20 73 6f 75 ection. The sou
1d1d0 72 63 65 20 64 61 74 61 62 61 73 65 20 63 6f 6e rce database con
1d1e0 6e 65 63 74 69 6f 6e 20 69 73 20 74 68 65 20 6f nection is the o
1d1f0 6e 65 0d 0a 20 20 20 20 2f 2f 2f 20 61 73 73 6f ne.. /// asso
1d200 63 69 61 74 65 64 20 77 69 74 68 20 74 68 69 73 ciated with this
1d210 20 6f 62 6a 65 63 74 2e 20 20 54 68 65 20 73 6f object. The so
1d220 75 72 63 65 20 61 6e 64 20 64 65 73 74 69 6e 61 urce and destina
1d230 74 69 6f 6e 20 64 61 74 61 62 61 73 65 0d 0a 20 tion database..
1d240 20 20 20 2f 2f 2f 20 63 6f 6e 6e 65 63 74 69 6f /// connectio
1d250 6e 73 20 63 61 6e 6e 6f 74 20 62 65 20 74 68 65 ns cannot be the
1d260 20 73 61 6d 65 2e 0d 0a 20 20 20 20 2f 2f 2f 20 same... ///
1d270 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 </summary>..
1d280 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d /// <param name=
1d290 22 64 65 73 74 43 6e 6e 22 3e 54 68 65 20 64 65 "destCnn">The de
1d2a0 73 74 69 6e 61 74 69 6f 6e 20 64 61 74 61 62 61 stination databa
1d2b0 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 2e 3c 2f se connection.</
1d2c0 70 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 param>.. ///
1d2d0 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 64 65 73 <param name="des
1d2e0 74 4e 61 6d 65 22 3e 54 68 65 20 64 65 73 74 69 tName">The desti
1d2f0 6e 61 74 69 6f 6e 20 64 61 74 61 62 61 73 65 20 nation database
1d300 6e 61 6d 65 2e 3c 2f 70 61 72 61 6d 3e 0d 0a 20 name.</param>..
1d310 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 /// <param na
1d320 6d 65 3d 22 73 6f 75 72 63 65 4e 61 6d 65 22 3e me="sourceName">
1d330 54 68 65 20 73 6f 75 72 63 65 20 64 61 74 61 62 The source datab
1d340 61 73 65 20 6e 61 6d 65 2e 3c 2f 70 61 72 61 6d ase name.</param
1d350 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 >.. /// <retu
1d360 72 6e 73 3e 54 68 65 20 6e 65 77 6c 79 20 63 72 rns>The newly cr
1d370 65 61 74 65 64 20 62 61 63 6b 75 70 20 6f 62 6a eated backup obj
1d380 65 63 74 2e 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a ect.</returns>..
1d390 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 internal ove
1d3a0 72 72 69 64 65 20 53 51 4c 69 74 65 42 61 63 6b rride SQLiteBack
1d3b0 75 70 20 49 6e 69 74 69 61 6c 69 7a 65 42 61 63 up InitializeBac
1d3c0 6b 75 70 28 0d 0a 20 20 20 20 20 20 20 20 53 51 kup(.. SQ
1d3d0 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 20 64 LiteConnection d
1d3e0 65 73 74 43 6e 6e 2c 0d 0a 20 20 20 20 20 20 20 estCnn,..
1d3f0 20 73 74 72 69 6e 67 20 64 65 73 74 4e 61 6d 65 string destName
1d400 2c 0d 0a 20 20 20 20 20 20 20 20 73 74 72 69 6e ,.. strin
1d410 67 20 73 6f 75 72 63 65 4e 61 6d 65 0d 0a 20 20 g sourceName..
1d420 20 20 20 20 20 20 29 0d 0a 20 20 20 20 7b 0d 0a ).. {..
1d430 20 20 20 20 20 20 20 20 69 66 20 28 64 65 73 74 if (dest
1d440 43 6e 6e 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 Cnn == null)..
1d450 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 throw
1d460 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c new ArgumentNull
1d470 45 78 63 65 70 74 69 6f 6e 28 22 64 65 73 74 43 Exception("destC
1d480 6e 6e 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 nn");....
1d490 20 69 66 20 28 64 65 73 74 4e 61 6d 65 20 3d 3d if (destName ==
1d4a0 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 null)..
1d4b0 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 throw new Ar
1d4c0 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 gumentNullExcept
1d4d0 69 6f 6e 28 22 64 65 73 74 4e 61 6d 65 22 29 3b ion("destName");
1d4e0 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 .... if (
1d4f0 73 6f 75 72 63 65 4e 61 6d 65 20 3d 3d 20 6e 75 sourceName == nu
1d500 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ll)..
1d510 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d throw new Argum
1d520 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e entNullException
1d530 28 22 73 6f 75 72 63 65 4e 61 6d 65 22 29 3b 0d ("sourceName");.
1d540 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 ... SQLit
1d550 65 33 20 64 65 73 74 53 71 6c 69 74 65 33 20 3d e3 destSqlite3 =
1d560 20 64 65 73 74 43 6e 6e 2e 5f 73 71 6c 20 61 73 destCnn._sql as
1d570 20 53 51 4c 69 74 65 33 3b 0d 0a 0d 0a 20 20 20 SQLite3;....
1d580 20 20 20 20 20 69 66 20 28 64 65 73 74 53 71 6c if (destSql
1d590 69 74 65 33 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 ite3 == null)..
1d5a0 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 throw
1d5b0 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 45 78 63 new ArgumentExc
1d5c0 65 70 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 eption(..
1d5d0 20 20 20 20 20 20 20 20 20 22 44 65 73 74 69 6e "Destin
1d5e0 61 74 69 6f 6e 20 63 6f 6e 6e 65 63 74 69 6f 6e ation connection
1d5f0 20 68 61 73 20 6e 6f 20 77 72 61 70 70 65 72 2e has no wrapper.
1d600 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ",..
1d610 20 20 20 20 22 64 65 73 74 43 6e 6e 22 29 3b 0d "destCnn");.
1d620 0a 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 ... SQLit
1d630 65 43 6f 6e 6e 65 63 74 69 6f 6e 48 61 6e 64 6c eConnectionHandl
1d640 65 20 64 65 73 74 48 61 6e 64 6c 65 20 3d 20 64 e destHandle = d
1d650 65 73 74 53 71 6c 69 74 65 33 2e 5f 73 71 6c 3b estSqlite3._sql;
1d660 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 28 .... if (
1d670 64 65 73 74 48 61 6e 64 6c 65 20 3d 3d 20 6e 75 destHandle == nu
1d680 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ll)..
1d690 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d throw new Argum
1d6a0 65 6e 74 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 entException(..
1d6b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 "
1d6c0 44 65 73 74 69 6e 61 74 69 6f 6e 20 63 6f 6e 6e Destination conn
1d6d0 65 63 74 69 6f 6e 20 68 61 73 20 61 6e 20 69 6e ection has an in
1d6e0 76 61 6c 69 64 20 68 61 6e 64 6c 65 2e 22 2c 0d valid handle.",.
1d6f0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
1d700 20 22 64 65 73 74 43 6e 6e 22 29 3b 0d 0a 0d 0a "destCnn");....
1d710 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 43 6f SQLiteCo
1d720 6e 6e 65 63 74 69 6f 6e 48 61 6e 64 6c 65 20 73 nnectionHandle s
1d730 6f 75 72 63 65 48 61 6e 64 6c 65 20 3d 20 5f 73 ourceHandle = _s
1d740 71 6c 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 ql;.... i
1d750 66 20 28 73 6f 75 72 63 65 48 61 6e 64 6c 65 20 f (sourceHandle
1d760 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 == null)..
1d770 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 throw new
1d780 49 6e 76 61 6c 69 64 4f 70 65 72 61 74 69 6f 6e InvalidOperation
1d790 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 20 20 20 Exception(..
1d7a0 20 20 20 20 20 20 20 20 20 20 20 20 22 53 6f 75 "Sou
1d7b0 72 63 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 68 rce connection h
1d7c0 61 73 20 61 6e 20 69 6e 76 61 6c 69 64 20 68 61 as an invalid ha
1d7d0 6e 64 6c 65 2e 22 29 3b 0d 0a 0d 0a 20 20 20 20 ndle.");....
1d7e0 20 20 20 20 62 79 74 65 5b 5d 20 7a 44 65 73 74 byte[] zDest
1d7f0 4e 61 6d 65 20 3d 20 54 6f 55 54 46 38 28 64 65 Name = ToUTF8(de
1d800 73 74 4e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 stName);..
1d810 20 20 62 79 74 65 5b 5d 20 7a 53 6f 75 72 63 65 byte[] zSource
1d820 4e 61 6d 65 20 3d 20 54 6f 55 54 46 38 28 73 6f Name = ToUTF8(so
1d830 75 72 63 65 4e 61 6d 65 29 3b 0d 0a 0d 0a 20 20 urceName);....
1d840 20 20 20 20 20 20 53 51 4c 69 74 65 42 61 63 6b SQLiteBack
1d850 75 70 48 61 6e 64 6c 65 20 62 61 63 6b 75 70 48 upHandle backupH
1d860 61 6e 64 6c 65 20 3d 20 6e 75 6c 6c 3b 0d 0a 0d andle = null;...
1d870 0a 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 . try..
1d880 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
1d890 20 20 20 20 20 2f 2f 20 64 6f 20 6e 6f 74 68 69 // do nothi
1d8a0 6e 67 2e 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a ng... }..
1d8b0 20 20 20 20 20 20 20 20 66 69 6e 61 6c 6c 79 20 finally
1d8c0 2f 2a 20 4e 4f 54 45 3a 20 54 68 72 65 61 64 2e /* NOTE: Thread.
1d8d0 41 62 6f 72 74 28 29 20 70 72 6f 74 65 63 74 69 Abort() protecti
1d8e0 6f 6e 2e 20 2a 2f 0d 0a 20 20 20 20 20 20 20 20 on. */..
1d8f0 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 {.. I
1d900 6e 74 50 74 72 20 62 61 63 6b 75 70 20 3d 20 55 ntPtr backup = U
1d910 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 68 6f nsafeNativeMetho
1d920 64 73 2e 73 71 6c 69 74 65 33 5f 62 61 63 6b 75 ds.sqlite3_backu
1d930 70 5f 69 6e 69 74 28 0d 0a 20 20 20 20 20 20 20 p_init(..
1d940 20 20 20 20 20 20 20 20 20 64 65 73 74 48 61 6e destHan
1d950 64 6c 65 2c 20 7a 44 65 73 74 4e 61 6d 65 2c 20 dle, zDestName,
1d960 73 6f 75 72 63 65 48 61 6e 64 6c 65 2c 20 7a 53 sourceHandle, zS
1d970 6f 75 72 63 65 4e 61 6d 65 29 3b 0d 0a 0d 0a 20 ourceName);....
1d980 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 62 if (b
1d990 61 63 6b 75 70 20 3d 3d 20 49 6e 74 50 74 72 2e ackup == IntPtr.
1d9a0 5a 65 72 6f 29 0d 0a 20 20 20 20 20 20 20 20 20 Zero)..
1d9b0 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 {..
1d9c0 20 20 20 20 20 20 53 51 4c 69 74 65 45 72 72 6f SQLiteErro
1d9d0 72 43 6f 64 65 20 72 65 73 75 6c 74 43 6f 64 65 rCode resultCode
1d9e0 20 3d 20 52 65 73 75 6c 74 43 6f 64 65 28 29 3b = ResultCode();
1d9f0 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ....
1da00 20 20 20 20 69 66 20 28 72 65 73 75 6c 74 43 6f if (resultCo
1da10 64 65 20 21 3d 20 53 51 4c 69 74 65 45 72 72 6f de != SQLiteErro
1da20 72 43 6f 64 65 2e 4f 6b 29 0d 0a 20 20 20 20 20 rCode.Ok)..
1da30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 t
1da40 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 65 45 hrow new SQLiteE
1da50 78 63 65 70 74 69 6f 6e 28 72 65 73 75 6c 74 43 xception(resultC
1da60 6f 64 65 2c 20 47 65 74 4c 61 73 74 45 72 72 6f ode, GetLastErro
1da70 72 28 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 r());..
1da80 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 else..
1da90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1daa0 20 74 68 72 6f 77 20 6e 65 77 20 53 51 4c 69 74 throw new SQLit
1dab0 65 45 78 63 65 70 74 69 6f 6e 28 22 66 61 69 6c eException("fail
1dac0 65 64 20 74 6f 20 69 6e 69 74 69 61 6c 69 7a 65 ed to initialize
1dad0 20 62 61 63 6b 75 70 22 29 3b 0d 0a 20 20 20 20 backup");..
1dae0 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 }....
1daf0 20 20 20 20 20 20 20 20 20 62 61 63 6b 75 70 48 backupH
1db00 61 6e 64 6c 65 20 3d 20 6e 65 77 20 53 51 4c 69 andle = new SQLi
1db10 74 65 42 61 63 6b 75 70 48 61 6e 64 6c 65 28 64 teBackupHandle(d
1db20 65 73 74 48 61 6e 64 6c 65 2c 20 62 61 63 6b 75 estHandle, backu
1db30 70 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a p);.. }..
1db40 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 .. SQLite
1db50 43 6f 6e 6e 65 63 74 69 6f 6e 2e 4f 6e 43 68 61 Connection.OnCha
1db60 6e 67 65 64 28 6e 75 6c 6c 2c 20 6e 65 77 20 43 nged(null, new C
1db70 6f 6e 6e 65 63 74 69 6f 6e 45 76 65 6e 74 41 72 onnectionEventAr
1db80 67 73 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 gs(..
1db90 20 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f SQLiteConnectio
1dba0 6e 45 76 65 6e 74 54 79 70 65 2e 4e 65 77 43 72 nEventType.NewCr
1dbb0 69 74 69 63 61 6c 48 61 6e 64 6c 65 2c 20 6e 75 iticalHandle, nu
1dbc0 6c 6c 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ll,..
1dbd0 20 6e 75 6c 6c 2c 20 6e 75 6c 6c 2c 20 6e 75 6c null, null, nul
1dbe0 6c 2c 20 62 61 63 6b 75 70 48 61 6e 64 6c 65 2c l, backupHandle,
1dbf0 20 6e 75 6c 6c 2c 20 6e 65 77 20 6f 62 6a 65 63 null, new objec
1dc00 74 5b 5d 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 t[] {..
1dc10 20 20 20 74 79 70 65 6f 66 28 53 51 4c 69 74 65 typeof(SQLite
1dc20 33 29 2c 20 64 65 73 74 43 6e 6e 2c 20 64 65 73 3), destCnn, des
1dc30 74 4e 61 6d 65 2c 20 73 6f 75 72 63 65 4e 61 6d tName, sourceNam
1dc40 65 20 7d 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 e }));....
1dc50 20 20 72 65 74 75 72 6e 20 6e 65 77 20 53 51 4c return new SQL
1dc60 69 74 65 42 61 63 6b 75 70 28 0d 0a 20 20 20 20 iteBackup(..
1dc70 20 20 20 20 20 20 20 20 74 68 69 73 2c 20 62 61 this, ba
1dc80 63 6b 75 70 48 61 6e 64 6c 65 2c 20 64 65 73 74 ckupHandle, dest
1dc90 48 61 6e 64 6c 65 2c 20 7a 44 65 73 74 4e 61 6d Handle, zDestNam
1dca0 65 2c 20 73 6f 75 72 63 65 48 61 6e 64 6c 65 2c e, sourceHandle,
1dcb0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7a 53 .. zS
1dcc0 6f 75 72 63 65 4e 61 6d 65 29 3b 0d 0a 20 20 20 ourceName);..
1dcd0 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 }.... /// <s
1dce0 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f ummary>.. ///
1dcf0 20 43 6f 70 69 65 73 20 75 70 20 74 6f 20 4e 20 Copies up to N
1dd00 70 61 67 65 73 20 66 72 6f 6d 20 74 68 65 20 73 pages from the s
1dd10 6f 75 72 63 65 20 64 61 74 61 62 61 73 65 20 74 ource database t
1dd20 6f 20 74 68 65 20 64 65 73 74 69 6e 61 74 69 6f o the destinatio
1dd30 6e 0d 0a 20 20 20 20 2f 2f 2f 20 64 61 74 61 62 n.. /// datab
1dd40 61 73 65 20 61 73 73 6f 63 69 61 74 65 64 20 77 ase associated w
1dd50 69 74 68 20 74 68 65 20 73 70 65 63 69 66 69 65 ith the specifie
1dd60 64 20 62 61 63 6b 75 70 20 6f 62 6a 65 63 74 2e d backup object.
1dd70 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d .. /// </summ
1dd80 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 ary>.. /// <p
1dd90 61 72 61 6d 20 6e 61 6d 65 3d 22 62 61 63 6b 75 aram name="backu
1dda0 70 22 3e 54 68 65 20 62 61 63 6b 75 70 20 6f 62 p">The backup ob
1ddb0 6a 65 63 74 20 74 6f 20 75 73 65 2e 3c 2f 70 61 ject to use.</pa
1ddc0 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 ram>.. /// <p
1ddd0 61 72 61 6d 20 6e 61 6d 65 3d 22 6e 50 61 67 65 aram name="nPage
1dde0 22 3e 0d 0a 20 20 20 20 2f 2f 2f 20 54 68 65 20 ">.. /// The
1ddf0 6e 75 6d 62 65 72 20 6f 66 20 70 61 67 65 73 20 number of pages
1de00 74 6f 20 63 6f 70 79 2c 20 6e 65 67 61 74 69 76 to copy, negativ
1de10 65 20 74 6f 20 63 6f 70 79 20 61 6c 6c 20 72 65 e to copy all re
1de20 6d 61 69 6e 69 6e 67 20 70 61 67 65 73 2e 0d 0a maining pages...
1de30 20 20 20 20 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e /// </param>
1de40 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d .. /// <param
1de50 20 6e 61 6d 65 3d 22 72 65 74 72 79 22 3e 0d 0a name="retry">..
1de60 20 20 20 20 2f 2f 2f 20 53 65 74 20 74 6f 20 74 /// Set to t
1de70 72 75 65 20 69 66 20 74 68 65 20 6f 70 65 72 61 rue if the opera
1de80 74 69 6f 6e 20 6e 65 65 64 73 20 74 6f 20 62 65 tion needs to be
1de90 20 72 65 74 72 69 65 64 20 64 75 65 20 74 6f 20 retried due to
1dea0 64 61 74 61 62 61 73 65 0d 0a 20 20 20 20 2f 2f database.. //
1deb0 2f 20 6c 6f 63 6b 69 6e 67 20 69 73 73 75 65 73 / locking issues
1dec0 3b 20 6f 74 68 65 72 77 69 73 65 2c 20 73 65 74 ; otherwise, set
1ded0 20 74 6f 20 66 61 6c 73 65 2e 0d 0a 20 20 20 20 to false...
1dee0 2f 2f 2f 20 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 /// </param>..
1def0 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 0d /// <returns>.
1df00 0a 20 20 20 20 2f 2f 2f 20 54 72 75 65 20 69 66 . /// True if
1df10 20 74 68 65 72 65 20 61 72 65 20 6d 6f 72 65 20 there are more
1df20 70 61 67 65 73 20 74 6f 20 62 65 20 63 6f 70 69 pages to be copi
1df30 65 64 2c 20 66 61 6c 73 65 20 6f 74 68 65 72 77 ed, false otherw
1df40 69 73 65 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ise... /// </
1df50 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 69 6e returns>.. in
1df60 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 ternal override
1df70 62 6f 6f 6c 20 53 74 65 70 42 61 63 6b 75 70 28 bool StepBackup(
1df80 0d 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 .. SQLite
1df90 42 61 63 6b 75 70 20 62 61 63 6b 75 70 2c 0d 0a Backup backup,..
1dfa0 20 20 20 20 20 20 20 20 69 6e 74 20 6e 50 61 67 int nPag
1dfb0 65 2c 0d 0a 20 20 20 20 20 20 20 20 72 65 66 20 e,.. ref
1dfc0 62 6f 6f 6c 20 72 65 74 72 79 0d 0a 20 20 20 20 bool retry..
1dfd0 20 20 20 20 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 ).. {..
1dfe0 20 20 20 20 20 20 72 65 74 72 79 20 3d 20 66 61 retry = fa
1dff0 6c 73 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 lse;....
1e000 69 66 20 28 62 61 63 6b 75 70 20 3d 3d 20 6e 75 if (backup == nu
1e010 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ll)..
1e020 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d throw new Argum
1e030 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e entNullException
1e040 28 22 62 61 63 6b 75 70 22 29 3b 0d 0a 0d 0a 20 ("backup");....
1e050 20 20 20 20 20 20 20 53 51 4c 69 74 65 42 61 63 SQLiteBac
1e060 6b 75 70 48 61 6e 64 6c 65 20 68 61 6e 64 6c 65 kupHandle handle
1e070 20 3d 20 62 61 63 6b 75 70 2e 5f 73 71 6c 69 74 = backup._sqlit
1e080 65 5f 62 61 63 6b 75 70 3b 0d 0a 0d 0a 20 20 20 e_backup;....
1e090 20 20 20 20 20 69 66 20 28 68 61 6e 64 6c 65 20 if (handle
1e0a0 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 == null)..
1e0b0 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 throw new
1e0c0 49 6e 76 61 6c 69 64 4f 70 65 72 61 74 69 6f 6e InvalidOperation
1e0d0 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 20 20 20 Exception(..
1e0e0 20 20 20 20 20 20 20 20 20 20 20 20 22 42 61 63 "Bac
1e0f0 6b 75 70 20 6f 62 6a 65 63 74 20 68 61 73 20 61 kup object has a
1e100 6e 20 69 6e 76 61 6c 69 64 20 68 61 6e 64 6c 65 n invalid handle
1e110 2e 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 .");....
1e120 49 6e 74 50 74 72 20 68 61 6e 64 6c 65 50 74 72 IntPtr handlePtr
1e130 20 3d 20 68 61 6e 64 6c 65 3b 0d 0a 0d 0a 20 20 = handle;....
1e140 20 20 20 20 20 20 69 66 20 28 68 61 6e 64 6c 65 if (handle
1e150 50 74 72 20 3d 3d 20 49 6e 74 50 74 72 2e 5a 65 Ptr == IntPtr.Ze
1e160 72 6f 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ro)..
1e170 20 74 68 72 6f 77 20 6e 65 77 20 49 6e 76 61 6c throw new Inval
1e180 69 64 4f 70 65 72 61 74 69 6f 6e 45 78 63 65 70 idOperationExcep
1e190 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 20 20 tion(..
1e1a0 20 20 20 20 20 20 20 22 42 61 63 6b 75 70 20 6f "Backup o
1e1b0 62 6a 65 63 74 20 68 61 73 20 61 6e 20 69 6e 76 bject has an inv
1e1c0 61 6c 69 64 20 68 61 6e 64 6c 65 20 70 6f 69 6e alid handle poin
1e1d0 74 65 72 2e 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 ter.");....
1e1e0 20 20 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f SQLiteErrorCo
1e1f0 64 65 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 de n = UnsafeNat
1e200 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 iveMethods.sqlit
1e210 65 33 5f 62 61 63 6b 75 70 5f 73 74 65 70 28 68 e3_backup_step(h
1e220 61 6e 64 6c 65 50 74 72 2c 20 6e 50 61 67 65 29 andlePtr, nPage)
1e230 3b 0d 0a 20 20 20 20 20 20 20 20 62 61 63 6b 75 ;.. backu
1e240 70 2e 5f 73 74 65 70 52 65 73 75 6c 74 20 3d 20 p._stepResult =
1e250 6e 3b 20 2f 2a 20 4e 4f 54 45 3a 20 53 61 76 65 n; /* NOTE: Save
1e260 20 66 6f 72 20 75 73 65 20 62 79 20 46 69 6e 69 for use by Fini
1e270 73 68 42 61 63 6b 75 70 2e 20 2a 2f 0d 0a 0d 0a shBackup. */....
1e280 20 20 20 20 20 20 20 20 69 66 20 28 6e 20 3d 3d if (n ==
1e290 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
1e2a0 2e 4f 6b 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d .Ok).. {.
1e2b0 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 . ret
1e2c0 75 72 6e 20 74 72 75 65 3b 0d 0a 20 20 20 20 20 urn true;..
1e2d0 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 65 6c }.. el
1e2e0 73 65 20 69 66 20 28 6e 20 3d 3d 20 53 51 4c 69 se if (n == SQLi
1e2f0 74 65 45 72 72 6f 72 43 6f 64 65 2e 42 75 73 79 teErrorCode.Busy
1e300 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 ).. {..
1e310 20 20 20 20 20 20 20 20 20 20 72 65 74 72 79 20 retry
1e320 3d 20 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 = true;..
1e330 20 20 20 20 20 72 65 74 75 72 6e 20 74 72 75 65 return true
1e340 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 ;.. }..
1e350 20 20 20 20 20 20 65 6c 73 65 20 69 66 20 28 6e else if (n
1e360 20 3d 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 == SQLiteErrorC
1e370 6f 64 65 2e 4c 6f 63 6b 65 64 29 0d 0a 20 20 20 ode.Locked)..
1e380 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 {..
1e390 20 20 20 20 72 65 74 72 79 20 3d 20 74 72 75 65 retry = true
1e3a0 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 ;.. r
1e3b0 65 74 75 72 6e 20 74 72 75 65 3b 0d 0a 20 20 20 eturn true;..
1e3c0 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 }..
1e3d0 65 6c 73 65 20 69 66 20 28 6e 20 3d 3d 20 53 51 else if (n == SQ
1e3e0 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 44 6f LiteErrorCode.Do
1e3f0 6e 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a ne).. {..
1e400 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 retu
1e410 72 6e 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 rn false;..
1e420 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 65 6c }.. el
1e430 73 65 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 se.. {..
1e440 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 throw
1e450 20 6e 65 77 20 53 51 4c 69 74 65 45 78 63 65 70 new SQLiteExcep
1e460 74 69 6f 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 tion(n, GetLastE
1e470 72 72 6f 72 28 29 29 3b 0d 0a 20 20 20 20 20 20 rror());..
1e480 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 }.. }....
1e490 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d /// <summary>.
1e4a0 0a 20 20 20 20 2f 2f 2f 20 52 65 74 75 72 6e 73 . /// Returns
1e4b0 20 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 70 the number of p
1e4c0 61 67 65 73 20 72 65 6d 61 69 6e 69 6e 67 20 74 ages remaining t
1e4d0 6f 20 62 65 20 63 6f 70 69 65 64 20 66 72 6f 6d o be copied from
1e4e0 20 74 68 65 20 73 6f 75 72 63 65 0d 0a 20 20 20 the source..
1e4f0 20 2f 2f 2f 20 64 61 74 61 62 61 73 65 20 74 6f /// database to
1e500 20 74 68 65 20 64 65 73 74 69 6e 61 74 69 6f 6e the destination
1e510 20 64 61 74 61 62 61 73 65 20 61 73 73 6f 63 69 database associ
1e520 61 74 65 64 20 77 69 74 68 20 74 68 65 20 73 70 ated with the sp
1e530 65 63 69 66 69 65 64 0d 0a 20 20 20 20 2f 2f 2f ecified.. ///
1e540 20 62 61 63 6b 75 70 20 6f 62 6a 65 63 74 2e 0d backup object..
1e550 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 . /// </summa
1e560 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 ry>.. /// <pa
1e570 72 61 6d 20 6e 61 6d 65 3d 22 62 61 63 6b 75 70 ram name="backup
1e580 22 3e 54 68 65 20 62 61 63 6b 75 70 20 6f 62 6a ">The backup obj
1e590 65 63 74 20 74 6f 20 63 68 65 63 6b 2e 3c 2f 70 ect to check.</p
1e5a0 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c aram>.. /// <
1e5b0 72 65 74 75 72 6e 73 3e 54 68 65 20 6e 75 6d 62 returns>The numb
1e5c0 65 72 20 6f 66 20 70 61 67 65 73 20 72 65 6d 61 er of pages rema
1e5d0 69 6e 69 6e 67 20 74 6f 20 62 65 20 63 6f 70 69 ining to be copi
1e5e0 65 64 2e 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 ed.</returns>..
1e5f0 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 internal over
1e600 72 69 64 65 20 69 6e 74 20 52 65 6d 61 69 6e 69 ride int Remaini
1e610 6e 67 42 61 63 6b 75 70 28 0d 0a 20 20 20 20 20 ngBackup(..
1e620 20 20 20 53 51 4c 69 74 65 42 61 63 6b 75 70 20 SQLiteBackup
1e630 62 61 63 6b 75 70 0d 0a 20 20 20 20 20 20 20 20 backup..
1e640 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
1e650 20 20 69 66 20 28 62 61 63 6b 75 70 20 3d 3d 20 if (backup ==
1e660 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 null)..
1e670 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 throw new Arg
1e680 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 umentNullExcepti
1e690 6f 6e 28 22 62 61 63 6b 75 70 22 29 3b 0d 0a 0d on("backup");...
1e6a0 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 42 . SQLiteB
1e6b0 61 63 6b 75 70 48 61 6e 64 6c 65 20 68 61 6e 64 ackupHandle hand
1e6c0 6c 65 20 3d 20 62 61 63 6b 75 70 2e 5f 73 71 6c le = backup._sql
1e6d0 69 74 65 5f 62 61 63 6b 75 70 3b 0d 0a 0d 0a 20 ite_backup;....
1e6e0 20 20 20 20 20 20 20 69 66 20 28 68 61 6e 64 6c if (handl
1e6f0 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 e == null)..
1e700 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 throw ne
1e710 77 20 49 6e 76 61 6c 69 64 4f 70 65 72 61 74 69 w InvalidOperati
1e720 6f 6e 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 20 onException(..
1e730 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 42 "B
1e740 61 63 6b 75 70 20 6f 62 6a 65 63 74 20 68 61 73 ackup object has
1e750 20 61 6e 20 69 6e 76 61 6c 69 64 20 68 61 6e 64 an invalid hand
1e760 6c 65 2e 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 le.");....
1e770 20 20 49 6e 74 50 74 72 20 68 61 6e 64 6c 65 50 IntPtr handleP
1e780 74 72 20 3d 20 68 61 6e 64 6c 65 3b 0d 0a 0d 0a tr = handle;....
1e790 20 20 20 20 20 20 20 20 69 66 20 28 68 61 6e 64 if (hand
1e7a0 6c 65 50 74 72 20 3d 3d 20 49 6e 74 50 74 72 2e lePtr == IntPtr.
1e7b0 5a 65 72 6f 29 0d 0a 20 20 20 20 20 20 20 20 20 Zero)..
1e7c0 20 20 20 74 68 72 6f 77 20 6e 65 77 20 49 6e 76 throw new Inv
1e7d0 61 6c 69 64 4f 70 65 72 61 74 69 6f 6e 45 78 63 alidOperationExc
1e7e0 65 70 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 eption(..
1e7f0 20 20 20 20 20 20 20 20 20 22 42 61 63 6b 75 70 "Backup
1e800 20 6f 62 6a 65 63 74 20 68 61 73 20 61 6e 20 69 object has an i
1e810 6e 76 61 6c 69 64 20 68 61 6e 64 6c 65 20 70 6f nvalid handle po
1e820 69 6e 74 65 72 2e 22 29 3b 0d 0a 0d 0a 20 20 20 inter.");....
1e830 20 20 20 20 20 72 65 74 75 72 6e 20 55 6e 73 61 return Unsa
1e840 66 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e feNativeMethods.
1e850 73 71 6c 69 74 65 33 5f 62 61 63 6b 75 70 5f 72 sqlite3_backup_r
1e860 65 6d 61 69 6e 69 6e 67 28 68 61 6e 64 6c 65 50 emaining(handleP
1e870 74 72 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 tr);.. }....
1e880 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e /// <summary>
1e890 0d 0a 20 20 20 20 2f 2f 2f 20 52 65 74 75 72 6e .. /// Return
1e8a0 73 20 74 68 65 20 74 6f 74 61 6c 20 6e 75 6d 62 s the total numb
1e8b0 65 72 20 6f 66 20 70 61 67 65 73 20 69 6e 20 74 er of pages in t
1e8c0 68 65 20 73 6f 75 72 63 65 20 64 61 74 61 62 61 he source databa
1e8d0 73 65 20 61 73 73 6f 63 69 61 74 65 64 0d 0a 20 se associated..
1e8e0 20 20 20 2f 2f 2f 20 77 69 74 68 20 74 68 65 20 /// with the
1e8f0 73 70 65 63 69 66 69 65 64 20 62 61 63 6b 75 70 specified backup
1e900 20 6f 62 6a 65 63 74 2e 0d 0a 20 20 20 20 2f 2f object... //
1e910 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 / </summary>..
1e920 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d /// <param nam
1e930 65 3d 22 62 61 63 6b 75 70 22 3e 54 68 65 20 62 e="backup">The b
1e940 61 63 6b 75 70 20 6f 62 6a 65 63 74 20 74 6f 20 ackup object to
1e950 63 68 65 63 6b 2e 3c 2f 70 61 72 61 6d 3e 0d 0a check.</param>..
1e960 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 /// <returns
1e970 3e 54 68 65 20 74 6f 74 61 6c 20 6e 75 6d 62 65 >The total numbe
1e980 72 20 6f 66 20 70 61 67 65 73 20 69 6e 20 74 68 r of pages in th
1e990 65 20 73 6f 75 72 63 65 20 64 61 74 61 62 61 73 e source databas
1e9a0 65 2e 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 e.</returns>..
1e9b0 20 20 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 internal overr
1e9c0 69 64 65 20 69 6e 74 20 50 61 67 65 43 6f 75 6e ide int PageCoun
1e9d0 74 42 61 63 6b 75 70 28 0d 0a 20 20 20 20 20 20 tBackup(..
1e9e0 20 20 53 51 4c 69 74 65 42 61 63 6b 75 70 20 62 SQLiteBackup b
1e9f0 61 63 6b 75 70 0d 0a 20 20 20 20 20 20 20 20 29 ackup.. )
1ea00 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .. {..
1ea10 20 69 66 20 28 62 61 63 6b 75 70 20 3d 3d 20 6e if (backup == n
1ea20 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 ull)..
1ea30 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 throw new Argu
1ea40 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f mentNullExceptio
1ea50 6e 28 22 62 61 63 6b 75 70 22 29 3b 0d 0a 0d 0a n("backup");....
1ea60 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 42 61 SQLiteBa
1ea70 63 6b 75 70 48 61 6e 64 6c 65 20 68 61 6e 64 6c ckupHandle handl
1ea80 65 20 3d 20 62 61 63 6b 75 70 2e 5f 73 71 6c 69 e = backup._sqli
1ea90 74 65 5f 62 61 63 6b 75 70 3b 0d 0a 0d 0a 20 20 te_backup;....
1eaa0 20 20 20 20 20 20 69 66 20 28 68 61 6e 64 6c 65 if (handle
1eab0 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 == null)..
1eac0 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 throw new
1ead0 20 49 6e 76 61 6c 69 64 4f 70 65 72 61 74 69 6f InvalidOperatio
1eae0 6e 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 20 20 nException(..
1eaf0 20 20 20 20 20 20 20 20 20 20 20 20 20 22 42 61 "Ba
1eb00 63 6b 75 70 20 6f 62 6a 65 63 74 20 68 61 73 20 ckup object has
1eb10 61 6e 20 69 6e 76 61 6c 69 64 20 68 61 6e 64 6c an invalid handl
1eb20 65 2e 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 e.");....
1eb30 20 49 6e 74 50 74 72 20 68 61 6e 64 6c 65 50 74 IntPtr handlePt
1eb40 72 20 3d 20 68 61 6e 64 6c 65 3b 0d 0a 0d 0a 20 r = handle;....
1eb50 20 20 20 20 20 20 20 69 66 20 28 68 61 6e 64 6c if (handl
1eb60 65 50 74 72 20 3d 3d 20 49 6e 74 50 74 72 2e 5a ePtr == IntPtr.Z
1eb70 65 72 6f 29 0d 0a 20 20 20 20 20 20 20 20 20 20 ero)..
1eb80 20 20 74 68 72 6f 77 20 6e 65 77 20 49 6e 76 61 throw new Inva
1eb90 6c 69 64 4f 70 65 72 61 74 69 6f 6e 45 78 63 65 lidOperationExce
1eba0 70 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 20 ption(..
1ebb0 20 20 20 20 20 20 20 20 22 42 61 63 6b 75 70 20 "Backup
1ebc0 6f 62 6a 65 63 74 20 68 61 73 20 61 6e 20 69 6e object has an in
1ebd0 76 61 6c 69 64 20 68 61 6e 64 6c 65 20 70 6f 69 valid handle poi
1ebe0 6e 74 65 72 2e 22 29 3b 0d 0a 0d 0a 20 20 20 20 nter.");....
1ebf0 20 20 20 20 72 65 74 75 72 6e 20 55 6e 73 61 66 return Unsaf
1ec00 65 4e 61 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 eNativeMethods.s
1ec10 71 6c 69 74 65 33 5f 62 61 63 6b 75 70 5f 70 61 qlite3_backup_pa
1ec20 67 65 63 6f 75 6e 74 28 68 61 6e 64 6c 65 50 74 gecount(handlePt
1ec30 72 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 r);.. }....
1ec40 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d /// <summary>.
1ec50 0a 20 20 20 20 2f 2f 2f 20 44 65 73 74 72 6f 79 . /// Destroy
1ec60 73 20 74 68 65 20 62 61 63 6b 75 70 20 6f 62 6a s the backup obj
1ec70 65 63 74 2c 20 72 6f 6c 6c 69 6e 67 20 62 61 63 ect, rolling bac
1ec80 6b 20 61 6e 79 20 62 61 63 6b 75 70 20 74 68 61 k any backup tha
1ec90 74 20 6d 61 79 20 62 65 20 69 6e 0d 0a 20 20 20 t may be in..
1eca0 20 2f 2f 2f 20 70 72 6f 67 65 73 73 2e 0d 0a 20 /// progess...
1ecb0 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 /// </summary
1ecc0 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 >.. /// <para
1ecd0 6d 20 6e 61 6d 65 3d 22 62 61 63 6b 75 70 22 3e m name="backup">
1ece0 54 68 65 20 62 61 63 6b 75 70 20 6f 62 6a 65 63 The backup objec
1ecf0 74 20 74 6f 20 64 65 73 74 72 6f 79 2e 3c 2f 70 t to destroy.</p
1ed00 61 72 61 6d 3e 0d 0a 20 20 20 20 69 6e 74 65 72 aram>.. inter
1ed10 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 76 6f 69 nal override voi
1ed20 64 20 46 69 6e 69 73 68 42 61 63 6b 75 70 28 0d d FinishBackup(.
1ed30 0a 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 42 . SQLiteB
1ed40 61 63 6b 75 70 20 62 61 63 6b 75 70 0d 0a 20 20 ackup backup..
1ed50 20 20 20 20 20 20 29 0d 0a 20 20 20 20 7b 0d 0a ).. {..
1ed60 20 20 20 20 20 20 20 20 69 66 20 28 62 61 63 6b if (back
1ed70 75 70 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 up == null)..
1ed80 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e throw n
1ed90 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 ew ArgumentNullE
1eda0 78 63 65 70 74 69 6f 6e 28 22 62 61 63 6b 75 70 xception("backup
1edb0 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 53 ");.... S
1edc0 51 4c 69 74 65 42 61 63 6b 75 70 48 61 6e 64 6c QLiteBackupHandl
1edd0 65 20 68 61 6e 64 6c 65 20 3d 20 62 61 63 6b 75 e handle = backu
1ede0 70 2e 5f 73 71 6c 69 74 65 5f 62 61 63 6b 75 70 p._sqlite_backup
1edf0 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 20 ;.... if
1ee00 28 68 61 6e 64 6c 65 20 3d 3d 20 6e 75 6c 6c 29 (handle == null)
1ee10 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 74 68 .. th
1ee20 72 6f 77 20 6e 65 77 20 49 6e 76 61 6c 69 64 4f row new InvalidO
1ee30 70 65 72 61 74 69 6f 6e 45 78 63 65 70 74 69 6f perationExceptio
1ee40 6e 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 n(..
1ee50 20 20 20 20 22 42 61 63 6b 75 70 20 6f 62 6a 65 "Backup obje
1ee60 63 74 20 68 61 73 20 61 6e 20 69 6e 76 61 6c 69 ct has an invali
1ee70 64 20 68 61 6e 64 6c 65 2e 22 29 3b 0d 0a 0d 0a d handle.");....
1ee80 20 20 20 20 20 20 20 20 49 6e 74 50 74 72 20 68 IntPtr h
1ee90 61 6e 64 6c 65 50 74 72 20 3d 20 68 61 6e 64 6c andlePtr = handl
1eea0 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 66 e;.... if
1eeb0 20 28 68 61 6e 64 6c 65 50 74 72 20 3d 3d 20 49 (handlePtr == I
1eec0 6e 74 50 74 72 2e 5a 65 72 6f 29 0d 0a 20 20 20 ntPtr.Zero)..
1eed0 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e throw n
1eee0 65 77 20 49 6e 76 61 6c 69 64 4f 70 65 72 61 74 ew InvalidOperat
1eef0 69 6f 6e 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 ionException(..
1ef00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 "
1ef10 42 61 63 6b 75 70 20 6f 62 6a 65 63 74 20 68 61 Backup object ha
1ef20 73 20 61 6e 20 69 6e 76 61 6c 69 64 20 68 61 6e s an invalid han
1ef30 64 6c 65 20 70 6f 69 6e 74 65 72 2e 22 29 3b 0d dle pointer.");.
1ef40 0a 0d 0a 23 69 66 20 21 53 51 4c 49 54 45 5f 53 ...#if !SQLITE_S
1ef50 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 20 TANDARD..
1ef60 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 SQLiteErrorCode
1ef70 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 n = UnsafeNativ
1ef80 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
1ef90 5f 62 61 63 6b 75 70 5f 66 69 6e 69 73 68 5f 69 _backup_finish_i
1efa0 6e 74 65 72 6f 70 28 68 61 6e 64 6c 65 50 74 72 nterop(handlePtr
1efb0 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 );..#else..
1efc0 20 20 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f SQLiteErrorCo
1efd0 64 65 20 6e 20 3d 20 55 6e 73 61 66 65 4e 61 74 de n = UnsafeNat
1efe0 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 iveMethods.sqlit
1eff0 65 33 5f 62 61 63 6b 75 70 5f 66 69 6e 69 73 68 e3_backup_finish
1f000 28 68 61 6e 64 6c 65 50 74 72 29 3b 0d 0a 23 65 (handlePtr);..#e
1f010 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 68 61 ndif.. ha
1f020 6e 64 6c 65 2e 53 65 74 48 61 6e 64 6c 65 41 73 ndle.SetHandleAs
1f030 49 6e 76 61 6c 69 64 28 29 3b 0d 0a 0d 0a 23 69 Invalid();....#i
1f040 66 20 43 4f 55 4e 54 5f 48 41 4e 44 4c 45 0d 0a f COUNT_HANDLE..
1f050 20 20 20 20 20 20 20 20 69 66 20 28 28 6e 20 3d if ((n =
1f060 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 = SQLiteErrorCod
1f070 65 2e 4f 6b 29 20 7c 7c 20 28 6e 20 3d 3d 20 62 e.Ok) || (n == b
1f080 61 63 6b 75 70 2e 5f 73 74 65 70 52 65 73 75 6c ackup._stepResul
1f090 74 29 29 20 68 61 6e 64 6c 65 2e 57 61 73 52 65 t)) handle.WasRe
1f0a0 6c 65 61 73 65 64 4f 6b 28 29 3b 0d 0a 23 65 6e leasedOk();..#en
1f0b0 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 dif.... i
1f0c0 66 20 28 28 6e 20 21 3d 20 53 51 4c 69 74 65 45 f ((n != SQLiteE
1f0d0 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 20 26 26 20 rrorCode.Ok) &&
1f0e0 28 6e 20 21 3d 20 62 61 63 6b 75 70 2e 5f 73 74 (n != backup._st
1f0f0 65 70 52 65 73 75 6c 74 29 29 0d 0a 20 20 20 20 epResult))..
1f100 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 throw ne
1f110 77 20 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f w SQLiteExceptio
1f120 6e 28 6e 2c 20 47 65 74 4c 61 73 74 45 72 72 6f n(n, GetLastErro
1f130 72 28 29 29 3b 0d 0a 20 20 20 20 7d 0d 0a 0d 0a r());.. }....
1f140 20 20 20 20 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////
1f150 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1f160 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1f170 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1f180 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1f190 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f 2f ////////////////
1f1a0 2f 2f 2f 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c ///.... /// <
1f1b0 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f summary>.. //
1f1c0 2f 20 44 65 74 65 72 6d 69 6e 65 73 20 69 66 20 / Determines if
1f1d0 74 68 65 20 53 51 4c 69 74 65 20 63 6f 72 65 20 the SQLite core
1f1e0 6c 69 62 72 61 72 79 20 68 61 73 20 62 65 65 6e library has been
1f1f0 20 69 6e 69 74 69 61 6c 69 7a 65 64 20 66 6f 72 initialized for
1f200 20 74 68 65 0d 0a 20 20 20 20 2f 2f 2f 20 63 75 the.. /// cu
1f210 72 72 65 6e 74 20 70 72 6f 63 65 73 73 2e 0d 0a rrent process...
1f220 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 /// </summar
1f230 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 65 74 y>.. /// <ret
1f240 75 72 6e 73 3e 0d 0a 20 20 20 20 2f 2f 2f 20 41 urns>.. /// A
1f250 20 62 6f 6f 6c 65 61 6e 20 69 6e 64 69 63 61 74 boolean indicat
1f260 69 6e 67 20 77 68 65 74 68 65 72 20 6f 72 20 6e ing whether or n
1f270 6f 74 20 74 68 65 20 53 51 4c 69 74 65 20 63 6f ot the SQLite co
1f280 72 65 20 6c 69 62 72 61 72 79 20 68 61 73 20 62 re library has b
1f290 65 65 6e 0d 0a 20 20 20 20 2f 2f 2f 20 69 6e 69 een.. /// ini
1f2a0 74 69 61 6c 69 7a 65 64 20 66 6f 72 20 74 68 65 tialized for the
1f2b0 20 63 75 72 72 65 6e 74 20 70 72 6f 63 65 73 73 current process
1f2c0 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 72 65 74 ... /// </ret
1f2d0 75 72 6e 73 3e 0d 0a 20 20 20 20 69 6e 74 65 72 urns>.. inter
1f2e0 6e 61 6c 20 6f 76 65 72 72 69 64 65 20 62 6f 6f nal override boo
1f2f0 6c 20 49 73 49 6e 69 74 69 61 6c 69 7a 65 64 28 l IsInitialized(
1f300 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 ).. {..
1f310 20 20 72 65 74 75 72 6e 20 53 74 61 74 69 63 49 return StaticI
1f320 73 49 6e 69 74 69 61 6c 69 7a 65 64 28 29 3b 0d sInitialized();.
1f330 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 2f 2f . }.... //
1f340 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 / <summary>..
1f350 20 2f 2f 2f 20 44 65 74 65 72 6d 69 6e 65 73 20 /// Determines
1f360 69 66 20 74 68 65 20 53 51 4c 69 74 65 20 63 6f if the SQLite co
1f370 72 65 20 6c 69 62 72 61 72 79 20 68 61 73 20 62 re library has b
1f380 65 65 6e 20 69 6e 69 74 69 61 6c 69 7a 65 64 20 een initialized
1f390 66 6f 72 20 74 68 65 0d 0a 20 20 20 20 2f 2f 2f for the.. ///
1f3a0 20 63 75 72 72 65 6e 74 20 70 72 6f 63 65 73 73 current process
1f3b0 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d ... /// </sum
1f3c0 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c mary>.. /// <
1f3d0 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 2f 2f returns>.. //
1f3e0 2f 20 41 20 62 6f 6f 6c 65 61 6e 20 69 6e 64 69 / A boolean indi
1f3f0 63 61 74 69 6e 67 20 77 68 65 74 68 65 72 20 6f cating whether o
1f400 72 20 6e 6f 74 20 74 68 65 20 53 51 4c 69 74 65 r not the SQLite
1f410 20 63 6f 72 65 20 6c 69 62 72 61 72 79 20 68 61 core library ha
1f420 73 20 62 65 65 6e 0d 0a 20 20 20 20 2f 2f 2f 20 s been.. ///
1f430 69 6e 69 74 69 61 6c 69 7a 65 64 20 66 6f 72 20 initialized for
1f440 74 68 65 20 63 75 72 72 65 6e 74 20 70 72 6f 63 the current proc
1f450 65 73 73 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f ess... /// </
1f460 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 69 6e returns>.. in
1f470 74 65 72 6e 61 6c 20 73 74 61 74 69 63 20 62 6f ternal static bo
1f480 6f 6c 20 53 74 61 74 69 63 49 73 49 6e 69 74 69 ol StaticIsIniti
1f490 61 6c 69 7a 65 64 28 29 0d 0a 20 20 20 20 7b 0d alized().. {.
1f4a0 0a 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 . //..
1f4b0 20 20 20 20 20 2f 2f 20 42 55 47 46 49 58 3a 20 // BUGFIX:
1f4c0 50 72 65 76 65 6e 74 20 72 61 63 65 73 20 77 69 Prevent races wi
1f4d0 74 68 20 6f 74 68 65 72 20 74 68 72 65 61 64 73 th other threads
1f4e0 20 66 6f 72 20 74 68 69 73 20 65 6e 74 69 72 65 for this entire
1f4f0 20 62 6c 6f 63 6b 2c 20 64 75 65 0d 0a 20 20 20 block, due..
1f500 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 20 20 //
1f510 74 6f 20 74 68 65 20 74 72 79 2f 66 69 6e 61 6c to the try/final
1f520 6c 79 20 73 65 6d 61 6e 74 69 63 73 2e 20 20 53 ly semantics. S
1f530 65 65 20 74 69 63 6b 65 74 20 5b 37 32 39 30 35 ee ticket [72905
1f540 63 39 61 37 37 5d 2e 0d 0a 20 20 20 20 20 20 20 c9a77]...
1f550 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 6c 6f 63 //.. loc
1f560 6b 20 28 73 79 6e 63 52 6f 6f 74 29 0d 0a 20 20 k (syncRoot)..
1f570 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 {..
1f580 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 //..
1f590 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 53 61 // NOTE: Sa
1f5a0 76 65 20 74 68 65 20 73 74 61 74 65 20 6f 66 20 ve the state of
1f5b0 74 68 65 20 6c 6f 67 67 69 6e 67 20 63 6c 61 73 the logging clas
1f5c0 73 20 61 6e 64 20 74 68 65 6e 20 72 65 73 74 6f s and then resto
1f5d0 72 65 20 69 74 0d 0a 20 20 20 20 20 20 20 20 20 re it..
1f5e0 20 20 20 2f 2f 20 20 20 20 20 20 20 61 66 74 65 // afte
1f5f0 72 20 77 65 20 61 72 65 20 64 6f 6e 65 20 74 6f r we are done to
1f600 20 61 76 6f 69 64 20 6c 6f 67 67 69 6e 67 20 74 avoid logging t
1f610 6f 6f 20 6d 61 6e 79 20 66 61 6c 73 65 20 65 72 oo many false er
1f620 72 6f 72 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 rors...
1f630 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 20 //..
1f640 20 20 20 62 6f 6f 6c 20 73 61 76 65 64 45 6e 61 bool savedEna
1f650 62 6c 65 64 20 3d 20 53 51 4c 69 74 65 4c 6f 67 bled = SQLiteLog
1f660 2e 45 6e 61 62 6c 65 64 3b 0d 0a 20 20 20 20 20 .Enabled;..
1f670 20 20 20 20 20 20 20 53 51 4c 69 74 65 4c 6f 67 SQLiteLog
1f680 2e 45 6e 61 62 6c 65 64 20 3d 20 66 61 6c 73 65 .Enabled = false
1f690 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ;....
1f6a0 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 20 20 try..
1f6b0 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 {..
1f6c0 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 //..
1f6d0 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 // NOTE
1f6e0 3a 20 54 68 69 73 20 6d 65 74 68 6f 64 20 5b 61 : This method [a
1f6f0 62 5d 75 73 65 73 20 74 68 65 20 66 61 63 74 20 b]uses the fact
1f700 74 68 61 74 20 53 51 4c 69 74 65 20 77 69 6c 6c that SQLite will
1f710 20 61 6c 77 61 79 73 0d 0a 20 20 20 20 20 20 20 always..
1f720 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 //
1f730 20 20 72 65 74 75 72 6e 20 53 51 4c 49 54 45 5f return SQLITE_
1f740 45 52 52 4f 52 20 66 6f 72 20 61 6e 79 20 75 6e ERROR for any un
1f750 6b 6e 6f 77 6e 20 63 6f 6e 66 69 67 75 72 61 74 known configurat
1f760 69 6f 6e 20 6f 70 74 69 6f 6e 0d 0a 20 20 20 20 ion option..
1f770 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 //
1f780 20 20 20 20 20 2a 75 6e 6c 65 73 73 2a 20 74 68 *unless* th
1f790 65 20 53 51 4c 69 74 65 20 6c 69 62 72 61 72 79 e SQLite library
1f7a0 20 68 61 73 20 61 6c 72 65 61 64 79 20 62 65 65 has already bee
1f7b0 6e 20 69 6e 69 74 69 61 6c 69 7a 65 64 2e 0d 0a n initialized...
1f7c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1f7d0 2f 2f 20 20 20 20 20 20 20 49 6e 20 74 68 61 74 // In that
1f7e0 20 63 61 73 65 20 69 74 20 77 69 6c 6c 20 61 6c case it will al
1f7f0 77 61 79 73 20 72 65 74 75 72 6e 20 53 51 4c 49 ways return SQLI
1f800 54 45 5f 4d 49 53 55 53 45 2e 0d 0a 20 20 20 20 TE_MISUSE...
1f810 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 0d 0a //..
1f820 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1f830 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 SQLiteErrorCode
1f840 72 63 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 rc = UnsafeNativ
1f850 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 eMethods.sqlite3
1f860 5f 63 6f 6e 66 69 67 5f 6e 6f 6e 65 28 0d 0a 20 _config_none(..
1f870 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1f880 20 20 20 53 51 4c 69 74 65 43 6f 6e 66 69 67 4f SQLiteConfigO
1f890 70 73 45 6e 75 6d 2e 53 51 4c 49 54 45 5f 43 4f psEnum.SQLITE_CO
1f8a0 4e 46 49 47 5f 4e 4f 4e 45 29 3b 0d 0a 0d 0a 20 NFIG_NONE);....
1f8b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 r
1f8c0 65 74 75 72 6e 20 28 72 63 20 3d 3d 20 53 51 4c eturn (rc == SQL
1f8d0 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4d 69 73 iteErrorCode.Mis
1f8e0 75 73 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 use);..
1f8f0 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 }..
1f900 20 20 66 69 6e 61 6c 6c 79 0d 0a 20 20 20 20 20 finally..
1f910 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 {..
1f920 20 20 20 20 20 20 20 20 20 20 53 51 4c 69 74 65 SQLite
1f930 4c 6f 67 2e 45 6e 61 62 6c 65 64 20 3d 20 73 61 Log.Enabled = sa
1f940 76 65 64 45 6e 61 62 6c 65 64 3b 0d 0a 20 20 20 vedEnabled;..
1f950 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 }..
1f960 20 20 20 20 7d 0d 0a 20 20 20 20 7d 0d 0a 0d 0a }.. }....
1f970 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 /// <summary
1f980 3e 0d 0a 20 20 20 20 2f 2f 2f 20 48 65 6c 70 65 >.. /// Helpe
1f990 72 20 66 75 6e 63 74 69 6f 6e 20 74 6f 20 72 65 r function to re
1f9a0 74 72 69 65 76 65 20 61 20 63 6f 6c 75 6d 6e 20 trieve a column
1f9b0 6f 66 20 64 61 74 61 20 66 72 6f 6d 20 61 6e 20 of data from an
1f9c0 61 63 74 69 76 65 20 73 74 61 74 65 6d 65 6e 74 active statement
1f9d0 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d ... /// </sum
1f9e0 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c mary>.. /// <
1f9f0 70 61 72 61 6d 20 6e 61 6d 65 3d 22 73 74 6d 74 param name="stmt
1fa00 22 3e 54 68 65 20 73 74 61 74 65 6d 65 6e 74 20 ">The statement
1fa10 62 65 69 6e 67 20 73 74 65 70 28 29 27 64 20 74 being step()'d t
1fa20 68 72 6f 75 67 68 3c 2f 70 61 72 61 6d 3e 0d 0a hrough</param>..
1fa30 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e /// <param n
1fa40 61 6d 65 3d 22 66 6c 61 67 73 22 3e 54 68 65 20 ame="flags">The
1fa50 66 6c 61 67 73 20 61 73 73 6f 63 69 61 74 65 64 flags associated
1fa60 20 77 69 74 68 20 74 68 65 20 63 6f 6e 6e 65 63 with the connec
1fa70 74 69 6f 6e 2e 3c 2f 70 61 72 61 6d 3e 0d 0a 20 tion.</param>..
1fa80 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 /// <param na
1fa90 6d 65 3d 22 69 6e 64 65 78 22 3e 54 68 65 20 63 me="index">The c
1faa0 6f 6c 75 6d 6e 20 69 6e 64 65 78 20 74 6f 20 72 olumn index to r
1fab0 65 74 72 69 65 76 65 3c 2f 70 61 72 61 6d 3e 0d etrieve</param>.
1fac0 0a 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 . /// <param
1fad0 6e 61 6d 65 3d 22 74 79 70 22 3e 54 68 65 20 74 name="typ">The t
1fae0 79 70 65 20 6f 66 20 64 61 74 61 20 63 6f 6e 74 ype of data cont
1faf0 61 69 6e 65 64 20 69 6e 20 74 68 65 20 63 6f 6c ained in the col
1fb00 75 6d 6e 2e 20 20 49 66 20 55 6e 69 6e 69 74 69 umn. If Uniniti
1fb10 61 6c 69 7a 65 64 2c 20 74 68 69 73 20 66 75 6e alized, this fun
1fb20 63 74 69 6f 6e 20 77 69 6c 6c 20 72 65 74 72 69 ction will retri
1fb30 65 76 65 20 74 68 65 20 64 61 74 61 74 79 70 65 eve the datatype
1fb40 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 2e 3c 2f 70 information.</p
1fb50 61 72 61 6d 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c aram>.. /// <
1fb60 72 65 74 75 72 6e 73 3e 52 65 74 75 72 6e 73 20 returns>Returns
1fb70 74 68 65 20 64 61 74 61 20 69 6e 20 74 68 65 20 the data in the
1fb80 63 6f 6c 75 6d 6e 3c 2f 72 65 74 75 72 6e 73 3e column</returns>
1fb90 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 6f .. internal o
1fba0 76 65 72 72 69 64 65 20 6f 62 6a 65 63 74 20 47 verride object G
1fbb0 65 74 56 61 6c 75 65 28 53 51 4c 69 74 65 53 74 etValue(SQLiteSt
1fbc0 61 74 65 6d 65 6e 74 20 73 74 6d 74 2c 20 53 51 atement stmt, SQ
1fbd0 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e 46 6c LiteConnectionFl
1fbe0 61 67 73 20 66 6c 61 67 73 2c 20 69 6e 74 20 69 ags flags, int i
1fbf0 6e 64 65 78 2c 20 53 51 4c 69 74 65 54 79 70 65 ndex, SQLiteType
1fc00 20 74 79 70 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 typ).. {..
1fc10 20 20 20 20 54 79 70 65 41 66 66 69 6e 69 74 79 TypeAffinity
1fc20 20 61 66 66 20 3d 20 74 79 70 2e 41 66 66 69 6e aff = typ.Affin
1fc30 69 74 79 3b 0d 0a 20 20 20 20 20 20 69 66 20 28 ity;.. if (
1fc40 61 66 66 20 3d 3d 20 54 79 70 65 41 66 66 69 6e aff == TypeAffin
1fc50 69 74 79 2e 4e 75 6c 6c 29 20 72 65 74 75 72 6e ity.Null) return
1fc60 20 44 42 4e 75 6c 6c 2e 56 61 6c 75 65 3b 0d 0a DBNull.Value;..
1fc70 20 20 20 20 20 20 54 79 70 65 20 74 20 3d 20 6e Type t = n
1fc80 75 6c 6c 3b 0d 0a 0d 0a 20 20 20 20 20 20 69 66 ull;.... if
1fc90 20 28 74 79 70 2e 54 79 70 65 20 21 3d 20 44 62 (typ.Type != Db
1fca0 54 79 70 65 2e 4f 62 6a 65 63 74 29 0d 0a 20 20 Type.Object)..
1fcb0 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 74 {.. t
1fcc0 20 3d 20 53 51 4c 69 74 65 43 6f 6e 76 65 72 74 = SQLiteConvert
1fcd0 2e 53 51 4c 69 74 65 54 79 70 65 54 6f 54 79 70 .SQLiteTypeToTyp
1fce0 65 28 74 79 70 29 3b 0d 0a 20 20 20 20 20 20 20 e(typ);..
1fcf0 20 61 66 66 20 3d 20 54 79 70 65 54 6f 41 66 66 aff = TypeToAff
1fd00 69 6e 69 74 79 28 74 2c 20 66 6c 61 67 73 29 3b inity(t, flags);
1fd10 0d 0a 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 .. }....
1fd20 20 20 20 69 66 20 28 28 66 6c 61 67 73 20 26 20 if ((flags &
1fd30 53 51 4c 69 74 65 43 6f 6e 6e 65 63 74 69 6f 6e SQLiteConnection
1fd40 46 6c 61 67 73 2e 47 65 74 41 6c 6c 41 73 54 65 Flags.GetAllAsTe
1fd50 78 74 29 20 3d 3d 20 53 51 4c 69 74 65 43 6f 6e xt) == SQLiteCon
1fd60 6e 65 63 74 69 6f 6e 46 6c 61 67 73 2e 47 65 74 nectionFlags.Get
1fd70 41 6c 6c 41 73 54 65 78 74 29 0d 0a 20 20 20 20 AllAsText)..
1fd80 20 20 20 20 20 20 72 65 74 75 72 6e 20 47 65 74 return Get
1fd90 54 65 78 74 28 73 74 6d 74 2c 20 69 6e 64 65 78 Text(stmt, index
1fda0 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 73 77 69 74 );.... swit
1fdb0 63 68 20 28 61 66 66 29 0d 0a 20 20 20 20 20 20 ch (aff)..
1fdc0 7b 0d 0a 20 20 20 20 20 20 20 20 63 61 73 65 20 {.. case
1fdd0 54 79 70 65 41 66 66 69 6e 69 74 79 2e 42 6c 6f TypeAffinity.Blo
1fde0 62 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 69 66 b:.. if
1fdf0 20 28 74 79 70 2e 54 79 70 65 20 3d 3d 20 44 62 (typ.Type == Db
1fe00 54 79 70 65 2e 47 75 69 64 20 26 26 20 74 79 70 Type.Guid && typ
1fe10 2e 41 66 66 69 6e 69 74 79 20 3d 3d 20 54 79 70 .Affinity == Typ
1fe20 65 41 66 66 69 6e 69 74 79 2e 54 65 78 74 29 0d eAffinity.Text).
1fe30 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 . ret
1fe40 75 72 6e 20 6e 65 77 20 47 75 69 64 28 47 65 74 urn new Guid(Get
1fe50 54 65 78 74 28 73 74 6d 74 2c 20 69 6e 64 65 78 Text(stmt, index
1fe60 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 ));....
1fe70 20 69 6e 74 20 6e 20 3d 20 28 69 6e 74 29 47 65 int n = (int)Ge
1fe80 74 42 79 74 65 73 28 73 74 6d 74 2c 20 69 6e 64 tBytes(stmt, ind
1fe90 65 78 2c 20 30 2c 20 6e 75 6c 6c 2c 20 30 2c 20 ex, 0, null, 0,
1fea0 30 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 62 0);.. b
1feb0 79 74 65 5b 5d 20 62 20 3d 20 6e 65 77 20 62 79 yte[] b = new by
1fec0 74 65 5b 6e 5d 3b 0d 0a 20 20 20 20 20 20 20 20 te[n];..
1fed0 20 20 47 65 74 42 79 74 65 73 28 73 74 6d 74 2c GetBytes(stmt,
1fee0 20 69 6e 64 65 78 2c 20 30 2c 20 62 2c 20 30 2c index, 0, b, 0,
1fef0 20 6e 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 n);....
1ff00 20 20 69 66 20 28 74 79 70 2e 54 79 70 65 20 3d if (typ.Type =
1ff10 3d 20 44 62 54 79 70 65 2e 47 75 69 64 20 26 26 = DbType.Guid &&
1ff20 20 6e 20 3d 3d 20 31 36 29 0d 0a 20 20 20 20 20 n == 16)..
1ff30 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 6e 65 return ne
1ff40 77 20 47 75 69 64 28 62 29 3b 0d 0a 0d 0a 20 20 w Guid(b);....
1ff50 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 62 return b
1ff60 3b 0d 0a 20 20 20 20 20 20 20 20 63 61 73 65 20 ;.. case
1ff70 54 79 70 65 41 66 66 69 6e 69 74 79 2e 44 61 74 TypeAffinity.Dat
1ff80 65 54 69 6d 65 3a 0d 0a 20 20 20 20 20 20 20 20 eTime:..
1ff90 20 20 72 65 74 75 72 6e 20 47 65 74 44 61 74 65 return GetDate
1ffa0 54 69 6d 65 28 73 74 6d 74 2c 20 69 6e 64 65 78 Time(stmt, index
1ffb0 29 3b 0d 0a 20 20 20 20 20 20 20 20 63 61 73 65 );.. case
1ffc0 20 54 79 70 65 41 66 66 69 6e 69 74 79 2e 44 6f TypeAffinity.Do
1ffd0 75 62 6c 65 3a 0d 0a 20 20 20 20 20 20 20 20 20 uble:..
1ffe0 20 69 66 20 28 74 20 3d 3d 20 6e 75 6c 6c 29 20 if (t == null)
1fff0 72 65 74 75 72 6e 20 47 65 74 44 6f 75 62 6c 65 return GetDouble
20000 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 3b 0d 0a (stmt, index);..
20010 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e return
20020 20 43 6f 6e 76 65 72 74 2e 43 68 61 6e 67 65 54 Convert.ChangeT
20030 79 70 65 28 47 65 74 44 6f 75 62 6c 65 28 73 74 ype(GetDouble(st
20040 6d 74 2c 20 69 6e 64 65 78 29 2c 20 74 2c 20 6e mt, index), t, n
20050 75 6c 6c 29 3b 0d 0a 20 20 20 20 20 20 20 20 63 ull);.. c
20060 61 73 65 20 54 79 70 65 41 66 66 69 6e 69 74 79 ase TypeAffinity
20070 2e 49 6e 74 36 34 3a 0d 0a 20 20 20 20 20 20 20 .Int64:..
20080 20 20 20 69 66 20 28 74 20 3d 3d 20 6e 75 6c 6c if (t == null
20090 29 20 72 65 74 75 72 6e 20 47 65 74 49 6e 74 36 ) return GetInt6
200a0 34 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 3b 0d 4(stmt, index);.
200b0 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 28 74 . if (t
200c0 20 3d 3d 20 74 79 70 65 6f 66 28 42 6f 6f 6c 65 == typeof(Boole
200d0 61 6e 29 29 20 72 65 74 75 72 6e 20 47 65 74 42 an)) return GetB
200e0 6f 6f 6c 65 61 6e 28 73 74 6d 74 2c 20 69 6e 64 oolean(stmt, ind
200f0 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 ex);..
20100 69 66 20 28 74 20 3d 3d 20 74 79 70 65 6f 66 28 if (t == typeof(
20110 53 42 79 74 65 29 29 20 72 65 74 75 72 6e 20 47 SByte)) return G
20120 65 74 53 42 79 74 65 28 73 74 6d 74 2c 20 69 6e etSByte(stmt, in
20130 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 dex);..
20140 20 69 66 20 28 74 20 3d 3d 20 74 79 70 65 6f 66 if (t == typeof
20150 28 42 79 74 65 29 29 20 72 65 74 75 72 6e 20 47 (Byte)) return G
20160 65 74 42 79 74 65 28 73 74 6d 74 2c 20 69 6e 64 etByte(stmt, ind
20170 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 ex);..
20180 69 66 20 28 74 20 3d 3d 20 74 79 70 65 6f 66 28 if (t == typeof(
20190 49 6e 74 31 36 29 29 20 72 65 74 75 72 6e 20 47 Int16)) return G
201a0 65 74 49 6e 74 31 36 28 73 74 6d 74 2c 20 69 6e etInt16(stmt, in
201b0 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 dex);..
201c0 20 69 66 20 28 74 20 3d 3d 20 74 79 70 65 6f 66 if (t == typeof
201d0 28 55 49 6e 74 31 36 29 29 20 72 65 74 75 72 6e (UInt16)) return
201e0 20 47 65 74 55 49 6e 74 31 36 28 73 74 6d 74 2c GetUInt16(stmt,
201f0 20 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 index);..
20200 20 20 20 20 69 66 20 28 74 20 3d 3d 20 74 79 70 if (t == typ
20210 65 6f 66 28 49 6e 74 33 32 29 29 20 72 65 74 75 eof(Int32)) retu
20220 72 6e 20 47 65 74 49 6e 74 33 32 28 73 74 6d 74 rn GetInt32(stmt
20230 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 , index);..
20240 20 20 20 20 20 69 66 20 28 74 20 3d 3d 20 74 79 if (t == ty
20250 70 65 6f 66 28 55 49 6e 74 33 32 29 29 20 72 65 peof(UInt32)) re
20260 74 75 72 6e 20 47 65 74 55 49 6e 74 33 32 28 73 turn GetUInt32(s
20270 74 6d 74 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 20 tmt, index);..
20280 20 20 20 20 20 20 20 20 69 66 20 28 74 20 3d 3d if (t ==
20290 20 74 79 70 65 6f 66 28 49 6e 74 36 34 29 29 20 typeof(Int64))
202a0 72 65 74 75 72 6e 20 47 65 74 49 6e 74 36 34 28 return GetInt64(
202b0 73 74 6d 74 2c 20 69 6e 64 65 78 29 3b 0d 0a 20 stmt, index);..
202c0 20 20 20 20 20 20 20 20 20 69 66 20 28 74 20 3d if (t =
202d0 3d 20 74 79 70 65 6f 66 28 55 49 6e 74 36 34 29 = typeof(UInt64)
202e0 29 20 72 65 74 75 72 6e 20 47 65 74 55 49 6e 74 ) return GetUInt
202f0 36 34 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 3b 64(stmt, index);
20300 0d 0a 20 20 20 20 20 20 20 20 20 20 72 65 74 75 .. retu
20310 72 6e 20 43 6f 6e 76 65 72 74 2e 43 68 61 6e 67 rn Convert.Chang
20320 65 54 79 70 65 28 47 65 74 49 6e 74 36 34 28 73 eType(GetInt64(s
20330 74 6d 74 2c 20 69 6e 64 65 78 29 2c 20 74 2c 20 tmt, index), t,
20340 6e 75 6c 6c 29 3b 0d 0a 20 20 20 20 20 20 20 20 null);..
20350 64 65 66 61 75 6c 74 3a 0d 0a 20 20 20 20 20 20 default:..
20360 20 20 20 20 72 65 74 75 72 6e 20 47 65 74 54 65 return GetTe
20370 78 74 28 73 74 6d 74 2c 20 69 6e 64 65 78 29 3b xt(stmt, index);
20380 0d 0a 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 7d .. }.. }
20390 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 6c .... internal
203a0 20 6f 76 65 72 72 69 64 65 20 69 6e 74 20 47 65 override int Ge
203b0 74 43 75 72 73 6f 72 46 6f 72 54 61 62 6c 65 28 tCursorForTable(
203c0 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e 74 20 SQLiteStatement
203d0 73 74 6d 74 2c 20 69 6e 74 20 64 62 2c 20 69 6e stmt, int db, in
203e0 74 20 72 6f 6f 74 50 61 67 65 29 0d 0a 20 20 20 t rootPage)..
203f0 20 7b 0d 0a 23 69 66 20 21 53 51 4c 49 54 45 5f {..#if !SQLITE_
20400 53 54 41 4e 44 41 52 44 0d 0a 20 20 20 20 20 20 STANDARD..
20410 72 65 74 75 72 6e 20 55 6e 73 61 66 65 4e 61 74 return UnsafeNat
20420 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 iveMethods.sqlit
20430 65 33 5f 74 61 62 6c 65 5f 63 75 72 73 6f 72 5f e3_table_cursor_
20440 69 6e 74 65 72 6f 70 28 73 74 6d 74 2e 5f 73 71 interop(stmt._sq
20450 6c 69 74 65 5f 73 74 6d 74 2c 20 64 62 2c 20 72 lite_stmt, db, r
20460 6f 6f 74 50 61 67 65 29 3b 0d 0a 23 65 6c 73 65 ootPage);..#else
20470 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 2d .. return -
20480 31 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 1;..#endif..
20490 7d 0d 0a 0d 0a 20 20 20 20 69 6e 74 65 72 6e 61 }.... interna
204a0 6c 20 6f 76 65 72 72 69 64 65 20 6c 6f 6e 67 20 l override long
204b0 47 65 74 52 6f 77 49 64 46 6f 72 43 75 72 73 6f GetRowIdForCurso
204c0 72 28 53 51 4c 69 74 65 53 74 61 74 65 6d 65 6e r(SQLiteStatemen
204d0 74 20 73 74 6d 74 2c 20 69 6e 74 20 63 75 72 73 t stmt, int curs
204e0 6f 72 29 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 or).. {..#if
204f0 21 53 51 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 !SQLITE_STANDARD
20500 0d 0a 20 20 20 20 20 20 6c 6f 6e 67 20 72 6f 77 .. long row
20510 69 64 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 53 id = 0;.. S
20520 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 72 QLiteErrorCode r
20530 63 20 3d 20 55 6e 73 61 66 65 4e 61 74 69 76 65 c = UnsafeNative
20540 4d 65 74 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f Methods.sqlite3_
20550 63 75 72 73 6f 72 5f 72 6f 77 69 64 5f 69 6e 74 cursor_rowid_int
20560 65 72 6f 70 28 73 74 6d 74 2e 5f 73 71 6c 69 74 erop(stmt._sqlit
20570 65 5f 73 74 6d 74 2c 20 63 75 72 73 6f 72 2c 20 e_stmt, cursor,
20580 72 65 66 20 72 6f 77 69 64 29 3b 0d 0a 20 20 20 ref rowid);..
20590 20 20 20 69 66 20 28 72 63 20 3d 3d 20 53 51 4c if (rc == SQL
205a0 69 74 65 45 72 72 6f 72 43 6f 64 65 2e 4f 6b 29 iteErrorCode.Ok)
205b0 20 72 65 74 75 72 6e 20 72 6f 77 69 64 3b 0d 0a return rowid;..
205c0 0d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 30 .. return 0
205d0 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 20 20 20 ;..#else..
205e0 72 65 74 75 72 6e 20 30 3b 0d 0a 23 65 6e 64 69 return 0;..#endi
205f0 66 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 f.. }....
20600 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 internal overrid
20610 65 20 76 6f 69 64 20 47 65 74 49 6e 64 65 78 43 e void GetIndexC
20620 6f 6c 75 6d 6e 45 78 74 65 6e 64 65 64 49 6e 66 olumnExtendedInf
20630 6f 28 73 74 72 69 6e 67 20 64 61 74 61 62 61 73 o(string databas
20640 65 2c 20 73 74 72 69 6e 67 20 69 6e 64 65 78 2c e, string index,
20650 20 73 74 72 69 6e 67 20 63 6f 6c 75 6d 6e 2c 20 string column,
20660 72 65 66 20 69 6e 74 20 73 6f 72 74 4d 6f 64 65 ref int sortMode
20670 2c 20 72 65 66 20 69 6e 74 20 6f 6e 45 72 72 6f , ref int onErro
20680 72 2c 20 72 65 66 20 73 74 72 69 6e 67 20 63 6f r, ref string co
20690 6c 6c 61 74 69 6f 6e 53 65 71 75 65 6e 63 65 29 llationSequence)
206a0 0d 0a 20 20 20 20 7b 0d 0a 23 69 66 20 21 53 51 .. {..#if !SQ
206b0 4c 49 54 45 5f 53 54 41 4e 44 41 52 44 0d 0a 20 LITE_STANDARD..
206c0 20 20 20 20 20 49 6e 74 50 74 72 20 63 6f 6c 6c IntPtr coll
206d0 20 3d 20 49 6e 74 50 74 72 2e 5a 65 72 6f 3b 0d = IntPtr.Zero;.
206e0 0a 20 20 20 20 20 20 69 6e 74 20 63 6f 6c 6c 6c . int colll
206f0 65 6e 20 3d 20 30 3b 0d 0a 20 20 20 20 20 20 53 en = 0;.. S
20700 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 65 20 72 QLiteErrorCode r
20710 63 3b 0d 0a 0d 0a 20 20 20 20 20 20 72 63 20 3d c;.... rc =
20720 20 55 6e 73 61 66 65 4e 61 74 69 76 65 4d 65 74 UnsafeNativeMet
20730 68 6f 64 73 2e 73 71 6c 69 74 65 33 5f 69 6e 64 hods.sqlite3_ind
20740 65 78 5f 63 6f 6c 75 6d 6e 5f 69 6e 66 6f 5f 69 ex_column_info_i
20750 6e 74 65 72 6f 70 28 5f 73 71 6c 2c 20 54 6f 55 nterop(_sql, ToU
20760 54 46 38 28 64 61 74 61 62 61 73 65 29 2c 20 54 TF8(database), T
20770 6f 55 54 46 38 28 69 6e 64 65 78 29 2c 20 54 6f oUTF8(index), To
20780 55 54 46 38 28 63 6f 6c 75 6d 6e 29 2c 20 72 65 UTF8(column), re
20790 66 20 73 6f 72 74 4d 6f 64 65 2c 20 72 65 66 20 f sortMode, ref
207a0 6f 6e 45 72 72 6f 72 2c 20 72 65 66 20 63 6f 6c onError, ref col
207b0 6c 2c 20 72 65 66 20 63 6f 6c 6c 6c 65 6e 29 3b l, ref colllen);
207c0 0d 0a 20 20 20 20 20 20 69 66 20 28 72 63 20 21 .. if (rc !
207d0 3d 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 = SQLiteErrorCod
207e0 65 2e 4f 6b 29 20 74 68 72 6f 77 20 6e 65 77 20 e.Ok) throw new
207f0 53 51 4c 69 74 65 45 78 63 65 70 74 69 6f 6e 28 SQLiteException(
20800 72 63 2c 20 6e 75 6c 6c 29 3b 0d 0a 0d 0a 20 20 rc, null);....
20810 20 20 20 20 63 6f 6c 6c 61 74 69 6f 6e 53 65 71 collationSeq
20820 75 65 6e 63 65 20 3d 20 55 54 46 38 54 6f 53 74 uence = UTF8ToSt
20830 72 69 6e 67 28 63 6f 6c 6c 2c 20 63 6f 6c 6c 6c ring(coll, colll
20840 65 6e 29 3b 0d 0a 23 65 6c 73 65 0d 0a 20 20 20 en);..#else..
20850 20 20 20 73 6f 72 74 4d 6f 64 65 20 3d 20 30 3b sortMode = 0;
20860 0d 0a 20 20 20 20 20 20 6f 6e 45 72 72 6f 72 20 .. onError
20870 3d 20 32 3b 0d 0a 20 20 20 20 20 20 63 6f 6c 6c = 2;.. coll
20880 61 74 69 6f 6e 53 65 71 75 65 6e 63 65 20 3d 20 ationSequence =
20890 22 42 49 4e 41 52 59 22 3b 0d 0a 23 65 6e 64 69 "BINARY";..#endi
208a0 66 0d 0a 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 f.. }....
208b0 69 6e 74 65 72 6e 61 6c 20 6f 76 65 72 72 69 64 internal overrid
208c0 65 20 53 51 4c 69 74 65 45 72 72 6f 72 43 6f 64 e SQLiteErrorCod
208d0 65 20 46 69 6c 65 43 6f 6e 74 72 6f 6c 28 73 74 e FileControl(st
208e0 72 69 6e 67 20 7a 44 62 4e 61 6d 65 2c 20 69 6e ring zDbName, in
208f0 74 20 6f 70 2c 20 49 6e 74 50 74 72 20 70 41 72 t op, IntPtr pAr
20900 67 29 0d 0a 20 20 20 20 7b 0d 0a 20 20 20 20 20 g).. {..
20910 20 72 65 74 75 72 6e 20 55 6e 73 61 66 65 4e 61 return UnsafeNa
20920 74 69 76 65 4d 65 74 68 6f 64 73 2e 73 71 6c 69 tiveMethods.sqli
20930 74 65 33 5f 66 69 6c 65 5f 63 6f 6e 74 72 6f 6c te3_file_control
20940 28 5f 73 71 6c 2c 20 28 7a 44 62 4e 61 6d 65 20 (_sql, (zDbName
20950 21 3d 20 6e 75 6c 6c 29 20 3f 20 54 6f 55 54 46 != null) ? ToUTF
20960 38 28 7a 44 62 4e 61 6d 65 29 20 3a 20 6e 75 6c 8(zDbName) : nul
20970 6c 2c 20 6f 70 2c 20 70 41 72 67 29 3b 0d 0a 20 l, op, pArg);..
20980 20 20 20 7d 0d 0a 20 20 7d 0d 0a 7d 0d 0a }.. }..}..