Finally fix ramshackle detection of routine body. Fixes issue #3103, #3104.

This commit is contained in:
Ansgar Becker
2013-02-08 11:25:12 +00:00
parent 28409cf78b
commit 95ab784008
3 changed files with 19 additions and 22 deletions

View File

@ -162,7 +162,7 @@ begin
lntProcedure: comboType.ItemIndex := 0;
lntFunction: comboType.ItemIndex := 1;
end;
DBObject.Connection.ParseRoutineStructure(Obj.CreateCode, Parameters, Deterministic, Definer, Returns, DataAccess, Security, Comment, Body);
DBObject.Connection.ParseRoutineStructure(Obj, Parameters, Deterministic, Definer, Returns, DataAccess, Security, Comment, Body);
comboReturns.Text := Returns;
chkDeterministic.Checked := Deterministic;
if DataAccess <> '' then
@ -173,16 +173,6 @@ begin
comboDefiner.Text := Definer;
// The whole CREATE CODE may be empty if the user is not allowed to view code in SHOW CREATE FUNCTION
// => Disable the whole editor in this case.
// Also, only the body may be empty, because ParseRoutineBody did not get a BEGIN..END block to see.
// See http://www.heidisql.com/forum.php?t=12075
// => Get the body from information_schema
if Body = '' then begin
Body := Obj.Connection.GetVar('SELECT '+Obj.Connection.QuoteIdent('ROUTINE_DEFINITION')+' FROM information_schema.'+Obj.Connection.QuoteIdent('ROUTINES')+
' WHERE '+Obj.Connection.QuoteIdent('ROUTINE_SCHEMA')+'='+esc(Obj.Database)+
' AND '+Obj.Connection.QuoteIdent('ROUTINE_NAME')+'='+esc(Obj.Name)+
' AND '+Obj.Connection.QuoteIdent('ROUTINE_TYPE')+'='+esc(FAlterRoutineType)
);
end;
SynMemoBody.Text := Body;
lblDisabledWhy.Visible := Body = '';
PageControlMain.Enabled := not lblDisabledWhy.Visible;