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

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

Overview
Comment:Code and comments cleanup
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sourceforge
Files: files | file ages | folders
SHA1: a428d558a9da34b96b5c958f66b78e2fa54f0c01
User & Date: rmsimpson 2006-03-09 15:21:24
Context
2006-03-10
19:11
Fixed a rather annoying bug in Role.DeleteUsersFromRoles. Updated ProviderUtility to give more descriptive errors. check-in: 98511b3009 user: jeffreyabecker tags: sourceforge
2006-03-09
15:21
Code and comments cleanup check-in: a428d558a9 user: rmsimpson tags: sourceforge
2006-03-02
20:24
Started on Profile Provider support check-in: 99e919890f user: jeffreyabecker tags: sourceforge
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SQLite.Interop/crypt.c.

251
252
253
254
255
256
257


258
259
260
261
262
263
264
265
266
267
268
269
270
271
272

273
274
275
276
277
278
279
    LPCRYPTBLOCK pBlock = CreateCryptBlock(hKey, sqlite3BtreePager(db->aDb[nDb].pBt), NULL);
    sqlite3pager_set_codec(sqlite3BtreePager(db->aDb[nDb].pBt), sqlite3Codec, pBlock);
    rc = SQLITE_OK;
  }
  return rc;
}



void sqlite3pager_free_codecarg(void *pArg)
{
  LPCRYPTBLOCK pBlock = (LPCRYPTBLOCK)pArg;

  if (pBlock)
  {
    if (pBlock->hReadKey)
      CryptDestroyKey(pBlock->hReadKey);
    if (pBlock->hWriteKey)
      CryptDestroyKey(pBlock->hWriteKey);

    if (pBlock->pvCrypt)
      sqliteFree(pBlock->pvCrypt);
  }
  sqliteFree(pBlock);

}

// Once a password has been supplied and a key created, we don't keep the 
// original password for security purposes.  Therefore return NULL.
void sqlite3CodecGetKey(sqlite3 *db, int nDb, void **ppKey, int *pnKeyLen)
{
  *ppKey = NULL;







>
>


<
<
|
<
<
<
<
<
<
<
<
<
<
>







251
252
253
254
255
256
257
258
259
260
261


262










263
264
265
266
267
268
269
270
    LPCRYPTBLOCK pBlock = CreateCryptBlock(hKey, sqlite3BtreePager(db->aDb[nDb].pBt), NULL);
    sqlite3pager_set_codec(sqlite3BtreePager(db->aDb[nDb].pBt), sqlite3Codec, pBlock);
    rc = SQLITE_OK;
  }
  return rc;
}

// Called by our code modification to pager.c to free the cryptblock associated with 
// a pager instance.
void sqlite3pager_free_codecarg(void *pArg)
{


  if (pArg)










    DestroyCryptBlock((LPCRYPTBLOCK)pArg);
}

// Once a password has been supplied and a key created, we don't keep the 
// original password for security purposes.  Therefore return NULL.
void sqlite3CodecGetKey(sqlite3 *db, int nDb, void **ppKey, int *pnKeyLen)
{
  *ppKey = NULL;

Changes to SQLite.Interop/interop.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
/*
   This interop file must be included at or near the top of the select.c file of the SQLite3 source distribution.

   generateColumnNames() in the select.c must be renamed to _generateColumnNames

*/

#include "src/sqliteint.h"
#include "src\os.h"
#include <tchar.h>

#if NDEBUG
#if _WIN32_WCE
#include "merge.h"
................................................................................
  int n = sqlite3_table_column_metadata(db, zDbName, zTableName, zColumnName, pzDataType, pzCollSeq, pNotNull, pPrimaryKey, pAutoinc);
  *pdtLen = (*pzDataType != 0) ? strlen(*pzDataType) : 0;
  *pcsLen = (*pzCollSeq != 0) ? strlen(*pzCollSeq) : 0;

  return n;
}

//__declspec(dllexport) void WINAPI sqlite3_realcolnames(sqlite3 *db, int bOn)
//{
//  if (bOn)
//    db->flags |= 0x01000000;
//  else
//    db->flags &= (~0x01000000);
//}

#endif // OS_WIN
<
<
<
<
<
<
<







 







<
<
<
<
<
<
<
<








1
2
3
4
5
6
7
...
698
699
700
701
702
703
704








705







#include "src/sqliteint.h"
#include "src\os.h"
#include <tchar.h>

#if NDEBUG
#if _WIN32_WCE
#include "merge.h"
................................................................................
  int n = sqlite3_table_column_metadata(db, zDbName, zTableName, zColumnName, pzDataType, pzCollSeq, pNotNull, pPrimaryKey, pAutoinc);
  *pdtLen = (*pzDataType != 0) ? strlen(*pzDataType) : 0;
  *pcsLen = (*pzCollSeq != 0) ? strlen(*pzCollSeq) : 0;

  return n;
}









#endif // OS_WIN

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

