Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Misc. code optimizations |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | sourceforge |
Files: | files | file ages | folders |
SHA1: |
bf66bbedceb0ce29bcdabccc7df156e9 |
User & Date: | rmsimpson 2005-03-02 23:10:43.000 |
Context
2005-03-04
| ||
21:29 | More performance enhancements to SQLiteCommand check-in: 8502a3ae6d user: rmsimpson tags: sourceforge | |
2005-03-02
| ||
23:10 | Misc. code optimizations check-in: bf66bbedce user: rmsimpson tags: sourceforge | |
16:00 | Release build now targets the bin directory check-in: b483cda274 user: rmsimpson tags: sourceforge | |
Changes
Changes to System.Data.SQLite/SQLite3.cs.
︙ | ︙ | |||
282 283 284 285 286 287 288 | return "TEXT"; } } } internal override int ColumnIndex(SQLiteStatement stmt, string columnName) { | > > | | 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | return "TEXT"; } } } internal override int ColumnIndex(SQLiteStatement stmt, string columnName) { int x = ColumnCount(stmt); for (int n = 0; n < x; n++) { if (String.Compare(columnName, ColumnName(stmt, n), true) == 0) return n; } return -1; } internal override double GetDouble(SQLiteStatement stmt, int index) |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteCommand.cs.
︙ | ︙ | |||
15 16 17 18 19 20 21 | /// <summary> /// SQLite implementation of DbCommand. /// </summary> public sealed class SQLiteCommand : DbCommand { private string _commandText; private SQLiteConnection _cnn; | | | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /// <summary> /// SQLite implementation of DbCommand. /// </summary> public sealed class SQLiteCommand : DbCommand { private string _commandText; private SQLiteConnection _cnn; private bool _isReaderOpen; private int _commandTimeout; private bool _designTimeVisible; private UpdateRowSource _updateRowSource; private SQLiteParameterCollection _parameterCollection; internal SQLiteStatement[] _statementList; |
︙ | ︙ | |||
66 67 68 69 70 71 72 | { Initialize(null, cnn); } private void Initialize(string strSql, SQLiteConnection cnn) { _statementList = null; | | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | { Initialize(null, cnn); } private void Initialize(string strSql, SQLiteConnection cnn) { _statementList = null; _isReaderOpen = false; _commandTimeout = 30; _parameterCollection = new SQLiteParameterCollection(this); _designTimeVisible = true; _updateRowSource = UpdateRowSource.FirstReturnedRecord; if (strSql != null) CommandText = strSql; |
︙ | ︙ | |||
88 89 90 91 92 93 94 95 96 97 98 99 100 | /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { base.Dispose(disposing); ClearCommands(); _parameterCollection.Clear(); } internal void ClearCommands() { if (_statementList == null) return; | > > > | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { base.Dispose(disposing); ClearCommands(); _parameterCollection.Clear(); _cnn = null; _commandText = null; } internal void ClearCommands() { if (_statementList == null) return; int x = _statementList.Length; for (int n = 0; n < x; n++) _statementList[n].Dispose(); _statementList = null; _parameterCollection.Unbind(); } |
︙ | ︙ | |||
150 151 152 153 154 155 156 | { return _commandText; } set { if (_commandText == value) return; | | | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | { return _commandText; } set { if (_commandText == value) return; if (_isReaderOpen) { throw new InvalidOperationException("Cannot set CommandText while a DataReader is active"); } // if (value == null) // throw new ArgumentNullException(); |
︙ | ︙ | |||
220 221 222 223 224 225 226 | { get { return _cnn; } set { | | | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | { get { return _cnn; } set { if (_isReaderOpen) throw new InvalidOperationException("Cannot set Connection while a DataReader is active"); if (_cnn != null) { ClearCommands(); _cnn._commandList.Remove(this); } |
︙ | ︙ | |||
276 277 278 279 280 281 282 | /// <summary> /// /// </summary> /// <param name="behavior"></param> /// <returns></returns> protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { | | > > | | | | | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | /// <summary> /// /// </summary> /// <param name="behavior"></param> /// <returns></returns> protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { if (_isReaderOpen ) throw new InvalidOperationException("DataReader already active on this command"); if (_cnn == null) throw new InvalidOperationException("No connection associated with this Command"); if (_cnn.State != ConnectionState.Open) throw new InvalidOperationException("Database is not open"); int n; int x; if (_statementList.Length == 0) { BuildCommands(); } // Make sure all parameters are mapped properly to associated statement(s) _parameterCollection.MapParameters(); x = _statementList.Length; // Bind all parameters to their statements for (n = 0; n < x; n++) _statementList[n].BindParameters(); _cnn._sql.SetTimeout(_commandTimeout * 1000); _isReaderOpen = true; return new SQLiteDataReader(this, behavior); } internal void ClearDataReader() { _isReaderOpen = false; } /// <summary> /// Execute the command and return the number of rows inserted/updated affected by it. /// </summary> /// <returns></returns> public override int ExecuteNonQuery() |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteConnection.cs.
︙ | ︙ | |||
254 255 256 257 258 259 260 | /// <summary> /// When the database connection is closed, all commands linked to this connection are automatically reset. /// </summary> public override void Close() { if (_sql != null) { | > | | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | /// <summary> /// When the database connection is closed, all commands linked to this connection are automatically reset. /// </summary> public override void Close() { if (_sql != null) { int x = _commandList.Count; for (int n = 0; n < x; n++) { _commandList[n].ClearCommands(); } _sql.Close(); } _sql = null; |
︙ | ︙ | |||
380 381 382 383 384 385 386 387 | List<KeyValuePair<string, string>> ls = new List<KeyValuePair<string, string>>(); // First split into semi-colon delimited values. The Split() function of SQLiteBase accounts for and properly // skips semi-colons in quoted strings string[] arParts = SQLiteConvert.Split(s, ';'); string[] arPiece; // For each semi-colon piece, split into key and value pairs by the presence of the = sign | > | | 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | List<KeyValuePair<string, string>> ls = new List<KeyValuePair<string, string>>(); // First split into semi-colon delimited values. The Split() function of SQLiteBase accounts for and properly // skips semi-colons in quoted strings string[] arParts = SQLiteConvert.Split(s, ';'); string[] arPiece; int x = arParts.Length; // For each semi-colon piece, split into key and value pairs by the presence of the = sign for (n = 0; n < x; n++) { arPiece = SQLiteConvert.Split(arParts[n], '='); if (arPiece.Length == 2) { kv.Key = arPiece[0]; kv.Value = arPiece[1]; ls.Add(kv); |
︙ | ︙ | |||
407 408 409 410 411 412 413 | /// </summary> /// <param name="opts">The Key/Value pair array to look in</param> /// <param name="key">The key to find</param> /// <param name="defValue">The default value to return if the key is not found</param> /// <returns>The value corresponding to the specified key, or the default value if not found.</returns> internal string FindKey(KeyValuePair<string, string>[] opts, string key, string defValue) { | > | | 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | /// </summary> /// <param name="opts">The Key/Value pair array to look in</param> /// <param name="key">The key to find</param> /// <param name="defValue">The default value to return if the key is not found</param> /// <returns>The value corresponding to the specified key, or the default value if not found.</returns> internal string FindKey(KeyValuePair<string, string>[] opts, string key, string defValue) { int x = opts.Length; for (int n = 0; n < x; n++) { if (String.Compare(opts[n].Key, key, true) == 0) { return opts[n].Value; } } return defValue; |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteDataReader.cs.
︙ | ︙ | |||
90 91 92 93 94 95 96 97 98 99 100 101 102 103 | } // If the datareader's behavior includes closing the connection, then do so here. if ((_commandBehavior & CommandBehavior.CloseConnection) != 0) _command.Connection.Close(); _command = null; } /// <summary> /// Disposes the datareader. Calls Close() to ensure everything is cleaned up. /// </summary> public override void Dispose() { | > > | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | } // If the datareader's behavior includes closing the connection, then do so here. if ((_commandBehavior & CommandBehavior.CloseConnection) != 0) _command.Connection.Close(); _command = null; _activeStatement = null; _fieldTypeArray = null; } /// <summary> /// Disposes the datareader. Calls Close() to ensure everything is cleaned up. /// </summary> public override void Dispose() { |
︙ | ︙ | |||
464 465 466 467 468 469 470 | // Create a new command based on the original. The only difference being that this new command returns // fully-qualified Database.Table.Column column names because of the above pragma using (SQLiteCommand cmd = new SQLiteCommand(_activeStatement._sqlStatement, cnn)) { using (DbDataReader rd = cmd.ExecuteReader()) { // No need to Read() from this reader, we just want the column names | | | 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | // Create a new command based on the original. The only difference being that this new command returns // fully-qualified Database.Table.Column column names because of the above pragma using (SQLiteCommand cmd = new SQLiteCommand(_activeStatement._sqlStatement, cnn)) { using (DbDataReader rd = cmd.ExecuteReader()) { // No need to Read() from this reader, we just want the column names for (int n = 0; n < _fieldCount; n++) { strTable = ""; strCatalog = "main"; row = tbl.NewRow(); // Default settings for the column |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteFunction.cs.
︙ | ︙ | |||
363 364 365 366 367 368 369 | /// Disposes of any active contextData variables that were not automatically cleaned up. Sometimes this can happen if /// someone closes the connection while a DataReader is open. /// </summary> public void Dispose() { Dispose(true); | < < < < < > > > > > > > | 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | /// Disposes of any active contextData variables that were not automatically cleaned up. Sometimes this can happen if /// someone closes the connection while a DataReader is open. /// </summary> public void Dispose() { Dispose(true); IDisposable disp; #if !PLATFORM_COMPACTFRAMEWORK foreach (KeyValuePair<int, object> kv in _contextDataList) #else foreach (DictionaryEntry kv in _contextDataList) #endif { disp = kv.Value as IDisposable; if (disp != null) disp.Dispose(); } _contextDataList.Clear(); _InvokeFunc = null; _StepFunc = null; _FinalFunc = null; _CompareFunc = null; _base = null; _contextDataList = null; GC.SuppressFinalize(this); } /// <summary> /// Using reflection, enumerate all assemblies in the current appdomain looking for classes that /// have a SQLiteFunctionAttribute attribute, and registering them accordingly. /// </summary> |
︙ | ︙ | |||
492 493 494 495 496 497 498 | /// </remarks> /// <param name="sqlbase">The base SQLite connection object</param> /// <param name="ar">An array of user-defined functions for this object</param> internal static void UnbindFunctions(SQLiteBase sqlbase, SQLiteFunction[] ar) { if (ar == null) return; | > | | 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | /// </remarks> /// <param name="sqlbase">The base SQLite connection object</param> /// <param name="ar">An array of user-defined functions for this object</param> internal static void UnbindFunctions(SQLiteBase sqlbase, SQLiteFunction[] ar) { if (ar == null) return; int x = ar.Length; for (int n = 0; n < x; n++) { sqlbase.FreeFunction(ar[n]._interopCookie); ar[n].Dispose(); } } } } |
Changes to System.Data.SQLite/SQLiteParameterCollection.cs.
︙ | ︙ | |||
151 152 153 154 155 156 157 | /// <summary> /// /// </summary> /// <param name="values"></param> public void AddRange(SQLiteParameter[] values) { | > | > | | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | /// <summary> /// /// </summary> /// <param name="values"></param> public void AddRange(SQLiteParameter[] values) { int x = values.Length; for (int n = 0; n < x; n++) Add(values[n]); } /// <summary> /// /// </summary> /// <param name="values"></param> public override void AddRange(Array values) { int x = values.Length; for (int n = 0; n < x; n++) Add((SQLiteParameter)(values.GetValue(n))); } /// <summary> /// /// </summary> /// <param name="parameterName"></param> |
︙ | ︙ | |||
252 253 254 255 256 257 258 | /// <summary> /// /// </summary> /// <param name="parameterName"></param> /// <returns></returns> public override int IndexOf(string parameterName) { | > | | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | /// <summary> /// /// </summary> /// <param name="parameterName"></param> /// <returns></returns> public override int IndexOf(string parameterName) { int x = _parameterList.Count; for (int n = 0; n < x; n++) { if (String.Compare(parameterName, _parameterList[n].ParameterName, true) == 0) return n; } return -1; } /// <summary> |
︙ | ︙ | |||
360 361 362 363 364 365 366 | s = p.ParameterName; if (s == null) { s = String.Format(";{0}", nUnnamed); nUnnamed++; } | | > | 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | s = p.ParameterName; if (s == null) { s = String.Format(";{0}", nUnnamed); nUnnamed++; } int x = _command._statementList.Length; for (n = 0; n < x; n++) { stmt = _command._statementList[n]; if (stmt._paramNames != null) { stmt.MapParameter(s, p); } } } _unboundFlag = false; } } } |
Changes to System.Data.SQLite/SQLiteStatement.cs.
︙ | ︙ | |||
56 57 58 59 60 61 62 | } } internal void MapParameter(string s, SQLiteParameter p) { if (_paramNames == null) return; | > | > > | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | } } internal void MapParameter(string s, SQLiteParameter p) { if (_paramNames == null) return; int x = _paramNames.Length; for (int n = 0; n < x; n++) { if (String.Compare(_paramNames[n], s, true) == 0) { _paramValues[n] = p; break; } } } #region IDisposable Members public void Dispose() { _sql.Finalize(this); _paramNames = null; _paramValues = null; _sql = null; _sqlStatement = null; GC.SuppressFinalize(this); } #endregion /// <summary> /// Bind all parameters, making sure the caller didn't miss any |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteTransaction.cs.
︙ | ︙ | |||
63 64 65 66 67 68 69 70 71 72 73 74 75 76 | /// <summary> /// Disposes the transaction. If it is currently active, any changes are rolled back. /// </summary> public override void Dispose() { if (_cnn != null) Rollback(); GC.SuppressFinalize(this); } /// <summary> /// Gets the isolation level of the transaction. SQLite does not support isolation levels, so this always returns Unspecified. /// </summary> public override IsolationLevel IsolationLevel | > > > | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | /// <summary> /// Disposes the transaction. If it is currently active, any changes are rolled back. /// </summary> public override void Dispose() { if (_cnn != null) Rollback(); _cnn = null; GC.SuppressFinalize(this); } /// <summary> /// Gets the isolation level of the transaction. SQLite does not support isolation levels, so this always returns Unspecified. /// </summary> public override IsolationLevel IsolationLevel |
︙ | ︙ |
Changes to bin/SQLite.Interop.dll.
cannot compute difference between binary files
Changes to bin/System.Data.SQLite.dll.
cannot compute difference between binary files
Changes to bin/test.exe.
cannot compute difference between binary files