Skip to content

Commit 77df51a

Browse files
committed
Avoid using Format() on event body, as this causes AVs when it contains some % sign. See http://www.heidisql.com/forum.php?t=13010
1 parent 3007a5e commit 77df51a

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

source/event_editor.pas

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ TfrmEventEditor = class(TFrame)
5757
AlterCodeValid, CreateCodeValid: Boolean;
5858
function ComposeCreateStatement: String;
5959
function ComposeAlterStatement: String;
60-
function ComposeBaseStatement: String;
60+
function ComposeStatement(CreateOrAlter, ObjName: String): String;
6161
procedure UpdateSQLcode;
6262
public
6363
{ Public declarations }
@@ -258,26 +258,26 @@ function TfrmEventEditor.ApplyModifications: TModalResult;
258258

259259
function TfrmEventEditor.ComposeCreateStatement: String;
260260
begin
261-
Result := Format(ComposeBaseStatement, ['CREATE', DBObject.Connection.QuoteIdent(editName.Text)]);
261+
Result := ComposeStatement('CREATE', editName.Text);
262262
end;
263263

264264

265265
function TfrmEventEditor.ComposeAlterStatement: String;
266266
begin
267-
Result := Format(ComposeBaseStatement, ['ALTER', DBObject.Connection.QuoteIdent(DBObject.Name)]);
267+
Result := ComposeStatement('ALTER', DBObject.Name);
268268
end;
269269

270270

271-
function TfrmEventEditor.ComposeBaseStatement: String;
271+
function TfrmEventEditor.ComposeStatement(CreateOrAlter, ObjName: String): String;
272272
var
273273
d: TDateTime;
274274
Quantity: String;
275275
begin
276276
// Return CREATE EVENT statement
277-
Result := '%s ';
277+
Result := CreateOrAlter + ' ';
278278
if comboDefiner.Text <> '' then
279279
Result := Result + 'DEFINER='+DBObject.Connection.QuoteIdent(comboDefiner.Text, True, '@')+' ';
280-
Result := Result + 'EVENT %s' + CRLF + #9 + 'ON SCHEDULE' + CRLF + #9#9;
280+
Result := Result + 'EVENT ' + DBObject.Connection.QuoteIdent(ObjName) + CRLF + #9 + 'ON SCHEDULE' + CRLF + #9#9;
281281
if radioOnce.Checked then begin
282282
d := dateOnce.DateTime;
283283
ReplaceTime(d, timeOnce.DateTime);

0 commit comments

Comments
 (0)