Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Increased performance ExecuteScalar() and ExecuteNonQuery() resulting in a nice boost in the insert 100k rows tests and user-function tests |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | sourceforge |
Files: | files | file ages | folders |
SHA1: |
5f0640967776054490bb3244eb97791a |
User & Date: | rmsimpson 2005-03-04 21:30:56.000 |
Context
2005-03-04
| ||
21:31 | Modified to use the new utility type conversion helper(s) in SQLiteBase and SQLiteConvert check-in: 6886e6f4fb user: rmsimpson tags: sourceforge | |
21:30 | Increased performance ExecuteScalar() and ExecuteNonQuery() resulting in a nice boost in the insert 100k rows tests and user-function tests check-in: 5f06409677 user: rmsimpson tags: sourceforge | |
21:30 | Added more internal-use utility type conversion helpers check-in: 1f38aec2e8 user: rmsimpson tags: sourceforge | |
Changes
Changes to System.Data.SQLite/SQLiteCommand.cs.
︙ | ︙ | |||
272 273 274 275 276 277 278 | if (value != _cnn._activeTransaction && value != null) { throw new ArgumentOutOfRangeException(); } } } | < < < < < | | | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | if (value != _cnn._activeTransaction && value != null) { throw new ArgumentOutOfRangeException(); } } } private void InitializeForReader() { 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"); |
︙ | ︙ | |||
303 304 305 306 307 308 309 310 311 312 | // 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); | > > > > > > > > > > > > > > | | | > > > > | < > | | > > | > > > > > > > > > > > > > > > > | > > > > > | > | > | > > > > | > > > > > > > > > > > > > > | | 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | // 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(); } /// <summary> /// /// </summary> /// <param name="behavior"></param> /// <returns></returns> protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { InitializeForReader(); _cnn._sql.SetTimeout(_commandTimeout * 1000); try { SQLiteDataReader rd = new SQLiteDataReader(this, behavior); _isReaderOpen = true; return rd; } finally { } } 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() { //using (DbDataReader rd = ExecuteDbDataReader(CommandBehavior.Default)) //{ // rd.Close(); // return rd.RecordsAffected; //} InitializeForReader(); _cnn._sql.SetTimeout(_commandTimeout * 1000); int nAffected = 0; int n; int x; x = _statementList.Length; for (n = 0; n < x; n++) { _cnn._sql.Step(_statementList[n]); nAffected += _cnn._sql.Changes; _cnn._sql.Reset(_statementList[n]); } return nAffected; } /// <summary> /// Execute the command and return the first column of the first row of the resultset (if present), or null if no resultset was returned. /// </summary> /// <returns></returns> public override object ExecuteScalar() { //using (DbDataReader rd = ExecuteDbDataReader(CommandBehavior.Default)) //{ // if (rd.Read()) // return rd[0]; //} //return null; InitializeForReader(); _cnn._sql.SetTimeout(_commandTimeout * 1000); int n; int x; object ret = null; SQLiteType typ = new SQLiteType(); x = _statementList.Length; for (n = 0; n < x; n++) { if (_cnn._sql.Step(_statementList[n]) == true) { ret = _cnn._sql.GetValue(_statementList[n], 0, ref typ); } _cnn._sql.Reset(_statementList[n]); if (ret != null) break; } if (ret == null) ret = DBNull.Value; return ret; } /// <summary> /// Prepares the command for execution. /// </summary> public override void Prepare() { |
︙ | ︙ |