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

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

Overview
Comment:Properly handle NULL values in the 'name' column of the results returned by PRAGMA index_info(). Fix for [5251bd0878].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-5251bd0878
Files: files | file ages | folders
SHA1: c93b891f69483b6994bd0c43e21b5d70ec7be31b
User & Date: mistachkin 2015-12-11 23:35:06
References
2015-12-11
23:35 Pending ticket [5251bd0878]: Failed to get column schema if using Indexes On Expressions plus 7 other changes artifact: 50148645f9 user: mistachkin
Context
2015-12-12
01:59
Revise fix for [5251bd0878] to use null for the 'COLUMN_NAME' if the original value was DBNull.Value. check-in: f8c2007d48 user: mistachkin tags: tkt-5251bd0878
2015-12-11
23:35
Properly handle NULL values in the 'name' column of the results returned by PRAGMA index_info(). Fix for [5251bd0878]. check-in: c93b891f69 user: mistachkin tags: tkt-5251bd0878
23:10
Add test case for ticket [5251bd0878]. check-in: 5f7617eb79 user: mistachkin tags: tkt-5251bd0878
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

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

  4753   4753                     try
  4754   4754                     {
  4755   4755                       using (SQLiteCommand cmdIndex = new SQLiteCommand(UnsafeNativeMethods.StringFormat(CultureInfo.InvariantCulture, "PRAGMA [{0}].index_info([{1}])", strCatalog, rdIndexes.GetString(1)), this))
  4756   4756                       using (SQLiteDataReader rdIndex = cmdIndex.ExecuteReader())
  4757   4757                       {
  4758   4758                         while (rdIndex.Read())
  4759   4759                         {
         4760  +                        string columnName = rdIndex.IsDBNull(2) ? String.Empty : rdIndex.GetString(2);
         4761  +
  4760   4762                           row = tbl.NewRow();
  4761   4763                           row["CONSTRAINT_CATALOG"] = strCatalog;
  4762   4764                           row["CONSTRAINT_NAME"] = rdIndexes.GetString(1);
  4763   4765                           row["TABLE_CATALOG"] = strCatalog;
  4764   4766                           row["TABLE_NAME"] = rdIndexes.GetString(2);
  4765         -                        row["COLUMN_NAME"] = rdIndex.GetString(2);
         4767  +                        row["COLUMN_NAME"] = columnName;
  4766   4768                           row["INDEX_NAME"] = rdIndexes.GetString(1);
  4767   4769                           row["ORDINAL_POSITION"] = ordinal; // rdIndex.GetInt32(1);
  4768   4770   
  4769   4771                           string collationSequence = null;
  4770   4772                           int sortMode = 0;
  4771   4773                           int onError = 0;
  4772         -                        _sql.GetIndexColumnExtendedInfo(strCatalog, rdIndexes.GetString(1), rdIndex.GetString(2), ref sortMode, ref onError, ref collationSequence);
         4774  +
         4775  +                        if(!String.IsNullOrEmpty(columnName))
         4776  +                          _sql.GetIndexColumnExtendedInfo(strCatalog, rdIndexes.GetString(1), columnName, ref sortMode, ref onError, ref collationSequence);
  4773   4777   
  4774   4778                           if (String.IsNullOrEmpty(collationSequence) == false)
  4775   4779                             row["COLLATION_NAME"] = collationSequence;
  4776   4780   
  4777   4781                           row["SORT_MODE"] = (sortMode == 0) ? "ASC" : "DESC";
  4778   4782                           row["CONFLICT_OPTION"] = onError;
  4779   4783