Strip routine body early in ParseRoutineStructure, so later regular expressions don't get confused by keywords in user SQL. Fixes issue #3085.

This commit is contained in:
Ansgar Becker
2013-01-27 06:59:37 +00:00
parent 78ef13fc99
commit ebe36bb0cd

View File

@@ -3485,6 +3485,12 @@ begin
// | SQL SECURITY { DEFINER | INVOKER } // SECURITY_TYPE
// | COMMENT 'string' // COMMENT
// Strip body early, so regular expressions don't get confused by keywords
rx.Expression := '\bBEGIN\b';
if rx.Exec(CreateCode) then begin
Body := TrimLeft(Copy(CreateCode, rx.MatchPos[0], MaxInt));
Delete(CreateCode, rx.MatchPos[0], MaxInt);
end;
rx.Expression := '\bLANGUAGE SQL\b';
if rx.Exec(CreateCode) then
Delete(CreateCode, rx.MatchPos[0], rx.MatchLen[0]);
@@ -3514,8 +3520,6 @@ begin
Comment := StringReplace(rx.Match[1], '''''', '''', [rfReplaceAll]);
Delete(CreateCode, rx.MatchPos[0], rx.MatchLen[0]-1);
end;
// Tata, remaining code is the routine body
Body := TrimLeft(CreateCode);
rx.Free;
end;