Try a new approach in TDBConnection.ParseRoutineStructure(). Should fix stripped backslashes from routine body, issue #3107.

* Use SHOW CREATE PROCEDURE/FUNCTION result again, instead of code from IS.ROUTINES
* Remove every known CREATE PROCEDURE/FUNCTION clause and use remaining text as routine body.
* Respect MS SQL function options, taken from http://msdn.microsoft.com/en-us/library/ms186755.aspx
* Introduce helpers.ExtractComment() for usage in ParseRoutineStructure() and ParseTableStructure()
This commit is contained in:
Ansgar Becker
2013-04-11 21:29:44 +00:00
parent c5ebca5e14
commit 7f87bc7eb2
2 changed files with 86 additions and 48 deletions

View File

@ -257,6 +257,7 @@ type
function ScanLineBreaks(Text: String): TLineBreaks;
function RemoveNulChars(Text: String): String;
function fixNewlines(txt: String): String;
function ExtractComment(var SQL: String): String;
function GetShellFolder(CSIDL: integer): string;
// Common directories
function DirnameCommonAppData: String;
@ -741,6 +742,33 @@ begin
end;
function ExtractComment(var SQL: String): String;
var
i, LitStart: Integer;
InLiteral: Boolean;
rx: TRegExpr;
begin
// Return comment from SQL and remove it from the original string
// Single quotes are escaped by a second single quote
rx := TRegExpr.Create;
rx.Expression := '^\s*COMMENT\s+''';
rx.ModifierI := True;
if rx.Exec(SQL) then begin
LitStart := rx.MatchLen[0]+1;
InLiteral := True;
for i:=LitStart to Length(SQL) do begin
if SQL[i] = '''' then
InLiteral := not InLiteral
else if not InLiteral then
break;
end;
Result := Copy(SQL, LitStart, i-LitStart-1);
Result := StringReplace(Result, '''''', '''', [rfReplaceAll]);
Delete(SQL, 1, i);
end;
rx.Free;
end;
{***
Get the path of a Windows(r)-shellfolder, specified by an integer or a constant