MySql.Data.MySqlClient.SchemaProvider.GetIndexes C# (CSharp) Method

GetIndexes() public method

public GetIndexes ( string restrictions ) : DataTable
restrictions string
return System.Data.DataTable
        public virtual DataTable GetIndexes(string[] restrictions)
        {
            DataTable dt = new DataTable("Indexes");
            dt.Columns.Add("INDEX_CATALOG", typeof (string));
            dt.Columns.Add("INDEX_SCHEMA", typeof (string));
            dt.Columns.Add("INDEX_NAME", typeof (string));
            dt.Columns.Add("TABLE_NAME", typeof (string));
            dt.Columns.Add("UNIQUE", typeof (bool));
            dt.Columns.Add("PRIMARY", typeof (bool));
            dt.Columns.Add("TYPE", typeof(string));
            dt.Columns.Add("COMMENT", typeof(string));

            // Get the list of tables first
            int max = restrictions == null ? 4 : restrictions.Length;
            string[] tableRestrictions = new string[Math.Max(max, 4)];
            if (restrictions != null)
                restrictions.CopyTo(tableRestrictions, 0);
            tableRestrictions[3] = "BASE TABLE";
            DataTable tables = GetTables(tableRestrictions);

            foreach (DataRow table in tables.Rows)
            {
                string sql = String.Format("SHOW INDEX FROM `{0}`.`{1}`",
                    MySqlHelper.DoubleQuoteString((string)table["TABLE_SCHEMA"]), 
                    MySqlHelper.DoubleQuoteString((string)table["TABLE_NAME"]));
                MySqlDataAdapter da = new MySqlDataAdapter(sql, connection);
                DataTable indexes = new DataTable();
                da.Fill(indexes);
                foreach (DataRow index in indexes.Rows)
                {
                    long seq_index = (long) index["SEQ_IN_INDEX"];
                    if (seq_index != 1) continue;
                    if (restrictions != null && restrictions.Length == 4 &&
                        restrictions[3] != null &&
                        !index["KEY_NAME"].Equals(restrictions[3])) continue;
                    DataRow row = dt.NewRow();
                    row["INDEX_CATALOG"] = null;
                    row["INDEX_SCHEMA"] = table["TABLE_SCHEMA"];
                    row["INDEX_NAME"] = index["KEY_NAME"];
                    row["TABLE_NAME"] = index["TABLE"];
                    row["UNIQUE"] = (long) index["NON_UNIQUE"] == 0;
                    row["PRIMARY"] = index["KEY_NAME"].Equals("PRIMARY");
                    row["TYPE"] = index["INDEX_TYPE"];
                    row["COMMENT"] = index["COMMENT"];
                    dt.Rows.Add(row);
                }
            }

            return dt;
        }