Modified:
branches/5.2/CHANGES
branches/5.2/Driver/Source/ISSchemaProvider.cs
branches/5.2/Driver/Source/MySqlScript.cs
branches/5.2/Driver/Source/Statement.cs
branches/5.2/Driver/Source/common/SqlTokenizer.cs
branches/5.2/VisualStudio/Descriptors/StoredProcDescriptor.cs
Log:
merge from 5.1 up through procedure parameter patch
Modified: branches/5.2/CHANGES
===================================================================
--- branches/5.2/CHANGES 2008-02-14 16:55:31 UTC (rev 1177)
+++ branches/5.2/CHANGES 2008-02-14 17:11:47 UTC (rev 1178)
@@ -1,3 +1,6 @@
+Version 5.2.1
+- Tons of fixes in providers. The actually work now. :)
+
Version 5.2 - 2/11/2008
. Added ClearPool and ClearAllPools features
. DDEX provider now works under Visual Studio 2008
@@ -12,6 +15,10 @@
. Added Allow User Variables connection string option so that users can use user
variables
without getting missing parameter exceptions
+Version 5.1.6
+ - Fixed problem where parameters lists were not showing when you tried to alter a
routine
+ in server explorer. (bug #34359)
+
Version 5.1.5 - 2/11/2008
- Fixed problem with membership provider where FindUserByEmail would fail trying to add
a second parameter with the same name as the first (bug #33347)
Modified: branches/5.2/Driver/Source/ISSchemaProvider.cs
===================================================================
--- branches/5.2/Driver/Source/ISSchemaProvider.cs 2008-02-14 16:55:31 UTC (rev 1177)
+++ branches/5.2/Driver/Source/ISSchemaProvider.cs 2008-02-14 17:11:47 UTC (rev 1178)
@@ -195,6 +195,60 @@
return dt;
}
+ private DataTable GetProceduresWithParameters(string[] restrictions)
+ {
+ DataTable dt = GetProcedures(restrictions);
+ dt.Columns.Add("ParameterList", typeof(string));
+
+ foreach (DataRow row in dt.Rows)
+ {
+ row["ParameterList"] = GetProcedureParameterLine(row);
+ }
+ return dt;
+ }
+
+ private string GetProcedureParameterLine(DataRow isRow)
+ {
+ string sql = "SHOW CREATE {0} {1}.{2}";
+ sql = String.Format(sql, isRow["ROUTINE_TYPE"], isRow["ROUTINE_SCHEMA"],
+ isRow["ROUTINE_NAME"]);
+ MySqlCommand cmd = new MySqlCommand(sql, connection);
+ using (MySqlDataReader reader = cmd.ExecuteReader())
+ {
+ reader.Read();
+
+ // if we are not the owner of this proc or have permissions
+ // then we will get null for the body
+ if (reader.IsDBNull(2)) return null;
+
+ string sql_mode = reader.GetString(1);
+
+ string body = reader.GetString(2);
+ SqlTokenizer tokenizer = new SqlTokenizer(body);
+ tokenizer.AnsiQuotes = sql_mode.IndexOf("ANSI_QUOTES") != -1;
+ tokenizer.BackslashEscapes = sql_mode.IndexOf("NO_BACKSLASH_ESCAPES") ==
-1;
+
+ string token = tokenizer.NextToken();
+ while (token != "(")
+ token = tokenizer.NextToken();
+ int start = tokenizer.Index + 1;
+ token = tokenizer.NextToken();
+ while (token != ")" || tokenizer.Quoted)
+ {
+ token = tokenizer.NextToken();
+ // if we see another ( and we are not quoted then we
+ // are in a size element and we need to look for the closing paren
+ if (token == "(" && !tokenizer.Quoted)
+ {
+ while (token != ")" || tokenizer.Quoted)
+ token = tokenizer.NextToken();
+ token = tokenizer.NextToken();
+ }
+ }
+ return body.Substring(start, tokenizer.Index - start);
+ }
+ }
+
/// <summary>
/// Return schema information about parameters for procedures and functions
/// Restrictions supported are:
@@ -237,6 +291,8 @@
return GetViews(restrictions);
case "procedures":
return GetProcedures(restrictions);
+ case "procedures with parameters":
+ return GetProceduresWithParameters(restrictions);
case "procedure parameters":
return GetProcedureParameters(restrictions, null);
case "triggers":
@@ -290,7 +346,6 @@
routines = GetSchema("procedures", restrictions);
MySqlCommand cmd = connection.CreateCommand();
- MySqlDataReader reader = null;
foreach (DataRow routine in routines.Rows)
{
@@ -304,20 +359,17 @@
if (restrictions != null && restrictions.Length == 5
&&
restrictions[4] != null)
nameToRestrict = restrictions[4];
- reader = cmd.ExecuteReader();
- reader.Read();
- ParseProcedureBody(parametersTable, reader.GetString(2),
- routine, nameToRestrict);
+ using (MySqlDataReader reader = cmd.ExecuteReader())
+ {
+ reader.Read();
+ ParseProcedureBody(parametersTable, reader.GetString(2),
+ routine, nameToRestrict);
+ }
}
catch (SqlNullValueException snex)
{
throw new
InvalidOperationException(Resources.UnableToRetrieveSProcData, snex);
}
- finally
- {
- if (reader != null)
- reader.Close();
- }
}
}
Modified: branches/5.2/Driver/Source/MySqlScript.cs
===================================================================
--- branches/5.2/Driver/Source/MySqlScript.cs 2008-02-14 16:55:31 UTC (rev 1177)
+++ branches/5.2/Driver/Source/MySqlScript.cs 2008-02-14 17:11:47 UTC (rev 1178)
@@ -257,8 +257,8 @@
int delimiterPos = token.IndexOf(Delimiter);
if (delimiterPos != -1)
{
- int endPos = tokenizer.CurrentPos - token.Length + delimiterPos;
- if (tokenizer.CurrentPos == query.Length-1)
+ int endPos = tokenizer.Index - token.Length + delimiterPos;
+ if (tokenizer.Index == query.Length-1)
endPos++;
string currentQuery = query.Substring(startPos, endPos-startPos);
ScriptStatement statement = new ScriptStatement();
@@ -273,7 +273,7 @@
}
// now clean up the last statement
- if (tokenizer.CurrentPos > startPos)
+ if (tokenizer.Index > startPos)
{
string sqlLeftOver = query.Substring(startPos).Trim();
if (!String.IsNullOrEmpty(sqlLeftOver))
Modified: branches/5.2/Driver/Source/Statement.cs
===================================================================
--- branches/5.2/Driver/Source/Statement.cs 2008-02-14 16:55:31 UTC (rev 1177)
+++ branches/5.2/Driver/Source/Statement.cs 2008-02-14 17:11:47 UTC (rev 1178)
@@ -269,8 +269,8 @@
}
else
{
- currentChunk.Append(sql.Substring(lastPos, tokenizer.CurrentPos -
lastPos+1));
- lastPos = tokenizer.CurrentPos;
+ currentChunk.Append(sql.Substring(lastPos, tokenizer.Index -
lastPos+1));
+ lastPos = tokenizer.Index;
}
token = tokenizer.NextToken();
}
Modified: branches/5.2/Driver/Source/common/SqlTokenizer.cs
===================================================================
--- branches/5.2/Driver/Source/common/SqlTokenizer.cs 2008-02-14 16:55:31 UTC (rev 1177)
+++ branches/5.2/Driver/Source/common/SqlTokenizer.cs 2008-02-14 17:11:47 UTC (rev 1178)
@@ -47,7 +47,7 @@
get { return quoted; }
}
- public int CurrentPos
+ public int Index
{
get { return index; }
}
Modified: branches/5.2/VisualStudio/Descriptors/StoredProcDescriptor.cs
===================================================================
--- branches/5.2/VisualStudio/Descriptors/StoredProcDescriptor.cs 2008-02-14 16:55:31 UTC
(rev 1177)
+++ branches/5.2/VisualStudio/Descriptors/StoredProcDescriptor.cs 2008-02-14 17:11:47 UTC
(rev 1178)
@@ -133,7 +133,7 @@
[Field(FieldType = TypeCode.String)]
public const string Definer = "DEFINER";
[Field(FieldType = TypeCode.String)]
- public const string ParameterList = "PARAM_LIST";
+ public const string ParameterList = "PARAMETERLIST";
}
#endregion
@@ -219,7 +219,7 @@
for (int x = 0; x < rest.Length; x++)
if (restrictions[x] != null)
rest[x] = restrictions[x].ToString();
- DataTable dt = conn.GetSchema("Procedures", rest);
+ DataTable dt = conn.GetSchema("Procedures With Parameters", rest);
connection.Connection.UnlockProviderObject();
return dt;
}
| Thread |
|---|
| • Connector/NET commit: r1178 - in branches/5.2: . Driver/Source Driver/Source/common VisualStudio/Descriptors | rburnett | 14 Feb |