102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
...
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
  /// </list>
  /// </remarks>
  public sealed class SQLiteConnection : DbConnection, ICloneable
  {
    /// <summary>
    /// State of the current connection
    /// </summary>
    private ConnectionState     _connectionState;
    /// <summary>
    /// The connection string
    /// </summary>
    private string              _connectionString;
    /// <summary>
    /// Nesting level of the transactions open on the connection
    /// </summary>
    internal int                 _transactionLevel;
    /// <summary>
    /// Whether or not the connection is enlisted in a distrubuted transaction
    /// </summary>
................................................................................
    /// <summary>
    /// Commands associated with this connection
    /// </summary>
    internal List<SQLiteCommand> _commandList;
    /// <summary>
    /// The database filename minus path and extension
    /// </summary>
    private string                _dataSource;
    /// <summary>
    /// Temporary password storage, emptied after the database has been opened
    /// </summary>
    private byte[]                _password;
    /// <event/>
    /// <summary>
    /// This event is raised whenever the database is opened or closed.
    /// </summary>
    public override event StateChangeEventHandler StateChange;

    ///<overloads>
................................................................................
      tbl.Columns.Add(DbMetaDataColumnNames.QuotedIdentifierCase, typeof(int));
      tbl.Columns.Add(DbMetaDataColumnNames.StatementSeparatorPattern, typeof(string));
      tbl.Columns.Add(DbMetaDataColumnNames.StringLiteralPattern, typeof(string));
      tbl.Columns.Add(DbMetaDataColumnNames.SupportedJoinOperators, typeof(int));

      tbl.BeginLoadData();

      // TODO: Fixup the regular expressions to support only the SQLite stuff, they were originally cloned
      // from JET's DataSourceInformation return result.
      row = tbl.NewRow();
      row.ItemArray = new object[] {
        null,
        "SQLite",
        _sql.Version,
        _sql.Version,
        3,







|



|







 







|



|







 







<
<







102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
...
930
931
932
933
934
935
936


937
938
939
940
941
942
943
  /// </list>
  /// </remarks>
  public sealed class SQLiteConnection : DbConnection, ICloneable
  {
    /// <summary>
    /// State of the current connection
    /// </summary>
    private ConnectionState      _connectionState;
    /// <summary>
    /// The connection string
    /// </summary>
    private string               _connectionString;
    /// <summary>
    /// Nesting level of the transactions open on the connection
    /// </summary>
    internal int                 _transactionLevel;
    /// <summary>
    /// Whether or not the connection is enlisted in a distrubuted transaction
    /// </summary>
................................................................................
    /// <summary>
    /// Commands associated with this connection
    /// </summary>
    internal List<SQLiteCommand> _commandList;
    /// <summary>
    /// The database filename minus path and extension
    /// </summary>
    private string               _dataSource;
    /// <summary>
    /// Temporary password storage, emptied after the database has been opened
    /// </summary>
    private byte[]               _password;
    /// <event/>
    /// <summary>
    /// This event is raised whenever the database is opened or closed.
    /// </summary>
    public override event StateChangeEventHandler StateChange;

    ///<overloads>
................................................................................
      tbl.Columns.Add(DbMetaDataColumnNames.QuotedIdentifierCase, typeof(int));
      tbl.Columns.Add(DbMetaDataColumnNames.StatementSeparatorPattern, typeof(string));
      tbl.Columns.Add(DbMetaDataColumnNames.StringLiteralPattern, typeof(string));
      tbl.Columns.Add(DbMetaDataColumnNames.SupportedJoinOperators, typeof(int));

      tbl.BeginLoadData();



      row = tbl.NewRow();
      row.ItemArray = new object[] {
        null,
        "SQLite",
        _sql.Version,
        _sql.Version,
        3,

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

417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
    public override int GetOrdinal(string name)
    {
      CheckClosed();
      return _activeStatement._sql.ColumnIndex(_activeStatement, name);
    }

    /// <summary>
    /// Schema information in SQLite is an iffy-business.  We've extended the native SQLite3.DLL to include a special pragma called
    /// PRAGMA real_column_names
    /// When enabled, the pragma causes all column aliases to be ignored, and the full Database.Table.ColumnName to be returned for
    /// each column of a SELECT statement.  Using this information it is then possible to query each database and table for the
    /// matching column, and associate it with the active statement.
    /// </summary>
    /// <remarks>
    /// The current connection is cloned for the sake of executing this statement, so as to avoid any possibility of corrupting the
    /// original connection's existing statements or state.  Any attached databases are re-attached to the new connection.
    /// </remarks>
    /// <returns>Returns a DataTable containing the schema information for the active SELECT statement being processed.</returns>
    public override DataTable GetSchemaTable()
    {
      return GetSchemaTable(true, true);
    }

    internal DataTable GetSchemaTable(bool wantUniqueInfo, bool wantDefaultValue)







|
|
<
<
<

<
<
<
<







417
418
419
420
421
422
423
424
425



426




427
428
429
430
431
432
433
    public override int GetOrdinal(string name)
    {
      CheckClosed();
      return _activeStatement._sql.ColumnIndex(_activeStatement, name);
    }

    /// <summary>
    /// Schema information in SQLite is difficult to map into .NET conventions, so a lot of work must be done
    /// to gather the necessary information so it can be represented in an ADO.NET manner.



    /// </summary>




    /// <returns>Returns a DataTable containing the schema information for the active SELECT statement being processed.</returns>
    public override DataTable GetSchemaTable()
    {
      return GetSchemaTable(true, true);
    }

    internal DataTable GetSchemaTable(bool wantUniqueInfo, bool wantDefaultValue)