System.Data.SQLite
Check-in [a47688aca5]
Not logged in

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

Overview
Comment:Fix issue that prevented SQLiteBlob creation from succeeding for tables that did not have an integer primary key.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:a47688aca5f546b6dc28c94ca54951b0c4345764
User & Date: mistachkin 2017-06-10 00:56:00
Context
2017-06-10
17:38
Merge updates from trunk. check-in: 091bc3a48a user: mistachkin tags: branch-1.0.105
01:09
Simplify the new test case added in the previous check-in. check-in: ac29179121 user: mistachkin tags: trunk
00:56
Fix issue that prevented SQLiteBlob creation from succeeding for tables that did not have an integer primary key. check-in: a47688aca5 user: mistachkin tags: trunk
00:51
Correct cursor type checking in the sqlite3_cursor_rowid_interop() function. check-in: 99b0ca713e user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

515
516
517
518
519
520
521


522
523
524
525
526
527
528

529
530
531
532
533
534
535
    {
        // CheckDisposed();
        VerifyForGet();

        if (_keyInfo == null)
            return null;



        int iRowId = _keyInfo.GetRowIdIndex(
            GetDatabaseName(i), GetTableName(i));

        if (iRowId == -1)
            return null;

        return GetInt64(iRowId);

    }

    /// <summary>
    /// Retrieves the column as a <see cref="SQLiteBlob" /> object.
    /// This will not work for tables that were created WITHOUT ROWID
    /// -OR- if the query does not include the "rowid" column or one
    /// of its aliases -OR- if the <see cref="SQLiteDataReader" /> was







>
>
|
<

|
|

<
>







515
516
517
518
519
520
521
522
523
524

525
526
527
528

529
530
531
532
533
534
535
536
    {
        // CheckDisposed();
        VerifyForGet();

        if (_keyInfo == null)
            return null;

        string databaseName = GetDatabaseName(i);
        string tableName = GetTableName(i);
        int iRowId = _keyInfo.GetRowIdIndex(databaseName, tableName);


        if (iRowId != -1)
            return GetInt64(iRowId);


        return _keyInfo.GetRowId(databaseName, tableName);
    }

    /// <summary>
    /// Retrieves the column as a <see cref="SQLiteBlob" /> object.
    /// This will not work for tables that were created WITHOUT ROWID
    /// -OR- if the query does not include the "rowid" column or one
    /// of its aliases -OR- if the <see cref="SQLiteDataReader" /> was

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

361
362
363
364
365
366
367



























368
369
370
371
372
373
374
                    return _rowIdInfo[i].column;
                }
            }
        }

        return -1;
    }




























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

    #region IDisposable Members
    public void Dispose()
    {
        Dispose(true);







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
                    return _rowIdInfo[i].column;
                }
            }
        }

        return -1;
    }

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

    internal long? GetRowId(
        string databaseName,
        string tableName
        )
    {
        if ((_keyInfo != null) &&
            (databaseName != null) &&
            (tableName != null))
        {
            for (int i = 0; i < _keyInfo.Length; i++)
            {
                if (_keyInfo[i].databaseName == databaseName &&
                    _keyInfo[i].tableName == tableName)
                {
                    long rowid = _stmt._sql.GetRowIdForCursor(_stmt, _keyInfo[i].cursor);

                    if (rowid != 0)
                        return rowid;
                }
            }
        }

        return null;
    }

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

    #region IDisposable Members
    public void Dispose()
    {
        Dispose(true);

Changes to Tests/basic.eagle.

4619
4620
4621
4622
4623
4624
4625


































































4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
      [getOtherCount Method_GetXmlConfigFileName] == 2 && \
      [getOtherCount Method_GetCachedAssemblyDirectory] >= 2 && \
      [getOtherCount Method_GetCachedXmlConfigFileName] >= 2}
} -cleanup {
  moveSystemDataSQLiteDllConfig true
} -constraints {eagle command.object monoBug28 System.Data.SQLite\
buildConfiguration.Debug} -result {True}}



































































###############################################################################

reportSQLiteResources $test_channel

###############################################################################

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
      [getOtherCount Method_GetXmlConfigFileName] == 2 && \
      [getOtherCount Method_GetCachedAssemblyDirectory] >= 2 && \
      [getOtherCount Method_GetCachedXmlConfigFileName] >= 2}
} -cleanup {
  moveSystemDataSQLiteDllConfig true
} -constraints {eagle command.object monoBug28 System.Data.SQLite\
buildConfiguration.Debug} -result {True}}

###############################################################################

runTest {test data-1.89 {using SQLiteBlob without rowid PK index} -setup {
  setupDb [set fileName data-1.89.db]
} -body {
  sql execute $db {
    CREATE TABLE t1 (x GUID UNIQUE NOT NULL, y BLOB NOT NULL);
    INSERT INTO t1 (x, y) VALUES(
      '12345678-0000-0000-0000-000000000000',
      X'010203040506070809'
    );
    INSERT INTO t1 (x, y) VALUES(
      '12345679-0000-0000-0000-000000000000',
      X'0102030405060708090A0B0C0D0E0F101113'
    );
  }

  set sql(1) { \
    SELECT rowid, y FROM t1 \
    WHERE x = '12345678-0000-0000-0000-000000000000'; \
  }

  set sql(2) { \
    SELECT rowid, y FROM t1 \
    WHERE x = '12345679-0000-0000-0000-000000000000'; \
  }

  set dataReader [sql execute -execute reader -format datareader \
      -behavior +KeyInfo -alias $db $sql(1)]

  while {[$dataReader Read]} {
    set blob [object invoke -alias \
        System.Data.SQLite.SQLiteBlob Create $dataReader 1 true]

    lappend result [$blob GetCount]

    $blob Close
  }

  $dataReader Close; unset dataReader

  set dataReader [sql execute -execute reader -format datareader \
      -behavior +KeyInfo -alias $db $sql(2)]

  while {[$dataReader Read]} {
    set blob [object invoke -alias \
        System.Data.SQLite.SQLiteBlob Create $dataReader 1 true]

    lappend result [$blob GetCount]

    $blob Close
  }

  $dataReader Close; unset dataReader

  set result
} -cleanup {
  unset -nocomplain blob
  unset -nocomplain dataReader

  cleanupDb $fileName

  unset -nocomplain result sql db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {9 18}}

###############################################################################

reportSQLiteResources $test_channel

###############################################################################

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue