System.Data.SQLite
Check-in [09db2a0a1b]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make the SAVEPOINT names used for nested transactions much less predictable.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-1f7bfff467
Files: files | file ages | folders
SHA1:09db2a0a1b37532d62bca59cba34e4baf00e434f
User & Date: mistachkin 2016-10-29 22:19:51
References
2016-10-29
22:22 Ticket [1f7bfff467] SQLiteTransaction: critical rollback bug status still Open with 3 other changes artifact: 9018a25250 user: mistachkin
Context
2016-10-30
03:27
Do not try to rollback a nested transaction after it has been committed. check-in: 2bed8a7ba9 user: mistachkin tags: tkt-1f7bfff467
2016-10-29
22:19
Make the SAVEPOINT names used for nested transactions much less predictable. check-in: 09db2a0a1b user: mistachkin tags: tkt-1f7bfff467
2016-10-28
21:30
Improve the new test. check-in: 588b7768a0 user: mistachkin tags: tkt-1f7bfff467
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/SQLiteTransaction.cs.

4
5
6
7
8
9
10

11
12
13
14
15
16
17
..
30
31
32
33
34
35
36










37
38
39
40
41
42
43
...
292
293
294
295
296
297
298
299
300
301
302











303





304
305
306
307
308
309
310
 *
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
    using System;

    using System.Data;
    using System.Data.Common;
    using System.Threading;

    ///////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
................................................................................
        private int _version;

        /// <summary>
        /// The isolation level for this transaction.
        /// </summary>
        private IsolationLevel _level;











        ///////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Constructs the transaction object, binding it to the supplied connection
        /// </summary>
        /// <param name="connection">The connection to open a transaction on</param>
        /// <param name="deferredLock">TRUE to defer the writelock, or FALSE to lock immediately</param>
................................................................................
        /// </summary>
        /// <param name="level">
        /// The transaction level associated with the connection.
        /// </param>
        /// <returns>
        /// The name of the savepoint -OR- null if it cannot be constructed.
        /// </returns>
        private static string GetSavePointName(
            int level
            )
        {











            return String.Format("sqlite_dotnet_savepoint_{0}", level);





        }

        ///////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Checks the state of this transaction, optionally throwing an exception if a state inconsistency is found.
        /// </summary>







>







 







>
>
>
>
>
>
>
>
>
>







 







|



>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
..
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
...
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
 *
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Common;
    using System.Threading;

    ///////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
................................................................................
        private int _version;

        /// <summary>
        /// The isolation level for this transaction.
        /// </summary>
        private IsolationLevel _level;

        /// <summary>
        /// The SAVEPOINT names for each transaction level.
        /// </summary>
        private Dictionary<int, string> _savePointNames;

        /// <summary>
        /// Random number generator used when creating new SAVEPOINT names.
        /// </summary>
        private Random _random;

        ///////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Constructs the transaction object, binding it to the supplied connection
        /// </summary>
        /// <param name="connection">The connection to open a transaction on</param>
        /// <param name="deferredLock">TRUE to defer the writelock, or FALSE to lock immediately</param>
................................................................................
        /// </summary>
        /// <param name="level">
        /// The transaction level associated with the connection.
        /// </param>
        /// <returns>
        /// The name of the savepoint -OR- null if it cannot be constructed.
        /// </returns>
        private string GetSavePointName(
            int level
            )
        {
            if (_savePointNames == null)
                _savePointNames = new Dictionary<int, string>();

            string name;

            if (!_savePointNames.TryGetValue(level, out name))
            {
                if (_random == null)
                    _random = new Random();

                name = String.Format(
                    "sqlite_dotnet_savepoint_{0}_{1}", level, _random.Next());

                _savePointNames[level] = name;
            }

            return name;
        }

        ///////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Checks the state of this transaction, optionally throwing an exception if a state inconsistency is found.
        /// </summary>