Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | The 'Apply' methods logically belong to the change set, not the session. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | sessions |
Files: | files | file ages | folders |
SHA1: |
baed0aa5035d4de06832a3a454144d93 |
User & Date: | mistachkin 2017-10-05 22:55:27.447 |
Context
2017-10-05
| ||
23:10 | Cleanup integration between the session extension classes and the SQLiteConnection class. check-in: 7529b50e97 user: mistachkin tags: sessions | |
22:55 | The 'Apply' methods logically belong to the change set, not the session. check-in: baed0aa503 user: mistachkin tags: sessions | |
22:33 | Further refinements. check-in: a16ea17d38 user: mistachkin tags: sessions | |
Changes
Changes to System.Data.SQLite/SQLiteSessions.cs.
︙ | ︙ | |||
55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #region Session Extension Interfaces public interface ISQLiteChangeSet { bool? IsPatchSet { get; } ISQLiteChangeSet Invert(); ISQLiteChangeSet CombineWith(ISQLiteChangeSet changeSet); } /////////////////////////////////////////////////////////////////////////// public interface ISQLiteChangeGroup { void AddChangeSet(byte[] rawData); | > > > > > > > > > > > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | #region Session Extension Interfaces public interface ISQLiteChangeSet { bool? IsPatchSet { get; } ISQLiteChangeSet Invert(); ISQLiteChangeSet CombineWith(ISQLiteChangeSet changeSet); void Apply( SessionConflictCallback conflictCallback, object clientData ); void Apply( SessionConflictCallback conflictCallback, SessionTableFilterCallback tableFilterCallback, object clientData ); } /////////////////////////////////////////////////////////////////////////// public interface ISQLiteChangeGroup { void AddChangeSet(byte[] rawData); |
︙ | ︙ | |||
117 118 119 120 121 122 123 | void CreatePatchSet(ref byte[] rawData); void CreatePatchSet(Stream stream); void LoadDifferencesFromTable( string fromDatabaseName, string tableName ); | < < < < < < < < < < < < < | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | void CreatePatchSet(ref byte[] rawData); void CreatePatchSet(Stream stream); void LoadDifferencesFromTable( string fromDatabaseName, string tableName ); } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteChangeSetIterator Class internal sealed class SQLiteChangeSetIterator : IDisposable |
︙ | ︙ | |||
859 860 861 862 863 864 865 | if (pError != IntPtr.Zero) { SQLiteMemory.Free(pError); pError = IntPtr.Zero; } } } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 857 858 859 860 861 862 863 864 865 866 867 868 869 870 | if (pError != IntPtr.Zero) { SQLiteMemory.Free(pError); pError = IntPtr.Zero; } } } #endregion /////////////////////////////////////////////////////////////////////// #region IDisposable Members public void Dispose() { |
︙ | ︙ | |||
1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 | #region SQLiteMemoryChangeSet Class public sealed class SQLiteMemoryChangeSet : ISQLiteChangeSet, IEnumerable<ISQLiteChangeSetMetadataItem>, IDisposable { #region Private Data private byte[] rawData; private bool? isPatchSet; #endregion /////////////////////////////////////////////////////////////////////// #region Private Constructors internal SQLiteMemoryChangeSet( byte[] rawData, bool? isPatchSet ) { this.rawData = rawData; this.isPatchSet = isPatchSet; } #endregion /////////////////////////////////////////////////////////////////////// #region ISQLiteChangeSet Members | > > > > > > | 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 | #region SQLiteMemoryChangeSet Class public sealed class SQLiteMemoryChangeSet : ISQLiteChangeSet, IEnumerable<ISQLiteChangeSetMetadataItem>, IDisposable { #region Private Data private byte[] rawData; private SQLiteConnectionHandle handle; private SQLiteConnectionFlags flags; private bool? isPatchSet; #endregion /////////////////////////////////////////////////////////////////////// #region Private Constructors internal SQLiteMemoryChangeSet( byte[] rawData, SQLiteConnectionHandle handle, SQLiteConnectionFlags flags, bool? isPatchSet ) { this.rawData = rawData; this.handle= handle; this.flags = flags; this.isPatchSet = isPatchSet; } #endregion /////////////////////////////////////////////////////////////////////// #region ISQLiteChangeSet Members |
︙ | ︙ | |||
1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 | ISQLiteChangeSet changeSet ) { CheckDisposed(); throw new NotImplementedException(); } #endregion /////////////////////////////////////////////////////////////////////// #region IEnumerable<ISQLiteChangeSetMetadataItem> Members public IEnumerator<ISQLiteChangeSetMetadataItem> GetEnumerator() { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 | ISQLiteChangeSet changeSet ) { CheckDisposed(); throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public void Apply( SessionConflictCallback conflictCallback, object clientData ) { CheckDisposed(); Apply(conflictCallback, null, clientData); } /////////////////////////////////////////////////////////////////////// public void Apply( SessionConflictCallback conflictCallback, SessionTableFilterCallback tableFilterCallback, object clientData ) { if (conflictCallback == null) throw new ArgumentNullException("conflictCallback"); CheckDisposed(); UnsafeNativeMethods.xSessionFilter xFilter = null; if (tableFilterCallback != null) { xFilter = new UnsafeNativeMethods.xSessionFilter( delegate(IntPtr context, byte[] tblName) { try { string name = SQLiteString.GetStringFromUtf8Bytes( tblName); return tableFilterCallback(clientData, name) ? 1 : 0; } catch (Exception e) { try { if ((flags & SQLiteConnectionFlags.LogCallbackException) == SQLiteConnectionFlags.LogCallbackException) { SQLiteLog.LogMessage(SQLiteBase.COR_E_EXCEPTION, HelperMethods.StringFormat(CultureInfo.CurrentCulture, "Caught exception in \"xFilter\" method: {0}", e)); /* throw */ } } catch { // do nothing. } } return 0; }); } UnsafeNativeMethods.xSessionConflict xConflict; xConflict = new UnsafeNativeMethods.xSessionConflict( delegate(IntPtr context, SQLiteChangeSetConflictType type, IntPtr iterator) { ISQLiteChangeSetMetadataItem item = null; try { return conflictCallback(clientData, type, item); } catch (Exception e) { try { if ((flags & SQLiteConnectionFlags.LogCallbackException) == SQLiteConnectionFlags.LogCallbackException) { SQLiteLog.LogMessage(SQLiteBase.COR_E_EXCEPTION, HelperMethods.StringFormat(CultureInfo.CurrentCulture, "Caught exception in \"xConflict\" method: {0}", e)); /* throw */ } } catch { // do nothing. } } return SQLiteChangeSetConflictResult.Abort; }); int nData = 0; IntPtr pData = IntPtr.Zero; SQLiteErrorCode rc = UnsafeNativeMethods.sqlite3changeset_apply( handle, nData, pData, xFilter, xConflict, IntPtr.Zero); if (rc != SQLiteErrorCode.Ok) throw new SQLiteException(rc, "sqlite3changeset_apply"); } #endregion /////////////////////////////////////////////////////////////////////// #region IEnumerable<ISQLiteChangeSetMetadataItem> Members public IEnumerator<ISQLiteChangeSetMetadataItem> GetEnumerator() { |
︙ | ︙ | |||
1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 | #region SQLiteStreamChangeSet Class public sealed class SQLiteStreamChangeSet : ISQLiteChangeSet, IEnumerable<ISQLiteChangeSetMetadataItem>, IDisposable { #region Private Data private Stream stream; private SQLiteConnectionFlags flags; private bool? isPatchSet; #endregion /////////////////////////////////////////////////////////////////////// #region Private Constructors internal SQLiteStreamChangeSet( Stream stream, SQLiteConnectionFlags flags, bool? isPatchSet ) { this.stream = stream; this.flags = flags; this.isPatchSet = isPatchSet; } #endregion /////////////////////////////////////////////////////////////////////// | > > > | 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 | #region SQLiteStreamChangeSet Class public sealed class SQLiteStreamChangeSet : ISQLiteChangeSet, IEnumerable<ISQLiteChangeSetMetadataItem>, IDisposable { #region Private Data private Stream stream; private SQLiteConnectionHandle handle; private SQLiteConnectionFlags flags; private bool? isPatchSet; #endregion /////////////////////////////////////////////////////////////////////// #region Private Constructors internal SQLiteStreamChangeSet( Stream stream, SQLiteConnectionHandle handle, SQLiteConnectionFlags flags, bool? isPatchSet ) { this.stream = stream; this.handle = handle; this.flags = flags; this.isPatchSet = isPatchSet; } #endregion /////////////////////////////////////////////////////////////////////// |
︙ | ︙ | |||
1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 | ISQLiteChangeSet changeSet ) { CheckDisposed(); throw new NotImplementedException(); } #endregion /////////////////////////////////////////////////////////////////////// #region IEnumerable<ISQLiteChangeSetMetadataItem> Members public IEnumerator<ISQLiteChangeSetMetadataItem> GetEnumerator() { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 | ISQLiteChangeSet changeSet ) { CheckDisposed(); throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public void Apply( SessionConflictCallback conflictCallback, object clientData ) { CheckDisposed(); throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public void Apply( SessionConflictCallback conflictCallback, SessionTableFilterCallback tableFilterCallback, object clientData ) { CheckDisposed(); UnsafeNativeMethods.xSessionFilter xFilter; xFilter = new UnsafeNativeMethods.xSessionFilter( delegate(IntPtr context, byte[] tblName) { try { string name = SQLiteString.GetStringFromUtf8Bytes( tblName); return tableFilterCallback(clientData, name) ? 1 : 0; } catch (Exception e) { try { if ((flags & SQLiteConnectionFlags.LogCallbackException) == SQLiteConnectionFlags.LogCallbackException) { SQLiteLog.LogMessage(SQLiteBase.COR_E_EXCEPTION, HelperMethods.StringFormat(CultureInfo.CurrentCulture, "Caught exception in \"xFilter\" method: {0}", e)); /* throw */ } } catch { // do nothing. } } return 0; }); UnsafeNativeMethods.xSessionConflict xConflict; xConflict = new UnsafeNativeMethods.xSessionConflict( delegate(IntPtr context, SQLiteChangeSetConflictType type, IntPtr iterator) { ISQLiteChangeSetMetadataItem item = null; try { return conflictCallback(clientData, type, item); } catch (Exception e) { try { if ((flags & SQLiteConnectionFlags.LogCallbackException) == SQLiteConnectionFlags.LogCallbackException) { SQLiteLog.LogMessage(SQLiteBase.COR_E_EXCEPTION, HelperMethods.StringFormat(CultureInfo.CurrentCulture, "Caught exception in \"xConflict\" method: {0}", e)); /* throw */ } } catch { // do nothing. } } return SQLiteChangeSetConflictResult.Abort; }); SQLiteErrorCode rc = UnsafeNativeMethods.sqlite3changeset_apply_strm( handle, new SQLiteStreamAdapter(stream, flags).xInput, IntPtr.Zero, xFilter, xConflict, IntPtr.Zero); if (rc != SQLiteErrorCode.Ok) throw new SQLiteException(rc, "sqlite3changeset_apply_strm"); } #endregion /////////////////////////////////////////////////////////////////////// #region IEnumerable<ISQLiteChangeSetMetadataItem> Members public IEnumerator<ISQLiteChangeSetMetadataItem> GetEnumerator() { |
︙ | ︙ | |||
1503 1504 1505 1506 1507 1508 1509 | #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteChangeSetMetadataItem Class | | | | 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 | #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteChangeSetMetadataItem Class public sealed class SQLiteChangeSetMetadataItem : ISQLiteChangeSetMetadataItem, IDisposable { #region Private Data private IntPtr iterator; #endregion /////////////////////////////////////////////////////////////////////// |
︙ | ︙ |